Ammar Rana

MC13213- Problem on perfoming check on MAC code bases extended address

Discussion created by Ammar Rana on Dec 12, 2007
Latest reply on Dec 13, 2007 by Mike Ware
Hello everyone ,
I am working on an application scenario (non beacon mode), where all my devices are using MAC addresses. After one day long fighthing with MAC extended address i made it worked. Now i could see at my sniffer that all my devices are using Extended address for transmission.
Now , while trying to put a check that , if i have a MAC of device already stored in my database . My device will not assosciate with that master  and find another master if it exist. For this purpose i am using information gained during the Scan procedure to compare with my stored value. And to check wether is there any value stored or return , i am printing it too.  
The printing is working and i could see that i am storing those addresses, but in comparison its not working.  The most amazing this is that if changed my condition    if(pPanDesc->coordAddress !=maDeviceLongAddress ) , it ll print the values wriiten in conditon , means it considering it true. But when i tried to put == , it wont work.  The addresses maDeviceLongAddress , pPanDesc->coordAddress and testaddr are all same and of one device.
I am in confusing state , as everything is fine and working , but why it come to comaprison its not working.
Anyone who has worked with MAC address or comparison , kindly guide me.
static uint8_t App_HandleScanActiveConfirm(nwkMessage_t *pMsg)
  uint8_t panDescListSize   = pMsg->msgData.scanCnf.resultListSize;
  panDescriptor_t *pPanDesc = pMsg->msgData.scanCnf.resList.pPanDescriptorList ;
  uint8_t rc = errorNoScanResults;
  UartUtil_Print("The address of the device in my range123 .......\n");
      UartUtil_Print("\n.0x"); UartUtil_PrintHex((uint8_t *)maDeviceLongAddress,8,0) ;
  /* Check if the scan resulted in any coordinator responses. */
  if(panDescListSize != 0)
    /* Initialize link quality to very poor. */
    uint8_t i, bestLinkQuality = 0;
    /* Check all PAN descriptors. */
    for(i=0; i<panDescListSize; i++, pPanDesc++)
      UartUtil_Print("The loop.......\n");
       UartUtil_PrintHex(&panDescListSize,1,0) ;
       UartUtil_Print("The loop2.......\n");
       UartUtil_PrintHex(&pPanDesc,1,0) ;
      /* Only attempt to associate if the coordinator
         accepts associations and is non-beacon. */
      if( ( pPanDesc->superFrameSpec[1] & gSuperFrameSpecMsbAssocPermit_c) &&
          ((pPanDesc->superFrameSpec[0] & gSuperFrameSpecLsbBO_c) == 0x0F) )
         UartUtil_Print("The address of the device in my range321 .......\n");
      UartUtil_Print("\n.0x"); UartUtil_PrintHex((uint8_t *)testaddr,8,0) ;
         if(pPanDesc->coordAddress==maDeviceLongAddress )
             UartUtil_Print("Hello world \n");
             UartUtil_Print("The address of the device in my range654 .......\n");
            UartUtil_Print("\n.0x"); UartUtil_PrintHex((uint8_t *)maDeviceLongAddress,8,0) ;
             UartUtil_Print("The address of the device in my range456 .......\n");
      UartUtil_Print("\n.0x"); UartUtil_PrintHex((uint8_t *)testaddr,8,0) ;
          /* Save the information of the coordinator candidate. If we
             find a better candiate, the information will be replaced. */
             FLib_MemCpy(&mCoordInfo, pPanDesc, sizeof(panDescriptor_t));
            UartUtil_Print("Found a coordinator with the following properties:\n");
            UartUtil_Print("\nAddress...........0x"); UartUtil_PrintHex(mCoordInfo.coordAddress, mCoordInfo.coordAddrMode == gAddrModeShort_c ? 2 : 8, 0);
            UartUtil_Print("\nPAN ID............0x"); UartUtil_PrintHex(mCoordInfo.coordPanId, 2, 0);
            UartUtil_Print("\nLogical Channel...0x"); UartUtil_PrintHex(&mCoordInfo.logicalChannel, 1, 0);
            UartUtil_Print("\nBeacon Spec.......0x"); UartUtil_PrintHex(mCoordInfo.superFrameSpec, 2, 0);
            UartUtil_Print("\nLink Quality......0x"); UartUtil_PrintHex(&mCoordInfo.linkQuality, 1, 0);
           rc = errorNoError;
  /* ALWAYS free the PAN descriptor list */
  MSG_Free(pMsg-> msgData.scanCnf.resList.pPanDescriptorList);
  return rc;