From b06f65c0fcb44b26ddb6370798c5562d269c8e4f Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Tue, 3 Oct 2023 02:21:27 +0700 Subject: [PATCH] add lock state reporting --- src/user_code.cpp | 6 +++++- src/user_code.hpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/user_code.cpp b/src/user_code.cpp index c719717..f1fc3a8 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -63,7 +63,6 @@ void user_init() elcd.print("dashboard.pic="); elcd.print(ac_lock ? "2" : "1"); elcd_sendstop(); - mqtt.subscribe(AC_LOCK_TOPIC, ac_lock_callback); lt_bt.attachPop(lt_btn_cb, <_bt); fan_bt.attachPop(fan_btn_cb, &fan_bt); puri_bt.attachPop(puri_btn_cb, &puri_bt); @@ -292,4 +291,9 @@ void pwm_update_lcd() { elcd.print("puri_bt.pic="); elcd.print(pwm_get_state(AIR_PURIFIER_PIN)?8:7); elcd_sendstop(); +} + +void mqtt_connected_user_callback() { + mqtt.subscribe(AC_LOCK_TOPIC, ac_lock_callback); + ac_lock_report(); } \ No newline at end of file diff --git a/src/user_code.hpp b/src/user_code.hpp index db96e76..201ed80 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -70,6 +70,7 @@ void ac_lock_callback(String topic, String payload); void elcd_sendstop(); void ac_update_lcd(); void pwm_update_lcd(); +void mqtt_connected_user_callback(); // ESPMega IoT Core Build-in Functions extern void pwm_set_state(int id, int state);