[Update: See [WiFly Shield code library alpha 2 release (also SPI UART) for the latest release.][/i] Hi all, I’ve been working on a library for the [Arduino WiFly Shield for the folks at SparkFun. The alpha 0 release of the WiFly library is now available for download and testing from: http://sparkfun.com/Code/wifly/WiFly-20 … 023939.zip The goal with this library is to make it–as much as possible–a “drop in” replacement for the [official Arduino Ethernet library. Once a wireless network is joined the library should respond in the same way as the Ethernet library. This means you should be able to take existing Ethernet examples and make them work wirelessly without too many changes. The library also provides a high-level interface for the “SC16IS750 I2C/SPI-to-UART IC” used in the shield but also [available separately. Usage
By way of example this is how you connect to a wireless network and use DHCP to obtain an IP address and DNS configuration: ```
*#include “WiFly.h”
void setup() {
WiFly.begin();
if (!WiFly.join(“ssid”, “passphrase”)) {
// Handle the failure
}
// Rejoice in your connection
}* * *From then on you can use the Client and Server classes (re-implemented for the WiFly) mostly as normal.* *You can supply a domain name rather than an IP address for client connections:* *
Client client(“google.com”, 80);* * *You can also retrieve the current IP address with:* *
Serial.println(WiFly.ip());* ``` This release of the library comes with three examples:
- WiFly_Autoconnect_Terminal: reimplementation from tutorial
- WiFly_WebClient: Ethernet WebClient demo with small WiFly changes
- WiFly_WebServer: Ethernet WebServer demo with small WiFly changes
You need to modify the file “Credentials.h” to supply your network’s name (SSID) and passphrase. Known issues This is an alpha release–this means it’s non-feature complete and may not be entirely reliable. I’ve tested it with the shipped examples and it mostly works for me. There are some known issues:
- Only supports WPA networks with passwords. If you have a network without a passphrase then it should work if you supply an empty string (or a dummy passphrase) but I have not tested this. If you have a WEP network you should probably use WPA instead. If that’s not an option then it should be possible to change the library code to set the WEP key rather than a WPA passphrase.
- Incomplete documentation
- Only tested with WiFly firmware version 2.18–earlier or later versions may or may not have issues.
- Only DHCP is supported–you can’t specify an IP address and DNS configuration directly.
- There are some situations (exact cause unknown but often it seems to be after initial programming) where the WiFly will fail to respond to requests. You may need to power-cycle the Arduino or try refreshing the page in your browser if it’s acting as a server.
- There’s a limit to how quickly you can refresh a page when acting as a server–this is because the library doesn’t handle dropped connections well at present. You can generally tell from the lights on the unit if it’s busy. (This is particularly obvious when a using a web browser (rather than something like ‘wget’) because after the page is loaded the browser makes an immediate request for the favicon. Once every five seconds or so should be fine depending on how big the page is. (This seems worse with Safari than Chrome.)
- None of the non-ethernet capabilities of the WiFly are yet exposed e.g. network scans, signal strength information etc.
- The code isn’t very robust for error states–in general it will hang rather than return useful information.
- We only have a 9600 baud connection between the Arduino and WiFly it should in theory be possible to be much faster.
- Passphrases or SSIDs that contain spaces or dollar signs ($) will probably not work.
License
The library is licensed under the LGPL. What Next?
and i am connected cant test WAP connection coz i am using hotels internet and even that i can accses router settings cant change them coz to many ppl using it.
And thank you for you hard work hope to see some updates
But I’m having a few problems connecting to a network. My WiFly is running the 2.18 firmware and my wifi network was WPA, but I’ve tried to connect it using no encryption too, but I still get nothing. It seems to get hung up at
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
Serial.println("Associated!");
}
I can see all the Serial.println’s that occur before this call, but after it, nothing, I don’t get confimation of weither or not Association failed, or worked. The strangest part of it all is that I when I look at my router logs, I can see a device that is connected with a 0.0.0.0 IP address…I’m assuming that’s the WiFly, but I don’t get any response from the terminal.
I’ve also tried using the WiFly Transparent Terminal Sketch http://www.sparkfun.com/commerce/images … rminal.zip, Whenever I pull up the terminal and enter in the $$$ it doesn’t return the CMD line. I just wanted to see if you guys think this is hardware related or if it’s software?
I can see all the Serial.println’s that occur before this call, but after it, nothing, I don’t get confimation of weither or not Association failed, or worked.
That means that the code hasn't made it past the association stage.
I’ve also tried using the WiFly Transparent Terminal Sketch http://www.sparkfun.com/commerce/images … rminal.zip, Whenever I pull up the terminal and enter in the $$$ it doesn’t return the CMD line. I just wanted to see if you guys think this is hardware related or if it’s software?
What Operating System are you using? As far as I can tell the Arduino Serial Monitor isn't very useful for communicating with the WiFly because it doesn't send newline characters.
On OS X I use “screen” as a terminal program but it’s not graphical. Windows people seem to use HyperTerminal or TeraTerm I think.
To get the same effect as the Transparent Terminal Sketch you can comment out the code “join” section of the code in the WiFly_Autoconnect_Terminal example that ships with the library. (I’ve discovered that a configuration change that the library makes seems to make the module no longer work with the Transparent Terminal. Which also reminded me that I forgot to mention the library makes a change to the configuration to enable hardware flow control and saves the change (unfortunately it won’t work without it being saved). To reverse the change you need to “set uart flow 0” and save the configuration again–it is best to do this after a reboot so other configuration changes don’t get saved.) (But if this configuration change was made it means that some successful communication happened!)
I suggest removing the join code and trying with a separate terminal program initially. At the moment there’s not enough detail to know if it’s hardware or software related.
then futher in the code in void autoconnect i found this
// Set authorization level to <auth_level>
SPI_Uart_print("set w a ");
SPI_Uart_println(auth_level);
delay(500);
Serial.print("Set wlan to authorization level ");
Serial.println(auth_level);
// Set passphrase to <auth_phrase>
SPI_Uart_print("set w p ");
SPI_Uart_println(auth_phrase);
delay(500);
Serial.print("Set security phrase to ");
Serial.println(auth_phrase);
just this part
// Set passphrase to <auth_phrase>
SPI_Uart_print("set w p ");
SPI_Uart_println(auth_phrase);
delay(500);
Serial.print("Set security phrase to ");
Serial.println(auth_phrase);
i needed to change to
// Set passphrase to <auth_phrase>
SPI_Uart_print("set w k ");
SPI_Uart_println(auth_phrase);
delay(500);
Serial.print("Set security phrase to ");
Serial.println(auth_phrase);
and just then i can connect to my hotels wireless which ssid is ‘3Com’ auth is 1 (WEP) and auth_phrase is D004…
thats how it worked for me hope it will help.
P.S. Sorry for doble posting but i want this library working to its max for my project
Has anyone put this thing under source control someplace, maybe with some documentation options? I just ask because I would probably contribute if it was easy to.
dustoaction:
Has anyone put this thing under source control someplace
Err, not yet, but given you're the second person to ask I'll bump doing so up the priority list a bit. :) Feel free to ping me again in a week or so if I don't get it done fast enough for your liking. :)
maybe with some documentation options?
What do you mean by "documentation options"?
I just ask because I would probably contribute if it was easy to.
The source is currently in a private hosted Mercurial repository and I will add a public repository and tracker to mirror it.
I’m not a huge fan of generated documentation but agree that the overall documentation needs to be improved. Have added it to the TODO list. Doxygen at least seems not to obscure the general readability of the comments as much as some systems do.