ayushsharma82 / ElegantOTA

OTA updates made slick and simple for everyone!
https://elegantota.pro
GNU Affero General Public License v3.0
607 stars 115 forks source link

no matching function for call to 'ElegantOTAClass::begin(AsyncWebServer*)' #169

Closed StefanL38 closed 1 month ago

StefanL38 commented 6 months ago

I get a compiler error no matching function for call to 'ElegantOTAClass::begin(AsyncWebServer*)'

what is wrong? Is this a problem because I have used the older AsyncElegantOTA?

Arduino: 1.8.19 (Windows 10), TD: 1.58, Board: "ESP32 Dev Module, Disabled, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None, Disabled"

Using board 'esp32' from platform in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14

Using core 'esp32' from platform in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14

cmd /c if exist "C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\partitions.csv" COPY /y "C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\partitions.csv" "C:\Users\dipl-\AppData\Local\Temp\arduino_build_776315\partitions.csv"

esptool.py v4.5.1

Creating esp32 image...

Merged 1 ELF section

Successfully created esp32 image.

cmd /c type nul > "C:\Users\dipl-\AppData\Local\Temp\arduino_build_776315/file_opts"

Detecting libraries used...

Alternatives for WiFi.h: [WiFiNINA@1.8.14 WiFi@2.0.0 WiFi@1.2.7]

ResolveLibrary(WiFi.h)

-> candidates: [WiFiNINA@1.8.14 WiFi@2.0.0 WiFi@1.2.7]

Alternatives for AsyncTCP.h: [AsyncTCP@1.1.4]

ResolveLibrary(AsyncTCP.h)

-> candidates: [AsyncTCP@1.1.4]

Alternatives for ESPAsyncWebServer.h: [ESPAsyncWebServer@1.2.3]

ResolveLibrary(ESPAsyncWebServer.h)

-> candidates: [ESPAsyncWebServer@1.2.3]

Alternatives for FS.h: [FS@2.0.0]

ResolveLibrary(FS.h)

-> candidates: [FS@2.0.0]

Alternatives for ElegantOTA.h: [ElegantOTA@3.1.0]

ResolveLibrary(ElegantOTA.h)

-> candidates: [ElegantOTA@3.1.0]

Alternatives for Update.h: [Update@2.0.0]

ResolveLibrary(Update.h)

-> candidates: [Update@2.0.0]

Alternatives for WebServer.h: [WebServer@2.0.0]

ResolveLibrary(WebServer.h)

-> candidates: [WebServer@2.0.0]

Generating function prototypes...

Compiling sketch...

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:95:6: error: 'HTTP_DELETE' conflicts with a previous declaration

XX(0, DELETE, DELETE) \

  ^

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:64:3: note: previous declaration 'WebRequestMethod HTTP_DELETE'

HTTP_DELETE = 0b00000100,

^~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:96:6: error: 'HTTP_GET' conflicts with a previous declaration

XX(1, GET, GET) \

  ^

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:62:3: note: previous declaration 'WebRequestMethod HTTP_GET'

HTTP_GET = 0b00000001,

^~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:97:6: error: 'HTTP_HEAD' conflicts with a previous declaration

XX(2, HEAD, HEAD) \

  ^

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:67:3: note: previous declaration 'WebRequestMethod HTTP_HEAD'

HTTP_HEAD = 0b00100000,

^~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:98:6: error: 'HTTP_POST' conflicts with a previous declaration

XX(3, POST, POST) \

  ^

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:63:3: note: previous declaration 'WebRequestMethod HTTP_POST'

HTTP_POST = 0b00000010,

^~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:99:6: error: 'HTTP_PUT' conflicts with a previous declaration

XX(4, PUT, PUT) \

  ^

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:65:3: note: previous declaration 'WebRequestMethod HTTP_PUT'

HTTP_PUT = 0b00001000,

^~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:102:6: error: 'HTTP_OPTIONS' conflicts with a previous declaration

XX(6, OPTIONS, OPTIONS) \

  ^

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:68:3: note: previous declaration 'WebRequestMethod HTTP_OPTIONS'

HTTP_OPTIONS = 0b01000000,

^~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/HTTP_Method.h:4,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer\src/WebServer.h:30,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:73,

             from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:128:6: error: 'HTTP_PATCH' conflicts with a previous declaration

XX(28, PATCH, PATCH) \

  ^~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:138:45: note: in definition of macro 'XX'

define XX(num, name, string) HTTP_##name = num,

                                         ^~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14/tools/sdk/esp32/include/nghttp/port/include/http_parser.h:139:3: note: in expansion of macro 'HTTP_METHOD_MAP'

HTTP_METHOD_MAP(XX)

^~~~~~~

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:33:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer\src/ESPAsyncWebServer.h:66:3: note: previous declaration 'WebRequestMethod HTTP_PATCH'

HTTP_PATCH = 0b00010000,

^~~~~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino: In function 'void setup()':

Async-OTA-Demo-001:88:27: error: no matching function for call to 'ElegantOTAClass::begin(AsyncWebServer*)'

ElegantOTA.begin(&server); // Start ElegantOTA

                       ^

