fix lock bug

This commit is contained in:
Siwat Sirichai 2023-11-12 22:39:22 +07:00
parent 497acec11b
commit 2014095833
2 changed files with 3 additions and 10 deletions

View File

@ -541,7 +541,7 @@ void mqtt_callback(char *topic, byte *payload, unsigned int length)
{ {
ac_state_callback(topic, topic_length, payload_nt, 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() void thread_initialization()

View File

@ -47,6 +47,8 @@ void user_pre_init()
nexInit(); nexInit();
memcpy(AC_LOCK_REPORT_TOPIC, MQTT_BASE_TOPIC, 20); memcpy(AC_LOCK_REPORT_TOPIC, MQTT_BASE_TOPIC, 20);
strcat(AC_LOCK_REPORT_TOPIC, "/ac/lock"); 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) void temp_up_btn_cb(void *comp)
{ {
Serial.println("UPCB");
if (!ac_lock) if (!ac_lock)
{ {
ac_set_state(ac_get_mode(), ac_get_temperature() + 1, ac_get_fan_speed()); ac_set_state(ac_get_mode(), ac_get_temperature() + 1, ac_get_fan_speed());
} }
Serial.println("UPCBEND");
} }
void temp_down_btn_cb(void *comp) void temp_down_btn_cb(void *comp)
{ {
Serial.println("DOWNCB");
if (!ac_lock) if (!ac_lock)
{ {
ac_set_state(ac_get_mode(), ac_get_temperature() - 1, ac_get_fan_speed()); ac_set_state(ac_get_mode(), ac_get_temperature() - 1, ac_get_fan_speed());
} }
Serial.println("DOWNCBEND");
} }
void mode_cool_btn_cb(void *comp) void mode_cool_btn_cb(void *comp)
{ {
@ -250,10 +248,8 @@ void ac_update_lcd() {
void ac_lock_callback(char* payload) void ac_lock_callback(char* payload)
{ {
Serial.println(payload);
if (!strcmp(payload,"lock")) if (!strcmp(payload,"lock"))
{ {
Serial.println("locking");
ac_lock = true; ac_lock = true;
ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock); ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock);
elcd.print("dashboard.pic="); elcd.print("dashboard.pic=");
@ -262,7 +258,6 @@ void ac_lock_callback(char* payload)
} }
else if (!strcmp(payload,"unlock")) else if (!strcmp(payload,"unlock"))
{ {
Serial.println("unlocking");
ac_lock = false; ac_lock = false;
ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock); ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock);
elcd.print("dashboard.pic="); 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) { 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)) { if(!strcmp(topic,AC_LOCK_TOPIC)) {
Serial.println("AC LOCK TOPIC TRIG");
ac_lock_callback(payload); ac_lock_callback(payload);
} }