Z-Stack 2.6.1中simplemeter_ProcessInConfigReportCmd函数的问题
时间:10-02
整理:3721RD
点击:
/********************************************************************* * @fn simplemeter_ProcessInConfigReportCmd * * @brief Process the "Profile" Configure Reporting Command * * @param pInMsg - incoming message to process * * @return TRUE if attribute was found in the Attribute list, * FALSE if not */ static uint8 simplemeter_ProcessInConfigReportCmd( zclIncomingMsg_t *pInMsg ) { zclCfgReportCmd_t *cfgReportCmd; zclCfgReportRec_t *reportRec; zclCfgReportRspCmd_t *cfgReportRspCmd; zclAttrRec_t attrRec; uint8 status; uint8 i, j = 0; cfgReportCmd = (zclCfgReportCmd_t *)pInMsg->attrCmd; // Allocate space for the response command cfgReportRspCmd = (zclCfgReportRspCmd_t *)osal_mem_alloc( sizeof ( zclCfgReportRspCmd_t ) + \ sizeof ( zclCfgReportStatus_t) * cfgReportCmd->numAttr ); if ( cfgReportRspCmd == NULL ) return FALSE; // EMBEDDED RETURN // Process each Attribute Reporting Configuration record for ( i = 0; i < cfgReportCmd->numAttr; i++ ) { reportRec = &(cfgReportCmd->attrList[i]); status = ZCL_STATUS_SUCCESS; if ( zclFindAttrRec( SIMPLEMETER_ENDPOINT, pInMsg->clusterId, reportRec->attrID, &attrRec ) ) { if ( reportRec->direction == ZCL_SEND_ATTR_REPORTS ) { if ( reportRec->dataType == attrRec.attr.dataType ) { // This the attribute that is to be reported if ( zcl_MandatoryReportableAttribute( &attrRec ) == TRUE ) { if ( reportRec->minReportInt < SIMPLEMETER_MIN_REPORTING_INTERVAL || ( reportRec->maxReportInt != 0 && reportRec->maxReportInt < reportRec->minReportInt ) ) { // Invalid fields status = ZCL_STATUS_INVALID_VALUE; } else { // Set the Min and Max Reporting Intervals and Reportable Change //status = zclSetAttrReportInterval( pAttr, cfgReportCmd ); status = ZCL_STATUS_UNREPORTABLE_ATTRIBUTE; // for now } } else { // Attribute cannot be reported status = ZCL_STATUS_UNREPORTABLE_ATTRIBUTE; } } else { // Attribute data type is incorrect status = ZCL_STATUS_INVALID_DATA_TYPE; } } else { // We shall expect reports of values of this attribute if ( zcl_MandatoryReportableAttribute( &attrRec ) == TRUE ) { // Set the Timeout Period //status = zclSetAttrTimeoutPeriod( pAttr, cfgReportCmd ); status = ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; // for now } else { // Reports of attribute cannot be received status = ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; } } } else { // Attribute is not supported status = ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; } // If not successful then record the status if ( status != ZCL_STATUS_SUCCESS ) { cfgReportRspCmd->attrList[j].status = status; cfgReportRspCmd->attrList[j++].attrID = reportRec->attrID; } } // for loop if ( j == 0 ) { // Since all attributes were configured successfully, include a single // attribute status record in the response command with the status field // set to SUCCESS and the attribute ID field omitted. cfgReportRspCmd->attrList[0].status = ZCL_STATUS_SUCCESS; cfgReportRspCmd->numAttr = 1; } else { cfgReportRspCmd->numAttr = j; } // Send the response back zcl_SendConfigReportRspCmd( SIMPLEMETER_ENDPOINT, &(pInMsg->srcAddr), pInMsg->clusterId, cfgReportRspCmd, ZCL_FRAME_SERVER_CLIENT_DIR, TRUE, pInMsg->zclHdr.transSeqNum ); osal_mem_free( cfgReportRspCmd ); return TRUE ; }
根据提示这个函数的功能应该是设置属性值并把未成功设置的属性值报告给发送方,当但是程序中并未有设置属性这部分,而且在程序里面循环中status值一定会从ZCL_STATUS_SUCCESS变为其他的错误指示值,这是什么原因呢?
你的Attribute有没有事先注册过?断点调试过吗