Tool/software: Code Composer Studio
I want to imply the following feature: CC2640R2 launchpad advertises normally and acts as a peripheral device. My iphone acts as a
central device. As long as my iphone connects with CC2640R2, it saves the address of my iphone to the whitelist and changes the
advertising mode to White List Only. As a result ,only my iphone can connect with this CC2640R2.
However, I failed to add my iphone to the whitelist. HCI_LE_ReadWhiteListSizeCmd() keeps return 0 . My code is as followed.
1、My code is written according to this post:
https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/p/417407/1845109?tisearch=e2e-sitesearch&keymatch=cc2640%20%20whitelist#1845109
2、simple_peripheral.c
case GAPROLE_CONNECTED:
{
//参数定义
uint8 adv_filter = GAP_FILTER_POLICY_WHITE;
uint8 remoteBdAddr[B_ADDR_LEN] = {0};
//获取已连接的设备的地址
GAPRole_GetParameter(GAPROLE_CONN_BD_ADDR, remoteBdAddr);
//设置广播模式为白名单模式
GAPRole_SetParameter( GAPROLE_ADV_FILTER_POLICY, sizeof( uint8 ), &adv_filter );
//清空白名单
HCI_LE_ClearWhiteListCmd();
//将已连接的设备的地址添加到白名单中
HCI_LE_AddWhiteListCmd( HCI_PUBLIC_DEVICE_ADDRESS, remoteBdAddr );
........
}
3、peripheral.c
if (events & START_ADVERTISING_EVT)
{
//读取白名单的大小
uint8 WL = HCI_LE_ReadWhiteListSizeCmd();
//whiteListNum为白名单的大小 ,whiteListNum为全局变量。
if(WL>0 )
{
gapRole_AdvFilterPolicy = GAP_FILTER_POLICY_WHITE;
whiteListNum = WL;
}
//whiteListNum为白名单的大小
else
{
gapRole_AdvFilterPolicy = GAP_FILTER_POLICY_ALL;
whiteListNum = 0;
}
.........
}
4、My complete workspace can be got from here:
5、My code is based on the simple_peripheral project in CC2640R2 SDK -v:1.40.00.45 . CC2640R2 SDK -v:1.40.00.45 is downloaded from here: