You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mongoose-os/api/rpc/rpc-gatts.md
-29
Original file line number
Diff line number
Diff line change
@@ -25,33 +25,4 @@ Three attributes are defined:
25
25
-`5f6d4f53-5f52-5043-5f72-785f63746c5f (_mOS_RPC_rx_ctl_)` - a read/notify attribute. It returns the length of the frame that device wishes to transmit as a big-endian 32-bit number. If this value is not zero, frame data will be returned in response to read requests of the data attribute. Read chunks will be up to MTU bytes in size. Client may subscribe to notifications on this attribute. Notification will be sent whenever a new frame is submitted for delivery and the notification body will contain length (the same value as returned by reading). Upon receiving notification client can proceed to read the data without reading `rx_ctl` again.
26
26
27
27
28
-
## Lightning How To
29
-
30
-
- Add `- origin: https://github.com/mongoose-os-libs/rpc-gatts` to your mos.yml libs
31
-
- For this example we'll be doing a wifi.scan as that's very handy! Add `- origin: https://github.com/mongoose-os-libs/rpc-service-wifi` to your mos.yml libs as well.
32
-
- Ensure your mos.yml config.schema has:
33
-
```
34
-
- ["bt.enable", "b", true, {title: "Enable the BT service"}]
35
-
- ["bt.keep_enabled", "b", true, {title: "Keep the BT service enabled despite WIFI being up"}]
36
-
- ["bt.random_address", "b", false, {title: "Use a consistent BT MAC address"}]
37
-
- ["bt.dev_name", "MyDeviceName_??????"]
38
-
```
39
-
- Rebuild/flash your app
40
-
- Run a BLE scanner (ie Bluesee) to see your MyDeviceName_????? device. Connect to see the services. Look for the one with 5f52-5043 in the middle.
41
-
- Select that service to open it. In Bluesee you'll have 3 characteristics per above docu.
42
-
- Figure out your RPC command, we'll use: `{"id":1999,"method":"Wifi.Scan"}`
43
-
- We need to tell the service ahead of time how many hex bytes we'll be sending. We need to convert ascii to hex, trim the extra spaces and then count the bytes. Fun!
44
-
- Enter your RPC command into this ascii to hex converter: https://www.rapidtables.com/convert/number/ascii-to-hex.html
45
-
- It'll give you a space separated hex output: `7b 22 69 64 22 3a 31 39 39 39 2c 22 6d 65 74 68 6f 64 22 3a 22 57 69 66 69 2e 53 63 61 6e 22 7d`
46
-
- Trim the spaces with http://www.unit-conversion.info/texttools/replace-text/
47
-
- Count the new hex string with: https://mothereff.in/byte-counter
48
-
- Halve the string count, as two hex characters equal one byte of data. With the text above, 64 / 2 = 32.
49
-
- Convert 32 to the large 32 bit number the system is expecting. Note: It's little endian, not big endian. Use this converter: https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ . Put the 32 in the input, then copy/paste the 'UINT32 - Little Endian (DCBA)' result and trim spaces:00000020
50
-
- Enter that `00000020` into the write only characteristic that has `5043-5F74` in the middle. Press write. In the console you'll see a log entry like: `mgos_rpc_channel_ga:296 0x3ffe1d24 expected_flen 32 res 0`
51
-
- On the middle read only characteristic with `5043-5F72` in the middle, click subscribe. The number will change to let us know when data is available (and how long the hex string is)
52
-
- On the read/write characteristic with `5043-5F53` in the middle, toggle the hex button so it says Ascii
53
-
- Paste in our ascii command: `{"id":1999,"method":"Wifi.Scan"}`
54
-
- You'll see the middle read only characteristic will have changed to let us know data is ready
55
-
- Click 'read' on the top read/write characteristic we just entered the scan command into. It'll start pulling the data of the scan results! You can click it multiple times to scroll through the data till the end.
56
-
- You can repeat the request by clicking the write only characteristic to send it our command length, then paste our command again, and click write.
Copy file name to clipboardExpand all lines: symbols.json
+8-2
Original file line number
Diff line number
Diff line change
@@ -5567,6 +5567,12 @@
5567
5567
"doc": "\n```c\nbool mgos_mqtt_global_connect(void);\n```\n> \n> Attempt MQTT connection now (if enabled and not already connected).\n> Normally MQTT will try to connect in the background, at certain interval.\n> This function will force immediate connection attempt.\n> \n",
"doc": "\n```c\nvoid mgos_mqtt_global_disconnect(void);\n```\n> \n> Disconnect from and/or stop trying to connect to MQTT server\n> until mgos_mqtt_global_connect() is called.\n> \n",
"doc": "\n```c\nbool mgos_mqtt_pub(const char *topic, const void *message, size_t len, int qos,\n bool retain);\n```\n> \n> Publish message to the configured MQTT server, to the given MQTT topic.\n> Return value will be true if there is a connection to the server and the\n> message has been queued for sending. In case of QoS 1 return value does\n> not indicate that PUBACK has been received; there is currently no way to\n> check for that.\n> \n",
5585
+
"doc": "\n```c\nuint16_t mgos_mqtt_pub(const char *topic, const void *message, size_t len,\n int qos, bool retain);\n```\n> \n> Publish message to the configured MQTT server, to the given MQTT topic.\n> Return value will be the packet id (> 0) if there is a connection to the\n> server and the message has been queued for sending. In case no connection is\n> available, 0 is returned. In case of QoS 1 return value does not indicate\n> that PUBACK has been received; there is currently no way to check for that.\n> \n",
0 commit comments