802.15.4 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 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 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

Network

You need to set up a coordinator in the network so it buffers the packets send to our local XBee device while it's sleeping.
A module configured as coordinator requires:

  • 'Coordinator Enable (CE)' parameter set to 1.
  • 'Coordinator Association (A2)' parameter set to 0x04 so the coordinator allows end device association.
  • 'Cyclic Sleep Period (SP)' parameter set as the local XBee device.
    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
  • 'Time Before Sleep (ST)' parameter set as the local XBee device; 500 ms = 0x1F4.

Demo run

While it is running, send a packet to the device:

  • Go to the "Console" tab of the XCTU connected to the coordinator.
  • Press the "Add API frame to the list" button.
  • Press "Create using API Frame generator" button.
  • Select "802.15.4" protocol and "0x00 - Tx (Transmit) Request 64-bit address" Frame Type.
  • Paste the Local XBee device 64-bit address in the "64-bit dest. address" text box. (You can copy it from the application banner).
  • In the "RF data" text box, select the ASCII box and type "Hello XBee!".
  • Press OK, Add Frame.
  • 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:56 2015 +0200
Revision:
0:8b05ec51d9b9
Automatic upload

Who changed what in which revision?

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