Parsing HTTPGet Request

Hello!
I'm developing an irrigation system for my father, controlled from browser.
I have 2 forms in one page:
1 for switching on and off relays (currently working)
1 for setting start and stop times for sectors. (currenly not parsed)

one form sends http get request like:
192.168.0.77/?RELAY0=ON or ?RELAY0=OFF
i had no trouble in parsing this, thanks to the example in arduino library.

the other form, sends this kind of http get:
192.168.0.77/?sector=1&enabled=true&onhour=0&onminute=0&offhour=0&offminute=0
these are the parameters i need to parse.

First question:
is get better than post in arduino? Should i switch to post for easier parsing?

Second question:
how should i manage parsing?
since i have 2 standard types of message, should i add another parameter at first, turning request like:
?page=manage&RELAY0=ON
?page=settings&sector=1&enabled=true&onhour=0&onminute=0&offhour=0&offminute=0

all parameters are uint8_t except enabled, boolean.

I use:
Arduino Mega 2560
Ethernet Shield (WizNet 5100)
DS3231 RTC
4 Channel Relay

Timing works ok for all channels, hardcoding start and stop times worked for test purpose. This is the last brick to see the system at work! :slight_smile:

Thanks for any tip!

POST won't make it easier.

ok, thank you!

I have 2 forms in one page:

Why? Parsing would be a lot easier with ONE form.

all parameters are uint8_t except enabled, boolean.

Which is the same size.

Thank you. I have 2 forms because:
One form is to start and stop manually single sectors (relay) and is actually parsed and workin.
The other is to program automatic start with hour and minutes.
I will post full code when i'll finish comment translation!
Thanks again!

use strtok to parse the string. your delimiters are ?=&.
I use strtok to parse json strings and it is fast and efficient.
just note that the string is parsed in place. meaning the token (delimiter) is replaced with a null character.

http://www.cplusplus.com/reference/cstring/strtok/

Thank you! I'm working on it right now!