@@ -736,6 +736,22 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
736736 if (!controller_get_interface ()-> supports_ble ()) {
737737 return FALSE;
738738 }
739+
740+ /*
741+ * Temporary solutions for pair with random address:
742+ * can't set privacy when advertising, scaning or using static random address
743+ * We will do futher work here
744+ */
745+ if (p_cb -> privacy_mode == BTM_PRIVACY_NONE
746+ && random_cb -> own_addr_type == BLE_ADDR_RANDOM ) {
747+ BTM_TRACE_ERROR ("Have set random adress, can't set privacy " );
748+ return FALSE;
749+ }
750+ if (!(p_cb -> inq_var .state != BTM_BLE_STOP_SCAN && p_cb -> inq_var .state != BTM_BLE_STOP_ADV )) {
751+ BTM_TRACE_ERROR ("Advertising or scaning now, can't set privacy " );
752+ return FALSE;
753+ }
754+
739755#if (defined(GAP_INCLUDED ) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE )
740756 uint8_t addr_resolution = 0 ;
741757#endif /* defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */
@@ -1165,6 +1181,16 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
11651181 return BTM_ILLEGAL_VALUE ;
11661182 }
11671183
1184+ /*
1185+ * Temporary solutions for pair with random address:
1186+ * can't set advertising with BLE_ADDR_PUBLIC when having set random adress or in privacy mode
1187+ * We will do futher work here
1188+ */
1189+ if (btm_cb .ble_ctr_cb .addr_mgnt_cb .own_addr_type == BLE_ADDR_RANDOM && own_bda_type == BLE_ADDR_PUBLIC ) {
1190+ BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n" );
1191+ return BTM_ILLEGAL_VALUE ;
1192+ }
1193+
11681194 if (!BTM_BLE_ISVALID_PARAM (adv_int_min , BTM_BLE_ADV_INT_MIN , BTM_BLE_ADV_INT_MAX ) ||
11691195 !BTM_BLE_ISVALID_PARAM (adv_int_max , BTM_BLE_ADV_INT_MIN , BTM_BLE_ADV_INT_MAX )) {
11701196 return BTM_ILLEGAL_VALUE ;
@@ -1315,6 +1341,19 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
13151341 return ;
13161342 }
13171343
1344+ /*
1345+ * Temporary solutions for pair with random address:
1346+ * can't set scan with BLE_ADDR_PUBLIC when having set random adress or in privacy mode
1347+ * We will do futher work here
1348+ */
1349+ if (btm_cb .ble_ctr_cb .addr_mgnt_cb .own_addr_type == BLE_ADDR_RANDOM && addr_type_own == BLE_ADDR_PUBLIC ) {
1350+ BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n" );
1351+ if (scan_setup_status_cback != NULL ) {
1352+ scan_setup_status_cback (client_if , BTM_ILLEGAL_VALUE );
1353+ }
1354+ return ;
1355+ }
1356+
13181357 /* If not supporting extended scan support, use the older range for checking */
13191358 if (btm_cb .cmn_ble_vsc_cb .extended_scan_support == 0 ) {
13201359 max_scan_interval = BTM_BLE_SCAN_INT_MAX ;
@@ -1500,6 +1539,24 @@ BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr)
15001539 if (rand_addr == NULL )
15011540 return set_flag ;
15021541
1542+ /*
1543+ * Temporary solutions for pair with random address:
1544+ * can't set rand address when advertising, scaning or in privacy mode
1545+ * We will do futher work here
1546+ */
1547+ #if BLE_PRIVACY_SPT == TRUE
1548+ if (btm_cb .ble_ctr_cb .privacy_mode != BTM_PRIVACY_NONE ) {
1549+ BTM_TRACE_ERROR ("privacy_mode is not BTM_PRIVACY_NONE " );
1550+ return set_flag ;
1551+ }
1552+
1553+ #endif
1554+ if (!(btm_cb .ble_ctr_cb .inq_var .state != BTM_BLE_STOP_SCAN && btm_cb .ble_ctr_cb .inq_var .state != BTM_BLE_STOP_ADV )) {
1555+ BTM_TRACE_ERROR ("Advertising or scaning now, can't set randaddress " );
1556+ return FALSE;
1557+ }
1558+ memcpy (btm_cb .ble_ctr_cb .addr_mgnt_cb .private_addr , rand_addr , BD_ADDR_LEN );
1559+ btm_cb .ble_ctr_cb .addr_mgnt_cb .own_addr_type = BLE_ADDR_RANDOM ;
15031560 //send the set random address to the controller
15041561 set_flag = btsnd_hcic_ble_set_random_addr (rand_addr );
15051562 return set_flag ;
@@ -3297,7 +3354,7 @@ tBTM_STATUS btm_ble_start_adv(void)
32973354#endif
32983355 if (p_cb -> afp != AP_SCAN_CONN_ALL ) {
32993356 //find the device in the btm dev buffer and write it to the controller white list
3300- btm_execute_wl_dev_operation ();
3357+ btm_execute_wl_dev_operation ();
33013358 btm_cb .ble_ctr_cb .wl_state |= BTM_BLE_WL_ADV ;
33023359 }
33033360
0 commit comments