节点上报的数据在协调器的接收处理如下,怎么只收到1字节数据
节点每格10秒上报3字节数据,节点为CC2630,协调器CC25358,协议栈home 1.2.2
case ZCL_CMD_REPORT://节点上报数据
//zclSampleDoorLockController_ProcessInReportCmd( pInMsg );
if (pInMsg->clusterId == ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK) rpt_cmd= ((zclReportCmd_t *)pInMsg->attrCmd);
//numAttr=rpt_cmd->numAttr;
//attrID=rpt_cmd->attrList->attrID;
//dataType=rpt_cmd->attrList->dataType; attrData=(rpt_cmd->attrList->attrData);//来自节点的数据
节点端(cc2630)上报程序如下:
zclReportCmd_t *reportCmd;
// Build and send a ZCL temperature reading to the matched device
reportCmd = ICall_malloc( sizeof(zclReportCmd_t) + sizeof(zclReport_t) );
//if(reportCmd != NULL)
//{
afAddrType_t dstAddr;
// Fill in the destination address
dstAddr.addrMode = (afAddrMode_t)Addr16Bit;
dstAddr.addr.shortAddr = 0x00;
dstAddr.endPoint = DLSAPP_EP;
//dstAddr.panId = ztsDstAddr.panID;
// Fill in the single attribute information for the temperature reading
reportCmd->numAttr = 1;
reportCmd->attrList[0].attrID = ATTRID_CLOSURES_LOCK_STATE;
reportCmd->attrList[0].dataType = ZCL_DATATYPE_UINT8;
reportCmd->attrList[0].attrData = (void *)(zdlLockState);
// Call ZCL function to send the report
zcl_SendReportCmd(DLSAPP_EP, &dstAddr,
ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK,
reportCmd,
ZCL_FRAME_CLIENT_SERVER_DIR,
true,
zclSampleDoorLockSeqNum++);
ICall_free(reportCmd);
Alvin Chen:
reportCmd->attrList[0].attrData = (void *)(zdlLockState);你这个zdlLockState是个什么?
Alvin Chen:
回复 Alvin Chen:
如果你想发送字符串你的datatype也对应的,剩下就是指针的问题。
pReportCmd->attrList[0].dataType = ZCL_DATATYPE_CHAR_STR;pReportCmd->attrList[0].attrData = (void *)(&zclFutureSensor_Value);
user5367314:
回复 Alvin Chen:
zdlLockState待发送的数组的名字,例如发送的3字节如下
zdlLockState[0]=0x00;zdlLockState[1]=0x11;zdlLockState[2]=0x22;
user5367314:
回复 Alvin Chen:
发送了协调收不到是什么原因?只发一个字节可以收到,发送2个字节的就收不到了
YiKai Chen:
回复 user5367314:
有沒有抓包看看发送2个字节的封包有沒有送出來?
user5367314:
回复 YiKai Chen:
接收的程序如下,能进入下面的case,但是收到的数据应该是放在哪里?
估计是我处理的不对,不知道从哪里取出收到的数据?请指教
case ZCL_CMD_REPORT://zclSampleDoorLockController_ProcessInReportCmd( pInMsg );if (pInMsg->clusterId == ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK)rpt_cmd= ((zclReportCmd_t *)pInMsg->attrCmd);//numAttr=rpt_cmd->numAttr;//attrID=rpt_cmd->attrList->attrID;//dataType=rpt_cmd->attrList->dataType; attrData=(rpt_cmd->attrList->attrData);
YiKai Chen:
回复 user5367314:
你填在attrData,當然就是從attrData取出收到的数据
user5367314:
回复 YiKai Chen:
ZCL_CLUSTER_ID_CLOSURES_DOOR_LOCK,{ // Attribute record,在这里ATTRID_CLOSURES_LOCK_STATE,ZCL_DATATYPE_ENUM8,(ACCESS_CONTROL_READ | ACCESS_REPORTABLE),(void *)&zdlLockState}
zdlLockState是我的数据,但是attrData是8bit的,多个字节的数据怎么放到attrData里?
另外ZCL_DATATYPE_ENUM8是什么意思?
YiKai Chen:
回复 user5367314:
多个字节的数据你就不能用ZCL_DATATYPE_ENUM8,ZCL_DATATYPE_ENUM8代表的是1个字节ENUM格式的数据