I have an error when compiling. No clue on where the type conversion is occurring.
I don’t see a typo. Using Arduino IDE 1.8.13
Any help would be much appreciated.
BB
CODE
server.on(“/get”, HTTP_GET, [] (AsyncWebServerRequest *request) { <<<<<<< this line has error
int paramsNr = request->params;
ERROR MSG
Arduino: 1.8.13 (Windows 10), Board: “ESP32 Dev Module, Enabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 115200, None”
C:\Users\iabar\Documents\ESP32\4_WayServer_015a\4_WayServer_015a.ino: In lambda function:
4_WayServer_015a:328:29:
UPDATE – just determined the error is a related to “int paramsNr” type conversion.
error: cannot convert ‘AsyncWebServerRequest::params’ from type ‘size_t (AsyncWebServerRequest::)() const {aka unsigned int (AsyncWebServerRequest::)() const}’ to type ‘int’
int paramsNr = request->params;
Hi Barry.
I’m not sure, but I think you need to get the parameter as a String. Also, I think it is better to declare the variable outside the server.on().
Like this, for example:
String paramsNr;
int paramsNrInt;
server.on(“/get”, HTTP_GET, [] (AsyncWebServerRequest *request) {
paramsNr = request->params;
paramsNrInt = paramsNr.toIn();
I haven’t tried it. Let me know if this works.
Regards,
Sara
//Global Vars
String paramsNr;
server.on(“/get”, HTTP_GET, [] (AsyncWebServerRequest *request) {
paramsNr = request->params;
^^^ “This generates error “invalid use of non-static member function”
Hi.
Can you share your complete code with me?
Otherwise, it is very difficult to debug.
To share your code use a link to pastebin, github, google drive, or others.
Regards,
Sara
Thank you Sara. I continue to make progress.
I’m having trouble with the server.on(“/get”…
Possibly the “/get” thinks that the get is on the root (index.html) page. In my case is it NOT. I have a page which is “/wifi_config.html”
Tried putting the full URL in front of the /get but this IF statement keeps failing. Also tried removing the ‘/’ from the front of “get” and no luck with that either.
All of the online examples are working from root (index.html) and I can’t find a good detailed explanation of what should be included.
[code]
server.on(“/get”, HTTP_GET, [] (AsyncWebServerRequest *request) {
^^^^ THIS IS THE PROBLEM
String inputMessage;
String inputParam;
Serial.println(“in server.on /get”);
if (request->hasParam(htmlssid)) {
inputMessage = request->getParam(htmlssid)->value();
inputParam = htmlssid;
Serial.print(“Value: “);
Serial.println(inputParam);
Serial.println();
Serial.println(inputMessage);
[/code]
Hi.
Can you show me the form in your HTML file? So that I can test the example and try to see what’s going on.
Thanks.
Regards,
Sara
I think you may be missing the way server.on() works. Yours is waiting for a URL of the form “<ESP_IP>/get?<htmlssid>=<value>”. eg. 192.168.1.22/get?myssid=helloworld. So, on your “/wifi_config.html” page you would have a link to that URL.
I hope I explained that OK?
Reading through the ESPAsyncWebServer documentation you see that request->params is not an int, it’s a function – request->params() and the return from that function is an int (the number of parameters sent).