Merge branch 'master' into dismiss_frames

This commit is contained in:
Jason P 2025-07-22 11:52:26 -05:00 committed by GitHub
commit 019a6dc4ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 63 additions and 56 deletions

View File

@ -9,9 +9,9 @@ plugins:
lint: lint:
enabled: enabled:
- checkov@3.2.451 - checkov@3.2.451
- renovate@41.38.1 - renovate@41.40.0
- prettier@3.6.2 - prettier@3.6.2
- trufflehog@3.90.0 - trufflehog@3.90.1
- yamllint@1.37.1 - yamllint@1.37.1
- bandit@1.8.6 - bandit@1.8.6
- trivy@0.64.1 - trivy@0.64.1
@ -28,7 +28,7 @@ lint:
- shellcheck@0.10.0 - shellcheck@0.10.0
- black@25.1.0 - black@25.1.0
- git-diff-check - git-diff-check
- gitleaks@8.27.2 - gitleaks@8.28.0
- clang-format@16.0.3 - clang-format@16.0.3
ignore: ignore:
- linters: [ALL] - linters: [ALL]

View File

@ -20,6 +20,11 @@
#include "meshUtils.h" #include "meshUtils.h"
#include "sleep.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 // Working USB detection for powered/charging states on the RAK platform
#ifdef NRF_APM #ifdef NRF_APM
#include "nrfx_power.h" #include "nrfx_power.h"
@ -690,6 +695,47 @@ bool Power::setup()
return found; 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() void Power::shutdown()
{ {

View File

@ -72,7 +72,7 @@ extern Power *power;
static void shutdownEnter() static void shutdownEnter()
{ {
LOG_DEBUG("State: SHUTDOWN"); LOG_DEBUG("State: SHUTDOWN");
power->shutdown(); shutdownAtMsec = millis();
} }
#include "error.h" #include "error.h"

View File

@ -223,7 +223,7 @@ void InkHUD::MenuApplet::execute(MenuItem item)
case SHUTDOWN: case SHUTDOWN:
LOG_INFO("Shutting down from menu"); LOG_INFO("Shutting down from menu");
power->shutdown(); shutdownAtMsec = millis();
// Menu is then sent to background via onShutdown // Menu is then sent to background via onShutdown
break; break;

View File

@ -33,7 +33,6 @@
#include "mesh/generated/meshtastic/config.pb.h" #include "mesh/generated/meshtastic/config.pb.h"
#include "meshUtils.h" #include "meshUtils.h"
#include "modules/Modules.h" #include "modules/Modules.h"
#include "shutdown.h"
#include "sleep.h" #include "sleep.h"
#include "target_specific.h" #include "target_specific.h"
#include <memory> #include <memory>
@ -1530,7 +1529,7 @@ void loop()
#ifdef ARCH_NRF52 #ifdef ARCH_NRF52
nrf52Loop(); nrf52Loop();
#endif #endif
powerCommandsCheck(); power->powerCommandsCheck();
#ifdef DEBUG_STACK #ifdef DEBUG_STACK
static uint32_t lastPrint = 0; static uint32_t lastPrint = 0;

View File

@ -34,6 +34,7 @@ Ch341Hal *ch341Hal = nullptr;
char *configPath = nullptr; char *configPath = nullptr;
char *optionMac = nullptr; char *optionMac = nullptr;
bool forceSimulated = false; bool forceSimulated = false;
bool verboseEnabled = false;
const char *argp_program_version = optstr(APP_VERSION); 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': case 'h':
optionMac = arg; optionMac = arg;
break; break;
case 'v':
verboseEnabled = true;
break;
case ARGP_KEY_ARG: case ARGP_KEY_ARG:
return 0; return 0;
default: default:
@ -85,6 +88,7 @@ void portduinoCustomInit()
{"config", 'c', "CONFIG_PATH", 0, "Full path of the .yaml config file to use."}, {"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"}, {"hwid", 'h', "HWID", 0, "The mac address to assign to this virtual machine"},
{"sim", 's', 0, 0, "Run in Simulated radio mode"}, {"sim", 's', 0, 0, "Run in Simulated radio mode"},
{"verbose", 'v', 0, 0, "Set log level to full debug"},
{0}}; {0}};
static void *childArguments; static void *childArguments;
static char doc[] = "Meshtastic native build."; static char doc[] = "Meshtastic native build.";
@ -417,6 +421,9 @@ void portduinoSetup()
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
if (verboseEnabled && settingsMap[logoutputlevel] != level_trace) {
settingsMap[logoutputlevel] = level_debug;
}
return; return;
} }

View File

@ -110,7 +110,7 @@ class Power : private concurrency::OSThread
Power(); Power();
void shutdown(); void powerCommandsCheck();
void readPowerStatus(); void readPowerStatus();
virtual bool setup(); virtual bool setup();
virtual int32_t runOnce() override; virtual int32_t runOnce() override;
@ -130,6 +130,8 @@ class Power : private concurrency::OSThread
bool lipoChargerInit(); bool lipoChargerInit();
private: private:
void shutdown();
void reboot();
// open circuit voltage lookup table // open circuit voltage lookup table
uint8_t low_voltage_counter; uint8_t low_voltage_counter;
#ifdef DEBUG_HEAP #ifdef DEBUG_HEAP

View File

@ -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();
}
}