From 86960cdb1da072b7ac8bd4561296b3baaf78d414 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 22 Jul 2025 06:21:51 -0500 Subject: [PATCH 1/4] Moves the shutdown thread into the Power class, make shutdown and reboot private (#7415) --- src/Power.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/PowerFSM.cpp | 2 +- src/main.cpp | 3 +-- src/power.h | 4 +++- src/shutdown.h | 47 ----------------------------------------------- 5 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 src/shutdown.h diff --git a/src/Power.cpp b/src/Power.cpp index 298f08e0d..b489bc33c 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -20,6 +20,11 @@ #include "meshUtils.h" #include "sleep.h" +#if defined(ARCH_PORTDUINO) +#include "api/WiFiServerAPI.h" +#include "input/LinuxInputImpl.h" +#endif + // Working USB detection for powered/charging states on the RAK platform #ifdef NRF_APM #include "nrfx_power.h" @@ -690,6 +695,47 @@ bool Power::setup() return found; } +void Power::powerCommandsCheck() +{ + if (rebootAtMsec && millis() > rebootAtMsec) { + LOG_INFO("Rebooting"); + reboot(); + } + + if (shutdownAtMsec && millis() > shutdownAtMsec) { + shutdownAtMsec = 0; + shutdown(); + } +} + +void Power::reboot() +{ + notifyReboot.notifyObservers(NULL); +#if defined(ARCH_ESP32) + ESP.restart(); +#elif defined(ARCH_NRF52) + NVIC_SystemReset(); +#elif defined(ARCH_RP2040) + rp2040.reboot(); +#elif defined(ARCH_PORTDUINO) + deInitApiServer(); + if (aLinuxInputImpl) + aLinuxInputImpl->deInit(); + SPI.end(); + Wire.end(); + Serial1.end(); + if (screen) + delete screen; + LOG_DEBUG("final reboot!"); + reboot(); +#elif defined(ARCH_STM32WL) + HAL_NVIC_SystemReset(); +#else + rebootAtMsec = -1; + LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied"); +#endif +} + void Power::shutdown() { diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 3b3f8080d..322b877ff 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -72,7 +72,7 @@ extern Power *power; static void shutdownEnter() { LOG_DEBUG("State: SHUTDOWN"); - power->shutdown(); + shutdownAtMsec = millis(); } #include "error.h" diff --git a/src/main.cpp b/src/main.cpp index c3e7c2a33..1868d98c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,6 @@ #include "mesh/generated/meshtastic/config.pb.h" #include "meshUtils.h" #include "modules/Modules.h" -#include "shutdown.h" #include "sleep.h" #include "target_specific.h" #include @@ -1530,7 +1529,7 @@ void loop() #ifdef ARCH_NRF52 nrf52Loop(); #endif - powerCommandsCheck(); + power->powerCommandsCheck(); #ifdef DEBUG_STACK static uint32_t lastPrint = 0; diff --git a/src/power.h b/src/power.h index 046980bd6..1c078c06d 100644 --- a/src/power.h +++ b/src/power.h @@ -110,7 +110,7 @@ class Power : private concurrency::OSThread Power(); - void shutdown(); + void powerCommandsCheck(); void readPowerStatus(); virtual bool setup(); virtual int32_t runOnce() override; @@ -130,6 +130,8 @@ class Power : private concurrency::OSThread bool lipoChargerInit(); private: + void shutdown(); + void reboot(); // open circuit voltage lookup table uint8_t low_voltage_counter; #ifdef DEBUG_HEAP diff --git a/src/shutdown.h b/src/shutdown.h deleted file mode 100644 index 973e388b1..000000000 --- a/src/shutdown.h +++ /dev/null @@ -1,47 +0,0 @@ -#include "buzz.h" -#include "configuration.h" -#include "graphics/Screen.h" -#include "main.h" -#include "power.h" -#include "sleep.h" -#if defined(ARCH_PORTDUINO) -#include "api/WiFiServerAPI.h" -#include "input/LinuxInputImpl.h" - -#endif - -void powerCommandsCheck() -{ - if (rebootAtMsec && millis() > rebootAtMsec) { - LOG_INFO("Rebooting"); - notifyReboot.notifyObservers(NULL); -#if defined(ARCH_ESP32) - ESP.restart(); -#elif defined(ARCH_NRF52) - NVIC_SystemReset(); -#elif defined(ARCH_RP2040) - rp2040.reboot(); -#elif defined(ARCH_PORTDUINO) - deInitApiServer(); - if (aLinuxInputImpl) - aLinuxInputImpl->deInit(); - SPI.end(); - Wire.end(); - Serial1.end(); - if (screen) - delete screen; - LOG_DEBUG("final reboot!"); - reboot(); -#elif defined(ARCH_STM32WL) - HAL_NVIC_SystemReset(); -#else - rebootAtMsec = -1; - LOG_WARN("FIXME implement reboot for this platform. Note that some settings require a restart to be applied"); -#endif - } - - if (shutdownAtMsec && millis() > shutdownAtMsec) { - shutdownAtMsec = 0; - power->shutdown(); - } -} \ No newline at end of file From 878d68c5efac54f80b1a02bb0f31acae85edc0d4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 22 Jul 2025 06:22:07 -0500 Subject: [PATCH 2/4] Upgrade trunk (#7420) Co-authored-by: vidplace7 <1779290+vidplace7@users.noreply.github.com> --- .trunk/trunk.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index d6a8cc8c1..2d4d3fc16 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -9,9 +9,9 @@ plugins: lint: enabled: - checkov@3.2.451 - - renovate@41.38.1 + - renovate@41.40.0 - prettier@3.6.2 - - trufflehog@3.90.0 + - trufflehog@3.90.1 - yamllint@1.37.1 - bandit@1.8.6 - trivy@0.64.1 @@ -28,7 +28,7 @@ lint: - shellcheck@0.10.0 - black@25.1.0 - git-diff-check - - gitleaks@8.27.2 + - gitleaks@8.28.0 - clang-format@16.0.3 ignore: - linters: [ALL] From 2087629a474c4b0b2d7a60995ce3b9b599b72c91 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 22 Jul 2025 06:22:23 -0500 Subject: [PATCH 3/4] Add a verbose mode flag to meshtasticd (#7416) --- src/platform/portduino/PortduinoGlue.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/platform/portduino/PortduinoGlue.cpp b/src/platform/portduino/PortduinoGlue.cpp index 685f0d077..5f99ec2c3 100644 --- a/src/platform/portduino/PortduinoGlue.cpp +++ b/src/platform/portduino/PortduinoGlue.cpp @@ -34,6 +34,7 @@ Ch341Hal *ch341Hal = nullptr; char *configPath = nullptr; char *optionMac = nullptr; bool forceSimulated = false; +bool verboseEnabled = false; const char *argp_program_version = optstr(APP_VERSION); @@ -70,7 +71,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 'h': optionMac = arg; break; - + case 'v': + verboseEnabled = true; + break; case ARGP_KEY_ARG: return 0; default: @@ -85,6 +88,7 @@ void portduinoCustomInit() {"config", 'c', "CONFIG_PATH", 0, "Full path of the .yaml config file to use."}, {"hwid", 'h', "HWID", 0, "The mac address to assign to this virtual machine"}, {"sim", 's', 0, 0, "Run in Simulated radio mode"}, + {"verbose", 'v', 0, 0, "Set log level to full debug"}, {0}}; static void *childArguments; static char doc[] = "Meshtastic native build."; @@ -417,6 +421,9 @@ void portduinoSetup() exit(EXIT_FAILURE); } } + if (verboseEnabled && settingsMap[logoutputlevel] != level_trace) { + settingsMap[logoutputlevel] = level_debug; + } return; } From d80dcd6afd1a94a99f934d92edfbcfc3b6f733c6 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 22 Jul 2025 08:49:33 -0500 Subject: [PATCH 4/4] Fix InkHUD shutdown code --- src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp index a1f79a28f..7876276a8 100644 --- a/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp +++ b/src/graphics/niche/InkHUD/Applets/System/Menu/MenuApplet.cpp @@ -223,7 +223,7 @@ void InkHUD::MenuApplet::execute(MenuItem item) case SHUTDOWN: LOG_INFO("Shutting down from menu"); - power->shutdown(); + shutdownAtMsec = millis(); // Menu is then sent to background via onShutdown break;