Compare commits
	
		
			4 Commits
		
	
	
		
			v1.4
			...
			cf32071ee0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| cf32071ee0 | |||
| e4572cc31a | |||
| 57d0bc6481 | |||
| 1e745724e4 | 
							
								
								
									
										16
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -42,7 +42,7 @@ void checkMqttAvailability(void);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void mqttPublish(const char *topic, const char *payload, bool retained);
 | 
					void mqttPublish(const char *topic, const char *payload, bool retained);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const String firmware{"1.4"};
 | 
					const String firmware{"1.42"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
String espnowNetName{"DEFAULT"};
 | 
					String espnowNetName{"DEFAULT"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -193,12 +193,12 @@ void setup()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void loop()
 | 
					void loop()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (mqttAvailabilityCheckTimerSemaphore)
 | 
					 | 
				
			||||||
        checkMqttAvailability();
 | 
					 | 
				
			||||||
    if (keepAliveMessageTimerSemaphore)
 | 
					    if (keepAliveMessageTimerSemaphore)
 | 
				
			||||||
        sendKeepAliveMessage();
 | 
					        sendKeepAliveMessage();
 | 
				
			||||||
    if (attributesMessageTimerSemaphore)
 | 
					    if (attributesMessageTimerSemaphore)
 | 
				
			||||||
        sendAttributesMessage();
 | 
					        sendAttributesMessage();
 | 
				
			||||||
 | 
					    if (mqttAvailabilityCheckTimerSemaphore)
 | 
				
			||||||
 | 
					        checkMqttAvailability();
 | 
				
			||||||
    if (workMode == ESP_NOW_WIFI)
 | 
					    if (workMode == ESP_NOW_WIFI)
 | 
				
			||||||
        mqttWifiClient.loop();
 | 
					        mqttWifiClient.loop();
 | 
				
			||||||
    if (workMode == ESP_NOW_LAN)
 | 
					    if (workMode == ESP_NOW_LAN)
 | 
				
			||||||
@@ -405,8 +405,6 @@ void onMqttMessage(char *topic, byte *payload, unsigned int length)
 | 
				
			|||||||
    StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
 | 
					    StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
 | 
				
			||||||
    if (message == "update" || message == "restart")
 | 
					    if (message == "update" || message == "restart")
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        mqttPublish(topic, "", true);
 | 
					 | 
				
			||||||
        mqttPublish((String(topic) + "/status").c_str(), "offline", true);
 | 
					 | 
				
			||||||
        if (mac == myNet.getNodeMac() && message == "restart")
 | 
					        if (mac == myNet.getNodeMac() && message == "restart")
 | 
				
			||||||
            ESP.restart();
 | 
					            ESP.restart();
 | 
				
			||||||
        flag = true;
 | 
					        flag = true;
 | 
				
			||||||
@@ -437,9 +435,7 @@ void onMqttMessage(char *topic, byte *payload, unsigned int length)
 | 
				
			|||||||
            outgoingData.payloadsType = ENPT_RESTART;
 | 
					            outgoingData.payloadsType = ENPT_RESTART;
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            outgoingData.payloadsType = message == "update" ? ENPT_UPDATE : ENPT_SET;
 | 
					            outgoingData.payloadsType = message == "update" ? ENPT_UPDATE : ENPT_SET;
 | 
				
			||||||
        char buffer[sizeof(esp_now_payload_data_t::message)]{0};
 | 
					        serializeJsonPretty(json, outgoingData.message);
 | 
				
			||||||
        serializeJsonPretty(json, buffer);
 | 
					 | 
				
			||||||
        memcpy(&outgoingData.message, &buffer, sizeof(esp_now_payload_data_t::message));
 | 
					 | 
				
			||||||
        char temp[sizeof(esp_now_payload_data_t)]{0};
 | 
					        char temp[sizeof(esp_now_payload_data_t)]{0};
 | 
				
			||||||
        memcpy(&temp, &outgoingData, sizeof(esp_now_payload_data_t));
 | 
					        memcpy(&temp, &outgoingData, sizeof(esp_now_payload_data_t));
 | 
				
			||||||
        uint8_t target[6];
 | 
					        uint8_t target[6];
 | 
				
			||||||
@@ -683,6 +679,8 @@ void checkMqttAvailability()
 | 
				
			|||||||
                    mqttWifiClient.subscribe((topicPrefix + "/espnow_led/#").c_str());
 | 
					                    mqttWifiClient.subscribe((topicPrefix + "/espnow_led/#").c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    sendConfigMessage();
 | 
					                    sendConfigMessage();
 | 
				
			||||||
 | 
					                    sendAttributesMessage();
 | 
				
			||||||
 | 
					                    sendKeepAliveMessage();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -700,6 +698,8 @@ void checkMqttAvailability()
 | 
				
			|||||||
                    mqttEthClient.subscribe((topicPrefix + "/espnow_led/#").c_str());
 | 
					                    mqttEthClient.subscribe((topicPrefix + "/espnow_led/#").c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    sendConfigMessage();
 | 
					                    sendConfigMessage();
 | 
				
			||||||
 | 
					                    sendAttributesMessage();
 | 
				
			||||||
 | 
					                    sendKeepAliveMessage();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user