Merge branch 'bugfix/ble_add_adv_state_bug_#12301' into 'master'

component/bt: Fix the bug that sometimes received a ble connection & the adv wil…

…l stop, can not send adv again.

See merge request !759
pull/439/merge
Jiang Jiang Jian 2017-05-18 15:03:41 +08:00
commit b5e2bcbb2c
5 zmienionych plików z 35 dodań i 5 usunięć

Wyświetl plik

@ -1487,6 +1487,20 @@ UINT16 BTM_BleReadConnectability()
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
@ -2957,6 +2971,7 @@ tBTM_STATUS btm_ble_start_scan(void)
if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) {
status = BTM_NO_RESOURCES;
} else {
btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_SCANNING;
if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) {
btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT);
} else {
@ -2983,7 +2998,7 @@ void btm_ble_stop_scan(void)
if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_DISABLE) {
/* 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.state = BTM_BLE_STOP_SCAN;
/* stop discovery now */
btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
@ -3139,6 +3154,7 @@ tBTM_STATUS btm_ble_start_adv(void)
if (btsnd_hcic_ble_set_adv_enable (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);
rt = BTM_SUCCESS;
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
@ -3169,6 +3185,7 @@ tBTM_STATUS btm_ble_stop_adv(void)
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
p_cb->fast_adv_on = FALSE;
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;
/* clear all adv states */

Wyświetl plik

@ -2184,8 +2184,10 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
}
memset(p_tcb, 0, sizeof(tGATT_TCB));
} else {
GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc ");
BTM_Recovery_Pre_State();
}
GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc ");
}
/*******************************************************************************
**

Wyświetl plik

@ -1532,6 +1532,8 @@ UINT16 BTM_BleReadDiscoverability();
//extern
UINT16 BTM_BleReadConnectability ();
void BTM_Recovery_Pre_State(void);
/*******************************************************************************
**
** Function BTM_ReadDevInfo

Wyświetl plik

@ -101,6 +101,15 @@ typedef UINT8 tBTM_BLE_SEC_REQ_ACT;
#define BTM_VSC_CHIP_CAPABILITY_L_VERSION 55
#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 {
UINT16 data_mask;
UINT8 *p_flags;
@ -155,7 +164,7 @@ typedef struct {
TIMER_LIST_ENT inq_timer_ent;
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;
} tBTM_BLE_INQ_CB;

Wyświetl plik

@ -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 */
p_lcb = l2cu_find_lcb_by_handle (handle);
/* If we don't have one, maybe an SCO link. Send to MM */
if (!p_lcb) {
BTM_Recovery_Pre_State();
status = FALSE;
} else {
/* There can be a case when we rejected PIN code authentication */
@ -613,7 +613,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb)
} else {
/* Check in case we were flow controlled */
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
}
}
#endif ///SMP_INCLUDED == TRUE
}
}