These are chat archives for esp8266/Arduino

20th
Sep 2015
brutzler
@brutzler
Sep 20 2015 15:52
Hi, is there somewhere a doc for the "ESP8266WebServer". Found nothing on reference.md or in the ESP-Book from Kolban. Actually setting up on the "advanced server"-example provided with the library. would like to see, what is coming back from browser on a method=get form. In the example I only see a "server.on as" a function like a jump distributor. In the keywords there are a lot of different things, but without explanation....
Martin Ayotte
@martinayotte
Sep 20 2015 16:30
@brutzler, although there is no details about it, the AdvancedWebServer.ino is printing the arguments of GET or POST in handleNotFound(). I've used that to create my own SaveConfig() from a POST form. In summary, server.args() returns the number of arguments, server.argName(i) allows to get the argument name, server.arg(i) and server.arg(name) actually return value of the argument, and there is also server.hasArg(name) which return boolean if argument exist.
brutzler
@brutzler
Sep 20 2015 16:52
Hey martin. You are my hero. The arg-stuff makes life for me very easy. I want to send two values to my ESP. With this:
<form action="/Uhrzeit" method="get">
<fieldset>
  <label for="Startzeit">Startzeit:</label>
  <input id="Startzeit" name="Startzeit" size="5" maxlength="5" value="02:00">
  <label for="Stopzeit">Endzeit:</label> 
  <input id="Stopzeit" name="Stopzeit" size="5" maxlength="5" value="04:00">
  <button type="submit" name="action" value="0">Werte senden</button> 
</fieldset>       
</form>
I get the needed infos already in the server.args(x) . Handling on "server.on("/Uhrzeit", handleTime);"
I like this :-)
sorry: server.arg(x) is correct
Martin Ayotte
@martinayotte
Sep 20 2015 17:08
@brutzler, if you don't want to bother parsing the whole form in your handleTime(), you can simply do something like 'if (servers.hasArg("Startzeit") { Startzeit = servers.arg("Startzeit") };'
brutzler
@brutzler
Sep 20 2015 17:24
@martinayotte: Thx fpr the hint. But there is no need for parsing. "handleTime()" is only called , if I press the button "Werte senden" in my website. And then the I know, that the two values are in server.arg(0) and server.arg(1).