-->
Page 4 of 5

Re: Async Web Server --send multiline HTML?

PostPosted: Fri Oct 18, 2019 2:06 pm
by Pablo2048
Glad to hear.
You can not use standard sync client to get the ip address - you are on async one so (just guessing from my memory) you have to use something like request->client()->remoteIP();. You have to use this probably in asyncwebserver request handler and store this information somewhere in global variable...

Re: Async Web Server --send multiline HTML?

PostPosted: Fri Oct 18, 2019 4:47 pm
by Sirquil
Working remote IP.JPG
Working!!!
Remote IP is working...

Code: Select all   global:
   
   IPAddress ipREMOTE;
   
   setup:
   
   serverAsync.on("/Weather", HTTP_GET, [](AsyncWebServerRequest * request) {
   request->send_P(200, PSTR("text/html"), MAINPAGE, processor);
   ipREMOTE = request->client()->remoteIP();
   });

 
   processor function:
   
    if(var == F("CLIENTIP"))
      return ipREMOTE.toString().c_str();


Thank you Pavel your help is appreciated!

William

Re: Async Web Server --send multiline HTML?

PostPosted: Sat Oct 19, 2019 11:46 am
by Pablo2048
You are welcome. Just one thing - swap the two lines: first save the IP address to the variable and then call template processing. Otherwise you return ip address from previous request ;-)

Re: Async Web Server --send multiline HTML?

PostPosted: Sat Oct 19, 2019 5:27 pm
by Sirquil
You are welcome. Just one thing - swap the two lines: first save the IP address to the variable and then call template processing. Otherwise you return ip address from previous request ;-)


Done. Thank you Pavel.

William