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.

config.h

Committer:
hbujanda
Date:
2015-05-11
Revision:
0:4fadd116f813

File content as of revision 0:4fadd116f813:


#if !defined(__CONFIG_H_)
#define __CONFIG_H_

#define PATFORM_ARCHPRO

/** Library configuration options */
#define ENABLE_LOGGING
#define ENABLE_ASSERTIONS
#define FRAME_BUFFER_SIZE   10
#define MAX_FRAME_PAYLOAD_LEN  128
#define ENABLE_PM_SUPPORT

#define SYNC_OPS_TIMEOUT_MS       2000

#if defined(PATFORM_ARCHPRO)
#define RADIO_TX            P4_28
#define RADIO_RX            P4_29
#define RADIO_RESET         P2_13
//#define RADIO_RESET         NC
#define RADIO_SLEEP_REQ     NC
#define RADIO_ON_SLEEP      NC
#define DEBUG_TX            P0_2
#define DEBUG_RX            P0_3
#elif defined(TARGET_LPC1768)
#define RADIO_TX            p9
#define RADIO_RX            p10
#define RADIO_RESET         p30
#define RADIO_SLEEP_REQ     NC
#define RADIO_ON_SLEEP      NC
#define DEBUG_TX            P0_2
#define DEBUG_RX            P0_3
#elif defined(TARGET_FRDM_KL25)
#define RADIO_TX            PTD3
#define RADIO_RX            PTD2
#define RADIO_RESET         NC
#define RADIO_SLEEP_REQ     NC
#define RADIO_ON_SLEEP      NC
#define DEBUG_TX            USBTX
#define DEBUG_RX            USBRX
#elif (defined TARGET_LPC11U24)
#define RADIO_TX            p9
#define RADIO_RX            p10
#define RADIO_RESET         p30
#define RADIO_SLEEP_REQ     NC
#define RADIO_ON_SLEEP      NC
#define DEBUG_TX            USBTX
#define DEBUG_RX            USBRX
#else
#error "Define a platform"
#endif

#endif /* __CONFIG_H_ */