4 Commits
v1.4 ... v1.42

Author SHA1 Message Date
cf32071ee0 Version 1.42
Fixed bug with ESP-NOW devices not getting restart or update command.
Minor main code refactoring.
2023-02-13 19:04:46 +03:00
e4572cc31a Version 1.42
Fixed bug with ESP-NOW devices not getting restart or update command.
Minor main code refactoring.
2023-02-13 18:56:39 +03:00
57d0bc6481 Version 1.42
Fixed bug with ESP-NOW devices not getting restart or update command.
Minor main code refactoring.
2023-02-13 18:53:41 +03:00
1e745724e4 Version 1.41
Minor changes.
2023-02-12 18:37:12 +03:00

View File

@ -42,7 +42,7 @@ void checkMqttAvailability(void);
void mqttPublish(const char *topic, const char *payload, bool retained);
const String firmware{"1.4"};
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();
}
}
}