ZIGBEE技术 Zigbee Technology



Thewireless control market has a number of unique needs for which ZigBee is

ideallysuited, because ZigBee is:

Highly reliable

Cost-effective

Able to achieve very lowpower

Highly secure

An open global standard

Toachieve the low power and low cost criteria, ZigBee added a constraint to the

technology:

Low data rate

Now, why would a networking standard want to encourage low data rates?Because

ZigBee is all about wireless monitoring and control. Think of a lightswitch. How often

does it need to communicate? Ten times per day? Or perhaps, not at all, ona given day?

Howlarge is that data set? By keeping focused on the appropriate technology forwireless

control,ZigBee achieves an elegant solution that makes sense and fits a set of markets

verywell. Just don’t expect to stream voice or video over ZigBee. Yes, I have seen

companiesstream voice over ZigBee, but that’s not the intended use, and it consumes

way too much bandwidthfor most ZigBee networks







ZigBeeachieves high reliability in a number of ways:


IEEE 802.15.4 withO-QPSK and DSSS


CSMA-CA


16-bit CRCs


Acknowledgments at eachhop


Mesh networking to findreliable route


End-to-endacknowledgments to verify data made it to the destination


 




 


 


 


ZIGBEE15 2025 26 WIFI不干扰


Often, when defining a private profileapplication, I’ll select channels 15, 20, 25, and


26, as these channels aren’t the same as oncommon WiFi installations. I do this not for


ZigBee’s sake, but for WiFi’s. If theapplication gets too chatty, it could cause WiFi to


miss a packet or two, and degrade theperformance of WiFi


WIFI


中心频率如下,总带宽为22,每个信道的有效宽度是 20MHz,另外还有2MHz的强制隔离频带(类似于公路上的隔离带),所以相邻的信道会有重叠



 1                2    3           4          5        6         7     8      9           10    11


2412    2417    2422      2427    2432    2437 2442  2447 2452  2457  2462


2401~2423 2406~2428 2411~2433           2416~24382421~2443 2426~2448 2431~2453 2436~2458 2441~2463 2446~2468 2451~2473


 12        13


2467  2472


2456~2478 2461~2483



ZIGBEE中心频率如下,有效带宽为2MHZ


Fc= 2405 + 5 (k11) in megahertz, fork= 11, 12, …, 26kis the channel number.


 11          12   13      14   15     16        17     18    19  20   21          22   23   24    25    26


2405       2410 2415 2420 2425  2430 2435 2440 2445 2450 2455 2460 2465 24702475 2480





Clusters encapsulateboth commands and data (类似每个Cluster都是一个对象,里面有方法和属性)


Clusters only havemeaning within a particular profile


(Profile包含了多个Cluster,ClusterProfile提供使用)


Eg:


Clusterscontain both code (commands) and data (attributes). Commands cause action.


Attributeskeep track of the current state of that cluster. A good example of this is theHA


DimmingLight.It supports both the OnOff Cluster (0x0006) and the LevelControl Cluster


(0x0008).There are commands to turn the light on, off, or toggle it on the OnOffCluster;


butto control the dimming function, commands on the LevelControl Cluster are used.


Thedata on the OnOff Cluster is simply a field: Is the light on, or off. The dataon the


LevelControlCluster indicates what dimming level the light is (or will be) at when it is in


the “ on ” state.


Thinkof clusters as an object, including both code (commands) and data (attributes).


Clusters may have anymeaning in a private profile


Commands


Publicprofiles use the ZigBee Cluster Library. ZCL introduces two new concepts


intoZigBee that you won’t find in the main ZigBee stack specification: commands


andattributes. ZCL makes it easy to get or to set attributes through a common setof


commands,and provides a simple mechanism for issuing cluster-specific commands.


Commandsare identified by an 8-bit number, and are either cluster-specific, orcrosscluster.


Cluster-specificcommands depend on the cluster number, and generally start at


0x00.For example, 0x00 is the “ off ” command in the OnOff Cluster, whereas 0x00 is


“move-to-level ” command in the LevelControl Cluster.


ZCLis used in (nearly) all of the ZigBee public profiles, but is not required forprivate


profiles.Considerable code space can be saved by leaving out ZCL, but then of course,


thefeatures of ZCL are left out, too.


Over-the-air,ZCL frames are the payload of the APS frame. Take a look at the


followingZCL:


ZigBee APS


FrameControl: 0x00


DestinationEndpoint: 0x08www.newnespress.com


ClusterIdentifier: On/off (0x0006)


