Example project to publish messages to a MQTT-SN broker using the u-blox SARA-N200 NB-IoT modem
Dependencies: MQTTSNPacket X-NUCLEO-SARA-N200
README.md@12:9a2dab9b927d, 2018-08-23 (annotated)
- Committer:
- KeystoneElectronic
- Date:
- Thu Aug 23 11:32:34 2018 +0200
- Revision:
- 12:9a2dab9b927d
- Parent:
- 0:c0cf12ee5420
Update readme
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
KeystoneElectronic |
12:9a2dab9b927d | 1 | # Getting started with Hello MQTT-SN |
KeystoneElectronic | 0:c0cf12ee5420 | 2 | |
KeystoneElectronic |
12:9a2dab9b927d | 3 | This guide reviews the steps required to use the MQTT-SN example on an mbed OS platform. |
KeystoneElectronic | 0:c0cf12ee5420 | 4 | |
KeystoneElectronic | 0:c0cf12ee5420 | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
KeystoneElectronic | 0:c0cf12ee5420 | 6 | |
KeystoneElectronic | 0:c0cf12ee5420 | 7 | ## Import the example application |
KeystoneElectronic | 0:c0cf12ee5420 | 8 | |
KeystoneElectronic | 0:c0cf12ee5420 | 9 | From the command-line, import the example: |
KeystoneElectronic | 0:c0cf12ee5420 | 10 | |
KeystoneElectronic | 0:c0cf12ee5420 | 11 | ``` |
KeystoneElectronic |
12:9a2dab9b927d | 12 | mbed import sara-n200-hello-mqtt-sn |
KeystoneElectronic |
12:9a2dab9b927d | 13 | cd sara-n200-hello-mqtt-sn |
KeystoneElectronic | 0:c0cf12ee5420 | 14 | ``` |
KeystoneElectronic | 0:c0cf12ee5420 | 15 | |
KeystoneElectronic |
12:9a2dab9b927d | 16 | ### Configure the MQTT-SN broker |
KeystoneElectronic |
12:9a2dab9b927d | 17 | Edit the mbed_app.json: |
KeystoneElectronic |
12:9a2dab9b927d | 18 | ``` |
KeystoneElectronic |
12:9a2dab9b927d | 19 | "topic": "\"nucleo\"", |
KeystoneElectronic |
12:9a2dab9b927d | 20 | "mqtt_sn_host": "\"160.119.253.14\"", |
KeystoneElectronic |
12:9a2dab9b927d | 21 | "mqtt_sn_port": "10000" |
KeystoneElectronic |
12:9a2dab9b927d | 22 | ``` |
KeystoneElectronic |
12:9a2dab9b927d | 23 | Set the host (do not forget the escaped Quotation marks), port and topic to which your node will connect to |
KeystoneElectronic |
12:9a2dab9b927d | 24 | |
KeystoneElectronic | 0:c0cf12ee5420 | 25 | ### Now compile |
KeystoneElectronic | 0:c0cf12ee5420 | 26 | |
KeystoneElectronic | 0:c0cf12ee5420 | 27 | Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: |
KeystoneElectronic | 0:c0cf12ee5420 | 28 | |
KeystoneElectronic | 0:c0cf12ee5420 | 29 | ``` |
KeystoneElectronic |
12:9a2dab9b927d | 30 | mbed compile -m NUCLEO_F411RE -t GCC_ARM |
KeystoneElectronic | 0:c0cf12ee5420 | 31 | ``` |
KeystoneElectronic | 0:c0cf12ee5420 | 32 | |
KeystoneElectronic | 0:c0cf12ee5420 | 33 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
KeystoneElectronic | 0:c0cf12ee5420 | 34 | |
KeystoneElectronic | 0:c0cf12ee5420 | 35 | ``` |
KeystoneElectronic | 0:c0cf12ee5420 | 36 | [snip] |
KeystoneElectronic |
12:9a2dab9b927d | 37 | +-----------------------------------------+-------+-------+------+ |
KeystoneElectronic |
12:9a2dab9b927d | 38 | | Module | .text | .data | .bss | |
KeystoneElectronic |
12:9a2dab9b927d | 39 | +-----------------------------------------+-------+-------+------+ |
KeystoneElectronic |
12:9a2dab9b927d | 40 | | MQTTSNPacket/MQTTSNConnectClient.o | 274 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 41 | | MQTTSNPacket/MQTTSNDeserializePublish.o | 390 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 42 | | MQTTSNPacket/MQTTSNPacket.o | 280 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 43 | | MQTTSNPacket/MQTTSNSerializePublish.o | 460 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 44 | | MQTTSNPacket/MQTTSNSubscribeClient.o | 304 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 45 | | X-NUCLEO-SARA-N200/sara-n2.o | 2018 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 46 | | [fill] | 172 | 4 | 18 | |
KeystoneElectronic |
12:9a2dab9b927d | 47 | | [lib]/c.a | 42290 | 2472 | 89 | |
KeystoneElectronic |
12:9a2dab9b927d | 48 | | [lib]/gcc.a | 3392 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 49 | | [lib]/misc | 252 | 16 | 28 | |
KeystoneElectronic |
12:9a2dab9b927d | 50 | | main.o | 3531 | 52 | 2099 | |
KeystoneElectronic |
12:9a2dab9b927d | 51 | | mbed-os/drivers | 3774 | 4 | 100 | |
KeystoneElectronic |
12:9a2dab9b927d | 52 | | mbed-os/features | 16 | 0 | 0 | |
KeystoneElectronic |
12:9a2dab9b927d | 53 | | mbed-os/hal | 1697 | 4 | 68 | |
KeystoneElectronic |
12:9a2dab9b927d | 54 | | mbed-os/platform | 6218 | 260 | 345 | |
KeystoneElectronic |
12:9a2dab9b927d | 55 | | mbed-os/rtos | 9058 | 168 | 6081 | |
KeystoneElectronic |
12:9a2dab9b927d | 56 | | mbed-os/targets | 8114 | 4 | 900 | |
KeystoneElectronic |
12:9a2dab9b927d | 57 | | Subtotals | 82240 | 2984 | 9728 | |
KeystoneElectronic |
12:9a2dab9b927d | 58 | +-----------------------------------------+-------+-------+------+ |
KeystoneElectronic |
12:9a2dab9b927d | 59 | Total Static RAM memory (data + bss): 12712 bytes |
KeystoneElectronic |
12:9a2dab9b927d | 60 | Total Flash memory (text + data): 85224 bytes |
KeystoneElectronic |
12:9a2dab9b927d | 61 | |
KeystoneElectronic |
12:9a2dab9b927d | 62 | Image: ./BUILD/NUCLEO_F411RE/GCC_ARM/sara-n200-hello-mqtt-sn.bin |
KeystoneElectronic |
12:9a2dab9b927d | 63 | |
KeystoneElectronic | 0:c0cf12ee5420 | 64 | ``` |
KeystoneElectronic | 0:c0cf12ee5420 | 65 | |
KeystoneElectronic | 0:c0cf12ee5420 | 66 | ### Program your board |
KeystoneElectronic | 0:c0cf12ee5420 | 67 | |
KeystoneElectronic | 0:c0cf12ee5420 | 68 | 1. Connect your mbed device to the computer over USB. |
KeystoneElectronic | 0:c0cf12ee5420 | 69 | 1. Copy the binary file to the mbed device. |
KeystoneElectronic | 0:c0cf12ee5420 | 70 | 1. Press the reset button to start the program. |
KeystoneElectronic | 0:c0cf12ee5420 | 71 | |
KeystoneElectronic | 0:c0cf12ee5420 | 72 | The LED on your platform turns on and off. |
KeystoneElectronic |
12:9a2dab9b927d | 73 | Open a terminal to see debug information. |
KeystoneElectronic | 0:c0cf12ee5420 | 74 | |
KeystoneElectronic | 0:c0cf12ee5420 | 75 | ## Troubleshooting |
KeystoneElectronic | 0:c0cf12ee5420 | 76 | |
KeystoneElectronic | 0:c0cf12ee5420 | 77 | If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. |