2
0
This commit is contained in:
2026-01-14 23:52:06 +01:00
parent 705b357f34
commit 729171bafe
5 changed files with 247 additions and 183 deletions

View File

@@ -111,17 +111,19 @@ public:
if (j.empty())
return;
if (j.contains("marche"))
if (j.contains("marche")) {
marche = j["marche"].get<int>() != 0;
}
if (j.contains("arret"))
if (j.contains("arret")) {
arret = j["arret"].get<int>() != 0;
}
if (j.contains("reset"))
if (j.contains("reset")) {
reset = j["reset"].get<int>() != 0;
}
if (j.contains("b0") && j["b0"].is_number())
{
if (j.contains("b0") && j["b0"].is_number()) {
bouton[0] = b0 = j["b0"].get<int>();
}
if (j.contains("b1") && j["b1"].is_number())
@@ -228,32 +230,22 @@ void mqtt_open(mqtt::async_client *client)
void mqtt_send(mqtt::async_client *client)
{
json obj = {
{"s0", s0},
{"s1", s1},
{"s2", s2},
{"s3", s3},
{"s4", s4},
{"s5", s5},
{"s6", s6},
{"s7", s7},
{"m0", m0},
{"m1", m1},
{"m2", m2},
{"m3", m3},
{"a0", a0},
{"a1", a1},
{"a2", a2},
{"a3", a3},
{"a4", a4},
{"a5", a5},
{"a6", a6},
{"a7", a7},
{"s8", s8},
{"s9", s9},
{"s10", s10},
{"s11", s11},
};
obj["c"] = json::array();
for (int i = 0; i < 8; ++i) {
obj["actionneurs"].push_back(actionneur[i]);
}
obj["sorties"] = json::array();
for (int i = 0; i < 12; ++i) {
obj["sorties"].push_back(sortie[i]);
}
std::string payload = obj.dump();
auto msg = mqtt::make_message("geii/out", payload);
msg->set_qos(1);