
www.rovingnetworks.com
Version 1.0r 9/21/2012
65
RN -W IFLYCR -U M
In your COM port redirector program, note your computer’s IP address, e.g., by typing the
ipconfig
command in the
Microsoft Command Window. Go to your terminal emulator and put the module into command mode. Type the
open
<
address
> <
port
> command. The server reports that the connection is open and you can type characters into the UART
window and see them on the server window or vice versa.
Setting Up Automatic Connections
Some applications require the module to connect to a remote server, send data, and then disconnect automatically upon
power up (or wakeup). You can configure the module to perform this functionality automatically.
Set the network SSID and security, and set
autojoin
to 1. When the module wakes up or is powered on, the auto-connect
timer causes the module to attempt a connection to the stored remote IP address and port. The sleep timer does not
decrement while this connection is open and the idle timer does not decrement while data is flowing. When data stops for
5 seconds the connection is closed; the sleep timer puts the module in deep sleep. The wake timer begins the cycle again
one minute later.
NOTE:
You can also use ad hoc mode (
autojoin
4); however, there will be a delay connecting to the ad hoc network
from the remote computer. Therefore, make the sleep timer large enough to allow the network to get set up
and the auto-connect to establish a TCP connection.
Example: Automatic Connection
set ip host
<
address
>
// Set up the 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)
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: Use GPIO6 & GPIO6 to Control Connections
set sys iofunc 0x20
// Enable GPIO5
set sys iofunc 0x40
// Enable GPIO6