Search in string

I am trying to make a save function for my web server, running on an arduino ethernet (the one with ethernet onboard).

But my problem is when I try to find the values in the url from the GET from the form.

The link looks like this

http://domain/?humidityTarget=5&minRunTime=10&minRunTime=15&sStart=00%3A00&sStop=01%3A00&sUse1=1&sUse2=1&sStart=0&sStart=100&sStart=0&sStart=100&Save=Save

What I use to find the thing I look for, is this

Serial.println(inString.indexOf("Save=Save"), DEC);

But even when it is in the end of the url, it returns 0 (zero) and -1 when not found.

What can I be doing wrong?

else if (inString.indexOf("GET /dynamic.data") != -1)

I also use this, and it does what it should.

Entire source: Bathroom Exhaust Fan Controller - Pastebin.com

Here are some suggestions:

  1. Have you tried printing inString to make sure it is exactly what you expect? Just in case you're trying to process UTF16-encoded Unicode as if it is ASCII, or something similar.

  2. Be aware that the String class is memory-intensive and causes memory fragmentation. You only have 2K of RAM on an Arduino Uno, so you have room for very few strings as long as the example you gave.

dc42:
Here are some suggestions:

  1. Have you tried printing inString to make sure it is exactly what you expect? Just in case you're trying to process UTF16-encoded Unicode as if it is ASCII, or something similar.

  2. Be aware that the String class is memory-intensive and causes memory fragmentation. You only have 2K of RAM on an Arduino Uno, so you have room for very few strings as long as the example you gave.

inString does return what I expect

GET /?humidityTarget=5&minRunTime=10&minRunTime=15&sStart=00%3A00&sStop=01%3A00&sUse1=1&sUse2=1&sStart=0&sStart=100&sStart=0&sStart=100&Save=Save

and then a lot of other stuff that I will make it strip out later to use less memory. But I wanted to figure out why I could not search for it in the string.

UPDATE!

Think I fixed it... Will do some more testing, and finish the function.

Okay, I got that search function fixed, and it returns the values I expect. But now I got a new problem.

When reading the index file, I am trying to read one line into a string, process it, then print it out to the client, empty it, read the next line... and so on, but all I get now is numbers. I have been trying to use itoa to convert it again, but without luck. Any idea what I can do instead, or what I am doing wrong?

Source: Bathroom Exhaust Fan Controller - Pastebin.com (line 167 to 180)