repair OTA & deepsleep combination
This commit is contained in:
parent
866d0bd730
commit
0393fa3a45
@ -20,16 +20,9 @@ void setCyclicIRQ() {
|
||||
// do all housekeeping
|
||||
void doHousekeeping() {
|
||||
|
||||
// check if update mode trigger switch was set
|
||||
if (RTC_runmode == RUNMODE_UPDATE) {
|
||||
// check battery status if we can before doing ota
|
||||
if (batt_sufficient()) {
|
||||
do_reset(true); // warmstart to runmode update
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Battery level %d%% is too low for OTA", batt_level);
|
||||
RTC_runmode = RUNMODE_NORMAL; // keep running in normal mode
|
||||
}
|
||||
}
|
||||
// check if update mode trigger switch was set by rcommand
|
||||
if (RTC_runmode == RUNMODE_UPDATE)
|
||||
do_reset(true);
|
||||
|
||||
// heap and task storage debugging
|
||||
ESP_LOGD(TAG, "Heap: Free:%d, Min:%d, Size:%d, Alloc:%d, StackHWM:%d",
|
||||
|
@ -35,7 +35,11 @@ void set_reset(uint8_t val[]) {
|
||||
case 9: // reset and ask for software update via Wifi OTA
|
||||
ESP_LOGI(TAG, "Remote command: software update via Wifi");
|
||||
#if (USE_OTA)
|
||||
// check power status before scheduling ota update
|
||||
if (batt_sufficient())
|
||||
RTC_runmode = RUNMODE_UPDATE;
|
||||
else
|
||||
ESP_LOGE(TAG, "Battery level %d%% is too low for OTA", batt_level);
|
||||
#endif // USE_OTA
|
||||
break;
|
||||
|
||||
|
@ -49,7 +49,6 @@ void do_after_reset(void) {
|
||||
break;
|
||||
|
||||
case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core
|
||||
RTC_runmode = RUNMODE_WAKEUP;
|
||||
// calculate time spent in deep sleep
|
||||
gettimeofday(&sleep_stop_time, NULL);
|
||||
sleep_time_ms =
|
||||
@ -57,6 +56,9 @@ void do_after_reset(void) {
|
||||
(sleep_stop_time.tv_usec - RTC_sleep_start_time.tv_usec) / 1000;
|
||||
ESP_LOGI(TAG, "Time spent in deep sleep: %d ms", sleep_time_ms);
|
||||
RTC_millis += sleep_time_ms; // increment system monotonic time
|
||||
// set wakeup state, not if we have pending OTA update
|
||||
if (RTC_runmode == RUNMODE_SLEEP)
|
||||
RTC_runmode = RUNMODE_WAKEUP;
|
||||
break;
|
||||
|
||||
case SW_RESET: // 0x03 Software reset digital core
|
||||
@ -103,7 +105,7 @@ void enter_deepsleep(const uint64_t wakeup_sec = 60,
|
||||
// stop further enqueuing of senddata and MAC processing
|
||||
sendTimer.detach();
|
||||
|
||||
// switch off radio
|
||||
// switch off radio and other power consuming hardware
|
||||
#if (WIFICOUNTER)
|
||||
switch_wifi_sniffer(0);
|
||||
#endif
|
||||
@ -111,6 +113,9 @@ void enter_deepsleep(const uint64_t wakeup_sec = 60,
|
||||
stop_BLEscan();
|
||||
btStop();
|
||||
#endif
|
||||
#if (HAS_SDS011)
|
||||
sds011_sleep(void);
|
||||
#endif
|
||||
|
||||
// stop MAC processing
|
||||
vTaskDelete(macProcessTask);
|
||||
|
Loading…
Reference in New Issue
Block a user