mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt: Fix the bug that sometimes received a ble connection & the adv will stop, can not send adv again.
This commit is contained in:
parent
1e0710f1b2
commit
e797cd03f0
@ -1484,6 +1484,20 @@ UINT16 BTM_BleReadConnectability()
|
|||||||
return (btm_cb.ble_ctr_cb.inq_var.connectable_mode);
|
return (btm_cb.ble_ctr_cb.inq_var.connectable_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BTM_Recovery_Pre_State(void)
|
||||||
|
{
|
||||||
|
tBTM_BLE_INQ_CB *ble_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||||
|
|
||||||
|
if (ble_inq_cb->state == BTM_BLE_ADVERTISING) {
|
||||||
|
btm_ble_stop_adv();
|
||||||
|
btm_ble_start_adv();
|
||||||
|
} else if (ble_inq_cb->state == BTM_BLE_SCANNING) {
|
||||||
|
btm_ble_start_scan();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function btm_ble_build_adv_data
|
** Function btm_ble_build_adv_data
|
||||||
@ -2954,6 +2968,7 @@ tBTM_STATUS btm_ble_start_scan(void)
|
|||||||
if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) {
|
if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) {
|
||||||
status = BTM_NO_RESOURCES;
|
status = BTM_NO_RESOURCES;
|
||||||
} else {
|
} else {
|
||||||
|
btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_SCANNING;
|
||||||
if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) {
|
if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) {
|
||||||
btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT);
|
btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT);
|
||||||
} else {
|
} else {
|
||||||
@ -2980,7 +2995,7 @@ void btm_ble_stop_scan(void)
|
|||||||
if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_DISABLE) {
|
if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_DISABLE) {
|
||||||
/* Clear the inquiry callback if set */
|
/* Clear the inquiry callback if set */
|
||||||
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
|
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
|
||||||
|
btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_STOP_SCAN;
|
||||||
/* stop discovery now */
|
/* stop discovery now */
|
||||||
btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
|
btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
|
||||||
|
|
||||||
@ -3136,6 +3151,7 @@ tBTM_STATUS btm_ble_start_adv(void)
|
|||||||
|
|
||||||
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE)) {
|
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE)) {
|
||||||
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
|
||||||
|
p_cb->state = BTM_BLE_ADVERTISING;
|
||||||
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
|
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
|
||||||
rt = BTM_SUCCESS;
|
rt = BTM_SUCCESS;
|
||||||
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
|
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
|
||||||
@ -3166,6 +3182,7 @@ tBTM_STATUS btm_ble_stop_adv(void)
|
|||||||
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
|
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
|
||||||
p_cb->fast_adv_on = FALSE;
|
p_cb->fast_adv_on = FALSE;
|
||||||
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
|
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
|
||||||
|
p_cb->state = BTM_BLE_STOP_ADV;
|
||||||
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_ADV;
|
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_ADV;
|
||||||
|
|
||||||
/* clear all adv states */
|
/* clear all adv states */
|
||||||
|
@ -2184,8 +2184,10 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
|
|||||||
}
|
}
|
||||||
memset(p_tcb, 0, sizeof(tGATT_TCB));
|
memset(p_tcb, 0, sizeof(tGATT_TCB));
|
||||||
|
|
||||||
}
|
} else {
|
||||||
GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc ");
|
GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc ");
|
||||||
|
BTM_Recovery_Pre_State();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
|
@ -1532,6 +1532,8 @@ UINT16 BTM_BleReadDiscoverability();
|
|||||||
//extern
|
//extern
|
||||||
UINT16 BTM_BleReadConnectability ();
|
UINT16 BTM_BleReadConnectability ();
|
||||||
|
|
||||||
|
void BTM_Recovery_Pre_State(void);
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function BTM_ReadDevInfo
|
** Function BTM_ReadDevInfo
|
||||||
|
@ -101,6 +101,15 @@ typedef UINT8 tBTM_BLE_SEC_REQ_ACT;
|
|||||||
#define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55
|
#define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55
|
||||||
#define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95
|
#define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BTM_BLE_SCANNING,
|
||||||
|
BTM_BLE_SCAN_PENDING,
|
||||||
|
BTM_BLE_STOP_SCAN,
|
||||||
|
BTM_BLE_ADVERTISING,
|
||||||
|
BTM_BLE_ADV_PENDING,
|
||||||
|
BTM_BLE_STOP_ADV,
|
||||||
|
}tBTM_BLE_GAP_STATE;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINT16 data_mask;
|
UINT16 data_mask;
|
||||||
UINT8 *p_flags;
|
UINT8 *p_flags;
|
||||||
@ -155,7 +164,7 @@ typedef struct {
|
|||||||
|
|
||||||
TIMER_LIST_ENT inq_timer_ent;
|
TIMER_LIST_ENT inq_timer_ent;
|
||||||
BOOLEAN scan_rsp;
|
BOOLEAN scan_rsp;
|
||||||
UINT8 state; /* Current state that the inquiry process is in */
|
tBTM_BLE_GAP_STATE state; /* Current state that the inquiry process is in */
|
||||||
INT8 tx_power;
|
INT8 tx_power;
|
||||||
} tBTM_BLE_INQ_CB;
|
} tBTM_BLE_INQ_CB;
|
||||||
|
|
||||||
|
@ -356,9 +356,9 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
|||||||
|
|
||||||
/* See if we have a link control block for the connection */
|
/* See if we have a link control block for the connection */
|
||||||
p_lcb = l2cu_find_lcb_by_handle (handle);
|
p_lcb = l2cu_find_lcb_by_handle (handle);
|
||||||
|
|
||||||
/* If we don't have one, maybe an SCO link. Send to MM */
|
/* If we don't have one, maybe an SCO link. Send to MM */
|
||||||
if (!p_lcb) {
|
if (!p_lcb) {
|
||||||
|
BTM_Recovery_Pre_State();
|
||||||
status = FALSE;
|
status = FALSE;
|
||||||
} else {
|
} else {
|
||||||
/* There can be a case when we rejected PIN code authentication */
|
/* There can be a case when we rejected PIN code authentication */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user