static void btif_dm_ble_passkey_req_evt(tBTA_DM_PIN_REQ *p_pin_req);
static void btif_dm_ble_key_nc_req_evt(tBTA_DM_SP_KEY_NOTIF *p_notif_req) ;
static void btif_dm_ble_oob_req_evt(tBTA_DM_SP_RMT_OOB *req_oob_type);
+static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB *req_oob_type);
#endif
static void bte_scan_filt_param_cfg_evt(UINT8 action_type,
}
if (btif_storage_get_remote_addr_type(bd_addr, &addr_type) != BT_STATUS_SUCCESS)
{
- btif_storage_set_remote_addr_type(bd_addr, BLE_ADDR_PUBLIC);
+
+ // Try to read address type. OOB pairing might have set it earlier, but
+ // didn't store it, it defaults to BLE_ADDR_PUBLIC
+ uint8_t tmp_dev_type;
+ uint8_t tmp_addr_type;
+ BTM_ReadDevInfo(bd_addr->address, &tmp_dev_type, &tmp_addr_type);
+ addr_type = tmp_addr_type;
+
+ btif_storage_set_remote_addr_type(bd_addr, addr_type);
}
}
if((btif_config_get_int((char const *)&bdstr,"DevType", &device_type) &&
bt_bdaddr_t bd_addr;
bt_bdname_t bd_name;
UINT32 cod;
- BOOLEAN is_incoming = !(pairing_cb.state == BT_BOND_STATE_BONDING);
int dev_type;
BTIF_TRACE_DEBUG("%s", __FUNCTION__);
pairing_cb.is_ssp = TRUE;
- /* If JustWorks auto-accept */
- if (p_ssp_cfm_req->just_works)
- {
- /* Pairing consent for JustWorks needed if:
- * 1. Incoming (non-temporary) pairing is detected AND
- * 2. local IO capabilities are DisplayYesNo AND
- * 3. remote IO capabiltiies are DisplayOnly or NoInputNoOutput;
- */
- if (is_incoming && pairing_cb.bond_type != BOND_TYPE_TEMPORARY &&
- ((p_ssp_cfm_req->loc_io_caps == HCI_IO_CAP_DISPLAY_YESNO) &&
- (p_ssp_cfm_req->rmt_io_caps == HCI_IO_CAP_DISPLAY_ONLY ||
- p_ssp_cfm_req->rmt_io_caps == HCI_IO_CAP_NO_IO)))
- {
- BTIF_TRACE_EVENT("%s: User consent needed for incoming pairing request. loc_io_caps: %d, rmt_io_caps: %d",
- __FUNCTION__, p_ssp_cfm_req->loc_io_caps, p_ssp_cfm_req->rmt_io_caps);
- }
- else
- {
- BTIF_TRACE_EVENT("%s: Auto-accept JustWorks pairing", __FUNCTION__);
- btif_dm_ssp_reply(&bd_addr, BT_SSP_VARIANT_CONSENT, TRUE, 0);
- return;
- }
- }
-
cod = devclass2uint(p_ssp_cfm_req->dev_class);
if (cod == 0) {
uint32_t i;
bt_bdaddr_t bd_addr;
- BTIF_TRACE_EVENT("btif_dm_upstreams_cback ev: %s", dump_dm_event(event));
+ BTIF_TRACE_EVENT("%s: ev: %s", __func__, dump_dm_event(event));
switch (event)
{
BTIF_TRACE_DEBUG("BTA_DM_BLE_OOB_REQ_EVT. ");
btif_dm_ble_oob_req_evt(&p_data->rmt_oob);
break;
+ case BTA_DM_BLE_SC_OOB_REQ_EVT:
+ BTIF_TRACE_DEBUG("BTA_DM_BLE_SC_OOB_REQ_EVT. ");
+ btif_dm_ble_sc_oob_req_evt(&p_data->rmt_oob);
+ break;
case BTA_DM_BLE_LOCAL_IR_EVT:
BTIF_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
ble_local_key_cb.is_id_keys_rcvd = TRUE;
bdcpy(oob_cb.bdaddr, bd_addr->address);
memcpy(&oob_cb.oob_data, oob_data, sizeof(bt_out_of_band_data_t));
+ uint8_t empty[] = {0, 0, 0, 0, 0, 0, 0};
+ // If LE Bluetooth Device Address is provided, use provided address type
+ // value.
+ if (memcmp(oob_data->le_bt_dev_addr, empty, 7) != 0) {
+ /* byte no 7 is address type in LE Bluetooth Address OOB data */
+ uint8_t address_type = oob_data->le_bt_dev_addr[6];
+ if (address_type == BLE_ADDR_PUBLIC || address_type == BLE_ADDR_RANDOM) {
+ // bd_addr->address is already reversed, so use it instead of
+ // oob_data->le_bt_dev_addr
+ BTM_SecAddBleDevice(bd_addr->address, NULL, BT_DEVICE_TYPE_BLE, address_type);
+ }
+ }
+
bdstr_t bdstr;
BTIF_TRACE_EVENT("%s: bd_addr=%s, transport=%d", __FUNCTION__, bdaddr_to_string(bd_addr, bdstr, sizeof(bdstr)), transport);
return btif_dm_create_bond(bd_addr, transport);
tBTA_LE_AUTH_REQ *p_auth_req)
{
- /* We currently support only Security Manager TK as OOB data for LE transport.
- If it's not present mark no OOB data.
- */
- if (!is_empty_128bit(oob_cb.oob_data.sm_tk))
- {
+ if (!is_empty_128bit(oob_cb.oob_data.le_sc_c) &&
+ !is_empty_128bit(oob_cb.oob_data.le_sc_r)) {
+ /* We have LE SC OOB data */
+
+ /* make sure OOB data is for this particular device */
+ if (memcmp(bd_addr, oob_cb.bdaddr, BD_ADDR_LEN) == 0) {
+ *p_auth_req = ((*p_auth_req) | BTM_LE_AUTH_REQ_SC_ONLY);
+ *p_has_oob_data = true;
+ } else {
+ *p_has_oob_data = false;
+ BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address",
+ __func__);
+ }
+ } else if (!is_empty_128bit(oob_cb.oob_data.sm_tk)) {
+ /* We have security manager TK */
+
/* make sure OOB data is for this particular device */
if (memcmp(bd_addr, oob_cb.bdaddr, BD_ADDR_LEN) == 0) {
// When using OOB with TK, SC Secure Connections bit must be disabled.
tBTA_LE_AUTH_REQ mask = ~BTM_LE_AUTH_REQ_SC_ONLY;
*p_auth_req = ((*p_auth_req) & mask);
- *p_has_oob_data = TRUE;
- }
- else
- {
- *p_has_oob_data = FALSE;
+ *p_has_oob_data = true;
+ } else {
+ *p_has_oob_data = false;
BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address",
__func__);
}
- }
- else
- {
- *p_has_oob_data = FALSE;
+ } else {
+ *p_has_oob_data = false;
}
BTIF_TRACE_DEBUG("%s *p_has_oob_data=%d", __func__, *p_has_oob_data);
}
btif_storage_remove_bonded_device(&bdaddr);
state = BT_BOND_STATE_NONE;
} else {
- /*
- * Note: This is a Wear-specific feature for iOS pairing.
- * Store the address of the first bonded device that is also of type LE to
- * enable auto connection parameter update.
- */
-#if (defined(WEAR_AUTO_CONN_PARAM_UPDATE) && (WEAR_AUTO_CONN_PARAM_UPDATE == TRUE))
- if (btif_storage_get_num_bonded_devices() == 0) {
- bdstr_t bdstr;
- bdaddr_to_string(&bdaddr, bdstr, sizeof(bdstr));
- btif_config_set_str("Adapter", "AutoConnParamUpdateAddr", bdstr);
- }
-#endif
btif_dm_save_ble_bonding_keys();
BTA_GATTC_Refresh(bd_addr.address);
btif_dm_get_remote_services_by_transport(&bd_addr, BTA_GATT_TRANSPORT_LE);
bt_bdaddr_t bd_addr;
bdcpy(bd_addr.address, req_oob_type->bd_addr);
-
- /* We currently support only Security Manager TK as OOB data. We already
- * checked if it's present in btif_dm_set_oob_for_le_io_req, but check here
- * again. If it's not present do nothing, pairing will timeout.
+ /* We already checked if OOB data is present in
+ * btif_dm_set_oob_for_le_io_req, but check here again. If it's not present
+ * do nothing, pairing will timeout.
*/
if (is_empty_128bit(oob_cb.oob_data.sm_tk)) {
return;
BTM_BleOobDataReply(req_oob_type->bd_addr, 0, 16, oob_cb.oob_data.sm_tk);
}
+
+static void btif_dm_ble_sc_oob_req_evt(tBTA_DM_SP_RMT_OOB *req_oob_type)
+{
+ BTIF_TRACE_DEBUG("%s", __func__);
+
+ bt_bdaddr_t bd_addr;
+ bdcpy(bd_addr.address, req_oob_type->bd_addr);
+
+ /* We already checked if OOB data is present in
+ * btif_dm_set_oob_for_le_io_req, but check here again. If it's not present
+ * do nothing, pairing will timeout.
+ */
+ if (is_empty_128bit(oob_cb.oob_data.le_sc_c) &&
+ is_empty_128bit(oob_cb.oob_data.le_sc_r)) {
+ BTIF_TRACE_WARNING("%s: LE SC OOB data is empty", __func__);
+ return;
+ }
+
+ /* make sure OOB data is for this particular device */
+ if (memcmp(req_oob_type->bd_addr, oob_cb.bdaddr, BD_ADDR_LEN) != 0) {
+ BTIF_TRACE_WARNING("%s: remote address didn't match OOB data address", __func__);
+ return;
+ }
+
+ /* Remote name update */
+ btif_update_remote_properties(req_oob_type->bd_addr , req_oob_type->bd_name,
+ NULL, BT_DEVICE_TYPE_BLE);
+
+ bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_BONDING);
+ pairing_cb.is_ssp = false;
+ pairing_cb.is_le_only = true; //TODO: we can derive classic pairing from this one
+ pairing_cb.is_le_nc = false;
+
+ BTM_BleSecureConnectionOobDataReply(req_oob_type->bd_addr,
+ oob_cb.oob_data.le_sc_c,
+ oob_cb.oob_data.le_sc_r);
+}
+
void btif_dm_update_ble_remote_properties( BD_ADDR bd_addr, BD_NAME bd_name,
tBT_DEVICE_TYPE dev_type)
{
uint32_t cod = get_cod(bd_addr);
uint64_t ts = event->timestamp.tv_sec * 1000 +
event->timestamp.tv_nsec / 1000000;
- metrics_pair_event(0, ts, cod, device_type);
+ metrics_log_pair_event(0, ts, cod, device_type);
pthread_mutex_unlock(&bond_event_lock);
}