WiFly Shield code library alpha 1 release (also SPI UART)

[Update: See [WiFly Shield code library alpha 2 release (also SPI UART) for the latest release.][/i]
Thanks for your feedback on the [WiFly Shield code library alpha 0 release.
Mainly due to the support for the new 14MHz crystal frequency I’ve made an alpha 1 release available for download and testing: http://sparkfun.com/Code/wifly/WiFly-20 … lpha-1.zip
NOTE: If you have the older 12 MHz crystal board you need to change “USE_14_MHZ_CRYSTAL” value in SpiUart.cpp to ‘false’.
(The small rectangular component near Arduino pins 6 & 7 will be engraved with 12.288 if you have the older crystal frequency.) If you have the newer frequency no change is necessary.
The changelog for this release is:
```
*+ alpha 1 – 31 August 2010 – “August Gratitude”

  • Change default crystal speed to match new 14MHz crystal used.
    NOTE: People using the older 12MHz crystal will need to change
    “USE_14_MHZ_CRYSTAL” in SpiUart.cpp to ‘false’.

  • Added ability to set baud rate at runtime in SpiUart class.
    (Note: This ability to change the baudrate has not yet been propagated
    to the WiFly class.)

  • Renamed Spi.h to _Spi.h in order to avoid clashes with the other
    library by the same name as the IDE might (and has) mistakenly
    included ours instead of the the other one which results in
    confusing error messages.

  • Changed the case of the ‘examples’ directory so it gets displayed
    in the IDE correctly.*
    ```
    I’m still in the process of getting the source repository publicly viewable.
    Additional functionality will hopefully appear in the next alpha release.
    –Philip;](WiFly Shield code library alpha 0 release (also SPI UART) - SparkFun Electronics Forum)](WiFly Shield code library alpha 2 release - SparkFun Electronics Forum)

Thank you very much i am trying this one now.:slight_smile:

Has any one looked into the option of setting the IP via code? I am thinking of adding the wifly to a set of mobile robots and would like to manually control the ip’s that they have. I am more than willing to take a stab at adding the new function, but at the moment, I don’t have a wifly to test with.

Sean

DPontes:
After connecting the shield to the Arduino, and having it connected to USB port, should I get any LED to light up?

I was hoping to get some help regarding this…

Thanks in advance.

Yes it is it lights up without any code on arduino (green and yello leds)

and 3.3V pins as well.

i think its Vin pin need to be connected not 3.3V pin :)

:slight_smile: glad to be helpful

csbaum:
Has any one looked into the option of setting the IP via code? I am thinking of adding the wifly to a set of mobile robots and would like to manually control the ip’s that they have. I am more than willing to take a stab at adding the new function, but at the moment, I don’t have a wifly to test with.

My intention is to match the Ethernet begin() functionality for setting the IP address etc:
Ethernet.begin(mac, ip); 
Ethernet.begin(mac, ip, gateway); 
Ethernet.begin(mac, ip, gateway, subnet);

You can’t specify the MAC address with the WiFly though so that would require removing that value from the parameters (I’d like to be able to make it 100% compatible but I think that makes it unnecessarily complicated for WiFly users):

WiFly.begin(ip); 
WiFly.begin(ip, gateway); 
WiFly.begin(ip, gateway, subnet);

Without having looked at it too closely, implementing it should be fairly straightforward and would require disabling DHCP and then using the “set ip …” commands.

For reasons of compatibility the method of supplying the address should be the same as the Ethernet library.

It would be nice if there was someway to indicate Auto-IP and/or Ad Hoc network setup also but I haven’t considered the details for that.

–Philip;

Greating people,

Could you implement most functions to use Wifly with UDP protocol for the next release please ?

Existant functions are for TCP protocol …

Another idea if you want, Try to use another method for getting IP and other parameters from Wifly , because, to use parsed *char is very very slow …

Thx for your next release :wink:

Hello,

I’ve been using the Library1 alpha1 to read a sensor temperature and update a webpage every 5 minutes.

