使用(void)NLME_GetExtAddr();可以获得64位终端地址,查资料知道地址是存放于saveExtAddr[]数组中,但是我写osal_memcpy(&strTemp[8],&saveExtAddr,16); 但是在串口显示不出来,一直乱码,请问怎么解决那?求助求助
gaoyang9992006:
(void)NLME_GetExtAddr();在调用的时候,会将获得的扩展地址(IEEE地址)保存到saveExtAddr这个数组里,saveExtAddr是在ZDApp.h里定义的:extern uint8 saveExtAddr[]; // Loaded with value by ZDApp_Init().通过后面的注释可以知道,这个数组里的面值在ZDApp_Init()函数里设定。而在ZDApp_Init()函数里正好有(void)NLME_GetExtAddr();
验证办法:
在ZDApp_Init()函数里将代码稍做修改,如下所示:
//==================================前面代码省略============================================
uint8 addr0 = saveExtAddr[0]; uint8 addr1 = saveExtAddr[1]; uint8 addr2 = saveExtAddr[2]; uint8 addr3 = saveExtAddr[3]; uint8 addr4 = saveExtAddr[4]; uint8 addr5 = saveExtAddr[5]; uint8 addr6 = saveExtAddr[6]; uint8 addr7 = saveExtAddr[7]; (void)NLME_GetExtAddr(); // Load the saveExtAddr pointer.加载saveExtAddr指针 addr0 = saveExtAddr[0]; addr1 = saveExtAddr[1]; addr2 = saveExtAddr[2]; addr3 = saveExtAddr[3]; addr4 = saveExtAddr[4]; addr5 = saveExtAddr[5]; addr6 = saveExtAddr[6]; addr7 = saveExtAddr[7];
//==================================后面代码省略============================================
用断点调试方法,可知在NLME_GetExtAddr(); 语句执行之前,saveExtAddr里面的值都是0x00,而在执行NLME_GetExtAddr(); 这一语句之后,saveExtAddr里的值分别为:c1 91 36 01 00 4b 12 00 。再通过Texas Instruments SmartRF这个软件来读扩展地址,读出来的扩展地址正好是相反的:00 12 4B 00 01 36 91 C1。一个正向保存,一个反向保存,验证完毕。