|
@ -91,11 +91,16 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { |
|
|
if (action.equals("reset")) ESP.reset(); |
|
|
if (action.equals("reset")) ESP.reset(); |
|
|
if (action.equals("restore") && root.containsKey("data")) { |
|
|
if (action.equals("restore") && root.containsKey("data")) { |
|
|
|
|
|
|
|
|
|
|
|
JsonObject& data = root["data"]; |
|
|
|
|
|
if (!data.containsKey("app") || (data["app"] != APP_NAME)) { |
|
|
|
|
|
ws.text(client_id, "{\"message\": \"The file does not look like a valid configuration backup.\"}"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (unsigned int i = EEPROM_DATA_END; i < SPI_FLASH_SEC_SIZE; i++) { |
|
|
for (unsigned int i = EEPROM_DATA_END; i < SPI_FLASH_SEC_SIZE; i++) { |
|
|
EEPROM.write(i, 0xFF); |
|
|
EEPROM.write(i, 0xFF); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
JsonObject& data = root["data"]; |
|
|
|
|
|
for (auto element : data){ |
|
|
for (auto element : data){ |
|
|
setSetting(element.key, element.value.as<char*>()); |
|
|
setSetting(element.key, element.value.as<char*>()); |
|
|
} |
|
|
} |
|
@ -731,6 +736,9 @@ void _onGetConfig(AsyncWebServerRequest *request) { |
|
|
AsyncJsonResponse * response = new AsyncJsonResponse(); |
|
|
AsyncJsonResponse * response = new AsyncJsonResponse(); |
|
|
JsonObject& root = response->getRoot(); |
|
|
JsonObject& root = response->getRoot(); |
|
|
|
|
|
|
|
|
|
|
|
root["app"] = APP_NAME; |
|
|
|
|
|
root["version"] = APP_VERSION; |
|
|
|
|
|
|
|
|
unsigned int size = settingsKeyCount(); |
|
|
unsigned int size = settingsKeyCount(); |
|
|
for (unsigned int i=0; i<size; i++) { |
|
|
for (unsigned int i=0; i<size; i++) { |
|
|
String key = settingsKeyName(i); |
|
|
String key = settingsKeyName(i); |
|
|