This is the second last post of the [series on IoT Communication](/blog/communication-for-iot-or-embedded-applications) which has gone on for slightly more than a month now. In this post, I endeavor to connect an IoT device to the Azure IoT Hub without using the provided IoT libraries.
Today's post is rather short as the end to the series on IoT communication nears.
As per the previous blog post, a TLS connection was established. A few issues like client-side certificate verification were solved. In this post, all I sort to show was doing the MQTT communication on a secure port.
This post will also be very short (or so I hope).
Setting up MQTT in your Keil MDK project is very easy especially for the Eclipse Paho client for C. I did this in one git commit. You will notice that of the three flavors available, I chose the MQTTPacket because it is lightweight. The other flavors required some more work. Setting the timing parts for the MQTTClient, required understanding the library perfectly to work it out. One requires the timing to work if you need to subscribe to a topic or if you need the broker to confirm delivery (QoS 2 or QoS 1). For the basic proof of concept, QoS 1 works fine. It means I need no response from the broker.
I choose to use LPC4337 and the Cortex-M4 core. No particular preference, only that it was on my desk at the time I chose to write this post. Also, I bought this developer board here. The network driver is documented at length by Keil/ARM here, in case you need to familiarize yourself with it before proceeding.
There are 15 commits up to this one that detail the steps on how code changed through the process.