Skip to content

Commit 429eb09

Browse files
committed
fix(ble/bluedroid): Fixed BLE report event when connection fails
1 parent 91aab8e commit 429eb09

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

components/bt/host/bluedroid/stack/btm/btm_ble.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void BTM_BleLoadLocalKeys(UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key)
217217
break;
218218

219219
default:
220-
BTM_TRACE_ERROR("unknow local key type: %d", key_type);
220+
BTM_TRACE_ERROR("unknown local key type: %d", key_type);
221221
break;
222222
}
223223
}
@@ -694,7 +694,7 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR
694694
BTM_TRACE_DEBUG ("btm_find_dev_type - unknown device, BR/EDR assumed");
695695
}
696696
}
697-
} else { /* there is a security device record exisitng */
697+
} else { /* there is a security device record existing */
698698
/* new inquiry result, overwrite device type in security device record */
699699
if (p_inq_info) {
700700
p_dev_rec->device_type = p_inq_info->results.device_type;
@@ -707,7 +707,7 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR
707707
} else if (memcmp(p_dev_rec->ble.pseudo_addr, remote_bda, BD_ADDR_LEN) == 0) {
708708
*p_dev_type = BT_DEVICE_TYPE_BLE;
709709
*p_addr_type = p_dev_rec->ble.ble_addr_type;
710-
} else { /* matching static adddress only */
710+
} else { /* matching static address only */
711711
*p_dev_type = BT_DEVICE_TYPE_BREDR;
712712
*p_addr_type = BLE_ADDR_PUBLIC;
713713
}
@@ -1061,7 +1061,7 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
10611061
** LE link for LE COC.
10621062
**
10631063
** Parameter bdaddr: remote device address.
1064-
** psm : PSM of the LE COC sevice.
1064+
** psm : PSM of the LE COC service.
10651065
** is_originator: TRUE if outgoing connection.
10661066
** p_callback : Pointer to the callback function.
10671067
** p_ref_data : Pointer to be returned along with the callback.
@@ -1078,7 +1078,7 @@ BOOLEAN btm_ble_start_sec_check(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originat
10781078
/* If there is no application registered with this PSM do not allow connection */
10791079
if (!p_serv_rec)
10801080
{
1081-
BTM_TRACE_WARNING ("%s PSM: %d no application registerd", __func__, psm);
1081+
BTM_TRACE_WARNING ("%s PSM: %d no application registered", __func__, psm);
10821082
(*p_callback) (bd_addr, BT_TRANSPORT_LE, p_ref_data, BTM_MODE_UNSUPPORTED);
10831083
return FALSE;
10841084
}
@@ -1151,7 +1151,7 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en
11511151

11521152
/* If there was a callback address for vcs complete, call it */
11531153
if (p_enc_cplt_cback && p) {
1154-
/* Pass paramters to the callback function */
1154+
/* Pass parameters to the callback function */
11551155
STREAM_TO_UINT8(params.status, p); /* command status */
11561156

11571157
if (params.status == HCI_SUCCESS) {
@@ -1208,7 +1208,7 @@ void btm_ble_increment_sign_ctr(BD_ADDR bd_addr, BOOLEAN is_local )
12081208
** Function btm_ble_get_enc_key_type
12091209
**
12101210
** Description This function is to get the BLE key type that has been exchanged
1211-
** in betweem local device and peer device.
1211+
** in between local device and peer device.
12121212
**
12131213
** Returns p_key_type: output parameter to carry the key type value.
12141214
**
@@ -1235,7 +1235,7 @@ BOOLEAN btm_ble_get_enc_key_type(BD_ADDR bd_addr, UINT8 *p_key_types)
12351235
**
12361236
** Description This function is called to read the local DIV
12371237
**
1238-
** Returns TRUE - if a valid DIV is availavle
1238+
** Returns TRUE - if a valid DIV is available
12391239
*******************************************************************************/
12401240
BOOLEAN btm_get_local_div (BD_ADDR bd_addr, UINT16 *p_div)
12411241
{
@@ -1487,7 +1487,7 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE
14871487

14881488
BTM_TRACE_DEBUG ("dev_rec sec_flags=0x%x", p_dev_rec->sec_flags);
14891489

1490-
/* currently encrpted */
1490+
/* currently encrypted */
14911491
if (p_dev_rec->sec_flags & BTM_SEC_LE_ENCRYPTED) {
14921492
if (p_dev_rec->sec_flags & BTM_SEC_LE_AUTHENTICATED) {
14931493
cur_sec_level = BTM_LE_SEC_AUTHENTICATED;
@@ -1691,7 +1691,7 @@ tBTM_STATUS btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk)
16911691
**
16921692
** Function btm_ble_link_encrypted
16931693
**
1694-
** Description This function is called when LE link encrption status is changed.
1694+
** Description This function is called when LE link encryption status is changed.
16951695
**
16961696
** Returns void
16971697
**
@@ -1949,7 +1949,7 @@ static void btm_ble_resolve_random_addr_on_conn_cmpl(void *p_rec, void *p_data)
19491949
** Function btm_ble_connected
19501950
**
19511951
** Description This function is when a LE connection to the peer device is
1952-
** establsihed
1952+
** established
19531953
**
19541954
** Returns void
19551955
**
@@ -2060,7 +2060,7 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
20602060
peer_addr_type = bda_type;
20612061
match = btm_identity_addr_to_random_pseudo (bda, &bda_type, FALSE);
20622062

2063-
/* possiblly receive connection complete with resolvable random on
2063+
/* possibly receive connection complete with resolvable random on
20642064
slave role while the device has been paired */
20652065

20662066
/* It will cause that scanner doesn't send scan request to advertiser
@@ -2143,6 +2143,16 @@ void btm_ble_create_ll_conn_complete (UINT8 status)
21432143
if (status != HCI_SUCCESS) {
21442144
btm_ble_set_conn_st(BLE_CONN_IDLE);
21452145
btm_ble_update_mode_operation(HCI_ROLE_UNKNOWN, NULL, status);
2146+
if(l2cb.is_ble_connecting) {
2147+
/* see L2CA_CancelBleConnectReq() */
2148+
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(l2cb.ble_connecting_bda, BT_TRANSPORT_LE);
2149+
/* Do not remove lcb if an LE link is already up as a peripheral */
2150+
if (p_lcb != NULL &&
2151+
!(p_lcb->link_role == HCI_ROLE_SLAVE && BTM_ACL_IS_CONNECTED(l2cb.ble_connecting_bda))) {
2152+
p_lcb->disc_reason = L2CAP_CONN_CANCEL;
2153+
l2cu_release_lcb (p_lcb);
2154+
}
2155+
}
21462156
}
21472157
}
21482158

@@ -2300,15 +2310,15 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
23002310
** Function BTM_BleDataSignature
23012311
**
23022312
** Description This function is called to sign the data using AES128 CMAC
2303-
** algorith.
2313+
** algorithm.
23042314
**
23052315
** Parameter bd_addr: target device the data to be signed for.
23062316
** p_text: singing data
23072317
** len: length of the data to be signed.
23082318
** signature: output parameter where data signature is going to
23092319
** be stored.
23102320
**
2311-
** Returns TRUE if signing sucessul, otherwise FALSE.
2321+
** Returns TRUE if signing successful, otherwise FALSE.
23122322
**
23132323
*******************************************************************************/
23142324
#if (SMP_INCLUDED == TRUE)
@@ -2491,7 +2501,7 @@ BOOLEAN BTM_BleSecurityProcedureIsRunning(BD_ADDR bd_addr)
24912501
** Function BTM_BleGetSupportedKeySize
24922502
**
24932503
** Description This function gets the maximum encryption key size in bytes
2494-
** the local device can suport.
2504+
** the local device can support.
24952505
** record.
24962506
**
24972507
** Returns the key size or 0 if the size can't be retrieved.

components/bt/host/bluedroid/stack/btu/btu_hcif.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,9 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
13791379
break;
13801380

13811381
#if BLE_INCLUDED == TRUE
1382+
#if (BLE_50_FEATURE_SUPPORT == TRUE)
1383+
case HCI_BLE_EXT_CREATE_CONN:
1384+
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
13821385
case HCI_BLE_CREATE_LL_CONN:
13831386
btm_ble_create_ll_conn_complete(status);
13841387
break;

0 commit comments

Comments
 (0)