ZigBee Receive Data example for mbed XBeeLib By Digi

Dependencies:   XBeeLib mbed

You are viewing an older revision! See the latest version

Homepage

Description

This example shows how to receive data. A remote XBee module has sent a packet to our local XBee module though the air. The local XBee module receives the packet and sends it to the mbed cpu through the serial port. This library decodes the packet and calls a user defined method to process the packet.

Common Setup

In this chapter we'll describe the setup required to evaluate the examples. That implies creating a wireless network between two XBee modules.
One of them will be physically connected to the mbed module though a serial link. We'll call it the 'local XBee module'. The other one will be called the 'remote XBee module'

Remote Setup

The more comfortable remote setup to evaluate these examples is having the remote XBee module mounted in baseboard (XBIB, TODO....) and connected to the PC through an usb cable to create a serial connection.
Open XCTU tool and connect to the remote XBee module through corresponding serial connection.
With XCTU tool its easy to configure the remote XBee module settings so it creates a wireless network with the local XBee module. Once the network is created, you can even discover the local XBee module through the air and check that the module settings match the requirements explained in the 'Local Setup' chapter.
The XCTU tool is later used to evaluate the examples by injecting or monitoring packets in the network.

<<<info>>> When using ZigBee modules, it's usual that the 'Remote XBee' it's an X-STICK module acting a network coordinator. <<</info>>>

Local Setup

The local setup includes:

  1. The mbed module and its debug connection to the PC (normally an usb cable)
    So you can see the sample application debug messages. For that you have to configure the DEBUG_TX and DEBUG_RX pins in config.h.
    See Configuring the library and Debugging the library chapters for more info.
  2. The connection between the mbed module and the local XBee module
    That includes at least wiring and configuring RADIO_TX and RADIO_RX in config.h. Wiring RADIO_RESET is highly recommended as well.
    See Configuring the library and Initializing modules chapters for more info.
  3. The local XBee module persistent configuration
    This library expects that the local XBee module has the default settings stored (but for the "AP" setting that must be set to 1 or 2). You can verify those settings previous to run the example using XCTU tool through following two options:
    - Having the local radio wired to the mbed module, you can discover the local XBee module from the remote XBee module in the same network as explained in the 'Remote Setup' chapter.
    - You can temporarily unplug the local XBee module from the mbed module and plug it to the PC.
    Special care must be taken with following settings:
  • "ID" and rest of Networking settings: Leave them default or customize them as in your remote XBee module. The important thing is that both local and remote XBee modules create a network. This library has methods to change these settings but the sample applications are not calling them.
  • Firmware: In S2B modules, end-device firmware will complicate evaluation of standard examples because the radio will sleep automatically. To avoid that it's recommended to flash 'router' firmware that make devices don't sleep.
  • "SM" setting: Set it to 0=No Sleep.
  • "BD" setting: The sample applications expect it set to 3=9600bps. If you change it, change it in the sample application accordingly (See Initializing modules chapters for more info).
  • "AP" setting: It's compulsory to change this setting set to 1 or 2 !!!!.

Example Setup

This example does not require any additional setup.

Running the example

Build and deploy the example to the mbed module.
Reset the mbed module so the example starts. You should see the example debug information

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

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.


All wikipages