feat(ble): add ble controller status check api on ESP32-C6 and ESP32-H2

This commit is contained in:
zwl 2024-01-25 16:29:08 +08:00 committed by luomanruo
parent b13a4e2d9c
commit d1e16cea67
2 changed files with 42 additions and 42 deletions

View File

@ -123,10 +123,10 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int ble_log_deinit_async(void);
extern void ble_log_async_select_dump_buffers(uint8_t buffers);
extern void ble_log_async_output_dump_all(bool output);
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int r_ble_log_deinit_async(void);
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
extern void r_ble_log_async_output_dump_all(bool output);
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
extern int ble_controller_deinit(void);
@ -140,8 +140,8 @@ extern void esp_unregister_npl_funcs (void);
extern void npl_freertos_mempool_deinit(void);
extern uint32_t r_os_cputime_get32(void);
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
extern void ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
void *w_arg, uint32_t us_to_enabled);
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
void *w_arg, uint32_t us_to_enabled);
extern void r_ble_rtc_wake_up_state_clr(void);
extern int os_msys_init(void);
extern void os_msys_deinit(void);
@ -541,10 +541,10 @@ esp_err_t controller_sleep_init(void)
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
BLE_RTC_DELAY_US_LIGHT_SLEEP);
#else
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
BLE_RTC_DELAY_US_MODEM_SLEEP);
#endif /* FREERTOS_USE_TICKLESS_IDLE */
#endif // CONFIG_BT_LE_SLEEP_ENABLE
@ -624,16 +624,16 @@ typedef enum {
}disc_duplicate_mode_t;
extern void filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
extern void filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
extern void filter_duplicate_set_ring_list_max_num(uint32_t max_num);
extern void scan_duplicate_cache_refresh_set_time(uint32_t period_time);
extern void r_filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
extern void r_filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
extern void r_filter_duplicate_set_ring_list_max_num(uint32_t max_num);
extern void r_scan_duplicate_cache_refresh_set_time(uint32_t period_time);
int
ble_vhci_disc_duplicate_mode_enable(int mode)
{
// TODO: use vendor hci to update
filter_duplicate_mode_enable(mode);
r_filter_duplicate_mode_enable(mode);
return true;
}
@ -641,19 +641,19 @@ int
ble_vhci_disc_duplicate_mode_disable(int mode)
{
// TODO: use vendor hci to update
filter_duplicate_mode_disable(mode);
r_filter_duplicate_mode_disable(mode);
return true;
}
int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size){
// TODO: use vendor hci to update
filter_duplicate_set_ring_list_max_num(max_cache_size);
r_filter_duplicate_set_ring_list_max_num(max_cache_size);
return true;
}
int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time){
// TODO: use vendor hci to update
scan_duplicate_cache_refresh_set_time(refresh_period_time);
r_scan_duplicate_cache_refresh_set_time(refresh_period_time);
return true;
}
@ -796,9 +796,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
buffers |= ESP_BLE_LOG_BUF_HCI;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
ret = r_ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
#else
ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
ret = r_ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
@ -835,7 +835,7 @@ free_controller:
controller_sleep_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
controller_init_err:
ble_log_deinit_async();
r_ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
os_msys_deinit();
ble_controller_deinit();
@ -871,7 +871,7 @@ esp_err_t esp_bt_controller_deinit(void)
modem_clock_module_disable(PERIPH_BT_MODULE);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_log_deinit_async();
r_ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();
@ -1191,7 +1191,7 @@ void esp_ble_controller_log_dump_all(bool output)
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_reconfigure_wdts(5000);
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
r_ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}

View File

@ -117,10 +117,10 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int ble_log_deinit_async(void);
extern void ble_log_async_select_dump_buffers(uint8_t buffers);
extern void ble_log_async_output_dump_all(bool output);
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int r_ble_log_deinit_async(void);
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
extern void r_ble_log_async_output_dump_all(bool output);
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
extern int ble_controller_deinit(void);
@ -139,8 +139,8 @@ extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(ui
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
extern void esp_ble_change_rtc_freq(uint32_t freq);
extern void ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
void *w_arg, uint32_t us_to_enabled);
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
void *w_arg, uint32_t us_to_enabled);
extern void r_ble_rtc_wake_up_state_clr(void);
extern int os_msys_init(void);
extern void os_msys_deinit(void);
@ -529,10 +529,10 @@ esp_err_t controller_sleep_init(void)
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
BLE_RTC_DELAY_US_LIGHT_SLEEP);
#else
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
BLE_RTC_DELAY_US_MODEM_SLEEP);
#endif /* FREERTOS_USE_TICKLESS_IDLE */
#endif // CONFIG_BT_LE_SLEEP_ENABLE
@ -599,16 +599,16 @@ typedef enum {
}disc_duplicate_mode_t;
extern void filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
extern void filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
extern void filter_duplicate_set_ring_list_max_num(uint32_t max_num);
extern void scan_duplicate_cache_refresh_set_time(uint32_t period_time);
extern void r_filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
extern void r_filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
extern void r_filter_duplicate_set_ring_list_max_num(uint32_t max_num);
extern void r_scan_duplicate_cache_refresh_set_time(uint32_t period_time);
int
ble_vhci_disc_duplicate_mode_enable(int mode)
{
// TODO: use vendor hci to update
filter_duplicate_mode_enable(mode);
r_filter_duplicate_mode_enable(mode);
return true;
}
@ -616,19 +616,19 @@ int
ble_vhci_disc_duplicate_mode_disable(int mode)
{
// TODO: use vendor hci to update
filter_duplicate_mode_disable(mode);
r_filter_duplicate_mode_disable(mode);
return true;
}
int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size){
// TODO: use vendor hci to update
filter_duplicate_set_ring_list_max_num(max_cache_size);
r_filter_duplicate_set_ring_list_max_num(max_cache_size);
return true;
}
int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time){
// TODO: use vendor hci to update
scan_duplicate_cache_refresh_set_time(refresh_period_time);
r_scan_duplicate_cache_refresh_set_time(refresh_period_time);
return true;
}
@ -769,9 +769,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
buffers |= ESP_BLE_LOG_BUF_HCI;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
ret = r_ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
#else
ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
ret = r_ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
@ -809,7 +809,7 @@ free_controller:
controller_sleep_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
controller_init_err:
ble_log_deinit_async();
r_ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
os_msys_deinit();
ble_controller_deinit();
@ -843,7 +843,7 @@ esp_err_t esp_bt_controller_deinit(void)
modem_clock_module_disable(PERIPH_BT_MODULE);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_log_deinit_async();
r_ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();
@ -1163,7 +1163,7 @@ void esp_ble_controller_log_dump_all(bool output)
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_reconfigure_wdts(5000);
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
r_ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}