Minor changes
This commit is contained in:
parent
af8cc16675
commit
53464acb22
10
src/main.cpp
10
src/main.cpp
@ -172,7 +172,7 @@ void onBroadcastReceiving(const char *data, const uint8_t *sender)
|
|||||||
if (myNet.macToString(gatewayMAC) == myNet.macToString(sender) && incomingData.payloadsType == ENPT_KEEP_ALIVE)
|
if (myNet.macToString(gatewayMAC) == myNet.macToString(sender) && incomingData.payloadsType == ENPT_KEEP_ALIVE)
|
||||||
{
|
{
|
||||||
isGatewayAvailable = true;
|
isGatewayAvailable = true;
|
||||||
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
|
DynamicJsonDocument json(sizeof(esp_now_payload_data_t::message));
|
||||||
deserializeJson(json, incomingData.message);
|
deserializeJson(json, incomingData.message);
|
||||||
bool temp = json["MQTT"] == "online" ? true : false;
|
bool temp = json["MQTT"] == "online" ? true : false;
|
||||||
if (wasMqttAvailable != temp)
|
if (wasMqttAvailable != temp)
|
||||||
@ -201,7 +201,7 @@ void onUnicastReceiving(const char *data, const uint8_t *sender)
|
|||||||
memcpy(&incomingData, data, sizeof(esp_now_payload_data_t));
|
memcpy(&incomingData, data, sizeof(esp_now_payload_data_t));
|
||||||
if (incomingData.deviceType != ENDT_GATEWAY || myNet.macToString(gatewayMAC) != myNet.macToString(sender))
|
if (incomingData.deviceType != ENDT_GATEWAY || myNet.macToString(gatewayMAC) != myNet.macToString(sender))
|
||||||
return;
|
return;
|
||||||
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
|
DynamicJsonDocument json(sizeof(esp_now_payload_data_t::message));
|
||||||
if (incomingData.payloadsType == ENPT_SET)
|
if (incomingData.payloadsType == ENPT_SET)
|
||||||
{
|
{
|
||||||
deserializeJson(json, incomingData.message);
|
deserializeJson(json, incomingData.message);
|
||||||
@ -407,7 +407,7 @@ void sendAttributesMessage(const uint8_t type)
|
|||||||
uint32_t days = hours / 24;
|
uint32_t days = hours / 24;
|
||||||
esp_now_payload_data_t outgoingData{ENDT_SWITCH, ENPT_ATTRIBUTES};
|
esp_now_payload_data_t outgoingData{ENDT_SWITCH, ENPT_ATTRIBUTES};
|
||||||
espnow_message_t message;
|
espnow_message_t message;
|
||||||
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
|
DynamicJsonDocument json(sizeof(esp_now_payload_data_t::message));
|
||||||
if (type == ENST_NONE)
|
if (type == ENST_NONE)
|
||||||
json["Type"] = "ESP-NOW switch";
|
json["Type"] = "ESP-NOW switch";
|
||||||
else
|
else
|
||||||
@ -446,7 +446,7 @@ void sendConfigMessage(const uint8_t type)
|
|||||||
return;
|
return;
|
||||||
esp_now_payload_data_t outgoingData{ENDT_SWITCH, ENPT_CONFIG};
|
esp_now_payload_data_t outgoingData{ENDT_SWITCH, ENPT_CONFIG};
|
||||||
espnow_message_t message;
|
espnow_message_t message;
|
||||||
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
|
DynamicJsonDocument json(sizeof(esp_now_payload_data_t::message));
|
||||||
if (type == ENST_NONE)
|
if (type == ENST_NONE)
|
||||||
{
|
{
|
||||||
json[MCMT_DEVICE_NAME] = config.deviceName;
|
json[MCMT_DEVICE_NAME] = config.deviceName;
|
||||||
@ -498,7 +498,7 @@ void sendStatusMessage(const uint8_t type)
|
|||||||
statusMessageTimerSemaphore = false;
|
statusMessageTimerSemaphore = false;
|
||||||
esp_now_payload_data_t outgoingData{ENDT_SWITCH, ENPT_STATE};
|
esp_now_payload_data_t outgoingData{ENDT_SWITCH, ENPT_STATE};
|
||||||
espnow_message_t message;
|
espnow_message_t message;
|
||||||
StaticJsonDocument<sizeof(esp_now_payload_data_t::message)> json;
|
DynamicJsonDocument json(sizeof(esp_now_payload_data_t::message));
|
||||||
if (type == ENST_NONE)
|
if (type == ENST_NONE)
|
||||||
json["state"] = relayStatus ? "ON" : "OFF";
|
json["state"] = relayStatus ? "ON" : "OFF";
|
||||||
if (type == ENST_DS18B20)
|
if (type == ENST_DS18B20)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user