From 2014095833cddc7a29a2be0863b52bf1d9eea646 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 12 Nov 2023 22:39:22 +0700 Subject: [PATCH] fix lock bug --- src/espmega_iot_core.cpp | 2 +- src/user_code.cpp | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/espmega_iot_core.cpp b/src/espmega_iot_core.cpp index 587adad..02766af 100644 --- a/src/espmega_iot_core.cpp +++ b/src/espmega_iot_core.cpp @@ -541,7 +541,7 @@ void mqtt_callback(char *topic, byte *payload, unsigned int length) { ac_state_callback(topic, topic_length, payload_nt, length); } - user_mqtt_callback(topic_trim, topic_length, payload_nt, length); + user_mqtt_callback(topic, topic_length, payload_nt, length); } void thread_initialization() diff --git a/src/user_code.cpp b/src/user_code.cpp index b1159e7..d0ee8f7 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -47,6 +47,8 @@ void user_pre_init() nexInit(); memcpy(AC_LOCK_REPORT_TOPIC, MQTT_BASE_TOPIC, 20); strcat(AC_LOCK_REPORT_TOPIC, "/ac/lock"); + memcpy(AC_LOCK_TOPIC, MQTT_BASE_TOPIC, 20); + strcat(AC_LOCK_TOPIC, "/ac/set/lock"); } /* @@ -126,21 +128,17 @@ void puri_btn_cb(void *comp) } void temp_up_btn_cb(void *comp) { - Serial.println("UPCB"); if (!ac_lock) { ac_set_state(ac_get_mode(), ac_get_temperature() + 1, ac_get_fan_speed()); } - Serial.println("UPCBEND"); } void temp_down_btn_cb(void *comp) { - Serial.println("DOWNCB"); if (!ac_lock) { ac_set_state(ac_get_mode(), ac_get_temperature() - 1, ac_get_fan_speed()); } - Serial.println("DOWNCBEND"); } void mode_cool_btn_cb(void *comp) { @@ -250,10 +248,8 @@ void ac_update_lcd() { void ac_lock_callback(char* payload) { - Serial.println(payload); if (!strcmp(payload,"lock")) { - Serial.println("locking"); ac_lock = true; ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock); elcd.print("dashboard.pic="); @@ -262,7 +258,6 @@ void ac_lock_callback(char* payload) } else if (!strcmp(payload,"unlock")) { - Serial.println("unlocking"); ac_lock = false; ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock); elcd.print("dashboard.pic="); @@ -305,9 +300,7 @@ void user_state_request_callback() { } void user_mqtt_callback(char* topic, uint8_t topic_length, char* payload, unsigned int payload_length) { - Serial.println("USERMQTTTRIG"); if(!strcmp(topic,AC_LOCK_TOPIC)) { - Serial.println("AC LOCK TOPIC TRIG"); ac_lock_callback(payload); }