migrate away from mqtt String
This commit is contained in:
		
							parent
							
								
									0754af5eea
								
							
						
					
					
						commit
						6df26d63df
					
				
					 2 changed files with 16 additions and 11 deletions
				
			
		|  | @ -45,8 +45,6 @@ Peripheral Initialization Routine | |||
| void user_pre_init() | ||||
| { | ||||
|     nexInit(); | ||||
|     memcpy(AC_LOCK_TOPIC, MQTT_BASE_TOPIC, 20); | ||||
|     strcat(AC_LOCK_TOPIC, "/ac/set/lock"); | ||||
|     memcpy(AC_LOCK_REPORT_TOPIC, MQTT_BASE_TOPIC, 20); | ||||
|     strcat(AC_LOCK_REPORT_TOPIC, "/ac/lock"); | ||||
| } | ||||
|  | @ -250,19 +248,21 @@ void ac_update_lcd() { | |||
|     elcd_sendstop(); | ||||
| } | ||||
| 
 | ||||
| void ac_lock_callback(String topic, String payload) | ||||
| void ac_lock_callback(char* payload) | ||||
| { | ||||
|     Serial.println("INPAYLOAD"); | ||||
|     if (payload.equals("lock")) | ||||
|     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="); | ||||
|         elcd.print(ac_lock ? "2" : "1"); | ||||
|         elcd_sendstop(); | ||||
|     } | ||||
|     else if (payload.equals("unlock")) | ||||
|     else if (!strcmp(payload,"unlock")) | ||||
|     { | ||||
|         Serial.println("unlocking"); | ||||
|         ac_lock = false; | ||||
|         ESPMega_FRAM.write8(AC_LOCK_ADDRESS, ac_lock); | ||||
|         elcd.print("dashboard.pic="); | ||||
|  | @ -273,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.publish(AC_LOCK_REPORT_TOPIC,ac_lock?"lock":"unlock"); | ||||
| } | ||||
| 
 | ||||
| void elcd_sendstop() { | ||||
|  | @ -295,7 +295,7 @@ void pwm_update_lcd() { | |||
| } | ||||
| 
 | ||||
| void mqtt_connected_user_callback() { | ||||
|     mqtt.subscribe(String(AC_LOCK_TOPIC), ac_lock_callback); | ||||
|     mqtt.subscribe(AC_LOCK_TOPIC); | ||||
|     ac_lock_report(); | ||||
| } | ||||
| 
 | ||||
|  | @ -305,5 +305,10 @@ 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); | ||||
|     } | ||||
|          | ||||
| } | ||||
|  | @ -10,7 +10,7 @@ | |||
| #define ESPMEGA_REV "ESPMega PRO R3.3b (CUD)" | ||||
| 
 | ||||
| // Enable Software Module(s)
 | ||||
| //#define ENABLE_INTERNAL_LCD
 | ||||
| //#define ENABLE_INTERNAL_LCD // This will disable PC Communication
 | ||||
| #define ENABLE_IR_MODULE | ||||
| #define ENABLE_CLIMATE_MODULE // Require IR Module
 | ||||
| #define ENABLE_WEBUI | ||||
|  | @ -83,7 +83,7 @@ void cud_light_toggle(); | |||
| bool cud_light_group_state(); | ||||
| void cud_fan_toggle(); | ||||
| bool cud_fan_group_state(); | ||||
| void ac_lock_callback(String topic, String payload); | ||||
| void ac_lock_callback(char* payload); | ||||
| void elcd_sendstop(); | ||||
| void ac_update_lcd(); | ||||
| void pwm_update_lcd(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue