#include #include #include const char* ssid = "Ateca"; const char* password = "q1w2e3r4t5"; WebServer server(80); // Cambiamos el dise帽o HTML para comprobar visualmente la actualizaci贸n const char* indexHTML = "ESP32 OTA V2" "" "

ESP32 OTA Portal - Versi贸n 2.0 馃殌

" "

隆Felicidades! Esta versi贸n fue cargada por WiFi sin cables.

" "
" "
" "" "
"; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("\n--- Firmware V2 Ejecut谩ndose ---"); Serial.print("IP: "); Serial.println(WiFi.localIP()); server.on("/", HTTP_GET, []() { server.send(200, "text/html", indexHTML); }); server.on("/update", HTTP_POST, []() { server.sendHeader("Connection", "close"); server.send(200, "text/html", "

Actualizando a nueva versi贸n... Reiniciando

"); delay(1000); ESP.restart(); }, []() { HTTPUpload& upload = server.upload(); if (upload.status == UPLOAD_FILE_START) { Serial.printf("Actualizaci贸n iniciada: %s\n", upload.filename.c_str()); if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { Update.printError(Serial); } } else if (upload.status == UPLOAD_FILE_WRITE) { if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { Update.printError(Serial); } } else if (upload.status == UPLOAD_FILE_END) { if (Update.end(true)) { Serial.printf("脡xito: %u bytes escritos.\n", upload.totalSize); } else { Update.printError(Serial); } } }); server.begin(); } void loop() { server.handleClient(); }