Added signal quality and wifi connect count to default web page.
This commit is contained in:
parent
26300287f9
commit
26db5f74a9
2 changed files with 39 additions and 10 deletions
|
@ -30,7 +30,9 @@
|
|||
// constant variables
|
||||
|
||||
const uint8_t VALUES = 8; // see constants.h file - count of number of SENSOR_ defines
|
||||
float currentSensorData[VALUES] = {nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value")};
|
||||
float currentSensorData[VALUES] = { nanf("no value"), nanf("no value"), nanf("no value"),
|
||||
nanf("no value"), nanf("no value"), nanf("no value"),
|
||||
nanf("no value"), nanf("no value")};
|
||||
float (*sensors[VALUES])() = {};
|
||||
|
||||
uint16_t update_sensor_cnt = 0;
|
||||
|
@ -41,6 +43,8 @@ boolean validData = false;
|
|||
|
||||
#ifdef USE_WIFIMANAGER
|
||||
WiFiManager wifiManager;
|
||||
#else
|
||||
unsigned int wifi_connect_cnt = 0;
|
||||
#endif
|
||||
|
||||
//*************************************************************************//
|
||||
|
@ -139,7 +143,8 @@ void setup()
|
|||
|
||||
debug("deep sleep");
|
||||
|
||||
// the ESP.deepSleep requires microseconds as input, after the sleep the system will run into the setup routine
|
||||
// the ESP.deepSleep requires microseconds as input, after the
|
||||
// sleep the system will run into the setup routine
|
||||
ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT);
|
||||
delay(100);
|
||||
#endif
|
||||
|
@ -189,6 +194,7 @@ void wifiConnectionCheck()
|
|||
Serial.println("WLAN connection already OK");
|
||||
return;
|
||||
}
|
||||
WiFi.disconnect();
|
||||
|
||||
if (!WiFi.config(local_IP, gateway, subnet))
|
||||
{
|
||||
|
@ -205,9 +211,13 @@ void wifiConnectionCheck()
|
|||
{
|
||||
delay(100);
|
||||
}
|
||||
WiFi.setAutoReconnect(true);
|
||||
WiFi.persistent(true);
|
||||
|
||||
Serial.println("WLAN connection OK");
|
||||
|
||||
wifi_connect_cnt += 1;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -372,7 +382,11 @@ void _loop()
|
|||
#endif
|
||||
|
||||
#ifdef WEBUPDATER_FEATURE
|
||||
#ifdef USE_WIFIMANAGER
|
||||
setSensorData(currentSensorData);
|
||||
#else
|
||||
setSensorData(currentSensorData, wifi_connect_cnt);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#ifdef USE_WIFIMANAGER
|
||||
#include <WiFiManager.h> // WiFiManager from bib manager
|
||||
#else
|
||||
unsigned int _wifi_connect_cnt = 0;
|
||||
#endif
|
||||
|
||||
ESP8266WebServer httpServer(WEB_UPDATER_HTTP_PORT);
|
||||
|
@ -74,7 +76,11 @@ void doWebUpdater(void)
|
|||
httpServer.handleClient();
|
||||
}
|
||||
|
||||
#ifdef USE_WIFIMANAGER
|
||||
void setSensorData(float sensorValues[])
|
||||
#else
|
||||
void setSensorData(float sensorValues[], unsigned int wifi_conn_cnt)
|
||||
#endif
|
||||
{
|
||||
|
||||
for (uint8_t i = 0; i < 5 and wuValidData == false; i++)
|
||||
|
@ -89,6 +95,11 @@ void setSensorData(float sensorValues[])
|
|||
_webUpdater_sensValues[i] = sensorValues[i];
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_WIFIMANAGER
|
||||
_wifi_connect_cnt = wifi_conn_cnt;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void showHTMLMain(void)
|
||||
|
@ -99,14 +110,18 @@ void showHTMLMain(void)
|
|||
"</head><body>"
|
||||
"<br><a href=\"http://" + _webUpdater_ip + ":8080/update\">firmware update</a><br><br>"
|
||||
"<table>"
|
||||
TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "humidity" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>light" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_LIGHT]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>windspeed" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>pressure" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>batvoltage" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>millis" + TD_TD_MID_STR + String(millis()) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "<tr><td>valid" + TD_TD_MID_STR + String(wuValidData) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "temperature" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "humidity" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "light" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_LIGHT]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "windspeed" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "pressure" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + TR_TD_END_STR
|
||||
TR_TD_START_STR + "batvoltage" + TD_TD_MID_STR + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + 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 + "wifi rssi" + TD_TD_MID_STR + WiFi.RSSI() + TR_TD_END_STR
|
||||
#ifndef USE_WIFIMANAGER
|
||||
TR_TD_START_STR + "wifi conn cnt" + TD_TD_MID_STR + _wifi_connect_cnt + TR_TD_END_STR
|
||||
#endif
|
||||
"</table>"
|
||||
"</body></html>";
|
||||
|
||||
|
|
Loading…
Reference in a new issue