mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
esp32: support LE-only versions
This commit is contained in:
parent
f83e233b86
commit
b0e734402b
@ -34,13 +34,16 @@ set(src_dirs "3rd-party/bluedroid/decoder/srce"
|
||||
"3rd-party/lwip/dhcp-server"
|
||||
"src/ble/gatt-service"
|
||||
"src/ble"
|
||||
"src/classic"
|
||||
"src/mesh"
|
||||
"src/"
|
||||
"platform/freertos"
|
||||
"platform/lwip"
|
||||
".")
|
||||
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
list(APPEND src_dirs "src/classic")
|
||||
endif()
|
||||
|
||||
set(priv_include_dirs
|
||||
"3rd-party/micro-ecc"
|
||||
)
|
||||
|
@ -234,6 +234,18 @@ static int transport_open(void){
|
||||
if (!bt_controller_initialized){
|
||||
bt_controller_initialized = 1;
|
||||
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#ifndef ENABLE_CLASSIC
|
||||
// LE-only on ESP32 - release memory used for classic mode
|
||||
ret = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
|
||||
if (ret) {
|
||||
log_error("Bluetooth controller release classic bt memory failed: %s", esp_err_to_name(ret));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
ret = esp_bt_controller_init(&bt_cfg);
|
||||
if (ret) {
|
||||
@ -243,15 +255,14 @@ static int transport_open(void){
|
||||
|
||||
}
|
||||
|
||||
// Enable classic mode by default
|
||||
esp_bt_mode_t bt_mode = ESP_BT_MODE_CLASSIC_BT;
|
||||
|
||||
// Enable LE mode by default
|
||||
esp_bt_mode_t bt_mode = ESP_BT_MODE_BLE;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#if CONFIG_BTDM_CTRL_MODE_BTDM
|
||||
// enable dual mode
|
||||
bt_mode = ESP_BT_MODE_BTDM;
|
||||
#elif BTDM_CTRL_MODE_BLE_ONLY
|
||||
// enable bluetooth low energy mode
|
||||
bt_mode = ESP_BT_MODE_BLE;
|
||||
#elif BTDM_CTRL_MODE_BR_EDR_ONLY
|
||||
bt_mode = ESP_BT_MODE_CLASSIC_BT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ret = esp_bt_controller_enable(bt_mode);
|
||||
@ -383,12 +394,16 @@ uint8_t btstack_init(void){
|
||||
const btstack_tlv_t * btstack_tlv_impl = btstack_tlv_esp32_get_instance();
|
||||
btstack_tlv_set_instance(btstack_tlv_impl, NULL);
|
||||
|
||||
#ifdef ENABLE_CLASSIC
|
||||
// setup Link Key DB using TLV
|
||||
const btstack_link_key_db_t * btstack_link_key_db = btstack_link_key_db_tlv_get_instance(btstack_tlv_impl, NULL);
|
||||
hci_set_link_key_db(btstack_link_key_db);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BLE
|
||||
// setup LE Device DB using TLV
|
||||
le_device_db_tlv_configure(btstack_tlv_impl, NULL);
|
||||
#endif
|
||||
|
||||
// inform about BTstack state
|
||||
hci_event_callback_registration.callback = &packet_handler;
|
||||
|
@ -40,11 +40,14 @@ COMPONENT_SRCDIRS := \
|
||||
3rd-party/md5 \
|
||||
src/ble/gatt-service \
|
||||
src/ble \
|
||||
src/classic \
|
||||
src/mesh \
|
||||
src/ \
|
||||
platform/freertos \
|
||||
platform/lwip \
|
||||
. \
|
||||
|
||||
ifdef CONFIG_IDF_TARGET_ESP32
|
||||
COMPONENT_SRCDIRS += src/classic
|
||||
endif
|
||||
|
||||
CFLAGS += -Wno-format
|
||||
|
Loading…
x
Reference in New Issue
Block a user