From 9e6129090d3410daf55f70c8a733885f4346ec3d Mon Sep 17 00:00:00 2001 From: Elektr0Vodka <211697683+Elektr0Vodka@users.noreply.github.com> Date: Fri, 16 Oct 2026 20:18:07 +0200 Subject: [PATCH 1/3] fix(companion): read meshcomod Wi-Fi from NVS without Preferences PlatformIO's library finder ignores the #if around the include, and the current RP2040 framework ships a library (iLabs Hearth) with its own Preferences.h, which then got built for the PicoW companions and failed. Use the IDF NVS API, the same storage Preferences wraps. --- examples/companion_radio/MeshcomodImport.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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)); From 857ab42c0e22c00745649b927dd7c4e540beda07 Mon Sep 17 00:00:00 2001 From: Elektr0Vodka <211697683+Elektr0Vodka@users.noreply.github.com> Date: Fri, 16 Oct 2026 20:18:07 +0200 Subject: [PATCH 2/3] fix(companion): shield InterfaceType from a NONE macro The Heltec mesh solar's meshsolar library defines NONE, which broke InterfaceType::NONE in Heltec_mesh_solar_companion_radio_ble. Push the macro out for the length of MultiSerialInterface.h. --- src/helpers/MultiSerialInterface.h | 7 +++++++ 1 file changed, 7 insertions(+) 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") From bfa80420983b64801fc82ff482aef43f58658e8e Mon Sep 17 00:00:00 2001 From: Elektr0Vodka <211697683+Elektr0Vodka@users.noreply.github.com> Date: Fri, 16 Oct 2026 20:18:08 +0200 Subject: [PATCH 3/3] fix(variants): use the 16 MB flash on Station G2/G3 and T-Beam 1W companions The boards have 16 MB flash but no partition table, so they got the 4 MB default with 1.25 MB app slots: the companion builds overflowed (BLE ones already, Wi-Fi ones with SNMP and OTA). Their companion envs now use default_16MB.csv (6.25 MB app slots). Moving a device to it needs the full -merged.bin flash once. --- variants/lilygo_tbeam_1w/platformio.ini | 2 ++ variants/station_g2/platformio.ini | 4 ++++ variants/station_g3_esp32/platformio.ini | 4 ++++ 3 files changed, 10 insertions(+) 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