因为这时你都不知道那个概念要去那个英文资料里去找,弄得你晕头转向.
头脑里有了一个基本框架之后,结合你要干的项目,找一个比较贴近的JN-AP-XXXX看一下,结合Jennic公司的演示
程序,进一步理解张宏亮先生讲的概念,然后就在这个演示程序的基础上做改动,变成你的开发程序,这样上手快,可以少
走弯路.
例如,我要搞一个将下位仪表的数据通过ZigBee上传到计算机的课题,我就选了JN-AP-1015做框架,在这个演示程序
的基础上开始了我的实际操练,在这个演示程序中,已有Router的发送程序和Coordinator的接收程序,我只需要再添加
Coordinator的发送程序和Router的接收程序就可以了,这样复杂的问题简单化了.下面分别叙述需要添加的程序:
在Router这方面,首先要添加Simple deor,没有这段程序,Router就不会实现接收功能,我加入的语句如下:
见JN-RM-2018的说明,
这是解释部分:
uint8 afmeAddSimpleDesc(uint8 u8Endpoint,
uint16 u16ProfileID,
uint16 u16DeviceID,
uint8 u8DeviceVersion,
uint8 u8Flags,
uint8 u8InClusteCount,
uint8 *pau8nClusterList,
uint8 u8OutClusterCount,
uint8 *pau8OutClusterList);
Deion:
afmeAddSimpleDesc函数来对Router添加deor,
Parameters:
1. EndPoint序号:
u8Endpoint Endpoint number that this deor
refers to (in range 0x01 to 0xF0),
本程序中定义为: WSN_DATA_SOURCE_ENDPOINT 0x41,
这里是指Router, 在此处和Coordinator程序中的
对象应该不是同一个了 !!!!!
2. 所使用的Profile ID:
u16ProfileID Profile ID that the endpoint supports
(in range 0 to 0xFFFF),
本程序中定义为: WSN_PROFILE_ID 0x123,
这是由ZigBee联盟分配的 !!!
3. 设备ID:
u16DeviceID Device deion that the endpoint supports
(in range 0 to 0xFFFF),
Jennic公司就规定为: 0000,
4. 设备版本:
u8DeviceVersion Version of the device deion
(in range 0 to 0xFF),
Jennic公司就规定为: 0x00,
5. 标志参数:
u8Flags Application specific flags (in range 0 to 0x0F).
For more details, see the deion of
AF_SIMPLE_DEOR in Section 3.1
本程序中定义为: 0x00, 4位有效数字,
bit 0表示是否有complex deor,
bit 1 表示是否有 user dero,
bit 2、3是保留的
6. 输入cluster数量:
u8InClusterCount Number of input clusters supported by
the endpoint (in range 0 to 0xFF),
本程序中定义为: 1,
7. cluster数组:
*pau8InClusterList Pointer to array containing list of input
clusters supported by the endpoint,
本程序中定义为: WSN_CID_SENSOR_READINGS 0x12,
8. 输出cluster数量: ***** 重点,
u8OutClusterCount Number of output clusters supported
by the endpoint (in range 0 to 0xFF),
本程序中定义为: 1,
9. cluster数组:
*pau8OutClusterList Pointer to array containing list of
output clusters supported by the endpoint,
本程序中定义为: WSN_CID_SENSOR_READINGS 0x12,
Return Values: Result code
需要注意的是:如果一个endpoint上没有正确定义的simple deor,
那么它就不能正确地接受别的节点发送来的数据,这是特别需要注意的 !!!!
================== ----------------
现在我使用afmeAddSimpleDesc函数来对endpoint添加deor:
*/
PUBLIC void JZA_vStackEvent(teJZS_EventIdentifier eEventId,
tuJZS_StackEvent *puStackEvent)
{
if (eEventId == JZS_EVENT_NWK_JOINED_AS_ROUTER)
{
/*
这个需要在Router端定义endpoint的 simple deor,而且co-ordinator端的
simple deor也需要修改。 要定义相应的input和output的cluster,
修改Router和Co-ordiantor端的"描述"代码如下,
这样应该就可以在router和co-ordinator之间互发数据了。
这段是我加的,
Router的"描述"位置和Coordinator的"描述"位置还不一样,
2007.11.16日,我给改成在同一个位置了,
*/
uint8 u8InputClusterCnt = 1;
uint8 au8InputClusterList[] = {WSN_CID_SENSOR_READINGS};
uint8 u8OutputClusterCnt = 1;
uint8 au8OutputClusterList[] = {WSN_CID_SENSOR_READINGS};
(void)afmeAddSimpleDesc(WSN_DATA_SOURCE_ENDPOINT,
WSN_PROFILE_ID,
0x0000,
0x00,
0x00,
u8InputClusterCnt,
au8InputClusterList,
u8OutputClusterCnt,
au8OutputClusterList);
bNwkJoined = TRUE;
}
}
/*
Macro Definitions in WSN_Profile.h,
#define WSN_DATA_SINK_ENDPOINT 0x40, Coordinator的端口号,
#define WSN_DATA_SOURCE_ENDPOINT 0x41, Router的端口号,
#define WSN_PROFILE_ID 0x123, 这是由ZigBee联盟分配的 !!!
#define WSN_CID_SENSOR_READINGS 0x12, 这是怎么定义的 ?
它相当于u8ClusterId, */
simple deor到此添加完毕,------------------------------------------------
发表评论 评论 (0 个评论)