@@ -60,6 +60,7 @@ static volatile bool ring_line_activity = false;
6060static volatile bool modem_is_in_power_save = false ;
6161static volatile bool pit_triggered = false ;
6262
63+ static SleepMode sleep_mode;
6364static bool retrieved_sleep_time = false ;
6465static uint32_t sleep_time = 0 ;
6566
@@ -278,7 +279,7 @@ static void disablePIT(void) {
278279/* *
279280 * Modem sleeping and CPU deep sleep.
280281 */
281- static SleepStatusCode regularSleep (void ) {
282+ static WakeUpReason regularSleep (void ) {
282283
283284 const unsigned long start_time_ms = millis ();
284285
@@ -288,7 +289,7 @@ static SleepStatusCode regularSleep(void) {
288289 sleep_time = retrieveOperatorSleepTime ();
289290
290291 if (sleep_time == 0 ) {
291- return SleepStatusCode ::INVALID_SLEEP_TIME;
292+ return WakeUpReason ::INVALID_SLEEP_TIME;
292293 } else {
293294 retrieved_sleep_time = true ;
294295 }
@@ -301,18 +302,18 @@ static SleepStatusCode regularSleep(void) {
301302 // If we surpassed the sleep time during setting the LTE to sleep, we
302303 // don't have any more time to sleep the CPU, so just return.
303304 if (millis () - start_time_ms >= sleep_time * 1000 ) {
304- return SleepStatusCode::TIMEOUT ;
305+ return WakeUpReason::MODEM_TIMEOUT ;
305306 }
306307
307308 enablePIT ();
308309
309310 uint32_t remaining_time_seconds =
310311 sleep_time - (uint32_t )(((millis () - start_time_ms) / 1000 .0f ));
311312
312- SleepStatusCode status_code = SleepStatusCode ::OK;
313+ WakeUpReason wakeup_reason = WakeUpReason ::OK;
313314
314315 if (remaining_time_seconds < 0 ) {
315- status_code = SleepStatusCode::TIMEOUT ;
316+ wakeup_reason = WakeUpReason::MODEM_TIMEOUT ;
316317 }
317318
318319 // As the PIT timer has a minimum frequency of 1 Hz, we loop over the
@@ -332,10 +333,10 @@ static SleepStatusCode regularSleep(void) {
332333 if (!modem_is_in_power_save) {
333334
334335 if (remaining_time_seconds < PSM_REMAINING_SLEEP_TIME_THRESHOLD) {
335- status_code = SleepStatusCode ::OK;
336+ wakeup_reason = WakeUpReason ::OK;
336337 break ;
337338 } else {
338- status_code = SleepStatusCode ::AWOKEN_BY_MODEM_PREMATURELY;
339+ wakeup_reason = WakeUpReason ::AWOKEN_BY_MODEM_PREMATURELY;
339340 break ;
340341 }
341342 }
@@ -348,13 +349,13 @@ static SleepStatusCode regularSleep(void) {
348349
349350 disablePIT ();
350351
351- return status_code ;
352+ return wakeup_reason ;
352353}
353354
354355/* *
355356 * Modem turned off and CPU deep sleep.
356357 */
357- static SleepStatusCode deepSleep (void ) {
358+ static WakeUpReason deepSleep (void ) {
358359
359360 const unsigned long start_time_ms = millis ();
360361
@@ -382,11 +383,14 @@ static SleepStatusCode deepSleep(void) {
382383
383384 Lte.begin ();
384385
385- return SleepStatusCode ::OK;
386+ return WakeUpReason ::OK;
386387}
387388
388389bool LowPowerClass::begin (const SleepMultiplier sleep_multiplier,
389- const uint8_t sleep_value) {
390+ const uint8_t sleep_value,
391+ const SleepMode mode) {
392+
393+ sleep_mode = mode;
390394
391395 // Reset in case there is a reconfiguration after sleep has been called
392396 // previously
@@ -448,13 +452,13 @@ bool LowPowerClass::begin(const SleepMultiplier sleep_multiplier,
448452 return SequansController.retryCommand (command);
449453}
450454
451- SleepStatusCode LowPowerClass::sleep (const SleepMode sleep_mode ) {
455+ WakeUpReason LowPowerClass::sleep (void ) {
452456 switch (sleep_mode) {
453457 case SleepMode::REGULAR:
454458 return regularSleep ();
455459 case SleepMode::DEEP:
456460 return deepSleep ();
457461 }
458462
459- return SleepStatusCode ::OK;
463+ return WakeUpReason ::OK;
460464}
0 commit comments