I have an Arduino web server project going. Right now I'm trying to parse url parameters. For instance, I wish to make a GET request to http://(localip)/info and then have the "info" returned and displayed.
I don't know if I've been staring at the screen too long today, but I can't seem to match a simple char which is a single space... This shouldn't be complex in the slightest! All the advice I've found do not work. Yet, I need to break the loop on a space because that is an indicator where my url parameter ends. I want to be able to use /info as well as /something else.
char *data = (char *) Ethernet::buffer + pos;
String buff;
for (int x = 5; x<15; x++) {
Serial.print(x); Serial.print(" - |"); Serial.print(data[x]); Serial.println("|");
if ((data[x] == " ") || (data[x] == char(" ")) || (strcmp(data[x], " ") == 0)) {
x = 999;
break;
} else {
buff += data[x];
}
delay(5);
}
Serial monitor output. It should break on #9 and buff should equal just "info"
5 - |i|
6 - |n|
7 - |f|
8 - |o|
9 - | |
10 - |H|
11 - |T|
12 - |T|
13 - |P|
14 - |/|
buff -> info HTTP/
Aucun commentaire:
Enregistrer un commentaire