Skip to content

Simple clients of a publisher and a subscriber based on libmosquitto

License

Notifications You must be signed in to change notification settings

airgalss/mqtt-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

This example, based on the libmosquitto library and implemented in the C language, demonstrates the process of communication between an MQTT publisher and an MQTT subscriber.

In this scenario, a simulated terminal device acts as an MQTT publisher, reporting the collected data. Subsequently, the central station acts as an MQTT subscriber, subscribing to the topic of this message. Upon successfully receiving the reported data, it notifies the simulated terminal device.

local deploy

  1. Clone this project and its submodules
git clone --recurse-submodule https://github.com/airgalss/mqtt-example

Or:

git clone https://github.com/airgalss/mqtt-example
git submodule update --init
  1. Install and start MQTT broker.
sudo apt install mosquitto
  1. Install dependency, which usually is installed default on most distros.
sudo apt install libssl-dev
  1. Compile, default dynamic linking.
make

Otherwise, you can compile with static linking

make static
  1. Change directory to the location of the executable file.
cd src
  1. Firstly run as a MQTT subscriber.
./subscriber
  1. Then open a new tab and run as a MQTT publisher.
./publisher

docker deploy

  1. Download docker-compose and deploy it with just one command
docker-compose up

License

MIT license

About

Simple clients of a publisher and a subscriber based on libmosquitto

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published