This shows you the differences between two versions of the page.
|
iothings:laboratoare:2025_code:lab10_3 [2025/12/06 21:11] dan.tudose |
iothings:laboratoare:2025_code:lab10_3 [2025/12/06 21:23] (current) dan.tudose |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| #include <AsyncTCP.h> | #include <AsyncTCP.h> | ||
| #include <ESPAsyncWebServer.h> | #include <ESPAsyncWebServer.h> | ||
| - | #include <ElegantOTA.h> | ||
| #include <Adafruit_NeoPixel.h> | #include <Adafruit_NeoPixel.h> | ||
| #include <HTTPClient.h> | #include <HTTPClient.h> | ||
| Line 14: | Line 13: | ||
| const char* ssid = "UPB-Guest"; | const char* ssid = "UPB-Guest"; | ||
| const char* password = ""; | const char* password = ""; | ||
| - | // OTA basic auth (recommended) | ||
| - | const char* ota_user = "admin"; | ||
| - | const char* ota_pass = "change-me"; | ||
| // Pull-OTA settings (host these on your local machine) | // Pull-OTA settings (host these on your local machine) | ||
| Line 296: | Line 292: | ||
| request->send(200, "text/plain", | request->send(200, "text/plain", | ||
| "ESP32-C6 Sparrow OTA ready.\n" | "ESP32-C6 Sparrow OTA ready.\n" | ||
| - | "Go to /update to upload new firmware.\n" | + | "Updates pull from manifest server.\n" |
| "Go to /status for telemetry."); | "Go to /status for telemetry."); | ||
| }); | }); | ||
| Line 317: | Line 313: | ||
| statusPixel.setBrightness(40); | statusPixel.setBrightness(40); | ||
| statusPixel.show(); // initialize to off | statusPixel.show(); // initialize to off | ||
| - | |||
| - | // Start ElegantOTA (async mode with ESPAsyncWebServer) | ||
| - | ElegantOTA.begin(&server, ota_user, ota_pass); | ||
| server.begin(); | server.begin(); | ||
| Serial.println("HTTP server started."); | Serial.println("HTTP server started."); | ||
| - | Serial.println("Open http://<device-ip>/update"); | + | Serial.println("Open http://<device-ip>/status"); |
| // First pull-based OTA check after boot | // First pull-based OTA check after boot | ||
| Line 330: | Line 323: | ||
| void loop() { | void loop() { | ||
| - | ElegantOTA.loop(); | ||
| - | |||
| static bool ledOn = false; | static bool ledOn = false; | ||
| static unsigned long lastToggle = 0; | static unsigned long lastToggle = 0; | ||