diff --git a/.trunk/.gitignore b/.trunk/.gitignore index 695b51906c..1e24652901 100644 --- a/.trunk/.gitignore +++ b/.trunk/.gitignore @@ -2,7 +2,7 @@ *logs *actions *notifications +*tools plugins user_trunk.yaml user.yaml -tools diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 7e81046a70..f2de06f0d4 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,48 +1,48 @@ version: 0.1 cli: - version: 1.13.0 + version: 1.16.2 plugins: sources: - id: trunk - ref: v1.1.1 + ref: v1.2.5 uri: https://github.com/trunk-io/plugins lint: enabled: - bandit@1.7.5 - - checkov@2.4.1 + - checkov@2.5.0 - terrascan@1.18.3 - - trivy@0.44.1 - - trufflehog@3.48.0 + - trivy@0.45.1 + - trufflehog@3.59.0 - taplo@0.8.1 - - ruff@0.0.284 + - ruff@0.0.292 - yamllint@1.32.0 - isort@5.12.0 - - markdownlint@0.35.0 + - markdownlint@0.37.0 - oxipng@8.0.0 - svgo@3.0.2 - - actionlint@1.6.25 + - actionlint@1.6.26 - flake8@6.1.0 - hadolint@2.12.0 - shfmt@3.6.0 - shellcheck@0.9.0 - - black@23.7.0 + - black@23.9.1 - git-diff-check - - gitleaks@8.17.0 + - gitleaks@8.18.0 - clang-format@16.0.3 - - prettier@3.0.2 + - prettier@3.0.3 disabled: - taplo@0.8.1 - shellcheck@0.9.0 - shfmt@3.6.0 - oxipng@8.0.0 - actionlint@1.6.22 - - markdownlint@0.35.0 + - markdownlint@0.37.0 - hadolint@2.12.0 - svgo@3.0.2 runtimes: enabled: - python@3.10.8 - - go@1.19.5 + - go@1.21.0 - node@18.12.1 actions: disabled: diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 29ddde4ce7..a7beeda282 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -178,9 +178,9 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t cha service.sendToMesh(p, RX_SRC_LOCAL, true); if (config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER && config.power.is_power_saving) { - LOG_DEBUG("Starting next execution in 3 seconds and then going to sleep.\n"); + LOG_DEBUG("Starting next execution in 5 seconds and then going to sleep.\n"); sleepOnNextExecution = true; - setIntervalFromNow(3000); + setIntervalFromNow(5000); } } diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 1f1a0cbf94..1047ade1d5 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -8,6 +8,8 @@ #include "configuration.h" #include "main.h" #include "power.h" +#include "sleep.h" +#include "target_specific.h" #include #include @@ -51,6 +53,13 @@ SHT31Sensor sht31Sensor; int32_t EnvironmentTelemetryModule::runOnce() { + if (sleepOnNextExecution == true) { + sleepOnNextExecution = false; + uint32_t nightyNightMs = getConfiguredOrDefaultMs(moduleConfig.telemetry.environment_update_interval); + LOG_DEBUG("Sleeping for %ims, then awaking to send metrics again.\n", nightyNightMs); + doDeepSleep(nightyNightMs, true); + } + uint32_t result = UINT32_MAX; /* Uncomment the preferences below if you want to use the module @@ -266,6 +275,12 @@ bool EnvironmentTelemetryModule::sendTelemetry(NodeNum dest, bool phoneOnly) } else { LOG_INFO("Sending packet to mesh\n"); service.sendToMesh(p, RX_SRC_LOCAL, true); + + if (config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR && config.power.is_power_saving) { + LOG_DEBUG("Starting next execution in 5 seconds and then going to sleep.\n"); + sleepOnNextExecution = true; + setIntervalFromNow(5000); + } } } return valid; diff --git a/src/platform/nrf52/main-nrf52.cpp b/src/platform/nrf52/main-nrf52.cpp index 6b986c778f..65b45f1e93 100644 --- a/src/platform/nrf52/main-nrf52.cpp +++ b/src/platform/nrf52/main-nrf52.cpp @@ -180,15 +180,19 @@ void cpuDeepSleep(uint32_t msecToWake) digitalWrite(AQ_SET_PIN, LOW); #endif #endif - // FIXME, use system off mode with ram retention for key state? - // FIXME, use non-init RAM per - // https://devzone.nordicsemi.com/f/nordic-q-a/48919/ram-retention-settings-with-softdevice-enabled - - if (config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER && config.power.is_power_saving == true) { + // Sleepy trackers or sensors can low power "sleep" + // Don't enter this if we're sleeping portMAX_DELAY, since that's a shutdown event + if (msecToWake != portMAX_DELAY && + (config.device.role == meshtastic_Config_DeviceConfig_Role_TRACKER || + config.device.role == meshtastic_Config_DeviceConfig_Role_SENSOR) && + config.power.is_power_saving == true) { sd_power_mode_set(NRF_POWER_MODE_LOWPWR); delay(msecToWake); NVIC_SystemReset(); } else { + // FIXME, use system off mode with ram retention for key state? + // FIXME, use non-init RAM per + // https://devzone.nordicsemi.com/f/nordic-q-a/48919/ram-retention-settings-with-softdevice-enabled auto ok = sd_power_system_off(); if (ok != NRF_SUCCESS) { LOG_ERROR("FIXME: Ignoring soft device (EasyDMA pending?) and forcing system-off!\n");