RESET
This commit is contained in:
37
autom.cpp
37
autom.cpp
@@ -88,6 +88,7 @@ const int CYCLE_MS = 100;
|
||||
|
||||
mqtt::async_client client(ADDRESS, CLIENTID);
|
||||
|
||||
void mqtt_start(mqtt::async_client *client);
|
||||
void mqtt_send(mqtt::async_client *client);
|
||||
|
||||
// Réception des messages MQTT
|
||||
@@ -111,10 +112,16 @@ public:
|
||||
if (j.empty())
|
||||
return;
|
||||
|
||||
if (j.contains("reset"))
|
||||
{
|
||||
reset = j["reset"].get<int>() != 0;
|
||||
}
|
||||
|
||||
if (j.contains("marche")) {
|
||||
marche = j["marche"].get<int>() != 0;
|
||||
}
|
||||
|
||||
|
||||
if (j.contains("arret")) {
|
||||
arret = j["arret"].get<int>() != 0;
|
||||
}
|
||||
@@ -193,26 +200,19 @@ public:
|
||||
v0 = j["v0"].get<int>();
|
||||
|
||||
if (j.contains("p0") && j["p0"].is_number()) {
|
||||
p0 = j["p0"].get<int>();
|
||||
niveau[0] = j["p0"].get<int>();
|
||||
niveau[0] = p0 = j["p0"].get<int>();
|
||||
}
|
||||
|
||||
if (j.contains("p1") && j["p1"].is_number())
|
||||
{
|
||||
p1 = j["p1"].get<int>();
|
||||
niveau[1] = j["p1"].get<int>();
|
||||
if (j.contains("p1") && j["p1"].is_number()) {
|
||||
niveau[1] = p1 = j["p1"].get<int>();
|
||||
}
|
||||
|
||||
if (j.contains("p2") && j["p2"].is_number())
|
||||
{
|
||||
p2 = j["p2"].get<int>();
|
||||
niveau[2] = j["p2"].get<int>();
|
||||
if (j.contains("p2") && j["p2"].is_number()) {
|
||||
niveau[2] = p2 = j["p2"].get<int>();
|
||||
}
|
||||
|
||||
if (j.contains("p3") && j["p3"].is_number())
|
||||
{
|
||||
p3 = j["p3"].get<int>();
|
||||
niveau[3] = j["p3"].get<int>();
|
||||
if (j.contains("p3") && j["p3"].is_number()) {
|
||||
niveau[3] = p3 = j["p3"].get<int>();
|
||||
}
|
||||
|
||||
process();
|
||||
@@ -229,7 +229,6 @@ callback cb;
|
||||
|
||||
void mqtt_open(mqtt::async_client *client)
|
||||
{
|
||||
|
||||
client->set_callback(cb);
|
||||
mqtt::connect_options connOpts;
|
||||
connOpts.set_clean_session(true);
|
||||
@@ -240,6 +239,7 @@ void mqtt_open(mqtt::async_client *client)
|
||||
client->connect(connOpts)->wait();
|
||||
client->start_consuming();
|
||||
client->subscribe(TOPIC, QOS)->wait();
|
||||
mqtt_start(client);
|
||||
}
|
||||
catch (const mqtt::exception &exc)
|
||||
{
|
||||
@@ -272,6 +272,13 @@ void mqtt_send(mqtt::async_client *client)
|
||||
client->publish(msg);
|
||||
}
|
||||
|
||||
void mqtt_start(mqtt::async_client *client)
|
||||
{
|
||||
auto msg = mqtt::make_message("geii/out", "reset");
|
||||
msg->set_qos(2);
|
||||
client->publish(msg);
|
||||
}
|
||||
|
||||
void mqtt_close()
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user