1

Am trying to display whatever value is sent to my Arduino (mega + WiFi r3) web server how do I do it ? Thanks in advance.

Using this sample, the server listens for "ledOn" and then performs an action but I want the server to listen to any request coming from clients and display the requests in the serial monitor.

server.on("ledOn", [](){
// My code     
  });

1 Answers1

1

You use the ESP8266WebServer library in the ESP8266 on the combined board. The reference is in the README file and the library has good examples.

The function to get the request's URL is server.uri().

Usually to process the GET request the URL is not read with uri() function, but the resource part (the 'path') is matched with the on() functions in setup() as server.on("some/path", fncToHandle); and the URL parameters of a GET request are parsed by the WebServer library and made available with a set of functions:

const String & arg();
const String & argName();
int args();
bool hasArg();

the standard url parameters are after ? in form of name=value, separated by & like

 /some/path?name=John&lastName=Smith

snippets from SimpleAuthentication example:

from setup()

server.on("/login", handleLogin);

from handleLogin:

  if (server.hasArg("USERNAME") && server.hasArg("PASSWORD")) {
    if (server.arg("USERNAME") == "admin" &&  server.arg("PASSWORD") == "admin") {
Juraj
  • 3,490
  • 4
  • 18
  • 25