DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
mqtt.h File Reference

Zero-heap MQTT 3.1.1 publish/subscribe client (DETWS_ENABLE_MQTT). More...

#include "ServerConfig.h"
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Detailed Description

Zero-heap MQTT 3.1.1 publish/subscribe client (DETWS_ENABLE_MQTT).

A full, persistent outbound client for IoT messaging: connect to a broker with an optional Last-Will and credentials, PUBLISH and SUBSCRIBE / UNSUBSCRIBE at QoS 0, 1, or 2 (complete acknowledgement flows in both directions, with bounded in-flight retransmit), receive messages via a callback, and keep the session alive. Split, like the other services, into a pure host-testable codec and an ESP32-only transport:

  • mqtt_build_* / mqtt_parse_* / mqtt_*_remlen are pure packet functions, unit-tested on the host (env:native_mqtt).
  • mqtt_connect() / mqtt_publish() / mqtt_subscribe() / mqtt_loop() resolve the broker (DNS), open a raw lwIP TCP connection (mqtts:// via client-side mbedTLS over the shared static arena), and drive the session. No heap; one broker connection at a time.

QoS 2 uses the four-packet PUBLISH/PUBREC/PUBREL/PUBCOMP exchange; outbound QoS 1/2 messages are held in a fixed in-flight pool and retransmitted (DUP) on timeout until acknowledged. Inbound QoS 2 is de-duplicated by packet id.

Definition in file mqtt.h.