Merge branch 'bugfix/btdm_fix_start_adv' into 'master'

Component/bt: fix start adv complete event state error in dual core

See merge request idf/esp-idf!2432
This commit is contained in:
Jiang Jiang Jian 2018-05-30 19:41:39 +08:00
commit fbbf4b0c03
3 changed files with 15 additions and 6 deletions

View file

@ -3457,15 +3457,21 @@ tBTM_STATUS btm_ble_start_adv(void)
btm_execute_wl_dev_operation();
btm_cb.ble_ctr_cb.wl_state |= BTM_BLE_WL_ADV;
}
/* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core,
this causes the 'adv_mode' and 'state' not be set yet, so we set the state first */
tBTM_BLE_GAP_STATE temp_state = p_cb->state;
UINT8 adv_mode = p_cb->adv_mode;
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
p_cb->state = BTM_BLE_ADV_PENDING;
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE)) {
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
p_cb->state = BTM_BLE_ADV_PENDING;
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
rt = BTM_SUCCESS;
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
} else {
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
p_cb->state = temp_state;
p_cb->adv_mode = adv_mode;
btm_ble_adv_states_operation(btm_ble_clear_topology_mask, p_cb->evt_type);
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_ADV;
}
return rt;

View file

@ -4046,7 +4046,10 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED;
}
} else {
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
#if BLE_INCLUDED == TRUE
/* Before the application layer has received the connection event, the device has received an
encrypted request from the peer device. The device should wait until the application layer
receives the connection event before updating 'sec_flags'. */
if ((p_tcb = gatt_find_tcb_by_addr(p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE)) == NULL) {
//do nothing
} else

View file

@ -46,7 +46,7 @@ typedef struct {
/* While scanning, if the free memory value in controller is less than SCAN_SEND_ADV_RESERVED_SIZE,
the adv packet will be discarded until the memory is restored. */
#define SCAN_SEND_ADV_RESERVED_SIZE 1000
/* open controller log debug when adv lost */
/* enable controller log debug when adv lost */
#define CONTROLLER_ADV_LOST_DEBUG_BIT (0<<0)
#ifdef CONFIG_BT_HCI_UART_NO