0

The ESP8266Webserver built in key-name pair parser does a nice job of accessing the arguments by name or by index.

For example, it is almost trivial to process the following http get request

http://retic.local/datetime_config_update?year=2024&month=10&day=10&hour=16&minute=27&second=23

by referring to the arguments like this

manSetTime(server.arg ("year" ).toInt(), \
           server.arg ("month" ).toInt(), \
           server.arg ("day" ).toInt(), \
           server.arg ("hour" ).toInt(), \
           server.arg ("minute" ).toInt(), \
           server.arg ("second" ).toInt() \
           );

I also want the user to be able to set Date/Time using Serial input (because feature creep). There appears to be many command line parser librarys available but was hoping the parser in the ESP8266Webserver library could be re-used and save some resources.

I had a poke around in the library files but I think the code is many levels above what I can grasp.

As such I was hoping someone may have already done this and could give some hints. Hints in terms of if its do-able or a waste of time and would be better to use one of the fore mentioned parser librarys.

I found Parsing-impl.h at C:\data\arduino-1.8.19\portable\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WebServer\src

and it contains code that looks like it processes the arguments but I cant see how to reuse it.

I was hoping I could create a object of type some class then pass a string like :year=2024&month=10&day=10&hour=16&minute=27&second=23" and have it do the hard work.

Any suggestions

2
  • ESP8266Webserver doesn't provide API for URL parsing, just the API for server that does it internally. So yeah, you can copy paste arg parsing implementation and try to reuse it. I am just not sure if it will be faster rather than simply splitting your string by &, and then by = to get keys and values. Commented Oct 10, 2024 at 10:12
  • Read POST - HTTP to understand how to post a data to a web server, then read how to handle a Post Request for ESP8266. Commented Oct 12, 2024 at 15:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.