User`s guide

RN-WIFLYCR-UG
www.rovingnetworks.com Version 1.2r 4/30/13 page 57
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 corre-
sponds to a maximum 1.19 million waking hours. The sleep timer is set with the
set sys sleep <value> command, where <value> is a decimal number represent-
ing seconds.
Wake timer—Used to wake the module. It is a 22-bit number, which corresponds
to a maximum sleep time of 1,165 hours. The wake timer is set with the set sys
wake <value> command, where <value> is a decimal number representing sec-
onds.
Auto-connect timer—Used to open a TCP connection automatically.
Idle timer—Used to close a TCP connection automatically.
The sleep and wake timers are responsible for putting the module to sleep and waking
it up. If the sleep timer is enabled, the module automatically goes into deep-sleep, low-
power mode once the timer counts down to 0. The sleep timer is disabled if the module
has an IP connection or is in command mode.
For example, if you want the module to wake up, join a network, and be available to
accept TCP connections for 30 seconds every 2 minutes you would set the timers as
shown in the following example:
set wlan ssid my_net // Set the host name
set wlan passphrase my_pass // Set the passphrase
set sys sleep 30 // Module sleeps after being awake for
// 30 s
set sys wake 90 // Module wakes after sleeping for 90 s
save // Save the settings
reboot // Reboot
Figure 3-7 shows the transitions between the sleep and awake state based on the
sleep and wake timer settings in the previous example.
FIGURE 3-7: SLEEP & AWAKE STATE TRANSITIONS
3.4.1 UDP Sleep & Connection Timers
In UDP only protocol mode (set with the set ip proto 1 command), the autoconn timer
is used as an auto-sleep timer. When the module begins to transmit the first UDP data
packet, this timer begins counting down. When it reaches 0, the module sleeps.
You set the UDP auto-sleep timer using two commands, set sys autosleep and set
comm timer. The timer interval is a product of the autosleep value and the comm flush
timer (in ms). The timer is decremented every “product” milliseconds.
Awake State
Sleep State
Sleep Timer
30 s
Wake Timer
90 s
Sleep Timer
30 s