Skip to content

Commit

Permalink
Merge branch 'bugfix/ble_stack_disable_v5.2' into 'release/v5.2'
Browse files Browse the repository at this point in the history
Bugfix/ble stack disable v5.2(backport v5.2)

See merge request espressif/esp-idf!27651
  • Loading branch information
Isl2017 committed Dec 25, 2023
2 parents 5592d28 + 90c51d2 commit c8b5789
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions components/bt/host/bluedroid/bta/dm/bta_dm_act.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,14 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
bta_dm_disable_search_and_disc();
bta_dm_cb.disabling = TRUE;

#if BLE_INCLUDED == TRUE
/* reset scan activity status*/
btm_cb.ble_ctr_cb.scan_activity = 0;

/* reset advertising activity status*/
btm_cb.ble_ctr_cb.inq_var.state = 0;
#endif

#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
BTM_BleClearBgConnDev();
#endif
Expand Down
14 changes: 11 additions & 3 deletions components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_STATUS statu
static void bta_gattc_enable(tBTA_GATTC_CB *p_cb)
{
APPL_TRACE_DEBUG("bta_gattc_enable");

if (p_cb->state == BTA_GATTC_STATE_DISABLED) {
/* This is a workaround because the task priority of btc (BTA_GATTC_CLOSE_EVT
in that task) is lower than the priority of the btu task.
Consequently, the p_cb->state fails to be restored to BTA_GATTC_STATE_DISABLED
and remains in the BTA_GATTC_STATE_DISABLING state. */
if (p_cb->state == BTA_GATTC_STATE_DISABLED || p_cb->state == BTA_GATTC_STATE_DISABLING) {
/* initialize control block */
memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
bta_gattc_cb.auto_disc = true;
Expand Down Expand Up @@ -158,6 +161,7 @@ void bta_gattc_disable(tBTA_GATTC_CB *p_cb)
for (i = 0; i < BTA_GATTC_CL_MAX; i ++) {
if (p_cb->cl_rcb[i].in_use) {
p_cb->state = BTA_GATTC_STATE_DISABLING;
p_cb->cl_rcb[i].in_use = false;
/* don't deregister HH GATT IF */
/* HH GATT IF will be deregistered by bta_hh_le_deregister when disable HH */
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
Expand Down Expand Up @@ -200,7 +204,11 @@ void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
cb_data.reg_oper.status = BTA_GATT_NO_RESOURCES;

/* check if GATTC module is already enabled . Else enable */
if (p_cb->state == BTA_GATTC_STATE_DISABLED) {
/* This is a workaround because the task priority of btc (BTA_GATTC_CLOSE_EVT
in that task) is lower than the priority of the btu task.
Consequently, the p_cb->state fails to be restored to BTA_GATTC_STATE_DISABLED
and remains in the BTA_GATTC_STATE_DISABLING state. */
if (p_cb->state == BTA_GATTC_STATE_DISABLED || p_cb->state == BTA_GATTC_STATE_DISABLING) {
bta_gattc_enable (p_cb);
}
/* todo need to check duplicate uuid */
Expand Down

0 comments on commit c8b5789

Please sign in to comment.