datasheets.com EBN.com EDN.com EETimes.com Embedded.com PlanetAnalog.com TechOnline.com  
Events
UBM Tech
UBM Tech

Design Article

ZigBee applications - Part 4: ZigBee addressing

Drew Gislason

7/27/2010 4:48 AM EDT

The Network Address

The network address, also called NwkAddr, short address, or node address, is a 16-bit number used to uniquely identify a particular node on a ZigBee network. The ZigBee Coordinator is always NwkAddr 0x0000. Yes, two ZigBee coordinators can exist on the same channel with NwkAddr 0x0000, because they are on different PAN IDs.

If using stack profile 0x01, which uses tree routing in addition to mesh, the NwkAddr reflects its position in the network. For example, NwkAddr 0x0001 is the first ZR that joined the network, and NwkAddr 0x796F is the first ZED. In stack profile 0x02 (with ZigBee 2007), the NwkAddr is assigned randomly.

Most of the examples so far have used service discovery and binding to determine which nodes in the network with which to communicate, such as using Match Descriptor or End-Device-Bind command.

But service discovery and binding are not required in ZigBee. Once a node is on the network, it can communicate to any other node in the network. Simply transmit a packet to that node address. It is very common to send something to the ZigBee Coordinator (NwkAddr 0x0000), because that node address is the same in every ZigBee network.

In this three-node example, the switch application already knows the topology of the network and the addresses of nodes in the network. It knows that one light will be at node 0x0001 (the first ZR), and the other light will be at node 0x143e (the second ZR). SW1 will toggle the light at NwkAddr 0x0001, and SW2 will toggle the light at NwkAddr 0x143e. No other binding or instructions are needed. Take a look at the very simple capture:

Packets 1 through 18 are the packets needed for the nodes to join the network. But notice that at packet 19, the switch begins to send data to the first light, 0x0001. No discovery occurred, the switch just "assumed" the light would be there.

This is a perfectly acceptable practice for a private profile, because the topology and relationships between nodes could be set up in advance. Public profiles require more sophisticated discovery techniques because the network topology is never known in advance.

To run this demo, download the following three projects into their respective boards:

• Chapter04\Example4-6ZigBeeNwkAddr\ZcNcbHaOnOffSwitch.mcp
• Chapter04\Example4-6ZigBeeNwkAddr\ZrSrbHaOnOffLight1.mcp
• Chapter04\Example4-6ZigBeeNwkAddr\ZrSrbHaOnOffLight2.mcp

Once the code is downloaded and the boards are booted (any order), press SW1 to toggle the SrbZrLight1 (NwkAddr 0x0001). Then press SW2 to toggle the SrbZrLight2 (NwkAddr 0x143e). It's as simple as that.

Take a look at the source code on the switch. It just makes a data request like you've seen before, setting the address to the desired node. It doesn't matter if the node is many hops away: ZigBee will discover a route automatically and find the node. The NwkAddr is all that is needed:

void BeeAppHandleKeys(key_event_t events)
{
    zbNwkAddr_t aDestAddress;
    zbEndPoint_t endPoint = appEndPoint;

    switch(events) {

    /* SW1 – send toggle to node 0x0001 */
    case gKBD_EventSW1_c:
        Set2Bytes(aDestAddress, 0x0100);
        OnOffSwitch_SetLightState(gZbAddrMode16Bit_c, aDestAddress,endPoint,gZclCmdOnOff_Toggle_c, 0);
        break;
    /* SW2 – send toggle command to node 0x143e */
    case gKBD_EventSW2_c:
    Set2Bytes(aDestAddress, 0x3e14);
        OnOffSwitch_SetLightState(gZbAddrMode16Bit_c, aDestAddress,endPoint,gZclCmdOnOff_Toggle_c, 0);
        break;
    }
}

Note that the addresses are little Endian (lowest byte first). So address 0x0001 is represented as 0x0100. All ZigBee data types are little Endian over-the-air. It is up to the stack vendor to choose how to implement this in source code. Freescale uses little Endian for all the ZigBee types, even though the HCS08 processor used in the MC13213 is big Endian.

The 16-bit NwkAddr uniquely identifies a node in the network.





Tim.Gillman

8/30/2010 1:38 AM EDT

To find out more about ZigBee and Wireless Sensor Networking, go to Drew's website: www.sanjuansw.com

Sign in to Reply



strawbot

9/25/2010 1:37 PM EDT

In table 4.5 column 1 you have your ZED and ZR swapped.

Sign in to Reply



jiki

10/31/2012 3:12 AM EDT

i downloaded the example but i am unable to open the file because i am not familiar with the extension of the file. please help me out. how to see the examples.

Sign in to Reply



Please sign in to post comment

Navigate to related information

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)