Merge branch 'web_ota' into 'master'

Add the possibility to upload OTA by http

Closes #2

See merge request !8
This commit is contained in:
Mathieu 2017-03-29 23:25:17 +02:00
commit 7839671bf8
2 changed files with 8 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#ifndef CONFIG_DISABLE_WEB #ifndef CONFIG_DISABLE_WEB
#include <ESP8266HTTPUpdateServer.h>
ESP8266HTTPUpdateServer httpUpdater;
String gpioControlHTML = ""; String gpioControlHTML = "";
String pwmControlHTML = ""; String pwmControlHTML = "";
@ -44,6 +46,7 @@ void WebHandleRoot() {
#ifdef CONFIG_ENABLE_BMP180 #ifdef CONFIG_ENABLE_BMP180
"BMP 180 (Temp+Pression) Status: " + (BMP180IsConnected() ? "Connected" : "Disconnected") + "<br/>" "BMP 180 (Temp+Pression) Status: " + (BMP180IsConnected() ? "Connected" : "Disconnected") + "<br/>"
#endif #endif
"<a href=\"/upload\">Update firmware</a><br/>"
"Wifi Strength: " + WiFi.RSSI() + "dBm<br/>" "Wifi Strength: " + WiFi.RSSI() + "dBm<br/>"
"Free space: " + ESP.getFreeSketchSpace() + "<br/>" "Free space: " + ESP.getFreeSketchSpace() + "<br/>"
"Free heap: " + ESP.getFreeHeap() + "<br/>" "Free heap: " + ESP.getFreeHeap() + "<br/>"
@ -293,6 +296,7 @@ void WebSetupServer(int ) {
server.on("/wifiStatus", WebHandleWifiStatus); server.on("/wifiStatus", WebHandleWifiStatus);
server.onNotFound(WebHandleNotFound); server.onNotFound(WebHandleNotFound);
httpUpdater.setup(&server, "/upload");
server.begin(); server.begin();
SKETCH_DEBUG_PRINTLN("HTTP server started"); SKETCH_DEBUG_PRINTLN("HTTP server started");
} }

View File

@ -129,6 +129,10 @@ void WifiSetup(productConfig conf) {
SKETCH_DEBUG_PRINTLN("Error setting up MDNS responder!"); SKETCH_DEBUG_PRINTLN("Error setting up MDNS responder!");
} else { } else {
SKETCH_DEBUG_PRINTLN("mDNS responder started"); SKETCH_DEBUG_PRINTLN("mDNS responder started");
#ifndef CONFIG_DISABLE_WEB
//Needed for OTA by HTTP
MDNS.addService("http", "tcp", 80);
#endif
} }
#endif #endif
myIP = WiFi.localIP(); myIP = WiFi.localIP();