RN-WIFLYCR-UG WiFly Command Reference, Advanced Features & Applications User's Guide MODULES SUPPORTED: RN121 RN123 RN125 RN131 RN171 RN174 RN171XV (c) 2013 Roving Networks. All rights reserved. RN-WIFLYCR-UG Version 1.2r 4/30/13 Copyright (c) 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. Roving Networks assumes no liability for applications assistance or customer's product design. Customers are responsible for their products and applications that use Roving Networks components. To minimize customer product risks, customers should provide adequate design and operating safeguards. Roving Networks, Inc. 102 Cooper Court Los Gatos, CA 95032 +1 (408) 395-5300 www.rovingnetworks.com www.rovingnetworks.com Roving Networks products are not authorized for use in safety-critical applications (such as life support) where a failure of the Roving Networks product would reasonably be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing such use. Version 1.2r 4/30/13 page 2 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 ................................................................................. 9 2.3 Set Commands ............................................................................................. 10 2.4 Get Commands ............................................................................................ 35 2.5 Status Commands ........................................................................................ 37 2.6 Action Commands ........................................................................................ 40 2.7 File I/O Commands ...................................................................................... 43 Chapter 3. Advanced Features & Settings 3.1 Access Point (AP) Mode .............................................................................. 45 3.2 Configuration Web Server ............................................................................ 49 3.3 Putting the Module to Sleep & Waking It ...................................................... 55 3.4 System & Auto-Connect Timers ................................................................... 57 3.5 Wake on Sensor Input .................................................................................. 58 3.6 Wake on UART Activity ................................................................................ 59 3.7 Setting Debug Print Levels ........................................................................... 64 3.8 Using the Real-Time Clock Function ............................................................ 67 3.9 Time Stamping Packets ............................................................................... 69 Chapter 4. Advanced Applications 4.1 Sending Data using UDP ............................................................................. 71 4.2 Joining Networks & Making Connections ..................................................... 73 4.3 Making Connections ..................................................................................... 75 4.4 Using the HTML Client Feature .................................................................... 77 4.5 Upgrading Firmware Via FTP ....................................................................... 83 4.6 FTP Client .................................................................................................... 86 4.7 Wi-Fi Protected Setup (WPS) ....................................................................... 87 4.8 Ad hoc Networking Mode ............................................................................. 89 4.9 Analog Sensor Capability ............................................................................ 92 Appendix A. Default Configuration A.1 ADHOC PARAMETERS .............................................................................. 95 A.2 BROADCAST PARAMETERS ..................................................................... 95 A.3 COMM PARAMETERS ................................................................................ 95 A.4 DNS PARAMETERS .................................................................................... 95 A.5 FTP PARAMETERS .................................................................................... 95 A.6 IP PARAMETERS ........................................................................................ 96 www.rovingnetworks.com Version 1.2r 4/30/13 page 3 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 ............................................................................... 97 A.12 String Variable Sizes .................................................................................. 97 A.13 Restoring Default Configuration Settings .................................................. 98 Appendix B. Boot-Up Timing Values Appendix C. Supported Access Points Appendix D. Command Quick Reference Guide Appendix E. Known Problems Appendix F. Current Firmware Features & Fixes F.1 VERSION 4.00.1 4/19/2013 ....................................................................... 111 F.2 VERSION 4.0 3/27/13 ................................................................................ 111 F.3 Version 2.36/2.45 9/14/2012 ...................................................................... 112 F.4 Version 2.30 10/26/2011 ............................................................................ 112 F.5 Version 2.27 09/08/11 ................................................................................ 113 F.6 Version 2.23 04/03/2011 ............................................................................ 113 F.7 Version 2.21 07/11/2010 ............................................................................ 114 F.8 Version 2.20 06/14/2010 ........................................................................... 114 Appendix G. Document Information 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. This user manual is applicable to standalone RN131 and RN171 modules, as well as Roving Networks products based on these modules. For example, the RN171XV device incorporates the RN171 module; therefore, all RN171 hardware features apply to the RN171XV. Although there are some differences, the RN131 and RN171 modules support the same ASCII command set. Table 1-1 compares the RN131 and RN171 module features. TABLE 1-1: COMPARING THE RN131 & RN171 Feature RN131 RN171 Output power (PMAX) 18 dBm (fixed) 12 dBm (programmable) Lowest power 18 dBm 0 dBm (< 100 mA Tx current) On-board antenna Yes No Accurate sleep timer Yes (32 kHz) GPIO pins available No (+/- 10% error) 10, GPIO4 - 13 (GPIO1 - 3 are not available for use) 14, GPIO1 - 14 Refer to the RN131 and the RN171 data sheets on the Roving Networks website at http://www.rovingnetworks.com for more details on their hardware differences and for detailed hardware specifications. 1.1.1 Features * Fully qualified and Wi-Fi certified 2.4-GHz IEEE 802.11 b/g transceiver * FCC, CE, IC certified, and RoHS compliant * Ultra-low power: - Intelligent, built-in power management with programmable wakeup - Accepts 3.3-V power supply or 2- to 3-V battery when using boost regulators - RN131: 4 uA sleep, 35 mA Rx, 210 m Tx at 18 dBm (Tx power not configurable) - RN171: 4 uA sleep, 35 mA Rx, 185 mA Tx at 12 dBm (Tx power configurable) * Antenna options: - RN131: On-board ceramic chip antenna and U.FL connector for external antenna - RN171: RF pad * Hardware: - 8-Mbit flash memory and 128-Kbyte RAM, 2-Kbyte ROM, 2 Kbyte batterybacked memory - General-purpose digital I/O pins (RN131: 10 GPIO pins, RN171: 14 GPIO pins) www.rovingnetworks.com Version 1.2r 4/30/13 page 5 RN-WIFLYCR-UG - 8 analog inputs (14 bits, 1.2 V) - Real-time clock for wakeup and time stamping/data logging; auto-sleep and auto-wakeup modes * Network support: - Supports Soft Access Point (AP), ad hoc, and infrastructure networking modes - Push-button WPS mode for easy network configuration - On-board TCP/IP stack - Over the air firmware upgrade (FTP) - Secure Wi-Fi authentication via WEP, WPA-PSK (TKIP), and WPA2-PSK (AES) - Configuration over UART or wireless interfaces using simple ASCII commands - Built in networking applications: DHCP client, DNS client, ARP, ICMP ping, FTP client, TELNET, HTTP, UDP, and TCP 1.2 CONFIGURATION The WiFly module has two modes of operation: data mode and command mode. In data mode, the module can accept incoming connections or initiate outgoing connections. To configure parameters and/or view the current configuration, you must put the module into command mode (also called configuration mode). 1.2.1 Entering Command Mode By default, the module is in data mode after power up. Sending the escape sequence $$$ causes the module to enter command mode. You must send $$$ together quickly with no additional characters before or after. You must not send a carriage return () or line feed after the $$$ to enter command mode. The module replies with CMD to indicate it is in command mode. Once in command mode, you can configure the WiFly device using simple ASCII commands; each command ends with a carriage return . Most valid commands return AOK; invalid ones return an ERR description. To exit command mode, send exit . The module responds with EXIT, indicating that it has exited command mode and entered data mode. Note: There is a 250-ms time buffer before and after the $$$ escape sequence. If characters are sent before or after the escape sequence within this 250ms interval, the WiFly module treats them as data and passes them over the TCP or UDP socket, and the module will not enter command mode. You can view various parameters, such as the SSID, channel, IP address, serial port, and other settings, and configure them in command mode. You send commands to the module through the UART or via remotely via telnet. When using the UART interface, the communications settings should match the WiFly module's stored settings. The www.rovingnetworks.com Version 1.2r 4/30/13 page 6 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. In firmware version 4.0 and higher, the auto join feature is disabled by default. Enable it using the ASCII command set wlan join 1. You can disable the auto-associate feature (default behavior) using the set wlan join 0 command. This command prevents the WiFly module from attempting to associate with a network that does not exist. 1.2.2 Remote Configuration Using Ad Hoc Mode NOTICE Firmware version 4.0 and higher does not support ad hoc mode (these versions support soft AP mode). If ad hoc mode is required, use firmware version 2.38.3. Using ad hoc mode to configure the device eliminates the need for the module to be associated with a network access point. In ad hoc mode, the module creates it's own "on demand" network to which you can connect via your computer as you would with any other network. To enable ad hoc mode using hardware, set GPIO9 high (3.3 V) at power up. For the RN134 board, GPIO9 is on pin 1 on the jumper block (J2). For the RN174 board, GPIO9 is on the J6 connector. Upon power up with GPIO9 high, the WiFly module creates an ad hoc network with the following settings: SSID: Channel: DHCP: IP address: Netmask: WiFly-GSX-XX, where XX is the final two bytes of the devices MAC address 1 Off 169.254.1.1 255.255.0.0 With the ad hoc jumper in place, these settings override any saved configuration settings. From your computer, connect to the WiFly-GSX-XX network. This open network does not require a pass phrase or pass key. Currently the WiFly module only supports OPEN mode for creating ad hoc networks. www.rovingnetworks.com Version 1.2r 4/30/13 page 7 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. If your computer has both wireless and wired interface hardware, you may need to disable the wired LAN interface hardware before connecting to the ad hoc network. If the wired LAN is enabled, the computer may assign an IP address that is not on the same subnet as the WiFly module. Once connected with an appropriate IP address, telnet into the WiFly module on port 2000 using the following command: telnet 169.254.1.1 2000 The module issues the response *HELLO*. You can now enter command mode using the escape sequence $$$ and configure the module. In firmware versions 2.28 and higher, you can disable remote configuration, e.g., for security. To disable remote configuration, use bit 4 in the TCP mode register by issuing the command: set ip tcp-mode 0x10 www.rovingnetworks.com Version 1.2r 4/30/13 page 8 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. String text data, such as the SSID, is case sensitive. You can use shorthand for the parameters. For example, the following commands are equivalent: * set uart baudrate 115200 * set uart b 115200 * set u b 15200 Note: You cannot use shorthand for command keywords. For example, s uart baudrate 115200 is illegal. You can type numbers in decimal (e.g., 115200) or hexadecimal. To enter a number in hex, use 0x. For example, the hex value FF would be entered as 0xFF. 2.2 COMMAND ORGANIZATION There are five general command categories, as shown in Table 2-1. TABLE 2-1: COMMAND TYPES Command Type Description Set commands Set commands take effect immediately and are stored to memory when the save command is issued. Get commands These commands retrieve the stored information and display it. Status commands These commands display the interface status, IP status, etc. Action commands Use these commands to perform actions such as scanning, connecting, disconnecting, etc. File I/O commands Use these commands to upgrade, load and save configuration, delete files, etc. Note: You must save any changes you make using the save command or the module will load the previous settings upon reboot or power up. When the system boots, all configuration data is loaded into RAM variables from the configuration file. The set commands only modify the RAM copy of the system variables. In general, the IP, WLAN, and UART settings require you to save and reboot before they take effect because they operate upon power up. For example, you only associate, set the channel, and obtain an IP address once at power up. Most of the other commands, e.g., COMM settings and timers, take effect immediately, allowing you to change parameters on the fly, minimizing power usage, and saving flash re-write cycles. www.rovingnetworks.com Version 1.2r 4/30/13 page 9 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. broadcast Controls the broadcast hello/heartbeat UDP message. comm Sets the communication and data transfer, timers, and matching characters. dns Sets the DNS host and domain. ftp Sets the FTP host address and login information. ip Specifies the IP settings. option Supports optional and infrequently used parameters. sys Sets system settings such as sleep and wake timers. time Sets the timer server settings. uart Specifies the serial port settings such as baud rate and parity. wlan Sets the wireless interface settings, such as SSID, channel, and security options. 2.3.1 set adhoc beacon This command sets the ad hoc beacon interval in milliseconds, where is a decimal number from 0 to 65,436. Note: Default: This command applies only to firmware versions supporting adhoc networking mode. WiFly firmware versions 4.0 and higher do not support adhoc networking mode. 102 Example: set adhoc beacon 120 2.3.2 // Beacons are sent every 120 ms set adhoc probe This command sets the ad hoc probe timeout in seconds, where is the number of seconds. The probe timeout is the number of seconds the module waits for probe responses before declaring, "ADHOC is lost," and disabling the network interface. Note: Default: This command applies only to firmware versions supporting adhoc networking mode. WiFly firmware versions 4.0 and higher do not support adhoc networking mode. 5 Example: set adhoc probe 80 www.rovingnetworks.com Version 1.2r 4/30/13 // Sets the ad hoc probe timeout to 80 s page 10 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. 2: Default: 0 Example: set adhoc reboot 600 2.3.4 // Sets the reboot timer to 600 seconds set broadcast address
This command sets the primary address to which the UDP hello/heartbeat message is sent, where
is an IP address in the form ... with being a number between 0 and 255. Default: 255.255.255.255 Example: set broadcast address 192.168.1.50 // Sets the broadcast address to // 192.168.1.50 2.3.5 set broadcast backup
This command sets the secondary address to which the UDP hello/heartbeat message is sent, where
is an IP address in the form ... with being a number between 0 and 255. The secondary broadcast is also a UDP packet sent after the primary broadcast and is of 120 bytes. The secondary broadcast contains the primary broadcast (110 bytes) plus the module's MAC address (6 bytes) and IP address (4 bytes), for a total of 120 bytes. Default: 0.0.0.0 Example: set broadcast backup 192.168.1.5 // Sets the broadcast address to // 192.168.1.5 2.3.6 set broadcast interval This command sets the interval at which the hello/heartbeat UDP message is sent and is specified in seconds. The value is a mask that is ANDed with a free running seconds counter; if the result is all 0s, a packet is sent. For example: * * * * * www.rovingnetworks.com If the interval is 0x1, the module sends one packet every 2 seconds. If the interval is 0x2. The module sends two packets every 4 seconds. If the interval is 0x3, the module sends one packet every 4 seconds. If the interval is 0x6, the module sends two packets every 8 seconds. If the interval is 0x7, the module sends one packet every 8 seconds. Version 1.2r 4/30/13 page 11 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.8 // Sets the port to which the UDP heart // beat is sent to 55555 set broadcast remote This commands sets the port to which the backup UDP hello/heartbeat message is sent, where represents the port number. Default: 0 Example: set broadcast port 4444 2.3.9 // Sets the port to 44444 set comm $ This command sets character used to enter command mode to . You typically use this setting when $$$ (the default string used to enter command mode) is a possible data string. You must carefully note the new character. After you save this setting, upon every subsequent reboot the module ignores $$$ and looks for to enter command mode. Default: $ Example: set comm $ w 2.3.10 // Sets the string to enter command mode // to www set comm close This command sets the ASCII string that is sent to the local UART when the TCP port is closed, 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: *CLOS* Example: set comm close *port closed* 2.3.11 // Set the string to *port closed* set comm open This command sets the ASCII string that is sent to the local UART 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: *OPEN* Example: set comm open *port open* www.rovingnetworks.com Version 1.2r 4/30/13 // Set the string to *port open* page 12 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.13 // Set the string to *welcome* set comm idle This command sets the idle timer value, where is a decimal number representing the number of seconds. The idle timer value is the number of seconds during which no data is transmitted or received over TCP before the connection is closed automatically. Setting the timer to 0 (the default) means the module never disconnects when idle. Default: 0 Example: set comm idle 25 2.3.14 // Set the idle timer value to 25 s set comm match | This command sets the match character, where is a decimal number from 0 to 127 or a hex number from 0 to 7F. When this configuration option is set, the module sends an IP packet each time the match character appears in the data. You enter either as the decimal (e.g., 13) or hex (e.g., 0xd) equivalent of the of the ASCII character. Setting the match character to 0 disables matching. A match character is one of three available methods you can use to control TCP/IP packet forwarding. The other methods are set comm size and set comm time. For more information refer to ""UART Receiver & RTS/CTS Hardware Flow Control" on page 60. Default: 0 Example: set comm match 1 2.3.15 // Set the match character to a carriage // return set comm size This commands sets the flush size in bytes, where is a decimal number from 0 to 1,420 (at 9600 baud). When this configuration option is set, the module sends an IP packet each time bytes are received. Roving Networks recommends that you set this value as large as possible to maximize TCP/IP performance. Flush size is one of three available methods you use to control TCP/IP packet forwarding. The other methods are set comm match and set comm time. For more information refer to "UART Receiver & RTS/CTS Hardware Flow Control" on page 60. Default: 1420 Example: set comm size 1420 2.3.16 // Set the flush size to 1,420 bytes set comm time This command sets the flush timer, where is a decimal number representing milliseconds. When this configuration option is set, the module sends an IP packet if no additional bytes are received for ms. Setting this value to 0 disables forwarding based on the flush timer. www.rovingnetworks.com Version 1.2r 4/30/13 page 13 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. The module uses this value when offering the DHCP lease to each client associating with the module in soft AP mode. Default: 86400 Example: set dhcp lease 2000 2.3.18 // Sets the DHCP lease to 2,000 seconds set dns address
This command sets the IP address of the DNS sever, where
is an IP address in the form ... with being a number between 0 and 255. This address is automatically set when using DHCP; you must set the DNS IP address for static IP or automatic IP modes. Default: 0.0.0.0 Example: set dns address 169.64.1.1 2.3.19 // Set the DNS server address to // 169.64.1.1 set dns name This command sets the name of the host for TCP/IP connections to , where is up to 32 characters (32 bytes). Default: server1 Example: set dns name roving1 2.3.20 // Set the DNS host name to roving1 set dns backup This command sets the name of the backup host for TCP/IP connections to , where is up to 32 characters (32 bytes). The FTP client uses the backup string to download the firmware via the ftp update command. Default: rn.microchip.com Example: set dns backup roving2 2.3.21 // Set the DNS host name to roving2 set ftp addr
This command sets the FTP server's IP address of the FTP server, where
is an IP address in the form ... with being a number between 0 and 255. Default: 0.0.0.0 Example: set ftp addr 66.35.227.3 www.rovingnetworks.com Version 1.2r 4/30/13 // Set the FTP server to 66.35.227.3 page 14 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.23 // Set FTP server starting directory to // demo // Set FTP server starting directory to // demo\test // Set FTP server starting directory to the // root directory set ftp filename This command sets the name of the file that is transferred when issuing the ftp u command, where is the firmware image. If you specify any file other than the firmware image, the WiFly module downloads the file and issues the UPDATE FAIL=3 error. Default: Firmware version 4.0 and higher: wifly3-.img (RN131), wifly7-.img (RN171) Firmware lower than version 4.0: wifly-GSX-.img (RN131), wifly-EZX-.img (RN171) Example: set ftp filename my_data 2.3.24 // Sets the firmware image to be retrieved // via FTP as my_data set ftp mode This command sets the ftp mode, where indicates active or passive mode. Default: 0x0 Example: set ftp mode 0x1 2.3.25 // Enables active FTP mode set ftp remote This command sets the FTP server's remote port number, where is the port number. Default: 21 Example: set ftp remote 25 2.3.26 // Sets the FTP server's remote port to 25 set ftp time The command sets the FTP timeout value, where is a decimal number that is five times the number of seconds required. The module uses this timer to close the FTP connection automatically after the specified time. Default: 200 Example: set ftp timer 40 set ftp timer 80 www.rovingnetworks.com Version 1.2r 4/30/13 // Sets a 5-second timer // Sets a 10-second timer page 15 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.29 // Sets the user name to my_password set ip address
This command sets the WiFly module's IP address, where
is an IP address in the form ... with being a number between 0 and 255. If DHCP is turned on, the IP address is assigned and overwritten when the module associates with an access point. IP addresses are "." delimited. Default: 0.0.0.0 Example: set ip a 10.20.20.1 2.3.30 // Sets the WiFly module's IP address to // 10.20.20.1 set ip backup
This command sets a secondary host IP address, where
is an IP address in the form ... with being a number between 0 and 255. If the primary host IP is unreachable, the module attempts to reach the secondary IP address (if set). Default: 0.0.0.0 Example: set ip a 10.20.20.2 2.3.31 // Sets the WiFly module's secondary IP // address to 10.20.20.2 set ip dhcp This command enables/disables DHCP mode, where is a decimal number shown in Table 2-3. If you set this parameter, the module requests and sets the IP address, gateway, netmask, and DNS server upon association with an access point. Any previously set IP information is overwritten. TABLE 2-3: DHCP MODES Mode www.rovingnetworks.com Protocol 0 Turns DHCP off. The module uses its stored static IP address. 1 Turns DHCP on. The module attempts to obtain an IP address and gateway from the access point. 2 Enables automatic IP, which is generally used with ad hoc networks. 3 Turns on DHCP cache mode. The module uses a previously set IP address if the lease is not expired (or the lease survives reboot). 4 Enables DHCP server in soft AP mode. Version 1.2r 4/30/13 page 16 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.32 // Turns DHCP off set ip flags This commands sets the TCP/IP functions, where is a hex number referring to a bit-mapped register. See Figure 2-1. FIGURE 2-1: SET IP FLAGS COMMAND BIT-MAPPED REGISTER 7 6 5 4 3 2 1 0 TCP connection status. See Notes (1), (2). Bypass Nagle algorithm and use TCP_NODELAY. TCP retry enabled (for a total of 96 packet retries). UDP RETRY (attempts retry if no ACK from UDP). DNS host address caching enabled. ARP table caching enabled. UDP auto pairing enabled. Add 8-byte timestamp to UDP or TCP packets. Note 1: 2: If the module loses the link to an associated access point while a TCP connection is active, the TCP connection may hang or be in an inconsistent state. In some cases, the TCP connection will not recover. In firmware version 2.20 and higher, if the module regains the link to the access point within 60 seconds, the TCP connection will survive. In firmware prior to version 2.20, bit 0 specified the TCP copy function. If bit 0 is set (the default), TCP connections are kept open when the connection to the access point is lost. If bit 0 is cleared (e.g., by sending set ip flags 0x6), if the module loses the access point connection while TCP is connected, the connection is closed. Default: 0x7 Example: set ip flags 0x6 2.3.33 // Clear bit 0 set ip gateway
This command sets the gateway IP address, where
is an IP address in the form ... with being a number between 0 and 255. If DHCP is turned on, the gateway IP address is assigned and overwritten when the module associates with the access point. Default: 0.0.0.0 Example: set ip gateway 169.254.1.1 www.rovingnetworks.com Version 1.2r 4/30/13 // Sets the IP gateway to 169.254.1.1 page 17 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.1 set ip localport This command sets the local port number, where is a decimal number representing the port. Default: 2000 Example: set ip localport 1025 2.3.36 // Sets the local port to 1025 set ip netmask
This command sets the network mask, where
is an IP address in the form ... with being a number between 0 and 255. If DHCP is turned on, the netmask is assigned and overwritten when the module associates with the access point. Default: 255.255.255.0 Example: set ip netmask 255.255.0.0 2.3.37 // Sets the netmask to 255.255.0.0 set ip protocol This command sets the IP protocol, where is a bit-mapped register as shown in Figure 2-2. To be able to connect to the WiFly module over TCP/IP (for example using telnet), you must set bit 2 of the IP protocol register. For the module to accept both TCP and UDP set bits 1 and 2 (value = 3). FIGURE 2-2: SET IP PROTOCOL COMMAND BIT-MAPPED REGISTER 4 3 2 1 0 UDP. TCP server and client (default). Secure mode (only receive packets form an IP address that matches the stored host IP). TCP client only. HTTP client mode. Default: 2 Example: set ip protocol 18 2.3.38 // enables TCP and HTTP client mode set ip remote This command sets the remote host port number, where is a decimal number representing the port. Default: 2000 Example: set ip remote 1025 www.rovingnetworks.com Version 1.2r 4/30/13 // Sets the remote host port to 1025 page 18 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). Forces the module to use DNS first to resolve the IP address, even if the host IP is set. Reserved. Disables remote configuration for security purposes. Default: 0x0 Example: set ip tcp-mode 0x4 set ip tcp-mode 0x10 2.3.40 // Forces the module to use DNS // Disables remote configuration set opt jointmr This command sets the join timer, which is the length of time (in ms) the join function waits for the access point to complete the association process. is a decimal number representing the number of ms. This timer is also used as the timeout for the WPA handshaking process. Default: 1000 Example set opt jointmr 1050 2.3.41 // Sets the join timer to 1,050 ms set opt format The command sets the HTTP client/web server information, where is a bitmapped register as shown in Figure 2-4. See "Using the HTML Client Feature" on page 77 for more details. FIGURE 2-4: SET OPT FORMAT COMMAND BIT-MAPPED REGISTER 4 3 2 1 0 Automatically send an HTML header-based broadcast interval. Send users binary data (converted to ASCII hex). Sample the GPIO and ADC pins and format to ASCII hex. Appends &id=, where is the device ID string that was set using set opt device . Appends the following key/value pairs to the HTTP message: &rtc=