SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By markmsmith
#191976
Hello, I was hoping one of the experts on this fine forum could help me out. I've been trying to get a WiFly shield to work for the last several days but haven't had any luck. I can get it to associate and can send traffic back and forth manually using the Aruduino IDE serial terminal and connecting via netcat, but whenever I try to have the arduino program perform the commands, it just hangs while trying to look for part of the response after a reboot.

I'm using an Arduino Uno R3 (https://www.sparkfun.com/products/11021) with the SparkFun WiFly shield (https://www.sparkfun.com/products/retired/9954), which has RN-131C wifi module and the SC16IS750 SPI-to-UART chip to talk to it over SPI.
I've updated the wifi module to the latest firmware from the manufacturer, 4.81 (wifly-GSX Ver: 4.81 Build: r1988, Jul 26 2016 19:41:27 on RN-131).

My development environment is using the Arduino IDE 1.6.12, on Mac OS X 10.10.5 (Yosemite), with the arduino powered via the USB cable.

I'm using the newest library I can find, which is the SparkFun_WiFly_Shield_Arduino_Library (https://github.com/sparkfun/SparkFun_Wi ... no_Library). I've installed the library by cloning it from github and softlinking it in ~/Documents/Arduino/libraries/WiFly

If I upload the example sketch SpiUartTerminal (https://github.com/sparkfun/SparkFun_Wi ... rminal.ino), I can happily talk to the module, enter command mode, connect to wifi, and generally run commands to connect to a server or respond to a connection request. I've even gone so far as to manually send back a response to an HTTP GET request, typing out the headers and simple html for a page and it's all worked great.
However, when I try to run any of the other sketches, like WiFly_WebServer (https://github.com/sparkfun/SparkFun_Wi ... Server.ino), it just hangs when it gets to the setup step to join the network. I've made a copy of the example, modified Credentials.h to have my WiFi SSID and password and I've changed line 19 to:
Code: Select all
if (!WiFly.join(ssid, passphrase, WPA_MODE)) {
    Serial.println("Failed to associate :(");
and moved Serial.begin(9600) to the top of setup().

To try to debug it I've been trawling through the library's source and set DEBUG_LEVEL to 3 in WiFlyDevice.cpp (https://github.com/sparkfun/SparkFun_Wi ... ice.cpp#L3). That caused it to fail to compile, so I also had to remove the F() macro from line 31 of Debug.h (https://github.com/sparkfun/SparkFun_Wi ... ebug.h#L31).

Running with these changes gets me the following output:
Code: Select all
DEBUG: Entered WiFlyDevice::begin()
DEBUG: Entered reboot
DEBUG: Entered findInResponse
DEBUG: Want to match:
DEBUG: *READY*
DEBUG: Found:
DEBUG:
DEBUG: w
DEBUG: i
DEBUG: f
DEBUG: l
DEBUG: y
DEBUG: -
DEBUG: G
DEBUG: S
DEBUG: X
DEBUG:
DEBUG: V
DEBUG: e
DEBUG: r
DEBUG: :
DEBUG:
DEBUG: 4
DEBUG: .
DEBUG: 8
DEBUG: 1
DEBUG:
DEBUG: B
DEBUG: u
DEBUG: i
DEBUG: l
DEBUG: d
DEBUG: :
DEBUG:
DEBUG: r
DEBUG: 1
DEBUG: 9
DEBUG: 8
DEBUG: 8
DEBUG: ,
DEBUG:
DEBUG: J
DEBUG: u
DEBUG: l
DEBUG:
DEBUG: 2
DEBUG: 6
DEBUG:
DEBUG: 2
DEBUG: 0
DEBUG: 1
DEBUG: 6
DEBUG:
DEBUG: 1
DEBUG: 9
DEBUG: :
DEBUG: 4
DEBUG: 1
DEBUG: :
DEBUG: 0
DEBUG: 0
DEBUG:
DEBUG: o
DEBUG: n
DEBUG:
DEBUG: R
DEBUG: N
DEBUG: -
DEBUG: 1
DEBUG: 3
DEBUG: 1
DEBUG:
DEBUG:

DEBUG: M
DEBUG: A
DEBUG: C
DEBUG:
DEBUG: A
DEBUG: d
DEBUG: d
DEBUG: r
DEBUG: =
DEBUG: 0
DEBUG: 0
DEBUG: :
DEBUG: 0
DEBUG: 6
DEBUG: 8
DEBUG: A
DEBUG: Failed to reboot. Halting.
I've tried messing with the timeouts used for the call to findInResponse(), but with the same result, leading me to think it might be an issue of not reading from the buffer fast enough. I see that there's a function to enable hardware flow control, but since it does a 'save' of that config, I'm wary of ending up in a state where I can't get back in to command mode if the RTS/CTS lines aren't managed correctly. Also, since I'm only doing a baud rate of 9600 it didn't seem like I should need it (people only seem to talk about it for higher baud rates).

Anyway, sorry for the wall of text, hopefully I've included all the relevant details.
I'm open to any suggestions at this point for what to try next.
Thanks!