Skip to content

Commit 3721575

Browse files
Eric Bersetheberseth
Eric Berseth
authored andcommitted
Additional GNSS IO shutdown to save battery power during shipping mode
1 parent 09cc349 commit 3721575

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/tracker.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ void Tracker::enableIoCanPower(bool enable)
168168
digitalWrite(MCP_CAN_PWR_EN_PIN, (_canPowerEnabled = enable) ? HIGH : LOW);
169169
}
170170

171+
void Tracker::forceShutdownGnss()
172+
{
173+
// Forceably shutdown the GNSS module
174+
digitalWrite(UBLOX_RESETN_PIN, LOW);
175+
delay(100);
176+
digitalWrite(UBLOX_RESETN_PIN, HIGH);
177+
digitalWrite(UBLOX_PWR_EN_PIN, LOW);
178+
}
179+
171180
int Tracker::initEsp32()
172181
{
173182
// ESP32 related GPIO
@@ -640,7 +649,7 @@ int Tracker::init()
640649

641650
shipping.init();
642651
shipping.regShutdownBeginCallback(std::bind(&Tracker::stop, this));
643-
shipping.regShutdownIoCallback(std::bind(&Tracker::end, this));
652+
shipping.regShutdownIoCallback(std::bind(&Tracker::shutdown, this));
644653
shipping.regShutdownFinalCallback(
645654
[this](){
646655
enableWatchdog(false);
@@ -752,6 +761,12 @@ int Tracker::end() {
752761
return SYSTEM_ERROR_NONE;
753762
}
754763

764+
int Tracker::shutdown() {
765+
end();
766+
forceShutdownGnss();
767+
return SYSTEM_ERROR_NONE;
768+
}
769+
755770
int Tracker::reset() {
756771
stop();
757772
end();

src/tracker.h

+14-1
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,19 @@ class Tracker {
314314
int stop();
315315

316316
/**
317-
* @brief Prepare tracker IO and peripherals for shutdown
317+
* @brief Prepare tracker IO and peripherals for low power
318318
*
319319
* @retval SYSTEM_ERROR_NONE
320320
*/
321321
int end();
322322

323+
/**
324+
* @brief Prepare tracker IO and peripherals for shutdown
325+
*
326+
* @retval SYSTEM_ERROR_NONE
327+
*/
328+
int shutdown();
329+
323330
/**
324331
* @brief Prepare tracker for reset and issue
325332
*
@@ -388,6 +395,12 @@ class Tracker {
388395
*/
389396
void enableIoCanPower(bool enable);
390397

398+
/**
399+
* @brief Force the GNSS module into low power state
400+
*
401+
*/
402+
void forceShutdownGnss();
403+
391404
/**
392405
* @brief Indicates whether device can accept commands through USB interface
393406
*

0 commit comments

Comments
 (0)