ProfileIdentifier: HA (0x0104)


SourceEndpoint: 0x08


Counter:0x3f


ZigBeeZCL


FrameControl: 0x01


......01 = Frame Type: Command is specific to a cluster (0x01)


.....0.. = Not Manufacturer Specific


....0... = Direction: From the client side to the server side


0000.... = Reserved: Reserved (0x00)


TransactionSequence Number: 0x48


CommandIdentifier: Off (0x00)


 


 


Profiles


Everydata request in ZigBee is sent (and received) on an Application Profile.Application


ProfileIDs are 16-bit numbers and range from 0x0000 to 0x7fff for public profiles and


0xbf00 to 0xffff formanufacturer specific profiles


Profiles包括Public Profile(ZIGBEE联盟标准规定为了互联互通)Private Profile(厂商自定义不能兼容其它厂家设备),不同的Profile属于不同的EndPoint


Anynumber of Application Profiles, both public and manufacturer-specific, mayexist in


asingle ZigBee network. In fact, any number of profiles may exist in a singlenode on the


network, separated ondifferent endpoints.



 


Device IDs


Every endpoint includes a profileidentifier and a device identifier.Think of a device as


aphysical thing: a light, temperature sensor, thermostat, or the like. Onephysical widget


mightcontain multiple devices. For example, a ZigBee thermostat sold at Home Depot


maycontain a temperature sensor, a thermostat, and a heating/cooling unitcontroller.


FromZigBee’s standpoint, these are separate devices. From a packaging standpoint,they


areall in one SKU (Shelf-Keeping Unit).


ZigBee Device IDs rangefrom 0x0000 to 0xffff


Each ZigBee PublicProfile contains a specific list of devices.


an endpoint defines an application.





 


 


 


ZigBee Application Support Sublayer (APS)


APS相当于TCP/IP中的传输层,但APS还包括了应用层的东西在里面)(APS包括了TCP的一些东西如端口及重传、确认、端到端可靠传输)


Whilethe MAC layer provides per-hop acknowledgments, the APS layer is what provides


end-to-endacknowledgments, also called ACKs.


Okay.Don’t ask me why the Application Support Sublayer uses the three-letter acronym


APS.It’s obvious, but don’t ask me.


TheApplication Support Sublayer, or APS, sits above the NWK layer, and is thelayer in


ZigBeewhich understands applications. The APS frame over-the-air includes endpoints,


clusters,profile IDs, and even groups.


APSis responsible for the following activities:


Filtering out packets for non-registered endpoints, or profiles that don’tmatch


Generating end-to-end acknowledgment with retries


Maintaining the local binding table


Maintaining the local groups table


Maintaining the local address map


APShas the job of filtering out packets for endpoints that don’t exist in thenode. APS


filterspackets that don’t match profile IDs. APS also filters duplicate packets, whichcan


happenin a network that supports automatic retries.


It’sthe job of APS to perform automatic retries, if acknowledgment is requested bythe


sender,to maximum the chance of successful transmission andto inform the sender


whether or not the packet was delivered.wnespress.com


APS also maintains a variety of application-level tables. Binding is allabout connecting


an endpoint on this node to one or more endpoints on other nodes. Groupsare all about


an arbitrary collection of applications residing on an arbitrary set ofnodes throughout


the network. The address map associates a 64-bit MAC address with a ZigBee16-bit


NwkAddr.


APS and the Application Framework (AF) together form the ZigBee interfaceused by


applications (seeFigure 4.26). Lower layers are not called upon directly,but are used by


APS and ZDO.




 


ZDO


The ZigBee Device Object (ZDO, shown inFigure 5.1) is simply the applicationrunning


on endpoint 0 in everyZigBee device. (Remember, application endpoints are numbered


1 through 240.)


This application, ZDO, keeps track of the state of the ZigBee device onand off the


network, and provides an interface to the ZigBee Device Profile (ZDP), aspecialized


Application Profile (with profile ID 0x0000) for discovering, configuring,and


maintainingZigBee devices and services on the network.



 


 


ZigBee and IEEE 802.15.4


What802.15.4 doesnotspecify is anything todo with multi-hop communications,


addressassignment, or application level interoperability.


Ifthe network you have in mind to build only needs a single hop (that is, allradios in the


networkcan hear each other), then the 802.15.4 MAC/PHY may be all that you need. In


fact,Freescale and other silicon vendors offer an 802.15.4 application environmentthat


doesn’trequire ZigBee at all.


