微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > CC2541连接微信读取MAC地址

CC2541连接微信读取MAC地址

时间:10-02 整理:3721RD 点击:

CC2541连接微信读取MAC地址

CC2541与微信连接
读取设备的 MAC 地址:
[html] view plain copy
GAPRole_GetParameter(GAPROLE_BD_ADDR, ownAddress);  
[html] view plain copy
#define GAPROLE_BD_ADDR             0x304  //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.  
因为微信协议规定 advertData 中要有设备的 MAC 地址,所以要将读到的 MAC 地址放到 advertData 中:
[html] view plain copy
        advertData[ADVERT_MAC_ADDR+0] = ownAddress[5];  
        advertData[ADVERT_MAC_ADDR+1] = ownAddress[4];  
        advertData[ADVERT_MAC_ADDR+2] = ownAddress[3];  
        advertData[ADVERT_MAC_ADDR+3] = ownAddress[2];  
        advertData[ADVERT_MAC_ADDR+4] = ownAddress[1];  
        advertData[ADVERT_MAC_ADDR+5] = ownAddress[0];  
        ownAddress[5] = advertData[ADVERT_MAC_ADDR+5];  
        ownAddress[4] = advertData[ADVERT_MAC_ADDR+4];  
        ownAddress[3] = advertData[ADVERT_MAC_ADDR+3];  
        ownAddress[2] = advertData[ADVERT_MAC_ADDR+2];  
        ownAddress[1] = advertData[ADVERT_MAC_ADDR+1];  
        ownAddress[0] = advertData[ADVERT_MAC_ADDR+0];  
        GAPRole_SetParameter( GAPROLE_SCAN_RSP_DATA, sizeof ( scanResponseData ), scanResponseData );  
        GAPRole_SetParameter( GAPROLE_ADVERT_DATA, sizeof( advertData ), advertData );  
最后要重新设置 GAPROLE_SCAN_RSP_DATA 和 GAPROLE_ADVERT_DATA
微信客户端是通过扫描 BLE 设备的 MAC 地址并连接

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top