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 );