diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index 89ee8133..e3235128 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -8,11 +8,11 @@ #define FIRMWARE_VER_CODE 7 #ifndef FIRMWARE_BUILD_DATE -#define FIRMWARE_BUILD_DATE "31 Aug 2025" +#define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION -#define FIRMWARE_VERSION "v1.8.0" +#define FIRMWARE_VERSION "v1.8.1" #endif #if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index 22f394e7..c751eaf5 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -354,6 +354,9 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no #if defined(PIN_USER_BTN) user_btn.begin(); #endif +#if defined(PIN_USER_BTN_ANA) + analog_btn.begin(); +#endif _node_prefs = node_prefs; if (_display != NULL) { @@ -508,6 +511,14 @@ void UITask::loop() { c = handleLongPress(KEY_RIGHT); } #endif +#if defined(PIN_USER_BTN_ANA) + ev = analog_btn.check(); + if (ev == BUTTON_EVENT_CLICK) { + c = checkDisplayOn(KEY_SELECT); + } else if (ev == BUTTON_EVENT_LONG_PRESS) { + c = handleLongPress(KEY_ENTER); + } +#endif if (c != 0 && curr) { curr->handleInput(c); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 2fda6b85..565dc04a 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -22,11 +22,11 @@ /* ------------------------------ Config -------------------------------- */ #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "31 Aug 2025" + #define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.8.0" + #define FIRMWARE_VERSION "v1.8.1" #endif #ifndef LORA_FREQ @@ -732,6 +732,20 @@ public: mesh::LocalIdentity& getSelfId() override { return self_id; } + void saveIdentity(const mesh::LocalIdentity& new_id) override { + self_id = new_id; +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) + IdentityStore store(*_fs, ""); +#elif defined(ESP32) + IdentityStore store(*_fs, "/identity"); +#elif defined(RP2040_PLATFORM) + IdentityStore store(*_fs, "/identity"); +#else + #error "need to define saveIdentity()" +#endif + store.save("_main", self_id); + } + void clearStats() override { radio_driver.resetStats(); resetStats(); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 77e59d99..fd9c4397 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -22,11 +22,11 @@ /* ------------------------------ Config -------------------------------- */ #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "31 Aug 2025" + #define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.8.0" + #define FIRMWARE_VERSION "v1.8.1" #endif #ifndef LORA_FREQ @@ -865,6 +865,20 @@ public: mesh::LocalIdentity& getSelfId() override { return self_id; } + void saveIdentity(const mesh::LocalIdentity& new_id) override { + self_id = new_id; +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) + IdentityStore store(*_fs, ""); +#elif defined(ESP32) + IdentityStore store(*_fs, "/identity"); +#elif defined(RP2040_PLATFORM) + IdentityStore store(*_fs, "/identity"); +#else + #error "need to define saveIdentity()" +#endif + store.save("_main", self_id); + } + void clearStats() override { radio_driver.resetStats(); resetStats(); diff --git a/examples/simple_sensor/SensorMesh.cpp b/examples/simple_sensor/SensorMesh.cpp index ad295501..72c0d97b 100644 --- a/examples/simple_sensor/SensorMesh.cpp +++ b/examples/simple_sensor/SensorMesh.cpp @@ -837,6 +837,20 @@ bool SensorMesh::formatFileSystem() { #endif } +void SensorMesh::saveIdentity(const mesh::LocalIdentity& new_id) { + self_id = new_id; +#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM) + IdentityStore store(*_fs, ""); +#elif defined(ESP32) + IdentityStore store(*_fs, "/identity"); +#elif defined(RP2040_PLATFORM) + IdentityStore store(*_fs, "/identity"); +#else + #error "need to define saveIdentity()" +#endif + store.save("_main", self_id); +} + void SensorMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) { set_radio_at = futureMillis(2000); // give CLI reply some time to be sent back, before applying temp radio params pending_freq = freq; diff --git a/examples/simple_sensor/SensorMesh.h b/examples/simple_sensor/SensorMesh.h index ddcdf685..7b3b3954 100644 --- a/examples/simple_sensor/SensorMesh.h +++ b/examples/simple_sensor/SensorMesh.h @@ -49,11 +49,11 @@ struct ContactInfo { }; #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "31 Aug 2025" + #define FIRMWARE_BUILD_DATE "1 Sep 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.8.0" + #define FIRMWARE_VERSION "v1.8.1" #endif #define FIRMWARE_ROLE "sensor" @@ -89,6 +89,7 @@ public: strcpy(reply, "not supported"); } mesh::LocalIdentity& getSelfId() override { return self_id; } + void saveIdentity(const mesh::LocalIdentity& new_id) override; void clearStats() override { } void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override; diff --git a/library.json b/library.json index 982983a3..572c55b0 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "MeshCore", - "version" : "1.7.4", + "version" : "1.8.0", "dependencies": { "SPI": "*", "Wire": "*", @@ -13,4 +13,4 @@ "build": { "extraScript": "build_as_lib.py" } -} \ No newline at end of file +} diff --git a/platformio.ini b/platformio.ini index c7d4eff8..1c89465f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -53,7 +53,7 @@ build_src_filter = [esp32_base] extends = arduino_base -platform = platformio/espressif32@^6.11.0 +platform = platformio/espressif32@6.11.0 monitor_filters = esp32_exception_decoder extra_scripts = merge-bin.py build_flags = ${arduino_base.build_flags} diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 45dfe29b..7125e5b0 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -305,7 +305,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch uint8_t prv_key[PRV_KEY_SIZE]; bool success = mesh::Utils::fromHex(prv_key, PRV_KEY_SIZE, &config[8]); if (success) { - _callbacks->getSelfId().readFrom(prv_key, PRV_KEY_SIZE); + mesh::LocalIdentity new_id; + new_id.readFrom(prv_key, PRV_KEY_SIZE); + _callbacks->saveIdentity(new_id); strcpy(reply, "OK"); } else { strcpy(reply, "Error, invalid key"); diff --git a/src/helpers/CommonCLI.h b/src/helpers/CommonCLI.h index d1e49873..ff8ff50e 100644 --- a/src/helpers/CommonCLI.h +++ b/src/helpers/CommonCLI.h @@ -47,6 +47,7 @@ public: // no op by default }; virtual mesh::LocalIdentity& getSelfId() = 0; + virtual void saveIdentity(const mesh::LocalIdentity& new_id) = 0; virtual void clearStats() = 0; virtual void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) = 0; }; diff --git a/src/helpers/ui/MomentaryButton.cpp b/src/helpers/ui/MomentaryButton.cpp index 9ddf1327..36309600 100644 --- a/src/helpers/ui/MomentaryButton.cpp +++ b/src/helpers/ui/MomentaryButton.cpp @@ -8,16 +8,29 @@ MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse prev = _reverse ? HIGH : LOW; cancel = 0; _long_millis = long_press_millis; + _threshold = 0; +} + +MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, int analog_threshold) { + _pin = pin; + _reverse = false; + _pull = false; + down_at = 0; + prev = LOW; + cancel = 0; + _long_millis = long_press_millis; + _threshold = analog_threshold; } void MomentaryButton::begin() { - if (_pin >= 0) { + if (_pin >= 0 && _threshold == 0) { pinMode(_pin, _pull ? (_reverse ? INPUT_PULLUP : INPUT_PULLDOWN) : INPUT); } } bool MomentaryButton::isPressed() const { - return isPressed(digitalRead(_pin)); + int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin); + return isPressed(btn); } void MomentaryButton::cancelClick() { @@ -25,6 +38,9 @@ void MomentaryButton::cancelClick() { } bool MomentaryButton::isPressed(int level) const { + if (_threshold > 0) { + return level; + } if (_reverse) { return level == LOW; } else { @@ -36,7 +52,7 @@ int MomentaryButton::check(bool repeat_click) { if (_pin < 0) return BUTTON_EVENT_NONE; int event = BUTTON_EVENT_NONE; - int btn = digitalRead(_pin); + int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin); if (btn != prev) { if (isPressed(btn)) { down_at = millis(); diff --git a/src/helpers/ui/MomentaryButton.h b/src/helpers/ui/MomentaryButton.h index 0bcc776c..d002f652 100644 --- a/src/helpers/ui/MomentaryButton.h +++ b/src/helpers/ui/MomentaryButton.h @@ -11,12 +11,14 @@ class MomentaryButton { int8_t prev, cancel; bool _reverse, _pull; int _long_millis; + int _threshold; // analog mode unsigned long down_at; bool isPressed(int level) const; public: MomentaryButton(int8_t pin, int long_press_mills=0, bool reverse=false, bool pulldownup=false); + MomentaryButton(int8_t pin, int long_press_mills, int analog_threshold); void begin(); int check(bool repeat_click=false); // returns one of BUTTON_EVENT_* void cancelClick(); // suppress next BUTTON_EVENT_CLICK (if already in DOWN state) diff --git a/variants/heltec_v2/platformio.ini b/variants/heltec_v2/platformio.ini index ea41f845..352ea34d 100644 --- a/variants/heltec_v2/platformio.ini +++ b/variants/heltec_v2/platformio.ini @@ -64,7 +64,7 @@ lib_deps = extends = Heltec_lora32_v2 build_flags = ${Heltec_lora32_v2.build_flags} - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=170 -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -80,7 +80,7 @@ build_flags = ${Heltec_lora32_v2.build_flags} -I examples/companion_radio/ui-new -D DISPLAY_CLASS=SSD1306Display - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=170 -D MAX_GROUP_CHANNELS=8 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 @@ -100,7 +100,7 @@ build_flags = ${Heltec_lora32_v2.build_flags} -I examples/companion_radio/ui-new -D DISPLAY_CLASS=SSD1306Display - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=170 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index ba34cead..f545d898 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -17,7 +17,7 @@ build_flags = -D PIN_VEXT_EN=36 -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 - -D SX126X_CURRENT_LIMIT=160 + -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D PIN_GPS_RX=47 -D PIN_GPS_TX=48 @@ -87,7 +87,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=300 -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SSD1306Display ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 @@ -130,7 +130,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=300 -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SSD1306Display -D WIFI_DEBUG_LOGGING=1 @@ -207,7 +207,7 @@ lib_deps = extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=300 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 diff --git a/variants/lilygo_tbeam_SX1262/platformio.ini b/variants/lilygo_tbeam_SX1262/platformio.ini index 7bb008ac..ea8872de 100644 --- a/variants/lilygo_tbeam_SX1262/platformio.ini +++ b/variants/lilygo_tbeam_SX1262/platformio.ini @@ -24,7 +24,7 @@ build_src_filter = ${esp32_base.build_src_filter} +<../variants/lilygo_tbeam_SX1262> + + - + + + board_build.partitions = min_spiffs.csv ; get around 4mb flash limit lib_deps = ${esp32_base.lib_deps} @@ -38,7 +38,7 @@ board_build.upload.maximum_ram_size=2000000 build_flags = ${LilyGo_TBeam_SX1262.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D OFFLINE_QUEUE_SIZE=256 diff --git a/variants/lilygo_tbeam_SX1276/platformio.ini b/variants/lilygo_tbeam_SX1276/platformio.ini index e0391f1d..782b74c7 100644 --- a/variants/lilygo_tbeam_SX1276/platformio.ini +++ b/variants/lilygo_tbeam_SX1276/platformio.ini @@ -22,7 +22,7 @@ build_src_filter = ${esp32_base.build_src_filter} +<../variants/lilygo_tbeam_SX1276> + + - + + + board_build.partitions = min_spiffs.csv ; get around 4mb flash limit lib_deps = ${esp32_base.lib_deps} @@ -37,7 +37,7 @@ board_build.upload.maximum_ram_size=2000000 build_flags = ${LilyGo_TBeam_SX1276.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 ; -D BLE_DEBUG_LOGGING=1 diff --git a/variants/lilygo_tlora_v2_1/platformio.ini b/variants/lilygo_tlora_v2_1/platformio.ini index 0ed06856..05a87d70 100644 --- a/variants/lilygo_tlora_v2_1/platformio.ini +++ b/variants/lilygo_tlora_v2_1/platformio.ini @@ -68,7 +68,7 @@ lib_deps = extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -84,7 +84,7 @@ extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 @@ -102,7 +102,7 @@ extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D OFFLINE_QUEUE_SIZE=256 @@ -136,3 +136,23 @@ build_flags = lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} ${esp32_ota.lib_deps} + +[env:LilyGo_TLora_V2_1_1_6_companion_radio_wifi] +extends = LilyGo_TLora_V2_1_1_6 +build_flags = + ${LilyGo_TLora_V2_1_1_6.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=160 + -D MAX_GROUP_CHANNELS=8 + -D WIFI_SSID='"ssid"' + -D WIFI_PWD='"password"' + -D WIFI_DEBUG_LOGGING=1 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + + + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${LilyGo_TLora_V2_1_1_6.lib_deps} + densaugeo/base64 @ ~1.4.0 diff --git a/variants/meshadventurer/platformio.ini b/variants/meshadventurer/platformio.ini index 3ea09ba7..1b881c1a 100644 --- a/variants/meshadventurer/platformio.ini +++ b/variants/meshadventurer/platformio.ini @@ -80,6 +80,8 @@ extends = Meshadventurer build_src_filter = ${Meshadventurer.build_src_filter} +<../examples/companion_radio/*.cpp> + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> build_flags = ${Meshadventurer.build_flags} -I examples/companion_radio/ui-new diff --git a/variants/rak4631/target.cpp b/variants/rak4631/target.cpp index 618c9fc5..bc7465fd 100644 --- a/variants/rak4631/target.cpp +++ b/variants/rak4631/target.cpp @@ -10,7 +10,11 @@ RAK4631Board board; #ifdef DISPLAY_CLASS DISPLAY_CLASS display; - MomentaryButton user_btn(PIN_USER_BTN, 1000, true); + MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true); + + #if defined(PIN_USER_BTN_ANA) + MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20); + #endif #endif RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); diff --git a/variants/rak4631/target.h b/variants/rak4631/target.h index 5e93b7fc..aa6be664 100644 --- a/variants/rak4631/target.h +++ b/variants/rak4631/target.h @@ -13,6 +13,9 @@ extern DISPLAY_CLASS display; #include extern MomentaryButton user_btn; + #if defined(PIN_USER_BTN_ANA) + extern MomentaryButton analog_btn; + #endif #endif extern RAK4631Board board;