It’s working great but after sometime it’s stopping. Using some Serial.print() as debugger, I found that the issue is inside the function WiFlyDevice::waitForResponse. The board has difficulties to connect (my signal il quite poor) and the Wifly doesn’t send the OPEN. The issue is that there is no way out, the Arduino will die in this loop.

It may be great in a Alpha 2 to have some timeout in strategic functions. I tried to implement it but to no avail. Do you have any plan for such improvement?

Thanks

Hello,

I implemanted a very dirty timeout in WiFlyDevice::responseMatched(). After 500ms in the while (!uart.available()), we reboot the Wifly, and then the Arduino (using void (*softReset_OPEN) (void) = 0;).

It improved globally the stability but there are still issues in WiFlyDevice::skipRemainderOfResponse(), where the Arduino is sometimes blocked.

I have a poor Wifi signal in the room, that’s why sometimes the Wifly can’t connect properly. Isn’t there a way to handle such errors in a better way?

thanks

faquin:
The board has difficulties to connect (my signal il quite poor) and the Wifly doesn’t send the OPEN. The issue is that there is no way out, the Arduino will die in this loop.

It may be great in a Alpha 2 to have some timeout in strategic functions. I tried to implement it but to no avail. Do you have any plan for such improvement?

Yeah, I acknowledge that error/side cases aren’t handled at all (aside from hanging). I was keen to at least get the working case working. :slight_smile:

faquin:
After 500ms in the while (!uart.available()), we reboot the Wifly, and then the Arduino

It shouldn’t be necessary to reboot the WiFly and definitely not the Arduino.

I have a poor Wifi signal in the room, that’s why sometimes the Wifly can’t connect properly. Isn’t there a way to handle such errors in a better way?

When manually making connections I’ve occasionally had similar issues before. In those cases it was enough to repeat the open request and the connection was made (with the appropriate “OPEN” response). My suggestion would be, rather than rebooting things, monitor for the timeout, clear the response buffer and then attempt to connect again.

–Philip;

racine_20:
Could you implement most functions to use Wifly with UDP protocol for the next release please ?

Existant functions are for TCP protocol …

Did you have anything specific in mind? And do you know if the WiFly module is capable of it?

Another idea if you want, Try to use another method for getting IP and other parameters from Wifly , because, to use parsed *char is very very slow …

Can you please explain this request further?

Thanks for your feedback.

–Philip;

Hi Philip,

Thanks for your answer. I know that the dirty reset is not a great solution, juste looking around.

Resending the Open command is a good idea, but how to know the status of the Wifly? Is there a way to sniff the communication Arduino/Wifly without interfering with the sketch running?

I guess I can’t telnet the Wifly since only one connexion at the same time is possible…

I’ll try to write the timeout that resend the command after a while.

Any target date for Alpha2?

Hello,

So I implemented a timeout that exits after 200ms if the expected answer was not received. The command is resent.

I still had issues with the OPEN, and I found that when I sent this command, Wifly reply like this:

<2.21>*OPEN*

But actually between the <2.21> and the OPEN there is a slight delay, and thus we exit the skipRemainderOfResponse() to enter the responseMatched() but a \n is sent, and we exit again. So the OPEN is trashed.

It’s not always the case so I guess the delay depends of how long is it to get the connection to website.

I modified skipRemainderOfResponse() in order to wait 20ms when there is no more data available on the uart, and check again if the \n was not received.

It’s been on for around 16 hours now, polling every 5min.

I also added a check if the Wifly is connected to the SSID before sending the OPEN command. My reception is poor so I’d better make sure it’s still connected. I used the “show net” and look for the “Assoc=” which returns OK or FAIL.

Hope this can help for future revisions.

Thanks for your help yesterday.

I posted this on the Arduino forums as well. Follower suggested that I try here.

I’m following the Sparkfun tutorial:

http://www.sparkfun.com/commerce/tutori … als_id=158

I’m getting stuck trying the Transparent Terminal Sketch (Search the page for it, and it will come up as the 2nd hit).

I’m trying to execute the paragraph right after that. I’m trying to send the command “$$$” (no quotes) to enter the command mode of the WiFly.

