with Microchip Zigbee Stack
Follow these basic steps to develop a ZigBee protocol application:
1. Determine the profile that the system will use:
(I.e. Format and nature of data)
2. Determine the endpoint structure that each device will use:
(I.e. RFD, FFD)
3. Create a new project directory.
Place all application-specific source files in this directory.
The application source code must include the header file, zAPL.h, to access the ZigBee protocol functions.
A ZigBee protocol coordinator application will need to have one support variable to keep track of the current primitive being executed by the Stack.
A ZigBee protocol router or end device will also need to keep track of the current primitive; but in addition, it will need two other support variables to assist in network discovery and joining.
NETWORK_DESCRIPTOR * currentNetworkDescriptor;
NETWORK_DESCRIPTOR * NetworkDescriptor;
Next, the application must configure all pins required to interface with the transceiver. The ZENA analyzer will create several labels that may be used to access the required LAT and TRIS bits. Refer to the README file for the labels created for the supported transceivers.
HardwareInit();//Initialize RF chip interfaced(SPI)
Before the Stack can be used, it must be initialized.
Interrupts must then be enabled:
IPEN = 1;
GIEH = 1;
The application now interfaces with the Stack through the primitives defined in the ZigBee protocol and IEEE 802.15.4 specifications. Stack operation is triggered by calling the function,
Stack operation will continue until the requested primitive path is complete or an application-level primitive needs to be processed.
Since only one primitive can be processed at one time, a single data structure (a union) is used to hold all the primitive parameters. This structure can be viewed in the file, ZigBeeTasks.h. Take care when accessing this structure that you do not overwrite a parameter before using it. After processing a primitive, it is critical that the current primitive be set to the next primitive to execute (or NO_PRIMITIVE) to avoid an infinite loop (see Example 1). Refer to the “Primitive Summary” section for a list of the common primitives used by the application layer.
Default processing for most primitives is included in the template files. Two primitives will require additional application-specific code:
ZigBeeTasks( ¤tPrimitive );
// Include cases for each required primitive.
// Be sure to update currentPrimitive!
currentPrimitive = NO_PRIMITIVE;