I started the first C++ API in ARM mbed as IBM and ARM were working together on an Internet of Things (IoT) kit. The ARM mbed online tools make it very easy to build and load applications onto an mbed-enabled micro controller. Just download the built application, drag to the USB-connected filesystem, then reset the micro controller. Easy as that!
To fit into mbed API conventions, the API:
- is written in C++
- uses templates
- does not use the STL (uses too much resources)
- is blocking, for ease of use
and uses no dynamic memory allocations. It’s called MQTTClient, and you can read the API description here.
The definitive source for the library is still in Paho, but both MQTTPacket and MQTTClient are also available directly in the mbed online environment. You can find them in the code for the MQTT team along with a sample application HelloMQTT, which uses the mbed Ethernet library.
If you want to use these APIs to connect to the IBM IoT service with MQTT, you can find applications that allow you to do just that in the IBM IoT team code library.
It’s easy to port the MQTTClient library to other networking libraries and other operating systems. So far, we’ve done that for Linux and Arduino. The Linux port makes it easy to build and test the code in the normal Eclipse build environments. The Arduino port was started to see if it would work. It does, and the resulting API is actually quite close to the Arduino conventions too.
The prebuilt Arduino client library is available here. After downloading it, in the Arduino IDE use Sketch -> Import Library… -> Add Library… selecting the downloaded zip file. A sample sketch demonstrating the client is included in the download. I intend to add an entry on the Arduino libraries page sometime soon.
We’ll make ports for other operating systems available as we create them. But if anyone gets around to a port before we do, we’d love that to be contributed to Paho. Operating systems such as Contiki, TinyOS, FreeRTOS and RIOT. If you have a favourite embedded OS that I’ve not mentioned, please suggest it.