From ab175f88459a1a0a29801391154c343856f11ee4 Mon Sep 17 00:00:00 2001 From: gengyuchao Date: Mon, 16 Mar 2020 21:37:07 +0800 Subject: [PATCH] fix allow to send stop adv hci cmd when host adv state is disable --- components/bt/bluedroid/stack/btm/btm_ble_gap.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index b3353eddc..fa4399149 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -586,7 +586,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_s } #endif - if (start && p_cb->adv_mode == BTM_BLE_ADV_DISABLE) { + if (start) { /* update adv params */ if (!btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min : BTM_BLE_GAP_ADV_INT), @@ -606,19 +606,13 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_s } status = btm_ble_start_adv (); - } else if (!start && p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { + } else { //save the stop adv callback to the BTM env. p_cb->p_stop_adv_cb = p_stop_adv_cback; status = btm_ble_stop_adv(); #if BLE_PRIVACY_SPT == TRUE btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, TRUE); #endif - } else { - /* - 1. start adv when adv has already started (not used) - 2. stop adv shen adv has already stoped - */ - status = BTM_SUCCESS; } return status; } @@ -3920,7 +3914,7 @@ tBTM_STATUS btm_ble_stop_adv(void) { tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; tBTM_STATUS rt = BTM_SUCCESS; - if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { + if (p_cb) { osi_mutex_lock(&adv_enable_lock, OSI_MUTEX_MAX_TIMEOUT); UINT8 temp_adv_mode = p_cb->adv_mode; BOOLEAN temp_fast_adv_on = p_cb->fast_adv_on;