commit
918aaca871
@ -20,16 +20,9 @@ void setCyclicIRQ() {
|
|||||||
// do all housekeeping
|
// do all housekeeping
|
||||||
void doHousekeeping() {
|
void doHousekeeping() {
|
||||||
|
|
||||||
// check if update mode trigger switch was set
|
// check if update mode trigger switch was set by rcommand
|
||||||
if (RTC_runmode == RUNMODE_UPDATE) {
|
if (RTC_runmode == RUNMODE_UPDATE)
|
||||||
// check battery status if we can before doing ota
|
do_reset(true);
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// heap and task storage debugging
|
// heap and task storage debugging
|
||||||
ESP_LOGD(TAG, "Heap: Free:%d, Min:%d, Size:%d, Alloc:%d, StackHWM:%d",
|
ESP_LOGD(TAG, "Heap: Free:%d, Min:%d, Size:%d, Alloc:%d, StackHWM:%d",
|
||||||
|
@ -29,11 +29,11 @@ Task Core Prio Purpose
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
ledloop 0 3 blinks LEDs
|
ledloop 0 3 blinks LEDs
|
||||||
spiloop 0 2 reads/writes data on spi interface
|
spiloop 0 2 reads/writes data on spi interface
|
||||||
mqttloop 0 2 reads/writes data on ETH interface
|
|
||||||
IDLE 0 0 ESP32 arduino scheduler -> runs wifi sniffer
|
IDLE 0 0 ESP32 arduino scheduler -> runs wifi sniffer
|
||||||
|
|
||||||
lmictask 1 2 MCCI LMiC LORAWAN stack
|
lmictask 1 2 MCCI LMiC LORAWAN stack
|
||||||
clockloop 1 4 generates realtime telegrams for external clock
|
clockloop 1 4 generates realtime telegrams for external clock
|
||||||
|
mqttloop 1 2 reads/writes data on ETH interface
|
||||||
timesync_proc 1 3 processes realtime time sync requests
|
timesync_proc 1 3 processes realtime time sync requests
|
||||||
irqhandler 1 2 cyclic tasks (i.e. displayrefresh) triggered by timers
|
irqhandler 1 2 cyclic tasks (i.e. displayrefresh) triggered by timers
|
||||||
gpsloop 1 1 reads data from GPS via serial or i2c
|
gpsloop 1 1 reads data from GPS via serial or i2c
|
||||||
|
@ -37,7 +37,7 @@ esp_err_t mqtt_init(void) {
|
|||||||
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
|
SEND_QUEUE_SIZE * PAYLOAD_BUFFER_SIZE);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Starting MQTTloop...");
|
ESP_LOGI(TAG, "Starting MQTTloop...");
|
||||||
xTaskCreate(mqtt_client_task, "mqttloop", 4096, (void *)NULL, 1, &mqttTask);
|
xTaskCreatePinnedToCore(mqtt_client_task, "mqttloop", 4096, (void *)NULL, 1, &mqttTask, 1);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,11 @@ void set_reset(uint8_t val[]) {
|
|||||||
case 9: // reset and ask for software update via Wifi OTA
|
case 9: // reset and ask for software update via Wifi OTA
|
||||||
ESP_LOGI(TAG, "Remote command: software update via Wifi");
|
ESP_LOGI(TAG, "Remote command: software update via Wifi");
|
||||||
#if (USE_OTA)
|
#if (USE_OTA)
|
||||||
RTC_runmode = RUNMODE_UPDATE;
|
// 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
|
#endif // USE_OTA
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ void do_after_reset(void) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core
|
case DEEPSLEEP_RESET: // 0x05 Deep Sleep reset digital core
|
||||||
RTC_runmode = RUNMODE_WAKEUP;
|
|
||||||
// calculate time spent in deep sleep
|
// calculate time spent in deep sleep
|
||||||
gettimeofday(&sleep_stop_time, NULL);
|
gettimeofday(&sleep_stop_time, NULL);
|
||||||
sleep_time_ms =
|
sleep_time_ms =
|
||||||
@ -57,6 +56,9 @@ void do_after_reset(void) {
|
|||||||
(sleep_stop_time.tv_usec - RTC_sleep_start_time.tv_usec) / 1000;
|
(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);
|
ESP_LOGI(TAG, "Time spent in deep sleep: %d ms", sleep_time_ms);
|
||||||
RTC_millis += sleep_time_ms; // increment system monotonic time
|
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;
|
break;
|
||||||
|
|
||||||
case SW_RESET: // 0x03 Software reset digital core
|
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
|
// stop further enqueuing of senddata and MAC processing
|
||||||
sendTimer.detach();
|
sendTimer.detach();
|
||||||
|
|
||||||
// switch off radio
|
// switch off radio and other power consuming hardware
|
||||||
#if (WIFICOUNTER)
|
#if (WIFICOUNTER)
|
||||||
switch_wifi_sniffer(0);
|
switch_wifi_sniffer(0);
|
||||||
#endif
|
#endif
|
||||||
@ -111,6 +113,9 @@ void enter_deepsleep(const uint64_t wakeup_sec = 60,
|
|||||||
stop_BLEscan();
|
stop_BLEscan();
|
||||||
btStop();
|
btStop();
|
||||||
#endif
|
#endif
|
||||||
|
#if (HAS_SDS011)
|
||||||
|
sds011_sleep(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
// stop MAC processing
|
// stop MAC processing
|
||||||
vTaskDelete(macProcessTask);
|
vTaskDelete(macProcessTask);
|
||||||
|
Loading…
Reference in New Issue
Block a user