From 6e1f64b14ff373774c3b875310d1127a8779cfe8 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Wed, 14 Sep 2022 20:05:50 +0200 Subject: [PATCH] Added reconnect info. Also added the info to the webupdater. --- firmware/config.h | 2 +- firmware/firmware.ino | 18 ++++++++++++++++-- firmware/webUpdater.ino | 11 +++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/firmware/config.h b/firmware/config.h index 5bfe79d..a923255 100644 --- a/firmware/config.h +++ b/firmware/config.h @@ -13,7 +13,7 @@ #define RESET_ESP_TIME_INTERVAL_MS (60*60*12*1000) // reset every 12 hours #define WIND_SENSOR_MEAS_TIME_S 15 #define WATCHDOG_TIMEOUT_MS 30000 -#define WIFI_CHECK_INTERVAL_MS 600000 +#define WIFI_CHECK_INTERVAL_MS 120000 #define ENERGY_SAVING_ITERATIONS 30 diff --git a/firmware/firmware.ino b/firmware/firmware.ino index aded435..00181f2 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -48,6 +48,8 @@ boolean validData = false; boolean do_not_read_windsensor = false; +uint32_t wifi_reconnect_cnt = 0; + //*************************************************************************// void debug(String x) @@ -155,6 +157,8 @@ void initSensors() #endif } +//*************************************************************************// + float readSensors(uint8_t s) { float ret = nan("no value"); @@ -241,12 +245,20 @@ void wifiConnectionCheck() return; } - debug("no wifi connection, try to reconnect"); + wifi_reconnect_cnt++; + + debug("no wifi connection, try to reconnect " + String(wifi_reconnect_cnt)); + +#ifdef WEBUPDATER_FEATURE + setWifiReconnectCnt(wifi_reconnect_cnt); +#endif wifiConnect(); } +//*************************************************************************// + void wifiConnect() { @@ -409,14 +421,16 @@ void _fsm_loop() { // read data from sensor currentSensorData[sensor_cnt] = readSensors(sensor_cnt); + //debug(String(sensor_cnt) + "=" + String(currentSensorData[sensor_cnt])); } else { + start_measure_wind(); // start measurement of wind speed fsm_state = FSM_STATE_9; // wait untile the wind meas time exceeded break; // abort case here to prevent read of next sensor in list } - if (sensor_cnt < VALUES) + if (sensor_cnt < VALUES-1) { sensor_cnt++; fsm_state = FSM_STATE_5; // jump to same state again, more sensors to read diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 5f53de1..af26554 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -41,6 +41,8 @@ const String hb_ws_msg_end = "}"; boolean wuValidData = false; +uint32_t _wifi_reconnect_cnt = 0; + //*************************************************************************// void setupWebUpdater(String device, String ip) @@ -75,6 +77,13 @@ void doWebUpdater(void) httpServer.handleClient(); } +//*************************************************************************// + +void setWifiReconnectCnt(uint32_t wrc) +{ + _wifi_reconnect_cnt = wrc; +} + void setSensorData(float sensorValues[]) { @@ -91,6 +100,7 @@ void setSensorData(float sensorValues[]) if (sensorValues[i] != nanf("no value") and (not isnan(sensorValues[i]))) { // only copy real float values + debug(String(i) + "=" + String(sensorValues[i])); _webUpdater_sensValues[i] = sensorValues[i]; } } @@ -124,6 +134,7 @@ TR_TD_START_STR + "batvoltage" + TD_TD_MID_STR + String(_webUpdater_sensValue TR_TD_START_STR + "millis" + TD_TD_MID_STR + String(millis()) + TR_TD_END_STR TR_TD_START_STR + "valid" + TD_TD_MID_STR + String(wuValidData) + TR_TD_END_STR TR_TD_START_STR + "wifi rssi" + TD_TD_MID_STR + WiFi.RSSI() + TR_TD_END_STR +TR_TD_START_STR + "wifi rec cnt" + TD_TD_MID_STR + String(_wifi_reconnect_cnt) + TR_TD_END_STR "" "




reset WiFi Manager
" "";