Summary
In this chapter, we analyzed the requirements to control sensors wired to different IoT boards with MQTT messages. We defined the topics that we would use and the commands that would be part of the messages' payloads to control sensors. We decided to take advantage of the last will and testament feature of MQTT. Then, we worked with the Eclipse Paho Java Client to write Java code that connected a non-blocking (asynchronous) MQTT client to the MQTT server.
We created a security helper class to establish a TLS secured connection and we worked with asynchronous notifications and callbacks in Java. We subscribed to topics, understood how notification events worked, and we wrote code that processed commands that interacted with sensors.
Finally, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access