When I hook up the system, I’m getting (In the Arduino Serial Monitor, TeraTerm, and Multi Terminal from Sourceforge):

WiFly Shield Terminal Routine

Bridge initialized successfully!

At this point I’ve tried entering the “$$$” command, and nothing else happens.

I’ve tried the other tutorials, and have not made progress with this shield (I can’t get the system to associate with wireless access points yet).

Once again, I’m worried I’m missing something basic.

I’ve tried both crystal settings (even though the crystal is clearly marked 14.7456).

It really seems to me that the Arduino is not interfacing correctly with the WiFly module. I’m not getting any information back from the WiFly.

I’m using an Arduino Diecimila with an external power brick (Thank you Michelle, SF Tech, for pointing me in the right direction on that one). I’ve tried two different computers, both running version 0021 of the Arduino IDE. Both computers with all three terminal programs.

StaticDet5:
I posted this on the Arduino forums as well.

Following on from there… :slight_smile:

The reason I suggested trying the library out is that it handles all the configuration and if the library example sketch doesn’t work then we know it’s something else.

Could you please try with the “WiFly_Autoconnect_Terminal” sketch from the library and see if it works?

–Philip;

My sincere apologies.

I seem to be having the same issue there.

I get:

WiFly Shield Terminal Routine

But nothing after that. No “Association failed”, or “Associated”

I deliberately changed the Credentials.h file to cause deliberate success or failure (I’ve even reconfigured my home network to open, then straight WEP, in case I was missing a setting). Nothing.

LED’s:

I’ve got a rapid green LED and pretty rapid yellow LED (but is is asynchronous to the green).

That means no IP address (The Green), and that it is sending and receiving data (The Yellow).

I’m not sure what data is being sent, as currently the module is unassociated with the network, AND I’m getting nothing over the serial monitor.

Changing the credentials back to legitimate credentials yields:

WiFly Shield Terminal Routine

On the serial monitor, but nothing further

And a rapidly blinking green LED on the shield (No IP address)

Any thoughts?

Hello StaticDet5,

try to load the basic terminal sketch. Then step by step, try to connect to the WIFI via the terminal, writting manually the necessary commands. The configuration is quite well detailled in the Wifly datasheet.

I’ve done that, but maybe you folks could help me.

I’ve tried using the Arduino Serial Monitor, Multi Terminal (from SourceForge, really nice terminal program), and TeraTerm.

What are the correct settings for the terminal?

I have the normal settings correct, 9600 baud, 8 data bits, 1 stop bit.

Anyone know about Parity (I have it set to off, but I’ve tried every option I can think of)

How about handshake (I hvae it set off as well, but tried every option)

Mode TX and RX? Carriage Return? Line Feed? Both?

Does it matter if I have Local Echo enabled (I like it enabled)

With the Arduino Serial Monitor (Can I use this, with version 0021)?

Line ending? No line ending?

Do I need to push -enter- after putting in $$$ ? (Tech support said no)

I’ve literally tried as many of the combinations above as I can think of, with both the Auto Connect sketch and the Terminal Sketch.

I’ve got the shield attached directly to the Arduino Diecimila, and no wires attached to the shield (naked shield). I have an external brick powering the shield, and the USB cable attached directly to my computer (I’m routinely trying two different computers). I’ve tried both crystal settings in the program (but my crystal is marked with 14.7456).

I know I’m repeating myself in parts of the post, but I feel like I’m missing something really basic here. I’ve done continuity tests on the shield and pins. The pins are connected to the chips on the board. I’ve run other sketches with the Arduino, and they all seem to be fine (including ones that report temperatures over the serial output).

Thank you folks SO much for looking at this for me.

First of all, try to send a text from arduino to the computer, with Serial.println(“Starting test sketch”);

if you never show it, there’s something wrong.

then i had issue to send data to the Wifly with arduino serial monotor, i had to use a specific application (minicom), but maybe that’s because i’m on a mac.

if correctly connected, the Wifly displays a welcome message on the uart, you’ll know when it’s working