Skip to content

Uri cannot be created from a flash string (WebServer.on calls) #4374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TD-er opened this issue Sep 30, 2020 · 0 comments · Fixed by #4429
Closed

Uri cannot be created from a flash string (WebServer.on calls) #4374

TD-er opened this issue Sep 30, 2020 · 0 comments · Fixed by #4429

Comments

@TD-er
Copy link
Contributor

TD-er commented Sep 30, 2020

Hardware:

Core Installation version: latest
IDE name: Platform.io
Computer OS: Windows 10

Description:

WebServer.on(...) function declaration now requires const Uri& uri.
However the Uri object cannot be constructed directly from a flash string.

Adding an extra constructor does seem to solve it, but I can't see why as the constructor of String also can handle a __FlashStringHelper* as argument

        Uri(const __FlashStringHelper* uri) : _uri(String(uri)) {}

N.B. this way of calling WebServer.on used to work just fine.

Sketch: (leave the backquotes for code formatting)

//Change the code below by your sketch
web_server.on(F("/"),                 handle_root);

Compiler output

C:/GitHub/TD-er/ESPEasy/src/WebServer.ino: In function 'void WebServerInit()':
C:/GitHub/TD-er/ESPEasy/src/WebServer.ino:180:36: error: no matching function for call to 'WebServer::on(const __FlashStringHelper*, void (&)())'
   web_server.on(F("/"),                 handle_root);
                                    ^
In file included from src\ESPEasy_fdwdecl.h:25:0,
                 from src\ESPEasy-Globals.h:28,
                 from C:/GitHub/TD-er/ESPEasy/src/ESPEasy.ino:92:
C:/users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.h:88:8: note: candidate: void WebServer::on(const Uri&, WebServer::THandlerFunction)
   void on(const Uri &uri, THandlerFunction handler);
        ^
C:/users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.h:88:8: note:   no known conversion for argument 1 from 'const __FlashStringHelper*' to 'const Uri&'
C:/users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.h:89:8: note: candidate: void WebServer::on(const Uri&, HTTPMethod, WebServer::THandlerFunction)
   void on(const Uri &uri, HTTPMethod method, THandlerFunction fn);
        ^
C:/users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.h:89:8: note:   candidate expects 3 arguments, 2 provided
C:/users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.h:90:8: note: candidate: void WebServer::on(const Uri&, HTTPMethod, WebServer::THandlerFunction, WebServer::THandlerFunction)
   void on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn);
        ^
C:/users/gijsn/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src/WebServer.h:90:8: note:   candidate expects 4 arguments, 2 provided
*** [.pio\build\custom_ESP32_4M316k_ETH\src\ESPEasy.ino.cpp.o] Error 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant