From a7a4e52947b3f077547fd49016a79ea2a1d8f70b Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Mon, 20 Jul 2026 16:19:27 +0700 Subject: [PATCH 1/7] GPS PowerSaving v1.1: Added support for BLE companions --- examples/companion_radio/main.cpp | 12 ++++ examples/simple_repeater/main.cpp | 12 ++++ src/MeshCore.h | 9 +++ src/helpers/CommonCLI.cpp | 6 +- .../sensors/EnvironmentSensorManager.cpp | 64 +++++++++---------- .../sensors/EnvironmentSensorManager.h | 1 + src/helpers/sensors/LocationProvider.h | 26 +++++--- 7 files changed, 85 insertions(+), 45 deletions(-) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index f10cb1702..364a5bb5b 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -234,6 +234,18 @@ void setup() { #error "need to define filesystem" #endif +#if ENV_INCLUDE_GPS == 1 + // Apply PowerSaving profile for GPS + if(sensors.getLocationProvider() != NULL) { + // Enable by default + sensors.powersaving_enabled = true; + sensors.getLocationProvider()->enablePowerSaving(true); + + // Set GPS on and off duration in seconds + sensors.getLocationProvider()->setPowerSavingProfile(600, 300); // Max 10 minutes, 5 minutes + } +#endif + sensors.begin(); #if ENV_INCLUDE_GPS == 1 diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 82e2a2121..b2c3d0566 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -87,6 +87,18 @@ void setup() { command[0] = 0; +#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 + } +#endif + sensors.begin(); the_mesh.begin(fs); diff --git a/src/MeshCore.h b/src/MeshCore.h index 4c23b415f..c3f417a49 100644 --- a/src/MeshCore.h +++ b/src/MeshCore.h @@ -37,6 +37,15 @@ #define BRIDGE_DEBUG_PRINTLN(...) {} #endif +#if POWERSAVING_DEBUG && ARDUINO + #include + #define POWERSAVING_DEBUG_PRINT(F, ...) Serial.printf("POWERSAVING: " F, ##__VA_ARGS__) + #define POWERSAVING_DEBUG_PRINTLN(F, ...) Serial.printf("POWERSAVING: " F "\n", ##__VA_ARGS__) +#else + #define POWERSAVING_DEBUG_PRINT(...) {} + #define POWERSAVING_DEBUG_PRINTLN(...) {} +#endif + namespace mesh { #define BD_STARTUP_NORMAL 0 // getStartupReason() codes diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 77f7a13d3..5e5cddb4a 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -436,9 +436,9 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re int sats = l->satellitesCount(); bool active = !strcmp(_sensors->getSettingByKey("gps"), "1"); - if (_prefs->powersaving_enabled && l->getGPSPowerSaving()) { // GPS Power Saving + if (_prefs->powersaving_enabled && l->isPowerSavingEnabled()) { // GPS Power Saving if (enabled) { - unsigned long mins = (l->getNextGPSOff() - millis()) / 60000UL; + unsigned long mins = (l->getNextSleep() - millis()) / 60000UL; sprintf(reply, "on (powersaving, sleep in %luh %lum), %s, %s, %d sats", mins / 60UL, mins % 60UL, @@ -446,7 +446,7 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re fix ? "fix" : "no fix", sats); } else { - unsigned long mins = (l->getNextGPSOn() - millis()) / 60000UL; + unsigned long mins = (l->getNextWake() - millis()) / 60000UL; sprintf(reply, "off (powersaving, wake in %luh %lum)", mins / 60UL, mins % 60UL); diff --git a/src/helpers/sensors/EnvironmentSensorManager.cpp b/src/helpers/sensors/EnvironmentSensorManager.cpp index fc66651a5..12f196b96 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.cpp +++ b/src/helpers/sensors/EnvironmentSensorManager.cpp @@ -621,12 +621,6 @@ static const SensorDef SENSOR_TABLE[] = { static const size_t SENSOR_TABLE_SIZE = (sizeof(SENSOR_TABLE) / sizeof(SENSOR_TABLE[0])) - 1; -// ============================================================ -// Power Saving GPS -// ============================================================ -static unsigned long GPS_ON_DURATION_SECS = 600; // 10 minutes -static unsigned long GPS_OFF_DURATION_SECS = 86400; // 1 day - // ============================================================ // begin() — scan the I2C bus, then initialize only what was // found. A sensor whose address does not ACK during the scan @@ -737,13 +731,13 @@ bool EnvironmentSensorManager::setSettingValue(const char* name, const char* val if (gps_detected && strcmp(name, "gps") == 0) { if (strcmp(value, "0") == 0) { if (powersaving_enabled) { - _location->setGPSPowerSaving(false); + _location->enablePowerSaving(false); } stop_gps(); } else { if (powersaving_enabled) { - _location->setGPSPowerSaving(true); + _location->enablePowerSaving(true); } start_gps(); @@ -885,6 +879,13 @@ bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin){ void EnvironmentSensorManager::start_gps() { gps_active = true; + + if (powersaving_enabled && _location->isPowerSavingEnabled()) { + gps_wake = true; // gps_active is true + _location->syncTime(); // Clear GPS data and force sync time + _location->setNextSleep(); // Next time to off + } + #ifdef RAK_WISBLOCK_GPS pinMode(gpsResetPin, OUTPUT); digitalWrite(gpsResetPin, HIGH); @@ -897,22 +898,19 @@ void EnvironmentSensorManager::start_gps() { #ifndef PIN_GPS_EN MESH_DEBUG_PRINTLN("Start GPS is N/A on this board. Actual GPS state unchanged"); #endif - - if (powersaving_enabled && _location->getGPSPowerSaving()) { - _location->syncTime(); // Clear GPS data and force sync time - _location->setNextGPSOff(millis() + GPS_ON_DURATION_SECS * 1000UL); // Next time to off - } } void EnvironmentSensorManager::stop_gps() { - gps_active = false; - - if (powersaving_enabled && _location->getGPSPowerSaving()) { + if (powersaving_enabled && _location->isPowerSavingEnabled()) { + gps_wake = false; // gps_active is unchanged (true) even the GPS sleep (e.g: off) _location->stopTimeSync(); // Stop time sync - _location->setNextGPSOn(millis() + GPS_OFF_DURATION_SECS * 1000UL); // Next time to on + _location->setNextWake(); // Next time to on + } else { + gps_active = false; + gps_wake = false; // When GPS is off, wake is false to be sure } -#ifdef RAK_WISBLOCK_GPS + #ifdef RAK_WISBLOCK_GPS pinMode(gpsResetPin, OUTPUT); digitalWrite(gpsResetPin, LOW); return; @@ -934,37 +932,35 @@ void EnvironmentSensorManager::loop() { // PowerSaving if (powersaving_enabled) { - if (gps_detected && _location->getGPSPowerSaving()) { - if (gps_active && ((int32_t)(millis() - _location->getNextGPSOff()) >= 0 || + if (gps_detected && _location->isPowerSavingEnabled()) { + if (gps_wake && ((int32_t)(millis() - _location->getNextSleep()) >= 0 || !_location->waitingTimeSync())) { // Time to off or GPS set - // --- TO REMOVE - if ((int32_t)(millis() - _location->getNextGPSOff()) >= 0) Serial.println("Timeout, off"); - else if (!_location->waitingTimeSync()) Serial.println("GPS set, off early"); - // --- TO REMOVE + if ((int32_t)(millis() - _location->getNextSleep()) >= 0) { + POWERSAVING_DEBUG_PRINTLN("GPS wake timeout. Enter sleep"); + } + else if (!_location->waitingTimeSync()) { + POWERSAVING_DEBUG_PRINTLN("GPS set. Enter sleep early"); + } stop_gps(); - } else if (!gps_active && ((int32_t)(millis() - _location->getNextGPSOn()) >= 0)) { // Time to on - // --- TO REMOVE - Serial.println("Timeout, on"); - // --- TO REMOVE + } else if (!gps_wake && ((int32_t)(millis() - _location->getNextWake()) >= 0)) { // Time to on + POWERSAVING_DEBUG_PRINTLN("GPS sleep timeout. Wakeup."); start_gps(); - } else if (!gps_active && _location->waitingTimeSync()) { // On for "gps sync" - // --- TO REMOVE - Serial.println("gps sync CLI, on"); - // --- TO REMOVE + } else if (!gps_wake && _location->waitingTimeSync()) { // On for "gps sync" + POWERSAVING_DEBUG_PRINTLN("CLI gps sync. Wakeup"); start_gps(); } } } - if (gps_active) { + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { _location->loop(); } if ((int32_t)(millis() - next_gps_update) >= 0) { - if(gps_active){ + if((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)){ #ifdef RAK_WISBLOCK_GPS if ((i2cGPSFlag || serialGPSFlag) && _location->isValid()) { node_lat = ((double)_location->getLatitude())/1000000.; diff --git a/src/helpers/sensors/EnvironmentSensorManager.h b/src/helpers/sensors/EnvironmentSensorManager.h index 29147c896..40c44e908 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.h +++ b/src/helpers/sensors/EnvironmentSensorManager.h @@ -21,6 +21,7 @@ protected: bool gps_detected = false; bool gps_active = false; + bool gps_wake = false; // In PowerSaving, gps_active can have gps_wake true or false uint32_t gps_update_interval_sec = 1; #if ENV_INCLUDE_GPS diff --git a/src/helpers/sensors/LocationProvider.h b/src/helpers/sensors/LocationProvider.h index 34c2fc2e3..810750409 100644 --- a/src/helpers/sensors/LocationProvider.h +++ b/src/helpers/sensors/LocationProvider.h @@ -6,22 +6,32 @@ class LocationProvider { protected: bool _time_sync_needed = true; + bool powersaving_enabled = false; - unsigned long _next_gps_off = 0; - unsigned long _next_gps_on = 0; + unsigned long _wake_duration_secs = 86400; // Full day + unsigned long _sleep_duration_secs = 0; // No off + unsigned long _next_wake = 0; + unsigned long _next_sleep = 0; unsigned long _last_valid_time_sync = 0; public: virtual void syncTime() { _time_sync_needed = true; } virtual bool waitingTimeSync() { return _time_sync_needed; } virtual void stopTimeSync() { _time_sync_needed = false; } - virtual void setGPSPowerSaving(bool enabled) { powersaving_enabled = enabled; _next_gps_off = 0; _next_gps_on = 0; } - virtual bool getGPSPowerSaving() { return powersaving_enabled; } - virtual void setNextGPSOff(unsigned long _millis) { _next_gps_off = _millis; } - virtual unsigned long getNextGPSOff() { return _next_gps_off; } - virtual void setNextGPSOn(unsigned long _millis) { _next_gps_on = _millis; } - virtual unsigned long getNextGPSOn() { return _next_gps_on; } + + virtual void setPowerSavingProfile(unsigned long wake_duration_secs, unsigned long sleep_duration_secs) { + _wake_duration_secs = wake_duration_secs; + _sleep_duration_secs = sleep_duration_secs; + } + + virtual void enablePowerSaving(bool enabled) { powersaving_enabled = enabled; _next_wake = 0; _next_sleep = 0; } + virtual bool isPowerSavingEnabled() { return powersaving_enabled; } + virtual void setNextWake() { _next_wake = millis() + _sleep_duration_secs * 1000UL; } + virtual unsigned long getNextWake() { return _next_wake; } + virtual void setNextSleep() { _next_sleep = millis() + _wake_duration_secs * 1000UL; } + virtual unsigned long getNextSleep() { return _next_sleep; } virtual unsigned long getLastValidTimeSync() { return _last_valid_time_sync; } + virtual long getLatitude() = 0; virtual long getLongitude() = 0; virtual long getAltitude() = 0; From 75cc95f17fd6599402dd07c0bbd86addabef7857 Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Mon, 20 Jul 2026 22:47:27 +0700 Subject: [PATCH 2/7] GPS PowerSaving 1.2: Fix gps on / off for RAK boards --- .../sensors/EnvironmentSensorManager.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/helpers/sensors/EnvironmentSensorManager.cpp b/src/helpers/sensors/EnvironmentSensorManager.cpp index 12f196b96..18ec7dad1 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.cpp +++ b/src/helpers/sensors/EnvironmentSensorManager.cpp @@ -798,6 +798,7 @@ void EnvironmentSensorManager::initBasicGPS() { // gps code for rak might be moved to MicroNMEALoactionProvider // or make a new location provider ... #ifdef RAK_WISBLOCK_GPS +static int8_t RAK_GPS_EN = -1; void EnvironmentSensorManager::rakGPSInit(){ Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX); @@ -809,13 +810,13 @@ void EnvironmentSensorManager::rakGPSInit(){ #endif //search for the correct IO standby pin depending on socket used - if(gpsIsAwake(WB_IO2)){ - } - else if(gpsIsAwake(WB_IO4)){ - } - else if(gpsIsAwake(WB_IO5)){ - } - else{ + if (gpsIsAwake(WB_IO2)) { + RAK_GPS_EN = WB_IO2; + } else if (gpsIsAwake(WB_IO4)) { + RAK_GPS_EN = WB_IO4; + } else if (gpsIsAwake(WB_IO5)) { + RAK_GPS_EN = WB_IO5; + } else { MESH_DEBUG_PRINTLN("No GPS found"); gps_active = false; gps_detected = false; @@ -889,6 +890,7 @@ void EnvironmentSensorManager::start_gps() { #ifdef RAK_WISBLOCK_GPS pinMode(gpsResetPin, OUTPUT); digitalWrite(gpsResetPin, HIGH); + gpsIsAwake(RAK_GPS_EN); // Turn on UART L76K for RAK12500 or I2C for RAK12501 return; #endif @@ -913,6 +915,7 @@ void EnvironmentSensorManager::stop_gps() { #ifdef RAK_WISBLOCK_GPS pinMode(gpsResetPin, OUTPUT); digitalWrite(gpsResetPin, LOW); + digitalWrite(RAK_GPS_EN, LOW); // Cut off power return; #endif From d16843d5ea0b3a2d075bb7e0811714d4c222cb01 Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Wed, 22 Jul 2026 12:07:27 +0700 Subject: [PATCH 3/7] GPS PowerSaving v1.3: Supported dynamic GPS_EN for RAK boards --- .../sensors/EnvironmentSensorManager.cpp | 56 +++++++++---------- src/helpers/sensors/LocationProvider.h | 2 + .../sensors/MicroNMEALocationProvider.h | 8 +++ 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/helpers/sensors/EnvironmentSensorManager.cpp b/src/helpers/sensors/EnvironmentSensorManager.cpp index 18ec7dad1..0156a03a8 100644 --- a/src/helpers/sensors/EnvironmentSensorManager.cpp +++ b/src/helpers/sensors/EnvironmentSensorManager.cpp @@ -185,6 +185,7 @@ class RAK12500LocationProvider : public LocationProvider { int _sats = 0; long _epoch = 0; bool _fix = false; + int _pin_en = -1; public: long getLatitude() override { return _lat; } long getLongitude() override { return _lng; } @@ -209,6 +210,8 @@ public: _epoch = ublox_GNSS.getUnixEpoch(2); } bool isEnabled() override { return true; } + void setPinEn(int pin_en) override { _pin_en = pin_en; } + int getPinEn() override { return _pin_en; } }; static RAK12500LocationProvider RAK12500_provider; @@ -798,24 +801,22 @@ void EnvironmentSensorManager::initBasicGPS() { // gps code for rak might be moved to MicroNMEALoactionProvider // or make a new location provider ... #ifdef RAK_WISBLOCK_GPS -static int8_t RAK_GPS_EN = -1; -void EnvironmentSensorManager::rakGPSInit(){ - +void EnvironmentSensorManager::rakGPSInit() { Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX); - #ifdef GPS_BAUD_RATE +#ifdef GPS_BAUD_RATE Serial1.begin(GPS_BAUD_RATE); - #else +#else Serial1.begin(9600); - #endif +#endif - //search for the correct IO standby pin depending on socket used + // search for the correct IO standby pin depending on socket used if (gpsIsAwake(WB_IO2)) { - RAK_GPS_EN = WB_IO2; + _location->setPinEn(WB_IO2); } else if (gpsIsAwake(WB_IO4)) { - RAK_GPS_EN = WB_IO4; + _location->setPinEn(WB_IO4); } else if (gpsIsAwake(WB_IO5)) { - RAK_GPS_EN = WB_IO5; + _location->setPinEn(WB_IO5); } else { MESH_DEBUG_PRINTLN("No GPS found"); gps_active = false; @@ -824,24 +825,23 @@ void EnvironmentSensorManager::rakGPSInit(){ return; } - #ifndef FORCE_GPS_ALIVE // for use with repeaters, until GPS toggle is implimented - //Now that GPS is found and set up, set to sleep for initial state +#ifndef FORCE_GPS_ALIVE // for use with repeaters, until GPS toggle is implimented + // Now that GPS is found and set up, set to sleep for initial state stop_gps(); - #endif +#endif } -bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin){ - - //set initial waking state - pinMode(ioPin,OUTPUT); - digitalWrite(ioPin,LOW); +bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin) { + // set initial waking state + pinMode(ioPin, OUTPUT); + digitalWrite(ioPin, LOW); delay(500); - digitalWrite(ioPin,HIGH); + digitalWrite(ioPin, HIGH); delay(500); - //Try to init RAK12500 on I2C - if (ublox_GNSS.begin(Wire) == true){ - MESH_DEBUG_PRINTLN("RAK12500 GPS init correctly with pin %i",ioPin); + // Try to init RAK12500 on I2C + if (ublox_GNSS.begin(Wire) == true) { + MESH_DEBUG_PRINTLN("RAK12500 GPS init correctly with pin %i", ioPin); ublox_GNSS.setI2COutput(COM_TYPE_UBX); ublox_GNSS.enableGNSS(true, SFE_UBLOX_GNSS_ID_GPS); ublox_GNSS.enableGNSS(true, SFE_UBLOX_GNSS_ID_GALILEO); @@ -859,10 +859,10 @@ bool EnvironmentSensorManager::gpsIsAwake(uint8_t ioPin){ _location = &RAK12500_provider; return true; - } else if (Serial1.available()) { + } else if (Serial1.available()) { // RAK12501 (L76K) on UART MESH_DEBUG_PRINTLN("Serial GPS init correctly and is turned on"); #ifdef PIN_GPS_EN - if(PIN_GPS_EN){ + if (PIN_GPS_EN) { gpsResetPin = PIN_GPS_EN; } #endif @@ -887,12 +887,12 @@ void EnvironmentSensorManager::start_gps() { _location->setNextSleep(); // Next time to off } - #ifdef RAK_WISBLOCK_GPS +#ifdef RAK_WISBLOCK_GPS pinMode(gpsResetPin, OUTPUT); digitalWrite(gpsResetPin, HIGH); - gpsIsAwake(RAK_GPS_EN); // Turn on UART L76K for RAK12500 or I2C for RAK12501 + gpsIsAwake(_location->getPinEn()); // Turn on UART L76K for RAK12500 or I2C for RAK12501 return; - #endif +#endif _location->begin(); _location->reset(); @@ -915,7 +915,7 @@ void EnvironmentSensorManager::stop_gps() { #ifdef RAK_WISBLOCK_GPS pinMode(gpsResetPin, OUTPUT); digitalWrite(gpsResetPin, LOW); - digitalWrite(RAK_GPS_EN, LOW); // Cut off power + digitalWrite(_location->getPinEn(), LOW); // Cut off power return; #endif diff --git a/src/helpers/sensors/LocationProvider.h b/src/helpers/sensors/LocationProvider.h index 810750409..c9204373e 100644 --- a/src/helpers/sensors/LocationProvider.h +++ b/src/helpers/sensors/LocationProvider.h @@ -44,4 +44,6 @@ public: virtual void stop() = 0; virtual void loop() = 0; virtual bool isEnabled() = 0; + virtual void setPinEn(int pin_en) = 0; + virtual int getPinEn() = 0; }; diff --git a/src/helpers/sensors/MicroNMEALocationProvider.h b/src/helpers/sensors/MicroNMEALocationProvider.h index a670b4427..dd569062b 100644 --- a/src/helpers/sensors/MicroNMEALocationProvider.h +++ b/src/helpers/sensors/MicroNMEALocationProvider.h @@ -111,6 +111,14 @@ public : } } + void setPinEn(int pin_en) override { + _pin_en = pin_en; + } + + int getPinEn() override { + return _pin_en; + } + void syncTime() override { nmea.clear(); LocationProvider::syncTime(); } long getLatitude() override { return nmea.getLatitude(); } long getLongitude() override { return nmea.getLongitude(); } From d6c61af7c7ed2e402525fe653f65ebc7ed45f1d6 Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Wed, 22 Jul 2026 16:19:54 +0700 Subject: [PATCH 4/7] Added POWERSAVING_DEBUG=1 --- variants/heltec_t096/platformio.ini | 2 ++ variants/heltec_t114/platformio.ini | 2 ++ variants/rak4631/platformio.ini | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/variants/heltec_t096/platformio.ini b/variants/heltec_t096/platformio.ini index 5f17436ad..1961b3747 100644 --- a/variants/heltec_t096/platformio.ini +++ b/variants/heltec_t096/platformio.ini @@ -69,6 +69,7 @@ build_flags = -D MAX_NEIGHBOURS=50 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +; -D POWERSAVING_DEBUG=1 [env:Heltec_t096_repeater_bridge_rs232] extends = Heltec_t096 @@ -135,6 +136,7 @@ build_flags = -D OFFLINE_QUEUE_SIZE=256 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +; -D POWERSAVING_DEBUG=1 build_src_filter = ${Heltec_t096.build_src_filter} + +<../examples/companion_radio/*.cpp> diff --git a/variants/heltec_t114/platformio.ini b/variants/heltec_t114/platformio.ini index e808d6c28..9817bc72c 100644 --- a/variants/heltec_t114/platformio.ini +++ b/variants/heltec_t114/platformio.ini @@ -170,6 +170,7 @@ build_flags = -D MAX_NEIGHBOURS=50 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +; -D POWERSAVING_DEBUG=1 [env:Heltec_t114_repeater_bridge_rs232] extends = Heltec_t114 @@ -219,6 +220,7 @@ build_flags = -D OFFLINE_QUEUE_SIZE=256 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +; -D POWERSAVING_DEBUG=1 build_src_filter = ${Heltec_t114_with_display.build_src_filter} + +<../examples/companion_radio/*.cpp> diff --git a/variants/rak4631/platformio.ini b/variants/rak4631/platformio.ini index 8f72999af..bcaacc47e 100644 --- a/variants/rak4631/platformio.ini +++ b/variants/rak4631/platformio.ini @@ -50,6 +50,7 @@ build_flags = -D MAX_NEIGHBOURS=50 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +; -D POWERSAVING_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} + +<../examples/simple_repeater> @@ -150,10 +151,11 @@ build_flags = -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 -D BLE_PIN_CODE=123456 - -D BLE_DEBUG_LOGGING=1 +; -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 +; -D POWERSAVING_DEBUG=1 build_src_filter = ${rak4631.build_src_filter} + +<../examples/companion_radio/*.cpp> From 0843c7c5aef0aedf04cd712c0281821693641946 Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Thu, 23 Jul 2026 12:26:31 +0700 Subject: [PATCH 5/7] Fix blank OLED on T-Beam Supreme V3 (I2C bus init + 0x3D address) https://github.com/meshcore-dev/MeshCore/pull/2815 --- src/helpers/esp32/TBeamBoard.cpp | 10 ++++++++++ src/helpers/ui/SH1106Display.cpp | 5 ++++- variants/lilygo_tbeam_supreme_SX1262/platformio.ini | 5 +---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/helpers/esp32/TBeamBoard.cpp b/src/helpers/esp32/TBeamBoard.cpp index 5f708d71d..d9f6e0227 100644 --- a/src/helpers/esp32/TBeamBoard.cpp +++ b/src/helpers/esp32/TBeamBoard.cpp @@ -16,6 +16,16 @@ void TBeamBoard::begin() { ESP32Board::begin(); +#ifdef TBEAM_SUPREME_SX1262 + // On the T-Beam S3 Supreme the PMU + RTC sit on Wire1 (GPIO 42/41, brought + // up by XPowersLib), while the SH1106 OLED and the BME280/QMC6310 sensors + // sit on the primary bus, Wire (GPIO PIN_BOARD_SDA/PIN_BOARD_SCL). Nothing + // else initialises Wire on this board, so the display driver would + // otherwise talk on the wrong (default) pins and display.begin() fails, + // leaving the screen blank. Bring the OLED bus up here. + Wire.begin(PIN_BOARD_SDA, PIN_BOARD_SCL); +#endif + power_init(); //Configure user button diff --git a/src/helpers/ui/SH1106Display.cpp b/src/helpers/ui/SH1106Display.cpp index f383bb005..57ccfc2e4 100644 --- a/src/helpers/ui/SH1106Display.cpp +++ b/src/helpers/ui/SH1106Display.cpp @@ -11,7 +11,10 @@ bool SH1106Display::i2c_probe(TwoWire &wire, uint8_t addr) bool SH1106Display::begin() { - return display.begin(DISPLAY_ADDRESS, true) && i2c_probe(Wire, DISPLAY_ADDRESS); + // Wire must already be initialised by board.begin() before this is called. + // Boards with non-standard SH1106 addresses should define DISPLAY_ADDRESS + // in their variant/platformio configuration. + return i2c_probe(Wire, DISPLAY_ADDRESS) && display.begin(DISPLAY_ADDRESS, true); } void SH1106Display::turnOn() diff --git a/variants/lilygo_tbeam_supreme_SX1262/platformio.ini b/variants/lilygo_tbeam_supreme_SX1262/platformio.ini index b930a25b9..8bfc4093a 100644 --- a/variants/lilygo_tbeam_supreme_SX1262/platformio.ini +++ b/variants/lilygo_tbeam_supreme_SX1262/platformio.ini @@ -18,6 +18,7 @@ build_flags = -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D DISPLAY_CLASS=SH1106Display + -D DISPLAY_ADDRESS=0x3D -D LORA_TX_POWER=22 -D P_LORA_TX_LED=6 -D PIN_BOARD_SDA=17 @@ -142,10 +143,6 @@ lib_deps = ${T_Beam_S3_Supreme_SX1262.lib_deps} densaugeo/base64 @ ~1.4.0 -[env:T_Beam_S3_Supreme_SX1262_companion_radio_ble_ps] -extends = env:T_Beam_S3_Supreme_SX1262_companion_radio_ble -platform_packages = framework-arduinoespressif32 @ symlink://D:/esp32-2.0.17 - [env:T_Beam_S3_Supreme_SX1262_companion_radio_wifi] extends = T_Beam_S3_Supreme_SX1262 build_flags = From a2fe2ea642ad07c7adaa9c45d8ab247907431beb Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Thu, 23 Jul 2026 12:35:43 +0700 Subject: [PATCH 6/7] Added T_Beam_S3_Supreme_SX1262_companion_radio_ble_ps --- variants/lilygo_tbeam_supreme_SX1262/platformio.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/variants/lilygo_tbeam_supreme_SX1262/platformio.ini b/variants/lilygo_tbeam_supreme_SX1262/platformio.ini index 8bfc4093a..2801b8d6e 100644 --- a/variants/lilygo_tbeam_supreme_SX1262/platformio.ini +++ b/variants/lilygo_tbeam_supreme_SX1262/platformio.ini @@ -143,6 +143,10 @@ lib_deps = ${T_Beam_S3_Supreme_SX1262.lib_deps} densaugeo/base64 @ ~1.4.0 +[env:T_Beam_S3_Supreme_SX1262_companion_radio_ble_ps] +extends = env:T_Beam_S3_Supreme_SX1262_companion_radio_ble +platform_packages = framework-arduinoespressif32 @ symlink://D:/esp32-2.0.17 + [env:T_Beam_S3_Supreme_SX1262_companion_radio_wifi] extends = T_Beam_S3_Supreme_SX1262 build_flags = From 0cc580afec363aab20608528abd847afb271285b Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Thu, 23 Jul 2026 23:21:41 +0700 Subject: [PATCH 7/7] GPS PowerSaving 1.4: Added GPS PowerSaving for Seeed T1000e, Heltec Mesh Solar and Heltec Tracker. Not supported: Mesh Adventurer (unable to off GPS power) and ThinkNode M1 (manual GPS switch). --- build-iotthinks.sh | 61 +++++++++++++++++++ variants/heltec_mesh_solar/target.cpp | 74 ++++++++++++++++++++--- variants/heltec_mesh_solar/target.h | 1 + variants/heltec_tracker/target.cpp | 74 ++++++++++++++++++++--- variants/heltec_tracker/target.h | 1 + variants/t1000-e/target.cpp | 84 +++++++++++++++++++++++---- variants/t1000-e/target.h | 1 + 7 files changed, 268 insertions(+), 28 deletions(-) diff --git a/build-iotthinks.sh b/build-iotthinks.sh index 613789d08..535c202a2 100644 --- a/build-iotthinks.sh +++ b/build-iotthinks.sh @@ -133,3 +133,64 @@ Xiao_C6_companion_radio_ble_ \ RAK_4631_companion_radio_ble \ Heltec_t096_companion_radio_ble \ Heltec_t096_companion_radio_ble_femoff + +############# GPS PowerSaving ############# +export FIRMWARE_VERSION="PowerSaving16.1.1" +sh build.sh build-firmware \ +heltec_v4_repeater \ +Heltec_t114_repeater \ +Heltec_t096_repeater \ +WioTrackerL1_repeater \ +LilyGo_T-Echo_repeater \ +Station_G2_repeater \ +Heltec_Wireless_Tracker_repeater \ +heltec_tracker_v2_repeater \ +Heltec_mesh_solar_repeater \ +SenseCap_Solar_repeater + +sh build.sh build-firmware \ +Heltec_t114_companion_radio_ble \ +t1000e_companion_radio_ble \ +LilyGo_T-Echo_companion_radio_ble \ +WioTrackerL1_companion_radio_ble \ +SenseCap_Solar_companion_radio_ble \ +Heltec_t096_companion_radio_ble \ +Heltec_t096_companion_radio_ble_femoff \ +heltec_v4_companion_radio_ble_ps \ +heltec_v4_3_companion_radio_ble_ps_femoff \ +LilyGo_TBeam_1W_companion_radio_ble_ps \ +Heltec_Wireless_Tracker_companion_radio_ble_ps \ +heltec_tracker_v2_companion_radio_ble_ps \ +T_Beam_S3_Supreme_SX1262 \ +Tbeam_SX1262_companion_radio_ble_ps \ +heltec_v4_expansionkit_tft_companion_radio_ble_ps + +export FIRMWARE_VERSION="PowerSaving16.1.2" +sh build.sh build-firmware \ +RAK_4631_repeater \ +RAK_3401_repeater \ +RAK_WisMesh_Tag_repeater \ +GAT562_30S_Mesh_Kit_repeater \ +GAT562_Mesh_Tracker_Pro_repeater \ +RAK_4631_companion_radio_ble \ +RAK_3401_companion_radio_ble \ +RAK_WisMesh_Tag_companion_radio_ble + +export FIRMWARE_VERSION="PowerSaving16.1.2" +sh build.sh build-firmware \ +Tbeam_SX1262_repeater \ +T_Beam_S3_Supreme_SX1262_repeater \ +LilyGo_TBeam_1W_repeater \ +Tbeam_SX1262_companion_radio_ble_ps \ +T_Beam_S3_Supreme_SX1262_companion_radio_ble_ps \ +LilyGo_TBeam_1W_companion_radio_ble_ps + +export FIRMWARE_VERSION="PowerSaving16.1.2" +sh build.sh build-firmware \ +t1000e_repeater \ +t1000e_companion_radio_ble \ +Heltec_mesh_solar_repeater \ +Heltec_mesh_solar_companion_radio_ble \ +Heltec_Wireless_Tracker_repeater \ +Heltec_Wireless_Tracker_companion_radio_ble_ps \ + diff --git a/variants/heltec_mesh_solar/target.cpp b/variants/heltec_mesh_solar/target.cpp index d140864cd..256b70a7c 100644 --- a/variants/heltec_mesh_solar/target.cpp +++ b/variants/heltec_mesh_solar/target.cpp @@ -31,13 +31,28 @@ mesh::LocalIdentity radio_new_identity() { void SolarSensorManager::start_gps() { if (!gps_active) { gps_active = true; + + if (powersaving_enabled && _location->isPowerSavingEnabled()) { + gps_wake = true; // gps_active is true + _location->syncTime(); // Clear GPS data and force sync time + _location->setNextSleep(); // Next time to off + } + _location->begin(); } } void SolarSensorManager::stop_gps() { if (gps_active) { - gps_active = false; + if (powersaving_enabled && _location->isPowerSavingEnabled()) { + gps_wake = false; // gps_active is unchanged (true) even the GPS sleep (e.g: off) + _location->stopTimeSync(); // Stop time sync + _location->setNextWake(); // Next time to on + } else { + gps_active = false; + gps_wake = false; // When GPS is off, wake is false to be sure + } + _location->stop(); } } @@ -67,16 +82,49 @@ bool SolarSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& void SolarSensorManager::loop() { static long next_gps_update = 0; - _location->loop(); + // PowerSaving + if (powersaving_enabled) { + if (gps_detected && _location->isPowerSavingEnabled()) { + if (gps_wake && ((int32_t)(millis() - _location->getNextSleep()) >= 0 || + !_location->waitingTimeSync())) { // Time to off or GPS set + if ((int32_t)(millis() - _location->getNextSleep()) >= 0) { + POWERSAVING_DEBUG_PRINTLN("GPS wake timeout. Enter sleep"); + } else if (!_location->waitingTimeSync()) { + POWERSAVING_DEBUG_PRINTLN("GPS set. Enter sleep early"); + } - if (millis() > next_gps_update) { - if (_location->isValid()) { - node_lat = ((double)_location->getLatitude())/1000000.; - node_lon = ((double)_location->getLongitude())/1000000.; - node_altitude = ((double)_location->getAltitude()) / 1000.0; - MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); + stop_gps(); + } else if (!gps_wake && ((int32_t)(millis() - _location->getNextWake()) >= 0)) { // Time to on + POWERSAVING_DEBUG_PRINTLN("GPS sleep timeout. Wakeup."); + + start_gps(); + } else if (!gps_wake && _location->waitingTimeSync()) { // On for "gps sync" + POWERSAVING_DEBUG_PRINTLN("CLI gps sync. Wakeup"); + + start_gps(); + } } - next_gps_update = millis() + 1000; + } + + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { + _location->loop(); + } + + if ((int32_t)(millis() - next_gps_update) >= 0) { + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { + if (_location->isValid()) { + node_lat = ((double)_location->getLatitude()) / 1000000.; + node_lon = ((double)_location->getLongitude()) / 1000000.; + MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); + node_altitude = ((double)_location->getAltitude()) / 1000.0; + MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude); + } + + // In powersaving mode, GPS is on and off. Only update data when GPS is on + if (powersaving_enabled) next_gps_update = millis() + 1000; + } + + if (!powersaving_enabled) next_gps_update = millis() + 1000; } } @@ -98,8 +146,16 @@ const char* SolarSensorManager::getSettingValue(int i) const { bool SolarSensorManager::setSettingValue(const char* name, const char* value) { if (gps_detected && strcmp(name, "gps") == 0) { if (strcmp(value, "0") == 0) { + if (powersaving_enabled) { + _location->enablePowerSaving(false); + } + stop_gps(); } else { + if (powersaving_enabled) { + _location->enablePowerSaving(true); + } + start_gps(); } return true; diff --git a/variants/heltec_mesh_solar/target.h b/variants/heltec_mesh_solar/target.h index 1956f50eb..13c7a55c3 100644 --- a/variants/heltec_mesh_solar/target.h +++ b/variants/heltec_mesh_solar/target.h @@ -15,6 +15,7 @@ class SolarSensorManager : public SensorManager { bool gps_active = false; bool gps_detected = false; + bool gps_wake = false; // In PowerSaving, gps_active can have gps_wake true or false LocationProvider* _location; void start_gps(); diff --git a/variants/heltec_tracker/target.cpp b/variants/heltec_tracker/target.cpp index f32c41ff4..c51da013c 100644 --- a/variants/heltec_tracker/target.cpp +++ b/variants/heltec_tracker/target.cpp @@ -46,13 +46,28 @@ void HWTSensorManager::start_gps() { if (!gps_active) { _location->begin(); // Claims periph_power via RefCountedDigitalPin gps_active = true; + + if (powersaving_enabled && _location->isPowerSavingEnabled()) { + gps_wake = true; // gps_active is true + _location->syncTime(); // Clear GPS data and force sync time + _location->setNextSleep(); // Next time to off + } + Serial1.println("$CFGSYS,h35155*68"); // Configure GPS for all constellations } } void HWTSensorManager::stop_gps() { if (gps_active) { - gps_active = false; + if (powersaving_enabled && _location->isPowerSavingEnabled()) { + gps_wake = false; // gps_active is unchanged (true) even the GPS sleep (e.g: off) + _location->stopTimeSync(); // Stop time sync + _location->setNextWake(); // Next time to on + } else { + gps_active = false; + gps_wake = false; // When GPS is off, wake is false to be sure + } + _location->stop(); // Releases periph_power via RefCountedDigitalPin } } @@ -73,16 +88,49 @@ bool HWTSensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& t void HWTSensorManager::loop() { static long next_gps_update = 0; - _location->loop(); + // PowerSaving + if (powersaving_enabled) { + if (_location->isPowerSavingEnabled()) { + if (gps_wake && ((int32_t)(millis() - _location->getNextSleep()) >= 0 || + !_location->waitingTimeSync())) { // Time to off or GPS set + if ((int32_t)(millis() - _location->getNextSleep()) >= 0) { + POWERSAVING_DEBUG_PRINTLN("GPS wake timeout. Enter sleep"); + } else if (!_location->waitingTimeSync()) { + POWERSAVING_DEBUG_PRINTLN("GPS set. Enter sleep early"); + } - if (millis() > next_gps_update) { - if (gps_active && _location->isValid()) { - node_lat = ((double)_location->getLatitude())/1000000.; - node_lon = ((double)_location->getLongitude())/1000000.; - node_altitude = ((double)_location->getAltitude()) / 1000.0; - MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); + stop_gps(); + } else if (!gps_wake && ((int32_t)(millis() - _location->getNextWake()) >= 0)) { // Time to on + POWERSAVING_DEBUG_PRINTLN("GPS sleep timeout. Wakeup."); + + start_gps(); + } else if (!gps_wake && _location->waitingTimeSync()) { // On for "gps sync" + POWERSAVING_DEBUG_PRINTLN("CLI gps sync. Wakeup"); + + start_gps(); + } } - next_gps_update = millis() + 1000; + } + + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { + _location->loop(); + } + + if ((int32_t)(millis() - next_gps_update) >= 0) { + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { + if (_location->isValid()) { + node_lat = ((double)_location->getLatitude()) / 1000000.; + node_lon = ((double)_location->getLongitude()) / 1000000.; + MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); + node_altitude = ((double)_location->getAltitude()) / 1000.0; + MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude); + } + + // In powersaving mode, GPS is on and off. Only update data when GPS is on + if (powersaving_enabled) next_gps_update = millis() + 1000; + } + + if (!powersaving_enabled) next_gps_update = millis() + 1000; } } @@ -100,8 +148,16 @@ const char* HWTSensorManager::getSettingValue(int i) const { bool HWTSensorManager::setSettingValue(const char* name, const char* value) { if (strcmp(name, "gps") == 0) { if (strcmp(value, "0") == 0) { + if (powersaving_enabled) { + _location->enablePowerSaving(false); + } + stop_gps(); } else { + if (powersaving_enabled) { + _location->enablePowerSaving(true); + } + start_gps(); } return true; diff --git a/variants/heltec_tracker/target.h b/variants/heltec_tracker/target.h index 2931eda81..0fe3d0251 100644 --- a/variants/heltec_tracker/target.h +++ b/variants/heltec_tracker/target.h @@ -15,6 +15,7 @@ class HWTSensorManager : public SensorManager { bool gps_active = false; + bool gps_wake = false; // In PowerSaving, gps_active can have gps_wake true or false LocationProvider * _location; void start_gps(); diff --git a/variants/t1000-e/target.cpp b/variants/t1000-e/target.cpp index 425328270..99c9be29a 100644 --- a/variants/t1000-e/target.cpp +++ b/variants/t1000-e/target.cpp @@ -81,6 +81,13 @@ mesh::LocalIdentity radio_new_identity() { void T1000SensorManager::start_gps() { gps_active = true; + + if (powersaving_enabled && _nmea->isPowerSavingEnabled()) { + gps_wake = true; // gps_active is true + _nmea->syncTime(); // Clear GPS data and force sync time + _nmea->setNextSleep(); // Next time to off + } + //_nmea->begin(); // this init sequence should be better // comes from seeed examples and deals with all gps pins @@ -104,7 +111,15 @@ void T1000SensorManager::start_gps() { } void T1000SensorManager::sleep_gps() { - gps_active = false; + if (powersaving_enabled && _nmea->isPowerSavingEnabled()) { + gps_wake = false; // gps_active is unchanged (true) even the GPS sleep (e.g: off) + _nmea->stopTimeSync(); // Stop time sync + _nmea->setNextWake(); // Next time to on + } else { + gps_active = false; + gps_wake = false; // When GPS is off, wake is false to be sure + } + digitalWrite(GPS_VRTC_EN, HIGH); digitalWrite(GPS_EN, LOW); digitalWrite(GPS_RESET, HIGH); @@ -116,7 +131,15 @@ void T1000SensorManager::sleep_gps() { } void T1000SensorManager::stop_gps() { - gps_active = false; + if (powersaving_enabled && _nmea->isPowerSavingEnabled()) { + gps_wake = false; // gps_active is unchanged (true) even the GPS sleep (e.g: off) + _nmea->stopTimeSync(); // Stop time sync + _nmea->setNextWake(); // Next time to on + } else { + gps_active = false; + gps_wake = false; // When GPS is off, wake is false to be sure + } + digitalWrite(GPS_VRTC_EN, LOW); digitalWrite(GPS_EN, LOW); digitalWrite(GPS_RESET, HIGH); @@ -149,16 +172,49 @@ bool T1000SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& void T1000SensorManager::loop() { static long next_gps_update = 0; - _nmea->loop(); + // PowerSaving + if (powersaving_enabled) { + if (_nmea->isPowerSavingEnabled()) { + if (gps_wake && ((int32_t)(millis() - _nmea->getNextSleep()) >= 0 || + !_nmea->waitingTimeSync())) { // Time to off or GPS set + if ((int32_t)(millis() - _nmea->getNextSleep()) >= 0) { + POWERSAVING_DEBUG_PRINTLN("GPS wake timeout. Enter sleep"); + } else if (!_nmea->waitingTimeSync()) { + POWERSAVING_DEBUG_PRINTLN("GPS set. Enter sleep early"); + } - if (millis() > next_gps_update) { - if (gps_active && _nmea->isValid()) { - node_lat = ((double)_nmea->getLatitude())/1000000.; - node_lon = ((double)_nmea->getLongitude())/1000000.; - node_altitude = ((double)_nmea->getAltitude()) / 1000.0; - //Serial.printf("lat %f lon %f\r\n", _lat, _lon); + stop_gps(); + } else if (!gps_wake && ((int32_t)(millis() - _nmea->getNextWake()) >= 0)) { // Time to on + POWERSAVING_DEBUG_PRINTLN("GPS sleep timeout. Wakeup."); + + start_gps(); + } else if (!gps_wake && _nmea->waitingTimeSync()) { // On for "gps sync" + POWERSAVING_DEBUG_PRINTLN("CLI gps sync. Wakeup"); + + start_gps(); + } } - next_gps_update = millis() + 1000; + } + + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { + _nmea->loop(); + } + + if ((int32_t)(millis() - next_gps_update) >= 0) { + if ((!powersaving_enabled && gps_active) || (powersaving_enabled && gps_wake)) { + if (_nmea->isValid()) { + node_lat = ((double)_nmea->getLatitude()) / 1000000.; + node_lon = ((double)_nmea->getLongitude()) / 1000000.; + MESH_DEBUG_PRINTLN("lat %f lon %f", node_lat, node_lon); + node_altitude = ((double)_nmea->getAltitude()) / 1000.0; + MESH_DEBUG_PRINTLN("lat %f lon %f alt %f", node_lat, node_lon, node_altitude); + } + + // In powersaving mode, GPS is on and off. Only update data when GPS is on + if (powersaving_enabled) next_gps_update = millis() + 1000; + } + + if (!powersaving_enabled) next_gps_update = millis() + 1000; } } @@ -176,8 +232,16 @@ const char* T1000SensorManager::getSettingValue(int i) const { bool T1000SensorManager::setSettingValue(const char* name, const char* value) { if (strcmp(name, "gps") == 0) { if (strcmp(value, "0") == 0) { + if (powersaving_enabled) { + _nmea->enablePowerSaving(false); + } + sleep_gps(); // sleep for faster fix ! } else { + if (powersaving_enabled) { + _nmea->enablePowerSaving(true); + } + start_gps(); } return true; diff --git a/variants/t1000-e/target.h b/variants/t1000-e/target.h index db003cc5f..cd91ceec9 100644 --- a/variants/t1000-e/target.h +++ b/variants/t1000-e/target.h @@ -14,6 +14,7 @@ class T1000SensorManager: public SensorManager { bool gps_active = false; + bool gps_wake = false; // In PowerSaving, gps_active can have gps_wake true or false LocationProvider * _nmea; void start_gps();