Update bt fork to be based on v5.3
This commit is contained in:
+25
-22
@@ -24,12 +24,16 @@ elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
set(target_specific_include_dirs include/esp32h2/include)
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C5)
|
||||
set(target_specific_include_dirs include/esp32c5/include)
|
||||
endif()
|
||||
|
||||
set(common_include_dirs
|
||||
common/api/include/api
|
||||
common/btc/profile/esp/blufi/include
|
||||
common/btc/profile/esp/include
|
||||
common/hci_log/include
|
||||
)
|
||||
|
||||
set(ble_mesh_include_dirs
|
||||
@@ -66,40 +70,44 @@ if(CONFIG_IDF_DOC_BUILD)
|
||||
${nimble_hci_include_dirs})
|
||||
endif()
|
||||
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
|
||||
set(srcs "")
|
||||
set(include_dirs "")
|
||||
set(ldfragments "linker.lf")
|
||||
set(ldscripts "linker_common.lf")
|
||||
if(CONFIG_BT_CONTROLLER_ENABLED)
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
list(APPEND srcs "controller/esp32/bt.c"
|
||||
"controller/esp32/hli_api.c"
|
||||
"controller/esp32/hli_vectors.S")
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C3)
|
||||
list(APPEND srcs "controller/esp32c3/bt.c")
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
list(APPEND srcs "controller/esp32c3/bt.c")
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
set(ldfragments "linker.lf.esp32c2")
|
||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||
set(ldscripts "linker_esp32c2.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||
list(APPEND srcs "controller/esp32c6/bt.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
list(APPEND srcs "controller/esp32h2/bt.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C5)
|
||||
list(APPEND srcs "controller/esp32c5/bt.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
endif()
|
||||
|
||||
list(APPEND include_dirs ${target_specific_include_dirs})
|
||||
|
||||
endif()
|
||||
|
||||
# Common
|
||||
@@ -114,6 +122,7 @@ if(CONFIG_BT_ENABLED)
|
||||
|
||||
list(APPEND srcs "common/btc/core/btc_alarm.c"
|
||||
"common/api/esp_blufi_api.c"
|
||||
"common/hci_log/bt_hci_log.c"
|
||||
"common/btc/core/btc_manage.c"
|
||||
"common/btc/core/btc_task.c"
|
||||
"common/btc/profile/esp/blufi/blufi_prf.c"
|
||||
@@ -566,7 +575,7 @@ if(CONFIG_BT_ENABLED)
|
||||
if(CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT)
|
||||
list(APPEND srcs
|
||||
"porting/npl/freertos/src/npl_os_freertos.c"
|
||||
"porting/nimble/src/os_msys_init.c"
|
||||
"porting/mem/os_msys_init.c"
|
||||
)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_DISABLED)
|
||||
@@ -576,7 +585,6 @@ if(CONFIG_BT_ENABLED)
|
||||
endif()
|
||||
list(APPEND include_dirs
|
||||
porting/include
|
||||
porting/nimble/include
|
||||
porting/npl/freertos/include
|
||||
porting/transport/include
|
||||
)
|
||||
@@ -718,7 +726,6 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/port/src/nvs_port.c"
|
||||
)
|
||||
list(APPEND include_dirs
|
||||
porting/include
|
||||
host/nimble/nimble/porting/nimble/include
|
||||
host/nimble/port/include
|
||||
host/nimble/nimble/nimble/transport/include
|
||||
@@ -747,9 +754,8 @@ if(CONFIG_BT_ENABLED)
|
||||
endif()
|
||||
|
||||
list(APPEND include_dirs
|
||||
porting/include
|
||||
host/nimble/nimble/porting/npl/freertos/include
|
||||
host/nimble/nimble/porting/nimble/include
|
||||
host/nimble/nimble/nimble/include
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -820,8 +826,8 @@ idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls driver vfs
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls esp_driver_uart vfs esp_ringbuf
|
||||
LDFRAGMENTS "${ldscripts}")
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
|
||||
@@ -838,14 +844,8 @@ if(CONFIG_BT_ENABLED)
|
||||
target_link_directories(${COMPONENT_LIB} INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32c6/esp32c6-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a")
|
||||
elseif(CONFIG_BT_CONTROLLER_ENABLED)
|
||||
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
endif()
|
||||
|
||||
@@ -875,6 +875,9 @@ if(CONFIG_BLE_MESH)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32h2/libble_mesh.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C5)
|
||||
add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32C5/libble_mesh.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -80,6 +80,37 @@ menu "Bluetooth"
|
||||
We cannot split the memory into 3 different regions (IRAM, BLE-IRAM, DRAM).
|
||||
So this option will disable the PMP (ESP_SYSTEM_PMP_IDRAM_SPLIT)
|
||||
|
||||
menu "Common Options"
|
||||
visible if (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED)
|
||||
|
||||
source "$IDF_PATH/components/bt/common/Kconfig.in"
|
||||
endmenu
|
||||
|
||||
config BT_HCI_LOG_DEBUG_EN
|
||||
depends on BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED
|
||||
bool "Enable Bluetooth HCI debug mode"
|
||||
default n
|
||||
help
|
||||
This option is used to enable bluetooth debug mode, which saves the hci layer data stream.
|
||||
|
||||
config BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
depends on BT_HCI_LOG_DEBUG_EN
|
||||
int "Size of the cache used for HCI data in Bluetooth HCI debug mode (N*1024 bytes)"
|
||||
range 1 100
|
||||
default 5
|
||||
help
|
||||
This option is to configure the buffer size of the hci data steam cache in hci debug mode.
|
||||
This is a ring buffer, the new data will overwrite the oldest data if the buffer is full.
|
||||
|
||||
config BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
depends on BT_HCI_LOG_DEBUG_EN
|
||||
int "Size of the cache used for adv report in Bluetooth HCI debug mode (N*1024 bytes)"
|
||||
range 1 100
|
||||
default 8
|
||||
help
|
||||
This option is to configure the buffer size of the hci adv report cache in hci debug mode.
|
||||
This is a ring buffer, the new data will overwrite the oldest data if the buffer is full.
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLE_MESH
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
config BT_ALARM_MAX_NUM
|
||||
int "Maximum number of Bluetooth alarms"
|
||||
default 50
|
||||
help
|
||||
This option decides the maximum number of alarms which
|
||||
could be used by Bluetooth host.
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -98,7 +98,7 @@ osi_thread_t *btc_thread;
|
||||
static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
|
||||
[BTC_PID_DEV] = {btc_dev_call_handler, NULL },
|
||||
[BTC_PID_DEV] = {btc_dev_call_handler, btc_dev_cb_handler },
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
@@ -405,6 +405,13 @@ static void btc_deinit_mem(void) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BTC_HF_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_local_param_ptr) {
|
||||
osi_free(hf_local_param_ptr);
|
||||
hf_local_param_ptr = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_client_local_param_ptr) {
|
||||
osi_free(hf_client_local_param_ptr);
|
||||
@@ -460,6 +467,13 @@ static bt_status_t btc_init_mem(void) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BTC_HF_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if ((hf_local_param_ptr = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
memset((void *)hf_local_param_ptr, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t));
|
||||
#endif
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if ((hf_client_local_param_ptr = (hf_client_local_param_t *)osi_malloc(sizeof(hf_client_local_param_t))) == NULL) {
|
||||
goto error_exit;
|
||||
|
||||
@@ -241,7 +241,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
blufi_env.handle_srvc = p_data->create.service_id;
|
||||
|
||||
//add the frist blufi characteristic --> write characteristic
|
||||
//add the first blufi characteristic --> write characteristic
|
||||
BTA_GATTS_AddCharacteristic(blufi_env.handle_srvc, &blufi_char_uuid_p2e,
|
||||
(GATT_PERM_WRITE),
|
||||
(GATT_CHAR_PROP_BIT_WRITE),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,6 +9,11 @@
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "esp_blufi_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
|
||||
#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion
|
||||
@@ -193,5 +198,10 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_blufi_cb_deep_free(btc_msg_t *msg);
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -20,6 +20,10 @@
|
||||
#include "esp_gap_ble_api.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLUFI_APP_UUID 0xFFFF
|
||||
#define BLUFI_DEVICE_NAME "BLUFI_DEVICE"
|
||||
|
||||
@@ -96,4 +100,7 @@ void esp_blufi_send_encap(void *arg);
|
||||
int esp_blufi_handle_gap_events(struct ble_gap_event *event, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif/* _ESP_BLUFI_ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -21,6 +21,11 @@
|
||||
#define ESP_BLUFI_SUCCESS 0x00
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
||||
|
||||
@@ -100,4 +105,7 @@ void btc_blufi_call_deep_free(btc_msg_t *msg);
|
||||
|
||||
uint16_t btc_blufi_get_version(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __BTC_BLUFI_PRF_H__ */
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
#include "bt_common.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
#define BT_HCI_LOG_PRINT_TAG (1)
|
||||
#define BT_HCI_LOG_DATA_BUF_SIZE (1024 * HCI_LOG_DATA_BUFFER_SIZE)
|
||||
#define BT_HCI_LOG_ADV_BUF_SIZE (1024 * HCI_LOG_ADV_BUFFER_SIZE)
|
||||
|
||||
typedef struct {
|
||||
osi_mutex_t mutex_lock;
|
||||
uint64_t log_record_in;
|
||||
uint64_t log_record_out;
|
||||
uint64_t buf_size;
|
||||
uint8_t *p_hci_log_buffer;
|
||||
uint8_t index;
|
||||
bool overflow;
|
||||
} bt_hci_log_t;
|
||||
|
||||
static const char s_hex_to_char_mapping[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
static bt_hci_log_t g_bt_hci_log_data_ctl = {0};
|
||||
static bt_hci_log_t g_bt_hci_log_adv_ctl = {0};
|
||||
|
||||
esp_err_t bt_hci_log_init(void)
|
||||
{
|
||||
uint8_t *g_bt_hci_log_data_buffer = NULL;
|
||||
uint8_t *g_bt_hci_log_adv_buffer = NULL;
|
||||
|
||||
g_bt_hci_log_data_buffer = malloc(BT_HCI_LOG_DATA_BUF_SIZE);
|
||||
if (!g_bt_hci_log_data_buffer) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
g_bt_hci_log_adv_buffer = malloc(BT_HCI_LOG_ADV_BUF_SIZE);
|
||||
if (!g_bt_hci_log_adv_buffer) {
|
||||
if (g_bt_hci_log_data_buffer) {
|
||||
free(g_bt_hci_log_data_buffer);
|
||||
g_bt_hci_log_data_buffer = NULL;
|
||||
}
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
memset(g_bt_hci_log_data_buffer, 0, BT_HCI_LOG_DATA_BUF_SIZE);
|
||||
memset(g_bt_hci_log_adv_buffer, 0, BT_HCI_LOG_ADV_BUF_SIZE);
|
||||
|
||||
memset(&g_bt_hci_log_data_ctl, 0, sizeof(bt_hci_log_t));
|
||||
g_bt_hci_log_data_ctl.buf_size = BT_HCI_LOG_DATA_BUF_SIZE;
|
||||
g_bt_hci_log_data_ctl.p_hci_log_buffer = g_bt_hci_log_data_buffer;
|
||||
|
||||
memset(&g_bt_hci_log_adv_ctl, 0, sizeof(bt_hci_log_t));
|
||||
g_bt_hci_log_adv_ctl.buf_size = BT_HCI_LOG_ADV_BUF_SIZE;
|
||||
g_bt_hci_log_adv_ctl.p_hci_log_buffer = g_bt_hci_log_adv_buffer;
|
||||
|
||||
osi_mutex_new((osi_mutex_t *)&g_bt_hci_log_data_ctl.mutex_lock);
|
||||
osi_mutex_new((osi_mutex_t *)&g_bt_hci_log_adv_ctl.mutex_lock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_hci_log_deinit(void)
|
||||
{
|
||||
if (g_bt_hci_log_data_ctl.p_hci_log_buffer) {
|
||||
free(g_bt_hci_log_data_ctl.p_hci_log_buffer);
|
||||
g_bt_hci_log_data_ctl.p_hci_log_buffer = NULL;
|
||||
}
|
||||
|
||||
if (g_bt_hci_log_adv_ctl.p_hci_log_buffer) {
|
||||
free(g_bt_hci_log_adv_ctl.p_hci_log_buffer);
|
||||
g_bt_hci_log_adv_ctl.p_hci_log_buffer = NULL;
|
||||
}
|
||||
|
||||
osi_mutex_free((osi_mutex_t *)&g_bt_hci_log_data_ctl.mutex_lock);
|
||||
osi_mutex_free((osi_mutex_t *)&g_bt_hci_log_adv_ctl.mutex_lock);
|
||||
|
||||
memset(&g_bt_hci_log_data_ctl, 0, sizeof(bt_hci_log_t));
|
||||
memset(&g_bt_hci_log_adv_ctl, 0, sizeof(bt_hci_log_t));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if (BT_HCI_LOG_PRINT_TAG)
|
||||
static char IRAM_ATTR *bt_data_type_to_str(uint8_t data_type)
|
||||
{
|
||||
char *tag = NULL;
|
||||
switch (data_type)
|
||||
{
|
||||
case HCI_LOG_DATA_TYPE_COMMAND:
|
||||
// hci cmd data
|
||||
tag = "C";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_H2C_ACL:
|
||||
// host to controller hci acl data
|
||||
tag = "H";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_SCO:
|
||||
// hci sco data
|
||||
tag = "S";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_EVENT:
|
||||
// hci event
|
||||
tag = "E";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_ADV:
|
||||
// controller adv report data
|
||||
tag = NULL;
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_C2H_ACL:
|
||||
// controller to host hci acl data
|
||||
tag = "D";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_SELF_DEFINE:
|
||||
// self-defining data
|
||||
tag = "S";
|
||||
break;
|
||||
default:
|
||||
// unknown data type
|
||||
tag = "U";
|
||||
break;
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
#endif
|
||||
|
||||
void bt_hci_log_record_hex(bt_hci_log_t *p_hci_log_ctl, uint8_t *hex, uint8_t hex_len)
|
||||
{
|
||||
uint8_t hci_log_char;
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
while (hex_len--)
|
||||
{
|
||||
hci_log_char = ((*hex) >> 4);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = s_hex_to_char_mapping [hci_log_char];
|
||||
|
||||
if (++ p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
hci_log_char = ((*hex) & 0x0f);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = s_hex_to_char_mapping [hci_log_char];
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = ' ';
|
||||
|
||||
if (++ p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
++ hex;
|
||||
}
|
||||
}
|
||||
|
||||
void bt_hci_log_record_string(bt_hci_log_t *p_hci_log_ctl, char *string)
|
||||
{
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
while (*string != '\0') {
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = *string;
|
||||
++string;
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_data(bt_hci_log_t *p_hci_log_ctl, char *str, uint8_t data_type, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
osi_mutex_t mutex_lock;
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
if (!p_hci_log_ctl->p_hci_log_buffer) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
if (!g_hci_log_buffer) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
mutex_lock = p_hci_log_ctl->mutex_lock;
|
||||
osi_mutex_lock(&mutex_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
#if (1)
|
||||
// Add hci data index
|
||||
bt_hci_log_record_hex(p_hci_log_ctl, &p_hci_log_ctl->index, 1);
|
||||
#endif
|
||||
|
||||
#if (BT_HCI_LOG_PRINT_TAG)
|
||||
char *tag = NULL;
|
||||
tag = bt_data_type_to_str(data_type);
|
||||
|
||||
if (tag) {
|
||||
bt_hci_log_record_string(p_hci_log_ctl, tag);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = ':';
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (str) {
|
||||
bt_hci_log_record_string(p_hci_log_ctl, str);
|
||||
}
|
||||
|
||||
bt_hci_log_record_hex(p_hci_log_ctl, data, data_len);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = '\n';
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
p_hci_log_ctl->index ++;
|
||||
|
||||
osi_mutex_unlock(&mutex_lock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void bt_hci_log_data_show(bt_hci_log_t *p_hci_log_ctl)
|
||||
{
|
||||
volatile uint64_t log_record_in,log_record_out;
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
if (!p_hci_log_ctl->p_hci_log_buffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
osi_mutex_t mutex_lock = p_hci_log_ctl->mutex_lock;
|
||||
|
||||
osi_mutex_lock(&mutex_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
log_record_in = p_hci_log_ctl->log_record_in;
|
||||
log_record_out = p_hci_log_ctl->log_record_out;
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
if (p_hci_log_ctl->overflow) {
|
||||
log_record_out = log_record_in;
|
||||
printf("%c",g_hci_log_buffer[log_record_out]);
|
||||
|
||||
if (++log_record_out >= p_hci_log_ctl->buf_size) {
|
||||
log_record_out = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while (log_record_in != log_record_out)
|
||||
{
|
||||
printf("%c",g_hci_log_buffer[log_record_out]);
|
||||
|
||||
if (++log_record_out >= p_hci_log_ctl->buf_size) {
|
||||
log_record_out = 0;
|
||||
}
|
||||
}
|
||||
|
||||
p_hci_log_ctl->log_record_out = log_record_out;
|
||||
p_hci_log_ctl->overflow = false;
|
||||
|
||||
osi_mutex_unlock(&mutex_lock);
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_hci_data(uint8_t data_type, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
return bt_hci_log_record_data(&g_bt_hci_log_data_ctl, NULL, data_type, data, data_len);
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_custom_data(char *string, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
return bt_hci_log_record_data(&g_bt_hci_log_data_ctl, string, HCI_LOG_DATA_TYPE_SELF_DEFINE, data, data_len);
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_hci_adv(uint8_t data_type, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
return bt_hci_log_record_data(&g_bt_hci_log_adv_ctl, NULL, data_type, data, data_len);
|
||||
}
|
||||
|
||||
void bt_hci_log_hci_data_show(void)
|
||||
{
|
||||
bt_hci_log_data_show(&g_bt_hci_log_data_ctl);
|
||||
}
|
||||
|
||||
void bt_hci_log_hci_adv_show(void)
|
||||
{
|
||||
bt_hci_log_data_show(&g_bt_hci_log_adv_ctl);
|
||||
}
|
||||
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_BT_HCI_LOG_H__
|
||||
#define __ESP_BT_HCI_LOG_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define HCI_LOG_DATA_TYPE_COMMAND (1)
|
||||
#define HCI_LOG_DATA_TYPE_H2C_ACL (2)
|
||||
#define HCI_LOG_DATA_TYPE_SCO (3)
|
||||
#define HCI_LOG_DATA_TYPE_EVENT (4)
|
||||
#define HCI_LOG_DATA_TYPE_ADV (5)
|
||||
#define HCI_LOG_DATA_TYPE_SELF_DEFINE (6)
|
||||
#define HCI_LOG_DATA_TYPE_C2H_ACL (7)
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to record self-defining data
|
||||
* @param string : data identification
|
||||
* @param data : data
|
||||
* @param data_len : the length of data
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_record_custom_data(char *string, uint8_t *data, uint8_t data_len);
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to print all hci data record
|
||||
*
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void bt_hci_log_hci_data_show(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to print all adv report
|
||||
*
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void bt_hci_log_hci_adv_show(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to init hci log env
|
||||
*
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to deinit hci debug mode,
|
||||
* and can only be called internally by Bluetooth
|
||||
*
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to record hci data without adv report event,
|
||||
* and can only be called internally by Bluetooth
|
||||
*
|
||||
* @param str : data type, define in bt_data_type_to_str()
|
||||
* @param data : data
|
||||
* @param data_len : the length of data
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_record_hci_data(uint8_t data_type, uint8_t *data, uint8_t data_len);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to record hci adv report event only
|
||||
* and can only be called internally by Bluetooth
|
||||
*
|
||||
* @param str : data type, define in bt_data_type_to_str()
|
||||
* @param data : data
|
||||
* @param data_len : the length of data
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_record_hci_adv(uint8_t data_type, uint8_t *data, uint8_t data_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BT_HCI_LOG_H__ */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -64,6 +64,24 @@
|
||||
#define BT_BLE_DYNAMIC_ENV_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_LOG_DEBUG_EN
|
||||
#define BT_HCI_LOG_INCLUDED UC_BT_HCI_LOG_DEBUG_EN
|
||||
#else
|
||||
#define BT_HCI_LOG_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define HCI_LOG_DATA_BUFFER_SIZE UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
#define HCI_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_ADV_BUFFER_SIZE
|
||||
#define HCI_LOG_ADV_BUFFER_SIZE UC_BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
#else
|
||||
#define HCI_LOG_ADV_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
/* OS Configuration from User config (eg: sdkconfig) */
|
||||
#define TASK_PINNED_TO_CORE UC_TASK_PINNED_TO_CORE
|
||||
#define BT_TASK_MAX_PRIORITIES configMAX_PRIORITIES
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -39,7 +39,7 @@
|
||||
* Thread/Task reference
|
||||
**********************************************************/
|
||||
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
|
||||
#define UC_TASK_PINNED_TO_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#define UC_TASK_PINNED_TO_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#else
|
||||
#define UC_TASK_PINNED_TO_CORE (0)
|
||||
#endif
|
||||
@@ -50,6 +50,15 @@
|
||||
#define UC_BTC_TASK_STACK_SIZE 4096
|
||||
#endif
|
||||
|
||||
/**********************************************************
|
||||
* Alarm reference
|
||||
**********************************************************/
|
||||
#ifdef CONFIG_BT_ALARM_MAX_NUM
|
||||
#define UC_ALARM_MAX_NUM CONFIG_BT_ALARM_MAX_NUM
|
||||
#else
|
||||
#define UC_ALARM_MAX_NUM 50
|
||||
#endif
|
||||
|
||||
/**********************************************************
|
||||
* Trace reference
|
||||
**********************************************************/
|
||||
@@ -98,4 +107,22 @@
|
||||
#define UC_BT_BLUEDROID_MEM_DEBUG FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_DEBUG_EN
|
||||
#define UC_BT_HCI_LOG_DEBUG_EN TRUE
|
||||
#else
|
||||
#define UC_BT_HCI_LOG_DEBUG_EN FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
#define UC_BT_HCI_LOG_ADV_BUFFER_SIZE CONFIG_BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
#else
|
||||
#define UC_BT_HCI_LOG_ADV_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
#endif /* __BT_USER_CONFIG_H__ */
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_timer.h"
|
||||
#include "bt_user_config.h"
|
||||
|
||||
typedef struct alarm_t osi_alarm_t;
|
||||
typedef uint64_t period_ms_t;
|
||||
@@ -33,7 +34,7 @@ typedef enum {
|
||||
OSI_ALARM_ERR_INVALID_STATE = -3,
|
||||
} osi_alarm_err_t;
|
||||
|
||||
#define ALARM_CBS_NUM 50
|
||||
#define ALARM_CBS_NUM UC_ALARM_MAX_NUM
|
||||
#define ALARM_ID_BASE 1000
|
||||
|
||||
int osi_alarm_create_mux(void);
|
||||
|
||||
@@ -172,7 +172,7 @@ config BTDM_CTRL_PINNED_TO_CORE
|
||||
choice BTDM_CTRL_HCI_MODE_CHOICE
|
||||
prompt "HCI mode"
|
||||
help
|
||||
Speicify HCI mode as VHCI or UART(H4)
|
||||
Specify HCI mode as VHCI or UART(H4)
|
||||
|
||||
config BTDM_CTRL_HCI_MODE_VHCI
|
||||
bool "VHCI"
|
||||
@@ -398,6 +398,14 @@ config BTDM_CTRL_FULL_SCAN_SUPPORTED
|
||||
The full scan function is mainly used to provide BLE scan performance.
|
||||
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
|
||||
|
||||
config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
bool "Disable active scan backoff"
|
||||
default n
|
||||
help
|
||||
Disable active scan backoff. The bluetooth spec requires that scanners should run a backoff procedure to
|
||||
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
|
||||
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.
|
||||
|
||||
config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
|
||||
|
||||
+139
-57
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -25,7 +25,9 @@
|
||||
#include "esp_task.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_attr.h"
|
||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||
#include "esp_phy_init.h"
|
||||
#endif
|
||||
#include "esp_bt.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
@@ -35,7 +37,9 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#ifdef CONFIG_ESP_COEX_ENABLED
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#endif
|
||||
#include "esp_timer.h"
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
#include "esp_ipc.h"
|
||||
@@ -89,7 +93,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010004
|
||||
#define OSI_VERSION 0x00010005
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
@@ -176,6 +180,7 @@ struct osi_funcs_t {
|
||||
void (*_interrupt_l3_restore)(void);
|
||||
void *(* _customer_queue_create)(uint32_t queue_len, uint32_t item_size);
|
||||
int (* _coex_version_get)(unsigned int *major, unsigned int *minor, unsigned int *patch);
|
||||
void (* _patch_apply)(void);
|
||||
uint32_t _magic;
|
||||
};
|
||||
|
||||
@@ -232,16 +237,16 @@ extern uint32_t _data_end_btdm_rom;
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _nimble_bss_start;
|
||||
extern uint32_t _nimble_bss_end;
|
||||
extern uint32_t _btdm_bss_start;
|
||||
extern uint32_t _btdm_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
extern uint32_t _bt_controller_bss_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
extern uint32_t _nimble_data_start;
|
||||
extern uint32_t _nimble_data_end;
|
||||
extern uint32_t _btdm_data_start;
|
||||
extern uint32_t _btdm_data_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
extern uint32_t _bt_controller_data_end;
|
||||
|
||||
extern void config_bt_funcs_reset(void);
|
||||
extern void config_ble_funcs_reset(void);
|
||||
extern void config_btdm_funcs_reset(void);
|
||||
|
||||
/* Local Function Declare
|
||||
*********************************************************************
|
||||
@@ -315,6 +320,7 @@ static void *customer_queue_create_hlevel_wrapper(uint32_t queue_len, uint32_t i
|
||||
static void interrupt_l3_disable(void);
|
||||
static void interrupt_l3_restore(void);
|
||||
static void bt_controller_deinit_internal(void);
|
||||
static void patch_apply(void);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@@ -402,6 +408,7 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._customer_queue_create = NULL,
|
||||
#endif /* CONFIG_BTDM_CTRL_HLI */
|
||||
._coex_version_get = coex_version_get_wrapper,
|
||||
._patch_apply = patch_apply,
|
||||
._magic = OSI_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
@@ -753,7 +760,7 @@ static int32_t queue_send_hlevel_wrapper(void *queue, void *item, uint32_t block
|
||||
* @param item The message which will be send
|
||||
* @param hptw need do task yield or not
|
||||
* @return send success or not
|
||||
* There is an issue here: When the queue is full, it may reture true but it send fail to the queue, sometimes.
|
||||
* There is an issue here: When the queue is full, it may return true but it send fail to the queue, sometimes.
|
||||
* But in Bluetooth controller's isr, We don't care about the return value.
|
||||
* It only required tp send success when the queue is empty all the time.
|
||||
* So, this function meets the requirement.
|
||||
@@ -823,7 +830,7 @@ static int32_t IRAM_ATTR queue_recv_from_isr_wrapper(void *queue, void *item, vo
|
||||
|
||||
static int32_t 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));
|
||||
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
@@ -1274,7 +1281,45 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
bool update = true;
|
||||
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
||||
@@ -1325,61 +1370,86 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == ESP_BT_MODE_BTDM) {
|
||||
mem_start = (intptr_t)&_btdm_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BTDM BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_btdm_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BTDM Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (mode == ESP_BT_MODE_BTDM) {
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
ret = esp_bt_mem_release_areas(&cont_data, &cont_bss);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret = esp_bt_controller_mem_release(mode);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode == ESP_BT_MODE_BTDM) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_nimble_bss_start;
|
||||
mem_end = (intptr_t)&_nimble_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_nimble_data_start;
|
||||
mem_end = (intptr_t)&_nimble_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
/* free data and BSS section for Bluetooth controller ROM code */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BTDM_CTRL_HLI
|
||||
@@ -1643,6 +1713,18 @@ static void bt_shutdown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static void patch_apply(void)
|
||||
{
|
||||
config_btdm_funcs_reset();
|
||||
|
||||
#ifndef CONFIG_BTDM_CTRL_MODE_BLE_ONLY
|
||||
config_bt_funcs_reset();
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY
|
||||
config_ble_funcs_reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
@@ -1676,7 +1758,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
|
||||
sdk_config_set_bt_pll_track_enable(true);
|
||||
|
||||
// inititalize bluetooth baseband
|
||||
// initialize bluetooth baseband
|
||||
btdm_check_and_init_bb();
|
||||
|
||||
ret = btdm_controller_enable(mode);
|
||||
@@ -1839,7 +1921,7 @@ esp_err_t esp_ble_scan_dupilcate_list_flush(void)
|
||||
|
||||
/**
|
||||
* This function re-write controller's function,
|
||||
* As coredump can not show paramerters in function which is in a .a file.
|
||||
* As coredump can not show parameters in function which is in a .a file.
|
||||
*
|
||||
* After coredump fixing this issue, just delete this function.
|
||||
*/
|
||||
|
||||
@@ -147,7 +147,7 @@ if BT_LE_EXT_ADV
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
@@ -349,7 +349,6 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
bool "Override TinyCrypt with mbedTLS for crypto computations"
|
||||
default y
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
select MBEDTLS_ECP_RESTARTABLE
|
||||
select MBEDTLS_CMAC_C
|
||||
help
|
||||
Enable this option to choose mbedTLS instead of TinyCrypt for crypto
|
||||
@@ -421,6 +420,26 @@ config BT_LE_SLEEP_ENABLE
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_LP_CLK_SRC
|
||||
prompt "BLE low power clock source"
|
||||
default BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
config BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
bool "Use main XTAL as RTC clock source"
|
||||
help
|
||||
User main XTAL as RTC clock source.
|
||||
This option is recommended if external 32.768k XTAL is not available.
|
||||
Using the external 32.768 kHz XTAL will have lower current consumption
|
||||
in light sleep compared to using the main XTAL.
|
||||
|
||||
config BT_LE_LP_CLK_SRC_DEFAULT
|
||||
bool "Use system RTC slow clock source"
|
||||
help
|
||||
Use the same slow clock source as system RTC
|
||||
Using any clock source other than external 32.768 kHz XTAL at pin0 supports only
|
||||
legacy ADV and SCAN due to low clock accuracy.
|
||||
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
bool "Use Esp Timer for callout"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -430,6 +449,7 @@ config BT_LE_USE_ESP_TIMER
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on BT_LE_ROLE_OBSERVER_ENABLE
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
@@ -464,3 +484,45 @@ config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
config BT_LE_RELEASE_IRAM_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
config BT_LE_ROLE_CENTROL_ENABLE
|
||||
bool "Enable BLE Centrol role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable centrol role function.
|
||||
|
||||
config BT_LE_ROLE_PERIPHERAL_ENABLE
|
||||
bool "Enable BLE Peripheral role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable Peripheral role function.
|
||||
|
||||
config BT_LE_ROLE_BROADCASTER_ENABLE
|
||||
bool "Enable BLE Broadcaster role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable broadcaster role function.
|
||||
|
||||
config BT_LE_ROLE_OBSERVER_ENABLE
|
||||
bool "Enable BLE Observer role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable observer role function.
|
||||
|
||||
+190
-49
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -16,26 +16,31 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "nimble/nimble_port.h"
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
#include "nimble/nimble_port_freertos.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "esp_log.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#ifdef CONFIG_ESP_COEX_ENABLED
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#endif
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
#include "ble_hci_trans.h"
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||
#include "esp_phy_init.h"
|
||||
#endif
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/modem_clkrst_reg.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
@@ -54,12 +59,14 @@
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/dport_access.h"
|
||||
|
||||
#include "hal/efuse_ll.h"
|
||||
#include "soc/rtc.h"
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -78,6 +85,11 @@
|
||||
#define ACL_DATA_MBUF_LEADINGSPCAE 4
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
|
||||
typedef enum ble_rtc_slow_clk_src {
|
||||
BT_SLOW_CLK_SRC_MAIN_XTAL,
|
||||
BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0,
|
||||
} ble_rtc_slow_clk_src_t;
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -156,15 +168,22 @@ extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t hand
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern void bt_track_pll_cap(void);
|
||||
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern const char *r_ble_controller_get_rom_compile_version(void);
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
extern uint32_t _iram_bt_text_start;
|
||||
extern uint32_t _bss_bt_end;
|
||||
#else
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
#endif
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
extern uint32_t _bt_controller_bss_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
extern uint32_t _bt_controller_data_end;
|
||||
|
||||
/* Local Function Declaration
|
||||
*********************************************************************
|
||||
*/
|
||||
@@ -362,7 +381,7 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
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));
|
||||
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
@@ -486,7 +505,7 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
esp_err_t controller_sleep_init(ble_rtc_slow_clk_src_t slow_clk_src)
|
||||
{
|
||||
esp_err_t rc = 0;
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
@@ -494,7 +513,11 @@ esp_err_t controller_sleep_init(void)
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0, 500 + BLE_RTC_DELAY_US);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||
if (slow_clk_src == BT_SLOW_CLK_SRC_MAIN_XTAL) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||
} else {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
@@ -545,37 +568,74 @@ void controller_sleep_deinit(void)
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
void ble_rtc_clk_init(void)
|
||||
static void esp_bt_rtc_slow_clk_select(ble_rtc_slow_clk_src_t slow_clk_src)
|
||||
{
|
||||
// modem_clkrst_reg
|
||||
// LP_TIMER_SEL_XTAL32K -> 0
|
||||
// LP_TIMER_SEL_XTAL -> 1
|
||||
// LP_TIMER_SEL_8M -> 0
|
||||
// LP_TIMER_SEL_RTC_SLOW -> 0
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
|
||||
/* Select slow clock source for BT momdule */
|
||||
switch (slow_clk_src) {
|
||||
case BT_SLOW_CLK_SRC_MAIN_XTAL:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
// LP_TIMER_CLK_DIV_NUM -> 130
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 129, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 129, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#else
|
||||
// LP_TIMER_CLK_DIV_NUM -> 250
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 249, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 249, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
|
||||
// MODEM_CLKRST_ETM_CLK_ACTIVE -> 1
|
||||
// MODEM_CLKRST_ETM_CLK_SEL -> 0
|
||||
break;
|
||||
case BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using external 32.768 kHz XTAL as clock source");
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 0, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported slow clock");
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_ETM_CLK_CONF_REG, 1, 1, MODEM_CLKRST_ETM_CLK_ACTIVE_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_ETM_CLK_CONF_REG, 1, 0, MODEM_CLKRST_ETM_CLK_SEL_S);
|
||||
}
|
||||
|
||||
static ble_rtc_slow_clk_src_t ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
ble_rtc_slow_clk_src_t slow_clk_src;
|
||||
|
||||
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
cfg->rtc_freq = 40000;
|
||||
#else
|
||||
cfg->rtc_freq = 32000;
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
slow_clk_src = BT_SLOW_CLK_SRC_MAIN_XTAL;
|
||||
#else
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) {
|
||||
cfg->rtc_freq = 32768;
|
||||
slow_clk_src = BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0;
|
||||
} else {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
cfg->rtc_freq = 40000;
|
||||
#else
|
||||
cfg->rtc_freq = 32000;
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
slow_clk_src = BT_SLOW_CLK_SRC_MAIN_XTAL;
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */
|
||||
esp_bt_rtc_slow_clk_select(slow_clk_src);
|
||||
return slow_clk_src;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ble_npl_count_info_t npl_info;
|
||||
ble_rtc_slow_clk_src_t rtc_clk_src;
|
||||
|
||||
memset(&npl_info, 0, sizeof(ble_npl_count_info_t));
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
@@ -587,7 +647,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ble_rtc_clk_init();
|
||||
rtc_clk_src = ble_rtc_clk_init(cfg);
|
||||
|
||||
ret = esp_register_ext_funcs(&ext_funcs_ro);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -595,6 +655,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
extern int esp_ble_rom_func_ptr_init_all(void);
|
||||
esp_ble_rom_func_ptr_init_all();
|
||||
#else
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Init only legacy adv and slave function");
|
||||
extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void);
|
||||
esp_ble_rom_func_ptr_init_legacy_adv_and_slave();
|
||||
#endif
|
||||
|
||||
/* Initialize the function pointers for OS porting */
|
||||
npl_freertos_funcs_init();
|
||||
struct npl_funcs_t *p_npl_funcs = npl_freertos_funcs_get();
|
||||
@@ -643,13 +712,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble rom commit:[%s]", r_ble_controller_get_rom_compile_version());
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -671,7 +742,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
|
||||
ret = controller_sleep_init();
|
||||
ret = controller_sleep_init(rtc_clk_src);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||
goto free_controller;
|
||||
@@ -840,9 +911,48 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_BT_RELEASE_IRAM
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if(area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||
/* Release Bluetooth text section and merge Bluetooth data, bss & text into a large free heap
|
||||
@@ -851,26 +961,58 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
* memory into 3 different regions (IRAM, BLE-IRAM, DRAM). So `ESP_SYSTEM_PMP_IDRAM_SPLIT` needs
|
||||
* to be disabled.
|
||||
*/
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "`ESP_SYSTEM_PMP_IDRAM_SPLIT` should be disabled!");
|
||||
assert(0);
|
||||
#error "ESP_SYSTEM_PMP_IDRAM_SPLIT should be disabled to allow BT to be released"
|
||||
#endif // CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
mem_start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start);
|
||||
mem_end = (intptr_t)&_bss_bt_end;
|
||||
#else
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
#endif // CONFIG_BT_RELEASE_IRAM
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Release BLE [0x%08x] - [0x%08x], len %d", mem_start,
|
||||
mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
if ((mode & ESP_BT_MODE_BLE) == 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
bt_area_t merged_region = {
|
||||
.start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start),
|
||||
.end = (intptr_t)&_bss_bt_end,
|
||||
.name = "BT Text, BSS and Data"
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_region);
|
||||
#else
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1235,4 +1377,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -46,6 +46,10 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||
#define DEFAULT_BT_LE_ROLE_BROADCASTER MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||
#else
|
||||
|
||||
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
@@ -57,13 +61,13 @@ extern "C" {
|
||||
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
|
||||
@@ -125,6 +129,29 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_CENTROL_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_PERIPHERAL_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_BROADCASTER_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_BROADCASTER (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_BROADCASTER (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_OBSERVER_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
@@ -23,7 +23,7 @@ config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
|
||||
default 0
|
||||
help
|
||||
BLE ACL buffer have two methods to be allocated. One is persistent allocating
|
||||
(alloate when controller initialise, never free until controller de-initialise)
|
||||
(allocate when controller initialise, never free until controller de-initialise)
|
||||
another is dynamically allocating (allocate before TX and free after TX).
|
||||
|
||||
choice BT_CTRL_PINNED_TO_CORE_CHOICE
|
||||
@@ -72,11 +72,11 @@ config BT_CTRL_HCI_TL
|
||||
HCI mode as VHCI or UART(H4)
|
||||
|
||||
config BT_CTRL_ADV_DUP_FILT_MAX
|
||||
int "The maxinum number of 5.0 extend duplicate scan filter"
|
||||
int "The maximum number of 5.0 extend duplicate scan filter"
|
||||
range 1 500
|
||||
default 30
|
||||
help
|
||||
The maxinum number of suplicate scan filter
|
||||
The maximum number of suplicate scan filter
|
||||
|
||||
choice BT_BLE_CCA_MODE
|
||||
prompt "BLE CCA mode"
|
||||
@@ -475,3 +475,17 @@ config BT_BLE_ADV_DATA_LENGTH_ZERO_AUX
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
|
||||
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
|
||||
|
||||
config BT_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment"
|
||||
default y
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_CTRL_LE_PING_EN
|
||||
bool "Enable LE Ping procedure"
|
||||
default y
|
||||
help
|
||||
If this option is disabled, The Controller will not start the LE authenticated payload timer.
|
||||
This option is used for some compatibility problems related to LE ping procedure.
|
||||
|
||||
+478
-330
@@ -22,7 +22,10 @@
|
||||
#include "esp_random.h"
|
||||
#include "esp_task.h"
|
||||
#include "esp_attr.h"
|
||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_private/phy.h"
|
||||
#endif
|
||||
#include "esp_bt.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
@@ -34,11 +37,12 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#ifdef CONFIG_ESP_COEX_ENABLED
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#endif
|
||||
#include "esp_timer.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_private/phy.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "riscv/interrupt.h"
|
||||
#include "esp32c3/rom/rom_layout.h"
|
||||
@@ -64,6 +68,7 @@
|
||||
// wakeup request sources
|
||||
enum {
|
||||
BTDM_ASYNC_WAKEUP_SRC_VHCI = 0,
|
||||
BTDM_ASYNC_WAKEUP_REQ_COEX,
|
||||
BTDM_ASYNC_WAKEUP_SRC_DISA,
|
||||
BTDM_ASYNC_WAKEUP_SRC_TMR,
|
||||
BTDM_ASYNC_WAKEUP_SRC_MAX,
|
||||
@@ -73,12 +78,12 @@ enum {
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t enable : 1; // whether low power mode is required
|
||||
uint32_t lpclk_sel : 2; // low power clock source
|
||||
uint32_t lpclk_sel : 3; // low power clock source
|
||||
uint32_t mac_bb_pd : 1; // whether hardware(MAC, BB) force-power-down is required during sleep
|
||||
uint32_t wakeup_timer_required : 1; // whether system timer is needed
|
||||
uint32_t no_light_sleep : 1; // do not allow system to enter light sleep after bluetooth is enabled
|
||||
uint32_t main_xtal_pu : 1; // power up main XTAL
|
||||
uint32_t reserved : 25; // reserved
|
||||
uint32_t reserved : 24; // reserved
|
||||
};
|
||||
uint32_t val;
|
||||
} btdm_lpcntl_t;
|
||||
@@ -110,7 +115,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010007
|
||||
#define OSI_VERSION 0x00010008
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
@@ -184,8 +189,12 @@ struct osi_funcs_t {
|
||||
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
|
||||
void (* _coex_wifi_sleep_set)(bool sleep);
|
||||
int (* _coex_core_ble_conn_dyn_prio_get)(bool *low, bool *high);
|
||||
int (* _coex_schm_register_btdm_callback)(void *callback);
|
||||
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
|
||||
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
|
||||
uint32_t (* _coex_schm_interval_get)(void);
|
||||
uint8_t (* _coex_schm_curr_period_get)(void);
|
||||
void *(* _coex_schm_curr_phase_get)(void);
|
||||
void (* _interrupt_on)(int intr_num);
|
||||
void (* _interrupt_off)(int intr_num);
|
||||
void (* _esp_hw_power_down)(void);
|
||||
@@ -193,6 +202,8 @@ struct osi_funcs_t {
|
||||
void (* _ets_backup_dma_copy)(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_rem);
|
||||
void (* _ets_delay_us)(uint32_t us);
|
||||
void (* _btdm_rom_table_ready)(void);
|
||||
bool (* _coex_bt_wakeup_request)(void);
|
||||
void (* _coex_bt_wakeup_request_end)(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -256,16 +267,12 @@ extern void btdm_cca_feature_enable(void);
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _btdm_bss_start;
|
||||
extern uint32_t _btdm_bss_end;
|
||||
extern uint32_t _nimble_bss_start;
|
||||
extern uint32_t _nimble_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
extern uint32_t _bt_controller_bss_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
extern uint32_t _btdm_data_start;
|
||||
extern uint32_t _btdm_data_end;
|
||||
extern uint32_t _nimble_data_start;
|
||||
extern uint32_t _nimble_data_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
extern uint32_t _bt_controller_data_end;
|
||||
|
||||
/* Local Function Declare
|
||||
*********************************************************************
|
||||
@@ -306,14 +313,20 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
|
||||
static void btdm_sleep_enter_phase2_wrapper(void);
|
||||
static void btdm_sleep_exit_phase3_wrapper(void);
|
||||
static void coex_wifi_sleep_set_hook(bool sleep);
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback);
|
||||
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 uint32_t coex_schm_interval_get_wrapper(void);
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void);
|
||||
static void * coex_schm_curr_phase_get_wrapper(void);
|
||||
static void interrupt_on_wrapper(int intr_num);
|
||||
static void interrupt_off_wrapper(int intr_num);
|
||||
static void btdm_hw_mac_power_up_wrapper(void);
|
||||
static void btdm_hw_mac_power_down_wrapper(void);
|
||||
static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem);
|
||||
static void btdm_funcs_table_ready_wrapper(void);
|
||||
static bool coex_bt_wakeup_request(void);
|
||||
static void coex_bt_wakeup_request_end(void);
|
||||
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
|
||||
@@ -371,8 +384,12 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
|
||||
._coex_wifi_sleep_set = coex_wifi_sleep_set_hook,
|
||||
._coex_core_ble_conn_dyn_prio_get = NULL,
|
||||
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
|
||||
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
|
||||
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
|
||||
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
|
||||
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
|
||||
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
|
||||
._interrupt_on = interrupt_on_wrapper,
|
||||
._interrupt_off = interrupt_off_wrapper,
|
||||
._esp_hw_power_down = btdm_hw_mac_power_down_wrapper,
|
||||
@@ -380,6 +397,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._ets_backup_dma_copy = btdm_backup_dma_copy_wrapper,
|
||||
._ets_delay_us = esp_rom_delay_us,
|
||||
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
|
||||
._coex_bt_wakeup_request = coex_bt_wakeup_request,
|
||||
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
|
||||
};
|
||||
|
||||
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
|
||||
@@ -400,7 +419,7 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0;
|
||||
// semaphore used for blocking VHCI API to wait for controller to wake up
|
||||
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
|
||||
// wakeup timer
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr = NULL;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
|
||||
@@ -463,9 +482,8 @@ static void interrupt_set_wrapper(int cpu_no, int intr_source, int intr_num, int
|
||||
{
|
||||
esp_rom_route_intr_matrix(cpu_no, intr_source, intr_num);
|
||||
#if __riscv
|
||||
esprv_intc_int_set_priority(intr_num, intr_prio);
|
||||
//esprv_intc_int_enable_level(1 << intr_num);
|
||||
esprv_intc_int_set_type(intr_num, 0);
|
||||
esprv_int_set_priority(intr_num, intr_prio);
|
||||
esprv_int_set_type(intr_num, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -637,7 +655,7 @@ static int IRAM_ATTR queue_recv_from_isr_wrapper(void *queue, void *item, void *
|
||||
|
||||
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));
|
||||
return (uint32_t)xTaskCreatePinnedToCore(task_func, name, stack_depth, param, prio, task_handle, (core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
@@ -853,6 +871,22 @@ static bool async_wakeup_request(int event)
|
||||
semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING);
|
||||
}
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
if (!btdm_power_state_active()) {
|
||||
do_wakeup_request = true;
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (s_lp_stat.pm_lock_released) {
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_wakeup_request();
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required && s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -872,6 +906,9 @@ static void async_wakeup_request_end(int event)
|
||||
case BTDM_ASYNC_WAKEUP_SRC_DISA:
|
||||
allow_to_sleep = true;
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
allow_to_sleep = false;
|
||||
break;
|
||||
default:
|
||||
allow_to_sleep = true;
|
||||
break;
|
||||
@@ -891,18 +928,25 @@ static void btdm_funcs_table_ready_wrapper(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
bool bt_async_wakeup_request(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_SRC_VHCI);
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
void bt_wakeup_request_end(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_SRC_VHCI);
|
||||
}
|
||||
|
||||
static bool coex_bt_wakeup_request(void)
|
||||
{
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
}
|
||||
|
||||
static void coex_bt_wakeup_request_end(void)
|
||||
{
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
return;
|
||||
}
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
@@ -939,145 +983,175 @@ static void btdm_controller_mem_init(void)
|
||||
btdm_controller_rom_data_init();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
/**
|
||||
* Release two memory areas to the heap. If both areas are consecutive, they will be released as
|
||||
* a single area.
|
||||
*/
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* if the addresses of rom btdm .data and .bss are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(ets_rom_layout_p->data_end_btdm == ets_rom_layout_p->bss_start_btdm) {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->bss_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->data_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
/* if the addresses of rom interface btdm .data and .bss are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(ets_rom_layout_p->data_end_interface_btdm == ets_rom_layout_p->bss_start_interface_btdm) {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->data_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)ets_rom_layout_p->bss_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
bt_area_t rom_btdm_data = {
|
||||
.start = (intptr_t) ets_rom_layout_p->data_start_btdm,
|
||||
.end = (intptr_t) ets_rom_layout_p->data_end_btdm,
|
||||
.name = "ROM btdm data",
|
||||
};
|
||||
bt_area_t rom_btdm_bss = {
|
||||
.start = (intptr_t)ets_rom_layout_p->bss_start_btdm,
|
||||
.end = (intptr_t)ets_rom_layout_p->bss_end_btdm,
|
||||
.name = "ROM btdm BSS",
|
||||
};
|
||||
bt_area_t rom_btdm_inter_data = {
|
||||
.start = (intptr_t) ets_rom_layout_p->data_start_interface_btdm,
|
||||
.end = (intptr_t) ets_rom_layout_p->data_end_interface_btdm,
|
||||
.name = "ROM interface btdm data",
|
||||
};
|
||||
bt_area_t rom_btdm_inter_bss = {
|
||||
.start = (intptr_t)ets_rom_layout_p->bss_start_interface_btdm,
|
||||
.end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm,
|
||||
.name = "ROM interface btdm BSS",
|
||||
};
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* Free BTDM memory used by the ROM */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&rom_btdm_data, &rom_btdm_bss);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&rom_btdm_inter_data, &rom_btdm_inter_bss);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* free data and BSS section for libbtdm_app.a */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&cont_data, &cont_bss);
|
||||
}
|
||||
/* free data and BSS section for Bluetooth controller ROM code */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret = esp_bt_controller_mem_release(mode);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* if the addresses of btdm .bss and bt .bss are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_bss_end == _btdm_bss_start) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_btdm_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BTDM BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
/* if the addresses of btdm .data and bt .data are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_data_end == _btdm_data_start) {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_btdm_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BTDM Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_nimble_bss_start;
|
||||
mem_end = (intptr_t)&_nimble_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
mem_start = (intptr_t)&_nimble_data_start;
|
||||
mem_end = (intptr_t)&_nimble_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
|
||||
/* free data and BSS section for Bluetooth controller ROM code */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
@@ -1112,6 +1186,147 @@ static void IRAM_ATTR btdm_mac_bb_power_up_cb(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
// init low-power control resources
|
||||
static esp_err_t btdm_low_power_mode_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
do {
|
||||
// set default values for global states or resources
|
||||
s_lp_stat.val = 0;
|
||||
s_lp_cntl.val = 0;
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
s_wakeup_req_sem = NULL;
|
||||
s_btdm_slp_tmr = NULL;
|
||||
|
||||
// configure and initialize resources
|
||||
s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0;
|
||||
s_lp_cntl.lpclk_sel = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? cfg->sleep_clock : ESP_BT_SLEEP_CLOCK_MAIN_XTAL;
|
||||
s_lp_cntl.no_light_sleep = 0;
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (!btdm_deep_sleep_mem_init()) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
break;
|
||||
}
|
||||
s_lp_cntl.mac_bb_pd = 1;
|
||||
#endif
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_lp_cntl.wakeup_timer_required = 1;
|
||||
#endif
|
||||
// async wakeup semaphore for VHCI
|
||||
s_wakeup_req_sem = semphr_create_wrapper(1, 0);
|
||||
if (s_wakeup_req_sem == NULL) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
break;
|
||||
}
|
||||
btdm_vnd_offload_task_register(BTDM_VND_OL_SIG_WAKEUP_TMR, btdm_sleep_exit_phase0);
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp",
|
||||
};
|
||||
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set default bluetooth sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) { // External 32 kHz XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() != SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
ESP_LOGW(BT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
s_lp_cntl.lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL;
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) { // Internal 136kHz RC oscillator
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) {
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 136kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is "
|
||||
"required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state.");
|
||||
} else {
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 136kHz RC oscillator not detected.");
|
||||
assert(0);
|
||||
}
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
ESP_LOGI(BT_LOG_TAG, "Bluetooth will use main XTAL as Bluetooth sleep clock.");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
}
|
||||
|
||||
bool select_src_ret __attribute__((unused));
|
||||
bool set_div_ret __attribute__((unused));
|
||||
if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON));
|
||||
s_lp_cntl.main_xtal_pu = 1;
|
||||
#endif
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() / MHZ);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 1 << (btdm_lpcycle_us_frac);
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = esp_clk_slowclk_cal_get();
|
||||
} else {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
break;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
break;
|
||||
}
|
||||
ESP_LOGW(BT_LOG_TAG, "light sleep mode will not be able to apply when bluetooth is enabled.");
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
break;
|
||||
} else {
|
||||
s_lp_stat.pm_lock_released = 1;
|
||||
}
|
||||
#endif
|
||||
} while (0);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void)
|
||||
{
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED &&
|
||||
btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
return ESP_BT_SLEEP_CLOCK_NONE;
|
||||
}
|
||||
|
||||
return s_lp_cntl.lpclk_sel;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err = ESP_FAIL;
|
||||
@@ -1147,6 +1362,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ESP_LOGE(BT_LOG_TAG, "SLEEP_MODE_1 enabled but sleep clock not configured");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (cfg->sleep_clock > ESP_BT_SLEEP_CLOCK_RTC_SLOW) {
|
||||
ESP_LOGE(BT_LOG_TAG, "SLEEP_MODE_1 is enabled but this sleep clock is not supported");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
// overwrite some parameters
|
||||
@@ -1172,133 +1391,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
ESP_LOGI(BT_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version());
|
||||
|
||||
// init low-power control resources
|
||||
do {
|
||||
// set default values for global states or resources
|
||||
s_lp_stat.val = 0;
|
||||
s_lp_cntl.val = 0;
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
s_wakeup_req_sem = NULL;
|
||||
s_btdm_slp_tmr = NULL;
|
||||
|
||||
// configure and initialize resources
|
||||
s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0;
|
||||
s_lp_cntl.no_light_sleep = 0;
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (!btdm_deep_sleep_mem_init()) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
s_lp_cntl.mac_bb_pd = 1;
|
||||
#endif
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_lp_cntl.wakeup_timer_required = 1;
|
||||
#endif
|
||||
// async wakeup semaphore for VHCI
|
||||
s_wakeup_req_sem = semphr_create_wrapper(1, 0);
|
||||
if (s_wakeup_req_sem == NULL) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
btdm_vnd_offload_task_register(BTDM_VND_OL_SIG_WAKEUP_TMR, btdm_sleep_exit_phase0);
|
||||
}
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp",
|
||||
};
|
||||
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
// set default bluetooth sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
// set default bluetooth sleep clock source
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL
|
||||
} else {
|
||||
ESP_LOGW(BT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
#elif (CONFIG_BT_CTRL_LPCLK_SEL_MAIN_XTAL)
|
||||
ESP_LOGI(BT_LOG_TAG, "Bluetooth will use main XTAL as Bluetooth sleep clock.");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
#elif (CONFIG_BT_CTRL_LPCLK_SEL_RTC_SLOW)
|
||||
// check whether or not internal 150 kHz RC oscillator is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) {
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is "
|
||||
"required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state.");
|
||||
} else {
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC oscillator not detected.");
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool select_src_ret __attribute__((unused));
|
||||
bool set_div_ret __attribute__((unused));
|
||||
if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON));
|
||||
s_lp_cntl.main_xtal_pu = 1;
|
||||
#endif
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() / MHZ);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 1 << (btdm_lpcycle_us_frac);
|
||||
} else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL32K) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
} else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_RTC_SLOW) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = esp_clk_slowclk_cal_get();
|
||||
} else {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
ESP_LOGW(BT_LOG_TAG, "light sleep mode will not be able to apply when bluetooth is enabled.");
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
} else {
|
||||
s_lp_stat.pm_lock_released = 1;
|
||||
}
|
||||
#endif
|
||||
} while (0);
|
||||
if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) {
|
||||
ESP_LOGE(BT_LOG_TAG, "Low power module initialization failed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
@@ -1336,69 +1432,70 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// deinit low power control resources
|
||||
static void btdm_low_power_mode_deinit(void)
|
||||
{
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (s_lp_cntl.mac_bb_pd) {
|
||||
btdm_deep_sleep_mem_deinit();
|
||||
s_lp_cntl.mac_bb_pd = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_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;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) {
|
||||
if (s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
}
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR);
|
||||
if (s_wakeup_req_sem != NULL) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
if (s_lp_cntl.main_xtal_pu) {
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF));
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
}
|
||||
|
||||
static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
// deinit low power control resources
|
||||
do {
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (s_lp_cntl.mac_bb_pd) {
|
||||
btdm_deep_sleep_mem_deinit();
|
||||
s_lp_cntl.mac_bb_pd = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_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;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
if (s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
}
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR);
|
||||
if (s_wakeup_req_sem != NULL) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
if (s_lp_cntl.main_xtal_pu) {
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF));
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
} while (0);
|
||||
btdm_low_power_mode_deinit();
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
#if CONFIG_MAC_BB_PD
|
||||
@@ -1677,4 +1774,55 @@ static void coex_wifi_sleep_set_hook(bool sleep)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback);
|
||||
#else
|
||||
return 0;
|
||||
#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 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 uint32_t coex_schm_interval_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_interval_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_period_get();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void * coex_schm_curr_phase_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_phase_get();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
|
||||
@@ -0,0 +1,563 @@
|
||||
|
||||
menu "HCI Config"
|
||||
|
||||
choice BT_LE_HCI_INTERFACE
|
||||
prompt "Select HCI interface"
|
||||
default BT_LE_HCI_INTERFACE_USE_RAM
|
||||
|
||||
config BT_LE_HCI_INTERFACE_USE_RAM
|
||||
bool "ram"
|
||||
help
|
||||
Use RAM as HCI interface
|
||||
config BT_LE_HCI_INTERFACE_USE_UART
|
||||
bool "uart"
|
||||
help
|
||||
Use UART as HCI interface
|
||||
endchoice
|
||||
|
||||
config BT_LE_HCI_UART_PORT
|
||||
int "HCI UART port"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 1
|
||||
help
|
||||
Set the port number of HCI UART
|
||||
|
||||
config BT_LE_HCI_UART_FLOWCTRL
|
||||
bool "HCI uart Hardware Flow ctrl"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default n
|
||||
|
||||
config BT_LE_HCI_UART_TX_PIN
|
||||
int "HCI uart Tx gpio"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 19
|
||||
|
||||
config BT_LE_HCI_UART_RX_PIN
|
||||
int "HCI uart Rx gpio"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 10
|
||||
|
||||
config BT_LE_HCI_UART_RTS_PIN
|
||||
int "HCI uart RTS gpio"
|
||||
depends on BT_LE_HCI_UART_FLOWCTRL
|
||||
default 4
|
||||
|
||||
config BT_LE_HCI_UART_CTS_PIN
|
||||
int "HCI uart CTS gpio"
|
||||
depends on BT_LE_HCI_UART_FLOWCTRL
|
||||
default 5
|
||||
|
||||
config BT_LE_HCI_UART_BAUD
|
||||
int "HCI uart baudrate"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 921600
|
||||
help
|
||||
HCI uart baud rate 115200 ~ 1000000
|
||||
|
||||
choice BT_LE_HCI_UART_PARITY
|
||||
prompt "select uart parity"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default BT_LE_HCI_UART_UART_PARITY_DISABLE
|
||||
|
||||
config BT_LE_HCI_UART_UART_PARITY_DISABLE
|
||||
bool "PARITY_DISABLE"
|
||||
help
|
||||
UART_PARITY_DISABLE
|
||||
config BT_LE_HCI_UART_UART_PARITY_EVEN
|
||||
bool "PARITY_EVEN"
|
||||
help
|
||||
UART_PARITY_EVEN
|
||||
config BT_LE_HCI_UART_UART_PARITY_ODD
|
||||
bool "PARITY_ODD"
|
||||
help
|
||||
UART_PARITY_ODD
|
||||
endchoice
|
||||
|
||||
config BT_LE_HCI_UART_TASK_STACK_SIZE
|
||||
int "HCI uart task stack size"
|
||||
depends on BT_LE_HCI_INTERFACE_USE_UART
|
||||
default 1000
|
||||
help
|
||||
Set the size of uart task stack
|
||||
endmenu
|
||||
|
||||
config BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
|
||||
bool
|
||||
default y
|
||||
help
|
||||
Enable NPL porting for controller.
|
||||
|
||||
|
||||
menuconfig BT_LE_50_FEATURE_SUPPORT
|
||||
bool "Enable BLE 5 feature"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable BLE 5 feature
|
||||
|
||||
config BT_LE_LL_CFG_FEAT_LE_2M_PHY
|
||||
bool "Enable 2M Phy"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable 2M-PHY
|
||||
|
||||
config BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
bool "Enable coded Phy"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable coded-PHY
|
||||
|
||||
config BT_LE_EXT_ADV
|
||||
bool "Enable extended advertising"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT
|
||||
default y
|
||||
help
|
||||
Enable this option to do extended advertising. Extended advertising
|
||||
will be supported from BLE 5.0 onwards.
|
||||
|
||||
if BT_LE_EXT_ADV
|
||||
config BT_LE_MAX_EXT_ADV_INSTANCES
|
||||
int "Maximum number of extended advertising instances."
|
||||
range 0 4
|
||||
default 1
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Change this option to set maximum number of extended advertising
|
||||
instances. Minimum there is always one instance of
|
||||
advertising. Enter how many more advertising instances you
|
||||
want.
|
||||
Each extended advertising instance will take about 0.5k DRAM.
|
||||
|
||||
config BT_LE_EXT_ADV_MAX_SIZE
|
||||
int "Maximum length of the advertising data."
|
||||
range 0 1650
|
||||
default 1650
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Defines the length of the extended adv data. The value should not
|
||||
exceed 1650.
|
||||
|
||||
config BT_LE_ENABLE_PERIODIC_ADV
|
||||
bool "Enable periodic advertisement."
|
||||
default y
|
||||
depends on BT_LE_EXT_ADV
|
||||
help
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
This enables controller transfer periodic sync events to host
|
||||
|
||||
endif
|
||||
|
||||
config BT_LE_MAX_PERIODIC_SYNCS
|
||||
int "Maximum number of periodic advertising syncs"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
|
||||
|
||||
range 0 8
|
||||
default 1 if BT_LE_ENABLE_PERIODIC_ADV
|
||||
default 0
|
||||
help
|
||||
Set this option to set the upper limit for number of periodic sync
|
||||
connections. This should be less than maximum connections allowed by
|
||||
controller.
|
||||
|
||||
config BT_LE_MAX_PERIODIC_ADVERTISER_LIST
|
||||
int "Maximum number of periodic advertiser list"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED
|
||||
range 1 5
|
||||
default 5
|
||||
help
|
||||
Set this option to set the upper limit for number of periodic advertiser list.
|
||||
|
||||
config BT_LE_POWER_CONTROL_ENABLED
|
||||
bool "Enable controller support for BLE Power Control"
|
||||
depends on BT_LE_50_FEATURE_SUPPORT && !BT_NIMBLE_ENABLED && IDF_TARGET_ESP32C6
|
||||
default n
|
||||
help
|
||||
Set this option to enable the Power Control feature on controller
|
||||
|
||||
menu "Memory Settings"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
config BT_LE_MSYS_1_BLOCK_COUNT
|
||||
int "MSYS_1 Block Count"
|
||||
default 12
|
||||
help
|
||||
MSYS is a system level mbuf registry. For prepare write & prepare
|
||||
responses MBUFs are allocated out of msys_1 pool. For NIMBLE_MESH
|
||||
enabled cases, this block count is increased by 8 than user defined
|
||||
count.
|
||||
|
||||
config BT_LE_MSYS_1_BLOCK_SIZE
|
||||
int "MSYS_1 Block Size"
|
||||
default 256
|
||||
help
|
||||
Dynamic memory size of block 1
|
||||
|
||||
config BT_LE_MSYS_2_BLOCK_COUNT
|
||||
int "MSYS_2 Block Count"
|
||||
default 24
|
||||
help
|
||||
Dynamic memory count
|
||||
|
||||
config BT_LE_MSYS_2_BLOCK_SIZE
|
||||
int "MSYS_2 Block Size"
|
||||
default 320
|
||||
help
|
||||
Dynamic memory size of block 2
|
||||
|
||||
config BT_LE_MSYS_BUF_FROM_HEAP
|
||||
bool "Get Msys Mbuf from heap"
|
||||
default y
|
||||
depends on BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
help
|
||||
This option sets the source of the shared msys mbuf memory between
|
||||
the Host and the Controller. Allocate the memory from the heap if
|
||||
this option is sets, from the mempool otherwise.
|
||||
|
||||
config BT_LE_ACL_BUF_COUNT
|
||||
int "ACL Buffer count"
|
||||
default 10
|
||||
help
|
||||
The number of ACL data buffers.
|
||||
|
||||
config BT_LE_ACL_BUF_SIZE
|
||||
int "ACL Buffer size"
|
||||
default 517
|
||||
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)
|
||||
|
||||
config BT_LE_HCI_EVT_BUF_SIZE
|
||||
int "HCI Event Buffer size"
|
||||
default 257 if BT_LE_EXT_ADV
|
||||
default 70
|
||||
help
|
||||
This is the size of each HCI event buffer in bytes. In case of
|
||||
extended advertising, packets can be fragmented. 257 bytes is the
|
||||
maximum size of a packet.
|
||||
|
||||
config BT_LE_HCI_EVT_HI_BUF_COUNT
|
||||
int "High Priority HCI Event Buffer count"
|
||||
default 30
|
||||
help
|
||||
This is the high priority HCI events' buffer size. High-priority
|
||||
event buffers are for everything except advertising reports. If there
|
||||
are no free high-priority event buffers then host will try to allocate a
|
||||
low-priority buffer instead
|
||||
|
||||
config BT_LE_HCI_EVT_LO_BUF_COUNT
|
||||
int "Low Priority HCI Event Buffer count"
|
||||
default 8
|
||||
help
|
||||
This is the low priority HCI events' buffer size. Low-priority event
|
||||
buffers are only used for advertising reports. If there are no free
|
||||
low-priority event buffers, then an incoming advertising report will
|
||||
get dropped
|
||||
endmenu
|
||||
|
||||
config BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
int "Controller task stack size"
|
||||
default 5120 if BLE_MESH
|
||||
default 4096
|
||||
help
|
||||
This configures stack size of NimBLE controller task
|
||||
|
||||
menuconfig BT_LE_CONTROLLER_LOG_ENABLED
|
||||
bool "Controller log enable"
|
||||
default n
|
||||
help
|
||||
Enable controller log
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_CTRL_ENABLED
|
||||
bool "enable controller log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable controller log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
bool "enable HCI log module"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable hci log module
|
||||
|
||||
config BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
bool "Controller log dump mode only"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default y
|
||||
help
|
||||
Only operate in dump mode
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF1_SIZE
|
||||
int "size of the first BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the first BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_CTRL_BUF2_SIZE
|
||||
int "size of the second BLE controller LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 1024
|
||||
help
|
||||
Configure the size of the second BLE controller LOG buffer.
|
||||
|
||||
config BT_LE_LOG_HCI_BUF_SIZE
|
||||
int "size of the BLE HCI LOG buffer"
|
||||
depends on BT_LE_CONTROLLER_LOG_ENABLED
|
||||
default 4096
|
||||
help
|
||||
Configure the size of the BLE HCI LOG buffer.
|
||||
|
||||
config BT_LE_LL_RESOLV_LIST_SIZE
|
||||
int "BLE LL Resolving list size"
|
||||
range 1 5
|
||||
default 4
|
||||
help
|
||||
Configure the size of resolving list used in link layer.
|
||||
|
||||
menuconfig BT_LE_SECURITY_ENABLE
|
||||
bool "Enable BLE SM feature"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable BLE sm feature
|
||||
|
||||
config BT_LE_SM_LEGACY
|
||||
bool "Security manager legacy pairing"
|
||||
depends on BT_LE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable security manager legacy pairing
|
||||
|
||||
config BT_LE_SM_SC
|
||||
bool "Security manager secure connections (4.2)"
|
||||
depends on BT_LE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable security manager secure connections
|
||||
|
||||
config BT_LE_SM_SC_DEBUG_KEYS
|
||||
bool "Use predefined public-private key pair"
|
||||
default n
|
||||
depends on BT_LE_SECURITY_ENABLE && BT_LE_SM_SC
|
||||
help
|
||||
If this option is enabled, SM uses predefined DH key pair as described
|
||||
in Core Specification, Vol. 3, Part H, 2.3.5.6.1. This allows to
|
||||
decrypt air traffic easily and thus should only be used for debugging.
|
||||
|
||||
config BT_LE_LL_CFG_FEAT_LE_ENCRYPTION
|
||||
bool "Enable LE encryption"
|
||||
depends on BT_LE_SECURITY_ENABLE
|
||||
default y
|
||||
help
|
||||
Enable encryption connection
|
||||
|
||||
config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
bool "Override TinyCrypt with mbedTLS for crypto computations"
|
||||
default y
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
select MBEDTLS_CMAC_C
|
||||
help
|
||||
Enable this option to choose mbedTLS instead of TinyCrypt for crypto
|
||||
computations.
|
||||
|
||||
config BT_LE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
range 1 15
|
||||
default 12
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
|
||||
help
|
||||
BLE list size
|
||||
|
||||
config BT_LE_LL_DUP_SCAN_LIST_COUNT
|
||||
int "BLE duplicate scan list count"
|
||||
range 5 100
|
||||
default 20
|
||||
help
|
||||
config the max count of duplicate scan list
|
||||
|
||||
config BT_LE_LL_SCA
|
||||
int "BLE Sleep clock accuracy"
|
||||
range 0 500
|
||||
default 60
|
||||
help
|
||||
Sleep clock accuracy of our device (in ppm)
|
||||
|
||||
config BT_LE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
range 1 70
|
||||
default 3
|
||||
help
|
||||
Defines maximum number of concurrent BLE connections. For ESP32, user
|
||||
is expected to configure BTDM_CTRL_BLE_MAX_CONN from controller menu
|
||||
along with this option. Similarly for ESP32-C3 or ESP32-S3, user is expected to
|
||||
configure BT_CTRL_BLE_MAX_ACT from controller menu.
|
||||
Each connection will take about 1k DRAM.
|
||||
|
||||
choice BT_LE_COEX_PHY_CODED_TX_RX_TLIM
|
||||
prompt "Coexistence: limit on MAX Tx/Rx time for coded-PHY connection"
|
||||
default BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
depends on ESP_COEX_SW_COEXIST_ENABLE
|
||||
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_LE_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_LE_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_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
int
|
||||
default 0 if !ESP_COEX_SW_COEXIST_ENABLE
|
||||
default 1 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EN
|
||||
default 0 if BT_LE_COEX_PHY_CODED_TX_RX_TLIM_DIS
|
||||
|
||||
config BT_LE_SLEEP_ENABLE
|
||||
bool "Enable BLE sleep"
|
||||
default n
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_LP_CLK_SRC
|
||||
prompt "BLE low power clock source"
|
||||
default BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
config BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
bool "Use main XTAL as RTC clock source"
|
||||
help
|
||||
User main XTAL as RTC clock source.
|
||||
This option is recommended if external 32.768k XTAL is not available.
|
||||
Using the external 32.768 kHz XTAL will have lower current consumption
|
||||
in light sleep compared to using the main XTAL.
|
||||
|
||||
config BT_LE_LP_CLK_SRC_DEFAULT
|
||||
bool "Use system RTC slow clock source"
|
||||
help
|
||||
Use the same slow clock source as system RTC
|
||||
Using any clock source other than external 32.768 kHz XTAL supports only
|
||||
legacy ADV and SCAN due to low clock accuracy.
|
||||
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
bool "Enable Esp Timer for Callout"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Set this option to use Esp Timer which has higher priority timer
|
||||
instead of FreeRTOS timer
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that bluetooth host can save.If you set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, bluetooth host may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
config BT_LE_SCAN_DUPL
|
||||
bool "BLE Scan Duplicate Options"
|
||||
default y
|
||||
help
|
||||
This select enables parameters setting of BLE scan duplicate.
|
||||
|
||||
choice BT_LE_SCAN_DUPL_TYPE
|
||||
prompt "Scan Duplicate Type"
|
||||
default BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
help
|
||||
Scan duplicate have three ways. one is "Scan Duplicate By Device Address", This way is to use
|
||||
advertiser address filtering. The adv packet of the same address is only allowed to be reported once.
|
||||
Another way is "Scan Duplicate By Device Address And Advertising Data". This way is to use advertising
|
||||
data and device address filtering. All different adv packets with the same address are allowed to be
|
||||
reported. The last way is "Scan Duplicate By Advertising Data". This way is to use advertising data
|
||||
filtering. All same advertising data only allow to be reported once even though they are from
|
||||
different devices.
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
bool "Scan Duplicate By Device Address"
|
||||
help
|
||||
This way is to use advertiser address filtering. The adv packet of the same address is only
|
||||
allowed to be reported once
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DATA
|
||||
bool "Scan Duplicate By Advertising Data"
|
||||
help
|
||||
This way is to use advertising data filtering. All same advertising data only allow to be reported
|
||||
once even though they are from different devices.
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
bool "Scan Duplicate By Device Address And Advertising Data"
|
||||
help
|
||||
This way is to use advertising data and device address filtering. All different adv packets with
|
||||
the same address are allowed to be reported.
|
||||
endchoice
|
||||
|
||||
config BT_LE_SCAN_DUPL_TYPE
|
||||
int
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
default 0 if BT_LE_SCAN_DUPL_TYPE_DEVICE
|
||||
default 1 if BT_LE_SCAN_DUPL_TYPE_DATA
|
||||
default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
|
||||
default 0
|
||||
|
||||
config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
depends on BT_LE_SCAN_DUPL
|
||||
range 0 1000
|
||||
default 0
|
||||
help
|
||||
If the period value is non-zero, the controller will periodically clear the device information
|
||||
stored in the scan duuplicate filter. If it is 0, the scan duuplicate filter will not be cleared
|
||||
until the scanning is disabled. Duplicate advertisements for this period should not be sent to the
|
||||
Host in advertising report events.
|
||||
There are two scenarios where the ADV packet will be repeatedly reported:
|
||||
1. The duplicate scan cache is full, the controller will delete the oldest device information and
|
||||
add new device information.
|
||||
2. When the refresh period is up, the controller will clear all device information and start filtering
|
||||
again.
|
||||
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool "Msys Mbuf Init in Controller"
|
||||
default y
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_BT_CFG_H__
|
||||
#define __ESP_BT_CFG_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "syscfg/syscfg.h"
|
||||
#endif
|
||||
|
||||
#define NIMBLE_LL_STACK_SIZE CONFIG_BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
#if CONFIG_BT_NIMBLE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
|
||||
#else
|
||||
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
|
||||
#endif
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST MYNEWT_VAL(BLE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS MYNEWT_VAL(BLE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_CONNECTIONS MYNEWT_VAL(BLE_MAX_CONNECTIONS)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_ACL_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_ACL_FROM_LL_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE MYNEWT_VAL(BLE_TRANSPORT_EVT_SIZE)
|
||||
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE)
|
||||
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES MYNEWT_VAL(BLE_MULTI_ADV_INSTANCES)
|
||||
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE MYNEWT_VAL(BLE_LL_WHITELIST_SIZE)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
|
||||
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED MYNEWT_VAL(BLE_POWER_CONTROL)
|
||||
#if defined(CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
#else
|
||||
|
||||
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
#define BLE_LL_SCAN_PHY_NUMBER_N (2)
|
||||
#else
|
||||
#define BLE_LL_SCAN_PHY_NUMBER_N (1)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
|
||||
#define DEFAULT_BT_LE_MAX_CONNECTIONS (CONFIG_BT_LE_MAX_CONNECTIONS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_CONNECTIONS (2)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ACL_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE (CONFIG_BT_LE_ACL_BUF_SIZE)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ACL_BUF_SIZE (255)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ACL_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT (CONFIG_BT_LE_ACL_BUF_COUNT)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ACL_BUF_COUNT (24)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (CONFIG_BT_LE_HCI_EVT_BUF_SIZE)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_HCI_EVT_BUF_SIZE (70)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
|
||||
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (CONFIG_BT_LE_EXT_ADV_MAX_SIZE)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_EXT_ADV_MAX_SIZE (31)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
|
||||
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (CONFIG_BT_LE_MAX_EXT_ADV_INSTANCES)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_EXT_ADV_INSTANCES (1)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_WHITELIST_SIZE)
|
||||
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (CONFIG_BT_LE_WHITELIST_SIZE)
|
||||
#else
|
||||
#define DEFAULT_BT_NIMBLE_WHITELIST_SIZE (12)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_HI_BUF_COUNT)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT (30)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (CONFIG_BT_LE_HCI_EVT_LO_BUF_COUNT)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT (8)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_POWER_CONTROL_ENABLED)
|
||||
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED (CONFIG_BT_LE_POWER_CONTROL_ENABLED)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED (0)
|
||||
#endif
|
||||
#if defined(CONFIG_BT_LE_50_FEATURE_SUPPORT)
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
|
||||
#else
|
||||
#define HCI_UART_EN 0 // hci ram mode
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
|
||||
#else
|
||||
#define NIMBLE_SLEEP_ENABLE 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_BT_LE_TX_CCA_ENABLED
|
||||
#define DEFAULT_BT_LE_TX_CCA_ENABLED (CONFIG_BT_LE_TX_CCA_ENABLED)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_TX_CCA_ENABLED (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_LE_CCA_RSSI_THRESH
|
||||
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (CONFIG_BT_LE_CCA_RSSI_THRESH)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_CCA_RSSI_THRESH (50)
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_SCAN_RSP_DATA_MAX_LEN_N DEFAULT_BT_LE_EXT_ADV_MAX_SIZE
|
||||
|
||||
|
||||
#if HCI_UART_EN
|
||||
#define DEFAULT_BT_LE_HCI_UART_TX_PIN (CONFIG_BT_LE_HCI_UART_TX_PIN)
|
||||
#define DEFAULT_BT_LE_HCI_UART_RX_PIN (CONFIG_BT_LE_HCI_UART_RX_PIN)
|
||||
#define DEFAULT_BT_LE_HCI_UART_PORT (CONFIG_BT_LE_HCI_UART_PORT)
|
||||
#define DEFAULT_BT_LE_HCI_UART_BAUD (CONFIG_BT_LE_HCI_UART_BAUD)
|
||||
#define DEFAULT_BT_LE_HCI_UART_DATA_BITS (UART_DATA_8_BITS)
|
||||
#define DEFAULT_BT_LE_HCI_UART_STOP_BITS (UART_STOP_BITS_1)
|
||||
#define DEFAULT_BT_LE_HCI_UART_PARITY (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_TASK_STACK_SIZE (CONFIG_BT_LE_HCI_UART_TASK_STACK_SIZE)
|
||||
#define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_HCI_UART_TX_PIN (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_RX_PIN (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_PORT (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_BAUD (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_DATA_BITS (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_STOP_BITS (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_PARITY (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_TASK_STACK_SIZE (0)
|
||||
#define DEFAULT_BT_LE_HCI_UART_FLOW_CTRL (0)
|
||||
#endif
|
||||
|
||||
/* Unchanged configuration */
|
||||
|
||||
#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)
|
||||
|
||||
#define RTC_FREQ_N (32768) /* in Hz */
|
||||
|
||||
#define BLE_LL_TX_PWR_DBM_N (9)
|
||||
|
||||
|
||||
#define RUN_BQB_TEST (0)
|
||||
#define RUN_QA_TEST (0)
|
||||
#define NIMBLE_DISABLE_SCAN_BACKOFF (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_BT_CFG_H__ */
|
||||
@@ -147,7 +147,7 @@ if BT_LE_EXT_ADV
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
@@ -365,7 +365,6 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
bool "Override TinyCrypt with mbedTLS for crypto computations"
|
||||
default y
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
select MBEDTLS_ECP_RESTARTABLE
|
||||
select MBEDTLS_CMAC_C
|
||||
help
|
||||
Enable this option to choose mbedTLS instead of TinyCrypt for crypto
|
||||
@@ -562,3 +561,17 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool "Msys Mbuf Init in Controller"
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
+150
-101
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "nimble/nimble_port.h"
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "nimble/nimble_port_freertos.h"
|
||||
#include "esp_private/esp_modem_clock.h"
|
||||
|
||||
@@ -23,19 +25,21 @@
|
||||
#include "esp_log.h"
|
||||
#endif // ESP_PLATFORM
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#ifdef CONFIG_ESP_COEX_ENABLED
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
#endif // CONFIG_ESP_COEX_ENABLED
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
#include "ble_hci_trans.h"
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
#ifdef CONFIG_ESP_PHY_ENABLED
|
||||
#include "esp_phy_init.h"
|
||||
#endif
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "hci_uart.h"
|
||||
#include "bt_osi_mem.h"
|
||||
@@ -121,7 +125,7 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
************************************************************************
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
@@ -129,12 +133,12 @@ extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_controller_deinit(void);
|
||||
extern int ble_controller_enable(uint8_t mode);
|
||||
extern int ble_controller_disable(void);
|
||||
extern int r_ble_controller_deinit(void);
|
||||
extern int r_ble_controller_enable(uint8_t mode);
|
||||
extern int r_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 r_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);
|
||||
@@ -147,17 +151,19 @@ extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
extern void esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern void r_esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
|
||||
const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern int r_ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int r_ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int r_ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern int esp_ble_register_bb_funcs(void);
|
||||
extern void esp_ble_unregister_bb_funcs(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -357,7 +363,7 @@ static int task_create_wrapper(void *task_func, const char *name, uint32_t stack
|
||||
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));
|
||||
(core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
@@ -512,25 +518,44 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
}
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
{
|
||||
uint8_t size;
|
||||
int extra = *(int *)arg;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
{
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
{
|
||||
esp_ble_set_wakeup_overhead(overhead);
|
||||
r_esp_ble_set_wakeup_overhead(overhead);
|
||||
}
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
|
||||
@@ -556,6 +581,9 @@ esp_err_t controller_sleep_init(void)
|
||||
goto error;
|
||||
}
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#if CONFIG_BT_LE_SLEEP_ENABLE && !CONFIG_MAC_BB_PD
|
||||
#error "CONFIG_MAC_BB_PD required for BLE light sleep to run properly"
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE && !CONFIG_MAC_BB_PD
|
||||
/* Create a new regdma link for BLE related register restoration */
|
||||
rc = sleep_modem_ble_mac_modem_state_init(1);
|
||||
assert(rc == 0);
|
||||
@@ -723,7 +751,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
ble_get_npl_element_info(cfg, &npl_info);
|
||||
r_ble_get_npl_element_info(cfg, &npl_info);
|
||||
npl_freertos_set_controller_npl_info(&npl_info);
|
||||
if (npl_freertos_mempool_init() != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl mempool init failed");
|
||||
@@ -780,13 +808,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
coex_init();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -804,11 +825,23 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto controller_init_err;
|
||||
goto modem_deint;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
ret = esp_ble_register_bb_funcs();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "esp_ble_register_bb_funcs failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
r_esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@@ -825,7 +858,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
||||
swap_in_place(mac, 6);
|
||||
esp_ble_ll_set_public_addr(mac);
|
||||
r_esp_ble_ll_set_public_addr(mac);
|
||||
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
@@ -835,13 +868,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_phy_modem_deinit();
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
@@ -872,10 +905,11 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* De-initialize default event queue */
|
||||
@@ -920,7 +954,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
if (ble_controller_enable(mode) != 0) {
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
@@ -948,7 +982,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (ble_controller_disable() != 0) {
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -986,70 +1020,86 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* If the addresses of btdm .bss and bt .bss are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_bss_end == _bt_controller_bss_start) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
/* If the addresses of btdm .data and bt .data are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_data_end == _bt_controller_data_start) {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1066,7 +1116,7 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1079,7 +1129,7 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL6:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL7:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL8:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1099,13 +1149,13 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
if (ble_txpwr_set(power_type, handle, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(power_type, handle, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1125,7 +1175,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL0:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL1:
|
||||
@@ -1136,7 +1186,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL6:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL7:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL8:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type);
|
||||
break;
|
||||
default:
|
||||
return ESP_PWR_LVL_INVALID;
|
||||
@@ -1158,11 +1208,11 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
tx_level = ble_txpwr_get(power_type, handle);
|
||||
tx_level = r_ble_txpwr_get(power_type, handle);
|
||||
break;
|
||||
default:
|
||||
return ESP_PWR_LVL_INVALID;
|
||||
@@ -1410,4 +1460,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ if BT_LE_EXT_ADV
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
@@ -356,7 +356,6 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
bool "Override TinyCrypt with mbedTLS for crypto computations"
|
||||
default y
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
select MBEDTLS_ECP_RESTARTABLE
|
||||
select MBEDTLS_CMAC_C
|
||||
help
|
||||
Enable this option to choose mbedTLS instead of TinyCrypt for crypto
|
||||
@@ -554,3 +553,17 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
+153
-109
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "nimble/nimble_port.h"
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "nimble/nimble_port_freertos.h"
|
||||
#include "esp_private/esp_modem_clock.h"
|
||||
|
||||
@@ -23,12 +25,12 @@
|
||||
#include "esp_log.h"
|
||||
#endif // ESP_PLATFORM
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
#ifdef CONFIG_ESP_COEX_ENABLED
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
#endif // CONFIG_ESP_COEX_ENABLED
|
||||
|
||||
#include "nimble/nimble_npl_os.h"
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
#include "ble_hci_trans.h"
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
@@ -59,8 +61,8 @@
|
||||
************************************************************************
|
||||
*/
|
||||
#define NIMBLE_PORT_LOG_TAG "BLE_INIT"
|
||||
#define OSI_COEX_VERSION 0x00010006
|
||||
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
|
||||
#define OSI_COEX_VERSION 0x00010006
|
||||
#define OSI_COEX_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
#define EXT_FUNC_VERSION 0x20221122
|
||||
#define EXT_FUNC_MAGIC_VALUE 0xA5A5A5A5
|
||||
@@ -115,7 +117,7 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
************************************************************************
|
||||
*/
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
extern int r_ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
@@ -123,35 +125,37 @@ extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_controller_deinit(void);
|
||||
extern int ble_controller_enable(uint8_t mode);
|
||||
extern int ble_controller_disable(void);
|
||||
extern int r_ble_controller_deinit(void);
|
||||
extern int r_ble_controller_enable(uint8_t mode);
|
||||
extern int r_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 r_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 uint32_t r_os_cputime_get32(void);
|
||||
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
extern void esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(uint8_t *size, uint8_t extra);
|
||||
extern void r_esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
extern void r_esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x,
|
||||
const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey);
|
||||
extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern int r_ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int r_ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int r_ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern int esp_ble_register_bb_funcs(void);
|
||||
extern void esp_ble_unregister_bb_funcs(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -351,7 +355,7 @@ static int task_create_wrapper(void *task_func, const char *name, uint32_t stack
|
||||
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));
|
||||
(core_id < CONFIG_FREERTOS_NUMBER_OF_CORES ? core_id : tskNO_AFFINITY));
|
||||
}
|
||||
|
||||
static void task_delete_wrapper(void *task_handle)
|
||||
@@ -501,27 +505,47 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
{
|
||||
uint8_t size;
|
||||
int extra = *(int *)arg;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Modem BLE MAC retention initialization");
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
{
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
{
|
||||
esp_ble_set_wakeup_overhead(overhead);
|
||||
r_esp_ble_set_wakeup_overhead(overhead);
|
||||
}
|
||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
{
|
||||
@@ -697,7 +721,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto free_mem;
|
||||
}
|
||||
|
||||
ble_get_npl_element_info(cfg, &npl_info);
|
||||
r_ble_get_npl_element_info(cfg, &npl_info);
|
||||
npl_freertos_set_controller_npl_info(&npl_info);
|
||||
if (npl_freertos_mempool_init() != 0) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl mempool init failed");
|
||||
@@ -711,10 +735,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
*/
|
||||
ble_npl_eventq_init(nimble_port_get_dflt_eventq());
|
||||
#endif // CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
/* Enable BT-related clocks */
|
||||
modem_clock_module_enable(PERIPH_BT_MODULE);
|
||||
modem_clock_module_mac_reset(PERIPH_BT_MODULE);
|
||||
/* Select slow clock source for BT momdule */
|
||||
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
esp_bt_rtc_slow_clk_select(MODEM_CLOCK_LPCLK_SRC_MAIN_XTAL);
|
||||
slow_clk_freq = 100000;
|
||||
@@ -753,13 +777,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
coex_init();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -777,11 +794,23 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto controller_init_err;
|
||||
goto modem_deint;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
ret = esp_ble_register_bb_funcs();
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "esp_ble_register_bb_funcs failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
ret = r_ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "r_ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
r_esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
|
||||
@@ -796,10 +825,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_read_mac((uint8_t *)mac, ESP_MAC_BT));
|
||||
swap_in_place(mac, 6);
|
||||
esp_ble_ll_set_public_addr(mac);
|
||||
r_esp_ble_ll_set_public_addr(mac);
|
||||
|
||||
ble_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
@@ -809,13 +837,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
os_msys_deinit();
|
||||
r_ble_controller_deinit();
|
||||
modem_deint:
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -844,10 +872,11 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
r_ble_controller_deinit();
|
||||
esp_ble_unregister_bb_funcs();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* De-initialize default event queue */
|
||||
@@ -892,7 +921,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
coex_enable();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
if (ble_controller_enable(mode) != 0) {
|
||||
if (r_ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
@@ -920,7 +949,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (ble_controller_disable() != 0) {
|
||||
if (r_ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
@@ -958,70 +987,86 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* If the addresses of btdm .bss and bt .bss are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_bss_end == _bt_controller_bss_start) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
/* If the addresses of btdm .data and bt .data are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_data_end == _bt_controller_data_start) {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1038,7 +1083,7 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1051,7 +1096,7 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL6:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL7:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL8:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1071,13 +1116,13 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
if (ble_txpwr_set(power_type, handle, power_level) == 0) {
|
||||
if (r_ble_txpwr_set(power_type, handle, power_level) == 0) {
|
||||
stat = ESP_OK;
|
||||
}
|
||||
break;
|
||||
@@ -1097,7 +1142,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
case ESP_BLE_PWR_TYPE_ADV:
|
||||
case ESP_BLE_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_PWR_TYPE_DEFAULT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL0:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL1:
|
||||
@@ -1108,7 +1153,7 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL6:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL7:
|
||||
case ESP_BLE_PWR_TYPE_CONN_HDL8:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_CONN, power_type);
|
||||
break;
|
||||
default:
|
||||
return ESP_PWR_LVL_INVALID;
|
||||
@@ -1130,11 +1175,11 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
|
||||
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
tx_level = r_ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
|
||||
break;
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
|
||||
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:
|
||||
tx_level = ble_txpwr_get(power_type, handle);
|
||||
tx_level = r_ble_txpwr_get(power_type, handle);
|
||||
break;
|
||||
default:
|
||||
return ESP_PWR_LVL_INVALID;
|
||||
@@ -1382,4 +1427,3 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -19,10 +19,9 @@ if BLE_MESH
|
||||
bool "Support Duplicate Scan in BLE Mesh"
|
||||
select BTDM_BLE_SCAN_DUPL if IDF_TARGET_ESP32
|
||||
select BTDM_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32
|
||||
select BT_CTRL_BLE_SCAN_DUPL if IDF_TARGET_ESP32C3
|
||||
select BT_CTRL_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32C3
|
||||
select BT_LE_SCAN_DUPL if IDF_TARGET_ESP32C6
|
||||
select BT_LE_SCAN_DUPL if IDF_TARGET_ESP32H2
|
||||
select BT_CTRL_BLE_SCAN_DUPL if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
|
||||
select BT_CTRL_BLE_MESH_SCAN_DUPL_EN if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
|
||||
select BT_LE_SCAN_DUPL if IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32H2
|
||||
select BT_NIMBLE_VS_SUPPORT if BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
|
||||
@@ -16,6 +16,6 @@ The ESP-BLE-MESH networking enables many-to-many (m:m) device communications and
|
||||
- [API Reference](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/esp-ble-mesh.html)
|
||||
|
||||
|
||||
### [ESP-BLE-MESH Examples](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh)
|
||||
### [ESP-BLE-MESH Examples](../../../examples/bluetooth/esp_ble_mesh)
|
||||
|
||||
- Refer to **ESP-BLE-MESH Examples** of [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp-ble-mesh/ble-mesh-index.html#getting-started-with-esp-ble-mesh) for the tutorials of ESP BLE Mesh examples.
|
||||
|
||||
@@ -96,7 +96,7 @@ esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
}
|
||||
|
||||
/* Take the Semaphore, wait BLE Mesh de-initialization to finish. */
|
||||
xSemaphoreTake(semaphore, portMAX_DELAY);
|
||||
__ASSERT(xSemaphoreTake(semaphore, 3000 / portTICK_PERIOD_MS) == pdTRUE, "BLE Mesh deinit take semaphore failed");
|
||||
/* Don't forget to delete the semaphore at the end. */
|
||||
vSemaphoreDelete(semaphore);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -576,9 +576,9 @@ esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_src) &&
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_dst) &&
|
||||
!ESP_BLE_MESH_ADDR_IS_GROUP(info->hb_dst)) {
|
||||
if (!(ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_src) &&
|
||||
(ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_dst) ||
|
||||
ESP_BLE_MESH_ADDR_IS_GROUP(info->hb_dst)))) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -33,7 +33,10 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
/**
|
||||
* @brief De-initialize BLE Mesh module.
|
||||
*
|
||||
* @note This function shall be invoked after esp_ble_mesh_client_model_deinit().
|
||||
* @note
|
||||
* 1. This function shall be invoked after esp_ble_mesh_client_model_deinit().
|
||||
* 2. This function is strictly forbidden to run in any BTC Task Context
|
||||
* (e.g. registered Mesh Event Callback).
|
||||
*
|
||||
* @param[in] param: Pointer to the structure of BLE Mesh deinit parameters.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -71,6 +71,29 @@
|
||||
#include "esp_ble_mesh_provisioning_api.h"
|
||||
#include "esp_ble_mesh_networking_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static SemaphoreHandle_t deinit_comp_semaphore;
|
||||
#endif
|
||||
|
||||
static inline void btc_ble_mesh_prov_cb_to_app_reprocess(esp_ble_mesh_prov_cb_event_t event,
|
||||
esp_ble_mesh_prov_cb_param_t *param)
|
||||
{
|
||||
switch (event) {
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
case ESP_BLE_MESH_DEINIT_MESH_COMP_EVT:
|
||||
assert(deinit_comp_semaphore);
|
||||
/* Give the semaphore when BLE Mesh de-initialization is finished.
|
||||
* @note: At nimble host, once this lock is released, it will cause
|
||||
* the btc task to be deleted.
|
||||
*/
|
||||
xSemaphoreGive(deinit_comp_semaphore);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t event,
|
||||
esp_ble_mesh_prov_cb_param_t *param)
|
||||
{
|
||||
@@ -79,6 +102,8 @@ static inline void btc_ble_mesh_prov_cb_to_app(esp_ble_mesh_prov_cb_event_t even
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
|
||||
btc_ble_mesh_prov_cb_to_app_reprocess(event, param);
|
||||
}
|
||||
|
||||
static inline void btc_ble_mesh_model_cb_to_app(esp_ble_mesh_model_cb_event_t event,
|
||||
@@ -2825,8 +2850,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
case BTC_BLE_MESH_ACT_DEINIT_MESH:
|
||||
act = ESP_BLE_MESH_DEINIT_MESH_COMP_EVT;
|
||||
param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param);
|
||||
/* Give the semaphore when BLE Mesh de-initialization is finished. */
|
||||
xSemaphoreGive(arg->mesh_deinit.semaphore);
|
||||
/* Temporarily save the deinit semaphore and release it after the mesh deinit complete event is handled in the app layer */
|
||||
deinit_comp_semaphore = arg->mesh_deinit.semaphore;
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
default:
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#ifndef _BLE_MESH_KERNEL_H_
|
||||
#define _BLE_MESH_KERNEL_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
@@ -22,7 +23,7 @@ extern "C" {
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
|
||||
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#else
|
||||
#define BLE_MESH_ADV_TASK_CORE (0)
|
||||
#endif
|
||||
@@ -30,7 +31,7 @@ extern "C" {
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
||||
#ifdef CONFIG_BT_NIMBLE_PINNED_TO_CORE
|
||||
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < CONFIG_FREERTOS_NUMBER_OF_CORES ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#else
|
||||
#define BLE_MESH_ADV_TASK_CORE (0)
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA
|
||||
* SPDX-FileCopyrightText: 2015-2016 Intel Corporation
|
||||
* SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ static struct bt_mesh_conn_cb *bt_mesh_gatts_conn_cb;
|
||||
static tBTA_GATTS_IF bt_mesh_gatts_if;
|
||||
static uint8_t bt_mesh_gatts_addr[BLE_MESH_ADDR_LEN];
|
||||
static uint16_t svc_handle, char_handle;
|
||||
static future_t *future_mesh;
|
||||
static future_t *gatts_future_mesh;
|
||||
|
||||
/* Static Functions */
|
||||
static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle);
|
||||
@@ -561,6 +561,9 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
case BTA_GATTS_REG_EVT:
|
||||
if (p_data->reg_oper.status == BTA_GATT_OK) {
|
||||
bt_mesh_gatts_if = p_data->reg_oper.server_if;
|
||||
future_ready(gatts_future_mesh, FUTURE_SUCCESS);
|
||||
} else {
|
||||
future_ready(gatts_future_mesh, FUTURE_FAIL);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_READ_EVT: {
|
||||
@@ -618,27 +621,27 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
svc_handle = p_data->create.service_id;
|
||||
BT_DBG("svc_handle %d, future_mesh %p", svc_handle, future_mesh);
|
||||
if (future_mesh != NULL) {
|
||||
future_ready(future_mesh, FUTURE_SUCCESS);
|
||||
BT_DBG("svc_handle %d, gatts_future_mesh %p", svc_handle, gatts_future_mesh);
|
||||
if (gatts_future_mesh != NULL) {
|
||||
future_ready(gatts_future_mesh, FUTURE_SUCCESS);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_ADD_INCL_SRVC_EVT:
|
||||
svc_handle = p_data->add_result.attr_id;
|
||||
if (future_mesh != NULL) {
|
||||
future_ready(future_mesh, FUTURE_SUCCESS);
|
||||
if (gatts_future_mesh != NULL) {
|
||||
future_ready(gatts_future_mesh, FUTURE_SUCCESS);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_EVT:
|
||||
char_handle = p_data->add_result.attr_id;
|
||||
if (future_mesh != NULL) {
|
||||
future_ready(future_mesh, FUTURE_SUCCESS);
|
||||
if (gatts_future_mesh != NULL) {
|
||||
future_ready(gatts_future_mesh, FUTURE_SUCCESS);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
char_handle = p_data->add_result.attr_id;
|
||||
if (future_mesh != NULL) {
|
||||
future_ready(future_mesh, FUTURE_SUCCESS);
|
||||
if (gatts_future_mesh != NULL) {
|
||||
future_ready(gatts_future_mesh, FUTURE_SUCCESS);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_DELELTE_EVT:
|
||||
@@ -962,11 +965,11 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
||||
if (svc->attrs[i].uuid->type == BLE_MESH_UUID_TYPE_16) {
|
||||
switch (BLE_MESH_UUID_16(svc->attrs[i].uuid)->val) {
|
||||
case BLE_MESH_UUID_GATT_PRIMARY_VAL: {
|
||||
future_mesh = future_new();
|
||||
gatts_future_mesh = future_new();
|
||||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, (struct bt_mesh_uuid *)svc->attrs[i].user_data);
|
||||
BTA_GATTS_CreateService(bt_mesh_gatts_if,
|
||||
&bta_uuid, 0, svc->attr_count, true);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
if (future_await(gatts_future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add primary service");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -976,11 +979,11 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_SECONDARY_VAL: {
|
||||
future_mesh = future_new();
|
||||
gatts_future_mesh = future_new();
|
||||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, (struct bt_mesh_uuid *)svc->attrs[i].user_data);
|
||||
BTA_GATTS_CreateService(bt_mesh_gatts_if,
|
||||
&bta_uuid, 0, svc->attr_count, false);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
if (future_await(gatts_future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add secondary service");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -993,11 +996,11 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
||||
break;
|
||||
}
|
||||
case BLE_MESH_UUID_GATT_CHRC_VAL: {
|
||||
future_mesh = future_new();
|
||||
gatts_future_mesh = future_new();
|
||||
struct bt_mesh_gatt_char *gatts_chrc = (struct bt_mesh_gatt_char *)svc->attrs[i].user_data;
|
||||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, gatts_chrc->uuid);
|
||||
BTA_GATTS_AddCharacteristic(svc_handle, &bta_uuid, bt_mesh_perm_to_bta_perm(svc->attrs[i + 1].perm), gatts_chrc->properties, NULL, NULL);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
if (future_await(gatts_future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add characteristic");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -1019,10 +1022,10 @@ int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc)
|
||||
case BLE_MESH_UUID_ES_CONFIGURATION_VAL:
|
||||
case BLE_MESH_UUID_ES_MEASUREMENT_VAL:
|
||||
case BLE_MESH_UUID_ES_TRIGGER_SETTING_VAL: {
|
||||
future_mesh = future_new();
|
||||
gatts_future_mesh = future_new();
|
||||
bta_uuid_to_bt_mesh_uuid(&bta_uuid, svc->attrs[i].uuid);
|
||||
BTA_GATTS_AddCharDescriptor(svc_handle, bt_mesh_perm_to_bta_perm(svc->attrs[i].perm), &bta_uuid, NULL, NULL);
|
||||
if (future_await(future_mesh) == FUTURE_FAIL) {
|
||||
if (future_await(gatts_future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Failed to add descriptor");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -1132,7 +1135,7 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
||||
|
||||
int bt_mesh_gatts_set_local_device_name(const char *name)
|
||||
{
|
||||
BTM_SetLocalDeviceName((char *)name);
|
||||
BTM_SetLocalDeviceName((char *)name, BT_DEVICE_TYPE_BLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1481,7 +1484,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
/* Register Notification fot Mesh Provisioning/Proxy Data Out Characteristic */
|
||||
/* Register Notification for Mesh Provisioning/Proxy Data Out Characteristic */
|
||||
status = BTA_GATTC_RegisterForNotifications(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].data_out_handle);
|
||||
if (status != BTA_GATT_OK) {
|
||||
@@ -1768,7 +1771,19 @@ void bt_mesh_gatt_init(void)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
tBT_UUID gatts_app_uuid = {LEN_UUID_128, {0}};
|
||||
memset(&gatts_app_uuid.uu.uuid128, BLE_MESH_GATTS_APP_UUID_BYTE, LEN_UUID_128);
|
||||
|
||||
gatts_future_mesh = future_new();
|
||||
if (!gatts_future_mesh) {
|
||||
BT_ERR("Mesh gatts sync lock alloc failed");
|
||||
return;
|
||||
}
|
||||
|
||||
BTA_GATTS_AppRegister(&gatts_app_uuid, bt_mesh_bta_gatts_cb);
|
||||
|
||||
if (future_await(gatts_future_mesh) == FUTURE_FAIL) {
|
||||
BT_ERR("Mesh gatts app register failed");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "mesh_v1.1/utils.h"
|
||||
|
||||
/* Minimum valid Mesh Network PDU length. The Network headers
|
||||
* themselves take up 9 bytes. After that there is a minumum of 1 byte
|
||||
* themselves take up 9 bytes. After that there is a minimum of 1 byte
|
||||
* payload for both CTL=1 and CTL=0 PDUs (smallest OpCode is 1 byte). CTL=1
|
||||
* PDUs must use a 64-bit (8 byte) NetMIC, whereas CTL=0 PDUs have at least
|
||||
* a 32-bit (4 byte) NetMIC and AppMIC giving again a total of 8 bytes.
|
||||
@@ -1751,9 +1751,7 @@ static bool ignore_net_msg(uint16_t src, uint16_t dst)
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
bt_mesh_is_provisioner_en() &&
|
||||
BLE_MESH_ADDR_IS_UNICAST(dst) &&
|
||||
bt_mesh_elem_find(dst)) {
|
||||
bt_mesh_is_provisioner_en()) {
|
||||
/* If the destination address of the message is the element
|
||||
* address of Provisioner, but Provisioner fails to find the
|
||||
* node in its provisioning database, then this message will
|
||||
@@ -1810,7 +1808,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi,
|
||||
bt_mesh_elem_find(rx.ctx.recv_dst));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
bt_mesh_private_gatt_proxy_state_get() == BLE_MESH_PRIVATE_GATT_PROXY_DISABLED &&
|
||||
bt_mesh_private_gatt_proxy_state_get() != BLE_MESH_PRIVATE_GATT_PROXY_ENABLED &&
|
||||
net_if == BLE_MESH_NET_IF_PROXY) {
|
||||
bt_mesh_proxy_server_addr_add(data, rx.ctx.addr);
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ static int provisioner_start_prov_pb_adv(const uint8_t uuid[16], const bt_mesh_a
|
||||
|
||||
if (is_unprov_dev_being_provision(uuid)) {
|
||||
bt_mesh_pb_adv_unlock();
|
||||
return -EALREADY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < CONFIG_BLE_MESH_PBA_SAME_TIME; i++) {
|
||||
@@ -428,7 +428,7 @@ static int provisioner_start_prov_pb_gatt(const uint8_t uuid[16], const bt_mesh_
|
||||
|
||||
if (is_unprov_dev_being_provision(uuid)) {
|
||||
bt_mesh_pb_gatt_unlock();
|
||||
return -EALREADY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = CONFIG_BLE_MESH_PBA_SAME_TIME; i < BLE_MESH_PROV_SAME_TIME; i++) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017 Intel Corporation
|
||||
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -121,22 +121,22 @@ static bt_mesh_mutex_t seg_rx_lock;
|
||||
|
||||
static inline void bt_mesh_seg_tx_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&seg_tx_lock);
|
||||
bt_mesh_r_mutex_lock(&seg_tx_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_seg_tx_unlock(void)
|
||||
{
|
||||
bt_mesh_mutex_unlock(&seg_tx_lock);
|
||||
bt_mesh_r_mutex_unlock(&seg_tx_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_seg_rx_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&seg_rx_lock);
|
||||
bt_mesh_r_mutex_lock(&seg_rx_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_seg_rx_unlock(void)
|
||||
{
|
||||
bt_mesh_mutex_unlock(&seg_rx_lock);
|
||||
bt_mesh_r_mutex_unlock(&seg_rx_lock);
|
||||
}
|
||||
|
||||
uint8_t bt_mesh_seg_send_interval(void)
|
||||
@@ -368,7 +368,6 @@ static void seg_tx_reset(struct seg_tx *tx)
|
||||
tx->cb_data = NULL;
|
||||
tx->seq_auth = 0U;
|
||||
tx->sub = NULL;
|
||||
tx->seg_n = 0;
|
||||
tx->last_seg_n = 0;
|
||||
tx->lsn_updated = 0;
|
||||
tx->dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
@@ -385,6 +384,7 @@ static void seg_tx_reset(struct seg_tx *tx)
|
||||
}
|
||||
|
||||
tx->nack_count = 0U;
|
||||
tx->seg_n = 0;
|
||||
|
||||
bt_mesh_seg_tx_unlock();
|
||||
|
||||
@@ -517,6 +517,12 @@ static bool send_next_segment(struct seg_tx *tx, int *result)
|
||||
|
||||
net_tx.ctx->net_idx = tx->sub->net_idx;
|
||||
|
||||
/**
|
||||
* Add one to the ref count only if the segment can be further
|
||||
* processed by the network.
|
||||
*/
|
||||
seg = net_buf_ref(seg);
|
||||
|
||||
err = bt_mesh_net_send(&net_tx, seg, &seg_sent_cb, tx);
|
||||
if (err) {
|
||||
BT_ERR("Send seg %u failed (err %d)", tx->last_seg_n, err);
|
||||
@@ -966,7 +972,18 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
||||
}
|
||||
}
|
||||
|
||||
tx->seg[seg_o] = net_buf_ref(seg);
|
||||
/**
|
||||
* If the net buffer allocation of the subsequent
|
||||
* segments of this segment message fails, it will
|
||||
* cause the ref count of the previously allocated
|
||||
* successful segments to not be unref, which will
|
||||
* cause the net buffer leakage to occur, so it is
|
||||
* necessary to wait until all the segments have been
|
||||
* allocated, and then when the segment is confirmed
|
||||
* that it will be network layer for further processing,
|
||||
* then ref of the net buffer should be plus one.
|
||||
*/
|
||||
tx->seg[seg_o] = seg;
|
||||
|
||||
BT_DBG("Seg %u/%u prepared", seg_o, tx->seg_n);
|
||||
}
|
||||
@@ -975,6 +992,11 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
|
||||
* tx->seg[0] will be NULL here.
|
||||
*/
|
||||
if (tx->seg[0]) {
|
||||
/**
|
||||
* Add one to the ref count only if the segment can be further
|
||||
* processed by the network.
|
||||
*/
|
||||
tx->seg[0] = net_buf_ref(tx->seg[0]);
|
||||
err = bt_mesh_net_send(net_tx, tx->seg[0], &seg_sent_cb, tx);
|
||||
if (err) {
|
||||
BT_ERR("Send 1st seg failed (err %d)", err);
|
||||
@@ -2327,8 +2349,8 @@ void bt_mesh_trans_init(void)
|
||||
seg_rx[i].buf.data = seg_rx[i].buf.__buf;
|
||||
}
|
||||
|
||||
bt_mesh_mutex_create(&seg_tx_lock);
|
||||
bt_mesh_mutex_create(&seg_rx_lock);
|
||||
bt_mesh_r_mutex_create(&seg_tx_lock);
|
||||
bt_mesh_r_mutex_create(&seg_rx_lock);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
@@ -2338,7 +2360,7 @@ void bt_mesh_trans_deinit(bool erase)
|
||||
bt_mesh_tx_reset();
|
||||
bt_mesh_rpl_reset(erase);
|
||||
|
||||
bt_mesh_mutex_free(&seg_tx_lock);
|
||||
bt_mesh_mutex_free(&seg_rx_lock);
|
||||
bt_mesh_r_mutex_free(&seg_tx_lock);
|
||||
bt_mesh_r_mutex_free(&seg_rx_lock);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -54,6 +54,25 @@ config BT_CLASSIC_ENABLED
|
||||
help
|
||||
For now this option needs "SMP_ENABLE" to be set to yes
|
||||
|
||||
choice BT_ENC_KEY_SIZE_CTRL_ENABLED
|
||||
prompt "configure encryption key size"
|
||||
depends on BT_CLASSIC_ENABLED
|
||||
default BT_ENC_KEY_SIZE_CTRL_VSC
|
||||
help
|
||||
This chooses the support status of configuring encryption key size
|
||||
|
||||
config BT_ENC_KEY_SIZE_CTRL_STD
|
||||
depends on (BT_CONTROLLER_DISABLED || (BT_CONTROLLER_ENABLED && SOC_BT_H2C_ENC_KEY_CTRL_ENH_STD_SUPPORTED))
|
||||
bool "Supported by standard HCI command"
|
||||
|
||||
config BT_ENC_KEY_SIZE_CTRL_VSC
|
||||
depends on (BT_CONTROLLER_DISABLED || (BT_CONTROLLER_ENABLED && SOC_BT_H2C_ENC_KEY_CTRL_ENH_VSC_SUPPORTED))
|
||||
bool "Supported by Vendor-specific HCI command"
|
||||
|
||||
config BT_ENC_KEY_SIZE_CTRL_NONE
|
||||
bool "Not supported"
|
||||
endchoice
|
||||
|
||||
config BT_CLASSIC_BQB_ENABLED
|
||||
bool "Host Qualitifcation support for Classic Bluetooth"
|
||||
depends on BT_CLASSIC_ENABLED
|
||||
@@ -273,7 +292,7 @@ config BT_GATTC_CACHE_NVS_FLASH
|
||||
config BT_GATTC_CONNECT_RETRY_COUNT
|
||||
int "The number of attempts to reconnect if the connection establishment failed"
|
||||
depends on BT_GATTC_ENABLE
|
||||
range 0 7
|
||||
range 0 255
|
||||
default 3
|
||||
help
|
||||
The number of attempts to reconnect if the connection establishment failed
|
||||
@@ -1168,21 +1187,21 @@ config BT_BLE_42_FEATURES_SUPPORTED
|
||||
|
||||
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable BLE periodic advertising sync transfer feature"
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n
|
||||
help
|
||||
This enables BLE periodic advertising sync transfer feature
|
||||
|
||||
config BT_BLE_FEAT_PERIODIC_ADV_ENH
|
||||
bool "Enable periodic adv enhancements(adi support)"
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n
|
||||
help
|
||||
Enable the periodic advertising enhancements
|
||||
|
||||
config BT_BLE_FEAT_CREATE_SYNC_ENH
|
||||
bool "Enable create sync enhancements(reporting disable and duplicate filtering enable support)"
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n
|
||||
help
|
||||
Enable the create sync enhancements
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#if (BT_CONTROLLER_INCLUDED == TRUE)
|
||||
#include "esp_bt.h"
|
||||
#endif
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#define LOG_TAG "HCI_API"
|
||||
|
||||
@@ -59,6 +60,9 @@ bool hci_host_check_send_available(void)
|
||||
|
||||
void hci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
{
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(data[0], &data[1], len - 1);
|
||||
#endif
|
||||
#if (BT_CONTROLLER_INCLUDED == TRUE)
|
||||
esp_vhci_host_send_packet(data, len);
|
||||
#else /* BT_CONTROLLER_INCLUDED == TRUE */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -12,6 +12,21 @@
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_dev.h"
|
||||
#include "btc/btc_config.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
esp_err_t esp_bt_dev_register_callback(esp_bt_dev_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_DEV, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
const uint8_t *esp_bt_dev_get_address(void)
|
||||
{
|
||||
@@ -39,14 +54,24 @@ esp_err_t esp_bt_dev_set_device_name(const char *name)
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_DEV;
|
||||
msg.act = BTC_DEV_ACT_SET_DEVICE_NAME;
|
||||
arg.set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (!arg.set_dev_name.device_name) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
arg.set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), btc_dev_call_arg_deep_copy, btc_dev_call_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_dev_get_device_name(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
strcpy(arg.set_dev_name.device_name, name);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_DEV;
|
||||
msg.act = BTC_DEV_ACT_GET_DEVICE_NAME;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "osi/future.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "config/stack_config.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
#include "bt_common.h"
|
||||
|
||||
static bool bd_already_enable = false;
|
||||
static bool bd_already_init = false;
|
||||
@@ -180,6 +182,10 @@ esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
|
||||
|
||||
bd_already_init = true;
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_init();
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -224,6 +230,10 @@ esp_err_t esp_bluedroid_deinit(void)
|
||||
|
||||
bluedriod_config_deinit();
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_deinit();
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
|
||||
bd_already_init = false;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_gap_ble.h"
|
||||
#include "btc/btc_ble_storage.h"
|
||||
|
||||
#include "esp_random.h"
|
||||
|
||||
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
|
||||
{
|
||||
@@ -188,6 +188,25 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_addr_create_static(esp_bd_addr_t rand_addr)
|
||||
{
|
||||
// Static device address: First two bits are '11', rest is random
|
||||
rand_addr[0] = 0xC0 | (esp_random() & 0x3F);
|
||||
for (int i = 1; i < 6; i++) {
|
||||
rand_addr[i] = esp_random() & 0xFF; // Randomize remaining bits
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_addr_create_nrpa(esp_bd_addr_t rand_addr)
|
||||
{
|
||||
// Non-resolvable private address: First two bits are '00', rest is random
|
||||
rand_addr[0] = (esp_random() & 0x3F);
|
||||
for (int i = 1; i < 6; i++) {
|
||||
rand_addr[i] = esp_random() & 0xFF; // Randomize remaining bits
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
|
||||
{
|
||||
@@ -204,6 +223,48 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeout)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (rpa_timeout < 0x0001 || rpa_timeout > 0x0E10) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT;
|
||||
arg.set_rpa_timeout.rpa_timeout = rpa_timeout;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint8_t addr_type, uint8_t *peer_irk)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (addr_type > BLE_ADDR_TYPE_RANDOM ||!peer_addr || (addr_type && ((peer_addr[0] & 0xC0) != 0xC0))) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST;
|
||||
|
||||
memcpy(arg.add_dev_to_resolving_list.addr, peer_addr, ESP_BD_ADDR_LEN);
|
||||
arg.add_dev_to_resolving_list.addr_type = addr_type;
|
||||
memcpy(arg.add_dev_to_resolving_list.irk, peer_irk, ESP_PEER_IRK_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_clear_rand_addr(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
@@ -299,6 +360,7 @@ esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV:
|
||||
case ESP_BLE_APPEARANCE_STANDALONE_SPEAKER:
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
|
||||
@@ -396,9 +458,25 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||
|
||||
esp_err_t esp_ble_gap_set_device_name(const char *name)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
return esp_bt_dev_set_device_name(name);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!name){
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
|
||||
arg.set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_get_device_name(void)
|
||||
@@ -936,6 +1014,25 @@ esp_err_t esp_ble_dtm_stop(void)
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_addr_t addr, esp_ble_privacy_mode_t mode)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_SET_PRIVACY_MODE;
|
||||
|
||||
arg.set_privacy_mode.addr_type = addr_type;
|
||||
memcpy(arg.set_privacy_mode.addr, addr, sizeof(esp_bd_addr_t));
|
||||
arg.set_privacy_mode.privacy_mode = mode;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
esp_err_t esp_ble_gap_read_phy(esp_bd_addr_t bd_addr)
|
||||
@@ -1599,3 +1696,31 @@ esp_err_t esp_ble_gap_set_periodic_adv_sync_trans_params(esp_bd_addr_t addr, con
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (!vendor_cmd_param || !vendor_cmd_param->p_param_buf || !vendor_cmd_param->param_len) {
|
||||
return ESP_ERR_NOT_ALLOWED;
|
||||
}
|
||||
// If command is not a VSC, return error
|
||||
if ((vendor_cmd_param->opcode & VENDOR_HCI_CMD_MASK) != VENDOR_HCI_CMD_MASK) {
|
||||
return ESP_ERR_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT;
|
||||
arg.vendor_cmd_send.opcode = vendor_cmd_param->opcode;
|
||||
arg.vendor_cmd_send.param_len = vendor_cmd_param->param_len;
|
||||
arg.vendor_cmd_send.p_param_buf = vendor_cmd_param->p_param_buf;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -494,4 +494,63 @@ esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, uint16_t pkt_ty
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
esp_err_t esp_bt_gap_set_min_enc_key_size(uint8_t key_size)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (key_size < ESP_BT_ENC_KEY_SIZE_CTRL_MIN || key_size > ESP_BT_ENC_KEY_SIZE_CTRL_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE;
|
||||
|
||||
arg.set_min_enc_key_size.key_size = key_size;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* #if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE) */
|
||||
|
||||
esp_err_t esp_bt_gap_set_device_name(const char *name)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if ((!name) || (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_DEV_NAME;
|
||||
arg.bt_set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
||||
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_device_name(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_GET_DEV_NAME;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
return ESP_ERR_INVALID_STATE; \
|
||||
}
|
||||
|
||||
#define ESP_BT_STATUS_BASE_FOR_HCI_ERR 0X0100 /* base for coverting HCI error code to ESP status */
|
||||
#define ESP_BT_STATUS_BASE_FOR_HCI_ERR 0X0100 /* base for converting HCI error code to ESP status */
|
||||
|
||||
/* relate to BT_STATUS_xxx in bt_def.h */
|
||||
/// Status Return Value
|
||||
@@ -163,6 +163,9 @@ typedef enum {
|
||||
/// Bluetooth address length
|
||||
#define ESP_BD_ADDR_LEN 6
|
||||
|
||||
/// Bluetooth peer irk
|
||||
#define ESP_PEER_IRK_LEN 16
|
||||
|
||||
/// Bluetooth device address
|
||||
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN];
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -37,6 +37,41 @@ typedef enum {
|
||||
ESP_BT_DEV_COEX_TYPE_BT,
|
||||
} esp_bt_dev_coex_type_t;
|
||||
|
||||
/// BT device callback events
|
||||
typedef enum {
|
||||
ESP_BT_DEV_NAME_RES_EVT = 0, /*!< Device name result event */
|
||||
ESP_BT_DEV_EVT_MAX,
|
||||
} esp_bt_dev_cb_event_t;
|
||||
|
||||
/// BT device callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BT_DEV_NAME_RES_EVT
|
||||
*/
|
||||
struct name_res_param {
|
||||
esp_bt_status_t status; /*!< Status of getting device name */
|
||||
char *name; /*!< Name of Bluetooth device */
|
||||
} name_res; /*!< discovery result parameter struct */
|
||||
} esp_bt_dev_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief bluetooth device callback function type
|
||||
*
|
||||
* @param event : Event type
|
||||
*
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_bt_dev_cb_t)(esp_bt_dev_cb_event_t event, esp_bt_dev_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief register callback function. This function should be called after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_dev_register_callback(esp_bt_dev_cb_t callback);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get bluetooth device address. Must use after "esp_bluedroid_enable".
|
||||
@@ -61,7 +96,21 @@ const uint8_t *esp_bt_dev_get_address(void);
|
||||
* - ESP_ERR_INVALID_STATE : if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL : others
|
||||
*/
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name);
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name) __attribute__((deprecated("Please use esp_bt_gap_set_device_name or esp_ble_gap_set_device_name")));
|
||||
|
||||
/**
|
||||
* @brief Get bluetooth device name. This function should be called after esp_bluedroid_enable()
|
||||
* completes successfully.
|
||||
*
|
||||
* A BR/EDR/LE device type shall have a single Bluetooth device name which shall be
|
||||
* identical irrespective of the physical channel used to perform the name discovery procedure.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE : if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL : others
|
||||
*/
|
||||
esp_err_t esp_bt_dev_get_device_name(void) __attribute__((deprecated("Please use esp_bt_gap_get_device_name or esp_ble_gap_get_device_name")));
|
||||
|
||||
/**
|
||||
* @brief Config bluetooth device coexis status. This function should be called after esp_bluedroid_enable()
|
||||
|
||||
@@ -70,7 +70,7 @@ esp_err_t esp_bluedroid_disable(void);
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_init(void) __attribute__((deprecated("Please use esp_bluedroid_init_with_cfg")));
|
||||
esp_err_t esp_bluedroid_init(void);
|
||||
|
||||
/**
|
||||
* @brief Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.
|
||||
|
||||
@@ -54,7 +54,7 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
|
||||
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_DISABLE 0 /*!< authentication disable*/
|
||||
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE 1 /*!< authentication enable*/
|
||||
|
||||
#define ESP_BLE_OOB_DISABLE 0 /*!< disbale the out of bond*/
|
||||
#define ESP_BLE_OOB_DISABLE 0 /*!< disable the out of bond*/
|
||||
#define ESP_BLE_OOB_ENABLE 1 /*!< enable the out of bond*/
|
||||
|
||||
/// relate to BTM_IO_CAP_xxx in stack/btm_api.h
|
||||
@@ -104,6 +104,7 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_CADENCE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_POWER 0x0484 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_POWER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 /*!< relate to BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_STANDALONE_SPEAKER 0x0841 /*!< relate to BTM_BLE_APPEARANCE_STANDALONE_SPEAKER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 /*!< relate to BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 /*!< relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 /*!< relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST in stack/btm_ble_api.h */
|
||||
@@ -156,7 +157,7 @@ typedef enum {
|
||||
ESP_GAP_BLE_PASSKEY_REQ_EVT, /*!< passkey request event */
|
||||
ESP_GAP_BLE_OOB_REQ_EVT, /*!< OOB request event */
|
||||
ESP_GAP_BLE_LOCAL_IR_EVT, /*!< BLE local IR (identity Root 128-bit random static value used to generate Long Term Key) event */
|
||||
ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root vakue used to genrate identity resolving key) event */
|
||||
ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root value used to generate identity resolving key) event */
|
||||
ESP_GAP_BLE_NC_REQ_EVT, /*!< Numeric Comparison request event */
|
||||
//BLE_42_FEATURE_SUPPORT
|
||||
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
|
||||
@@ -224,6 +225,10 @@ typedef enum {
|
||||
ESP_GAP_BLE_DTM_TEST_UPDATE_EVT, /*!< when direct test mode state changes, the event comes */
|
||||
// BLE_INCLUDED
|
||||
ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT, /*!< When clear advertising complete, the event comes */
|
||||
ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT, /*!< When set the Resolvable Private Address (RPA) timeout completes, the event comes */
|
||||
ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT, /*!< when add a device to the resolving list completes, the event comes*/
|
||||
ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT, /*!< When set privacy mode complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
@@ -238,6 +243,8 @@ typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN];
|
||||
/// Scan response data maximum length
|
||||
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
|
||||
|
||||
#define VENDOR_HCI_CMD_MASK (0x3F << 10) /**!< 0xFC00 */
|
||||
|
||||
/* relate to BTM_BLE_AD_TYPE_xxx in stack/btm_ble_api.h */
|
||||
/// The type of advertising data(not adv_type)
|
||||
typedef enum {
|
||||
@@ -364,6 +371,15 @@ typedef enum {
|
||||
DTM_TEST_STOP_EVT,
|
||||
} esp_ble_dtm_update_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Vendor HCI command parameters
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t opcode; /*!< vendor hci command opcode */
|
||||
uint8_t param_len; /*!< the length of parameter */
|
||||
uint8_t *p_param_buf; /*!< the point of parameter buffer */
|
||||
} esp_ble_vendor_cmd_params_t;
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/**
|
||||
* @brief DTM TX parameters
|
||||
@@ -786,9 +802,9 @@ typedef uint8_t esp_ble_gap_all_phys_t;
|
||||
#define ESP_BLE_GAP_PRI_PHY_CODED ESP_BLE_GAP_PHY_CODED /*!< Primary Phy is LE CODED */
|
||||
typedef uint8_t esp_ble_gap_pri_phy_t; // primary phy
|
||||
|
||||
#define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or reciever PHY */
|
||||
#define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or reciever PHY */
|
||||
#define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or reciever PHY */
|
||||
#define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or receiver PHY */
|
||||
#define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or receiver PHY */
|
||||
#define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or receiver PHY */
|
||||
typedef uint8_t esp_ble_gap_phy_mask_t;
|
||||
|
||||
#define ESP_BLE_GAP_PHY_OPTIONS_NO_PREF 0 /*!< The Host has no preferred coding when transmitting on the LE Coded PHY */
|
||||
@@ -945,7 +961,7 @@ typedef struct {
|
||||
esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */
|
||||
uint8_t adv_data_len; /*!< extend advertising data length */
|
||||
uint8_t adv_data[251]; /*!< extend advertising data */
|
||||
} esp_ble_gap_ext_adv_reprot_t;
|
||||
} esp_ble_gap_ext_adv_report_t;
|
||||
|
||||
/**
|
||||
* @brief periodic adv report parameters
|
||||
@@ -1015,6 +1031,11 @@ typedef struct {
|
||||
} esp_ble_gap_past_params_t;
|
||||
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
typedef enum{
|
||||
ESP_BLE_NETWORK_PRIVACY_MODE = 0X00, /*!< Network Privacy Mode for peer device (default) */
|
||||
ESP_BLE_DEVICE_PRIVACY_MODE = 0X01, /*!< Device Privacy Mode for peer device */
|
||||
} esp_ble_privacy_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Gap callback parameters union
|
||||
*/
|
||||
@@ -1140,6 +1161,19 @@ typedef union {
|
||||
struct ble_local_privacy_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */
|
||||
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_rpa_timeout_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set RPA timeout operation success status */
|
||||
} set_rpa_timeout_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_add_dev_to_resolving_list_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicates the success status of adding a device to the resolving list */
|
||||
} add_dev_to_resolving_list_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
@@ -1410,7 +1444,7 @@ typedef union {
|
||||
* @brief ESP_GAP_BLE_EXT_ADV_REPORT_EVT
|
||||
*/
|
||||
struct ble_ext_adv_report_param {
|
||||
esp_ble_gap_ext_adv_reprot_t params; /*!< extend advertising report parameters */
|
||||
esp_ble_gap_ext_adv_report_t params; /*!< extend advertising report parameters */
|
||||
} ext_adv_report; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_REPORT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT
|
||||
@@ -1471,6 +1505,20 @@ typedef union {
|
||||
esp_ble_dtm_update_evt_t update_evt; /*!< DTM state change event, 0x00: DTM TX start, 0x01: DTM RX start, 0x02:DTM end */
|
||||
uint16_t num_of_pkt; /*!< number of packets received, only valid if update_evt is DTM_TEST_STOP_EVT and shall be reported as 0 for a transmitter */
|
||||
} dtm_state_update; /*!< Event parameter of ESP_GAP_BLE_DTM_TEST_UPDATE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT
|
||||
*/
|
||||
struct vendor_cmd_cmpl_evt_param {
|
||||
uint16_t opcode; /*!< vendor hci command opcode */
|
||||
uint16_t param_len; /*!< The length of parameter buffer */
|
||||
uint8_t *p_param_buf; /*!< The point of parameter buffer */
|
||||
} vendor_cmd_cmpl; /*!< Event parameter of ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_set_privacy_mode_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate privacy mode set operation success status */
|
||||
} set_privacy_mode_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -1608,13 +1656,13 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
|
||||
*
|
||||
* @param[in] rand_addr: The address to be configured. Refer to the table below for possible address subtypes:
|
||||
*
|
||||
* | address [47:46] | Address Type |
|
||||
* |-----------------|--------------------------|
|
||||
* | 0b00 | Non-Resolvable Private |
|
||||
* | | Address |
|
||||
* |-----------------|--------------------------|
|
||||
* | 0b11 | Static Random Address |
|
||||
* |-----------------|--------------------------|
|
||||
* | address [47:46] | Address Type | Corresponding API |
|
||||
* |-----------------|-----------------------------|----------------------------------------|
|
||||
* | 0b00 | Non-Resolvable Private | esp_ble_gap_addr_create_nrpa |
|
||||
* | | Address (NRPA) | |
|
||||
* |-----------------|-----------------------------|----------------------------------------|
|
||||
* | 0b11 | Static Random Address | esp_ble_gap_addr_create_static |
|
||||
* |-----------------|-----------------------------|----------------------------------------|
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
@@ -1623,6 +1671,60 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
|
||||
/**
|
||||
* @brief Create a static device address
|
||||
* @param[out] rand_addr: Pointer to the buffer where the static device address will be stored.
|
||||
* @return - ESP_OK : Success
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_addr_create_static(esp_bd_addr_t rand_addr);
|
||||
|
||||
/**
|
||||
* @brief Create a non-resolvable private address (NRPA)
|
||||
* @param[out] rand_addr: Pointer to the buffer where the NRPA will be stored.
|
||||
* @return - ESP_OK : Success
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_addr_create_nrpa(esp_bd_addr_t rand_addr);
|
||||
|
||||
/**
|
||||
* @brief This function sets the length of time the Controller uses a Resolvable Private Address
|
||||
* before generating and starting to use a new resolvable private address.
|
||||
*
|
||||
* @note Note: This function is currently not supported on the ESP32 but will be enabled in a future update.
|
||||
*
|
||||
* @param[in] rpa_timeout: The timeout duration in seconds for how long a Resolvable Private Address
|
||||
* is used before a new one is generated. The value must be within the range specified by
|
||||
* the Bluetooth specification (0x0001 to 0x0E10), which corresponds to a time range of
|
||||
* 1 second to 1 hour. The default value is 0x0384 (900 seconds or 15 minutes).
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeout);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function adds a device to the resolving list used to generate and resolve Resolvable Private Addresses
|
||||
* in the Controller.
|
||||
*
|
||||
* @note Note: This function shall not be used when address resolution is enabled in the Controller and:
|
||||
* - Advertising (other than periodic advertising) is enabled,
|
||||
* - Scanning is enabled, or
|
||||
* - an HCI_LE_Create_Connection, HCI_LE_Extended_Create_Connection, or HCI_LE_Periodic_Advertising_Create_Sync command is pending.
|
||||
* This command may be used at any time when address resolution is disabled in the Controller.
|
||||
* The added device shall be set to Network Privacy mode.
|
||||
*
|
||||
* @param[in] peer_addr: The peer identity address of the device to be added to the resolving list.
|
||||
* @param[in] addr_type: The address type of the peer identity address (BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM).
|
||||
* @param[in] peer_irk: The Identity Resolving Key (IRK) of the device.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_add_device_to_resolving_list(esp_bd_addr_t peer_addr, uint8_t addr_type, uint8_t *peer_irk);
|
||||
/**
|
||||
* @brief This function clears the random address for the application
|
||||
*
|
||||
@@ -1633,8 +1735,6 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_clear_rand_addr(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Enable/disable privacy (including address resolution) on the local device
|
||||
*
|
||||
@@ -1949,7 +2049,6 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
*/
|
||||
int esp_ble_get_bond_device_num(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the device from the security database list of peer device.
|
||||
* It will return the device bonded information immediately.
|
||||
@@ -2540,6 +2639,34 @@ esp_err_t esp_ble_dtm_stop(void);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_clear_advertising(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to send vendor hci command.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param[in] vendor_cmd_param: vendor hci command parameters
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param);
|
||||
|
||||
/**
|
||||
* @brief This function set the privacy mode of the device in resolving list.
|
||||
*
|
||||
* @note This feature is not supported on ESP32.
|
||||
*
|
||||
* @param[in] addr_type: The address type of the peer identity address (BLE_ADDR_TYPE_PUBLIC or BLE_ADDR_TYPE_RANDOM).
|
||||
* @param[in] addr: The peer identity address of the device.
|
||||
* @param[in] mode: The privacy mode of the device.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_addr_t addr, esp_ble_privacy_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -105,7 +105,7 @@ typedef uint8_t esp_bt_eir_type_t;
|
||||
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_2_DH5 0x1000
|
||||
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_3_DH5 0x2000
|
||||
|
||||
// DM1 cann not be disabled. All options are mandatory to include DM1.
|
||||
// DM1 can not be disabled. All options are mandatory to include DM1.
|
||||
#define ESP_BT_ACL_DM1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM1 | 0x330e) /* 0x330e */
|
||||
#define ESP_BT_ACL_DH1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DH1 | 0x330e) /* 0x331e */
|
||||
#define ESP_BT_ACL_DM3_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM3 | 0x330e) /* 0x370e */
|
||||
@@ -121,6 +121,10 @@ typedef uint8_t esp_bt_eir_type_t;
|
||||
|
||||
typedef uint16_t esp_bt_acl_pkt_type_t;
|
||||
|
||||
/* Range of encryption key size */
|
||||
#define ESP_BT_ENC_KEY_SIZE_CTRL_MAX (16)
|
||||
#define ESP_BT_ENC_KEY_SIZE_CTRL_MIN (7)
|
||||
|
||||
/* ESP_BT_EIR_FLAG bit definition */
|
||||
#define ESP_BT_EIR_FLAG_LIMIT_DISC (0x01 << 0)
|
||||
#define ESP_BT_EIR_FLAG_GEN_DISC (0x01 << 1)
|
||||
@@ -142,7 +146,7 @@ typedef struct {
|
||||
uint8_t *p_url; /*!< URL point */
|
||||
} esp_bt_eir_data_t;
|
||||
|
||||
/// Major service class field of Class of Device, mutiple bits can be set
|
||||
/// Major service class field of Class of Device, multiple bits can be set
|
||||
typedef enum {
|
||||
ESP_BT_COD_SRVC_NONE = 0, /*!< None indicates an invalid value */
|
||||
ESP_BT_COD_SRVC_LMTD_DISCOVER = 0x1, /*!< Limited Discoverable Mode */
|
||||
@@ -266,6 +270,8 @@ typedef enum {
|
||||
ESP_BT_GAP_GET_PAGE_TO_EVT, /*!< Get page timeout event */
|
||||
ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, /*!< Set ACL packet types event */
|
||||
ESP_BT_GAP_ENC_CHG_EVT, /*!< Encryption change event */
|
||||
ESP_BT_GAP_SET_MIN_ENC_KEY_SIZE_EVT, /*!< Set minimum encryption key size */
|
||||
ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, /*!< Get device name complete event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
@@ -458,6 +464,13 @@ typedef union {
|
||||
uint16_t pkt_types; /*!< packet types successfully set */
|
||||
} set_acl_pkt_types; /*!< set ACL packet types parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_SET_MIN_ENC_KEY_SIZE_EVT
|
||||
*/
|
||||
struct set_min_enc_key_size_param {
|
||||
esp_bt_status_t status; /*!< set minimum encryption key size status */
|
||||
} set_min_enc_key_size; /*!< set minimum encryption key size parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT
|
||||
*/
|
||||
@@ -475,6 +488,14 @@ typedef union {
|
||||
uint16_t handle; /*!< ACL connection handle */
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address */
|
||||
} acl_disconn_cmpl_stat; /*!< ACL disconnection complete status parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_GAP_BT_GET_DEV_NAME_CMPL_EVT
|
||||
*/
|
||||
struct get_dev_name_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the get device name success status */
|
||||
char *name; /*!< Name of bluetooth device */
|
||||
} get_dev_name_cmpl; /*!< Get device name complete status parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -541,7 +562,7 @@ static inline uint32_t esp_bt_gap_get_cod_format_type(uint32_t cod)
|
||||
*
|
||||
* @return
|
||||
* - true if cod is valid
|
||||
* - false otherise
|
||||
* - false otherwise
|
||||
*/
|
||||
static inline bool esp_bt_gap_is_valid_cod(uint32_t cod)
|
||||
{
|
||||
@@ -909,6 +930,35 @@ esp_err_t esp_bt_gap_get_page_timeout(void);
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, esp_bt_acl_pkt_type_t pkt_types);
|
||||
|
||||
/**
|
||||
* @brief Set the minimal size of encryption key
|
||||
*
|
||||
* @return - ESP_OK: success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_min_enc_key_size(uint8_t key_size);
|
||||
|
||||
/**
|
||||
* @brief Set device name to the local device
|
||||
*
|
||||
* @param[in] name - device name.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_device_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Get device name of the local device
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_device_name(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,337 +1,552 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_GATT_DEFS_H__
|
||||
#define __ESP_GATT_DEFS_H__
|
||||
|
||||
#pragma once
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// GATT INVALID UUID
|
||||
/** @brief GATT INVALID UUID. */
|
||||
#define ESP_GATT_ILLEGAL_UUID 0
|
||||
/// GATT INVALID HANDLE
|
||||
|
||||
/** @brief GATT INVALID HANDLE. */
|
||||
#define ESP_GATT_ILLEGAL_HANDLE 0
|
||||
/// GATT attribute max handle
|
||||
|
||||
/** @brief GATT attribute max handle. */
|
||||
#define ESP_GATT_ATTR_HANDLE_MAX UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
|
||||
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
|
||||
|
||||
/** @brief Maximum number of attributes to read in one request. */
|
||||
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10
|
||||
|
||||
|
||||
/**@{
|
||||
* All "ESP_GATT_UUID_xxx" is attribute types
|
||||
/**
|
||||
* @defgroup GATT_UUIDs GATT Service UUIDs
|
||||
* @brief Definitions of GATT Service UUIDs.
|
||||
*
|
||||
* This module contains the definitions of standard GATT service UUIDs. These UUIDs
|
||||
* identify the type of GATT service.
|
||||
* @{
|
||||
*/
|
||||
#define ESP_GATT_UUID_IMMEDIATE_ALERT_SVC 0x1802 /* Immediate alert Service*/
|
||||
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803 /* Link Loss Service*/
|
||||
#define ESP_GATT_UUID_TX_POWER_SVC 0x1804 /* TX Power Service*/
|
||||
#define ESP_GATT_UUID_CURRENT_TIME_SVC 0x1805 /* Current Time Service Service*/
|
||||
#define ESP_GATT_UUID_REF_TIME_UPDATE_SVC 0x1806 /* Reference Time Update Service*/
|
||||
#define ESP_GATT_UUID_NEXT_DST_CHANGE_SVC 0x1807 /* Next DST Change Service*/
|
||||
#define ESP_GATT_UUID_GLUCOSE_SVC 0x1808 /* Glucose Service*/
|
||||
#define ESP_GATT_UUID_HEALTH_THERMOM_SVC 0x1809 /* Health Thermometer Service*/
|
||||
#define ESP_GATT_UUID_DEVICE_INFO_SVC 0x180A /* Device Information Service*/
|
||||
#define ESP_GATT_UUID_HEART_RATE_SVC 0x180D /* Heart Rate Service*/
|
||||
#define ESP_GATT_UUID_PHONE_ALERT_STATUS_SVC 0x180E /* Phone Alert Status Service*/
|
||||
#define ESP_GATT_UUID_BATTERY_SERVICE_SVC 0x180F /* Battery Service*/
|
||||
#define ESP_GATT_UUID_BLOOD_PRESSURE_SVC 0x1810 /* Blood Pressure Service*/
|
||||
#define ESP_GATT_UUID_ALERT_NTF_SVC 0x1811 /* Alert Notification Service*/
|
||||
#define ESP_GATT_UUID_HID_SVC 0x1812 /* HID Service*/
|
||||
#define ESP_GATT_UUID_SCAN_PARAMETERS_SVC 0x1813 /* Scan Parameters Service*/
|
||||
#define ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC 0x1814 /* Running Speed and Cadence Service*/
|
||||
#define ESP_GATT_UUID_Automation_IO_SVC 0x1815 /* Automation IO Service*/
|
||||
#define ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC 0x1816 /* Cycling Speed and Cadence Service*/
|
||||
#define ESP_GATT_UUID_CYCLING_POWER_SVC 0x1818 /* Cycling Power Service*/
|
||||
#define ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC 0x1819 /* Location and Navigation Service*/
|
||||
#define ESP_GATT_UUID_ENVIRONMENTAL_SENSING_SVC 0x181A /* Environmental Sensing Service*/
|
||||
#define ESP_GATT_UUID_BODY_COMPOSITION 0x181B /* Body Composition Service*/
|
||||
#define ESP_GATT_UUID_USER_DATA_SVC 0x181C /* User Data Service*/
|
||||
#define ESP_GATT_UUID_WEIGHT_SCALE_SVC 0x181D /* Weight Scale Service*/
|
||||
#define ESP_GATT_UUID_BOND_MANAGEMENT_SVC 0x181E /* Bond Management Service*/
|
||||
#define ESP_GATT_UUID_CONT_GLUCOSE_MONITOR_SVC 0x181F /* Continuous Glucose Monitoring Service*/
|
||||
|
||||
/** @brief Immediate Alert Service UUID. */
|
||||
#define ESP_GATT_UUID_IMMEDIATE_ALERT_SVC 0x1802
|
||||
/** @brief Link Loss Service UUID. */
|
||||
#define ESP_GATT_UUID_LINK_LOSS_SVC 0x1803
|
||||
/** @brief TX Power Service UUID. */
|
||||
#define ESP_GATT_UUID_TX_POWER_SVC 0x1804
|
||||
/** @brief Current Time Service UUID. */
|
||||
#define ESP_GATT_UUID_CURRENT_TIME_SVC 0x1805
|
||||
/** @brief Reference Time Update Service UUID. */
|
||||
#define ESP_GATT_UUID_REF_TIME_UPDATE_SVC 0x1806
|
||||
/** @brief Next DST Change Service UUID. */
|
||||
#define ESP_GATT_UUID_NEXT_DST_CHANGE_SVC 0x1807
|
||||
/** @brief Glucose Service UUID. */
|
||||
#define ESP_GATT_UUID_GLUCOSE_SVC 0x1808
|
||||
/** @brief Health Thermometer Service UUID. */
|
||||
#define ESP_GATT_UUID_HEALTH_THERMOM_SVC 0x1809
|
||||
/** @brief Device Information Service UUID. */
|
||||
#define ESP_GATT_UUID_DEVICE_INFO_SVC 0x180A
|
||||
/** @brief Heart Rate Service UUID. */
|
||||
#define ESP_GATT_UUID_HEART_RATE_SVC 0x180D
|
||||
/** @brief Phone Alert Status Service UUID. */
|
||||
#define ESP_GATT_UUID_PHONE_ALERT_STATUS_SVC 0x180E
|
||||
/** @brief Battery Service UUID. */
|
||||
#define ESP_GATT_UUID_BATTERY_SERVICE_SVC 0x180F
|
||||
/** @brief Blood Pressure Service UUID. */
|
||||
#define ESP_GATT_UUID_BLOOD_PRESSURE_SVC 0x1810
|
||||
/** @brief Alert Notification Service UUID. */
|
||||
#define ESP_GATT_UUID_ALERT_NTF_SVC 0x1811
|
||||
/** @brief HID Service UUID. */
|
||||
#define ESP_GATT_UUID_HID_SVC 0x1812
|
||||
/** @brief Scan Parameters Service UUID. */
|
||||
#define ESP_GATT_UUID_SCAN_PARAMETERS_SVC 0x1813
|
||||
/** @brief Running Speed and Cadence Service UUID. */
|
||||
#define ESP_GATT_UUID_RUNNING_SPEED_CADENCE_SVC 0x1814
|
||||
/** @brief Automation IO Service UUID. */
|
||||
#define ESP_GATT_UUID_Automation_IO_SVC 0x1815
|
||||
/** @brief Cycling Speed and Cadence Service UUID. */
|
||||
#define ESP_GATT_UUID_CYCLING_SPEED_CADENCE_SVC 0x1816
|
||||
/** @brief Cycling Power Service UUID. */
|
||||
#define ESP_GATT_UUID_CYCLING_POWER_SVC 0x1818
|
||||
/** @brief Location and Navigation Service UUID. */
|
||||
#define ESP_GATT_UUID_LOCATION_AND_NAVIGATION_SVC 0x1819
|
||||
/** @brief Environmental Sensing Service UUID. */
|
||||
#define ESP_GATT_UUID_ENVIRONMENTAL_SENSING_SVC 0x181A
|
||||
/** @brief Body Composition Service UUID. */
|
||||
#define ESP_GATT_UUID_BODY_COMPOSITION 0x181B
|
||||
/** @brief User Data Service UUID. */
|
||||
#define ESP_GATT_UUID_USER_DATA_SVC 0x181C
|
||||
/** @brief Weight Scale Service UUID. */
|
||||
#define ESP_GATT_UUID_WEIGHT_SCALE_SVC 0x181D
|
||||
/** @brief Bond Management Service UUID. */
|
||||
#define ESP_GATT_UUID_BOND_MANAGEMENT_SVC 0x181E
|
||||
/** @brief Continuous Glucose Monitoring Service UUID. */
|
||||
#define ESP_GATT_UUID_CONT_GLUCOSE_MONITOR_SVC 0x181F
|
||||
/** @brief Primary Service UUID. */
|
||||
#define ESP_GATT_UUID_PRI_SERVICE 0x2800
|
||||
/** @brief Secondary Service UUID. */
|
||||
#define ESP_GATT_UUID_SEC_SERVICE 0x2801
|
||||
/** @brief Include Service UUID. */
|
||||
#define ESP_GATT_UUID_INCLUDE_SERVICE 0x2802
|
||||
#define ESP_GATT_UUID_CHAR_DECLARE 0x2803 /* Characteristic Declaration*/
|
||||
|
||||
#define ESP_GATT_UUID_CHAR_EXT_PROP 0x2900 /* Characteristic Extended Properties */
|
||||
#define ESP_GATT_UUID_CHAR_DESCRIPTION 0x2901 /* Characteristic User Description*/
|
||||
#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /* Client Characteristic Configuration */
|
||||
#define ESP_GATT_UUID_CHAR_SRVR_CONFIG 0x2903 /* Server Characteristic Configuration */
|
||||
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904 /* Characteristic Presentation Format*/
|
||||
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
|
||||
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906 /* Characteristic Valid Range */
|
||||
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907 /* External Report Reference */
|
||||
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908 /* Report Reference */
|
||||
#define ESP_GATT_UUID_NUM_DIGITALS_DESCR 0x2909 /* Number of Digitals */
|
||||
#define ESP_GATT_UUID_VALUE_TRIGGER_DESCR 0x290A /* Value Trigger Setting */
|
||||
#define ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR 0x290B /* Environmental Sensing Configuration */
|
||||
#define ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR 0x290C /* Environmental Sensing Measurement */
|
||||
#define ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR 0x290D /* Environmental Sensing Trigger Setting */
|
||||
#define ESP_GATT_UUID_TIME_TRIGGER_DESCR 0x290E /* Time Trigger Setting */
|
||||
/** @brief Characteristic Declaration UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_DECLARE 0x2803
|
||||
/** @brief Characteristic Extended Properties UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_EXT_PROP 0x2900
|
||||
/** @brief Characteristic User Description UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_DESCRIPTION 0x2901
|
||||
/** @brief Client Characteristic Configuration UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_CLIENT_CONFIG 0x2902
|
||||
/** @brief Server Characteristic Configuration UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_SRVR_CONFIG 0x2903
|
||||
/** @brief Characteristic Presentation Format UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_PRESENT_FORMAT 0x2904
|
||||
/** @brief Characteristic Aggregate Format UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_AGG_FORMAT 0x2905
|
||||
/** @brief Characteristic Valid Range UUID. */
|
||||
#define ESP_GATT_UUID_CHAR_VALID_RANGE 0x2906
|
||||
/** @brief External Report Reference Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_EXT_RPT_REF_DESCR 0x2907
|
||||
/** @brief Report Reference Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_RPT_REF_DESCR 0x2908
|
||||
/** @brief Number of Digitals Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_NUM_DIGITALS_DESCR 0x2909
|
||||
/** @brief Value Trigger Setting Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_VALUE_TRIGGER_DESCR 0x290A
|
||||
/** @brief Environmental Sensing Configuration Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR 0x290B
|
||||
/** @brief Environmental Sensing Measurement Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR 0x290C
|
||||
/** @brief Environmental Sensing Trigger Setting Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR 0x290D
|
||||
/** @brief Time Trigger Setting Descriptor UUID. */
|
||||
#define ESP_GATT_UUID_TIME_TRIGGER_DESCR 0x290E
|
||||
|
||||
/* GAP Profile Attributes */
|
||||
/** @brief GAP Device Name UUID. */
|
||||
#define ESP_GATT_UUID_GAP_DEVICE_NAME 0x2A00
|
||||
/** @brief GAP Icon UUID. */
|
||||
#define ESP_GATT_UUID_GAP_ICON 0x2A01
|
||||
/** @brief GAP Preferred Connection Parameters UUID. */
|
||||
#define ESP_GATT_UUID_GAP_PREF_CONN_PARAM 0x2A04
|
||||
/** @brief GAP Central Address Resolution UUID. */
|
||||
#define ESP_GATT_UUID_GAP_CENTRAL_ADDR_RESOL 0x2AA6
|
||||
|
||||
/* Attribute Profile Attribute UUID */
|
||||
/** @brief GATT Service Changed UUID. */
|
||||
#define ESP_GATT_UUID_GATT_SRV_CHGD 0x2A05
|
||||
|
||||
/* Link ESP_Loss Service */
|
||||
#define ESP_GATT_UUID_ALERT_LEVEL 0x2A06 /* Alert Level */
|
||||
#define ESP_GATT_UUID_TX_POWER_LEVEL 0x2A07 /* TX power level */
|
||||
/* Link Loss Service */
|
||||
/** @brief Alert Level UUID. */
|
||||
#define ESP_GATT_UUID_ALERT_LEVEL 0x2A06
|
||||
/** @brief TX Power Level UUID. */
|
||||
#define ESP_GATT_UUID_TX_POWER_LEVEL 0x2A07
|
||||
|
||||
/* Current Time Service */
|
||||
#define ESP_GATT_UUID_CURRENT_TIME 0x2A2B /* Current Time */
|
||||
#define ESP_GATT_UUID_LOCAL_TIME_INFO 0x2A0F /* Local time info */
|
||||
#define ESP_GATT_UUID_REF_TIME_INFO 0x2A14 /* reference time information */
|
||||
/** @brief Current Time UUID. */
|
||||
#define ESP_GATT_UUID_CURRENT_TIME 0x2A2B
|
||||
/** @brief Local Time Info UUID. */
|
||||
#define ESP_GATT_UUID_LOCAL_TIME_INFO 0x2A0F
|
||||
/** @brief Reference Time Information UUID. */
|
||||
#define ESP_GATT_UUID_REF_TIME_INFO 0x2A14
|
||||
|
||||
/* Network availability Profile */
|
||||
#define ESP_GATT_UUID_NW_STATUS 0x2A18 /* network availability status */
|
||||
#define ESP_GATT_UUID_NW_TRIGGER 0x2A1A /* Network availability trigger */
|
||||
/* Network Availability Service */
|
||||
/** @brief Network Availability Status UUID. */
|
||||
#define ESP_GATT_UUID_NW_STATUS 0x2A18
|
||||
/** @brief Network Availability Trigger UUID. */
|
||||
#define ESP_GATT_UUID_NW_TRIGGER 0x2A1A
|
||||
|
||||
/* Phone alert */
|
||||
#define ESP_GATT_UUID_ALERT_STATUS 0x2A3F /* alert status */
|
||||
#define ESP_GATT_UUID_RINGER_CP 0x2A40 /* ringer control point */
|
||||
#define ESP_GATT_UUID_RINGER_SETTING 0x2A41 /* ringer setting */
|
||||
/* Phone Alert Status Service */
|
||||
/** @brief Alert Status UUID. */
|
||||
#define ESP_GATT_UUID_ALERT_STATUS 0x2A3F
|
||||
/** @brief Ringer Control Point UUID. */
|
||||
#define ESP_GATT_UUID_RINGER_CP 0x2A40
|
||||
/** @brief Ringer Setting UUID. */
|
||||
#define ESP_GATT_UUID_RINGER_SETTING 0x2A41
|
||||
|
||||
/* Glucose Service */
|
||||
/** @brief Glucose Measurement Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_GM_MEASUREMENT 0x2A18
|
||||
/** @brief Glucose Measurement Context Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_GM_CONTEXT 0x2A34
|
||||
/** @brief Glucose Control Point Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_GM_CONTROL_POINT 0x2A52
|
||||
/** @brief Glucose Feature Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_GM_FEATURE 0x2A51
|
||||
|
||||
/* device information characteristic */
|
||||
/* Device Information Service Characteristics */
|
||||
/** @brief System ID Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_SYSTEM_ID 0x2A23
|
||||
/** @brief Model Number String Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_MODEL_NUMBER_STR 0x2A24
|
||||
/** @brief Serial Number String Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_SERIAL_NUMBER_STR 0x2A25
|
||||
/** @brief Firmware Revision String Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_FW_VERSION_STR 0x2A26
|
||||
/** @brief Hardware Revision String Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HW_VERSION_STR 0x2A27
|
||||
/** @brief Software Revision String Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_SW_VERSION_STR 0x2A28
|
||||
/** @brief Manufacturer Name String Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_MANU_NAME 0x2A29
|
||||
/** @brief IEEE 11073-20601 Regulatory Certification Data List Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_IEEE_DATA 0x2A2A
|
||||
/** @brief PnP ID Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_PNP_ID 0x2A50
|
||||
|
||||
/* HID characteristics */
|
||||
/* HID Service Characteristics */
|
||||
/** @brief HID Information Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_INFORMATION 0x2A4A
|
||||
/** @brief HID Report Map Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_REPORT_MAP 0x2A4B
|
||||
/** @brief HID Control Point Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_CONTROL_POINT 0x2A4C
|
||||
/** @brief HID Report Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_REPORT 0x2A4D
|
||||
/** @brief HID Protocol Mode Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_PROTO_MODE 0x2A4E
|
||||
/** @brief HID Bluetooth Keyboard Input Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_BT_KB_INPUT 0x2A22
|
||||
/** @brief HID Bluetooth Keyboard Output Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_BT_KB_OUTPUT 0x2A32
|
||||
/** @brief HID Bluetooth Mouse Input Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_HID_BT_MOUSE_INPUT 0x2A33
|
||||
|
||||
/// Heart Rate Measurement
|
||||
#define ESP_GATT_HEART_RATE_MEAS 0x2A37
|
||||
/// Body Sensor Location
|
||||
#define ESP_GATT_BODY_SENSOR_LOCATION 0x2A38
|
||||
/// Heart Rate Control Point
|
||||
#define ESP_GATT_HEART_RATE_CNTL_POINT 0x2A39
|
||||
/* Heart Rate Service Characteristics */
|
||||
/** @brief Heart Rate Measurement Characteristic UUID. */
|
||||
#define ESP_GATT_HEART_RATE_MEAS 0x2A37
|
||||
/** @brief Body Sensor Location Characteristic UUID. */
|
||||
#define ESP_GATT_BODY_SENSOR_LOCATION 0x2A38
|
||||
/** @brief Heart Rate Control Point Characteristic UUID. */
|
||||
#define ESP_GATT_HEART_RATE_CNTL_POINT 0x2A39
|
||||
|
||||
/* Battery Service characteristics */
|
||||
/* Battery Service Characteristics */
|
||||
/** @brief Battery Level Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_BATTERY_LEVEL 0x2A19
|
||||
|
||||
/* Sensor Service */
|
||||
/* Sensor Service Characteristics */
|
||||
/** @brief Sensor Control Point Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_SC_CONTROL_POINT 0x2A55
|
||||
/** @brief Sensor Location Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_SENSOR_LOCATION 0x2A5D
|
||||
|
||||
/* Runners speed and cadence service */
|
||||
/* Running Speed and Cadence Service Characteristics */
|
||||
/** @brief RSC Measurement Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_RSC_MEASUREMENT 0x2A53
|
||||
/** @brief RSC Feature Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_RSC_FEATURE 0x2A54
|
||||
|
||||
/* Cycling speed and cadence service */
|
||||
/* Cycling Speed and Cadence Service Characteristics */
|
||||
/** @brief CSC Measurement Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_CSC_MEASUREMENT 0x2A5B
|
||||
/** @brief CSC Feature Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_CSC_FEATURE 0x2A5C
|
||||
|
||||
/* Scan ESP_Parameter characteristics */
|
||||
/* Scan Parameters Service Characteristics */
|
||||
/** @brief Scan Interval Window Characteristic UUID. */
|
||||
#define ESP_GATT_UUID_SCAN_INT_WINDOW 0x2A4F
|
||||
/** @brief Scan Refresh UUID. */
|
||||
#define ESP_GATT_UUID_SCAN_REFRESH 0x2A31
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/* Additional GATT Services not covered yet */
|
||||
/** @} */ // End of group GATT_UUIDs
|
||||
|
||||
/* relate to BTA_GATT_PREP_WRITE_xxx in bta/bta_gatt_api.h */
|
||||
/// Attribute write data type from the client
|
||||
|
||||
/**
|
||||
* @brief Defines the attribute write operation types from the client.
|
||||
*
|
||||
* These values are used to specify the type of write operation in a prepare write sequence.
|
||||
* relate to BTA_GATT_PREP_WRITE_xxx in bta/bta_gatt_api.h.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */ /* relate to BTA_GATT_PREP_WRITE_CANCEL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */ /* relate to BTA_GATT_PREP_WRITE_EXEC in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel. Corresponds to BTA_GATT_PREP_WRITE_CANCEL. */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute. Corresponds to BTA_GATT_PREP_WRITE_EXEC. */
|
||||
} esp_gatt_prep_write_type;
|
||||
|
||||
/* relate to BTA_GATT_xxx in bta/bta_gatt_api.h */
|
||||
|
||||
/**
|
||||
* @brief GATT success code and error codes
|
||||
* @brief GATT operation status codes.
|
||||
*
|
||||
* These status codes are used to indicate the result of various GATT operations.
|
||||
* relate to BTA_GATT_xxx in bta/bta_gatt_api.h .
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_OK = 0x0, /* relate to BTA_GATT_OK in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */ /* relate to BTA_GATT_INVALID_HANDLE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */ /* relate to BTA_GATT_READ_NOT_PERMIT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */ /* relate to BTA_GATT_WRITE_NOT_PERMIT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */ /* relate to BTA_GATT_INVALID_PDU in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */ /* relate to BTA_GATT_INSUF_AUTHENTICATION in bta/bta_gatt_api.h */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */ /* relate to BTA_GATT_REQ_NOT_SUPPORTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */ /* relate to BTA_GATT_INVALID_OFFSET in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */ /* relate to BTA_GATT_INSUF_AUTHORIZATION in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */ /* relate to BTA_GATT_PREPARE_Q_FULL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */ /* relate to BTA_GATT_NOT_FOUND in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */ /* relate to BTA_GATT_NOT_LONG in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */ /* relate to BTA_GATT_INSUF_KEY_SIZE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */ /* relate to BTA_GATT_INVALID_ATTR_LEN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */ /* relate to BTA_GATT_ERR_UNLIKELY in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */ /* relate to BTA_GATT_INSUF_ENCRYPTION in bta/bta_gatt_api.h */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */ /* relate to BTA_GATT_UNSUPPORT_GRP_TYPE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */ /* relate to BTA_GATT_INSUF_RESOURCE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_OK = 0x0, /*!< 0x0, Operation successful. Corresponds to BTA_GATT_OK. */
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /*!< 0x01, Invalid handle. Corresponds to BTA_GATT_INVALID_HANDLE. */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /*!< 0x02, Read operation not permitted. Corresponds to BTA_GATT_READ_NOT_PERMIT. */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /*!< 0x03, Write operation not permitted. Corresponds to BTA_GATT_WRITE_NOT_PERMIT. */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /*!< 0x04, Invalid PDU. Corresponds to BTA_GATT_INVALID_PDU. */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /*!< 0x05, Insufficient authentication. Corresponds to BTA_GATT_INSUF_AUTHENTICATION. */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /*!< 0x06, Request not supported. Corresponds to BTA_GATT_REQ_NOT_SUPPORTED. */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /*!< 0x07, Invalid offset. Corresponds to BTA_GATT_INVALID_OFFSET. */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /*!< 0x08, Insufficient authorization. Corresponds to BTA_GATT_INSUF_AUTHORIZATION. */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /*!< 0x09, Prepare queue full. Corresponds to BTA_GATT_PREPARE_Q_FULL. */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /*!< 0x0a, Not found. Corresponds to BTA_GATT_NOT_FOUND. */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /*!< 0x0b, Not long. Corresponds to BTA_GATT_NOT_LONG. */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /*!< 0x0c, Insufficient key size. Corresponds to BTA_GATT_INSUF_KEY_SIZE. */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /*!< 0x0d, Invalid attribute length. Corresponds to BTA_GATT_INVALID_ATTR_LEN. */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /*!< 0x0e, Unlikely error. Corresponds to BTA_GATT_ERR_UNLIKELY. */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /*!< 0x0f, Insufficient encryption. Corresponds to BTA_GATT_INSUF_ENCRYPTION. */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /*!< 0x10, Unsupported group type. Corresponds to BTA_GATT_UNSUPPORT_GRP_TYPE. */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /*!< 0x11, Insufficient resource. Corresponds to BTA_GATT_INSUF_RESOURCE. */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */ /* relate to BTA_GATT_NO_RESOURCES in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */ /* relate to BTA_GATT_INTERNAL_ERROR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */ /* relate to BTA_GATT_WRONG_STATE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */ /* relate to BTA_GATT_DB_FULL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */ /* relate to BTA_GATT_BUSY in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */ /* relate to BTA_GATT_ERROR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */ /* relate to BTA_GATT_CMD_STARTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */ /* relate to BTA_GATT_ILLEGAL_PARAMETER in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */ /* relate to BTA_GATT_PENDING in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */ /* relate to BTA_GATT_AUTH_FAIL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */ /* relate to BTA_GATT_MORE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */ /* relate to BTA_GATT_INVALID_CFG in bta/bta_gatt_api.h */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */ /* relate to BTA_GATT_SERVICE_STARTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPTED_MITM = ESP_GATT_OK, /* relate to BTA_GATT_ENCRYPED_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPTED_NO_MITM = 0x8d, /* 0x8d */ /* relate to BTA_GATT_ENCRYPED_NO_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */ /* relate to BTA_GATT_NOT_ENCRYPTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */ /* relate to BTA_GATT_CONGESTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */ /* relate to BTA_GATT_DUP_REG in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */ /* relate to BTA_GATT_ALREADY_OPEN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */ /* relate to BTA_GATT_CANCEL in bta/bta_gatt_api.h */
|
||||
/* Additional error codes specific to implementation or future use */
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /*!< 0x80, No resources. Corresponds to BTA_GATT_NO_RESOURCES. */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /*!< 0x81, Internal error. Corresponds to BTA_GATT_INTERNAL_ERROR. */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /*!< 0x82, Wrong state. Corresponds to BTA_GATT_WRONG_STATE. */
|
||||
ESP_GATT_DB_FULL = 0x83, /*!< 0x83, Database full. Corresponds to BTA_GATT_DB_FULL. */
|
||||
ESP_GATT_BUSY = 0x84, /*!< 0x84, Busy. Corresponds to BTA_GATT_BUSY. */
|
||||
ESP_GATT_ERROR = 0x85, /*!< 0x85, Generic error. Corresponds to BTA_GATT_ERROR. */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /*!< 0x86, Command started. Corresponds to BTA_GATT_CMD_STARTED. */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /*!< 0x87, Illegal parameter. Corresponds to BTA_GATT_ILLEGAL_PARAMETER. */
|
||||
ESP_GATT_PENDING = 0x88, /*!< 0x88, Operation pending. Corresponds to BTA_GATT_PENDING. */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /*!< 0x89, Authentication failed. Corresponds to BTA_GATT_AUTH_FAIL. */
|
||||
ESP_GATT_MORE = 0x8a, /*!< 0x8a, More data available. Corresponds to BTA_GATT_MORE. */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /*!< 0x8b, Invalid configuration. Corresponds to BTA_GATT_INVALID_CFG. */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /*!< 0x8c, Service started. Corresponds to BTA_GATT_SERVICE_STARTED. */
|
||||
ESP_GATT_ENCRYPTED_MITM = ESP_GATT_OK, /*!< 0x0, Encrypted, with MITM protection. Corresponds to BTA_GATT_ENCRYPTED_MITM. */
|
||||
ESP_GATT_ENCRYPTED_NO_MITM = 0x8d, /*!< 0x8d, Encrypted, without MITM protection. Corresponds to BTA_GATT_ENCRYPTED_NO_MITM. */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /*!< 0x8e, Not encrypted. Corresponds to BTA_GATT_NOT_ENCRYPTED. */
|
||||
ESP_GATT_CONGESTED = 0x8f, /*!< 0x8f, Congested. Corresponds to BTA_GATT_CONGESTED. */
|
||||
ESP_GATT_DUP_REG = 0x90, /*!< 0x90, Duplicate registration. Corresponds to BTA_GATT_DUP_REG. */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /*!< 0x91, Already open. Corresponds to BTA_GATT_ALREADY_OPEN. */
|
||||
ESP_GATT_CANCEL = 0x92, /*!< 0x92, Operation cancelled. Corresponds to BTA_GATT_CANCEL. */
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_STACK_RSP = 0xe0, /* 0xe0 */ /* relate to BTA_GATT_STACK_RSP in bta/bta_gatt_api.h */
|
||||
ESP_GATT_APP_RSP = 0xe1, /* 0xe1 */ /* relate to BTA_GATT_APP_RSP in bta/bta_gatt_api.h */
|
||||
//Error caused by customer application or stack bug
|
||||
ESP_GATT_UNKNOWN_ERROR = 0xef, /* 0xef */ /* relate to BTA_GATT_UNKNOWN_ERROR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ /* relate to BTA_GATT_CCC_CFG_ERR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */ /* relate to BTA_GATT_PRC_IN_PROGRESS in bta/bta_gatt_api.h */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFF Attribute value out of range */ /* relate to BTA_GATT_OUT_OF_RANGE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_STACK_RSP = 0xe0, /*!< 0xe0, Stack response. Corresponds to BTA_GATT_STACK_RSP. */
|
||||
ESP_GATT_APP_RSP = 0xe1, /*!< 0xe1, Application response. Corresponds to BTA_GATT_APP_RSP. */
|
||||
/* Error caused by customer application or stack bug */
|
||||
ESP_GATT_UNKNOWN_ERROR = 0xef, /*!< 0xef, Unknown error. Corresponds to BTA_GATT_UNKNOWN_ERROR. */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /*!< 0xfd, Client Characteristic Configuration Descriptor improperly configured. Corresponds to BTA_GATT_CCC_CFG_ERR. */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /*!< 0xfe, Procedure already in progress. Corresponds to BTA_GATT_PRC_IN_PROGRESS. */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff /*!< 0xff, Attribute value out of range. Corresponds to BTA_GATT_OUT_OF_RANGE. */
|
||||
} esp_gatt_status_t;
|
||||
|
||||
/* relate to BTA_GATT_CONN_xxx in bta/bta_gatt_api.h */
|
||||
|
||||
/**
|
||||
* @brief Gatt Connection reason enum
|
||||
* @brief Enumerates reasons for GATT connection.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */ /* relate to BTA_GATT_CONN_UNKNOWN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */ /* relate to BTA_GATT_CONN_L2C_FAILURE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */ /* relate to BTA_GATT_CONN_TIMEOUT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */ /* relate to BTA_GATT_CONN_TERMINATE_PEER_USER in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connection terminated by local host */ /* relate to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */ /* relate to BTA_GATT_CONN_FAIL_ESTABLISH in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */ /* relate to BTA_GATT_CONN_LMP_TIMEOUT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */ /* relate to BTA_GATT_CONN_CONN_CANCEL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */ /* relate to BTA_GATT_CONN_NONE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Unknown connection reason. Corresponds to BTA_GATT_CONN_UNKNOWN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2CAP failure. Corresponds to BTA_GATT_CONN_L2C_FAILURE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout. Corresponds to BTA_GATT_CONN_TIMEOUT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminated by peer user. Corresponds to BTA_GATT_CONN_TERMINATE_PEER_USER in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connection terminated by local host. Corresponds to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Failure to establish connection. Corresponds to BTA_GATT_CONN_FAIL_ESTABLISH in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection failed due to LMP response timeout. Corresponds to BTA_GATT_CONN_LMP_TIMEOUT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled. Corresponds to BTA_GATT_CONN_CONN_CANCEL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel. Corresponds to BTA_GATT_CONN_NONE in bta/bta_gatt_api.h */
|
||||
} esp_gatt_conn_reason_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gatt id, include uuid and instance id
|
||||
* @brief Represents a GATT identifier.
|
||||
*/
|
||||
typedef struct {
|
||||
esp_bt_uuid_t uuid; /*!< UUID */
|
||||
uint8_t inst_id; /*!< Instance id */
|
||||
esp_bt_uuid_t uuid; /*!< @brief The UUID component of the GATT ID. */
|
||||
uint8_t inst_id; /*!< @brief The instance ID component of the GATT ID, providing further differentiation of the GATT ID. */
|
||||
} __attribute__((packed)) esp_gatt_id_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gatt service id, include id
|
||||
* (uuid and instance id) and primary flag
|
||||
* @brief Represents a GATT service identifier.
|
||||
*/
|
||||
typedef struct {
|
||||
esp_gatt_id_t id; /*!< Gatt id, include uuid and instance */
|
||||
bool is_primary; /*!< This service is primary or not */
|
||||
esp_gatt_id_t id; /*!< @brief Encapsulates the UUID and instance ID of the GATT service. */
|
||||
bool is_primary; /*!< @brief Indicates if the service is primary. A value of true means it is a primary service, false indicates a secondary service. */
|
||||
} __attribute__((packed)) esp_gatt_srvc_id_t;
|
||||
|
||||
/* relate to BTA_GATT_AUTH_REQ_xxx in bta/bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Gatt authentication request type
|
||||
* @brief Defines the GATT authentication request types.
|
||||
*
|
||||
* This enumeration lists the types of authentication requests that can be made.
|
||||
* It corresponds to the `BTA_GATT_AUTH_REQ_xxx` values defined in `bta/bta_gatt_api.h`.
|
||||
* The types include options for no authentication, unauthenticated encryption, authenticated encryption,
|
||||
* and both signed versions with and without MITM (Man-In-The-Middle) protection.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_AUTH_REQ_NONE = 0, /* relate to BTA_GATT_AUTH_REQ_NONE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_NO_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /* relate to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /* relate to BTA_GATT_AUTH_REQ_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NONE = 0, /*!< No authentication required. Corresponds to BTA_GATT_AUTH_REQ_NONE. */
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /*!< Unauthenticated encryption. Corresponds to BTA_GATT_AUTH_REQ_NO_MITM. */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /*!< Authenticated encryption (MITM protection). Corresponds to BTA_GATT_AUTH_REQ_MITM. */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /*!< Signed data, no MITM protection. Corresponds to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM. */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /*!< Signed data with MITM protection. Corresponds to BTA_GATT_AUTH_REQ_SIGNED_MITM. */
|
||||
} esp_gatt_auth_req_t;
|
||||
|
||||
/* relate to BTA_GATT_PERM_xxx in bta/bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Attribute permissions
|
||||
*/
|
||||
#define ESP_GATT_PERM_READ (1 << 0) /* bit 0 - 0x0001 */ /* relate to BTA_GATT_PERM_READ in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 - 0x0002 */ /* relate to BTA_GATT_PERM_READ_ENCRYPTED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 - 0x0004 */ /* relate to BTA_GATT_PERM_READ_ENC_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE (1 << 4) /* bit 4 - 0x0010 */ /* relate to BTA_GATT_PERM_WRITE in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 - 0x0020 */ /* relate to BTA_GATT_PERM_WRITE_ENCRYPTED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 - 0x0200 */
|
||||
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10) /* bit 10 - 0x0400 */
|
||||
#define ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize) (((keysize - 6) & 0xF) << 12) /* bit 12:15 - 0xF000 */
|
||||
typedef uint16_t esp_gatt_perm_t;
|
||||
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
||||
/* definition of characteristic properties */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0) /* 0x01 */ /* relate to BTA_GATT_CHAR_PROP_BIT_BROADCAST in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1) /* 0x02 */ /* relate to BTA_GATT_CHAR_PROP_BIT_READ in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2) /* 0x04 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE_NR in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3) /* 0x08 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4) /* 0x10 */ /* relate to BTA_GATT_CHAR_PROP_BIT_NOTIFY in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5) /* 0x20 */ /* relate to BTA_GATT_CHAR_PROP_BIT_INDICATE in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6) /* 0x40 */ /* relate to BTA_GATT_CHAR_PROP_BIT_AUTH in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) /* 0x80 */ /* relate to BTA_GATT_CHAR_PROP_BIT_EXT_PROP in bta/bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Defines GATT attribute permission flags.
|
||||
*
|
||||
* These permission flags are used to specify the security requirements for GATT attributes.
|
||||
* They correlate directly with the BTA_GATT_PERM_xxx definitions found in bta/bta_gatt_api.h.
|
||||
*/
|
||||
|
||||
/** @defgroup GATT_PERMS GATT Attribute Permissions
|
||||
* @brief Definitions of permission flags for GATT attributes.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @brief Permission to read the attribute. Corresponds to BTA_GATT_PERM_READ. */
|
||||
#define ESP_GATT_PERM_READ (1 << 0)
|
||||
|
||||
/** @brief Permission to read the attribute with encryption. Corresponds to BTA_GATT_PERM_READ_ENCRYPTED. */
|
||||
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1)
|
||||
|
||||
/** @brief Permission to read the attribute with encrypted MITM (Man In The Middle) protection. Corresponds to BTA_GATT_PERM_READ_ENC_MITM.*/
|
||||
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2)
|
||||
|
||||
/** @brief Permission to write to the attribute. Corresponds to BTA_GATT_PERM_WRITE. */
|
||||
#define ESP_GATT_PERM_WRITE (1 << 4)
|
||||
|
||||
/** @brief Permission to write to the attribute with encryption. Corresponds to BTA_GATT_PERM_WRITE_ENCRYPTED. */
|
||||
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5)
|
||||
|
||||
/** @brief Permission to write to the attribute with encrypted MITM protection. Corresponds to BTA_GATT_PERM_WRITE_ENC_MITM. */
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6)
|
||||
|
||||
/** @brief Permission for signed writes to the attribute. Corresponds to BTA_GATT_PERM_WRITE_SIGNED. */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7)
|
||||
|
||||
/** @brief Permission for signed writes to the attribute with MITM protection. Corresponds to BTA_GATT_PERM_WRITE_SIGNED_MITM. */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8)
|
||||
|
||||
/** @brief Permission to read the attribute with authorization. */
|
||||
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9)
|
||||
|
||||
/** @brief Permission to write to the attribute with authorization. */
|
||||
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10)
|
||||
|
||||
/**
|
||||
* @brief Macro to specify minimum encryption key size.
|
||||
*
|
||||
* @param keysize The minimum size of the encryption key, in bytes.
|
||||
*/
|
||||
#define ESP_GATT_PERM_ENCRYPT_KEY_SIZE(keysize) (((keysize - 6) & 0xF) << 12)
|
||||
|
||||
/** @} */ // End of GATT_PERMS group
|
||||
|
||||
typedef uint16_t esp_gatt_perm_t; ///< Type to represent GATT attribute permissions.
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Defines GATT characteristic properties.
|
||||
*
|
||||
* These properties are related to `BTA_GATT_CHAR_PROP_BIT_xxx` in `bta/bta_gatt_api.h`.
|
||||
*/
|
||||
|
||||
/** @defgroup GATT_CHAR_PROPERTIES GATT Characteristic Properties
|
||||
* These properties define various capabilities of a GATT characteristic.
|
||||
* @{
|
||||
*/
|
||||
/** @brief Ability to broadcast.Corresponds to BTA_GATT_CHAR_PROP_BIT_BROADCAST. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0)
|
||||
|
||||
/** @brief Ability to read.Corresponds to BTA_GATT_CHAR_PROP_BIT_READ. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1)
|
||||
|
||||
/** @brief Ability to write without response.Corresponds to BTA_GATT_CHAR_PROP_BIT_WRITE_NR. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2)
|
||||
|
||||
/** @brief Ability to write.Corresponds to BTA_GATT_CHAR_PROP_BIT_WRITE. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3)
|
||||
|
||||
/** @brief Ability to notify.Corresponds to BTA_GATT_CHAR_PROP_BIT_NOTIFY. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4)
|
||||
|
||||
/** @brief Ability to indicate.Corresponds to BTA_GATT_CHAR_PROP_BIT_INDICATE. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5)
|
||||
|
||||
/** @brief Ability to authenticate.Corresponds to BTA_GATT_CHAR_PROP_BIT_AUTH. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6)
|
||||
|
||||
/** @brief Has extended properties.Corresponds to BTA_GATT_CHAR_PROP_BIT_EXT_PROP. */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7)
|
||||
|
||||
/** @} */ // end of GATT_CHAR_PROPERTIES
|
||||
|
||||
/**
|
||||
* @typedef esp_gatt_char_prop_t
|
||||
* @brief Type for characteristic properties bitmask.
|
||||
*/
|
||||
typedef uint8_t esp_gatt_char_prop_t;
|
||||
|
||||
/// GATT maximum attribute length
|
||||
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
|
||||
|
||||
/**
|
||||
* @brief Defines the maximum length of a GATT attribute.
|
||||
*
|
||||
* This definition specifies the maximum number of bytes that a GATT attribute can hold.
|
||||
*/
|
||||
#define ESP_GATT_MAX_ATTR_LEN 512 /*!< As same as GATT_MAX_ATTR_LEN. */
|
||||
|
||||
/**
|
||||
* @brief Enumerates the possible sources of a GATT service discovery.
|
||||
*
|
||||
* This enumeration identifies the source of a GATT service discovery process,
|
||||
* indicating whether the service information was obtained from a remote device,
|
||||
* from NVS (Non-Volatile Storage) flash, or the source is unknown.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_SERVICE_FROM_REMOTE_DEVICE = 0, /* relate to BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE in bta_gattc_int.h */
|
||||
ESP_GATT_SERVICE_FROM_NVS_FLASH = 1, /* relate to BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH in bta_gattc_int.h */
|
||||
ESP_GATT_SERVICE_FROM_UNKNOWN = 2, /* relate to BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN in bta_gattc_int.h */
|
||||
ESP_GATT_SERVICE_FROM_REMOTE_DEVICE = 0, /*!< Service information from a remote device. Relates to BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE. */
|
||||
ESP_GATT_SERVICE_FROM_NVS_FLASH = 1, /*!< Service information from NVS flash. Relates to BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH. */
|
||||
ESP_GATT_SERVICE_FROM_UNKNOWN = 2, /*!< Service source is unknown. Relates to BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN. */
|
||||
} esp_service_source_t;
|
||||
|
||||
/**
|
||||
* @brief Attribute description (used to create database)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid_length; /*!< UUID length */
|
||||
uint8_t *uuid_p; /*!< UUID value */
|
||||
uint16_t perm; /*!< Attribute permission */
|
||||
uint16_t max_length; /*!< Maximum length of the element*/
|
||||
uint16_t length; /*!< Current length of the element*/
|
||||
uint8_t *value; /*!< Element value array*/
|
||||
} esp_attr_desc_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief attribute auto response flag
|
||||
* @brief Defines an attribute's description.
|
||||
*
|
||||
* This structure is used to describe an attribute in the GATT database. It includes
|
||||
* details such as the UUID of the attribute, its permissions, and its value.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid_length; /*!< Length of the UUID in bytes. */
|
||||
uint8_t *uuid_p; /*!< Pointer to the UUID value. */
|
||||
uint16_t perm; /*!< Attribute permissions, defined by esp_gatt_perm_t. */
|
||||
uint16_t max_length; /*!< Maximum length of the attribute's value. */
|
||||
uint16_t length; /*!< Current length of the attribute's value. */
|
||||
uint8_t *value; /*!< Pointer to the attribute's value array. */
|
||||
} esp_attr_desc_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Defines attribute control for GATT operations.
|
||||
*
|
||||
* This module provides definitions for controlling attribute auto responses
|
||||
* in GATT operations.
|
||||
*/
|
||||
|
||||
/** @brief Response to Write/Read operations should be handled by the application. */
|
||||
#define ESP_GATT_RSP_BY_APP 0
|
||||
|
||||
/** @brief Response to Write/Read operations should be automatically handled by the GATT stack. */
|
||||
#define ESP_GATT_AUTO_RSP 1
|
||||
|
||||
/**
|
||||
* @brief Defines the auto response setting for attribute operations.
|
||||
*
|
||||
* This structure is used to control whether the GATT stack or the application
|
||||
* will handle responses to Read/Write operations.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#define ESP_GATT_RSP_BY_APP 0
|
||||
#define ESP_GATT_AUTO_RSP 1
|
||||
/**
|
||||
* @brief if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application.
|
||||
if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.
|
||||
* @brief Controls who handles the response to Read/Write operations.
|
||||
*
|
||||
* - If set to @c ESP_GATT_RSP_BY_APP, the application is responsible for
|
||||
* generating the response.
|
||||
* - If set to @c ESP_GATT_AUTO_RSP, the GATT stack will automatically generate
|
||||
* the response.
|
||||
*/
|
||||
uint8_t auto_rsp;
|
||||
} esp_attr_control_t;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief attribute type added to the gatt server database
|
||||
* @brief attribute type added to the GATT server database
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -370,116 +585,103 @@ typedef struct
|
||||
uint16_t end_hdl; /*!< Gatt end handle value of included 128 bit service */
|
||||
} esp_gatts_incl128_svc_desc_t; /*!< Gatt include 128 bit service entry element */
|
||||
|
||||
/// Gatt attribute value
|
||||
/**
|
||||
* @brief Represents a GATT attribute's value.
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t value[ESP_GATT_MAX_ATTR_LEN]; /*!< Gatt attribute value */
|
||||
uint16_t handle; /*!< Gatt attribute handle */
|
||||
uint16_t offset; /*!< Gatt attribute value offset */
|
||||
uint16_t len; /*!< Gatt attribute value length */
|
||||
uint8_t auth_req; /*!< Gatt authentication request */
|
||||
uint8_t value[ESP_GATT_MAX_ATTR_LEN]; /*!< Array holding the value of the GATT attribute. */
|
||||
uint16_t handle; /*!< Unique identifier (handle) of the GATT attribute. */
|
||||
uint16_t offset; /*!< Offset within the attribute's value, for partial updates. */
|
||||
uint16_t len; /*!< Current length of the data in the value array. */
|
||||
uint8_t auth_req; /*!< Authentication requirements for accessing this attribute. */
|
||||
} esp_gatt_value_t;
|
||||
|
||||
/// GATT remote read request response type
|
||||
/**
|
||||
* @brief Represents the response type for a GATT remote read request.
|
||||
*/
|
||||
typedef union {
|
||||
esp_gatt_value_t attr_value; /*!< Gatt attribute structure */
|
||||
uint16_t handle; /*!< Gatt attribute handle */
|
||||
esp_gatt_value_t attr_value; /*!< The GATT attribute value, including its data, handle, and metadata. */
|
||||
uint16_t handle; /*!< Only the handle of the GATT attribute, when that's the only required information. */
|
||||
} esp_gatt_rsp_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Gatt write type
|
||||
*/
|
||||
* @brief Defines the types of GATT write operations.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_WRITE_TYPE_NO_RSP = 1, /*!< Gatt write attribute need no response */
|
||||
ESP_GATT_WRITE_TYPE_RSP, /*!< Gatt write attribute need remote response */
|
||||
ESP_GATT_WRITE_TYPE_NO_RSP = 1, /*!< Write operation where no response is needed. */
|
||||
ESP_GATT_WRITE_TYPE_RSP = 2, /*!< Write operation that requires a remote response. */
|
||||
} esp_gatt_write_type_t;
|
||||
|
||||
/**
|
||||
* @brief Connection parameters information
|
||||
*/
|
||||
|
||||
/** @brief Connection parameters for GATT. */
|
||||
typedef struct {
|
||||
uint16_t interval; /*!< connection interval */
|
||||
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
|
||||
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
|
||||
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec
|
||||
Time Range: 100 msec to 32 seconds */
|
||||
uint16_t interval; /*!< Connection interval. */
|
||||
uint16_t latency; /*!< Slave latency for the connection in number of connection events. */
|
||||
uint16_t timeout; /*!< Supervision timeout for the LE Link. */
|
||||
} esp_gatt_conn_params_t;
|
||||
|
||||
#define ESP_GATT_IF_NONE 0xff /*!< If callback report gattc_if/gatts_if as this macro, means this event is not correspond to any app */
|
||||
/** @brief Macro indicating no specific GATT interface. */
|
||||
#define ESP_GATT_IF_NONE 0xff /*!< No specific application GATT interface. */
|
||||
|
||||
typedef uint8_t esp_gatt_if_t; /*!< Gatt interface type, different application on GATT client use different gatt_if */
|
||||
/** @brief GATT interface type for client applications. */
|
||||
typedef uint8_t esp_gatt_if_t;
|
||||
|
||||
/**
|
||||
* @brief the type of attribute element
|
||||
*/
|
||||
/** @brief Enumerates types of GATT database attributes. */
|
||||
typedef enum {
|
||||
ESP_GATT_DB_PRIMARY_SERVICE, /*!< Gattc primary service attribute type in the cache */
|
||||
ESP_GATT_DB_SECONDARY_SERVICE, /*!< Gattc secondary service attribute type in the cache */
|
||||
ESP_GATT_DB_CHARACTERISTIC, /*!< Gattc characteristic attribute type in the cache */
|
||||
ESP_GATT_DB_DESCRIPTOR, /*!< Gattc characteristic descriptor attribute type in the cache */
|
||||
ESP_GATT_DB_INCLUDED_SERVICE, /*!< Gattc include service attribute type in the cache */
|
||||
ESP_GATT_DB_ALL, /*!< Gattc all the attribute (primary service & secondary service & include service & char & descriptor) type in the cache */
|
||||
} esp_gatt_db_attr_type_t; /*!< Gattc attribute type element */
|
||||
ESP_GATT_DB_PRIMARY_SERVICE, /*!< Primary service attribute. */
|
||||
ESP_GATT_DB_SECONDARY_SERVICE, /*!< Secondary service attribute. */
|
||||
ESP_GATT_DB_CHARACTERISTIC, /*!< Characteristic attribute. */
|
||||
ESP_GATT_DB_DESCRIPTOR, /*!< Descriptor attribute. */
|
||||
ESP_GATT_DB_INCLUDED_SERVICE, /*!< Included service attribute. */
|
||||
ESP_GATT_DB_ALL, /*!< All attribute types. */
|
||||
} esp_gatt_db_attr_type_t;
|
||||
|
||||
/**
|
||||
* @brief read multiple attribute
|
||||
*/
|
||||
/** @brief Represents multiple attributes for reading. */
|
||||
typedef struct {
|
||||
uint8_t num_attr; /*!< The number of the attribute */
|
||||
uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES]; /*!< The handles list */
|
||||
} esp_gattc_multi_t; /*!< The gattc multiple read element */
|
||||
uint8_t num_attr; /*!< Number of attributes. */
|
||||
uint16_t handles[ESP_GATT_MAX_READ_MULTI_HANDLES]; /*!< List of attribute handles. */
|
||||
} esp_gattc_multi_t;
|
||||
|
||||
/**
|
||||
* @brief data base attribute element
|
||||
*/
|
||||
/** @brief GATT database attribute element. */
|
||||
typedef struct {
|
||||
esp_gatt_db_attr_type_t type; /*!< The attribute type */
|
||||
uint16_t attribute_handle; /*!< The attribute handle, it's valid for all of the type */
|
||||
uint16_t start_handle; /*!< The service start handle, it's valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE */
|
||||
uint16_t end_handle; /*!< The service end handle, it's valid only when the type = ESP_GATT_DB_PRIMARY_SERVICE or ESP_GATT_DB_SECONDARY_SERVICE */
|
||||
esp_gatt_char_prop_t properties; /*!< The characteristic properties, it's valid only when the type = ESP_GATT_DB_CHARACTERISTIC */
|
||||
esp_bt_uuid_t uuid; /*!< The attribute uuid, it's valid for all of the type */
|
||||
} esp_gattc_db_elem_t; /*!< The gattc service data base element in the cache */
|
||||
esp_gatt_db_attr_type_t type; /*!< Attribute type. */
|
||||
uint16_t attribute_handle; /*!< Attribute handle. */
|
||||
uint16_t start_handle; /*!< Service start handle. */
|
||||
uint16_t end_handle; /*!< Service end handle. */
|
||||
esp_gatt_char_prop_t properties; /*!< Characteristic properties. */
|
||||
esp_bt_uuid_t uuid; /*!< Attribute UUID. */
|
||||
} esp_gattc_db_elem_t;
|
||||
|
||||
/**
|
||||
* @brief service element
|
||||
*/
|
||||
/** @brief Represents a GATT service element. */
|
||||
typedef struct {
|
||||
bool is_primary; /*!< The service flag, true if the service is primary service, else is secondary service */
|
||||
uint16_t start_handle; /*!< The start handle of the service */
|
||||
uint16_t end_handle; /*!< The end handle of the service */
|
||||
esp_bt_uuid_t uuid; /*!< The uuid of the service */
|
||||
} esp_gattc_service_elem_t; /*!< The gattc service element */
|
||||
bool is_primary; /*!< Indicates if the service is primary. */
|
||||
uint16_t start_handle; /*!< Service start handle. */
|
||||
uint16_t end_handle; /*!< Service end handle. */
|
||||
esp_bt_uuid_t uuid; /*!< Service UUID. */
|
||||
} esp_gattc_service_elem_t;
|
||||
|
||||
/**
|
||||
* @brief characteristic element
|
||||
*/
|
||||
/** @brief Represents a GATT characteristic element. */
|
||||
typedef struct {
|
||||
uint16_t char_handle; /*!< The characteristic handle */
|
||||
esp_gatt_char_prop_t properties; /*!< The characteristic properties */
|
||||
esp_bt_uuid_t uuid; /*!< The characteristic uuid */
|
||||
} esp_gattc_char_elem_t; /*!< The gattc characteristic element */
|
||||
uint16_t char_handle; /*!< Characteristic handle. */
|
||||
esp_gatt_char_prop_t properties; /*!< Characteristic properties. */
|
||||
esp_bt_uuid_t uuid; /*!< Characteristic UUID. */
|
||||
} esp_gattc_char_elem_t;
|
||||
|
||||
/**
|
||||
* @brief descriptor element
|
||||
*/
|
||||
/** @brief Represents a GATT descriptor element. */
|
||||
typedef struct {
|
||||
uint16_t handle; /*!< The characteristic descriptor handle */
|
||||
esp_bt_uuid_t uuid; /*!< The characteristic descriptor uuid */
|
||||
} esp_gattc_descr_elem_t; /*!< The gattc descriptor type element */
|
||||
uint16_t handle; /*!< Descriptor handle. */
|
||||
esp_bt_uuid_t uuid; /*!< Descriptor UUID. */
|
||||
} esp_gattc_descr_elem_t;
|
||||
|
||||
/**
|
||||
* @brief include service element
|
||||
*/
|
||||
/** @brief Represents an included GATT service element. */
|
||||
typedef struct {
|
||||
uint16_t handle; /*!< The include service current attribute handle */
|
||||
uint16_t incl_srvc_s_handle; /*!< The start handle of the service which has been included */
|
||||
uint16_t incl_srvc_e_handle; /*!< The end handle of the service which has been included */
|
||||
esp_bt_uuid_t uuid; /*!< The include service uuid */
|
||||
} esp_gattc_incl_svc_elem_t; /*!< The gattc include service element */
|
||||
|
||||
uint16_t handle; /*!< Current attribute handle of the included service. */
|
||||
uint16_t incl_srvc_s_handle; /*!< Start handle of the included service. */
|
||||
uint16_t incl_srvc_e_handle; /*!< End handle of the included service. */
|
||||
esp_bt_uuid_t uuid; /*!< Included service UUID. */
|
||||
} esp_gattc_incl_svc_elem_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GATT_DEFS_H__ */
|
||||
|
||||
@@ -615,6 +615,11 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
|
||||
btm_ble_resolving_list_cleanup (); //by TH, because cmn_ble_vsc_cb.max_filter has something mistake as btm_ble_adv_filter_cleanup
|
||||
#endif
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
// btm_ble_multi_adv_init is called when the host is enabled, so btm_ble_multi_adv_cleanup is called when the host is disabled.
|
||||
btm_ble_multi_adv_cleanup();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -649,7 +654,7 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
}
|
||||
|
||||
/* Retrigger disable timer in case ACL disconnect failed, DISABLE_EVT still need
|
||||
to be sent out to avoid jave layer disable timeout */
|
||||
to be sent out to avoid the layer disable timeout */
|
||||
if (trigger_disc) {
|
||||
bta_dm_cb.disable_timer.p_cback = (TIMER_CBACK *)&bta_dm_disable_timer_cback;
|
||||
bta_dm_cb.disable_timer.param = 1;
|
||||
@@ -678,9 +683,11 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
*******************************************************************************/
|
||||
void bta_dm_set_dev_name (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name);
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name, p_data->set_name.name_type);
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
bta_dm_set_eir ((char *)p_data->set_name.name);
|
||||
if (p_data->set_name.name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
bta_dm_set_eir ((char *)p_data->set_name.name);
|
||||
}
|
||||
#endif /// CLASSIC_BT_INCLUDED
|
||||
}
|
||||
|
||||
@@ -699,7 +706,7 @@ void bta_dm_get_dev_name (tBTA_DM_MSG *p_data)
|
||||
tBTM_STATUS status;
|
||||
char *name = NULL;
|
||||
|
||||
status = BTM_ReadLocalDeviceName(&name);
|
||||
status = BTM_ReadLocalDeviceName(&name, p_data->get_name.name_type);
|
||||
if (p_data->get_name.p_cback) {
|
||||
(*p_data->get_name.p_cback)(status, name);
|
||||
}
|
||||
@@ -709,7 +716,7 @@ void bta_dm_get_dev_name (tBTA_DM_MSG *p_data)
|
||||
**
|
||||
** Function bta_dm_cfg_coex_status
|
||||
**
|
||||
** Description config coexistance status
|
||||
** Description config coexistence status
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
@@ -724,6 +731,14 @@ void bta_dm_cfg_coex_status (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
#endif
|
||||
|
||||
void bta_dm_send_vendor_hci(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_VendorSpecificCommand(p_data->vendor_hci_cmd.opcode,
|
||||
p_data->vendor_hci_cmd.param_len,
|
||||
p_data->vendor_hci_cmd.p_param_buf,
|
||||
p_data->vendor_hci_cmd.vendor_hci_cb);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_set_afh_channels
|
||||
@@ -772,7 +787,7 @@ static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT tr
|
||||
APPL_TRACE_DEBUG("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName is busy");
|
||||
|
||||
/* Remote name discovery is on going now so BTM cannot notify through "bta_dm_remname_cback" */
|
||||
/* adding callback to get notified that current reading remore name done */
|
||||
/* adding callback to get notified that current reading remote name done */
|
||||
BTM_SecAddRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
|
||||
|
||||
return (TRUE);
|
||||
@@ -907,6 +922,23 @@ void bta_dm_set_acl_pkt_types (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_set_min_enc_key_size
|
||||
**
|
||||
** Description Sets the minimal size of encryption key
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
void bta_dm_set_min_enc_key_size (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_SetMinEncKeySize(p_data->set_min_enc_key_size.key_size, p_data->set_min_enc_key_size.set_min_enc_key_size_cb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1156,7 +1188,7 @@ void bta_dm_add_device (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
if (p_dev->is_trusted) {
|
||||
/* covert BTA service mask to BTM mask */
|
||||
/* convert BTA service mask to BTM mask */
|
||||
while (p_dev->tm && (index < BTA_MAX_SERVICE_ID)) {
|
||||
if (p_dev->tm & (UINT32)(1 << index)) {
|
||||
|
||||
@@ -1184,7 +1216,7 @@ void bta_dm_add_device (tBTA_DM_MSG *p_data)
|
||||
** Function bta_dm_close_acl
|
||||
**
|
||||
** Description This function forces to close the connection to a remote device
|
||||
** and optionaly remove the device from security database if
|
||||
** and optionally remove the device from security database if
|
||||
** required.
|
||||
****
|
||||
*******************************************************************************/
|
||||
@@ -2707,7 +2739,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
|
||||
&bta_dm_search_cb.services_found );
|
||||
}
|
||||
|
||||
/* if seaching with EIR is not completed */
|
||||
/* if searching with EIR is not completed */
|
||||
if (bta_dm_search_cb.services_to_search) {
|
||||
/* check whether connection already exists to the device
|
||||
if connection exists, we don't have to wait for ACL
|
||||
@@ -3794,7 +3826,7 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
tBTA_SYS_HW_MSG *sys_enable_event;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* disable the power managment module */
|
||||
/* disable the power management module */
|
||||
bta_dm_disable_pm();
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
@@ -4138,7 +4170,7 @@ static void bta_dm_set_eir (char *local_name)
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_name) {
|
||||
/* if local name is not provided, get it from controller */
|
||||
if ( local_name == NULL ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name ) != BTM_SUCCESS ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name, BT_DEVICE_TYPE_BREDR) != BTM_SUCCESS ) {
|
||||
APPL_TRACE_ERROR("Fail to read local device name for EIR");
|
||||
}
|
||||
}
|
||||
@@ -4181,7 +4213,7 @@ static void bta_dm_set_eir (char *local_name)
|
||||
p = (UINT8 *)p_buf + BTM_HCI_EIR_OFFSET; /* reset p */
|
||||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
|
||||
/* if UUID doesn't fit remaing space, shorten local name */
|
||||
/* if UUID doesn't fit remaining space, shorten local name */
|
||||
if ( local_name_len > (free_eir_length - 4 - num_uuid * LEN_UUID_16)) {
|
||||
APPL_TRACE_WARNING("BTA EIR: local name is shortened");
|
||||
local_name_len = p_bta_dm_eir_cfg->bta_dm_eir_min_name_len;
|
||||
@@ -5234,14 +5266,14 @@ void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data)
|
||||
**
|
||||
** Description This function set the LE random address for the device.
|
||||
**
|
||||
** Parameters: rand_addr:the random address whitch should be setting
|
||||
** Parameters: rand_addr:the random address which should be setting
|
||||
** Explanation: This function added by Yulong at 2016/9/9
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTM_STATUS status = BTM_SET_STATIC_RAND_ADDR_FAIL;
|
||||
if (p_data->set_addr.addr_type != BLE_ADDR_RANDOM) {
|
||||
APPL_TRACE_ERROR("Invalid random adress type = %d\n", p_data->set_addr.addr_type);
|
||||
APPL_TRACE_ERROR("Invalid random address type = %d\n", p_data->set_addr.addr_type);
|
||||
if(p_data->set_addr.p_set_rand_addr_cback) {
|
||||
(*p_data->set_addr.p_set_rand_addr_cback)(status);
|
||||
}
|
||||
@@ -5596,7 +5628,7 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback;
|
||||
// if the value of the data length is same, triger callback directly
|
||||
// if the value of the data length is same, trigger callback directly
|
||||
if(p_data->ble_set_data_length.tx_data_length == p_acl_cb->data_length_params.tx_len) {
|
||||
if(p_data->ble_set_data_length.p_set_pkt_data_cback) {
|
||||
(*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params);
|
||||
@@ -5605,7 +5637,7 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
if(p_acl_cb->data_len_updating) {
|
||||
// aleady have one cmd
|
||||
// already have one cmd
|
||||
if(p_acl_cb->data_len_waiting) {
|
||||
status = BTM_ILLEGAL_ACTION;
|
||||
} else {
|
||||
@@ -5791,6 +5823,28 @@ void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_API("%s, rpa_timeout = %d", __func__, p_data->set_rpa_timeout.rpa_timeout);
|
||||
BTM_BleSetRpaTimeout(p_data->set_rpa_timeout.rpa_timeout,p_data->set_rpa_timeout.p_set_rpa_timeout_cback);
|
||||
}
|
||||
|
||||
void bta_dm_ble_gap_add_dev_to_resolving_list(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_API("%s", __func__);
|
||||
BTM_BleAddDevToResolvingList(p_data->add_dev_to_resolving_list.addr,
|
||||
p_data->add_dev_to_resolving_list.addr_type,
|
||||
p_data->add_dev_to_resolving_list.irk,
|
||||
p_data->add_dev_to_resolving_list.p_add_dev_to_resolving_list_callback);
|
||||
}
|
||||
|
||||
void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_API("%s, privacy_mode = %d", __func__, p_data->ble_set_privacy_mode.privacy_mode);
|
||||
BTM_BleSetPrivacyMode(p_data->ble_set_privacy_mode.addr_type, p_data->ble_set_privacy_mode.addr,
|
||||
p_data->ble_set_privacy_mode.privacy_mode, p_data->ble_set_privacy_mode.p_cback);
|
||||
}
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
@@ -6472,7 +6526,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id)
|
||||
}
|
||||
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s out of room to accomodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used );
|
||||
APPL_TRACE_ERROR("%s out of room to accommodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used );
|
||||
}
|
||||
|
||||
APPL_TRACE_API("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len);
|
||||
|
||||
@@ -166,7 +166,7 @@ void BTA_DisableTestMode(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetDeviceName(const char *p_name)
|
||||
void BTA_DmSetDeviceName(const char *p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
|
||||
tBTA_DM_API_SET_NAME *p_msg;
|
||||
@@ -176,6 +176,7 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
/* truncate the name if needed */
|
||||
BCM_STRNCPY_S((char *)p_msg->name, p_name, BD_NAME_LEN);
|
||||
p_msg->name[BD_NAME_LEN] = '\0';
|
||||
p_msg->name_type = name_type;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
@@ -191,13 +192,14 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback)
|
||||
void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
tBTA_DM_API_GET_NAME *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_GET_NAME *) osi_malloc(sizeof(tBTA_DM_API_GET_NAME))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_GET_NAME_EVT;
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->name_type = name_type;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
@@ -227,6 +229,21 @@ void BTA_DmCfgCoexStatus(UINT8 op, UINT8 type, UINT8 status)
|
||||
}
|
||||
#endif
|
||||
|
||||
void BTA_DmsendVendorHciCmd(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf, tBTA_SEND_VENDOR_HCI_CMPL_CBACK p_vendor_cmd_complete_cback)
|
||||
{
|
||||
tBTA_DM_API_SEND_VENDOR_HCI_CMD *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_SEND_VENDOR_HCI_CMD *)osi_malloc(sizeof(tBTA_DM_API_SEND_VENDOR_HCI_CMD) + param_len)) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT;
|
||||
p_msg->opcode = opcode;
|
||||
p_msg->param_len = param_len;
|
||||
p_msg->p_param_buf = (UINT8 *)(p_msg + 1);
|
||||
memcpy(p_msg->p_param_buf, p_param_buf, param_len);
|
||||
p_msg->vendor_hci_cb = p_vendor_cmd_complete_cback;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
|
||||
@@ -365,6 +382,31 @@ void BTA_DmSetAclPktTypes(BD_ADDR remote_addr, UINT16 pkt_types, tBTM_CMPL_CB *p
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmSetMinEncKeySize
|
||||
**
|
||||
** Description This function sets the minimal size of encryption key.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
void BTA_DmSetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tBTA_DM_API_SET_MIN_ENC_KEY_SIZE *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_MIN_ENC_KEY_SIZE *) osi_malloc(sizeof(tBTA_DM_API_SET_MIN_ENC_KEY_SIZE))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT;
|
||||
p_msg->key_size = key_size;
|
||||
p_msg->set_min_enc_key_size_cb = p_cb;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /// CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
@@ -940,7 +982,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
|
||||
**
|
||||
** Function BTA_DmRemoveDevice
|
||||
**
|
||||
** Description This function removes a device fromthe security database list of
|
||||
** Description This function removes a device from the security database list of
|
||||
** peer device. It manages unpairing even while connected.
|
||||
**
|
||||
**
|
||||
@@ -1158,7 +1200,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, int auth_mode
|
||||
** Description Send BLE SMP passkey reply.
|
||||
**
|
||||
** Parameters: bd_addr - BD address of the peer
|
||||
** accept - passkey entry sucessful or declined.
|
||||
** accept - passkey entry successful or declined.
|
||||
** passkey - passkey value, must be a 6 digit number,
|
||||
** can be lead by 0.
|
||||
**
|
||||
@@ -1997,7 +2039,7 @@ void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
|
||||
** p_services: if service is not empty, service discovery will be done.
|
||||
** for all GATT based service condition, put num_uuid, and
|
||||
** p_uuid is the pointer to the list of UUID values.
|
||||
** p_cback: callback functino when search is completed.
|
||||
** p_cback: callback function when search is completed.
|
||||
**
|
||||
**
|
||||
**
|
||||
@@ -2085,7 +2127,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
|
||||
**
|
||||
** Description Enable/disable privacy on the local device
|
||||
**
|
||||
** Parameters: privacy_enable - enable/disabe privacy on remote device.
|
||||
** Parameters: privacy_enable - enable/disable privacy on remote device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -2137,7 +2179,7 @@ void BTA_DmBleConfigLocalIcon(uint16_t icon)
|
||||
**
|
||||
** Function BTA_BleEnableAdvInstance
|
||||
**
|
||||
** Description This function enable a Multi-ADV instance with the specififed
|
||||
** Description This function enable a Multi-ADV instance with the specified
|
||||
** adv parameters
|
||||
**
|
||||
** Parameters p_params: pointer to the adv parameter structure.
|
||||
@@ -2176,7 +2218,7 @@ void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
|
||||
**
|
||||
** Function BTA_BleUpdateAdvInstParam
|
||||
**
|
||||
** Description This function update a Multi-ADV instance with the specififed
|
||||
** Description This function update a Multi-ADV instance with the specified
|
||||
** adv parameters.
|
||||
**
|
||||
** Parameters inst_id: Adv instance to update the parameter.
|
||||
@@ -2207,7 +2249,7 @@ void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
|
||||
**
|
||||
** Function BTA_BleCfgAdvInstData
|
||||
**
|
||||
** Description This function configure a Multi-ADV instance with the specififed
|
||||
** Description This function configure a Multi-ADV instance with the specified
|
||||
** adv data or scan response data.
|
||||
**
|
||||
** Parameter inst_id: Adv instance to configure the adv data or scan response.
|
||||
@@ -2637,6 +2679,21 @@ void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback)
|
||||
}
|
||||
}
|
||||
|
||||
void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t privacy_mode, tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback)
|
||||
{
|
||||
tBTA_DM_API_SET_PRIVACY_MODE *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_PRIVACY_MODE *)osi_malloc(sizeof(tBTA_DM_API_SET_PRIVACY_MODE)))
|
||||
!= NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_SET_PRIVACY_MODE_EVT;
|
||||
p_msg->addr_type = addr_type;
|
||||
memcpy(p_msg->addr, addr, sizeof(BD_ADDR));
|
||||
p_msg->privacy_mode = privacy_mode;
|
||||
p_msg->p_cback = p_cback;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2650,7 +2707,7 @@ void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback)
|
||||
**
|
||||
** Parameters: bd_addr - Address of the peer device
|
||||
** transport - transport of the link to be encruypted
|
||||
** p_callback - Pointer to callback function to indicat the
|
||||
** p_callback - Pointer to callback function to indicate the
|
||||
** link encryption status
|
||||
** sec_act - This is the security action to indicate
|
||||
** what kind of BLE security level is required for
|
||||
@@ -2830,7 +2887,7 @@ extern void BTA_DmBleStopAdvertising(void)
|
||||
**
|
||||
** Description This function set the random address for the APP
|
||||
**
|
||||
** Parameters rand_addr: the random address whith should be setting
|
||||
** Parameters rand_addr: the random address with should be setting
|
||||
** p_set_rand_addr_cback: complete callback
|
||||
** Returns void
|
||||
**
|
||||
@@ -2846,7 +2903,68 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_
|
||||
p_msg->hdr.event = BTA_DM_API_SET_RAND_ADDR_EVT;
|
||||
p_msg->addr_type = BLE_ADDR_RANDOM;
|
||||
p_msg->p_set_rand_addr_cback = p_set_rand_addr_cback;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetRpaTimeout
|
||||
**
|
||||
** Description This function sets the Resolvable Private Address (RPA) timeout
|
||||
** for the Bluetooth device. The RPA timeout defines how long an RPA
|
||||
** remains in use before a new one is generated.
|
||||
**
|
||||
** Parameters rpa_timeout: The timeout in seconds within the range of 1s to 1 hour
|
||||
** as defined by the Bluetooth specification. This duration
|
||||
** specifies how long the controller uses an RPA before
|
||||
** generating a new one.
|
||||
** Returns void
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSetRpaTimeout(uint16_t rpa_timeout,tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback)
|
||||
{
|
||||
tBTA_DM_API_SET_RPA_TIMEOUT *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_SET_RPA_TIMEOUT *) osi_malloc(sizeof(tBTA_DM_API_SET_RPA_TIMEOUT))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_RPA_TIMEOUT));
|
||||
p_msg->hdr.event = BTA_DM_API_SET_RPA_TIMEOUT_EVT;
|
||||
p_msg->rpa_timeout = rpa_timeout; // Assign the RPA timeout value to the message
|
||||
p_msg->p_set_rpa_timeout_cback = p_set_rpa_timeout_cback;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleAddDevToResolvingList
|
||||
**
|
||||
** Description This function adds a device to the resolving list of the
|
||||
** Bluetooth controller. The resolving list is used for resolving
|
||||
** the identity of devices using resolvable private addresses (RPAs).
|
||||
**
|
||||
** Parameters addr: Bluetooth device address to be added to the resolving list
|
||||
** addr_type: Type of the address (public or random)
|
||||
** irk: Identity Resolving Key (IRK) of the device
|
||||
** add_dev_to_resolving_list_callback: Callback function to be invoked
|
||||
** upon completion of the operation
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleAddDevToResolvingList(BD_ADDR addr,
|
||||
uint8_t addr_type,
|
||||
PEER_IRK irk,
|
||||
tBTA_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *add_dev_to_resolving_list_callback)
|
||||
{
|
||||
tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST *) osi_malloc(sizeof(tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST));
|
||||
p_msg->hdr.event = BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT;
|
||||
memcpy(p_msg->addr, addr, BD_ADDR_LEN); // Copy the device address to the message
|
||||
p_msg->addr_type = addr_type; // Assign the address type to the message
|
||||
memcpy(p_msg->irk, irk, PEER_IRK_LEN); // Copy the IRK to the message
|
||||
p_msg->p_add_dev_to_resolving_list_callback = add_dev_to_resolving_list_callback;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
@@ -2906,7 +3024,6 @@ void BTA_VendorCleanup (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
btm_ble_multi_adv_cleanup();
|
||||
}
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
void BTA_DmBleGapReadPHY(BD_ADDR addr)
|
||||
@@ -2917,7 +3034,7 @@ void BTA_DmBleGapReadPHY(BD_ADDR addr)
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_READ_PHY));
|
||||
p_msg->hdr.event = BTA_DM_API_READ_PHY_EVT;
|
||||
memcpy(p_msg->bd_addr, addr, BD_ADDR_LEN);
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -2929,13 +3046,13 @@ void BTA_DmBleGapSetPreferedDefaultPHY(tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask,
|
||||
tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask)
|
||||
{
|
||||
tBTA_DM_API_SET_PER_DEF_PHY *p_msg;
|
||||
APPL_TRACE_API("%s, Set prefered default phy.", __func__);
|
||||
APPL_TRACE_API("%s, Set preferred default phy.", __func__);
|
||||
if ((p_msg = (tBTA_DM_API_SET_PER_DEF_PHY *) osi_malloc(sizeof(tBTA_DM_API_SET_PER_DEF_PHY))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_PER_DEF_PHY));
|
||||
p_msg->hdr.event = BTA_DM_API_SET_PER_DEF_PHY_EVT;
|
||||
p_msg->tx_phy_mask = tx_phy_mask;
|
||||
p_msg->rx_phy_mask = rx_phy_mask;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -2950,7 +3067,7 @@ void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr,
|
||||
UINT16 phy_options)
|
||||
{
|
||||
tBTA_DM_API_SET_PER_PHY *p_msg;
|
||||
APPL_TRACE_API("%s, Set prefered phy.", __func__);
|
||||
APPL_TRACE_API("%s, Set preferred phy.", __func__);
|
||||
if ((p_msg = (tBTA_DM_API_SET_PER_PHY *) osi_malloc(sizeof(tBTA_DM_API_SET_PER_PHY))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_PER_PHY));
|
||||
p_msg->hdr.event = BTA_DM_API_SET_PER_PHY_EVT;
|
||||
@@ -2959,7 +3076,7 @@ void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr,
|
||||
p_msg->tx_phy_mask = tx_phy_mask;
|
||||
p_msg->rx_phy_mask = rx_phy_mask;
|
||||
p_msg->phy_options = phy_options;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -2975,7 +3092,7 @@ void BTA_DmBleGapExtAdvSetRandaddr(UINT16 instance, BD_ADDR addr)
|
||||
p_msg->hdr.event = BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT;
|
||||
p_msg->instance = instance;
|
||||
memcpy(&p_msg->rand_addr, addr, BD_ADDR_LEN);
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -2993,7 +3110,7 @@ void BTA_DmBleGapExtAdvSetParams(UINT16 instance,
|
||||
p_msg->hdr.event = BTA_DM_API_SET_EXT_ADV_PARAMS_EVT;
|
||||
p_msg->instance = instance;
|
||||
memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_GAP_EXT_ADV_PARAMS));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3016,7 +3133,7 @@ void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16
|
||||
if (data) {
|
||||
memcpy(p_msg->data, data, length);
|
||||
}
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3036,7 +3153,7 @@ void BTA_DmBleGapExtAdvEnable(BOOLEAN enable, UINT8 num, tBTA_DM_BLE_EXT_ADV *ex
|
||||
if (ext_adv) {
|
||||
memcpy(p_msg->ext_adv, ext_adv, sizeof(tBTA_DM_BLE_EXT_ADV)*num);
|
||||
}
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3051,7 +3168,7 @@ void BTA_DmBleGapExtAdvSetRemove(UINT8 instance)
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE));
|
||||
p_msg->hdr.event = BTA_DM_API_EXT_ADV_SET_REMOVE_EVT;
|
||||
p_msg->instance = instance;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3065,7 +3182,7 @@ void BTA_DmBleGapExtAdvSetClear(void)
|
||||
if ((p_msg = (tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR *) osi_malloc(sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR));
|
||||
p_msg->hdr.event = BTA_DM_API_EXT_ADV_SET_CLEAR_EVT;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3082,7 +3199,7 @@ void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance,
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT;
|
||||
p_msg->instance = instance;
|
||||
memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_Periodic_Adv_Params));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3104,7 +3221,7 @@ void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length,
|
||||
memcpy(p_msg->data, data, length);
|
||||
p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL;
|
||||
p_msg->only_update_did = only_update_did;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3121,7 +3238,7 @@ void BTA_DmBleGapPeriodicAdvEnable(UINT8 enable, UINT8 instance)
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_ENABLE_EVT;
|
||||
p_msg->instance = instance;
|
||||
p_msg->enable = enable;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3137,7 +3254,7 @@ void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params)
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC));
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_EVT;
|
||||
memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_Periodic_Sync_Params));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3152,7 +3269,7 @@ void BTA_DmBleGapPeriodicAdvSyncCancel(void)
|
||||
if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL));
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3168,7 +3285,7 @@ void BTA_DmBleGapPeriodicAdvSyncTerm(UINT16 sync_handle)
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_TERM));
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT;
|
||||
p_msg->sync_handle = sync_handle;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3188,7 +3305,7 @@ void BTA_DmBleGapPeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type,
|
||||
p_msg->addr_type = addr_type;
|
||||
p_msg->sid = sid;
|
||||
memcpy(p_msg->addr, addr, sizeof(BD_ADDR));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3208,7 +3325,7 @@ void BTA_DmBleGapPeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type,
|
||||
p_msg->addr_type = addr_type;
|
||||
p_msg->sid = sid;
|
||||
memcpy(p_msg->addr, addr, sizeof(BD_ADDR));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3223,7 +3340,7 @@ void BTA_DmBleGapPeriodicAdvClearDev(void)
|
||||
if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR));
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3239,7 +3356,7 @@ void BTA_DmBleGapSetExtScanParams(tBTA_DM_BLE_EXT_SCAN_PARAMS *params)
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_EXT_SCAN_PARAMS));
|
||||
p_msg->hdr.event = BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT;
|
||||
memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_EXT_SCAN_PARAMS));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3257,7 +3374,7 @@ void BTA_DmBleGapExtScan(BOOLEAN start, UINT32 duration, UINT16 period)
|
||||
p_msg->start = start;
|
||||
p_msg->duration = duration;
|
||||
p_msg->period = period;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3291,7 +3408,7 @@ void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr,
|
||||
if (phy_coded_conn_params) {
|
||||
memcpy(&p_msg->phy_coded_conn_params, phy_coded_conn_params, sizeof(tBTA_DM_BLE_CONN_PARAMS));
|
||||
}
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3310,7 +3427,7 @@ void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_add
|
||||
p_msg->hdr.event = BTA_DM_API_EXT_CONN_EVT;
|
||||
p_msg->own_addr_type = own_addr_type;
|
||||
memcpy(p_msg->peer_addr, peer_addr, sizeof(BD_ADDR));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3363,7 +3480,7 @@ void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable)
|
||||
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT;
|
||||
p_msg->sync_handle = sync_handle;
|
||||
p_msg->enable = enable;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3380,7 +3497,7 @@ void BTA_DmBleGapPeriodicAdvSyncTrans(BD_ADDR peer_addr, UINT16 service_data, UI
|
||||
memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR));
|
||||
p_msg->service_data = service_data;
|
||||
p_msg->sync_handle = sync_handle;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3397,7 +3514,7 @@ void BTA_DmBleGapPeriodicAdvSetInfoTrans(BD_ADDR peer_addr, UINT16 service_data,
|
||||
memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR));
|
||||
p_msg->service_data = service_data;
|
||||
p_msg->adv_hanlde = adv_handle;
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
@@ -3413,7 +3530,7 @@ void BTA_DmBleGapSetPeriodicAdvSyncTransParams(BD_ADDR peer_addr, tBTA_DM_BLE_PA
|
||||
p_msg->hdr.event = BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT;
|
||||
memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR));
|
||||
memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_PAST_PARAMS));
|
||||
//start sent the msg to the bta system control moudle
|
||||
//start sent the msg to the bta system control module
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s malloc failed", __func__);
|
||||
|
||||
@@ -31,7 +31,9 @@
|
||||
#include "osi/allocator.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef CONFIG_ESP_COEX_ENABLED
|
||||
#include "esp_coexist.h"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
@@ -65,11 +67,15 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
bta_dm_cfg_coex_status, /* BTA_DM_API_CFG_COEX_ST_EVT */
|
||||
#endif
|
||||
bta_dm_send_vendor_hci, /* BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT */
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
|
||||
bta_dm_set_page_timeout, /* BTA_DM_API_PAGE_TO_SET_EVT */
|
||||
bta_dm_get_page_timeout, /* BTA_DM_API_PAGE_TO_GET_EVT */
|
||||
bta_dm_set_acl_pkt_types, /* BTA_DM_API_SET_ACL_PKT_TYPES_EVT */
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
bta_dm_set_min_enc_key_size, /* BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT */
|
||||
#endif
|
||||
#endif
|
||||
bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
@@ -87,7 +93,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_pin_reply, /* BTA_DM_API_PIN_REPLY_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
/* power manager events */
|
||||
bta_dm_pm_btm_status, /* BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* BTA_DM_PM_TIMER_EVT */
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
@@ -226,6 +232,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_ble_gap_dtm_rx_start, /* BTA_DM_API_DTM_RX_START_EVT */
|
||||
bta_dm_ble_gap_dtm_stop, /* BTA_DM_API_DTM_STOP_EVT */
|
||||
bta_dm_ble_gap_clear_adv, /* BTA_DM_API_BLE_CLEAR_ADV_EVT */
|
||||
bta_dm_ble_gap_set_rpa_timeout, /* BTA_DM_API_SET_RPA_TIMEOUT_EVT */
|
||||
bta_dm_ble_gap_add_dev_to_resolving_list, /* BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT */
|
||||
bta_dm_ble_gap_set_privacy_mode, /* BTA_DM_API_SET_PRIVACY_MODE_EVT */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -57,11 +57,15 @@ enum {
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
BTA_DM_API_CFG_COEX_ST_EVT,
|
||||
#endif
|
||||
BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT,
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
BTA_DM_API_CONFIG_EIR_EVT,
|
||||
BTA_DM_API_PAGE_TO_SET_EVT,
|
||||
BTA_DM_API_PAGE_TO_GET_EVT,
|
||||
BTA_DM_API_SET_ACL_PKT_TYPES_EVT,
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT,
|
||||
#endif
|
||||
#endif
|
||||
BTA_DM_API_SET_AFH_CHANNELS_EVT,
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
@@ -80,7 +84,7 @@ enum {
|
||||
BTA_DM_API_PIN_REPLY_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
/* power manager events */
|
||||
BTA_DM_PM_BTM_STATUS_EVT,
|
||||
BTA_DM_PM_TIMER_EVT,
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
@@ -219,6 +223,9 @@ enum {
|
||||
BTA_DM_API_DTM_RX_START_EVT,
|
||||
BTA_DM_API_DTM_STOP_EVT,
|
||||
BTA_DM_API_BLE_CLEAR_ADV_EVT,
|
||||
BTA_DM_API_SET_RPA_TIMEOUT_EVT,
|
||||
BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT,
|
||||
BTA_DM_API_SET_PRIVACY_MODE_EVT,
|
||||
#endif
|
||||
BTA_DM_MAX_EVT
|
||||
};
|
||||
@@ -249,11 +256,13 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_NAME name; /* max 248 bytes name, plus must be Null terminated */
|
||||
tBT_DEVICE_TYPE name_type; /* name for BLE, name for BT or name for BTDM */
|
||||
} tBTA_DM_API_SET_NAME;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BT_HDR hdr;
|
||||
tBTA_GET_DEV_NAME_CBACK *p_cback;
|
||||
tBT_DEVICE_TYPE name_type;
|
||||
} tBTA_DM_API_GET_NAME;
|
||||
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
@@ -265,6 +274,14 @@ typedef struct {
|
||||
} tBTA_DM_API_CFG_COEX_STATUS;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 opcode;
|
||||
UINT8 param_len;
|
||||
UINT8 *p_param_buf;
|
||||
tBTA_SEND_VENDOR_HCI_CMPL_CBACK *vendor_hci_cb;
|
||||
}tBTA_DM_API_SEND_VENDOR_HCI_CMD;
|
||||
|
||||
/* data type for BTA_DM_API_CONFIG_EIR_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -308,6 +325,15 @@ typedef struct {
|
||||
tBTM_CMPL_CB *set_acl_pkt_types_cb;
|
||||
} tBTA_DM_API_SET_ACL_PKT_TYPES;
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
/* data type for BTA_DM_API_SET_MIN_ENC_KEY_SIZE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 key_size;
|
||||
tBTM_CMPL_CB *set_min_enc_key_size_cb;
|
||||
} tBTA_DM_API_SET_MIN_ENC_KEY_SIZE;
|
||||
#endif
|
||||
|
||||
/* data type for BTA_DM_API_GET_REMOTE_NAME_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -660,7 +686,7 @@ typedef struct {
|
||||
tBTA_DM_BLE_SEL_CBACK *p_select_cback;
|
||||
} tBTA_DM_API_BLE_SET_BG_CONN_TYPE;
|
||||
|
||||
/* set prefered BLE connection parameters for a device */
|
||||
/* set preferred BLE connection parameters for a device */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_bda;
|
||||
@@ -761,6 +787,20 @@ typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_DM_APT_CLEAR_ADDR;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 rpa_timeout;
|
||||
tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback;
|
||||
} tBTA_DM_API_SET_RPA_TIMEOUT;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr; // Event header
|
||||
esp_bd_addr_t addr; // Bluetooth device address
|
||||
UINT8 addr_type; // Type of the address
|
||||
UINT8 irk[PEER_IRK_LEN]; // Identity Resolving Key (IRK)
|
||||
tBTA_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_add_dev_to_resolving_list_callback; // Callback function pointer
|
||||
} tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST;
|
||||
|
||||
/* set adv parameter for BLE advertising */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -911,6 +951,14 @@ typedef struct {
|
||||
tBTA_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback;
|
||||
} tBTA_DM_API_CLEAR_ADV;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBLE_ADDR_TYPE addr_type;
|
||||
BD_ADDR addr;
|
||||
UINT8 privacy_mode;
|
||||
tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback;
|
||||
} tBTA_DM_API_SET_PRIVACY_MODE;
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
|
||||
@@ -1162,12 +1210,16 @@ typedef union {
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
tBTA_DM_API_CFG_COEX_STATUS cfg_coex_status;
|
||||
#endif
|
||||
tBTA_DM_API_SEND_VENDOR_HCI_CMD vendor_hci_cmd;
|
||||
tBTA_DM_API_CONFIG_EIR config_eir;
|
||||
|
||||
tBTA_DM_API_SET_AFH_CHANNELS set_afh_channels;
|
||||
tBTA_DM_API_PAGE_TO_SET set_page_timeout;
|
||||
tBTA_DM_API_PAGE_TO_GET get_page_timeout;
|
||||
tBTA_DM_API_SET_ACL_PKT_TYPES set_acl_pkt_types;
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
tBTA_DM_API_SET_MIN_ENC_KEY_SIZE set_min_enc_key_size;
|
||||
#endif
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tBTA_DM_API_GET_REMOTE_NAME get_rmt_name;
|
||||
#endif
|
||||
@@ -1261,6 +1313,8 @@ typedef union {
|
||||
tBTA_DM_API_BLE_SET_DATA_LENGTH ble_set_data_length;
|
||||
tBTA_DM_APT_SET_DEV_ADDR set_addr;
|
||||
tBTA_DM_APT_CLEAR_ADDR clear_addr;
|
||||
tBTA_DM_API_SET_RPA_TIMEOUT set_rpa_timeout;
|
||||
tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST add_dev_to_resolving_list;
|
||||
tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb;
|
||||
tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param;
|
||||
tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data;
|
||||
@@ -1310,6 +1364,7 @@ typedef union {
|
||||
tBTA_DM_API_BLE_DTM_RX_START dtm_rx_start;
|
||||
tBTA_DM_API_BLE_DTM_STOP dtm_stop;
|
||||
tBTA_DM_API_CLEAR_ADV ble_clear_adv;
|
||||
tBTA_DM_API_SET_PRIVACY_MODE ble_set_privacy_mode;
|
||||
#endif
|
||||
|
||||
tBTA_DM_API_REMOVE_ACL remove_acl;
|
||||
@@ -1444,7 +1499,7 @@ typedef struct {
|
||||
UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */
|
||||
UINT16 cur_policy; /* current default link policy */
|
||||
UINT16 rs_event; /* the event waiting for role switch */
|
||||
UINT8 cur_av_count; /* current AV connecions */
|
||||
UINT8 cur_av_count; /* current AV connections */
|
||||
BOOLEAN disable_pair_mode; /* disable pair mode or not */
|
||||
BOOLEAN conn_paired_only; /* allow connectable to paired device only or not */
|
||||
tBTA_DM_API_SEARCH search_msg;
|
||||
@@ -1676,11 +1731,15 @@ extern void bta_dm_get_dev_name (tBTA_DM_MSG *p_data);
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
extern void bta_dm_cfg_coex_status(tBTA_DM_MSG *p_data);
|
||||
#endif
|
||||
extern void bta_dm_send_vendor_hci(tBTA_DM_MSG *p_data);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_page_timeout (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_get_page_timeout (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_acl_pkt_types (tBTA_DM_MSG *p_data);
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
extern void bta_dm_set_min_enc_key_size (tBTA_DM_MSG *p_data);
|
||||
#endif
|
||||
#endif
|
||||
extern void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data);
|
||||
@@ -1751,7 +1810,9 @@ extern void bta_dm_ble_gap_dtm_tx_start(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_dtm_rx_start(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_dtm_stop(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data);
|
||||
|
||||
extern void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_add_dev_to_resolving_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
extern void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data);
|
||||
|
||||
@@ -722,6 +722,26 @@ extern void bta_hd_exit_suspend_act(tBTA_HD_DATA *p_data)
|
||||
bta_sys_idle(BTA_ID_HD, 1, p_cback->addr);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function bta_hd_open_failure
|
||||
*
|
||||
* Description
|
||||
*
|
||||
* Returns void
|
||||
*
|
||||
******************************************************************************/
|
||||
extern void bta_hd_open_failure(tBTA_HD_DATA *p_data)
|
||||
{
|
||||
tBTA_HD_CBACK_DATA *p_cback = (tBTA_HD_CBACK_DATA *)p_data;
|
||||
tBTA_HD cback_data = {0};
|
||||
|
||||
bdcpy(cback_data.conn.bda, p_cback->addr);
|
||||
cback_data.conn.status = BTA_HD_ERROR;
|
||||
cback_data.conn.conn_status = BTA_HD_CONN_STATE_DISCONNECTED;
|
||||
bta_hd_cb.p_cback(BTA_HD_OPEN_EVT, &cback_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function bta_hd_cback
|
||||
|
||||
@@ -62,6 +62,7 @@ enum {
|
||||
BTA_HD_VC_UNPLUG_DONE_ACT,
|
||||
BTA_HD_SUSPEND_ACT,
|
||||
BTA_HD_EXIT_SUSPEND_ACT,
|
||||
BTA_HD_OPEN_FAILURE,
|
||||
BTA_HD_NUM_ACTIONS
|
||||
};
|
||||
|
||||
@@ -74,7 +75,7 @@ const tBTA_HD_ACTION bta_hd_action[] = {
|
||||
bta_hd_disconnect_act, bta_hd_add_device_act, bta_hd_remove_device_act, bta_hd_send_report_act,
|
||||
bta_hd_report_error_act, bta_hd_vc_unplug_act, bta_hd_open_act, bta_hd_close_act,
|
||||
bta_hd_intr_data_act, bta_hd_get_report_act, bta_hd_set_report_act, bta_hd_set_protocol_act,
|
||||
bta_hd_vc_unplug_done_act, bta_hd_suspend_act, bta_hd_exit_suspend_act,
|
||||
bta_hd_vc_unplug_done_act, bta_hd_suspend_act, bta_hd_exit_suspend_act, bta_hd_open_failure
|
||||
};
|
||||
|
||||
/* state table information */
|
||||
@@ -118,7 +119,7 @@ const uint8_t bta_hd_st_idle[][BTA_HD_NUM_COLS] = {
|
||||
/* BTA_HD_API_REPORT_ERROR_EVT */ {BTA_HD_IGNORE, BTA_HD_IDLE_ST},
|
||||
/* BTA_HD_API_VC_UNPLUG_EVT */ {BTA_HD_VC_UNPLUG_ACT, BTA_HD_IDLE_ST},
|
||||
/* BTA_HD_INT_OPEN_EVT */ {BTA_HD_OPEN_ACT, BTA_HD_CONN_ST},
|
||||
/* BTA_HD_INT_CLOSE_EVT */ {BTA_HD_IGNORE, BTA_HD_IDLE_ST},
|
||||
/* BTA_HD_INT_CLOSE_EVT */ {BTA_HD_OPEN_FAILURE, BTA_HD_IDLE_ST},
|
||||
/* BTA_HD_INT_INTR_DATA_EVT */ {BTA_HD_IGNORE, BTA_HD_IDLE_ST},
|
||||
/* BTA_HD_INT_GET_REPORT_EVT */ {BTA_HD_IGNORE, BTA_HD_IDLE_ST},
|
||||
/* BTA_HD_INT_SET_REPORT_EVT */ {BTA_HD_IGNORE, BTA_HD_IDLE_ST},
|
||||
|
||||
@@ -164,5 +164,6 @@ extern void bta_hd_set_protocol_act(tBTA_HD_DATA *p_data);
|
||||
extern void bta_hd_vc_unplug_done_act(tBTA_HD_DATA *p_data);
|
||||
extern void bta_hd_suspend_act(tBTA_HD_DATA *p_data);
|
||||
extern void bta_hd_exit_suspend_act(tBTA_HD_DATA *p_data);
|
||||
extern void bta_hd_open_failure(tBTA_HD_DATA *p_data);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -276,7 +276,7 @@ static void bta_hh_di_sdp_cback(UINT16 result)
|
||||
bta_hh_update_di_info(p_cb, di_rec.rec.vendor, di_rec.rec.product, di_rec.rec.version, 0);
|
||||
}
|
||||
|
||||
} else { /* no DI recrod available */
|
||||
} else { /* no DI record available */
|
||||
bta_hh_update_di_info(p_cb, BTA_HH_VENDOR_ID_INVALID, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
|
||||
return;
|
||||
}
|
||||
/* GetSDPRecord. at one time only one SDP precedure can be active */
|
||||
/* GetSDPRecord. at one time only one SDP procedure can be active */
|
||||
else if (!bta_hh_cb.p_disc_db) {
|
||||
bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_malloc(p_bta_hh_cfg->sdp_db_size);
|
||||
|
||||
@@ -429,6 +429,7 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
APPL_TRACE_DEBUG ("bta_hh_sdp_cmpl: HID_HostOpenDev failed: \
|
||||
Status 0x%2X", ret);
|
||||
#endif
|
||||
conn_dat.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
/* open fail, remove device from management device list */
|
||||
HID_HostRemoveDev( p_cb->hid_handle);
|
||||
status = BTA_HH_ERR;
|
||||
@@ -452,8 +453,6 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
HID_HostRemoveDev( p_cb->incoming_hid_handle);
|
||||
}
|
||||
conn_dat.status = status;
|
||||
/* check if host initiate the connection*/
|
||||
conn_dat.is_orig = !p_cb->incoming_conn;
|
||||
(* bta_hh_cb.p_cback)(BTA_HH_OPEN_EVT, (tBTA_HH *)&conn_dat);
|
||||
|
||||
/* move state machine W4_CONN ->IDLE */
|
||||
@@ -523,8 +522,7 @@ void bta_hh_open_cmpl_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
|
||||
memset((void *)&conn, 0, sizeof (tBTA_HH_CONN));
|
||||
conn.handle = dev_handle;
|
||||
/* check if host initiate the connection*/
|
||||
conn.is_orig = !p_cb->incoming_conn;
|
||||
conn.is_orig = HID_HostConnectOrig(dev_handle);
|
||||
bdcpy(conn.bda, p_cb->addr);
|
||||
|
||||
/* increase connection number */
|
||||
@@ -596,7 +594,7 @@ void bta_hh_open_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
if (p_cb->app_id != 0) {
|
||||
bta_hh_sm_execute(p_cb, BTA_HH_OPEN_CMPL_EVT, p_data);
|
||||
} else
|
||||
/* app_id == 0 indicates an incoming conenction request arrives without SDP
|
||||
/* app_id == 0 indicates an incoming connection request arrives without SDP
|
||||
performed, do it first */
|
||||
{
|
||||
/* store the handle here in case sdp fails - need to disconnect */
|
||||
@@ -637,7 +635,7 @@ void bta_hh_data_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
**
|
||||
** Function bta_hh_handsk_act
|
||||
**
|
||||
** Description HID Host process a handshake acknoledgement.
|
||||
** Description HID Host process a handshake acknowledgement.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
@@ -674,7 +672,7 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
p_cb->w4_evt = 0;
|
||||
break;
|
||||
|
||||
/* acknoledgement from HID device for SET_ transaction */
|
||||
/* acknowledgement from HID device for SET_ transaction */
|
||||
case BTA_HH_SET_RPT_EVT:
|
||||
case BTA_HH_SET_PROTO_EVT:
|
||||
case BTA_HH_SET_IDLE_EVT :
|
||||
@@ -693,8 +691,7 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
case BTA_HH_OPEN_EVT:
|
||||
conn.status = p_data->hid_cback.data ? BTA_HH_ERR_PROTO : BTA_HH_OK;
|
||||
conn.handle = p_cb->hid_handle;
|
||||
/* check if host initiate the connection*/
|
||||
conn.is_orig = !p_cb->incoming_conn;
|
||||
conn.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
bdcpy(conn.bda, p_cb->addr);
|
||||
(* bta_hh_cb.p_cback)(p_cb->w4_evt, (tBTA_HH *)&conn);
|
||||
#if BTA_HH_DEBUG
|
||||
@@ -704,12 +701,12 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
break;
|
||||
|
||||
default:
|
||||
/* unknow transaction handshake response */
|
||||
/* unknown transaction handshake response */
|
||||
APPL_TRACE_DEBUG("unknown transaction type");
|
||||
break;
|
||||
}
|
||||
|
||||
/* transaction achknoledgement received, inform PM for mode change */
|
||||
/* transaction acknowledgement received, inform PM for mode change */
|
||||
bta_sys_idle(BTA_ID_HH, p_cb->app_id, p_cb->addr);
|
||||
return;
|
||||
}
|
||||
@@ -799,7 +796,7 @@ void bta_hh_open_failure(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
conn_dat.status = (reason == HID_ERR_AUTH_FAILED) ?
|
||||
BTA_HH_ERR_AUTH_FAILED : BTA_HH_ERR;
|
||||
/* check if host initiate the connection*/
|
||||
conn_dat.is_orig = !p_cb->incoming_conn;
|
||||
conn_dat.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
bdcpy(conn_dat.bda, p_cb->addr);
|
||||
HID_HostCloseDev(p_cb->hid_handle);
|
||||
|
||||
@@ -844,13 +841,13 @@ void bta_hh_close_act (tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
|
||||
/* Check reason for closing */
|
||||
if ((reason & (HID_L2CAP_CONN_FAIL | HID_L2CAP_REQ_FAIL)) || /* Failure to initialize connection (page timeout or l2cap error) */
|
||||
(reason == HID_ERR_AUTH_FAILED) || /* Authenication error (while initiating) */
|
||||
(reason == HID_ERR_AUTH_FAILED) || /* Authentication error (while initiating) */
|
||||
(reason == HID_ERR_L2CAP_FAILED)) { /* Failure creating l2cap connection */
|
||||
/* Failure in opening connection */
|
||||
conn_dat.handle = p_cb->hid_handle;
|
||||
conn_dat.status = (reason == HID_ERR_AUTH_FAILED) ? BTA_HH_ERR_AUTH_FAILED : BTA_HH_ERR;
|
||||
/* check if host initiate the connection*/
|
||||
conn_dat.is_orig = !p_cb->incoming_conn;
|
||||
conn_dat.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
bdcpy(conn_dat.bda, p_cb->addr);
|
||||
HID_HostCloseDev(p_cb->hid_handle);
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA *p_data)
|
||||
cback_data.conn.status = BTA_HH_ERR_DB_FULL;
|
||||
cback_data.conn.handle = BTA_HH_INVALID_HANDLE;
|
||||
/* check if host initiate the connection*/
|
||||
cback_data.conn.is_orig = !p_cb->incoming_conn;
|
||||
cback_data.conn.is_orig = TRUE;
|
||||
break;
|
||||
/* DB full, BTA_HhAddDev */
|
||||
case BTA_HH_API_MAINT_DEV_EVT:
|
||||
|
||||
@@ -398,7 +398,7 @@ typedef tBTM_BLE_128SERVICE tBTA_BLE_128SERVICE;
|
||||
typedef tBTM_BLE_32SERVICE tBTA_BLE_32SERVICE;
|
||||
|
||||
typedef struct {
|
||||
tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
|
||||
tBTA_BLE_INT_RANGE int_range; /* slave preferred conn interval range */
|
||||
tBTA_BLE_MANU *p_manu; /* manufacturer data */
|
||||
tBTA_BLE_SERVICE *p_services; /* 16 bits services */
|
||||
tBTA_BLE_128SERVICE *p_services_128b; /* 128 bits service */
|
||||
@@ -417,6 +417,8 @@ typedef void (tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTA_STATUS st
|
||||
|
||||
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef tBTM_VSC_CMPL_CB tBTA_SEND_VENDOR_HCI_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK;
|
||||
@@ -431,8 +433,16 @@ typedef tBTM_SET_RAND_ADDR_CBACK tBTA_SET_RAND_ADDR_CBACK;
|
||||
|
||||
typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
|
||||
|
||||
typedef tBTM_SET_RPA_TIMEOUT_CMPL_CBACK tBTA_SET_RPA_TIMEOUT_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK tBTA_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_SET_PRIVACY_MODE_CMPL_CBACK tBTA_SET_PRIVACY_MODE_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_CMPL_CB tBTA_CMPL_CB;
|
||||
|
||||
typedef tBTM_VSC_CMPL tBTA_VSC_CMPL;
|
||||
|
||||
typedef tBTM_TX_POWER_RESULTS tBTA_TX_POWER_RESULTS;
|
||||
|
||||
typedef tBTM_RSSI_RESULTS tBTA_RSSI_RESULTS;
|
||||
@@ -445,6 +455,10 @@ typedef tBTM_GET_PAGE_TIMEOUT_RESULTS tBTA_GET_PAGE_TIMEOUT_RESULTS;
|
||||
|
||||
typedef tBTM_SET_ACL_PKT_TYPES_RESULTS tBTA_SET_ACL_PKT_TYPES_RESULTS;
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
typedef tBTM_SET_MIN_ENC_KEY_SIZE_RESULTS tBTA_SET_MIN_ENC_KEY_SIZE_RESULTS;
|
||||
#endif
|
||||
|
||||
typedef tBTM_REMOTE_DEV_NAME tBTA_REMOTE_DEV_NAME;
|
||||
|
||||
/* advertising channel map */
|
||||
@@ -661,7 +675,7 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK;
|
||||
// btla-specific --
|
||||
#define BTA_DM_DEV_UNPAIRED_EVT 25 /* BT unpair event */
|
||||
#define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
|
||||
#define BTA_DM_LE_FEATURES_READ 27 /* Cotroller specific LE features are read */
|
||||
#define BTA_DM_LE_FEATURES_READ 27 /* Controller specific LE features are read */
|
||||
#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
|
||||
#define BTA_DM_BLE_DEV_UNPAIRED_EVT 29 /* BLE unpair event */
|
||||
#define BTA_DM_SP_KEY_REQ_EVT 30 /* Simple Pairing Passkey request */
|
||||
@@ -1107,7 +1121,7 @@ typedef struct {
|
||||
#define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */
|
||||
#define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */
|
||||
#define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */
|
||||
#define BTA_DM_DISC_BLE_RES_EVT 3 /* Discovery result for BLE GATT based servoce on a peer device. */
|
||||
#define BTA_DM_DISC_BLE_RES_EVT 3 /* Discovery result for BLE GATT based service on a peer device. */
|
||||
#define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */
|
||||
#define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */
|
||||
#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
|
||||
@@ -1716,7 +1730,7 @@ extern void BTA_DisableTestMode(void);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
extern void BTA_DmSetDeviceName(const char *p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1728,7 +1742,7 @@ extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback);
|
||||
extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1744,6 +1758,8 @@ extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback);
|
||||
extern void BTA_DmCfgCoexStatus(UINT8 op, UINT8 type, UINT8 status);
|
||||
#endif
|
||||
|
||||
extern void BTA_DmsendVendorHciCmd(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf, tBTA_SEND_VENDOR_HCI_CMPL_CBACK p_vendor_cmd_complete_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmGetRemoteName
|
||||
@@ -1829,6 +1845,20 @@ void BTA_DmGetPageTimeout(tBTM_CMPL_CB *p_cb);
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetAclPktTypes(BD_ADDR remote_addr, UINT16 pkt_types, tBTM_CMPL_CB *p_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmSetMinEncKeySize
|
||||
**
|
||||
** Description This function sets the minimal size of encryption key.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
void BTA_DmSetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb);
|
||||
#endif
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1929,7 +1959,7 @@ extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
|
||||
**
|
||||
** Function BTA_DmGetCachedRemoteName
|
||||
**
|
||||
** Description Retieve cached remote name if available
|
||||
** Description Retrieve cached remote name if available
|
||||
**
|
||||
** Returns BTA_SUCCESS if cached name was retrieved
|
||||
** BTA_FAILURE if cached name is not available
|
||||
@@ -2280,7 +2310,7 @@ extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_B
|
||||
** Description Send BLE SMP passkey reply.
|
||||
**
|
||||
** Parameters: bd_addr - BD address of the peer
|
||||
** accept - passkey entry sucessful or declined.
|
||||
** accept - passkey entry successful or declined.
|
||||
** passkey - passkey value, must be a 6 digit number,
|
||||
** can be lead by 0.
|
||||
**
|
||||
@@ -2446,7 +2476,7 @@ extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interva
|
||||
**
|
||||
** Parameters: adv_int_min - adv interval minimum
|
||||
** adv_int_max - adv interval max
|
||||
** p_dir_bda - directed adv initator address
|
||||
** p_dir_bda - directed adv initiator address
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -2472,7 +2502,7 @@ extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
** services: if service is not empty, service discovery will be done.
|
||||
** for all GATT based service condition, put num_uuid, and
|
||||
** p_uuid is the pointer to the list of UUID values.
|
||||
** p_cback: callback functino when search is completed.
|
||||
** p_cback: callback function when search is completed.
|
||||
**
|
||||
**
|
||||
**
|
||||
@@ -2531,7 +2561,7 @@ extern void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_
|
||||
**
|
||||
** Parameters: bd_addr - Address of the peer device
|
||||
** transport - transport of the link to be encruypted
|
||||
** p_callback - Pointer to callback function to indicat the
|
||||
** p_callback - Pointer to callback function to indicate the
|
||||
** link encryption status
|
||||
** sec_act - This is the security action to indicate
|
||||
** what knid of BLE security level is required for
|
||||
@@ -2588,7 +2618,11 @@ extern void BTA_DmBleStopAdvertising(void);
|
||||
|
||||
extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback);
|
||||
extern void BTA_DmClearRandAddress(void);
|
||||
|
||||
extern void BTA_DmBleSetRpaTimeout(uint16_t rpa_timeout,tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback);
|
||||
extern void BTA_DmBleAddDevToResolvingList(BD_ADDR addr,
|
||||
uint8_t addr_type,
|
||||
PEER_IRK irk,
|
||||
tBTA_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *add_dev_to_resolving_list_callback);
|
||||
#endif
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
@@ -2599,7 +2633,7 @@ extern void BTA_DmClearRandAddress(void);
|
||||
**
|
||||
** Description Enable/disable privacy on the local device
|
||||
**
|
||||
** Parameters: privacy_enable - enable/disabe privacy on remote device.
|
||||
** Parameters: privacy_enable - enable/disable privacy on remote device.
|
||||
** set_local_privacy_cback -callback to be called with result
|
||||
** Returns void
|
||||
**
|
||||
@@ -2626,7 +2660,7 @@ extern void BTA_DmBleConfigLocalIcon(uint16_t icon);
|
||||
** Description Enable/disable privacy on a remote device
|
||||
**
|
||||
** Parameters: bd_addr - BD address of the peer
|
||||
** privacy_enable - enable/disabe privacy on remote device.
|
||||
** privacy_enable - enable/disable privacy on remote device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -2861,6 +2895,8 @@ extern void BTA_DmBleDtmTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t
|
||||
extern void BTA_DmBleDtmRxStart(uint8_t rx_channel, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback);
|
||||
extern void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback);
|
||||
|
||||
extern void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t privacy_mode, tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetStorageParams
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the implementation of the JAVA API for Bluetooth Wireless
|
||||
* Technology (JABWT) as specified by the JSR82 specificiation
|
||||
* Technology (JABWT) as specified by the JSR82 specification
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@@ -118,6 +118,11 @@ void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback)
|
||||
|
||||
APPL_TRACE_API( "BTA_JvDisable");
|
||||
bta_sys_deregister(BTA_ID_JV);
|
||||
memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB));
|
||||
/* set handle to invalid value by default */
|
||||
for (int i = 0; i < BTA_JV_PM_MAX_NUM; i++) {
|
||||
bta_jv_cb.pm_cb[i].handle = BTA_JV_PM_HANDLE_CLEAR;
|
||||
}
|
||||
if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_JV_API_DISABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
@@ -893,7 +898,7 @@ tBTA_JV_STATUS BTA_JvRfcommConfig(BOOLEAN enable_l2cap_ertm)
|
||||
**
|
||||
** Function BTA_JvRfcommConnect
|
||||
**
|
||||
** Description This function makes an RFCOMM conection to a remote BD
|
||||
** Description This function makes an RFCOMM connection to a remote BD
|
||||
** Address.
|
||||
** When the connection is initiated or failed to initiate,
|
||||
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT
|
||||
@@ -1204,7 +1209,7 @@ tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given)
|
||||
** Parameters: handle, JV handle from RFCOMM or L2CAP
|
||||
** app_id: app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details
|
||||
** BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and
|
||||
** BTA_JV_CONN_CLOSE is called implicitely
|
||||
** BTA_JV_CONN_CLOSE is called implicitly
|
||||
** init_st: state after calling this API. typically it should be BTA_JV_CONN_OPEN
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
|
||||
@@ -1,32 +1,132 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "osi/allocator.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc/btc_util.h"
|
||||
#include "btc/btc_dev.h"
|
||||
|
||||
void btc_dev_arg_deep_free(btc_msg_t *msg)
|
||||
static inline void btc_dev_cb_to_app(esp_bt_dev_cb_event_t event, esp_bt_dev_cb_param_t *param)
|
||||
{
|
||||
esp_bt_dev_cb_t btc_bt_dev_cb = (esp_bt_dev_cb_t)btc_profile_cb_get(BTC_PID_DEV);
|
||||
if (btc_bt_dev_cb) {
|
||||
btc_bt_dev_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_dev_get_dev_name_callback(UINT8 status, char *name)
|
||||
{
|
||||
esp_bt_dev_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
memset(¶m, 0, sizeof(esp_bt_dev_cb_param_t));
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_DEV;
|
||||
msg.act = ESP_BT_DEV_NAME_RES_EVT;
|
||||
|
||||
param.name_res.status = btc_btm_status_to_esp_status(status);
|
||||
param.name_res.name = name;
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_bt_dev_cb_param_t), btc_dev_cb_arg_deep_copy, btc_dev_cb_arg_deep_free);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_dev_call_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
BTC_TRACE_DEBUG("%s \n", __func__);
|
||||
btc_dev_args_t *arg = (btc_dev_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:{
|
||||
if (arg->set_dev_name.device_name) {
|
||||
osi_free(arg->set_dev_name.device_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_DEV_ACT_GET_DEVICE_NAME:
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
case BTC_DEV_ACT_CFG_COEX_STATUS:
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_dev_call_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
BTC_TRACE_DEBUG("%s \n", __func__);
|
||||
btc_dev_args_t *dst = (btc_dev_args_t *)p_dest;
|
||||
btc_dev_args_t *src = (btc_dev_args_t *)p_src;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:{
|
||||
dst->set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->set_dev_name.device_name, src->set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_DEV_ACT_GET_DEVICE_NAME:
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
case BTC_DEV_ACT_CFG_COEX_STATUS:
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_dev_cb_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_bt_dev_cb_param_t *src = (esp_bt_dev_cb_param_t *)p_src;
|
||||
esp_bt_dev_cb_param_t *dst = (esp_bt_dev_cb_param_t *) p_dest;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BT_DEV_NAME_RES_EVT:{
|
||||
dst->name_res.name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->name_res.name) {
|
||||
BCM_STRNCPY_S(dst->name_res.name, src->name_res.name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->name_res.name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s, malloc failed\n", __func__);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_dev_cb_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
BTC_TRACE_DEBUG("%s \n", __func__);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:{
|
||||
char *device_name = ((btc_dev_args_t *)msg->arg)->set_dev_name.device_name;
|
||||
if (device_name) {
|
||||
osi_free(device_name);
|
||||
case ESP_BT_DEV_NAME_RES_EVT:{
|
||||
char *name = ((esp_bt_dev_cb_param_t *)msg->arg)->name_res.name;
|
||||
if (name) {
|
||||
osi_free(name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
case BTC_DEV_ACT_CFG_COEX_STATUS:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
@@ -41,7 +141,10 @@ void btc_dev_call_handler(btc_msg_t *msg)
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name, BT_DEVICE_TYPE_DUMO);
|
||||
break;
|
||||
case BTC_DEV_ACT_GET_DEVICE_NAME:
|
||||
BTA_DmGetDeviceName(btc_dev_get_dev_name_callback, BT_DEVICE_TYPE_DUMO);
|
||||
break;
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
case BTC_DEV_ACT_CFG_COEX_STATUS:
|
||||
@@ -54,5 +157,18 @@ void btc_dev_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
|
||||
btc_dev_arg_deep_free(msg);
|
||||
btc_dev_call_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_dev_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_bt_dev_cb_param_t *param = (esp_bt_dev_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BT_DEV_EVT_MAX) {
|
||||
btc_dev_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_dev_cb_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "btc/btc_common.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_main.h"
|
||||
#include "btc/btc_util.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "common/bt_target.h"
|
||||
#include "btc/btc_storage.h"
|
||||
@@ -717,14 +718,14 @@ static void btc_dm_acl_link_stat(tBTA_DM_ACL_LINK_STAT *p_acl_link_stat)
|
||||
switch (p_acl_link_stat->event) {
|
||||
case BTA_ACL_LINK_STAT_CONN_CMPL: {
|
||||
event = ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT;
|
||||
param.acl_conn_cmpl_stat.stat = p_acl_link_stat->link_act.conn_cmpl.status | ESP_BT_STATUS_BASE_FOR_HCI_ERR;
|
||||
param.acl_conn_cmpl_stat.stat = btc_hci_to_esp_status(p_acl_link_stat->link_act.conn_cmpl.status);
|
||||
param.acl_conn_cmpl_stat.handle = p_acl_link_stat->link_act.conn_cmpl.handle;
|
||||
memcpy(param.acl_conn_cmpl_stat.bda, p_acl_link_stat->link_act.conn_cmpl.bd_addr, ESP_BD_ADDR_LEN);
|
||||
break;
|
||||
}
|
||||
case BTA_ACL_LINK_STAT_DISCONN_CMPL: {
|
||||
event = ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT;
|
||||
param.acl_disconn_cmpl_stat.reason = p_acl_link_stat->link_act.disconn_cmpl.reason | ESP_BT_STATUS_BASE_FOR_HCI_ERR;
|
||||
param.acl_disconn_cmpl_stat.reason = btc_hci_to_esp_status(p_acl_link_stat->link_act.disconn_cmpl.reason);
|
||||
param.acl_disconn_cmpl_stat.handle = p_acl_link_stat->link_act.disconn_cmpl.handle;
|
||||
memcpy(param.acl_disconn_cmpl_stat.bda, p_acl_link_stat->link_act.disconn_cmpl.bd_addr, ESP_BD_ADDR_LEN);
|
||||
break;
|
||||
@@ -788,7 +789,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
/* Set initial device name, it can be overwritten later */
|
||||
if (p_data->enable.status == BTA_SUCCESS) {
|
||||
const char *initial_device_name = "ESP32";
|
||||
BTA_DmSetDeviceName(initial_device_name);
|
||||
BTA_DmSetDeviceName(initial_device_name, BT_DEVICE_TYPE_DUMO);
|
||||
}
|
||||
btc_enable_bluetooth_evt(p_data->enable.status);
|
||||
break;
|
||||
|
||||
@@ -141,18 +141,34 @@ uint32_t btc_get_ble_status(void)
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
// Number of recorded devices
|
||||
extern uint8_t btm_ble_sec_dev_active_count(void);
|
||||
if (btm_ble_sec_dev_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_KEYS);
|
||||
}
|
||||
|
||||
// Number of saved bonded devices
|
||||
if (btc_storage_get_num_ble_bond_devices()) {
|
||||
status |= BIT(BTC_BLE_STATUS_BOND);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
// Privacy enabled
|
||||
extern uint8_t btm_ble_privacy_is_enabled(void);
|
||||
if (btm_ble_privacy_is_enabled()) {
|
||||
status |= BIT(BTC_BLE_STATUS_PRIVACY);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Number of recorded devices
|
||||
extern uint8_t btdm_sec_dev_active_count(void);
|
||||
if (btdm_sec_dev_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_DEV);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
// Number of active extended advertsing
|
||||
extern uint8_t btm_ble_ext_adv_active_count(void);
|
||||
if (btm_ble_ext_adv_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_EXT_ADV);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Number of active ACL connection
|
||||
extern uint8_t btm_acl_active_count(void);
|
||||
|
||||
@@ -338,8 +338,11 @@ esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
esp_status = ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT;
|
||||
break;
|
||||
case HCI_ERR_UNSUPPORTED_VALUE:
|
||||
esp_status = ESP_BT_STATUS_UNSUPPORTED;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
esp_status = hci_status | ESP_BT_STATUS_BASE_FOR_HCI_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
typedef enum {
|
||||
BTC_DEV_ACT_SET_DEVICE_NAME,
|
||||
BTC_DEV_ACT_GET_DEVICE_NAME,
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
BTC_DEV_ACT_CFG_COEX_STATUS,
|
||||
#endif
|
||||
@@ -36,5 +37,10 @@ typedef union {
|
||||
} btc_dev_args_t;
|
||||
|
||||
void btc_dev_call_handler(btc_msg_t *msg);
|
||||
void btc_dev_cb_handler(btc_msg_t *msg);
|
||||
void btc_dev_call_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_dev_call_arg_deep_free(btc_msg_t *msg);
|
||||
void btc_dev_cb_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_dev_cb_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
#endif /* __BTC_DEV_H__ */
|
||||
|
||||
@@ -31,13 +31,15 @@ typedef enum {
|
||||
#define BTC_BLE_STATUS_IDLE 0
|
||||
typedef enum {
|
||||
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
||||
BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist
|
||||
BTC_BLE_STATUS_SCAN, // Scanning exist
|
||||
BTC_BLE_STATUS_CONN, // Connection exist
|
||||
BTC_BLE_STATUS_DEV, // Device record exist
|
||||
BTC_BLE_STATUS_KEYS, // Device keys record exist
|
||||
BTC_BLE_STATUS_BOND, // Bond info exist
|
||||
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
|
||||
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist
|
||||
BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist
|
||||
BTC_BLE_STATUS_PRIVACY, // Privacy enabled
|
||||
} tBTC_BLE_STATUS;
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -891,6 +891,40 @@ static void btc_set_local_privacy_callback(UINT8 status)
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_set_rpa_timeout_callback(UINT8 status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT;
|
||||
param.set_rpa_timeout_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_add_dev_to_resolving_list_callback(UINT8 status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_ADD_DEV_TO_RESOLVING_LIST_COMPLETE_EVT;
|
||||
|
||||
param.add_dev_to_resolving_list_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status)
|
||||
@@ -1067,7 +1101,7 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
|
||||
break;
|
||||
case BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT:
|
||||
msg.act = ESP_GAP_BLE_EXT_ADV_REPORT_EVT;
|
||||
memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_reprot_t));
|
||||
memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_report_t));
|
||||
if (params->ext_adv_report.adv_data) {
|
||||
memcpy(param.ext_adv_report.params.adv_data,
|
||||
params->ext_adv_report.adv_data, params->ext_adv_report.adv_data_len);
|
||||
@@ -1256,6 +1290,61 @@ void btc_dtm_stop_callback(void *p1)
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_vendor_hci_cmd_complete_callback(tBTA_VSC_CMPL *p_param)
|
||||
{
|
||||
bool param_invalid = false;
|
||||
if ((!p_param) || (!p_param->param_len) || (!p_param->p_param_buf)) {
|
||||
BTC_TRACE_ERROR("%s param error\n", __func__);
|
||||
param_invalid = true;
|
||||
}
|
||||
|
||||
esp_ble_gap_cb_param_t param = {0};
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT;
|
||||
if (!param_invalid) {
|
||||
param.vendor_cmd_cmpl.opcode = p_param->opcode;
|
||||
param.vendor_cmd_cmpl.param_len = p_param->param_len;
|
||||
param.vendor_cmd_cmpl.p_param_buf = p_param->p_param_buf;
|
||||
} else {
|
||||
if (p_param) {
|
||||
param.vendor_cmd_cmpl.opcode = p_param->opcode;
|
||||
} else {
|
||||
param.vendor_cmd_cmpl.opcode = 0;
|
||||
}
|
||||
param.vendor_cmd_cmpl.param_len = 0;
|
||||
param.vendor_cmd_cmpl.p_param_buf = NULL;
|
||||
}
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), btc_gap_ble_cb_deep_copy, btc_gap_ble_cb_deep_free);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_set_privacy_mode_callback(UINT8 status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT;
|
||||
|
||||
param.set_privacy_mode_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_get_whitelist_size(uint16_t *length)
|
||||
{
|
||||
BTM_BleGetWhiteListSize(length);
|
||||
@@ -1369,6 +1458,19 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_set_rpa_timeout(uint16_t rpa_timeout,tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *set_rpa_timeout_cback)
|
||||
{
|
||||
BTA_DmBleSetRpaTimeout(rpa_timeout,set_rpa_timeout_cback);
|
||||
}
|
||||
|
||||
static void btc_ble_add_device_to_resolving_list(BD_ADDR addr,
|
||||
uint8_t addr_type,
|
||||
uint8_t irk[],
|
||||
tBTA_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *add_dev_to_resolving_list_callback)
|
||||
{
|
||||
BTA_DmBleAddDevToResolvingList(addr, addr_type, irk, add_dev_to_resolving_list_callback);
|
||||
}
|
||||
|
||||
static void btc_ble_clear_rand_addr (void)
|
||||
{
|
||||
BTA_DmClearRandAddress();
|
||||
@@ -1421,6 +1523,13 @@ static void btc_ble_dtm_stop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback)
|
||||
BTA_DmBleDtmStop(p_dtm_cmpl_cback);
|
||||
}
|
||||
|
||||
static void btc_ble_set_privacy_mode(uint8_t addr_type,
|
||||
BD_ADDR addr,
|
||||
uint8_t privacy_mode,
|
||||
tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback)
|
||||
{
|
||||
BTA_DmBleSetPrivacyMode(addr_type, addr, privacy_mode, p_cback);
|
||||
}
|
||||
|
||||
void btc_gap_ble_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
@@ -1429,7 +1538,7 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
|
||||
if (msg->act < ESP_GAP_BLE_EVT_MAX) {
|
||||
btc_gap_ble_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s, unknow msg->act = %d", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s, unknown msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_gap_ble_cb_deep_free(msg);
|
||||
@@ -1598,6 +1707,31 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
break;
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: {
|
||||
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
|
||||
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
|
||||
if (src->vendor_cmd_send.param_len) {
|
||||
dst->vendor_cmd_send.p_param_buf = osi_malloc(src->vendor_cmd_send.param_len);
|
||||
if (dst->vendor_cmd_send.p_param_buf) {
|
||||
memcpy(dst->vendor_cmd_send.p_param_buf, src->vendor_cmd_send.p_param_buf, src->vendor_cmd_send.param_len);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
|
||||
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
|
||||
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
|
||||
dst->set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->set_dev_name.device_name, src->set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@@ -1606,7 +1740,22 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
|
||||
void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_gap_cb_param_t *src = (esp_ble_gap_cb_param_t *)p_src;
|
||||
esp_ble_gap_cb_param_t *dst = (esp_ble_gap_cb_param_t *) p_dest;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT: {
|
||||
if (src->vendor_cmd_cmpl.param_len) {
|
||||
dst->vendor_cmd_cmpl.p_param_buf = osi_malloc(src->vendor_cmd_cmpl.param_len);
|
||||
if (dst->vendor_cmd_cmpl.p_param_buf) {
|
||||
memcpy(dst->vendor_cmd_cmpl.p_param_buf, src->vendor_cmd_cmpl.p_param_buf,
|
||||
src->vendor_cmd_cmpl.param_len);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s, malloc failed\n", __func__);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
@@ -1704,6 +1853,21 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: {
|
||||
uint8_t *p_param_buf = ((btc_ble_gap_args_t *)msg->arg)->vendor_cmd_send.p_param_buf;
|
||||
if (p_param_buf) {
|
||||
osi_free(p_param_buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
|
||||
char *p_name = ((btc_ble_gap_args_t *)msg->arg)->set_dev_name.device_name;
|
||||
if (p_name) {
|
||||
osi_free((uint8_t *)p_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
@@ -1721,6 +1885,13 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT: {
|
||||
uint8_t *value = ((esp_ble_gap_cb_param_t *)msg->arg)->vendor_cmd_cmpl.p_param_buf;
|
||||
if (value) {
|
||||
osi_free(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d", msg->act);
|
||||
break;
|
||||
@@ -1781,6 +1952,17 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
btc_ble_set_rand_addr(bd_addr, btc_set_rand_addr_callback);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT: {
|
||||
btc_ble_set_rpa_timeout(arg->set_rpa_timeout.rpa_timeout,btc_set_rpa_timeout_callback);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST: {
|
||||
btc_ble_add_device_to_resolving_list(arg->add_dev_to_resolving_list.addr,
|
||||
arg->add_dev_to_resolving_list.addr_type,
|
||||
arg->add_dev_to_resolving_list.irk,
|
||||
btc_add_dev_to_resolving_list_callback);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS: {
|
||||
btc_ble_clear_rand_addr();
|
||||
break;
|
||||
@@ -1808,10 +1990,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_GET_DEV_NAME:
|
||||
BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback);
|
||||
BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
|
||||
@@ -2192,6 +2374,16 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
btc_ble_dtm_enhance_rx_start(arg_5->dtm_enh_rx_start.rx_channel, arg_5->dtm_enh_rx_start.phy, arg_5->dtm_enh_rx_start.modulation_index, btc_dtm_rx_start_callback);
|
||||
break;
|
||||
#endif // if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT:
|
||||
BTA_DmsendVendorHciCmd(arg->vendor_cmd_send.opcode,
|
||||
arg->vendor_cmd_send.param_len,
|
||||
arg->vendor_cmd_send.p_param_buf,
|
||||
btc_ble_vendor_hci_cmd_complete_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_SET_PRIVACY_MODE:
|
||||
btc_ble_set_privacy_mode(arg->set_privacy_mode.addr_type, arg->set_privacy_mode.addr,
|
||||
arg->set_privacy_mode.privacy_mode, btc_ble_set_privacy_mode_callback);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2202,6 +2394,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
//register connection parameter update callback
|
||||
void btc_gap_callback_init(void)
|
||||
{
|
||||
BTM_BleRegiseterPktLengthChangeCallback(btc_set_pkt_length_callback);
|
||||
BTM_BleRegiseterConnParamCallback(btc_update_conn_param_callback);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
BTM_BleGapRegisterCallback(btc_ble_5_gap_callback);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -797,6 +797,31 @@ static void btc_gap_set_acl_pkt_types(btc_gap_bt_args_t *arg)
|
||||
btc_gap_bt_set_acl_pkt_types_cmpl_callback);
|
||||
}
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
static void btc_gap_bt_set_min_enc_key_size_cmpl_callback(void *p_data)
|
||||
{
|
||||
tBTA_SET_MIN_ENC_KEY_SIZE_RESULTS *result = (tBTA_SET_MIN_ENC_KEY_SIZE_RESULTS *)p_data;
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT;
|
||||
|
||||
param.set_min_enc_key_size.status = btc_hci_to_esp_status(result->hci_status);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_bt_gap_cb_param_t), NULL, NULL);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gap_set_min_enc_key_size(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmSetMinEncKeySize(arg->set_min_enc_key_size.key_size, btc_gap_bt_set_min_enc_key_size_cmpl_callback);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void btc_gap_bt_read_remote_name_cmpl_callback(void *p_data)
|
||||
{
|
||||
tBTA_REMOTE_DEV_NAME *result = (tBTA_REMOTE_DEV_NAME *)p_data;
|
||||
@@ -853,6 +878,33 @@ static void btc_gap_bt_set_qos(btc_gap_bt_args_t *arg)
|
||||
#endif /// (BTA_DM_QOS_INCLUDED == TRUE)
|
||||
}
|
||||
|
||||
static void btc_gap_bt_get_dev_name_callback(UINT8 status, char *name)
|
||||
{
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
memset(¶m, 0, sizeof(esp_bt_gap_cb_param_t));
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT;
|
||||
|
||||
param.get_dev_name_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
param.get_dev_name_cmpl.name = (char *)osi_malloc(BTC_MAX_LOC_BD_NAME_LEN + 1);
|
||||
if (param.get_dev_name_cmpl.name) {
|
||||
BCM_STRNCPY_S(param.get_dev_name_cmpl.name, name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
param.get_dev_name_cmpl.name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
param.get_dev_name_cmpl.status = ESP_BT_STATUS_NOMEM;
|
||||
}
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_bt_gap_cb_param_t), NULL, NULL);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
switch (msg->act) {
|
||||
@@ -872,6 +924,10 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME:
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
case BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE:
|
||||
#endif
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
@@ -913,6 +969,18 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
btc_gap_bt_args_t *src = (btc_gap_bt_args_t *)p_src;
|
||||
btc_gap_bt_args_t *dst = (btc_gap_bt_args_t *)p_dest;
|
||||
dst->bt_set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->bt_set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->bt_set_dev_name.device_name, src->bt_set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->bt_set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@@ -939,6 +1007,10 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME:
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
case BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE:
|
||||
#endif
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
@@ -957,6 +1029,13 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
osi_free(arg->config_eir.eir_data.p_url);
|
||||
}
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
char *p_name = arg->bt_set_dev_name.device_name;
|
||||
if (p_name) {
|
||||
osi_free((uint8_t *)p_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d, arg: %p\n", msg->act, arg);
|
||||
break;
|
||||
@@ -1049,6 +1128,20 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_set_acl_pkt_types(arg);
|
||||
break;
|
||||
}
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
case BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE: {
|
||||
btc_gap_set_min_enc_key_size(arg);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
BTA_DmSetDeviceName(arg->bt_set_dev_name.device_name, BT_DEVICE_TYPE_BREDR);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME: {
|
||||
BTA_DmGetDeviceName(btc_gap_bt_get_dev_name_callback, BT_DEVICE_TYPE_BREDR);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1101,6 +1194,10 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
#if (BTC_DM_PM_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_MODE_CHG_EVT:
|
||||
#endif /// BTC_DM_PM_INCLUDED == TRUE
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
case BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT:
|
||||
#endif /// ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE
|
||||
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT:
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
@@ -1192,6 +1289,16 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
case BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT: {
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_SET_MIN_ENC_KEY_SIZE_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT: {
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -68,7 +68,7 @@ static UINT16 btc_max_hf_clients = BTC_HF_NUM_CB;
|
||||
#if HFP_DYNAMIC_MEMORY == FALSE
|
||||
static hf_local_param_t hf_local_param[BTC_HF_NUM_CB];
|
||||
#else
|
||||
static hf_local_param_t *hf_local_param = NULL;
|
||||
hf_local_param_t *hf_local_param_ptr = NULL;
|
||||
#endif
|
||||
|
||||
#if (BTM_WBS_INCLUDED == TRUE)
|
||||
@@ -319,20 +319,18 @@ bt_status_t btc_hf_init(void)
|
||||
BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients);
|
||||
|
||||
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_local_param != NULL) {
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
if ((hf_local_param = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
|
||||
APPL_TRACE_ERROR("%s malloc failed!", __func__);
|
||||
return BT_STATUS_NOMEM;
|
||||
if (hf_local_param == NULL) {
|
||||
if ((hf_local_param = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
|
||||
BTC_TRACE_ERROR("%s malloc failed!", __func__);
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
}
|
||||
memset((void *)hf_local_param, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t));
|
||||
#endif
|
||||
|
||||
/* Invoke the enable service API to the core to set the appropriate service_id
|
||||
* Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled (phone)
|
||||
* othwerwise only HSP is enabled (tablet)*/
|
||||
* otherwise only HSP is enabled (tablet)*/
|
||||
#if (defined(BTC_HF_SERVICES) && (BTC_HF_SERVICES & BTA_HFP_SERVICE_MASK))
|
||||
btc_dm_enable_service(BTA_HFP_SERVICE_ID);
|
||||
#else
|
||||
@@ -759,7 +757,7 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
|
||||
}
|
||||
/* CIND response should have been updated. */
|
||||
BTA_AgResult(BTA_AG_HANDLE_ALL, res, &ag_res);
|
||||
/* Just open SCO conenction. */
|
||||
/* Just open SCO connection. */
|
||||
BTA_AgAudioOpen(ag_res.audio_handle);
|
||||
activeCallUpdated = TRUE;
|
||||
}
|
||||
@@ -1572,7 +1570,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
|
||||
CHECK_HF_IDX(idx);
|
||||
BTC_TRACE_DEBUG("AG Bitmap of peer-codecs %d", p_data->val.num);
|
||||
#if (BTM_WBS_INCLUDED == TRUE)
|
||||
/* If the peer supports mSBC and the BTC prefferred codec is also mSBC, then
|
||||
/* If the peer supports mSBC and the BTC preferred codec is also mSBC, then
|
||||
** we should set the BTA AG Codec to mSBC. This would trigger a +BCS to mSBC at the time
|
||||
** of SCO connection establishment */
|
||||
if ((btc_conf_hf_force_wbs == TRUE) && (p_data->val.num & BTA_AG_CODEC_MSBC)) {
|
||||
@@ -1608,7 +1606,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
|
||||
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
|
||||
memcpy(param.bcs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
|
||||
param.bcs_rep.mode = p_data->val.num;
|
||||
/* No ESP_HF_WBS_NONE case, becuase HFP 1.6 supported device can send BCS */
|
||||
/* No ESP_HF_WBS_NONE case, because HFP 1.6 supported device can send BCS */
|
||||
btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
|
||||
@@ -261,7 +261,7 @@ static void btc_hd_deinit(void)
|
||||
}
|
||||
|
||||
btc_hd_cb.service_dereg_active = FALSE;
|
||||
// unresgister app will also relase the connection
|
||||
// unregister app will also release the connection
|
||||
// and disable after receiving unregister event from lower layer
|
||||
if (is_hidd_app_register()) {
|
||||
btc_hd_unregister_app(true);
|
||||
@@ -844,6 +844,8 @@ void btc_hd_cb_handler(btc_msg_t *msg)
|
||||
// }
|
||||
// btc_storage_set_hidd((bt_bdaddr_t *)&p_data->conn.bda);
|
||||
btc_hd_cb.status = BTC_HD_CONNECTED;
|
||||
} else if (p_data->conn.conn_status == BTA_HD_CONN_STATE_DISCONNECTED) {
|
||||
btc_hd_cb.status = BTC_HD_DISCONNECTED;
|
||||
}
|
||||
param.open.status = p_data->conn.status;
|
||||
param.open.conn_status = p_data->conn.conn_status;
|
||||
|
||||
@@ -189,7 +189,7 @@ static btc_hh_device_t *btc_hh_find_connected_dev_by_bda(BD_ADDR bd_addr)
|
||||
*
|
||||
* Function btc_hh_stop_vup_timer
|
||||
*
|
||||
* Description stop vitual unplug timer
|
||||
* Description stop virtual unplug timer
|
||||
*
|
||||
* Returns void
|
||||
******************************************************************************/
|
||||
@@ -316,7 +316,7 @@ void btc_hh_remove_device(BD_ADDR bd_addr)
|
||||
|
||||
for (i = 0; i < BTC_HH_MAX_ADDED_DEV; i++) {
|
||||
p_added_dev = &btc_hh_cb.added_devices[i];
|
||||
if (p_added_dev->bd_addr == bd_addr) {
|
||||
if (memcmp(p_added_dev->bd_addr, bd_addr, BD_ADDR_LEN) == 0) {
|
||||
BTA_HhRemoveDev(p_added_dev->dev_handle);
|
||||
btc_storage_remove_hid_info((bt_bdaddr_t *)p_added_dev->bd_addr);
|
||||
memset(p_added_dev->bd_addr, 0, 6);
|
||||
@@ -544,6 +544,11 @@ static void btc_hh_connect(btc_hidh_args_t *arg)
|
||||
BTC_TRACE_ERROR("%s exceeded the maximum supported HID device number %d!", __func__, BTC_HH_MAX_HID);
|
||||
ret = ESP_HIDH_ERR_NO_RES;
|
||||
break;
|
||||
} else if (dev && dev->dev_status == ESP_HIDH_CONN_STATE_CONNECTED) {
|
||||
BTC_TRACE_WARNING("%s Device[%s] already connected", __func__,
|
||||
bdaddr_to_string((const bt_bdaddr_t *)arg->connect.bd_addr, bdstr, sizeof(bdstr)));
|
||||
param.open.conn_status = ESP_HIDH_CONN_STATE_CONNECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < BTC_HH_MAX_ADDED_DEV; i++) {
|
||||
@@ -662,7 +667,7 @@ static void btc_hh_virtual_unplug(btc_hidh_args_t *arg)
|
||||
param.unplug.conn_status = ESP_HIDH_CONN_STATE_DISCONNECTING;
|
||||
param.unplug.handle = p_dev->dev_handle;
|
||||
} else if ((p_dev != NULL) && (p_dev->dev_status == ESP_HIDH_CONN_STATE_CONNECTED)) {
|
||||
BTC_TRACE_WARNING("%s: Virtual unplug not suported, disconnecting device", __func__);
|
||||
BTC_TRACE_WARNING("%s: Virtual unplug not supported, disconnecting device", __func__);
|
||||
/* start the timer */
|
||||
btc_hh_start_vup_timer(arg->unplug.bd_addr);
|
||||
p_dev->local_vup = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -102,6 +102,10 @@ typedef enum {
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
BTC_GAP_BLE_ACT_CLEAR_ADV,
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT,
|
||||
BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST,
|
||||
BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT,
|
||||
BTC_GAP_BLE_SET_PRIVACY_MODE,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@@ -139,6 +143,16 @@ typedef union {
|
||||
struct set_rand_addr_args {
|
||||
esp_bd_addr_t rand_addr;
|
||||
} set_rand_addr;
|
||||
// BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT
|
||||
struct set_rpa_timeout_args {
|
||||
uint16_t rpa_timeout;
|
||||
} set_rpa_timeout;
|
||||
//BTC_GAP_BLE_ACT_ADD_DEVICE_TO_RESOLVING_LIST
|
||||
struct add_dev_to_resolving_list_args {
|
||||
esp_bd_addr_t addr;
|
||||
uint8_t addr_type;
|
||||
uint8_t irk[PEER_IRK_LEN];
|
||||
} add_dev_to_resolving_list;
|
||||
//BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY,
|
||||
struct cfg_local_privacy_args {
|
||||
bool privacy_enable;
|
||||
@@ -172,7 +186,7 @@ typedef union {
|
||||
//BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
struct set_dev_name_args {
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
|
||||
char *device_name;
|
||||
} set_dev_name;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
@@ -248,9 +262,21 @@ typedef union {
|
||||
struct dtm_rx_start_args {
|
||||
uint8_t rx_channel;
|
||||
} dtm_rx_start;
|
||||
//BTC_DEV_VENDOR_HCI_CMD_EVT
|
||||
struct vendor_cmd_send_args {
|
||||
uint16_t opcode;
|
||||
uint8_t param_len;
|
||||
uint8_t *p_param_buf;
|
||||
} vendor_cmd_send;
|
||||
// BTC_GAP_BLE_SET_PRIVACY_MODE
|
||||
struct set_privacy_mode {
|
||||
esp_ble_addr_type_t addr_type;
|
||||
esp_bd_addr_t addr;
|
||||
uint8_t privacy_mode;
|
||||
} set_privacy_mode;
|
||||
} btc_ble_gap_args_t;
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
typedef union {
|
||||
struct read_phy_args {
|
||||
esp_bd_addr_t bd_addr;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,6 +35,10 @@ typedef enum {
|
||||
BTC_GAP_BT_SET_PAGE_TO_EVT,
|
||||
BTC_GAP_BT_GET_PAGE_TO_EVT,
|
||||
BTC_GAP_BT_SET_ACL_PKT_TYPES_EVT,
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
BTC_GAP_BT_SET_MIN_ENC_KEY_SIZE_EVT,
|
||||
#endif
|
||||
BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -58,6 +62,11 @@ typedef enum {
|
||||
BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT,
|
||||
BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT,
|
||||
BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES,
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE,
|
||||
#endif
|
||||
BTC_GAP_BT_ACT_SET_DEV_NAME,
|
||||
BTC_GAP_BT_ACT_GET_DEV_NAME,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
@@ -165,6 +174,17 @@ typedef union {
|
||||
uint16_t pkt_types;
|
||||
} set_acl_pkt_types;
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
// BTC_GAP_BT_ACT_SET_MIN_ENC_KEY_SIZE
|
||||
struct set_min_enc_key_size_args {
|
||||
uint8_t key_size;
|
||||
} set_min_enc_key_size;
|
||||
#endif
|
||||
|
||||
// BTC_GAP_BT_ACT_SET_DEV_NAME
|
||||
struct bt_set_dev_name_args {
|
||||
char *device_name;
|
||||
} bt_set_dev_name;
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -233,6 +233,11 @@ typedef struct
|
||||
esp_hf_outgoing_data_cb_t btc_hf_outgoing_data_cb;
|
||||
} hf_local_param_t;
|
||||
|
||||
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||
extern hf_local_param_t *hf_local_param_ptr;
|
||||
#define hf_local_param (hf_local_param_ptr)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
** BTC HF AG Handle Hub
|
||||
********************************************************************************/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -285,8 +285,8 @@ static int free_sdp_slot(int id)
|
||||
// Record have already been freed
|
||||
handle = -1;
|
||||
}
|
||||
osi_free(slot);
|
||||
slot = NULL;
|
||||
osi_free(sdp_local_param.sdp_slots[id]);
|
||||
sdp_local_param.sdp_slots[id] = NULL;
|
||||
|
||||
return handle;
|
||||
}
|
||||
@@ -1034,14 +1034,16 @@ static void btc_sdp_remove_record(btc_sdp_args_t *arg)
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s SDP record with handle %d not found",
|
||||
__func__, arg->remove_record.record_handle);
|
||||
return;
|
||||
ret = ESP_SDP_NO_CREATE_RECORD;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the Record handle, and free the slot */
|
||||
/* The application layer record_handle is equivalent to the id of the btc layer */
|
||||
int slot = get_sdp_slot_id_by_handle(arg->remove_record.record_handle);
|
||||
if (slot < 0) {
|
||||
return;
|
||||
ret = ESP_SDP_NO_CREATE_RECORD;
|
||||
break;
|
||||
}
|
||||
|
||||
handle = free_sdp_slot(slot);
|
||||
|
||||
@@ -95,6 +95,15 @@
|
||||
#define UC_BT_CLASSIC_BQB_ENABLED FALSE
|
||||
#endif
|
||||
|
||||
//Set Encryption Key Size(BT)
|
||||
#ifdef CONFIG_BT_ENC_KEY_SIZE_CTRL_STD
|
||||
#define UC_BT_ENC_KEY_SIZE_CTRL_MODE 1
|
||||
#elif CONFIG_BT_ENC_KEY_SIZE_CTRL_VSC
|
||||
#define UC_BT_ENC_KEY_SIZE_CTRL_MODE 2
|
||||
#else
|
||||
#define UC_BT_ENC_KEY_SIZE_CTRL_MODE 0
|
||||
#endif
|
||||
|
||||
//BLE
|
||||
#ifdef CONFIG_BT_BLE_ENABLED
|
||||
#define UC_BT_BLE_ENABLED CONFIG_BT_BLE_ENABLED
|
||||
|
||||
@@ -73,6 +73,11 @@
|
||||
#define SDP_INCLUDED TRUE
|
||||
#define BTA_DM_QOS_INCLUDED TRUE
|
||||
|
||||
#define ENC_KEY_SIZE_CTRL_MODE_NONE 0
|
||||
#define ENC_KEY_SIZE_CTRL_MODE_STD 1
|
||||
#define ENC_KEY_SIZE_CTRL_MODE_VSC 2
|
||||
#define ENC_KEY_SIZE_CTRL_MODE UC_BT_ENC_KEY_SIZE_CTRL_MODE
|
||||
|
||||
#if (UC_BT_A2DP_ENABLED == TRUE)
|
||||
#define BTA_AR_INCLUDED TRUE
|
||||
#define BTA_AV_INCLUDED TRUE
|
||||
|
||||
@@ -36,13 +36,14 @@
|
||||
#include "stack/hcimsgs.h"
|
||||
|
||||
#if ((BT_CONTROLLER_INCLUDED == TRUE) && SOC_ESP_NIMBLE_CONTROLLER)
|
||||
#include "nimble/ble_hci_trans.h"
|
||||
#include "ble_hci_trans.h"
|
||||
#endif
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
#include "l2c_int.h"
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
#include "stack/hcimsgs.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#define HCI_BLE_EVENT 0x3e
|
||||
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
|
||||
@@ -441,7 +442,7 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
uint8_t len = 0;
|
||||
STREAM_TO_UINT8(len, stream);
|
||||
#endif
|
||||
HCI_TRACE_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
HCI_TRACE_ERROR("Workaround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
packet->len, len);
|
||||
osi_free(packet);
|
||||
return;
|
||||
@@ -540,6 +541,26 @@ static void host_send_pkt_available_cb(void)
|
||||
hci_downstream_data_post(OSI_THREAD_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
|
||||
void bt_record_hci_data(uint8_t *data, uint16_t len)
|
||||
{
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
if ((data[0] == DATA_TYPE_EVENT) && (data[1] == HCI_BLE_EVENT) && ((data[3] == HCI_BLE_ADV_PKT_RPT_EVT) || (data[3] == HCI_BLE_DIRECT_ADV_EVT)
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| (data[3] == HCI_BLE_ADV_DISCARD_REPORT_EVT)
|
||||
#endif // (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|| (data[3] == HCI_BLE_EXT_ADV_REPORT_EVT) || (data[3] == HCI_BLE_PERIOD_ADV_REPORT_EVT)
|
||||
#endif // (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
)) {
|
||||
bt_hci_log_record_hci_adv(HCI_LOG_DATA_TYPE_ADV, &data[2], len - 2);
|
||||
} else {
|
||||
uint8_t data_type = ((data[0] == 2) ? HCI_LOG_DATA_TYPE_C2H_ACL : data[0]);
|
||||
bt_hci_log_record_hci_data(data_type, &data[1], len - 1);
|
||||
}
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
}
|
||||
|
||||
static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
{
|
||||
//Target has packet to host, malloc new buffer for packet
|
||||
@@ -551,13 +572,15 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
bt_record_hci_data(data, len);
|
||||
|
||||
bool is_adv_rpt = host_recv_adv_packet(data);
|
||||
|
||||
if (!is_adv_rpt) {
|
||||
pkt_size = BT_HDR_SIZE + len;
|
||||
pkt = (BT_HDR *) osi_calloc(pkt_size);
|
||||
if (!pkt) {
|
||||
HCI_TRACE_ERROR("%s couldn't aquire memory for inbound data buffer.\n", __func__);
|
||||
HCI_TRACE_ERROR("%s couldn't acquire memory for inbound data buffer.\n", __func__);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,6 +144,10 @@ void hci_shut_down(void)
|
||||
|
||||
bool hci_downstream_data_post(uint32_t timeout)
|
||||
{
|
||||
if (hci_host_env.downstream_data_ready == NULL) {
|
||||
HCI_TRACE_WARNING("%s downstream_data_ready event not created", __func__);
|
||||
return false;
|
||||
}
|
||||
return osi_thread_post_event(hci_host_env.downstream_data_ready, timeout);
|
||||
}
|
||||
|
||||
@@ -263,7 +267,7 @@ static void transmit_command(
|
||||
// in case the upper layer didn't already
|
||||
command->event = MSG_STACK_TO_HC_HCI_CMD;
|
||||
|
||||
HCI_TRACE_DEBUG("HCI Enqueue Comamnd opcode=0x%x\n", metadata->opcode);
|
||||
HCI_TRACE_DEBUG("HCI Enqueue Command opcode=0x%x\n", metadata->opcode);
|
||||
BTTRC_DUMP_BUFFER(NULL, command->data + command->offset, command->len);
|
||||
|
||||
fixed_pkt_queue_enqueue(hci_host_env.command_queue, linked_pkt, FIXED_PKT_QUEUE_MAX_TIMEOUT);
|
||||
|
||||
@@ -2931,4 +2931,31 @@ uint8_t btm_ble_scan_active_count(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
uint8_t btm_ble_sec_dev_active_count(void)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
/* First look for the non-paired devices for the oldest entry */
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE) && (p_dev_rec->ble.key_type != BTM_LE_KEY_NONE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
uint8_t btm_ble_privacy_is_enabled(void)
|
||||
{
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
return (p_cb->privacy_mode != BTM_PRIVACY_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
@@ -27,6 +27,7 @@ static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len,
|
||||
typedef struct {
|
||||
uint16_t ter_con_handle;
|
||||
bool invalid;
|
||||
bool enabled;
|
||||
UINT8 instance;
|
||||
int duration;
|
||||
int max_events;
|
||||
@@ -331,7 +332,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr)
|
||||
__func__, btm_ble_hci_status_to_str(err), err);
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
} else {
|
||||
// set random address success, update address infor
|
||||
// set random address success, update address info
|
||||
if(extend_adv_cb.inst[instance].configured && extend_adv_cb.inst[instance].connetable) {
|
||||
BTM_BleSetStaticAddr(rand_addr);
|
||||
BTM_UpdateAddrInfor(BLE_ADDR_RANDOM, rand_addr);
|
||||
@@ -415,7 +416,7 @@ end:
|
||||
BTM_TRACE_ERROR("LE EA SetParams: cmd err=0x%x", err);
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
} else {
|
||||
// set addr success, update address infor
|
||||
// set addr success, update address info
|
||||
BTM_UpdateAddrInfor(BLE_ADDR_RANDOM, rand_addr);
|
||||
}
|
||||
}
|
||||
@@ -540,6 +541,7 @@ end:
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++)
|
||||
{
|
||||
adv_record[i].invalid = false;
|
||||
adv_record[i].enabled = false;
|
||||
adv_record[i].instance = INVALID_VALUE;
|
||||
adv_record[i].duration = INVALID_VALUE;
|
||||
adv_record[i].max_events = INVALID_VALUE;
|
||||
@@ -550,6 +552,7 @@ end:
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
adv_record[index].invalid = false;
|
||||
adv_record[index].enabled = false;
|
||||
adv_record[index].instance = INVALID_VALUE;
|
||||
adv_record[index].duration = INVALID_VALUE;
|
||||
adv_record[index].max_events = INVALID_VALUE;
|
||||
@@ -563,6 +566,7 @@ end:
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
adv_record[index].invalid = true;
|
||||
adv_record[index].enabled = true;
|
||||
adv_record[index].instance = ext_adv[i].instance;
|
||||
adv_record[index].duration = ext_adv[i].duration;
|
||||
adv_record[index].max_events = ext_adv[i].max_events;
|
||||
@@ -588,12 +592,12 @@ tBTM_STATUS BTM_BleStartExtAdvRestart(uint8_t con_handle)
|
||||
}
|
||||
}
|
||||
|
||||
if((index >= MAX_BLE_ADV_INSTANCE) || (!adv_record[index].invalid) || (adv_record[index].retry_count > GATTC_CONNECT_RETRY_COUNT)) {
|
||||
if((index >= MAX_BLE_ADV_INSTANCE) || (!adv_record[index].invalid)) {
|
||||
return BTM_WRONG_MODE;
|
||||
}
|
||||
|
||||
adv_record[index].retry_count ++;
|
||||
BTM_TRACE_DEBUG("remote device did not reveive aux connect response, retatrt the extend adv to reconnect, adv handle %d con_handle %d\n", index, con_handle);
|
||||
BTM_TRACE_DEBUG("remote device did not receive aux connect response, retatrt the extend adv to reconnect, adv handle %d con_handle %d\n", index, con_handle);
|
||||
ext_adv.instance = adv_record[index].instance;
|
||||
ext_adv.duration = adv_record[index].duration;
|
||||
ext_adv.max_events = adv_record[index].max_events;
|
||||
@@ -794,8 +798,13 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params)
|
||||
|| (params->reports_disabled > 0x01)
|
||||
|| (params->filter_duplicates > 0x01)
|
||||
#endif
|
||||
|| (params->addr_type > 0x01) ||
|
||||
(params->sid > 0xf) || (params->skip > 0x01F3)) {
|
||||
/*If the Periodic Advertiser List is not used,
|
||||
the Advertising_SID, Advertiser Address_Type, and Advertiser Address
|
||||
parameters specify the periodic advertising device to listen to; otherwise they
|
||||
shall be ignored.*/
|
||||
|| (params->filter_policy == 0 && params->addr_type > 0x01)
|
||||
|| (params->filter_policy == 0 && params->sid > 0xf)
|
||||
|| (params->skip > 0x01F3)) {
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
BTM_TRACE_ERROR("%s, The sync parameters is invalid.", __func__);
|
||||
goto end;
|
||||
@@ -1196,6 +1205,7 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params)
|
||||
adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE;
|
||||
adv_record[params->adv_handle].invalid = false;
|
||||
}
|
||||
adv_record[params->adv_handle].enabled = false;
|
||||
|
||||
memcpy(&cb_params.adv_term, params, sizeof(tBTM_BLE_ADV_TERMINAT));
|
||||
|
||||
@@ -1311,6 +1321,19 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par
|
||||
|
||||
}
|
||||
|
||||
uint8_t btm_ble_ext_adv_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) {
|
||||
if (adv_record[i].enabled == true) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
@@ -70,7 +70,7 @@ static tBTM_BLE_VSC_CB *cmn_ble_gap_vsc_cb_ptr;
|
||||
static tBTM_BLE_CTRL_FEATURES_CBACK *p_ctrl_le_feature_rd_cmpl_cback = NULL;
|
||||
#endif
|
||||
|
||||
tBTM_CallbackFunc conn_param_update_cb;
|
||||
tBTM_CallbackFunc conn_callback_func;
|
||||
/*******************************************************************************
|
||||
** Local functions
|
||||
*******************************************************************************/
|
||||
@@ -309,7 +309,21 @@ void btm_ble_sem_free(void)
|
||||
*******************************************************************************/
|
||||
void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb)
|
||||
{
|
||||
conn_param_update_cb.update_conn_param_cb = update_conn_param_cb;
|
||||
conn_callback_func.update_conn_param_cb = update_conn_param_cb;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleRegiseterPktLengthChangeCallback
|
||||
**
|
||||
** Description Registers a callback function for packet length changes.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_BleRegiseterPktLengthChangeCallback(tBTM_SET_PKT_DATA_LENGTH_CBACK *ptk_len_chane_cb)
|
||||
{
|
||||
conn_callback_func.set_pkt_data_length_cb = ptk_len_chane_cb;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1333,7 +1347,7 @@ tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode)
|
||||
**
|
||||
** Function btm_set_conn_mode_adv_init_addr
|
||||
**
|
||||
** Description set initator address type and local address type based on adv
|
||||
** Description set initiator address type and local address type based on adv
|
||||
** mode.
|
||||
**
|
||||
**
|
||||
@@ -2001,7 +2015,7 @@ tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr)
|
||||
}
|
||||
|
||||
if (btm_cb.ble_ctr_cb.inq_var.state != BTM_BLE_IDLE) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state);
|
||||
BTM_TRACE_ERROR("Advertising or scanning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state);
|
||||
return BTM_SET_STATIC_RAND_ADDR_FAIL;
|
||||
}
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, rand_addr, BD_ADDR_LEN);
|
||||
@@ -2030,7 +2044,7 @@ void BTM_BleClearRandAddress(void)
|
||||
{
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && (p_cb->inq_var.state != BTM_BLE_IDLE)) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't restore public address ");
|
||||
BTM_TRACE_ERROR("Advertising or scanning now, can't restore public address ");
|
||||
return;
|
||||
}
|
||||
memset(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, 0, BD_ADDR_LEN);
|
||||
@@ -2236,16 +2250,16 @@ UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
|
||||
/* device name */
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME) {
|
||||
if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
|
||||
if (strlen(btm_cb.cfg.ble_bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
|
||||
cp_len = (UINT16)(len - MIN_ADV_LENGTH);
|
||||
*p++ = cp_len + 1;
|
||||
*p++ = BTM_BLE_AD_TYPE_NAME_SHORT;
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.ble_bd_name, cp_len);
|
||||
} else {
|
||||
cp_len = (UINT16)strlen(btm_cb.cfg.bd_name);
|
||||
cp_len = (UINT16)strlen(btm_cb.cfg.ble_bd_name);
|
||||
*p++ = cp_len + 1;
|
||||
*p++ = BTM_BLE_AD_TYPE_NAME_CMPL;
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.ble_bd_name, cp_len);
|
||||
}
|
||||
len -= (cp_len + MIN_ADV_LENGTH);
|
||||
data_mask &= ~BTM_BLE_AD_BIT_DEV_NAME;
|
||||
@@ -3291,6 +3305,7 @@ static void btm_ble_appearance_to_cod(UINT16 appearance, UINT8 *dev_class)
|
||||
case BTM_BLE_APPEARANCE_CYCLING_CADENCE:
|
||||
case BTM_BLE_APPEARANCE_CYCLING_POWER:
|
||||
case BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE:
|
||||
case BTM_BLE_APPEARANCE_STANDALONE_SPEAKER:
|
||||
case BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS:
|
||||
case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION:
|
||||
case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
|
||||
@@ -3728,7 +3743,7 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
/* never been report as an LE device */
|
||||
if (p_i &&
|
||||
(!(p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BLE) ||
|
||||
/* scan repsonse to be updated */
|
||||
/* scan response to be updated */
|
||||
(!p_i->scan_rsp))) {
|
||||
update = TRUE;
|
||||
} else if (BTM_BLE_IS_DISCO_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) {
|
||||
@@ -4002,7 +4017,7 @@ static void btm_ble_stop_discover(void)
|
||||
**
|
||||
** Description Set or clear adv states in topology mask
|
||||
**
|
||||
** Returns operation status. TRUE if sucessful, FALSE otherwise.
|
||||
** Returns operation status. TRUE if successful, FALSE otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
typedef BOOLEAN (BTM_TOPOLOGY_FUNC_PTR)(tBTM_BLE_STATE_MASK);
|
||||
@@ -4263,7 +4278,7 @@ void btm_ble_timeout(TIMER_LIST_ENT *p_tle)
|
||||
break;
|
||||
|
||||
case BTU_TTYPE_BLE_GAP_LIM_DISC:
|
||||
/* lim_timeout expiried, limited discovery should exit now */
|
||||
/* lim_timeout expired, limited discovery should exit now */
|
||||
btm_cb.btm_inq_vars.discoverable_mode &= ~BTM_BLE_LIMITED_DISCOVERABLE;
|
||||
btm_ble_set_adv_flag(btm_cb.btm_inq_vars.connectable_mode, btm_cb.btm_inq_vars.discoverable_mode);
|
||||
break;
|
||||
@@ -4364,7 +4379,7 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
|
||||
*******************************************************************************/
|
||||
void btm_ble_write_adv_enable_complete(UINT8 *p)
|
||||
{
|
||||
/* if write adv enable/disbale not succeed */
|
||||
/* if write adv enable/disable not succeed */
|
||||
if (*p != HCI_SUCCESS) {
|
||||
BTM_TRACE_ERROR("%s failed", __func__);
|
||||
}
|
||||
@@ -4702,6 +4717,40 @@ BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback)
|
||||
p_cb->inq_var.p_clear_adv_cb = p_clear_adv_cback;
|
||||
return TRUE;
|
||||
}
|
||||
BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout,tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback)
|
||||
{
|
||||
if ((btsnd_hcic_ble_set_rand_priv_addr_timeout(rpa_timeout)) != TRUE) {
|
||||
BTM_TRACE_ERROR("Set RPA Timeout error, rpa_timeout:0x%04x",rpa_timeout);
|
||||
return FALSE;
|
||||
}
|
||||
btm_cb.devcb.p_ble_set_rpa_timeout_cmpl_cb = p_set_rpa_timeout_cback;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN BTM_BleAddDevToResolvingList(BD_ADDR addr,
|
||||
uint8_t addr_type,
|
||||
uint8_t irk[],
|
||||
tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_add_dev_to_resolving_list_callback)
|
||||
{
|
||||
UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
|
||||
if ((btsnd_hcic_ble_add_device_resolving_list(addr_type, addr, irk, local_irk)) != TRUE) {
|
||||
BTM_TRACE_ERROR("Add device to resolving list error");
|
||||
return FALSE;
|
||||
}
|
||||
btm_cb.devcb.p_add_dev_to_resolving_list_cmpl_cb = p_add_dev_to_resolving_list_callback;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type, BD_ADDR bd_addr, UINT8 privacy_mode, tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_callback)
|
||||
{
|
||||
if (btsnd_hcic_ble_set_privacy_mode(addr_type, bd_addr, privacy_mode) != TRUE) {
|
||||
BTM_TRACE_ERROR("LE SetPrivacyMode Mode=%d: error", privacy_mode);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
btm_cb.devcb.p_set_privacy_mode_cmpl_cb = p_callback;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool btm_ble_adv_pkt_ready(void)
|
||||
{
|
||||
|
||||
@@ -824,6 +824,13 @@ void btm_ble_multi_adv_init(void)
|
||||
*******************************************************************************/
|
||||
void btm_ble_multi_adv_cleanup(void)
|
||||
{
|
||||
#if BTM_DYNAMIC_MEMORY == TRUE
|
||||
if (btm_multi_adv_cb_ptr == NULL)
|
||||
{
|
||||
BTM_TRACE_WARNING("%s memory has been freed", __func__);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (btm_multi_adv_cb.p_adv_inst) {
|
||||
osi_free(btm_multi_adv_cb.p_adv_inst);
|
||||
btm_multi_adv_cb.p_adv_inst = NULL;
|
||||
|
||||
@@ -275,6 +275,14 @@ void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
UINT8 status;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
if (btm_cb.devcb.p_add_dev_to_resolving_list_cmpl_cb) {
|
||||
tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_cb = btm_cb.devcb.p_add_dev_to_resolving_list_cmpl_cb;
|
||||
if (p_cb) {
|
||||
(*p_cb)(status);
|
||||
}
|
||||
} else {
|
||||
BTM_TRACE_DEBUG("no resolving list callback");
|
||||
}
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = %d", __func__, status);
|
||||
|
||||
@@ -416,6 +424,64 @@ void btm_ble_set_addr_resolution_enable_complete(UINT8 *p, UINT16 evt_len)
|
||||
random_cb->set_local_privacy_cback(BTM_ILLEGAL_VALUE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_set_rpa_timeout_complete
|
||||
**
|
||||
** Description This function is called when the LE Set Resolvable Private
|
||||
** Address Timeout command completes.
|
||||
**
|
||||
** Parameters p: Pointer to the command complete event data.
|
||||
** evt_len: Length of the event data.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_set_rpa_timeout_complete(UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
UINT8 status;
|
||||
|
||||
// Extract the status of the command completion from the event data
|
||||
STREAM_TO_UINT8(status, p);
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = %d", __func__, status);
|
||||
|
||||
tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_cb = btm_cb.devcb.p_ble_set_rpa_timeout_cmpl_cb;
|
||||
|
||||
if (p_cb) {
|
||||
(*p_cb)(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_set_privacy_mode_complete
|
||||
**
|
||||
** Description This function is called when the LE Set Privacy Mode command completes.
|
||||
**
|
||||
** Parameters p: Pointer to the command complete event data.
|
||||
** evt_len: Length of the event data.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_set_privacy_mode_complete(UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
UINT8 status;
|
||||
|
||||
// Extract the status of the command completion from the event data
|
||||
STREAM_TO_UINT8(status, p);
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = 0x%x", __func__, status);
|
||||
|
||||
tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_cb = btm_cb.devcb.p_set_privacy_mode_cmpl_cb;
|
||||
|
||||
if (p_cb) {
|
||||
(*p_cb)(status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
VSC that implement controller based privacy
|
||||
********************************************************************************/
|
||||
@@ -459,7 +525,7 @@ void btm_ble_resolving_list_vsc_op_cmpl (tBTM_VSC_CMPL *p_params)
|
||||
** Description This function to remove an IRK entry from the list
|
||||
**
|
||||
** Parameters ble_addr_type: address type
|
||||
** ble_addr: LE adddress
|
||||
** ble_addr: LE address
|
||||
**
|
||||
** Returns status
|
||||
**
|
||||
@@ -949,7 +1015,7 @@ void btm_ble_enable_resolving_list(UINT8 rl_mask)
|
||||
**
|
||||
** Function btm_ble_resolving_list_empty
|
||||
**
|
||||
** Description check to see if resoving list is empty or not
|
||||
** Description check to see if resolving list is empty or not
|
||||
**
|
||||
** Returns TRUE: empty; FALSE non-empty
|
||||
**
|
||||
@@ -1074,7 +1140,7 @@ void btm_ble_add_default_entry_to_resolving_list(void)
|
||||
/*
|
||||
* Add local IRK entry with 00:00:00:00:00:00 address. This entry will
|
||||
* be used to generate RPA for non-directed advertising if own_addr_type
|
||||
* is set to rpa_pub since we use all-zero address as peer addres in
|
||||
* is set to rpa_pub since we use all-zero address as peer address in
|
||||
* such case. Peer IRK should be left all-zero since this is not for an
|
||||
* actual peer.
|
||||
*/
|
||||
|
||||
@@ -81,7 +81,8 @@ void btm_dev_init (void)
|
||||
|
||||
/* Initialize nonzero defaults */
|
||||
#if (BTM_MAX_LOC_BD_NAME_LEN > 0)
|
||||
memset(btm_cb.cfg.bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
memset(btm_cb.cfg.ble_bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
memset(btm_cb.cfg.bredr_bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
#endif
|
||||
|
||||
btm_cb.devcb.reset_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RESET;
|
||||
@@ -449,11 +450,11 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
UINT8 *p;
|
||||
|
||||
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN)) {
|
||||
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN) || (name_type > BT_DEVICE_TYPE_DUMO)) {
|
||||
return (BTM_ILLEGAL_VALUE);
|
||||
}
|
||||
|
||||
@@ -463,16 +464,26 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
/* Save the device name if local storage is enabled */
|
||||
p = (UINT8 *)btm_cb.cfg.bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
if (name_type & BT_DEVICE_TYPE_BLE) {
|
||||
p = (UINT8 *)btm_cb.cfg.ble_bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.ble_bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.ble_bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
p = (UINT8 *)btm_cb.cfg.bredr_bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.bredr_bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.bredr_bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
}
|
||||
}
|
||||
#else
|
||||
p = (UINT8 *)p_name;
|
||||
#endif
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
if (btsnd_hcic_change_name(p)) {
|
||||
if ((name_type & BT_DEVICE_TYPE_BREDR) && btsnd_hcic_change_name(p)) {
|
||||
return (BTM_CMD_STARTED);
|
||||
} else
|
||||
#endif
|
||||
@@ -496,10 +507,33 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
** is returned and p_name is set to NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name)
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
/*
|
||||
// name_type should be BT_DEVICE_TYPE_BLE or BT_DEVICE_TYPE_BREDR
|
||||
if (name_type > BT_DEVICE_TYPE_BREDR) {
|
||||
*p_name = NULL;
|
||||
BTM_TRACE_ERROR("name_type unknown %d", name_type);
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
*/
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
*p_name = btm_cb.cfg.bd_name;
|
||||
if ((name_type == BT_DEVICE_TYPE_DUMO) &&
|
||||
(BCM_STRNCMP_S(btm_cb.cfg.bredr_bd_name, btm_cb.cfg.ble_bd_name, BTM_MAX_LOC_BD_NAME_LEN) != 0)) {
|
||||
*p_name = NULL;
|
||||
BTM_TRACE_ERROR("Error, BLE and BREDR have different names, return NULL\n");
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BLE) {
|
||||
*p_name = btm_cb.cfg.ble_bd_name;
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
*p_name = btm_cb.cfg.bredr_bd_name;
|
||||
}
|
||||
|
||||
return (BTM_SUCCESS);
|
||||
#else
|
||||
*p_name = NULL;
|
||||
@@ -740,19 +774,20 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
#endif // (BLE_INCLUDED == TRUE)
|
||||
tBTM_VSC_CMPL vcs_cplt_params;
|
||||
|
||||
/* If there was a callback address for vcs complete, call it */
|
||||
if (p_vsc_cplt_cback) {
|
||||
/* Pass paramters to the callback function */
|
||||
/* Pass parameters to the callback function */
|
||||
vcs_cplt_params.opcode = opcode; /* Number of bytes in return info */
|
||||
vcs_cplt_params.param_len = evt_len; /* Number of bytes in return info */
|
||||
vcs_cplt_params.p_param_buf = p;
|
||||
(*p_vsc_cplt_cback)(&vcs_cplt_params); /* Call the VSC complete callback function */
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -876,6 +911,42 @@ tBTM_STATUS BTM_WritePageTimeout(UINT16 timeout, tBTM_CMPL_CB *p_cb)
|
||||
return (BTM_CMD_STARTED);
|
||||
}
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE != ENC_KEY_SIZE_CTRL_MODE_NONE)
|
||||
void btm_set_min_enc_key_size_complete(const UINT8 *p)
|
||||
{
|
||||
tBTM_SET_MIN_ENC_KEY_SIZE_RESULTS results;
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_set_min_enc_key_size_cmpl_cb;
|
||||
|
||||
STREAM_TO_UINT8(results.hci_status, p);
|
||||
|
||||
if (p_cb) {
|
||||
btm_cb.devcb.p_set_min_enc_key_size_cmpl_cb = NULL;
|
||||
(*p_cb)(&results);
|
||||
}
|
||||
}
|
||||
|
||||
tBTM_STATUS BTM_SetMinEncKeySize(UINT8 key_size, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
BTM_TRACE_EVENT ("BTM: BTM_SetMinEncKeySize: key_size: %d.", key_size);
|
||||
|
||||
btm_cb.devcb.p_set_min_enc_key_size_cmpl_cb = p_cb;
|
||||
tBTM_STATUS status = BTM_NO_RESOURCES;
|
||||
|
||||
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_VSC)
|
||||
/* Send the HCI command */
|
||||
UINT8 param[1];
|
||||
UINT8 *p = (UINT8 *)param;
|
||||
UINT8_TO_STREAM(p, key_size);
|
||||
status = BTM_VendorSpecificCommand(HCI_VENDOR_BT_SET_MIN_ENC_KEY_SIZE, 1, param, NULL);
|
||||
#else
|
||||
if (btsnd_hcic_set_min_enc_key_size(key_size)) {
|
||||
status = BTM_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_set_page_timeout_complete
|
||||
|
||||
@@ -133,20 +133,3 @@ uint8_t btm_acl_active_count(void)
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t btdm_sec_dev_active_count(void)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
/* First look for the non-paired devices for the oldest entry */
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed autorization will take place */
|
||||
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed authorization will take place */
|
||||
if (p_dev_rec->last_author_service_id != BTM_SEC_NO_LAST_SERVICE_ID && p_dev_rec->p_cur_service) {
|
||||
BTM_TRACE_DEBUG ("btm_sec_clr_auth_service_by_psm [clearing device: %02x:%02x:%02x:%02x:%02x:%02x]\n",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
@@ -1364,7 +1364,7 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
|| (transport == BT_TRANSPORT_LE && p_dev_rec->ble_hci_handle == BTM_SEC_INVALID_HANDLE)
|
||||
#endif
|
||||
) {
|
||||
/* Connection should be up and runnning */
|
||||
/* Connection should be up and running */
|
||||
BTM_TRACE_WARNING ("Security Manager: BTM_SetEncryption not connected\n");
|
||||
|
||||
if (p_callback) {
|
||||
@@ -1790,15 +1790,15 @@ UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
|
||||
}
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
name_size = name_len;
|
||||
if (name_size > strlen(btm_cb.cfg.bd_name)) {
|
||||
if (name_size > strlen(btm_cb.cfg.bredr_bd_name)) {
|
||||
name_type = BTM_EIR_COMPLETE_LOCAL_NAME_TYPE;
|
||||
name_size = (UINT16)strlen(btm_cb.cfg.bd_name);
|
||||
name_size = (UINT16)strlen(btm_cb.cfg.bredr_bd_name);
|
||||
}
|
||||
delta = name_size + 2;
|
||||
if (max_len >= delta) {
|
||||
*p++ = name_size + 1;
|
||||
*p++ = name_type;
|
||||
ARRAY_TO_STREAM (p, btm_cb.cfg.bd_name, name_size);
|
||||
ARRAY_TO_STREAM (p, btm_cb.cfg.bredr_bd_name, name_size);
|
||||
len += delta;
|
||||
max_len -= delta;
|
||||
}
|
||||
@@ -2118,7 +2118,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
|
||||
|
||||
/* If there is no application registered with this PSM do not allow connection */
|
||||
if (!p_serv_rec) {
|
||||
BTM_TRACE_WARNING ("%s() PSM: %d no application registerd\n", __func__, psm);
|
||||
BTM_TRACE_WARNING ("%s() PSM: %d no application registered\n", __func__, psm);
|
||||
(*p_callback) (bd_addr, transport, p_ref_data, BTM_MODE_UNSUPPORTED);
|
||||
return (BTM_MODE_UNSUPPORTED);
|
||||
}
|
||||
@@ -2514,7 +2514,7 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
|
||||
|
||||
if (rc == BTM_SUCCESS) {
|
||||
BTM_TRACE_EVENT("%s: allow to bypass, checking authorization\n", __FUNCTION__);
|
||||
/* the security in BTM_SEC_IN_FLAGS is fullfilled so far, check the requirements in */
|
||||
/* the security in BTM_SEC_IN_FLAGS is fulfilled so far, check the requirements in */
|
||||
/* btm_sec_execute_procedure */
|
||||
if ((is_originator && (p_serv_rec->security_flags & BTM_SEC_OUT_AUTHORIZE)) ||
|
||||
(!is_originator && (p_serv_rec->security_flags & BTM_SEC_IN_AUTHORIZE))) {
|
||||
@@ -3979,7 +3979,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
||||
/* or BR key is higher security than existing LE keys */
|
||||
(!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) &&
|
||||
(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED)))) {
|
||||
BTM_TRACE_DEBUG ("link encrypted afer dedic bonding can use SMP_BR_CHNL\n");
|
||||
BTM_TRACE_DEBUG ("link encrypted after dedic bonding can use SMP_BR_CHNL\n");
|
||||
|
||||
if (btm_sec_is_master(p_dev_rec)) {
|
||||
// Encryption is required to start SM over BR/EDR
|
||||
@@ -4255,7 +4255,7 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
|
||||
** Function btm_sec_connected
|
||||
**
|
||||
** Description This function is when a connection to the peer device is
|
||||
** establsihed
|
||||
** established
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -5926,7 +5926,7 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
**
|
||||
** Function btm_sec_auth_payload_tout
|
||||
**
|
||||
** Description Processes the HCI Autheniticated Payload Timeout Event
|
||||
** Description Processes the HCI Authenticated Payload Timeout Event
|
||||
** indicating that a packet containing a valid MIC on the
|
||||
** connection handle was not received within the programmed
|
||||
** timeout value. (Spec Default is 30 secs, but can be
|
||||
@@ -6294,7 +6294,7 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
** Description This function is called when legacy authentication is used
|
||||
** and only remote device has completed the authentication
|
||||
**
|
||||
** Returns TRUE if aunthentication command sent successfully
|
||||
** Returns TRUE if authentication command sent successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user