Skip to content

Commit

Permalink
Merge branch 'bugfix/backport_some_ble_bugs_20231020_v4.3' into 'rele…
Browse files Browse the repository at this point in the history
…ase/v4.3'

Fixed some BLE bugs 20231020 (backport v4.3)

See merge request espressif/esp-idf!26614
  • Loading branch information
wmy-espressif committed Oct 26, 2023
2 parents 2d97663 + 1b20c19 commit 2b6ebac
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 3 deletions.
5 changes: 5 additions & 0 deletions components/bt/controller/esp32/Kconfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ menu "HCI UART(H4) Options"
help
UART Baudrate for HCI. Please use standard baudrate.

config BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
bool "Enable UART flow control"
depends on BTDM_CTRL_HCI_MODE_UART_H4
default y

endmenu

menu "MODEM SLEEP Options"
Expand Down
10 changes: 10 additions & 0 deletions components/bt/controller/esp32/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ extern int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary);
extern int coex_register_wifi_channel_change_callback(void *cb);
/* Shutdown */
extern void esp_bt_controller_shutdown(void);
extern void sdk_config_set_bt_pll_track_enable(bool enable);
extern void sdk_config_set_uart_flow_ctrl_enable(bool enable);

extern char _bss_start_btdm;
extern char _bss_end_btdm;
Expand Down Expand Up @@ -1314,6 +1316,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif

#if CONFIG_BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
sdk_config_set_uart_flow_ctrl_enable(true);
#else
sdk_config_set_uart_flow_ctrl_enable(false);
#endif

#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
Expand Down Expand Up @@ -1457,6 +1465,8 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
btdm_controller_enable_sleep(true);
}

sdk_config_set_bt_pll_track_enable(true);

// inititalize bluetooth baseband
btdm_check_and_init_bb();

Expand Down
2 changes: 1 addition & 1 deletion components/bt/controller/lib_esp32c3_family
Original file line number Diff line number Diff line change
Expand Up @@ -674,14 +674,18 @@ typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SOLIC_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1859 | .... |` */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_URI_ADV, /*!< BLE mesh URI adv, the format is ...| Len | 0x24 | data |... */
} esp_ble_duplicate_exceptional_info_type_t;

typedef enum {
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with proxy service uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SOLIC_ADV_LIST = BLE_BIT(5), /*!< duplicate scan exceptional mesh adv with proxy solicitation PDU uuid */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_URI_ADV_LIST = BLE_BIT(6), /*!< duplicate scan exceptional URI list */
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */
} esp_duplicate_scan_exceptional_list_type_t;

Expand Down
1 change: 1 addition & 0 deletions components/bt/host/bluedroid/hci/hci_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ static void command_timed_out(void *context)
{
hci_cmd_metadata_t *metadata = (hci_cmd_metadata_t *)(wait_entry->data);
HCI_TRACE_ERROR("%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, metadata->opcode);
UNUSED(metadata);
}
}

Expand Down
1 change: 1 addition & 0 deletions components/bt/host/bluedroid/stack/l2cap/l2c_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
STREAM_TO_UINT16(mps, p);
STREAM_TO_UINT16(credits, p);
L2CAP_TRACE_DEBUG("%s spsm %x, scid %x", __func__, spsm, scid);
UNUSED(spsm);

p_ccb = l2cu_find_ccb_by_remote_cid(p_lcb, scid);
if (p_ccb) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void uart_gpio_reset(void)
periph_module_enable(PERIPH_UHCI0_MODULE);

#ifdef CONFIG_BTDM_CTRL_HCI_UART_NO
ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX 18, CTS 23, RTS 19", CONFIG_BTDM_CTRL_HCI_UART_NO);
ESP_LOGI(tag, "HCI UART%d Pin select: TX 5, RX 18, CTS 23, RTS 19 Baudrate:%d", CONFIG_BTDM_CTRL_HCI_UART_NO, CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE);

uart_set_pin(CONFIG_BTDM_CTRL_HCI_UART_NO, 5, 18, 19, 23);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ menu "Example Configuration"
help
UART Baudrate for HCI. Please use standard baudrate.

config EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
bool "Enable HCI UART flow control"
default y
help
Enable/disable HCI UART flow control

endmenu
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ static const char *tag = "UHCI";
#define GPIO_OUTPUT_PIN_SEL ((1ULL<<GPIO_UART_TXD_OUT) | (1ULL<<GPIO_UART_RTS_OUT))
#define GPIO_INPUT_PIN_SEL ((1ULL<<GPIO_UART_RXD_IN) | (1ULL<<GPIO_UART_CTS_IN))

#ifdef CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
#define HCI_UART_FLOW_CTRL_ENABLE CONFIG_EXAMPLE_HCI_UART_FLOW_CTRL_ENABLE
#else
#define HCI_UART_FLOW_CTRL_ENABLE FALSE
#endif

// Operation functions for HCI UART Transport Layer
static bool hci_uart_tl_init(void);
static void hci_uart_tl_deinit(void);
Expand Down Expand Up @@ -205,7 +211,11 @@ void uhci_uart_install(void)
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
#if (HCI_UART_FLOW_CTRL_ENABLE == TRUE)
.flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS,
#else
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
#endif
.rx_flow_ctrl_thresh = UART_RX_THRS,
.source_clk = UART_SCLK_APB,
};
Expand Down Expand Up @@ -286,4 +296,5 @@ void app_main(void)
"--Baudrate: %d", UART_HCI_NUM,
GPIO_UART_TXD_OUT, GPIO_UART_RXD_IN, GPIO_UART_RTS_OUT, GPIO_UART_CTS_IN,
CONFIG_EXAMPLE_HCI_UART_BAUDRATE);

}

0 comments on commit 2b6ebac

Please sign in to comment.