User`s guide

RN-WIFLYCR-UG
www.rovingnetworks.com Version 1.2r 4/30/13 page 76
EXAMPLE 4-5: AUTOMATIC CONNECTION
4.3.2 Controlling Connections using GPIO5 & GPIO6
You can use GPIO5 to control the TCP connection. After you configure the pin with the
set sys iofunc command, the module attempts to connect to the stored IP address and
port when GPIO5 goes high and disconnects when GPIO5 goes low.
Similarly, you can monitor the connection status by reading GPIO6. When it goes high,
the connection is open; when it goes low, the connection is closed. Use the command
set sys iofunc command to enable GPIO6.
EXAMPLE 4-6: USE GPIO6 & GPIO6 TO CONTROL CONNECTIONS
4.3.3 Using DNS Settings
The module contains a built-in DNS client. If you do not specify the host’s IP address,
(i.e., it is set to 0.0.0.0), the module uses DNS protocol. When you set the host name
using the set dns name <string> command, the module automatically attempts to
resolve the host address. When the address is resolved, the module connects automat-
ically.
To manually look up a host’s IP address, use the lookup <string>command, where
<string> is the hostname.
EXAMPLE 4-7: USE DNS
4.3.4 Using the Backup IP Address/Connect Function
The module contains a feature for auto-retry and redundancy. If the host’s first IP
address connection fails, the module uses the backup IP (if set). If this fails (or is not
set), the module uses the first DNS name. If this fails (or is not set), the module uses
the backup DNS name (if set).
EXAMPLE 4-8: SET THE BACKUP IP ADDRESS
set ip host <address> // Set up remote machine’s IP address
set ip remote_port <value>// 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 connection upon incoming
// UART data (supported in firmware
// version 2.19 and higher)
set sys iofunc 0x20 // Enable GPIO5
set sys iofunc 0x40 // Enable GPIO6
set dns name my_server // Set the DNS host name to my_server
set ip backup <address> // Set the backup IP address