Skip to content

romuloceccon/lightmqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightMQTT

Build Status Documentation

LightMQTT is a MQTT 3.1.1 client library written in pure C and designed to work with both embedded and large systems.

Features

  • Fully asynchronous (no threads)
  • Supports QoS 0, 1 and 2 messages
  • No malloc's. Pure C. (Only dependencies are stddef.h and string.h)
  • Handles large payloads in both directions
  • Minimal memory requirements, even with large payloads (about 2 KB)

Examples

Examples are available under examples.

pingpong

pingpong is a client which echoes a given message back and forth, demonstrating the usage of subscriptions and exchanging of QoS 2 messages. To test it first start the pong side:

examples/pingpong -h 127.0.0.1 -i pong -t ping

The arguments given mean it'll connect with client id pong to a broker running at the default port (1883) on host 127.0.0.1, expecting the other side to be identified as ping. Then start the ping side in another terminal:

examples/pingpong -h 127.0.0.1 -i ping -t pong -m test

Besides having the -i and -t arguments reversed, the second instance also passes a message (test) to be sent to the other side after the initialization is completed (that's required and won't work if given to the first instance).

Instead of a string you can also give the program a file with -f. If the file is larger than the message buffer (message_payload, currently 256 bytes) pingpong will use temporary files, created via mkostemp, to transfer it.

Try pingpong with a large file (tens of megabytes) and a fast, local broker (like ActiveMQ Apollo) and check how little CPU and memory it uses!

reconnect

reconnect maintains a connection to the broker using a given keep alive interval. If the connection is dropped the client reconnects without reinitializing the internal data (i.e. the session state is preserved). For example, to connect to host 127.0.0.1 and send keep alive packets every 5 seconds execute:

examples/reconnect -h 127.0.0.1 -i reconnect -k 5

Contributing

To contribute:

  • Fork the project on Github
  • Checkout a new branch
  • Write one or more tests evidencing the bug or the features you want
  • Make your changes
  • Send a pull request

Or open an issue on Github explaining clearly how to reproduce the bug or the motivation for the feature.

To build the project you need Autoconf Archive and Check. On Linux Ubuntu/Debian/Mint they are available via apt:

$ apt install autoconf-archive check

Then execute:

$ autoreconf --install
$ mkdir build && cd build
$ ../configure
$ make && make check

License

See LICENSE.

About

MQTT 3.1.1 client library written in pure C, fully asynchronous, supporting QoS 0, 1 and 2 messages and large payloads

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages