/* To upload through terminal you can use: curl -u admin:admin -F "image=@firmware.bin" esp8266-webupdate.local/firmware */ #include #include #include #include #include const char* host = "myesp8266"; const char* update_path = "/firmware"; const char* update_username = "admin"; const char* update_password = "best"; const char* ssid = "TR-2"; const char* password = "AQW112"; const int greenledPin = 5;//green led attached to ESP8266 ESP-12E module GPIO pin 5 const int redledPin = 4;//red led attached to ESP8266 ESP-12E module GPIO pin 4 ESP8266WebServer httpServer(80); ESP8266HTTPUpdateServer httpUpdater; void setup(void) { Serial.begin(115200); Serial.println(); WiFi.mode(WIFI_AP_STA); WiFi.begin(ssid, password); Serial.println(""); /* set pins as output */ pinMode(greenledPin, OUTPUT); pinMode(redledPin, OUTPUT); // Wait for connection while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.print("Connected to "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); /*use mdns for host name resolution*/ if (!MDNS.begin(host)) { //http://myesp8266.local Serial.println("Error setting up MDNS responder!"); while (1) { delay(1000); } } Serial.println("mDNS responder started"); httpUpdater.setup(&httpServer, update_path, update_username, update_password); httpServer.begin(); MDNS.addService("http", "tcp", 80); Serial.printf("ESP8266 OTA UpdateServer ready! Open http://%s.local%s ", host, update_path, update_username, update_password); Serial.println(); Serial.print("or http://"); Serial.print(WiFi.localIP()); Serial.print(update_path); Serial.println(" in your browser and login"); } void loop(void) { httpServer.handleClient(); digitalWrite(greenledPin, LOW);//green led off delay(1000); digitalWrite(greenledPin, HIGH);//green led on delay(1000); digitalWrite(redledPin, LOW);//red led off }