the zigbee development enviroment date: 2009/11/24 speaker: junn-keh yeh advisor: quincy wu

22
The ZigBee Development Enviroment Date: 2009/11/24 Speaker: Junn-Keh Yeh Advisor: Quincy Wu

Upload: howard-maximillian-ellis

Post on 30-Dec-2015

230 views

Category:

Documents


2 download

TRANSCRIPT

The ZigBee Development Enviroment

Date: 2009/11/24Speaker: Junn-Keh Yeh

Advisor: Quincy Wu

Outline

• Introduction• Development hardware• Introduction to the Freescale NSK• The ZigBee stack • Introduction to Freescale BeeStack• Introduction to Freescale BeeKit

2009/11/24 2

Introduction

• This chapter is for those who want to understand how to develop for ZigBee.

• If you want to develop ZigBee-based products, or are new to embedded development, or if you want to follow along with the examples using actual hardware rather than simply reading about ZigBee, then this chapter contains what you need.

• A story – Chapultepec(Nahuatl language)Zigibi

2009/11/24 3

Development hardware

• The PC tools required for ZigBee development usually include: – An IDE.(Integrated Development Environment)– A ZigBee stack configuration or application “

template ” tool.– A debugger for downloading and stepping through

source code lines on the target platform.– A protocol analyzer for debugging the network over-the-air.

2009/11/24 4

Development hardware(con.)• Hardware for ZigBee development kits usually

include:– Two or more ZigBee boards.– A means of connecting target boards to the PC, usually

through USB or Ethernet.– A JTAG (Joint Test Action Group) or BDM (Background

Debug Monitor ) debug device for programming the flash memory in the target boards.

– A sniffer for detecting over-the-air packets and delivering them to the protocol analyzer.

– Power supplies and/or batteries for powering the boards.

2009/11/24 5

Development hardware(con.)• Airbee• Atmel• Ember• Freescale• Integration

Associates• Jennic• MeshNetics• Microchip

2009/11/24

• Nec• Oki• Freescale• Renesas/ZMD• Silicon Laboratories• ST Microelectronics• Texas

Instruments/ChipCon

Golden Unit6

A Typical ZigBee System

2009/11/24 7

Introduction to the Freescale NSK

• Each board hosts four application-driven buttons, a reset button, four LEDs, and a serial connection via the USB port. In addition, each board exposes the GPIOs(General Purpose I/O) available from the microcontroller, so that sensors and actuators can be added using a simple connector.

• The smaller Sensor Remote Boards (SRB) also include a low-g 3-axis accelerometer and a temperature sensor, both of which will be used in examples later on in this book.

• The larger Network Control Board (NCB) does not include sensors, but does include a 2-line by 16-column LCD display.

2009/11/24 8

Introduction to the Freescale NSK

2009/11/24 9

The ZigBee stack

2009/11/24 10

Figure: ZigBee diamond network

The ZigBee stack

• The multitasking kernel found with ZigBee implementations include multiple timers to allow applications to time various events, and for ZigBee to time random back-offs, retransmissions, acknowledged packets, and other networking operations.

• The kernel also controls memory allocation for transmitted and received packets.

2009/11/24 11

The ZigBee stack

2009/11/24 12

Figure: ZigBee Implementations Include a Multitasking Kernel

Introduction to Freescale BeeStack

2009/11/24 13

Each layer is connected through what is called a Service Access Point (SAP).

AF-APS SAP handlertypedef struct zbApsdeDataReq_tag {

zbAddrMode_t dstAddrMode; /* indirect, group, direct-16, direct-64 */zbApsAddr_t dstAddr; /* short address, long address or group (ignored on indirect mode) */zbEndPoint_t dstEndPoint; /* destination endpoint (ignored if group mode) */zbProfileId_t aProfileId; /* application profile (either private or

public) */zbClusterId_t aClusterId; /* cluster identifier */zbEndPoint_t srcEndPoint; /* source endpoint */uint8_t asduLength; /* length of payload */uint8_t *pAsdu; /* pointer to payload */zbApsTxOption_t txOptions; /* options on transmit */uint8_t radiusCounter; /* # of hops */

} zbApsdeDataReq_t;

2009/11/24 14

Initializes the Application

2009/11/24 15

void BeeAppInit( void ){index_t i;/* initialize LED driver */LED_Init();/* register to get keyboard input */KBD_Init(BeeAppHandleKeys);/* initialize LCD (NCB only) */LCD_Init();/* initialize buzzer (NCB, SRB only) */BuzzerInit();BuzzerBeep();/* register to get ZDP responses */Zdp_AppRegisterCallBack(BeeAppZdpCallBack);/* flash LED1 to indicate not on network */LED_TurnOffAllLeds();LED_SetLed(LED1, gLedFlashing_c);/* indicate the app on the LCD */LCD_WriteString(2, “ CustomApp ” );

Initializes the Application(con.)

2009/11/24 16

/* register the application endpoint(s) */for(i = 0; i < gNum_EndPoints_c; + + i) {(void)AF_RegisterEndPoint(endPointList[i].pEndpointDesc);}/* remember first endpoint */appEndPoint =endPointList[0].pEndpointDesc- > pSimpleDesc- > endPoint;/* remember first cluster */Copy2Bytes(appDataCluster, endPointList[0].pEndpointDesc- > pSimpleDesc- > pAppInClusterList);/* allocate timers for use by this application */appTimerId = TMR_AllocateTimer();}

LED Link Function

2009/11/24 17

void MyLedBlinkFunction(void){/* flash LED4 for 3 seconds */LED_SetLed(LED4, gLedFlashing_c);TMR_StartSingleShotTimer(appTimerId, 3000, MyTimerCallBack);}void MyTimerCallBack(tmrTimerID_t timerId){(void)timerId; /* timer ID not used in this case */LED_SetLed(LED4, gLedOff_c);}

BeeStack Event Scheduler

2009/11/24 18

The multitasking environment in BeeStack is cooperative, not preemptive. That means if a single task (say the application) stays in a while() loop, no other task receives control until the BeeAppTask() function exits.

Summarize BeeStack• Freescale BeeStack represents ZigBee as a set of separate

tasks, mirroring the modules in the ZigBee architecture.• The BeeStack ZigBee modules (also called layers)

communicate to each other through service access points.• Each task may receive callbacks for various physical events

such as key presses, serial input, expired timers, and data indications.

• Each task may also receive logical events, represented by a bit-mask of events passed to the task’s event function. Application events go to BeeAppTask().

• A common user interface is used for all demo applications.

2009/11/24 19

Introduction to Freescale BeeKit• BeeKit’s main features include:– A set of application templates– The ability to configure application and stack

options through properties– An easy-to-use New Project Wizard– Full context-sensitive help for properties– The ability to easily upgrade to a new code base

• BeeKit uses the following terms: solution, project, template, code base, and properties

2009/11/24 20

Introduction to Freescale BeeKit

2009/11/24 21

Thanks

2009/11/24 22