-->
Page 1 of 1

ESP8266WebServer, server.on callback does not work

PostPosted: Fri Nov 13, 2015 12:50 am
by Rudolf
After changing from WiFiServer to ESP8266WebServer, I have a problem with the "ESP8266WebServer.on" callback.
The setup is:
Code: Select allserver.on ( "/engines/", handleMotor );

The request is: "/engines/1000,1000"
That had worked before with
Code: Select allWiFiServer server(80);
...
Javasript
     request.open('GET', '/engines/' + Math.round(-left) + "," + Math.round(-right), true);
     request.send(null);

Unfortunately no longer with the ESP8266WebServer.on callback.

What I am doing wrong?

Regards, Rudolf

Re: ESP8266WebServer, server.on callback does not work

PostPosted: Fri Nov 13, 2015 10:24 am
by martinayotte
ESP8266WebServer.on() function always worked with a perfect match of the path, so "/engines/1000,1000" will never match with "/engines/".
What you should do is using arguments such as "/engines?arg1=1000&arg2=1000" and the path will match "/engines", you could then read the argument values.

Re: ESP8266WebServer, server.on callback does not work

PostPosted: Fri Nov 13, 2015 12:13 pm
by Rudolf
Hello Martin,
Thank you very much for the help. Now it works.

Unfortunately I have very little knowledge in the HTTP protocol.

For beginners like me it would be helpful to put in the top comment of the source code
some examples for the web browser URL line, like:
http://192.168.100.68/msg?msg=Have+a+gr ... %2C+Ray%21
seen at:
https://www.hackster.io/rayburne/esp826 ... ver-696587

Best regards, Rudolf

Re: ESP8266WebServer, server.on callback does not work

PostPosted: Sun Nov 15, 2015 2:00 pm
by mrburnette
Rudolf wrote:Hello Martin,
Thank you very much for the help. Now it works.

Unfortunately I have very little knowledge in the HTTP protocol.

For beginners like me it would be helpful to put in the top comment of the source code
some examples for the web browser URL line, like:

http://192.168.100.68/msg?msg=Have+a+gr ... %2C+Ray%21
seen at:
https://www.hackster.io/rayburne/esp8266-01-web-server-696587

Best regards, Rudolf


I'm Ray and I agree, such comments would be helpful for evolutionary coding... those wanting to evolve the example.
But, as a retired senior technical architect (fancy ol' engineer) who in his career worked for 3 years as a manager in an IT adult education group responsible for course development and initial course delivery and training of subordinate instructors, I can only say that no matter how well you explain something, there will always be exception cases. My Hackster.io series are "project" driven toward individuals who are wanting to get their feet wet with a working example. Attempting to include "extra" material in the write-up or in the code remarks is a nightmare since these ideas do not represent the working example provided in the ZIP. Going off topic in the project description simply creates a nightmare for me as the Hackster.io site generates personal emails to my gmail account with a request to login and provide assistance. It has gotten so bad, that I have taken a sabbatical from Hackster.io as I cannot keep up with all of the requests.

All that I promise my audience is that the examples and sample code will work as shown in the accompanying pictures and write-up. Somewhere, the end-user must take the time to learn the underlying concepts and become familiar with the next level of technology. The author of an article simply cannot hand-hold those wanting to move beyond the current example project.

Thank you for understanding,

Ray Burnette (rayburne)
https://www.hackster.io/rayburne