Added reconnect info. Also added the info to the webupdater.
This commit is contained in:
parent
c89486bd31
commit
6e1f64b14f
3 changed files with 28 additions and 3 deletions
|
@ -13,7 +13,7 @@
|
||||||
#define RESET_ESP_TIME_INTERVAL_MS (60*60*12*1000) // reset every 12 hours
|
#define RESET_ESP_TIME_INTERVAL_MS (60*60*12*1000) // reset every 12 hours
|
||||||
#define WIND_SENSOR_MEAS_TIME_S 15
|
#define WIND_SENSOR_MEAS_TIME_S 15
|
||||||
#define WATCHDOG_TIMEOUT_MS 30000
|
#define WATCHDOG_TIMEOUT_MS 30000
|
||||||
#define WIFI_CHECK_INTERVAL_MS 600000
|
#define WIFI_CHECK_INTERVAL_MS 120000
|
||||||
|
|
||||||
#define ENERGY_SAVING_ITERATIONS 30
|
#define ENERGY_SAVING_ITERATIONS 30
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ boolean validData = false;
|
||||||
|
|
||||||
boolean do_not_read_windsensor = false;
|
boolean do_not_read_windsensor = false;
|
||||||
|
|
||||||
|
uint32_t wifi_reconnect_cnt = 0;
|
||||||
|
|
||||||
//*************************************************************************//
|
//*************************************************************************//
|
||||||
|
|
||||||
void debug(String x)
|
void debug(String x)
|
||||||
|
@ -155,6 +157,8 @@ void initSensors()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*************************************************************************//
|
||||||
|
|
||||||
float readSensors(uint8_t s)
|
float readSensors(uint8_t s)
|
||||||
{
|
{
|
||||||
float ret = nan("no value");
|
float ret = nan("no value");
|
||||||
|
@ -241,12 +245,20 @@ void wifiConnectionCheck()
|
||||||
return;
|
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();
|
wifiConnect();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*************************************************************************//
|
||||||
|
|
||||||
void wifiConnect()
|
void wifiConnect()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -409,14 +421,16 @@ void _fsm_loop()
|
||||||
{
|
{
|
||||||
// read data from sensor
|
// read data from sensor
|
||||||
currentSensorData[sensor_cnt] = readSensors(sensor_cnt);
|
currentSensorData[sensor_cnt] = readSensors(sensor_cnt);
|
||||||
|
//debug(String(sensor_cnt) + "=" + String(currentSensorData[sensor_cnt]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
start_measure_wind(); // start measurement of wind speed
|
start_measure_wind(); // start measurement of wind speed
|
||||||
fsm_state = FSM_STATE_9; // wait untile the wind meas time exceeded
|
fsm_state = FSM_STATE_9; // wait untile the wind meas time exceeded
|
||||||
break; // abort case here to prevent read of next sensor in list
|
break; // abort case here to prevent read of next sensor in list
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sensor_cnt < VALUES)
|
if (sensor_cnt < VALUES-1)
|
||||||
{
|
{
|
||||||
sensor_cnt++;
|
sensor_cnt++;
|
||||||
fsm_state = FSM_STATE_5; // jump to same state again, more sensors to read
|
fsm_state = FSM_STATE_5; // jump to same state again, more sensors to read
|
||||||
|
|
|
@ -41,6 +41,8 @@ const String hb_ws_msg_end = "}";
|
||||||
|
|
||||||
boolean wuValidData = false;
|
boolean wuValidData = false;
|
||||||
|
|
||||||
|
uint32_t _wifi_reconnect_cnt = 0;
|
||||||
|
|
||||||
//*************************************************************************//
|
//*************************************************************************//
|
||||||
|
|
||||||
void setupWebUpdater(String device, String ip)
|
void setupWebUpdater(String device, String ip)
|
||||||
|
@ -75,6 +77,13 @@ void doWebUpdater(void)
|
||||||
httpServer.handleClient();
|
httpServer.handleClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//*************************************************************************//
|
||||||
|
|
||||||
|
void setWifiReconnectCnt(uint32_t wrc)
|
||||||
|
{
|
||||||
|
_wifi_reconnect_cnt = wrc;
|
||||||
|
}
|
||||||
|
|
||||||
void setSensorData(float sensorValues[])
|
void setSensorData(float sensorValues[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -91,6 +100,7 @@ void setSensorData(float sensorValues[])
|
||||||
if (sensorValues[i] != nanf("no value") and (not isnan(sensorValues[i])))
|
if (sensorValues[i] != nanf("no value") and (not isnan(sensorValues[i])))
|
||||||
{
|
{
|
||||||
// only copy real float values
|
// only copy real float values
|
||||||
|
debug(String(i) + "=" + String(sensorValues[i]));
|
||||||
_webUpdater_sensValues[i] = 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 + "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 + "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 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
|
||||||
"</table>"
|
"</table>"
|
||||||
"<br><br><br><br><br><a href=\"http://" + _webUpdater_ip + ":8080/resetWifiManager\">reset WiFi Manager</a><br>"
|
"<br><br><br><br><br><a href=\"http://" + _webUpdater_ip + ":8080/resetWifiManager\">reset WiFi Manager</a><br>"
|
||||||
"</body></html>";
|
"</body></html>";
|
||||||
|
|
Loading…
Reference in a new issue