Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Protocol Overview
Atmel ZigBee Nodes
Example Application
Christian Trödhandl
Outline
1 Introduction
2 Protocol Overview
Node Types
Network Topology
Protocol Stack Architecture
Communication between Nodes
4 Example Application
Outline
1 Introduction
2 Protocol Overview
Node Types
Network Topology
Protocol Stack Architecture
Communication between Nodes
4 Example Application
Outline
1 Introduction
2 Protocol Overview
Node Types
Network Topology
Protocol Stack Architecture
Communication between Nodes
4 Example Application
Star Network
Peer-to-Peer Network
Multi-Cluster Network
The lower level of the ZigBee protocol builds on the MAC layer of
IEEE 802.15.4.
Topology specific routing
Security
New device configuration
Network startup
Joining/leaving a network
Addressing
Neighbour discovery
Route discovery
Reception control
Application Layer
Addressing
Beacon Mode
Frame Types
Service Primitives
Outline
1 Introduction
2 Protocol Overview
Node Types
Network Topology
Protocol Stack Architecture
Communication between Nodes
4 Example Application
Outline
1 Introduction
2 Protocol Overview
Node Types
Network Topology
Protocol Stack Architecture
Communication between Nodes
4 Example Application
The following application code shows how to use the Atmel MAC
library for implementing a device application.
The application starts the MAC stack and associates with the
coordinator node. (Code snippets taken from the demos supplied
with the Atmel MAC library, see disclaimer)
/∗ I n c l u d e i n t e r r u p t . h f o r t h e s e i ( ) macro ∗/
#i n c l u d e < a v r / i n t e r r u p t . h>
/∗ d e f i n e s f o r demo a p p l i c a t i o n s ∗/
#i n c l u d e ” w p a n d e f i n e s . h”
/∗ i e e e c o n s t . h h o l d s IEEE 8 0 2 . 1 5 . 4 c o n s t a n t s
and a t t r i b u t e d e f i n i t i o n s ∗/
#i n c l u d e ” i e e e c o n s t . h”
/∗ wpan mac . h i n c l u d e s f u n c t i o n d e f i n i t i o n s f o r
a l l l i b r a r y f u n c t i o n s ∗/
#i n c l u d e ” wpan mac . h”
/∗ d e f i n e s t a t u s v a r i a b l e ∗/
typedef s t r u c t
{
uint16 t device short address ;
u i n t 8 t coord address mode ;
uint64 t coord address ;
uint16 t pan id ;
uint8 t logical channel ;
u i n t 8 t msdu handle ;
device state t state ;
} device status t ;
/∗ d e f i n e s t a t u s v a r i a b l e ∗/
s t a t i c void a p p l i c a t i o n i n i t ( void )
{
/∗ r e s e t g l o b a l a p p l i c a t i o n s t a t u s v a r i a b l e ∗/
memset(& d s t a t u s , 0 , s i z e o f ( d s t a t u s ) ) ;
/∗ i n i t IO p o r t s . . . . ∗/
/∗ i n i t mac l a y e r ∗/
wpan init ();
s t a t i c void s w i t c h t a s k ( void )
{
/∗ do s o m e t h i n g . . . ∗/
i f ( send data )
{
/∗ s e n d d a t a ∗/
wpan mcpsdata addr t a i ;
a i . SrcAddrMode = WPAN ADDRMODE SHORT;
a i . SrcPANId = d s t a t u s . p a n i d ;
a i . SrcAddr = d s t a t u s . d e v i c e s h o r t a d d r e s s ;
a i . DstAddrMode =
d status . coord address mode ;
a i . DstPANId = d s t a t u s . p a n i d ;
a i . DstAddr = d s t a t u s . c o o r d a d d r e s s ;
w p a n m c p s d a t a r e q u e s t (& a i ,
d s t a t u s . m s d u h a n d l e ++,
WPAN TXOPT ACK,
( void ∗) & d s t a t u s . led ,
sizeof ( uint8 t ));
}
return ;
}
void u s r m c p s d a t a i n d (
wpan mcpsdata addr t ∗ pAddrInfo ,
u i n t 8 t mpduLinkQuality ,
uint8 t SecurityUse ,
u i n t 8 t ACLEntry , u i n t 8 t msduLength ,
u i n t 8 t ∗ msdu )
{
i f ( ( d s t a t u s . s t a t e == RUN) &&
( p A d d r I n f o −>DstPANId == d s t a t u s . p a n i d ) )
{
/∗ do s o m e t h i n g w i t h r e c e i v e d d a t a ∗/
}
}
Main function
i n t main ( v o i d )
{
application init ();
/∗ s e n d r e s e t , s c a n r e q u e s t , . . . ∗/
mac do reset ( ) ;
while (1)
{
while ( wpan task ( ) )
{
/∗ s h o r t r u n n i n g t a s k s ∗/
}
s w i t c h t a s k ( ) ; /∗ main u s e r t a s k ∗/
}
}
Trödhandl Introduction to ZigBee 35
Introduction
Protocol Overview
Atmel ZigBee Nodes
Example Application
Some References
IEEE.
IEEE std 802.15.4-2003: Wireless medium access control (MAC) and physical
layer (PHY) specifications for low-rate wireless personal area networks
(LR-WPANs).
Specification, IEEE, October 2003.
Available at http://www.ieee802.org.
ZigBee Alliance.
ZigBee specification.
Specification, ZigBee Alliance, December 2006.
Available at http://www.zigbee.org.
Atmel.
IEEE 802.15.4 MAC User Guide.
2325 Orchard Parkway, San Jose, California, September 2006.
Available at http://www.atmel.com.
Atmel.
ATAVRRZ200 Demonstartion Kit AT86RF230 (2450 MHz band) Radio
Transceiver User Guide.
2325 Orchard Parkway, San Jose, California, July 2006.
Available at http://www.atmel.com.
Trödhandl Introduction to ZigBee 36
Introduction
Protocol Overview
Atmel ZigBee Nodes
Example Application
Sourcecode Disclaimer
Copyright (C) 2006, Atmel Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of ATMEL may not be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ATMEL ”AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS