Skip to content

Commit

Permalink
Additional GNSS IO shutdown to save battery power during shipping mode
Browse files Browse the repository at this point in the history
  • Loading branch information
eberseth committed Sep 23, 2024
1 parent 09cc349 commit 3721575
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ void Tracker::enableIoCanPower(bool enable)
digitalWrite(MCP_CAN_PWR_EN_PIN, (_canPowerEnabled = enable) ? HIGH : LOW);
}

void Tracker::forceShutdownGnss()
{
// Forceably shutdown the GNSS module
digitalWrite(UBLOX_RESETN_PIN, LOW);
delay(100);
digitalWrite(UBLOX_RESETN_PIN, HIGH);
digitalWrite(UBLOX_PWR_EN_PIN, LOW);
}

int Tracker::initEsp32()
{
// ESP32 related GPIO
Expand Down Expand Up @@ -640,7 +649,7 @@ int Tracker::init()

shipping.init();
shipping.regShutdownBeginCallback(std::bind(&Tracker::stop, this));
shipping.regShutdownIoCallback(std::bind(&Tracker::end, this));
shipping.regShutdownIoCallback(std::bind(&Tracker::shutdown, this));
shipping.regShutdownFinalCallback(
[this](){
enableWatchdog(false);
Expand Down Expand Up @@ -752,6 +761,12 @@ int Tracker::end() {
return SYSTEM_ERROR_NONE;
}

int Tracker::shutdown() {
end();
forceShutdownGnss();
return SYSTEM_ERROR_NONE;
}

int Tracker::reset() {
stop();
end();
Expand Down
15 changes: 14 additions & 1 deletion src/tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,19 @@ class Tracker {
int stop();

/**
* @brief Prepare tracker IO and peripherals for shutdown
* @brief Prepare tracker IO and peripherals for low power
*
* @retval SYSTEM_ERROR_NONE
*/
int end();

/**
* @brief Prepare tracker IO and peripherals for shutdown
*
* @retval SYSTEM_ERROR_NONE
*/
int shutdown();

/**
* @brief Prepare tracker for reset and issue
*
Expand Down Expand Up @@ -388,6 +395,12 @@ class Tracker {
*/
void enableIoCanPower(bool enable);

/**
* @brief Force the GNSS module into low power state
*
*/
void forceShutdownGnss();

/**
* @brief Indicates whether device can accept commands through USB interface
*
Expand Down

0 comments on commit 3721575

Please sign in to comment.