Other Parts Discussed in Thread: Z-STACK
在Z-stack中,使用pfnReadWriteCB访问的Attribute和实际分配了全局变量的Attribute有什么区别?为什么前者不能用Reporting的方式进行上报?
针对上述情况,我修改了ZCL.c下面的函数zcl_SendReportCmd,使其能够被Reporting
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 );
if( reportRec->attrData )
{
dataLen += zclGetAttrDataLength( reportRec->dataType, reportRec->attrData );
}
else
{
dataLen += zclGetAttrDataLengthUsingCB( srcEP, clusterID, reportRec->attrID );
}
}
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 );
if ( reportRec->attrData != NULL )
{
// Copy attribute data to the buffer to be sent out
pBuf = zclSerializeData( reportRec->dataType, reportRec->attrData, pBuf );
}
else
{
uint16 dataLen;
// Read attribute data directly into the buffer to be sent out
zclReadAttrDataUsingCB( srcEP, clusterID, reportRec->attrID, pBuf, &dataLen );
pBuf += dataLen;
}
}
status = zcl_SendCommand( srcEP, dstAddr, clusterID, ZCL_CMD_REPORT, FALSE,
direction, disableDefaultRsp, 0, seqNum, dataLen, buf );
zcl_mem_free( buf );
}
else
{
status = ZMemError;
}
return ( status );
}
另外还要修改BDB_Reporting中的函数,这样改是否符合zigbee规范?