Foreword
Back in 1999, we saw the need for an organization with a mission to define a complete,
open, global standard for reliable, cost-effective, low-power, wirelessly networked
products addressing monitoring and control. While there were other standards that
addressed higher data rates or battery-powered networks for a very small number of
devices, none of these truly met the needs of this market. Instead, what we needed was
something focused on:
●
●
●
●
Large networks (a large number of devices and a large coverage area) that could
form autonomously, and operate very reliably and securely for years without
operator intervention
Very long battery life (years of use from a pair of AA cells), very low
infrastructure cost (low device and setup costs), very low complexity, and
small size
A relatively low data rate
A standardized protocol, allowing multiple-vendor, interoperable products for the
global market
Thus, in 2002, the ZigBee Alliance was born.
Now, with over 225 member companies, we are able to draw on a wealth of experience in
every aspect of the business. Allowing so many companies the opportunity to have input
is not as fast-paced as adopting a single proprietary system and declaring it a standard.
Even so, the combined wisdom and the vetting process enable a much better solution to
be built, one which meets all of the needs mentioned above. Getting it right is extremely
important if a standard is to have a long track record of success.
www.newnespress.com
FOR-H8597.indd ix
FOR-H8597.indd ix
7/26/2008 3:03:05 PM
7/26/2008 3:03:05 PM
x
Foreword
The ZigBee Alliance slogan, “ Wireless Control That Simply Works, ” is clearly what is
needed for end users and implementers, but achieving that result places a heavy burden
on the developers and OEMs. Drew Gislason has the ability to take complex topics and
present them in a manner that is cogent and easily digestible to OEMs and developers.
This book goes a long way in helping to explain ZigBee concepts, and in explaining how
to implement ZigBee in a wide variety of products.
Many people do not realize that a quiet revolution is already under way in business, and
in our homes. Great emphasis is being placed on reducing natural resource waste and in
becoming exponentially more efficient. To achieve global efficiency goals, we must have
an extensive, intelligent, easy-to-deploy, low-cost infrastructure to monitor and manage
our surroundings. ZigBee is a solid technological solution for this monumental task, and
brings with it other benefits and lifestyle improvements, such as increased security and
convenience.
The momentum is gathering, and we are about to take a leap that brings remarkable
savings, not only of resources, but of money and time. History repeatedly demonstrates
that companies at the forefront set the mark for their industries. Indeed, many current
industry leaders who take a “ wait and see ” approach are likely to be supplanted by new
leaders willing to make an early investment in learning and implementing solutions such
as ZigBee into their product lines. This book will help companies move up the learning
curve rapidly.
Bob Heile, Ph.D.
Chairman, ZigBee Alliance
www.newnespress.com
FOR-H8597.indd x
FOR-H8597.indd x
7/26/2008 3:03:05 PM
7/26/2008 3:03:05 PM
Preface
Intended Audience
ZigBee Wireless Networking is for developers who are interested in learning more about
ZigBee. The developer who actually has a project at hand may benefit the most from the
text and examples, but managers considering using ZigBee on a project will also benefit,
especially from Chapter 1, “ Hello ZigBee, ” and Chapter 2, “ Deciding on ZigBee. ”
No prior experience with embedded programming, 802.15.4, or networking is required,
but a working knowledge of the C programming language is helpful.
Most of the examples use the Freescale ZigBee platform, but the ideas apply to all
ZigBee platform vendors. Occasionally, an example or solution is specific to the
Freescale platform. Where this occurs, the text makes it clear that the solution is
Freescale-specific, and not a ZigBee requirement, in general.
Formatting Conventions
Various elements in this book are specially formatted for easier identification while
reading. Code samples are printed in a different style on a light gray background.
Variables in the text are printed in bold . Each section ends in a brief summary,
indicating the key points. For example, Code samples look like this:
void BeeAppDataIndication(void)
{
apsdeToAfMessage_t *pMsg;
zbApsdeDataIndication_t *pIndication;
zbStatus_t status = gZclMfgSpecific_c;
while(MSG_Pending( & gAppDataIndicationQueue)
The Book’s Structure
This book is designed to be read from cover-to-cover, tutorial style. Each chapter
introduces concepts that are used in later chapters. However, the reader is encouraged to
www.newnespress.com
PRE-H8597.indd xi
PRE-H8597.indd xi
7/26/2008 3:18:33 PM
7/26/2008 3:18:33 PM
xii
Preface
skip ahead if the concepts of any section are already familiar. To keep the reader oriented
in each section, some overlap is necessary.
While it is not required, it is helpful to have the ZigBee and IEEE 802.15.4 specifications
available when reading this book. I’ll sometimes refer to a section or a concept in those
specifications for further reading.
To obtain the ZigBee specification, go to http://www.zigbee.org and click on “ Download
the Specification. ” It is free, and comes in PDF format.
Go to http://standards.ieee.org/getieee802/802.15.html and select “ IEEE 802.15.2-2003 ”
to obtain the 802.15.4 standard in PDF format. There is a new draft standard, IEEE
802.15.2-2006, but ZigBee does not currently use that specification.
The chapters are organized as follows.
Chapter 1, “ Hello ZigBee, ” lays out the basics of ZigBee and its intended use. It describes
the ZigBee Alliance, which is the standards body which defines and promotes the ZigBee
standard worldwide. This chapter also provides the developer with several ZigBee
networking examples, complete with source code.
Chapter 2, “ Deciding on ZigBee, ” helps the developer make technical and marketing
choices about ZigBee, and even helps determine whether ZigBee is the right solution
for any given problem. It provides a concise checklist, with all of the ZigBee factors
that must be considered throughout the entire product life cycle, from inception through
development, deployment, and maintenance.
Chapter 3, “ The ZigBee Development Environment, ” covers the basics of the ZigBee
development environment, and walks the reader through an example, step-by-step, to
help gain a full understanding of what’s involved in the development and debug phase.
This chapter contains information necessary if the reader plans to follow along with the
examples using actual hardware.
Chapter 4, “ ZigBee Applications, ” goes in-depth into application development, including
the fundamentals of ZigBee networks, nodes, addressing, Application Profiles, and the
features provided to the application by the Application Framework (AF) and Application
Support Sub-layer (APS).
Chapter 5, “ ZigBee, ZDO, and ZDP, ” describes the ZigBee Device Object (ZDO) and
how it interacts with and is used by applications, including how to achieve maximum
battery life from ZigBee nodes.
www.newnespress.com
PRE-H8597.indd xii
PRE-H8597.indd xii
7/26/2008 3:18:33 PM
7/26/2008 3:18:33 PM
Preface
xiii
Chapter 6, “ The ZigBee Cluster Library, ” covers the library of common clusters used for
profile and device development. It describes Home Automation in some detail.
Chapter 7, “ The ZigBee Networking Layer, ” goes in-depth into how ZigBee actually
delivers packets from one node to another, including mesh and tree networking. It also
discusses some of the table management that must occur for ZigBee nodes to last for
years (and decades) in the field with no required maintenance. This chapter also describes
security in detail.
Chapter 8, “ Commissioning ZigBee Networks, ” describes the commissioning process
with ZigBee. This topic is critical to the successful deployment and maintenance of
ZigBee networks.
Chapter 9, “ ZigBee Gateways, ” introduces gateways and describes techniques for
retrieving information from a ZigBee network, as well as controlling and configuring
sensors and actuators from outside the ZigBee network.
Appendix A, “ ZigBee 2007 and ZigBee Pro, ” is a quick reference to the ZigBee
application API.
Appendix B, “ ZigBee Quick Reference, ” is a quick reference to ZigBee architecture and
commands.
Appendix C, “ ZigBee Cluster Library Quick Reference, ” covers some of the new features
in ZigBee to be found in the upcoming ZigBee 2007, a specification that was not quite
ready for publication at the time of this writing.
Example Source Code
Each chapter contains examples designed to enhance understanding of the ZigBee
concepts introduced. Only partial source code is included in the text of this book.
For full source code, including Freescale CodeWarrior project files, go to the web site:
http://www.zigbookexamples.com/code
The home page of this site is just an advertisement for the book, so remember to type in
/code after the site name. The sample code may be freely used in applications. A standard
author’s disclaimer applies:
No warrantee is implied or expressed and it’s probably not suitable for anything other
than instructional purposes, and maybe not even that. If you use the source code, keep the
copyright text intact.
www.newnespress.com
PRE-H8597.indd xiii
PRE-H8597.indd xiii
7/26/2008 3:18:33 PM
7/26/2008 3:18:33 PM
xiv
Preface
The code on the Web site is organized by chapters. Each example, except for the two in
Chapter 1, contain only the application source code, and assume that you use Freescale’s
BeeKit to generate the project. The whole process of taking small source code samples
and incorporating them into the Freescale solution is described, step-by-step, in
Chapter 3, “ The ZigBee Development Environment. ”
www.newnespress.com
PRE-H8597.indd Sec1:xiv
PRE-H8597.indd Sec1:xiv
7/26/2008 3:18:33 PM
7/26/2008 3:18:33 PM
Acknowledgments
There are so many people that contributed to this book. First of all, I’d like to thank my
wife, Alicia. Without her countless hours of encouragement and solid support of this
arduous process called writing a book, this would not have been possible. And to my
daughters, Lita, Genevieve, and Elanor, I love you.
To Rachel, my editor at Elsevier, a big thank you, especially for your patience. There is a
White Chocolate Frappuccino® waiting for you at Starbucks®, my treat.
I’d like to thank all the staff at Freescale, in what’s now called Wireless Commercial
Operations (WCO), especially Brett Black for believing in and championing this
technology, Darrel Simms for introducing me to Freescale, Mark Williams for always
supporting his partners, Walter Young whose command of the English language is
greater than Strunk and White, Mads Westergreen—a Danish man who knows more
about ZigBee than just about anybody on the planet, Matt Maupin, Ryan Kelly,
Shannon Reid, and so many others as well.
Also, ZigBee Alliance members deserve many thanks for this book: Bob Heile,
Zachary Smith, Ian Marsden, Don Sturek, Phil Jamieson, and Skip Ashton, all of whom
have made the ZigBee standard possible. I really appreciate all the time you’ve spent
explaining the concepts to me, and discussing the edge cases. You have taught me so
much. And to others within the Alliance who have patiently answered my questions:
Spiro Sacre, Monique Brown, Wally Burnham, Claudio Borean, Rudi Belliardi,
Greg Henry, Silviu Chiricescu, and Bill Wood, thank you.
To my good friends and colleagues, Masaru and Blanca Natsu, Christian Garcia, and
Dalila Pinedo, thank you for all your help, suggestions, corrections, and insight. And to
www.newnespress.com
ACK-H8597.indd xv
ACK-H8597.indd xv
7/26/2008 3:09:06 PM
7/26/2008 3:09:06 PM