In file included from C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\Async-OTA-Demo-001\Async-OTA-Demo-001.ino:34:

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:107:10: note: candidate: 'void ElegantOTAClass::begin(WebServer, const char, const char*)'

 void begin(ELEGANTOTA_WEBSERVER *server, const char * username = "", const char * password = "");

      ^~~~~

C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA\src/ElegantOTA.h:107:10: note: no known conversion for argument 1 from 'AsyncWebServer' to 'WebServer'

Multiple libraries were found for "WiFi.h"

Used: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WiFi

Not used: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\WiFiNINA

Not used: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\WiFi

Using library WiFi at version 2.0.0 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WiFi

Using library AsyncTCP at version 1.1.4 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\AsyncTCP

Using library ESPAsyncWebServer at version 1.2.3 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ESPAsyncWebServer

Using library FS at version 2.0.0 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\FS

Using library ElegantOTA at version 3.1.0 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\sketchbook\libraries\ElegantOTA

Using library Update at version 2.0.0 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\Update

Using library WebServer at version 2.0.0 in folder: C:\Arduino-Pure-Portable\arduino-1.8.19\portable\packages\esp32\hardware\esp32\2.0.14\libraries\WebServer

exit status 1

no matching function for call to 'ElegantOTAClass::begin(AsyncWebServer*)'

StefanL38 commented 6 months ago

I found the solution this modifying of the file ElegantOTA.h.

This modification is far from beeing userfriendly

You should find a way that this will be adjusted through a

define

inside your demo.ino-file or as a variant of the constructor with a parameter inside the demo.ino-file

best regards Stefan

mathieucarbou commented 6 months ago

You should find a way that this will be adjusted through a

define

inside your demo.ino-file

There are 2 ways to fix this:

1) re-order the includes in order to put ESPAsyncWebServer at the end 2) If you use ESPAsyncWebServer, use async mode: https://docs.elegantota.pro/async-mode/

ednieuw commented 6 months ago

I hope you solve the error with this define. " Locate the ELEGANTOTA_USE_ASYNC_WEBSERVER macro in the ElegantOTA.h file, and set it to 1: #define ELEGANTOTA_USE_ASYNC_WEBSERVER 1"

After een upgrade to a newer version the define is overwritten and you get a compile error

thehans commented 3 months ago

Requiring the user to manually edit a dependency (this library) for it to compile is awful. I guess I will try the obsolete AsyncElegantOTA instead.

mathieucarbou commented 3 months ago

Requiring the user to manually edit a dependency (this library) for it to compile is awful. I guess I will try the obsolete AsyncElegantOTA instead.

no need to edit.

just set a build flag: build_flags=-DELEGANTOTA_USE_ASYNC_WEBSERVER=1

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

StefanL38 commented 2 months ago

@mathieucarbou no need to edit.

just set a build flag: build_flags=-DELEGANTOTA_USE_ASYNC_WEBSERVER=1 Not everybody has the same knoweldge-level as you

can you please explain in detail in which file at which line do I set this build-flag?

ayushsharma82 commented 2 months ago

@StefanL38 just the matter of reading docs: https://docs.elegantota.pro/async-mode/#for-platformio

StefanL38 commented 2 months ago

Directly quoting what is written at the link

` Enabling Async Mode For Arduino IDE

Go to your Arduino libraries directory Open ElegantOTA folder and then open src folder Locate the ELEGANTOTA_USE_ASYNC_WEBSERVER macro in the ElegantOTA.h file, and set it to 1:

define ELEGANTOTA_USE_ASYNC_WEBSERVER 1

Save the changes to the ElegantOTA.h file.

You are now ready to use ElegantOTA in async mode for your OTA updates, utilizing the ESPAsyncWebServer library. For PlatformIO If you use PlatformIO then we can use a neat trick! You can set build_flags in your platformio.ini file that enables Async Mode of ElegantOTA.

Open platformio.ini file of your project Paste this line build_flags=-DELEGANTOTA_USE_ASYNC_WEBSERVER=1 at bottom Done! PlatformIO will now compile ElegantOTA in Async Mode!

Benefits of Async Mode Enabling async mode for ElegantOTA offers several advantages:

Non-blocking Operation: In async mode, ElegantOTA leverages the asynchronous web server capabilities of ESPAsyncWebServer. This means that OTA updates won't block your device's main loop. It allows your device to continue executing other tasks while handling OTA updates in the background.

Improved Responsiveness: Your device can remain responsive to user interactions or other processes during OTA updates, ensuring a smoother user experience. `

mathieucarbou commented 2 months ago

Example if you use PlatformIO (But in this case, it would have been better to read the doc about how to set build flags with PlatformIO).

image

The doc explains one way to do it. But setting build flags is common in C/C++ and specific to the IDE. This is a way to change the program behaviour from an external config flag. So it is up to the user to know how to set those by reading the manual of its IDE. A library cannot document all the possible ways to set flags for each IDE: this is completely impossible.

And It does not require any specific knowledge level - this is part of C/C++ basics about how to compile that anyone should know when dealing with C / C++ libraries. Arduino IDE has a doc about that, PlatformIO also, and @ayushsharma82 also added another alternative on his website, so it is more than enough IMO.