/* * To upload through terminal you can use: curl -F "image=@firmware.bin" http://:8080/update * * * bin file location on windows: C:\Users\\AppData\Local\Temp\arduino_build_ */ #include #include #include #include #include #include // WiFiManager from bib manager ESP8266WebServer httpServer(8080); ESP8266HTTPUpdateServer httpUpdater; String _webUpdater_ip = "127.0.0.1"; String _webUpdater_dev = "unknown"; float _webUpdater_sensValues[VALUES]; void setupWebUpdater(String device, String ip) { debug("Starting WebUpdater... " + ip); _webUpdater_ip = ip; _webUpdater_dev = device; httpUpdater.setup(&httpServer); httpServer.on("/", showHTMLMain); httpServer.on("/resetWifiManager", resetWifiManager); httpServer.begin(); debug("HTTPUpdateServer ready!"); } void doWebUpdater(void) { digitalWrite(D0, HIGH); httpServer.handleClient(); } void setSensorData(float sensorValues[]) { for (uint8_t i = 0; i < VALUES; i++) { _webUpdater_sensValues[i] = sensorValues[i]; } } void showHTMLMain(void) { String message = "OKO Weatherstation - " + String(_webUpdater_dev) + "" "" "" "
firmware update

" "" "" "" "" "" "" "" "
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]) + "
" ""; httpServer.send(200, "text/html", message); } void resetWifiManager() { String message = "OKO Weatherstation - " + String(_webUpdater_dev) + "" "" "" "Reset WifiManager config.
" "Rebooting...
" ""; httpServer.send(200, "text/html", message); // Erase WiFi Credentials, enable, compile, flash, disable and reflash. WiFiManager.resetSettings(); delay(5000); ESP.restart(); }