Hi -
I am using the WiFly-Arduino shield, with code linked to the new WiFly library (http://sparkfun.com/Code/wifly/WiFly-20 … 023939.zip).
Things work well - I can enter command mode, and configure the device. I can telnet into the device remotely. But, I am having trouble processing GET requests. I made a page that provides the epoch time within square brackets, with the goal of being able to timestamp data collected by the arduino. In setup(), I would want to
a) open a connection,
b) receive the serial data from the remote server,
c) process the serial character stream to extract the time string,
d) then drop the connection.
I can do a and b, but am not getting the expected results from parsing the string, and then the program hangs at the end of the GET request, without dropping back into command mode (as I have it coded).
Program looks like this:
#include "WiFly.h"
int epochTimeAtInit = 0;
void setup() {
Serial.begin(9600);
Serial.println("WiFly Shield Terminal Routine");
WiFly.begin();
SpiSerial.print("join Stanford\r\n");
delay(3000);
SpiSerial.print("open econet.stanford.edu 80\r\n");
delay(100);
SpiSerial.print("GET http://econet.stanford.edu/getEpochTime.php HTTP/1.1\r\n");
delay(100);
SpiSerial.print("HOST: econet.stanford.edu\r\n\r\n");
delay(100);
SpiSerial.print("close\r\n");
delay(100);
SpiSerial.print("exit\r\n");
delay(100);
//SpiSerial.print("$$\r\n");
char * epochTimeString;
char testChar;
boolean junk = true;
int iTimeString = 0;
while(SpiSerial.available()) {
testChar = SpiSerial.read();
if (testChar == '[') { junk = false;}
if (testChar == ']') { junk = true;}
if (junk == false) { epochTimeString += testChar; }
}
epochTimeAtInit = (int)epochTimeString;
Serial.print("Epoch Time = "); Serial.println(epochTimeString);
}
Serial output (from screen command) looks like this. The value in the brackets is the epoch time, so that’s good. Notice that the “Epoch Time =” part prints to the Serial port before the WiFly connection stuff, even though it appears afterwards in code. The cursor hangs after that last character and no typing prints to the screen. WiFly seems not to respond to command mode requests. I’m not sure how to proceed. Ideas? Anyone else trying to deal with GET requests? - Adam
WiFly Shield Terminal Routine
Epoch Time = `g
join Stanford
Auto-Assoc Stanford chan=11 mode=OPEN SCAN OK
Joining Stanford now…
<2.18>
Associated!
DHCP: Start
DHCP in 659ms, lease=2520s
IF=UP
DHCP=ON
IP=10.33.155.106:80
NM=255.255.248.0
GW=10.33.152.1
Listen on 80
open econet.stanford.edu 80
Connect to 171.66.69.32:80
<2.18>
HTTP/1.1 200 OK
Date: Wed, 21 Jul 2010 20:13:21 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.1.6
Content-Length: 12
Connection: close
Content-Type: text/html; charset=UTF-8
[1279743201]