Seeed-Shield / WiFi_Shield

WiFi library using WiFly.
https://github.com/Seeed-Studio/WiFi_Shield
3 stars 42 forks source link

HTTPClient always fails on first request. #1

Closed jlkalberer closed 11 years ago

jlkalberer commented 11 years ago

When I run the example wifly_http I always get the "Failed to connect" the first time around. Can you tell me why this happens?

Here is the output:

------- WIFLY HTTP -------- Try to join wifi Succeed to join wifi

Try to get url - http://httpbin.org/get?hello=world

Failed to connect.

HTTP/1.1 200 OK Server: gunicorn/0.16.1 Date: Fri, 22 Mar 2013 07:01:51 GMT Content-Type: application/json Content-Length: 189 Connection: close

{ "url": "http://httpbin.org/get?hello=world", "headers": { "Host": "httpbin.org", "Connection": "close" }, "args": { "hello": "world" }, "origin": "10.12.253.100" }CLOS

Try to post data to url - http://httpbin.org/post

HTTP/1.1 200 OK Server: gunicorn/0.16.1 Date: Fri, 22 Mar 2013 07:01:53 GMT Content-Type: application/json Content-Length: 286 Connection: close

{ "origin": "10.78.27.124", "files": {}, "form": {}, "url": "http://httpbin.org/post", "args": {}, "headers": { "Content-Length": "12", "Host": "httpbin.org", "Content-Type": "text/plain", "Connection": "close" }, "json": null, "data": "Hello world!" }CLOS

Enter command mode. Send "exit"(with \r) to exit command mode

xiongyihui commented 11 years ago

The result shows Arduino succeeded to connect http://httpbin.org/get?hello=world, but got a wrong response. It's likely the response data from WiFly to Arduino is not received correctly because Arduino's SoftwareSerial is not stable enough.

xiongyihui commented 11 years ago

Failed to connect.

is a debug message. You can disable debug message output by removing #define DEBUG in debug.h

jlkalberer commented 11 years ago

Thanks, but I am using a different HttpClient class than your library and I don't want to wrap the connect method in a while loop. The debug output is fine for me, I just want to try to make the connect method succeed every time (as long as the server can actually respond with a 200).

Is there any place to get new firmware for the WiFly? I saw that you had an wifly_update example which attempts to grab the new firmware from the FTP site but that didn't run for me last time I tried.

Thanks a ton for this library though. It is so much better than what is on the seeed wiki.

xiongyihui commented 11 years ago

You can get the firmware from rn.microchip.com. Ping rn.microchip.com to get the IP.

ftp server: ftp://rn.microchip.com ftp username: roving ftp passwd: Pass123

You can visit the ftp site through web browser to make sure your network can access rn.mirochip.com

jlkalberer commented 11 years ago

So if you add a delay after you connect to the wifi, the first request will work every time. I added this in the wifly_http example:

delay(3000);

I had to use these commands to get it to update in case anyone else has any issues:

set ftp address 0 set dns name rn.microchip.com save set ftp user roving set ftp pass Pass123 set ftp dir ./public ftp update wifly-EZX-AP.img factory RESET reboot