MQTT
This commit is contained in:
@@ -15,13 +15,25 @@ RUN set -eux; \
|
|||||||
libmicrohttpd-dev \
|
libmicrohttpd-dev \
|
||||||
libcurl4-openssl-dev \
|
libcurl4-openssl-dev \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
prometheus-cpp-dev
|
prometheus-cpp-dev \
|
||||||
|
nlohmann-json3-dev
|
||||||
|
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
libpaho-mqtt-dev
|
libpaho-mqtt-dev
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
git clone https://github.com/eclipse/paho.mqtt.cpp.git; \
|
||||||
|
cd paho.mqtt.cpp; \
|
||||||
|
git submodule init; \
|
||||||
|
git submodule update; \
|
||||||
|
mkdir build && cd build; \
|
||||||
|
cmake -DPAHO_WITH_MQTT_C=ON ..; \
|
||||||
|
cmake --build . --target install; \
|
||||||
|
ldconfig;
|
||||||
|
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ find_library(NCURSESW_LIB ncursesw REQUIRED)
|
|||||||
find_library(RABBITMQ_LIB rabbitmq REQUIRED)
|
find_library(RABBITMQ_LIB rabbitmq REQUIRED)
|
||||||
|
|
||||||
# Paho MQTT C client
|
# Paho MQTT C client
|
||||||
|
find_library(PAHO_MQTTPP3_LIB paho-mqttpp3 REQUIRED)
|
||||||
find_library(PAHO_MQTT3C_LIB paho-mqtt3c REQUIRED)
|
find_library(PAHO_MQTT3C_LIB paho-mqtt3c REQUIRED)
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
@@ -53,5 +54,6 @@ target_link_libraries(geii_exporter
|
|||||||
${Z_LIB}
|
${Z_LIB}
|
||||||
${NCURSESW_LIB}
|
${NCURSESW_LIB}
|
||||||
${RABBITMQ_LIB}
|
${RABBITMQ_LIB}
|
||||||
${PAHO_MQTT3C_LIB}
|
${PAHO_MQTT3C_LIB} # dépendance C
|
||||||
|
${PAHO_MQTTPP3_LIB} # lib C++
|
||||||
)
|
)
|
||||||
|
|||||||
17
main.cpp
17
main.cpp
@@ -12,6 +12,23 @@
|
|||||||
#include <prometheus/registry.h>
|
#include <prometheus/registry.h>
|
||||||
#include <prometheus/exposer.h>
|
#include <prometheus/exposer.h>
|
||||||
|
|
||||||
|
#include <curl/curl.h>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <atomic>
|
||||||
|
#include <queue>
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <csignal>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstring>
|
||||||
|
#undef timeout
|
||||||
|
#include "mqtt/async_client.h"
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
// Constantes de fonctionnement
|
// Constantes de fonctionnement
|
||||||
#define LEVEL_MIN 2
|
#define LEVEL_MIN 2
|
||||||
#define FLOW_PER_PUMP 150
|
#define FLOW_PER_PUMP 150
|
||||||
|
|||||||
Reference in New Issue
Block a user