From cf170915881f50150a309691898f2682d779a842 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Fri, 7 Mar 2025 17:19:27 +1100 Subject: [PATCH 01/48] * display.begin() delayed in setup(). * all firmwares now bumped to v1.2.0 --- examples/companion_radio/main.cpp | 9 +++------ examples/simple_repeater/main.cpp | 9 +++------ examples/simple_room_server/main.cpp | 9 +++------ src/helpers/ui/SSD1306Display.cpp | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index be2fed28..0a25f23a 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -120,11 +120,11 @@ static uint32_t _atoi(const char* sp) { #define FIRMWARE_VER_CODE 2 #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "3 Mar 2025" + #define FIRMWARE_BUILD_DATE "7 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.0.0" + #define FIRMWARE_VERSION "v1.2.0" #endif #define CMD_APP_START 1 @@ -1239,10 +1239,6 @@ void setup() { float tcxo = 1.6f; #endif -#ifdef DISPLAY_CLASS - display.begin(); -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); @@ -1303,6 +1299,7 @@ void setup() { #endif #ifdef DISPLAY_CLASS + display.begin(); ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, the_mesh.getBLEPin()); #endif } diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index a5f06c1d..d41fd3e7 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 "3 Mar 2025" + #define FIRMWARE_BUILD_DATE "7 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.0.0" + #define FIRMWARE_VERSION "v1.2.0" #endif #ifndef LORA_FREQ @@ -662,10 +662,6 @@ void setup() { float tcxo = 1.6f; #endif -#ifdef DISPLAY_CLASS - display.begin(); -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); @@ -719,6 +715,7 @@ void setup() { the_mesh.begin(fs); #ifdef DISPLAY_CLASS + display.begin(); ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE); #endif diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 04266e11..51e9ab3f 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 "6 Mar 2025" + #define FIRMWARE_BUILD_DATE "7 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.1.0" + #define FIRMWARE_VERSION "v1.2.0" #endif #ifndef LORA_FREQ @@ -716,10 +716,6 @@ void setup() { float tcxo = 1.6f; #endif -#ifdef DISPLAY_CLASS - display.begin(); -#endif - #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); @@ -772,6 +768,7 @@ void setup() { the_mesh.begin(fs); #ifdef DISPLAY_CLASS + display.begin(); ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE); #endif diff --git a/src/helpers/ui/SSD1306Display.cpp b/src/helpers/ui/SSD1306Display.cpp index 84db7d13..fe5be0ca 100644 --- a/src/helpers/ui/SSD1306Display.cpp +++ b/src/helpers/ui/SSD1306Display.cpp @@ -1,7 +1,7 @@ #include "SSD1306Display.h" bool SSD1306Display::begin() { - return display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_ADDRESS); + return display.begin(SSD1306_SWITCHCAPVCC, DISPLAY_ADDRESS, true, false); } void SSD1306Display::turnOn() { From ae8fb5d9b148fc963eecab0765e54622c41610fb Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Fri, 7 Mar 2025 21:37:05 +1100 Subject: [PATCH 02/48] * Heltec v3.2 VEXT fix * Heltec T114 LED fix, (now flashes with LoRa TX) --- platformio.ini | 1 + src/helpers/HeltecV3Board.h | 3 ++- src/helpers/nrf52/T114Board.cpp | 5 +++++ src/helpers/nrf52/T114Board.h | 9 +++++++++ variants/t114/variant.cpp | 2 -- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 631e78e5..e9a615d4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -688,6 +688,7 @@ board_build.ldscript = boards/nrf52840_s140_v6.ld build_flags = ${nrf52840_t114.build_flags} -Ivariants/t114 -DHELTEC_T114 + -D P_LORA_TX_LED=35 -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 diff --git a/src/helpers/HeltecV3Board.h b/src/helpers/HeltecV3Board.h index ce742efa..927d537e 100644 --- a/src/helpers/HeltecV3Board.h +++ b/src/helpers/HeltecV3Board.h @@ -29,7 +29,8 @@ public: ESP32Board::begin(); pinMode(PIN_ADC_CTRL, OUTPUT); - //pinMode(PIN_VEXT_EN, OUTPUT); + pinMode(PIN_VEXT_EN, OUTPUT); + digitalWrite(PIN_VEXT_EN, LOW); // for V3.2 boards esp_reset_reason_t reason = esp_reset_reason(); if (reason == ESP_RST_DEEPSLEEP) { diff --git a/src/helpers/nrf52/T114Board.cpp b/src/helpers/nrf52/T114Board.cpp index 4171bf34..d3d93999 100644 --- a/src/helpers/nrf52/T114Board.cpp +++ b/src/helpers/nrf52/T114Board.cpp @@ -32,6 +32,11 @@ void T114Board::begin() { Wire.begin(); #endif +#ifdef P_LORA_TX_LED + pinMode(P_LORA_TX_LED, OUTPUT); + digitalWrite(P_LORA_TX_LED, HIGH); +#endif + pinMode(SX126X_POWER_EN, OUTPUT); digitalWrite(SX126X_POWER_EN, HIGH); delay(10); // give sx1262 some time to power up diff --git a/src/helpers/nrf52/T114Board.h b/src/helpers/nrf52/T114Board.h index 47dde5c2..35056592 100644 --- a/src/helpers/nrf52/T114Board.h +++ b/src/helpers/nrf52/T114Board.h @@ -28,6 +28,15 @@ public: void begin(); uint8_t getStartupReason() const override { return startup_reason; } +#if defined(P_LORA_TX_LED) + void onBeforeTransmit() override { + digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on + } + void onAfterTransmit() override { + digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off + } +#endif + #define BATTERY_SAMPLES 8 uint16_t getBattMilliVolts() override { diff --git a/variants/t114/variant.cpp b/variants/t114/variant.cpp index 8387e038..4d07d1ae 100644 --- a/variants/t114/variant.cpp +++ b/variants/t114/variant.cpp @@ -11,6 +11,4 @@ const uint32_t g_ADigitalPinMap[] = { void initVariant() { - pinMode(LED_BUILTIN, OUTPUT); - ledOff(LED_BUILTIN); } From 808d3933c15d14751c58ff97ad1e9ceefe7799de Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Fri, 7 Mar 2025 22:01:30 +1100 Subject: [PATCH 03/48] Version bump to v1.2.1 --- examples/companion_radio/main.cpp | 2 +- examples/simple_repeater/main.cpp | 2 +- examples/simple_room_server/main.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 0a25f23a..5cfeac60 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -124,7 +124,7 @@ static uint32_t _atoi(const char* sp) { #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.0" + #define FIRMWARE_VERSION "v1.2.1" #endif #define CMD_APP_START 1 diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index d41fd3e7..2cdf074a 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -26,7 +26,7 @@ #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.0" + #define FIRMWARE_VERSION "v1.2.1" #endif #ifndef LORA_FREQ diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 51e9ab3f..56ad2c42 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -26,7 +26,7 @@ #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.0" + #define FIRMWARE_VERSION "v1.2.1" #endif #ifndef LORA_FREQ From 477f2e1d814961cdf578d22bb68876d890d77f63 Mon Sep 17 00:00:00 2001 From: Rastislav Vysoky Date: Fri, 7 Mar 2025 13:17:46 +0100 Subject: [PATCH 04/48] fix: added t114 and t-echo boards to uf2conv release workflow --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index d3ce6d46..f14b2f1c 100644 --- a/build.sh +++ b/build.sh @@ -57,8 +57,8 @@ build_firmware() { pio run -t mergebin -e $1 fi - # build .uf2 for RAK_4631 and t1000e - if [[ $1 == *"RAK_4631"* || $1 == *"t1000e"* ]]; then + # build .uf2 for nrf52 boards + if [[ $1 == *"RAK_4631"* || $1 == *"t1000e"* || $1 == *"t114"* || $1 == *"T-Echo"* ]]; then python bin/uf2conv/uf2conv.py .pio/build/$1/firmware.hex -c -o .pio/build/$1/firmware.uf2 -f 0xADA52840 fi From 708065a0ba0d75be4a9a22c45a31c72e0fc286b4 Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Fri, 7 Mar 2025 13:52:47 +0100 Subject: [PATCH 05/48] tx_power can be raised to 22dBm on LR1110 --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index e9a615d4..bc4cfbb8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -648,6 +648,7 @@ build_flags = ${nrf52840_t1000e.build_flags} -D PIN_USER_BTN=6 -D RADIO_CLASS=CustomLR1110 -D WRAPPER_CLASS=CustomLR1110Wrapper + -D MAX_LORA_TX_POWER=22 build_src_filter = ${nrf52840_t1000e.build_src_filter} + + From acac20dc89b6bc183125bcb9341eb33c56e1ece8 Mon Sep 17 00:00:00 2001 From: Rastislav Vysoky Date: Fri, 7 Mar 2025 15:34:00 +0100 Subject: [PATCH 06/48] Added basic support for Station G2 --- boards/station-g2.json | 43 ++++ examples/simple_repeater/main.cpp | 6 +- examples/simple_room_server/main.cpp | 18 +- platformio.ini | 303 ++++++++++++++++++--------- src/helpers/StationG2Board.h | 69 ++++++ 5 files changed, 328 insertions(+), 111 deletions(-) create mode 100644 boards/station-g2.json create mode 100644 src/helpers/StationG2Board.h diff --git a/boards/station-g2.json b/boards/station-g2.json new file mode 100644 index 00000000..8ea6ebc6 --- /dev/null +++ b/boards/station-g2.json @@ -0,0 +1,43 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [["0x303A", "0x1001"]], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "BQ Station G2", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://wiki.uniteng.com/en/meshtastic/station-g2", + "vendor": "BQ Consulting" +} diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 2cdf074a..a6ddcfda 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -76,10 +76,14 @@ #include #include static ESP32Board board; - #elif defined(LILYGO_TLORA) +#elif defined(LILYGO_TLORA) #include #include static LilyGoTLoraBoard board; +#elif defined(STATION_G2) + #include + #include + static StationG2Board board; #elif defined(RAK_4631) #include #include diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 56ad2c42..a0d6ced1 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -59,7 +59,7 @@ #define ADMIN_PASSWORD "password" #endif -#ifndef MAX_CLIENTS +#ifndef MAX_CLIENTS #define MAX_CLIENTS 32 #endif @@ -84,6 +84,10 @@ #include #include static LilyGoTLoraBoard board; +#elif defined(STATION_G2) + #include + #include + static StationG2Board board; #elif defined(RAK_4631) #include #include @@ -265,7 +269,7 @@ protected: return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time); } - const char* getLogDateTime() override { + const char* getLogDateTime() override { static char tmp[32]; uint32_t now = getRTCClock()->getCurrentTime(); DateTime dt = DateTime(now); @@ -470,7 +474,7 @@ protected: } else { memcpy(&data[5], &forceSince, 4); // make sure there are zeroes in payload (for ack_hash calc below) } - if (forceSince > 0) { + if (forceSince > 0) { client->sync_since = forceSince; // force-update the 'sync since' } @@ -525,7 +529,7 @@ protected: public: MyMesh(RADIO_CLASS& phy, mesh::MainBoard& board, RadioLibWrapper& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables) - : mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables), + : mesh::Mesh(radio, ms, rng, rtc, *new StaticPoolPacketManager(32), tables), _phy(&phy), _board(&board), _cli(board, this, &_prefs, this) { my_radio = &radio; @@ -593,7 +597,7 @@ public: return false; #endif } - + void sendSelfAdvertisement(int delay_millis) override { mesh::Packet* pkt = createSelfAdvert(); if (pkt) { @@ -688,7 +692,7 @@ SimpleMeshTables tables; #ifdef ESP32 ESP32RTCClock fallback_clock; #else -VolatileRTCClock fallback_clock; +VolatileRTCClock fallback_clock; #endif AutoDiscoverRTCClock rtc_clock(fallback_clock); @@ -780,7 +784,7 @@ void loop() { int len = strlen(command); while (Serial.available() && len < sizeof(command)-1) { char c = Serial.read(); - if (c != '\n') { + if (c != '\n') { command[len++] = c; command[len] = 0; } diff --git a/platformio.ini b/platformio.ini index e9a615d4..ffbb502f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,7 +22,9 @@ build_flags = -w -DNDEBUG -DRADIOLIB_STATIC_ONLY=1 -DRADIOLIB_GODMODE=1 -D LORA_FREQ=867.5 -D LORA_BW=250 -D LORA_SF=10 -build_src_filter = +<*.cpp> + +build_src_filter = + +<*.cpp> + + [esp32_base] extends = arduino_base @@ -54,7 +56,8 @@ build_flags = -D ADMIN_PASSWORD="\"password\"" ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v2.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${Heltec_lora32_v2.build_src_filter} + +<../examples/simple_repeater/main.cpp> [env:Heltec_v2_terminal_chat] extends = Heltec_lora32_v2 @@ -64,7 +67,8 @@ build_flags = -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v2.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${Heltec_lora32_v2.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> lib_deps = ${Heltec_lora32_v2.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -77,7 +81,9 @@ build_flags = -D MAX_GROUP_CHANNELS=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v2.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${Heltec_lora32_v2.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${Heltec_lora32_v2.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -94,7 +100,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v2.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${Heltec_lora32_v2.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${Heltec_lora32_v2.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -133,11 +141,15 @@ build_flags = -D ADMIN_PASSWORD="\"password\"" -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/simple_repeater> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + +<../examples/simple_repeater> [env:Heltec_v3_room_server] extends = Heltec_lora32_v3 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/simple_room_server> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + +<../examples/simple_room_server> build_flags = ${Heltec_lora32_v3.build_flags} -D DISPLAY_CLASS=SSD1306Display @@ -157,7 +169,8 @@ build_flags = -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -173,7 +186,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/companion_radio> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -191,7 +206,10 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + +<../examples/companion_radio> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -208,7 +226,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/companion_radio> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -227,7 +247,10 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + +<../examples/companion_radio> +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + + + +<../examples/companion_radio> lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -253,7 +276,8 @@ build_flags = [env:Xiao_C3_Repeater_sx1262] extends = Xiao_esp32_C3 -build_src_filter = ${Xiao_esp32_C3.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${Xiao_esp32_C3.build_src_filter} + +<../examples/simple_repeater/main.cpp> build_flags = ${Xiao_esp32_C3.build_flags} -D RADIO_CLASS=CustomSX1262 @@ -268,7 +292,8 @@ build_flags = [env:Xiao_C3_Repeater_sx1268] extends = Xiao_esp32_C3 -build_src_filter = ${Xiao_esp32_C3.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${Xiao_esp32_C3.build_src_filter} + +<../examples/simple_repeater/main.cpp> build_flags = ${Xiao_esp32_C3.build_flags} -D RADIO_CLASS=CustomSX1268 @@ -305,7 +330,8 @@ build_flags = ${esp32_base.build_flags} [env:Xiao_S3_WIO_Repeater] extends = Xiao_S3_WIO -build_src_filter = ${Xiao_S3_WIO.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${Xiao_S3_WIO.build_src_filter} + +<../examples/simple_repeater/main.cpp> build_flags = ${Xiao_S3_WIO.build_flags} -D ADVERT_NAME="\"XiaoS3 Repeater\"" @@ -323,7 +349,8 @@ build_flags = -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Xiao_S3_WIO.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${Xiao_S3_WIO.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> lib_deps = ${Xiao_S3_WIO.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -340,7 +367,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Xiao_S3_WIO.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${Xiao_S3_WIO.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${Xiao_S3_WIO.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -370,6 +399,84 @@ build_flags = -D WRAPPER_CLASS=CustomSX1276Wrapper -D LORA_TX_POWER=20 +; === LILYGO T-LoRa V2.1-1.6 with SX1276 environments === +[env:LilyGo_TLora_V2_1_1_6_Repeater] +extends = LilyGo_TLora_V2_1_1_6 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/simple_repeater/main.cpp> +build_flags = + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D ADVERT_NAME="\"TLora-V2.1-1.6 Repeater\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +; -D CORE_DEBUG_LEVEL=3 + +[env:LilyGo_TLora_V2_1_1_6_terminal_chat] +extends = LilyGo_TLora_V2_1_1_6 +build_flags = + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> +lib_deps = + ${LilyGo_TLora_V2_1_1_6.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_TLora_V2_1_1_6_companion_radio_usb] +extends = LilyGo_TLora_V2_1_1_6 +build_flags = + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/companion_radio/main.cpp> +lib_deps = + ${LilyGo_TLora_V2_1_1_6.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_TLora_V2_1_1_6_companion_radio_ble] +extends = LilyGo_TLora_V2_1_1_6 +build_flags = + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 + -D BLE_PIN_CODE=123456 +; -D BLE_DEBUG_LOGGING=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + + + +<../examples/companion_radio/main.cpp> +lib_deps = + ${LilyGo_TLora_V2_1_1_6.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_TLora_V2_1_1_6_room_server] +extends = LilyGo_TLora_V2_1_1_6 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/simple_room_server/main.cpp> +build_flags = + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D ADVERT_NAME="\"TLora-V2.1-1.6 Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + ; ============= [LilyGo_T3S3_sx1262] extends = esp32_base @@ -392,83 +499,11 @@ build_flags = ${esp32_base.build_flags} -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 - -; === LILYGO T-LoRa V2.1-1.6 with SX1276 environments === -[env:LilyGo_TLora_V2_1_1_6_Repeater] -extends = LilyGo_TLora_V2_1_1_6 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_repeater/main.cpp> -build_flags = - ${LilyGo_TLora_V2_1_1_6.build_flags} - -D ADVERT_NAME="\"TLora-V2.1-1.6 Repeater\"" - -D ADVERT_LAT=-37.0 - -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 -; -D CORE_DEBUG_LEVEL=3 - -[env:LilyGo_TLora_V2_1_1_6_terminal_chat] -extends = LilyGo_TLora_V2_1_1_6 -build_flags = - ${LilyGo_TLora_V2_1_1_6.build_flags} - -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_secure_chat/main.cpp> -lib_deps = - ${LilyGo_TLora_V2_1_1_6.lib_deps} - densaugeo/base64 @ ~1.4.0 - -[env:LilyGo_TLora_V2_1_1_6_companion_radio_usb] -extends = LilyGo_TLora_V2_1_1_6 -build_flags = - ${LilyGo_TLora_V2_1_1_6.build_flags} - -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 -; -D ENABLE_PRIVATE_KEY_IMPORT=1 -; -D ENABLE_PRIVATE_KEY_EXPORT=1 -; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 -; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/companion_radio/main.cpp> -lib_deps = - ${LilyGo_TLora_V2_1_1_6.lib_deps} - densaugeo/base64 @ ~1.4.0 - -[env:LilyGo_TLora_V2_1_1_6_companion_radio_ble] -extends = LilyGo_TLora_V2_1_1_6 -build_flags = - ${LilyGo_TLora_V2_1_1_6.build_flags} - -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 - -D BLE_PIN_CODE=123456 -; -D BLE_DEBUG_LOGGING=1 -; -D ENABLE_PRIVATE_KEY_IMPORT=1 -; -D ENABLE_PRIVATE_KEY_EXPORT=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/companion_radio/main.cpp> -lib_deps = - ${LilyGo_TLora_V2_1_1_6.lib_deps} - densaugeo/base64 @ ~1.4.0 - -[env:LilyGo_TLora_V2_1_1_6_room_server] -extends = LilyGo_TLora_V2_1_1_6 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_room_server/main.cpp> -build_flags = - ${LilyGo_TLora_V2_1_1_6.build_flags} - -D ADVERT_NAME="\"TLora-V2.1-1.6 Room\"" - -D ADVERT_LAT=-37.0 - -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 - ; === LilyGo T3S3 with SX1262 environments === [env:LilyGo_T3S3_sx1262_Repeater] extends = LilyGo_T3S3_sx1262 -build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} + +<../examples/simple_repeater/main.cpp> build_flags = ${LilyGo_T3S3_sx1262.build_flags} -D ADVERT_NAME="\"T3S3-1262 Repeater\"" @@ -486,7 +521,8 @@ build_flags = -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -501,7 +537,8 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} + +<../examples/companion_radio/main.cpp> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -518,11 +555,59 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${LilyGo_T3S3_sx1262.lib_deps} densaugeo/base64 @ ~1.4.0 +[Station_G2] +extends = esp32_base +board = station-g2 +build_flags = + ${esp32_base.build_flags} + -D STATION_G2 + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=7 +; -D P_LORA_TX_LED=35 +; -D PIN_BOARD_SDA=5 +; -D PIN_BOARD_SCL=6 + -D PIN_USER_BTN=0 + -D SX126X_DIO2_AS_RF_SWITCH=true + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 + -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! +build_src_filter = ${esp32_base.build_src_filter} +lib_deps = + ${esp32_base.lib_deps} + +[env:Station_G2_repeater] +extends = Station_G2 +build_flags = + ${Station_G2.build_flags} + -D ADVERT_NAME="\"Station G2 Repeater\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Station_G2.build_src_filter} + +<../examples/simple_repeater> + +[env:Station_G2_room_server] +extends = Station_G2 +build_src_filter = ${Station_G2.build_src_filter} + +<../examples/simple_room_server> +build_flags = + ${Station_G2.build_flags} + -D ADVERT_NAME="\"Station G2 Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 ; ----------------- NRF52 --------------------- [nrf52_base] @@ -544,7 +629,8 @@ extends = nrf52840_base platform = https://github.com/maxgerhardt/platform-nordicnrf52.git#rak board = wiscore_rak4631 board_check = true -build_src_filter = ${nrf52840_base.build_src_filter} + +build_src_filter = ${nrf52840_base.build_src_filter} + + build_flags = ${nrf52840_base.build_flags} -D RAK_4631 -D RADIO_CLASS=CustomSX1262 @@ -554,7 +640,8 @@ build_flags = ${nrf52840_base.build_flags} [env:RAK_4631_Repeater] extends = rak4631 -build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${rak4631.build_src_filter} + +<../examples/simple_repeater/main.cpp> build_flags = ${rak4631.build_flags} -D ADVERT_NAME="\"RAK4631 Repeater\"" @@ -566,7 +653,8 @@ build_flags = [env:RAK_4631_room_server] extends = rak4631 -build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_room_server/main.cpp> +build_src_filter = ${rak4631.build_src_filter} + +<../examples/simple_room_server/main.cpp> build_flags = ${rak4631.build_flags} -D ADVERT_NAME="\"Test Room\"" @@ -585,7 +673,8 @@ build_flags = -D MAX_GROUP_CHANNELS=1 -D MESH_PACKET_LOGGING=1 -D MESH_DEBUG=1 -build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${rak4631.build_src_filter} + +<../examples/simple_secure_chat/main.cpp> lib_deps = ${rak4631.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -600,7 +689,8 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${rak4631.build_src_filter} +<../examples/companion_radio/main.cpp> +build_src_filter = ${rak4631.build_src_filter} + +<../examples/companion_radio/main.cpp> lib_deps = ${rak4631.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -617,7 +707,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${rak4631.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${rak4631.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${rak4631.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -702,7 +794,8 @@ upload_protocol = nrfutil [env:Heltec_t114_repeater] extends = Heltec_t114 -build_src_filter = ${Heltec_t114.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${Heltec_t114.build_src_filter} + +<../examples/simple_repeater/main.cpp> build_flags = ${Heltec_t114.build_flags} -D ADVERT_NAME="\"Heltec_T114 Repeater\"" @@ -724,7 +817,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_t114.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${Heltec_t114.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${Heltec_t114.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -782,7 +877,9 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_Techo.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_Techo.build_src_filter} + + + +<../examples/companion_radio/main.cpp> lib_deps = ${LilyGo_Techo.lib_deps} densaugeo/base64 @ ~1.4.0 diff --git a/src/helpers/StationG2Board.h b/src/helpers/StationG2Board.h new file mode 100644 index 00000000..2e31571f --- /dev/null +++ b/src/helpers/StationG2Board.h @@ -0,0 +1,69 @@ +#pragma once + +#include + +// LoRa radio module pins for Station G2 +#define P_LORA_DIO_1 48 +#define P_LORA_NSS 11 +#define P_LORA_RESET 21 +#define P_LORA_BUSY 47 +#define P_LORA_SCLK 12 +#define P_LORA_MISO 14 +#define P_LORA_MOSI 13 + +// built-ins +//#define PIN_LED_BUILTIN 35 +//#define PIN_VEXT_EN 36 + +#include "ESP32Board.h" + +#include + +class StationG2Board : public ESP32Board { +public: + void begin() { + ESP32Board::begin(); + + esp_reset_reason_t reason = esp_reset_reason(); + if (reason == ESP_RST_DEEPSLEEP) { + long wakeup_source = esp_sleep_get_ext1_wakeup_status(); + if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep) + startup_reason = BD_STARTUP_RX_PACKET; + } + + rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS); + rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1); + } + } + + void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) { + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); + + // Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep + rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY); + rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1); + + rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS); + + if (pin_wake_btn < 0) { + esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet + } else { + esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn + } + + if (secs > 0) { + esp_sleep_enable_timer_wakeup(secs * 1000000); + } + + // Finally set ESP32 into sleep + esp_deep_sleep_start(); // CPU halts here and never returns! + } + + uint16_t getBattMilliVolts() override { + return 0; + } + + const char* getManufacturerName() const override { + return "Station G2"; + } +}; From a5fb3acc9b0a1a0aa5202094de3238c2b7b8dc01 Mon Sep 17 00:00:00 2001 From: Diego Munhoz Date: Fri, 7 Mar 2025 11:41:53 -0600 Subject: [PATCH 07/48] add: BLE_NAME_PREFIX flag --- examples/companion_radio/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 5cfeac60..6f4db19e 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1272,7 +1272,13 @@ void setup() { #ifdef BLE_PIN_CODE char dev_name[32+10]; - sprintf(dev_name, "MeshCore-%s", the_mesh.getNodeName()); + const char* prefix = + #ifdef BLE_NAME_PREFIX + BLE_NAME_PREFIX; + #else + "MeshCore-"; + #endif + sprintf(dev_name, "%s%s", prefix, the_mesh.getNodeName()); serial_interface.begin(dev_name, the_mesh.getBLEPin()); #else pinMode(WB_IO2, OUTPUT); @@ -1288,7 +1294,13 @@ void setup() { serial_interface.begin(TCP_PORT); #elif defined(BLE_PIN_CODE) char dev_name[32+10]; - sprintf(dev_name, "MeshCore-%s", the_mesh.getNodeName()); + const char* prefix = + #ifdef BLE_NAME_PREFIX + BLE_NAME_PREFIX; + #else + "MeshCore-"; + #endif + sprintf(dev_name, "%s%s", prefix, the_mesh.getNodeName()); serial_interface.begin(dev_name, the_mesh.getBLEPin()); #else serial_interface.begin(Serial); From 37652459a11cbfb812eb92e2dc599ea52fe6fe15 Mon Sep 17 00:00:00 2001 From: Alex Wolden Date: Fri, 7 Mar 2025 13:18:24 -0800 Subject: [PATCH 08/48] Enable SSD1306 display class for LilyGo_TLora_V2_1_1_6 --- platformio.ini | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index e9a615d4..c3ad2b25 100644 --- a/platformio.ini +++ b/platformio.ini @@ -365,10 +365,15 @@ build_flags = -D P_LORA_MOSI=27 ; SPI MOSI -D P_LORA_TX_LED=2 ; LED pin for TX indication -D PIN_VBAT_READ=35 ; Battery voltage reading (analog pin) + -D PIN_USER_BTN=0 -D RADIO_CLASS=CustomSX1276 -D ARDUINO_LOOP_STACK_SIZE=16384 + -D DISPLAY_CLASS=SSD1306Display -D WRAPPER_CLASS=CustomSX1276Wrapper -D LORA_TX_POWER=20 +lib_deps = + ${esp32_base.lib_deps} + adafruit/Adafruit SSD1306 @ ^2.5.13 ; ============= [LilyGo_T3S3_sx1262] @@ -396,7 +401,7 @@ build_flags = ${esp32_base.build_flags} ; === LILYGO T-LoRa V2.1-1.6 with SX1276 environments === [env:LilyGo_TLora_V2_1_1_6_Repeater] extends = LilyGo_TLora_V2_1_1_6 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/simple_repeater> build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -D ADVERT_NAME="\"TLora-V2.1-1.6 Repeater\"" @@ -415,7 +420,7 @@ build_flags = -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/simple_repeater> lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -430,7 +435,7 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/companion_radio> lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} densaugeo/base64 @ ~1.4.0 @@ -447,14 +452,14 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/companion_radio> lib_deps = ${LilyGo_TLora_V2_1_1_6.lib_deps} densaugeo/base64 @ ~1.4.0 [env:LilyGo_TLora_V2_1_1_6_room_server] extends = LilyGo_TLora_V2_1_1_6 -build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_room_server/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/simple_room_server> build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -D ADVERT_NAME="\"TLora-V2.1-1.6 Room\"" From 87d4285cf1ef37bbf17e93d6a6f3f9bff3ef1ceb Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sat, 8 Mar 2025 13:40:39 +1100 Subject: [PATCH 09/48] * doc updates --- README.md | 12 +++++++----- docs/faq.md | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 97890ce8..0103da77 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,11 @@ MeshCore provides the ability to create wireless mesh networks, similar to Mesht ## 🚀 How to Get Started -Flash the Firmware: Download the pre-built firmware binary for Heltec V3 and flash it using Adafruit ESPTool. -Install [PlatformIO](https://docs.platformio.org) in Visual Studio Code (optional for developers who want to modify the firmware). +Andy Kirby has published a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) which explains the steps for beginners. + +For developers, install [PlatformIO](https://docs.platformio.org) in Visual Studio Code. Download & Open the MeshCore repository. -Select a Sample Application: Choose from chat, ping, repeater, or admin test tools. +Select a Sample Application: Choose from chat, repeater, other example app. Monitor & Communicate using the Serial Monitor (e.g., Serial USB Terminal on Android). 📁 Included Example Applications @@ -36,8 +37,6 @@ Monitor & Communicate using the Serial Monitor (e.g., Serial USB Terminal on And * 📡 Simple Repeater: Extends network coverage by relaying messages. * 📡 Companion Radio: For use with an external chat app, over BLE or USB. * 📡 Room Server: A simple BBS server for shared Posts. -* 📡 Ping Client, Ping Server & Client: Basic client/server example. -* 📡 Test Admin: Monitors and manages repeaters remotely. ## 🛠 Hardware Compatibility @@ -49,6 +48,9 @@ MeshCore is designed for use with: * LilyGo T3S3 * Heltec T114 * Station G2 +* Sensecap T1000e +* Heltec V2 +* LilyGo TLora32 v1.6 ## 📜 License MeshCore is open-source software released under the MIT License. You are free to use, modify, and distribute it for personal and commercial projects. diff --git a/docs/faq.md b/docs/faq.md index a7169a0e..eb5fdf29 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -26,6 +26,7 @@ Anyone is able to build anything they like on top of MeshCore without paying any Phone Client Applications: https://meshcore.co.uk/apps.html MeshCore Fimrware Github: https://github.com/ripplebiz/MeshCore + NOTE: Andy Kirby has a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) for beginners. You need LoRa hardware devices to run MeshCore firmware as clients or server (repeater and room server). From b1a5badf985d02eab51b6932da23bfb2cf538596 Mon Sep 17 00:00:00 2001 From: Rastislav Vysoky Date: Sat, 8 Mar 2025 09:15:51 +0100 Subject: [PATCH 10/48] added room server roles to t114 and t-echo; added repeater and room server roles to WSL3; unified json intendations in /boards --- boards/t-echo.json | 120 +++++++++++++-------------- boards/t3_s3_v1_x.json | 82 +++++++++--------- examples/simple_room_server/main.cpp | 8 ++ platformio.ini | 91 +++++++++++++++----- 4 files changed, 181 insertions(+), 120 deletions(-) diff --git a/boards/t-echo.json b/boards/t-echo.json index dee7297c..6bfa64df 100644 --- a/boards/t-echo.json +++ b/boards/t-echo.json @@ -1,62 +1,62 @@ { - "build": { - "arduino": { - "ldscript": "nrf52840_s140_v6.ld" - }, - "core": "nRF5", - "cpu": "cortex-m4", - "extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA", - "f_cpu": "64000000L", - "hwids": [ - [ - "0x239A", - "0x8029" - ] - ], - "usb_product": "NRF52 DK", - "mcu": "nrf52840", - "variant": "pca10056", - "bsp": { - "name": "adafruit" - }, - "softdevice": { - "sd_flags": "-DS140", - "sd_name": "s140", - "sd_version": "6.1.1", - "sd_fwid": "0x00B6" - }, - "bootloader": { - "settings_addr": "0xFF000" - } - }, - "connectivity": [ - "bluetooth" - ], - "debug": { - "jlink_device": "nRF52840_xxAA", - "onboard_tools": [ - "jlink" - ], - "svd_path": "nrf52840.svd" - }, - "frameworks": [ - "arduino" - ], - "name": "LilyGo T-ECHO", - "upload": { - "maximum_ram_size": 248832, - "maximum_size": 815104, - "require_upload_port": true, - "speed": 115200, - "protocol": "jlink", - "protocols": [ - "jlink", - "nrfjprog", - "stlink", - "cmsis-dap", - "blackmagic" - ] - }, - "url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/", - "vendor": "Nordic" + "build": { + "arduino": { + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + [ + "0x239A", + "0x8029" + ] + ], + "usb_product": "NRF52 DK", + "mcu": "nrf52840", + "variant": "pca10056", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": [ + "bluetooth" + ], + "debug": { + "jlink_device": "nRF52840_xxAA", + "onboard_tools": [ + "jlink" + ], + "svd_path": "nrf52840.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "LilyGo T-ECHO", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "require_upload_port": true, + "speed": 115200, + "protocol": "jlink", + "protocols": [ + "jlink", + "nrfjprog", + "stlink", + "cmsis-dap", + "blackmagic" + ] + }, + "url": "https://os.mbed.com/platforms/Nordic-nRF52840-DK/", + "vendor": "Nordic" } \ No newline at end of file diff --git a/boards/t3_s3_v1_x.json b/boards/t3_s3_v1_x.json index 49f9171c..d09c354a 100644 --- a/boards/t3_s3_v1_x.json +++ b/boards/t3_s3_v1_x.json @@ -1,45 +1,45 @@ { - "build": { - "arduino": { - "ldscript": "esp32s3_out.ld", - "partitions": "default.csv", - "memory_type": "qio_qspi" - }, - "core": "esp32", - "extra_flags": [ - "-DARDUINO_LILYGO_T3_S3_V1_X", - "-DBOARD_HAS_PSRAM", - "-DARDUINO_USB_CDC_ON_BOOT=1", - "-DARDUINO_RUNNING_CORE=1", - "-DARDUINO_EVENT_RUNNING_CORE=1", - "-DARDUINO_USB_MODE=1" - ], - "f_cpu": "240000000L", - "f_flash": "80000000L", - "flash_mode": "qio", - "mcu": "esp32s3", - "variant": "esp32s3" + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "partitions": "default.csv", + "memory_type": "qio_qspi" }, - "connectivity": [ - "wifi" + "core": "esp32", + "extra_flags": [ + "-DARDUINO_LILYGO_T3_S3_V1_X", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1", + "-DARDUINO_USB_MODE=1" ], - "debug": { - "openocd_target": "esp32s3.cfg" - }, - "frameworks": [ - "arduino", - "espidf" - ], - "name": "LilyGo T3-S3 Radio", - "upload": { - "flash_size": "4MB", - "maximum_ram_size": 327680, - "maximum_size": 4194304, - "use_1200bps_touch": true, - "wait_for_upload_port": true, - "require_upload_port": true, - "speed": 460800 - }, - "url": "https://www.lilygo.cc", - "vendor": "LilyGo" + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LilyGo T3-S3 Radio", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://www.lilygo.cc", + "vendor": "LilyGo" } \ No newline at end of file diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index a0d6ced1..81d1a6d9 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -92,6 +92,14 @@ #include #include static RAK4631Board board; +#elif defined(HELTEC_T114) + #include + #include + static T114Board board; +#elif defined(LILYGO_TECHO) + #include + #include + static TechoBoard board; #else #error "need to provide a 'board' object" #endif diff --git a/platformio.ini b/platformio.ini index ffbb502f..16c6fed7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -214,25 +214,6 @@ lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 -[env:Heltec_WSL3_companion_radio_ble] -extends = Heltec_lora32_v3 -build_flags = - ${Heltec_lora32_v3.build_flags} - -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 - -D BLE_PIN_CODE=123456 - -D BLE_DEBUG_LOGGING=1 -; -D ENABLE_PRIVATE_KEY_IMPORT=1 -; -D ENABLE_PRIVATE_KEY_EXPORT=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 -build_src_filter = ${Heltec_lora32_v3.build_src_filter} - + - +<../examples/companion_radio> -lib_deps = - ${Heltec_lora32_v3.lib_deps} - densaugeo/base64 @ ~1.4.0 - [env:Heltec_v3_companion_radio_wifi] extends = Heltec_lora32_v3 build_flags = @@ -255,6 +236,52 @@ lib_deps = ${Heltec_lora32_v3.lib_deps} densaugeo/base64 @ ~1.4.0 +[env:Heltec_WSL3_repeater] +extends = Heltec_lora32_v3 +build_flags = + ${Heltec_lora32_v3.build_flags} + -D ADVERT_NAME="\"Heltec Repeater\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/simple_repeater> + +[env:Heltec_WSL3_room_server] +extends = Heltec_lora32_v3 +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + +<../examples/simple_room_server> +build_flags = + ${Heltec_lora32_v3.build_flags} + -D ADVERT_NAME="\"Heltec Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + +[env:Heltec_WSL3_companion_radio_ble] +extends = Heltec_lora32_v3 +build_flags = + ${Heltec_lora32_v3.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 +; -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D ENABLE_PRIVATE_KEY_EXPORT=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Heltec_lora32_v3.build_src_filter} + + + +<../examples/companion_radio> +lib_deps = + ${Heltec_lora32_v3.lib_deps} + densaugeo/base64 @ ~1.4.0 + ; ================ [Xiao_esp32_C3] extends = esp32_base @@ -805,6 +832,20 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +[env:Heltec_t114_room_server] +extends = Heltec_t114 +build_src_filter = ${Heltec_t114.build_src_filter} + +<../examples/simple_room_server> +build_flags = + ${Heltec_t114.build_flags} + -D ADVERT_NAME="\"Heltec_T114 Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + [env:Heltec_t114_companion_radio_ble] extends = Heltec_t114 build_flags = @@ -865,6 +906,18 @@ build_flags = ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +[env:LilyGo_T-Echo_room_server] +extends = LilyGo_Techo +build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_room_server/main.cpp> +build_flags = + ${LilyGo_Techo.build_flags} + -D ADVERT_NAME="\"T-Echo Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 + [env:LilyGo_T-Echo_companion_radio_ble] extends = LilyGo_Techo build_flags = From 2889867c4c6a73ab2d5d5eb5955ad21a2c44f646 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sat, 8 Mar 2025 19:38:36 +1100 Subject: [PATCH 11/48] * Dispatcher: added guard for packet payload size too large --- src/Dispatcher.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Dispatcher.cpp b/src/Dispatcher.cpp index 3c351eb7..b9da0e65 100644 --- a/src/Dispatcher.cpp +++ b/src/Dispatcher.cpp @@ -106,10 +106,16 @@ void Dispatcher::checkRecv() { memcpy(pkt->path, &raw[i], pkt->path_len); i += pkt->path_len; pkt->payload_len = len - i; // payload is remainder - memcpy(pkt->payload, &raw[i], pkt->payload_len); + if (pkt->payload_len > sizeof(pkt->payload)) { + MESH_DEBUG_PRINTLN("%s Dispatcher::checkRecv(): packet payload too big, payload_len=%d", getLogDateTime(), (uint32_t)pkt->payload_len); + _mgr->free(pkt); // put back into pool + pkt = NULL; + } else { + memcpy(pkt->payload, &raw[i], pkt->payload_len); - score = _radio->packetScore(_radio->getLastSNR(), len); - air_time = _radio->getEstAirtimeFor(len); + score = _radio->packetScore(_radio->getLastSNR(), len); + air_time = _radio->getEstAirtimeFor(len); + } } } } else { From 5acfe52417cd31ab40676bab08938c7553340d4c Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sat, 8 Mar 2025 19:59:07 +1100 Subject: [PATCH 12/48] * new build option: SX126X_RX_BOOSTED_GAIN --- examples/companion_radio/main.cpp | 4 +++- examples/simple_repeater/main.cpp | 4 +++- examples/simple_room_server/main.cpp | 4 +++- platformio.ini | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 5cfeac60..ea5efc5e 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1257,10 +1257,12 @@ void setup() { #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); #endif - #ifdef SX126X_DIO2_AS_RF_SWITCH radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif +#ifdef SX126X_RX_BOOSTED_GAIN + radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN); +#endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index a6ddcfda..55dbe3f7 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -685,10 +685,12 @@ void setup() { #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); #endif - #ifdef SX126X_DIO2_AS_RF_SWITCH radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif +#ifdef SX126X_RX_BOOSTED_GAIN + radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN); +#endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index a0d6ced1..339e580e 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -739,10 +739,12 @@ void setup() { #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); #endif - #ifdef SX126X_DIO2_AS_RF_SWITCH radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif +#ifdef SX126X_RX_BOOSTED_GAIN + radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN); +#endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/platformio.ini b/platformio.ini index ffbb502f..116432e1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -125,6 +125,7 @@ build_flags = -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! + -D SX126X_RX_BOOSTED_GAIN=true build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} From 9b5a294695654d2dd4e39ff629e505149b6b5874 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sat, 8 Mar 2025 20:18:15 +1100 Subject: [PATCH 13/48] * T1000e battery measure fix --- src/helpers/nrf52/T1000eBoard.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/helpers/nrf52/T1000eBoard.h b/src/helpers/nrf52/T1000eBoard.h index 14272edb..3c0f30b4 100644 --- a/src/helpers/nrf52/T1000eBoard.h +++ b/src/helpers/nrf52/T1000eBoard.h @@ -31,8 +31,13 @@ public: uint16_t getBattMilliVolts() override { #ifdef BATTERY_PIN + analogReference(AR_INTERNAL_3_0); analogReadResolution(12); float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096; + + analogReference(AR_DEFAULT); // put back to default + analogReadResolution(10); + return volts * 1000; #else return 0; From 3dea712d37ac285466e2d33fdff77d5678266719 Mon Sep 17 00:00:00 2001 From: Alex Wolden Date: Wed, 5 Mar 2025 19:52:24 -0800 Subject: [PATCH 14/48] Fix heltec v3.2 pin polarity reversal --- src/helpers/HeltecV3Board.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/helpers/HeltecV3Board.h b/src/helpers/HeltecV3Board.h index 927d537e..75f93853 100644 --- a/src/helpers/HeltecV3Board.h +++ b/src/helpers/HeltecV3Board.h @@ -24,11 +24,20 @@ #include class HeltecV3Board : public ESP32Board { +private: + bool adc_active_state; + public: void begin() { ESP32Board::begin(); + // Auto-detect correct ADC_CTRL pin polarity (different for boards >3.2) + pinMode(PIN_ADC_CTRL, INPUT); + adc_active_state = !digitalRead(PIN_ADC_CTRL); + pinMode(PIN_ADC_CTRL, OUTPUT); + digitalWrite(PIN_ADC_CTRL, !adc_active_state); // Initially inactive + pinMode(PIN_VEXT_EN, OUTPUT); digitalWrite(PIN_VEXT_EN, LOW); // for V3.2 boards @@ -69,7 +78,7 @@ public: uint16_t getBattMilliVolts() override { analogReadResolution(10); - digitalWrite(PIN_ADC_CTRL, PIN_ADC_CTRL_ACTIVE); + digitalWrite(PIN_ADC_CTRL, adc_active_state); uint32_t raw = 0; for (int i = 0; i < 8; i++) { @@ -77,7 +86,7 @@ public: } raw = raw / 8; - digitalWrite(PIN_ADC_CTRL, PIN_ADC_CTRL_INACTIVE); + digitalWrite(PIN_ADC_CTRL, !adc_active_state); return (5.2 * (3.3 / 1024.0) * raw) * 1000; } From 8f609524bda17154ec6290a570ad83ab5e82263e Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 15:41:32 +1100 Subject: [PATCH 15/48] * companion: added new PUSH_CODE_LOG_RX_DATA (0x88) for inspecting all received packets --- examples/companion_radio/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index ea5efc5e..dd3b9e32 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -184,6 +184,7 @@ static uint32_t _atoi(const char* sp) { #define PUSH_CODE_LOGIN_SUCCESS 0x85 #define PUSH_CODE_LOGIN_FAIL 0x86 #define PUSH_CODE_STATUS_RESPONSE 0x87 +#define PUSH_CODE_LOG_RX_DATA 0x88 /* -------------------------------------------------------------------------------------- */ @@ -435,6 +436,24 @@ protected: return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time); } + void logRx(mesh::Packet* pkt, int len, float score) override { + if (_serial->isConnected()) { + int i = 0; + out_frame[i++] = PUSH_CODE_LOG_RX_DATA; + out_frame[i++] = (int8_t)(_radio->getLastSNR() * 4); + out_frame[i++] = (int8_t)(_radio->getLastRSSI()); + if (pkt->isRouteFlood()) { + out_frame[i++] = pkt->path_len; + memcpy(&out_frame[i], pkt->path, pkt->path_len); i += pkt->path_len; + } else { + out_frame[i++] = 0xFF; + } + memcpy(&out_frame[i], pkt->payload, pkt->payload_len); i += pkt->payload_len; + + _serial->writeFrame(out_frame, i); + } + } + void onDiscoveredContact(ContactInfo& contact, bool is_new) override { if (_serial->isConnected()) { out_frame[0] = PUSH_CODE_ADVERT; From f77a6944f93738b67ad0dbac54ccd39cb0460f75 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 17:04:22 +1100 Subject: [PATCH 16/48] * PUSH_CODE_LOG_RX_DATA: is now just: {snr*4},{rssi},{raw-lora-packet} --- examples/companion_radio/main.cpp | 14 ++++---------- src/Dispatcher.cpp | 4 +++- src/Dispatcher.h | 2 ++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index dd3b9e32..10eca8c9 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -436,19 +436,13 @@ protected: return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time); } - void logRx(mesh::Packet* pkt, int len, float score) override { + void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override { if (_serial->isConnected()) { int i = 0; out_frame[i++] = PUSH_CODE_LOG_RX_DATA; - out_frame[i++] = (int8_t)(_radio->getLastSNR() * 4); - out_frame[i++] = (int8_t)(_radio->getLastRSSI()); - if (pkt->isRouteFlood()) { - out_frame[i++] = pkt->path_len; - memcpy(&out_frame[i], pkt->path, pkt->path_len); i += pkt->path_len; - } else { - out_frame[i++] = 0xFF; - } - memcpy(&out_frame[i], pkt->payload, pkt->payload_len); i += pkt->payload_len; + out_frame[i++] = (int8_t)(snr * 4); + out_frame[i++] = (int8_t)(rssi); + memcpy(&out_frame[i], raw, len); i += len; _serial->writeFrame(out_frame, i); } diff --git a/src/Dispatcher.cpp b/src/Dispatcher.cpp index b9da0e65..e4943254 100644 --- a/src/Dispatcher.cpp +++ b/src/Dispatcher.cpp @@ -78,9 +78,11 @@ void Dispatcher::checkRecv() { float score; uint32_t air_time; { - uint8_t raw[MAX_TRANS_UNIT]; + uint8_t raw[MAX_TRANS_UNIT+1]; int len = _radio->recvRaw(raw, MAX_TRANS_UNIT); if (len > 0) { + logRxRaw(_radio->getLastSNR(), _radio->getLastRSSI(), raw, len); + pkt = _mgr->allocNew(); if (pkt == NULL) { MESH_DEBUG_PRINTLN("%s Dispatcher::checkRecv(): WARNING: received data, no unused packets available!", getLogDateTime()); diff --git a/src/Dispatcher.h b/src/Dispatcher.h index 7d75c219..0b00f1a9 100644 --- a/src/Dispatcher.h +++ b/src/Dispatcher.h @@ -117,6 +117,8 @@ protected: virtual DispatcherAction onRecvPacket(Packet* pkt) = 0; + virtual void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) { } // custom hook + virtual void logRx(Packet* packet, int len, float score) { } // hooks for custom logging virtual void logTx(Packet* packet, int len) { } virtual void logTxFail(Packet* packet, int len) { } From 3778c0a8ffdbf21305637aa50361a148015230a4 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 20:36:49 +1100 Subject: [PATCH 17/48] * repeater and room server: MESH_PACKET_LOGGING, now dumps RAW: rx packet contents * Dispatcher: MESH_PACKET_LOGGING, added " hash={packet-hash}" --- examples/simple_repeater/main.cpp | 9 +++++++++ examples/simple_room_server/main.cpp | 9 +++++++++ platformio.ini | 2 +- src/Dispatcher.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 55dbe3f7..b20354aa 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -246,6 +246,15 @@ protected: return tmp; } + void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override { + #if MESH_PACKET_LOGGING + Serial.print(getLogDateTime()); + Serial.print(" RAW: "); + mesh::Utils::printHex(Serial, raw, len); + Serial.println(); + #endif + } + void logRx(mesh::Packet* pkt, int len, float score) override { if (_logging) { File f = openAppend(PACKET_LOG_FILE); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 339e580e..131343a6 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -264,6 +264,15 @@ protected: return _prefs.airtime_factor; } + void logRxRaw(float snr, float rssi, const uint8_t raw[], int len) override { + #if MESH_PACKET_LOGGING + Serial.print(getLogDateTime()); + Serial.print(" RAW: "); + mesh::Utils::printHex(Serial, raw, len); + Serial.println(); + #endif + } + int calcRxDelay(float score, uint32_t air_time) const override { if (_prefs.rx_delay_base <= 0.0f) return 0; return (int) ((pow(_prefs.rx_delay_base, 0.85f - score) - 1.0) * air_time); diff --git a/platformio.ini b/platformio.ini index e6e1f53c..205bb701 100644 --- a/platformio.ini +++ b/platformio.ini @@ -159,7 +159,7 @@ build_flags = -D ADVERT_LON=145.0 -D ADMIN_PASSWORD="\"password\"" -D ROOM_PASSWORD="\"hello\"" -; -D MESH_PACKET_LOGGING=1 + -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 [env:Heltec_v3_terminal_chat] diff --git a/src/Dispatcher.cpp b/src/Dispatcher.cpp index e4943254..dffabcc3 100644 --- a/src/Dispatcher.cpp +++ b/src/Dispatcher.cpp @@ -130,6 +130,12 @@ void Dispatcher::checkRecv() { Serial.printf(": RX, len=%d (type=%d, route=%s, payload_len=%d) SNR=%d RSSI=%d score=%d", 2 + pkt->path_len + pkt->payload_len, pkt->getPayloadType(), pkt->isRouteDirect() ? "D" : "F", pkt->payload_len, (int)_radio->getLastSNR(), (int)_radio->getLastRSSI(), (int)(score*1000)); + + static uint8_t packet_hash[MAX_HASH_SIZE]; + pkt->calculatePacketHash(packet_hash); + Serial.print(" hash="); + mesh::Utils::printHex(Serial, packet_hash, MAX_HASH_SIZE); + if (pkt->getPayloadType() == PAYLOAD_TYPE_PATH || pkt->getPayloadType() == PAYLOAD_TYPE_REQ || pkt->getPayloadType() == PAYLOAD_TYPE_RESPONSE || pkt->getPayloadType() == PAYLOAD_TYPE_TXT_MSG) { Serial.printf(" [%02X -> %02X]\n", (uint32_t)pkt->payload[1], (uint32_t)pkt->payload[0]); From a259d27cfed84d1506fbb1d3ac69c6530c567316 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 22:15:58 +1100 Subject: [PATCH 18/48] * trying setCRC(1) --- examples/companion_radio/main.cpp | 2 +- examples/simple_repeater/main.cpp | 2 +- examples/simple_room_server/main.cpp | 2 +- examples/simple_secure_chat/main.cpp | 2 +- src/helpers/RadioLibWrappers.cpp | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 10eca8c9..b25445c0 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1265,7 +1265,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index b20354aa..703c989f 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -689,7 +689,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 131343a6..0c1fb135 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -743,7 +743,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 1f854773..951d51dc 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -585,7 +585,7 @@ void setup() { halt(); } - radio.setCRC(0); + radio.setCRC(1); #ifdef SX126X_CURRENT_LIMIT radio.setCurrentLimit(SX126X_CURRENT_LIMIT); diff --git a/src/helpers/RadioLibWrappers.cpp b/src/helpers/RadioLibWrappers.cpp index 8d133ccd..03f8f3ce 100644 --- a/src/helpers/RadioLibWrappers.cpp +++ b/src/helpers/RadioLibWrappers.cpp @@ -52,10 +52,11 @@ int RadioLibWrapper::recvRaw(uint8_t* bytes, int sz) { int err = _radio->readData(bytes, len); if (err != RADIOLIB_ERR_NONE) { MESH_DEBUG_PRINTLN("RadioLibWrapper: error: readData(%d)", err); + len = 0; } else { // Serial.print(" readData() -> "); Serial.println(len); + n_recv++; } - n_recv++; } state = STATE_IDLE; // need another startReceive() return len; From 291b98cd56c6c2bbf4236679a3d8ff1dd6cd1c7b Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 23:44:34 +1100 Subject: [PATCH 19/48] updating RadioLib to ver 7.1.2 --- platformio.ini | 2 +- src/helpers/CustomSX1262.h | 2 +- src/helpers/CustomSX1268.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 205bb701..bc26d65c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,7 @@ monitor_speed = 115200 lib_deps = SPI Wire - jgromes/RadioLib @ ^6.3.0 + jgromes/RadioLib @ ^7.1.2 rweather/Crypto @ ^0.4.0 adafruit/RTClib @ ^2.1.3 melopero/Melopero RV3028 @ ^1.1.0 diff --git a/src/helpers/CustomSX1262.h b/src/helpers/CustomSX1262.h index 6f66d129..70a1077f 100644 --- a/src/helpers/CustomSX1262.h +++ b/src/helpers/CustomSX1262.h @@ -9,7 +9,7 @@ class CustomSX1262 : public SX1262 { CustomSX1262(Module *mod) : SX1262(mod) { } bool isReceiving() { - uint16_t irq = getIrqStatus(); + uint16_t irq = getIrqFlags(); bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID); return hasPreamble; } diff --git a/src/helpers/CustomSX1268.h b/src/helpers/CustomSX1268.h index 46ce922a..50024693 100644 --- a/src/helpers/CustomSX1268.h +++ b/src/helpers/CustomSX1268.h @@ -9,7 +9,7 @@ class CustomSX1268 : public SX1268 { CustomSX1268(Module *mod) : SX1268(mod) { } bool isReceiving() { - uint16_t irq = getIrqStatus(); + uint16_t irq = getIrqFlags(); bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID); return hasPreamble; } From 2cb742b1004cb1d86004a9502b51ef6404b4b39d Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 9 Mar 2025 23:46:03 +1100 Subject: [PATCH 20/48] ver bump to 1.2.2 --- examples/companion_radio/main.cpp | 4 ++-- examples/simple_repeater/main.cpp | 4 ++-- examples/simple_room_server/main.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index b25445c0..833e41d8 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -120,11 +120,11 @@ static uint32_t _atoi(const char* sp) { #define FIRMWARE_VER_CODE 2 #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "7 Mar 2025" + #define FIRMWARE_BUILD_DATE "9 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.1" + #define FIRMWARE_VERSION "v1.2.2" #endif #define CMD_APP_START 1 diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 703c989f..5743647b 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 "7 Mar 2025" + #define FIRMWARE_BUILD_DATE "9 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.1" + #define FIRMWARE_VERSION "v1.2.2" #endif #ifndef LORA_FREQ diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 0c1fb135..cde56c47 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 "7 Mar 2025" + #define FIRMWARE_BUILD_DATE "9 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.1" + #define FIRMWARE_VERSION "v1.2.2" #endif #ifndef LORA_FREQ From a706d905987a44ff1e6252ffc23f448a21e2a88a Mon Sep 17 00:00:00 2001 From: Florent Date: Sun, 9 Mar 2025 15:49:35 +0100 Subject: [PATCH 21/48] Add an ESP32_CPU_FREQ build flag to lower freq --- examples/companion_radio/main.cpp | 4 ++++ examples/simple_repeater/main.cpp | 4 ++++ examples/simple_room_server/main.cpp | 5 +++++ examples/simple_secure_chat/main.cpp | 5 +++++ platformio.ini | 1 + 5 files changed, 19 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 833e41d8..ac0b3111 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1246,6 +1246,10 @@ void setup() { Serial.begin(115200); board.begin(); +#ifdef ESP32_CPU_FREQ + setCpuFrequencyMhz(ESP32_CPU_FREQ); +#endif + #ifdef SX126X_DIO3_TCXO_VOLTAGE float tcxo = SX126X_DIO3_TCXO_VOLTAGE; #else diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 5743647b..e9f6d480 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -664,6 +664,10 @@ void setup() { delay(1000); board.begin(); + +#ifdef ESP32_CPU_FREQ + setCpuFrequencyMhz(ESP32_CPU_FREQ); +#endif #ifdef ESP32 fallback_clock.begin(); #endif diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 285d59c6..5f7d577a 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -726,6 +726,11 @@ void setup() { delay(1000); board.begin(); + +#ifdef ESP32_CPU_FREQ + setCpuFrequencyMhz(ESP32_CPU_FREQ); +#endif + #ifdef ESP32 fallback_clock.begin(); #endif diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 951d51dc..f34f025f 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -566,6 +566,11 @@ void setup() { Serial.begin(115200); board.begin(); + +#ifdef ESP32_CPU_FREQ + setCpuFrequencyMhz(ESP32_CPU_FREQ); +#endif + #ifdef SX126X_DIO3_TCXO_VOLTAGE float tcxo = SX126X_DIO3_TCXO_VOLTAGE; #else diff --git a/platformio.ini b/platformio.ini index 02ce189c..6cb473f3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -126,6 +126,7 @@ build_flags = -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! -D SX126X_RX_BOOSTED_GAIN=true + -D ESP32_CPU_FREQ=240 build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} From de3f11d16c3be61205cdeebbf48d336c623d9169 Mon Sep 17 00:00:00 2001 From: recrof Date: Sun, 9 Mar 2025 22:57:31 +0100 Subject: [PATCH 22/48] - Enabled sx1262 boosted RX gain for all supported radios - Made quoted -D flags more readable --- platformio.ini | 104 ++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 48 deletions(-) diff --git a/platformio.ini b/platformio.ini index 20e2802b..a203e807 100644 --- a/platformio.ini +++ b/platformio.ini @@ -50,10 +50,10 @@ build_src_filter = ${esp32_base.build_src_filter} extends = Heltec_lora32_v2 build_flags = ${Heltec_lora32_v2.build_flags} - -D ADVERT_NAME="\"Heltec Repeater\"" + -D ADVERT_NAME='"Heltec Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} @@ -107,7 +107,6 @@ lib_deps = ${Heltec_lora32_v2.lib_deps} densaugeo/base64 @ ~1.4.0 - ; ================ [Heltec_lora32_v3] extends = esp32_base @@ -125,7 +124,7 @@ build_flags = -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! - -D SX126X_RX_BOOSTED_GAIN=true + -D SX126X_RX_BOOSTED_GAIN=1 build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} @@ -136,10 +135,10 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -D DISPLAY_CLASS=SSD1306Display - -D ADVERT_NAME="\"Heltec Repeater\"" + -D ADVERT_NAME='"Heltec Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} @@ -154,11 +153,11 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter} build_flags = ${Heltec_lora32_v3.build_flags} -D DISPLAY_CLASS=SSD1306Display - -D ADVERT_NAME="\"Heltec Room\"" + -D ADVERT_NAME='"Heltec Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -223,8 +222,8 @@ build_flags = -D MAX_GROUP_CHANNELS=1 -D DISPLAY_CLASS=SSD1306Display -D WIFI_DEBUG_LOGGING=1 - -D WIFI_SSID="\"myssid\"" - -D WIFI_PWD="\"mypwd\"" + -D WIFI_SSID='"myssid"' + -D WIFI_PWD='"mypwd"' ; -D ENABLE_PRIVATE_KEY_IMPORT=1 ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 @@ -241,10 +240,10 @@ lib_deps = extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} - -D ADVERT_NAME="\"Heltec Repeater\"" + -D ADVERT_NAME='"Heltec Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v3.build_src_filter} @@ -256,11 +255,11 @@ build_src_filter = ${Heltec_lora32_v3.build_src_filter} +<../examples/simple_room_server> build_flags = ${Heltec_lora32_v3.build_flags} - -D ADVERT_NAME="\"Heltec Room\"" + -D ADVERT_NAME='"Heltec Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -310,11 +309,12 @@ build_flags = ${Xiao_esp32_C3.build_flags} -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper + -D SX126X_RX_BOOSTED_GAIN=1 -D LORA_TX_POWER=22 - -D ADVERT_NAME="\"Xiao Repeater\"" + -D ADVERT_NAME='"Xiao Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -327,10 +327,10 @@ build_flags = -D RADIO_CLASS=CustomSX1268 -D WRAPPER_CLASS=CustomSX1268Wrapper -D LORA_TX_POWER=22 - -D ADVERT_NAME="\"Xiao Repeater\"" + -D ADVERT_NAME='"Xiao Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -355,6 +355,7 @@ build_flags = ${esp32_base.build_flags} -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 + -D SX126X_RX_BOOSTED_GAIN=1 [env:Xiao_S3_WIO_Repeater] extends = Xiao_S3_WIO @@ -362,10 +363,10 @@ build_src_filter = ${Xiao_S3_WIO.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = ${Xiao_S3_WIO.build_flags} - -D ADVERT_NAME="\"XiaoS3 Repeater\"" + -D ADVERT_NAME='"XiaoS3 Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -440,10 +441,10 @@ build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_repeater> build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} - -D ADVERT_NAME="\"TLora-V2.1-1.6 Repeater\"" + -D ADVERT_NAME='"TLora-V2.1-1.6 Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 ; -D CORE_DEBUG_LEVEL=3 @@ -507,11 +508,11 @@ build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_room_server> build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} - -D ADVERT_NAME="\"TLora-V2.1-1.6 Room\"" + -D ADVERT_NAME='"TLora-V2.1-1.6 Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -536,6 +537,7 @@ build_flags = ${esp32_base.build_flags} -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 + -D SX126X_RX_BOOSTED_GAIN=1 ; === LilyGo T3S3 with SX1262 environments === [env:LilyGo_T3S3_sx1262_Repeater] @@ -544,10 +546,10 @@ build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = ${LilyGo_T3S3_sx1262.build_flags} - -D ADVERT_NAME="\"T3S3-1262 Repeater\"" + -D ADVERT_NAME='"T3S3-1262 Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -616,6 +618,9 @@ build_flags = -D SX126X_DIO2_AS_RF_SWITCH=true -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! +; -D SX126X_RX_BOOSTED_GAIN=1 - DO NOT ENABLE THIS! +; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance + build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} @@ -624,10 +629,10 @@ lib_deps = extends = Station_G2 build_flags = ${Station_G2.build_flags} - -D ADVERT_NAME="\"Station G2 Repeater\"" + -D ADVERT_NAME='"Station G2 Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Station_G2.build_src_filter} @@ -639,11 +644,11 @@ build_src_filter = ${Station_G2.build_src_filter} +<../examples/simple_room_server> build_flags = ${Station_G2.build_flags} - -D ADVERT_NAME="\"Station G2 Room\"" + -D ADVERT_NAME='"Station G2 Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -675,6 +680,7 @@ build_flags = ${nrf52840_base.build_flags} -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_CURRENT_LIMIT=130 + -D SX126X_RX_BOOSTED_GAIN=1 [env:RAK_4631_Repeater] extends = rak4631 @@ -682,10 +688,10 @@ build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = ${rak4631.build_flags} - -D ADVERT_NAME="\"RAK4631 Repeater\"" + -D ADVERT_NAME='"RAK4631 Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -695,11 +701,11 @@ build_src_filter = ${rak4631.build_src_filter} +<../examples/simple_room_server/main.cpp> build_flags = ${rak4631.build_flags} - -D ADVERT_NAME="\"Test Room\"" + -D ADVERT_NAME='"Test Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -823,6 +829,7 @@ build_flags = ${nrf52840_t114.build_flags} -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_CURRENT_LIMIT=130 + -D SX126X_RX_BOOSTED_GAIN=1 build_src_filter = ${nrf52840_t114.build_src_filter} + + @@ -836,10 +843,10 @@ build_src_filter = ${Heltec_t114.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = ${Heltec_t114.build_flags} - -D ADVERT_NAME="\"Heltec_T114 Repeater\"" + -D ADVERT_NAME='"Heltec_T114 Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -849,11 +856,11 @@ build_src_filter = ${Heltec_t114.build_src_filter} +<../examples/simple_room_server> build_flags = ${Heltec_t114.build_flags} - -D ADVERT_NAME="\"Heltec_T114 Room\"" + -D ADVERT_NAME='"Heltec_T114 Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" - -D ROOM_PASSWORD="\"hello\"" + -D ADMIN_PASSWORD='"password"' + -D ROOM_PASSWORD='"hello"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -898,6 +905,7 @@ build_flags = ${nrf52840_techo.build_flags} -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_CURRENT_LIMIT=130 + -D SX126X_RX_BOOSTED_GAIN=1 build_src_filter = ${nrf52840_techo.build_src_filter} + + @@ -910,10 +918,10 @@ extends = LilyGo_Techo build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = ${LilyGo_Techo.build_flags} - -D ADVERT_NAME="\"T-Echo Repeater\"" + -D ADVERT_NAME='"T-Echo Repeater"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -922,10 +930,10 @@ extends = LilyGo_Techo build_src_filter = ${LilyGo_Techo.build_src_filter} +<../examples/simple_room_server/main.cpp> build_flags = ${LilyGo_Techo.build_flags} - -D ADVERT_NAME="\"T-Echo Room\"" + -D ADVERT_NAME='"T-Echo Room"' -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 - -D ADMIN_PASSWORD="\"password\"" + -D ADMIN_PASSWORD='"password"' ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 From 5c72969e2c47169c1f223a62ddf3d81b2b2c207b Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Mon, 10 Mar 2025 23:28:19 +1100 Subject: [PATCH 23/48] * repeater & room server: new CLI config "flood.max" --- examples/simple_repeater/main.cpp | 5 ++++- examples/simple_room_server/main.cpp | 5 ++++- src/helpers/CommonCLI.cpp | 13 +++++++++++++ src/helpers/CommonCLI.h | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 5743647b..605e7a35 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -235,7 +235,9 @@ protected: } bool allowPacketForward(const mesh::Packet* packet) override { - return !_prefs.disable_fwd; + if (_prefs.disable_fwd) return false; + if (packet->isRouteFlood() && packet->path_len >= _prefs.flood_max) return false; + return true; } const char* getLogDateTime() override { @@ -536,6 +538,7 @@ public: _prefs.cr = LORA_CR; _prefs.tx_power_dbm = LORA_TX_POWER; _prefs.advert_interval = 1; // default to 2 minutes for NEW installs + _prefs.flood_max = 64; } CommonCLI* getCLI() { return &_cli; } diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 285d59c6..573ff1a4 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -304,7 +304,9 @@ protected: } bool allowPacketForward(const mesh::Packet* packet) override { - return !_prefs.disable_fwd; + if (_prefs.disable_fwd) return false; + if (packet->isRouteFlood() && packet->path_len >= _prefs.flood_max) return false; + return true; } void onAnonDataRecv(mesh::Packet* packet, uint8_t type, const mesh::Identity& sender, uint8_t* data, size_t len) override { @@ -568,6 +570,7 @@ public: _prefs.tx_power_dbm = LORA_TX_POWER; _prefs.disable_fwd = 1; _prefs.advert_interval = 1; // default to 2 minutes for NEW installs + _prefs.flood_max = 64; #ifdef ROOM_PASSWORD StrHelper::strncpy(_prefs.guest_password, ROOM_PASSWORD, sizeof(_prefs.guest_password)); #endif diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 21cd690f..30777b4b 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -41,6 +41,7 @@ void CommonCLI::loadPrefs(FILESYSTEM* fs) { file.read((uint8_t *) &_prefs->reserved2, sizeof(_prefs->reserved2)); // 115 file.read((uint8_t *) &_prefs->bw, sizeof(_prefs->bw)); // 116 file.read(pad, 4); // 120 + file.read((uint8_t *) &_prefs->flood_max, sizeof(_prefs->flood_max)); // 124 // sanitise bad pref values _prefs->rx_delay_base = constrain(_prefs->rx_delay_base, 0, 20.0f); @@ -91,6 +92,7 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) { file.write((uint8_t *) &_prefs->reserved2, sizeof(_prefs->reserved2)); // 115 file.write((uint8_t *) &_prefs->bw, sizeof(_prefs->bw)); // 116 file.write(pad, 4); // 120 + file.write((uint8_t *) &_prefs->flood_max, sizeof(_prefs->flood_max)); // 124 file.close(); } @@ -176,6 +178,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch sprintf(reply, "> %s", StrHelper::ftoa(_prefs->rx_delay_base)); } else if (memcmp(config, "txdelay", 7) == 0) { sprintf(reply, "> %s", StrHelper::ftoa(_prefs->tx_delay_factor)); + } else if (memcmp(config, "flood.max", 9) == 0) { + sprintf(reply, "> %d", (uint32_t)_prefs->flood_max); } else if (memcmp(config, "direct.txdelay", 14) == 0) { sprintf(reply, "> %s", StrHelper::ftoa(_prefs->direct_tx_delay_factor)); } else if (memcmp(config, "tx", 2) == 0 && (config[2] == 0 || config[2] == ' ')) { @@ -262,6 +266,15 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch } else { strcpy(reply, "Error, cannot be negative"); } + } else if (memcmp(config, "flood.max ", 10) == 0) { + uint8_t m = atoi(&config[10]); + if (m <= 64) { + _prefs->flood_max = m; + savePrefs(); + strcpy(reply, "OK"); + } else { + strcpy(reply, "Error, max 64"); + } } else if (memcmp(config, "direct.txdelay ", 15) == 0) { float f = atof(&config[15]); if (f >= 0) { diff --git a/src/helpers/CommonCLI.h b/src/helpers/CommonCLI.h index ec038d07..5538f339 100644 --- a/src/helpers/CommonCLI.h +++ b/src/helpers/CommonCLI.h @@ -23,6 +23,7 @@ struct NodePrefs { // persisted to file uint8_t reserved1; uint8_t reserved2; float bw; + uint8_t flood_max; }; class CommonCLICallbacks { From 7bb16cd7f3c91397e3757a8449dc6fce4b3ffcad Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Mon, 10 Mar 2025 17:11:55 +0100 Subject: [PATCH 24/48] enhancement on the UI and support for power off and status_led for t1000e --- examples/companion_radio/UITask.cpp | 161 +++++++++++++++++++--------- examples/companion_radio/UITask.h | 19 +++- examples/companion_radio/main.cpp | 23 ++-- platformio.ini | 8 +- src/MeshCore.h | 1 + src/helpers/HeltecV3Board.h | 4 + src/helpers/nrf52/T1000eBoard.h | 4 +- 7 files changed, 157 insertions(+), 63 deletions(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index 8ffb2c1f..f4981984 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -28,7 +28,16 @@ void UITask::begin(const char* node_name, const char* build_date, uint32_t pin_c _node_name = node_name; _build_date = build_date; _pin_code = pin_code; - _display->turnOn(); + if (_display != NULL) { + _display->turnOn(); + } +} + +void UITask::msgRead(int msgcount) { + _msgcount = msgcount; + if (msgcount == 0) { + clearMsgPreview(); + } } void UITask::clearMsgPreview() { @@ -36,7 +45,9 @@ void UITask::clearMsgPreview() { _msg[0] = 0; } -void UITask::showMsgPreview(uint8_t path_len, const char* from_name, const char* text) { +void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount) { + _msgcount = msgcount; + if (path_len == 0xFF) { sprintf(_origin, "(F) %s", from_name); } else { @@ -44,67 +55,121 @@ void UITask::showMsgPreview(uint8_t path_len, const char* from_name, const char* } StrHelper::strncpy(_msg, text, sizeof(_msg)); - if (!_display->isOn()) _display->turnOn(); - _auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer + if (_display != NULL) { + if (!_display->isOn()) _display->turnOn(); + _auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer + } } void UITask::renderCurrScreen() { - char tmp[80]; - if (_origin[0] && _msg[0]) { - // render message preview - _display->setCursor(0, 0); - _display->setTextSize(1); - _display->print(_node_name); + if (_display != NULL) { + char tmp[80]; + if (_origin[0] && _msg[0]) { + // render message preview + _display->setCursor(0, 0); + _display->setTextSize(1); + _display->print(_node_name); - _display->setCursor(0, 12); - _display->print(_origin); - _display->setCursor(0, 24); - _display->print(_msg); + _display->setCursor(0, 12); + _display->print(_origin); + _display->setCursor(0, 24); + _display->print(_msg); - //_display->setCursor(100, 9); TODO - //_display->setTextSize(2); - //_display->printf("%d", msgs); - } else { - // render 'home' screen - _display->drawXbm(0, 0, meshcore_logo, 128, 13); - _display->setCursor(0, 20); - _display->setTextSize(1); - _display->print(_node_name); - - sprintf(tmp, "Build: %s", _build_date); - _display->setCursor(0, 32); - _display->print(tmp); - - if (_connected) { - //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); - //_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr); - } else if (_pin_code != 0) { + _display->setCursor(100, 9); _display->setTextSize(2); - _display->setCursor(0, 43); - sprintf(tmp, "Pin:%d", _pin_code); + sprintf(tmp, "%d", _msgcount); _display->print(tmp); + } else { + // render 'home' screen + _display->drawXbm(0, 0, meshcore_logo, 128, 13); + _display->setCursor(0, 20); + _display->setTextSize(1); + _display->print(_node_name); + + sprintf(tmp, "Build: %s", _build_date); + _display->setCursor(0, 32); + _display->print(tmp); + + if (_connected) { + //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); + //_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr); + } else if (_pin_code != 0) { + _display->setTextSize(2); + _display->setCursor(0, 43); + sprintf(tmp, "Pin:%d", _pin_code); + _display->print(tmp); + } } } } -void UITask::loop() { - if (millis() >= _next_read) { - int btnState = digitalRead(PIN_USER_BTN); - if (btnState != _prevBtnState) { - if (btnState == LOW) { // pressed? - if (_display->isOn()) { - clearMsgPreview(); - } else { - _display->turnOn(); - } - _auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer +void UITask::userLedHandler() { +#ifdef PIN_STATUS_LED + static int state = 0; + static int next_change = 0; + int cur_time = millis(); + if (cur_time > next_change) { + if (state == 0) { + state = 1; // led on, short = unread msg + if (_msgcount > 0) { + next_change = cur_time + 500; + } else { + next_change = cur_time + 2000; + } + } else { + state = 0; + if (_board->getBattMilliVolts() > 3800) { + next_change = cur_time + 2000; + } else { + next_change = cur_time + 4000; // 4s blank if bat level low } - _prevBtnState = btnState; } - _next_read = millis() + 100; // 10 reads per second + digitalWrite(PIN_STATUS_LED, state); } +#endif +} - if (_display->isOn()) { +void UITask::buttonHandler() { +#ifdef PIN_USER_BTN + static int prev_btn_state = HIGH; + static unsigned long btn_state_change_time = 0; + static unsigned long next_read = 0; + int cur_time = millis(); + if (cur_time >= next_read) { + int btn_state = digitalRead(PIN_USER_BTN); + if (btn_state != prev_btn_state) { + if (btn_state == USER_BTN_PRESSED) { // pressed? + if (_display != NULL) { + if (_display->isOn()) { + clearMsgPreview(); + } else { + _display->turnOn(); + } + _auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer + } + } else { // unpressed ? check pressed time ... + if ((cur_time - btn_state_change_time) > 5000) { + Serial.println("power off"); + #ifdef PIN_STATUS_LED + digitalWrite(PIN_STATUS_LED, LOW); + delay(10); + #endif + _board->powerOff(); + } + } + btn_state_change_time = millis(); + prev_btn_state = btn_state; + } + next_read = millis() + 100; // 10 reads per second + } +#endif +} + +void UITask::loop() { + buttonHandler(); + userLedHandler(); + + if (_display != NULL && _display->isOn()) { if (millis() >= _next_refresh) { _display->startFrame(); renderCurrScreen(); diff --git a/examples/companion_radio/UITask.h b/examples/companion_radio/UITask.h index f1a63225..fa645324 100644 --- a/examples/companion_radio/UITask.h +++ b/examples/companion_radio/UITask.h @@ -1,10 +1,12 @@ #pragma once +#include #include class UITask { DisplayDriver* _display; - unsigned long _next_read, _next_refresh, _auto_off; + mesh::MainBoard* _board; + unsigned long _next_refresh, _auto_off; int _prevBtnState; bool _connected; uint32_t _pin_code; @@ -12,14 +14,23 @@ class UITask { const char* _build_date; char _origin[62]; char _msg[80]; + int _msgcount; void renderCurrScreen(); + void buttonHandler(); + void userLedHandler(); + public: - UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; _connected = false; } + + UITask(mesh::MainBoard* board, DisplayDriver* display) : _board(board), _display(display){ + _next_refresh = 0; + _connected = false; + } void begin(const char* node_name, const char* build_date, uint32_t pin_code); void setHasConnection(bool connected) { _connected = connected; } void clearMsgPreview(); - void showMsgPreview(uint8_t path_len, const char* from_name, const char* text); + void msgRead(int msgcount); + void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount); void loop(); -}; \ No newline at end of file +}; diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 833e41d8..a4009779 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -97,12 +97,16 @@ #endif #ifdef DISPLAY_CLASS + #include "UITask.h" #include static DISPLAY_CLASS display; - + static UITask ui_task(&board, &display); + #define HAS_UI +#elif defined(HAS_UI) #include "UITask.h" - static UITask ui_task(display); + + static UITask ui_task(&board, NULL); #endif // Believe it or not, this std C function is busted on some platforms! @@ -508,8 +512,8 @@ protected: } else { soundBuzzer(); } - #ifdef DISPLAY_CLASS - ui_task.showMsgPreview(path_len, from.name, text); + #ifdef HAS_UI + ui_task.newMsg(path_len, from.name, text, offline_queue_len); #endif } @@ -550,8 +554,8 @@ protected: } else { soundBuzzer(); } - #ifdef DISPLAY_CLASS - ui_task.showMsgPreview(in_path_len < 0 ? 0xFF : in_path_len, "Public", text); + #ifdef HAS_UI + ui_task.newMsg(in_path_len < 0 ? 0xFF : in_path_len, "Public", text, offline_queue_len); #endif } @@ -1010,6 +1014,9 @@ public: int out_len; if ((out_len = getFromOfflineQueue(out_frame)) > 0) { _serial->writeFrame(out_frame, out_len); + #ifdef HAS_UI + ui_task.msgRead(offline_queue_len); + #endif } else { out_frame[0] = RESP_CODE_NO_MORE_MESSAGES; _serial->writeFrame(out_frame, 1); @@ -1190,7 +1197,7 @@ public: checkConnections(); } - #ifdef DISPLAY_CLASS + #ifdef HAS_UI ui_task.setHasConnection(_serial->isConnected()); ui_task.loop(); #endif @@ -1315,6 +1322,8 @@ void setup() { #ifdef DISPLAY_CLASS display.begin(); +#endif +#ifdef HAS_UI ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, the_mesh.getBLEPin()); #endif } diff --git a/platformio.ini b/platformio.ini index 02ce189c..a8bdf219 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,6 +22,7 @@ build_flags = -w -DNDEBUG -DRADIOLIB_STATIC_ONLY=1 -DRADIOLIB_GODMODE=1 -D LORA_FREQ=867.5 -D LORA_BW=250 -D LORA_SF=10 + -D USER_BTN_PRESSED=LOW build_src_filter = +<*.cpp> + @@ -774,10 +775,14 @@ board = tracker-t1000-e board_build.ldscript = boards/nrf52840_s140_v7.ld build_flags = ${nrf52840_t1000e.build_flags} -Ivariants/t1000-e - -DT1000_E + -D T1000_E -D PIN_USER_BTN=6 + -D USER_BTN_PRESSED=HIGH + -D PIN_STATUS_LED=24 -D RADIO_CLASS=CustomLR1110 -D WRAPPER_CLASS=CustomLR1110Wrapper + -D MAX_LORA_TX_POWER=22 + -D LORA_TX_POWER=22 build_src_filter = ${nrf52840_t1000e.build_src_filter} + + @@ -794,6 +799,7 @@ build_flags = ${t1000-e.build_flags} -D BLE_DEBUG_LOGGING=1 -D MESH_PACKET_LOGGING=1 -D MESH_DEBUG=1 + -D HAS_UI build_src_filter = ${t1000-e.build_src_filter} + +<../examples/companion_radio/*.cpp> diff --git a/src/MeshCore.h b/src/MeshCore.h index 6bb11989..5f9956a3 100644 --- a/src/MeshCore.h +++ b/src/MeshCore.h @@ -40,6 +40,7 @@ public: virtual void onBeforeTransmit() { } virtual void onAfterTransmit() { } virtual void reboot() = 0; + virtual void powerOff() { while (1) { }}; // hope it's overriden or never called ;) virtual uint8_t getStartupReason() const = 0; virtual bool startOTAUpdate() { return false; } // not supported }; diff --git a/src/helpers/HeltecV3Board.h b/src/helpers/HeltecV3Board.h index 927d537e..c61189f2 100644 --- a/src/helpers/HeltecV3Board.h +++ b/src/helpers/HeltecV3Board.h @@ -67,6 +67,10 @@ public: esp_deep_sleep_start(); // CPU halts here and never returns! } + void powerOff() override { + enterDeepSleep(0); + } + uint16_t getBattMilliVolts() override { analogReadResolution(10); digitalWrite(PIN_ADC_CTRL, PIN_ADC_CTRL_ACTIVE); diff --git a/src/helpers/nrf52/T1000eBoard.h b/src/helpers/nrf52/T1000eBoard.h index 3c0f30b4..ce2206e8 100644 --- a/src/helpers/nrf52/T1000eBoard.h +++ b/src/helpers/nrf52/T1000eBoard.h @@ -3,8 +3,6 @@ #include #include -#define HAS_T1000e_POWEROFF - // LoRa and SPI pins #define P_LORA_DIO_1 (32 + 1) // P1.1 #define P_LORA_NSS (0 + 12) // P0.12 @@ -61,7 +59,7 @@ public: return 0; } - void powerOff() { + void powerOff() override { #ifdef HAS_GPS digitalWrite(GPS_VRTC_EN, LOW); digitalWrite(GPS_RESET, LOW); From 648cdf6945b9fa2f6b1b319c2341aff05ee5bbac Mon Sep 17 00:00:00 2001 From: uncle lit <43320854+LitBomb@users.noreply.github.com> Date: Mon, 10 Mar 2025 11:52:39 -0700 Subject: [PATCH 25/48] Update faq.md update Canada to use USA frequency add guide to add nodes to map add guide to do OTA firmware update for nRF devices update donation links general text cleanup --- docs/faq.md | 94 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 88 insertions(+), 6 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index eb5fdf29..c94d231f 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,6 +1,9 @@ # MeshCore-FAQ A list of frequently-asked questions and answers for MeshCore +The current version of this MeshCore FAQ is at https://github.com/ripplebiz/MeshCore/blob/main/docs/faq.md. +This MeshCore FAQ is also mirrored at https://github.com/LitBomb/MeshCore-FAQ and might have newer updates if pull requests on Scott's MeshCore repo are not approved yet. + author: https://github.com/LitBomb --- @@ -25,8 +28,9 @@ Anyone is able to build anything they like on top of MeshCore without paying any Firmware Flasher: https://flasher.meshcore.co.uk/ Phone Client Applications: https://meshcore.co.uk/apps.html MeshCore Fimrware Github: https://github.com/ripplebiz/MeshCore - + NOTE: Andy Kirby has a very useful [intro video](https://www.youtube.com/watch?v=t1qne8uJBAc) for beginners. + You need LoRa hardware devices to run MeshCore firmware as clients or server (repeater and room server). @@ -95,7 +99,7 @@ The T-Deck firmware is free to download and most features are available without - Australia and New Zealand are using **915.8MHz** - UK and EU are gravitating toward **867.5MHz** - There are discussions on discord for UK to move to 869.525MHz (https://discord.com/channels/826570251612323860/1330643963501351004/1342554454498742374) -- USA is gravitating toward **910.525MHz** +- Canada and USA is on **910.525MHz** the rest of the radio settings are the same for all frequencies: - Spread Factor (SF): 10 @@ -127,11 +131,11 @@ MeshCore clients only advertise themselves when the user initiates it. A repeate ### Q: How do you configure a repeater or a room server? **A:** One of these servers can be administered with one of the options below: -- Connect the server device through a USB serial connection to a computer running Chrome on this site: - +- Connect the server device using a USB cable to a computer running Chrome on https://flasher.meshcore.co.uk/, then use the `console` feature to connect to the device + - this is necessary to set the server device's frequency if it doesn't match the frequency for your local region or country +- MeshCore smart device clients have the ability to remotely administer servers. - A T-Deck running unlocked/registered MeshCore firmware. Remote server administration is enabled through registering your T-Deck with Ripple Radios. It is one of the ways to support MeshCore development. You can register your T-Deck at: -- MeshCore smart device clients may have the ability to remotely administer servers in the future. ### Q: Do I need to set the location for a repeater? **A:** With location set for a repeater, it can show up on a MeshCore map in the future. Set location with the following commands: @@ -232,7 +236,11 @@ things network is mainly focused on LoRaWAN, but the LoRa low-level stuff still - Firmware repo: ### Q: How can I support MeshCore? -**A:** Provide your honest feedback on GitHub and on AndyKirby's Discord server . Spread the word of MeshCore to your friends and communities; help them get started with MeshCore. Support MeshCore development at . +**A:** Provide your honest feedback on GitHub and on AndyKirby's Discord server . Spread the word of MeshCore to your friends and communities; help them get started with MeshCore. Support Scott's MeshCore development at . + +Support Liam Cottle's smartphone client development by unlocking the server administration wait gate with in-app purchase + +Support Rastislav Vysoky (recrof)'s flasher web site and the map web site development through [PayPal](https://www.paypal.com/donate/?business=DREHF5HM265ES&no_recurring=0&item_name=If+you+enjoy+my+work%2C+you+can+support+me+here%3A¤cy_code=EUR) or [Revolut](https://revolut.me/recrof) ### Q: How do I build MeshCore firmware from source? **A:** See instructions here: @@ -251,6 +259,12 @@ Javascript: https://github.com/liamcottle/meshcore.js ### Q: Does MeshCore support ATAK **A:** ATAK is not currently on MeshCore's roadmap. + +### Q: How do I add a node to the [MeshCore Map]([url](https://meshcore.co.uk/map.html)) +**A:** From the smartphone app, connect to a BLE Companion radio +- To add the BLE Companion radio your smartphone is connected to to the map, tap the `advert` icon, then tap `Advert (To Clipboard)`. +- To add a Repeater or Room Server to the map, tap the 3 dots next to the Repeater or Room Server you want to add to the map, then tap `Share (To Clipboard)`. +- Go to the [MeshCore Map web site]([url](https://meshcore.co.uk/map.html)), tap the plus sign on the lower right corner and paste in the meshcore://... blob, then tap `Add Node` --- @@ -275,6 +289,74 @@ You can get the epoch time on and use it to se **A:** Heltec V3 has a very small coil antenna on its PCB for WiFi and Bluetooth connectivty. It has a very short range, only a few feet. It is possible to remove the coil antenna and replace it with a 31mm wire. The BT range is much improved with the modification. +--- +## Other Questions: +### Q: How to Update repeater and room server firmware over the air? + +**A:** Only nRF-based RAK4631 and Heltec T114 OTA firmware update are verified using nRF smartphone app. Lilygo T-Echo doesn't work currently. +You can update repeater and room server firmware with a bluetooth connection between your smartphone and your LoRa radio using the nRF app. + +1. Download the ZIP file for the specific node from the web flasher to your smartphone +2. On the phone client, log on to the repeater as administrator (default password is `password`) to issue the `start ota`command to the repeater or room server to get the device into OTA DFU mode + +![image](https://github.com/user-attachments/assets/889bb81b-7214-4a1c-955a-396b5a05d8ad) + 1. `start ota` can be initiated from USB serial console on the web flasher page or a T-Deck +4. On the smartphone, download and run the nRF app and scan for Bluetooth devices +5. Connect to the repeater/room server node you want to update + 1. nRF app is available on both Android and iOS + +**Android continues after the iOS section:** + +**iOS continues here:** +5. Once connected successfully, a `DFU` icon ![Pasted image 20250309173039](https://github.com/user-attachments/assets/af7a9f78-8739-4946-b734-02bade9c8e71) + appears in the top right corner of the app![Pasted image 20250309171919](https://github.com/user-attachments/assets/08007ec8-4924-49c1-989f-ca2611e78793) + +6. Scroll down to change the `PRN(s)` number: + +![Pasted image 20250309190158](https://github.com/user-attachments/assets/11f69cdd-12f3-4696-a6fc-14a78c85fe32) + +- For the T114, change the number of packets `(PRN(s)` to 8 +- For RAK, it can be 10, but it also works on 8. + +7. Click the `DFU` icon ![Pasted image 20250309173039](https://github.com/user-attachments/assets/af7a9f78-8739-4946-b734-02bade9c8e71), select the type of file to upload (choose ZIP), then select the ZIP file that was downloaded earlier from the web flasher +8. The upload process will start now. If everything goes well, the node resets and is flashed successfully. +![Pasted image 20250309190342](https://github.com/user-attachments/assets/a60e25d0-33b8-46cf-af90-20a7d8ac2adb) + + + +**Android steps continues below:** +1. on the top left corner of the nRF Connect app on Android, tap the 3-bar hamburger menu, then `Settings`, then `nRF5 DFU Options` + +![Android nRF Hamberger](https://github.com/user-attachments/assets/ea6dfeef-9367-4830-bd70-1441d517c706) + +![Android nRF Settings](https://github.com/user-attachments/assets/c63726bf-cecd-4987-be68-afb6358c7190) + +![Android nRF DFU Options](https://github.com/user-attachments/assets/b20e872f-5122-41d9-90df-0215cff5fbc9) + +2. Change `Number of packets` to `10` for RAK, `8` for Heltec T114 + +![Android nRF Number of Packets](https://github.com/user-attachments/assets/c092adaf-4cb3-460b-b7ef-8d7f450d602b) + +3. Go back to the main screen +4. Your LoRa device should already ben in DFU mode from previous steps +5. tap `SCANNER` and then `SCAN` to find the device you want to update, tap `CONNECT` + +![Android nRF Scanner Scan Connect](https://github.com/user-attachments/assets/37218717-f167-48b6-a6ca-93d132ef77ca) + +6. On the top left corner of the nRF Connect app, tap the `DFU` icon next to the three dots + +![Android nRF DFU](https://github.com/user-attachments/assets/1ec3b818-bf0c-461f-8fdf-37c41a63cafa) + +7. Choose `Distribution packet (ZIP)` and then `OK` + +![Android nRF Distribution Packet (ZIP)](https://github.com/user-attachments/assets/e65f5616-9793-44f5-95c0-a3eb15aa7152) + +8. Choose the firmware file in ZIP formate that you downloaded earlier from the MeshCore web flasher, update will start as soon as you tap the file + +![Android nRF FW Updating](https://github.com/user-attachments/assets/0814d123-85ce-4c87-90a7-e1a25dc71900) + +9. When the update process is done, the device will disconnect from nRF app and the LoRa device is updated + --- From 4cfdb0ef7c648bab05f2916241e3243cf86b967f Mon Sep 17 00:00:00 2001 From: Florent Date: Mon, 10 Mar 2025 22:42:52 +0100 Subject: [PATCH 26/48] better handling of BTN_USER_PRESSED definition --- examples/companion_radio/UITask.cpp | 4 ++++ platformio.ini | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index f4981984..df09e269 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -4,6 +4,10 @@ #define AUTO_OFF_MILLIS 15000 // 15 seconds +#ifndef USER_BTN_PRESSED +#define USER_BTN_PRESSED LOW +#endif + // 'meshcore', 128x13px static const uint8_t meshcore_logo [] PROGMEM = { 0x3c, 0x01, 0xe3, 0xff, 0xc7, 0xff, 0x8f, 0x03, 0x87, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, 0x1f, 0xfe, diff --git a/platformio.ini b/platformio.ini index a8bdf219..f6221c51 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,7 +22,6 @@ build_flags = -w -DNDEBUG -DRADIOLIB_STATIC_ONLY=1 -DRADIOLIB_GODMODE=1 -D LORA_FREQ=867.5 -D LORA_BW=250 -D LORA_SF=10 - -D USER_BTN_PRESSED=LOW build_src_filter = +<*.cpp> + From 8e793dc55e0287de8506413bace968c5e84cd629 Mon Sep 17 00:00:00 2001 From: taco Date: Thu, 20 Feb 2025 22:24:46 +1100 Subject: [PATCH 27/48] Faketec board support, including build targets --- boards/supermini_nrf52840.json | 78 +++++++++++ examples/companion_radio/main.cpp | 6 + examples/simple_repeater/main.cpp | 4 + examples/simple_room_server/main.cpp | 4 + examples/simple_secure_chat/main.cpp | 4 + platformio.ini | 88 ++++++++++++ src/helpers/nrf52/faketecBoard.cpp | 63 +++++++++ src/helpers/nrf52/faketecBoard.h | 61 ++++++++ variants/supermini_nrf52840/variant.cpp | 52 +++++++ variants/supermini_nrf52840/variant.h | 176 ++++++++++++++++++++++++ 10 files changed, 536 insertions(+) create mode 100644 boards/supermini_nrf52840.json create mode 100644 src/helpers/nrf52/faketecBoard.cpp create mode 100644 src/helpers/nrf52/faketecBoard.h create mode 100644 variants/supermini_nrf52840/variant.cpp create mode 100644 variants/supermini_nrf52840/variant.h diff --git a/boards/supermini_nrf52840.json b/boards/supermini_nrf52840.json new file mode 100644 index 00000000..328c0c9d --- /dev/null +++ b/boards/supermini_nrf52840.json @@ -0,0 +1,78 @@ +{ + "build": { + "arduino":{ + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + [ + "0x239A", + "0x00B3" + ], + [ + "0x239A", + "0x8029" + ], + [ + "0x239A", + "0x0029" + ], + [ + "0x239A", + "0x002A" + ], + [ + "0x239A", + "0x802A" + ] + ], + "usb_product": "SuperMini nRF52840", + "mcu": "nrf52840", + "variant": "supermini_nrf52840", + "variants_dir": "variants", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": [ + "bluetooth" + ], + "debug": { + "jlink_device": "nRF52840_xxAA", + "svd_path": "nrf52840.svd" + }, + "frameworks": [ + "arduino", + "zephyr" + ], + "name": "Nologo SuperMini nRF52840", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "speed": 115200, + "protocol": "nrfutil", + "protocols": [ + "jlink", + "nrfjprog", + "nrfutil", + "stlink" + ], + "use_1200bps_touch": true, + "require_upload_port": true, + "wait_for_upload_port": true + }, + "url": "https://www.nologo.tech/en/product/otherboard/NRF52840.html", + "vendor": "Nologo" + } \ No newline at end of file diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 833e41d8..75dbfba1 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -92,6 +92,10 @@ #include #include static TechoBoard board; +#elif defined(FAKETEC) + #include + #include + static faketecBoard board; #else #error "need to provide a 'board' object" #endif @@ -1290,7 +1294,9 @@ void setup() { sprintf(dev_name, "MeshCore-%s", the_mesh.getNodeName()); serial_interface.begin(dev_name, the_mesh.getBLEPin()); #else +#ifdef RAK_4631 pinMode(WB_IO2, OUTPUT); +#endif serial_interface.begin(Serial); #endif the_mesh.startInterface(serial_interface); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 5743647b..3f57e814 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -96,6 +96,10 @@ #include #include static TechoBoard board; +#elif defined(FAKETEC) + #include + #include + static faketecBoard board; #else #error "need to provide a 'board' object" #endif diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 285d59c6..76412d90 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -100,6 +100,10 @@ #include #include static TechoBoard board; +#elif defined(FAKETEC) + #include + #include + static faketecBoard board; #else #error "need to provide a 'board' object" #endif diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 951d51dc..64e5c321 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -78,6 +78,10 @@ #include #include static T1000eBoard board; +#elif defined(FAKETEC) + #include + #include + static faketecBoard board; #else #error "need to provide a 'board' object" #endif diff --git a/platformio.ini b/platformio.ini index 02ce189c..a1e154ce 100644 --- a/platformio.ini +++ b/platformio.ini @@ -947,3 +947,91 @@ build_src_filter = ${LilyGo_Techo.build_src_filter} lib_deps = ${LilyGo_Techo.lib_deps} densaugeo/base64 @ ~1.4.0 + + +[faketec] +extends = nrf52840_base +board = supermini_nrf52840 +#board_check = true +build_src_filter = ${nrf52840_base.build_src_filter} + +build_flags = ${nrf52840_base.build_flags} + -D FAKETEC + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D SX126X_CURRENT_LIMIT=130 + +[env:Faketec_Repeater] +extends = faketec +build_src_filter = ${faketec.build_src_filter} +<../examples/simple_repeater/main.cpp> +build_flags = + ${faketec.build_flags} + -D ADVERT_NAME="\"Faketec Repeater\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +lib_deps = + ${faketec.lib_deps} + adafruit/RTClib @ ^2.1.3 + +[env:Faketec_room_server] +extends = faketec +build_src_filter = ${faketec.build_src_filter} +<../examples/simple_room_server/main.cpp> +build_flags = + ${faketec.build_flags} + -D ADVERT_NAME="\"Test Room\"" + -D ADVERT_LAT=-37.0 + -D ADVERT_LON=145.0 + -D ADMIN_PASSWORD="\"password\"" + -D ROOM_PASSWORD="\"hello\"" +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +lib_deps = + ${faketec.lib_deps} + adafruit/RTClib @ ^2.1.3 + +[env:Faketec_terminal_chat] +extends = faketec +build_flags = + ${faketec.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${faketec.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +lib_deps = + ${faketec.lib_deps} + densaugeo/base64 @ ~1.4.0 + adafruit/RTClib @ ^2.1.3 + +[env:Faketec_companion_radio_usb] +extends = faketec +build_flags = + ${faketec.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${faketec.build_src_filter} +<../examples/companion_radio/main.cpp> +lib_deps = + ${faketec.lib_deps} + adafruit/RTClib @ ^2.1.3 + densaugeo/base64 @ ~1.4.0 + +[env:Faketec_companion_radio_ble] +extends = faketec +build_flags = + ${faketec.build_flags} + -D MAX_CONTACTS=100 + -D MAX_GROUP_CHANNELS=1 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${faketec.build_src_filter} + +<../examples/companion_radio/main.cpp> +lib_deps = + ${faketec.lib_deps} + adafruit/RTClib @ ^2.1.3 + densaugeo/base64 @ ~1.4.0 \ No newline at end of file diff --git a/src/helpers/nrf52/faketecBoard.cpp b/src/helpers/nrf52/faketecBoard.cpp new file mode 100644 index 00000000..6ef294bc --- /dev/null +++ b/src/helpers/nrf52/faketecBoard.cpp @@ -0,0 +1,63 @@ +#include +#include "faketecBoard.h" + +#include +#include + +static BLEDfu bledfu; + +static void connect_callback(uint16_t conn_handle) +{ + (void)conn_handle; + MESH_DEBUG_PRINTLN("BLE client connected"); +} + +static void disconnect_callback(uint16_t conn_handle, uint8_t reason) +{ + (void)conn_handle; + (void)reason; + + MESH_DEBUG_PRINTLN("BLE client disconnected"); +} + +bool faketecBoard::startOTAUpdate() { + // Config the peripheral connection with maximum bandwidth + // more SRAM required by SoftDevice + // Note: All config***() function must be called before begin() + Bluefruit.configPrphBandwidth(BANDWIDTH_MAX); + Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16); + + Bluefruit.begin(1, 0); + // Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4 + Bluefruit.setTxPower(4); + // Set the BLE device name + Bluefruit.setName("Faketec_OTA"); + + Bluefruit.Periph.setConnectCallback(connect_callback); + Bluefruit.Periph.setDisconnectCallback(disconnect_callback); + + // To be consistent OTA DFU should be added first if it exists + bledfu.begin(); + + // Set up and start advertising + // Advertising packet + Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); + Bluefruit.Advertising.addTxPower(); + Bluefruit.Advertising.addName(); + + /* Start Advertising + - Enable auto advertising if disconnected + - Interval: fast mode = 20 ms, slow mode = 152.5 ms + - Timeout for fast mode is 30 seconds + - Start(timeout) with timeout = 0 will advertise forever (until connected) + + For recommended advertising interval + https://developer.apple.com/library/content/qa/qa1931/_index.html + */ + Bluefruit.Advertising.restartOnDisconnect(true); + Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms + Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode + Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds + + return true; +} diff --git a/src/helpers/nrf52/faketecBoard.h b/src/helpers/nrf52/faketecBoard.h new file mode 100644 index 00000000..42ea37dc --- /dev/null +++ b/src/helpers/nrf52/faketecBoard.h @@ -0,0 +1,61 @@ +#pragma once + +#include +#include + +#define P_LORA_NSS D13 +#define P_LORA_DIO_1 D11 +#define P_LORA_RESET D10 +#define P_LORA_BUSY D16 +#define P_LORA_MISO D15 +#define P_LORA_SCLK D12 +#define P_LORA_MOSI D14 +#define SX126X_POWER_EN EXT_VCC + +#define SX126X_DIO2_AS_RF_SWITCH true +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 + +#define PIN_VBAT_READ PIN_A2 +#define ADC_MULTIPLIER (1.815) // dependent on voltage divider resistors. TODO: more accurate battery tracking + +class faketecBoard : public mesh::MainBoard { +protected: + uint8_t startup_reason; + +public: + void begin() { + // for future use, sub-classes SHOULD call this from their begin() + startup_reason = BD_STARTUP_NORMAL; + + pinMode(PIN_VBAT_READ, INPUT); + + pinMode(SX126X_POWER_EN, OUTPUT); + digitalWrite(SX126X_POWER_EN, HIGH); + delay(10); // give sx1262 some time to power up + } + + uint8_t getStartupReason() const override { return startup_reason; } + + #define BATTERY_SAMPLES 8 + + uint16_t getBattMilliVolts() override { + analogReadResolution(12); + + uint32_t raw = 0; + for (int i = 0; i < BATTERY_SAMPLES; i++) { + raw += analogRead(PIN_VBAT_READ); + } + raw = raw / BATTERY_SAMPLES; + return (ADC_MULTIPLIER * raw); + } + + const char* getManufacturerName() const override { + return "Faketec DIY"; + } + + void reboot() override { + NVIC_SystemReset(); + } + + bool startOTAUpdate() override; +}; diff --git a/variants/supermini_nrf52840/variant.cpp b/variants/supermini_nrf52840/variant.cpp new file mode 100644 index 00000000..2e832f31 --- /dev/null +++ b/variants/supermini_nrf52840/variant.cpp @@ -0,0 +1,52 @@ +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // D0 - D9 (left side, top to bottom) + 6, // D0 is P0.06 (D0, TX) + 8, // D1 is P0.08 (D1, RX) + 17, // D2 is P0.17 (D2, SCK) + 20, // D3 is P0.20 (D3, MISO) + 22, // D4 is P0.22 (D4, MOSI) + 24, // D5 is P0.24 (D5, CS) + 32, // D6 is P1.00 (D6, SDA) + 11, // D7 is P0.11 (D7, SCL) + 36, // D8 is P1.04 (D8) + 38, // D9 is P1.06 (D9) + + // D10 - D17 (right side, bottom to top) + 9, // D10 is P0.09 (D10, NFC1) + 10, // D11 is P0.10 (D11, NFC2) + 43, // D12 is P1.11 (D12) + 45, // D13 is P1.13 (D13, SDA1) + 47, // D14 is P1.15 (D14, SCL1) + 2, // D15 is P0.02 (D15, A0) + 29, // D16 is P0.29 (D16, A1) + 31, // D17 is P0.31 (D17, A2) + + // D18 - D20 (extra center pins, left to right) + 33, // D18 is P1.01 (D18, SCK1) + 34, // D19 is P1.02 (D19, MISO1) + 39, // D20 is P1.07 (D20, MOSI1) + + // EXT_VCC + 13, // 'D21' is P0.13 (EXT_VCC) [active high] + + // LED + 15, // 'D22' is P0.15 (LED) +}; + +void initVariant() +{ + // enable EXT_VCC by default + pinMode(EXT_VCC, OUTPUT); + digitalWrite(EXT_VCC, HIGH); + + // enable LED by default + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, HIGH); +} + diff --git a/variants/supermini_nrf52840/variant.h b/variants/supermini_nrf52840/variant.h new file mode 100644 index 00000000..b7b59c8e --- /dev/null +++ b/variants/supermini_nrf52840/variant.h @@ -0,0 +1,176 @@ +#ifndef _SUPERMINI_NRF52840_H_ +#define _SUPERMINI_NRF52840_H_ + +#define TARGET_SUPERMINI_NRF52840 + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +//#define USE_LFXO // Board uses 32khz crystal for LF +#define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +#define PINS_COUNT (23) +#define NUM_DIGITAL_PINS (23) +#define NUM_ANALOG_INPUTS (3) +#define NUM_ANALOG_OUTPUTS (0) + +// NOTE: +// +// BATTERY VOLTAGE IS READ VIA VDDH/5 BY CALLING +// +// analogReadVDDHDIV5() // returns uint32_t + +// 3V3 Regulator Disable +#define PIN_EXT_VCC (21) // EXT_VCC is P0.13 (set low to disable 3v3) +#define EXT_VCC (PIN_EXT_VCC) + +// LEDs +#define PIN_LED (22) // USR LED is P0.15 +#define LED_PWR (PINS_COUNT) // no LED_PWR +#define PIN_NEOPIXEL (PINS_COUNT) // no neopixel +#define NEOPIXEL_NUM 0 +#define LED_BLUE PIN_LED // required by bluefruit library + +#define LED_BUILTIN PIN_LED + +#define LED_STATE_ON 1 // State when LED is on + +/* + * Buttons + */ +#define PIN_BUTTON1 (PINS_COUNT) // no button + +// Digital PINs +// NOTE: THIS IS A RENUMBERING OF THE PINS +// AND DOES NOT CORRESPOND TO THE NICENANO DIAGRAM + +// left side (top to bottom) +#define D0 (0ul) // P0.06 (TX) +#define D1 (1ul) // P0.08 (RX) +#define D2 (2ul) // P0.17 (SCK) +#define D3 (3ul) // P0.20 (MISO) +#define D4 (4ul) // P0.22 (MOSI) +#define D5 (5ul) // P0.24 (CS) +#define D6 (6ul) // P1.00 (SDA) +#define D7 (7ul) // P0.11 (SCL) +#define D8 (8ul) // P1.04 +#define D9 (9ul) // P1.06 + +// right side (bottom to top) +#define D10 (10ul) // P0.09 (NFC1) +#define D11 (11ul) // P0.10 (NFC2) +#define D12 (12ul) // P1.11 +#define D13 (13ul) // P1.13 (SDA1) +#define D14 (14ul) // P1.15 (SCL1) +#define D15 (15ul) // P0.02/AIN0 (A0) +#define D16 (16ul) // P0.29/AIN6 (A1) +#define D17 (17ul) // P0.31/AIN7 (A2) + +// extra center pins (left to right) +#define D18 (18ul) // P1.01 (SCK1) +#define D19 (19ul) // P1.02 (MISO1) +#define D20 (20ul) // P1.07 (MOSI1) + +/* + * Macros for nRF pin numbers for compatibility + */ +#define P0_06 (D0) +#define P0_08 (D1) +#define P0_17 (D2) +#define P0_20 (D3) +#define P0_22 (D4) +#define P0_24 (D5) +#define P1_00 (D6) +#define P0_11 (D7) +#define P1_04 (D8) +#define P1_06 (D9) +#define P0_09 (D10) +#define P0_10 (D11) +#define P1_11 (D12) +#define P1_13 (D13) +#define P1_15 (D14) +#define P0_02 (D15) +#define P0_29 (D16) +#define P0_31 (D17) +#define P1_01 (D18) +#define P1_02 (D19) +#define P1_07 (D20) +#define P0_13 (EXT_VCC) +#define P0_15 (PIN_LED) + +/* + * Analog pins + */ +#define PIN_A0 (15) // P0.02 (D15) +#define PIN_A1 (16) // P0.29 (D16) +#define PIN_A2 (17) // P0.31 (D17) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +#define ADC_RESOLUTION 12 + +/* + * Other pins + */ +#define PIN_NFC1 (10) // P0.09 - also D10 +#define PIN_NFC2 (11) // P0.10 - also D11 + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_TX (0) // P0.06 - also D0 +#define PIN_SERIAL1_RX (1) // P0.08 - also D1 + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 2 + +#define PIN_SPI_SCK (2) // P0.17 - D2 +#define PIN_SPI_MISO (3) // P0.20 - D3 +#define PIN_SPI_MOSI (4) // P0.22 - D4 + +static const uint8_t SS = (5); // P0.24 - D5 +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +#define PIN_SPI1_SCK (18) // P1.01 - D18 +#define PIN_SPI1_MISO (19) // P1.02 - D19 +#define PIN_SPI1_MOSI (20) // P1.07 - D20 + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 2 + +#define PIN_WIRE_SDA (6) // P1.00 - D6 +#define PIN_WIRE_SCL (7) // P0.11 - D7 + +static const uint8_t SDA = PIN_WIRE_SDA; +static const uint8_t SCL = PIN_WIRE_SCL; + +#define PIN_WIRE1_SDA (13) // P1.13 - D13 +#define PIN_WIRE1_SCL (14) // P1.15 - D14 + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif From a57053207f98464edd0cc1bd786a4d8fd6385ef6 Mon Sep 17 00:00:00 2001 From: taco Date: Tue, 25 Feb 2025 16:20:35 +1100 Subject: [PATCH 28/48] Added defines for SX126X_RXEN, SX126X_TXEN. Updated build target to enable privkey import/export. --- platformio.ini | 2 ++ src/helpers/nrf52/faketecBoard.h | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/platformio.ini b/platformio.ini index a1e154ce..a3abb38e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1030,6 +1030,8 @@ build_flags = -D BLE_DEBUG_LOGGING=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 + -D ENABLE_PRIVATE_KEY_EXPORT=1 + -D ENABLE_PRIVATE_KEY_IMPORT=1 build_src_filter = ${faketec.build_src_filter} + +<../examples/companion_radio/main.cpp> lib_deps = ${faketec.lib_deps} diff --git a/src/helpers/nrf52/faketecBoard.h b/src/helpers/nrf52/faketecBoard.h index 42ea37dc..5e6e86cf 100644 --- a/src/helpers/nrf52/faketecBoard.h +++ b/src/helpers/nrf52/faketecBoard.h @@ -3,20 +3,21 @@ #include #include -#define P_LORA_NSS D13 -#define P_LORA_DIO_1 D11 -#define P_LORA_RESET D10 -#define P_LORA_BUSY D16 -#define P_LORA_MISO D15 -#define P_LORA_SCLK D12 -#define P_LORA_MOSI D14 -#define SX126X_POWER_EN EXT_VCC - +#define P_LORA_NSS D13 //P1.13 45 +#define P_LORA_DIO_1 D11 //P0.10 10 +#define P_LORA_RESET D10 //P0.09 9 +#define P_LORA_BUSY D16 //P0.29 29 +#define P_LORA_MISO D15 //P0.02 2 +#define P_LORA_SCLK D12 //P1.11 43 +#define P_LORA_MOSI D14 //P1.15 47 +#define SX126X_POWER_EN EXT_VCC //P0.13 13 +#define SX126X_RXEN D2 //P0.17 +#define SX126X_TXEN RADIOLIB_NC #define SX126X_DIO2_AS_RF_SWITCH true -#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#define SX126X_DIO3_TCXO_VOLTAGE (1.8f) #define PIN_VBAT_READ PIN_A2 -#define ADC_MULTIPLIER (1.815) // dependent on voltage divider resistors. TODO: more accurate battery tracking +#define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking class faketecBoard : public mesh::MainBoard { protected: From 027b7d83cb45c8f35c44fecd345535040f70234f Mon Sep 17 00:00:00 2001 From: taco Date: Tue, 25 Feb 2025 16:35:54 +1100 Subject: [PATCH 29/48] Added logic to companion_radio firmware to hopefully fix the radio bringup for Faketec with RA01-SH. --- examples/companion_radio/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 75dbfba1..97ee2e6a 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1263,6 +1263,13 @@ void setup() { spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#if defined(FAKETEC) + if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) { + #define SX126X_DIO3_TCXO_VOLTAGE (0.0f); + tcxo = SX126X_DIO3_TCXO_VOLTAGE; + status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); + } +#endif if (status != RADIOLIB_ERR_NONE) { Serial.print("ERROR: radio init failed: "); Serial.println(status); From c1faaf5e828c333f8bab79abdc17d023140a96ba Mon Sep 17 00:00:00 2001 From: taco Date: Fri, 28 Feb 2025 12:07:16 +1100 Subject: [PATCH 30/48] build fix to support RTC detection code --- src/helpers/nrf52/faketecBoard.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/helpers/nrf52/faketecBoard.h b/src/helpers/nrf52/faketecBoard.h index 5e6e86cf..cd4a73ff 100644 --- a/src/helpers/nrf52/faketecBoard.h +++ b/src/helpers/nrf52/faketecBoard.h @@ -2,6 +2,7 @@ #include #include +#include #define P_LORA_NSS D13 //P1.13 45 #define P_LORA_DIO_1 D11 //P0.10 10 @@ -30,6 +31,12 @@ public: pinMode(PIN_VBAT_READ, INPUT); + #if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) + Wire.begin(PIN_BOARD_SDA, PIN_BOARD_SCL); + #else + Wire.begin(); + #endif + pinMode(SX126X_POWER_EN, OUTPUT); digitalWrite(SX126X_POWER_EN, HIGH); delay(10); // give sx1262 some time to power up From 92bb6a844fd205f1c3ba3ed9f27b4aa4561c4cf6 Mon Sep 17 00:00:00 2001 From: taco Date: Sun, 2 Mar 2025 11:31:57 +1100 Subject: [PATCH 31/48] added conditional to radio bringup for RA01-SH support on faketec --- examples/simple_repeater/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 3f57e814..7b8dff87 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -686,6 +686,13 @@ void setup() { spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#if defined(FAKETEC) + if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) { + #define SX126X_DIO3_TCXO_VOLTAGE (0.0f); + tcxo = SX126X_DIO3_TCXO_VOLTAGE; + status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); + } +#endif if (status != RADIOLIB_ERR_NONE) { delay(5000); Serial.print("ERROR: radio init failed: "); From f9b2428dcd9963fd0a2956df01ea8349cc15baa2 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Tue, 11 Mar 2025 13:25:48 +1100 Subject: [PATCH 32/48] * BLE_NAME_PREFIX refactor --- examples/companion_radio/main.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 29ec7028..35600de1 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -46,6 +46,10 @@ #define OFFLINE_QUEUE_SIZE 16 #endif +#ifndef BLE_NAME_PREFIX + #define BLE_NAME_PREFIX "MeshCore-" +#endif + #include #define SEND_TIMEOUT_BASE_MILLIS 500 @@ -1286,14 +1290,8 @@ void setup() { the_mesh.begin(InternalFS, trng); #ifdef BLE_PIN_CODE - char dev_name[32+10]; - const char* prefix = - #ifdef BLE_NAME_PREFIX - BLE_NAME_PREFIX; - #else - "MeshCore-"; - #endif - sprintf(dev_name, "%s%s", prefix, the_mesh.getNodeName()); + char dev_name[32+16]; + sprintf(dev_name, "%s%s", BLE_NAME_PREFIX, the_mesh.getNodeName()); serial_interface.begin(dev_name, the_mesh.getBLEPin()); #else pinMode(WB_IO2, OUTPUT); @@ -1308,14 +1306,8 @@ void setup() { WiFi.begin(WIFI_SSID, WIFI_PWD); serial_interface.begin(TCP_PORT); #elif defined(BLE_PIN_CODE) - char dev_name[32+10]; - const char* prefix = - #ifdef BLE_NAME_PREFIX - BLE_NAME_PREFIX; - #else - "MeshCore-"; - #endif - sprintf(dev_name, "%s%s", prefix, the_mesh.getNodeName()); + char dev_name[32+16]; + sprintf(dev_name, "%s%s", BLE_NAME_PREFIX, the_mesh.getNodeName()); serial_interface.begin(dev_name, the_mesh.getBLEPin()); #else serial_interface.begin(Serial); From 8c68dbb6e95b56970e6d451c58f316d22d180fd6 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Tue, 11 Mar 2025 14:50:40 +1100 Subject: [PATCH 33/48] * Companion: new CMD_GET_CHANNEL, CMD_SET_CHANNEL --- examples/companion_radio/main.cpp | 37 ++++++++++++++++++++++++++---- platformio.ini | 36 ++++++++++++++--------------- src/helpers/BaseChatMesh.cpp | 38 ++++++++++++++++++++++++++++++- src/helpers/BaseChatMesh.h | 6 ++++- 4 files changed, 92 insertions(+), 25 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 35600de1..c8178b25 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -161,6 +161,8 @@ static uint32_t _atoi(const char* sp) { #define CMD_HAS_CONNECTION 28 #define CMD_LOGOUT 29 // 'Disconnect' #define CMD_GET_CONTACT_BY_KEY 30 +#define CMD_GET_CHANNEL 31 +#define CMD_SET_CHANNEL 32 #define RESP_CODE_OK 0 #define RESP_CODE_ERR 1 @@ -178,6 +180,7 @@ static uint32_t _atoi(const char* sp) { #define RESP_CODE_DEVICE_INFO 13 // a reply to CMD_DEVICE_QEURY #define RESP_CODE_PRIVATE_KEY 14 // a reply to CMD_EXPORT_PRIVATE_KEY #define RESP_CODE_DISABLED 15 +#define RESP_CODE_CHANNEL_INFO 16 // a reply to CMD_GET_CHANNEL // these are _pushed_ to client app at any time #define PUSH_CODE_ADVERT 0x80 @@ -216,7 +219,6 @@ class MyMesh : public BaseChatMesh { uint32_t expected_ack_crc; // TODO: keep table of expected ACKs uint32_t pending_login; uint32_t pending_status; - mesh::GroupChannel* _public; BaseSerialInterface* _serial; unsigned long last_msg_sent; ContactsIterator _iter; @@ -536,7 +538,7 @@ protected: void onChannelMessageRecv(const mesh::GroupChannel& channel, int in_path_len, uint32_t timestamp, const char *text) override { int i = 0; out_frame[i++] = RESP_CODE_CHANNEL_MSG_RECV; - out_frame[i++] = 0; // FUTURE: channel_idx (will just be 'public' for now) + out_frame[i++] = findChannelIdx(channel); out_frame[i++] = in_path_len < 0 ? 0xFF : in_path_len; out_frame[i++] = TXT_TYPE_PLAIN; memcpy(&out_frame[i], ×tamp, 4); i += 4; @@ -713,7 +715,7 @@ public: _fs->mkdir("/bl"); loadContacts(); - _public = addChannel(PUBLIC_GROUP_PSK); // pre-configure Andy's public channel + addChannel(PUBLIC_GROUP_PSK); // pre-configure Andy's public channel _phy->setFrequency(_prefs.freq); _phy->setSpreadingFactor(_prefs.sf); @@ -844,12 +846,14 @@ public: } else if (cmd_frame[0] == CMD_SEND_CHANNEL_TXT_MSG) { // send GroupChannel msg int i = 1; uint8_t txt_type = cmd_frame[i++]; // should be TXT_TYPE_PLAIN - uint8_t channel_idx = cmd_frame[i++]; // reserved future + uint8_t channel_idx = cmd_frame[i++]; uint32_t msg_timestamp; memcpy(&msg_timestamp, &cmd_frame[i], 4); i += 4; const char *text = (char *) &cmd_frame[i]; - if (txt_type == TXT_TYPE_PLAIN && sendGroupMessage(msg_timestamp, *_public, _prefs.node_name, text, len - i)) { // hard-coded to 'public' channel for now + mesh::GroupChannel channel; + bool success = getChannel(channel_idx, channel); + if (success && txt_type == TXT_TYPE_PLAIN && sendGroupMessage(msg_timestamp, channel, _prefs.node_name, text, len - i)) { writeOKFrame(); } else { writeErrFrame(); @@ -1161,6 +1165,29 @@ public: uint8_t* pub_key = &cmd_frame[1]; stopConnection(pub_key); writeOKFrame(); + } else if (cmd_frame[0] == CMD_GET_CHANNEL && len >= 2) { + uint8_t channel_idx = cmd_frame[1]; + mesh::GroupChannel channel; + if (getChannel(channel_idx, channel)) { + out_frame[0] = RESP_CODE_CHANNEL_INFO; + out_frame[1] = channel_idx; + memcpy(&out_frame[2], channel.secret, 16); // NOTE: only 128-bit supported + _serial->writeFrame(out_frame, 2 + 16); + } else { + writeErrFrame(); + } + } else if (cmd_frame[0] == CMD_SET_CHANNEL && len >= 3+32) { + writeErrFrame(); // not supported (yet) + } else if (cmd_frame[0] == CMD_SET_CHANNEL && len >= 3+16) { + uint8_t channel_idx = cmd_frame[1]; + mesh::GroupChannel channel; + memset(channel.secret, 0, sizeof(channel.secret)); + memcpy(channel.secret, &cmd_frame[2], 16); // NOTE: only 128-bit supported + if (setChannel(channel_idx, channel)) { + writeOKFrame(); + } else { + writeErrFrame(); + } } else { writeErrFrame(); MESH_DEBUG_PRINTLN("ERROR: unknown command: %02X", cmd_frame[0]); diff --git a/platformio.ini b/platformio.ini index 6175206f..07ffbf91 100644 --- a/platformio.ini +++ b/platformio.ini @@ -78,7 +78,7 @@ extends = Heltec_lora32_v2 build_flags = ${Heltec_lora32_v2.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} @@ -93,7 +93,7 @@ extends = Heltec_lora32_v2 build_flags = ${Heltec_lora32_v2.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -180,7 +180,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SSD1306Display ; -D ENABLE_PRIVATE_KEY_IMPORT=1 ; -D ENABLE_PRIVATE_KEY_EXPORT=1 @@ -198,7 +198,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SSD1306Display -D BLE_PIN_CODE=0 ; dynamic, random PIN -D BLE_DEBUG_LOGGING=1 @@ -219,7 +219,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D DISPLAY_CLASS=SSD1306Display -D WIFI_DEBUG_LOGGING=1 -D WIFI_SSID='"myssid"' @@ -268,7 +268,7 @@ extends = Heltec_lora32_v3 build_flags = ${Heltec_lora32_v3.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -375,7 +375,7 @@ extends = Xiao_S3_WIO build_flags = ${Xiao_S3_WIO.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Xiao_S3_WIO.build_src_filter} @@ -389,7 +389,7 @@ extends = Xiao_S3_WIO build_flags = ${Xiao_S3_WIO.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 ; -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -454,7 +454,7 @@ extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} @@ -469,7 +469,7 @@ extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 @@ -486,7 +486,7 @@ extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 ; -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -572,7 +572,7 @@ extends = LilyGo_T3S3_sx1262 build_flags = ${LilyGo_T3S3_sx1262.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 @@ -588,7 +588,7 @@ extends = LilyGo_T3S3_sx1262 build_flags = ${LilyGo_T3S3_sx1262.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -728,7 +728,7 @@ extends = rak4631 build_flags = ${rak4631.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 @@ -744,7 +744,7 @@ extends = rak4631 build_flags = ${rak4631.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -796,7 +796,7 @@ upload_protocol = nrfutil extends = t1000-e build_flags = ${t1000-e.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 -D MESH_PACKET_LOGGING=1 @@ -870,7 +870,7 @@ extends = Heltec_t114 build_flags = ${Heltec_t114.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 @@ -943,7 +943,7 @@ extends = LilyGo_Techo build_flags = ${LilyGo_Techo.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index e8e48e53..e44ffcf3 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -203,7 +203,7 @@ void BaseChatMesh::onAckRecv(mesh::Packet* packet, uint32_t ack_crc) { #ifdef MAX_GROUP_CHANNELS int BaseChatMesh::searchChannelsByHash(const uint8_t* hash, mesh::GroupChannel dest[], int max_matches) { int n = 0; - for (int i = 0; i < num_channels && n < max_matches; i++) { + for (int i = 0; i < MAX_GROUP_CHANNELS && n < max_matches; i++) { if (channels[i].hash[0] == hash[0]) { dest[n++] = channels[i]; } @@ -602,10 +602,46 @@ mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) { } return NULL; } +bool BaseChatMesh::getChannel(int idx, mesh::GroupChannel& dest) { + if (idx >= 0 && idx < MAX_GROUP_CHANNELS) { + dest = channels[idx]; + return true; + } + return false; +} +bool BaseChatMesh::setChannel(int idx, const mesh::GroupChannel& src) { + static uint8_t zeroes[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + + if (idx >= 0 && idx < MAX_GROUP_CHANNELS) { + channels[idx] = src; + if (memcmp(&src.secret[16], zeroes, 16) == 0) { + mesh::Utils::sha256(channels[idx].hash, sizeof(channels[idx].hash), src.secret, 16); // 128-bit key + } else { + mesh::Utils::sha256(channels[idx].hash, sizeof(channels[idx].hash), src.secret, 32); // 256-bit key + } + return true; + } + return false; +} +int BaseChatMesh::findChannelIdx(const mesh::GroupChannel& ch) { + for (int i = 0; i < MAX_GROUP_CHANNELS; i++) { + if (memcmp(ch.secret, channels[i].secret, sizeof(ch.secret)) == 0) return i; + } + return -1; // not found +} #else mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) { return NULL; // not supported } +bool BaseChatMesh::getChannel(int idx, mesh::GroupChannel& dest) { + return false; +} +bool BaseChatMesh::setChannel(int idx, const mesh::GroupChannel& src) { + return false; +} +int BaseChatMesh::findChannelIdx(const mesh::GroupChannel& ch) { + return -1; // not found +} #endif ContactsIterator BaseChatMesh::startContactsIterator() { diff --git a/src/helpers/BaseChatMesh.h b/src/helpers/BaseChatMesh.h index 0f2e0283..c5b60dd1 100644 --- a/src/helpers/BaseChatMesh.h +++ b/src/helpers/BaseChatMesh.h @@ -75,7 +75,7 @@ class BaseChatMesh : public mesh::Mesh { unsigned long txt_send_timeout; #ifdef MAX_GROUP_CHANNELS mesh::GroupChannel channels[MAX_GROUP_CHANNELS]; - int num_channels; + int num_channels; // only for addChannel() #endif mesh::Packet* _pendingLoopback; uint8_t temp_buf[MAX_TRANS_UNIT]; @@ -89,6 +89,7 @@ protected: { num_contacts = 0; #ifdef MAX_GROUP_CHANNELS + memset(channels, 0, sizeof(channels)); num_channels = 0; #endif txt_send_timeout = 0; @@ -152,6 +153,9 @@ public: int getNumContacts() const { return num_contacts; } ContactsIterator startContactsIterator(); mesh::GroupChannel* addChannel(const char* psk_base64); + bool getChannel(int idx, mesh::GroupChannel& dest); + bool setChannel(int idx, const mesh::GroupChannel& src); + int findChannelIdx(const mesh::GroupChannel& ch); void loop(); }; From adf9b24867ee296ae1f7921b8f26e464d0fb0140 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Tue, 11 Mar 2025 15:31:38 +1100 Subject: [PATCH 34/48] * companion: channels now persisted. RESP_CODE_DEVICE_INFO now includes MAX_CONTACTS (div 2) and MAX_GROUP_CHANNELS --- examples/companion_radio/main.cpp | 59 +++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index c8178b25..c0b98c7b 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -180,7 +180,8 @@ static uint32_t _atoi(const char* sp) { #define RESP_CODE_DEVICE_INFO 13 // a reply to CMD_DEVICE_QEURY #define RESP_CODE_PRIVATE_KEY 14 // a reply to CMD_EXPORT_PRIVATE_KEY #define RESP_CODE_DISABLED 15 -#define RESP_CODE_CHANNEL_INFO 16 // a reply to CMD_GET_CHANNEL +// ... _V3 stuff in here +#define RESP_CODE_CHANNEL_INFO 18 // a reply to CMD_GET_CHANNEL // these are _pushed_ to client app at any time #define PUSH_CODE_ADVERT 0x80 @@ -313,6 +314,56 @@ class MyMesh : public BaseChatMesh { } } + void loadChannels() { + if (_fs->exists("/channels")) { + File file = _fs->open("/channels"); + if (file) { + bool full = false; + uint8_t channel_idx = 0; + while (!full) { + mesh::GroupChannel ch; + uint8_t unused[4]; + + bool success = (file.read(unused, 4) == 4); + success = success && (file.read((uint8_t *) ch.secret, 32) == 32); + + if (!success) break; // EOF + + if (setChannel(channel_idx, ch)) { + channel_idx++; + } else { + full = true; + } + } + file.close(); + } + } + } + + void saveChannels() { + #if defined(NRF52_PLATFORM) + File file = _fs->open("/channels", FILE_O_WRITE); + if (file) { file.seek(0); file.truncate(); } + #else + File file = _fs->open("/channels", "w", true); + #endif + if (file) { + uint8_t channel_idx = 0; + mesh::GroupChannel ch; + uint8_t unused[4]; + memset(unused, 0, 4); + + while (getChannel(channel_idx, ch)) { + bool success = (file.write(unused, 4) == 4); + success = success && (file.write((uint8_t *) ch.secret, 32) == 32); + + if (!success) break; // write failed + channel_idx++; + } + file.close(); + } + } + int getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]) override { char path[64]; char fname[18]; @@ -716,6 +767,7 @@ public: loadContacts(); addChannel(PUBLIC_GROUP_PSK); // pre-configure Andy's public channel + loadChannels(); _phy->setFrequency(_prefs.freq); _phy->setSpreadingFactor(_prefs.sf); @@ -771,7 +823,9 @@ public: int i = 0; out_frame[i++] = RESP_CODE_DEVICE_INFO; out_frame[i++] = FIRMWARE_VER_CODE; - memset(&out_frame[i], 0, 6); i += 6; // reserved + out_frame[i++] = MAX_CONTACTS / 2; // v3+ + out_frame[i++] = MAX_GROUP_CHANNELS; // v3+ + memset(&out_frame[i], 0, 4); i += 4; // reserved memset(&out_frame[i], 0, 12); strcpy((char *) &out_frame[i], FIRMWARE_BUILD_DATE); i += 12; StrHelper::strzcpy((char *) &out_frame[i], board.getManufacturerName(), 40); i += 40; @@ -1184,6 +1238,7 @@ public: memset(channel.secret, 0, sizeof(channel.secret)); memcpy(channel.secret, &cmd_frame[2], 16); // NOTE: only 128-bit supported if (setChannel(channel_idx, channel)) { + saveChannels(); writeOKFrame(); } else { writeErrFrame(); From 1a21a08845b1d89476fe97152592eb79bf74b515 Mon Sep 17 00:00:00 2001 From: taco Date: Tue, 11 Mar 2025 15:38:37 +1100 Subject: [PATCH 35/48] updated to MIT licensed board variant --- boards/promicro_nrf52840.json | 78 +++++++++++ platformio.ini | 3 +- src/helpers/nrf52/faketecBoard.h | 20 +-- variants/promicro_nrf52840/variant.cpp | 15 ++ variants/promicro_nrf52840/variant.h | 82 +++++++++++ variants/supermini_nrf52840/variant.cpp | 52 ------- variants/supermini_nrf52840/variant.h | 176 ------------------------ 7 files changed, 186 insertions(+), 240 deletions(-) create mode 100644 boards/promicro_nrf52840.json create mode 100644 variants/promicro_nrf52840/variant.cpp create mode 100644 variants/promicro_nrf52840/variant.h delete mode 100644 variants/supermini_nrf52840/variant.cpp delete mode 100644 variants/supermini_nrf52840/variant.h diff --git a/boards/promicro_nrf52840.json b/boards/promicro_nrf52840.json new file mode 100644 index 00000000..346f0f26 --- /dev/null +++ b/boards/promicro_nrf52840.json @@ -0,0 +1,78 @@ +{ + "build": { + "arduino":{ + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + [ + "0x239A", + "0x00B3" + ], + [ + "0x239A", + "0x8029" + ], + [ + "0x239A", + "0x0029" + ], + [ + "0x239A", + "0x002A" + ], + [ + "0x239A", + "0x802A" + ] + ], + "usb_product": "ProMicro NRF52840", + "mcu": "nrf52840", + "variant": "promicro_nrf52840", + "variants_dir": "variants", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": [ + "bluetooth" + ], + "debug": { + "jlink_device": "nRF52840_xxAA", + "svd_path": "nrf52840.svd" + }, + "frameworks": [ + "arduino", + "zephyr" + ], + "name": "ProMicro NRF52840", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "speed": 115200, + "protocol": "nrfutil", + "protocols": [ + "jlink", + "nrfjprog", + "nrfutil", + "stlink" + ], + "use_1200bps_touch": true, + "require_upload_port": true, + "wait_for_upload_port": true + }, + "url": "https://www.nologo.tech/en/product/otherboard/NRF52840.html", + "vendor": "Nologo" + } \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index a3abb38e..5e22eb56 100644 --- a/platformio.ini +++ b/platformio.ini @@ -951,8 +951,7 @@ lib_deps = [faketec] extends = nrf52840_base -board = supermini_nrf52840 -#board_check = true +board = promicro_nrf52840 build_src_filter = ${nrf52840_base.build_src_filter} + build_flags = ${nrf52840_base.build_flags} -D FAKETEC diff --git a/src/helpers/nrf52/faketecBoard.h b/src/helpers/nrf52/faketecBoard.h index cd4a73ff..b5cebb78 100644 --- a/src/helpers/nrf52/faketecBoard.h +++ b/src/helpers/nrf52/faketecBoard.h @@ -4,20 +4,20 @@ #include #include -#define P_LORA_NSS D13 //P1.13 45 -#define P_LORA_DIO_1 D11 //P0.10 10 -#define P_LORA_RESET D10 //P0.09 9 -#define P_LORA_BUSY D16 //P0.29 29 -#define P_LORA_MISO D15 //P0.02 2 -#define P_LORA_SCLK D12 //P1.11 43 -#define P_LORA_MOSI D14 //P1.15 47 -#define SX126X_POWER_EN EXT_VCC //P0.13 13 -#define SX126X_RXEN D2 //P0.17 +#define P_LORA_NSS 13 //P1.13 45 +#define P_LORA_DIO_1 11 //P0.10 10 +#define P_LORA_RESET 10 //P0.09 9 +#define P_LORA_BUSY 16 //P0.29 29 +#define P_LORA_MISO 15 //P0.02 2 +#define P_LORA_SCLK 12 //P1.11 43 +#define P_LORA_MOSI 14 //P1.15 47 +#define SX126X_POWER_EN 21 //P0.13 13 +#define SX126X_RXEN 2 //P0.17 #define SX126X_TXEN RADIOLIB_NC #define SX126X_DIO2_AS_RF_SWITCH true #define SX126X_DIO3_TCXO_VOLTAGE (1.8f) -#define PIN_VBAT_READ PIN_A2 +#define PIN_VBAT_READ 17 #define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking class faketecBoard : public mesh::MainBoard { diff --git a/variants/promicro_nrf52840/variant.cpp b/variants/promicro_nrf52840/variant.cpp new file mode 100644 index 00000000..0a4c3aac --- /dev/null +++ b/variants/promicro_nrf52840/variant.cpp @@ -0,0 +1,15 @@ +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + 8, 6, 17, 20, 22, 24, 32, 11, 36, 38, + 9, 10, 43, 45, 47, 2, 29, 31, + 33, 34, 37, + 13, 15 +}; + +void initVariant() +{ +} + diff --git a/variants/promicro_nrf52840/variant.h b/variants/promicro_nrf52840/variant.h new file mode 100644 index 00000000..98489da1 --- /dev/null +++ b/variants/promicro_nrf52840/variant.h @@ -0,0 +1,82 @@ +/* + * variant.h + * Copyright (C) 2023 Seeed K.K. + * MIT License + */ + + #pragma once + + #include "WVariant.h" + + //////////////////////////////////////////////////////////////////////////////// + // Low frequency clock source + +#define VARIANT_MCK (64000000ul) + +//#define USE_LFXO // 32.768 kHz crystal oscillator +#define USE_LFRC // 32.768 kHz RC oscillator + +//////////////////////////////////////////////////////////////////////////////// +// Power + +#define PIN_EXT_VCC (21) +#define EXT_VCC (PIN_EXT_VCC) + +#define BATTERY_PIN (17) +#define ADC_RESOLUTION 12 + +//////////////////////////////////////////////////////////////////////////////// +// Number of pins + +#define PINS_COUNT (23) +#define NUM_DIGITAL_PINS (23) +#define NUM_ANALOG_INPUTS (3) +#define NUM_ANALOG_OUTPUTS (0) + +//////////////////////////////////////////////////////////////////////////////// +// UART pin definition + +#define PIN_SERIAL1_TX (1) +#define PIN_SERIAL1_RX (0) + +//////////////////////////////////////////////////////////////////////////////// +// I2C pin definition + +#define WIRE_INTERFACES_COUNT 2 + +#define PIN_WIRE_SDA (6) +#define PIN_WIRE_SCL (7) +#define PIN_WIRE1_SDA (13) +#define PIN_WIRE1_SCL (14) + +//////////////////////////////////////////////////////////////////////////////// +// SPI pin definition + +#define SPI_INTERFACES_COUNT 2 + +#define PIN_SPI_SCK (2) +#define PIN_SPI_MISO (3) +#define PIN_SPI_MOSI (4) + +#define PIN_SPI_NSS (5) + +#define PIN_SPI1_SCK (18) +#define PIN_SPI1_MISO (19) +#define PIN_SPI1_MOSI (20) + +//////////////////////////////////////////////////////////////////////////////// +// Builtin LEDs + +#define PIN_LED (22) +#define LED_PIN PIN_LED +#define LED_BLUE PIN_LED +#define LED_BUILTIN PIN_LED +#define LED_STATE_ON 1 + +//////////////////////////////////////////////////////////////////////////////// +// Builtin buttons + +#define PIN_BUTTON1 (6) +#define BUTTON_PIN PIN_BUTTON1 + + diff --git a/variants/supermini_nrf52840/variant.cpp b/variants/supermini_nrf52840/variant.cpp deleted file mode 100644 index 2e832f31..00000000 --- a/variants/supermini_nrf52840/variant.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "variant.h" -#include "wiring_constants.h" -#include "wiring_digital.h" -#include "nrf.h" - -const uint32_t g_ADigitalPinMap[] = -{ - // D0 - D9 (left side, top to bottom) - 6, // D0 is P0.06 (D0, TX) - 8, // D1 is P0.08 (D1, RX) - 17, // D2 is P0.17 (D2, SCK) - 20, // D3 is P0.20 (D3, MISO) - 22, // D4 is P0.22 (D4, MOSI) - 24, // D5 is P0.24 (D5, CS) - 32, // D6 is P1.00 (D6, SDA) - 11, // D7 is P0.11 (D7, SCL) - 36, // D8 is P1.04 (D8) - 38, // D9 is P1.06 (D9) - - // D10 - D17 (right side, bottom to top) - 9, // D10 is P0.09 (D10, NFC1) - 10, // D11 is P0.10 (D11, NFC2) - 43, // D12 is P1.11 (D12) - 45, // D13 is P1.13 (D13, SDA1) - 47, // D14 is P1.15 (D14, SCL1) - 2, // D15 is P0.02 (D15, A0) - 29, // D16 is P0.29 (D16, A1) - 31, // D17 is P0.31 (D17, A2) - - // D18 - D20 (extra center pins, left to right) - 33, // D18 is P1.01 (D18, SCK1) - 34, // D19 is P1.02 (D19, MISO1) - 39, // D20 is P1.07 (D20, MOSI1) - - // EXT_VCC - 13, // 'D21' is P0.13 (EXT_VCC) [active high] - - // LED - 15, // 'D22' is P0.15 (LED) -}; - -void initVariant() -{ - // enable EXT_VCC by default - pinMode(EXT_VCC, OUTPUT); - digitalWrite(EXT_VCC, HIGH); - - // enable LED by default - pinMode(LED_BUILTIN, OUTPUT); - digitalWrite(LED_BUILTIN, HIGH); -} - diff --git a/variants/supermini_nrf52840/variant.h b/variants/supermini_nrf52840/variant.h deleted file mode 100644 index b7b59c8e..00000000 --- a/variants/supermini_nrf52840/variant.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef _SUPERMINI_NRF52840_H_ -#define _SUPERMINI_NRF52840_H_ - -#define TARGET_SUPERMINI_NRF52840 - -/** Master clock frequency */ -#define VARIANT_MCK (64000000ul) - -//#define USE_LFXO // Board uses 32khz crystal for LF -#define USE_LFRC // Board uses RC for LF - -/*---------------------------------------------------------------------------- - * Headers - *----------------------------------------------------------------------------*/ - -#include "WVariant.h" - -#ifdef __cplusplus -extern "C" -{ -#endif // __cplusplus - -#define PINS_COUNT (23) -#define NUM_DIGITAL_PINS (23) -#define NUM_ANALOG_INPUTS (3) -#define NUM_ANALOG_OUTPUTS (0) - -// NOTE: -// -// BATTERY VOLTAGE IS READ VIA VDDH/5 BY CALLING -// -// analogReadVDDHDIV5() // returns uint32_t - -// 3V3 Regulator Disable -#define PIN_EXT_VCC (21) // EXT_VCC is P0.13 (set low to disable 3v3) -#define EXT_VCC (PIN_EXT_VCC) - -// LEDs -#define PIN_LED (22) // USR LED is P0.15 -#define LED_PWR (PINS_COUNT) // no LED_PWR -#define PIN_NEOPIXEL (PINS_COUNT) // no neopixel -#define NEOPIXEL_NUM 0 -#define LED_BLUE PIN_LED // required by bluefruit library - -#define LED_BUILTIN PIN_LED - -#define LED_STATE_ON 1 // State when LED is on - -/* - * Buttons - */ -#define PIN_BUTTON1 (PINS_COUNT) // no button - -// Digital PINs -// NOTE: THIS IS A RENUMBERING OF THE PINS -// AND DOES NOT CORRESPOND TO THE NICENANO DIAGRAM - -// left side (top to bottom) -#define D0 (0ul) // P0.06 (TX) -#define D1 (1ul) // P0.08 (RX) -#define D2 (2ul) // P0.17 (SCK) -#define D3 (3ul) // P0.20 (MISO) -#define D4 (4ul) // P0.22 (MOSI) -#define D5 (5ul) // P0.24 (CS) -#define D6 (6ul) // P1.00 (SDA) -#define D7 (7ul) // P0.11 (SCL) -#define D8 (8ul) // P1.04 -#define D9 (9ul) // P1.06 - -// right side (bottom to top) -#define D10 (10ul) // P0.09 (NFC1) -#define D11 (11ul) // P0.10 (NFC2) -#define D12 (12ul) // P1.11 -#define D13 (13ul) // P1.13 (SDA1) -#define D14 (14ul) // P1.15 (SCL1) -#define D15 (15ul) // P0.02/AIN0 (A0) -#define D16 (16ul) // P0.29/AIN6 (A1) -#define D17 (17ul) // P0.31/AIN7 (A2) - -// extra center pins (left to right) -#define D18 (18ul) // P1.01 (SCK1) -#define D19 (19ul) // P1.02 (MISO1) -#define D20 (20ul) // P1.07 (MOSI1) - -/* - * Macros for nRF pin numbers for compatibility - */ -#define P0_06 (D0) -#define P0_08 (D1) -#define P0_17 (D2) -#define P0_20 (D3) -#define P0_22 (D4) -#define P0_24 (D5) -#define P1_00 (D6) -#define P0_11 (D7) -#define P1_04 (D8) -#define P1_06 (D9) -#define P0_09 (D10) -#define P0_10 (D11) -#define P1_11 (D12) -#define P1_13 (D13) -#define P1_15 (D14) -#define P0_02 (D15) -#define P0_29 (D16) -#define P0_31 (D17) -#define P1_01 (D18) -#define P1_02 (D19) -#define P1_07 (D20) -#define P0_13 (EXT_VCC) -#define P0_15 (PIN_LED) - -/* - * Analog pins - */ -#define PIN_A0 (15) // P0.02 (D15) -#define PIN_A1 (16) // P0.29 (D16) -#define PIN_A2 (17) // P0.31 (D17) - -static const uint8_t A0 = PIN_A0 ; -static const uint8_t A1 = PIN_A1 ; -static const uint8_t A2 = PIN_A2 ; -#define ADC_RESOLUTION 12 - -/* - * Other pins - */ -#define PIN_NFC1 (10) // P0.09 - also D10 -#define PIN_NFC2 (11) // P0.10 - also D11 - -/* - * Serial interfaces - */ -#define PIN_SERIAL1_TX (0) // P0.06 - also D0 -#define PIN_SERIAL1_RX (1) // P0.08 - also D1 - -/* - * SPI Interfaces - */ -#define SPI_INTERFACES_COUNT 2 - -#define PIN_SPI_SCK (2) // P0.17 - D2 -#define PIN_SPI_MISO (3) // P0.20 - D3 -#define PIN_SPI_MOSI (4) // P0.22 - D4 - -static const uint8_t SS = (5); // P0.24 - D5 -static const uint8_t MOSI = PIN_SPI_MOSI ; -static const uint8_t MISO = PIN_SPI_MISO ; -static const uint8_t SCK = PIN_SPI_SCK ; - -#define PIN_SPI1_SCK (18) // P1.01 - D18 -#define PIN_SPI1_MISO (19) // P1.02 - D19 -#define PIN_SPI1_MOSI (20) // P1.07 - D20 - -/* - * Wire Interfaces - */ -#define WIRE_INTERFACES_COUNT 2 - -#define PIN_WIRE_SDA (6) // P1.00 - D6 -#define PIN_WIRE_SCL (7) // P0.11 - D7 - -static const uint8_t SDA = PIN_WIRE_SDA; -static const uint8_t SCL = PIN_WIRE_SCL; - -#define PIN_WIRE1_SDA (13) // P1.13 - D13 -#define PIN_WIRE1_SCL (14) // P1.15 - D14 - -#ifdef __cplusplus -} -#endif - -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - -#endif From b94fed4e4e9bd9cf50dc5ab45b1794ab4086a93b Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Tue, 11 Mar 2025 17:58:12 +1100 Subject: [PATCH 36/48] * companion: channel names --- examples/companion_radio/main.cpp | 47 +++++++++++++++------------- examples/simple_secure_chat/main.cpp | 6 ++-- src/helpers/BaseChatMesh.cpp | 31 +++++++++--------- src/helpers/BaseChatMesh.h | 13 +++++--- 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index c0b98c7b..05a8c58d 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -315,17 +315,18 @@ class MyMesh : public BaseChatMesh { } void loadChannels() { - if (_fs->exists("/channels")) { - File file = _fs->open("/channels"); + if (_fs->exists("/channels2")) { + File file = _fs->open("/channels2"); if (file) { bool full = false; uint8_t channel_idx = 0; while (!full) { - mesh::GroupChannel ch; + ChannelDetails ch; uint8_t unused[4]; bool success = (file.read(unused, 4) == 4); - success = success && (file.read((uint8_t *) ch.secret, 32) == 32); + success = success && (file.read((uint8_t *) ch.name, 32) == 32); + success = success && (file.read((uint8_t *) ch.channel.secret, 32) == 32); if (!success) break; // EOF @@ -342,20 +343,21 @@ class MyMesh : public BaseChatMesh { void saveChannels() { #if defined(NRF52_PLATFORM) - File file = _fs->open("/channels", FILE_O_WRITE); + File file = _fs->open("/channels2", FILE_O_WRITE); if (file) { file.seek(0); file.truncate(); } #else - File file = _fs->open("/channels", "w", true); + File file = _fs->open("/channels2", "w", true); #endif if (file) { uint8_t channel_idx = 0; - mesh::GroupChannel ch; + ChannelDetails ch; uint8_t unused[4]; memset(unused, 0, 4); while (getChannel(channel_idx, ch)) { bool success = (file.write(unused, 4) == 4); - success = success && (file.write((uint8_t *) ch.secret, 32) == 32); + success = success && (file.write((uint8_t *) ch.name, 32) == 32); + success = success && (file.write((uint8_t *) ch.channel.secret, 32) == 32); if (!success) break; // write failed channel_idx++; @@ -766,7 +768,7 @@ public: _fs->mkdir("/bl"); loadContacts(); - addChannel(PUBLIC_GROUP_PSK); // pre-configure Andy's public channel + addChannel("Public", PUBLIC_GROUP_PSK); // pre-configure Andy's public channel loadChannels(); _phy->setFrequency(_prefs.freq); @@ -905,9 +907,9 @@ public: memcpy(&msg_timestamp, &cmd_frame[i], 4); i += 4; const char *text = (char *) &cmd_frame[i]; - mesh::GroupChannel channel; + ChannelDetails channel; bool success = getChannel(channel_idx, channel); - if (success && txt_type == TXT_TYPE_PLAIN && sendGroupMessage(msg_timestamp, channel, _prefs.node_name, text, len - i)) { + if (success && txt_type == TXT_TYPE_PLAIN && sendGroupMessage(msg_timestamp, channel.channel, _prefs.node_name, text, len - i)) { writeOKFrame(); } else { writeErrFrame(); @@ -1221,22 +1223,25 @@ public: writeOKFrame(); } else if (cmd_frame[0] == CMD_GET_CHANNEL && len >= 2) { uint8_t channel_idx = cmd_frame[1]; - mesh::GroupChannel channel; + ChannelDetails channel; if (getChannel(channel_idx, channel)) { - out_frame[0] = RESP_CODE_CHANNEL_INFO; - out_frame[1] = channel_idx; - memcpy(&out_frame[2], channel.secret, 16); // NOTE: only 128-bit supported - _serial->writeFrame(out_frame, 2 + 16); + int i = 0; + out_frame[i++] = RESP_CODE_CHANNEL_INFO; + out_frame[i++] = channel_idx; + strcpy((char *)&out_frame[i], channel.name); i += 32; + memcpy(&out_frame[i], channel.channel.secret, 16); i += 16; // NOTE: only 128-bit supported + _serial->writeFrame(out_frame, i); } else { writeErrFrame(); } - } else if (cmd_frame[0] == CMD_SET_CHANNEL && len >= 3+32) { + } else if (cmd_frame[0] == CMD_SET_CHANNEL && len >= 2+32+32) { writeErrFrame(); // not supported (yet) - } else if (cmd_frame[0] == CMD_SET_CHANNEL && len >= 3+16) { + } else if (cmd_frame[0] == CMD_SET_CHANNEL && len >= 2+32+16) { uint8_t channel_idx = cmd_frame[1]; - mesh::GroupChannel channel; - memset(channel.secret, 0, sizeof(channel.secret)); - memcpy(channel.secret, &cmd_frame[2], 16); // NOTE: only 128-bit supported + ChannelDetails channel; + StrHelper::strncpy(channel.name, (char *) &cmd_frame[2], 32); + memset(channel.channel.secret, 0, sizeof(channel.channel.secret)); + memcpy(channel.channel.secret, &cmd_frame[2+32], 16); // NOTE: only 128-bit supported if (setChannel(channel_idx, channel)) { saveChannels(); writeOKFrame(); diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index 951d51dc..3a376e54 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -107,7 +107,7 @@ class MyMesh : public BaseChatMesh, ContactVisitor { FILESYSTEM* _fs; NodePrefs _prefs; uint32_t expected_ack_crc; - mesh::GroupChannel* _public; + ChannelDetails* _public; unsigned long last_msg_sent; ContactInfo* curr_recipient; char command[512+10]; @@ -337,7 +337,7 @@ public: } loadContacts(); - _public = addChannel(PUBLIC_GROUP_PSK); // pre-configure Andy's public channel + _public = addChannel("Public", PUBLIC_GROUP_PSK); // pre-configure Andy's public channel } void savePrefs() { @@ -405,7 +405,7 @@ public: temp[5 + MAX_TEXT_LEN] = 0; // truncate if too long int len = strlen((char *) &temp[5]); - auto pkt = createGroupDatagram(PAYLOAD_TYPE_GRP_TXT, *_public, temp, 5 + len); + auto pkt = createGroupDatagram(PAYLOAD_TYPE_GRP_TXT, _public->channel, temp, 5 + len); if (pkt) { sendFlood(pkt); Serial.println(" Sent."); diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index e44ffcf3..f49c5364 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -204,8 +204,8 @@ void BaseChatMesh::onAckRecv(mesh::Packet* packet, uint32_t ack_crc) { int BaseChatMesh::searchChannelsByHash(const uint8_t* hash, mesh::GroupChannel dest[], int max_matches) { int n = 0; for (int i = 0; i < MAX_GROUP_CHANNELS && n < max_matches; i++) { - if (channels[i].hash[0] == hash[0]) { - dest[n++] = channels[i]; + if (channels[i].channel.hash[0] == hash[0]) { + dest[n++] = channels[i].channel; } } return n; @@ -588,36 +588,37 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) { #ifdef MAX_GROUP_CHANNELS #include -mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) { +ChannelDetails* BaseChatMesh::addChannel(const char* name, const char* psk_base64) { if (num_channels < MAX_GROUP_CHANNELS) { auto dest = &channels[num_channels]; - memset(dest->secret, 0, sizeof(dest->secret)); - int len = decode_base64((unsigned char *) psk_base64, strlen(psk_base64), dest->secret); + memset(dest->channel.secret, 0, sizeof(dest->channel.secret)); + int len = decode_base64((unsigned char *) psk_base64, strlen(psk_base64), dest->channel.secret); if (len == 32 || len == 16) { - mesh::Utils::sha256(dest->hash, sizeof(dest->hash), dest->secret, len); + mesh::Utils::sha256(dest->channel.hash, sizeof(dest->channel.hash), dest->channel.secret, len); + StrHelper::strncpy(dest->name, name, sizeof(dest->name)); num_channels++; return dest; } } return NULL; } -bool BaseChatMesh::getChannel(int idx, mesh::GroupChannel& dest) { +bool BaseChatMesh::getChannel(int idx, ChannelDetails& dest) { if (idx >= 0 && idx < MAX_GROUP_CHANNELS) { dest = channels[idx]; return true; } return false; } -bool BaseChatMesh::setChannel(int idx, const mesh::GroupChannel& src) { +bool BaseChatMesh::setChannel(int idx, const ChannelDetails& src) { static uint8_t zeroes[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; if (idx >= 0 && idx < MAX_GROUP_CHANNELS) { channels[idx] = src; - if (memcmp(&src.secret[16], zeroes, 16) == 0) { - mesh::Utils::sha256(channels[idx].hash, sizeof(channels[idx].hash), src.secret, 16); // 128-bit key + if (memcmp(&src.channel.secret[16], zeroes, 16) == 0) { + mesh::Utils::sha256(channels[idx].channel.hash, sizeof(channels[idx].channel.hash), src.channel.secret, 16); // 128-bit key } else { - mesh::Utils::sha256(channels[idx].hash, sizeof(channels[idx].hash), src.secret, 32); // 256-bit key + mesh::Utils::sha256(channels[idx].channel.hash, sizeof(channels[idx].channel.hash), src.channel.secret, 32); // 256-bit key } return true; } @@ -625,18 +626,18 @@ bool BaseChatMesh::setChannel(int idx, const mesh::GroupChannel& src) { } int BaseChatMesh::findChannelIdx(const mesh::GroupChannel& ch) { for (int i = 0; i < MAX_GROUP_CHANNELS; i++) { - if (memcmp(ch.secret, channels[i].secret, sizeof(ch.secret)) == 0) return i; + if (memcmp(ch.secret, channels[i].channel.secret, sizeof(ch.secret)) == 0) return i; } return -1; // not found } #else -mesh::GroupChannel* BaseChatMesh::addChannel(const char* psk_base64) { +ChannelDetails* BaseChatMesh::addChannel(const char* psk_base64) { return NULL; // not supported } -bool BaseChatMesh::getChannel(int idx, mesh::GroupChannel& dest) { +bool BaseChatMesh::getChannel(int idx, ChannelDetails& dest) { return false; } -bool BaseChatMesh::setChannel(int idx, const mesh::GroupChannel& src) { +bool BaseChatMesh::setChannel(int idx, const ChannelDetails& src) { return false; } int BaseChatMesh::findChannelIdx(const mesh::GroupChannel& ch) { diff --git a/src/helpers/BaseChatMesh.h b/src/helpers/BaseChatMesh.h index c5b60dd1..ec603a7e 100644 --- a/src/helpers/BaseChatMesh.h +++ b/src/helpers/BaseChatMesh.h @@ -61,6 +61,11 @@ struct ConnectionInfo { uint32_t expected_ack; }; +struct ChannelDetails { + mesh::GroupChannel channel; + char name[32]; +}; + /** * \brief abstract Mesh class for common 'chat' client */ @@ -74,7 +79,7 @@ class BaseChatMesh : public mesh::Mesh { int matching_peer_indexes[MAX_SEARCH_RESULTS]; unsigned long txt_send_timeout; #ifdef MAX_GROUP_CHANNELS - mesh::GroupChannel channels[MAX_GROUP_CHANNELS]; + ChannelDetails channels[MAX_GROUP_CHANNELS]; int num_channels; // only for addChannel() #endif mesh::Packet* _pendingLoopback; @@ -152,9 +157,9 @@ public: bool addContact(const ContactInfo& contact); int getNumContacts() const { return num_contacts; } ContactsIterator startContactsIterator(); - mesh::GroupChannel* addChannel(const char* psk_base64); - bool getChannel(int idx, mesh::GroupChannel& dest); - bool setChannel(int idx, const mesh::GroupChannel& src); + ChannelDetails* addChannel(const char* name, const char* psk_base64); + bool getChannel(int idx, ChannelDetails& dest); + bool setChannel(int idx, const ChannelDetails& src); int findChannelIdx(const mesh::GroupChannel& ch); void loop(); From 4a0f4f4b68c65b56e9ee80d2a31b17d350c77670 Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Tue, 11 Mar 2025 09:11:14 +0100 Subject: [PATCH 37/48] set cpu freq in ESP32Board.h --- examples/companion_radio/main.cpp | 4 ---- examples/simple_repeater/main.cpp | 4 ---- examples/simple_room_server/main.cpp | 5 ----- examples/simple_secure_chat/main.cpp | 5 ----- platformio.ini | 3 ++- src/helpers/ESP32Board.h | 4 ++++ 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index e719e900..29ec7028 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1246,10 +1246,6 @@ void setup() { Serial.begin(115200); board.begin(); -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif - #ifdef SX126X_DIO3_TCXO_VOLTAGE float tcxo = SX126X_DIO3_TCXO_VOLTAGE; #else diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index e9f6d480..5743647b 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -664,10 +664,6 @@ void setup() { delay(1000); board.begin(); - -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif #ifdef ESP32 fallback_clock.begin(); #endif diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 5f7d577a..285d59c6 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -726,11 +726,6 @@ void setup() { delay(1000); board.begin(); - -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif - #ifdef ESP32 fallback_clock.begin(); #endif diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index f34f025f..951d51dc 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -566,11 +566,6 @@ void setup() { Serial.begin(115200); board.begin(); - -#ifdef ESP32_CPU_FREQ - setCpuFrequencyMhz(ESP32_CPU_FREQ); -#endif - #ifdef SX126X_DIO3_TCXO_VOLTAGE float tcxo = SX126X_DIO3_TCXO_VOLTAGE; #else diff --git a/platformio.ini b/platformio.ini index 7ecb7ff4..d89737ea 100644 --- a/platformio.ini +++ b/platformio.ini @@ -31,6 +31,8 @@ extends = arduino_base platform = espressif32 monitor_filters = esp32_exception_decoder extra_scripts = merge-bin.py +build_flags = ${arduino_base.build_flags} +; -D ESP32_CPU_FREQ=80 ; change it to your need build_src_filter = ${arduino_base.build_src_filter} ; ================ @@ -126,7 +128,6 @@ build_flags = -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=130.0f ; for best TX power! -D SX126X_RX_BOOSTED_GAIN=true - -D ESP32_CPU_FREQ=240 build_src_filter = ${esp32_base.build_src_filter} lib_deps = ${esp32_base.lib_deps} diff --git a/src/helpers/ESP32Board.h b/src/helpers/ESP32Board.h index 45fb16bd..70e29575 100644 --- a/src/helpers/ESP32Board.h +++ b/src/helpers/ESP32Board.h @@ -17,6 +17,10 @@ public: // for future use, sub-classes SHOULD call this from their begin() startup_reason = BD_STARTUP_NORMAL; + #ifdef ESP32_CPU_FREQ + setCpuFrequencyMhz(ESP32_CPU_FREQ); + #endif + #ifdef PIN_VBAT_READ // battery read support pinMode(PIN_VBAT_READ, INPUT); From dc4a139f88437500d37bbfa3427751352fea213c Mon Sep 17 00:00:00 2001 From: Florent de Lamotte Date: Tue, 11 Mar 2025 09:18:50 +0100 Subject: [PATCH 38/48] resolve conflict --- platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index f6221c51..be098c43 100644 --- a/platformio.ini +++ b/platformio.ini @@ -781,7 +781,6 @@ build_flags = ${nrf52840_t1000e.build_flags} -D RADIO_CLASS=CustomLR1110 -D WRAPPER_CLASS=CustomLR1110Wrapper -D MAX_LORA_TX_POWER=22 - -D LORA_TX_POWER=22 build_src_filter = ${nrf52840_t1000e.build_src_filter} + + From 6b6534ed7985d686af803dcb99eb088f8386d6de Mon Sep 17 00:00:00 2001 From: uncle lit <43320854+LitBomb@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:45:07 -0700 Subject: [PATCH 39/48] Update faq.md update UK and EU frequency to 869.525MHz per Andy and Recrof add steps to set frequency on repeater after flash and before disconnecting USB cable --- docs/faq.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index c94d231f..fd578ad2 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -83,6 +83,12 @@ If you have two supported devices, and there are not many MeshCore users near yo If you have two supported devices, and there are other MeshcCore users near by, you can flash one of your devices with BLE Companion firmware, and flash another supported device to repeater firmware. Place the repeater high above ground o extend your MeshCore network's reach. +After you flashed the latest firmware onto your repeater device, keep the device connected to your computer via USB serial, use the console feature on the web flasher and set the frequency for your region or country, so your client can remote administer the rpeater or room server over RF: + +`set freq {frequency}` + +The repeater and room server CLI reference is here: https://github.com/ripplebiz/MeshCore/wiki/Repeater-&-Room-Server-CLI-Reference + If you have more supported devices, you can use your additional deivces with the room server firmware. ### Q: Does MeshCore cost any money? @@ -96,10 +102,10 @@ The T-Deck firmware is free to download and most features are available without ### Q: What frequencies are supported by MeshCore? **A:** It supports the 868MHz range in the UK/EU and the 915MHz range in New Zealand, Australia, and the USA. Countries and regions in these two frequency ranges are also supported. The firmware and client allow users to set their preferred frequency. -- Australia and New Zealand are using **915.8MHz** -- UK and EU are gravitating toward **867.5MHz** -- There are discussions on discord for UK to move to 869.525MHz (https://discord.com/channels/826570251612323860/1330643963501351004/1342554454498742374) -- Canada and USA is on **910.525MHz** +- Australia and New Zealand are on **915.8MHz** +- UK and EU are on **869.525MHz** +- Canada and USA are on **910.525MHz** +- For other regions and countries, please check your local LoRa frequency the rest of the radio settings are the same for all frequencies: - Spread Factor (SF): 10 @@ -231,6 +237,13 @@ Lowering the spreading factor makes it more difficult for the gateway to receive So it's balancing act between speed of the transmission and resistance to noise. things network is mainly focused on LoRaWAN, but the LoRa low-level stuff still checks out for any LoRa project +### Q: What happens when a node learns a route via a mobile repeater, and that repeater is gone? + +**A:** If you used to reach a node through a repeater and the repeater is no longer reachable, the client will send the message using the existing (but now broken) known path, the message will fail after 3 retries, and the app will reset the path and send the message as flood on the last retry by default. This can be turned off in settings. If the destination is reachable directly or through another repeater, the new path will be used going forward. Or you can set the path manually if you know a specific repeater to use to reach that destination. + +In the case if users are moving around frequently, and the paths are breaking, they just see the phone client retries and revert to flood to attempt to reestablish a path. + + ### Q: Is MeshCore open source? **A:** Most of the firmware is freely available. Everything is open source except the T-Deck firmware and Liam's native mobile apps. - Firmware repo: @@ -360,4 +373,3 @@ You can update repeater and room server firmware with a bluetooth connection bet --- - From 38b9834261eda606231e70ef684bd007dcb0fbef Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Thu, 13 Mar 2025 13:32:46 +1100 Subject: [PATCH 40/48] * missing param --- src/helpers/BaseChatMesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index f49c5364..99fd942a 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -631,7 +631,7 @@ int BaseChatMesh::findChannelIdx(const mesh::GroupChannel& ch) { return -1; // not found } #else -ChannelDetails* BaseChatMesh::addChannel(const char* psk_base64) { +ChannelDetails* BaseChatMesh::addChannel(const char* name, const char* psk_base64) { return NULL; // not supported } bool BaseChatMesh::getChannel(int idx, ChannelDetails& dest) { From 658094f654f48bb569412d64b4d4d195eda248bd Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Thu, 13 Mar 2025 13:46:01 +1100 Subject: [PATCH 41/48] * ver bump: 1.3.0 --- examples/companion_radio/main.cpp | 4 ++-- examples/simple_repeater/main.cpp | 4 ++-- examples/simple_room_server/main.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 05a8c58d..f3374ecb 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -124,11 +124,11 @@ static uint32_t _atoi(const char* sp) { #define FIRMWARE_VER_CODE 2 #ifndef FIRMWARE_BUILD_DATE - #define FIRMWARE_BUILD_DATE "9 Mar 2025" + #define FIRMWARE_BUILD_DATE "13 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.2" + #define FIRMWARE_VERSION "v1.3.0" #endif #define CMD_APP_START 1 diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 605e7a35..0ddf4fdf 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 "9 Mar 2025" + #define FIRMWARE_BUILD_DATE "13 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.2" + #define FIRMWARE_VERSION "v1.3.0" #endif #ifndef LORA_FREQ diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 573ff1a4..94d1e4fc 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 "9 Mar 2025" + #define FIRMWARE_BUILD_DATE "13 Mar 2025" #endif #ifndef FIRMWARE_VERSION - #define FIRMWARE_VERSION "v1.2.2" + #define FIRMWARE_VERSION "v1.3.0" #endif #ifndef LORA_FREQ From 9c3b4dd5208e3e1511589604c7744d6a3d1b099f Mon Sep 17 00:00:00 2001 From: taco Date: Thu, 13 Mar 2025 17:46:58 +1100 Subject: [PATCH 42/48] added SX126X_RX_BOOSTED_GAIN=1 to faketec target --- platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio.ini b/platformio.ini index 7b91655e..0086c2a7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -970,6 +970,7 @@ build_flags = ${nrf52840_base.build_flags} -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_CURRENT_LIMIT=130 + -D SX126X_RX_BOOSTED_GAIN=1 [env:Faketec_Repeater] extends = faketec From 87462b20d53b9d507f536bdc1645407b5b680870 Mon Sep 17 00:00:00 2001 From: ripplebiz Date: Fri, 14 Mar 2025 09:55:48 +1100 Subject: [PATCH 43/48] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0103da77..1413a4b4 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,11 @@ MeshCore is designed for use with: ## 📜 License MeshCore is open-source software released under the MIT License. You are free to use, modify, and distribute it for personal and commercial projects. +## Contributing + +Please submit PR's using 'dev' as the base branch! +For minor changes just submit your PR and I'll try to review it, but for anything more 'impactful' please open an Issue first and start a discussion. Is better to sound out what it is you want to achieve first, and try to come to a consensus on what the best approach is, especially when it impacts the structure or architecture of this codebase. + ## 📞 Get Support Check out the GitHub Issues page to report bugs or request features. From 5632e2771e00ab9f98160376e761ad105a89f6cf Mon Sep 17 00:00:00 2001 From: taco Date: Fri, 14 Mar 2025 15:22:42 +1100 Subject: [PATCH 44/48] added conditional to room server radio bringup for supporting RA01sh radio on faketec --- examples/simple_room_server/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index bd4564ee..e2572613 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -751,6 +751,13 @@ void setup() { spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); +#if defined(FAKETEC) + if (status == RADIOLIB_ERR_SPI_CMD_FAILED || status == RADIOLIB_ERR_SPI_CMD_INVALID) { + #define SX126X_DIO3_TCXO_VOLTAGE (0.0f); + tcxo = SX126X_DIO3_TCXO_VOLTAGE; + status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); + } +#endif if (status != RADIOLIB_ERR_NONE) { delay(5000); Serial.print("ERROR: radio init failed: "); From fbb879600d53331cc38f1f3e17d6ec28dc965de3 Mon Sep 17 00:00:00 2001 From: taco Date: Fri, 14 Mar 2025 15:24:58 +1100 Subject: [PATCH 45/48] MAX_GROUP_CHANNELS=8 for faketec --- platformio.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platformio.ini b/platformio.ini index 0086c2a7..c6e31268 100644 --- a/platformio.ini +++ b/platformio.ini @@ -1022,7 +1022,7 @@ extends = faketec build_flags = ${faketec.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 build_src_filter = ${faketec.build_src_filter} +<../examples/companion_radio/main.cpp> @@ -1036,13 +1036,13 @@ extends = faketec build_flags = ${faketec.build_flags} -D MAX_CONTACTS=100 - -D MAX_GROUP_CHANNELS=1 + -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 -; -D MESH_PACKET_LOGGING=1 -; -D MESH_DEBUG=1 -D ENABLE_PRIVATE_KEY_EXPORT=1 -D ENABLE_PRIVATE_KEY_IMPORT=1 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 build_src_filter = ${faketec.build_src_filter} + +<../examples/companion_radio/main.cpp> lib_deps = ${faketec.lib_deps} From 6a4b7463ef79058fe4e5248cfff39595b5ea5f6d Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Fri, 14 Mar 2025 19:08:41 +1100 Subject: [PATCH 46/48] * some fixes around the powerOff(). Tidy ups --- examples/companion_radio/UITask.cpp | 74 ++++++++++++++--------------- examples/companion_radio/UITask.h | 1 - src/MeshCore.h | 2 +- src/helpers/HeltecV3Board.h | 3 +- 4 files changed, 39 insertions(+), 41 deletions(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index df09e269..b454d939 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -26,7 +26,6 @@ static const uint8_t meshcore_logo [] PROGMEM = { }; void UITask::begin(const char* node_name, const char* build_date, uint32_t pin_code) { - _prevBtnState = HIGH; _auto_off = millis() + AUTO_OFF_MILLIS; clearMsgPreview(); _node_name = node_name; @@ -66,43 +65,43 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i } void UITask::renderCurrScreen() { - if (_display != NULL) { - char tmp[80]; - if (_origin[0] && _msg[0]) { - // render message preview - _display->setCursor(0, 0); - _display->setTextSize(1); - _display->print(_node_name); + if (_display == NULL) return; // assert() ?? - _display->setCursor(0, 12); - _display->print(_origin); - _display->setCursor(0, 24); - _display->print(_msg); + char tmp[80]; + if (_origin[0] && _msg[0]) { + // render message preview + _display->setCursor(0, 0); + _display->setTextSize(1); + _display->print(_node_name); - _display->setCursor(100, 9); + _display->setCursor(0, 12); + _display->print(_origin); + _display->setCursor(0, 24); + _display->print(_msg); + + _display->setCursor(100, 9); + _display->setTextSize(2); + sprintf(tmp, "%d", _msgcount); + _display->print(tmp); + } else { + // render 'home' screen + _display->drawXbm(0, 0, meshcore_logo, 128, 13); + _display->setCursor(0, 20); + _display->setTextSize(1); + _display->print(_node_name); + + sprintf(tmp, "Build: %s", _build_date); + _display->setCursor(0, 32); + _display->print(tmp); + + if (_connected) { + //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); + //_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr); + } else if (_pin_code != 0) { _display->setTextSize(2); - sprintf(tmp, "%d", _msgcount); + _display->setCursor(0, 43); + sprintf(tmp, "Pin:%d", _pin_code); _display->print(tmp); - } else { - // render 'home' screen - _display->drawXbm(0, 0, meshcore_logo, 128, 13); - _display->setCursor(0, 20); - _display->setTextSize(1); - _display->print(_node_name); - - sprintf(tmp, "Build: %s", _build_date); - _display->setCursor(0, 32); - _display->print(tmp); - - if (_connected) { - //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); - //_display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr); - } else if (_pin_code != 0) { - _display->setTextSize(2); - _display->setCursor(0, 43); - sprintf(tmp, "Pin:%d", _pin_code); - _display->print(tmp); - } } } } @@ -135,7 +134,7 @@ void UITask::userLedHandler() { void UITask::buttonHandler() { #ifdef PIN_USER_BTN - static int prev_btn_state = HIGH; + static int prev_btn_state = !USER_BTN_PRESSED; static unsigned long btn_state_change_time = 0; static unsigned long next_read = 0; int cur_time = millis(); @@ -153,11 +152,10 @@ void UITask::buttonHandler() { } } else { // unpressed ? check pressed time ... if ((cur_time - btn_state_change_time) > 5000) { - Serial.println("power off"); - #ifdef PIN_STATUS_LED + #ifdef PIN_STATUS_LED digitalWrite(PIN_STATUS_LED, LOW); delay(10); - #endif + #endif _board->powerOff(); } } diff --git a/examples/companion_radio/UITask.h b/examples/companion_radio/UITask.h index fa645324..4cea0b8d 100644 --- a/examples/companion_radio/UITask.h +++ b/examples/companion_radio/UITask.h @@ -7,7 +7,6 @@ class UITask { DisplayDriver* _display; mesh::MainBoard* _board; unsigned long _next_refresh, _auto_off; - int _prevBtnState; bool _connected; uint32_t _pin_code; const char* _node_name; diff --git a/src/MeshCore.h b/src/MeshCore.h index 5f9956a3..9593877d 100644 --- a/src/MeshCore.h +++ b/src/MeshCore.h @@ -40,7 +40,7 @@ public: virtual void onBeforeTransmit() { } virtual void onAfterTransmit() { } virtual void reboot() = 0; - virtual void powerOff() { while (1) { }}; // hope it's overriden or never called ;) + virtual void powerOff() { /* no op */ } virtual uint8_t getStartupReason() const = 0; virtual bool startOTAUpdate() { return false; } // not supported }; diff --git a/src/helpers/HeltecV3Board.h b/src/helpers/HeltecV3Board.h index c61189f2..88e49970 100644 --- a/src/helpers/HeltecV3Board.h +++ b/src/helpers/HeltecV3Board.h @@ -68,7 +68,8 @@ public: } void powerOff() override { - enterDeepSleep(0); + // TODO: re-enable this when there is a definite wake-up source pin: + // enterDeepSleep(0); } uint16_t getBattMilliVolts() override { From 6931887424cb756028c678ff9433b7800a1c7000 Mon Sep 17 00:00:00 2001 From: taco Date: Sat, 15 Mar 2025 10:54:37 +1100 Subject: [PATCH 47/48] remove old unused board.json --- boards/supermini_nrf52840.json | 78 ---------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 boards/supermini_nrf52840.json diff --git a/boards/supermini_nrf52840.json b/boards/supermini_nrf52840.json deleted file mode 100644 index 328c0c9d..00000000 --- a/boards/supermini_nrf52840.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "build": { - "arduino":{ - "ldscript": "nrf52840_s140_v6.ld" - }, - "core": "nRF5", - "cpu": "cortex-m4", - "extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA", - "f_cpu": "64000000L", - "hwids": [ - [ - "0x239A", - "0x00B3" - ], - [ - "0x239A", - "0x8029" - ], - [ - "0x239A", - "0x0029" - ], - [ - "0x239A", - "0x002A" - ], - [ - "0x239A", - "0x802A" - ] - ], - "usb_product": "SuperMini nRF52840", - "mcu": "nrf52840", - "variant": "supermini_nrf52840", - "variants_dir": "variants", - "bsp": { - "name": "adafruit" - }, - "softdevice": { - "sd_flags": "-DS140", - "sd_name": "s140", - "sd_version": "6.1.1", - "sd_fwid": "0x00B6" - }, - "bootloader": { - "settings_addr": "0xFF000" - } - }, - "connectivity": [ - "bluetooth" - ], - "debug": { - "jlink_device": "nRF52840_xxAA", - "svd_path": "nrf52840.svd" - }, - "frameworks": [ - "arduino", - "zephyr" - ], - "name": "Nologo SuperMini nRF52840", - "upload": { - "maximum_ram_size": 248832, - "maximum_size": 815104, - "speed": 115200, - "protocol": "nrfutil", - "protocols": [ - "jlink", - "nrfjprog", - "nrfutil", - "stlink" - ], - "use_1200bps_touch": true, - "require_upload_port": true, - "wait_for_upload_port": true - }, - "url": "https://www.nologo.tech/en/product/otherboard/NRF52840.html", - "vendor": "Nologo" - } \ No newline at end of file From 27aa7a7bb03d97da6d3a610adca39c5bb27fb620 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sat, 15 Mar 2025 14:55:52 +1100 Subject: [PATCH 48/48] * minor refactor for RAK_4631 SerialInterface --- examples/companion_radio/main.cpp | 3 --- src/helpers/ArduinoSerialInterface.h | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 3411db92..44275226 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1399,9 +1399,6 @@ void setup() { sprintf(dev_name, "%s%s", BLE_NAME_PREFIX, the_mesh.getNodeName()); serial_interface.begin(dev_name, the_mesh.getBLEPin()); #else -#ifdef RAK_4631 - pinMode(WB_IO2, OUTPUT); -#endif serial_interface.begin(Serial); #endif the_mesh.startInterface(serial_interface); diff --git a/src/helpers/ArduinoSerialInterface.h b/src/helpers/ArduinoSerialInterface.h index 43613af2..e84f6d37 100644 --- a/src/helpers/ArduinoSerialInterface.h +++ b/src/helpers/ArduinoSerialInterface.h @@ -23,7 +23,12 @@ public: #ifdef LILYGO_T3S3 void begin(HWCDC& serial) { _serial = &serial; } #elif defined(NRF52_PLATFORM) - void begin(Adafruit_USBD_CDC& serial) { _serial = &serial; } + void begin(Adafruit_USBD_CDC& serial) { + _serial = &serial; + #ifdef RAK_4631 + pinMode(WB_IO2, OUTPUT); + #endif + } #else void begin(HardwareSerial& serial) { _serial = &serial; } #endif