Use MQTT with mbedTLS in Keil uVision 5 (MDK)
Today’s post is rather short as it is the end of 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.
The changes done to the code are as shown in commit b85db2c9. The MQTT broker used is hosted at iot.eclipse.org:8883
. I printed out the bytes sent and received using a simple hex dump function which I added in commit 82b44fec. The hex dump function gives a print of the ASCII representation where applicable. The results of the communication are shown below. Details about what each non-ASCII byte represents may be found in the MQTT-3.1.1 spec on OASIS.
To enable communication with iot.eclipse.org:8883
, the certificate provided on their site was added to the list of known CAs (certificate authorities) as evident in commit 2b902433.
I used the MQTT paho library for embedded C and in particular the MQTT Packet because it is lightweight. I needed to see what was sent on the wire and that seemed the best way to do so. Please do not crucify me for how I did the MQTT process in the while loop because it was just for this example.
In the next post, we shall consider sending this information to a secure broker which can be connected to other solutions in the cloud. This results in delivering a complete end-to-end solution. Till then, enjoy yourself.