Skip to content

Commit edcfcc0

Browse files
committed
update to current version
1 parent 3b1c702 commit edcfcc0

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

include/iot.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,10 @@ class Iot
184184

185185
int64_t getBootTimestamp_ms() { return _bootTimestamp_ms; }
186186
esp_sleep_wakeup_cause_t getWakeupCause() { return _wakeupCause; };
187-
uint32_t getBootCount() { return _bootCount; }
188-
int64_t getActiveDuration_ms() { return _activeDuration_ms; }
189-
int getLastSleepDuration_s() { return _lastSleepDuration_s; }
190-
int getPanicSleepDuration_s() { return _panicSleepDuration_s; }
187+
uint32_t getBootCount() { return _bootCount.get(); }
188+
int64_t getActiveDuration_ms() { return _activeDuration_ms.get(); }
189+
int getLastSleepDuration_s() { return _lastSleepDuration_s.get(); }
190+
int getPanicSleepDuration_s() { return _panicSleepDuration_s.get(); }
191191

192192
String getFirmwareVersion();
193193
String getFirmwareSha256();

src/iot.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
Iot iot;
2323
static const char *tag = "iot";
2424

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;
3030

3131
static void defaultPanicHandler()
3232
{
@@ -78,12 +78,12 @@ Iot::Iot() :
7878

7979
// startup logging
8080
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());
8282
if (WiFi.status() == WL_CONNECTED)
8383
{
84-
if (_panicSleepDuration_s >= 0)
84+
if (getPanicSleepDuration_s() >= 0)
8585
{
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());
8787
}
8888
}
8989
log_i("--- Firmware %s", getFirmwareVersion().c_str());
@@ -392,18 +392,18 @@ void Iot::panicEarly(const char* format...)
392392

393393
void Iot::escalatingSleepPanicHandler()
394394
{
395-
if (_panicSleepDuration_s <= 0)
395+
if (getPanicSleepDuration_s() <= 0)
396396
{
397397
// first panic, last run was successful
398398
_panicSleepDuration_s = _panicSleepDurationInit_s;
399399
restart(true);
400400
} 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)
403403
{
404404
_panicSleepDuration_s = _panicSleepDurationMax_s;
405405
}
406-
deepSleep(_panicSleepDuration_s, true);
406+
deepSleep(getPanicSleepDuration_s(), true);
407407
}
408408
}
409409

@@ -480,7 +480,7 @@ void Iot::deepSleep(int sleep_duration_s, bool panic)
480480

481481
_lastSleepDuration_s = sleep_duration_s;
482482
_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);
484484
delay(50); // delay to allow log to be written
485485
esp_deep_sleep(sleep_duration_s * 1000ll * 1000ll);
486486
}
@@ -496,7 +496,7 @@ void Iot::restart(bool panic)
496496

497497
_lastSleepDuration_s = 0;
498498
_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());
500500
delay(50); // delay to allow log to be written
501501
esp_restart();
502502
}
@@ -512,7 +512,7 @@ void Iot::shutdown(bool panic)
512512

513513
_lastSleepDuration_s = 0;
514514
_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());
516516
delay(50); // delay to allow log to be written
517517
esp_deep_sleep_start();
518518
}

0 commit comments

Comments
 (0)