sec: dane wifi nie pobierane przez endpoint do konfiguracji

This commit is contained in:
2026-06-05 13:44:03 +02:00
parent 7f66b93edb
commit 7ba9c55e27
2 changed files with 108 additions and 67 deletions
+10 -14
View File
@@ -1055,22 +1055,18 @@ void setupHttpServer()
saveConfig();
req->send(200, "application/json", "{\"ok\":true}"); });
// GET /config.json — gesture config only (WiFi credentials are NEVER exposed)
// GET /config.json — gesture config only, built from RAM (WiFi NEVER exposed)
httpServer.on("/config.json", HTTP_GET, [](AsyncWebServerRequest *req) {
if (!LittleFS.begin(false)) {
req->send(500, "application/json", "{\"error\":\"LittleFS unavailable\"}");
return;
JsonDocument doc;
for (uint8_t i = 0; i < NUM_GESTURES; i++) {
doc[GNAME[i]]["url"] = gConfig[i].url;
doc[GNAME[i]]["mood"] = gConfig[i].mood;
doc[GNAME[i]]["action"] = gConfig[i].action;
doc[GNAME[i]]["enabled"] = gConfig[i].enabled;
}
File f = LittleFS.open("/config.json", "r");
if (!f) {
LittleFS.end();
req->send(404, "application/json", "{\"error\":\"not found\"}");
return;
}
String body = f.readString();
f.close();
LittleFS.end();
req->send(200, "application/json", body);
String out;
serializeJsonPretty(doc, out);
req->send(200, "application/json", out);
});
httpServer.begin();