#define MAX_ATTEMPTS 100uint8_t requestor[2];index_t txAttempt;zbApsCounter_t confirmId = 0x6;void BeeAppDataIndication ( void ){ apsdeToAfMessage_t *pMsg; zbApsdeDataIndication_t *pIndication; while(MSG_Pending(&gAppDataIndicationQueue)) { /* Get a message from a queue */ pMsg = MSG_DeQueue( &gAppDataIndicationQueue ); /* ask ZCL to handle the frame */ pIndication = &(pMsg->msgData.dataIndication); /* handle the command */ if(pIndication->aClusterId[0] == appDataCluster[0]) { Copy2Bytes(requestor,pIndication->aSrcAddr); txAttempt = 0; SendPacket(); } /* Free memory allocated by data indication */ MSG_Free(pMsg); }}void BeeAppDataConfirm ( void ){ apsdeToAfMessage_t *pMsg; zbApsdeDataConfirm_t *pConfirm; while(MSG_Pending(&gAppDataConfirmQueue)) { /* Get a message from a queue */ pMsg = MSG_DeQueue( &gAppDataConfirmQueue ); pConfirm = &(pMsg->msgData.dataConfirm); /* Action taken when confirmation is received. */ if( pConfirm->status == gSuccess_c ) { /* successful confirm */ if(pConfirm->confirmId == confirmId) SendLQI(); } /* Free memory allocated in Call Back function */ MSG_Free(pMsg); }}void SendPacket ( void ) { if(txAttempt != MAX_ATTEMPTS) { afAddrInfo_t addrInfo; addrInfo.dstAddrMode = gZbAddrMode16Bit_c; Copy2Bytes(addrInfo.dstAddr.aNwkAddr,requestor); addrInfo.dstEndPoint = 0x01; addrInfo.srcEndPoint = 0x01; addrInfo.txOptions = gApsTxOptionNone_c; addrInfo.radiusCounter = afDefaultRadius_c; /* set up cluster */ Copy2Bytes(addrInfo.aClusterId, appDataCluster); /* send the data request */ (void)AF_DataRequest(&addrInfo,10,"Message",&confirmId); txAttempt++; } }
#define mDefaultValueOfPollTimeOut_c 3000