RN-WIFLYCR-UG WiFly Command Reference, Advanced Features & Applications User’s Guide MODULES SUPPORTED: RN121 RN123 RN125 RN131 RN171 RN174 RN171XV © 2013 Roving Networks. All rights reserved. RN-WIFLYCR-UG Version 1.
Copyright © 2013 Roving Networks. All rights reserved. Roving Networks is a registered trademark of Roving Networks. Apple Inc., iPhone, iPad, iTunes, Made for iPhone are registered trademarks of Apple Computer. Roving Networks reserves the right to make corrections, modifications, and other changes to its products, documentation and services at any time. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete.
RN-WIFLYCR-UG Table of Contents Chapter 1. Introduction 1.1 Overview ........................................................................................................ 5 1.2 Configuration .................................................................................................. 6 Chapter 2. Command Reference 2.1 Command Syntax ........................................................................................... 9 2.2 Command Organization ................................................
RN-WIFLYCR-UG A.7 OPTIONAL PARAMETERS ......................................................................... 96 A.8 SYSTEM PARAMETERS ............................................................................ 96 A.9 TIME SERVER PARAMETERS ................................................................... 97 A.10 UART PARAMETERS ............................................................................... 97 A.11 WLAN PARAMETERS .......................................................................
RN-WIFLYCR-UG Chapter 1. Introduction 1.1 OVERVIEW The Roving Networks WiFly radio module is a complete, standalone embedded wireless LAN access device. The device has an on-board TCP/IP stack and applications, and in the simplest hardware configuration requires only four pins (power, TX, RX, and ground). Once you have performed the initial configuration, the device automatically accesses a Wi-Fi network and sends/receives serial data.
RN-WIFLYCR-UG - 8 analog inputs (14 bits, 1.
RN-WIFLYCR-UG default is 9,600 baud, 8 bits, no parity, 1 stop bit, and hardware flow control disabled. You can enter command mode locally over the UART interface at any time irrespective of an active TCP connection. Note: Roving Networks suggests using either the TeraTerm (Windows OS) or CoolTerm (Mac OS-X) terminal emulator program. When the WiFly module powers up, it attempts to auto-associate with the access point stored in its configuration settings if the auto join feature is enabled.
RN-WIFLYCR-UG It may take a few minutes for Windows to assign an IP address and connect to the network. You can check your computer’s IP address by running the ipconfig command in the Command Window. If connected, this command displays your computer’s IP address and netmask. Note: The automatically assigned IP address must be on the 169.254.x.y subnet, otherwise the WiFly module will not be accessible.
RN-WIFLYCR-UG Chapter 2. Command Reference Roving Networks WiFly modules support a variety of commands for configuration. This section describes these commands in detail and provides examples. 2.1 COMMAND SYNTAX To issue commands to the module, you send a keyword followed by optional parameters. Commands are case sensitive, and you cannot use spaces in parameters. Use a $ to indicate a space, e.g., MY NETWORK should be written as MY$NETWORK. Hex input data can be uppercase or lowercase.
RN-WIFLYCR-UG Once configuration is complete, you must save the settings to store the configuration data, otherwise it will not take effect upon reboot or reset. You can store multiple configurations using the save command, and you can load them using the load command. 2.3 SET COMMANDS These commands begin with the set keyword and include the categories shown in Table 2-2. TABLE 2-2: SET COMMANDS Parameter Description adhoc Controls the ad hoc parameters.
RN-WIFLYCR-UG 2.3.3 set adhoc reboot This command sets the reboot timer to reboot the module periodically every seconds. must be greater than 60 secs. To enable the automatic reboot feature, the reboot timer must be used in conjunction with the debug register (set system debug 0x80). Note 1: This command applies only to firmware versions supporting adhoc networking mode. WiFly firmware versions 4.0 and higher do not support adhoc networking mode.
RN-WIFLYCR-UG The minimum interval value is 1 (every 2 seconds) and the maximum value is 0xff (every 256 seconds). Setting the interval value to zero disables UDP broadcast messages. Default: 7 Example: set broadcast interval 6 2.3.7 // Sets the heartbeat UDP message // interval to 6 seconds set broadcast port This commands sets the port to which the UDP hello/heartbeat message is sent, where represents the port number. Default: 55555 Example: set broadcast port 55555 2.3.
RN-WIFLYCR-UG 2.3.12 set comm remote This command sets the ASCII string that is sent to the remote TCP client when the TCP port is opened, where is one or more characters up to a maximum of 32 (32 bytes). If you do not wish to use a string, use a zero (0) as the parameter. Default: *HELLO* Example: set comm remote *welcome* 2.3.
RN-WIFLYCR-UG The flush timer is one of three available methods you can use to control TCP/IP packet forwarding. The others are set comm match and set comm size. For more information refer to “UART Receiver & RTS/CTS Hardware Flow Control” on page 60. Default: 5 Example: set comm time 20 2.3.17 // Set the flush timer to 20 ms set dhcp lease This command sets the soft AP mode DHCP lease time to , where is the number of seconds.
RN-WIFLYCR-UG 2.3.22 set ftp dir This command sets the starting directory on the FTP server, where is up to 32 characters. To read/write to subfolders, use the \ character. To indicate the root directory, use a period. Default: public Example: set ftp dir demo set ftp dir demo\test set ftp dir . 2.3.
RN-WIFLYCR-UG 2.3.27 set ftp user This command sets the user name for accessing the FTP server, where is up to 16 characters (16 bytes). Default: roving Example: set ftp user my_username 2.3.28 // Sets the user name to my_username set ftp pass This command sets the password for accessing the FTP server, where is up to 16 characters (16 bytes). Default: Pass123 Example: set ftp user my_password 2.3.
RN-WIFLYCR-UG Using DHCP cache mode can reduce the time the module requires to wake from deep sleep, which saves power. The module checks the lease time; if it is not expired, the module uses the previous IP settings. If the lease has expired, the module attempts to associate and uses DHCP to obtain the IP settings. The DHCP cached IP address does not survive a power cycle or reset. Default: 1 Example: set ip dhcp 0 2.3.
RN-WIFLYCR-UG 2.3.34 set ip host
This command sets the remote host’s IP address, where is an IP address in the form ... with being a number between 0 and 255. You use this command to make connections from the WiFly module to a TCP/ IP server with the IP address . Default: 0.0.0.0 Example: set ip host 137.57.1.1 2.3.35 // Sets the remote host’s IP address to // 137.57.1.RN-WIFLYCR-UG 2.3.39 set ip tcp-mode This command controls the TCP connect timers, DNS preferences, and remote configuration options. is a hex number referring to a bit-mapped register as shown in Figure 2-3. Note: The TCPMODE register is available in firmware version 2.27 and higher. FIGURE 2-3: SET IP TCP-MODE COMMAND BIT-MAPPED REGISTER 4 3 2 1 0 Shorten the TCP connect timer (use with bit 1). Shorten the TCP connect timer (use with bit 0).
RN-WIFLYCR-UG 2.3.42 set opt replace This command sets the replacement character used to indicate spaces in the SSID and pass phrases string, where is the ASCII value of the character. Each occurrence of the replacement character is changed into a space. Only the WiFly command parser uses this replacement character. For example, to change the replace character to %, use the set opt replace 0x25 command (the ASCII value of % is 0x25). Default: 0x24 Example: set opt replace 0x25 2.3.
RN-WIFLYCR-UG The recommended range for is between 50 and 80. As is lowered, the module more frequently deauthenticates itself from the AP. This command applies in infrastructure mode only. It is not applicable in soft AP mode. Note: You must enable the link monitor for this feature to work. Default: 0 Example: set opt signal 70 2.3.47 // Sets the RSSI threshold to -70 dBm. If // the RSSI average falls below -70 dBm, // the module deauthenticates itself.
RN-WIFLYCR-UG // Sets power to 3.3 V when a // sampling event occurs set q power 0x04 2.3.49 set sys autoconn This command sets the auto-connect timer in TCP mode, where is a decimal number from 0 to 255 as shown in Table 2-5. Setting this parameter causes the module to connect to the stored remote host periodically as specified by .
RN-WIFLYCR-UG set sys launch_string This command sets the name of the application (indicated by ) that is launched when GPIO9 toggles from high to low after power up (e.g., by pressing the FN button on evaluation kits). You use this mechanism to invoke valid applications as shown in Table 2-7. TABLE 2-7: VALID APPLICATION STRINGS Note: Description web_app Launches the configuration web server. wps_app Launches the WPS application.
RN-WIFLYCR-UG TABLE 2-8: GPIO PIN USAGE, DEFAULT STATE & FUNCTIONALITY Bit Signal Name RN-131 RN-171 Default State Default State 0 GPIO0 N/A N/A - 1 GPIO1 N/A Input Unused. 2 GPIO2 N/A Input Unused. 3 GPIO3 N/A Input Unused. 4 GPIO4 Output Output Default Function Green LED. 5 GPIO5 Output Output Yellow LED. 6 GPIO6 Output Output Red LED. 7 GPIO7 Output Output Blue LED. 8 GPIO8 Input Output Unused.
RN-WIFLYCR-UG 2.3.52 set sys printlvl This command controls the debug print messages printed by the WiFly module on the UART, where is one of the values shown in Table 2-9. Refer to “Setting Debug Print Levels” on page 64 for more information. TABLE 2-9: DEBUG PRINT MESSAGE SETTINGS Value 0 Description Quiet mode. Messages are not printed when the module wakes up or powers up. 1 Print all status messages. 2 Print only critical network access point connection level status, e.g.
RN-WIFLYCR-UG 2.3.55 set sys trigger or With this parameter setting, the module wakes from sleep state using the sensor input 0, 1, 2, and 3, where is a decimal number referring to a bit-mapped register as shown in Table 2-10 and is a hex number. You use either or with this parameter setting. This command sets the sensor input(s) to wake on (0 to 3). Setting to 0 disables wake on sensor inputs.
RN-WIFLYCR-UG To configure GPIO pins as outputs, use the set sys mask command. Note: Default: GPIO pins 4, 5, and 6 are used by the firmware to blink the status LEDs. To set the default power up states for these GPIO pins, you must first disable their use by the firmware using the set sys iofunc 0x7 command. 0x0 Example: To configure power-up states of GPIO8 (output by default): set sys value 0x0100 set sys value 0x0000 2.3.
RN-WIFLYCR-UG 2.3.61 set time raw This parameter setting allows you to set the RTC raw value from the console, where is a decimal number in seconds. The RTC ticks at 32,768 Hz. Default: None Example: set time raw 1 2.3.62 // Set to 1 second set uart baud This command sets the UART baud rate, where is 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800. Note: Default: The RN134 evaluation board’s RS-232 interface cannot exceed 230,400 baud.
RN-WIFLYCR-UG 2.3.64 set uart instant This command immediately changes the baud rate, where is 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, or 921600. This command is useful when testing baud rate settings or when switching the baud rate “on the fly” while connected over TCP via telnet. Using this command does not affect configuration. The module returns the AOK response, and then the module exits command mode. Note: In firmware version 2.
RN-WIFLYCR-UG Using non-standard raw baud rates with hardware flow control can be more useful at speeds as the microcontroller interfaced to the module may be able to better match the UART speed and get better results. Table 2-12 shows the supported raw baud rates: TABLE 2-12: SUPPORTED RAW BAUD RATES Raw Baud Rate Comment 458,333 This is 460,800. 500,000 Raw baud rate. 550,000 Raw baud rate. 611,111 Raw baud rate. 687,599 Raw baud rate. 785,714 Raw baud rate. 916,667 This is 921,600.
RN-WIFLYCR-UG TABLE 2-13: SET WLAN AUTH COMMAND AUTHENTICATION MODES Value Authentication Mode 0 Open (Default) 1 WEP-128 2 WPA1 3 Mixed WPA1 and WPA2-PSK 4 WPA2-PSK 5 Not used 6 Ad hoc mode (join any ad hoc network) 8 WPE-64 Default: 0 Example: set wlan auth 4 2.3.
RN-WIFLYCR-UG 2.3.71 set wlan fmon This parameter is used in soft AP mode to detect if the individual client devices are active and in range of the module. This command sets the soft AP mode link monitor timeout threshold for the associated client device, where is a decimal number representing the number of seconds of client inactivity (i.e., no data received from the client device). When this timer expires, the module deauthenticates the inactive client.
RN-WIFLYCR-UG Default: 0 Example: set wlan join 4 2.3.75 // Create an ad hoc network set wlan key This command sets the WEP-64 or WEP-128 key, where is EXACTLY 26 ASCII chars (13 bytes) in hex without the preceding 0x. Hex digits greater than 9 can be either upper or lower case. If you are using WPA or WPA2, enter a pass phrase with the set wlan passphrase command.
RN-WIFLYCR-UG 2.3.78 set wlan number This command sets the WEP key number. The WEP key number must match the key number on the router or access point. You only need to set this parameter when using the WEP-64 or WEP-128 security modes. This setting is not required if you are using the WPA security mode. Default: 0 Example: set wlan number 1 2.3.
RN-WIFLYCR-UG 2.3.81 set wlan ssid This command sets the SSID with which the module associates, where is 1 to 32 characters (32 bytes). Note: Default: cannot contain spaces. If the SSID has spaces, use the $ character to indicate the space. For example, yellow brick road becomes yellow$brick$road. When you use the get wlan command to view the SSID, the module properly displays it as SSID=yellow brick road. roving1 Example: set wlan ssid my_network 2.3.
RN-WIFLYCR-UG 2.4.4 get dns This command displays the DNS settings. Example: get dns 2.4.5 // Show the DNS information get everything This command displays all of the configuration settings, which is useful for debugging. Example: get everything 2.4.6 // Show all configuration settings get ftp This command displays the FTP settings. Example: get ftp 2.4.
RN-WIFLYCR-UG 2.4.14 ver The command displays the firmware version. Example: ver 2.5 // Show the firmware version STATUS COMMANDS These commands begin with the keyword show and they return the current values of the system variables. In some cases, e.g., IP addresses, the current values are received from the network and may not match the stored values. Except where noted, the show commands do not have any parameters. 2.5.
RN-WIFLYCR-UG 2.5.5 show q This command displays the value of the analog interface pin, where is 0 to 7. The A/D reading is 14 bits with a range of 0 to 400 mV (therefore, the resolution is 24 uV). The output is in uV (1,000 millivolts). The module returns a value in the format 8xxxxx, where xxxxx is the voltage in microvolts sampled on the channel you requested. Note: If a web post or UDP broadcast samples the data, the data is shifted as described in “UDP Broadcast” on page 72.
RN-WIFLYCR-UG 2.5.8 show stats This command displays the current statistics, packet RX/TX counters, etc. The command returns the statistics shown in Table 2-16. TABLE 2-16: DISPLAY STATISTICS Statistic Description Conns The number of TCP connections. WRX Number of bytes received by the module over TCP. WTX Number of bytes transmitted by the module over TCP. RTRY Total number of TCP retries. RTRYfail URX UTX RXdrop Total number of TCP retries failed.
RN-WIFLYCR-UG 2.6 ACTION COMMANDS The action commands allow you to enter and exit command mode, join networks, etc. Except where noted, these commands do not have any parameters. 2.6.1 $$$ You use this command to enter command mode. You must type $$$ together quickly with no additional characters before or after. You must not type a carriage return () after the $$$ to enter command mode. The module replies with CMD to indicate it is in command mode.
RN-WIFLYCR-UG 2.6.5 factory RESET This command loads the factory defaults into the module’s RAM and writes the settings to the standard configuration file. You must type the word RESET in capital letters. After you type this command, you must reboot the module for the settings to take effect. Example: factory RESET 2.6.6 // Reset the configuration settings to the // factory defaults join This commands instructs the WiFly module to join the network indicated by .
RN-WIFLYCR-UG parameters, the module attempts to connect to the stored remote host IP address and remote port number. can also be a DNS host name that the module attempts to resolve. Default: Stored remote IP address and port Example: open 10.20.20.62 2000 2.6.11 // Open a connection to 10.20.20.62 // port 2000 ping This command pings a remote host, where is one of the parameters shown in Table 2-17 and is the number of pings to send.
RN-WIFLYCR-UG Default: 200 ms/channel Example: scan 30 2.6.15 // Scan for 30 ms/channel sleep This command puts the module to sleep. You can wake the module by sending characters over the UART or by using the wake timer. Example: sleep 2.6.16 // Put the module to sleep time This command sets the real-time clock by synchronizing with the time server specified with the time server (set time) parameters. This command sends a UDP time server request packet. Example: time 2.
RN-WIFLYCR-UG 2.7.5 boot image This command makes a file represented by the new boot image. Example: boot image 55 Note: 2.7.6 // Set the new boot image to a file // represented by filename 55 After changing the boot pointer to the new image, you must reboot the module to boot up with the new image. After the module boots up with new image, you must perform a factory reset on the module to initialize all the parameters to the factory default settings.
RN-WIFLYCR-UG Chapter 3. Advanced Features & Settings This chapter describes the WiFly module’s advanced features, including techniques to put the module to sleep, wake up, and methods to open a TCP connection when awake. It also describes the UART flow control, alternative GPIO functions, and the real-time clock. 3.1 ACCESS POINT (AP) MODE Roving Networks WiFly modules support several methods for accessing Wi-Fi networks. In addition to infrastructure mode and ad hoc mode, with firmware version 2.
RN-WIFLYCR-UG Table 3-1 shows the default AP mode settings. TABLE 3-1: DEFAULT AP MODE SETTINGS Setting AP Mode Default SSID WiFly-XXX-yy, where: • XXX is GSX for the RN131 and EZX for the RN171 • yy is the LSB byte of the module’s MAC address Channel 1 DHCP server Enabled IP address 1.2.3.4 Netmask 255.255.255.0 Gateway 1.2.3.4 When the module boots up in soft AP mode, other Wi-Fi-enabled devices (PCs, iPhones, iPads, Android tablets, etc.
RN-WIFLYCR-UG • Creates the soft AP network on channel 1. Note: This command does not survive power cycling. After a power cycle, the module behaves according to the wireless join policy determined by the set wlan join command. // Creates a soft AP network on channel // 11 with SSID MyNetwork apmode MyNetwork 11 3.1.
RN-WIFLYCR-UG 3.1.2.2 CHECK FOR THE LAST CONNECTED DEVICE OVER TCP In some cases, it is beneficial to know the IP address of last device that connected to the module over TCP or the last device to which the module connected over TCP. To find this address, use the show z command. This command does not survive a power cycle or reboot. Upon power up, if no device is connected over TCP, the show z command returns 0.0.0.0. 3.1.2.
RN-WIFLYCR-UG 3.1.2.6 GPIO4, 5 & 6 ALTERNATIVE FUNCTIONS GPIO4, 5, and 6 have alternative functions in soft AP mode as described in the advanced sections later in this document. You enable the alternative functions using the following commands: // Enables alternative functions set sys iofunc 0x70 The link monitor feature must be enabled to turn on the alternative functions in soft AP mode only. Table 3-2 shows the GPIO alternative functions. TABLE 3-2: GPIO ALTERNATIVE FUNCTIONS GPIO 3.
RN-WIFLYCR-UG 3.2.2 Using the Configuration Web Server Configuring the embedded WiFly module to associate with an AP in infrastructure mode involves the following process: 1. Invoke the module’s configuration web server. 2. Connect your client device (PC, smartphone, tablet, etc.) to the module’s soft AP network. 3. Access the module’s configuration web page from your client device’s web browser. 4. Save the settings (SSID and passphrase) in your web browser and exit. 3.2.2.
RN-WIFLYCR-UG 3.2.2.1.2 Invoke Configuration Web Server in Software If GPIO9 is not accessible using a pushbutton or jumper, an embedded microcontroller can invoke the configuration web server mode in software using the ASCII command run web_app. This command runs the configuration web server application and creates an AP network to which devices can join and configure the WiFly module from a web browser. 3.2.2.
RN-WIFLYCR-UG FIGURE 3-3: MODULE’S NETWORK NAME 2. Launch your web browser. 3. Type http://config to go to the home page of web server running on the module. The page has two tabs displayed by default: • Network Configuration—Used to set the AP?s SSID and passphrase. • Information—Displays information about the WiFly module. This tab displays the following information: - WiFly module’s MAC address - Module type (RN131 or RN171) - List of files on the file system - Battery strength 4.
RN-WIFLYCR-UG FIGURE 3-4: NETWORK CONFIGURATION TAB Note: If your wireless network is hidden (i.e., not broadcasting an SSID), it does not display in the scan output. In this case, you must manually enter the SSID. b) Type your AP’s security passphrase in the Passphrase box. c) (Optional) The module uses DHCP by default. If you want to assign the module a static IP, turn off the Check to enable DHCP option and enter the static IP, subnet mask, and gateway.
RN-WIFLYCR-UG FIGURE 3-5: TERMINAL TAB 3.2.4.2 MODULE CONFIGURATION TAB Click the Module Configuration tab (see Figure 3-6). In this tab you configure the WiFly module’s frequently used parameters such as device ID, UART baud rate, and flow control. You configure other parameters with ASCII commands in the Terminal tab. FIGURE 3-6: MODULE CONFIGURATION TAB 3.2.
RN-WIFLYCR-UG 3.2.5.1 IDLE TIMER The idle timer ensures that the client associated with the WiFly module’s AP network is not lost or unresponsive. If there is no interaction between the configuration web server and the client’s web browser for five minutes (default value), the WiFly module reboots to the boot image. To restart the configuration web server, you must invoke it in software or hardware as described previously.
RN-WIFLYCR-UG TABLE 3-6: METHODS FOR WAKING THE MODULE (SHEET 2 OF 2) Method Interface Description Wake timer Internal RTC The wake timer wakes the module based on the set sys wake command setting. FORCE AWAKE FORCE AWAKE pin An input pulse of at least 31 s (3.3 V) wakes the module. When the module wakes up from sleep, it takes time (in milliseconds) to initialize the internal hardware. During this time, any data that is sent to the WiFly module over the UART is not processed.
RN-WIFLYCR-UG 3.4 SYSTEM & AUTO-CONNECT TIMERS The WiFly module uses a real-time clock (RTC) to generate timers. The RTC is active even when the module is asleep, allowing you to put the module to sleep and wake it based on timer intervals. The module has the following timers: • Sleep timer—Used to put the module to sleep. It is a 32-bit number, which corresponds to a maximum 1.19 million waking hours.
RN-WIFLYCR-UG For example, if you want a UDP sleep timer of 40 ms, use the following commands: // Set auto-sleep value to 4 // Set comm timer to 10 ms (default value) set sys autosleep 4 set comm timer 10 The resulting UDP sleep timer is 4 x 10 ms or 40 ms. You could also set autosleep = 2 and comm timer = 20 ms to achieve the same effect. Roving Networks recommends using a minimum value of 2 (when the default flush time is 10 ms) to ensure that the UDP packet is transmitted.
RN-WIFLYCR-UG Table 3-9 describes the values to wake the module using individual sensor inputs. TABLE 3-9: SENSOR INPUT VALUES Wake on Sensor Input Value Command 0 1 set sys trigger 1 1 2 set sys trigger 2 2 4 set sys trigger 4 3 8 set sys trigger 8 WARNING The voltage on any sensor input CANNOT exceed 1.2-V DC or the module will be permanently damaged. The sensor inputs are rated 1.2-V DC, maximum. You must use a resistor divider when driving a sensor pin from the other 3-V pins such as RX.
RN-WIFLYCR-UG The first (or possibly multiple) byte sent to the module will likely be lost; therefore, you should take care to send a preamble byte to wake the module before sending valid data bytes. Alternatively, use the CTS input to wake the module and wait until it is ready to accept data. To enable this setting, use the set sys trig 2 command. Note: 3.6.1 On the RN-134 evaluation board revision 2, the resistor pack connecting the RX and CTS signals is not correctly connected to the sensors.
RN-WIFLYCR-UG 3.6.2.1 CONTROL GPIO DIRECTION WITH SET SYS MASK You can control the GPIO pin direction with the GPIO mask using the set sys mask command, where is entered as a hex number. The hex number represents a bitmask that controls each pin, where 1 = output and 0 = input. For example: // Sets all pins as inputs // Set only GPIO6 and GPIO7 set sys mask 0x0 set sys mask 0xc0 If you only need to set one bit in the mask, you need to read, mask, and set the value.
RN-WIFLYCR-UG FIGURE 3-8: GPIO PIN BITMASK 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 GPIO14 GPIO0 GPIO13 UART RTS GPIO1 GPIO12 UART CTS GPIO2 GPIO11 UART RX GPIO3 GPIO10 UART TX GPIO4 GPIO9 GPIO8 GPIO5 GPIO6 GPIO7 TABLE 3-10: Bit Signal Name GPIO PIN USAGE, DEFAULT STATE & FUNCTIONALITY RN-131 RN-171 Default State Default State Default Function 0 GPIO0 N/A N/A - 1 GPIO1 N/A Input Unused. 2 GPIO2 N/A Input Unused. 3 GPIO3 N/A Input Unused. 4 GPIO4 Output Output Green LED.
RN-WIFLYCR-UG ticular GPIO pin. If a bit is 0, then the corresponding GPIO pin is driven/read by the firmware per the default function. The I/O function is encoded as shown in Table 3-11. TABLE 3-11: Bit GPIO PIN ALTERNATE FUNCTION BITMASK Signal Name Direction Function 0 GPIO4 Output Disable the LED function so the I/O can be used as a GPIO pin. 1 GPIO5 Output Disable the LED function so the I/O can be used as a GPIO pin.
RN-WIFLYCR-UG To configure the module to connect using GPIO5 and GPIO6, use the following commands: set ip host
set ip remote set sys iofunc 0x70 save reboot // Set the IP address of the remote host // Set the IP port of the remote host // Set alternate function for GPIO4 - 6 // Store configuration // Reboot the module After executing these commands, run your application or other software on the remote host that opens and listens on the specified port.RN-WIFLYCR-UG 3.7.1.1 FIRMWARE VERSION 2.36 & HIGHER Firmware version 2.36 and 2.45 support a comma-delimited scan output format, which a microprocessor can use to parse the RSSI information.
RN-WIFLYCR-UG Table 3-13 describes the capabilities bit mask values. TABLE 3-13: CAPABILITIES BIT MASK VALUES Bit Mask Value Description 0004 Short slot time 0100 ESS (infrastructure mode) 0200 IBSS (ad hoc mode) 1000 Privacy (secure with WEP or WPA) 2000 Short preamble Table 3-14 describes the WPA bit mask values.
RN-WIFLYCR-UG 3.7.2 UART Heartbeat Messages In firmware version 2.22 and higher, the module can output UART heartbeat messages. The bit-mapped message is output periodically while the module is in data mode and not connected to a remote host. Messages are not output while in command mode. The heartbeat message encodes the module’s state for the embedded microprocessor. Based on the heartbeat message, the microprocessor can choose to change the configuration by going into command mode.
RN-WIFLYCR-UG Use the show time command to see the current time and uptime as shown below: <2.23> show t Time=08:43:10 UpTime=10 s To set the time, use the time command: <2. 23> show t Time NOT SET UpTime=8 s <2. 23> time <2. 23> show t Time=08:51:31 UpTime=15 s Note: The module must be associated with a network for the module to contact the sNTP server. The module can also be configured to get the time whenever it powers up using the set time enable 1 command.
RN-WIFLYCR-UG 3.9 TIME STAMPING PACKETS You can use the time stamping feature to append 8 bytes to a TCP or UDP packet automatically. The set ip flags 0x87 command enables the time stamp and keeps other default settings). The time stamp bits from MSB to LSB are: User’s TCP or UDP packet data 63..56 55..48 47..40 39..32 31..24 23..16 15..8 7..0 The 8 bytes represents the 64-bit raw value of the real-time clock register.
RN-WIFLYCR-UG www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG Chapter 4. Advanced Applications This section describes a variety of advanced applications for the WiFly module, such as sending data using UDP, associating with access points, using the HTML client feature, upgrading the firmware over FTP, etc. 4.1 SENDING DATA USING UDP UDP is a connectionless protocol: there is no initial handshaking between the hosts to set up the UDP connection and the receiver does not send an acknowledgement when it receives UDP packets.
RN-WIFLYCR-UG 4.1.1 UDP Auto Pairing With the UDP auto-pairing feature, the module temporarily stores the host IP address of the first remote device that sends a UDP packet to the module. This host IP address is stored in the module’s RAM, which is cleared when the module sleeps or power cycles. This feature allows the module to echo to any client that sends a UDP packet. EXAMPLE 4-3: TURN ON AUTO PAIRING // Set the host to 0.0.0.0 set ip host 0.0.0.0 set ip flags 0x40 4.1.
RN-WIFLYCR-UG The packet is 110 bytes of data as shown in Figure 4-1. FIGURE 4-1: UDP BROADCAST PACKET BYTE FORMAT Position 0 - 5 6 7 8 - 9 10 - 13 14 - 15 16 - 17 18 - 31 32 - 59 60 - 91 92 - 93 94 - 110 Access Point’s MAC Address (6 Bytes) Channel (1 Byte) RSSI (1 Byte) Local TCP Port (2 Bytes) RTC Value, MSB to LSB (4 Bytes) Pin 20’s Battery Voltage in mV, e.g.
RN-WIFLYCR-UG FIGURE 4-2: DISPLAY CURRENT NETWORK SETTINGS Find all available networks with the scan command as shown in Figure 4-3. FIGURE 4-3: FIND AVAILABLE NETWORKS If you are connecting to an open network, use the join command to associate with the access point. The scan list in Figure 4-3 shows that roving1 is an open access point. Type join roving1 (or join # 1) to associate with the network as shown in Figure 4-4.
RN-WIFLYCR-UG 4.3 MAKING CONNECTIONS To connect to the module, open an IP socket and connect to the module’s IP address. You can use telnet to test the connection; type open
in a telnet window. After the connection is open, you can type characters into the UART window and see them on the telnet window or vise versa. EXAMPLE 4-4: OPEN A CONNECTION open 10.20.20.RN-WIFLYCR-UG EXAMPLE 4-5: AUTOMATIC CONNECTION set ip host
// Set up remote machine’s IP address set ip remote_port // Set up the remote machine’s IP port set sys autoconn 1 // Automatically connect when ready set com idle 5 // Disconnect after 5 seconds with no data activity set sys sleep 2 // Sleep 2 seconds after connection is closed set sys wake 60 // Wake up after 1 minute of sleep set uart mode 2 // Use UART data trigger mode, which // causes the module to make a // TCP/HTTP conneRN-WIFLYCR-UG EXAMPLE 4-9: SET THE BACKUP DNS NAME set dns backup 4.4 // Set the backup host name USING THE HTML CLIENT FEATURE The module has a built-in HTML client. When enabled, the module can get or post data to a web server. For example, you can use the HTML client to post serial and/or sensor data to the host web server. This feature makes possible to provide Wi-Fi capabilities to applications such as GPS units, remote sensors, weather stations, etc. 4.4.
RN-WIFLYCR-UG 4.4.2 Built-In HTML Client Modes You can set up the module to post data to and get data from a web server automatically without an external host CPU. You enable these advanced web features using the set opt format command, where represents a bit-mapped register. Refer to “set opt format ” on page 19 for the bit function descriptions. Table 4-1 describes the wake reason values. TABLE 4-1: WAKE REASON VALUES Value Wake Reason 0 Undefined.
RN-WIFLYCR-UG EXAMPLE 4-11: CONNECT TO WEB SERVER EVERY 30 SECONDS Use the following commands to configure the module to connect to a web server every 30 seconds: set com remote GET$/ob.php?obvar=WEATHER // Setup the HTML string set sys auto 30 // Auto-connect every 30 seconds. set option format 1 // Send header automatically when // connection is open set ip proto 18 // Turn on HTTP mode = 0x10 + TCP // mode = 0x2 4.4.
RN-WIFLYCR-UG 4.4.5 Post Binary Data Web servers expect ASCII data. If the user data is binary, the module can convert it to ASCII format before sending it to the web server. EXAMPLE 4-13: EXAMPLE: CONVERT DATA FROM BINARY TO ASCII // Turn on HTTP mode = 0x10 and // TCP mode = 0x2 set dns name www.webserver.com // Set the web server name set ip host 0 // Turn on DNS set ip remote 80 // Set the web server port, 80 is // standard set com remote GET$/userprog.
RN-WIFLYCR-UG The resulting string sent to the server is: GET /userprog.php?DATA=0F3000001111222233334444555566667777\n\n The data format for this example is: 2 Bytes GPIO Channel 0 Channel 1 Channel 2 Channel 3 Channel 4 Channel 5 Channel 6 Channel 7 0F30 0000 1111 2222 3333 4444 5555 6666 7777 4.4.7 HTML Client Example: Posting Sensor Data Automatically In this example, the module connects to the web server at www.rovingnetworks.com/ server.
RN-WIFLYCR-UG FIGURE 4-5: SERVER RESPONSE You can view the data you sent to the Roving Networks web server at http://rovingnetworks.com/wiflys/view. 4.4.8 HTML Client Example: Posting UART Data to a Web server The module can post serial UART data in ASCII or binary format automatically. In this example, when the serial UART data comes in, the module connects and sends data to the web server in the following format: GET /server.
RN-WIFLYCR-UG With these settings enabled, the module connects to the web server every time it receives data on the RX line. Serial data is sent to the host web server according to the flush timer and the flush size. Note: You cannot append the sampled sensor data to the UART data. Enabling option format 7 with set uart mode 2 results in erroneous data. You can view the data you sent to the Roving Networks web server at http://rovingnetworks.com/wiflys/view. 4.
RN-WIFLYCR-UG 4.5.1 Upgrading with Multiple Image Format Files (Firmware Versions 4.0 & Higher) Firmware version 4.0 and higher introduces support for Multiple Image Format (.mif) files. .mif files contain the firmware image (.img) and associated applications and files to support all the features of firmware versions 4.0 and higher. Firmware versions 4.0 and higher can unpack the .mif file and install the applications and files into the module’s flash memory. Download the .
RN-WIFLYCR-UG 4.5.2 Upgrading Firmware to Version 4.0 To update the firmware from a version lower than 4.0, follow this process: 1. Update the firmware .img file to version 4.xx using the command: •ftp update wifly3-400.img// For RN131 module •ftp update wifly7-400.img// For RN171 module Reboot the module to boot into the new image. NOTICE You MUST reset the module to factory default settings at this point using the factory RESET and reboot commands. 2. Download the .
RN-WIFLYCR-UG After downloading, the firmware checks the image and compares it to the stored values in the file before committing the image to flash and updating the boot record. If the checksum fails, the module displays UPDATE FAILED=x and deletes the image. Note: You must reboot or power cycle the module to use the new firmware. To boot with different firmware, use the command boot image , which sets the current boot image as .
RN-WIFLYCR-UG 4.6.2 Creating Files on the FTP Server Once the module is configured to connect to the FTP server, it can create files on the FTP server. To create a file, you use the ftp put command, where is up to 64 bytes. This command creates a file on the FTP server with the name and prints the open string on the UART. By default, the open string is *OPEN*. After you see *OPEN* on the UART, you can begin writing data in to the file.
RN-WIFLYCR-UG The most common mode of WPS is the Push Button Mode (PBC) in which the user simply pushes a button on both the access point and the wireless client (e.g., the Roving Networks’ WiFly module). See Figure 4-6. FIGURE 4-6: PUSH-BUTTON WPS The module supports the WPS feature in firmware version 2.28 and higher. To upgrade to the current firmware version and download the WPS application, refer to the WPS application note on the Support page of the Roving Networks web site at http:// www.
RN-WIFLYCR-UG 4.7.1 Launching a WPS Application There are two ways to invoke a WPS function: • Using the run wps command in the console. • Using the ad hoc/factory reset pin (GPIO9). To invoke a WPS function using the ad hoc/factory reset (GPIO9) mode: 3. Enable the WPS function on GPIO9 using the set sys launch wps_app command. WPS on GPIO9 is disabled by default to avoid accidentally invoking the WPS function. 4. The WPS application is invoked when GPIO9 goes from low to high.
RN-WIFLYCR-UG track of the other active devices on the network by sending and receiving beacon and probe packets. In most cases, IP addresses are assigned through automatic IP, although one of the Wi-Fi devices can be configured as a DHCP server. Note: 4.8.1 Roving Networks supports ad hoc networking, however, going forward, ad hoc mode will be replaced with soft AP mode. Ad hoc mode and soft AP mode are mutually exclusive and cannot operate at the same time.
RN-WIFLYCR-UG so that other devices connecting to the module can be reached. You can also set the netmask to a smaller subnet if the other device’s IP addresses begin statically at the same subnet as the ad hoc device. set ip address 169.254.1.1 set ip netmask 255.255.0.0 set ip dhcp 0 Save your configuration and reboot. The module will be in ad hoc mode. The module can associate with an ad hoc network created by another device.
RN-WIFLYCR-UG With firmware version 2.22 and higher, the module can scan for networks while in ad hoc mode. Issuing the scan command temporarily disables ad hoc model while the module is scanning. Ad hoc mode is restored automatically when the scan completes. If you are connected to the module over telnet, the scan result is sent over telnet and ad hoc mode is restored. 4.9 ANALOG SENSOR CAPABILITY The module has 8 analog sensor inputs that can be driven between 0 to 1.2-V DC.
RN-WIFLYCR-UG To enable these modes, use the set q sensor command. EXAMPLE 4-20: SAMPLE ALL SENSOR INPUTS // Sample all sensor inputs set q sensor 0xff 4.9.2 Using the Built-In Sensor Power The modules contain an on-board sensor power pin, which is controlled by the set q sensor command. is a bit mask value that determines which sensor pins to sample when sending data using the UDP broadcast packet or the HTTP autosample function.
RN-WIFLYCR-UG NOTES: www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG Appendix A. Default Configuration This section describes the default configuration settings and how to restore them. A.1 ADHOC PARAMETERS Beacon Probe 102 (milliseconds) for ad hoc mode only 5 (seconds to look for beacons before declaring ad hoc is lost) for ad hoc mode only 0, for adhoc mode only Reboot A.2 BROADCAST PARAMETERS IP address Port Interval 255.255.255.255 55555 7 (seconds) Backup address0.0.0.0 Backup port0 A.
RN-WIFLYCR-UG Password Dir Timeout FTP_mode A.6 IP PARAMETERS DHCP IP address Net mask Local port Gateway Host Remote port Protocol MTU Flags TCP mode Backup A.7 ON (1 = enabled) 0.0.0.0 255.255.255.0 2000 0.0.0.0 0.0.0.0 2000 2 (TCP server and client) 1524 0x7 0x0 0.0.0.0 OPTIONAL PARAMETERS Device ID Join timer/WPA timer Replacement char Format Password Signal Average A.
RN-WIFLYCR-UG A.9 TIME SERVER PARAMETERS Enable Server address Zone 0 (disabled) 64.90.182.55 (fixed to port 123 - SNTP protocol) 7 (Pacific time, USA) A.10 UART PARAMETERS Baudrate Flow Mode Cmd_GPIO 9600 0 (disabled) 0 0 A.11 WLAN PARAMETERS SSID Channel External antenna Join mode roving1 0 (Automatic scan) 0 (Off - use on-board chip antenna for RN131 ONLY) 1 (Automatically scan and join based on SSID) for firmware version 2.36 (ad hoc mode) and lower 0 for firmware version 2.
RN-WIFLYCR-UG TABLE A-1: STRING VARIABLE SIZES Parameter Value (Bytes) comm Parameters open 32 close 32 remote 64 deviceid 32 A.13 RESTORING DEFAULT CONFIGURATION SETTINGS You can restore the default factory configuration settings in software and hardware. • Software—In command mode, use the factory RESET command to restore the defaults. This command automatically loads the default settings and executes a save command.
RN-WIFLYCR-UG Appendix B. Boot-Up Timing Values Table B-1 shows the boot-up timing values. TABLE B-1: BOOT-UP TIMING VALUES Function Description Time (ms) Power up Power up time from reset high or power good to boot code loaded. 70 Initialization Initialize ECOS. 50 Ready Load configuration and Initialize application 30 Join Associate using channel = 0 (full channel scan, mask = 0x1FFF). 80 Associate using channel = 0 (primary channel scan, mask = 0x421).
RN-WIFLYCR-UG NOTES: www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG Appendix C. Supported Access Points The module should work with any standard access point. Roving Networks has tested the module with the following access points: • • • • • • • • • • • • • • Cisco Aeronet series Linksys (both standard and open WRT Linux) Netgear WGR614 v8 , WNDR3700 v3.0 Netgear WGN54 DLINK dir-615 Airlink 101 Apple Airport express Buffalo networks Belkin F7D3302 v1.
RN-WIFLYCR-UG NOTES: www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG Appendix D. Command Quick Reference Guide Table D-1 through Table D-5 provide a listing of all available commands and their defaults. For more detailed information refer to “Command Reference” on page 9. TABLE D-1: SET COMMAND LIST (SHEET 1 OF 4) Command Default Description set adhoc beacon 102 Sets the ad hoc beacon interval in milliseconds. set adhoc probe 5 Sets the ad hoc probe timeout in seconds (ad hoc mode only).
RN-WIFLYCR-UG TABLE D-1: SET COMMAND LIST (SHEET 2 OF 4) Command set ftp time Default Description 200 Sets the FTP timeout value, where is a decimal number that is five times the number of seconds required. set ftp user roving Sets the user name for accessing the FTP server. set ip address 0.0.0.0 Sets the WiFly module’s IP address. set ip backup 0.0.0.0 Sets a secondary host IP address. set ip dhcp 1 Enables/disables DHCP mode.
RN-WIFLYCR-UG TABLE D-1: SET COMMAND LIST (SHEET 3 OF 4) Command Default Description set sys sleep 0 Sets the sleep timer. set sys trigger or 0x1 With this parameter setting, the module wakes from sleep state using the sensor input 0, 1, 2, and 3. set sys value 0x0 Sets the default value of the GPIO pins’ outputs upon power-up. set sys wake 0 Sets the automatic wake timer in seconds. set time address 64.90.182.
RN-WIFLYCR-UG TABLE D-1: SET COMMAND LIST (SHEET 4 OF 4) Command Default Description set wlan ssid roving1 Sets the SSID with which the module associates. set wlan tx 0 Sets the Wi-Fi transmit power, where is a decimal number from 1 to 12 that corresponds to 1 to 12 dBm. set wlan user – Reserved for future use. TABLE D-2: GET COMMANDS Command Description get adhoc Displays the ad hoc settings.
RN-WIFLYCR-UG TABLE D-4: ACTION COMMANDS Command Description close Disconnects a TCP connection. exit Exits command mode. factory RESET Loads the factory defaults into the module’s RAM and writes the settings to the standard configuration file. You must type the word RESET in capital letters. join Instructs the WiFly module to join the network indicated by .
RN-WIFLYCR-UG NOTES: www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG Appendix E. Known Problems The firmware has the following known issues: • Flow control—RTS may fail to de-assert quickly enough for some high-speed CPUs to stop sending data bytes correctly. For high-speed transfers at baud rates greater than 460,800, Roving Networks recommends limiting the RX data to the maximum Ethernet frame (1,460 bytes) and using a protocol to acknowledge that the remote host receives the data. www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG NOTES: www.rovingnetworks.com Version 1.
RN-WIFLYCR-UG Appendix F. Current Firmware Features & Fixes F.1 VERSION 4.00.1 4/19/2013 F.1.1 Features • Added a new feature to indicate the number of clients associated with the module in soft AP mode in the UART heartbeat message. F.1.2 Bug Fixes & Improvements • Fixed an issue in which the GPIO4, 5, and 6 alternate mode was not working. • Fixed an issue in which the link monitor was not working in infrastructure mode when auto join to a wireless network is disabled (set wlan join 0).
RN-WIFLYCR-UG • Deprecated the wps command. F.2.2 Bug Fixes • Fixed a bug wherein the UART would occasionally lock up upon performing the factory RESET command and while telnet session was in progress. • Fixed a bug in soft AP mode wherein the module would close the TCP connection upon another client being deauthorized. • Fixed an issue with the link monitor in AP mode to correctly age out stale clients. • Fixed an issue that would cause the module to crash due to a high-speed optimization error. F.
RN-WIFLYCR-UG • • • • F.5 VERSION 2.27 09/08/11 • • • • • • • • F.6 and WPAv2 with TKIP encryption. Added support for WEP shared mode Increased FTP filename size to 64 bytes Added a new reboot register in ad hoc parameters. This register is reserved for future development and should not be used. Please leave it to default values. Added a new debug register in the system parameters. This register is reserved for future development and should not be used. Please leave it to default values.
RN-WIFLYCR-UG scan command is issued, ad hoc is temporarily disabled and results of the scan are sent over telnet. • The behavior of the auto connect timer has changed. • Added the ability to set RTC from console. • Added a feature wherein the module can be put to sleep using GPIO8. F.7 VERSION 2.21 07/11/2010 • The firmware checksum the image (and compare to the stored values in the file) now before committing it to flash and updating the boot record after download.
RN-WIFLYCR-UG Appendix G. Document Information CONVENTIONS USED IN THIS GUIDE This manual uses the following documentation conventions: DOCUMENTATION CONVENTIONS Description Arial font: Italic characters Represents Referenced books Emphasized text A window A dialog A menu selection A field name in a window or dialog A menu path MPLAB® IDE User’s Guide ...is the only compiler...
RN-WIFLYCR-UG RECOMMENDED READING This user’s guide describes how to configure the RN131 and RN171 modules. The module-specific data sheets contain current information on the module specifications. Other useful documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources: RN131G & RN131C 802.11 b/g Wireless LAN Module Data Sheet This data sheet provides detailed specifications for the RN131 module. RN171 802.
RN-WIFLYCR-UG Index Symbols B .mif, upgrading with .................................................. 84 $$$ ........................................................................6, 40 escape buffer ...................................................... 6 baud rates ................................................................ 29 bit-mapped register ip flags............................................................... 17 ip protocol .........................................................
RN-WIFLYCR-UG open .................................................................. 75 timer .................................................................. 57 to FTP server .................................................... 87 to web server .................................................... 78 connections making .............................................................. 73 controlling connections ............................................ 63 creating ad hoc network .........................
RN-WIFLYCR-UG wlan .................................................................. 36 get commands ......................................................... 35 GPIO alternate functions .......................................22, 60 AP mode alternative functions .......................... 48 controlling connections with .............................. 63 default power-up value setting .......................... 26 disable LEDs..................................................... 60 output setting .........
RN-WIFLYCR-UG Network Configuration tab ....................................... 52 network status, show ............................................... 37 network, join ............................................................. 41 network, joining ........................................................ 73 network, point-to-point ............................................. 89 O open ......................................................................... 41 open connection...........................
RN-WIFLYCR-UG opt format.......................................................... 19 opt jointmr ......................................................... 19 opt password .................................................... 20 opt replace ........................................................ 20 opt signal .......................................................... 20 q power ............................................................. 21 q sensor ........................................................
RN-WIFLYCR-UG GPIO10 ............................................................. 30 heartbeat messages ......................................... 67 instant baud change setting .............................. 29 mode setting ..................................................... 29 posting data to web example ............................ 82 raw setting ........................................................ 29 TX pin setting .................................................... 30 wake on activity .........