Change bool to int

This commit is contained in:
2024-12-30 12:39:24 +03:00
parent a453adb1af
commit 7b20c656a9

View File

@@ -176,10 +176,10 @@ void onMqttConnect(bool sessionPresent) {
Serial.println("Connected to MQTT.");
Serial.print("Session present: ");
Serial.println(sessionPresent);
mqttClient.publish(TOPIC"roz1/on1", 1, false, stat1 == 0 ? "false" : "true");
mqttClient.publish(TOPIC"roz1/on1_set", 1, false, stat1 == 0 ? "false" : "true");
mqttClient.publish(TOPIC"roz1/on2", 1, false, stat2 == 0 ? "false" : "true");
mqttClient.publish(TOPIC"roz1/on2_set", 1, false, stat2 == 0 ? "false" : "true");
mqttClient.publish(TOPIC"roz1/on1", 1, false, stat1 == 0 ? "0" : "1");
mqttClient.publish(TOPIC"roz1/on1_set", 1, false, stat1 == 0 ? "0" : "1");
mqttClient.publish(TOPIC"roz1/on2", 1, false, stat2 == 0 ? "0" : "1");
mqttClient.publish(TOPIC"roz1/on2_set", 1, false, stat2 == 0 ? "0" : "1");
mqttClient.subscribe(TOPIC"roz1/on1_set", 1);
mqttClient.subscribe(TOPIC"roz1/on2_set", 1);
nSec = 59;
@@ -202,7 +202,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
Serial.println(topic);
Serial.println(pl);
if(strcmp(topic, TOPIC"roz1/on1_set") == 0){
if(strcmp(pl, "true") == 0){
if(strcmp(pl, "1") == 0){
stat1 = 1;
}
else{
@@ -211,7 +211,7 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
return;
}
if(strcmp(topic, TOPIC"roz1/on2_set") == 0){
if(strcmp(pl, "true") == 0){
if(strcmp(pl, "1") == 0){
stat2 = 1;
}
else{