components/bt: Fix two bugs about pairing

1. Fix Legacy Pairing failed without remote device name
2. Fix discovery no device after disabling SSP
This commit is contained in:
baohongde 2018-12-11 19:39:04 +08:00
parent 9c48528fcc
commit d601ed8023
4 changed files with 18 additions and 60 deletions

View File

@ -1160,7 +1160,7 @@ void bta_dm_loc_oob(tBTA_DM_MSG *p_data)
** Returns void ** Returns void
** **
*******************************************************************************/ *******************************************************************************/
void bta_dm_oob_reply(tBTA_DM_MSG *p_data) void bta_dm_oob_reply(tBTA_DM_MSG *p_data)
{ {
BTM_BleOobDataReply(p_data->oob_reply.bd_addr, BTM_SUCCESS, p_data->oob_reply.len, p_data->oob_reply.value); BTM_BleOobDataReply(p_data->oob_reply.bd_addr, BTM_SUCCESS, p_data->oob_reply.len, p_data->oob_reply.value);
} }
@ -2681,9 +2681,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
} }
} }
#if (BT_SSP_INCLUDED == TRUE)
/******************************************************************************* /*******************************************************************************
** **
** Function bta_dm_pinname_cback ** Function bta_dm_pinname_cback
@ -2740,6 +2738,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
bta_dm_cb.p_sec_cback(event, &sec_event); bta_dm_cb.p_sec_cback(event, &sec_event);
} }
} }
#endif /// BT_SSP_INCLUDED == TRUE
/******************************************************************************* /*******************************************************************************
** **
@ -2759,18 +2758,6 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_
return BTM_NOT_AUTHORIZED; return BTM_NOT_AUTHORIZED;
} }
/* If the device name is not known, save bdaddr and devclass and initiate a name request */
if (bd_name[0] == 0) {
bta_dm_cb.pin_evt = BTA_DM_PIN_REQ_EVT;
bdcpy(bta_dm_cb.pin_bd_addr, bd_addr);
BTA_COPY_DEVICE_CLASS(bta_dm_cb.pin_dev_class, dev_class);
if ((BTM_ReadRemoteDeviceName(bd_addr, bta_dm_pinname_cback, BT_TRANSPORT_BR_EDR)) == BTM_CMD_STARTED) {
return BTM_CMD_STARTED;
}
APPL_TRACE_WARNING(" bta_dm_pin_cback() -> Failed to start Remote Name Request ");
}
bdcpy(sec_event.pin_req.bd_addr, bd_addr); bdcpy(sec_event.pin_req.bd_addr, bd_addr);
BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, dev_class); BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, dev_class);
BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1)); BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1));
@ -4632,12 +4619,12 @@ void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data)
status = BTA_SUCCESS; status = BTA_SUCCESS;
} else { } else {
APPL_TRACE_ERROR("%s(), fail to set scan params.", __func__); APPL_TRACE_ERROR("%s(), fail to set scan params.", __func__);
} }
if (p_data->ble_set_scan_fil_params.scan_param_setup_cback != NULL) { if (p_data->ble_set_scan_fil_params.scan_param_setup_cback != NULL) {
p_data->ble_set_scan_fil_params.scan_param_setup_cback(p_data->ble_set_scan_fil_params.client_if, status); p_data->ble_set_scan_fil_params.scan_param_setup_cback(p_data->ble_set_scan_fil_params.client_if, status);
} }
} }
@ -4902,7 +4889,7 @@ void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data)
} }
if(p_data->ble_set_adv_params_all.p_start_adv_cback) { if(p_data->ble_set_adv_params_all.p_start_adv_cback) {
(*p_data->ble_set_adv_params_all.p_start_adv_cback)(status); (*p_data->ble_set_adv_params_all.p_start_adv_cback)(status);
} }
} }
/******************************************************************************* /*******************************************************************************

View File

@ -750,7 +750,7 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
break; break;
#endif ///BT_SSP_INCLUDED == TRUE #endif ///BT_SSP_INCLUDED == TRUE
default: default:
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act); BTC_TRACE_ERROR("Unhandled deep copy %d, arg: %p\n", msg->act, arg);
break; break;
} }
} }

View File

@ -254,10 +254,10 @@ static void start_up(void)
} }
#endif #endif
if (simple_pairing_supported) {
response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK)); response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK));
packet_parser->parse_generic_command_complete(response); packet_parser->parse_generic_command_complete(response);
}
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
response = AWAIT_COMMAND(packet_factory->make_write_sync_flow_control_enable(1)); response = AWAIT_COMMAND(packet_factory->make_write_sync_flow_control_enable(1));

View File

@ -5030,42 +5030,13 @@ void btm_sec_pin_code_request (UINT8 *p_bda)
memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN); memcpy (p_cb->connecting_bda, p_bda, BD_ADDR_LEN);
memcpy (p_cb->connecting_dc, p_dev_rec->dev_class, DEV_CLASS_LEN); memcpy (p_cb->connecting_dc, p_dev_rec->dev_class, DEV_CLASS_LEN);
/* Check if the name is known */ BTM_TRACE_EVENT ("btm_sec_pin_code_request going for callback\n");
/* Even if name is not known we might not be able to get one */ btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
/* this is the case when we are already getting something from the */ if (p_cb->api.p_pin_callback) {
/* device, so HCI level is flow controlled */ (*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name,
/* Also cannot send remote name request while paging, i.e. connection is not completed */ (p_dev_rec->p_cur_service == NULL) ? FALSE
if (p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) { : (p_dev_rec->p_cur_service->security_flags
BTM_TRACE_EVENT ("btm_sec_pin_code_request going for callback\n"); & BTM_SEC_IN_MIN_16_DIGIT_PIN));
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
if (p_cb->api.p_pin_callback) {
(*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class, p_dev_rec->sec_bd_name,
(p_dev_rec->p_cur_service == NULL) ? FALSE
: (p_dev_rec->p_cur_service->security_flags
& BTM_SEC_IN_MIN_16_DIGIT_PIN));
}
} else {
BTM_TRACE_EVENT ("btm_sec_pin_code_request going for remote name\n");
/* We received PIN code request for the device with unknown name */
/* it is not user friendly just to ask for the PIN without name */
/* try to get name at first */
if (!btsnd_hcic_rmt_name_req (p_dev_rec->bd_addr,
HCI_PAGE_SCAN_REP_MODE_R1,
HCI_MANDATARY_PAGE_SCAN_MODE, 0)) {
p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN;
p_dev_rec->sec_bd_name[0] = 'f';
p_dev_rec->sec_bd_name[1] = '0';
BTM_TRACE_ERROR ("can not send rmt_name_req?? fake a name and call callback\n");
btm_cb.pairing_flags |= BTM_PAIR_FLAGS_PIN_REQD;
if (p_cb->api.p_pin_callback)
(*p_cb->api.p_pin_callback) (p_bda, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, (p_dev_rec->p_cur_service == NULL) ? FALSE
: (p_dev_rec->p_cur_service->security_flags
& BTM_SEC_IN_MIN_16_DIGIT_PIN));
}
} }
} }
return; return;