Hello,
I have a weird issue/bug where I use the following code for sleeping (I have a hall effect sensor that can wake the device up prematurely from sleep):
/**
Sleep function between measurements
@param measurementDelay The time it takes to conduct a measurement
@param networkStandby Whether the device should put modem on standby during sleep
*/
void Class:measurementSleep(int measurementDelay, std::chrono::seconds measurementSleepTime, bool hallEnabled)
{
Class::instance().setPanicCode(234);
// Initialize Power Configuration
SystemSleepConfiguration measurementSleepConfig;
// Power Configuration using ULTRA_LOW_POWER, HALL_PIN for restart and compensated sleep duration - SystemSleepMode::ULTRA_LOW_POWER
measurementSleepConfig.mode(SystemSleepMode::ULTRA_LOW_POWER).duration(Class::instance().getCompensatedSleepTime(measurementDelay, measurementSleepTime));
Class::instance().setPanicCode(239);
if (hallEnabled)
{
measurementSleepConfig.gpio(IOConstants::HALL_PIN, CHANGE);
}
Class::instance().setPanicCode(244);
// Handle network standby for cellular interface based on constants or time limit
if (Class::instance().getNetworkStandby()) // (measurementSleepTime.count() * Class::instance().getNumberOfMeasurements()) < CloudConstants::NETWORK_STANDBY_LIMIT)
{
Class::instance().setPanicCode(248);
classLogger.info("Setting network to standby");
measurementSleepConfig.network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY);
}
Class::instance().setPanicCode(25200);
// Do one last system/watchdog checkin
Class::instance().systemCheckin();
// Execute SystemSleepConfiguration and enter sleep
SystemSleepResult result = System.sleep(measurementSleepConfig);
Class::instance().setPanicCode(256);
// If device was woken up due to hall effect being triggered
if (result.wakeupReason() == SystemSleepWakeupReason::BY_GPIO)
{
Class::instance().setPanicCode(260);
delay(500);
classLogger.info("Device was woken up by hall effect sensor");
// Hall sensor was triggered during sleep, so let's restart!
System.reset(RESET_APP_ENUM::HALL_MEASUREMENT_SLEEP, RESET_NO_WAIT);
}
Class::instance().setPanicCode(264);
}
I have the device hooked up to my computer, so I can see that the serial monitor suddenly opens up, but the device doesn't progress with any other tasks, it simply 'hangs'/freezes until the watchdog timer triggers and the device resets, whereas I get the following event:
HALL_MEASUREMENT_SLEEP_25200
or
HARDWARE_WATCHDOG_25200
Which means that the device was reset due to the hall effect sensor or watchdog being triggered when sleeping and the last panic code being set is 25200 (the code just before the System.sleep command), which means it doesn't run the following code:
// If device was woken up due to hall effect being triggered
if (result.wakeupReason() == SystemSleepWakeupReason::BY_GPIO)
{
Class::instance().setPanicCode(260);
delay(500);
classLogger.info("Device was woken up by hall effect sensor");
// Hall sensor was triggered during sleep, so let's restart!
System.reset(RESET_APP_ENUM::HALL_MEASUREMENT_SLEEP, RESET_NO_WAIT);
}
It freezes right after it wakes up, and not even the line after SystemSleepResult result = System.sleep(measurementSleepConfig); is executed.
I have no idea what is happening, this is happening on both DeviceOS 5.3.2 and DeviceOS 5.5.0