This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Extended PanID -> PanID

Other Parts Discussed in Thread: Z-STACK, PMP

I have 2 questions about network scan.

 

I could get  Extended PanID of other pan nodes around with ZDP_MgmtNwkDiscReq().

How can I get 2byte Pan ID from Extended PanID ?

 

and 

 

When  NLME_NetworkDiscoveryRequest() sent,

How or where can I get the result ?

 

  • Hi,

    For the second question, Z-Stack API says that the result should be returned to ZDO_NetworkDiscoveryConfirmCB( uint8 ResultCount, networkDesc_t *NetworkList ).
    Try to add some of your own code to this function, e.g. print ResultCount throught uart. Also for the first question, you should be able to find Pan ID's from NetworkList->panId.

    (I'm scanning networks using function NLME_NwkDiscReq2(). At least the result of this function is returned to ZDO_NetworkDiscoveryConfirmCB)

  • Hi i am doing Active scan to know the panid and channel.

     

    I use

     ZDP_MgmtNwkDiscReq( &destAddr,scanChannels,scanDuration, startIndex, 0);

    i get the response in  ZDO_ParseMgmNwkDiscRsp( zdoIncomingMsg_t *inMsg );

    I always get the extended Panid .

    first how to know the extended panid to PANID

    SECOND is there any function call in zstack to get the panid ?

     

    Thanks and regards

    Lakshman,PMP

  • I don't understand either question - could you re-phrase? On second question, what PanId are you asking about - the PanId joined up to?

  • Hi Harry,
     
    I am doing active scan thru serial port to get the result of expanid , panid and channel using
    ZDP_MgmtNwkDiscReq( &destAddr,scanChannels,scanDuration, startIndex, 0);
    and i will get the response in ZDO_ParseMgmNwkDiscRsp( zdoIncomingMsg_t *inMsg );

    but the result dont have the Panid. I always get the expanid and channel

    for example ExPID:0x00124B00012F6A1A Panid 6A1A,CH:12

    Bug Fix :
    I have fixed the bug in zDProfile.c and ZDObject.c

    afStatus_t ZDP_MgmtNwkDiscRsp( byte TransSeq, zAddrType_t *dstAddr,
                                byte Status,
                                byte NetworkCount,
                                byte StartIndex,
                                byte NetworkListCount,
                                networkDesc_t *NetworkList,
                                byte SecurityEnable )
    {
      uint8 *buf;
      uint8 *pBuf;
      byte len = 1+1+1+1;  // Status + NetworkCount + StartIndex + NetworkCountList.
      byte idx;

      (void)SecurityEnable;  // Intentionally unreferenced parameter

      //len += (NetworkListCount * ( ZDP_NETWORK_EXTENDED_DISCRIPTOR_SIZE - 2 ));
     
       len += (NetworkListCount * ( ZDP_NETWORK_EXTENDED_DISCRIPTOR_SIZE )); //require 14 + 4 bytes to scan Lakshman bug fix

      buf = osal_mem_alloc( len+1 );
      if ( buf == NULL )
      {
        return afStatus_MEM_FAIL;
      }

      pBuf = buf+1;

      *pBuf++ = Status;
      *pBuf++ = NetworkCount;
      *pBuf++ = StartIndex;
      *pBuf++ = NetworkListCount;

      for ( idx = 0; idx < NetworkListCount; idx++ )
      {
        osal_cpyExtAddr( pBuf, NetworkList->extendedPANID);
        pBuf += Z_EXTADDR_LEN;
        //Lakshman bug fix
         *pBuf++ = LO_UINT16( NetworkList->panId );
         *pBuf++ = HI_UINT16( NetworkList->panId );
        //Lakshman bug fix

        *pBuf++  = NetworkList->logicalChannel;                // LogicalChannel
        *pBuf    = NetworkList->stackProfile;                  // Stack profile
        *pBuf++ |= (byte)(NetworkList->version << 4);          // ZigBee Version
        *pBuf    = BEACON_ORDER_NO_BEACONS;                    // Beacon Order
        *pBuf++ |= (uint8)(BEACON_ORDER_NO_BEACONS << 4);      // Superframe Order

        if ( NetworkList->chosenRouter != INVALID_NODE_ADDR )
        {
          *pBuf++ = TRUE;                         // Permit Joining
        }
        else
        {
          *pBuf++ = FALSE;
        }

        NetworkList = NetworkList->nextDesc;    // Move to next list entry
      }

      FillAndSendBuffer( &TransSeq, dstAddr, Mgmt_NWK_Disc_rsp, len, buf );
    }
    ZDO_MgmNwkDiscRsp_t *ZDO_ParseMgmNwkDiscRsp( zdoIncomingMsg_t *inMsg )
    {
      ZDO_MgmNwkDiscRsp_t *pRsp;
      uint8 status;
      uint8 networkCount = 0;
      uint8 startIndex = 0;
      uint8 networkListCount = 0;
      uint8 *msg;

      msg = inMsg->asdu;
      status = *msg++;

      if ( status == ZSuccess )
      {
        networkCount = *msg++;
        startIndex = *msg++;
        networkListCount = *msg++;
      }

      // Allocate a buffer big enough to handle the list.
      pRsp = (ZDO_MgmNwkDiscRsp_t *)osal_mem_alloc( sizeof( ZDO_MgmNwkDiscRsp_t )
                                      + (networkListCount * sizeof( mgmtNwkDiscItem_t )) );
      if ( pRsp )
      {
        uint8 x;
        mgmtNwkDiscItem_t *pList;

        pRsp->status = status;
        pRsp->networkCount = networkCount;
        pRsp->startIndex = startIndex;
        pRsp->networkListCount = networkListCount;
        pList = pRsp->list;

        for ( x = 0; x < networkListCount; x++ )
        {
          osal_cpyExtAddr(pList->extendedPANID, msg);   //Copy extended PAN ID
          //pList->PANId = BUILD_UINT16( msg[0], msg[1] );
          //msg += Z_EXTADDR_LEN;
         
          //Lakshman bug fix
          msg += Z_EXTADDR_LEN;
          pList->PANId = BUILD_UINT16( msg[0], msg[1] );
          msg += 2; //panid     
          //Lakshman bug fix

          pList->logicalChannel = *msg++;
          pList->stackProfile = (*msg) & 0x0F;
          pList->version = (*msg++ >> 4) & 0x0F;
          pList->beaconOrder = (*msg) & 0x0F;
          pList->superFrameOrder = (*msg++ >> 4) & 0x0F;
          pList->permitJoining = *msg++;
          pList++;
        }
      }

      return ( pRsp );
    }

    now i am able to get the expected result from scan : expanid , panid and ch

    for example ExPID:0x00124B00012F6A1A ,PID:0xE03A,CH:12

    Second Question :
    Is there anyway to know panid other than ZDP_MgmtNwkDiscReq() for scanning.

    for example NLME_NwkDiscReq2() . How to use it ?

    anyway i got the expected result using ZDP_MgmtNwkDiscReq().kindly confirm the bug fix.

    Thanks and Regards
    Lakshman,PMP

  • The implemented Mgmt_NWK_Disc_rsp (Cluster Id 0x8030) is not a bug - checkout the ZigBee specification related to the contents of this message.

    053474r19ZB_CSG-ZigBee-Specification - Mgmt_NWK_Disc_rsp.pdf
  • Thanks Harry. Yes its true. In the specification they didnt mention it. But in the ZDO_MgmNwkDiscRsp_t *ZDO_ParseMgmNwkDiscRsp( zdoIncomingMsg_t *inMsg ) 

    Z-stack do mention the the PANID in the response.
    {
      ZDO_MgmNwkDiscRsp_t *pRsp;
      uint8 status;
      uint8 networkCount = 0;
      uint8 startIndex = 0;
      uint8 networkListCount = 0;
      uint8 *msg;

      msg = inMsg->asdu;
      status = *msg++;

      if ( status == ZSuccess )
      {
        networkCount = *msg++;
        startIndex = *msg++;
        networkListCount = *msg++;
      }

      // Allocate a buffer big enough to handle the list.
      pRsp = (ZDO_MgmNwkDiscRsp_t *)osal_mem_alloc( sizeof( ZDO_MgmNwkDiscRsp_t )
                                      + (networkListCount * sizeof( mgmtNwkDiscItem_t )) );
      if ( pRsp )
      {
        uint8 x;
        mgmtNwkDiscItem_t *pList;

        pRsp->status = status;
        pRsp->networkCount = networkCount;
        pRsp->startIndex = startIndex;
        pRsp->networkListCount = networkListCount;
        pList = pRsp->list;

        for ( x = 0; x < networkListCount; x++ )
        {
          osal_cpyExtAddr(pList->extendedPANID, msg);   //Copy extended PAN ID
          pList->PANId = BUILD_UINT16( msg[0], msg[1] );
          msg += Z_EXTADDR_LEN;

    Thanks harry for your time and effort.

     

    Thanks and Regards

    Lakshman,PMP

  • Hi Friends,

                   I am Siva and now i have a task from my company in Zigtee Zstack,So i want know how to learn properly.