Step-by-step Usage Instructions

Minimal steps

  1. Make sure you have the SOCK library in your project.
  2. Add mqtt.tbs and mqtt.tbh files to your project (they are in current_library_set\mqtt\trunk).
  3. Add #define MQTT_DEBUG_PRINT 1 to the defines section of the global.tbh file of your project. This way you will "see what's going on". Don't forget to remove this later, after you've made sure that the library operates as expected. Debug printing really slows things down!
  4. Add include "mqtt\trunk\mqtt.tbh" to the Includes section of the global.tbh file.
  5. Add mqtt_proc_timer() to the on_sys_timer() event handler code.
  6. Add mqtt_proc_data() to the on_sock_data_arrival() event handler code.
  7. Add the following into the on_sys_init() event handler:
      • Add mqtt_start() to initialize the library;
      • Add mqtt_connect() with correct MQTT server (broker) parameters to initiate the connection to the server.
- If your device is a publisher, implement the code that invokes [mqtt_publish()](mqtt_publish) at the appropriate times.
  1. Create callback function bodies somewhere in your project (for example, in the device.tbs file):