Asidefrom ZigBee, many other network protocols have been built on the 802.15.4


standard,some which are mesh or multi-hop, some which are single-hop or star networks.


Someexamples of non-ZigBee network protocols on 802.15.4 include MicroChip


MiWi™,Synap SNAP, 6LoWPAN (an IETF standard), Tiny O/S (an open source


project), and San JuanSoftware PopNet™.





ZigBeespecifies all the layers above MAC and PHY, including the NWK (network)


layer,APS, ZDO, and security layers. It’s ZigBee that provides the mesh networking


andmulti-hop capabilities, enhances the reliability of data packet delivery, andspecifies


application-to-applicationinteroperability.


ZigBeedoes not use all of the 802.15.4 MAC/PHY specification; only a small subset.


Thisallows stack vendors to offer smaller solutions (less RAM and flash) byproviding


a limited MAC for theirZigBee stacks. For example, ZigBee does not use any of the


802.15.4beaconing methods, or guaranteed time slots. ZigBee is asynchronous.


Anynode may transmit at any time. Only the CSMA-CA (carrier-sense multiple-access


withcollision avoidance), a MAC-level mechanism, prevents nodes from talking over


each other.


 


 


Forming, Joining, and Rejoining ZigBee Networks


Beforeany ZigBee node may communicate on a network, it must either form a new


networkor join an existing network. Only the ZigBee Coordinator may form a network.


OnlyZigBee Routers and ZigBee End-Devices may join a network. Many stack vendors


offerthe ability to have a node designated as a ZC, ZR, or ZED at compile time (tosave


code and RAM) or atrun-time (to reduce OEM-manufactured parts).


Every node starts out with a unique 64-bitIEEE (aka MAC or long) address, assigned by


theOEM during manufacturing. During the process of joining the network, each nodeis


assigneda unique (within that network) 16-bit short address (aka NwkAddr) to use when


communicatingto other nodes across the network. The 16-bit address is used for nearly


allcommunications, to reduce over-the-air protocol overhead, leaving more room for


application payload.


 


 


ZigBee Over-the-Air Frames(协议报文)


Anessential part of understanding ZigBee is understanding over-the-air frames. Infact,


over-the-airframes are all that the ZigBee Alliance cares about for compatibility testing.


Certainframes are sent over-the-air and certain replies are expected, but the rest isa


black box.


There are a variety of “ layers ” involved in any given over-the-airpacket, including the


MAC, NWK, APS, ZCL, and data. Over-the-air, these layers create a seriesof bytes,


framing (on either side) the rest of the bytes in the packet. That’s whyit’s called a frame.


The next higher layer frame is always inside the lower layer frameover-the-air. So the


NWK frame is inside the MAC frame, the APS frame is inside the NWK frame,and so on.


A full ZigBee data packet could contain all of the following frames (MAC,NWK, APS,


and ZCL), asshown inFigure 7.19.




 


The size of each frame header (MAC, NWK, APS, etc.) is variable, dependingon


parameters. Every frame header begins with what is called a frame control(FC) field,


which describes the optional fields in that frame.


The MAC frame ends with the Frame Check-Sum (FCS). The NWK frame ends with


the optional NWK Auxiliary Message Integrity Code (MIC). The NWK AUX HDR and


NWK MIC are present only in a secure network. The APS frame also may havesecurity


applied, with an APS AUX HDR and APS MIC.


The first two headers are node-oriented: that is, the MAC and NWK headers.The MAC


header controls the per-hop protocol, and the NWK header controls theend-to-end


protocol (seeFigure 7.20).


Notice how both the MAC and NWK headers contain destination and sourceaddresses.


Think of node A sending a packet multi-hop to node F. The first hop wouldbe from A to B.


The next hop would be from B to C, and so on. The final hop would be fromE to F. The


MAC source and destination would change along this entire journey, but theNWK source


anddestination addresses would not.


 

 


All ZigBee data packets are sent using the 16-bit short addresses, butother packets are


not. For example, when joining a network, the association request andresponse are sent


with the long (64-bit IEEE) addresses.


The next two headers, APS and ZCL, are application-level headers (seeFigure 7.21).


They describe application-level information including endpoints,application profile,


and for ZCL, the specific command for the cluster (reading and writingattributes, or


commanding the application to do something such as turning on a light).


All of the addressing fields in APS are within the node, so as to send thepacket to the


right application, as opposed to the NWK layer which addresses betweennodes. The ZCL


frame isoptional, but is present in all ZigBee public profiles.