MQTT - SN
MQTT for Sensor Networks
- MQTT-SN uses UDP and not TCP for its transport.
- UDP is a connection less protocol whereasTCPis connection orientated.
- MQTT-SN is designed, as far as possible, to work in the same way as MQTT
- In that regard MQTT-SN usually requires a connection to the broker before it can send and receive messages.
- This connection is in effect avirtual connection.
QOS Levels
MQTT-SN supports QOS 0,1,2 as per MQTT, but it also supports a special publish QOS of 3 or -1.
Note: it is known as QOS -1 but the QOS flag in the message is set to 11 or decimal 3.
Publishing messages with a QOS of -1 or 3 doesn't require an initial connection to have been set up.
You can publish using the topic id or short topic name.
Subscribing to MQTT-SN Topics
You cansubscribe to a topicsusing 3 different formats:
- A long topic name as per MQTT e.g.house/sensor1
- A short topic name of 2 characters only e.g.s1
- A pre-defined topic id (integer) e.g. 1
Wildcardscan be used as per MQTT, but they only make sense for long topic names.
MQTT-SN clients have the ability to discover brokers
There are two mechanisms used:
- Advertising by a broker or Gateway
- A Search by the client
Both methods use a multicast packet. Currently there is no standardized multicast packet address.