HTTP GET gives 400 bad request (telnet, arduino) -
for school project i'm building small arduino based weather station. station sends data php page (using cc3000) puts mysql database. code have worked few days ago , somehow stopped working now. problem 400 bad request server. code use follows
while (!client.connected()){ connect(); } client.fastrprint(f(" ")); client.fastrprint(page); client.fastrprint(f("?sensor=")); client.fastrprint(sensor); client.fastrprint(f("&&unit=")); client.fastrprint(unit); client.fastrprint(f("&&value=")); client.fastrprint(charbuffer); client.fastrprint(f("&&pass=")); client.fastrprint(f(" http/1.1\r\n")); client.fastrprint(f("host: ")); client.fastrprint(server); client.fastrprint(f(":80\r\n")); client.fastrprint(f("\r\n")); client.println();
now of code comes sample functions of adafruit. strange thing when use telnet send same request http 400 bad request back. when request url using browser php page accepts data , puts database. here command used in telnet.
get /weer/add.php?sensor=dht&&unit=c&&value=99.99&&pass= http:/1.1 host:www.---.nl
can me figuring out what's wrong request?
the server runs nginx 1.7.0 if helps
so, changed code uses buffer of format string compile string. buffer send using client.println. in end i'm still sending exact same message server, works. i'm guessing client.fastrprint screws things up.
string buffer = "get "; buffer += page; buffer += "?sensor="; buffer += sensor; buffer += "&&unit="; buffer += unit; buffer += "&&value="; buffer += charbuffer; buffer += "&&pass="; buffer += " http/1.1\r\n"; buffer += "host: "; buffer += server; buffer += ":80\r\n\r\n"; while (!client.connected()){ connect(); } client.println(buffer);
Comments
Post a Comment