Zigbee协议栈--重要设备地址

来源:互联网 发布:u盘 恢复数据.电脑 编辑:程序博客网 时间:2024/06/05 02:44

本文来自:http://blog.163.com/baly_bao/blog/static/128486557201102525210913/
重要设备地址(Important Device Addresses) 

应用程序可能需要知道他的设备地址和父地址。使用下面的函数获取设备地址(在ZStack API中定义):

    
NLME_GetShortAddr() - 返回本设备的16位网络地址

unsigned int shortaddr;
shortaddr = NLME_GetShortAddr(); 
    
NLME_GetExtAddr() - 返回本设备的64位扩展地址

注意:NLME_GetExtAddr()函数返回的是64位扩展地址转存于XDATA区的起始地址

uint8 *macAddr;

macAddr = NLME_GetExtAddr();

*macAddr = 0x04c0; 

 上图黑色部分为64位扩展地址


使用下面的函数获取该设备的父亲设备的地址:

 
NLME_GetCoordShortAddr() - 返回本设备的父亲设备的16位网络地址 
unsigned int shortaddr_father;
shortaddr_father = NLME_GetCoordShortAddr();

   
NLME_GetCoordExtAddr(uint8 *addr) - 返回本设备的父亲设备的64位扩展地址

uint8 parentmacAddr[8];
NLME_GetCoordExtAddr(parentmacAddr) ;//64位父亲设备扩展地址存于parentmacAddr数组

NLME_GetExtAddr()函数和NLME_GetCoordExtAddr(uint8 *addr) 函数 是库函数,无法查看其内容。

上述函数涉及到网络,必须等子设备加入网络成功后才能执行。

原创粉丝点击