This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
平台是cc2530 +z-stack3.0.1,使用enddevice类型设备。
在设备初次上电并找网完成之后,通过zcl_SendReportCmd函数上报数据正常。但是当低功耗设备进入睡眠之后通过外部中断唤醒,当使用相同的函数上报相同的数据时,每次都返回错误0x10.
zcl_SendReportCmd返回0x10错误是什么原因?为什么在未睡眠之前可以发送成功,睡眠唤醒之后就一直返回0x10?
uint8 DataBuff[16] = {0};
zclReportCmd_t* reportCmd = osal_mem_alloc( sizeof( zclReportCmd_t ) + sizeof( zclReport_t ));
if(reportCmd != NULL)
{
reportCmd->numAttr = 1;
reportCmd->attrList[0].attrID = ATTRID_BASIC_SMART_LOCK_DATA;
reportCmd->attrList[0].dataType = ZCL_DATATYPE_CHAR_STR;
DataBuff[0] = len;
memcpy(DataBuff + 1,buff,len);
memcpy(SmartLockData,DataBuff,len + 1);
reportCmd->attrList[0].attrData = SmartLockData;
if(ZDApp_GetState() == DEV_END_DEVICE && zoneState == SS_IAS_ZONE_STATE_ENROLLED)
{
HalLedSet(led_red, HAL_LED_MODE_ON);
osal_start_timerEx(ias_TaskID, SAMPLEAPP_TURN_OFF_RED, 100);//亮灯
ZStatus_t status = zcl_SendReportCmd(SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, ZCL_CLUSTER_ID_GEN_BASIC,
reportCmd, ZCL_FRAME_SERVER_CLIENT_DIR, TRUE, zclSampleSwSeqNum++);
}
这是使用zcl_SendReportCmd函数的相关代码,就是此处status返回0x10错误。
ZStatus_t zcl_SendReportCmd( uint8 srcEP, afAddrType_t *dstAddr,
uint16 clusterID, zclReportCmd_t *reportCmd,
uint8 direction, uint8 disableDefaultRsp, uint8 seqNum )
{
uint16 dataLen = 0;
uint8 *buf;
ZStatus_t status;
uint8 i;
// calculate the size of the command
for ( i = 0; i < reportCmd->numAttr; i++ )
{
zclReport_t *reportRec = &(reportCmd->attrList[i]);
dataLen += 2 + 1; // Attribute ID + data type
// Attribute Data
dataLen += zclGetAttrDataLength( reportRec->dataType, reportRec->attrData );
}
buf = zcl_mem_alloc( dataLen );
if ( buf != NULL )
{
// Load the buffer - serially
uint8 *pBuf = buf;
for ( i = 0; i < reportCmd->numAttr; i++ )
{
zclReport_t *reportRec = &(reportCmd->attrList[i]);
*pBuf++ = LO_UINT16( reportRec->attrID );
*pBuf++ = HI_UINT16( reportRec->attrID );
*pBuf++ = reportRec->dataType;
pBuf = zclSerializeData( reportRec->dataType, reportRec->attrData, pBuf );
}
status = zcl_SendCommand( srcEP, dstAddr, clusterID, ZCL_CMD_REPORT, FALSE,
direction, disableDefaultRsp, ReportMandCode, seqNum, dataLen, buf );
zcl_mem_free( buf );
}
else
{
status = ZMemError;
}
return ( status );
}
这是zcl_SendReportCmd函数,用的是协议栈自带的版本,没有做改动,其中修改ReportMandCode=0x1249.