Skip to content

Commit

Permalink
Merge branch 'master' into nrf-low-power-repeater
Browse files Browse the repository at this point in the history
  • Loading branch information
thebentern authored Oct 5, 2023
2 parents 345cc90 + 950d5f0 commit 09085fc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .trunk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tools
26 changes: 13 additions & 13 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -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:
- [email protected]
- checkov@2.4.1
- checkov@2.5.0
- [email protected]
- trivy@0.44.1
- trufflehog@3.48.0
- trivy@0.45.1
- trufflehog@3.59.0
- [email protected]
- [email protected].284
- [email protected].292
- [email protected]
- [email protected]
- markdownlint@0.35.0
- markdownlint@0.37.0
- [email protected]
- [email protected]
- [email protected].25
- [email protected].26
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- black@23.7.0
- black@23.9.1
- git-diff-check
- gitleaks@8.17.0
- gitleaks@8.18.0
- [email protected]
- [email protected].2
- [email protected].3
disabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- markdownlint@0.35.0
- markdownlint@0.37.0
- [email protected]
- [email protected]
runtimes:
enabled:
- [email protected]
- go@1.19.5
- go@1.21.0
- [email protected]
actions:
disabled:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/PositionModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/modules/Telemetry/EnvironmentTelemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "configuration.h"
#include "main.h"
#include "power.h"
#include "sleep.h"
#include "target_specific.h"
#include <OLEDDisplay.h>
#include <OLEDDisplayUi.h>

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions src/platform/nrf52/main-nrf52.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 09085fc

Please sign in to comment.