Expand description
MQTT-SN (MQTT for Sensor Networks) layer implementation.
Implements MQTT-SN v1.2 packet parsing as a zero-copy view into a packet buffer.
§Header Format
MQTT-SN uses a variable-length header:
Short form (length 2..=255):
Byte 0: Length (1 byte)
Byte 1: Message Type (1 byte)
Byte 2+: Message body (variable)
Extended form (length 256..=65535):
Byte 0: 0x01 (marker)
Byte 1-2: Length (2 bytes, big-endian)
Byte 3: Message Type (1 byte)
Byte 4+: Message body (variable)§Flags Byte (used in CONNECT, PUBLISH, SUBSCRIBE, etc.)
Bit: 7 6-5 4 3 2 1-0
Field: DUP QoS RETAIN WILL CleanSess TID_TYPE§Message Types
| Value | Name |
|---|---|
| 0x00 | ADVERTISE |
| 0x01 | SEARCHGW |
| 0x02 | GWINFO |
| 0x04 | CONNECT |
| 0x05 | CONNACK |
| 0x06 | WILLTOPICREQ |
| 0x07 | WILLTOPIC |
| 0x08 | WILLMSGREQ |
| 0x09 | WILLMSG |
| 0x0A | REGISTER |
| 0x0B | REGACK |
| 0x0C | PUBLISH |
| 0x0D | PUBACK |
| 0x0E | PUBCOMP |
| 0x0F | PUBREC |
| 0x10 | PUBREL |
| 0x12 | SUBSCRIBE |
| 0x13 | SUBACK |
| 0x14 | UNSUBSCRIBE |
| 0x15 | UNSUBACK |
| 0x16 | PINGREQ |
| 0x17 | PINGRESP |
| 0x18 | DISCONNECT |
| 0x1A | WILLTOPICUPD |
| 0x1B | WILLTOPICRESP |
| 0x1C | WILLMSGUPD |
| 0x1D | WILLMSGRESP |
| 0xFE | ENCAPS_MSG |
Re-exports§
pub use builder::MqttSnBuilder;
Modules§
- builder
- MQTT-SN packet builder.
Structs§
- Mqtt
SnLayer - MQTT-SN layer – a zero-copy view into a packet buffer.
Constants§
- ADVERTISE
- CONNACK
- CONNECT
- DISCONNECT
- ENCAPS_
MSG - GWINFO
- MQTTSN_
MIN_ HEADER_ LEN - Minimum MQTT-SN header: 1 byte length + 1 byte type.
- MQTTSN_
PORT - Default MQTT-SN UDP port.
- PINGREQ
- PINGRESP
- PUBACK
- PUBCOMP
- PUBLISH
- PUBREC
- PUBREL
- RC_
ACCEPTED - RC_
REJ_ CONGESTION - RC_
REJ_ INVALID_ TID - RC_
REJ_ NOT_ SUPPORTED - REGACK
- REGISTER
- SEARCHGW
- SUBACK
- SUBSCRIBE
- TID_
NORMAL - TID_
PREDEF - TID_
SHORT - UNSUBACK
- UNSUBSCRIBE
- WILLMSG
- WILLMSGREQ
- WILLMSGRESP
- WILLMSGUPD
- WILLTOPIC
- WILLTOPICREQ
- WILLTOPICRESP
- WILLTOPICUPD
Statics§
- MQTTSN_
FIELD_ NAMES - Field names for the MQTT-SN layer.
Functions§
- decode_
mqttsn_ length - Decode the MQTT-SN variable length field.
- is_
mqttsn_ payload - Check if a UDP payload looks like an MQTT-SN packet.
- message_
type_ name - Get the human-readable name for a message type.
- return_
code_ name - Get the human-readable name for a return code.