Embedded MQTT v3.11 / v5.0 broker#457
Conversation
6ddbfe8 to
c2433c0
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
embhorn
left a comment
There was a problem hiding this comment.
Excellent. Couple small build issues I saw.
embhorn
left a comment
There was a problem hiding this comment.
This is a great start. I think it's good to publish.
Adds embedded MQTT broker (
src/mqtt_broker) supporting v3.1.1/v5.0 clients with optional TLS.Features
Protocol
+,#)Security
MQTT v5
Resource Management
WOLFMQTT_STATIC_MEMORY) - zero mallocLogging
-v)--disable-broker-log)Build
Autotools:
./configure --enable-broker [--disable-broker-{retained,will,wildcards,auth,log}] make