📄 tempdemocoord.c
字号:
/*
Microchip ZigBee Stack
Temperature Demo - Coordinator
This demonstration shows how to use the temperature sensor on the PICDEM Z
Demo Board. Since the Home Controls, Lighting profile does not contain the
device description for a temperature sensor, a demonstration profile has been
created.
NOTE: This profile is for demonstration purposes only. It has not been
approved by the ZigBee Alliance, and therefore should not be used for
creating commercial applications.
The Temperature Demo ZigBee coordinator project is designed to interact with
a second PICDEM Z programmed with the Temperature Demo RFD project. The
coordinator device must be powered on first. After it has established a
network, the RFD device may be powered on. After the RFD has joined the network,
the coordinator must obtain the short address of the RFD so the coordinator can
request temperature information from the RFD. The coordinator can discover the
network address of the RFD using two methods. If the USE_BINDINGS definition is
uncommented below, then End Device Binding must be performed between the two
devices before messages can be sent and received successfully. If USE_BINDINGS
is commented out, then the coordinator will default to the probable network address
of the RFD, and messages may be able to be sent immediately. However, the
coordinator will also be capable of performing Device Discovery to discover the
actual network address of the RFD, in case the network was formed with alternate
short address assignments.
NOTE: In this demo, only the ZigBee coordinator needs to be configured with the
USE_BINDINGS definition. The RFD contains the code for sending the End Device Bind
request, but can automatically respond to either direct or indirect messages.
Switch functionality is as follows:
RB4, Request temperature from RFD
RB5, USE_BINDINGS undefined, sends a NWK_ADDR_req for the MAC address specified
RB5, USE_BINDINGS defined, sends an End Device Bind request
Device Discovery
----------------
If the USE_BINDINGS definition is commented out, pressing RB5 will send a
broadcast NWK_ADDR_req message. The NWK_ADDR_req message contains the MAC
address of the desired node. Be sure this address matches the address
contained in the other node's zigbee.def file. Note that only the coordinator
needs to determine the RFD's network address. The RFD will know whom to send
the response to based on the information in the request message. NOTE: When
using this method, the RFD's temperature endpoint must be known by the coordinator.
For demostration purposes only, it has been hardcoded.
End Device Binding
------------------
If the USE_BINDINGS definition is uncommented, the coordinator will send an
APS indirect message to request the temperature, and the RFD will reply using
an APS indirect message. To perform End Device Binding, press RB5 on one
PICDEM Z, and then press RB5 on the other PICDEM Z within 5 seconds. A message
will be displayed indicating if binding was successful or not. Note that End
Device Binding is a toggle function. Performing the operation again will
unbind the nodes, and messages will not reach their final destination.
NOTE: Bindings are unidirectional. Therefore, when using End Device Bindings,
two bindings must be created, one for the request message to travel to
the RFD, and one for the response to travel from the RFD. The End Device
Bind Request messages have the Temperature_CLUSTER specified as both an
input and an output cluster to create two bindings, one for each direction.
To describe the devices accurately, however, the device's simple descriptors
use only the appropriate input or output cluster.
*********************************************************************
* FileName: TempDemoCoord.c
* Dependencies:
* Processor: PIC18F
* Complier: MCC18 v3.00 or higher
* Company: Microchip Technology, Inc.
*
* Software License Agreement
*
* The software supplied herewith by Microchip Technology Incorporated
* (the 揅ompany
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -