mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Add support in Nimble for ESP32H2
This commit is contained in:
parent
5963de1caf
commit
f376bb5d05
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -90,3 +90,7 @@
|
||||
[submodule "components/ieee802154/lib"]
|
||||
path = components/ieee802154/lib
|
||||
url = ../../espressif/esp-ieee802154-lib.git
|
||||
|
||||
[submodule "components/bt/controller/lib_esp32h2/esp32h2-bt-lib"]
|
||||
path = components/bt/controller/lib_esp32h2/esp32h2-bt-lib
|
||||
url = ../../espressif/esp32h2-bt-lib.git
|
||||
|
@ -36,6 +36,8 @@ __attribute__((weak)) void bootloader_clock_configure(void)
|
||||
DPORT_REG_GET_FIELD(DPORT_CPU_PER_CONF_REG, DPORT_CPUPERIOD_SEL) == DPORT_CPUPERIOD_SEL_240) {
|
||||
cpu_freq_mhz = 240;
|
||||
}
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
cpu_freq_mhz = 64;
|
||||
#endif
|
||||
|
||||
if (rtc_clk_apb_freq_get() < APB_CLK_FREQ || esp_rom_get_reset_reason(0) != RESET_REASON_CPU0_SW) {
|
||||
|
@ -7,6 +7,15 @@ if(CONFIG_BT_ENABLED)
|
||||
set(srcs "controller/esp32c3/bt.c")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
set(srcs "controller/esp32s3/bt.c")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
set(srcs "controller/esp32h2/bt.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_NIMBLE_USE_UART_HCI)
|
||||
set(srcs
|
||||
"porting/nimble/src/hal_uart.c"
|
||||
)
|
||||
else()
|
||||
endif()
|
||||
|
||||
set(include_dirs common/osi/include)
|
||||
@ -17,6 +26,8 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND include_dirs include/esp32c3/include)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
list(APPEND include_dirs include/esp32s3/include)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
list(APPEND include_dirs include/esp32h2/include)
|
||||
endif()
|
||||
|
||||
list(APPEND priv_include_dirs
|
||||
@ -462,6 +473,7 @@ if(CONFIG_BT_ENABLED)
|
||||
host/nimble/nimble/nimble/host/store/ram/include
|
||||
host/nimble/nimble/nimble/host/store/config/include
|
||||
host/nimble/nimble/porting/npl/freertos/include
|
||||
host/nimble/nimble/nimble/transport/ram/include
|
||||
host/nimble/esp-hci/include)
|
||||
|
||||
if(NOT CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
|
||||
@ -545,17 +557,34 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
|
||||
"host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c"
|
||||
"host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c"
|
||||
"host/nimble/nimble/porting/nimble/src/endian.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_cputime_pwr2.c"
|
||||
"host/nimble/nimble/porting/nimble/src/hal_timer.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mempool.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_msys_init.c"
|
||||
"host/nimble/nimble/porting/nimble/src/nimble_port.c"
|
||||
"host/nimble/nimble/porting/nimble/src/mem.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mbuf.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_cputime.c"
|
||||
"host/nimble/port/src/esp_nimble_mem.c"
|
||||
"host/nimble/esp-hci/src/esp_nimble_hci.c"
|
||||
"host/nimble/port/src/esp_nimble_mem.c")
|
||||
"host/nimble/nimble/porting/nimble/src/os_cputime.c")
|
||||
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/endian.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mempool.c"
|
||||
"host/nimble/nimble/porting/nimble/src/mem.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mbuf.c")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C3)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/endian.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mempool.c"
|
||||
"host/nimble/nimble/porting/nimble/src/mem.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mbuf.c")
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/endian.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mempool.c"
|
||||
"host/nimble/nimble/porting/nimble/src/mem.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mbuf.c")
|
||||
endif()
|
||||
|
||||
|
||||
list(APPEND srcs
|
||||
"common/btc/profile/esp/blufi/nimble_host/esp_blufi.c")
|
||||
@ -566,7 +595,8 @@ if(CONFIG_BT_ENABLED)
|
||||
if(CONFIG_BT_NIMBLE_MESH)
|
||||
|
||||
list(APPEND include_dirs
|
||||
host/nimble/nimble/nimble/host/mesh/include)
|
||||
host/nimble/nimble/nimble/host/mesh/include
|
||||
host/nimble/nimble/nimble/host/include/host)
|
||||
|
||||
list(APPEND srcs "host/nimble/nimble/nimble/host/mesh/src/shell.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/friend.c"
|
||||
@ -580,7 +610,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/mesh/src/transport.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/prov.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/mesh.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/nodes.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/access.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/cfg_srv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/cfg_cli.c"
|
||||
@ -590,8 +619,18 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/mesh/src/proxy.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/health_srv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/testing.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/aes-ccm.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/app_keys.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/cdb.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/cfg.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/pb_adv.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/pb_gatt.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/prov_device.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/provisioner.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/heartbeat.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/rpl.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/subnet.c"
|
||||
"host/nimble/nimble/nimble/host/mesh/src/net.c")
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -619,6 +658,20 @@ if(CONFIG_BT_ENABLED)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE
|
||||
"-L${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
|
||||
if(CONFIG_BT_NIMBLE_CONTROL_SEQUENCE_MODE_ENABLED)
|
||||
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/libcontroller_5p0_seq.a")
|
||||
else()
|
||||
if(CONFIG_BLE_50_FEATURE_SUPPORT)
|
||||
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/libcontroller_5p0.a")
|
||||
else()
|
||||
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/libcontroller_4p2.a")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE nimblelib)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
menu "Bluetooth"
|
||||
visible if (IDF_TARGET_ESP32 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
|
||||
visible if SOC_BT_SUPPORTED
|
||||
|
||||
config BT_ENABLED
|
||||
bool "Bluetooth"
|
||||
@ -21,7 +21,7 @@ menu "Bluetooth"
|
||||
|
||||
choice BT_HOST
|
||||
prompt "Bluetooth Host"
|
||||
depends on BT_ENABLED && (BTDM_CTRL_HCI_MODE_VHCI || BT_CTRL_HCI_MODE_VHCI)
|
||||
depends on BT_ENABLED
|
||||
default BT_BLUEDROID_ENABLED
|
||||
help
|
||||
This helps to choose Bluetooth host stack
|
||||
@ -47,7 +47,7 @@ menu "Bluetooth"
|
||||
endchoice
|
||||
|
||||
menu "Bluedroid Options"
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
depends on BT_BLUEDROID_ENABLED && SOC_BLUEDROID_SUPPORTED
|
||||
|
||||
source "$IDF_PATH/components/bt/host/bluedroid/Kconfig.in"
|
||||
endmenu
|
||||
|
629
components/bt/controller/esp32h2/bt.c
Normal file
629
components/bt/controller/esp32h2/bt.c
Normal file
@ -0,0 +1,629 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <esp_random.h>
|
||||
#include <esp_mac.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "os/os.h"
|
||||
#include "sysinit/sysinit.h"
|
||||
#include "nimble/nimble_port.h"
|
||||
#include "nimble/nimble_port_freertos.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_log.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#include "esp_coexist_internal.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
#include "transport/uart/ble_hci_uart.h"
|
||||
#else
|
||||
#include "transport/ram/ble_hci_ram.h"
|
||||
#endif
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
#include "esp_bt.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "hal/hal_uart.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "host/ble_hs.h"
|
||||
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
#define NIMBLE_PORT_LOG_TAG "BLE_INIT"
|
||||
#define OSI_COEX_VERSION 0x00010006
|
||||
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
struct osi_coex_funcs_t {
|
||||
uint32_t _magic;
|
||||
uint32_t _version;
|
||||
void (* _coex_wifi_sleep_set)(bool sleep);
|
||||
int (* _coex_core_ble_conn_dyn_prio_get)(bool *low, bool *high);
|
||||
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
|
||||
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
|
||||
};
|
||||
|
||||
struct ext_funcs_t {
|
||||
uint32_t ext_version;
|
||||
int (*_esp_intr_alloc)(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle);
|
||||
int (*_esp_intr_free)(void **ret_handle);
|
||||
void *(* _malloc)(size_t size);
|
||||
void (*_free)(void *p);
|
||||
void (*_hal_uart_start_tx)(int);
|
||||
int (*_hal_uart_init_cbs)(int, hal_uart_tx_char, hal_uart_tx_done, hal_uart_rx_char, void *);
|
||||
int (*_hal_uart_config)(int, int32_t, uint8_t, uint8_t, enum hal_uart_parity, enum hal_uart_flow_ctl);
|
||||
int (*_hal_uart_close)(int);
|
||||
void (*_hal_uart_blocking_tx)(int, uint8_t);
|
||||
int (*_hal_uart_init)(int, void *);
|
||||
int (* _task_create)(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id);
|
||||
void (* _task_delete)(void *task_handle);
|
||||
void (*_osi_assert)(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
|
||||
uint32_t (* _os_random)(void);
|
||||
uint32_t magic;
|
||||
};
|
||||
|
||||
struct ble_ll_trace_func_t {
|
||||
void (*_ble_ll_trace_u32_func)(uint32_t id, uint32_t p1);
|
||||
void (*_ble_ll_trace_u32x2_func)(uint32_t id, uint32_t p1, uint32_t p2);
|
||||
void (*_ble_ll_trace_u32x3_func)(uint32_t id, uint32_t p1, uint32_t p2, uint32_t p3);
|
||||
};
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
|
||||
extern int ble_plf_set_log_level(int level);
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high);
|
||||
extern int ble_controller_init(struct esp_bt_controller_config_t *cfg);
|
||||
extern int ble_controller_deinit(void);
|
||||
extern int ble_controller_enable(uint8_t mode);
|
||||
extern int ble_controller_disable(void);
|
||||
extern int esp_register_ext_funcs (struct ext_funcs_t *);
|
||||
extern void esp_unregister_ext_funcs (void);
|
||||
extern int esp_ble_ll_set_public_addr(const uint8_t *addr);
|
||||
extern int esp_register_npl_funcs (struct npl_funcs_t *p_npl_func);
|
||||
extern void esp_unregister_npl_funcs (void);
|
||||
extern void npl_freertos_mempool_deinit(void);
|
||||
extern void coex_pti_v2(void);
|
||||
extern void bt_bb_v2_init_cmplx(uint8_t i);
|
||||
extern int os_msys_buf_alloc(void);
|
||||
extern uint32_t r_os_cputime_get32(void);
|
||||
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
|
||||
extern void r_ble_ll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg, void *w_arg, uint32_t us_to_enabled);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_buf_free(void);
|
||||
extern void esp_ble_register_trace_funcs(struct ble_ll_trace_func_t *funcs);
|
||||
extern void bt_bb_set_le_tx_on_delay(uint32_t delay_us);
|
||||
|
||||
/* Local Function Declaration
|
||||
*********************************************************************
|
||||
*/
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
|
||||
static int task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id);
|
||||
static void task_delete_wrapper(void *task_handle);
|
||||
static void hal_uart_start_tx_wrapper(int uart_no);
|
||||
static int hal_uart_init_cbs_wrapper(int uart_no, hal_uart_tx_char tx_func,
|
||||
hal_uart_tx_done tx_done, hal_uart_rx_char rx_func, void *arg);
|
||||
static int hal_uart_config_wrapper(int uart_no, int32_t speed, uint8_t databits, uint8_t stopbits,
|
||||
enum hal_uart_parity parity, enum hal_uart_flow_ctl flow_ctl);
|
||||
static int hal_uart_close_wrapper(int uart_no);
|
||||
static void hal_uart_blocking_tx_wrapper(int port, uint8_t data);
|
||||
static int hal_uart_init_wrapper(int uart_no, void *cfg);
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in);
|
||||
static int esp_intr_free_wrapper(void **ret_handle);
|
||||
static void osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2);
|
||||
static uint32_t osi_random_wrapper(void);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
*/
|
||||
|
||||
/* Static variable declare */
|
||||
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
static bool s_is_sleep_state = false;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
uint32_t s_sleep_tick;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr = NULL;
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
|
||||
static bool s_pm_lock_acquired = true;
|
||||
static DRAM_ATTR bool s_btdm_allow_light_sleep;
|
||||
// pm_lock to prevent light sleep when using main crystal as Bluetooth low power clock
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
#define BTDM_MIN_TIMER_UNCERTAINTY_US (200)
|
||||
#endif /* #ifdef CONFIG_PM_ENABLE */
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
#define BLE_RTC_DELAY_US (1100)
|
||||
#else
|
||||
#define BLE_RTC_DELAY_US (0)
|
||||
#endif
|
||||
|
||||
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
|
||||
._magic = OSI_COEX_MAGIC_VALUE,
|
||||
._version = OSI_COEX_VERSION,
|
||||
._coex_wifi_sleep_set = NULL,
|
||||
._coex_core_ble_conn_dyn_prio_get = NULL,
|
||||
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
|
||||
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
|
||||
};
|
||||
|
||||
struct ext_funcs_t ext_funcs_ro = {
|
||||
.ext_version = 0xE0000001,
|
||||
._esp_intr_alloc = esp_intr_alloc_wrapper,
|
||||
._esp_intr_free = esp_intr_free_wrapper,
|
||||
._malloc = malloc,
|
||||
._free = free,
|
||||
._hal_uart_start_tx = hal_uart_start_tx_wrapper,
|
||||
._hal_uart_init_cbs = hal_uart_init_cbs_wrapper,
|
||||
._hal_uart_config = hal_uart_config_wrapper,
|
||||
._hal_uart_close = hal_uart_close_wrapper,
|
||||
._hal_uart_blocking_tx = hal_uart_blocking_tx_wrapper,
|
||||
._hal_uart_init = hal_uart_init_wrapper,
|
||||
._task_create = task_create_wrapper,
|
||||
._task_delete = task_delete_wrapper,
|
||||
._osi_assert = osi_assert_wrapper,
|
||||
._os_random = osi_random_wrapper,
|
||||
.magic = 0xA5A5A5A5,
|
||||
};
|
||||
|
||||
static void IRAM_ATTR osi_assert_wrapper(const uint32_t ln, const char *fn, uint32_t param1, uint32_t param2)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
static uint32_t IRAM_ATTR osi_random_wrapper(void)
|
||||
{
|
||||
return esp_random();
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int task_create_wrapper(void *task_func, const char *name, uint32_t stack_depth, void *param, uint32_t prio, void *task_handle, uint32_t core_id)
|
||||
{
|
||||
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < portNUM_PROCESSORS ? core_id : tskNO_AFFINITY));
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
{
|
||||
vTaskDelete(task_handle);
|
||||
}
|
||||
|
||||
static void hal_uart_start_tx_wrapper(int uart_no)
|
||||
{
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
hal_uart_start_tx(uart_no);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int hal_uart_init_cbs_wrapper(int uart_no, hal_uart_tx_char tx_func,
|
||||
hal_uart_tx_done tx_done, hal_uart_rx_char rx_func, void *arg)
|
||||
{
|
||||
int rc = -1;
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
rc = hal_uart_init_cbs(uart_no, tx_func, tx_done, rx_func, arg);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int hal_uart_config_wrapper(int uart_no, int32_t speed, uint8_t databits, uint8_t stopbits,
|
||||
enum hal_uart_parity parity, enum hal_uart_flow_ctl flow_ctl)
|
||||
{
|
||||
int rc = -1;
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
rc = hal_uart_config(uart_no, speed, databits, stopbits, parity, flow_ctl);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int hal_uart_close_wrapper(int uart_no)
|
||||
{
|
||||
int rc = -1;
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
rc = hal_uart_close(uart_no);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void hal_uart_blocking_tx_wrapper(int port, uint8_t data)
|
||||
{
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
hal_uart_blocking_tx(port, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int hal_uart_init_wrapper(int uart_no, void *cfg)
|
||||
{
|
||||
int rc = -1;
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
rc = hal_uart_init(uart_no, cfg);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int esp_intr_alloc_wrapper(int source, int flags, intr_handler_t handler, void *arg, void **ret_handle_in)
|
||||
{
|
||||
int rc = esp_intr_alloc(source, flags, handler, arg, (intr_handle_t *)ret_handle_in);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int esp_intr_free_wrapper(void **ret_handle)
|
||||
{
|
||||
int rc = 0;
|
||||
rc = esp_intr_free((intr_handle_t) * ret_handle);
|
||||
*ret_handle = NULL;
|
||||
return rc;
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
|
||||
{
|
||||
if (s_is_sleep_state) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "sleep state error");
|
||||
assert(0);
|
||||
}
|
||||
s_is_sleep_state = true;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
uint32_t tick_invalid = *(uint32_t *)(arg);
|
||||
if (!tick_invalid) {
|
||||
s_sleep_tick = r_os_cputime_get32();
|
||||
assert(enable_tick >= s_sleep_tick);
|
||||
// start a timer to wake up and acquire the pm_lock before modem_sleep awakes
|
||||
uint32_t us_to_sleep = os_cputime_ticks_to_usecs(enable_tick - s_sleep_tick);
|
||||
assert(us_to_sleep > BTDM_MIN_TIMER_UNCERTAINTY_US);
|
||||
if (esp_timer_start_once(s_btdm_slp_tmr, us_to_sleep - BTDM_MIN_TIMER_UNCERTAINTY_US) != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "timer start failed");
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_pm_lock_acquired) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
s_pm_lock_acquired = false;
|
||||
}
|
||||
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
{
|
||||
if (!s_is_sleep_state) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "wake up state error");
|
||||
assert(0);
|
||||
}
|
||||
s_is_sleep_state = false;
|
||||
|
||||
// need to check if need to call pm lock here
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_pm_lock_acquired) {
|
||||
s_pm_lock_acquired = true;
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
}
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_TIMER) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "wake up source %d", esp_sleep_get_wakeup_cause());
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
if (esp_sleep_get_wakeup_cause() != ESP_SLEEP_WAKEUP_BT) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "wake up source %d", esp_sleep_get_wakeup_cause());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
static void btdm_slp_tmr_callback(void *arg)
|
||||
{
|
||||
(void)(arg);
|
||||
if (!s_pm_lock_acquired) {
|
||||
s_pm_lock_acquired = true;
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
void controller_sleep_init(void)
|
||||
{
|
||||
|
||||
#ifdef CONFIG_NIMBLE_SLEEP_ENABLE
|
||||
s_is_sleep_state = false;
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = true;
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
|
||||
// register sleep callbacks
|
||||
r_ble_ll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0, 500 + BLE_RTC_DELAY_US);
|
||||
#else
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = false;
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
#endif // CONFIG_NIMBLE_SLEEP_ENABLE
|
||||
|
||||
// enable light sleep
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if (esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btnosleep", &s_light_sleep_pm_lock) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp"
|
||||
};
|
||||
if ( esp_timer_create(&create_args, &s_btdm_slp_tmr) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "light sleep enable success, CPU RTC timer wake up");
|
||||
#endif //CONFIG_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_enable_bt_wakeup();
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "light sleep enable success, BLE RTC timer wake up");
|
||||
#endif // CONFIG_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
|
||||
s_pm_lock_acquired = true;
|
||||
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_acquire(s_light_sleep_pm_lock);
|
||||
}
|
||||
if (s_pm_lock) {
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
}
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_btdm_slp_tmr != NULL) {
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
#endif // CONFIG_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
esp_sleep_disable_bt_wakeup();
|
||||
#endif // CONFIG_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void controller_sleep_deinit(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
}
|
||||
#ifdef CONFIG_BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
if (s_btdm_slp_tmr != NULL) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
#endif
|
||||
s_pm_lock_acquired = false;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(struct esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (cfg == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (esp_register_ext_funcs(&ext_funcs_ro) != 0) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Initialize the function pointers for OS porting */
|
||||
npl_freertos_funcs_init();
|
||||
|
||||
struct npl_funcs_t *p_npl_funcs = npl_freertos_funcs_get();
|
||||
if (!p_npl_funcs) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl functions get failed");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (esp_register_npl_funcs(p_npl_funcs) != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl functions register failed");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (npl_freertos_mempool_init() != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl mempool init failed");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Initialize the global memory pool */
|
||||
if (os_msys_buf_alloc() != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "os msys alloc failed");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
os_msys_init();
|
||||
|
||||
// ble_npl_eventq_init() need to use npl function in rom and must be called after esp_bt_controller_init()
|
||||
/* Initialize default event queue */
|
||||
ble_npl_eventq_init(nimble_port_get_dflt_eventq());
|
||||
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
|
||||
// init phy
|
||||
esp_phy_enable();
|
||||
|
||||
// set bb delay
|
||||
bt_bb_set_le_tx_on_delay(50);
|
||||
|
||||
if (ble_osi_coex_funcs_register((struct osi_coex_funcs_t *)&s_osi_coex_funcs_ro) != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "osi coex funcs reg failed");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif
|
||||
|
||||
if (ble_controller_init(cfg) != 0) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
controller_sleep_init();
|
||||
|
||||
uint8_t mac[6];
|
||||
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
||||
|
||||
swap_in_place(mac, 6);
|
||||
|
||||
esp_ble_ll_set_public_addr(mac);
|
||||
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_deinit(void)
|
||||
{
|
||||
if ((ble_controller_status < ESP_BT_CONTROLLER_STATUS_INITED) || (ble_controller_status >= ESP_BT_CONTROLLER_STATUS_ENABLED)) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
controller_sleep_deinit();
|
||||
|
||||
if (ble_controller_deinit() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* De-initialize default event queue */
|
||||
ble_npl_eventq_deinit(nimble_port_get_dflt_eventq());
|
||||
|
||||
os_msys_buf_free();
|
||||
|
||||
esp_unregister_npl_funcs();
|
||||
|
||||
esp_unregister_ext_funcs();
|
||||
|
||||
/* De-initialize npl functions */
|
||||
npl_freertos_funcs_deinit();
|
||||
|
||||
npl_freertos_mempool_deinit();
|
||||
|
||||
esp_phy_disable();
|
||||
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
if (mode != ESP_BT_MODE_BLE) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller mode");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_INITED) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (ble_controller_enable(mode) != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_disable(void)
|
||||
{
|
||||
if (ble_controller_status < ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "%s not implemented, return OK", __func__);
|
||||
return ESP_OK;
|
||||
}
|
@ -0,0 +1 @@
|
||||
Subproject commit b595381e3cb4cb4b34cbf9f0b18256553d0dea66
|
@ -1,3 +1,32 @@
|
||||
config BT_NIMBLE_CONTROLLER_ENABLED
|
||||
bool "Enable NimBLE controller"
|
||||
depends on BT_NIMBLE_ENABLED && IDF_TARGET_ESP32H2
|
||||
default y
|
||||
help
|
||||
Enable or Disable NimBLE controller
|
||||
|
||||
config BT_NIMBLE_CONTROL_SEQUENCE_MODE_ENABLED
|
||||
bool "Enable controller in sequence mode"
|
||||
depends on BT_NIMBLE_CONTROLLER_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable or Disable controller sequence mode
|
||||
|
||||
choice
|
||||
prompt "Select HCI interface"
|
||||
depends on BT_NIMBLE_ENABLED && IDF_TARGET_ESP32H2
|
||||
default BT_NIMBLE_CONTROL_USE_RAM_HCI
|
||||
|
||||
config BT_NIMBLE_CONTROL_USE_RAM_HCI
|
||||
bool "ram"
|
||||
help
|
||||
Use RAM as HCI interface
|
||||
config BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
bool "uart"
|
||||
help
|
||||
Use UART as HCI interface
|
||||
endchoice
|
||||
|
||||
|
||||
choice BT_NIMBLE_MEM_ALLOC_MODE
|
||||
prompt "Memory allocation strategy"
|
||||
@ -62,9 +91,53 @@ config BT_NIMBLE_LOG_LEVEL
|
||||
default 3 if BT_NIMBLE_LOG_LEVEL_ERROR
|
||||
default 4 if BT_NIMBLE_LOG_LEVEL_NONE
|
||||
|
||||
|
||||
config BT_NIMBLE_HCI_UART_PORT
|
||||
int "HCI UART port"
|
||||
depends on BT_NIMBLE_USE_UART_HCI
|
||||
default 1
|
||||
help
|
||||
Set the port number of HCI UART
|
||||
|
||||
config BT_NIMBLE_HCI_UART_TX_PIN
|
||||
int "HCI uart Tx gpio"
|
||||
depends on BT_NIMBLE_USE_UART_HCI
|
||||
default 19
|
||||
|
||||
config BT_NIMBLE_HCI_UART_RX_PIN
|
||||
int "HCI uart Rx gpio"
|
||||
depends on BT_NIMBLE_USE_UART_HCI
|
||||
default 10
|
||||
|
||||
config BT_NIMBLE_HCI_UART_TASK_STACK_SIZE
|
||||
int "HCI uart task stack size"
|
||||
depends on BT_NIMBLE_USE_UART_HCI
|
||||
default 1000
|
||||
help
|
||||
Set the size of uart task stack
|
||||
|
||||
config BT_NIMBLE_HCI_UART_BAUD
|
||||
int "HCI uart baudrate"
|
||||
depends on BT_NIMBLE_USE_UART_HCI
|
||||
default 921600
|
||||
help
|
||||
HCI uart baud rate 115200 ~ 1000000
|
||||
|
||||
config BT_NIMBLE_RUN_QA_TEST
|
||||
bool "Run QA test"
|
||||
default y
|
||||
help
|
||||
Enable this option to run QA test.
|
||||
|
||||
config BT_NIMBLE_RUN_BQB_TEST
|
||||
bool "Run BQB test"
|
||||
default n
|
||||
help
|
||||
Enable this option to run BQB test.
|
||||
|
||||
config BT_NIMBLE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
range 1 8 if (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
|
||||
range 1 8 if (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32H2)
|
||||
range 1 9 if IDF_TARGET_ESP32
|
||||
default 3
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
@ -117,7 +190,7 @@ config BT_NIMBLE_PINNED_TO_CORE
|
||||
default 1 if BT_NIMBLE_PINNED_TO_CORE_1
|
||||
default 0
|
||||
|
||||
config BT_NIMBLE_TASK_STACK_SIZE
|
||||
config BT_NIMBLE_HOST_TASK_STACK_SIZE
|
||||
int "NimBLE Host task stack size"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default 5120 if BLE_MESH
|
||||
@ -129,39 +202,69 @@ config BT_NIMBLE_ROLE_CENTRAL
|
||||
bool "Enable BLE Central role"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enables central role
|
||||
|
||||
config BT_NIMBLE_ROLE_PERIPHERAL
|
||||
bool "Enable BLE Peripheral role"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable peripheral role
|
||||
|
||||
config BT_NIMBLE_ROLE_BROADCASTER
|
||||
bool "Enable BLE Broadcaster role"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enables broadcaster role
|
||||
|
||||
config BT_NIMBLE_ROLE_OBSERVER
|
||||
bool "Enable BLE Observer role"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enables observer role
|
||||
|
||||
config BT_NIMBLE_CONTROLLER_TASK_STACK_SIZE
|
||||
int "NimBLE Controller task stack size"
|
||||
depends on BT_NIMBLE_ENABLED && IDF_TARGET_ESP32H2
|
||||
default 5120 if BLE_MESH
|
||||
default 4096
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
config BT_NIMBLE_CONTROLLER_TASK_PRIORITY
|
||||
int "NimBLE Controller task priority"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default 23
|
||||
help
|
||||
This configures priority of NimBLE controller task
|
||||
|
||||
config BT_NIMBLE_NVS_PERSIST
|
||||
bool "Persist the BLE Bonding keys in NVS"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
default n
|
||||
help
|
||||
Enable this flag to make bonding persistent across device reboots
|
||||
|
||||
menuconfig BT_NIMBLE_SECURITY_ENABLE
|
||||
bool "Enable BLE SM feature"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable BLE sm feature
|
||||
|
||||
config BT_NIMBLE_SM_LEGACY
|
||||
bool "Security manager legacy pairing"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
depends on BT_NIMBLE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable security manager legacy pairing
|
||||
|
||||
config BT_NIMBLE_SM_SC
|
||||
bool "Security manager secure connections (4.2)"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
depends on BT_NIMBLE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable security manager secure connections
|
||||
@ -173,6 +276,14 @@ config BT_NIMBLE_DEBUG
|
||||
help
|
||||
This enables extra runtime asserts and host debugging
|
||||
|
||||
|
||||
config BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION
|
||||
bool "Enable LE encryption"
|
||||
depends on BT_NIMBLE_SECURITY_ENABLE && BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable encryption connection
|
||||
|
||||
config BT_NIMBLE_SM_SC_DEBUG_KEYS
|
||||
bool "Use predefined public-private key pair"
|
||||
default n
|
||||
@ -200,7 +311,7 @@ config BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN
|
||||
config BT_NIMBLE_ATT_PREFERRED_MTU
|
||||
int "Preferred MTU size in octets"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default 256
|
||||
default 512
|
||||
help
|
||||
This is the default value of ATT MTU indicated by the device during an ATT MTU exchange.
|
||||
This value can be changed using API ble_att_set_preferred_mtu()
|
||||
@ -215,14 +326,14 @@ config BT_NIMBLE_SVC_GAP_APPEARANCE
|
||||
config BT_NIMBLE_ACL_BUF_COUNT
|
||||
int "ACL Buffer count"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default 20
|
||||
default 24
|
||||
help
|
||||
The number of ACL data buffers.
|
||||
|
||||
config BT_NIMBLE_ACL_BUF_SIZE
|
||||
int "ACL Buffer size"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default 255
|
||||
default 251
|
||||
help
|
||||
This is the maximum size of the data portion of HCI ACL data packets.
|
||||
It does not include the HCI data header (of 4 bytes)
|
||||
@ -257,9 +368,15 @@ config BT_NIMBLE_HCI_EVT_LO_BUF_COUNT
|
||||
low-priority event buffers, then an incoming advertising report will
|
||||
get dropped
|
||||
|
||||
config BT_NIMBLE_MSYS1_BLOCK_COUNT
|
||||
menuconfig BT_NIMBLE_MEMORY_SETTINGS
|
||||
bool "OS Memory Settings"
|
||||
default y
|
||||
help
|
||||
Settings memory blocks
|
||||
|
||||
config BT_NIMBLE_MSYS_1_BLOCK_COUNT
|
||||
int "MSYS_1 Block Count"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
depends on BT_NIMBLE_MEMORY_SETTINGS
|
||||
default 12
|
||||
help
|
||||
MSYS is a system level mbuf registry. For prepare write & prepare
|
||||
@ -267,6 +384,27 @@ config BT_NIMBLE_MSYS1_BLOCK_COUNT
|
||||
enabled cases, this block count is increased by 8 than user defined
|
||||
count.
|
||||
|
||||
config BT_NIMBLE_MSYS_1_BLOCK_SIZE
|
||||
int "MSYS_1 Block Size"
|
||||
depends on BT_NIMBLE_MEMORY_SETTINGS
|
||||
default 256
|
||||
help
|
||||
Dynamic memory size of block 1
|
||||
|
||||
config BT_NIMBLE_MSYS_2_BLOCK_COUNT
|
||||
int "MSYS_2 Block Count"
|
||||
depends on BT_NIMBLE_MEMORY_SETTINGS
|
||||
default 24
|
||||
help
|
||||
Dynamic memory count
|
||||
|
||||
config BT_NIMBLE_MSYS_2_BLOCK_SIZE
|
||||
int "MSYS_2 Block Size"
|
||||
depends on BT_NIMBLE_MEMORY_SETTINGS
|
||||
default 320
|
||||
help
|
||||
Dynamic memory size of block 2
|
||||
|
||||
config BT_NIMBLE_HS_FLOW_CTRL
|
||||
bool "Enable Host Flow control"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
@ -429,7 +567,7 @@ config BT_NIMBLE_HOST_BASED_PRIVACY
|
||||
|
||||
config BT_NIMBLE_ENABLE_CONN_REATTEMPT
|
||||
bool "Enable connection reattempts on connection establishment error"
|
||||
default y if (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
|
||||
default y if (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32H2 )
|
||||
default n if IDF_TARGET_ESP32
|
||||
help
|
||||
Enable to make the NimBLE host to reattempt GAP connection on connection
|
||||
@ -443,14 +581,66 @@ config BT_NIMBLE_MAX_CONN_REATTEMPT
|
||||
help
|
||||
Defines maximum number of connection reattempts.
|
||||
|
||||
menuconfig BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
bool "Enable BLE v5.0 feature"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable BLE v5.0 feature
|
||||
|
||||
|
||||
config BT_NIMBLE_EXT_ADV
|
||||
bool "Enable extended advertising."
|
||||
bool "Enable extended advertising"
|
||||
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
default n
|
||||
depends on BT_NIMBLE_ENABLED && BT_SOC_SUPPORT_5_0
|
||||
help
|
||||
Enable this option to do extended advertising. Extended advertising
|
||||
will be supported from BLE 5.0 onwards.
|
||||
|
||||
if BT_NIMBLE_EXT_ADV
|
||||
config BT_NIMBLE_EXT_ADV_MAX_SIZE
|
||||
int "set ext adv maximum paket size"
|
||||
depends on BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
default 1650
|
||||
help
|
||||
Ext ADV packet size
|
||||
endif
|
||||
|
||||
choice BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on ESP32_WIFI_SW_COEXIST_ENABLE && BT_NIMBLE_ENABLED
|
||||
help
|
||||
When using PHY-Coded in BLE connection, limitation on max tx/rx time can be applied to
|
||||
better avoid dramatic performance deterioration of Wi-Fi.
|
||||
|
||||
config BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
bool "Force Enable"
|
||||
help
|
||||
Always enable the limitation on max tx/rx time for Coded-PHY connection
|
||||
|
||||
config BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
bool "Force Disable"
|
||||
help
|
||||
Disable the limitation on max tx/rx time for Coded-PHY connection
|
||||
endchoice
|
||||
|
||||
config BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
default 0 if !(ESP32_WIFI_SW_COEXIST_ENABLE && BT_NIMBLE_ENABLED)
|
||||
default 1 if BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
|
||||
config BT_NIMBLE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
range 1 15
|
||||
default 12
|
||||
help
|
||||
BLE list size
|
||||
|
||||
|
||||
config BT_NIMBLE_MAX_EXT_ADV_INSTANCES
|
||||
int "Maximum number of extended advertising instances."
|
||||
range 0 4
|
||||
@ -480,6 +670,14 @@ config BT_NIMBLE_ENABLE_PERIODIC_ADV
|
||||
help
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
depends on BT_NIMBLE_EXT_ADV
|
||||
default y
|
||||
help
|
||||
This enables controller transfer periodic sync events to host
|
||||
|
||||
|
||||
config BT_NIMBLE_MAX_PERIODIC_SYNCS
|
||||
int "Maximum number of periodic advertising syncs."
|
||||
default 1 if BT_NIMBLE_ENABLE_PERIODIC_ADV
|
||||
@ -491,6 +689,68 @@ config BT_NIMBLE_MAX_PERIODIC_SYNCS
|
||||
connections. This should be less than maximum connections allowed by
|
||||
controller.
|
||||
|
||||
config BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY
|
||||
bool "Enable 2M Phy"
|
||||
depends on BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable 2M-PHY
|
||||
|
||||
config BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
bool "Enable coded Phy"
|
||||
depends on BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable coded-PHY
|
||||
|
||||
config BT_NIMBLE_HARDWARE_BLE_ONLY
|
||||
bool "Run example on Ble Only Hardware"
|
||||
default y
|
||||
help
|
||||
Run example on Ble Only Hardware
|
||||
|
||||
config BT_NIMBLE_TEST_THROUGHPUT_TEST
|
||||
bool "Throughput Test Mode enable"
|
||||
default n
|
||||
help
|
||||
Enable the throughput test mode
|
||||
|
||||
|
||||
config BT_NIMBLE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
default 4
|
||||
help
|
||||
Configure the size of resolving list used in link layer.
|
||||
|
||||
config BT_NIMBLE_LL_DUP_SCAN_LIST_COUNT
|
||||
int "BLE duplicate scan list count"
|
||||
range 1 100
|
||||
default 8
|
||||
help
|
||||
config the max count of duplicate scan list
|
||||
|
||||
config BT_NIMBLE_SLEEP_ENABLE
|
||||
bool "Enable BLE sleep"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice
|
||||
prompt "BLE light sleep wakeup source"
|
||||
depends on BT_NIMBLE_SLEEP_ENABLE
|
||||
default BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
config BT_NIMBLE_WAKEUP_SOURCE_CPU_RTC_TIMER
|
||||
bool "Use CPU rtc timer to wakeup CPU"
|
||||
help
|
||||
Use CPU rtc timer to wakeup CPU
|
||||
|
||||
config BT_NIMBLE_WAKEUP_SOURCE_BLE_RTC_TIMER
|
||||
bool "Use BLE rtc timer to wakeup CPU"
|
||||
help
|
||||
Use BLE rtc timer to wakeup CPU
|
||||
endchoice
|
||||
|
||||
config BT_NIMBLE_BLUFI_ENABLE
|
||||
bool "Enable blufi functionality"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -15,6 +15,21 @@
|
||||
#include "esp_bt.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
|
||||
/* For Chips not using VHCI, these functions return success */
|
||||
esp_err_t esp_nimble_hci_and_controller_init(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_nimble_hci_and_controller_deinit(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
#else
|
||||
|
||||
#define NIMBLE_VHCI_TIMEOUT_MS 2000
|
||||
#define BLE_HCI_EVENT_HDR_LEN (2)
|
||||
@ -519,3 +534,4 @@ esp_err_t esp_nimble_hci_and_controller_deinit(void)
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif // #if SOC_ESP_NIMBLE_CONTROLLER
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit e6cc38908c58a5d3590bff96a2904fc70d746346
|
||||
Subproject commit 517374e64880d0659a358588d2aba7b109eb7738
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -15,104 +15,174 @@
|
||||
* attempt to use these macros without including this header will result in a
|
||||
* compiler error.
|
||||
*/
|
||||
#define MYNEWT_VAL(x) MYNEWT_VAL_ ## x
|
||||
#define MYNEWT_VAL(_name) MYNEWT_VAL_ ## _name
|
||||
#define MYNEWT_VAL_CHOICE(_name, _val) MYNEWT_VAL_ ## _name ## __ ## _val
|
||||
|
||||
#ifndef IRAM_ATTR_64MCPU
|
||||
#define IRAM_ATTR_64MCPU IRAM_ATTR
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_RUN_QA_TEST
|
||||
#define RUN_QA_TEST_N (CONFIG_BT_NIMBLE_RUN_QA_TEST)
|
||||
#else
|
||||
#define RUN_QA_TEST_N (0)
|
||||
#endif
|
||||
|
||||
#define BLE_LL_CTRL_PROC_TIMEOUT_MS_N (40000) /* ms */
|
||||
|
||||
#define BLE_LL_CFG_NUM_HCI_CMD_PKTS_N (1)
|
||||
|
||||
#define BLE_LL_SCHED_ADV_MAX_USECS_N (852)
|
||||
|
||||
#define BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N (502)
|
||||
|
||||
#define BLE_LL_SCHED_MAX_ADV_PDU_USECS_N (376)
|
||||
|
||||
#define BLE_LL_SUB_VERS_NR_N (0x0000)
|
||||
|
||||
#define BLE_LL_JITTER_USECS_N (16)
|
||||
|
||||
#define BLE_PHY_MAX_PWR_DBM_N (10)
|
||||
|
||||
#define BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N (3000)
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32H2
|
||||
#define RTC_FREQ_N (32768) /* in Hz */
|
||||
#else
|
||||
#define RTC_FREQ_N (32000) /* in Hz */
|
||||
#endif
|
||||
|
||||
#define BLE_LL_TX_PWR_DBM_N (0)
|
||||
|
||||
#define BLE_LL_SYNC_CNT_N (7)
|
||||
|
||||
#define BLE_LL_SYNC_LIST_CNT_N (7)
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_CONTROLLER_ENABLED
|
||||
#define NIMBLE_CFG_CONTROLLER 0
|
||||
#else
|
||||
#define NIMBLE_CFG_CONTROLLER CONFIG_BT_NIMBLE_CONTROLLER_ENABLED
|
||||
#endif
|
||||
|
||||
/*** kernel/os */
|
||||
#ifndef MYNEWT_VAL_MSYS_1_BLOCK_COUNT
|
||||
#ifdef CONFIG_BT_NIMBLE_MESH
|
||||
#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT + 8)
|
||||
#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT (CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT + 8)
|
||||
#else
|
||||
#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT
|
||||
#define MYNEWT_VAL_MSYS_1_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_MSYS_1_BLOCK_SIZE
|
||||
#define MYNEWT_VAL_MSYS_1_BLOCK_SIZE (292)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_MSYS_1_SANITY_MIN_COUNT
|
||||
#define MYNEWT_VAL_MSYS_1_SANITY_MIN_COUNT (0)
|
||||
#define MYNEWT_VAL_MSYS_1_BLOCK_SIZE CONFIG_BT_NIMBLE_MSYS_1_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_MSYS_2_BLOCK_COUNT
|
||||
#define MYNEWT_VAL_MSYS_2_BLOCK_COUNT (0)
|
||||
#define MYNEWT_VAL_MSYS_2_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS_2_BLOCK_COUNT
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_MSYS_2_BLOCK_SIZE
|
||||
#define MYNEWT_VAL_MSYS_2_BLOCK_SIZE (0)
|
||||
#define MYNEWT_VAL_MSYS_2_BLOCK_SIZE CONFIG_BT_NIMBLE_MSYS_2_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_OS_CPUTIME_FREQ
|
||||
#define MYNEWT_VAL_OS_CPUTIME_FREQ (1000000)
|
||||
//#define MYNEWT_VAL_OS_CPUTIME_FREQ (1000000)
|
||||
#define MYNEWT_VAL_OS_CPUTIME_FREQ (32000)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_OS_CPUTIME_TIMER_NUM
|
||||
#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (0)
|
||||
#define MYNEWT_VAL_OS_CPUTIME_TIMER_NUM (5)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_TIMER_5
|
||||
#define MYNEWT_VAL_TIMER_5 1
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_LOG_LVL
|
||||
#define MYNEWT_VAL_BLE_HS_LOG_LVL CONFIG_BT_NIMBLE_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_NEWT_FEATURE_LOGCFG
|
||||
#define MYNEWT_VAL_NEWT_FEATURE_LOGCFG 1
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_OS_TICKS_PER_SEC
|
||||
#define MYNEWT_VAL_OS_TICKS_PER_SEC (100)
|
||||
#endif
|
||||
|
||||
/*** nimble */
|
||||
#ifndef MYNEWT_VAL_BLE_EXT_ADV
|
||||
#ifndef CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
#define BLE_50_FEATURE_SUPPORT (0)
|
||||
#else
|
||||
#define BLE_50_FEATURE_SUPPORT (CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_EXT_ADV
|
||||
#define MYNEWT_VAL_BLE_EXT_ADV (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_EXT_ADV (CONFIG_BT_NIMBLE_EXT_ADV)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE
|
||||
#ifdef CONFIG_BT_NIMBLE_EXT_ADV
|
||||
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN)
|
||||
#ifndef CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE
|
||||
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (31)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (0)
|
||||
#endif
|
||||
#define MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE (CONFIG_BT_NIMBLE_EXT_ADV_MAX_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MAX_CONNECTIONS
|
||||
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS CONFIG_BT_NIMBLE_MAX_CONNECTIONS
|
||||
#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
|
||||
#define BLE_SCAN_RSP_DATA_MAX_LEN_N (1650)
|
||||
#else
|
||||
/* In this case the value will be overwritten by 31 in controller. */
|
||||
#define BLE_SCAN_RSP_DATA_MAX_LEN_N (MYNEWT_VAL_BLE_EXT_ADV_MAX_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES
|
||||
#ifdef CONFIG_BT_NIMBLE_EXT_ADV
|
||||
#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS
|
||||
#ifdef CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV
|
||||
#define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS)
|
||||
#else
|
||||
#ifndef CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS
|
||||
#define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (0)
|
||||
#endif
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS (CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ROLE_BROADCASTER
|
||||
#ifdef CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES
|
||||
#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NIMBLE_MAX_CONNECTIONS
|
||||
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (4)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_MAX_CONNECTIONS (CONFIG_NIMBLE_MAX_CONNECTIONS)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||
#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (0)
|
||||
#endif
|
||||
#define MYNEWT_VAL_BLE_ROLE_BROADCASTER (CONFIG_BT_NIMBLE_ROLE_BROADCASTER)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ROLE_CENTRAL
|
||||
#ifdef CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||
#ifndef CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||
#define MYNEWT_VAL_BLE_ROLE_CENTRAL (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_ROLE_CENTRAL (0)
|
||||
#endif
|
||||
#define MYNEWT_VAL_BLE_ROLE_CENTRAL (CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ROLE_OBSERVER
|
||||
#ifdef CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||
#ifndef CONFIG_BT_NIMBLE_ROLE_OBSERVER
|
||||
#define MYNEWT_VAL_BLE_ROLE_OBSERVER (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_ROLE_OBSERVER (0)
|
||||
#endif
|
||||
#define MYNEWT_VAL_BLE_ROLE_OBSERVER (CONFIG_BT_NIMBLE_ROLE_OBSERVER)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ROLE_PERIPHERAL
|
||||
#ifdef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||
#ifndef CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||
#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (0)
|
||||
#endif
|
||||
#define MYNEWT_VAL_BLE_ROLE_PERIPHERAL (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_WHITELIST
|
||||
@ -120,13 +190,17 @@
|
||||
#endif
|
||||
|
||||
/*** @apache-mynewt-nimble/nimble/controller */
|
||||
#ifndef MYNEWT_VAL_BLE_DEVICE
|
||||
#define MYNEWT_VAL_BLE_DEVICE (0)
|
||||
/*** @apache-mynewt-nimble/nimble/controller */
|
||||
#ifndef MYNEWT_VAL_BLE_CONTROLLER
|
||||
#if CONFIG_IDF_TARGET_ESP32H2
|
||||
#define MYNEWT_VAL_BLE_CONTROLLER (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_CONTROLLER (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Overridden by @apache-mynewt-nimble/nimble/controller (defined by @apache-mynewt-nimble/nimble/controller) */
|
||||
#ifndef MYNEWT_VAL_BLE_HW_WHITELIST_ENABLE
|
||||
#define MYNEWT_VAL_BLE_HW_WHITELIST_ENABLE (0)
|
||||
#ifndef MYNEWT_VAL_BLE_VERSION
|
||||
#define MYNEWT_VAL_BLE_VERSION (50)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_ADD_STRICT_SCHED_PERIODS
|
||||
@ -145,12 +219,127 @@
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_EXT_SCAN_FILT (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_2M_PHY
|
||||
#ifndef CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_2M_PHY (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_2M_PHY (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_2M_PHY)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
#ifndef CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CODED_PHY (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CODED_PHY (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CSA2
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_CSA2 (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_ADDRESS_END_PIN
|
||||
#define MYNEWT_VAL_BLE_PHY_DBG_TIME_ADDRESS_END_PIN (-1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_TXRXEN_READY_PIN
|
||||
#define MYNEWT_VAL_BLE_PHY_DBG_TIME_TXRXEN_READY_PIN (-1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_PHY_DBG_TIME_WFR_PIN
|
||||
#define MYNEWT_VAL_BLE_PHY_DBG_TIME_WFR_PIN (-1)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_DEVICE
|
||||
#define MYNEWT_VAL_BLE_DEVICE (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_SLAVE_INIT_FEAT_XCHG (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES
|
||||
#define MYNEWT_VAL_BLE_LL_CONN_INIT_MAX_TX_BYTES (27)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_MIN_WIN_OFFSET
|
||||
#define MYNEWT_VAL_BLE_LL_CONN_INIT_MIN_WIN_OFFSET (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS
|
||||
#define MYNEWT_VAL_BLE_LL_CONN_INIT_SLOTS (4)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN
|
||||
#define MYNEWT_VAL_BLE_LL_DBG_HCI_CMD_PIN (-1)
|
||||
#endif
|
||||
|
||||
/* Overridden by @apache-mynewt-nimble/nimble/controller (defined by @apache-mynewt-nimble/nimble/controller) */
|
||||
#ifndef CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION (CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_PING
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_PING (MYNEWT_VAL_BLE_LL_CFG_FEAT_LE_ENCRYPTION)
|
||||
#endif
|
||||
|
||||
/* Value copied from BLE_LL_OUR_SCA */
|
||||
#ifndef MYNEWT_VAL_BLE_LL_SCA
|
||||
#define MYNEWT_VAL_BLE_LL_SCA (60)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_ADD_STRICT_SCHED_PERIODS
|
||||
#define MYNEWT_VAL_BLE_LL_ADD_STRICT_SCHED_PERIODS (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_CONN_PARAM_REQ
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_CONN_PARAM_REQ (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_EXT_SCAN_FILT
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_EXT_SCAN_FILT (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_STRICT_CONN_SCHEDULING
|
||||
#define MYNEWT_VAL_BLE_LL_STRICT_CONN_SCHEDULING (0)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_HCI_UART_BAUD
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_BAUD (115200)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_BAUD (CONFIG_BT_NIMBLE_HCI_UART_BAUD)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_UART_DATA_BITS
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_DATA_BITS (8)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_UART_FLOW_CTRL
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_FLOW_CTRL (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_FLOW_CTRL (CONFIG_UART_FLOW_CTRL)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_UART_PARITY
|
||||
#if CONFIG_IDF_TARGET_ESP32H2
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_PARITY 0
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_PARITY (HAL_UART_PARITY_NONE)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_HCI_UART_PORT
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_PORT (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_PORT (CONFIG_BT_NIMBLE_HCI_UART_PORT)
|
||||
#endif
|
||||
|
||||
/* Overridden by @apache-mynewt-nimble/nimble/controller (defined by @apache-mynewt-nimble/nimble/controller) */
|
||||
@ -170,6 +359,35 @@
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV (MYNEWT_VAL_BLE_EXT_ADV)
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_EXT_ADV
|
||||
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
|
||||
#else
|
||||
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
|
||||
#endif
|
||||
|
||||
/* Value copied from BLE_PERIODIC_ADV */
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV)
|
||||
#endif
|
||||
|
||||
/* Value copied from BLE_MAX_PERIODIC_SYNCS */
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_CNT
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_CNT (MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS)
|
||||
#endif
|
||||
|
||||
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_LIST_CNT (MYNEWT_VAL_BLE_MAX_PERIODIC_SYNCS)
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV_SYNC_TRANSFER (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV_SYNC_TRANSFER (CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER)
|
||||
#endif
|
||||
|
||||
/* Value copied from BLE_PERIODIC_ADV_SYNC_TRANSFER */
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PERIODIC_ADV_SYNC_TRANSFER (CONFIG_BT_NIMBLE_PERIODIC_ADV_SYNC_TRANSFER)
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY
|
||||
#define MYNEWT_VAL_BLE_LL_CFG_FEAT_LL_PRIVACY (1)
|
||||
#endif
|
||||
@ -200,35 +418,19 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_MASTER_SCA
|
||||
#define MYNEWT_VAL_BLE_LL_MASTER_SCA (4)
|
||||
#define MYNEWT_VAL_BLE_LL_MASTER_SCA (60)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE
|
||||
#define MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE (251)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_MFRG_ID
|
||||
#define MYNEWT_VAL_BLE_LL_MFRG_ID (0xFFFF)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_NUM_SCAN_DUP_ADVS
|
||||
#define MYNEWT_VAL_BLE_LL_NUM_SCAN_DUP_ADVS (8)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_NUM_SCAN_RSP_ADVS
|
||||
#define MYNEWT_VAL_BLE_LL_NUM_SCAN_RSP_ADVS (8)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_OUR_SCA
|
||||
#define MYNEWT_VAL_BLE_LL_OUR_SCA (60)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_PRIO
|
||||
#define MYNEWT_VAL_BLE_LL_PRIO (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE
|
||||
#define MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE (4)
|
||||
#define MYNEWT_VAL_BLE_LL_RESOLV_LIST_SIZE (CONFIG_BT_NIMBLE_LL_RESOLV_LIST_SIZE)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_RNG_BUFSIZE
|
||||
@ -264,7 +466,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LL_WHITELIST_SIZE
|
||||
#define MYNEWT_VAL_BLE_LL_WHITELIST_SIZE (8)
|
||||
#define MYNEWT_VAL_BLE_LL_WHITELIST_SIZE CONFIG_BT_NIMBLE_WHITELIST_SIZE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_LP_CLOCK
|
||||
@ -276,7 +478,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR
|
||||
#define MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR ((uint8_t[6]){0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
|
||||
#define MYNEWT_VAL_BLE_PUBLIC_DEV_ADDR (((uint8_t[6]){0x01,0x21,0x03,0x66,0x05,0x30}))
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_XTAL_SETTLE_TIME
|
||||
@ -288,26 +490,6 @@
|
||||
#define MYNEWT_VAL_BLE_ATT_PREFERRED_MTU CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_LOG_LVL
|
||||
#define MYNEWT_VAL_BLE_HS_LOG_LVL CONFIG_BT_NIMBLE_LOG_LEVEL
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_PERIODIC_ADV
|
||||
#ifdef CONFIG_BT_NIMBLE_EXT_ADV
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV (CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
#define MYNEWT_VAL_BLE_PERIODIC_ADV_SYNC_TRANSFER (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_VERSION
|
||||
#define MYNEWT_VAL_BLE_VERSION (50)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ATT_SVR_FIND_INFO
|
||||
#define MYNEWT_VAL_BLE_ATT_SVR_FIND_INFO (1)
|
||||
#endif
|
||||
@ -477,31 +659,26 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS
|
||||
#ifdef CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS
|
||||
#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS (0)
|
||||
#endif
|
||||
#define MYNEWT_VAL_BLE_SM_SC_DEBUG_KEYS CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_AUTO_START
|
||||
#define MYNEWT_VAL_BLE_HS_AUTO_START (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL
|
||||
#ifdef CONFIG_BT_NIMBLE_HS_FLOW_CTRL
|
||||
#define MYNEWT_VAL_BLE_HS_FLOW_CTRL (1)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_HS_FLOW_CTRL (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL
|
||||
#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL CONFIG_BT_NIMBLE_HS_FLOW_CTRL_ITVL
|
||||
#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_ITVL 2000
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH
|
||||
#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH CONFIG_BT_NIMBLE_HS_FLOW_CTRL_THRESH
|
||||
#define MYNEWT_VAL_BLE_HS_FLOW_CTRL_THRESH 2
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HS_FLOW_CTRL_TX_ON_DISCONNECT
|
||||
@ -529,7 +706,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM
|
||||
#define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM
|
||||
#define MYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM 2
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_L2CAP_COC_MPS
|
||||
@ -541,7 +718,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_L2CAP_MAX_CHANS
|
||||
#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*MYNEWT_VAL_BLE_MAX_CONNECTIONS)
|
||||
#define MYNEWT_VAL_BLE_L2CAP_MAX_CHANS (3*CONFIG_BT_NIMBLE_MAX_CONNECTIONS)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_L2CAP_RX_FRAG_TIMEOUT
|
||||
@ -668,27 +845,6 @@
|
||||
#define MYNEWT_VAL_BLE_STORE_MAX_CCCDS CONFIG_BT_NIMBLE_MAX_CCCDS
|
||||
#endif
|
||||
|
||||
/*** @apache-mynewt-nimble/nimble/host/mesh */
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ACCESS_LOG_LVL
|
||||
#define MYNEWT_VAL_BLE_MESH_ACCESS_LOG_LVL (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ACCESS_LOG_MOD
|
||||
#define MYNEWT_VAL_BLE_MESH_ACCESS_LOG_MOD (10)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_BUF_COUNT (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ADV_LOG_LVL
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_LOG_LVL (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_ADV_LOG_MOD
|
||||
#define MYNEWT_VAL_BLE_MESH_ADV_LOG_MOD (11)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_STORE_CONFIG_PERSIST
|
||||
#ifdef CONFIG_BT_NIMBLE_NVS_PERSIST
|
||||
#define MYNEWT_VAL_BLE_STORE_CONFIG_PERSIST (1)
|
||||
@ -927,6 +1083,10 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_LPN_GROUPS (10)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_LPN_SUB_ALL_NODES_ADDR
|
||||
#define MYNEWT_VAL_BLE_MESH_LPN_SUB_ALL_NODES_ADDR (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT
|
||||
#define MYNEWT_VAL_BLE_MESH_LPN_INIT_POLL_TIMEOUT (MYNEWT_VAL_BLE_MESH_LPN_POLL_TIMEOUT)
|
||||
#endif
|
||||
@ -1048,6 +1208,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_CDB
|
||||
#define MYNEWT_VAL_BLE_MESH_CDB (0)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_PROV_LOG_LVL
|
||||
#define MYNEWT_VAL_BLE_MESH_PROV_LOG_LVL (1)
|
||||
#endif
|
||||
@ -1093,6 +1257,15 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_RX_SDU_MAX (72)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_SEG_BUFS
|
||||
#define MYNEWT_VAL_BLE_MESH_SEG_BUFS (72)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_RX_SEG_MAX
|
||||
#define MYNEWT_VAL_BLE_MESH_RX_SEG_MAX (3)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_RX_SEG_MSG_COUNT (2)
|
||||
#endif
|
||||
@ -1105,6 +1278,63 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_SEQ_STORE_RATE (128)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_COUNT (4)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST
|
||||
#define MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_UNICAST (400)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP
|
||||
#define MYNEWT_VAL_BLE_MESH_TX_SEG_RETRANS_TIMEOUT_GROUP (50)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_LOOPBACK_BUFS
|
||||
#define MYNEWT_VAL_BLE_MESH_LOOPBACK_BUFS (3)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_DEFAULT_TTL
|
||||
#define MYNEWT_VAL_BLE_MESH_DEFAULT_TTL (7)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_COUNT (2)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_INTERVAL
|
||||
#define MYNEWT_VAL_BLE_MESH_NETWORK_TRANSMIT_INTERVAL (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_COUNT
|
||||
#define MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_COUNT (2)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_PB_ADV_RETRANS_TIMEOUT
|
||||
#define MYNEWT_VAL_BLE_MESH_PB_ADV_RETRANS_TIMEOUT (500)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_RELAY_ENABLED
|
||||
#define MYNEWT_VAL_BLE_MESH_RELAY_ENABLED (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_GATT_PROXY_ENABLED
|
||||
#define MYNEWT_VAL_BLE_MESH_GATT_PROXY_ENABLED (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_FRIEND_ENABLED
|
||||
#define MYNEWT_VAL_BLE_MESH_FRIEND_ENABLED (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_BEACON_ENABLED
|
||||
#define MYNEWT_VAL_BLE_MESH_BEACON_ENABLED (1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_INTERVAL
|
||||
#define MYNEWT_VAL_BLE_MESH_RELAY_RETRANSMIT_INTERVAL (20)
|
||||
#endif
|
||||
|
||||
|
||||
/* Overridden by apps/blemesh (defined by @apache-mynewt-nimble/nimble/host/mesh) */
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_SETTINGS
|
||||
#define MYNEWT_VAL_BLE_MESH_SETTINGS (0)
|
||||
@ -1163,6 +1393,10 @@
|
||||
#define MYNEWT_VAL_BLE_MESH_TX_SEG_MSG_COUNT (4)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_MESH_UNPROV_BEACON_INT
|
||||
#define MYNEWT_VAL_BLE_MESH_UNPROV_BEACON_INT (5)
|
||||
#endif
|
||||
|
||||
/*** @apache-mynewt-nimble/nimble/host/services/ans */
|
||||
#ifndef MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT
|
||||
#define MYNEWT_VAL_BLE_SVC_ANS_NEW_ALERT_CAT (0)
|
||||
@ -1274,11 +1508,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME
|
||||
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME
|
||||
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME "nimble"
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH
|
||||
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN
|
||||
#define MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_MAX_LENGTH CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN // According to the specification, the maximum length should be 248
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SVC_GAP_DEVICE_NAME_WRITE_PERM
|
||||
@ -1325,6 +1559,9 @@
|
||||
#endif
|
||||
|
||||
/*** nimble/transport/uart */
|
||||
#ifndef MYNEWT_VAL_BLE_ACL_BU24
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ACL_BUF_COUNT
|
||||
#define MYNEWT_VAL_BLE_ACL_BUF_COUNT CONFIG_BT_NIMBLE_ACL_BUF_COUNT
|
||||
#endif
|
||||
@ -1334,7 +1571,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT
|
||||
#define MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT (12)
|
||||
#define MYNEWT_VAL_BLE_HCI_ACL_OUT_COUNT (20)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_HCI_EVT_BUF_SIZE
|
||||
@ -1375,6 +1612,19 @@
|
||||
#define MYNEWT_VAL_BLE_HCI_UART_STOP_BITS (1)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_TX_CCA_ENABLED
|
||||
#define MYNEWT_VAL_BLE_TX_CCA_ENABLED (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_TX_CCA_ENABLED (CONFIG_BLE_TX_CCA_ENABLED)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_CCA_RSSI_THRESH
|
||||
#define MYNEWT_VAL_BLE_CCA_RSSI_THRESH (50)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_CCA_RSSI_THRESH (CONFIG_BLE_CCA_RSSI_THRESH)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_NEWT_FEATURE_LOGCFG
|
||||
#define MYNEWT_VAL_NEWT_FEATURE_LOGCFG (1)
|
||||
#endif
|
||||
|
186
components/bt/include/esp32h2/include/esp_bt.h
Normal file
186
components/bt/include/esp32h2/include/esp_bt.h
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_BT_H__
|
||||
#define __ESP_BT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_task.h"
|
||||
|
||||
#include "nimble/nimble_npl.h"
|
||||
#include "syscfg/syscfg.h"
|
||||
#include "esp_nimble_cfg.h"
|
||||
#include "nimble/ble.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
|
||||
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
|
||||
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
|
||||
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
|
||||
} esp_bt_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
ESP_BT_CONTROLLER_STATUS_IDLE = 0, /*!< Controller is in idle state */
|
||||
ESP_BT_CONTROLLER_STATUS_INITED, /*!< Controller is in initialising state */
|
||||
ESP_BT_CONTROLLER_STATUS_ENABLED, /*!< Controller is in enabled state */
|
||||
ESP_BT_CONTROLLER_STATUS_NUM, /*!< Controller is in disabled state */
|
||||
} esp_bt_controller_status_t;
|
||||
|
||||
#define CONFIG_VERSION 0x02109228
|
||||
#define CONFIG_MAGIC 0x5A5AA5A5
|
||||
|
||||
/**
|
||||
* @brief Controller config options, depend on config mask.
|
||||
* Config mask indicate which functions enabled, this means
|
||||
* some options or parameters of some functions enabled by config mask.
|
||||
*/
|
||||
|
||||
struct esp_bt_controller_config_t {
|
||||
uint32_t config_version;
|
||||
uint16_t ble_ll_resolv_list_size;
|
||||
uint16_t ble_hci_evt_hi_buf_count;
|
||||
uint16_t ble_hci_evt_lo_buf_count;
|
||||
uint8_t ble_ll_sync_list_cnt;
|
||||
uint8_t ble_ll_sync_cnt;
|
||||
uint16_t ble_ll_rsp_dup_list_count;
|
||||
uint16_t ble_ll_adv_dup_list_count;
|
||||
uint8_t ble_ll_tx_pwr_dbm;
|
||||
uint64_t rtc_freq;
|
||||
uint16_t ble_ll_sca;
|
||||
uint8_t ble_ll_scan_phy_number;
|
||||
uint16_t ble_ll_conn_def_auth_pyld_tmo;
|
||||
uint8_t ble_ll_jitter_usecs;
|
||||
uint16_t ble_ll_sched_max_adv_pdu_usecs;
|
||||
uint16_t ble_ll_sched_direct_adv_max_usecs;
|
||||
uint16_t ble_ll_sched_adv_max_usecs;
|
||||
uint16_t ble_scan_rsp_data_max_len;
|
||||
uint8_t ble_ll_cfg_num_hci_cmd_pkts;
|
||||
uint32_t ble_ll_ctrl_proc_timeout_ms;
|
||||
uint16_t nimble_max_connections;
|
||||
uint8_t ble_whitelist_size;
|
||||
uint16_t ble_acl_buf_size;
|
||||
uint16_t ble_acl_buf_count;
|
||||
uint16_t ble_hci_evt_buf_size;
|
||||
uint16_t ble_multi_adv_instances;
|
||||
uint16_t ble_ext_adv_max_size;
|
||||
uint16_t controller_task_stack_size;
|
||||
uint8_t controller_task_prio;
|
||||
uint8_t controller_run_cpu;
|
||||
uint8_t enable_qa_test;
|
||||
uint8_t enable_bqb_test;
|
||||
uint8_t enable_uart_hci;
|
||||
uint8_t ble_hci_uart_port;
|
||||
uint32_t ble_hci_uart_baud;
|
||||
uint8_t ble_hci_uart_data_bits;
|
||||
uint8_t ble_hci_uart_stop_bits;
|
||||
uint8_t ble_hci_uart_flow_ctrl;
|
||||
uint8_t ble_hci_uart_uart_parity;
|
||||
uint8_t enable_tx_cca;
|
||||
uint8_t cca_rssi_thresh;
|
||||
uint8_t sleep_en;
|
||||
uint8_t coex_phy_coded_tx_rx_time_limit;
|
||||
uint32_t config_magic;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_RUN_BQB_TEST
|
||||
#define RUN_BQB_TEST CONFIG_BT_NIMBLE_RUN_BQB_TEST
|
||||
#else
|
||||
#define RUN_BQB_TEST 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_RUN_QA_TEST
|
||||
#define RUN_QA_TEST CONFIG_BT_NIMBLE_RUN_QA_TEST
|
||||
#else
|
||||
#define RUN_QA_TEST 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
#define HCI_UART_EN CONFIG_BT_NIMBLE_CONTROL_USE_UART_HCI
|
||||
#else
|
||||
#define HCI_UART_EN 0 // hci ram mode
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_SLEEP_ENABLE
|
||||
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_NIMBLE_SLEEP_ENABLE
|
||||
#else
|
||||
#define NIMBLE_SLEEP_ENABLE 0
|
||||
#endif
|
||||
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
|
||||
.config_version = CONFIG_VERSION, \
|
||||
.ble_ll_resolv_list_size = MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE), \
|
||||
.ble_hci_evt_hi_buf_count = MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT), \
|
||||
.ble_hci_evt_lo_buf_count = MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT), \
|
||||
.ble_ll_sync_list_cnt = BLE_LL_SYNC_LIST_CNT_N, \
|
||||
.ble_ll_sync_cnt = BLE_LL_SYNC_CNT_N, \
|
||||
.ble_ll_rsp_dup_list_count = CONFIG_BT_NIMBLE_LL_DUP_SCAN_LIST_COUNT, \
|
||||
.ble_ll_adv_dup_list_count = CONFIG_BT_NIMBLE_LL_DUP_SCAN_LIST_COUNT, \
|
||||
.ble_ll_tx_pwr_dbm = BLE_LL_TX_PWR_DBM_N, \
|
||||
.rtc_freq = RTC_FREQ_N, \
|
||||
.ble_ll_sca = MYNEWT_VAL(BLE_LL_SCA), \
|
||||
.ble_ll_scan_phy_number = BLE_LL_SCAN_PHY_NUMBER_N, \
|
||||
.ble_ll_conn_def_auth_pyld_tmo = BLE_LL_CONN_DEF_AUTH_PYLD_TMO_N, \
|
||||
.ble_ll_jitter_usecs = BLE_LL_JITTER_USECS_N, \
|
||||
.ble_ll_sched_max_adv_pdu_usecs = BLE_LL_SCHED_MAX_ADV_PDU_USECS_N, \
|
||||
.ble_ll_sched_direct_adv_max_usecs = BLE_LL_SCHED_DIRECT_ADV_MAX_USECS_N, \
|
||||
.ble_ll_sched_adv_max_usecs = BLE_LL_SCHED_ADV_MAX_USECS_N, \
|
||||
.ble_scan_rsp_data_max_len = BLE_SCAN_RSP_DATA_MAX_LEN_N, \
|
||||
.ble_ll_cfg_num_hci_cmd_pkts = BLE_LL_CFG_NUM_HCI_CMD_PKTS_N, \
|
||||
.ble_ll_ctrl_proc_timeout_ms = BLE_LL_CTRL_PROC_TIMEOUT_MS_N, \
|
||||
.nimble_max_connections = MYNEWT_VAL(BLE_MAX_CONNECTIONS), \
|
||||
.ble_whitelist_size = MYNEWT_VAL(BLE_LL_WHITELIST_SIZE), \
|
||||
.ble_acl_buf_size = MYNEWT_VAL(BLE_ACL_BUF_SIZE), \
|
||||
.ble_acl_buf_count = MYNEWT_VAL(BLE_ACL_BUF_COUNT), \
|
||||
.ble_hci_evt_buf_size = MYNEWT_VAL(BLE_HCI_EVT_BUF_SIZE), \
|
||||
.ble_multi_adv_instances = MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES), \
|
||||
.ble_ext_adv_max_size = MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE), \
|
||||
.controller_task_stack_size = NIMBLE_LL_STACK_SIZE, \
|
||||
.controller_task_prio = CONFIG_BT_NIMBLE_CONTROLLER_TASK_PRIORITY, \
|
||||
.controller_run_cpu = 0, \
|
||||
.enable_qa_test = RUN_QA_TEST, \
|
||||
.enable_bqb_test = RUN_BQB_TEST, \
|
||||
.enable_uart_hci = HCI_UART_EN, \
|
||||
.ble_hci_uart_port = MYNEWT_VAL(BLE_HCI_UART_PORT), \
|
||||
.ble_hci_uart_baud = MYNEWT_VAL(BLE_HCI_UART_BAUD), \
|
||||
.ble_hci_uart_data_bits = MYNEWT_VAL(BLE_HCI_UART_DATA_BITS), \
|
||||
.ble_hci_uart_stop_bits = MYNEWT_VAL(BLE_HCI_UART_STOP_BITS), \
|
||||
.ble_hci_uart_flow_ctrl = MYNEWT_VAL(BLE_HCI_UART_FLOW_CTRL), \
|
||||
.ble_hci_uart_uart_parity = MYNEWT_VAL(BLE_HCI_UART_PARITY), \
|
||||
.enable_tx_cca = MYNEWT_VAL(BLE_TX_CCA_ENABLED), \
|
||||
.cca_rssi_thresh = 256 - MYNEWT_VAL(BLE_CCA_RSSI_THRESH), \
|
||||
.sleep_en = NIMBLE_SLEEP_ENABLE, \
|
||||
.coex_phy_coded_tx_rx_time_limit = CONFIG_BT_NIMBLE_COEX_PHY_CODED_TX_RX_TLIM_EFF, \
|
||||
.config_magic = CONFIG_MAGIC, \
|
||||
};
|
||||
|
||||
esp_err_t esp_bt_controller_init(struct esp_bt_controller_config_t *cfg);
|
||||
esp_err_t esp_bt_controller_deinit(void);
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
|
||||
esp_err_t esp_bt_controller_disable(void);
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
|
||||
/* Returns random static address or -1 if not present */
|
||||
extern int esp_ble_hw_get_static_addr(ble_addr_t *addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_BT_H__ */
|
@ -241,7 +241,7 @@ CONFIG_NIMBLE_PINNED_TO_CORE_CHOICE CONFIG_BT_NIMBLE_PIN
|
||||
CONFIG_NIMBLE_PINNED_TO_CORE CONFIG_BT_NIMBLE_PINNED_TO_CORE
|
||||
CONFIG_NIMBLE_PINNED_TO_CORE_0 CONFIG_BT_NIMBLE_PINNED_TO_CORE_0
|
||||
CONFIG_NIMBLE_PINNED_TO_CORE_1 CONFIG_BT_NIMBLE_PINNED_TO_CORE_1
|
||||
CONFIG_NIMBLE_TASK_STACK_SIZE CONFIG_BT_NIMBLE_TASK_STACK_SIZE
|
||||
CONFIG_NIMBLE_TASK_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE
|
||||
CONFIG_NIMBLE_ROLE_CENTRAL CONFIG_BT_NIMBLE_ROLE_CENTRAL
|
||||
CONFIG_NIMBLE_ROLE_PERIPHERAL CONFIG_BT_NIMBLE_ROLE_PERIPHERAL
|
||||
CONFIG_NIMBLE_ROLE_BROADCASTER CONFIG_BT_NIMBLE_ROLE_BROADCASTER
|
||||
@ -277,3 +277,5 @@ CONFIG_NIMBLE_MESH_LOW_POWER CONFIG_BT_NIMBLE_MES
|
||||
CONFIG_NIMBLE_MESH_FRIEND CONFIG_BT_NIMBLE_MESH_FRIEND
|
||||
CONFIG_NIMBLE_MESH_DEVICE_NAME CONFIG_BT_NIMBLE_MESH_DEVICE_NAME
|
||||
CONFIG_NIMBLE_CRYPTO_STACK_MBEDTLS CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
|
||||
CONFIG_BT_NIMBLE_TASK_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE
|
||||
CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT CONFIG_BT_NIMBLE_MSYS_1_BLOCK_COUNT
|
||||
|
@ -91,7 +91,7 @@ menu "ESP32H2-Specific"
|
||||
config ESP32H2_RTC_CLK_SRC_INT_RC
|
||||
bool "Internal 150kHz RC oscillator"
|
||||
config ESP32H2_RTC_CLK_SRC_EXT_CRYS
|
||||
bool "External 32kHz crystal"
|
||||
bool "External 32.768kHz crystal"
|
||||
select ESP_SYSTEM_RTC_EXT_XTAL
|
||||
config ESP32H2_RTC_CLK_SRC_EXT_OSC
|
||||
bool "External 32kHz oscillator at 32K_XP pin"
|
||||
|
@ -149,6 +149,8 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
|
||||
case PERIPH_GDMA_MODULE:
|
||||
case PERIPH_TEMPSENSOR_MODULE:
|
||||
return SYSTEM_PERIP_CLK_EN1_REG;
|
||||
case PERIPH_BT_MODULE:
|
||||
return SYSTEM_MODEM_CLK_EN_REG;
|
||||
default:
|
||||
return SYSTEM_PERIP_CLK_EN0_REG;
|
||||
}
|
||||
@ -165,6 +167,8 @@ static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
|
||||
case PERIPH_GDMA_MODULE:
|
||||
case PERIPH_TEMPSENSOR_MODULE:
|
||||
return SYSTEM_PERIP_RST_EN1_REG;
|
||||
case PERIPH_BT_MODULE:
|
||||
return SYSTEM_MODEM_RST_EN_REG;
|
||||
default:
|
||||
return SYSTEM_PERIP_RST_EN0_REG;
|
||||
}
|
||||
|
@ -35,6 +35,10 @@ config SOC_BT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_BLUEDROID_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_CLASSIC_BT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
@ -68,6 +68,7 @@
|
||||
#define SOC_MCPWM_SUPPORTED 1
|
||||
#define SOC_SDMMC_HOST_SUPPORTED 1
|
||||
#define SOC_BT_SUPPORTED 1
|
||||
#define SOC_BLUEDROID_SUPPORTED 1
|
||||
#define SOC_CLASSIC_BT_SUPPORTED 1
|
||||
#define SOC_PCNT_SUPPORTED 1
|
||||
#define SOC_WIFI_SUPPORTED 1
|
||||
|
@ -27,6 +27,10 @@ config SOC_BT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_BLUEDROID_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_DIG_SIGN_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define SOC_GDMA_SUPPORTED 1
|
||||
#define SOC_TWAI_SUPPORTED 1
|
||||
#define SOC_BT_SUPPORTED 1
|
||||
#define SOC_BLUEDROID_SUPPORTED 1
|
||||
#define SOC_DIG_SIGN_SUPPORTED 1
|
||||
#define SOC_HMAC_SUPPORTED 1
|
||||
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
|
||||
|
@ -27,6 +27,14 @@ config SOC_BT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_BLUEDROID_SUPPORTED
|
||||
bool
|
||||
default n
|
||||
|
||||
config SOC_ESP_NIMBLE_CONTROLLER
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_DIG_SIGN_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
@ -39,6 +39,8 @@
|
||||
#define SOC_GDMA_SUPPORTED 1
|
||||
#define SOC_TWAI_SUPPORTED 1
|
||||
#define SOC_BT_SUPPORTED 1
|
||||
#define SOC_BLUEDROID_SUPPORTED 0
|
||||
#define SOC_ESP_NIMBLE_CONTROLLER 1
|
||||
#define SOC_DIG_SIGN_SUPPORTED 1
|
||||
#define SOC_HMAC_SUPPORTED 1
|
||||
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
|
||||
|
@ -151,6 +151,10 @@ config SOC_BT_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_BLUEDROID_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_USB_OTG_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
@ -38,6 +38,7 @@
|
||||
#define SOC_ULP_SUPPORTED 1
|
||||
#define SOC_RISCV_COPROC_SUPPORTED 1
|
||||
#define SOC_BT_SUPPORTED 1
|
||||
#define SOC_BLUEDROID_SUPPORTED 1
|
||||
#define SOC_USB_OTG_SUPPORTED 1
|
||||
#define SOC_USB_SERIAL_JTAG_SUPPORTED 1
|
||||
#define SOC_CCOMP_TIMER_SUPPORTED 1
|
||||
|
@ -79,7 +79,7 @@ The default stack sizes for these tasks are usually set conservatively high, to
|
||||
- :doc:`/api-guides/event-handling` system task to execute callbacks for the default system event loop has stack size :ref:`CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE`.
|
||||
- :doc:`/api-guides/lwip` TCP/IP task has stack size :ref:`CONFIG_LWIP_TCPIP_TASK_STACK_SIZE`
|
||||
:SOC_BT_SUPPORTED: - :doc:`Bluedroid Bluetooth Host </api-reference/bluetooth/index>` have task stack sizes :ref:`CONFIG_BT_BTC_TASK_STACK_SIZE`, :ref:`CONFIG_BT_BTU_TASK_STACK_SIZE`.
|
||||
:SOC_BT_SUPPORTED: - :doc:`NimBLE Bluetooth Host </api-reference/bluetooth/nimble/index>` has task stack size :ref:`CONFIG_BT_NIMBLE_TASK_STACK_SIZE`
|
||||
:SOC_BT_SUPPORTED: - :doc:`NimBLE Bluetooth Host </api-reference/bluetooth/nimble/index>` has task stack size :ref:`CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE`
|
||||
- The Ethernet driver creates a task for the MAC to receive Ethernet frames. If using the default config ``ETH_MAC_DEFAULT_CONFIG`` then the task stack size is 4 KB. This setting can be changed by passing a custom :cpp:class:`eth_mac_config_t` struct when initializing the Ethernet MAC.
|
||||
- FreeRTOS idle task stack size is configured by :ref:`CONFIG_FREERTOS_IDLE_TASK_STACKSIZE`.
|
||||
- If using the :doc:`mDNS </api-reference/protocols/mdns>` and/or :doc:`MQTT </api-reference/protocols/mqtt>` components, they create tasks with stack sizes configured by :ref:`CONFIG_MDNS_TASK_STACK_SIZE` and :ref:`CONFIG_MQTT_TASK_STACK_SIZE`, respectively. MQTT stack size can also be configured using ``task_stack`` field of :cpp:class:`esp_mqtt_client_config_t`.
|
||||
|
@ -6,4 +6,10 @@ menu "Example Configuration"
|
||||
help
|
||||
Enter the peer address in aa:bb:cc:dd:ee:ff form to connect to a specific peripheral
|
||||
|
||||
config EXAMPLE_EXTENDED_ADV
|
||||
bool
|
||||
default y if SOC_ESP_NIMBLE_CONTROLLER
|
||||
prompt "Enable Extended Adv"
|
||||
help
|
||||
Use this option to enable extended advertising in the example
|
||||
endmenu
|
||||
|
@ -45,6 +45,7 @@ char *addr_str(const void *addr);
|
||||
void print_uuid(const ble_uuid_t *uuid);
|
||||
void print_conn_desc(const struct ble_gap_conn_desc *desc);
|
||||
void print_adv_fields(const struct ble_hs_adv_fields *fields);
|
||||
void ext_print_adv_report(const void *param);
|
||||
|
||||
/** Peer. */
|
||||
struct peer_dsc {
|
||||
|
@ -213,7 +213,7 @@ blecent_on_disc_complete(const struct peer *peer, int status, void *arg)
|
||||
* list of services, characteristics, and descriptors that the peer
|
||||
* supports.
|
||||
*/
|
||||
MODLOG_DFLT(ERROR, "Service discovery complete; status=%d "
|
||||
MODLOG_DFLT(INFO, "Service discovery complete; status=%d "
|
||||
"conn_handle=%d\n", status, peer->conn_handle);
|
||||
|
||||
/* Now perform three GATT procedures against the peer: read,
|
||||
@ -269,6 +269,52 @@ blecent_scan(void)
|
||||
* advertisement. The function returns a positive result if the device
|
||||
* advertises connectability and support for the Alert Notification service.
|
||||
*/
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
static int
|
||||
ext_blecent_should_connect(const struct ble_gap_ext_disc_desc *disc)
|
||||
{
|
||||
int offset = 0;
|
||||
int ad_struct_len = 0;
|
||||
|
||||
if (disc->legacy_event_type != BLE_HCI_ADV_RPT_EVTYPE_ADV_IND &&
|
||||
disc->legacy_event_type != BLE_HCI_ADV_RPT_EVTYPE_DIR_IND) {
|
||||
return 0;
|
||||
}
|
||||
if (strlen(CONFIG_EXAMPLE_PEER_ADDR) && (strncmp(CONFIG_EXAMPLE_PEER_ADDR, "ADDR_ANY", strlen ("ADDR_ANY")) != 0)) {
|
||||
ESP_LOGI(tag, "Peer address from menuconfig: %s", CONFIG_EXAMPLE_PEER_ADDR);
|
||||
/* Convert string to address */
|
||||
sscanf(CONFIG_EXAMPLE_PEER_ADDR, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
|
||||
&peer_addr[5], &peer_addr[4], &peer_addr[3],
|
||||
&peer_addr[2], &peer_addr[1], &peer_addr[0]);
|
||||
if (memcmp(peer_addr, disc->addr.val, sizeof(disc->addr.val)) != 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* The device has to advertise support for the Alert Notification
|
||||
* service (0x1811).
|
||||
*/
|
||||
do {
|
||||
ad_struct_len = disc->data[offset];
|
||||
|
||||
if (!ad_struct_len) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Search if ANS UUID is advertised */
|
||||
if (disc->data[offset] == 0x03 && disc->data[offset + 1] == 0x03) {
|
||||
if ( disc->data[offset + 2] == 0x18 && disc->data[offset + 3] == 0x11 ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
offset += ad_struct_len + 1;
|
||||
|
||||
} while ( offset < disc->length_data );
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int
|
||||
blecent_should_connect(const struct ble_gap_disc_desc *disc)
|
||||
{
|
||||
@ -310,6 +356,7 @@ blecent_should_connect(const struct ble_gap_disc_desc *disc)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Connects to the sender of the specified advertisement of it looks
|
||||
@ -317,15 +364,22 @@ blecent_should_connect(const struct ble_gap_disc_desc *disc)
|
||||
* support for the Alert Notification service.
|
||||
*/
|
||||
static void
|
||||
blecent_connect_if_interesting(const struct ble_gap_disc_desc *disc)
|
||||
blecent_connect_if_interesting(void *disc)
|
||||
{
|
||||
uint8_t own_addr_type;
|
||||
int rc;
|
||||
ble_addr_t *addr;
|
||||
|
||||
/* Don't do anything if we don't care about this advertiser. */
|
||||
if (!blecent_should_connect(disc)) {
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
if (!ext_blecent_should_connect((struct ble_gap_ext_disc_desc *)disc)) {
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (!blecent_should_connect((struct ble_gap_disc_desc *)disc)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Scanning must be stopped before a connection can be initiated. */
|
||||
rc = ble_gap_disc_cancel();
|
||||
@ -344,13 +398,18 @@ blecent_connect_if_interesting(const struct ble_gap_disc_desc *disc)
|
||||
/* Try to connect the the advertiser. Allow 30 seconds (30000 ms) for
|
||||
* timeout.
|
||||
*/
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
addr = &((struct ble_gap_ext_disc_desc *)disc)->addr;
|
||||
#else
|
||||
addr = &((struct ble_gap_disc_desc *)disc)->addr;
|
||||
#endif
|
||||
|
||||
rc = ble_gap_connect(own_addr_type, &disc->addr, 30000, NULL,
|
||||
rc = ble_gap_connect(own_addr_type, addr, 30000, NULL,
|
||||
blecent_gap_event, NULL);
|
||||
if (rc != 0) {
|
||||
MODLOG_DFLT(ERROR, "Error: Failed to connect to device; addr_type=%d "
|
||||
"addr=%s; rc=%d\n",
|
||||
disc->addr.type, addr_str(disc->addr.val), rc);
|
||||
addr->type, addr_str(addr->val), rc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -490,6 +549,15 @@ blecent_gap_event(struct ble_gap_event *event, void *arg)
|
||||
*/
|
||||
return BLE_GAP_REPEAT_PAIRING_RETRY;
|
||||
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
case BLE_GAP_EVENT_EXT_DISC:
|
||||
/* An advertisment report was received during GAP discovery. */
|
||||
ext_print_adv_report(&event->disc);
|
||||
|
||||
blecent_connect_if_interesting(&event->disc);
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -101,6 +101,27 @@ print_conn_desc(const struct ble_gap_conn_desc *desc)
|
||||
desc->sec_state.bonded);
|
||||
}
|
||||
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
void
|
||||
print_addr(const void *addr, const char *name)
|
||||
{
|
||||
const uint8_t *u8p;
|
||||
u8p = addr;
|
||||
MODLOG_DFLT(DEBUG, "%s = %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
name, u8p[5], u8p[4], u8p[3], u8p[2], u8p[1], u8p[0]);
|
||||
}
|
||||
void
|
||||
ext_print_adv_report(const void *param)
|
||||
{
|
||||
const struct ble_gap_ext_disc_desc *disc = (struct ble_gap_ext_disc_desc *)param;
|
||||
MODLOG_DFLT(DEBUG, "props=%d data_status=%d legacy_event_type=%d", disc->props, disc->data_status, disc->legacy_event_type);
|
||||
print_addr(disc->addr.val, "address");
|
||||
MODLOG_DFLT(DEBUG, "rssi=%d tx_power=%d", disc->rssi, disc->tx_power);
|
||||
MODLOG_DFLT(DEBUG, "sid=%d prim_phy=%d sec_phy=%d", disc->sid, disc->prim_phy, disc->sec_phy);
|
||||
MODLOG_DFLT(DEBUG, "periodic_adv_itvl=%d length_data=%d", disc->periodic_adv_itvl, disc->length_data);
|
||||
print_addr(disc->direct_addr.val, "direct address");
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
print_adv_fields(const struct ble_hs_adv_fields *fields)
|
||||
|
@ -46,25 +46,6 @@ static int recent_test_id = STANDARD_TEST_ID;
|
||||
|
||||
static bool has_reg_fault = true;
|
||||
|
||||
|
||||
static struct bt_mesh_cfg_srv cfg_srv = {
|
||||
.relay = BT_MESH_RELAY_DISABLED,
|
||||
.beacon = BT_MESH_BEACON_ENABLED,
|
||||
#if MYNEWT_VAL(BLE_MESH_FRIEND)
|
||||
.frnd = BT_MESH_FRIEND_ENABLED,
|
||||
#endif
|
||||
#if MYNEWT_VAL(BLE_MESH_GATT_PROXY)
|
||||
.gatt_proxy = BT_MESH_GATT_PROXY_ENABLED,
|
||||
#else
|
||||
.gatt_proxy = BT_MESH_GATT_PROXY_NOT_SUPPORTED,
|
||||
#endif
|
||||
.default_ttl = 7,
|
||||
|
||||
/* 3 transmissions with 20ms interval */
|
||||
.net_transmit = BT_MESH_TRANSMIT(2, 20),
|
||||
.relay_retransmit = BT_MESH_TRANSMIT(2, 20),
|
||||
};
|
||||
|
||||
static int
|
||||
fault_get_cur(struct bt_mesh_model *model,
|
||||
uint8_t *test_id,
|
||||
@ -328,7 +309,7 @@ static const struct bt_mesh_model_op gen_level_op[] = {
|
||||
};
|
||||
|
||||
static struct bt_mesh_model root_models[] = {
|
||||
BT_MESH_MODEL_CFG_SRV(&cfg_srv),
|
||||
BT_MESH_MODEL_CFG_SRV,
|
||||
BT_MESH_MODEL_HEALTH_SRV(&health_srv, &health_pub),
|
||||
BT_MESH_MODEL(BT_MESH_MODEL_ID_GEN_ONOFF_SRV, gen_onoff_op,
|
||||
&gen_onoff_pub, NULL),
|
||||
@ -386,7 +367,7 @@ static int output_number(bt_mesh_output_action_t action, uint32_t number)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void prov_complete(u16_t net_idx, u16_t addr)
|
||||
static void prov_complete(uint16_t net_idx, uint16_t addr)
|
||||
{
|
||||
ESP_LOGI(tag, "Local node provisioned, primary address 0x%04x\n", addr);
|
||||
}
|
||||
@ -427,6 +408,10 @@ blemesh_on_sync(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (MYNEWT_VAL(BLE_MESH_SHELL))
|
||||
shell_register_default_module("mesh");
|
||||
#endif
|
||||
|
||||
ESP_LOGI(tag, "Mesh initialized\n");
|
||||
|
||||
if (IS_ENABLED(CONFIG_SETTINGS)) {
|
||||
|
@ -48,4 +48,11 @@ menu "Example Configuration"
|
||||
help
|
||||
Use this option to enable/disable Security Manager Secure Connection 4.2 feature.
|
||||
|
||||
config EXAMPLE_EXTENDED_ADV
|
||||
bool
|
||||
default y if SOC_ESP_NIMBLE_CONTROLLER
|
||||
prompt "Enable Extended Adv"
|
||||
help
|
||||
Use this option to enable extended advertising in the example
|
||||
|
||||
endmenu
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "services/gap/ble_svc_gap.h"
|
||||
#include "services/gatt/ble_svc_gatt.h"
|
||||
#include "bleprph.h"
|
||||
#include "services/ans/ble_svc_ans.h"
|
||||
|
||||
/**
|
||||
* The vendor specific security test service consists of two characteristics:
|
||||
@ -195,6 +196,7 @@ gatt_svr_init(void)
|
||||
|
||||
ble_svc_gap_init();
|
||||
ble_svc_gatt_init();
|
||||
ble_svc_ans_init();
|
||||
|
||||
rc = ble_gatts_count_cfg(gatt_svr_svcs);
|
||||
if (rc != 0) {
|
||||
|
@ -29,6 +29,15 @@
|
||||
#include "services/gap/ble_svc_gap.h"
|
||||
#include "bleprph.h"
|
||||
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
static uint8_t ext_adv_pattern_1[] = {
|
||||
0x02, 0x01, 0x06,
|
||||
0x03, 0x03, 0xab, 0xcd,
|
||||
0x03, 0x03, 0x18, 0x11,
|
||||
0x11, 0X09, 'e', 's', 'p', '3', '2', 'h', '2', '-', 'B', 'L', 'E', '5', '0', '-', 'S', '\0',
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char *tag = "NimBLE_BLE_PRPH";
|
||||
static int bleprph_gap_event(struct ble_gap_event *event, void *arg);
|
||||
static uint8_t own_addr_type;
|
||||
@ -62,6 +71,62 @@ bleprph_print_conn_desc(struct ble_gap_conn_desc *desc)
|
||||
desc->sec_state.bonded);
|
||||
}
|
||||
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
/**
|
||||
* Enables advertising with the following parameters:
|
||||
* o General discoverable mode.
|
||||
* o Undirected connectable mode.
|
||||
*/
|
||||
static void
|
||||
ext_bleprph_advertise(void)
|
||||
{
|
||||
struct ble_gap_ext_adv_params params;
|
||||
struct os_mbuf *data;
|
||||
uint8_t instance = 1;
|
||||
int rc;
|
||||
|
||||
/* use defaults for non-set params */
|
||||
memset (¶ms, 0, sizeof(params));
|
||||
|
||||
/* enable connectable advertising */
|
||||
params.connectable = 1;
|
||||
params.scannable = 1;
|
||||
params.legacy_pdu = 1;
|
||||
|
||||
/* advertise using random addr */
|
||||
params.own_addr_type = BLE_OWN_ADDR_PUBLIC;
|
||||
|
||||
params.primary_phy = BLE_HCI_LE_PHY_1M;
|
||||
params.secondary_phy = BLE_HCI_LE_PHY_2M;
|
||||
//params.tx_power = 127;
|
||||
params.sid = 1;
|
||||
|
||||
params.itvl_min = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
|
||||
params.itvl_max = BLE_GAP_ADV_FAST_INTERVAL1_MIN;
|
||||
|
||||
/* configure instance 0 */
|
||||
rc = ble_gap_ext_adv_configure(instance, ¶ms, NULL,
|
||||
bleprph_gap_event, NULL);
|
||||
assert (rc == 0);
|
||||
|
||||
/* in this case only scan response is allowed */
|
||||
|
||||
/* get mbuf for scan rsp data */
|
||||
data = os_msys_get_pkthdr(sizeof(ext_adv_pattern_1), 0);
|
||||
assert(data);
|
||||
|
||||
/* fill mbuf with scan rsp data */
|
||||
rc = os_mbuf_append(data, ext_adv_pattern_1, sizeof(ext_adv_pattern_1));
|
||||
assert(rc == 0);
|
||||
|
||||
rc = ble_gap_ext_adv_set_data(instance, data);
|
||||
assert (rc == 0);
|
||||
|
||||
/* start advertising */
|
||||
rc = ble_gap_ext_adv_start(instance, 0, 0);
|
||||
assert (rc == 0);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Enables advertising with the following parameters:
|
||||
* o General discoverable mode.
|
||||
@ -127,6 +192,7 @@ bleprph_advertise(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The nimble host executes this callback when a GAP event occurs. The
|
||||
@ -164,7 +230,11 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
|
||||
if (event->connect.status != 0) {
|
||||
/* Connection failed; resume advertising. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
#else
|
||||
bleprph_advertise();
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -174,7 +244,11 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
|
||||
/* Connection terminated; resume advertising. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
#else
|
||||
bleprph_advertise();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
case BLE_GAP_EVENT_CONN_UPDATE:
|
||||
@ -190,7 +264,9 @@ bleprph_gap_event(struct ble_gap_event *event, void *arg)
|
||||
case BLE_GAP_EVENT_ADV_COMPLETE:
|
||||
MODLOG_DFLT(INFO, "advertise complete; reason=%d",
|
||||
event->adv_complete.reason);
|
||||
#if !CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
bleprph_advertise();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
case BLE_GAP_EVENT_ENC_CHANGE:
|
||||
@ -298,6 +374,7 @@ bleprph_on_sync(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Make sure we have proper identity address set (public preferred) */
|
||||
rc = ble_hs_util_ensure_addr(0);
|
||||
assert(rc == 0);
|
||||
|
||||
@ -316,7 +393,11 @@ bleprph_on_sync(void)
|
||||
print_addr(addr_val);
|
||||
MODLOG_DFLT(INFO, "\n");
|
||||
/* Begin advertising. */
|
||||
#if CONFIG_EXAMPLE_EXTENDED_ADV
|
||||
ext_bleprph_advertise();
|
||||
#else
|
||||
bleprph_advertise();
|
||||
#endif
|
||||
}
|
||||
|
||||
void bleprph_host_task(void *param)
|
||||
|
@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
15
examples/bluetooth/nimble/bleprph/sdkconfig.defaults.esp32h2
Normal file
15
examples/bluetooth/nimble/bleprph/sdkconfig.defaults.esp32h2
Normal file
@ -0,0 +1,15 @@
|
||||
CONFIG_IDF_TARGET="esp32h2"
|
||||
CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=y
|
||||
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
|
||||
CONFIG_ESPTOOLPY_FLASHFREQ_40M=y
|
||||
CONFIG_ESPTOOLPY_FLASHFREQ="40m"
|
||||
CONFIG_ESP32H2_RTC_CLK_SRC_EXT_CRYS=y
|
||||
CONFIG_ESP32H2_RTC_CLK_CAL_CYCLES=576
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
||||
CONFIG_BT_BLUEDROID_ENABLED=n
|
||||
CONFIG_BT_NIMBLE_ENABLED=y
|
||||
CONFIG_BT_NIMBLE_EXT_ADV=y
|
||||
CONFIG_BT_NIMBLE_USE_ESP_TIMER=n
|
@ -211,9 +211,14 @@ static int deep_sleep(int argc, char **argv)
|
||||
ESP_LOGI(TAG, "Enabling wakeup on GPIO%d, wakeup on %s level",
|
||||
io_num, level ? "HIGH" : "LOW");
|
||||
|
||||
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||
ESP_ERROR_CHECK( esp_sleep_enable_ext1_wakeup(1ULL << io_num, level) );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOC_RTCIO_HOLD_SUPPORTED
|
||||
rtc_gpio_isolate(GPIO_NUM_12);
|
||||
#endif
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user