1.What is MQTT
MQTT (Message Queuing Telemetry Transport, Message Queuing Telemetry Transport Protocol) is a "lightweight" communication protocol based on the publish/subscribe (publish/subscribe) model. The protocol is built on the TCP/IP protocol.
Advantages : Provide real-time and reliable messaging services for connecting remote devices with very little code and limited bandwidth.
Features : Client-server- based message publishing-subscription message transfer protocol
The publish-subscribe messaging model used by MQTT provides a one-to-many message distribution mechanism to achieve decoupling from applications. This is a messaging mode in which messages are not sent directly from the sender to the receiver (i.e. point-to-point), but are distributed by the MQTT server (or MQTT Broker).
2. Install MQTT under linux
2.1 Install doxygen
Building documentation requires doxygen to be installed
sudo apt-get install doxygen graphviz
2.2 Generate and install PahoC library
Before building the C++ library, first build and install the Paho C library (if you haven't already). Note that this version of the C++ library requires Paho C v1.3.8 or higher.
git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
git checkout v1.3.8
cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_BUILD_STATIC=ON -DPAHO_WITH_SSL=ON -DPAHO_HIGH_PERFORMANCE=ON
sudo cmake --build build/ --target install
sudo ldconfig
2.3 Generate and install Paho C++ library
git clone https://github.com/eclipse/paho.mqtt.cpp
cd paho.mqtt.cpp
cmake -Bbuild -H. -DPAHO_BUILD_STATIC=ON -DPAHO_BUILD_DOCUMENTATION=TRUE -DPAHO_BUILD_SAMPLES=TRUE
sudo cmake --build build/ --target install
sudo ldconfig