mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
updates
This commit is contained in:
@@ -13,11 +13,11 @@ NetworkSettingsService::NetworkSettingsService(PsychicHttpServer * server, FS *
|
|||||||
void NetworkSettingsService::begin() {
|
void NetworkSettingsService::begin() {
|
||||||
// We want the device to come up in opmode=0 (WIFI_OFF), when erasing the flash this is not the default.
|
// We want the device to come up in opmode=0 (WIFI_OFF), when erasing the flash this is not the default.
|
||||||
// If needed, we save opmode=0 before disabling persistence so the device boots with WiFi disabled in the future.
|
// If needed, we save opmode=0 before disabling persistence so the device boots with WiFi disabled in the future.
|
||||||
if (WiFi.getMode() != WIFI_OFF) {
|
// if (WiFi.getMode() != WIFI_OFF) {
|
||||||
WiFi.mode(WIFI_OFF);
|
// WiFi.mode(WIFI_OFF);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Disable WiFi config persistance and auto reconnect
|
// WiFi.useStaticBuffers(true); // uses 40kb more heap and max alloc, so not recommended
|
||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.setAutoReconnect(false);
|
WiFi.setAutoReconnect(false);
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
; default_envs = esp32_4M
|
; default_envs = esp32_4M
|
||||||
; default_envs = lolin_s3
|
default_envs = lolin_s3
|
||||||
; default_envs = esp32_16M
|
; default_envs = esp32_16M
|
||||||
; default_envs = standalone
|
; default_envs = standalone
|
||||||
default_envs = https
|
; default_envs = https
|
||||||
|
|
||||||
extra_configs =
|
extra_configs =
|
||||||
factory_settings.ini
|
factory_settings.ini
|
||||||
@@ -39,7 +39,7 @@ unbuild_flags =
|
|||||||
${common.core_unbuild_flags}
|
${common.core_unbuild_flags}
|
||||||
|
|
||||||
[espressi32_base]
|
[espressi32_base]
|
||||||
platform = espressif32@6.4.0
|
platform = espressif32@6.5.0
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
build_flags = ${common.build_flags}
|
build_flags = ${common.build_flags}
|
||||||
@@ -182,7 +182,7 @@ build_flags =
|
|||||||
; platform = https://github.com/platformio/platform-espressif32.git
|
; platform = https://github.com/platformio/platform-espressif32.git
|
||||||
; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5
|
; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5
|
||||||
; platform_packages = https://github.com/espressif/arduino-esp32.git#3.0.0-alpha2
|
; platform_packages = https://github.com/espressif/arduino-esp32.git#3.0.0-alpha2
|
||||||
platform = espressif32@6.4.0
|
platform = espressif32@6.5.0
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
@@ -212,6 +212,7 @@ build_flags =
|
|||||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN
|
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN
|
||||||
-D EMSESP_TEST
|
-D EMSESP_TEST
|
||||||
-D EMSESP_DEBUG
|
-D EMSESP_DEBUG
|
||||||
|
-D CONFIG_ETH_ENABLED
|
||||||
; -D BOARD_HAS_PSRAM
|
; -D BOARD_HAS_PSRAM
|
||||||
'-DEMSESP_DEFAULT_BOARD_PROFILE="Test"'
|
'-DEMSESP_DEFAULT_BOARD_PROFILE="Test"'
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,16 @@ Authorization: Bearer {{token}}
|
|||||||
"id" : 0
|
"id" : 0
|
||||||
}
|
}
|
||||||
###
|
###
|
||||||
|
POST {{host_dev}}/api
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"device" : "system",
|
||||||
|
"entity" : "info",
|
||||||
|
"id" : 0
|
||||||
|
}
|
||||||
|
###
|
||||||
GET {{host_dev}}/rest/features
|
GET {{host_dev}}/rest/features
|
||||||
###
|
###
|
||||||
GET {{host_dev}}/rest/getSettings
|
GET {{host_dev}}/rest/getSettings
|
||||||
|
|||||||
@@ -1435,7 +1435,9 @@ void EMSESP::setupWeb() {
|
|||||||
// esp8266React services has 13
|
// esp8266React services has 13
|
||||||
// custom projects has around 23
|
// custom projects has around 23
|
||||||
webServer.config.max_uri_handlers = 80;
|
webServer.config.max_uri_handlers = 80;
|
||||||
// webServer.config.uri_match_fn = NULL;
|
// webServer.config.uri_match_fn = NULL; // don't use wildcards
|
||||||
|
|
||||||
|
// webServer.config.task_priority = uxTaskPriorityGet(nullptr); // seems to make it slightly slower
|
||||||
|
|
||||||
// TODO add support for https
|
// TODO add support for https
|
||||||
webServer.listen(80); // start the web server
|
webServer.listen(80); // start the web server
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ WebAPIService::WebAPIService(PsychicHttpServer * server, SecurityManager * secur
|
|||||||
|
|
||||||
void WebAPIService::registerURI() {
|
void WebAPIService::registerURI() {
|
||||||
// POST /api/{device}[/{hc|wwc|id}][/{name}]
|
// POST /api/{device}[/{hc|wwc|id}][/{name}]
|
||||||
// note: must explicity use 'Content-Type: application/json' in header
|
|
||||||
_server->on(EMSESP_API_SERVICE_PATH, HTTP_POST, [this](PsychicRequest * request, JsonVariant & json) {
|
_server->on(EMSESP_API_SERVICE_PATH, HTTP_POST, [this](PsychicRequest * request, JsonVariant & json) {
|
||||||
// if no json body then treat it as a secure GET
|
// if no json body then treat it as a secure GET
|
||||||
if (!json.is<JsonObject>()) {
|
if (!json.is<JsonObject>()) {
|
||||||
@@ -53,14 +52,6 @@ void WebAPIService::registerURI() {
|
|||||||
return parse(request, input);
|
return parse(request, input);
|
||||||
});
|
});
|
||||||
|
|
||||||
// GET - for when using GET query parameters, the old style from v2
|
|
||||||
// Note POST just to /api is no longer supported
|
|
||||||
_server->on("/api", HTTP_GET, [this](PsychicRequest * request) {
|
|
||||||
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> input_doc;
|
|
||||||
JsonObject input = input_doc.to<JsonObject>(); // empty input json
|
|
||||||
return parse(request, input);
|
|
||||||
});
|
|
||||||
|
|
||||||
// for settings
|
// for settings
|
||||||
_server->on(GET_SETTINGS_PATH, HTTP_GET, _securityManager->wrapRequest(std::bind(&WebAPIService::getSettings, this, _1), AuthenticationPredicates::IS_ADMIN));
|
_server->on(GET_SETTINGS_PATH, HTTP_GET, _securityManager->wrapRequest(std::bind(&WebAPIService::getSettings, this, _1), AuthenticationPredicates::IS_ADMIN));
|
||||||
_server->on(GET_CUSTOMIZATIONS_PATH,
|
_server->on(GET_CUSTOMIZATIONS_PATH,
|
||||||
@@ -141,7 +132,7 @@ esp_err_t WebAPIService::parse(PsychicRequest * request, JsonObject & input) {
|
|||||||
request->reply(ret_codes[return_code]); // exit with error code
|
request->reply(ret_codes[return_code]); // exit with error code
|
||||||
}
|
}
|
||||||
|
|
||||||
api_count_++; // another succesful api call
|
api_count_++; // another successful api call
|
||||||
|
|
||||||
// if we're returning single values, just sent as plain text and not json
|
// if we're returning single values, just sent as plain text and not json
|
||||||
// https://github.com/emsesp/EMS-ESP32/issues/462#issuecomment-1093877210
|
// https://github.com/emsesp/EMS-ESP32/issues/462#issuecomment-1093877210
|
||||||
@@ -151,7 +142,6 @@ esp_err_t WebAPIService::parse(PsychicRequest * request, JsonObject & input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// normal return
|
// normal return
|
||||||
// TODO check if needed to add utf-8 here
|
|
||||||
response.setContentType("application/json; charset=utf-8"); // TODO doesn't seem to work
|
response.setContentType("application/json; charset=utf-8"); // TODO doesn't seem to work
|
||||||
// response.addHeader("Connection", "close");
|
// response.addHeader("Connection", "close");
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#ifndef WebAPIService_h
|
#ifndef WebAPIService_h
|
||||||
#define WebAPIService_h
|
#define WebAPIService_h
|
||||||
|
|
||||||
#define EMSESP_API_SERVICE_PATH "/api/*"
|
#define EMSESP_API_SERVICE_PATH "/api/?*"
|
||||||
#define GET_SETTINGS_PATH "/rest/getSettings"
|
#define GET_SETTINGS_PATH "/rest/getSettings"
|
||||||
#define GET_CUSTOMIZATIONS_PATH "/rest/getCustomizations"
|
#define GET_CUSTOMIZATIONS_PATH "/rest/getCustomizations"
|
||||||
#define GET_SCHEDULE_PATH "/rest/getSchedule"
|
#define GET_SCHEDULE_PATH "/rest/getSchedule"
|
||||||
|
|||||||
Reference in New Issue
Block a user