/* OTAUpdate.ino, Example for the AutoConnect library. Copyright (c) 2020, Hieromon Ikasamo https://github.com/Hieromon/AutoConnect This example is an implementation of a lightweight update feature that updates the ESP8266's firmware from your web browser. You need a compiled sketch binary file to the actual update and can retrieve it using Arduino-IDE menu: [Sketck] -> [Export compiled binary]. Then you will find the .bin file in your sketch folder. Select the.bin file on the update UI page to update the firmware. Notes: If you receive a following error, you need reset the module before sketch running. Update error: ERROR[11]: Invalid bootstrapping state, reset ESP8266 before updating. Refer to https://hieromon.github.io/AutoConnect/faq.html#hang-up-after-reset for details. This software is released under the MIT License. https://opensource.org/licenses/MIT */ #if defined(ARDUINO_ARCH_ESP8266) #include #include typedef ESP8266WebServer WiFiWebServer; #elif defined(ARDUINO_ARCH_ESP32) #include #include typedef WebServer WiFiWebServer; #endif #include WiFiWebServer server; AutoConnect portal(server); AutoConnectConfig config; void setup() { delay(1000); Serial.begin(115200); Serial.println(); // Responder of root page and apply page handled directly from WebServer class. server.on("/", []() { String content = R"( Place the root page with the sketch application.  __AC_LINK__ )"; content.replace("__AC_LINK__", String(AUTOCONNECT_LINK(COG_16))); server.send(200, "text/html", content); }); config.ota = AC_OTA_BUILTIN; portal.config(config); portal.begin(); } void loop() { portal.handleClient(); }