diff --git a/code/espurna/settings.ino b/code/espurna/settings.ino index b05f9a08..89a2cd54 100644 --- a/code/espurna/settings.ino +++ b/code/espurna/settings.ino @@ -38,7 +38,7 @@ unsigned long settingsSize() { // ----------------------------------------------------------------------------- -unsigned int _settingsKeyCount() { +unsigned int settingsKeyCount() { unsigned count = 0; unsigned pos = SPI_FLASH_SEC_SIZE - 1; while (size_t len = EEPROMr.read(pos)) { @@ -50,7 +50,7 @@ unsigned int _settingsKeyCount() { return count; } -String _settingsKeyName(unsigned int index) { +String settingsKeyName(unsigned int index) { String s; @@ -80,11 +80,11 @@ std::vector _settingsKeys() { std::vector keys; //unsigned int size = settingsKeyCount(); - unsigned int size = _settingsKeyCount(); + unsigned int size = settingsKeyCount(); for (unsigned int i=0; ibeginResponseStream("text/json"); - DynamicJsonBuffer jsonBuffer; - JsonObject &root = jsonBuffer.createObject(); - root["app"] = APP_NAME; - root["version"] = APP_VERSION; - settingsGetJson(root); - root.prettyPrintTo(*response); - jsonBuffer.clear(); - char buffer[100]; snprintf_P(buffer, sizeof(buffer), PSTR("attachment; filename=\"%s-backup.json\""), (char *) getSetting("hostname").c_str()); response->addHeader("Content-Disposition", buffer); response->addHeader("X-XSS-Protection", "1; mode=block"); response->addHeader("X-Content-Type-Options", "nosniff"); response->addHeader("X-Frame-Options", "deny"); + + response->printf("{\n \"app\": \"%s\",\n \"version\": \"%s\"", APP_NAME, APP_VERSION); + + // Write the keys line by line (not sorted) + unsigned long count = settingsKeyCount(); + for (unsigned int i=0; iprintf(",\n \"%s\": \"%s\"", key.c_str(), value.c_str()); + } + response->printf("\n}"); + request->send(response); }