About this project

# wolfMQTT wolfMQTT is a compact, efficient MQTT client implementation written in C, designed for embedded systems and resource-constrained environments. It integrates with the wolfSSL library to provide robust TLS support, including TLS 1.3. ## Key Features - **MQTT v3.1.1 and v5.0 support**: Full specification support for QoS 0-2, Last Will and Testament (LWT), and many v5 features like AUTH packet, user properties, server disconnect, reason codes, and topic aliases. - **MQTT-SN support**: For low-bandwidth sensor networks, based on the OASIS MQTT-SN v1.2 specification, operating over UDP. - **TLS 1.3 with Post-Quantum support**: Can be built with wolfSSL to support post-quantum algorithms like ML-KEM-768 and ML-DSA-65 for secure communication. - **Lightweight broker**: Includes a simple MQTT broker suitable for embedded environments, supporting both v3.1.1 and v5.0 clients with optional TLS and WebSocket transport. - **WebSocket support**: Connect to MQTT brokers over standard or secure WebSockets. - **Multi-platform**: Buildable on Linux, macOS, Windows (Visual Studio), MinGW, Zephyr RTOS, and Arduino. - **Non-blocking and multithreaded operation**: Optional features for enhanced concurrency and performance. ## Building ### Mac/Linux/Unix 1. `./autogen.sh` (if cloned from GitHub) 2. `./configure` (see `./configure --help` for options) 3. `make` 4. `sudo make install` ### Windows Visual Studio Build wolfSSL first, then open the `wolfmqtt.sln` solution and build with the same architecture. ### CMake ``` mkdir build && cd build cmake .. -DWITH_WOLFSSL=/prefix/to/wolfssl/install/ cmake --build . ``` ### vcpkg Install via `./vcpkg install wolfmqtt`. ## Architecture The library is composed of three main components: 1. **mqtt_client**: Top-level application interfaces for MQTT client operations (connect, publish, subscribe, etc.). 2. **mqtt_packet**: Handles packet encoding/decoding for all MQTT packet types. 3. **mqtt_socket**: Transport layer that optionally wraps TLS and uses platform-specific network callbacks. ## Examples - **mqttclient**: General client example with many MQTT v5 features. - **mqttsimple**: Standalone client using standard BSD sockets. - **nbclient**: Non-blocking I/O example. - **firmware**: Firmware update example with signed image publishing and verification. - **Azure IoT Hub**: Example for connecting to Azure IoT Hub. - **AWS IoT**: Example for AWS IoT with TLS client certificate authentication. - **Watson IoT**: Example for IBM Watson IoT Platform. - **sn-client**: MQTT-SN client example for sensor networks. - **multithread**: Demonstrates multithreaded publishing and message waiting. - **pub-sub**: Simple publish and subscribe examples for quick testing. - **websocket**: WebSocket client example. ## Broker Compatibility Tested with Adafruit IO, AWS, Azure, flespi, HiveMQ, IBM WIoTP, Mosquitto, Paho MQTT-SN Gateway, VerneMQ, and EMQX. ## Post-Quantum MQTT Support Build wolfSSL with `--enable-dilithium --enable-mlkem`, then build wolfMQTT normally. Use the `mqttclient` example with the `-Q` option to specify the post-quantum group (e.g., `SecP384r1MLKEM768`). ## WebSocket Support Build with `--enable-websocket` and install `libwebsockets`. The example connects to a broker over WebSockets, with optional TLS and mutual authentication. ## Broker Build with `--enable-broker` to include a lightweight MQTT broker. See `BROKER.md` for full details. ## Additional Options - `--enable-debug` or `--enable-debug=verbose` for logging. - `--enable-nonblock` for non-blocking I/O. - `--enable-mt` for multithreading. - `--enable-v5` for MQTT v5 support. - `--enable-sn` for MQTT-SN support. - `--enable-curl` to use libcurl's easy socket interface as a backend. - `--enable-stress` for stress testing with multithreading and nonblocking. For more details, refer to the [wolfMQTT Manual](https://www.wolfssl.com/documentation/manuals/wolfmqtt/wolfMQTT-Manual.pdf).