mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(bt/bluedroid): fixed btc_config_lock error
This commit is contained in:
parent
692d15abbe
commit
5515c890ed
@ -264,13 +264,13 @@ bool config_update_newest_section(config_t *config, const char *section)
|
||||
return false;
|
||||
}
|
||||
section_t *first_sec = list_node(first_node);
|
||||
if (!strcmp(first_sec->name, section)) {
|
||||
if (strcmp(first_sec->name, section) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
|
||||
section_t *sec = list_node(node);
|
||||
if (!strcmp(sec->name, section)) {
|
||||
if (strcmp(sec->name, section) == 0) {
|
||||
list_delete(config->sections, sec);
|
||||
list_prepend(config->sections, sec);
|
||||
return true;
|
||||
|
@ -706,6 +706,7 @@ static void btc_dm_acl_link_stat(tBTA_DM_ACL_LINK_STAT *p_acl_link_stat)
|
||||
}
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if (p_acl_link_stat->event == BTA_ACL_LINK_STAT_CONN_CMPL &&
|
||||
p_acl_link_stat->link_act.conn_cmpl.status == HCI_SUCCESS) {
|
||||
memcpy(bt_addr.address, p_acl_link_stat->link_act.conn_cmpl.bd_addr, sizeof(bt_addr.address));
|
||||
@ -716,7 +717,7 @@ static void btc_dm_acl_link_stat(tBTA_DM_ACL_LINK_STAT *p_acl_link_stat)
|
||||
bt_addr.address[4], bt_addr.address[5]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
esp_bt_gap_cb_t cb = (esp_bt_gap_cb_t)btc_profile_cb_get(BTC_PID_GAP_BT);
|
||||
if (cb) {
|
||||
cb(event, ¶m);
|
||||
|
@ -196,6 +196,32 @@ bt_status_t btc_storage_load_bonded_devices(void)
|
||||
BTC_TRACE_DEBUG("Storage load rslt %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_update_active_device
|
||||
**
|
||||
** Description BTC storage API - Once an ACL link is established and remote
|
||||
** bd_addr is already stored in NVRAM, update the config and update
|
||||
** the remote device to be the newest active device, The updates will
|
||||
** not be stored into NVRAM immediately.
|
||||
**
|
||||
** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bool btc_storage_update_active_device(bt_bdaddr_t *remote_bd_addr)
|
||||
{
|
||||
bdstr_t bdstr;
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||
bool ret = false;
|
||||
BTC_TRACE_DEBUG("Update active device: Remote device:%s\n", bdstr);
|
||||
|
||||
btc_config_lock();
|
||||
ret = btc_config_update_newest_section(bdstr);
|
||||
btc_config_unlock();
|
||||
|
||||
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
@ -308,32 +334,6 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *d
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_update_active_device
|
||||
**
|
||||
** Description BTC storage API - Once an ACL link is established and remote
|
||||
** bd_addr is already stored in NVRAM, update the config and update
|
||||
** the remote device to be the newest active device, The updates will
|
||||
** not be stored into NVRAM immediately.
|
||||
**
|
||||
** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bool btc_storage_update_active_device(bt_bdaddr_t *remote_bd_addr)
|
||||
{
|
||||
bdstr_t bdstr;
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||
bool ret = false;
|
||||
BTC_TRACE_DEBUG("Update active device: Remote device:%s\n", bdstr);
|
||||
|
||||
btc_config_lock();
|
||||
ret = btc_config_update_newest_section(bdstr);
|
||||
btc_config_unlock();
|
||||
|
||||
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
#if (defined BTC_HH_INCLUDED && BTC_HH_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
*
|
||||
|
@ -926,6 +926,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTA_GATTC_CONNECT_EVT: {
|
||||
tBTA_GATTC_CONNECT *connect = &arg->connect;
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bt_addr;
|
||||
|
||||
memcpy(bt_addr.address, connect->remote_bda, sizeof(bt_addr.address));
|
||||
@ -935,7 +936,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
bt_addr.address[2], bt_addr.address[3],
|
||||
bt_addr.address[4], bt_addr.address[5]);
|
||||
}
|
||||
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
gattc_if = connect->client_if;
|
||||
param.connect.conn_id = BTC_GATT_GET_CONN_ID(connect->conn_id);
|
||||
param.connect.link_role = connect->link_role;
|
||||
|
@ -901,6 +901,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
|
||||
btc_gatts_cb_to_app(ESP_GATTS_STOP_EVT, gatts_if, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CONNECT_EVT: {
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bt_addr;
|
||||
memcpy(bt_addr.address, p_data->conn.remote_bda, sizeof(bt_addr.address));
|
||||
if (btc_storage_update_active_device(&bt_addr)) {
|
||||
@ -909,7 +910,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
|
||||
bt_addr.address[2], bt_addr.address[3],
|
||||
bt_addr.address[4], bt_addr.address[5]);
|
||||
}
|
||||
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
gatts_if = p_data->conn.server_if;
|
||||
param.connect.conn_id = BTC_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
param.connect.link_role = p_data->conn.link_role;
|
||||
|
Loading…
Reference in New Issue
Block a user