Moderator: igrr
I haven't looked at esphttpd, I'm not even sure what you mean, but if you're talking about passing arguments to an URL and having the function do something with those arguments then that's perfectly doable with just the ESP8266WebServer.
Do you have an example code snippet to show this functionality?
Top-Dog wrote:Do you have an example code snippet to show this functionality?
This is not a full sketch, but should be enough to illustrate the point:
void TogglePin() {
if (server.method() == HTTP_GET) {
for ( uint8_t i = 0; i < server.args(); i++ ) {
if (server.argName(i) == "gpio") {
int pin = atoi(server.arg(i).c_str());
pinMode ( pin, OUTPUT );
digitalWrite(pin, !digitalRead(pin));
}
}
server.send ( 200, "text/plain", "OK.");
}
}
setup()
{
//Do whatever, set WiFi, server and such up
server.on ( "/togglepin", TogglePin );
}
You request the URL http://your.esp/togglepin?gpio=gpio_pin_number_here, like e.g. http://your.esp/togglepin?gpio=4 would toggle GPIO4. You can even toggle multiple pins in one URL with that code-snippet, if you like, as can be seen from the for - loop.