Firmware for listening command

hi,
I have a simple firmware for the power module, everything works, now I would like to be able to send a command/value to the module. How do I do it the easiest way? Thank you

Hi, since the power module is externally powered, you might initialize radio so it will listen.

Take inspiration from generic FW where the power module is powered and there is radio event handler set

Related:

Hi,
thanks, I initialize radio with TWR_RADIO_MODE_NODE_LISTENING, but I could not find any handler for operations with incoming mqqt messages.

Hi,

See the MQTT commands page. Search for /set, which are the topics tosend data from dongle(or different node) to the end node.

Then in your C code you use pre-defined C functions. They are weak so they are defined in SDK, but if you redefine them in your app code, then linker uses your implementation.
Here is the list of all of them

If you look at those weak functions, think about them like they could control LED or relay, but you can also use them and in you weak function use the received parameters for completely something else. I’ll explain that later below.

Now, the question is, what would you like to control?

  • A single device that expects on/off (use the relay functions, one of them has also a duration)
  • Some color LED (you can also send multiple colors, see “compound”, you might use that to pass multiple values in a array to your device from MQTT)
  • Or even something bigger and more complex? (use generic twr_radio_node_on_buffer, however this function is in C, but the Dongle does not have it implemented in the MQTT topics)

Look to the generic node FW, which contains relay and LED receive logic, and inside those weak functions it decides which relay to turn off/on

Here is how the C code of the LED compound might look. You might send an array in the MQTT using node/{id}/led-strip/-/compound/set and receive the array in your node. Then you might not need to use it for LEDs, you might use the data to control something completely different, just using the compound message to encapsulate your payload.