Skip to content

Commit bb2f5ae

Browse files
committed
Merge branch 'fix/btc_config_lock_error_v5.0' into 'release/v5.0'
fix(bt/bluedroid): fixed btc_config_lock error (backport v5.0) See merge request espressif/esp-idf!28071
2 parents 0b38d37 + e38db79 commit bb2f5ae

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

components/bt/host/bluedroid/btc/core/btc_dm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ static void btc_dm_acl_link_stat(tBTA_DM_ACL_LINK_STAT *p_acl_link_stat)
712712
}
713713
}
714714

715+
#if (SMP_INCLUDED == TRUE)
715716
if (p_acl_link_stat->event == BTA_ACL_LINK_STAT_CONN_CMPL &&
716717
p_acl_link_stat->link_act.conn_cmpl.status == HCI_SUCCESS) {
717718
memcpy(bt_addr.address, p_acl_link_stat->link_act.conn_cmpl.bd_addr, sizeof(bt_addr.address));
@@ -722,7 +723,7 @@ static void btc_dm_acl_link_stat(tBTA_DM_ACL_LINK_STAT *p_acl_link_stat)
722723
bt_addr.address[4], bt_addr.address[5]);
723724
}
724725
}
725-
726+
#endif ///SMP_INCLUDED == TRUE
726727
esp_bt_gap_cb_t cb = (esp_bt_gap_cb_t)btc_profile_cb_get(BTC_PID_GAP_BT);
727728
if (cb) {
728729
cb(event, &param);

components/bt/host/bluedroid/btc/core/btc_storage.c

+26-26
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,32 @@ bt_status_t btc_storage_load_bonded_devices(void)
196196
BTC_TRACE_DEBUG("Storage load rslt %d\n", status);
197197
return status;
198198
}
199+
200+
/*******************************************************************************
201+
**
202+
** Function btc_storage_update_active_device
203+
**
204+
** Description BTC storage API - Once an ACL link is established and remote
205+
** bd_addr is already stored in NVRAM, update the config and update
206+
** the remote device to be the newest active device, The updates will
207+
** not be stored into NVRAM immediately.
208+
**
209+
** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
210+
**
211+
*******************************************************************************/
212+
bool btc_storage_update_active_device(bt_bdaddr_t *remote_bd_addr)
213+
{
214+
bdstr_t bdstr;
215+
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
216+
bool ret = false;
217+
BTC_TRACE_DEBUG("Update active device: Remote device:%s\n", bdstr);
218+
219+
btc_config_lock();
220+
ret = btc_config_update_newest_section(bdstr);
221+
btc_config_unlock();
222+
223+
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
224+
}
199225
#endif ///SMP_INCLUDED == TRUE
200226

201227
/*******************************************************************************
@@ -308,32 +334,6 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *d
308334
return BT_STATUS_SUCCESS;
309335
}
310336

311-
/*******************************************************************************
312-
**
313-
** Function btc_storage_update_active_device
314-
**
315-
** Description BTC storage API - Once an ACL link is established and remote
316-
** bd_addr is already stored in NVRAM, update the config and update
317-
** the remote device to be the newest active device, The updates will
318-
** not be stored into NVRAM immediately.
319-
**
320-
** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
321-
**
322-
*******************************************************************************/
323-
bool btc_storage_update_active_device(bt_bdaddr_t *remote_bd_addr)
324-
{
325-
bdstr_t bdstr;
326-
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
327-
bool ret = false;
328-
BTC_TRACE_DEBUG("Update active device: Remote device:%s\n", bdstr);
329-
330-
btc_config_lock();
331-
ret = btc_config_update_newest_section(bdstr);
332-
btc_config_unlock();
333-
334-
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
335-
}
336-
337337
#if (defined BTC_HH_INCLUDED && BTC_HH_INCLUDED == TRUE)
338338
/*******************************************************************************
339339
*

components/bt/host/bluedroid/btc/profile/std/gatt/btc_gattc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
926926
}
927927
case BTA_GATTC_CONNECT_EVT: {
928928
tBTA_GATTC_CONNECT *connect = &arg->connect;
929+
#if (SMP_INCLUDED == TRUE)
929930
bt_bdaddr_t bt_addr;
930931

931932
memcpy(bt_addr.address, connect->remote_bda, sizeof(bt_addr.address));
@@ -935,7 +936,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
935936
bt_addr.address[2], bt_addr.address[3],
936937
bt_addr.address[4], bt_addr.address[5]);
937938
}
938-
939+
#endif ///SMP_INCLUDED == TRUE
939940
gattc_if = connect->client_if;
940941
param.connect.conn_id = BTC_GATT_GET_CONN_ID(connect->conn_id);
941942
param.connect.link_role = connect->link_role;

components/bt/host/bluedroid/btc/profile/std/gatt/btc_gatts.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
901901
btc_gatts_cb_to_app(ESP_GATTS_STOP_EVT, gatts_if, &param);
902902
break;
903903
case BTA_GATTS_CONNECT_EVT: {
904+
#if (SMP_INCLUDED == TRUE)
904905
bt_bdaddr_t bt_addr;
905906
memcpy(bt_addr.address, p_data->conn.remote_bda, sizeof(bt_addr.address));
906907
if (btc_storage_update_active_device(&bt_addr)) {
@@ -909,7 +910,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
909910
bt_addr.address[2], bt_addr.address[3],
910911
bt_addr.address[4], bt_addr.address[5]);
911912
}
912-
913+
#endif ///SMP_INCLUDED == TRUE
913914
gatts_if = p_data->conn.server_if;
914915
param.connect.conn_id = BTC_GATT_GET_CONN_ID(p_data->conn.conn_id);
915916
param.connect.link_role = p_data->conn.link_role;

0 commit comments

Comments
 (0)