From bf3306fbc8ec0452b2f41966855df88f7ef4b1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 9 Sep 2022 22:31:30 +0200 Subject: [PATCH] use the new ESP Framework for our older boards too --- platformio.ini | 35 ++++++++++++++---------- src/FSCommon.h | 11 ++------ src/mesh/http/ContentHandler.cpp | 2 -- src/mesh/http/WiFiAPClient.cpp | 21 +++----------- src/platform/esp32/ESP32CryptoEngine.cpp | 10 +------ 5 files changed, 27 insertions(+), 52 deletions(-) diff --git a/platformio.ini b/platformio.ini index e1dbe47e..def7901e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,7 @@ default_envs = tbeam ;default_envs = tlora-v2 ;default_envs = tlora-v2-1-1.6 ;default_envs = lora-relay-v1 # nrf board -; default_envs = t-echo +;default_envs = t-echo ;default_envs = nrf52840dk-geeksville ;default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here ;default_envs = nano-g1 @@ -90,7 +90,7 @@ lib_deps = ; Common settings for ESP targes, mixin with extends = esp32_base [esp32_base] extends = arduino_base -platform = espressif32@3.5.0 +platform = espressif32 build_src_filter = ${arduino_base.build_src_filter} - - - upload_speed = 115200 @@ -100,24 +100,33 @@ debug_init_break = tbreak setup # See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h # This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h build_flags = - ${arduino_base.build_flags} -Wall -Wextra -Isrc/platform/esp32 -lnimble -std=c++11 - -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL - -DAXP_DEBUG_PORT=Serial -DCONFIG_BT_NIMBLE_ENABLED -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 + ${arduino_base.build_flags} + -Wall + -Wextra + -Isrc/platform/esp32 + -std=c++11 + -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL + -DAXP_DEBUG_PORT=Serial + -DCONFIG_BT_NIMBLE_ENABLED + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 + lib_deps = ${arduino_base.lib_deps} ${networking_base.lib_deps} ${environmental_base.lib_deps} - https://github.com/meshtastic/esp32_https_server.git + https://github.com/caveman99/esp32_https_server.git h2zero/NimBLE-Arduino@1.4.0 arduino-libraries/NTPClient@^3.1.0 - lorol/LittleFS_esp32@^1.0.6 - https://github.com/lewisxhe/XPowersLib.git - + https://github.com/lewisxhe/XPowersLib.git + lib_ignore = segger_rtt ESP32 BLE Arduino platform_packages = - framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276 + framework-arduinoespressif32@3.20004.220825 ; leave this commented out to avoid breaking Windows ;upload_port = /dev/ttyUSB0 @@ -205,8 +214,6 @@ lib_deps = lib_ignore = mathertel/OneButton@^2.0.3 - - [esp32s3_base] extends = arduino_base platform = espressif32 @@ -237,9 +244,7 @@ lib_deps = ${arduino_base.lib_deps} ${networking_base.lib_deps} ${environmental_base.lib_deps} - ; https://github.com/meshtastic/esp32_https_server.git - ; PR has been submitted and can be deleted after merging ,https://github.com/meshtastic/esp32_https_server/pull/1 - https://github.com/lewisxhe/esp32_https_server.git + https://github.com/meshtastic/esp32_https_server.git h2zero/NimBLE-Arduino@1.4.0 arduino-libraries/NTPClient@^3.1.0 https://github.com/lewisxhe/XPowersLib.git diff --git a/src/FSCommon.h b/src/FSCommon.h index 4336e88d..38ca403b 100644 --- a/src/FSCommon.h +++ b/src/FSCommon.h @@ -23,16 +23,9 @@ #endif #if defined(ARCH_ESP32) -#if CONFIG_IDF_TARGET_ESP32S3 -#include //esp32s3 uses the framework's built-in LittleFS -#define FSCom LittleFS -#else // ESP32 version -#include "LITTLEFS.h" -#define FSCom LITTLEFS -#endif - - +#include "LittleFS.h" +#define FSCom LittleFS #define FSBegin() FSCom.begin(true) #define FILE_O_WRITE "w" #define FILE_O_READ "r" diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 298fce3c..6763d70f 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -48,8 +48,6 @@ using namespace httpsserver; HTTPClient httpClient; #define DEST_FS_USES_LITTLEFS -#define ESP_ARDUINO_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) -#define ESP_ARDUINO_VERSION ESP_ARDUINO_VERSION_VAL(1, 0, 4) // We need to specify some content-type mapping, so the resources get delivered with the // right content type and are displayed correctly in the browser diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index f7868106..576492a2 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -238,10 +238,8 @@ bool initWifi(bool forceSoftAP) WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); DEBUG_MSG("MY IP AP ADDRESS: %s\n", WiFi.softAPIP().toString().c_str()); -#if !CONFIG_IDF_TARGET_ESP32S3 // This is needed to improve performance. - esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving -#endif + // esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving dnsServer.start(53, "*", apIP); @@ -254,19 +252,14 @@ bool initWifi(bool forceSoftAP) WiFi.setHostname(ourHost); WiFi.onEvent(WiFiEvent); -#if !CONFIG_IDF_TARGET_ESP32S3 // This is needed to improve performance. - esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving -#endif + // esp_wifi_set_ps(WIFI_PS_NONE); // Disable radio power saving WiFi.onEvent( [](WiFiEvent_t event, WiFiEventInfo_t info) { Serial.print("\nWiFi lost connection. Reason: "); - #if CONFIG_IDF_TARGET_ESP32S3 Serial.println(info.wifi_sta_disconnected.reason); - wifiDisconnectReason = info.wifi_sta_disconnected.reason; - #else - Serial.println(info.disconnected.reason); + /* If we are disconnected from the AP for some reason, save the error code. @@ -274,15 +267,9 @@ bool initWifi(bool forceSoftAP) For a reference to the codes: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wi-fi-reason-code */ - wifiDisconnectReason = info.disconnected.reason; - #endif - + wifiDisconnectReason = info.wifi_sta_disconnected.reason; }, -#if CONFIG_IDF_TARGET_ESP32S3 WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED); -#else - WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED); -#endif DEBUG_MSG("JOINING WIFI soon: ssid=%s\n", wifiName); wifiReconnect = new Periodic("WifiConnect", reconnectWiFi); diff --git a/src/platform/esp32/ESP32CryptoEngine.cpp b/src/platform/esp32/ESP32CryptoEngine.cpp index 60026c4d..4bbbc4ad 100644 --- a/src/platform/esp32/ESP32CryptoEngine.cpp +++ b/src/platform/esp32/ESP32CryptoEngine.cpp @@ -1,16 +1,8 @@ #include "CryptoEngine.h" #include "configuration.h" -#if CONFIG_IDF_TARGET_ESP32S3 #include "mbedtls/aes.h" -#else -#include "crypto/includes.h" -#include "crypto/common.h" -// #include "esp_system.h" -#include "crypto/aes.h" -#include "crypto/aes_wrap.h" -#include "mbedtls/aes.h" -#endif + class ESP32CryptoEngine : public CryptoEngine