Sample MQTT program - simple send and receive

Dependencies:   C12832 MQTT

Dependents:   MQTT_G_SENSOR

This program and the MQTT libraries it uses are part of the EclipseTM Paho project; specifically the embedded client.

This example and API are working, but are still in progress. Please give us your feedback.

HelloMQTT is an example of using the MQTT API. The MQTT API is portable across network interface stacks. MQTT is designed to be used with TCP/IP, but any transport with similar characteristics should be suitable.

HelloMQTT uses the NetworkInterface APIs in mbed OS 5 to show how this works. The MQTT library contains an MQTTNetwork.h header, which is a wrapper around the mbed networking interface. To switch between connectivity methods (the default is Ethernet) the easy-connect library is provided in this example application. You can change the connectivity method in mbed_app.json.

Adding new connectivity methods to the program is trivial, as long as they implement the mbed OS 5 NetworkStack API.

Committer:
Jan Jongboom
Date:
Mon Sep 11 16:43:49 2017 +0200
Revision:
22:f5f6c9059eed
Parent:
20:49c9daf2b0ff
Roll back update to mbed OS 5.5

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jan Jongboom 20:49c9daf2b0ff 1 {
Jan Jongboom 20:49c9daf2b0ff 2 "config": {
Jan Jongboom 20:49c9daf2b0ff 3 "network-interface":{
Jan Jongboom 21:a68bd76740f9 4 "help": "options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, WIFI_RTW, MESH_LOWPAN_ND, MESH_THREAD, CELLULAR_ONBOARD",
Jan Jongboom 20:49c9daf2b0ff 5 "value": "ETHERNET"
Jan Jongboom 20:49c9daf2b0ff 6 },
Jan Jongboom 20:49c9daf2b0ff 7 "mesh_radio_type": {
Jan Jongboom 20:49c9daf2b0ff 8 "help": "options are ATMEL, MCR20",
Jan Jongboom 20:49c9daf2b0ff 9 "value": "ATMEL"
Jan Jongboom 20:49c9daf2b0ff 10 },
Jan Jongboom 20:49c9daf2b0ff 11 "esp8266-tx": {
Jan Jongboom 20:49c9daf2b0ff 12 "help": "Pin used as TX (connects to ESP8266 RX)",
Jan Jongboom 20:49c9daf2b0ff 13 "value": "D1"
Jan Jongboom 20:49c9daf2b0ff 14 },
Jan Jongboom 20:49c9daf2b0ff 15 "esp8266-rx": {
Jan Jongboom 20:49c9daf2b0ff 16 "help": "Pin used as RX (connects to ESP8266 TX)",
Jan Jongboom 20:49c9daf2b0ff 17 "value": "D0"
Jan Jongboom 20:49c9daf2b0ff 18 },
Jan Jongboom 20:49c9daf2b0ff 19 "esp8266-ssid": {
Jan Jongboom 20:49c9daf2b0ff 20 "value": "\"SSID\""
Jan Jongboom 20:49c9daf2b0ff 21 },
Jan Jongboom 20:49c9daf2b0ff 22 "esp8266-password": {
Jan Jongboom 20:49c9daf2b0ff 23 "value": "\"Password\""
Jan Jongboom 20:49c9daf2b0ff 24 },
Jan Jongboom 20:49c9daf2b0ff 25 "esp8266-debug": {
Jan Jongboom 20:49c9daf2b0ff 26 "value": true
Jan Jongboom 20:49c9daf2b0ff 27 },
Jan Jongboom 20:49c9daf2b0ff 28 "lcd-mosi": {
Jan Jongboom 20:49c9daf2b0ff 29 "value": "D11",
Jan Jongboom 20:49c9daf2b0ff 30 "macro_name": "LCD_MOSI"
Jan Jongboom 20:49c9daf2b0ff 31 },
Jan Jongboom 20:49c9daf2b0ff 32 "lcd-sck": {
Jan Jongboom 20:49c9daf2b0ff 33 "value": "D13",
Jan Jongboom 20:49c9daf2b0ff 34 "macro_name": "LCD_SCK"
Jan Jongboom 20:49c9daf2b0ff 35 },
Jan Jongboom 20:49c9daf2b0ff 36 "lcd-miso": {
Jan Jongboom 20:49c9daf2b0ff 37 "value": "D12",
Jan Jongboom 20:49c9daf2b0ff 38 "macro_name": "LCD_MISO"
Jan Jongboom 20:49c9daf2b0ff 39 },
Jan Jongboom 20:49c9daf2b0ff 40 "lcd-a0": {
Jan Jongboom 20:49c9daf2b0ff 41 "value": "D7",
Jan Jongboom 20:49c9daf2b0ff 42 "macro_name": "LCD_A0"
Jan Jongboom 20:49c9daf2b0ff 43 },
Jan Jongboom 20:49c9daf2b0ff 44 "lcd-ncs": {
Jan Jongboom 20:49c9daf2b0ff 45 "value": "D10",
Jan Jongboom 20:49c9daf2b0ff 46 "macro_name": "LCD_NCS"
Jan Jongboom 20:49c9daf2b0ff 47 }
Jan Jongboom 20:49c9daf2b0ff 48 },
Jan Jongboom 20:49c9daf2b0ff 49 "target_overrides": {
Jan Jongboom 20:49c9daf2b0ff 50 "*": {
Jan Jongboom 20:49c9daf2b0ff 51 "target.features_add": ["NANOSTACK", "LOWPAN_ROUTER", "COMMON_PAL"],
Jan Jongboom 20:49c9daf2b0ff 52 "mbed-mesh-api.6lowpan-nd-channel-page": 0,
Jan Jongboom 20:49c9daf2b0ff 53 "mbed-mesh-api.6lowpan-nd-channel": 12,
Jan Jongboom 20:49c9daf2b0ff 54 "mbed-trace.enable": 0
Jan Jongboom 20:49c9daf2b0ff 55 },
Jan Jongboom 20:49c9daf2b0ff 56 "HEXIWEAR": {
Jan Jongboom 20:49c9daf2b0ff 57 "esp8266-tx": "PTD3",
Jan Jongboom 20:49c9daf2b0ff 58 "esp8266-rx": "PTD2"
Jan Jongboom 20:49c9daf2b0ff 59 },
Jan Jongboom 20:49c9daf2b0ff 60 "NUCLEO_F401RE": {
Jan Jongboom 20:49c9daf2b0ff 61 "esp8266-tx": "D8",
Jan Jongboom 20:49c9daf2b0ff 62 "esp8266-rx": "D2"
Jan Jongboom 20:49c9daf2b0ff 63 },
Jan Jongboom 20:49c9daf2b0ff 64 "NUCLEO_F411RE": {
Jan Jongboom 20:49c9daf2b0ff 65 "esp8266-tx": "D8",
Jan Jongboom 20:49c9daf2b0ff 66 "esp8266-rx": "D2"
Jan Jongboom 20:49c9daf2b0ff 67 }
Jan Jongboom 20:49c9daf2b0ff 68 }
Jan Jongboom 20:49c9daf2b0ff 69 }