ZigBee> Ti z-stack protocol stack address acquisition

Source: Internet
Author: User

The first method is to use the special API defined in nlme. h

Obtain the IEEE address of the device.
/*
* This function will return a pointer to the device's IEEE 64 bit address
*
* This function resides in nwk_util.c.
*/
Extern byte * nlme_getextaddr (void );


Obtain the network address of the device.
/*
* This function will return this device's 16 Bit short address
*
* This function resides in nwk_util.c.
*/
Extern uint16 nlme_getincluaddr (void );


Obtain the network address of the parent device.
/*
* This function will return the Mac's coordinator's short (16bit) Address
* Which is this device's parent, not necessarily the ZigBee coordinator.
*
* This function resides in nwk_util.c.
*/
Extern uint16 nlme_getcoord1_addr (void );


Obtain the IEEE address of the parent device.
/*
* This function will return the Mac's coordinator's extented (64bit) Address
* Which is this device's parent, not necessarily the ZigBee coordinator.
*
* This function resides in nwk_util.c.
*/
Extern void nlme_getcoordextaddr (byte *);

Method 2:
Use the zb_getdeviceinfo () function
View the function definition to learn how to use it:
Void zb_getdeviceinfo (uint8 Param, void * pvalue)
{
Switch (PARAM)
{
Case zb_info_dev_state:
Osal_memcpy (pvalue, & devstate, sizeof (uint8 ));
Break;
Case zb_info_ieee_addr:
Osal_memcpy (pvalue, & aextendedaddress, z_extaddr_len );
Break;
Case zb_info_short_addr:
Osal_memcpy (pvalue, & _ nib. nwkdevaddress, sizeof (uint16 ));
Break;
Case zb_info_parent_short_addr:
Osal_memcpy (pvalue, & _ nib. nwkcoordaddress, sizeof (uint16 ));
Break;
Case zb_info_parent_ieee_addr:
Osal_memcpy (pvalue, & _ nib. nwkcoordextaddress, z_extaddr_len );
Break;
Case zb_info_channel:
Osal_memcpy (pvalue, & _ nib. nwklogicalchannel, sizeof (uint8 ));
Break;
Case zb_info_pan_id:
Osal_memcpy (pvalue, & _ nib. nwkpanid, sizeof (uint16 ));
Break;
Case zb_info_ext_pan_id:
Osal_memcpy (pvalue, & _ nib. extendedpanid, z_extaddr_len );
Break;
}
}
For example, to obtain a short device address, you can:
Uint16 my_short_addr;
Zb_getdeviceinfo (zb_info_short_addr, my_short_addr );


Method 3: Use the preceding definition of the zb_getdeviceinfo () function to obtain the address information by reading the value of _ nib. You can call the following method:
Uint16 my_short_addr = _ nib. nwkdevaddress;


Method 4: Read NV directly. The method is as follows:
Uint8 pvalue [8];
Osal_nv_read (zcd_nv_extaddr, z_extaddr_len, size, pvalue );
The extended device address is saved in pvalue.

Method 5: Use the global variable aextendedaddress defined in onboard. C to obtain the IEEE address, as follows:

Uint8 * pvalue [z_extaddr_len];

Osal_memcpy (pvalue, & aextendedaddress, z_extaddr_len );

Method 6: Use the zmacgetreq () function as follows:

Uint8 * pvalue [z_extaddr_len];

Zmacgetreq (zmacextaddr, pvalue );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.