
www.rovingnetworks.com
Version 1.0r 9/21/2012
48
RN -W IFLYCR -U M
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. The sleep timer is set with the
set sys sleep
<
value
> command, where <
value
> is a
decimal number representing 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 seconds.
•
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
// The module sleeps after being awake for 30 s
set sys wake 90
// The module wakes after sleeping for 90 s
save
// Save the settings
reboot
// Reboot
Figure 9 shows the transitions between the sleep and awake state based on the sleep and wake timer settings in the
previous example.
Figure 9. Sleep & Awake State Transitions
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