ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
mqtt_sn.h File Reference

The MQTT-SN v1.2 wire codec (PROTOCORE_ENABLE_MQTT_SN). More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

The MQTT-SN v1.2 wire codec (PROTOCORE_ENABLE_MQTT_SN).

The governing document is "MQTT For Sensor Networks (MQTT-SN) Protocol Specification Version 1.2", by Andy Stanford-Clark and Hong Linh Truong, published by IBM on 14 November 2013. It is not an OASIS Standard and it is not an IETF protocol: it carries neither a standard number nor an RFC number. OASIS hosts the document for its MQTT Technical Committee's MQTT-SN Subcommittee, whose own MQTT-SN Version 2.0 work is a separate specification. Every section, table and message name cited here is from that v1.2 document.

MQTT-SN carries publish/subscribe over a datagram link for constrained, lossy networks: numeric topic ids instead of topic names, gateway discovery, and a keep-alive that supports sleeping clients (sec 2, sec 3). A message is:

[Length][MsgType][Message Variable Part]
  • Length is 1 octet when the whole message, the Length field included, is at most 255 octets; otherwise it is 3 octets: ::MQTTSN_LEN3_PREFIX then a big-endian uint16 of that same total (sec 5.2.1). The 3-octet form reaches 65535 octets.
  • MsgType is one octet, from Table 3 (sec 5.2.2).
  • TopicId, MsgId and Duration are 2 octets, most significant octet first (sec 5.3.3, sec 5.3.7, sec 5.3.11). A topic is named by a registered TopicId, a pre-defined TopicId, or a 2-character short topic name, as the Flags TopicIdType states (sec 5.3.4).

This is the wire codec only. The gateway connection, the topic registry, and the retransmission and sleep state (sec 6.13, sec 6.14) belong to the application.

The module exports one symbol, Mqttsn. Everything in mqtt_sn.c has internal linkage.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file mqtt_sn.h.