diff --git a/src/tracker.cpp b/src/tracker.cpp index d20e7a7..b6a16b2 100644 --- a/src/tracker.cpp +++ b/src/tracker.cpp @@ -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 @@ -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); @@ -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(); diff --git a/src/tracker.h b/src/tracker.h index 28b3929..48676df 100644 --- a/src/tracker.h +++ b/src/tracker.h @@ -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 * @@ -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 *