(Reprint) zigbee zcl specification and its protocol stack implementation 2

zigbee zcl specification and its protocol stack, real now 2  has introduced to deal with common commands, add the server to read the property value in accordance with the ideas and information flow function client samplesw want to know and own 12 Endpoint SAMPLESW_ENDPOINT bound that node samplelight (No. 13 endpoint) hardware version and vendor name, which has two properties zcl provisions belong zcl general of ZCL_CLUSTER_ID_GEN_BASIC a 1. first, you must configure the server samplelight this property, the code has been written, it is located function zclSampleLight_Init registered in the attribute table, zcl_registerAttrList (SAMPLELIGHT_ENDPOINT, SAMPLELIGHT_MAX_ATTRIBUTES, zclSampleLight_Attrs); attribute table configured zclSampleLight_Attrs properties ATTRID_BASIC_ZCL_VERSION and ATTRID_BASIC_MANUFACTURER_NAME, belonging ZCL_CLUSTER_ID_GEN_BASIC   { ZCL_CLUSTER_ID_GEN_BASIC ,     {// the attribute Record       ATTRID_BASIC_ZCL_VERSION,       ZCL_DATATYPE_UINT8, 














    







      ACCESS_CONTROL_READ,

      (void *)&zclSampleLight_ZCLVersion

    }

  },

  {

    ZCL_CLUSTER_ID_GEN_BASIC,

    { // Attribute record

      ATTRID_BASIC_MANUFACTURER_NAME,

      ZCL_DATATYPE_CHAR_STR,

      ACCESS_CONTROL_READ,

      (void *)zclSampleLight_ManufacturerName

    }

  },

2. InClusters里必须添加对clusterid ZCL_CLUSTER_ID_GEN_BASIC的支持
#define ZCLSAMPLELIGHT_BINDINGLIST       2
static cId_t bindingInClusters[ZCLSAMPLELIGHT_BINDINGLIST]
=

{
  ZCL_CLUSTER_ID_GEN_ON_OFF,
  ZCL_CLUSTER_ID_GEN_BASIC
};

3. At the time of application to get bound, bindingInClusters used as a parameter, the code has been implemented


    ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(),

                           SAMPLELIGHT_ENDPOINT,

                           ZCL_HA_PROFILE_ID,

                           ZCLSAMPLELIGHT_BINDINGLIST, bindingInClusters,

                           0, NULL,   // No Outgoing clusters to bind

                           TRUE );



B
1. The client samplesw cluster corresponding to the server using a list of
#define ZCLSAMPLESW_BINDINGLIST 2
static cId_t bindingOutClusters [ZCLSAMPLESW_BINDINGLIST] =
{
  ZCL_CLUSTER_ID_GEN_ON_OFF, ZCL_CLUSTER_ID_GEN_BASIC }; 2. use when applying the binding bindingOutClusters as a parameter, the code has been implemented     dstAddr.addrMode afAddr16Bit =;     dstAddr.addr.shortAddr = 0; // Makes The Coordinator match     ZDP_EndDeviceBindReq (& DstAddr, NLME_GetShortAddr (),                            SAMPLESW_ENDPOINT,                            ZCL_HA_PROFILE_ID,  0, NULL, // No incoming Clusters to the bind                            ZCLSAMPLESW_BINDINGLIST, bindingOutClusters ,
  







                          

                           TRUE);
3. performed somewhere in the following code, i.e., the application reads the following two properties of zclSampleSw_DstAddr ( zcl_SendRead () will be automatically assigned ZCL_FRAME_TYPE_PROFILE_CMD )
   zclReadCmd_t readcmd;
   ZStatus_t ST;
   readcmd.numAttr = 2;
   readcmd.attrID [0 ] = ATTRID_BASIC_ZCL_VERSION ;
   readcmd.attrID [. 1] = ATTRID_BASIC_MANUFACTURER_NAME ;
   ST = zcl_SendRead (SAMPLESW_ENDPOINT, & zclSampleSw_DstAddr,
                               / ZCL_CLUSTER_ID_GEN_ON_OFF / ZCL_CLUSTER_ID_GEN_BASIC ,
 & readcmd,

                               ZCL_FRAME_CLIENT_SERVER_DIR, to false, 0);

C
servers will receive information, triggerzclCmdTable [ZCL_CMD_READ] Function i.e. zclProcessInReadCmd function, which automatically read the relevant attributes back to the client, by the function zcl_SendReadRsp (), a command is ZCL_CMD_READ_RSP


D

client, samplesw after receiving the trigger information zclCmdTable [ZCL_CMD_READ_RSP] Function i.e. zclSendMsg function, this this function will send a message to the event ZCL_INCOMING_MSG upper task to deal with, provided that the top task using zcl_registerForMsg registered, while in samplesw already registered in the init.


In the process of the client, samplesw tasks

        Case ZCL_INCOMING_MSG:

          // Incoming ZCL Foundation the Command / the Response messages

          zclSampleSw_ProcessIncomingMsg ((zclIncomingMsg_t *) MSGpkt); -> zclSampleSw_ProcessInReadRspCmd

          BREAK;
  1. // property returns processing  
  2. static uint8 zclSampleSw_ProcessInReadRspCmd( zclIncomingMsg_t *pInMsg )  
  3. {  
  4.   zclReadRspCmd_t * readRspCmd;  
  5.   uint8 in;  
  6.   
  7.   readRspCmd = (zclReadRspCmd_t *)pInMsg->attrCmd;  
  8.   for (i = 0; i < readRspCmd->numAttr; i++)  
  9.   {  
  10.      uint8 str [6];  
  11.     // Notify the originator of the results of the original read attributes  
  12.     // attempt and, for each successfull request, the value of the requested  
  13.     // attribute  
  14.     /* 
  15.     if(i==0) 
  16.     { 
  17.        uint8  ii=*readRspCmd->attrList[i].data; 
  18.        _itoa (s, str, 10); 
  19.        HalLcdWriteString (size, 2); 
  20.     } 
  21.     */  
  22.     if(i==1)  
  23.     {  
  24.       uint8* pp=readRspCmd->attrList[i].data;  
  25.       HalLcdWriteString(pp,2);  
  26.     }  
  27.   }  
  28.   return TRUE;  
  29. }  
Released five original articles · won praise 0 · Views 251

Guess you like

Origin blog.csdn.net/DIANZI520SUA/article/details/103560868