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

MQTT-SN - Max payload length

Hello,

I developed a code for nRF52840 Dongle to publish data on mqtt-sn topics (I'm currently using Nordic SDK for Thread and Zigbee). I need to know what are the limitations in terms on number of bytes that I can send over mqtt-sn in a single payload.

Is there any define that specifies this limitation?

Thanks!

  • Hi,

    In section 5.2.1 of the MQTT-SN 1.2 specifications it is mentioned that the header can have either 1 or 3-byte length fields for message length up to 65535 octets.

    The IEEE 802.15.4 packets support only up to 127 octets payload, but the 6LowPAN layer used in OpenThread supports fragmentation of IPv6 packets to allow larger payloads. See this document for more details on that.

    When it comes to what is supported in the Thread MQTT-SN examples in our SDK, I cannot find any limiting code. The source code shows that it supports both 1 and 3-byte lengths:

    /**
     * Calculates the full packet length including length field
     * @param length the length of the MQTT-SN packet without the length field
     * @return the total length of the MQTT-SN packet including the length field
     */
    int MQTTSNPacket_len(int length)
    {
    	return (length > 255) ? length + 3 : length + 1;
    }

    Best regards,
    Jørgen

Related