mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-15 21:18:21 +01:00
save whole config file
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#ifndef __WEB_CONFIG_PLUGIN_H__
|
#ifndef __WEB_CONFIG_PLUGIN_H__
|
||||||
#define __WEB_CONFIG_PLUGIN_H__
|
#define __WEB_CONFIG_PLUGIN_H__
|
||||||
|
|
||||||
|
#include <FS.h>
|
||||||
#include "TaskSchedulerDeclarations.h"
|
#include "TaskSchedulerDeclarations.h"
|
||||||
#include "ArduinoOTA.h"
|
#include "ArduinoOTA.h"
|
||||||
#include "MeshNet.h"
|
#include "MeshNet.h"
|
||||||
@@ -37,10 +38,17 @@ class WebConfigPlugin : public Plugin {
|
|||||||
Serial.println("POST /config");
|
Serial.println("POST /config");
|
||||||
if(request->hasParam("config", true)) {
|
if(request->hasParam("config", true)) {
|
||||||
String inStr = request->getParam("config", true)->value();
|
String inStr = request->getParam("config", true)->value();
|
||||||
MeshSprocketConfig config;
|
//MeshSprocketConfig config;
|
||||||
config.fromJsonString(inStr);
|
//config.fromJsonString(inStr);
|
||||||
Serial.println(config.toJsonString());
|
//Serial.println(config.toJsonString());
|
||||||
config.saveFile("/config.json");
|
//config.saveFile("/config.json");
|
||||||
|
File f = SPIFFS.open("/config.json", "w");
|
||||||
|
if (!f) {
|
||||||
|
Serial.println("file open for write failed");
|
||||||
|
}
|
||||||
|
Serial.println("====== Writing to SPIFFS file =========");
|
||||||
|
f.print(inStr);
|
||||||
|
f.close();
|
||||||
}
|
}
|
||||||
request->redirect("/");
|
request->redirect("/");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user