![](/media/cache/group/Avnet_silica_2000px.png.50x50_q85.png)
MQTT client for IBM Bluemix
Dependencies: HTS221 LIS3MDL LPS22HB LSM303AGR LSM6DSL MQTT VL53L0X
Getting started with IBM Bluemix
This is the MQTT Client example for mbed OS. It demonstrates how to connect a device with IBM Bluemix, how to get values from sensors, and how to see them on the IBM quickstart website. If you are unfamiliar with IBM Bluemix, we recommend that you read the introduction starting here.
Demo workflow:
- Connection to the local network with 6LoWPAN ND connection.
- Connection to the Quickstart Bluemix.
- Read data sensors.
- Sends data sensors to the Quickstart Bluemix
You can compile this project in three ways:
1. Using the Online compiler. Just clicking here:
Information
Learn how to use the Online compiler reading https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/online_comp/ page.
2. Using the compiler on your PC:
- mbed import https://os.mbed.com/teams/Avnet-Silica/code/mbed-os-mqtt-client
- mbed compile -m SILICA_SENSOR_NODE -t GCC_ARM
Information
Learn how to use the mbed-cli reading https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/cli/ page.
The name of the machine is SILICA_SENSOR_NODE.
3. Exporting to 3rd party tools (IDE) like eclipse, IAR, uvision 5 and more others
Information
Learn how to use the mbed-cli reading https://docs.mbed.com/docs/mbed-os-handbook/en/latest/dev_tools/third_party/ page.
Warning
This example requires a Border Router board. For more details please read the Border Router paragraph from this page.
Please read carefully the next pages:
- What to do before to compile the project: read here. This step is indipendent from the way you compile the project.
- How to run the client read here.
MQTTNetwork.h
- Committer:
- rspelta
- Date:
- 2017-11-02
- Revision:
- 0:e673387d5add
File content as of revision 0:e673387d5add:
#ifndef _MQTTNETWORK_H_ #define _MQTTNETWORK_H_ #include "NetworkInterface.h" class MQTTNetwork { public: MQTTNetwork(NetworkInterface* aNetwork) : network(aNetwork) { socket = new TCPSocket(); } ~MQTTNetwork() { delete socket; } int read(unsigned char* buffer, int len, int timeout) { return socket->recv(buffer, len); } int write(unsigned char* buffer, int len, int timeout) { return socket->send(buffer, len); } int connect(const char* hostname, int port) { socket->open(network); return socket->connect(hostname, port); } int disconnect() { return socket->close(); } private: NetworkInterface* network; TCPSocket* socket; }; #endif // _MQTTNETWORK_H_