Skip to content

Commit

Permalink
Fixed one bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aZholtikov committed Feb 26, 2023
1 parent 98a082d commit 651ade7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta

void loadConfig()
{
ETS_GPIO_INTR_DISABLE();
if (!LittleFS.exists("/config.json"))
saveConfig();
File file = LittleFS.open("/config.json", "r");
Expand All @@ -272,10 +273,13 @@ void loadConfig()
sensorType = json["sensorType"];
workMode = json["workMode"];
file.close();
delay(50);
ETS_GPIO_INTR_ENABLE();
}

void saveConfig()
{
ETS_GPIO_INTR_DISABLE();
StaticJsonDocument<512> json;
json["firmware"] = firmware;
json["espnowNetName"] = espnowNetName;
Expand All @@ -296,6 +300,8 @@ void saveConfig()
File file = LittleFS.open("/config.json", "w");
serializeJsonPretty(json, file);
file.close();
delay(50);
ETS_GPIO_INTR_ENABLE();
}

void setupWebServer()
Expand Down Expand Up @@ -346,6 +352,7 @@ void IRAM_ATTR buttonInterrupt()

void switchingRelay()
{
ETS_GPIO_INTR_ENABLE();
relayStatus = !relayStatus;
if (relayPin)
{
Expand All @@ -363,7 +370,6 @@ void switchingRelay()
}
saveConfig();
sendStatusMessage();
ETS_GPIO_INTR_ENABLE();
}

void sendAttributesMessage(const uint8_t type)
Expand Down

0 comments on commit 651ade7

Please sign in to comment.