Problems while passing a pointer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems while passing a pointer

2,750 Views
CecchiSandrone
Contributor II
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?

Labels (1)
0 Kudos
Reply
3 Replies

762 Views
Sten
Contributor IV
Do you have the SendLQI-function declared before you call it? Try changing the order of the functions or adding a prototype before using it in BeeAppDataIndication.
 
Sten
 
0 Kudos
Reply

762 Views
CecchiSandrone
Contributor II
Yes, I declared SendLQI even before BeeAppDataIndication but I have same results :smileysad:
0 Kudos
Reply

762 Views
CecchiSandrone
Contributor II
Mmm, it seems to be a debugger bug. If I print these values with LCD display they are correct. I'll submit a service request.
0 Kudos
Reply