Skip to content

Embedded MQTT v3.11 / v5.0 broker#457

Merged
embhorn merged 2 commits intowolfSSL:masterfrom
dgarske:broker
Feb 10, 2026
Merged

Embedded MQTT v3.11 / v5.0 broker#457
embhorn merged 2 commits intowolfSSL:masterfrom
dgarske:broker

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Jan 30, 2026

Adds embedded MQTT broker (src/mqtt_broker) supporting v3.1.1/v5.0 clients with optional TLS.

Features

Protocol

  • QoS 0/1/2 (full PUBREC/PUBREL/PUBCOMP flow)
  • Retained messages
  • LWT with v5 Will Delay Interval & Message Expiry
  • Wildcard subscriptions (+, #)
  • Client ID enforcement & takeover
  • Keep-alive monitoring

Security

  • TLS 1.2/1.3 via wolfSSL
  • Mutual TLS (RSA/ECC)
  • Username/password auth

MQTT v5

  • CONNACK properties (Retain Available, Max QoS, etc.)
  • PUBLISH property forwarding
  • Reason codes in UNSUBACK/DISCONNECT
  • Multi-topic UNSUBACK compliance

Resource Management

  • Static memory mode (WOLFMQTT_STATIC_MEMORY) - zero malloc
  • Dynamic mode (linked lists)
  • Configurable limits (clients: 8, subs: 32, retained: 16)
  • 4KB RX/TX buffers

Logging

  • 3 levels (ERROR/INFO/DEBUG), runtime control (-v)
  • Compile-time disable (--disable-broker-log)

Build

Autotools:

./configure --enable-broker [--disable-broker-{retained,will,wildcards,auth,log}]
make

@dgarske dgarske self-assigned this Jan 30, 2026
@dgarske dgarske force-pushed the broker branch 2 times, most recently from 6ddbfe8 to c2433c0 Compare February 5, 2026 23:03
@dgarske dgarske requested a review from Copilot February 6, 2026 06:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements a simple MQTT v5.0 broker for the wolfMQTT library. The implementation provides a lightweight, embeddable broker that supports both static and dynamic memory allocation, making it suitable for both resource-constrained embedded systems and server environments. The broker includes essential MQTT features such as pub/sub messaging, retained messages, Last Will and Testament (LWT), QoS 0-1 support, client authentication, and optional TLS encryption.

Changes:

  • Added complete broker implementation with support for MQTT v3.1.1 and v5.0 protocols
  • Exposed packet encoding/decoding functions as public API for broker use via WOLFMQTT_BROKER build option
  • Fixed existing bug in MQTT_CONNECT_FLAG_GET_QOS macro (missing & operator)
  • Added comprehensive test suite with 14 test cases covering core functionality and TLS support
  • Integrated broker into build systems (autotools and CMake) and CI/CD pipeline

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
wolfmqtt/mqtt_types.h Added XSTRCMP macro for string comparison abstraction
wolfmqtt/mqtt_packet.h Changed WOLFMQTT_LOCAL to WOLFMQTT_API for broker-needed functions; fixed QoS extraction macro bug; added broker-specific decode/encode API declarations
wolfmqtt/mqtt_broker.h New header defining broker types (MqttBroker, BrokerClient, BrokerSub, etc.) and public API
src/mqtt_packet.c Implemented broker-side packet decode/encode functions (Connect, ConnectAck, Subscribe, Unsubscribe, UnsubscribeAck, Disconnect)
src/mqtt_broker.c Main broker implementation (2371 lines) with client management, subscription handling, retained messages, topic matching, and LWT support
wolfmqtt/include.am Added mqtt_broker.h to installed headers
src/include.am Added mqtt_broker binary to build
scripts/include.am Added broker.test script to distribution
scripts/broker.test Comprehensive test script with 14 test cases using mosquitto_pub/sub clients
scripts/broker_test/*.pem Test certificates for TLS testing
configure.ac Added --enable-broker option; fixed trailing whitespace
CMakeLists.txt Added WOLFMQTT_BROKER option and broker executable target
.gitignore Added configure~ and src/mqtt_broker to ignore list
.github/workflows/broker-check.yml New CI workflow testing broker with 4 configurations (dynamic/static memory, with/without TLS)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dgarske dgarske changed the title Simple MQTT v5.0 broker Embedded MQTT v3.11 / v5.0 broker Feb 6, 2026
@dgarske dgarske marked this pull request as ready for review February 6, 2026 19:06
@dgarske dgarske requested a review from Copilot February 9, 2026 20:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@embhorn embhorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Couple small build issues I saw.

@embhorn embhorn self-requested a review February 10, 2026 21:54
Copy link
Member

@embhorn embhorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start. I think it's good to publish.

@embhorn embhorn merged commit e1caa8e into wolfSSL:master Feb 10, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants