diff --git a/examples/companion_radio/MeshcomodImport.cpp b/examples/companion_radio/MeshcomodImport.cpp index d7fbdafbf9..6ba2f1e646 100644 --- a/examples/companion_radio/MeshcomodImport.cpp +++ b/examples/companion_radio/MeshcomodImport.cpp @@ -5,8 +5,11 @@ #include "MyMesh.h" #include "MeshcomodPrefs.h" +// The IDF NVS API, not Arduino's Preferences: PlatformIO's library finder does not +// see the #if, and on RP2040 a framework library (iLabs Hearth) ships its own +// Preferences.h that then gets built and fails. #if defined(ESP32) && defined(ENABLE_WIFI_INTERFACE) - #include + #include #endif void importMeshcomodSettings(NodePrefs& prefs, DataStore& store) { @@ -44,13 +47,15 @@ void importMeshcomodSettings(NodePrefs& prefs, DataStore& store) { #if defined(ESP32) && defined(ENABLE_WIFI_INTERFACE) // meshcomod's runtime Wi-Fi credentials (WifiRuntimeStore: NVS "meshcomod"). // NVS survives an app-only flash; read-only, so meshcomod's copy stays intact. - Preferences nvs; - if (nvs.begin("meshcomod", true)) { + nvs_handle_t nvs; + if (nvs_open("meshcomod", NVS_READONLY, &nvs) == ESP_OK) { char ssid[sizeof(prefs.wifi_ssid)] = { 0 }; char pwd[sizeof(prefs.wifi_pwd)] = { 0 }; - nvs.getString("wifi_ssid", ssid, sizeof(ssid)); - nvs.getString("wifi_pwd", pwd, sizeof(pwd)); - nvs.end(); + size_t n = sizeof(ssid); + if (nvs_get_str(nvs, "wifi_ssid", ssid, &n) != ESP_OK) ssid[0] = 0; // missing or too long + n = sizeof(pwd); + if (nvs_get_str(nvs, "wifi_pwd", pwd, &n) != ESP_OK) pwd[0] = 0; + nvs_close(nvs); if (MeshcomodPrefs::shouldImportWifi(prefs.wifi_ssid, ssid)) { memcpy(prefs.wifi_ssid, ssid, sizeof(prefs.wifi_ssid)); memcpy(prefs.wifi_pwd, pwd, sizeof(prefs.wifi_pwd)); diff --git a/src/helpers/MultiSerialInterface.h b/src/helpers/MultiSerialInterface.h index f7742b24c3..dc7cfd5f3a 100644 --- a/src/helpers/MultiSerialInterface.h +++ b/src/helpers/MultiSerialInterface.h @@ -2,6 +2,11 @@ #include "BaseSerialInterface.h" +// Some board libraries #define NONE (the Heltec mesh solar's meshsolar logger.h +// does), which breaks InterfaceType::NONE. Shield this header from it. +#pragma push_macro("NONE") +#undef NONE + #ifndef MAX_INTERFACES // ble, usb, wifi, ethernet #define MAX_INTERFACES 4 @@ -198,3 +203,5 @@ class MultiSerialInterface : public BaseSerialInterface { } }; + +#pragma pop_macro("NONE") diff --git a/variants/lilygo_tbeam_1w/platformio.ini b/variants/lilygo_tbeam_1w/platformio.ini index 0ba509a97e..d1ad2e3610 100644 --- a/variants/lilygo_tbeam_1w/platformio.ini +++ b/variants/lilygo_tbeam_1w/platformio.ini @@ -150,6 +150,8 @@ lib_deps = ; === LILYGO T-Beam 1W Companion Radio (WiFi) === [env:LilyGo_TBeam_1W_companion_radio_wifi] extends = LilyGo_TBeam_1W +; 16 MB flash: use it (the default 4 MB table leaves 1.25 MB app slots, too small) +board_build.partitions = default_16MB.csv build_flags = ${LilyGo_TBeam_1W.build_flags} -I examples/companion_radio/ui-new diff --git a/variants/station_g2/platformio.ini b/variants/station_g2/platformio.ini index 012081329b..1ec51c70d7 100644 --- a/variants/station_g2/platformio.ini +++ b/variants/station_g2/platformio.ini @@ -201,6 +201,8 @@ lib_deps = [env:Station_G2_companion_radio_ble] extends = Station_G2 +; 16 MB flash: use it (the default 4 MB table leaves 1.25 MB app slots, too small) +board_build.partitions = default_16MB.csv build_flags = ${Station_G2.build_flags} -I examples/companion_radio/ui-new @@ -221,6 +223,8 @@ lib_deps = [env:Station_G2_companion_radio_wifi] extends = Station_G2 +; 16 MB flash: use it (the default 4 MB table leaves 1.25 MB app slots, too small) +board_build.partitions = default_16MB.csv build_flags = ${Station_G2.build_flags} -I examples/companion_radio/ui-new diff --git a/variants/station_g3_esp32/platformio.ini b/variants/station_g3_esp32/platformio.ini index c813558a14..26082b3645 100644 --- a/variants/station_g3_esp32/platformio.ini +++ b/variants/station_g3_esp32/platformio.ini @@ -116,6 +116,8 @@ lib_deps = [env:Station_G3_ESP32_companion_radio_ble] extends = Station_G3_ESP32 +; 16 MB flash: use it (the default 4 MB table leaves 1.25 MB app slots, too small) +board_build.partitions = default_16MB.csv build_flags = ${Station_G3_ESP32.build_flags} -I examples/companion_radio/ui-new @@ -136,6 +138,8 @@ lib_deps = [env:Station_G3_ESP32_companion_radio_wifi] extends = Station_G3_ESP32 +; 16 MB flash: use it (the default 4 MB table leaves 1.25 MB app slots, too small) +board_build.partitions = default_16MB.csv build_flags = ${Station_G3_ESP32.build_flags} -I examples/companion_radio/ui-new