22
22
Iot iot;
23
23
static const char *tag = " iot" ;
24
24
25
- RTC_DATA_ATTR static int32_t rtcBootCount;
26
- RTC_DATA_ATTR static int64_t rtcActiveDuration_ms;
27
- RTC_DATA_ATTR static int32_t rtcLastSleepDuration_s;
28
- RTC_DATA_ATTR static int64_t rtcNtpLastSyncTime;
29
- RTC_DATA_ATTR static int32_t rtcPanicSleepDuration_s;
25
+ RTC_DATA_ATTR static int32_t rtcBootCount = 0 ;
26
+ RTC_DATA_ATTR static int64_t rtcActiveDuration_ms = 0 ;
27
+ RTC_DATA_ATTR static int32_t rtcLastSleepDuration_s = 0 ;
28
+ RTC_DATA_ATTR static int64_t rtcNtpLastSyncTime = 0 ;
29
+ RTC_DATA_ATTR static int32_t rtcPanicSleepDuration_s = - 1 ;
30
30
31
31
static void defaultPanicHandler ()
32
32
{
@@ -78,12 +78,12 @@ Iot::Iot() :
78
78
79
79
// startup logging
80
80
log_i (" --- Bootup #%lu, cause %d after %d s, panicSleepDuration=%d s" ,
81
- getBootCount (), (int )getWakeupCause (), getLastSleepDuration_s (), _panicSleepDuration_s );
81
+ getBootCount (), (int )getWakeupCause (), getLastSleepDuration_s (), getPanicSleepDuration_s () );
82
82
if (WiFi.status () == WL_CONNECTED)
83
83
{
84
- if (_panicSleepDuration_s >= 0 )
84
+ if (getPanicSleepDuration_s () >= 0 )
85
85
{
86
- log_i (" *** LAST STARTUP WAS A PANIC, panicSpeepDuration=%d s" , _panicSleepDuration_s );
86
+ log_i (" *** LAST STARTUP WAS A PANIC, panicSpeepDuration=%d s" , getPanicSleepDuration_s () );
87
87
}
88
88
}
89
89
log_i (" --- Firmware %s" , getFirmwareVersion ().c_str ());
@@ -392,18 +392,18 @@ void Iot::panicEarly(const char* format...)
392
392
393
393
void Iot::escalatingSleepPanicHandler ()
394
394
{
395
- if (_panicSleepDuration_s <= 0 )
395
+ if (getPanicSleepDuration_s () <= 0 )
396
396
{
397
397
// first panic, last run was successful
398
398
_panicSleepDuration_s = _panicSleepDurationInit_s;
399
399
restart (true );
400
400
} else {
401
- _panicSleepDuration_s = _panicSleepDuration_s * _panicSleepDurationFactor;
402
- if (_panicSleepDuration_s > _panicSleepDurationMax_s)
401
+ _panicSleepDuration_s = getPanicSleepDuration_s () * _panicSleepDurationFactor;
402
+ if (getPanicSleepDuration_s () > _panicSleepDurationMax_s)
403
403
{
404
404
_panicSleepDuration_s = _panicSleepDurationMax_s;
405
405
}
406
- deepSleep (_panicSleepDuration_s , true );
406
+ deepSleep (getPanicSleepDuration_s () , true );
407
407
}
408
408
}
409
409
@@ -480,7 +480,7 @@ void Iot::deepSleep(int sleep_duration_s, bool panic)
480
480
481
481
_lastSleepDuration_s = sleep_duration_s;
482
482
_activeDuration_ms = millis () - _bootTimestamp_ms;
483
- log_i (" Active for %d ms, going to deep sleep for %d s" , _activeDuration_ms , sleep_duration_s);
483
+ log_i (" Active for %d ms, going to deep sleep for %d s" , getActiveDuration_ms () , sleep_duration_s);
484
484
delay (50 ); // delay to allow log to be written
485
485
esp_deep_sleep (sleep_duration_s * 1000ll * 1000ll );
486
486
}
@@ -496,7 +496,7 @@ void Iot::restart(bool panic)
496
496
497
497
_lastSleepDuration_s = 0 ;
498
498
_activeDuration_ms = millis () - _bootTimestamp_ms;
499
- log_i (" Active for %d ms, restarting" , _activeDuration_ms );
499
+ log_i (" Active for %d ms, restarting" , getActiveDuration_ms () );
500
500
delay (50 ); // delay to allow log to be written
501
501
esp_restart ();
502
502
}
@@ -512,7 +512,7 @@ void Iot::shutdown(bool panic)
512
512
513
513
_lastSleepDuration_s = 0 ;
514
514
_activeDuration_ms = millis () - _bootTimestamp_ms;
515
- log_i (" Active for %d ms, shutting down" , _activeDuration_ms );
515
+ log_i (" Active for %d ms, shutting down" , getActiveDuration_ms () );
516
516
delay (50 ); // delay to allow log to be written
517
517
esp_deep_sleep_start ();
518
518
}
0 commit comments