diff --git a/firmware/firmware.ino b/firmware/firmware.ino index e53531a..9008d5b 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -55,9 +55,6 @@ uint16_t update_webserver_cnt = 0; WiFiManager wifiManager; -#ifdef WEBUPDATER_FEATURE -String localIP = "127.0.0.1"; -#endif //*************************************************************************// void debug(String x) { @@ -144,8 +141,7 @@ void setup() { #ifdef WEBUPDATER_FEATURE #ifndef BATTERY_POWERED - setupWebUpdater(); - localIP = WiFi.localIP().toString(); + setupWebUpdater(DEVICE_NAME, WiFi.localIP().toString()); #endif #endif @@ -252,7 +248,7 @@ void _loop() { #endif #ifdef WEBUPDATER_FEATURE - setSensorData(DEVICE_NAME, localIP, currentSensorData); + setSensorData(currentSensorData); #endif } diff --git a/firmware/webUpdater.ino b/firmware/webUpdater.ino index 2b1bb87..82b264d 100644 --- a/firmware/webUpdater.ino +++ b/firmware/webUpdater.ino @@ -15,16 +15,15 @@ ESP8266WebServer httpServer(8080); ESP8266HTTPUpdateServer httpUpdater; -String ip = "127.0.0.1"; -String dev = "unknown"; -float sensValues[6]; +String _webUpdater_ip = "127.0.0.1"; +String _webUpdater_dev = "unknown"; +float _webUpdater_sensValues[VALUES]; -void setupWebUpdater(void) +void setupWebUpdater(String device, String ip) { -#ifdef DEBUG - Serial.println(); - Serial.println("Starting WebUpdater..."); -#endif + debug("Starting WebUpdater... " + ip); + _webUpdater_ip = ip; + _webUpdater_dev = device; httpUpdater.setup(&httpServer); @@ -32,9 +31,7 @@ void setupWebUpdater(void) httpServer.begin(); -#ifdef DEBUG - Serial.println("HTTPUpdateServer ready!"); -#endif + debug("HTTPUpdateServer ready!"); } void doWebUpdater(void) @@ -43,27 +40,24 @@ void doWebUpdater(void) httpServer.handleClient(); } -void setSensorData(String device, String localip, float sensorValues[]) { - dev = device; - ip = localip; - for (uint8_t i = 0; i < VALUES; i++) - { - sensValues[i] = sensorValues[i]; +void setSensorData(float sensorValues[]) { + for (uint8_t i = 0; i < VALUES; i++) { + _webUpdater_sensValues[i] = sensorValues[i]; } } void showHTMLMain(void) { - String message = "
temperature | " + String(sensValues[SENSOR_TEMPERATURE]) + " |
humidity | " + String(sensValues[SENSOR_HUMIDITY]) + " |
light | " + String(sensValues[SENSOR_LIGHT]) + " |
windspeed | " + String(sensValues[SENSOR_WINDSPEED]) + " |
pressure | " + String(sensValues[SENSOR_PRESSURE]) + " |
batvoltage | " + String(sensValues[SENSOR_BAT_VOLTAGE]) + " |
temperature | " + String(_webUpdater_sensValues[SENSOR_TEMPERATURE]) + " |
humidity | " + String(_webUpdater_sensValues[SENSOR_HUMIDITY]) + " |
light | " + String(_webUpdater_sensValues[SENSOR_LIGHT]) + " |
windspeed | " + String(_webUpdater_sensValues[SENSOR_WINDSPEED]) + " |
pressure | " + String(_webUpdater_sensValues[SENSOR_PRESSURE]) + " |
batvoltage | " + String(_webUpdater_sensValues[SENSOR_BAT_VOLTAGE]) + " |