Go Down

Topic: WiFlySerial and WiFly RN-XV (Read 5161 times) previous topic - next topic

garrettlynch

#15
Jul 18, 2012, 02:20 pm Last Edit: Jul 18, 2012, 02:21 pm by garrettlynch Reason: 1
ok found the issue, this:

Code: [Select]
   // Build GET expression
   strRequest << F("GET ") << MY_SERVER_GET_URL << F("?count=") << iLoopCounter
   << F(" HTTP/1.0") << "\n"
   << F("Host: ") << MY_SERVER_GET << "\n"
   << F("Connection: close") << "\n"
   << "\n\n";
   // send data via request
   // close connection


is not a true or correct GET request (I don't know which it is or why and I would quite like to know why).  So my php check for the GET request was failing:

Code: [Select]
if ($_SERVER['REQUEST_METHOD'] == 'GET')

It didn't fail through the browser, command line or my Max/MSP tests as they are all true GET requests.  The request string is almost identical to the one in the WebClientGetPost example that comes with WiFly (I just changed the variable and value) so that must be wrong as it's normal to check php side if it's a GET or POST request (amongst some other checks to see if the request originates from the right source).

Thanks for all your help and patience pylon, this I think has been technically the most gruelling thing I've ever done.

Garrett

pylon

I found it: "\n" is just a newline, a correct client request must have "\r\n" to end a line.

client.println() does that automatically.

I haven't seen this detail though...

garrettlynch


I found it: "\n" is just a newline, a correct client request must have "\r\n" to end a line.


mmm I tried changing them all and no difference. 

Code: [Select]
// Build GET expression
    strRequest << F("GET ") << MY_SERVER_GET_URL << F("?count=") << iLoopCounter
    << F(" HTTP/1.0") << "\r\n"
    << F("Host: ") << MY_SERVER_GET << "\r\n"
    << F("Connection: close") << "\r\n"
    << "\r\n";
    // send data via request
    // close connection


What's strange is when I look at the output in the serial monitor, it looks like this:

Code: [Select]
$$$set u m 1 set u b 9600 vershow conn open www.mysite.com 80GET /in-progress/arduino-test/counter/index.php?count=17 HTTP/1.0
Host: www.mysite.com
Connection: close


The GET is pushed right up against the 80.  I tried a \r\n there as well (which would make sense since php doesn't see it as a GET) but it didn't make any difference.

pylon

Have you checked your Streaming library if the << operator is doing what you expect it to do? The standard Print class does not support that operator.

Quote
The GET is pushed right up against the 80


This is probably correct as "open www.mysite.com 80" is a command for the RN-XV. You don't see the response to it, which is probably CONNECT. Then you send the data for that connection which directly starts with a GET.

garrettlynch


Have you checked your Streaming library if the << operator is doing what you expect it to do? The standard Print class does not support that operator.


Rather than pick apart the streaming library ( I wouldn't know where to begin) I've tried this:

Code: [Select]
strRequest = "GET " + String(MY_SERVER_GET_URL) + "?count=" + iLoopCounter + " HTTP/1.0\n" + "Host: " + String(MY_SERVER_GET) + "\n" + "Connection: close\n\n\n";

which looks a lot more familar to me.  Works fine when the php GET check isn't there but fails with the check as the other string did.

Go Up