You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#endif
#include <ESPAsyncWebServer.h>
#include <ElegantOTA.h>
const char *ssid = "A";
const char *password = "B";
AsyncWebServer server(80);
unsigned long ota_progress_millis = 0;
void onOTAStart()
{
// Log when OTA has started
Serial.println("OTA update started!");
// <Add your own code here>
}
void onOTAProgress(size_t current, size_t final)
{
// Log every 1 second
if (millis() - ota_progress_millis > 1000)
{
ota_progress_millis = millis();
Serial.printf("OTA Progress Current: %u bytes, Final: %u bytes\n", current, final);
}
}
void onOTAEnd(bool success)
{
// Log when OTA has finished
if (success)
{
Serial.println("OTA update finished successfully!");
}
else
{
Serial.println("There was an error during OTA update!");
}
// <Add your own code here>
}
void setup()
{
// Initialize the serial port
Serial.begin(9600);
// Initialize the LED pin as an output
pinMode(LED_BUILTIN, OUTPUT);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
// 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());
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{ request->send(200, "text/plain", "Hi! This is ElegantOTA AsyncDemo."); });
ElegantOTA.begin(&server); // Start ElegantOTA
// ElegantOTA callbacks
ElegantOTA.onStart(onOTAStart);
ElegantOTA.onProgress(onOTAProgress);
ElegantOTA.onEnd(onOTAEnd);
server.begin();
Serial.println("HTTP server started");
}
void loop()
{
ElegantOTA.loop();
}
Error:
In file included from C:/Users/X/.platformio/packages/framework-arduinoespressif32@src-0c9bc5a2e917d2a24b2fba29cb704cc7/libraries/WebServer/src/HTTP_Method.h:4,
from C:/Users/X/.platformio/packages/framework-arduinoespressif32@src-0c9bc5a2e917d2a24b2fba29cb704cc7/libraries/WebServer/src/WebServer.h:30,
from .pio/libdeps/wemos_d1_mini32/ElegantOTA/src/ElegantOTA.h:73,
from src/main.cpp:10:
C:/Users/X/.platformio/packages/framework-arduinoespressif32-libs/esp32/include/http_parser/http_parser.h:95:6: error: 'HTTP_DELETE' conflicts with a previous declaration
The text was updated successfully, but these errors were encountered:
platformio.ini:
main.cpp:
Error:
The text was updated successfully, but these errors were encountered: