TIDUE59A May 2018 – September 2020
The TIDC-01005 leverages the MQTT client library from the SimpleLink Wi-Fi CC3220 device SDK, to communicate with the cloud. When building an application based on the MQTT library, two software threads are responsible for implementing the MQTT client functionality: an overall MQTT Thread and an MQTT Client Thread. The overall MQTT Thread configures the parameters of the MQTT connection, establishes the connection with the MQTT broker, spawns the MQTT Client Thread, and then handles all messages received through the MQTT client callbacks. The MQTT Client Thread runs a task that is implemented in the MQTT library and is dedicated to receiving incoming messages from the MQTT connection, then passing the messages to the MQTT client callback.
In the TIDC-01005, the MQTT client task is implemented as a state machine that waits for the system to be connected to a local network and then attempts to connect to an MQTT broker. When the system is connected to the local network and the broker, the MQTT task runs the main loop to handle received messages. The main loop of the MQTT Thread (MQTT Client Connected state) is intended to be customized by the developer, based on the application needs. Figure 2-8 shows a diagram of the MQTT client task state machine.
When the system successfully enters the MQTT Connected state, the MQTT client task in the TIDC-01005 acts as an interface, for the user to access the electronic smart lock through the cloud. In the TIDC-01005, the client task uses multiple MQTT topics and messages to enable remote control of the system.
The messages received by the client are handled according to the decision tree shown in Figure 2-9.