Hi,I'm writing a simple app that upon receiving a packet from a zigbee device, sends a response packet containing a value (Link Quality Indicator from incoming data indication, a uint8_t). Here it is the code taken from BeeApp.c:Code:
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);
/*
Note: if multiple endpoints are supported by this app, insert
endpoint filtering here...
This app assumes only 1 active endpoint. APS layer has already
filtered by endpoint and profile.
Note: all multi-byte over-the-air fields are little endian.
That is 0x1101 would come in byte order 0x01 0x11.
*/
/* handle the command */
if(pIndication->aClusterId[0] == appDataCluster[0]) {
SendLQI(pIndication);
}
/* Free memory allocated by data indication */
MSG_Free(pMsg);
}
}
void SendLQI
(
zbApsdeDataIndication_t *indication // Contains requestor info (address)
)
{
afAddrInfo_t addrInfo;
/* set up address information */
addrInfo.dstAddrMode = gZbAddrMode16Bit_c;
Copy2Bytes(addrInfo.dstAddr.aNwkAddr,indication->aSrcAddr);
addrInfo.dstEndPoint = dstEndPoint;
addrInfo.srcEndPoint = srcEndPoint;
addrInfo.txOptions = gApsTxOptionNone_c;
addrInfo.radiusCounter = afDefaultRadius_c;
/* set up cluster */
Copy2Bytes(addrInfo.aClusterId, appDataCluster);
/* send the data request */
(void)AF_DataRequest(&addrInfo,1,indication->linkQuality,NULL);
}
The problem is that into the function, the values pointed by
indication are wrong. This is due to
indication value variation when the function is invoked. I used debugger and the value of the pointer is different before and after SendLQI() invocation. Why? Maybe isn't the correct modality to pass that pointer?