GPS PowerSaving v2: Added GPS wake up upon telemtry requests for companions. Bug fixes for "gps" CLI.
This commit is contained in:
1 parent
d9c42964eb
commit
1aa8ae90fb
16 files changed
+177
-201
No files matched your search
@@ -926,6 +926,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
|
||||
_prefs.rx_boosted_gain = 1; // enabled by default
|
||||
#endif
|
||||
#endif
|
||||
_prefs.powersaving_enabled = 1; // Power Saving enabled by default
|
||||
}
|
||||
|
||||
void MyMesh::begin(bool has_display) {
|
||||
@@ -1689,6 +1690,9 @@ void MyMesh::handleCmdFrame(size_t len) {
|
||||
}
|
||||
|
||||
// query other sensors -- target specific
|
||||
if (sensors.getLocationProvider() != NULL && sensors.getLocationProvider()->isPowerSavingEnabled()) {
|
||||
sensors.getLocationProvider()->syncTime(); // Request for GPS sync if GPS is in PowerSaving
|
||||
}
|
||||
sensors.querySensors(0xFF, telemetry);
|
||||
|
||||
int i = 0;
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
uint8_t autoadd_max_hops = 0; // 0 = no limit, 1 = direct (0 hops), N = up to N-1 hops (max 64)
|
||||
char default_scope_name[31];
|
||||
uint8_t default_scope_key[16];
|
||||
uint8_t powersaving_enabled = 0; // Power Saving
|
||||
|
||||
private:
|
||||
class RadioPrefs : public ConfigSerializer { // COPIED from CommonCLI (for now)
|
||||
|
||||
@@ -236,6 +236,16 @@ void setup() {
|
||||
#endif
|
||||
|
||||
the_mesh.startInterface(interface_manager);
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
// Apply PowerSaving profile for GPS
|
||||
if (sensors.getLocationProvider() != NULL) {
|
||||
// GPS on and off duration in seconds
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(the_mesh.getNodePrefs()->powersaving_enabled, 600,
|
||||
1800); // Max 10 minutes, 30 minutes
|
||||
}
|
||||
#endif
|
||||
|
||||
sensors.begin();
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
|
||||
@@ -163,13 +163,6 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
// If powersaving on, apply powersaving to sensors
|
||||
if (_prefs.powersaving_enabled) {
|
||||
sensors.powersaving_enabled = true;
|
||||
} else {
|
||||
sensors.powersaving_enabled = false;
|
||||
}
|
||||
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -105,12 +105,9 @@ void setup() {
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
// Apply PowerSaving profile for GPS
|
||||
if (sensors.getLocationProvider() != NULL) {
|
||||
// Let CLI "gps on" call setSettingValue to enable the PowerSaving mode
|
||||
// sensors.powersaving_enabled = true;
|
||||
// sensors.getLocationProvider()->enablePowerSaving(true);
|
||||
|
||||
// GPS on and off duration in seconds
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(600, 86400); // Max 10 minutes, 1 day
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(the_mesh.getNodePrefs()->powersaving_enabled, 600,
|
||||
86400); // Max 10 minutes, 1 day
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -168,13 +168,6 @@ protected:
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
// If powersaving on, apply powersaving to sensors
|
||||
if (_prefs.powersaving_enabled) {
|
||||
sensors.powersaving_enabled = true;
|
||||
} else {
|
||||
sensors.powersaving_enabled = false;
|
||||
}
|
||||
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -89,12 +89,9 @@ void setup() {
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
// Apply PowerSaving profile for GPS
|
||||
if (sensors.getLocationProvider() != NULL) {
|
||||
// Let CLI "gps on" call setSettingValue to enable the PowerSaving mode
|
||||
// sensors.powersaving_enabled = true;
|
||||
// sensors.getLocationProvider()->enablePowerSaving(true);
|
||||
|
||||
// GPS on and off duration in seconds
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(600, 86400); // Max 10 minutes, 1 day
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(the_mesh.getNodePrefs()->powersaving_enabled, 600,
|
||||
86400); // Max 10 minutes, 1 day
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -162,15 +162,8 @@ private:
|
||||
|
||||
void sendAlert(const ClientInfo* c, Trigger* t);
|
||||
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
void applyGpsPrefs() {
|
||||
// If powersaving on, apply powersaving to sensors
|
||||
if (_prefs.powersaving_enabled) {
|
||||
sensors.powersaving_enabled = true;
|
||||
} else {
|
||||
sensors.powersaving_enabled = false;
|
||||
}
|
||||
|
||||
sensors.setSettingValue("gps", _prefs.gps_enabled?"1":"0");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -65,6 +65,12 @@ void setup() {
|
||||
external_watchdog.begin();
|
||||
#endif
|
||||
|
||||
#if defined(MESH_DEBUG) && defined(NRF52_PLATFORM)
|
||||
// give some extra time for serial to settle so
|
||||
// boot debug messages can be seen on terminal
|
||||
delay(5000);
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
@@ -112,12 +118,9 @@ void setup() {
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
// Apply PowerSaving profile for GPS
|
||||
if (sensors.getLocationProvider() != NULL) {
|
||||
// Let CLI "gps on" call setSettingValue to enable the PowerSaving mode
|
||||
// sensors.powersaving_enabled = true;
|
||||
// sensors.getLocationProvider()->enablePowerSaving(true);
|
||||
|
||||
// GPS on and off duration in seconds
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(600, 86400); // Max 10 minutes, 1 day
|
||||
sensors.getLocationProvider()->setPowerSavingProfile(the_mesh.getNodePrefs()->powersaving_enabled, 600,
|
||||
86400); // Max 10 minutes, 1 day
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user