[zb] Debugging changes:

- Disables double reset
- Fully reset with zb_reset() on reset watchdog instead of
  user_input_indicate()
- Debug counters before/after sensors read
This commit is contained in:
rbaron 2023-06-18 14:37:25 +02:00
parent a4a02257f9
commit 5882312a77
6 changed files with 10 additions and 3 deletions

View file

@ -34,6 +34,9 @@ config PRST_ZB_FACTORY_RESET_VIA_RESET_PIN
config PRST_ZB_FACTORY_RESET_VIA_SW1
bool "Resetting while pressing and holding SW1 for 5 seconds will factory reset the device. Only available on v2.0.0+ hardware revisions."
config PRST_ZB_FACTORY_RESET_DISABLED
bool "No factory reset procedure."
endchoice # PRST_ZB_FACTORY_RESET_METHOD
config PRST_ZB_RESTART_WATCHDOG_TIMEOUT_SEC

View file

@ -60,3 +60,4 @@ CONFIG_FILE_SYSTEM_LITTLEFS=y
# Factory reset method selection. Only hardware revision 2.0.0+ has button SW1. Earlier
# revisions must select a different method. See Kconfig for options.
# CONFIG_PRST_ZB_FACTORY_RESET_VIA_SW1=y
CONFIG_PRST_ZB_FACTORY_RESET_DISABLED=y

View file

@ -65,6 +65,7 @@ int prst_debug_counters_increment(const char* counter_name) {
if (written != sizeof(value)) {
LOG_ERR("fs_write returned %d, expected %d", written, sizeof(value));
}
RET_IF_ERR(fs_sync(&file));
return fs_close(&file);
}

View file

@ -66,6 +66,7 @@ int prst_zb_factory_reset_check() {
LOG_DBG("SW1 pressed. Scheduling timer");
k_timer_start(&sw1_factory_reset_check_timer, K_SECONDS(5), K_NO_WAIT);
}
#endif
#elif CONFIG_PRST_ZB_FACTORY_RESET_DISABLED
return 0;
#endif // CONFIG_PRST_ZB_FACTORY_RESET_VIA_RESET_PIN
}

View file

@ -198,11 +198,13 @@ void update_sensors_cb(zb_uint8_t arg) {
/*param=*/0,
ZB_TIME_ONE_SECOND * CONFIG_PRST_ZB_SLEEP_DURATION_SEC);
prst_debug_counters_increment("sensors_read_before");
if (prst_sensors_read_all(&sensors)) {
prst_debug_counters_increment("sensors_read_error");
LOG_ERR("Unable to read sensors");
return;
}
prst_debug_counters_increment("sensors_read_after");
// Battery voltage in units of 100 mV.
uint8_t batt_voltage = sensors.batt.adc_read.millivolts / 100;

View file

@ -11,8 +11,7 @@ LOG_MODULE_REGISTER(restart_handler, CONFIG_LOG_DEFAULT_LEVEL);
void callback_work_handler(struct k_work *work) {
LOG_INF("Running restart callback_work_handler.");
prst_debug_counters_increment("steering_watchdog_restart");
// If the device is not commissioned, the rejoin procedure is started.
user_input_indicate();
zb_reset(0);
}
K_WORK_DEFINE(callback_work, callback_work_handler);