Skip to content

Commit

Permalink
attempt to work around the issue of pax counter dropping to 0 and sta…
Browse files Browse the repository at this point in the history
…ying at 0 on ttgo t-beam v0.7
  • Loading branch information
HouzuoGuo committed Jan 8, 2021
1 parent 686d7b4 commit c18ff86
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cyclic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// Local logging tag
static const char TAG[] = __FILE__;

static int consecutive_macs_counter_zero = 0;

Ticker cyclicTimer;

#if (HAS_SDS011)
Expand Down Expand Up @@ -92,6 +94,21 @@ void doHousekeeping() {
#endif
#endif

// On TTGO T-Beam v0.7, the pax counter (wifi+ble) often reads 0 after a short short while.
// The cause is yet to be determined. As a temporary measure, count the consecutive readings of counter value 0.
// If there are 10 consecutive readings of 0 within timespan of 5 minutes, then reset the microcontroller.
ESP_LOGI(TAG, "WiFi macs counter: %d; BLE macs counter: %d", macs_wifi, macs_ble);
if (macs_wifi == 0 && macs_ble == 0) {
++consecutive_macs_counter_zero;
ESP_LOGI(TAG, "number of consecutive zero readings on the mac counter: %d", consecutive_macs_counter_zero);
if (consecutive_macs_counter_zero >= 300 / HOMECYCLE) {
ESP_LOGE(TAG, "too many consecutive zero reading on the mac counter, resetting microcontroller.");
do_reset(true);
}
} else {
consecutive_macs_counter_zero = 0;
}

// check free heap memory
if (ESP.getMinFreeHeap() <= MEM_LOW) {
ESP_LOGI(TAG,
Expand Down

0 comments on commit c18ff86

Please sign in to comment.