ZigBee Get device address information

Source: Internet
Author: User
Tags function definition

The first approach, using the specialized APIs defined within the NLME.h

Get the device's own IEEE address

extern byte *nlme_getextaddr (void);


Get the device's own network address

extern uint16 nlme_getshortaddr (void);


Get the parent Device network address

extern uint16 nlme_getcoordshortaddr (void);


Get the parent device IEEE address

extern void Nlme_getcoordextaddr (BYTE *);

The second method:
Using the Zb_getdeviceinfo () function
To view the function definition, you can know how to use:
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 get the device's short address, you can:
UInt16 my_short_addr;
Zb_getdeviceinfo (ZB_INFO_SHORT_ADDR,MY_SHORT_ADDR);


The third method: using the definition of the above zb_getdeviceinfo () function, it is also known that by reading the value of the _nib, the address information can be obtained, such as a downward
UInt16 my_short_addr = _nib.nwkdevaddress;


The fourth method: directly read NV, the method is as follows:
Uint8 Pvalue[8];
Osal_nv_read (ZCD_NV_EXTADDR, Z_extaddr_len, size, pValue);
The device extension address is stored in the pvalue.

The fifth method, using the global variable aextendedaddress defined in ONBOARD.C, obtains the IEEE address, as follows:

Uint8 * Pvalue[z_extaddr_len];

osal_memcpy (PValue, &aextendedaddress, Z_extaddr_len);

The sixth method, using the Zmacgetreq () function, is 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.