This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Sending commands to Thingy91 by subscribing to mqtt server

Hi Dev team,

I am working on a Thingy91 device, and I am sending data out through MQTT.

I need a functionality to send some commands to do assigned tasks from the MQTT server back to the LTE device.

Are there any nRF or Zephyr API that supports this functionality to send commands from any server to the LTE Device? 

If not, I was thinking to use the MQTT subscribe to receive commands and perform actions based on that.

What would be a feasible approach to implement the command functionality ?

Regards,

Adeel.

  • The mqtt_evt_handler function is the same as in the mqtt_simple sample.

    If it receives the MQTT_EVT_PUBLISH event (which means that it has received a message on some topic), it checks if the topic is the command topic, and if it is, it calls a function that handles the command (handle_command_message()).

    The handle_command_message() function parses the command (from some unspecified format to something that is easier to work with in the code, e.g. an enum). When the command is parsed, the function checks what command it is, and calls a new function that handles that particular command.

    mqtt_evt_handler is already a part of the mqtt_simple sample. is_command_topic(), handle_command_message(), parse_command() and handle_set_light() (or handle_lighton() or handle_<this particular command>()) you must implement yourself.

Related