diff --git a/lib/framework/NetworkSettingsService.cpp b/lib/framework/NetworkSettingsService.cpp index 9408f9bcc..962384df3 100644 --- a/lib/framework/NetworkSettingsService.cpp +++ b/lib/framework/NetworkSettingsService.cpp @@ -13,11 +13,11 @@ NetworkSettingsService::NetworkSettingsService(PsychicHttpServer * server, FS * void NetworkSettingsService::begin() { // 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 (WiFi.getMode() != WIFI_OFF) { - WiFi.mode(WIFI_OFF); - } + // if (WiFi.getMode() != 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.setAutoReconnect(false); diff --git a/platformio.ini b/platformio.ini index 64e1b8e36..eec50c32d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -3,10 +3,10 @@ [platformio] ; default_envs = esp32_4M -; default_envs = lolin_s3 +default_envs = lolin_s3 ; default_envs = esp32_16M ; default_envs = standalone -default_envs = https +; default_envs = https extra_configs = factory_settings.ini @@ -39,7 +39,7 @@ unbuild_flags = ${common.core_unbuild_flags} [espressi32_base] -platform = espressif32@6.4.0 +platform = espressif32@6.5.0 framework = arduino board_build.filesystem = littlefs build_flags = ${common.build_flags} @@ -182,7 +182,7 @@ build_flags = ; platform = https://github.com/platformio/platform-espressif32.git ; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5 ; 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 board = esp32dev board_build.filesystem = littlefs @@ -212,6 +212,7 @@ build_flags = ; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_WARN -D EMSESP_TEST -D EMSESP_DEBUG + -D CONFIG_ETH_ENABLED ; -D BOARD_HAS_PSRAM '-DEMSESP_DEFAULT_BOARD_PROFILE="Test"' diff --git a/scripts/api_test.http b/scripts/api_test.http index 5434d2797..2f5f4893d 100755 --- a/scripts/api_test.http +++ b/scripts/api_test.http @@ -84,6 +84,16 @@ Authorization: Bearer {{token}} "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/getSettings diff --git a/src/emsesp.cpp b/src/emsesp.cpp index f18ec06b7..6054adf92 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -1435,7 +1435,9 @@ void EMSESP::setupWeb() { // esp8266React services has 13 // custom projects has around 23 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 webServer.listen(80); // start the web server diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index f4edda0c5..99b125e38 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -32,7 +32,6 @@ WebAPIService::WebAPIService(PsychicHttpServer * server, SecurityManager * secur void WebAPIService::registerURI() { // 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) { // if no json body then treat it as a secure GET if (!json.is()) { @@ -53,14 +52,6 @@ void WebAPIService::registerURI() { 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 input_doc; - JsonObject input = input_doc.to(); // empty input json - return parse(request, input); - }); - // for settings _server->on(GET_SETTINGS_PATH, HTTP_GET, _securityManager->wrapRequest(std::bind(&WebAPIService::getSettings, this, _1), AuthenticationPredicates::IS_ADMIN)); _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 } - 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 // 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 - // TODO check if needed to add utf-8 here response.setContentType("application/json; charset=utf-8"); // TODO doesn't seem to work // response.addHeader("Connection", "close"); diff --git a/src/web/WebAPIService.h b/src/web/WebAPIService.h index 22fbb56b6..de9f695f5 100644 --- a/src/web/WebAPIService.h +++ b/src/web/WebAPIService.h @@ -19,7 +19,7 @@ #ifndef 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_CUSTOMIZATIONS_PATH "/rest/getCustomizations" #define GET_SCHEDULE_PATH "/rest/getSchedule"