Update user_code.cpp
This commit is contained in:
parent
b22d3bc8a4
commit
4ebafa7cb7
|
@ -55,7 +55,7 @@ void user_init()
|
|||
elcd.print("page dashboard");
|
||||
elcd_sendstop();
|
||||
memcpy(AC_LOCK_TOPIC, MQTT_BASE_TOPIC, 20);
|
||||
strcat(AC_LOCK_TOPIC, "/ac/lock/set");
|
||||
strcat(AC_LOCK_TOPIC, "/ac/set/lock");
|
||||
memcpy(AC_LOCK_REPORT_TOPIC, MQTT_BASE_TOPIC, 20);
|
||||
strcat(AC_LOCK_REPORT_TOPIC, "/ac/lock");
|
||||
ac_lock = ESPMega_FRAM.read8(AC_LOCK_ADDRESS);
|
||||
|
@ -252,6 +252,7 @@ void ac_update_lcd() {
|
|||
|
||||
void ac_lock_callback(String topic, String payload)
|
||||
{
|
||||
Serial.println("INPAYLOAD");
|
||||
if (payload.equals("lock"))
|
||||
{
|
||||
ac_lock = true;
|
||||
|
@ -272,7 +273,7 @@ void ac_lock_callback(String topic, String payload)
|
|||
}
|
||||
|
||||
void ac_lock_report() {
|
||||
mqtt_client.publish(AC_LOCK_REPORT_TOPIC,ac_lock?"lock":"unlock");
|
||||
//mqtt_client.publish(AC_LOCK_REPORT_TOPIC,ac_lock?"lock":"unlock");
|
||||
}
|
||||
|
||||
void elcd_sendstop() {
|
||||
|
@ -294,7 +295,8 @@ void pwm_update_lcd() {
|
|||
}
|
||||
|
||||
void mqtt_connected_user_callback() {
|
||||
mqtt.subscribe(AC_LOCK_TOPIC, ac_lock_callback);
|
||||
Serial.println("User Subscribing");
|
||||
mqtt.subscribe(String(AC_LOCK_TOPIC), ac_lock_callback);
|
||||
ac_lock_report();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue