Skip to main content

mqtt-sn-publish

:::warning [UNTESTED] — and the real library is not exercised Two separate caveats. First, the usual one: native_sim only, no bench. Second, and more important: the real coreMQTT-SN library is not called at all here. This example hand-rolls the identical OASIS MQTT-SN v1.2 PUBLISH wire format so the round-trip still builds and runs. See Integration reality. :::

Serialize an MQTT-SN PUBLISH packet into a buffer and parse it back — the wire format MQTT-SN uses to reach constrained, non-TCP links.

Source: examples/connectivity/mqtt-sn-publish/.

What it does

mqttsn_wire_encode_publish() → buffer → mqttsn_wire_decode_publish(), asserting that topic ID, message ID, QoS, retain flag, and payload all survive the round-trip. No transport, no socket, no gateway.

This is the shape a customer would unit-test a real MQTT-SN encoder/decoder with before wiring it to a live link.

Integration reality

coreMQTT-SN is pinned in west.yml (freertos-org/coreMQTT-SN) under the disabled-by-default extras-tier1 group. In the authoring workspace modules/lib/coremqtt_sn/ is an empty working tree — an orphan init_placeholder branch with zero commits — so there is no header on disk to include. coreMQTT-SN also ships no zephyr/module.yml of its own.

libraries: [coremqtt_sn] therefore emits CONFIG_ALP_MQTTSN_NO_TLS=y (the software-fallback default) but does not add the upstream module's include path.

caution

The README's instructions for swapping in the real library are written against the module's public documentation, not verified against a local checkout.

Hardware swap

No board-specific wiring — this is pure buffer logic. Once wired to a real MQTT-SN gateway, the transport is what changes (UDP broadcast, BLE GATT, or a UART framing layer); the PUBLISH encode/decode calls stay the same regardless of SoM family.

board.yaml

libraries:
- name: coremqtt-sn
cores: [m55_hp]

som:
sku: E1M-AEN801

preset: e1m-evk

cores:
m55_hp:
app: ./src
peripherals: []

diagnostics:
log_level: info

Expected output

[mqtt-sn-publish] encoding PUBLISH: topic_id=0x0001 msg_id=0x0007 "23.5C"
[mqtt-sn-publish] encoded 12 bytes
[mqtt-sn-publish] decoded: topic_id=0x0001 msg_id=0x0007 qos=0 retain=0 payload="23.5C"
[mqtt-sn-publish] round trip OK
[mqtt-sn-publish] done

See also

Questions about this page? Discuss in Community Forum