ZigBee协议中的规范(Profile)和簇(Cluester)的概念

来源:互联网 发布:网络大专文凭找工作 编辑:程序博客网 时间:2024/05/15 23:53

转自:http://blog.csdn.net/gdliweibing/article/details/12745505

ZigBee协议中的规范(Profile)和簇(Cluester)的概念

        1、规范(Profile):ZigBee网络中数据的收发是建立应用规范(Application  Profile)的基础上的。每个应用规范都有 一个ID;应用规范可分为公共规范(Public profile)且ID范围为0x0000`0x7FFF和制造商特定规范(Manufacturer Specific Profile)且ID范围为0xbF00~0xFFFF.其实,规范就是说一类建筑或场合使用某规范。比如:商业楼宇自动化有他自己的规范,且ID为0x0105,民宅要使用另一个ID号。很简单的吧。

        2、簇(Cluester):某一应用对象的一个特定对象。比如自动窗帘。(打开是一个命令、关闭要是另一个命令)。比如实验2中的点对点通信中

  1. //Coordinator.h    
  2. #define GENERICAPP_MAX_CLUSTERS   1 //定义一个簇的大小,一个簇的大小为N
  3. #define GENERICAPP_CLUSTERID      1 //定义一个簇中的一个一个命令ID



  1. //Coordinator.c  
  2. const cId_t GenericApp_ClusterList[GENERICAPP_MAX_CLUSTERS]=  //GenericApp_ClusterList就是一个簇,他有GENERICAPP_MAX_CLUSTERS条命令,下面一一列出命令的ID号
  3. {  
  4.   GENERICAPP_CLUSTERID   
  5. };  

        3、端口:使用一个节点就有一个网络地址,但在一个节点上可以有很多端口。在规范中使用简单描述符(SimpleDescriptionFormat_t结构)来描述一个端口。而在因为有很多端口,端口之间必需附加有任务切换使用的参数。结果就用endPointDesc_t结构来表示一个端口。endPointDesc_t定义如下:

[cpp] view plain copy
  1. //AF.h  
[cpp] view plain copy
  1. typedef struct  
  2. {  
  3.   byte endPoint;  
  4.   byte *task_id;  // Pointer to location of the Application task ID.  
  5.   SimpleDescriptionFormat_t *simpleDesc;   //关键是这个,见下面的结构体。  
  6.   afNetworkLatencyReq_t latencyReq;    //使用默认参数即可  
  7. } endPointDesc_t;  

SimpleDescriptionFormat_t结构如下:
[cpp] view plain copy
  1. //Filename:       AF.h  
[cpp] view plain copy
  1. typedef uint16  cId_t;  
  2. // Simple Description Format Structure  
  3. typedef struct  
  4. {  
  5.   byte          EndPoint;       //端口号  
  6.   uint16        AppProfId;      //应用规范ID  
  7.   uint16        AppDeviceId;    //应用设备ID  
  8.   byte          AppDevVer:4;    //应用设备版本号  4bit 这里使用的是位域  
  9.   byte          Reserved:4;             // AF_V1_SUPPORT uses for AppFlags:4.  
  10.   byte          AppNumInClusters;    //输入簇包含的命令个数  
  11.   cId_t         *pAppInClusterList;  //输入簇列表  可有<span style="font-family:Consolas,'Courier New',Courier,mono,serif; line-height:18px; background-color:rgb(248,248,248)">GENERICAPP_MAX_CLUSTERS个输入命令</span>  
  12.   byte          AppNumOutClusters;   //输出簇包含的命令个数  
  13.   cId_t         *pAppOutClusterList;//输出簇列表  可有<span style="font-family:Consolas,'Courier New',Courier,mono,serif; line-height:18px; background-color:rgb(248,248,248)">GENERICAPP_MAX_CLUSTERS个输出命令</span>  
  14. } SimpleDescriptionFormat_t;  

在协调器和终端节点都有一个SimpleDescripitonFormat_t类型定义的GenericApp_SipleDesc变量。(当然也可以定义多个变量。到底怎样应用到实例呢?还没想到)综合上面的所有,回看代码:

[cpp] view plain copy
  1. //Coordinator.c  
[cpp] view plain copy
  1. //简单设备描述符(描述一个ZigBee设备节点)  
  2. const SimpleDescriptionFormat_t GenericApp_SimpleDesc=  
  3. {  
  4.   GENERICAPP_ENDPOINT,  
  5.   GENERICAPP_PROFID,  
  6.   GENERICAPP_DEVICEID,  
  7.   GENERICAPP_DEVICE_VERSION,  
  8.   GENERICAPP_FLAGS,  
  9.   GENERICAPP_MAX_CLUSTERS, //输入簇包含的命令个数  
  10.  (cId_t*)GenericApp_ClusterList, //输入簇列表  可有<span style="font-family:Consolas,'Courier New',Courier,mono,serif; line-height:18px; background-color:rgb(248,248,248)">GENERICAPP_MAX_CLUSTERS个输入命令</span>  
  11.   0,  
  12.   (cId_t *)NULL  
  13. };  

上面的宏是在下面的代码中定义的,这个宏也被终端节点引用
[cpp] view plain copy
  1. //Coordinator.h  
  2. #define GENERICAPP_ENDPOINT   10  //端口在这里使用的是端口号10,可用的范围为(1~240)  
  3.   
  4. #define GENERICAPP_PROFID     0x0F04    //  
  5. #define GENERICAPP_DEVICEID   0x0001  //  
  6.   
  7. #define GENERICAPP_DEVICE_VERSION 0 //  
  8. #define GENERICAPP_FLAGS          0 /  
  9.   
  10. #define GENERICAPP_MAX_CLUSTERS   1   
  11. #define GENERICAPP_CLUSTERID      1   

终端节点代码:
[cpp] view plain copy
  1. //Enddevice.c  
[cpp] view plain copy
  1. //初始化端口描述符  
  2. const SimpleDescriptionFormat_t GenericApp_SimpleDesc=  
  3. {  
  4.   GENERICAPP_ENDPOINT,  
  5.   GENERICAPP_PROFID,  
  6.   GENERICAPP_DEVICEID,  
  7.   GENERICAPP_DEVICE_VERSION,  
  8.   GENERICAPP_FLAGS,  
  9.   0,  
  10.   (cId_t*)NULL,  
  11.   GENERICAPP_MAX_CLUSTERS,         //输出簇包含的命令个数  
  12.   (cId_t*)GenericApp_ClusterList  //输出簇列表  可有<span style="font-family:Consolas,'Courier New',Courier,mono,serif; line-height:18px; background-color:rgb(248,248,248)">GENERICAPP_MAX_CLUSTERS个输出命令</span>  
  13. };  

注意到没?这个协调器上的簇是输入命令,而终端节点是输出命令。对于通信双方来说,必须是一方是输入命令,另一方则是输出命令。(到底哪一方式输入,哪一方式输出则看看在说。对到目前只做过一个节点发送数据,另一个接受数据。都还没有做过两节点间的双向发送和接受通信)。
本文参考自:《ZigBee无线传感器网络设计与实现》      王小强等人编著化学工业出版社
0 0
原创粉丝点击