ZigBee Power Management using Cyclic Sleep example for mbed XBeeLib By Digi

Dependencies:   XBeeLib mbed

Description

This example characterizes a device that needs to be continuously joined to the coordinator so it doesn't lose any incoming packets. A fast response to packets is not required so the radio can sleep for some time to save power while the coordinator buffers its packets.

The example configures the radio to poll its coordinator every 5 seconds to check if there is any packet for it. If there is one or more, it awakes and send the packets to the mbed micro-controller.

Setup

Firmware

In S2B modules, router firmware will not work for this example, because routers don't support sleep modes.
Make sure the XBee module has end-device firmware.
To flash new firmware into an XBee module, you need to use the XCTU software.

Network

Make sure the coordinator has at Cyclic Sleep Period (SP) option a value greater than XBee module.
In the example it is set to 5000 which represent 5000 mS or 5 seconds.
In the coordinator, when using X-CTU for configuration, the SP parameter has to be entered as the desired sleep time divided by 10 and in hexadecimal so to cope with the example it should be 5000 / 10 = 500 = 0x1F4 -> 1F4
On a router or coordinator, SP determines the transmission timeout when sending to a sleeping end device. SP also determines how long the parent will buffer a message for a sleeping child.

Demo run

While it is running, go to the "Console" tab of the X-CTU connected to the coordinator. Press the "Add API frame to the list" and paste following bytes that create a new broadcast transmit request packet:

7E 00 19 10 01 00 00 00 00 00 00 FF FF FF FE 00 00 48 65 6C 6C 6F 20 58 42 65 65 21 5A

Select the frame and press the "Send selected frame" button to send the frame ("Hello XBee!") to the XBee network.

Once the XBee device receives the frame, the radio will wake up to send it to mbed micro-controller, which will process and print the received data.

Verify that the XBee module has received the frame by accessing the serial console terminal. If it was successful, the "Hello XBee!" message will be displayed there.

After that, the radio will go to sleep again until new data is received.

Committer:
hbujanda
Date:
Mon May 11 18:03:37 2015 +0200
Revision:
0:4fadd116f813
Automatic upload

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hbujanda 0:4fadd116f813 1
hbujanda 0:4fadd116f813 2 #if !defined(__CONFIG_H_)
hbujanda 0:4fadd116f813 3 #define __CONFIG_H_
hbujanda 0:4fadd116f813 4
hbujanda 0:4fadd116f813 5 #define PATFORM_ARCHPRO
hbujanda 0:4fadd116f813 6
hbujanda 0:4fadd116f813 7 /** Library configuration options */
hbujanda 0:4fadd116f813 8 #define ENABLE_LOGGING
hbujanda 0:4fadd116f813 9 #define ENABLE_ASSERTIONS
hbujanda 0:4fadd116f813 10 #define FRAME_BUFFER_SIZE 10
hbujanda 0:4fadd116f813 11 #define MAX_FRAME_PAYLOAD_LEN 128
hbujanda 0:4fadd116f813 12 #define ENABLE_PM_SUPPORT
hbujanda 0:4fadd116f813 13
hbujanda 0:4fadd116f813 14 #define SYNC_OPS_TIMEOUT_MS 2000
hbujanda 0:4fadd116f813 15
hbujanda 0:4fadd116f813 16 #if defined(PATFORM_ARCHPRO)
hbujanda 0:4fadd116f813 17 #define RADIO_TX P4_28
hbujanda 0:4fadd116f813 18 #define RADIO_RX P4_29
hbujanda 0:4fadd116f813 19 #define RADIO_RESET P2_13
hbujanda 0:4fadd116f813 20 //#define RADIO_RESET NC
hbujanda 0:4fadd116f813 21 #define RADIO_SLEEP_REQ NC
hbujanda 0:4fadd116f813 22 #define RADIO_ON_SLEEP NC
hbujanda 0:4fadd116f813 23 #define DEBUG_TX P0_2
hbujanda 0:4fadd116f813 24 #define DEBUG_RX P0_3
hbujanda 0:4fadd116f813 25 #elif defined(TARGET_LPC1768)
hbujanda 0:4fadd116f813 26 #define RADIO_TX p9
hbujanda 0:4fadd116f813 27 #define RADIO_RX p10
hbujanda 0:4fadd116f813 28 #define RADIO_RESET p30
hbujanda 0:4fadd116f813 29 #define RADIO_SLEEP_REQ NC
hbujanda 0:4fadd116f813 30 #define RADIO_ON_SLEEP NC
hbujanda 0:4fadd116f813 31 #define DEBUG_TX P0_2
hbujanda 0:4fadd116f813 32 #define DEBUG_RX P0_3
hbujanda 0:4fadd116f813 33 #elif defined(TARGET_FRDM_KL25)
hbujanda 0:4fadd116f813 34 #define RADIO_TX PTD3
hbujanda 0:4fadd116f813 35 #define RADIO_RX PTD2
hbujanda 0:4fadd116f813 36 #define RADIO_RESET NC
hbujanda 0:4fadd116f813 37 #define RADIO_SLEEP_REQ NC
hbujanda 0:4fadd116f813 38 #define RADIO_ON_SLEEP NC
hbujanda 0:4fadd116f813 39 #define DEBUG_TX USBTX
hbujanda 0:4fadd116f813 40 #define DEBUG_RX USBRX
hbujanda 0:4fadd116f813 41 #elif (defined TARGET_LPC11U24)
hbujanda 0:4fadd116f813 42 #define RADIO_TX p9
hbujanda 0:4fadd116f813 43 #define RADIO_RX p10
hbujanda 0:4fadd116f813 44 #define RADIO_RESET p30
hbujanda 0:4fadd116f813 45 #define RADIO_SLEEP_REQ NC
hbujanda 0:4fadd116f813 46 #define RADIO_ON_SLEEP NC
hbujanda 0:4fadd116f813 47 #define DEBUG_TX USBTX
hbujanda 0:4fadd116f813 48 #define DEBUG_RX USBRX
hbujanda 0:4fadd116f813 49 #else
hbujanda 0:4fadd116f813 50 #error "Define a platform"
hbujanda 0:4fadd116f813 51 #endif
hbujanda 0:4fadd116f813 52
hbujanda 0:4fadd116f813 53 #endif /* __CONFIG_H_ */
hbujanda 0:4fadd116f813 54