How espressif/esp-mqtt works
ESP-MQTT is an ESP-IDF MQTT client supporting MQTT 3.1.1 and 5.0 over TCP, TLS, WebSocket, and secure WebSocket. Applications configure and start one or more clients, then publish or subscribe; the client runtime handles transport connection, MQTT packet exchange, QoS acknowledgments, retransmission state, and event delivery. Packet codecs and the outbox are distinct internal layers. The README documents the protocol and transport capabilities; excerpts show transport selection and message reception, but not enough of the runtime call graph to assert most internal links.
Main entry points: mqtt_client.c Client Runtime · mqtt5_client.c MQTT 5 Runtime · mqtt_client.h Client API · mqtt5_client.h MQTT 5 API
Components 18
Client API
- Client API
include/mqtt_client.h - MQTT 5 API
include/mqtt5_client.h - Common Types
include/mqtt_common.h
Client Runtime
- Client Runtime
mqtt_client.c - MQTT 5 Runtime
mqtt5_client.c - Client State
lib/include/mqtt_client_priv.h - MQTT 5 State
lib/include/mqtt5_client_priv.h - Transport Adapters
mqtt_client.c - URI Utilities
lib/mqtt_utils/mqtt_utils.c
MQTT Protocol
- MQTT Codec
lib/mqtt_msg/mqtt_msg.c - MQTT Message Model
lib/mqtt_msg/include/mqtt_msg.h - MQTT 5 Codec
lib/mqtt_msg/mqtt5_msg.c - MQTT 5 Message Model
lib/mqtt_msg/include/mqtt5_msg.h
Delivery State
- QoS Outbox
lib/mqtt_outbox.c - Outbox Interface
lib/include/mqtt_outbox.h - Platform Helpers
lib/platform.c
Other components
- Application
- MQTT Broker
Connections 18
- Application → Client API: configures client
- Client API → Client Runtime: starts runtime
mqtt_client.c - Application → MQTT 5 API: sets MQTT 5 options
- MQTT 5 API → MQTT 5 Runtime: configures protocol
mqtt5_client.c - Client Runtime → Transport Adapters: selects transport
mqtt_client.c - Client Runtime → MQTT Broker: exchanges packets
- MQTT Broker → Client Runtime: returns packets
- Client Runtime → MQTT Codec: decodes packets
- MQTT Codec → MQTT Message Model: uses model
lib/mqtt_msg/mqtt_msg.c - MQTT 5 Runtime → MQTT 5 Codec: encodes properties
- MQTT 5 Codec → MQTT 5 Message Model: uses model
lib/mqtt_msg/mqtt5_msg.c - MQTT 5 Runtime → Client Runtime: extends runtime
- Client Runtime → Client State: uses state
mqtt_client.c - MQTT 5 Runtime → MQTT 5 State: uses state
- Client Runtime → QoS Outbox: queues delivery
- QoS Outbox → Outbox Interface: implements interface
lib/mqtt_outbox.c - Client Runtime → URI Utilities: parses URI
- Client Runtime → Platform Helpers: uses helpers