Atmel AVR2070 User Manual

Page of 93
 
30 
AVR2070 
8240B-AVR-06/09 
6.7 Sleeping Nodes 
A node that spends much its time asleep is good for battery life, but makes IP 
connectivity harder. If a node only wakes up every 5 minutes, attempting to ping the 
node will either fail or have a very long latency. The 6LoWPAN sleeping system 
contains an extension of the RUM sleeping system. The RUM sleep system provides 
a method to buffer some packets to a sleeping node. The RUM sleep system will 
buffer packets if memory is available, but does not guarantee a message will be 
delivered to a sleeping node. The 6LoWPAN sleep system extends this to guarantee 
buffering of a special ‘wake’ command to an end node.  
To communicate with a sleeping node, simply send messages to that node. When the 
node awakes the message should be delivered to it, provided sufficient memory was 
available to buffer the request. Since a node has a message delivered to it 
immediately when it awakes, it does not need to spend much time awake and hence 
saves considerable power. 
A node can also be forced awake. To use this simply send the ‘w’ character to port 
61618. This specific request is stored by the edge router. When the node awakes the 
original ‘w’ message it passed on to the end node. This transmits to the end node the 
IP address and UDP source port of the requesting computer. The end node will 
process the ‘w’ message, announcing to requesting computer it is now awake. The 
current code sends back the string ‘awake’ to the requesting computer. The node will 
then stay awake for a configurable timeout period where the default is seven 
seconds. If no activity is detected in seven seconds, the node goes back to sleep. 
Both the timeout period and the node polling interval are configurable. A short timeout 
and long polling interval means the node is spending the minimum amount of time 
awake, and will have the best battery consumption.  
The time between the node waking up and checking if it has new data is the 
‘SIXLOWPAN_PERIODIC_TIME’ variable. The time is defined in tenths of a second, 
and has a minimum value of 1/10
th
 of a second. For example the following would set 
a 2-second period: 
SIXLOWPAN_PERIODIC_TIME = 20; 
The amount of time the node waits before going back to sleep is set by the 
SIXLOWPAN_TIMEOUT_MS define. This is a value in mS, and has a minimum value 
of 50 mS and a maximum of 65000 mS. This is defined as a constant in 
sixlowpan_wake.h: 
#define SIXLOWPAN_TIMEOUT_MS 7000 
Additionally an application callback is provided. This will be called after a certain 
number of SIXLOWPAN_PERIODIC_TIME, and can be used to send periodic sensor 
readings for example. If this variable is set to ‘0’ the feature is disabled.  
SIXLOWPAN_PERIODIC_APP_TIME = 15; 
When using the SENSORS app with IPv6, the periodic app timer is set to a constant 
of ‘1’. The periodic time is a user-configurable variable, hence every time the node 
wakes up the periodic data is sent. This variable is set using the 'r' command 
described in section 5. 
In normal 6LoWPAN applications the SIXLOWPAN_PERIODIC_TIME and 
SIXLOWPAN_PERIODIC_APP_TIME are set in the sixlowpan_application_init() 
function. They can also be changed at run-time, for instance to switch to shorter sleep 
intervals during certain times of the day when power is abundant.