From 860283aff19c689d4c744d873cb1b08984f8c1b5 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Thu, 27 Dec 2018 20:35:05 +1300 Subject: [PATCH 1/5] Forcing sim808 to powerOff before deep sleep regardless of the current state --- src/MainUnit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MainUnit.cpp b/src/MainUnit.cpp index 37b51df..892e2cd 100644 --- a/src/MainUnit.cpp +++ b/src/MainUnit.cpp @@ -13,7 +13,9 @@ namespace mainunit { namespace details { void prepareSleep() { + hardware::sim808::powerOff(); //forcing power off, regardless of the counts and current use hardware::sim808::simSerial.end(); //avoid woke up by SoftwareSerial interrupt + delay(5); //ensure log messages have been printed out } @@ -44,8 +46,8 @@ namespace mainunit { #define CURRENT_LOGGER_FUNCTION "deepSleep" NOTICE_FORMAT("%ds", seconds); - interruptIn(seconds); details::prepareSleep(); + interruptIn(seconds); LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); details::wokeUp(); } From 303d8edf07f79e2620d07c2be4f737723e159de1 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Thu, 27 Dec 2018 20:36:34 +1300 Subject: [PATCH 2/5] Force INT1 clear before setting alarm --- src/MainUnit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MainUnit.cpp b/src/MainUnit.cpp index 892e2cd..69f2c0a 100644 --- a/src/MainUnit.cpp +++ b/src/MainUnit.cpp @@ -36,9 +36,10 @@ namespace mainunit { } void interruptIn(uint16_t seconds) { - rtc::setAlarm(seconds); - pinMode(RTC_WAKE, INPUT); + + EIFR |= 1 << INTF1; //forcing interrupt clear as sometimes, it does not seems to work (1 second appart positions) + rtc::setAlarm(seconds); attachInterrupt(digitalPinToInterrupt(RTC_WAKE), interrupt, FALLING); } From 22b5d0cd7ed63e20f194746a0050d9e9d5a743ee Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Thu, 27 Dec 2018 20:48:12 +1300 Subject: [PATCH 3/5] Version bump to 1.43 --- src/config/System.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/System.h b/src/config/System.h index 5fc3938..61fb742 100644 --- a/src/config/System.h +++ b/src/config/System.h @@ -3,7 +3,7 @@ #define CONFIG_ADDR 0 ///< Address of the config block in the I2C EEPROM chip. #define CONFIG_RESERVED_SIZE 128 ///< Reserved size for the config block in the I2C EEPROM chip. #define CONFIG_SEED 14 ///< Seed use to detect invalid or outdate configuration data. -#define VERSION "1.42" /// Version string, only used for indicative purpose. +#define VERSION "1.43" /// Version string, only used for indicative purpose. /** From f6bebe22658c7e54930fc1cee450b98390212fee Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Thu, 27 Dec 2018 20:53:10 +1300 Subject: [PATCH 4/5] Revert "Forcing sim808 to powerOff before deep sleep regardless of the current state". Sim808 is used during deepsleep (eg acquiring gps) This reverts commit ae9a4f318e0ce4b3c984f5b675ac91e6455583d4. --- src/MainUnit.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/MainUnit.cpp b/src/MainUnit.cpp index 69f2c0a..0f705ed 100644 --- a/src/MainUnit.cpp +++ b/src/MainUnit.cpp @@ -13,9 +13,7 @@ namespace mainunit { namespace details { void prepareSleep() { - hardware::sim808::powerOff(); //forcing power off, regardless of the counts and current use hardware::sim808::simSerial.end(); //avoid woke up by SoftwareSerial interrupt - delay(5); //ensure log messages have been printed out } @@ -47,8 +45,8 @@ namespace mainunit { #define CURRENT_LOGGER_FUNCTION "deepSleep" NOTICE_FORMAT("%ds", seconds); - details::prepareSleep(); interruptIn(seconds); + details::prepareSleep(); LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); details::wokeUp(); } From e114208fbcc4b7fe2a0d6508e7f15af4f87345a4 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Thu, 27 Dec 2018 20:54:15 +1300 Subject: [PATCH 5/5] Forcing sim808 powerOff on main loop --- src/Core.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Core.cpp b/src/Core.cpp index 8d83215..1a96126 100644 --- a/src/Core.cpp +++ b/src/Core.cpp @@ -61,6 +61,8 @@ namespace core { } if (acquired) updateRtcTime(); + + hardware::sim808::powerOff(); //forcing power off, regardless of the counts and current use mainunit::deepSleep(sleepTime); }