2026-01-09 09:25:37 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <locale.h>
|
2026-01-09 07:46:52 +01:00
|
|
|
#include <array>
|
|
|
|
|
#include "main.hpp"
|
2026-01-09 09:25:37 +01:00
|
|
|
#include "AutomForArduino.cpp"
|
|
|
|
|
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <queue>
|
|
|
|
|
#include <mutex>
|
|
|
|
|
#include <condition_variable>
|
|
|
|
|
#include <csignal>
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#undef timeout
|
|
|
|
|
#include "mqtt/async_client.h"
|
|
|
|
|
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
using json = nlohmann::json;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-01-09 07:46:52 +01:00
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2026-01-09 09:25:37 +01:00
|
|
|
mqtt::async_client client(ADDRESS, CLIENTID);
|
|
|
|
|
callback cb;
|
|
|
|
|
client.set_callback(cb);
|
|
|
|
|
|
|
|
|
|
mqtt::connect_options connOpts;
|
|
|
|
|
connOpts.set_clean_session(true);
|
|
|
|
|
connOpts.set_user_name("admin");
|
|
|
|
|
connOpts.set_password("geii2025");
|
|
|
|
|
try {
|
|
|
|
|
client.connect(connOpts)->wait();
|
|
|
|
|
client.start_consuming();
|
|
|
|
|
client.subscribe(TOPIC, QOS)->wait();
|
|
|
|
|
} catch (const mqtt::exception &exc) {
|
|
|
|
|
std::cerr << "Erreur MQTT: " << exc.what() << "\n";
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2026-01-09 07:46:52 +01:00
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2026-01-09 09:52:51 +01:00
|
|
|
s0 = b0;
|
|
|
|
|
s1 = b1;
|
|
|
|
|
s2 = b2;
|
|
|
|
|
s3 = b3;
|
|
|
|
|
s4 = b4;
|
|
|
|
|
s5 = b5;
|
|
|
|
|
s6 = b6;
|
|
|
|
|
s7 = b7;
|
|
|
|
|
|
2026-01-09 09:25:37 +01:00
|
|
|
ProcessMQTT(&client);
|
|
|
|
|
|
|
|
|
|
usleep(100000);
|
2026-01-09 07:46:52 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-09 09:25:37 +01:00
|
|
|
try {
|
|
|
|
|
client.unsubscribe(TOPIC)->wait();
|
|
|
|
|
client.stop_consuming();
|
|
|
|
|
client.disconnect()->wait();
|
|
|
|
|
} catch(const mqtt::exception &exc){
|
|
|
|
|
std::cerr << "Erreur déconnexion MQTT: " << exc.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::cout << "Fin du programme" << std::endl;
|
2026-01-09 07:46:52 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|