MQTT messages and sensor tree



  • Hi There,
    I have my MQTT client gateway up and running - and tried to decode the mqtt topic tree that is sent to the mqtt broker.

    EDIT: I have deleted the (wrong) information from this post. Below I have added the correct interpretation in a reply.

    I have set the publish prefix to "to", node id and sensor id are set in the sensor sketch

    ex. from mqtt.fx subscribing to "to/#"
    to/10/4/1/0/16 payload 1/0
    Prefix "to", node 10, sensor 4

    I have another sensor (id 11) that does not work so well. The radio works but it reports several errors and I have not fund out why yet. But it reports several other mqtt topics that are forwarded to the mqtt broker during boot:
    to/11/255/3/0/6 payload "0"
    to/11/255/3/0/12 payload "1.0"
    to/11/4/0/0/0 no payload
    Prefix "to", node 11, sensor 4 and 255

    The strange thing is that the binary sensor I have that works, does NOT send any messages to mqtt unless I activate the button. I will investigate later...

    So - the question is how to understand the mqtt topic tree - so that my controlling app can subscribe to the right topics.

    I have - at least partially answered the questions below...
    /th



  • This post is deleted!


  • Ok, Responding to my own post so whoever is in the same boat does not have to search for this info...

    In the API-description - which I for some reason had not discovered before, there is a wealth of information. In the serial API description there are all the tables we need to understand the mqtt client operation.

    So... Look here for v2.0 serial API description.

    The documents are not directly describing the mqtt tree - but the information in the mqtt tree is all described there:

    mqtt topic tree: prefix/node-id/child-sensor-id/message-type/ack/sub-type + payload

    Ok - prefix, node-id and child-sensor-id are defined by you in the sketches. Prefix in the gw the other two in the sensors. NB. your sensors must use manual id assigment unless you have a controller that handles that - I do not.

    Message type: defines what the message contains AND what the sub-type means:

    • Presentation (0): Contains the S_xxx sensor type
    • set/req (1/2): Contains the V_xxx data type
    • Internal (3): Contains an I_xxx constant that describes what the payload is - ex. I_CONFIG (6) or I_SKETCH_VERSION (12) from my example above
    • stream (4): for fw update. I have not investigated that yet.

    The **ack **field is used to know if a message is an ack to a previous message or a real message. I assume that only normal messages will be forwarded to the mqtt broker - so I think it will always be 0.

    I hope this information can help somone else to avoid spending time digging in the documentation, code and exampes πŸ™‚

    /th


  • Hardware Contributor

    in MyGatewayTransportMQTTClient.cpp, l.21 πŸ˜‰
    // Topic structure: MY_MQTT_PUBLISH_TOPIC_PREFIX/NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE



  • @scalz - jeez I spent a lot of time invesstigating this πŸ™‚


Log in to reply
 

Suggested Topics

  • 4
  • 4
  • 15
  • 17
  • 3
  • 9

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts