GatoMQTT
GatoMQTT is a no_std, no-allocator MQTT 3.1.1 broker library for embedded
Rust — small enough to run on a Raspberry Pi Pico (RP2040) or ESP32-C3 with
a few connected clients, while staying transport-agnostic (plain TCP or any
implementation of the TlsSession trait).
Features
- MQTT 3.1.1 control plane — CONNECT / SUBSCRIBE / PUBLISH (QoS 0 + QoS 1) / PINGREQ / DISCONNECT, retained messages, Last Will & Testament, simple constant-time username/password auth.
- Bounded session storage —
SessionRegistry<MAX_SESSIONS, MAX_SUBS, MAX_INFLIGHT>with per-session subscription set, in-flight QoS 1 PIDs, and token-bucket rate limiting. All state lives on the stack/static — no heap. - Transport-agnostic — implements broker logic over a
Transporttrait (asyncread/write/close). Wrappers exist for plain TCP, and anyTlsSessionimplementation can be plugged in viaTlsTransport. - TLS 1.3 PSK_KE out-of-the-box adapter (behind the
tls-pskfeature) usingGatoPSKTLS— a sibling crate with ano_stdTLS 1.3 PSK client + server. - Embassy-friendly — async logic uses
embassy-syncprimitives. Optional integration withembassy-net::TcpSocketbehind theembassy-netfeature.
Status / scope
GatoMQTT targets a small private deployment where predictability, static
limits, and low resource usage matter more than full MQTT broker feature
coverage. It is not an mosquitto replacement; rather, a building block
for "broker on a microcontroller" use cases.
| Area | Status |
|---|---|
| MQTT 3.1.1 control packets | ✅ |
| QoS 0 + QoS 1 | ✅ |
| Retained messages, LWT | ✅ |
| Username/password auth | ✅ |
| Bounded heapless storage | ✅ |
| TLS 1.3 PSK adapter | ✅ via tls-psk feature |
| MQTT 5.0 | ❌ |
| QoS 2 (PUBREC/PUBREL/PUBCOMP) | ❌ |
| Bridges / clustering | ❌ |
| Persistent retained-store | ❌ — in-memory only |
Quick start
use RefCell;
use Spawner;
use CriticalSectionRawMutex;
use ;
use GATOMQTT_CONFIG;
use MqttIntent;
use connection_loop;
use RetainedStore;
use SessionRegistry;
// Static broker state — bounded.
const MAX_SESSIONS: usize = 4;
const MAX_SUBS: usize = 8;
const MAX_INFLIGHT: usize = 2;
const MAX_RETAINED: usize = 8;
const INBOUND_N: usize = 4;
static REGISTRY: = new;
static RETAINED: =
new;
static INBOUND: =
new;
static OUTBOX: =
;
// Per-connection task — accept a TCP socket, wrap in your transport, drive.
async
For TLS 1.3 PSK, enable the tls-psk feature and wrap your TCP transport in
EmbeddedTlsPskSession → TlsTransport. See the
tls::embedded_tls_psk module docs for the
wiring snippet.
For a fully wired ESP32-C3 example combining GatoMQTT + GatoPSKTLS over Wi-Fi,
see the picobrokerTLS
companion repository under examples/esp32c3_mqtt_server/.
Cargo features
= { = "0.2", = false }
| Feature | Effect |
|---|---|
embassy-net |
Pulls embassy-net so TcpTransport examples work directly with embassy-net TcpSocket. |
tls-psk |
Enables tls::embedded_tls_psk::EmbeddedTlsPskSession — a TlsSession implementation backed by GatoPSKTLS for TLS 1.3 PSK_KE. |
License
MIT — see LICENSE.