mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 19:12:10 +01:00
Prepare for LAN adapter settings
* Fix radio pin settings where the old values were being set to the config then reloaded. This meant that the new pin settings were not being saved. * Disable the radio when the radio cannot be configured. This stops the microcontroller from hitting a hard halt and allows the pin settings to be changed. * Add ethernet configuration options in preparation for boards with ethernet connections.
This commit is contained in:
parent
028cce5d8f
commit
7f5463250f
10 changed files with 255 additions and 57 deletions
29
Web.cpp
29
Web.cpp
|
|
@ -57,7 +57,7 @@ void Web::begin() {
|
|||
Serial.println("Discovery Requested");
|
||||
DynamicJsonDocument doc(16384);
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["serverId"] = settings.WIFI.serverId;
|
||||
obj["serverId"] = settings.serverId;
|
||||
obj["version"] = settings.fwVersion;
|
||||
obj["model"] = "ESPSomfyRTS";
|
||||
JsonArray arr = obj.createNestedArray("shades");
|
||||
|
|
@ -991,7 +991,7 @@ void Web::begin() {
|
|||
if (method == HTTP_POST || method == HTTP_PUT) {
|
||||
somfy.transceiver.fromJSON(obj);
|
||||
somfy.transceiver.save();
|
||||
DynamicJsonDocument sdoc(512);
|
||||
DynamicJsonDocument sdoc(1024);
|
||||
JsonObject sobj = sdoc.to<JsonObject>();
|
||||
somfy.transceiver.toJSON(sobj);
|
||||
serializeJson(sdoc, g_content);
|
||||
|
|
@ -1076,9 +1076,9 @@ void Web::begin() {
|
|||
HTTPMethod method = server.method();
|
||||
if (method == HTTP_POST || method == HTTP_PUT) {
|
||||
// Parse out all the inputs.
|
||||
if (obj.containsKey("hostname")) {
|
||||
settings.WIFI.fromJSON(obj);
|
||||
settings.WIFI.save();
|
||||
if (obj.containsKey("hostname") || obj.containsKey("ssdpBroadcast")) {
|
||||
settings.fromJSON(obj);
|
||||
settings.save();
|
||||
}
|
||||
if (obj.containsKey("ntpServer") || obj.containsKey("ntpServer")) {
|
||||
settings.NTP.fromJSON(obj);
|
||||
|
|
@ -1122,7 +1122,6 @@ void Web::begin() {
|
|||
else {
|
||||
SETCHARPROP(settings.WIFI.ssid, ssid.c_str(), sizeof(settings.WIFI.ssid));
|
||||
SETCHARPROP(settings.WIFI.passphrase, passphrase.c_str(), sizeof(settings.WIFI.passphrase));
|
||||
if (obj.containsKey("ssdpBroadcast")) settings.WIFI.ssdpBroadcast = obj["ssdpBroadcast"].as<bool>();
|
||||
settings.WIFI.save();
|
||||
settings.WIFI.print();
|
||||
server.send(201, _encoding_json, "{\"status\":\"OK\",\"desc\":\"Successfully set server connection\"}");
|
||||
|
|
@ -1143,11 +1142,27 @@ void Web::begin() {
|
|||
DynamicJsonDocument doc(512);
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
doc["fwVersion"] = settings.fwVersion;
|
||||
settings.WIFI.toJSON(obj);
|
||||
settings.toJSON(obj);
|
||||
//settings.Ethernet.toJSON(obj);
|
||||
//settings.WIFI.toJSON(obj);
|
||||
settings.NTP.toJSON(obj);
|
||||
serializeJson(doc, g_content);
|
||||
server.send(200, _encoding_json, g_content);
|
||||
});
|
||||
server.on("/networksettings", []() {
|
||||
webServer.sendCORSHeaders();
|
||||
DynamicJsonDocument doc(1024);
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
doc["fwVersion"] = settings.fwVersion;
|
||||
settings.toJSON(obj);
|
||||
JsonObject eth = obj.createNestedObject("ethernet");
|
||||
settings.Ethernet.toJSON(eth);
|
||||
JsonObject wifi = obj.createNestedObject("wifi");
|
||||
settings.WIFI.toJSON(wifi);
|
||||
serializeJson(doc, g_content);
|
||||
server.send(200, _encoding_json, g_content);
|
||||
});
|
||||
|
||||
server.on("/connectmqtt", []() {
|
||||
DynamicJsonDocument doc(512);
|
||||
DeserializationError err = deserializeJson(doc, server.arg("plain"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue