All Projects → LiamBindle → Mqtt C

LiamBindle / Mqtt C

Licence: mit
A portable MQTT C client for embedded systems and PCs alike.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Mqtt C

zmosq
MQTT/Mosquitto / ZeroMQ proxy
Stars: ✭ 22 (-93.57%)
Mutual labels:  mqtt, mqtt-client
wyzesense2mqtt
Configurable WyzeSense to MQTT Gateway intended for use with Home Assistant or other platforms that use MQTT discovery mechanisms.
Stars: ✭ 55 (-83.92%)
Mutual labels:  mqtt, mqtt-client
sol
Lightweight MQTT broker, written from scratch. IO is handled by a super simple event loop based upon the most common IO multiplexing implementations.
Stars: ✭ 72 (-78.95%)
Mutual labels:  mqtt, simple
mqttools
MQTT version 5.0 client and broker using asyncio
Stars: ✭ 44 (-87.13%)
Mutual labels:  mqtt, mqtt-client
ESPecial
ESP32 automation with web interface and telegram bot
Stars: ✭ 77 (-77.49%)
Mutual labels:  mqtt, mqtt-client
CODESYS-MQTT
MQTT client library for CODESYS, supporting all QoS
Stars: ✭ 63 (-81.58%)
Mutual labels:  mqtt, mqtt-client
Mqtt Panel
A web interface for MQTT
Stars: ✭ 315 (-7.89%)
Mutual labels:  mqtt, mqtt-client
Emqtt
Erlang MQTT v5.0 Client
Stars: ✭ 253 (-26.02%)
Mutual labels:  mqtt, mqtt-client
ministaller
Lightweight installer/updater for portable desktop applications
Stars: ✭ 15 (-95.61%)
Mutual labels:  simple, portable
WeConnect-mqtt
MQTT Client that publishes data from Volkswagen WeConnect
Stars: ✭ 14 (-95.91%)
Mutual labels:  mqtt, mqtt-client
Wolfmqtt
wolfMQTT is a small, fast, portable MQTT client implementation, including support for TLS 1.3.
Stars: ✭ 316 (-7.6%)
Mutual labels:  mqtt, mqtt-client
node-deepstackai-trigger
Detects motion using Deepstack AI and calls registered triggers based on trigger rules.
Stars: ✭ 154 (-54.97%)
Mutual labels:  mqtt, mqtt-client
wasm-joey
Serverless Wasm - A lightweight Node.js application for deploying and executing WebAssembly(Wasm) binary-code via HTTP
Stars: ✭ 48 (-85.96%)
Mutual labels:  simple, portable
mqtt-datasource
MQTT Datasource for Grafana allows streaming data from any MQTT broker running either locally or remotely.
Stars: ✭ 99 (-71.05%)
Mutual labels:  mqtt, mqtt-client
Simple
The Simple Intelligent and Modular Programming Language and Environment
Stars: ✭ 120 (-64.91%)
Mutual labels:  simple, portable
mqtt-mock
mqtt压测工具。支持subscribe、publish压测方式,支持模拟客户端连接数。
Stars: ✭ 78 (-77.19%)
Mutual labels:  mqtt, mqtt-client
Iot Harbor
reactor3实现的mqtt库
Stars: ✭ 234 (-31.58%)
Mutual labels:  mqtt, mqtt-client
Android Mqtt Service
A simple MQTT Service that will keep running for the duration of your Android application using the Paho Java MQTT Client.
Stars: ✭ 238 (-30.41%)
Mutual labels:  mqtt, mqtt-client
ArduinoMqtt
MQTT client for Arduino
Stars: ✭ 58 (-83.04%)
Mutual labels:  mqtt, mqtt-client
asyncio-mqtt
Idomatic asyncio wrapper around paho-mqtt
Stars: ✭ 137 (-59.94%)
Mutual labels:  mqtt, mqtt-client


MQTT-C is an MQTT v3.1.1 client written in C. MQTT is a lightweight publisher-subscriber-based messaging protocol that is commonly used in IoT and networking applications where high-latency and low data-rate links are expected. The purpose of MQTT-C is to provide a portable MQTT client, written in C, for embedded systems and PC's alike. MQTT-C does this by providing a transparent Platform Abstraction Layer (PAL) which makes porting to new platforms easy. MQTT-C is completely thread-safe but can also run perfectly fine on single-threaded systems making MQTT-C well-suited for embedded systems and microcontrollers. Finally, MQTT-C is small; there are only two source files totalling less than 2000 lines.

A note from the author

It's been great to hear about all the places MQTT-C is being used! Please don't hesitate to get in touch with me or submit issues on GitHub!

Getting Started

To use MQTT-C you first instantiate a struct mqtt_client and initialize it by calling @ref mqtt_init.

    struct mqtt_client client; /* instantiate the client */
    mqtt_init(&client, ...);   /* initialize the client */

Once your client is initialized you need to connect to an MQTT broker.

    mqtt_connect(&client, ...); /* send a connection request to the broker. */

At this point the client is ready to use! For example, we can subscribe to a topic like so:

    /* subscribe to "toaster/temperature" with a max QoS level of 0 */
    mqtt_subscribe(&client, "toaster/temperature", 0);

And we can publish to a topic like so:

    /* publish coffee temperature with a QoS level of 1 */
    int temperature = 67;
    mqtt_publish(&client, "coffee/temperature", &temperature, sizeof(int), MQTT_PUBLISH_QOS_1);

Those are the basics! From here the examples and API documentation are good places to get started.

Building

There are only two source files that need to be built, mqtt.c and mqtt_pal.c. These files are ANSI C (C89) compatible, and should compile with any C compiler.

Then, simply #include <mqtt.h>.

Alternatively, you can build MQTT-C with CMake or the provided Makefile. These are provided for convenience.

Documentation

Pre-built documentation can be found here: https://liambindle.ca/MQTT-C. Be sure to check out the examples too.

The @ref api documentation contains all the documentation application programmers should need. The @ref pal documentation contains everything you should need to port MQTT-C to a new platform, and the other modules contain documentation for MQTT-C developers.

Testing and Building the Tests

The MQTT-C unit tests use the cmocka unit testing framework. Therefore, cmocka must be installed on your machine to build and run the unit tests. For convenience, a simple "makefile" is included to build the unit tests and examples on UNIX-like machines. The unit tests and examples can be built as follows:

    $ make all

The unit tests and examples will be built in the "bin/" directory. The unit tests can be run like so:

    $ ./bin/tests [address [port]]

Note that the \c address and \c port arguments are both optional to specify the location of the MQTT broker that is to be used for the tests. If no \c address is given then the Mosquitto MQTT Test Server will be used. If no \c port is given, port 1883 will be used.

Portability

MQTT-C provides a transparent platform abstraction layer (PAL) in mqtt_pal.h and mqtt_pal.c. These files declare and implement the types and calls that MQTT-C requires. Refer to @ref pal for the complete documentation of the PAL.

Contributing

Please feel free to submit issues and pull-requests here. When submitting a pull-request please ensure you have fully documented your changes and added the appropriate unit tests.

License

This project is licensed under the MIT License. See the "LICENSE" file for more details.

Authors

MQTT-C was initially developed as a CMPT 434 (Winter Term, 2018) final project at the University of Saskatchewan by:

  • Liam Bindle
  • Demilade Adeoye
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].