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