Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions examples/companion_radio/MeshcomodImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Preferences.h>
#include <nvs.h>
#endif

void importMeshcomodSettings(NodePrefs& prefs, DataStore& store) {
Expand Down Expand Up @@ -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));
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/MultiSerialInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -198,3 +203,5 @@ class MultiSerialInterface : public BaseSerialInterface {
}

};

#pragma pop_macro("NONE")
2 changes: 2 additions & 0 deletions variants/lilygo_tbeam_1w/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions variants/station_g2/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions variants/station_g3_esp32/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading