Home

Awesome

license

中文说明

mqttclient

A high-performance, high-stability, cross-platform MQTT client

A high-performance, high-stability, cross-platform MQTT client, developed based on the socket API, can be used on embedded devices (FreeRTOS/LiteOS/RT-Thread/TencentOS tiny), Linux, Windows, Mac, and has a very concise The API interface realizes the quality of service of QOS2 with very few resources, and seamlessly connects the mbedtls encryption library.

Advantage:

Online code generation tool

This project has a code generation tool that only requires online configuration to generate code, which is extremely simple and easy to use. The code generation tool address is: https://jiejietop.gitee.io/mqtt/index.html

Online code generation tool

occupied resource size

A total of 10857 bytes of ROM, and the overhead of RAM is almost only dependent on dynamic memory. Without using TLS encrypted transmission, the communication dynamic memory that maintains the QOS0 quality of service level requires only about 3694 bytes. Including 1024 read buffer + 1024 write buffer + 1024 internal thread stack size, compared with other MQTT clients, mqttclient requires very little RAM resource overhead.

CodeRO DataRW DataZI DataObject Name
711879100mqttclient.o
546000mqttconnectclient.o
212000mqttdeserializepublish.o
476040mqttpacket.o
236000mqttserializepublish.o
310000mqttsubscribeclient.o
38000mqttunsubscribeclient.o
56000nettype_tcp.o
62000network.o
24000platform_memory.o
40000platform_mutex.o
344000platform_net_socket.o
94000platform_thread.o
70000platform_timer.o
246040random.o
62000mqtt_list.o
-----
1006679180total

Overall framework

Has a very clear layered framework.

Overall Frame

Supported platforms

At present, Linux, TencentOS tiny, FreeRTOS, RT-Thread platforms have been implemented (software package is named kawaii-mqtt`), in addition to TencentOS tiny AT framework can also be used, and the stability is excellent!

PlatformCode Location
Linuxhttps://github.com/jiejieTop/mqttclient
TencentOS tinyhttps://github.com/Tencent/TencentOS-tiny/tree/master/board/Fire_STM32F429
TencentOS tiny AT frameworkhttps://github.com/jiejieTop/gokit3-board-mqttclient
RT-Threadhttps://github.com/jiejieTop/kawaii-mqtt
FreeRTOShttps://github.com/jiejieTop/freertos-mqttclient

Version

Release VersionDescription
[v1.0.0]Initial release, complete basic framework and stability verification
[v1.0.1]Fix the logical processing when actively disconnecting from the server
[v1.0.2]Add a new feature-interceptor, fix some small bugs
[v1.0.3]To avoid global pollution, modify the naming of log and list related functions
[v1.0.4]Network structure and mbedtls data channel readjusted
[v1.1.0]A larger version of the update, refactoring part of the code, optimizing the logic of MQTT processing, improving the overall stability, supporting multiple clients, supporting setting the will, optimizing the API interface, and adding multiple cloud platforms Test code and documentation, add online code generation tool, online cutting configuration tool

question

Welcome to submit issues and bug reports in the form of GitHub Issues

Copyright and License

mqttclient follows the Apache License v2.0 open source agreement. Encourage code sharing and respect the copyright of the original author. You can freely use and modify the source code, or you can publish the modified code as open source or closed source software.

Test and use under Linux platform

Install cmake:

    sudo apt-get install cmake g++

test program

Test PlatformLocation
emqx (my privately deployed server)./test/emqx/test.c
Baidu Tiangong./test/baidu/test.c
onenet./test/onenet/test.c
Alibaba Cloud Internet of Things./test/ali/test.c

Compile & Run

    ./build.sh

After running the build.sh script, the executable files emqx, baidu, onenet and other platforms will be generated under the ./build/bin/ directory Executable programs can be run directly.

    ./build/bin/emqx

Compile into a dynamic library libmqttclient.so

    ./make-libmqttclient.sh

After running the make-libmqttclient.sh script, a dynamic library file libmqttclient.so will be generated in the ./libmqttclient/lib directory, and installed into the system’s /usr/lib directory, the relevant header files have been Copy to the ./libmqttclient/include directory and copy it to your project. You only need to link the dynamic library when compiling the application. -lmqttclient -lpthread, the configuration file of the dynamic library is based on ./test/mqtt_config.h configuration.

If you are using a cross-compiler, you should export the corresponding environment variables according to the compiler you are using (the cross-compiler used here is arm-linux-gnueabihf-gcc), and you must also set the dynamic library file libmqttclient .so is copied to the /usr/lib directory of your embedded system:

    export CROSS_COMPILE=arm-linux-gnueabihf-

If you need to uninstall libmqttclient.so, execute the following command:

    ./make-libmqttclient.sh remove

Learn more

Please see the documentation: