协议栈:Z-Stack 3.0.2
协调器:CC2538
1、问题描述
(1)我用终端主动发送 “Discover Commands Received Response” 命令给协调器。
(2)协调器在应用层的 ZCL_CMD_DISCOVER_CMDS_RECEIVED_RSP 中处理此消息。
- static uint8 zclGenericApp_ProcessInDiscCmdsRspCmd( zclIncomingMsg_t *pInMsg )
- {
- zclDiscoverCmdsCmdRsp_t *discoverRspCmd;
- uint8 i;
- discoverRspCmd = (zclDiscoverCmdsCmdRsp_t *)pInMsg->attrCmd;
- for ( i = 0; i < discoverRspCmd->numCmd; i++ )
- {
- // Device is notified of the result of its attribute discovery command.
- }
- return ( TRUE );
- }
(3)发现获取到的命令ID与终端发送过来的命令ID不同。
2、我更改 zclDiscoverCmdsCmdRsp_t 结构体后就可以了。
将:
typedef struct
{
uint8 discComplete;
uint8 cmdType; // either ZCL_CMD_DISCOVER_CMDS_GEN or ZCL_CMD_DISCOVER_CMDS_RECEIVED
uint8 numCmd; // number of provided commands
uint8 *pCmdID; // variable length array
} zclDiscoverCmdsCmdRsp_t;
改为:
typedef struct
{
uint8 discComplete;
uint8 cmdType; // either ZCL_CMD_DISCOVER_CMDS_GEN or ZCL_CMD_DISCOVER_CMDS_RECEIVED
uint8 numCmd; // number of provided commands
uint8 pCmdID[]; // variable length array
} zclDiscoverCmdsCmdRsp_t;
为什么像 zclDiscoverAttrsRspCmd_t 、zclReportCmd_t 这些结构体都是用数组 uint8 pCmdID[]; 而 zclDiscoverCmdsCmdRsp_t 却是用 uint8 *pCmdID; 呢,这两者有区别吗?