如何配置CC2640R2的地址为private resolvable address?
在peripheral.c文件中,调用GAP_ConfigDeviceAddr()函数,将地址配置为private resolvable address模式。将程序在CC2640R2中运行起来,然后使
用packet sniffer抓包分析,发现数据包中地址的MSB与《Core_v4.2.pdf》的介绍不同。说明地址配置失败了。请问哪里出错了?
static void gapRole_processGAPMsg(gapEventHdr_t *pMsg) { uint8_t notify = FALSE; // State changed notify the app? (default no) switch (pMsg->opcode) { case GAP_DEVICE_INIT_DONE_EVENT: { gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg; bStatus_t stat = pPkt->hdr.status; if (stat == SUCCESS) { // Save off the generated keys VOID osal_snv_write(BLE_NVID_IRK, KEYLEN, gapRole_IRK); VOID osal_snv_write(BLE_NVID_CSRK, KEYLEN, gapRole_SRK); // Save off the information VOID memcpy(gapRole_bdAddr, pPkt->devAddr, B_ADDR_LEN); //设置地址格式为private resolvable if (GAP_ConfigDeviceAddr(ADDRMODE_PRIVATE_RESOLVE, NULL) != SUCCESS) { System_abort("Error!"); GAP_ConfigDeviceAddr_SUCCESS = 0; } else { GAP_ConfigDeviceAddr_SUCCESS = 1; } //设置地址每间隔1min变化一次 if (GAP_SetParamValue(TGAP_PRIVATE_ADDR_INT, 1) != SUCCESS) { System_abort("Error!"); TGAP_PRIVATE_ADDR_INT_SUCCESS = 0; } else { TGAP_PRIVATE_ADDR_INT_SUCCESS = 1; } ...... } break; ...... } ...... }
使用packet sniffer抓包分析,发现数据包中地址AdvA有三种,分别如图1、图2、图3所示。而正确的private resolvable address的MSB应为01,如图4
所示。
0X463D16AF5422 对应的MSB为10,不是01
0X7A70A4013E70 对应的MSB为11,不是01
0X69210A6E50F2 对应的MSB为11,不是01
图1
图2
图3
图4
附加链接:
1、simple_peripheral project在我的电脑上的位置:
C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral
2、simplelink_cc2640r2_sdk_1_40_00_45可从如下路径下载:
http://dev.ti.com/tirex/#/?link=Software%2FSimpleLink%20CC2640R2%20SDK
3、Core_v4.2.pdf可从这里下载:
https://www.bluetooth.com/specifications/bluetooth-core-specification
4,CC2640R2 launchpad 可从这里购买:
http://www.ti.com/tool/launchxl-cc2640r2#1
5,我的完整的project文件可从这里下载:
0407.CCSworkspace157.rar
开发环境:
CCS:Code Composer Studio 7.2.0
SDK:simplelink_cc2640r2_sdk_1_40_00_45
hardware:CC26640R2 launchpad develop kit
建议您将代码放在
case
GAPROLE_STARTED:
内试试
Hi
0X463D16AF5422 = 010001100011110100010110101011110101010000100010
0X7A70A4013E70 = 011110100111000010100100000000010011111001110000
0X69210A6E50F2 = 011010010010000100001010011011100101000011110010
没错吧,LSB先传输,MSB在前面。也就是倒过来 前面是01,也就对应上了10.
将代码放在case
GAPROLE_STARTED中,CC26640R2的adv address不会发生改变。