From 82b14fe07c8965c88ace0c54060c24972299eaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 23 Feb 2023 22:54:07 +0100 Subject: [PATCH 01/21] Leaving this here in case someone ever needs int :-) --- arch/esp32/esp32c3.ini | 46 +++++++++++++++++++++++++++++++ src/mesh/http/ContentHandler.cpp | 2 +- src/modules/Modules.cpp | 2 +- src/modules/SerialModule.cpp | 2 +- src/modules/SerialModule.h | 2 +- src/platform/esp32/main-esp32.cpp | 7 +++++ src/sleep.cpp | 2 ++ 7 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 arch/esp32/esp32c3.ini diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini new file mode 100644 index 00000000..08ab377d --- /dev/null +++ b/arch/esp32/esp32c3.ini @@ -0,0 +1,46 @@ +[esp32c3_base] +extends = arduino_base +platform = platformio/espressif32@^6.0.0 +build_src_filter = + ${arduino_base.build_src_filter} - - - - +upload_speed = 961200 +monitor_speed = 115200 +debug_init_break = tbreak setup +monitor_filters = esp32_exception_decoder +board_build.filesystem = littlefs + +# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging. +# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h +# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h +build_flags = + ${arduino_base.build_flags} + -Wall + -Wextra + -Isrc/platform/esp32 + -std=c++11 + -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL + -DAXP_DEBUG_PORT=Serial + -DCONFIG_BT_NIMBLE_ENABLED + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 + -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING + ;-DDEBUG_HEAP + +lib_deps = + ${arduino_base.lib_deps} + ${networking_base.lib_deps} + ${environmental_base.lib_deps} + https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 + h2zero/NimBLE-Arduino@^1.4.0 + https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 + caveman99/ESP32 Codec2@^1.0.1 + +lib_ignore = + segger_rtt + ESP32 BLE Arduino + +; customize the partition table +; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables +board_build.partitions = partition-table.csv \ No newline at end of file diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 8683f9cb..0a93298b 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -833,7 +833,7 @@ void handleScanNetworks(HTTPRequest *req, HTTPResponse *res) if (WiFi.encryptionType(i) != WIFI_AUTH_OPEN) { JSONObject thisNetwork; thisNetwork["ssid"] = new JSONValue(ssidArray); - thisNetwork["rssi"] = new JSONValue(WiFi.RSSI(i)); + thisNetwork["rssi"] = new JSONValue(int(WiFi.RSSI(i))); networkObjs.push_back(new JSONValue(thisNetwork)); } // Yield some cpu cycles to IP stack. diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 3247d02c..30034b78 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -72,7 +72,7 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) &&!defined(CONFIG_IDF_TARGET_ESP32C3) new SerialModule(); #endif #ifdef ARCH_ESP32 diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 5637f7eb..b13e8001 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -44,7 +44,7 @@ */ -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) #define RX_BUFFER 128 #define TIMEOUT 250 diff --git a/src/modules/SerialModule.h b/src/modules/SerialModule.h index 8c53d206..5aa0f97b 100644 --- a/src/modules/SerialModule.h +++ b/src/modules/SerialModule.h @@ -8,7 +8,7 @@ #include #include -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) class SerialModule : public StreamAPI, private concurrency::OSThread { diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index f6bd4f50..4f627d27 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -178,6 +178,7 @@ void cpuDeepSleep(uint64_t msecToWake) Note: we don't isolate pins that are used for the LORA, LED, i2c, spi or the wake button */ +#if SOC_RTCIO_HOLD_SUPPORTED static const uint8_t rtcGpios[] = {/* 0, */ 2, /* 4, */ #ifndef USE_JTAG @@ -189,8 +190,10 @@ void cpuDeepSleep(uint64_t msecToWake) 36, 37 /* 38, 39 */}; + for (int i = 0; i < sizeof(rtcGpios); i++) rtc_gpio_isolate((gpio_num_t)rtcGpios[i]); +#endif // FIXME, disable internal rtc pullups/pulldowns on the non isolated pins. for inputs that we aren't using // to detect wake and in normal operation the external part drives them hard. @@ -200,7 +203,9 @@ void cpuDeepSleep(uint64_t msecToWake) #ifdef BUTTON_PIN // Only GPIOs which are have RTC functionality can be used in this bit map: 0,2,4,12-15,25-27,32-39. +#if SOC_RTCIO_HOLD_SUPPORTED uint64_t gpioMask = (1ULL << BUTTON_PIN); +#endif #ifdef BUTTON_NEED_PULLUP gpio_pullup_en((gpio_num_t)BUTTON_PIN); @@ -210,7 +215,9 @@ void cpuDeepSleep(uint64_t msecToWake) // FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead of // just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN); +#if SOC_PM_SUPPORT_EXT_WAKEUP esp_sleep_enable_ext1_wakeup(gpioMask, ESP_EXT1_WAKEUP_ALL_LOW); +#endif #endif esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs diff --git a/src/sleep.cpp b/src/sleep.cpp index 77c8d711..72d4974a 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -337,6 +337,8 @@ void enableModemSleep() esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32S2 esp32_config.max_freq_mhz = CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ; +#elif CONFIG_IDF_TARGET_ESP32C3 + esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ; #else esp32_config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; #endif From 9a8bfa113d552fd102b401b1acec67a9f18aa98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 23 Feb 2023 22:54:07 +0100 Subject: [PATCH 02/21] Leaving this here in case someone ever needs int :-) --- arch/esp32/esp32c3.ini | 46 +++++++++++++++++++++++++++++++ src/mesh/http/ContentHandler.cpp | 2 +- src/modules/Modules.cpp | 2 +- src/modules/SerialModule.cpp | 2 +- src/modules/SerialModule.h | 2 +- src/platform/esp32/main-esp32.cpp | 7 +++++ src/sleep.cpp | 2 ++ 7 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 arch/esp32/esp32c3.ini diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini new file mode 100644 index 00000000..08ab377d --- /dev/null +++ b/arch/esp32/esp32c3.ini @@ -0,0 +1,46 @@ +[esp32c3_base] +extends = arduino_base +platform = platformio/espressif32@^6.0.0 +build_src_filter = + ${arduino_base.build_src_filter} - - - - +upload_speed = 961200 +monitor_speed = 115200 +debug_init_break = tbreak setup +monitor_filters = esp32_exception_decoder +board_build.filesystem = littlefs + +# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging. +# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h +# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h +build_flags = + ${arduino_base.build_flags} + -Wall + -Wextra + -Isrc/platform/esp32 + -std=c++11 + -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL + -DAXP_DEBUG_PORT=Serial + -DCONFIG_BT_NIMBLE_ENABLED + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 + -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING + ;-DDEBUG_HEAP + +lib_deps = + ${arduino_base.lib_deps} + ${networking_base.lib_deps} + ${environmental_base.lib_deps} + https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 + h2zero/NimBLE-Arduino@^1.4.0 + https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 + caveman99/ESP32 Codec2@^1.0.1 + +lib_ignore = + segger_rtt + ESP32 BLE Arduino + +; customize the partition table +; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables +board_build.partitions = partition-table.csv \ No newline at end of file diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 8683f9cb..0a93298b 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -833,7 +833,7 @@ void handleScanNetworks(HTTPRequest *req, HTTPResponse *res) if (WiFi.encryptionType(i) != WIFI_AUTH_OPEN) { JSONObject thisNetwork; thisNetwork["ssid"] = new JSONValue(ssidArray); - thisNetwork["rssi"] = new JSONValue(WiFi.RSSI(i)); + thisNetwork["rssi"] = new JSONValue(int(WiFi.RSSI(i))); networkObjs.push_back(new JSONValue(thisNetwork)); } // Yield some cpu cycles to IP stack. diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 3247d02c..30034b78 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -72,7 +72,7 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) &&!defined(CONFIG_IDF_TARGET_ESP32C3) new SerialModule(); #endif #ifdef ARCH_ESP32 diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 5637f7eb..b13e8001 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -44,7 +44,7 @@ */ -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) #define RX_BUFFER 128 #define TIMEOUT 250 diff --git a/src/modules/SerialModule.h b/src/modules/SerialModule.h index 8c53d206..5aa0f97b 100644 --- a/src/modules/SerialModule.h +++ b/src/modules/SerialModule.h @@ -8,7 +8,7 @@ #include #include -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) class SerialModule : public StreamAPI, private concurrency::OSThread { diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index f6bd4f50..4f627d27 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -178,6 +178,7 @@ void cpuDeepSleep(uint64_t msecToWake) Note: we don't isolate pins that are used for the LORA, LED, i2c, spi or the wake button */ +#if SOC_RTCIO_HOLD_SUPPORTED static const uint8_t rtcGpios[] = {/* 0, */ 2, /* 4, */ #ifndef USE_JTAG @@ -189,8 +190,10 @@ void cpuDeepSleep(uint64_t msecToWake) 36, 37 /* 38, 39 */}; + for (int i = 0; i < sizeof(rtcGpios); i++) rtc_gpio_isolate((gpio_num_t)rtcGpios[i]); +#endif // FIXME, disable internal rtc pullups/pulldowns on the non isolated pins. for inputs that we aren't using // to detect wake and in normal operation the external part drives them hard. @@ -200,7 +203,9 @@ void cpuDeepSleep(uint64_t msecToWake) #ifdef BUTTON_PIN // Only GPIOs which are have RTC functionality can be used in this bit map: 0,2,4,12-15,25-27,32-39. +#if SOC_RTCIO_HOLD_SUPPORTED uint64_t gpioMask = (1ULL << BUTTON_PIN); +#endif #ifdef BUTTON_NEED_PULLUP gpio_pullup_en((gpio_num_t)BUTTON_PIN); @@ -210,7 +215,9 @@ void cpuDeepSleep(uint64_t msecToWake) // FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead of // just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN); +#if SOC_PM_SUPPORT_EXT_WAKEUP esp_sleep_enable_ext1_wakeup(gpioMask, ESP_EXT1_WAKEUP_ALL_LOW); +#endif #endif esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs diff --git a/src/sleep.cpp b/src/sleep.cpp index 77c8d711..72d4974a 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -337,6 +337,8 @@ void enableModemSleep() esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32S2 esp32_config.max_freq_mhz = CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ; +#elif CONFIG_IDF_TARGET_ESP32C3 + esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ; #else esp32_config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; #endif From baeb2807a4689597f961fb8f65e4a5f9f8d6f60d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 24 Feb 2023 09:32:31 +0100 Subject: [PATCH 03/21] disable the frequency switcher for the C3 CPU... --- src/sleep.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sleep.cpp b/src/sleep.cpp index 72d4974a..9bdd52cb 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -61,13 +61,15 @@ void setCPUFast(bool on) * all WiFi use cases. * (Added: Dec 23, 2021 by Jm Casler) */ +#ifndef CONFIG_IDF_TARGET_ESP32C3 LOG_DEBUG("Setting CPU to 240mhz because WiFi is in use.\n"); setCpuFrequencyMhz(240); +#endif return; } // The Heltec LORA32 V1 runs at 26 MHz base frequency and doesn't react well to switching to 80 MHz... -#ifndef ARDUINO_HELTEC_WIFI_LORA_32 +#if !defined(ARDUINO_HELTEC_WIFI_LORA_32) && !defined(CONFIG_IDF_TARGET_ESP32C3) setCpuFrequencyMhz(on ? 240 : 80); #endif From a3f1e53017b59365bbf229e406d6d157ddce6020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 24 Feb 2023 09:53:25 +0100 Subject: [PATCH 04/21] fmt --- src/modules/Modules.cpp | 3 ++- src/modules/SerialModule.cpp | 3 ++- src/modules/SerialModule.h | 3 ++- src/platform/esp32/main-esp32.cpp | 3 +-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 30034b78..5d49a213 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -72,7 +72,8 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) &&!defined(CONFIG_IDF_TARGET_ESP32C3) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ + !defined(CONFIG_IDF_TARGET_ESP32C3) new SerialModule(); #endif #ifdef ARCH_ESP32 diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index b13e8001..35b83e6c 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -44,7 +44,8 @@ */ -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ + !defined(CONFIG_IDF_TARGET_ESP32C3) #define RX_BUFFER 128 #define TIMEOUT 250 diff --git a/src/modules/SerialModule.h b/src/modules/SerialModule.h index 5aa0f97b..cc696316 100644 --- a/src/modules/SerialModule.h +++ b/src/modules/SerialModule.h @@ -8,7 +8,8 @@ #include #include -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ + !defined(CONFIG_IDF_TARGET_ESP32C3) class SerialModule : public StreamAPI, private concurrency::OSThread { diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 4f627d27..95e899a7 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -178,7 +178,7 @@ void cpuDeepSleep(uint64_t msecToWake) Note: we don't isolate pins that are used for the LORA, LED, i2c, spi or the wake button */ -#if SOC_RTCIO_HOLD_SUPPORTED +#if SOC_RTCIO_HOLD_SUPPORTED static const uint8_t rtcGpios[] = {/* 0, */ 2, /* 4, */ #ifndef USE_JTAG @@ -190,7 +190,6 @@ void cpuDeepSleep(uint64_t msecToWake) 36, 37 /* 38, 39 */}; - for (int i = 0; i < sizeof(rtcGpios); i++) rtc_gpio_isolate((gpio_num_t)rtcGpios[i]); #endif From 0940c6462b18a7bc5986bf310d4858f9c52d966c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 23 Feb 2023 22:54:07 +0100 Subject: [PATCH 05/21] Leaving this here in case someone ever needs int :-) --- arch/esp32/esp32c3.ini | 46 +++++++++++++++++++++++++++++++ src/mesh/http/ContentHandler.cpp | 2 +- src/modules/Modules.cpp | 2 +- src/modules/SerialModule.cpp | 2 +- src/modules/SerialModule.h | 2 +- src/platform/esp32/main-esp32.cpp | 7 +++++ src/sleep.cpp | 2 ++ 7 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 arch/esp32/esp32c3.ini diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini new file mode 100644 index 00000000..08ab377d --- /dev/null +++ b/arch/esp32/esp32c3.ini @@ -0,0 +1,46 @@ +[esp32c3_base] +extends = arduino_base +platform = platformio/espressif32@^6.0.0 +build_src_filter = + ${arduino_base.build_src_filter} - - - - +upload_speed = 961200 +monitor_speed = 115200 +debug_init_break = tbreak setup +monitor_filters = esp32_exception_decoder +board_build.filesystem = littlefs + +# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging. +# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h +# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h +build_flags = + ${arduino_base.build_flags} + -Wall + -Wextra + -Isrc/platform/esp32 + -std=c++11 + -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG + -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL + -DAXP_DEBUG_PORT=Serial + -DCONFIG_BT_NIMBLE_ENABLED + -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 + -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 + -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING + ;-DDEBUG_HEAP + +lib_deps = + ${arduino_base.lib_deps} + ${networking_base.lib_deps} + ${environmental_base.lib_deps} + https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2 + h2zero/NimBLE-Arduino@^1.4.0 + https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6 + caveman99/ESP32 Codec2@^1.0.1 + +lib_ignore = + segger_rtt + ESP32 BLE Arduino + +; customize the partition table +; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables +board_build.partitions = partition-table.csv \ No newline at end of file diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 8683f9cb..0a93298b 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -833,7 +833,7 @@ void handleScanNetworks(HTTPRequest *req, HTTPResponse *res) if (WiFi.encryptionType(i) != WIFI_AUTH_OPEN) { JSONObject thisNetwork; thisNetwork["ssid"] = new JSONValue(ssidArray); - thisNetwork["rssi"] = new JSONValue(WiFi.RSSI(i)); + thisNetwork["rssi"] = new JSONValue(int(WiFi.RSSI(i))); networkObjs.push_back(new JSONValue(thisNetwork)); } // Yield some cpu cycles to IP stack. diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 3247d02c..30034b78 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -72,7 +72,7 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) &&!defined(CONFIG_IDF_TARGET_ESP32C3) new SerialModule(); #endif #ifdef ARCH_ESP32 diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 5637f7eb..b13e8001 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -44,7 +44,7 @@ */ -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) #define RX_BUFFER 128 #define TIMEOUT 250 diff --git a/src/modules/SerialModule.h b/src/modules/SerialModule.h index 8c53d206..5aa0f97b 100644 --- a/src/modules/SerialModule.h +++ b/src/modules/SerialModule.h @@ -8,7 +8,7 @@ #include #include -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) class SerialModule : public StreamAPI, private concurrency::OSThread { diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index f6bd4f50..4f627d27 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -178,6 +178,7 @@ void cpuDeepSleep(uint64_t msecToWake) Note: we don't isolate pins that are used for the LORA, LED, i2c, spi or the wake button */ +#if SOC_RTCIO_HOLD_SUPPORTED static const uint8_t rtcGpios[] = {/* 0, */ 2, /* 4, */ #ifndef USE_JTAG @@ -189,8 +190,10 @@ void cpuDeepSleep(uint64_t msecToWake) 36, 37 /* 38, 39 */}; + for (int i = 0; i < sizeof(rtcGpios); i++) rtc_gpio_isolate((gpio_num_t)rtcGpios[i]); +#endif // FIXME, disable internal rtc pullups/pulldowns on the non isolated pins. for inputs that we aren't using // to detect wake and in normal operation the external part drives them hard. @@ -200,7 +203,9 @@ void cpuDeepSleep(uint64_t msecToWake) #ifdef BUTTON_PIN // Only GPIOs which are have RTC functionality can be used in this bit map: 0,2,4,12-15,25-27,32-39. +#if SOC_RTCIO_HOLD_SUPPORTED uint64_t gpioMask = (1ULL << BUTTON_PIN); +#endif #ifdef BUTTON_NEED_PULLUP gpio_pullup_en((gpio_num_t)BUTTON_PIN); @@ -210,7 +215,9 @@ void cpuDeepSleep(uint64_t msecToWake) // FIXME change polarity in hw so we can wake on ANY_HIGH instead - that would allow us to use all three buttons (instead of // just the first) gpio_pullup_en((gpio_num_t)BUTTON_PIN); +#if SOC_PM_SUPPORT_EXT_WAKEUP esp_sleep_enable_ext1_wakeup(gpioMask, ESP_EXT1_WAKEUP_ALL_LOW); +#endif #endif esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs diff --git a/src/sleep.cpp b/src/sleep.cpp index 77c8d711..72d4974a 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -337,6 +337,8 @@ void enableModemSleep() esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ; #elif CONFIG_IDF_TARGET_ESP32S2 esp32_config.max_freq_mhz = CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ; +#elif CONFIG_IDF_TARGET_ESP32C3 + esp32_config.max_freq_mhz = CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ; #else esp32_config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; #endif From ecd67f0a859fc6932b667637c3c6d84b6aca5aad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 24 Feb 2023 09:32:31 +0100 Subject: [PATCH 06/21] disable the frequency switcher for the C3 CPU... --- src/sleep.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sleep.cpp b/src/sleep.cpp index 72d4974a..9bdd52cb 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -61,13 +61,15 @@ void setCPUFast(bool on) * all WiFi use cases. * (Added: Dec 23, 2021 by Jm Casler) */ +#ifndef CONFIG_IDF_TARGET_ESP32C3 LOG_DEBUG("Setting CPU to 240mhz because WiFi is in use.\n"); setCpuFrequencyMhz(240); +#endif return; } // The Heltec LORA32 V1 runs at 26 MHz base frequency and doesn't react well to switching to 80 MHz... -#ifndef ARDUINO_HELTEC_WIFI_LORA_32 +#if !defined(ARDUINO_HELTEC_WIFI_LORA_32) && !defined(CONFIG_IDF_TARGET_ESP32C3) setCpuFrequencyMhz(on ? 240 : 80); #endif From 4355f51a90642015347ab74a0ee8f6fb950c15bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 24 Feb 2023 09:53:25 +0100 Subject: [PATCH 07/21] fmt --- src/modules/Modules.cpp | 3 ++- src/modules/SerialModule.cpp | 3 ++- src/modules/SerialModule.h | 3 ++- src/platform/esp32/main-esp32.cpp | 3 +-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules/Modules.cpp b/src/modules/Modules.cpp index 30034b78..5d49a213 100644 --- a/src/modules/Modules.cpp +++ b/src/modules/Modules.cpp @@ -72,7 +72,8 @@ void setupModules() new AirQualityTelemetryModule(); } #endif -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) &&!defined(CONFIG_IDF_TARGET_ESP32C3) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ + !defined(CONFIG_IDF_TARGET_ESP32C3) new SerialModule(); #endif #ifdef ARCH_ESP32 diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index b13e8001..35b83e6c 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -44,7 +44,8 @@ */ -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ + !defined(CONFIG_IDF_TARGET_ESP32C3) #define RX_BUFFER 128 #define TIMEOUT 250 diff --git a/src/modules/SerialModule.h b/src/modules/SerialModule.h index 5aa0f97b..cc696316 100644 --- a/src/modules/SerialModule.h +++ b/src/modules/SerialModule.h @@ -8,7 +8,8 @@ #include #include -#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2) && \ + !defined(CONFIG_IDF_TARGET_ESP32C3) class SerialModule : public StreamAPI, private concurrency::OSThread { diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 4f627d27..95e899a7 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -178,7 +178,7 @@ void cpuDeepSleep(uint64_t msecToWake) Note: we don't isolate pins that are used for the LORA, LED, i2c, spi or the wake button */ -#if SOC_RTCIO_HOLD_SUPPORTED +#if SOC_RTCIO_HOLD_SUPPORTED static const uint8_t rtcGpios[] = {/* 0, */ 2, /* 4, */ #ifndef USE_JTAG @@ -190,7 +190,6 @@ void cpuDeepSleep(uint64_t msecToWake) 36, 37 /* 38, 39 */}; - for (int i = 0; i < sizeof(rtcGpios); i++) rtc_gpio_isolate((gpio_num_t)rtcGpios[i]); #endif From b249970a1227ed2f3fd2840e6cfc8e2a9d3cd783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 5 Mar 2023 14:55:12 +0100 Subject: [PATCH 08/21] add rudimentary exception decoder for RISC-V CPU --- arch/esp32/esp32c3.ini | 3 +- monitor/filter_c3_exception_decoder.py | 155 +++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 monitor/filter_c3_exception_decoder.py diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini index 08ab377d..130664f7 100644 --- a/arch/esp32/esp32c3.ini +++ b/arch/esp32/esp32c3.ini @@ -6,7 +6,7 @@ build_src_filter = upload_speed = 961200 monitor_speed = 115200 debug_init_break = tbreak setup -monitor_filters = esp32_exception_decoder +monitor_filters = esp32_c3_exception_decoder board_build.filesystem = littlefs # Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging. @@ -21,7 +21,6 @@ build_flags = -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL - -DAXP_DEBUG_PORT=Serial -DCONFIG_BT_NIMBLE_ENABLED -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 -DCONFIG_BT_NIMBLE_MAX_CCCDS=20 diff --git a/monitor/filter_c3_exception_decoder.py b/monitor/filter_c3_exception_decoder.py new file mode 100644 index 00000000..e59b0be2 --- /dev/null +++ b/monitor/filter_c3_exception_decoder.py @@ -0,0 +1,155 @@ +# Copyright (c) 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re +import subprocess +import sys + +from platformio.project.exception import PlatformioException +from platformio.public import ( + DeviceMonitorFilterBase, + load_build_metadata, +) + +# By design, __init__ is called inside miniterm and we can't pass context to it. +# pylint: disable=attribute-defined-outside-init + +IS_WINDOWS = sys.platform.startswith("win") + + +class Esp32C3ExceptionDecoder(DeviceMonitorFilterBase): + NAME = "esp32_c3_exception_decoder" + + PCADDR_PATTERN = re.compile(r'0x4[0-9a-f]{7}', re.IGNORECASE) + + def __call__(self): + self.buffer = "" + self.pcaddr_re = self.PCADDR_PATTERN + + self.firmware_path = None + self.addr2line_path = None + self.enabled = self.setup_paths() + + if self.config.get("env:" + self.environment, "build_type") != "debug": + print( + """ +Please build project in debug configuration to get more details about an exception. +See https://docs.platformio.org/page/projectconf/build_configurations.html + +""" + ) + + return self + + def setup_paths(self): + self.project_dir = os.path.abspath(self.project_dir) + try: + data = load_build_metadata(self.project_dir, self.environment) + self.firmware_path = data["prog_path"] + if not os.path.isfile(self.firmware_path): + sys.stderr.write( + "%s: disabling, firmware at %s does not exist, rebuild the project?\n" + % (self.__class__.__name__, self.firmware_path) + ) + return False + + if self.addr2line_path is None: + cc_path = data.get("cc_path", "") + if "-gcc" in cc_path: + self.addr2line_path = cc_path.replace("-gcc", "-addr2line") + else: + sys.stderr.write( + "%s: disabling, failed to find addr2line.\n" + % self.__class__.__name__ + ) + return False + + if not os.path.isfile(self.addr2line_path): + sys.stderr.write( + "%s: disabling, addr2line at %s does not exist\n" + % (self.__class__.__name__, self.addr2line_path) + ) + return False + + return True + except PlatformioException as e: + sys.stderr.write( + "%s: disabling, exception while looking for addr2line: %s\n" + % (self.__class__.__name__, e) + ) + return False + + def rx(self, text): + if not self.enabled: + return text + + last = 0 + while True: + idx = text.find("\n", last) + if idx == -1: + if len(self.buffer) < 4096: + self.buffer += text[last:] + break + + line = text[last:idx] + if self.buffer: + line = self.buffer + line + self.buffer = "" + last = idx + 1 + + # Output each trace on a separate line below ours + # Logic identical to https://github.com/espressif/esp-idf/blob/master/tools/idf_monitor_base/logger.py#L131 + for m in re.finditer(self.pcaddr_re, line): + if m is None: + continue + + trace = self.get_backtrace(m) + if len(trace) != "": + text = text[: last] + trace + text[last :] + last += len(trace) + + return text + + def get_backtrace(self, match): + trace = "\n" + enc = "mbcs" if IS_WINDOWS else "utf-8" + args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path] + try: + addr = match.group() + output = ( + subprocess.check_output(args + [addr]) + .decode(enc) + .strip() + ) + output = output.replace( + "\n", "\n " + ) # newlines happen with inlined methods + output = self.strip_project_dir(output) + # Output the trace in yellow color so that it is easier to spot + trace += "\033[33m=> %s: %s\033[0m\n" % (addr, output) + except subprocess.CalledProcessError as e: + sys.stderr.write( + "%s: failed to call %s: %s\n" + % (self.__class__.__name__, self.addr2line_path, e) + ) + return trace + + def strip_project_dir(self, trace): + while True: + idx = trace.find(self.project_dir) + if idx == -1: + break + trace = trace[:idx] + trace[idx + len(self.project_dir) + 1 :] + return trace From 75db8c2d2e38a58bee781efb30d626d70930ddca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Tue, 21 Mar 2023 16:24:24 +0100 Subject: [PATCH 09/21] the target starts up and works for a few seconds before crashing. Good enough for others to continue the work :-) --- arch/esp32/esp32c3.ini | 2 +- variants/ai-c3/platformio.ini | 8 ++++++++ variants/ai-c3/variant.h | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 variants/ai-c3/platformio.ini create mode 100644 variants/ai-c3/variant.h diff --git a/arch/esp32/esp32c3.ini b/arch/esp32/esp32c3.ini index 130664f7..cca95f48 100644 --- a/arch/esp32/esp32c3.ini +++ b/arch/esp32/esp32c3.ini @@ -1,6 +1,6 @@ [esp32c3_base] extends = arduino_base -platform = platformio/espressif32@^6.0.0 +platform = platformio/espressif32@^6.1.0 build_src_filter = ${arduino_base.build_src_filter} - - - - upload_speed = 961200 diff --git a/variants/ai-c3/platformio.ini b/variants/ai-c3/platformio.ini new file mode 100644 index 00000000..76ecd9f0 --- /dev/null +++ b/variants/ai-c3/platformio.ini @@ -0,0 +1,8 @@ +[env:ai-c3] +extends = esp32c3_base +board = esp32-c3-devkitm-1 +board_level = extra +build_flags = + ${esp32_base.build_flags} + -D PRIVATE_HW + -I variants/ai-c3 diff --git a/variants/ai-c3/variant.h b/variants/ai-c3/variant.h new file mode 100644 index 00000000..05f0abb5 --- /dev/null +++ b/variants/ai-c3/variant.h @@ -0,0 +1,26 @@ +// #define BUTTON_NEED_PULLUP // if set we need to turn on the internal CPU pullup during sleep + +#define I2C_SDA 8 +#define I2C_SCL 9 + +#define BUTTON_PIN 0 + +#define USE_RF95 +#undef RF95_SCK +#define RF95_SCK 4 +#undef RF95_MISO +#define RF95_MISO 5 +#undef RF95_MOSI +#define RF95_MOSI 6 +#undef RF95_NSS +#define RF95_NSS 7 + +#define LORA_DIO0 10 // a No connect on the SX1262 module +#define LORA_DIO1 3 // a No connect on the SX1262 module +#define LORA_RESET 2 + +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +#define HAS_SCREEN 0 +#define HAS_GPS 0 From 5cb1f96240fd3366043a95520c3d55ca521a6183 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 23 Mar 2023 11:32:04 -0500 Subject: [PATCH 10/21] Use accelerometer to wake up screen (#2371) * WIP accelerometer tinkering * Debug logging * RAK LIS3DH sensor * Deconflict temperature sensor and LIS3DH * Finishing up * StateON * Protobufs * Default of none * Formatting --- platformio.ini | 2 + protobufs | 2 +- src/AccelerometerThread.h | 67 +++++++++++++++++++ src/PowerFSM.h | 2 +- src/configuration.h | 10 ++- src/detect/ScanI2C.cpp | 6 ++ src/detect/ScanI2C.h | 4 ++ src/detect/ScanI2CTwoWire.cpp | 14 +++- src/main.cpp | 22 +++++- src/main.h | 1 + src/mesh/generated/meshtastic/config.pb.h | 12 ++-- src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/localonly.pb.h | 2 +- 13 files changed, 131 insertions(+), 15 deletions(-) create mode 100644 src/AccelerometerThread.h diff --git a/platformio.ini b/platformio.ini index b54274a4..aaebceed 100644 --- a/platformio.ini +++ b/platformio.ini @@ -111,3 +111,5 @@ lib_deps = adafruit/Adafruit LPS2X@^2.0.4 adafruit/Adafruit SHT31 Library@^2.2.0 adafruit/Adafruit PM25 AQI Sensor@^1.0.6 + adafruit/Adafruit MPU6050@^2.2.4 + adafruit/Adafruit LIS3DH@^1.2.4 diff --git a/protobufs b/protobufs index e3e22cde..9c9fe890 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit e3e22cdee6024663031fa2d87afd98a88adc2685 +Subproject commit 9c9fe890ce55ad9f3f5f6dae28fda629a5cc25bb diff --git a/src/AccelerometerThread.h b/src/AccelerometerThread.h new file mode 100644 index 00000000..94129630 --- /dev/null +++ b/src/AccelerometerThread.h @@ -0,0 +1,67 @@ +#include "PowerFSM.h" +#include "concurrency/OSThread.h" +#include "configuration.h" +#include "main.h" +#include "power.h" + +#include +#include + +namespace concurrency +{ +class AccelerometerThread : public concurrency::OSThread +{ + public: + AccelerometerThread(ScanI2C::DeviceType type = ScanI2C::DeviceType::NONE) : OSThread("AccelerometerThread") + { + if (accelerometer_found.port == ScanI2C::I2CPort::NO_I2C || !config.display.wake_on_tap_or_motion) { + disable(); + return; + } + accleremoter_type = type; + LOG_DEBUG("AccelerometerThread initializing\n"); + + if (accleremoter_type == ScanI2C::DeviceType::MPU6050 && mpu.begin(accelerometer_found.address)) { + LOG_DEBUG("MPU6050 initializing\n"); + // setup motion detection + mpu.setHighPassFilter(MPU6050_HIGHPASS_0_63_HZ); + mpu.setMotionDetectionThreshold(1); + mpu.setMotionDetectionDuration(20); + mpu.setInterruptPinLatch(true); // Keep it latched. Will turn off when reinitialized. + mpu.setInterruptPinPolarity(true); + } else if (accleremoter_type == ScanI2C::DeviceType::LIS3DH && lis.begin(accelerometer_found.address)) { + LOG_DEBUG("LIS3DH initializing\n"); + lis.setRange(LIS3DH_RANGE_2_G); + + // Adjust threshhold, higher numbers are less sensitive + lis.setClick(1, 80); + } + } + + protected: + int32_t runOnce() override + { + canSleep = true; // Assume we should not keep the board awake + + if (accleremoter_type == ScanI2C::DeviceType::MPU6050 && mpu.getMotionInterruptStatus()) { + wakeScreen(); + } else if (accleremoter_type == ScanI2C::DeviceType::LIS3DH && lis.getClick() > 0) { + wakeScreen(); + } + return 100; + } + + private: + void wakeScreen() + { + LOG_DEBUG("Tap or motion detected. Turning on screen\n"); + if (powerFSM.getState() == &stateDARK) { + powerFSM.trigger(EVENT_INPUT); + } + } + ScanI2C::DeviceType accleremoter_type; + Adafruit_MPU6050 mpu; + Adafruit_LIS3DH lis; +}; + +} // namespace concurrency diff --git a/src/PowerFSM.h b/src/PowerFSM.h index 6692172f..11646812 100644 --- a/src/PowerFSM.h +++ b/src/PowerFSM.h @@ -23,6 +23,6 @@ #define EVENT_INPUT 17 // input broker wants something, we need to wake up and enable screen extern Fsm powerFSM; -extern State statePOWER, stateSERIAL; +extern State stateON, statePOWER, stateSERIAL, stateDARK; void PowerFSM_setup(); diff --git a/src/configuration.h b/src/configuration.h index f35fff4e..58e41877 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -82,7 +82,7 @@ along with this program. If not, see . // #define DISABLE_NTP // Disable the welcome screen and allow -//#define DISABLE_WELCOME_UNSET +// #define DISABLE_WELCOME_UNSET // ----------------------------------------------------------------------------- // OLED & Input @@ -93,7 +93,7 @@ along with this program. If not, see . // The SH1106 controller is almost, but not quite, the same as SSD1306 // Define this if you know you have that controller or your "SSD1306" misbehaves. -//#define USE_SH1106 +// #define USE_SH1106 // Define if screen should be mirrored left to right // #define SCREEN_MIRROR @@ -118,6 +118,12 @@ along with this program. If not, see . #define SHT31_ADDR 0x44 #define PMSA0031_ADDR 0x12 +// ----------------------------------------------------------------------------- +// ACCELEROMETER +// ----------------------------------------------------------------------------- +#define MPU6050_ADDR 0x68 +#define LIS3DH_ADR 0x18 + // ----------------------------------------------------------------------------- // Security // ----------------------------------------------------------------------------- diff --git a/src/detect/ScanI2C.cpp b/src/detect/ScanI2C.cpp index e72478c1..4ce84861 100644 --- a/src/detect/ScanI2C.cpp +++ b/src/detect/ScanI2C.cpp @@ -34,6 +34,12 @@ ScanI2C::FoundDevice ScanI2C::firstKeyboard() const return firstOfOrNONE(2, types); } +ScanI2C::FoundDevice ScanI2C::firstAccelerometer() const +{ + ScanI2C::DeviceType types[] = {MPU6050, LIS3DH}; + return firstOfOrNONE(2, types); +} + ScanI2C::FoundDevice ScanI2C::find(ScanI2C::DeviceType) const { return DEVICE_NONE; diff --git a/src/detect/ScanI2C.h b/src/detect/ScanI2C.h index 0e7e442b..01b300c1 100644 --- a/src/detect/ScanI2C.h +++ b/src/detect/ScanI2C.h @@ -31,6 +31,8 @@ class ScanI2C QMI8658, QMC5883L, PMSA0031, + MPU6050, + LIS3DH, } DeviceType; // typedef uint8_t DeviceAddress; @@ -79,6 +81,8 @@ class ScanI2C FoundDevice firstKeyboard() const; + FoundDevice firstAccelerometer() const; + virtual FoundDevice find(DeviceType) const; virtual bool exists(DeviceType) const; diff --git a/src/detect/ScanI2CTwoWire.cpp b/src/detect/ScanI2CTwoWire.cpp index 53e4dca5..fb568b55 100644 --- a/src/detect/ScanI2CTwoWire.cpp +++ b/src/detect/ScanI2CTwoWire.cpp @@ -248,7 +248,17 @@ void ScanI2CTwoWire::scanPort(I2CPort port) } break; - SCAN_SIMPLE_CASE(MCP9808_ADDR, MCP9808, "MCP9808 sensor found\n") + case MCP9808_ADDR: + registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x07), 2); + if (registerValue == 0x0400) { + type = MCP9808; + LOG_INFO("MCP9808 sensor found\n"); + } else { + type = LIS3DH; + LOG_INFO("LIS3DH accelerometer found\n"); + } + + break; SCAN_SIMPLE_CASE(SHT31_ADDR, SHT31, "SHT31 sensor found\n") SCAN_SIMPLE_CASE(SHTC3_ADDR, SHTC3, "SHTC3 sensor found\n") @@ -261,11 +271,11 @@ void ScanI2CTwoWire::scanPort(I2CPort port) SCAN_SIMPLE_CASE(QMC5883L_ADDR, QMC5883L, "QMC5883L Highrate 3-Axis magnetic sensor found\n") SCAN_SIMPLE_CASE(PMSA0031_ADDR, PMSA0031, "PMSA0031 air quality sensor found\n") + SCAN_SIMPLE_CASE(MPU6050_ADDR, MPU6050, "MPU6050 accelerometer found\n"); default: LOG_INFO("Device found at address 0x%x was not able to be enumerated\n", addr.address); } - } else if (err == 4) { LOG_ERROR("Unknown error at address 0x%x\n", addr); } diff --git a/src/main.cpp b/src/main.cpp index aca54032..9e657e7e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,6 +68,10 @@ NRF52Bluetooth *nrf52Bluetooth; #endif #include "PowerFSMThread.h" +#if !defined(ARCH_PORTDUINO) +#include "AccelerometerThread.h" +#endif + using namespace concurrency; // We always create a screen object, but we only init it if we find the hardware @@ -94,6 +98,8 @@ uint8_t kb_model; // The I2C address of the RTC Module (if found) ScanI2C::DeviceAddress rtc_found = ScanI2C::ADDRESS_NONE; +// The I2C address of the Accelerometer (if found) +ScanI2C::DeviceAddress accelerometer_found = ScanI2C::ADDRESS_NONE; #if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL) ATECCX08A atecc; @@ -163,6 +169,7 @@ static OSThread *powerFSMthread; static OSThread *buttonThread; uint32_t ButtonThread::longPressTime = 0; #endif +static OSThread *accelerometerThread; RadioInterface *rIf = NULL; @@ -350,6 +357,15 @@ void setup() * nodeTelemetrySensorsMap singleton. This wraps that logic in a temporary scope to declare the temporary field * "found". */ +#if !defined(ARCH_PORTDUINO) + auto acc_info = i2cScanner->firstAccelerometer(); + accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found; + + LOG_DEBUG("acc_info = %i\n", acc_info.type); + if (acc_info.type != ScanI2C::DeviceType::NONE) { + accelerometerThread = new AccelerometerThread(acc_info.type); + } +#endif #define STRING(S) #S @@ -459,14 +475,14 @@ void setup() // Now that the mesh service is created, create any modules setupModules(); - // Do this after service.init (because that clears error_code) +// Do this after service.init (because that clears error_code) #ifdef HAS_PMU if (!pmu_found) RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_NO_AXP192); // Record a hardware fault for missing hardware #endif - // Don't call screen setup until after nodedb is setup (because we need - // the current region name) +// Don't call screen setup until after nodedb is setup (because we need +// the current region name) #if defined(ST7735_CS) || defined(USE_EINK) || defined(ILI9341_DRIVER) screen->setup(); #else diff --git a/src/main.h b/src/main.h index 29fe34f7..db5fc26d 100644 --- a/src/main.h +++ b/src/main.h @@ -24,6 +24,7 @@ extern ScanI2C::DeviceAddress screen_found; extern ScanI2C::DeviceAddress cardkb_found; extern uint8_t kb_model; extern ScanI2C::DeviceAddress rtc_found; +extern ScanI2C::DeviceAddress accelerometer_found; extern bool eink_found; extern bool pmu_found; diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index 0b2aff4d..fd949cde 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -360,6 +360,8 @@ typedef struct _meshtastic_Config_DisplayConfig { meshtastic_Config_DisplayConfig_DisplayMode displaymode; /* Print first line in pseudo-bold? FALSE is original style, TRUE is bold */ bool heading_bold; + /* Should we wake the screen up on accelerometer detected motion or tap */ + bool wake_on_tap_or_motion; } meshtastic_Config_DisplayConfig; /* Lora Config */ @@ -526,7 +528,7 @@ extern "C" { #define meshtastic_Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_NetworkConfig_init_default {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_default, ""} #define meshtastic_Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} -#define meshtastic_Config_DisplayConfig_init_default {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0} +#define meshtastic_Config_DisplayConfig_init_default {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0, 0} #define meshtastic_Config_LoRaConfig_init_default {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}} #define meshtastic_Config_BluetoothConfig_init_default {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0} #define meshtastic_Config_init_zero {0, {meshtastic_Config_DeviceConfig_init_zero}} @@ -535,7 +537,7 @@ extern "C" { #define meshtastic_Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_NetworkConfig_init_zero {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_zero, ""} #define meshtastic_Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} -#define meshtastic_Config_DisplayConfig_init_zero {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0} +#define meshtastic_Config_DisplayConfig_init_zero {0, _meshtastic_Config_DisplayConfig_GpsCoordinateFormat_MIN, 0, 0, 0, _meshtastic_Config_DisplayConfig_DisplayUnits_MIN, _meshtastic_Config_DisplayConfig_OledType_MIN, _meshtastic_Config_DisplayConfig_DisplayMode_MIN, 0, 0} #define meshtastic_Config_LoRaConfig_init_zero {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}} #define meshtastic_Config_BluetoothConfig_init_zero {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0} @@ -585,6 +587,7 @@ extern "C" { #define meshtastic_Config_DisplayConfig_oled_tag 7 #define meshtastic_Config_DisplayConfig_displaymode_tag 8 #define meshtastic_Config_DisplayConfig_heading_bold_tag 9 +#define meshtastic_Config_DisplayConfig_wake_on_tap_or_motion_tag 10 #define meshtastic_Config_LoRaConfig_use_preset_tag 1 #define meshtastic_Config_LoRaConfig_modem_preset_tag 2 #define meshtastic_Config_LoRaConfig_bandwidth_tag 3 @@ -696,7 +699,8 @@ X(a, STATIC, SINGULAR, BOOL, flip_screen, 5) \ X(a, STATIC, SINGULAR, UENUM, units, 6) \ X(a, STATIC, SINGULAR, UENUM, oled, 7) \ X(a, STATIC, SINGULAR, UENUM, displaymode, 8) \ -X(a, STATIC, SINGULAR, BOOL, heading_bold, 9) +X(a, STATIC, SINGULAR, BOOL, heading_bold, 9) \ +X(a, STATIC, SINGULAR, BOOL, wake_on_tap_or_motion, 10) #define meshtastic_Config_DisplayConfig_CALLBACK NULL #define meshtastic_Config_DisplayConfig_DEFAULT NULL @@ -750,7 +754,7 @@ extern const pb_msgdesc_t meshtastic_Config_BluetoothConfig_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_Config_BluetoothConfig_size 10 #define meshtastic_Config_DeviceConfig_size 26 -#define meshtastic_Config_DisplayConfig_size 26 +#define meshtastic_Config_DisplayConfig_size 28 #define meshtastic_Config_LoRaConfig_size 77 #define meshtastic_Config_NetworkConfig_IpV4Config_size 20 #define meshtastic_Config_NetworkConfig_size 195 diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index 043c1b8a..e0d70840 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -188,7 +188,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_ChannelFile_size 638 #define meshtastic_DeviceState_size 21800 -#define meshtastic_OEMStore_size 3006 +#define meshtastic_OEMStore_size 3008 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h index 6aa0fdbe..41d6d70a 100644 --- a/src/mesh/generated/meshtastic/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -156,7 +156,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg; #define meshtastic_LocalModuleConfig_fields &meshtastic_LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define meshtastic_LocalConfig_size 440 +#define meshtastic_LocalConfig_size 442 #define meshtastic_LocalModuleConfig_size 420 #ifdef __cplusplus From 958d2cf630559c6864da70560957efbf0813af2f Mon Sep 17 00:00:00 2001 From: code8buster Date: Thu, 23 Mar 2023 17:05:12 +0000 Subject: [PATCH 11/21] Remove call to randomSeed() (#2374) This function causes the new arduino-esp32 core to revert to the pseudorandom behavior specified in Arduino. Calls to random() automatically use esp_random() if randomSeed or useRealRandomGenerator(false) aren't called. Tentative fix for #2357 --- src/platform/esp32/main-esp32.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 95e899a7..645132f3 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -85,7 +85,6 @@ void esp32Setup() { uint32_t seed = esp_random(); LOG_DEBUG("Setting random seed %u\n", seed); - randomSeed(seed); // ESP docs say this is fairly random LOG_DEBUG("Total heap: %d\n", ESP.getHeapSize()); LOG_DEBUG("Free heap: %d\n", ESP.getFreeHeap()); @@ -221,4 +220,4 @@ void cpuDeepSleep(uint64_t msecToWake) esp_sleep_enable_timer_wakeup(msecToWake * 1000ULL); // call expects usecs esp_deep_sleep_start(); // TBD mA sleep current (battery) -} \ No newline at end of file +} From 9d6e1ce8e5aa39ab5eb58619eca17cef00e946a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 23 Mar 2023 13:13:47 -0500 Subject: [PATCH 12/21] [create-pull-request] automated change (#2375) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index 1d98192f..e5f585ef 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 1 -build = 4 +build = 5 From 2c259b8464263e294408fdcebf701280a88264e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 24 Mar 2023 16:57:30 +0100 Subject: [PATCH 13/21] Add Power Restraint for 1280 PA Model Add Debug Print for all module parameters Add RX/TX Switch to 1280 --- src/mesh/RF95Interface.cpp | 2 +- src/mesh/SX128xInterface.cpp | 8 ++++++++ variants/tlora_t3s3_v1/variant.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp index 49872763..f57aaa05 100644 --- a/src/mesh/RF95Interface.cpp +++ b/src/mesh/RF95Interface.cpp @@ -15,7 +15,7 @@ RF95Interface::RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOL SPIClass &spi) : RadioLibInterface(cs, irq, rst, busy, spi) { - // FIXME - we assume devices never get destroyed + LOG_WARN("RF95Interface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy); } /** Some boards require GPIO control of tx vs rx paths */ diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp index aff4c125..85e41f29 100644 --- a/src/mesh/SX128xInterface.cpp +++ b/src/mesh/SX128xInterface.cpp @@ -13,6 +13,7 @@ SX128xInterface::SX128xInterface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, SPIClass &spi) : RadioLibInterface(cs, irq, rst, busy, spi, &lora), lora(&module) { + LOG_WARN("SX128xInterface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy); } /// Initialise the Driver transport hardware and software. @@ -73,6 +74,13 @@ template bool SX128xInterface::init() LOG_INFO("Bandwidth set to %f\n", bw); LOG_INFO("Power output set to %d\n", power); +#if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC) && defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC) + // lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX + if (res == RADIOLIB_ERR_NONE) { + lora.setRfSwitchPins(SX128X_RXEN, SX128X_TXEN); + } +#endif + if (res == RADIOLIB_ERR_NONE) res = lora.setCRC(2); diff --git a/variants/tlora_t3s3_v1/variant.h b/variants/tlora_t3s3_v1/variant.h index 0f88af81..768a7c2d 100644 --- a/variants/tlora_t3s3_v1/variant.h +++ b/variants/tlora_t3s3_v1/variant.h @@ -59,4 +59,5 @@ #define SX128X_RESET LORA_RESET #define SX128X_RXEN 21 #define SX128X_TXEN 10 +#define SX128X_MAX_POWER 3 #endif \ No newline at end of file From 5ac24bb33b612cd7005395995855260209a6814d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 25 Mar 2023 14:23:30 +0100 Subject: [PATCH 14/21] Update SX128xInterface.cpp --- src/mesh/SX128xInterface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp index 85e41f29..e271cb71 100644 --- a/src/mesh/SX128xInterface.cpp +++ b/src/mesh/SX128xInterface.cpp @@ -75,7 +75,6 @@ template bool SX128xInterface::init() LOG_INFO("Power output set to %d\n", power); #if defined(SX128X_TXEN) && (SX128X_TXEN != RADIOLIB_NC) && defined(SX128X_RXEN) && (SX128X_RXEN != RADIOLIB_NC) - // lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX if (res == RADIOLIB_ERR_NONE) { lora.setRfSwitchPins(SX128X_RXEN, SX128X_TXEN); } From 1f130d671b225e055f37bfe9474f16fc89eebdfd Mon Sep 17 00:00:00 2001 From: caveman99 Date: Sat, 25 Mar 2023 13:38:35 +0000 Subject: [PATCH 15/21] [create-pull-request] automated change --- protobufs | 2 +- src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/mesh.pb.h | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/protobufs b/protobufs index 9c9fe890..a73083db 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 9c9fe890ce55ad9f3f5f6dae28fda629a5cc25bb +Subproject commit a73083db549d7f0a4e47b0ebd5e6d363f130fcf9 diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index e0d70840..c43777bd 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -187,7 +187,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_ChannelFile_size 638 -#define meshtastic_DeviceState_size 21800 +#define meshtastic_DeviceState_size 22040 #define meshtastic_OEMStore_size 3008 #ifdef __cplusplus diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 1f980474..e95cffdf 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -563,6 +563,8 @@ typedef struct _meshtastic_NodeInfo { /* The latest device metrics for the node. */ bool has_device_metrics; meshtastic_DeviceMetrics device_metrics; + /* local channel index we heard that node on. Only populated if its not the default channel. */ + uint8_t channel; } meshtastic_NodeInfo; /* Unique local debugging info for this node @@ -823,7 +825,7 @@ extern "C" { #define meshtastic_Data_init_default {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define meshtastic_Waypoint_init_default {0, 0, 0, 0, 0, "", "", 0} #define meshtastic_MeshPacket_init_default {0, 0, 0, 0, {meshtastic_Data_init_default}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN} -#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default} +#define meshtastic_NodeInfo_init_default {0, false, meshtastic_User_init_default, false, meshtastic_Position_init_default, 0, 0, false, meshtastic_DeviceMetrics_init_default, 0} #define meshtastic_MyNodeInfo_init_default {0, 0, 0, "", _meshtastic_CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0} #define meshtastic_LogRecord_init_default {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_QueueStatus_init_default {0, 0, 0, 0} @@ -838,7 +840,7 @@ extern "C" { #define meshtastic_Data_init_zero {_meshtastic_PortNum_MIN, {0, {0}}, 0, 0, 0, 0, 0, 0} #define meshtastic_Waypoint_init_zero {0, 0, 0, 0, 0, "", "", 0} #define meshtastic_MeshPacket_init_zero {0, 0, 0, 0, {meshtastic_Data_init_zero}, 0, 0, 0, 0, 0, _meshtastic_MeshPacket_Priority_MIN, 0, _meshtastic_MeshPacket_Delayed_MIN} -#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero} +#define meshtastic_NodeInfo_init_zero {0, false, meshtastic_User_init_zero, false, meshtastic_Position_init_zero, 0, 0, false, meshtastic_DeviceMetrics_init_zero, 0} #define meshtastic_MyNodeInfo_init_zero {0, 0, 0, "", _meshtastic_CriticalErrorCode_MIN, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, {0, 0, 0, 0, 0, 0, 0, 0}, 0, 0, 0} #define meshtastic_LogRecord_init_zero {"", 0, "", _meshtastic_LogRecord_Level_MIN} #define meshtastic_QueueStatus_init_zero {0, 0, 0, 0} @@ -915,6 +917,7 @@ extern "C" { #define meshtastic_NodeInfo_snr_tag 4 #define meshtastic_NodeInfo_last_heard_tag 5 #define meshtastic_NodeInfo_device_metrics_tag 6 +#define meshtastic_NodeInfo_channel_tag 7 #define meshtastic_MyNodeInfo_my_node_num_tag 1 #define meshtastic_MyNodeInfo_has_gps_tag 2 #define meshtastic_MyNodeInfo_max_channels_tag 3 @@ -1067,7 +1070,8 @@ X(a, STATIC, OPTIONAL, MESSAGE, user, 2) \ X(a, STATIC, OPTIONAL, MESSAGE, position, 3) \ X(a, STATIC, SINGULAR, FLOAT, snr, 4) \ X(a, STATIC, SINGULAR, FIXED32, last_heard, 5) \ -X(a, STATIC, OPTIONAL, MESSAGE, device_metrics, 6) +X(a, STATIC, OPTIONAL, MESSAGE, device_metrics, 6) \ +X(a, STATIC, SINGULAR, UINT32, channel, 7) #define meshtastic_NodeInfo_CALLBACK NULL #define meshtastic_NodeInfo_DEFAULT NULL #define meshtastic_NodeInfo_user_MSGTYPE meshtastic_User @@ -1207,7 +1211,7 @@ extern const pb_msgdesc_t meshtastic_DeviceMetadata_msg; #define meshtastic_LogRecord_size 81 #define meshtastic_MeshPacket_size 321 #define meshtastic_MyNodeInfo_size 179 -#define meshtastic_NodeInfo_size 258 +#define meshtastic_NodeInfo_size 261 #define meshtastic_Position_size 137 #define meshtastic_QueueStatus_size 23 #define meshtastic_RouteDiscovery_size 40 From 1425657a3c214f9af8c5df0c5889d8b4bbc59f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 25 Mar 2023 20:14:04 +0100 Subject: [PATCH 16/21] fix channel num in json output --- src/mesh/http/ContentHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/http/ContentHandler.cpp b/src/mesh/http/ContentHandler.cpp index 0a93298b..03aab54a 100644 --- a/src/mesh/http/ContentHandler.cpp +++ b/src/mesh/http/ContentHandler.cpp @@ -645,7 +645,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res) // data->radio JSONObject jsonObjRadio; jsonObjRadio["frequency"] = new JSONValue(RadioLibInterface::instance->getFreq()); - jsonObjRadio["lora_channel"] = new JSONValue((int)RadioLibInterface::instance->getChannelNum()); + jsonObjRadio["lora_channel"] = new JSONValue((int)RadioLibInterface::instance->getChannelNum() + 1); // collect data to inner data object JSONObject jsonObjInner; From 8f736c8ecc70560f1f30c97a120aa8ff0d6bd8b3 Mon Sep 17 00:00:00 2001 From: GUVWAF Date: Sun, 26 Mar 2023 13:48:14 +0200 Subject: [PATCH 17/21] Remove sending network ping to displayed node on interval --- src/PowerFSM.cpp | 11 ----------- src/graphics/Screen.cpp | 11 ----------- src/mesh/NodeDB.cpp | 6 ------ src/mesh/NodeDB.h | 6 ------ src/modules/CannedMessageModule.cpp | 2 -- src/modules/esp32/AudioModule.cpp | 2 -- 6 files changed, 38 deletions(-) diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index e96b36c1..73fb7e87 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -194,17 +194,6 @@ static void onEnter() LOG_INFO("Enter state: ON\n"); screen->setOn(true); setBluetoothEnable(true); - - static uint32_t lastPingMs; - - uint32_t now = millis(); - - if ((now - lastPingMs) > - 30 * 1000) { // if more than a minute since our last press, ask node we are looking at to update their state - if (displayedNodeNum) - service.sendNetworkPing(displayedNodeNum, true); // Refresh the currently displayed node - lastPingMs = now; - } } static void onIdle() diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 0512b405..b5a74b38 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -348,8 +348,6 @@ static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, i /// Draw the last text message we received static void drawCriticalFaultFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - displayedNodeNum = 0; // Not currently showing a node pane - display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(FONT_MEDIUM); @@ -370,8 +368,6 @@ static bool shouldDrawMessage(const meshtastic_MeshPacket *packet) /// Draw the last text message we received static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - displayedNodeNum = 0; // Not currently showing a node pane - // the max length of this buffer is much longer than we can possibly print static char tempBuf[237]; @@ -773,7 +769,6 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_ nodeIndex = (nodeIndex + 1) % nodeDB.getNumNodes(); n = nodeDB.getNodeByIndex(nodeIndex); } - displayedNodeNum = n->num; } meshtastic_NodeInfo *node = nodeDB.getNodeByIndex(nodeIndex); @@ -1393,8 +1388,6 @@ void Screen::setFastFramerate() void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - displayedNodeNum = 0; // Not currently showing a node pane - display->setFont(FONT_SMALL); // The coordinates define the left starting point of the text @@ -1502,8 +1495,6 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i #if HAS_WIFI const char *wifiName = config.network.wifi_ssid; - displayedNodeNum = 0; // Not currently showing a node pane - display->setFont(FONT_SMALL); // The coordinates define the left starting point of the text @@ -1634,8 +1625,6 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - displayedNodeNum = 0; // Not currently showing a node pane - display->setFont(FONT_SMALL); // The coordinates define the left starting point of the text diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 6e9ac4c1..5aa0ca45 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -58,12 +58,6 @@ meshtastic_User &owner = devicestate.owner; static uint8_t ourMacAddr[6]; -/** - * The node number the user is currently looking at - * 0 if none - */ -NodeNum displayedNodeNum; - NodeDB::NodeDB() : nodes(devicestate.node_db), numNodes(&devicestate.node_db_count) {} /** diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index a6fbd9cb..6ab4c46e 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -153,12 +153,6 @@ class NodeDB void installDefaultDeviceState(), installDefaultChannels(), installDefaultConfig(), installDefaultModuleConfig(); }; -/** - * The node number the user is currently looking at - * 0 if none - */ -extern NodeNum displayedNodeNum; - extern NodeDB nodeDB; /* diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index e831db02..5fba2b5d 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -446,8 +446,6 @@ int CannedMessageModule::getPrevIndex() void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - displayedNodeNum = 0; // Not currently showing a node pane - char buffer[50]; if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE) { diff --git a/src/modules/esp32/AudioModule.cpp b/src/modules/esp32/AudioModule.cpp index 9db7fbbc..e6a97511 100644 --- a/src/modules/esp32/AudioModule.cpp +++ b/src/modules/esp32/AudioModule.cpp @@ -153,8 +153,6 @@ AudioModule::AudioModule() : SinglePortModule("AudioModule", meshtastic_PortNum_ void AudioModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { - displayedNodeNum = 0; // Not currently showing a node pane - char buffer[50]; display->setTextAlignment(TEXT_ALIGN_LEFT); From 15dbe5da975b9e27cee8e495b7b63f89bfe2661d Mon Sep 17 00:00:00 2001 From: lewishe Date: Mon, 27 Mar 2023 10:33:26 +0800 Subject: [PATCH 18/21] Added t-beam v1.2 support --- src/Power.cpp | 39 ++++++++++++++++++++++++++++++++++++++- src/sleep.cpp | 13 ++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 5c5c7bca..d650bf17 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -527,8 +527,42 @@ bool Power::axpChipInit() } else if (PMU->getChipModel() == XPOWERS_AXP2101) { - // t-beam s3 core + /*The alternative version of T-Beam 1.1 differs from T-Beam V1.1 in that it uses an AXP2101 power chip*/ +#if defined(CONFIG_IDF_TARGET_ESP32) + //Unuse power channel + PMU->disablePowerOutput(XPOWERS_DCDC2); + PMU->disablePowerOutput(XPOWERS_DCDC3); + PMU->disablePowerOutput(XPOWERS_DCDC4); + PMU->disablePowerOutput(XPOWERS_DCDC5); + PMU->disablePowerOutput(XPOWERS_ALDO1); + PMU->disablePowerOutput(XPOWERS_ALDO4); + PMU->disablePowerOutput(XPOWERS_BLDO1); + PMU->disablePowerOutput(XPOWERS_BLDO2); + PMU->disablePowerOutput(XPOWERS_DLDO1); + PMU->disablePowerOutput(XPOWERS_DLDO2); + // GNSS RTC PowerVDD 3300mV + PMU->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300); + PMU->enablePowerOutput(XPOWERS_VBACKUP); + + //ESP32 VDD 3300mV + // ! No need to set, automatically open , Don't close it + // PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300); + // PMU->setProtectedChannel(XPOWERS_DCDC1); + + // LoRa VDD 3300mV + PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO2); + + //GNSS VDD 3300mV + PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); + PMU->enablePowerOutput(XPOWERS_ALDO3); + +#endif /*CONFIG_IDF_TARGET_ESP32*/ + + + // t-beam s3 core +#if defined(CONFIG_IDF_TARGET_ESP32S3) /** * gnss module power channel * The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during initialization @@ -571,6 +605,9 @@ bool Power::axpChipInit() PMU->disablePowerOutput(XPOWERS_DLDO2); // Invalid power channel, it does not exist PMU->disablePowerOutput(XPOWERS_VBACKUP); +#endif + + // disable all axp chip interrupt PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ); diff --git a/src/sleep.cpp b/src/sleep.cpp index 9bdd52cb..d4991691 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -99,10 +99,15 @@ void setGPSPower(bool on) if (pmu_found && PMU) { uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { +#if defined(CONFIG_IDF_TARGET_ESP32) + //t-beam v1.2 GNSS power channel + on ? PMU->enablePowerOutput(XPOWERS_ALDO3) : PMU->disablePowerOutput(XPOWERS_ALDO3); +#else // t-beam-s3-core GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4); +#endif } else if (model == XPOWERS_AXP192) { - // t-beam GNSS power channel + // t-beam v1.1 GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_LDO3) : PMU->disablePowerOutput(XPOWERS_LDO3); } } @@ -237,8 +242,14 @@ void doDeepSleep(uint64_t msecToWake) uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { +#if defined(CONFIG_IDF_TARGET_ESP32) + //t-beam v1.2 radio power channel + PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel +#else PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel +#endif } else if (model == XPOWERS_AXP192) { + //t-beam v1.1 radio power channel PMU->disablePowerOutput(XPOWERS_LDO2); // lora radio power channel } } From 1898fe850e00e92af2ac018f291a6919864453ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 27 Mar 2023 10:50:17 +0200 Subject: [PATCH 19/21] trunk format --- src/Power.cpp | 16 +++++++--------- src/sleep.cpp | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index d650bf17..498d702e 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -527,9 +527,9 @@ bool Power::axpChipInit() } else if (PMU->getChipModel() == XPOWERS_AXP2101) { - /*The alternative version of T-Beam 1.1 differs from T-Beam V1.1 in that it uses an AXP2101 power chip*/ + /*The alternative version of T-Beam 1.1 differs from T-Beam V1.1 in that it uses an AXP2101 power chip*/ #if defined(CONFIG_IDF_TARGET_ESP32) - //Unuse power channel + // Unuse power channel PMU->disablePowerOutput(XPOWERS_DCDC2); PMU->disablePowerOutput(XPOWERS_DCDC3); PMU->disablePowerOutput(XPOWERS_DCDC4); @@ -545,22 +545,21 @@ bool Power::axpChipInit() PMU->setPowerChannelVoltage(XPOWERS_VBACKUP, 3300); PMU->enablePowerOutput(XPOWERS_VBACKUP); - //ESP32 VDD 3300mV - // ! No need to set, automatically open , Don't close it - // PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300); - // PMU->setProtectedChannel(XPOWERS_DCDC1); + // ESP32 VDD 3300mV + // ! No need to set, automatically open , Don't close it + // PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300); + // PMU->setProtectedChannel(XPOWERS_DCDC1); // LoRa VDD 3300mV PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300); PMU->enablePowerOutput(XPOWERS_ALDO2); - //GNSS VDD 3300mV + // GNSS VDD 3300mV PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); PMU->enablePowerOutput(XPOWERS_ALDO3); #endif /*CONFIG_IDF_TARGET_ESP32*/ - // t-beam s3 core #if defined(CONFIG_IDF_TARGET_ESP32S3) /** @@ -607,7 +606,6 @@ bool Power::axpChipInit() #endif - // disable all axp chip interrupt PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ); diff --git a/src/sleep.cpp b/src/sleep.cpp index d4991691..796c8a51 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -100,7 +100,7 @@ void setGPSPower(bool on) uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { #if defined(CONFIG_IDF_TARGET_ESP32) - //t-beam v1.2 GNSS power channel + // t-beam v1.2 GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_ALDO3) : PMU->disablePowerOutput(XPOWERS_ALDO3); #else // t-beam-s3-core GNSS power channel @@ -243,13 +243,13 @@ void doDeepSleep(uint64_t msecToWake) uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { #if defined(CONFIG_IDF_TARGET_ESP32) - //t-beam v1.2 radio power channel + // t-beam v1.2 radio power channel PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel #else PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel #endif } else if (model == XPOWERS_AXP192) { - //t-beam v1.1 radio power channel + // t-beam v1.1 radio power channel PMU->disablePowerOutput(XPOWERS_LDO2); // lora radio power channel } } From eda00b7b9c01862b0bd4321a8a45ced95d9675d2 Mon Sep 17 00:00:00 2001 From: lewishe Date: Mon, 27 Mar 2023 17:02:17 +0800 Subject: [PATCH 20/21] Change to Variation Macro Definition --- src/Power.cpp | 6 ++---- src/sleep.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 498d702e..d6dbd05d 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -528,7 +528,7 @@ bool Power::axpChipInit() } else if (PMU->getChipModel() == XPOWERS_AXP2101) { /*The alternative version of T-Beam 1.1 differs from T-Beam V1.1 in that it uses an AXP2101 power chip*/ -#if defined(CONFIG_IDF_TARGET_ESP32) +#if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) // Unuse power channel PMU->disablePowerOutput(XPOWERS_DCDC2); PMU->disablePowerOutput(XPOWERS_DCDC3); @@ -558,10 +558,8 @@ bool Power::axpChipInit() PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300); PMU->enablePowerOutput(XPOWERS_ALDO3); -#endif /*CONFIG_IDF_TARGET_ESP32*/ - +#elif (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) // t-beam s3 core -#if defined(CONFIG_IDF_TARGET_ESP32S3) /** * gnss module power channel * The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during initialization diff --git a/src/sleep.cpp b/src/sleep.cpp index 796c8a51..8b634603 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -99,10 +99,10 @@ void setGPSPower(bool on) if (pmu_found && PMU) { uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { -#if defined(CONFIG_IDF_TARGET_ESP32) +#if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) // t-beam v1.2 GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_ALDO3) : PMU->disablePowerOutput(XPOWERS_ALDO3); -#else +#elif (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) // t-beam-s3-core GNSS power channel on ? PMU->enablePowerOutput(XPOWERS_ALDO4) : PMU->disablePowerOutput(XPOWERS_ALDO4); #endif @@ -242,10 +242,10 @@ void doDeepSleep(uint64_t msecToWake) uint8_t model = PMU->getChipModel(); if (model == XPOWERS_AXP2101) { -#if defined(CONFIG_IDF_TARGET_ESP32) +#if (HW_VENDOR == meshtastic_HardwareModel_TBEAM) // t-beam v1.2 radio power channel PMU->disablePowerOutput(XPOWERS_ALDO2); // lora radio power channel -#else +#elif (HW_VENDOR == meshtastic_HardwareModel_LILYGO_TBEAM_S3_CORE) PMU->disablePowerOutput(XPOWERS_ALDO3); // lora radio power channel #endif } else if (model == XPOWERS_AXP192) { From 1af7e48136689115b82259e24797d9cb4d6a8196 Mon Sep 17 00:00:00 2001 From: Dan Fay <33201069+faydr@users.noreply.github.com> Date: Mon, 27 Mar 2023 05:52:48 -0600 Subject: [PATCH 21/21] Fixed the semi-silent failure to regenerate protobufs on Linux (#2383) Co-authored-by: Ben Meadors --- bin/regen-protos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/regen-protos.sh b/bin/regen-protos.sh index 5fa3ab04..ad771ab4 100755 --- a/bin/regen-protos.sh +++ b/bin/regen-protos.sh @@ -8,7 +8,7 @@ echo "prebuilt binaries for your computer into nanopb-0.4.7" # the nanopb tool seems to require that the .options file be in the current directory! cd protobufs -../nanopb-0.4.7/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated/ -I=../protobufs meshtastic/*.proto +../nanopb-0.4.7/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated/ -I=../protobufs meshtastic/*.proto --experimental_allow_proto3_optional # cd ../src/mesh/generated/meshtastic # sed -i 's/#include "meshtastic/#include "./g' -- *