if ( p_clreg->notif_reg[i].in_use &&
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
p_clreg->notif_reg[i].handle == handle) {
- APPL_TRACE_WARNING("notification already registered");
+ APPL_TRACE_DEBUG("notification already registered");
status = BTA_GATT_OK;
break;
}
#if (BLE_PRIVACY_SPT == TRUE)
if (key_type == BTM_LE_KEY_PID || key_type == BTM_LE_KEY_LID) {
- /* It will cause that scanner doesn't send scan request to advertiser
- * which has sent IRK to us and we have stored the IRK in controller.
- * It is a design problem of hardware. The temporal solution is not to
- * send the key to the controller and then resolve the random address in host. */
- //btm_ble_resolving_list_load_dev (p_dev_rec);
+ btm_ble_resolving_list_load_dev (p_dev_rec);
}
#endif
/* possiblly receive connection complete with resolvable random on
slave role while the device has been paired */
- if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) {
+
+ /* It will cause that scanner doesn't send scan request to advertiser
+ * which has sent IRK to us and we have stored the IRK in controller.
+ * It is a design problem of hardware. The temporal solution is not to
+ * send the key to the controller and then resolve the random address in host.
+ * so we need send the real address information to controller to connect.
+ * Once the connection is successful, resolve device address whether it is
+ * slave or master*/
+
+ /* if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) { */
+ if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
// save the enhanced value to used in btm_ble_resolve_random_addr_on_conn_cmpl func.
temp_enhanced = enhanced;
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl, p_data);
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* add all bonded device into resolving list if IRK is available*/
- /* It will cause that scanner doesn't send scan request to advertiser
- * which has sent IRK to us and we have stored the IRK in controller.
- * It is a design problem of hardware. The temporal solution is not to
- * send the key to the controller and then resolve the random address in host. */
- //btm_ble_resolving_list_load_dev(p_dev_rec);
+ btm_ble_resolving_list_load_dev(p_dev_rec);
#endif
}
void btm_ble_process_adv_pkt (UINT8 *p_data)
{
BD_ADDR bda;
+ BD_ADDR temp_bda;
+ UINT8 temp_addr_type = 0;
UINT8 evt_type = 0, *p = p_data;
UINT8 addr_type = 0;
UINT8 num_reports;
STREAM_TO_UINT8 (evt_type, p);
STREAM_TO_UINT8 (addr_type, p);
STREAM_TO_BDADDR (bda, p);
+ temp_addr_type = addr_type;
+ memcpy(temp_bda, bda, BD_ADDR_LEN);
//BTM_TRACE_ERROR("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x\n",
// bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv, p_data);
} else
#endif
- btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
-
+ btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
+ //save current adv addr information if p_dev_rec!= NULL
+ tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
+ if(p_dev_rec) {
+ p_dev_rec->ble.current_addr_type = temp_addr_type;
+ memcpy(p_dev_rec->ble.current_addr, temp_bda, BD_ADDR_LEN);
+ p_dev_rec->ble.current_addr_valid = true;
+ }
STREAM_TO_UINT8(data_len, p);
/* Advance to the next event data_len + rssi byte */
btm_ble_update_resolving_list(p_dev_rec->bd_addr, TRUE);
if (controller_get_interface()->supports_ble_privacy()) {
BD_ADDR dummy_bda = {0};
- UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
- UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
-
if (memcmp(p_dev_rec->ble.static_addr, dummy_bda, BD_ADDR_LEN) == 0) {
memcpy(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
p_dev_rec->ble.static_addr_type = p_dev_rec->ble.ble_addr_type;
}
-
+ /* It will cause that scanner doesn't send scan request to advertiser
+ * which has sent IRK to us and we have stored the IRK in controller.
+ * It is a design problem of hardware. The temporal solution is not to
+ * send the key to the controller and then resolve the random address in host. */
+ /*
BTM_TRACE_DEBUG("%s:adding device to controller resolving list\n", __func__);
- // use identical IRK for now
+ UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
+ UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
+ //use identical IRK for now
rt = btsnd_hcic_ble_add_device_resolving_list(p_dev_rec->ble.static_addr_type,
- p_dev_rec->ble.static_addr, peer_irk, local_irk);
+ p_dev_rec->ble.static_addr, peer_irk, local_irk);
+ */
} else {
UINT8 param[40] = {0};
UINT8 *p = param;
}
}
} else {
- BTM_TRACE_ERROR("Device already in Resolving list\n");
+ BTM_TRACE_DEBUG("Device already in Resolving list\n");
rt = TRUE;
}
} else {
tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */
tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */
#endif
+#if (BLE_PRIVACY_SPT == TRUE)
+ tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/
+ BD_ADDR current_addr; /* current adv addr*/
+ bool current_addr_valid; /* current addr info is valid or not*/
+#endif
} tBTM_SEC_BLE;
*******************************************************************************/
BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
{
+#if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE))
+ //check for security device information in the cache
+ bool dev_rec_exist = true;
+ tBTM_SEC_DEV_REC *find_dev_rec = btm_find_dev (p_lcb->remote_bd_addr);
+ if(find_dev_rec == NULL) {
+ dev_rec_exist = false;
+ }
+
+#endif
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_lcb->remote_bd_addr);
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
UINT16 scan_int;
#if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE))
own_addr_type = btm_cb.ble_ctr_cb.privacy_mode ? BLE_ADDR_RANDOM : BLE_ADDR_PUBLIC;
+ if(dev_rec_exist) {
+ // if the current address information is valid, get the real address information
+ if(p_dev_rec->ble.current_addr_valid) {
+ peer_addr_type = p_dev_rec->ble.current_addr_type;
+ memcpy(peer_addr, p_dev_rec->ble.current_addr, 6);
+ } else {
+ /* find security device information but not find the real address information
+ * This state may be directly open whithout scanning. In this case, you must
+ * use the current adv address of the device to open*/
+ }
+ } else {
+ //not find security device information, We think this is a new device, connect directly
+ }
+
+ /* It will cause that scanner doesn't send scan request to advertiser
+ * which has sent IRK to us and we have stored the IRK in controller.
+ * It is a design problem of hardware. The temporal solution is not to
+ * send the key to the controller and then resolve the random address in host.
+ * so we need send the real address information to controller. */
+ /*
if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) {
if (btm_cb.ble_ctr_cb.privacy_mode >= BTM_PRIVACY_1_2) {
own_addr_type |= BLE_ADDR_TYPE_ID_BIT;
} else {
btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, TRUE);
}
+ */
#endif
if (!btm_ble_topology_check(BTM_BLE_STATE_INIT)) {