From d83ab162181105c0fb8c45da19b94eea0934ea4c Mon Sep 17 00:00:00 2001 From: Mictronics Date: Thu, 4 Jan 2024 10:27:31 +0100 Subject: [PATCH 01/14] Fix LED pinout for T-Echo board marked v1.0, date 2021-6-28 --- variants/t-echo/variant.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 6bd5091dd0..8679dbde9d 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -43,9 +43,9 @@ extern "C" { #define NUM_ANALOG_OUTPUTS (0) // LEDs -#define PIN_LED1 (0 + 14) // 13 red (confirmed on 1.0 board) -#define PIN_LED2 (0 + 15) // 14 blue -#define PIN_LED3 (0 + 13) // 15 green +#define PIN_LED1 (0 + 14) // blue (confirmed on boards marked v1.0, date 2021-6-28) +#define PIN_LED2 (32 + 1) // green +#define PIN_LED3 (32 + 3) // red #define LED_RED PIN_LED3 #define LED_BLUE PIN_LED1 @@ -232,4 +232,4 @@ External serial flash WP25R1635FZUIL0 * Arduino objects - C++ only *----------------------------------------------------------------------------*/ -#endif +#endif \ No newline at end of file From 32f1aea6b5b40d449813e5226a1e780775194025 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Wed, 10 Jan 2024 09:49:51 +0100 Subject: [PATCH 02/14] Merge PR #420 --- protobufs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobufs b/protobufs index 2ccf73428d..1091250d25 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 2ccf73428da8dac87aca12a1f91ac5cd76a7442c +Subproject commit 1091250d256d415df2a1b2644b4d282eab6570f4 From 0dd9ce35aa7a05691b934713d261ee6c1bde0726 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Tue, 19 Mar 2024 19:41:03 +0100 Subject: [PATCH 03/14] Fixed double and missing Default class. --- src/gps/GPS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 5595172ddb..506f6d89c6 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -759,7 +759,7 @@ uint32_t GPS::getWakeTime() const if (t == UINT32_MAX) return t; // already maxint - return Default::Default::getConfiguredOrDefaultMs(t, default_broadcast_interval_secs); + return Default::getConfiguredOrDefaultMs(t, default_broadcast_interval_secs); } /** Get how long we should sleep between aqusition attempts in msecs @@ -775,7 +775,7 @@ uint32_t GPS::getSleepTime() const if (t == UINT32_MAX) return t; // already maxint - return t * 1000; + return Default::getConfiguredOrDefaultMs(t, default_gps_update_interval); } void GPS::publishUpdate() From 55e0a8429e13180b85132cc7b914c35b3093e71c Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sun, 21 Apr 2024 19:26:02 +0200 Subject: [PATCH 04/14] Use correct format specifier and fixed typo. --- src/mesh/NodeDB.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 8e3784e582..4946672ece 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -150,12 +150,12 @@ class NodeDB void setLocalPosition(meshtastic_Position position, bool timeOnly = false) { if (timeOnly) { - LOG_DEBUG("Setting local position time only: time=%i timestamp=%i\n", position.time, position.timestamp); + LOG_DEBUG("Setting local position time only: time=%u timestamp=%u\n", position.time, position.timestamp); localPosition.time = position.time; localPosition.timestamp = position.timestamp > 0 ? position.timestamp : position.time; return; } - LOG_DEBUG("Setting local position: latitude=%i, longitude=%i, time=%i, timeestamp=%i\n", position.latitude_i, + LOG_DEBUG("Setting local position: latitude=%i, longitude=%i, time=%u, timestamp=%u\n", position.latitude_i, position.longitude_i, position.time, position.timestamp); localPosition = position; } From 328becfa502db8a30fbdd61ce87c71a6fb5f164a Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sat, 20 Jul 2024 09:41:16 +0200 Subject: [PATCH 05/14] Removed duplicate code. --- src/mesh/NodeDB.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5678009c08..c0bed34371 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -432,7 +432,6 @@ void NodeDB::initModuleConfigIntervals() moduleConfig.telemetry.power_update_interval = 0; moduleConfig.neighbor_info.update_interval = 0; moduleConfig.paxcounter.paxcounter_update_interval = 0; - moduleConfig.neighbor_info.update_interval = 0; } void NodeDB::installDefaultChannels() From ff10e99793fd327529b3bf324c4594e277b6eea5 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sat, 20 Jul 2024 09:55:52 +0200 Subject: [PATCH 06/14] Fix error: #if with no expression --- src/gps/GPS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 8eb7fef273..feeac84945 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -865,7 +865,7 @@ void GPS::writePinStandby(bool standby) // Determine the new value for the pin // Normally: active HIGH for awake -#if PIN_GPS_STANDBY_INVERTED +#ifdef PIN_GPS_STANDBY_INVERTED bool val = standby; #else bool val = !standby; From 072aaae5dd198c99e4c6952bf25bf4a7d0c93217 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sat, 10 Aug 2024 18:37:26 +0200 Subject: [PATCH 07/14] Fix warning: extra tokens at end of #endif directive. --- src/modules/AdminModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 778b7193d4..25450992b1 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -828,7 +828,8 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r conn.serial.is_connected = powerFSM.getState() == &stateSERIAL; #else conn.serial.is_connected = powerFSM.getState(); -#endif conn.serial.baud = SERIAL_BAUD; +#endif + conn.serial.baud = SERIAL_BAUD; r.get_device_connection_status_response = conn; r.which_payload_variant = meshtastic_AdminMessage_get_device_connection_status_response_tag; From 33df0baa4ab0e3fdaa542328c00980db8639be90 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Sat, 17 Aug 2024 19:35:04 +0200 Subject: [PATCH 08/14] Fix antenna switching logic. Complementary-pin control logic is required on the rp2040-lora board. --- variants/rp2040-lora/variant.h | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/variants/rp2040-lora/variant.h b/variants/rp2040-lora/variant.h index 1f42c4db74..d0bbc0ec39 100644 --- a/variants/rp2040-lora/variant.h +++ b/variants/rp2040-lora/variant.h @@ -15,7 +15,7 @@ // rxd = 9 #define EXT_NOTIFY_OUT 22 -#define BUTTON_PIN 17 +#undef BUTTON_PIN // Pin 17 used for antenna switching via DIO4 #define LED_PIN PIN_LED @@ -32,23 +32,28 @@ // https://www.waveshare.com/rp2040-lora.htm // https://www.waveshare.com/img/devkit/RP2040-LoRa-HF/RP2040-LoRa-HF-details-11.jpg -#define LORA_SCK 14 // 10 -#define LORA_MISO 24 // 12 -#define LORA_MOSI 15 // 11 -#define LORA_CS 13 // 3 - -#define LORA_DIO0 RADIOLIB_NC -#define LORA_RESET 23 // 15 -#define LORA_DIO1 16 // 20 -#define LORA_DIO2 18 // 2 -#define LORA_DIO3 RADIOLIB_NC -#define LORA_DIO4 17 +#define LORA_SCK 14 // GPIO14 +#define LORA_MISO 24 // GPIO24 +#define LORA_MOSI 15 // GPIO15 +#define LORA_CS 13 // GPIO13 + +#define LORA_DIO0 RADIOLIB_NC // No GPIO connection +#define LORA_RESET 23 // GPIO23 +#define LORA_BUSY 18 // GPIO18 +#define LORA_DIO1 16 // GPIO16 +#define LORA_DIO2 RADIOLIB_NC // Antenna switching, no GPIO connection +#define LORA_DIO3 RADIOLIB_NC // No GPIO connection +#define LORA_DIO4 17 // GPIO17 + +// On rp2040-lora board the antenna switch is wired and works with complementary-pin control logic. +// See PE4259 datasheet page 4 #ifdef USE_SX1262 #define SX126X_CS LORA_CS #define SX126X_DIO1 LORA_DIO1 -#define SX126X_BUSY LORA_DIO2 +#define SX126X_BUSY LORA_BUSY #define SX126X_RESET LORA_RESET -#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO2_AS_RF_SWITCH // Antenna switch CTRL +#define SX126X_RXEN LORA_DIO4 // Antenna switch !CTRL via GPIO17 // #define SX126X_DIO3_TCXO_VOLTAGE 1.8 #endif \ No newline at end of file From 22122d44b85f8fb7ad8b9ed1630b81c714336a78 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Mon, 19 Aug 2024 12:47:02 +0200 Subject: [PATCH 09/14] Fix deprecated macros. --- src/modules/Telemetry/Sensor/OPT3001Sensor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp b/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp index d0e38bf889..338bd9e2c1 100644 --- a/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp +++ b/src/modules/Telemetry/Sensor/OPT3001Sensor.cpp @@ -25,10 +25,10 @@ void OPT3001Sensor::setup() { OPT3001_Config newConfig; - newConfig.RangeNumber = B1100; - newConfig.ConvertionTime = B0; - newConfig.Latch = B1; - newConfig.ModeOfConversionOperation = B11; + newConfig.RangeNumber = 0b1100; + newConfig.ConvertionTime = 0b0; + newConfig.Latch = 0b1; + newConfig.ModeOfConversionOperation = 0b11; OPT3001_ErrorCode errorConfig = opt3001.writeConfig(newConfig); if (errorConfig != NO_ERROR) { From 248cabd3c3c7c1000c20613f2d34d52510fc61d6 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Tue, 20 Aug 2024 10:13:52 +0200 Subject: [PATCH 10/14] Set RP2040 in dormant mode when deep sleep is triggered. --- src/platform/rp2040/main-rp2040.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platform/rp2040/main-rp2040.cpp b/src/platform/rp2040/main-rp2040.cpp index af3aeadc33..6306f34c11 100644 --- a/src/platform/rp2040/main-rp2040.cpp +++ b/src/platform/rp2040/main-rp2040.cpp @@ -1,4 +1,5 @@ #include "configuration.h" +#include "hardware/xosc.h" #include #include #include @@ -12,7 +13,11 @@ void setBluetoothEnable(bool enable) void cpuDeepSleep(uint32_t msecs) { - // not needed + /* Disable both PLL to avoid power dissipation */ + pll_deinit(pll_sys); + pll_deinit(pll_usb); + /* Set RP2040 in dormant mode. Will not wake up. */ + xosc_dormant(); } void updateBatteryLevel(uint8_t level) From fabadbfa782bd8682eb97dda7bd472f951d2bb4a Mon Sep 17 00:00:00 2001 From: Mictronics Date: Tue, 20 Aug 2024 18:49:46 +0200 Subject: [PATCH 11/14] Fix array out of bounds read. --- src/modules/AdminModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 81d595d29e..9d3d5f53f7 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -350,7 +350,7 @@ void AdminModule::handleGetModuleConfigResponse(const meshtastic_MeshPacket &mp, if (devicestate.node_remote_hardware_pins[i].node_num == 0 || !devicestate.node_remote_hardware_pins[i].has_pin) { continue; } - for (uint8_t j = 0; j < sizeof(r->get_module_config_response.payload_variant.remote_hardware.available_pins); j++) { + for (uint8_t j = 0; j < r->get_module_config_response.payload_variant.remote_hardware.available_pins_count; j++) { auto availablePin = r->get_module_config_response.payload_variant.remote_hardware.available_pins[j]; if (i < devicestate.node_remote_hardware_pins_count) { devicestate.node_remote_hardware_pins[i].node_num = mp.from; From f42dbf50d77769d5f5f34b1665cf4e515fac95b2 Mon Sep 17 00:00:00 2001 From: Mictronics Date: Mon, 7 Oct 2024 19:06:32 +0200 Subject: [PATCH 12/14] Admin key count needs to be set otherwise the key will be zero loaded after reset. --- src/mesh/NodeDB.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 639e8109ba..157b1de5f4 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -317,6 +317,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) #ifdef USERPREFS_USE_ADMIN_KEY memcpy(config.security.admin_key[0].bytes, USERPREFS_ADMIN_KEY, 32); config.security.admin_key[0].size = 32; + config.security.admin_key_count = 1; #else config.security.admin_key[0].size = 0; #endif From ac920494935fe80b82344d1230e345c05c71a0af Mon Sep 17 00:00:00 2001 From: Mictronics Date: Mon, 7 Oct 2024 19:08:59 +0200 Subject: [PATCH 13/14] Don't reset the admin key size when loading defaults. Preserve an existing key in config if possible. --- src/mesh/NodeDB.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 157b1de5f4..97ded5a50f 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -318,8 +318,6 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) memcpy(config.security.admin_key[0].bytes, USERPREFS_ADMIN_KEY, 32); config.security.admin_key[0].size = 32; config.security.admin_key_count = 1; -#else - config.security.admin_key[0].size = 0; #endif if (shouldPreserveKey) { config.security.private_key.size = 32; From 5bae4d02de807fc2b729535f3e5cf1dbf524b1de Mon Sep 17 00:00:00 2001 From: Mictronics Date: Wed, 13 Nov 2024 18:57:37 +0100 Subject: [PATCH 14/14] Remove log spam when reading INA voltage sensor. --- src/Power.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Power.cpp b/src/Power.cpp index d662143154..a354b74e2c 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -251,7 +251,6 @@ class AnalogBatteryLevel : public HasBatteryLevel #if HAS_TELEMETRY && !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) && !defined(HAS_PMU) && \ !MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR if (hasINA()) { - LOG_DEBUG("Use INA on I2C addr 0x%x for device battery voltage", config.power.device_battery_ina_address); return getINAVoltage(); } #endif