add: mqtt status client
This commit is contained in:
parent
1d1ae61310
commit
679175f1a9
11 changed files with 119 additions and 40 deletions
src/handlers
|
@ -35,12 +35,16 @@ handler_loop(struct mg_connection *c_mqtt)
|
|||
}
|
||||
|
||||
if(relay->is_on != is_active)
|
||||
{
|
||||
relay->sent_to_broker = 0;
|
||||
}
|
||||
if(!relay->sent_to_broker && c_mqtt)
|
||||
{
|
||||
sprintf(topic_buf, "controller/%s/relay/%u", controller_uid, i);
|
||||
sprintf(payload_buf, "%u", is_active);
|
||||
mg_mqtt_publish(c_mqtt, topic_buf, 0, MG_MQTT_QOS(0), payload_buf, strlen(payload_buf));
|
||||
relay->sent_to_broker = 1;
|
||||
}
|
||||
|
||||
relay->is_on = is_active;
|
||||
|
||||
if(global_config.relay_configs[i].inverted)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue