ZigBee Node Types
Before going into more ZigBee addressing, I'd like to address a concept I've been skirting but need to define formally: ZigBee node types.
Every node in a ZigBee network is one of three types: a ZigBee Coordinator (ZC), a ZigBee Router (ZR), or a ZigBee End-Device (ZED). In IEEE 802.15.4-speak, both ZCs and ZRs are full-function devices, and a ZED is a reduced-function device (see Table 4.5).
Table 4.5: ZigBee Node Types
Use a ZigBee Coordinator to form a network. This is the only device type that can. If the network is secure, the ZC must be present to add nodes to the network. Otherwise, once the network starts, it's just a router. The ZC is also the root of the tree when using tree routing in stack profile 0x01, so if the ZC is gone, only mesh routing is available across branches of the tree. Tree routing is explained in-depth in Chapter 7, "The ZigBee Networking Layer."
The ZigBee Coordinator is not needed for normal operation of the network, but is required to allow nodes to join or leave the network, as it contains the Trust Center. Only the Trust Center can decide whether to allow a node on a ZigBee network, or to deny it access.
Use a ZigBee Router to enhance the mesh in the network. ZigBee Routers can extend the range of the network and increase its reliability. ZRs like the ZigBee Coordinator route packets, and also allow other nodes to join the network.
Use a ZigBee End-Device if the node must be battery-operated and sleep during network inactivity. A ZED may be RxOnIde or not. When RxOnIdle is false, ZEDs may sleep for long periods of time. There is no ZigBee-imposed limit on sleeping, but some Application Profiles define a maximum, such as one hour in the Home Automation profile.
When an RxOnIdle is false, ZED wakes up. It may transmit immediately, poll its parent to see if any messages are waiting for it, then go back to sleep. When RxOnIdle is true, ZEDs receive messages immediately. In either case, a ZED may transmit any time it wishes. Use an RxOnIdle ZED when an application needs more RAM or flash memory because ZEDs make the smallest code image.
Any application can reside in any ZigBee node type. For example, a ZC, ZR, or ZED could contain a light, switch, temperature sensor, thermostat, gateway, or whatever is appropriate for the physical device.
The following example, Example 4-5 ZigBee Node Types, contains one ZigBee node of each type: a ZC, a ZR, and a ZED. In this case, the ZC will be the switch, the ZR and ZED will be lights.
This example can be followed using the three-node Freescale Network Starter Kit. The BeeKit Solution file, capture file, and source code to the application can be found in the usual place: http://www.zigbookexamples.com. To follow the example, download the following three projects to the respective boards:
After they are all programmed, turn the nodes on, in any order. Once the ZigBee Coordinator forms the network the other devices will join, in this case on channel 25, PAN ID 0x0f00. Now press SW1 on the ZcNcbOnOffSwitch to toggle the lights.
Notice the delay on the ZED! Over-the-air, you can see the reason for the delay: the ZED doesn't receive the message until it polls its parent for the message. By default, this occurs once every three seconds. I've included time in the following capture so you can see how often the ZED polls its parent for messages. The ZigBee polling command looks like an 802.15.4 Command: Data Request in the captures:
Notice that the broadcast toggle command, initiated by the ZC (address 0x0000) in packet 21, is repeated by the router (address 0x0001) in packet 22. Then, three seconds later, the polling ZED asks node 0x0000 (its parent) if there are any messages waiting for it. The parent responds, "Why, yes, there are," and promptly sends down the broadcast to the child:
Frame 25 (Length = 30 bytes)
Frame Control: 0x8861
Sequence Number: 254
Destination PAN Identifier: 0x0f00
Destination Address: 0x796f
Source Address: 0x0000
Frame Check Sequence: Correct
Frame Control: 0x0048
Destination Address: 0xffff
Source Address: 0x0000
Radius = 10
Sequence Number = 217
Frame Control: 0x08
Destination Endpoint: 0x08
Cluster Identifier: On/off (0x0006)
Profile Identifier: HA (0x0104)
Source Endpoint: 0x08
Frame Control: 0x01
Transaction Sequence Number: 0x42
Command Identifier: Toggle (0x02)
Note how the 802.15.4 (MAC) frame indicates a unicast from the parent to the child, but the NWK frame indicates that it's a broadcast (destination 0xffff) from node 0x0000, the ZcNcbOnOffSwitch.
Any application may reside in any ZigBee node type: ZC, ZR, or ZED.