Setting Up WiFly
Roving Networks' RN-XV "Wi-Fly" modules are marketed as drop-in replacements for the XBee 802.15.4. This article will describe how to connect to and setup the device.
Tools for the Job
If this really can simple replace an XBee, that is going to be the starting point. SparkFun Electronics sells an XBee Explorer USB board that I am going to use as a host board for the RN-XV.
Immediate Success!
This was remarkably easy! After seating the RN-XV in the Explorer board, I plugged it into my computer. The D1 and D3 LED indicators immediately started blinking.
Next, I started up PuTTY and connected to the board using a serial port (9600-N-8-1 with Flow Controll disabled are the device defaults).
The device immediately greeted me with the following message: "Auto-Assoc roving1 chan=0 mode=NONE FAILED".
So...what next? Accordingly to the User's Manual, the device operates in two different modes: data mode and command mode. When it is first started, the device operates in data mode. To enter command mode, all you have to do is send type '$$$' (without quotes) in PuTTY. The device will respond with 'CMD' to indicate that it is now in command mode and the "Auto-Assoc" messages will stop.
Until command mode is exited, the device will wait for incoming commands. All commands are terminated with a carriage return (abbreviated "<CR>"). Valid commands should be acknowledged with an "AOK" while bad commands should elicit an "ERR" response. To exit command mode, simply type "exit".
A Note about Ad-Hoc Configuration
Not everyone will have the Explorer board. You can start the RN-XV in ad-hoc networking mode, by holding PIO9 high (3.3V) at power up. At this time, this article is not exploring that option, but it may be the subject of future articles.
Connecting to a Local Network
The User's Manual lists all of the commands that can be used with the device. Here, we are just going to focus on getting the device up and running on my local, security enabled network.
DHCP
For now, I want to set the device to use DHCP. There are two DHCP modes: (1) get IP from access point, (3) reused IP address if lease is not expired. I prefer cached DHCP, so let's send that command:

You can inspect the settings of the device by issuing a "get ip " command. The network is not currently up, but you can see that the DHCP mode has been set to "CACHE". It should also be noted that the protocol mode (denoted by "PROTO") is currently set only to TCP.
Protocol
Since I want this to also be able to accept UDP messages, we need to add that capability right now by sending "set ip protocol 3". Where did that "3" come from?
The protocol is actually a bitmapped field that allows you to enable multiple modes at once. The User's Manual has an error in the protocol table!
| Value | Protocol |
| 1 | UDP |
| 2 | TCP (Client & Server) - Default |
| 4 | Secure (Only Receive packets from a stored IP address) |
| 8 | TCP (Client only) |
| 16 | HTTP Client |
The "3" comes from adding UDP's value (1) and TCP's value (2). It is interesting to note, the device will allow you to set a protocol mode of 10 (TCP Client & Server and TCP Client only). I don't really know what effect this would have, but the device readily accepts this combination.
Network ID
The device needs to know the SSID of the network it is expected to connect to. If your network's SSID contains spaces, replace them with '$'. As an example, the network "New Spin" would become "New$Spin".
Set the SSID with the command: "set wlan ssid New$Spin"
Security
The security configuration can be a little bit confusing. There are two network join modes that seem very similar. Mode 2 allows the device to join any network matching the stored security mode, whereas Mode 1 allows the device to join any network that matches stored settings (like security keys). If you select mode 2, you must also set the acceptable security mode using "set wlan auth". Mode 1 is the default and that is the mode that I want. So, all I need to do is set my security key:
![]()
Note: If you are using WEP, the RN-XV only accepts the 128-bit keys. So if you are still limping along on 64-bits, you are going to have to upgrade!
Commit
Up to this point, all of the changes have been temporary. This is great news if you made a critical mistake; you can just cycle power and all of the previously stored values will be returned. If you are happy with the changes you have made, simply send the following command: "save".
This will save your settings to the default configuration. If you want to save them to an alternate file, you can issue the save command with a filename as follows: "save alt_config". The alternate configuration can be loaded from command mode with: "load alt_config".
Reboot and Go!
Exiting at this point does not seem to make the device connect, but a reboot will. Just type "reboot" and your RN-XV will reboot itself while keeping the UART connection open. If you have configured everything correctly, you should be greeting with something like the following:

Parting Shots
This just wouldn't seem complete if I didn't prove to you (and to myself) that this thing actually works. With that, I provide the following bit of eye candy:

And now that the device is configured, I can enter command mode using telnet! Using PuTTY (this time in telnet mode), I connect to the device on port 2000. The device greets me with "*HELLO*" to indicate that I am connected. At this point, I can type "$$$" to enter command mode.
NOTE: Wireless configuration can be disabled using: "set ip tcp-mode 0x10".

