Call read commands from Web #2116

This commit is contained in:
proddy
2024-10-20 15:02:11 +02:00
parent bd08b7e0e4
commit 798e20a266
25 changed files with 282 additions and 127 deletions

View File

@@ -28,8 +28,9 @@ WebAPIService::WebAPIService(AsyncWebServer * server, SecurityManager * security
server->on(EMSESP_API_SERVICE_PATH, [this](AsyncWebServerRequest * request, JsonVariant json) { webAPIService(request, json); });
}
// POST|GET /{device}
// POST|GET /{device}/{entity}
// POST|GET api/
// POST|GET api/{device}
// POST|GET api/{device}/{entity}
void WebAPIService::webAPIService(AsyncWebServerRequest * request, JsonVariant json) {
JsonObject input;
// if no body then treat it as a secure GET

View File

@@ -80,6 +80,7 @@ void WebSettings::read(WebSettings & settings, JsonObject root) {
root["modbus_port"] = settings.modbus_port;
root["modbus_max_clients"] = settings.modbus_max_clients;
root["modbus_timeout"] = settings.modbus_timeout;
root["developer_mode"] = settings.developer_mode;
}
// call on initialization and also when settings are updated via web or console
@@ -358,9 +359,12 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
settings.fahrenheit = root["fahrenheit"];
EMSESP::system_.fahrenheit(settings.fahrenheit);
settings.readonly_mode = root["readonly_mode"];
settings.readonly_mode = root["readonly_mode"] | false;
EMSESP::system_.readonly_mode(settings.readonly_mode);
settings.developer_mode = root["developer_mode"] | false;
EMSESP::system_.developer_mode(settings.developer_mode);
settings.bool_dashboard = root["bool_dashboard"] | EMSESP_DEFAULT_BOOL_FORMAT;
EMSESP::system_.bool_dashboard(settings.bool_dashboard);

View File

@@ -65,10 +65,13 @@ class WebSettings {
uint8_t bool_format;
uint8_t bool_dashboard;
uint8_t enum_format;
int8_t weblog_level;
uint8_t weblog_buffer;
bool weblog_compact;
bool fahrenheit;
int8_t weblog_level;
uint8_t weblog_buffer;
bool weblog_compact;
bool fahrenheit;
bool modbus_enabled;
uint16_t modbus_port;
uint8_t modbus_max_clients;
@@ -79,6 +82,8 @@ class WebSettings {
uint8_t eth_phy_addr;
uint8_t eth_clock_mode;
bool developer_mode; // developer mode
static void read(WebSettings & settings, JsonObject root);
static StateUpdateResult update(JsonObject root, WebSettings & settings);