Merge branch 'feature/support_esp32c3_s3_ble_5.0_and_bug_fix' into 'master'

Feature/support esp32c3 s3 ble 5.0 and bug fix

See merge request espressif/esp-idf!12007
This commit is contained in:
Jiang Jiang Jian 2021-01-17 17:06:12 +08:00
commit 8b33695495
251 changed files with 84149 additions and 844 deletions

View File

@ -1,8 +1,21 @@
if(CONFIG_BT_ENABLED) if(CONFIG_BT_ENABLED)
if(CONFIG_IDF_TARGET_ESP32)
set(srcs "controller/esp32/bt.c")
elseif(CONFIG_IDF_TARGET_ESP32C3)
set(srcs "controller/esp32c3/bt.c")
elseif(CONFIG_IDF_TARGET_ESP32S3)
set(srcs "controller/esp32s3/bt.c")
endif()
set(srcs "controller/bt.c") set(include_dirs common/osi/include)
set(include_dirs include
common/osi/include) if(CONFIG_IDF_TARGET_ESP32)
list(APPEND include_dirs include/esp32/include)
elseif(CONFIG_IDF_TARGET_ESP32C3)
list(APPEND include_dirs include/esp32c3/include)
elseif(CONFIG_IDF_TARGET_ESP32S3)
list(APPEND include_dirs include/esp32s3/include)
endif()
list(APPEND priv_include_dirs list(APPEND priv_include_dirs
common/btc/include common/btc/include
@ -243,6 +256,7 @@ if(CONFIG_BT_ENABLED)
"host/bluedroid/stack/btm/btm_ble_bgconn.c" "host/bluedroid/stack/btm/btm_ble_bgconn.c"
"host/bluedroid/stack/btm/btm_ble_cont_energy.c" "host/bluedroid/stack/btm/btm_ble_cont_energy.c"
"host/bluedroid/stack/btm/btm_ble_gap.c" "host/bluedroid/stack/btm/btm_ble_gap.c"
"host/bluedroid/stack/btm/btm_ble_5_gap.c"
"host/bluedroid/stack/btm/btm_ble_multi_adv.c" "host/bluedroid/stack/btm/btm_ble_multi_adv.c"
"host/bluedroid/stack/btm/btm_ble_privacy.c" "host/bluedroid/stack/btm/btm_ble_privacy.c"
"host/bluedroid/stack/btm/btm_dev.c" "host/bluedroid/stack/btm/btm_dev.c"
@ -573,7 +587,14 @@ idf_component_register(SRCS "${srcs}"
if(CONFIG_BT_ENABLED) if(CONFIG_BT_ENABLED)
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable) target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
if(CONFIG_IDF_TARGET_ESP32)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib") target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib/esp32")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
elseif(CONFIG_IDF_TARGET_ESP32C3)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib/esp32c3")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app btbb)
elseif(CONFIG_IDF_TARGET_ESP32S3)
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib/esp32s3")
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app btbb)
endif()
endif() endif()

View File

@ -1,453 +1,47 @@
menu "Bluetooth" menu "Bluetooth"
visible if IDF_TARGET_ESP32 visible if (IDF_TARGET_ESP32 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
config BT_ENABLED config BT_ENABLED
bool "Bluetooth" bool "Bluetooth"
depends on IDF_TARGET_ESP32 depends on (IDF_TARGET_ESP32 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
help help
Select this option to enable Bluetooth and show the submenu with Bluetooth configuration choices. Select this option to enable Bluetooth and show the submenu with Bluetooth configuration choices.
menu "Bluetooth controller" config BT_CTRL_ESP32
visible if BT_ENABLED bool
depends on BT_ENABLED && IDF_TARGET_ESP32
choice BTDM_CTRL_MODE
prompt "Bluetooth controller mode (BR/EDR/BLE/DUALMODE)"
depends on BT_ENABLED
help
Specify the bluetooth controller mode (BR/EDR, BLE or dual mode).
config BTDM_CTRL_MODE_BLE_ONLY
bool "BLE Only"
config BTDM_CTRL_MODE_BR_EDR_ONLY
bool "BR/EDR Only"
config BTDM_CTRL_MODE_BTDM
bool "Bluetooth Dual Mode"
endchoice
config BTDM_CTRL_BLE_MAX_CONN
int "BLE Max Connections"
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default 3
range 1 9
help
BLE maximum connections of bluetooth controller.
Each connection uses 1KB static DRAM whenever the BT controller is enabled.
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN
int "BR/EDR ACL Max Connections"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 2
range 1 7
help
BR/EDR ACL maximum connections of bluetooth controller.
Each connection uses 1.2KB static DRAM whenever the BT controller is enabled.
config BTDM_CTRL_BR_EDR_MAX_SYNC_CONN
int "BR/EDR Sync(SCO/eSCO) Max Connections"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
range 0 3
help
BR/EDR Synchronize maximum connections of bluetooth controller.
Each connection uses 2KB static DRAM whenever the BT controller is enabled.
choice BTDM_CTRL_BR_EDR_SCO_DATA_PATH
prompt "BR/EDR Sync(SCO/eSCO) default data path"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
help
SCO data path, i.e. HCI or PCM.
SCO data can be sent/received through HCI synchronous packets, or the data
can be routed to on-chip PCM module on ESP32. PCM input/output signals can
be "matrixed" to GPIOs. The default data path can also be set using API
"esp_bredr_sco_datapath_set"
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
bool "HCI"
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
bool "PCM"
endchoice
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF
int
default 0 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default 0
menuconfig BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
bool "PCM Signal Config (Role and Polar)"
depends on BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default y default y
choice BTDM_CTRL_PCM_ROLE config BT_CTRL_ESP32C3
prompt "PCM Role"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM role can be configured as PCM master or PCM slave
config BTDM_CTRL_PCM_ROLE_MASTER
bool "PCM Master"
config BTDM_CTRL_PCM_ROLE_SLAVE
bool "PCM Slave"
endchoice
choice BTDM_CTRL_PCM_POLAR
prompt "PCM Polar"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM polarity can be configured as Falling Edge or Rising Edge
config BTDM_CTRL_PCM_POLAR_FALLING_EDGE
bool "Falling Edge"
config BTDM_CTRL_PCM_POLAR_RISING_EDGE
bool "Rising Edge"
endchoice
config BTDM_CTRL_PCM_ROLE_EFF
int
default 0 if BTDM_CTRL_PCM_ROLE_MASTER
default 1 if BTDM_CTRL_PCM_ROLE_SLAVE
default 0
config BTDM_CTRL_PCM_POLAR_EFF
int
default 0 if BTDM_CTRL_PCM_POLAR_FALLING_EDGE
default 1 if BTDM_CTRL_PCM_POLAR_RISING_EDGE
default 0
config BTDM_CTRL_AUTO_LATENCY
bool "Auto latency"
depends on BTDM_CTRL_MODE_BTDM
default n
help
BLE auto latency, used to enhance classic BT performance
while classic BT and BLE are enabled at the same time.
config BTDM_CTRL_AUTO_LATENCY_EFF
bool bool
default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM depends on BT_ENABLED && IDF_TARGET_ESP32C3
default n
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
bool "Legacy Authentication Vendor Specific Event Enable"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default y default y
help config BT_CTRL_ESP32S3
To protect from BIAS attack during Legacy authentication,
Legacy authentication Vendor specific event should be enabled
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
bool bool
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM depends on BT_ENABLED && IDF_TARGET_ESP32S3
default 0 default y
menu "Bluetooth controller(ESP32 Dual Mode Bluetooth)"
visible if BT_CTRL_ESP32
config BTDM_CTRL_BLE_MAX_CONN_EFF source "$IDF_PATH/components/bt/controller/esp32/Kconfig.in"
int
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF
int
default BTDM_CTRL_BR_EDR_MAX_ACL_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF
int
default BTDM_CTRL_BR_EDR_MAX_SYNC_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
choice BTDM_CTRL_PINNED_TO_CORE_CHOICE
prompt "The cpu core which bluetooth controller run"
depends on BT_ENABLED && !FREERTOS_UNICORE
help
Specify the cpu core to run bluetooth controller.
Can not specify no-affinity.
config BTDM_CTRL_PINNED_TO_CORE_0
bool "Core 0 (PRO CPU)"
config BTDM_CTRL_PINNED_TO_CORE_1
bool "Core 1 (APP CPU)"
depends on !FREERTOS_UNICORE
endchoice
config BTDM_CTRL_PINNED_TO_CORE
int
default 0 if BTDM_CTRL_PINNED_TO_CORE_0
default 1 if BTDM_CTRL_PINNED_TO_CORE_1
default 0
choice BTDM_CTRL_HCI_MODE_CHOICE
prompt "HCI mode"
depends on BT_ENABLED
help
Speicify HCI mode as VHCI or UART(H4)
config BTDM_CTRL_HCI_MODE_VHCI
bool "VHCI"
help
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32, too.
config BTDM_CTRL_HCI_MODE_UART_H4
bool "UART(H4)"
help
If use external bluetooth host which run on other hardware and use UART as the HCI interface,
choose this option.
endchoice
menu "HCI UART(H4) Options"
visible if BTDM_CTRL_HCI_MODE_UART_H4
config BT_HCI_UART_NO
int "UART Number for HCI"
depends on BTDM_CTRL_HCI_MODE_UART_H4
range 1 2
default 1
help
Uart number for HCI. The available uart is UART1 and UART2.
config BT_HCI_UART_BAUDRATE
int "UART Baudrate for HCI"
depends on BTDM_CTRL_HCI_MODE_UART_H4
range 115200 921600
default 921600
help
UART Baudrate for HCI. Please use standard baudrate.
endmenu endmenu
menu "MODEM SLEEP Options" menu "Bluetooth controller(ESP32C3 Bluetooth Low Energy)"
visible if BT_ENABLED visible if BT_CTRL_ESP32C3
config BTDM_MODEM_SLEEP
bool "Bluetooth modem sleep"
depends on BT_ENABLED
default y
help
Enable/disable bluetooth controller low power mode.
choice BTDM_MODEM_SLEEP_MODE
prompt "Bluetooth Modem sleep mode"
depends on BTDM_MODEM_SLEEP
help
To select which strategy to use for modem sleep
config BTDM_MODEM_SLEEP_MODE_ORIG
bool "ORIG Mode(sleep with low power clock)"
help
ORIG mode is a bluetooth sleep mode that can be used for dual mode controller. In this mode,
bluetooth controller sleeps between BR/EDR frames and BLE events. A low power clock is used to
maintain bluetooth reference clock.
config BTDM_MODEM_SLEEP_MODE_EVED
bool "EVED Mode(For internal test only)"
help
EVED mode is for BLE only and is only for internal test. Do not use it for production. this
mode is not compatible with DFS nor light sleep
endchoice
choice BTDM_LOW_POWER_CLOCK
prompt "Bluetooth low power clock"
depends on BTDM_MODEM_SLEEP_MODE_ORIG
help
Select the low power clock source for bluetooth controller. Bluetooth low power clock is
the clock source to maintain time in sleep mode.
- "Main crystal" option provides good accuracy and can support Dynamic Frequency Scaling
to be used with Bluetooth modem sleep. Light sleep is not supported.
- "External 32kHz crystal" option allows user to use a 32.768kHz crystal as Bluetooth low
power clock. This option is allowed as long as External 32kHz crystal is configured as
the system RTC clock source. This option provides good accuracy and supports Bluetooth
modem sleep to be used alongside Dynamic Frequency Scaling or light sleep.
config BTDM_LPCLK_SEL_MAIN_XTAL
bool "Main crystal"
help
Main crystal can be used as low power clock for bluetooth modem sleep. If this option is
selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but
cannot work when light sleep is enabled. Main crystal has a good performance in accuracy as
the bluetooth low power clock source.
config BTDM_LPCLK_SEL_EXT_32K_XTAL
bool "External 32kHz crystal"
depends on ESP32_RTC_CLK_SRC_EXT_CRYS
help
External 32kHz crystal has a nominal frequency of 32.768kHz and provides good frequency
stability. If used as Bluetooth low power clock, External 32kHz can support Bluetooth
modem sleep to be used with both DFS and light sleep.
endchoice
source "$IDF_PATH/components/bt/controller/esp32c3/Kconfig.in"
endmenu endmenu
choice BTDM_BLE_SLEEP_CLOCK_ACCURACY menu "Bluetooth controller(ESP32S3 Bluetooth Low Energy)"
prompt "BLE Sleep Clock Accuracy" visible if BT_CTRL_ESP32S3
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default BTDM_BLE_DEFAULT_SCA_250PPM
help
BLE Sleep Clock Accuracy(SCA) for the local device is used to estimate window widening in BLE
connection events. With a lower level of clock accuracy(e.g. 500ppm over 250ppm), the slave
needs a larger RX window to synchronize with master in each anchor point, thus resulting in an
increase of power consumption but a higher level of robustness in keeping connected. According
to the requirements of Bluetooth Core specification 4.2, the worst-case accuracy of Classic
Bluetooth low power oscialltor(LPO) is +/-250ppm in STANDBY and in low power modes such as
sniff. For BLE the worst-case SCA is +/-500ppm.
- "151ppm to 250ppm" option is the default value for Bluetooth Dual mode
- "251ppm to 500ppm" option can be used in BLE only mode when using external 32kHz crystal as
low power clock. This option is provided in case that BLE sleep clock has a lower level of
accuracy, or other error sources contribute to the inaccurate timing during sleep.
config BTDM_BLE_DEFAULT_SCA_500PPM
bool "251ppm to 500ppm"
depends on BTDM_LPCLK_SEL_EXT_32K_XTAL && BTDM_CTRL_MODE_BLE_ONLY
config BTDM_BLE_DEFAULT_SCA_250PPM
bool "151ppm to 250ppm"
endchoice
config BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF
int
default 0 if BTDM_BLE_DEFAULT_SCA_500PPM
default 1 if BTDM_BLE_DEFAULT_SCA_250PPM
default 1
config BTDM_BLE_SCAN_DUPL
bool "BLE Scan Duplicate Options"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
default y
help
This select enables parameters setting of BLE scan duplicate.
choice BTDM_SCAN_DUPL_TYPE
prompt "Scan Duplicate Type"
default BTDM_SCAN_DUPL_TYPE_DEVICE
depends on BTDM_BLE_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 BTDM_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 BTDM_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 BTDM_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 BTDM_SCAN_DUPL_TYPE
int
depends on BTDM_BLE_SCAN_DUPL
default 0 if BTDM_SCAN_DUPL_TYPE_DEVICE
default 1 if BTDM_SCAN_DUPL_TYPE_DATA
default 2 if BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
default 0
config BTDM_SCAN_DUPL_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BTDM_BLE_SCAN_DUPL
range 10 1000
default 200
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BTDM_BLE_MESH_SCAN_DUPL_EN
bool "Special duplicate scan mechanism for BLE Mesh scan"
depends on BTDM_BLE_SCAN_DUPL
default n
help
This enables the BLE scan duplicate for special BLE Mesh scan.
config BTDM_MESH_DUPL_SCAN_CACHE_SIZE
int "Maximum number of Mesh adv packets in scan duplicate filter"
depends on BTDM_BLE_MESH_SCAN_DUPL_EN
range 10 1000
default 200
help
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BTDM_CTRL_FULL_SCAN_SUPPORTED
bool "BLE full scan feature supported"
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
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_BLE_ADV_REPORT_FLOW_CTRL_SUPP
bool "BLE adv report flow control supported"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
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 BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM
int "BLE adv report flow control number"
depends on BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
range 50 1000
default 100
help
The number of unprocessed advertising report that Bluedroid can save.If you set
`BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
If you set `BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, Bluedroid 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
`BTDM_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 BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
int "BLE adv lost event threshold value"
depends on BTDM_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 `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
may cause adv packets lost more.
menuconfig BTDM_COEX_BT_OPTIONS
bool "Coexistence Bluetooth Side Options"
depends on ESP32_WIFI_SW_COEXIST_ENABLE
default n
help
Options of Bluetooth Side of WiFi and bluetooth coexistence.
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
depends on BTDM_COEX_BT_OPTIONS
default n
help
Improve BLE ADV coexistence priority to make it better performance.
For example, BLE mesh need to enable this option to improve BLE adv performance.
source "$IDF_PATH/components/bt/controller/esp32s3/Kconfig.in"
endmenu endmenu
choice BT_HOST choice BT_HOST
prompt "Bluetooth Host" prompt "Bluetooth Host"
depends on BT_ENABLED && BTDM_CTRL_HCI_MODE_VHCI depends on BT_ENABLED && (BTDM_CTRL_HCI_MODE_VHCI || BT_CTRL_HCI_MODE_VHCI)
default BT_BLUEDROID_ENABLED default BT_BLUEDROID_ENABLED
help help
This helps to choose Bluetooth host stack This helps to choose Bluetooth host stack

View File

@ -15,7 +15,6 @@
#ifndef __THREAD_H__ #ifndef __THREAD_H__
#define __THREAD_H__ #define __THREAD_H__
#include "freertos/xtensa_api.h"
#include "freertos/FreeRTOSConfig.h" #include "freertos/FreeRTOSConfig.h"
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/queue.h" #include "freertos/queue.h"

View File

@ -9,17 +9,21 @@ COMPONENT_ADD_INCLUDEDIRS := include
LIBS := btdm_app LIBS := btdm_app
COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/controller/lib \ COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/controller/lib/esp32 \
$(addprefix -l,$(LIBS)) $(addprefix -l,$(LIBS))
# re-link program if BT binary libs change # re-link program if BT binary libs change
COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/controller/lib/lib%.a,$(LIBS)) COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/controller/lib/esp32/lib%.a,$(LIBS))
COMPONENT_SUBMODULES += controller/lib COMPONENT_SUBMODULES += controller/lib
# TODO: annotate fallthroughs in Bluedroid code with comments # TODO: annotate fallthroughs in Bluedroid code with comments
CFLAGS += -Wno-implicit-fallthrough CFLAGS += -Wno-implicit-fallthrough
COMPONENT_ADD_INCLUDEDIRS += include/esp32/include
COMPONENT_SRCDIRS += controller/esp32
ifdef CONFIG_BT_BLUEDROID_ENABLED ifdef CONFIG_BT_BLUEDROID_ENABLED
COMPONENT_PRIV_INCLUDEDIRS += host/bluedroid/bta/include \ COMPONENT_PRIV_INCLUDEDIRS += host/bluedroid/bta/include \
@ -64,7 +68,7 @@ COMPONENT_PRIV_INCLUDEDIRS += host/bluedroid/bta/include \
host/bluedroid/stack/rfcomm/include \ host/bluedroid/stack/rfcomm/include \
host/bluedroid/stack/include \ host/bluedroid/stack/include \
host/bluedroid/utils/include \ host/bluedroid/utils/include \
host/bluedroid/common/include host/bluedroid/common/include \
COMPONENT_ADD_INCLUDEDIRS += host/bluedroid/api/include/api \ COMPONENT_ADD_INCLUDEDIRS += host/bluedroid/api/include/api \
common/osi/include common/osi/include
@ -128,7 +132,7 @@ COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
common/include common/include
COMPONENT_SRCDIRS += common/osi \ COMPONENT_SRCDIRS += common/osi \
common/btc/core common/btc/core \
ifdef CONFIG_BLE_MESH ifdef CONFIG_BLE_MESH

View File

@ -0,0 +1,432 @@
choice BTDM_CTRL_MODE
prompt "Bluetooth controller mode (BR/EDR/BLE/DUALMODE)"
depends on BT_CTRL_ESP32
help
Specify the bluetooth controller mode (BR/EDR, BLE or dual mode).
config BTDM_CTRL_MODE_BLE_ONLY
bool "BLE Only"
config BTDM_CTRL_MODE_BR_EDR_ONLY
bool "BR/EDR Only"
config BTDM_CTRL_MODE_BTDM
bool "Bluetooth Dual Mode"
endchoice
config BTDM_CTRL_BLE_MAX_CONN
int "BLE Max Connections"
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default 3
range 1 9
help
BLE maximum connections of bluetooth controller.
Each connection uses 1KB static DRAM whenever the BT controller is enabled.
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN
int "BR/EDR ACL Max Connections"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 2
range 1 7
help
BR/EDR ACL maximum connections of bluetooth controller.
Each connection uses 1.2KB static DRAM whenever the BT controller is enabled.
config BTDM_CTRL_BR_EDR_MAX_SYNC_CONN
int "BR/EDR Sync(SCO/eSCO) Max Connections"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
range 0 3
help
BR/EDR Synchronize maximum connections of bluetooth controller.
Each connection uses 2KB static DRAM whenever the BT controller is enabled.
choice BTDM_CTRL_BR_EDR_SCO_DATA_PATH
prompt "BR/EDR Sync(SCO/eSCO) default data path"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
help
SCO data path, i.e. HCI or PCM.
SCO data can be sent/received through HCI synchronous packets, or the data
can be routed to on-chip PCM module on ESP32. PCM input/output signals can
be "matrixed" to GPIOs. The default data path can also be set using API
"esp_bredr_sco_datapath_set"
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
bool "HCI"
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
bool "PCM"
endchoice
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF
int
default 0 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default 0
menuconfig BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
bool "PCM Signal Config (Role and Polar)"
depends on BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
default y
choice BTDM_CTRL_PCM_ROLE
prompt "PCM Role"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM role can be configured as PCM master or PCM slave
config BTDM_CTRL_PCM_ROLE_MASTER
bool "PCM Master"
config BTDM_CTRL_PCM_ROLE_SLAVE
bool "PCM Slave"
endchoice
choice BTDM_CTRL_PCM_POLAR
prompt "PCM Polar"
depends on BTDM_CTRL_PCM_ROLE_EDGE_CONFIG
help
PCM polarity can be configured as Falling Edge or Rising Edge
config BTDM_CTRL_PCM_POLAR_FALLING_EDGE
bool "Falling Edge"
config BTDM_CTRL_PCM_POLAR_RISING_EDGE
bool "Rising Edge"
endchoice
config BTDM_CTRL_PCM_ROLE_EFF
int
default 0 if BTDM_CTRL_PCM_ROLE_MASTER
default 1 if BTDM_CTRL_PCM_ROLE_SLAVE
default 0
config BTDM_CTRL_PCM_POLAR_EFF
int
default 0 if BTDM_CTRL_PCM_POLAR_FALLING_EDGE
default 1 if BTDM_CTRL_PCM_POLAR_RISING_EDGE
default 0
config BTDM_CTRL_AUTO_LATENCY
bool "Auto latency"
depends on BTDM_CTRL_MODE_BTDM
default n
help
BLE auto latency, used to enhance classic BT performance
while classic BT and BLE are enabled at the same time.
config BTDM_CTRL_AUTO_LATENCY_EFF
bool
default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM
default n
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
bool "Legacy Authentication Vendor Specific Event Enable"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
To protect from BIAS attack during Legacy authentication,
Legacy authentication Vendor specific event should be enabled
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
bool
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BLE_MAX_CONN_EFF
int
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF
int
default BTDM_CTRL_BR_EDR_MAX_ACL_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF
int
default BTDM_CTRL_BR_EDR_MAX_SYNC_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
choice BTDM_CTRL_PINNED_TO_CORE_CHOICE
prompt "The cpu core which bluetooth controller run"
depends on BT_CTRL_ESP32 && !FREERTOS_UNICORE
help
Specify the cpu core to run bluetooth controller.
Can not specify no-affinity.
config BTDM_CTRL_PINNED_TO_CORE_0
bool "Core 0 (PRO CPU)"
config BTDM_CTRL_PINNED_TO_CORE_1
bool "Core 1 (APP CPU)"
depends on !FREERTOS_UNICORE
endchoice
config BTDM_CTRL_PINNED_TO_CORE
int
default 0 if BTDM_CTRL_PINNED_TO_CORE_0
default 1 if BTDM_CTRL_PINNED_TO_CORE_1
default 0
choice BTDM_CTRL_HCI_MODE_CHOICE
prompt "HCI mode"
depends on BT_CTRL_ESP32
help
Speicify HCI mode as VHCI or UART(H4)
config BTDM_CTRL_HCI_MODE_VHCI
bool "VHCI"
help
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32, too.
config BTDM_CTRL_HCI_MODE_UART_H4
bool "UART(H4)"
help
If use external bluetooth host which run on other hardware and use UART as the HCI interface,
choose this option.
endchoice
menu "HCI UART(H4) Options"
visible if BTDM_CTRL_HCI_MODE_UART_H4
config BTDM_CTRL_HCI_UART_NO
int "UART Number for HCI"
depends on BTDM_CTRL_HCI_MODE_UART_H4
range 1 2
default 1
help
Uart number for HCI. The available uart is UART1 and UART2.
config BTDM_CTRL_HCI_UART_BAUDRATE
int "UART Baudrate for HCI"
depends on BTDM_CTRL_HCI_MODE_UART_H4
range 115200 921600
default 921600
help
UART Baudrate for HCI. Please use standard baudrate.
endmenu
menu "MODEM SLEEP Options"
visible if BT_CTRL_ESP32
config BTDM_CTRL_MODEM_SLEEP
bool "Bluetooth modem sleep"
depends on BT_CTRL_ESP32
default y
help
Enable/disable bluetooth controller low power mode.
choice BTDM_CTRL_MODEM_SLEEP_MODE
prompt "Bluetooth Modem sleep mode"
depends on BTDM_CTRL_MODEM_SLEEP
help
To select which strategy to use for modem sleep
config BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
bool "ORIG Mode(sleep with low power clock)"
help
ORIG mode is a bluetooth sleep mode that can be used for dual mode controller. In this mode,
bluetooth controller sleeps between BR/EDR frames and BLE events. A low power clock is used to
maintain bluetooth reference clock.
config BTDM_CTRL_MODEM_SLEEP_MODE_EVED
bool "EVED Mode(For internal test only)"
help
EVED mode is for BLE only and is only for internal test. Do not use it for production. this
mode is not compatible with DFS nor light sleep
endchoice
choice BTDM_CTRL_LOW_POWER_CLOCK
prompt "Bluetooth low power clock"
depends on BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
help
Select the low power clock source for bluetooth controller. Bluetooth low power clock is
the clock source to maintain time in sleep mode.
- "Main crystal" option provides good accuracy and can support Dynamic Frequency Scaling
to be used with Bluetooth modem sleep. Light sleep is not supported.
- "External 32kHz crystal" option allows user to use a 32.768kHz crystal as Bluetooth low
power clock. This option is allowed as long as External 32kHz crystal is configured as
the system RTC clock source. This option provides good accuracy and supports Bluetooth
modem sleep to be used alongside Dynamic Frequency Scaling or light sleep.
config BTDM_CTRL_LPCLK_SEL_MAIN_XTAL
bool "Main crystal"
help
Main crystal can be used as low power clock for bluetooth modem sleep. If this option is
selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but
cannot work when light sleep is enabled. Main crystal has a good performance in accuracy as
the bluetooth low power clock source.
config BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
bool "External 32kHz crystal"
depends on ESP32_RTC_CLK_SRC_EXT_CRYS
help
External 32kHz crystal has a nominal frequency of 32.768kHz and provides good frequency
stability. If used as Bluetooth low power clock, External 32kHz can support Bluetooth
modem sleep to be used with both DFS and light sleep.
endchoice
endmenu
choice BTDM_BLE_SLEEP_CLOCK_ACCURACY
prompt "BLE Sleep Clock Accuracy"
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default BTDM_BLE_DEFAULT_SCA_250PPM
help
BLE Sleep Clock Accuracy(SCA) for the local device is used to estimate window widening in BLE
connection events. With a lower level of clock accuracy(e.g. 500ppm over 250ppm), the slave
needs a larger RX window to synchronize with master in each anchor point, thus resulting in an
increase of power consumption but a higher level of robustness in keeping connected. According
to the requirements of Bluetooth Core specification 4.2, the worst-case accuracy of Classic
Bluetooth low power oscialltor(LPO) is +/-250ppm in STANDBY and in low power modes such as
sniff. For BLE the worst-case SCA is +/-500ppm.
- "151ppm to 250ppm" option is the default value for Bluetooth Dual mode
- "251ppm to 500ppm" option can be used in BLE only mode when using external 32kHz crystal as
low power clock. This option is provided in case that BLE sleep clock has a lower level of
accuracy, or other error sources contribute to the inaccurate timing during sleep.
config BTDM_BLE_DEFAULT_SCA_500PPM
bool "251ppm to 500ppm"
depends on BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL && BTDM_CTRL_MODE_BLE_ONLY
config BTDM_BLE_DEFAULT_SCA_250PPM
bool "151ppm to 250ppm"
endchoice
config BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF
int
default 0 if BTDM_BLE_DEFAULT_SCA_500PPM
default 1 if BTDM_BLE_DEFAULT_SCA_250PPM
default 1
config BTDM_BLE_SCAN_DUPL
bool "BLE Scan Duplicate Options"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
default y
help
This select enables parameters setting of BLE scan duplicate.
choice BTDM_SCAN_DUPL_TYPE
prompt "Scan Duplicate Type"
default BTDM_SCAN_DUPL_TYPE_DEVICE
depends on BTDM_BLE_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 BTDM_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 BTDM_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 BTDM_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 BTDM_SCAN_DUPL_TYPE
int
depends on BTDM_BLE_SCAN_DUPL
default 0 if BTDM_SCAN_DUPL_TYPE_DEVICE
default 1 if BTDM_SCAN_DUPL_TYPE_DATA
default 2 if BTDM_SCAN_DUPL_TYPE_DATA_DEVICE
default 0
config BTDM_SCAN_DUPL_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BTDM_BLE_SCAN_DUPL
range 10 1000
default 200
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BTDM_BLE_MESH_SCAN_DUPL_EN
bool "Special duplicate scan mechanism for BLE Mesh scan"
depends on BTDM_BLE_SCAN_DUPL
default n
help
This enables the BLE scan duplicate for special BLE Mesh scan.
config BTDM_MESH_DUPL_SCAN_CACHE_SIZE
int "Maximum number of Mesh adv packets in scan duplicate filter"
depends on BTDM_BLE_MESH_SCAN_DUPL_EN
range 10 1000
default 200
help
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BTDM_CTRL_FULL_SCAN_SUPPORTED
bool "BLE full scan feature supported"
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default y
help
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_BLE_ADV_REPORT_FLOW_CTRL_SUPP
bool "BLE adv report flow control supported"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
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 BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM
int "BLE adv report flow control number"
depends on BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
range 50 1000
default 100
help
The number of unprocessed advertising report that Bluedroid can save.If you set
`BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a small value, this may cause adv packets lost.
If you set `BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM` to a large value, Bluedroid 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
`BTDM_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 BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD
int "BLE adv lost event threshold value"
depends on BTDM_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 `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
may cause adv packets lost more.
menuconfig BTDM_COEX_BT_OPTIONS
bool "Coexistence Bluetooth Side Options"
depends on ESP32_WIFI_SW_COEXIST_ENABLE
default n
help
Options of Bluetooth Side of WiFi and bluetooth coexistence.
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
depends on BTDM_COEX_BT_OPTIONS
default n
help
Improve BLE ADV coexistence priority to make it better performance.
For example, BLE mesh need to enable this option to improve BLE adv performance.

View File

@ -392,10 +392,10 @@ static DRAM_ATTR portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
static DRAM_ATTR uint32_t btdm_lpcycle_us = 0; static DRAM_ATTR uint32_t btdm_lpcycle_us = 0;
static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit for btdm_lpcycle_us static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit for btdm_lpcycle_us
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG #if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
// used low power clock // used low power clock
static DRAM_ATTR uint8_t btdm_lpclk_sel; static DRAM_ATTR uint8_t btdm_lpclk_sel;
#endif /* #ifdef CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG */ #endif /* #ifdef CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG */
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL; static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
#ifdef CONFIG_PM_ENABLE #ifdef CONFIG_PM_ENABLE
@ -1293,10 +1293,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT; btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac); btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG #if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#if CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL #if CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
// check whether or not EXT_CRYS is working // check whether or not EXT_CRYS is working
if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) { if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) {
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value
@ -1330,7 +1330,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
} }
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG); btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED #elif CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED); btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else #else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE); btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);

View File

@ -0,0 +1,331 @@
config BT_CTRL_MODE_EFF
int
default 1
config BT_CTRL_BLE_MAX_ACT
int "BLE Max Instances"
default 10
range 1 10
help
BLE maximum instances of bluetooth controller.
config BT_CTRL_BLE_MAX_ACT_EFF
int
default BT_CTRL_BLE_MAX_ACT
default 0
config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
int "BLE static ACL TX buffer numbers"
range 0 12
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)
another is dynamically allocating (allocate before TX and free after TX).
config BT_CTRL_PINNED_TO_CORE
int
default 0
choice BT_CTRL_HCI_MODE_CHOICE
prompt "HCI mode"
help
Specify HCI mode as VHCI or UART(H4)
config BT_CTRL_HCI_MODE_VHCI
bool "VHCI"
help
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32C3, too.
config BT_CTRL_HCI_MODE_UART_H4
bool "UART(H4)"
help
If use external bluetooth host which run on other hardware and use UART as the HCI interface,
choose this option.
endchoice
config BT_CTRL_HCI_TL
int
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1
help
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"
range 1 500
default 30
help
The maxinum number of suplicate scan filter
config BT_CTRL_HW_CCA
bool "HW CCA check enable"
default n
help
It enables HW CCA feature in controller
config BT_CTRL_HW_CCA_EFF
int
default 1 if BT_CTRL_HW_CCA
default 0
help
If other devices are sending packets in the air and the signal is strong,
the packet hw to be sent this time is cancelled.
config BT_CTRL_COEX_PARAMETERS_ENABLE
bool "Allow Bluetooth preemption in the use of RF to support coexistence with Wi-Fi"
default n
help
Use pre-determined parameter set to control the use of RF by Bluetooth,
so that Bluetooth can compete for RF with Wi-fi to support coexistence.
choice BT_CTRL_CE_LENGTH_TYPE
prompt "Connection event length determination method"
help
Specify connection event length determination
config BT_CTRL_CE_LENGTH_TYPE_ORIG
bool "ORIGINAL"
config BT_CTRL_CE_LENGTH_TYPE_CE
bool "Use CE parameter for HCI command"
config BT_CTRL_CE_LENGTH_TYPE_SD
bool "Use Espressif self-defined method"
endchoice
config BT_CTRL_CE_LENGTH_TYPE_EFF
int
default 0 if BT_CTRL_CE_LENGTH_TYPE_ORIG
default 1 if BT_CTRL_CE_LENGTH_TYPE_CE
default 2 if BT_CTRL_CE_LENGTH_TYPE_SD
choice BT_CTRL_TX_ANTENNA_INDEX
prompt "default Tx anntena used"
help
Specify default Tx antenna used for bluetooth
config BT_CTRL_TX_ANTENNA_INDEX_0
bool "Antenna 0"
config BT_CTRL_TX_ANTENNA_INDEX_1
bool "Antenna 1"
endchoice
config BT_CTRL_TX_ANTENNA_INDEX_EFF
int
default 0 if BT_CTRL_TX_ANTENNA_INDEX_0
default 1 if BT_CTRL_TX_ANTENNA_INDEX_1
choice BT_CTRL_RX_ANTENNA_INDEX
prompt "default Rx anntena used"
help
Specify default Rx antenna used for bluetooth
config BT_CTRL_RX_ANTENNA_INDEX_0
bool "Antenna 0"
config BT_CTRL_RX_ANTENNA_INDEX_1
bool "Antenna 1"
endchoice
config BT_CTRL_RX_ANTENNA_INDEX_EFF
int
default 0 if BT_CTRL_RX_ANTENNA_INDEX_0
default 1 if BT_CTRL_RX_ANTENNA_INDEX_1
choice BT_CTRL_DFT_TX_POWER_LEVEL
prompt "BLE default Tx power level"
default BT_CTRL_DFT_TX_POWER_LEVEL_P9
help
Specify default Tx power level
config BT_CTRL_DFT_TX_POWER_LEVEL_N12
bool "-12dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N9
bool "-9dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N6
bool "-6dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N3
bool "-3dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N0
bool "0dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P3
bool "+3dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P6
bool "+6dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P9
bool "+9dBm"
endchoice
config BT_CTRL_DFT_TX_POWER_LEVEL_EFF
int
default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N12
default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N9
default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N6
default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N3
default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N0
default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_P3
default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_P6
default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_P9
default 0
config BT_CTRL_COEX_USE_HOOKS
bool "Communicate Bluetooth working status with Wi-Fi to support coexistence"
default n
help
Send notifications of Bluetooth working status to support coexistence with Wi-Fi.
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_CTRL_BLE_SCAN_DUPL
bool "BLE Scan Duplicate Options"
default y
help
This select enables parameters setting of BLE scan duplicate.
choice BT_CTRL_SCAN_DUPL_TYPE
prompt "Scan Duplicate Type"
default BT_CTRL_SCAN_DUPL_TYPE_DEVICE
depends on BT_CTRL_BLE_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_CTRL_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_CTRL_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_CTRL_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_CTRL_SCAN_DUPL_TYPE
int
depends on BT_CTRL_BLE_SCAN_DUPL
default 0 if BT_CTRL_SCAN_DUPL_TYPE_DEVICE
default 1 if BT_CTRL_SCAN_DUPL_TYPE_DATA
default 2 if BT_CTRL_SCAN_DUPL_TYPE_DATA_DEVICE
default 0
config BT_CTRL_SCAN_DUPL_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BT_CTRL_BLE_SCAN_DUPL
range 10 1000
default 100
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BT_CTRL_BLE_MESH_SCAN_DUPL_EN
bool "Special duplicate scan mechanism for BLE Mesh scan"
depends on BT_CTRL_BLE_SCAN_DUPL
default n
help
This enables the BLE scan duplicate for special BLE Mesh scan.
config BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
int "Maximum number of Mesh adv packets in scan duplicate filter"
depends on BT_CTRL_BLE_MESH_SCAN_DUPL_EN
range 10 1000
default 100
help
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
menu "MODEM SLEEP Options"
visible if BT_ENABLED
config BT_CTRL_MODEM_SLEEP
bool "Bluetooth modem sleep"
depends on !BT_CTRL_HCI_MODE_UART_H4
default n
help
Enable/disable bluetooth controller low power mode.
Modem sleep is not supported to be used with UART HCI.
config BT_CTRL_MODEM_SLEEP_MODE_1
bool "Bluetooth Modem sleep Mode 1"
depends on BT_CTRL_MODEM_SLEEP
default y
help
Mode 1 is the currently supported sleep mode. In this mode,
bluetooth controller sleeps between and BLE events. A low
power clock is used to maintain bluetooth reference clock.
choice BT_CTRL_LOW_POWER_CLOCK
prompt "Bluetooth low power clock"
depends on BT_CTRL_MODEM_SLEEP_MODE_1
help
Select the low power clock source for bluetooth controller
config BT_CTRL_LPCLK_SEL_MAIN_XTAL
bool "Main crystal"
help
Main crystal can be used as low power clock for bluetooth modem sleep. If this option is
selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but
cannot work when light sleep is enabled. Main crystal has a relatively better performance than
other bluetooth low power clock sources.
endchoice
endmenu
config BT_CTRL_SLEEP_MODE_EFF
int
default 1 if BT_CTRL_MODEM_SLEEP_MODE_1
default 0
config BT_CTRL_SLEEP_CLOCK_EFF
int
default 1 if BT_CTRL_LPCLK_SEL_MAIN_XTAL
default 0
config BT_CTRL_HCI_TL_EFF
int
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,239 @@
config BT_CTRL_MODE_EFF
int
default 1
config BT_CTRL_BLE_MAX_ACT
int "BLE Max Instances"
default 10
range 1 10
help
BLE maximum instances of bluetooth controller.
config BT_CTRL_BLE_MAX_ACT_EFF
int
default BT_CTRL_BLE_MAX_ACT
default 0
config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
int "BLE static ACL TX buffer numbers"
range 0 12
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)
another is dynamically allocating (allocate before TX and free after TX).
choice BT_CTRL_PINNED_TO_CORE_CHOICE
prompt "The cpu core which bluetooth controller run"
depends on !FREERTOS_UNICORE
help
Specify the cpu core to run bluetooth controller.
Can not specify no-affinity.
config BT_CTRL_PINNED_TO_CORE_0
bool "Core 0 (PRO CPU)"
config BT_CTRL_PINNED_TO_CORE_1
bool "Core 1 (APP CPU)"
depends on !FREERTOS_UNICORE
endchoice
config BT_CTRL_PINNED_TO_CORE
int
default 0 if BT_CTRL_PINNED_TO_CORE_0
default 1 if BT_CTRL_PINNED_TO_CORE_1
default 0
choice BT_CTRL_HCI_MODE_CHOICE
prompt "HCI mode"
help
Specify HCI mode as VHCI or UART(H4)
config BT_CTRL_HCI_MODE_VHCI
bool "VHCI"
help
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32S3, too.
config BT_CTRL_HCI_MODE_UART_H4
bool "UART(H4)"
help
If use external bluetooth host which run on other hardware and use UART as the HCI interface,
choose this option.
endchoice
config BT_CTRL_HCI_TL
int
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1
config BT_CTRL_ADV_DUP_FILT_MAX
int "The maxinum number of 5.0 extend duplicate scan filter"
range 1 500
default 30
help
The maxinum number of suplicate scan filter
config BT_CTRL_HW_CCA
bool "HW CCA check enable"
default y
help
It enables HW CCA feature in controller
config BT_CTRL_HW_CCA_EFF
int
default 1 if BT_CTRL_HW_CCA
default 0
config BT_CTRL_COEX_PARAMETERS_ENABLE
bool "Allow Bluetooth preemption in the use of RF to support coexistence with Wi-Fi"
default n
help
Use pre-determined parameter set to control the use of RF by Bluetooth,s
so that Bluetooth can compete for RF with Wi-fi to support coexistence.
choice BT_CTRL_CE_LENGTH_TYPE
prompt "Connection event length determination method"
help
Specify connection event length determination
config BT_CTRL_CE_LENGTH_TYPE_ORIG
bool "ORIGINAL"
config BT_CTRL_CE_LENGTH_TYPE_CE
bool "Use CE parameter for HCI command"
config BT_CTRL_CE_LENGTH_TYPE_SD
bool "Use Espressif self-defined method"
endchoice
config BT_CTRL_CE_LENGTH_TYPE_EFF
int
default 0 if BT_CTRL_CE_LENGTH_TYPE_ORIG
default 1 if BT_CTRL_CE_LENGTH_TYPE_CE
default 2 if BT_CTRL_CE_LENGTH_TYPE_SD
choice BT_CTRL_TX_ANTENNA_INDEX
prompt "default Tx anntena used"
help
Specify default Tx antenna used for bluetooth
config BT_CTRL_TX_ANTENNA_INDEX_0
bool "Antenna 0"
config BT_CTRL_TX_ANTENNA_INDEX_1
bool "Antenna 1"
endchoice
config BT_CTRL_TX_ANTENNA_INDEX_EFF
int
default 0 if BT_CTRL_TX_ANTENNA_INDEX_0
default 1 if BT_CTRL_TX_ANTENNA_INDEX_1
choice BT_CTRL_RX_ANTENNA_INDEX
prompt "default Rx anntena used"
help
Specify default Rx antenna used for bluetooth
config BT_CTRL_RX_ANTENNA_INDEX_0
bool "Antenna 0"
config BT_CTRL_RX_ANTENNA_INDEX_1
bool "Antenna 1"
endchoice
config BT_CTRL_RX_ANTENNA_INDEX_EFF
int
default 0 if BT_CTRL_RX_ANTENNA_INDEX_0
default 1 if BT_CTRL_RX_ANTENNA_INDEX_1
choice BT_CTRL_DFT_TX_POWER_LEVEL
prompt "BLE default Tx power level"
default BT_CTRL_DFT_TX_POWER_LEVEL_P9
help
Specify default Tx power level
config BT_CTRL_DFT_TX_POWER_LEVEL_N12
bool "-12dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N9
bool "-9dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N6
bool "-6dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N3
bool "-3dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_N0
bool "0dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P3
bool "+3dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P6
bool "+6dBm"
config BT_CTRL_DFT_TX_POWER_LEVEL_P9
bool "+9dBm"
endchoice
config BT_CTRL_DFT_TX_POWER_LEVEL_EFF
int
default 0 if BT_CTRL_DFT_TX_POWER_LEVEL_N12
default 1 if BT_CTRL_DFT_TX_POWER_LEVEL_N9
default 2 if BT_CTRL_DFT_TX_POWER_LEVEL_N6
default 3 if BT_CTRL_DFT_TX_POWER_LEVEL_N3
default 4 if BT_CTRL_DFT_TX_POWER_LEVEL_N0
default 5 if BT_CTRL_DFT_TX_POWER_LEVEL_P3
default 6 if BT_CTRL_DFT_TX_POWER_LEVEL_P6
default 7 if BT_CTRL_DFT_TX_POWER_LEVEL_P9
default 0
config BT_CTRL_COEX_USE_HOOKS
bool "Communicate Bluetooth working status with Wi-Fi to support coexistence"
default n
help
Send notifications of Bluetooth working status to support coexistence with Wi-Fi.
menu "MODEM SLEEP Options"
visible if BT_ENABLED
config BT_CTRL_MODEM_SLEEP
bool "Bluetooth modem sleep"
depends on !BT_CTRL_HCI_MODE_UART_H4
default n
help
Enable/disable bluetooth controller low power mode.
Modem sleep is not supported to be used with UART HCI.
config BT_CTRL_MODEM_SLEEP_MODE_1
bool "Bluetooth Modem sleep Mode 1"
depends on BT_CTRL_MODEM_SLEEP
default y
help
Mode 1 is the currently supported sleep mode. In this mode,
bluetooth controller sleeps between and BLE events. A low
power clock is used to maintain bluetooth reference clock.
choice BT_CTRL_LOW_POWER_CLOCK
prompt "Bluetooth low power clock"
depends on BT_CTRL_MODEM_SLEEP_MODE_1
help
Select the low power clock source for bluetooth controller
config BT_CTRL_LPCLK_SEL_MAIN_XTAL
bool "Main crystal"
help
Main crystal can be used as low power clock for bluetooth modem sleep. If this option is
selected, bluetooth modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but
cannot work when light sleep is enabled. Main crystal has a relatively better performance than
other bluetooth low power clock sources.
endchoice
endmenu
config BT_CTRL_SLEEP_MODE_EFF
int
default 1 if BT_CTRL_MODEM_SLEEP_MODE_1
default 0
config BT_CTRL_SLEEP_CLOCK_EFF
int
default 1 if BT_CTRL_LPCLK_SEL_MAIN_XTAL
default 0
config BT_CTRL_HCI_TL_EFF
int
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 0fd5fffa0872d6860000b10c067990b5b17d5712 Subproject commit 006f49fde59374b54cb23e066c5ec8f10da28da1

View File

@ -1207,7 +1207,7 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64); BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64);
BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val, BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE); bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE, FALSE);
return 0; return 0;
} }

View File

@ -42,7 +42,7 @@ config BT_BLUEDROID_MEM_DEBUG
config BT_CLASSIC_ENABLED config BT_CLASSIC_ENABLED
bool "Classic Bluetooth" bool "Classic Bluetooth"
depends on BT_BLUEDROID_ENABLED depends on BT_BLUEDROID_ENABLED && BT_CTRL_ESP32
default n default n
help help
For now this option needs "SMP_ENABLE" to be set to yes For now this option needs "SMP_ENABLE" to be set to yes
@ -1002,6 +1002,27 @@ config BT_BLE_ESTAB_LINK_CONN_TOUT
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered. establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
config BT_BLE_RPA_SUPPORTED
bool "Update RPA to Controller"
depends on (BT_BLUEDROID_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3))
default y
help
This enables controller RPA list function.
config BT_BLE_50_FEATURES_SUPPORTED
bool "Enable BLE 5.0 features"
depends on (BT_BLUEDROID_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3))
default y
help
This enables BLE 5.0 features, this option only support esp32c3/esp32s3 chip
config BT_BLE_42_FEATURES_SUPPORTED
bool "Enable BLE 4.2 features"
depends on (BT_BLUEDROID_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3))
default n
help
This enables BLE 4.2 features.
config BT_RESERVE_DRAM config BT_RESERVE_DRAM
hex hex
default 0xdb5c if BT_ENABLED default 0xdb5c if BT_ENABLED

View File

@ -30,7 +30,7 @@ esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL); return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL);
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data) esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
{ {
btc_msg_t msg; btc_msg_t msg;
@ -130,7 +130,7 @@ esp_err_t esp_ble_gap_stop_advertising(void)
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params) esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
{ {
@ -333,7 +333,7 @@ esp_err_t esp_ble_gap_get_whitelist_size(uint16_t *length)
return ESP_OK; return ESP_OK;
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr, esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
uint16_t min_conn_int, uint16_t max_conn_int, uint16_t min_conn_int, uint16_t max_conn_int,
uint16_t slave_latency, uint16_t supervision_tout) uint16_t slave_latency, uint16_t supervision_tout)
@ -368,6 +368,7 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
return ESP_FAIL; return ESP_FAIL;
} }
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_set_device_name(const char *name) esp_err_t esp_ble_gap_set_device_name(const char *name)
{ {
@ -403,7 +404,7 @@ uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *len
return (BTM_CheckAdvData( adv_data, type, length)); return (BTM_CheckAdvData( adv_data, type, length));
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len) esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{ {
btc_msg_t msg; btc_msg_t msg;
@ -425,7 +426,7 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr) esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
{ {
btc_msg_t msg; btc_msg_t msg;
@ -442,7 +443,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len) esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{ {
btc_msg_t msg; btc_msg_t msg;
@ -531,7 +532,7 @@ esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_e
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if (SMP_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE)
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type, esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
void *value, uint8_t len) void *value, uint8_t len)
@ -760,3 +761,495 @@ esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize)
} }
return ESP_FAIL; return ESP_FAIL;
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_read_phy(esp_bd_addr_t bd_addr)
{
btc_msg_t msg;
btc_ble_5_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_READ_PHY;
memcpy(arg.read_phy.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_prefered_default_phy(esp_ble_gap_phy_mask_t tx_phy_mask,
esp_ble_gap_phy_mask_t rx_phy_mask)
{
btc_msg_t msg;
btc_ble_5_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_PREFERED_DEF_PHY;
arg.set_perf_def_phy.tx_phy_mask = tx_phy_mask;
arg.set_perf_def_phy.rx_phy_mask = rx_phy_mask;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_prefered_phy(esp_bd_addr_t bd_addr,
esp_ble_gap_all_phys_t all_phys_mask,
esp_ble_gap_phy_mask_t tx_phy_mask,
esp_ble_gap_phy_mask_t rx_phy_mask,
esp_ble_gap_prefer_phy_options_t phy_options)
{
btc_msg_t msg;
btc_ble_5_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_DEF_PHY;
memcpy(arg.set_def_phy.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
arg.set_def_phy.all_phys_mask = all_phys_mask;
arg.set_def_phy.tx_phy_mask = tx_phy_mask;
arg.set_def_phy.rx_phy_mask = rx_phy_mask;
arg.set_def_phy.phy_options = phy_options;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_ext_adv_set_rand_addr(uint8_t instance, esp_bd_addr_t rand_addr)
{
btc_msg_t msg;
btc_ble_5_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_EXT_ADV_RAND_ADDR;
arg.ext_adv_set_rand_addr.instance = instance;
memcpy(arg.ext_adv_set_rand_addr.rand_addr, rand_addr, BD_ADDR_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_ext_adv_set_params(uint8_t instance,
const esp_ble_gap_ext_adv_params_t *params)
{
btc_msg_t msg;
btc_ble_5_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_EXT_ADV_PARAMS;
arg.ext_adv_set_params.instance = instance;
memcpy(&arg.ext_adv_set_params.params, params, sizeof(esp_ble_gap_ext_adv_params_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_config_ext_adv_data_raw(uint8_t instance, uint16_t length,
const uint8_t *data)
{
btc_msg_t msg;
btc_ble_5_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_CFG_EXT_ADV_DATA_RAW;
arg.ext_adv_cfg_data.instance = instance;
arg.ext_adv_cfg_data.length = length;
arg.ext_adv_cfg_data.data = (uint8_t *)data;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), btc_gap_ble_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_config_ext_scan_rsp_data_raw(uint8_t instance, uint16_t length,
const uint8_t *scan_rsp_data)
{
btc_msg_t msg;
btc_ble_5_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_CFG_EXT_SCAN_RSP_DATA_RAW;
arg.cfg_scan_rsp.instance = instance;
arg.cfg_scan_rsp.length = length;
arg.cfg_scan_rsp.data = (uint8_t *)scan_rsp_data;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), btc_gap_ble_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_ext_adv_start(uint8_t num_adv, const esp_ble_gap_ext_adv_t *ext_adv)
{
btc_msg_t msg;
btc_ble_5_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_EXT_ADV_START;
arg.ext_adv_start.num_adv = num_adv;
arg.ext_adv_start.ext_adv = (esp_ble_gap_ext_adv_t *)ext_adv;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), btc_gap_ble_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_ext_adv_stop(uint8_t num_adv, const uint8_t *ext_adv_inst)
{
btc_msg_t msg;
btc_ble_5_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_EXT_ADV_STOP;
arg.ext_adv_stop.num_adv = num_adv;
arg.ext_adv_stop.ext_adv_inst = (uint8_t *)ext_adv_inst;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), btc_gap_ble_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_ext_adv_set_remove(uint8_t instance)
{
btc_msg_t msg;
btc_ble_5_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_EXT_ADV_SET_REMOVE;
arg.ext_adv_set_remove.instance = instance;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_ext_adv_set_clear(void)
{
btc_msg_t msg;
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_EXT_ADV_SET_CLEAR;
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_gap_periodic_adv_params_t *params)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_ADV_PARAMS;
arg.peridic_adv_set_params.instance = instance;
memcpy(&arg.peridic_adv_set_params.params, params, sizeof(esp_ble_gap_periodic_adv_params_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_config_periodic_adv_data_raw(uint8_t instance, uint16_t length,
const uint8_t *data)
{
btc_msg_t msg;
btc_ble_5_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_CFG_PERIODIC_ADV_DATA_RAW;
arg.periodic_adv_cfg_data.instance = instance;
arg.periodic_adv_cfg_data.len = length;
arg.periodic_adv_cfg_data.data = (uint8_t *)data;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), btc_gap_ble_arg_deep_copy)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_start(uint8_t instance)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_ADV_START;
arg.periodic_adv_start.instance = instance;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_stop(uint8_t instance)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_ADV_STOP;
arg.periodic_adv_stop.instance = instance;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_create_sync(const esp_ble_gap_periodic_adv_sync_params_t *params)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_ADV_CREATE_SYNC;
memcpy(&arg.periodic_adv_create_sync.params, params, sizeof(esp_ble_gap_periodic_adv_sync_params_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_sync_cancel(void)
{
btc_msg_t msg;
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_PERIODIC_ADV_SYNC_CANCEL;
return (btc_transfer_context(&msg, NULL, 0, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_sync_terminate(uint16_t sync_handle)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_ADV_SYNC_TERMINATE;
arg.periodic_adv_sync_term.sync_handle = sync_handle;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_add_dev_to_list(esp_ble_addr_type_t addr_type,
esp_bd_addr_t addr,
uint8_t sid)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_ADV_ADD_DEV_TO_LIST;
arg.periodic_adv_add_dev.addr_type = addr_type;
arg.periodic_adv_add_dev.sid = sid;
memcpy(arg.periodic_adv_add_dev.addr, addr, sizeof(esp_bd_addr_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_remove_dev_from_list(esp_ble_addr_type_t addr_type,
esp_bd_addr_t addr,
uint8_t sid)
{
btc_msg_t msg;
btc_ble_5_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_PERIODIC_REMOVE_ADD_DEV_FROM_LIST;
arg.periodic_adv_remove_dev.addr_type = addr_type;
arg.periodic_adv_remove_dev.sid = sid;
memcpy(arg.periodic_adv_remove_dev.addr, addr, sizeof(esp_bd_addr_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_periodic_adv_clear_dev(void)
{
btc_msg_t msg;
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_PERIODIC_CLEAR_DEV;
return (btc_transfer_context(&msg, NULL, 0, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_ext_scan_params(const esp_ble_ext_scan_params_t *params)
{
btc_msg_t msg;
btc_ble_5_gap_args_t arg;
if (!params) {
return ESP_ERR_INVALID_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_EXT_SCAN_PARAMS;
memcpy(&arg.set_ext_scan_params.params, params, sizeof(esp_ble_ext_scan_params_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_start_ext_scan(uint32_t duration, uint16_t period)
{
btc_msg_t msg;
btc_ble_5_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_START_EXT_SCAN;
arg.start_ext_scan.duration = duration;
arg.start_ext_scan.period = period;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_stop_ext_scan(void)
{
btc_msg_t msg;
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_STOP_EXT_SCAN;
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
esp_ble_gap_phy_mask_t phy_mask,
const esp_ble_gap_conn_params_t *phy_1m_conn_params,
const esp_ble_gap_conn_params_t *phy_2m_conn_params,
const esp_ble_gap_conn_params_t *phy_coded_conn_params)
{
btc_msg_t msg;
btc_ble_5_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_EXT_PEFER_CONNET_PARAMS;
arg.set_ext_conn_params.phy_mask = phy_mask;
if (phy_mask & ESP_BLE_GAP_PHY_1M_PREF_MASK) {
if (!phy_1m_conn_params) {
return BT_STATUS_PARM_INVALID;
}
memcpy(&arg.set_ext_conn_params.phy_1m_conn_params,
phy_1m_conn_params, sizeof(esp_ble_gap_conn_params_t));
}
if (phy_mask & ESP_BLE_GAP_PHY_2M_PREF_MASK) {
if (!phy_2m_conn_params) {
return BT_STATUS_PARM_INVALID;
}
memcpy(&arg.set_ext_conn_params.phy_2m_conn_params,
phy_2m_conn_params, sizeof(esp_ble_gap_conn_params_t));
}
if (phy_mask & ESP_BLE_GAP_PHY_CODED_PREF_MASK) {
if (!phy_coded_conn_params) {
return BT_STATUS_PARM_INVALID;
}
memcpy(&arg.set_ext_conn_params.phy_coded_conn_params,
phy_coded_conn_params, sizeof(esp_ble_gap_conn_params_t));
}
memcpy(arg.set_ext_conn_params.addr, addr, sizeof(esp_bd_addr_t));
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)

View File

@ -21,6 +21,7 @@
#include "btc_gatt_util.h" #include "btc_gatt_util.h"
#include "stack/l2cdefs.h" #include "stack/l2cdefs.h"
#include "stack/l2c_api.h" #include "stack/l2c_api.h"
#include "gatt_int.h"
#if (GATTC_INCLUDED == TRUE) #if (GATTC_INCLUDED == TRUE)
@ -69,7 +70,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct) esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
{ {
btc_msg_t msg; btc_msg_t msg;
@ -84,9 +85,33 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, e
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN); memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
arg.open.remote_addr_type = remote_addr_type; arg.open.remote_addr_type = remote_addr_type;
arg.open.is_direct = is_direct; arg.open.is_direct = is_direct;
arg.open.is_aux = false;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
{
btc_msg_t msg;
btc_ble_gattc_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GATTC;
msg.act = BTC_GATTC_ACT_AUX_OPEN;
arg.open.gattc_if = gattc_if;
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
arg.open.remote_addr_type = remote_addr_type;
arg.open.is_direct = is_direct;
arg.open.is_aux = true;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id) esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id)
{ {
@ -334,8 +359,13 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
btc_ble_gattc_args_t arg; btc_ble_gattc_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -366,7 +396,13 @@ esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if,
return ESP_GATT_ILLEGAL_PARAMETER; return ESP_GATT_ILLEGAL_PARAMETER;
} }
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -392,7 +428,13 @@ esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -423,7 +465,13 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -450,7 +498,13 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -482,7 +536,13 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -514,7 +574,13 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }
@ -544,7 +610,13 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }

View File

@ -22,6 +22,7 @@
#include "common/bt_target.h" #include "common/bt_target.h"
#include "stack/l2cdefs.h" #include "stack/l2cdefs.h"
#include "stack/l2c_api.h" #include "stack/l2c_api.h"
#include "gatt_int.h"
#if (GATTS_INCLUDED == TRUE) #if (GATTS_INCLUDED == TRUE)
#define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type)) #define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type))
@ -260,7 +261,13 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) { tGATT_TCB *p_tcb = gatt_get_tcb_by_idx(conn_id);
if (!p_tcb) {
LOG_WARN("%s, The connection not created.", __func__);
return ESP_ERR_INVALID_STATE;
}
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, p_tcb->peer_bda)) {
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__); LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL; return ESP_FAIL;
} }

View File

@ -306,7 +306,7 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id);
*/ */
esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if); esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
#if (BLE_42_FEATURE_SUPPORT == TRUE)
/** /**
* @brief Open a direct connection or add a background auto connection * @brief Open a direct connection or add a background auto connection
* *
@ -321,8 +321,11 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
* *
*/ */
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct); esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct);
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gattc_aux_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/** /**
* @brief Close the virtual connection to the GATT server. gattc may have multiple virtual GATT server connections when multiple app_id registered, * @brief Close the virtual connection to the GATT server. gattc may have multiple virtual GATT server connections when multiple app_id registered,
* this API only close one virtual GATT server connection. if there exist other virtual GATT server connections, * this API only close one virtual GATT server connection. if there exist other virtual GATT server connections,

View File

@ -77,8 +77,9 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
#if (BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE) #if (BT_SSP_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data); static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
#endif /* (BT_SSP_INCLUDED == TRUE) */ #endif /* (BT_SSP_INCLUDED == TRUE) */
#if (CLASSIC_BT_INCLUDED == TRUE)
static void bta_dm_set_eir (char *local_name); static void bta_dm_set_eir (char *local_name);
#endif
#if (SDP_INCLUDED == TRUE) #if (SDP_INCLUDED == TRUE)
static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result, static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result,
tBTA_SERVICE_MASK *p_services_to_search, tBTA_SERVICE_MASK *p_services_to_search,
@ -477,9 +478,10 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb)); memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb));
memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs)); memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs));
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB)); memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class)); memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class));
#if CLASSIC_BT_INCLUDED
BTM_SetDeviceClass (dev_class); BTM_SetDeviceClass (dev_class);
#endif
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE) #if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE && GATTC_CACHE_NVS == TRUE) #if (GATTC_INCLUDED == TRUE && GATTC_CACHE_NVS == TRUE)
@ -503,9 +505,11 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
BTM_SecRegister((tBTM_APPL_INFO *)&bta_security); BTM_SecRegister((tBTM_APPL_INFO *)&bta_security);
#endif ///SMP_INCLUDED == TRUE #endif ///SMP_INCLUDED == TRUE
BTM_SetDefaultLinkSuperTout(p_bta_dm_cfg->link_timeout); BTM_SetDefaultLinkSuperTout(p_bta_dm_cfg->link_timeout);
#if CLASSIC_BT_INCLUDED
BTM_WritePageTimeout(p_bta_dm_cfg->page_timeout); BTM_WritePageTimeout(p_bta_dm_cfg->page_timeout);
bta_dm_cb.cur_policy = p_bta_dm_cfg->policy_settings; bta_dm_cb.cur_policy = p_bta_dm_cfg->policy_settings;
BTM_SetDefaultLinkPolicy(bta_dm_cb.cur_policy); BTM_SetDefaultLinkPolicy(bta_dm_cb.cur_policy);
#endif
BTM_RegBusyLevelNotif (bta_dm_bl_change_cback, NULL, BTM_BL_UPDATE_MASK | BTM_BL_ROLE_CHG_MASK); BTM_RegBusyLevelNotif (bta_dm_bl_change_cback, NULL, BTM_BL_UPDATE_MASK | BTM_BL_ROLE_CHG_MASK);
#if BLE_VND_INCLUDED == TRUE #if BLE_VND_INCLUDED == TRUE
@ -559,9 +563,10 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
/* disable all active subsystems */ /* disable all active subsystems */
bta_sys_disable(BTA_SYS_HW_BLUETOOTH); bta_sys_disable(BTA_SYS_HW_BLUETOOTH);
#if CLASSIC_BT_INCLUDED
BTM_SetDiscoverability(BTM_NON_DISCOVERABLE, 0, 0); BTM_SetDiscoverability(BTM_NON_DISCOVERABLE, 0, 0);
BTM_SetConnectability(BTM_NON_CONNECTABLE, 0, 0); BTM_SetConnectability(BTM_NON_CONNECTABLE, 0, 0);
#endif // #if CLASSIC_BT_INCLUDED
#if (BTA_DM_PM_INCLUDED == TRUE) #if (BTA_DM_PM_INCLUDED == TRUE)
bta_dm_disable_pm(); bta_dm_disable_pm();
@ -754,6 +759,7 @@ void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data)
} }
#endif ///SDP_INCLUDED == TRUE #endif ///SDP_INCLUDED == TRUE
#if (CLASSIC_BT_INCLUDED == TRUE)
void bta_dm_config_eir (tBTA_DM_MSG *p_data) void bta_dm_config_eir (tBTA_DM_MSG *p_data)
{ {
tBTA_DM_API_CONFIG_EIR *config_eir = &p_data->config_eir; tBTA_DM_API_CONFIG_EIR *config_eir = &p_data->config_eir;
@ -795,7 +801,7 @@ void bta_dm_config_eir (tBTA_DM_MSG *p_data)
bta_dm_set_eir(NULL); bta_dm_set_eir(NULL);
} }
#endif
/******************************************************************************* /*******************************************************************************
** **
** Function bta_dm_ble_set_channels ** Function bta_dm_ble_set_channels
@ -3911,6 +3917,7 @@ static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result)
** Returns None ** Returns None
** **
*******************************************************************************/ *******************************************************************************/
#if (CLASSIC_BT_INCLUDED == TRUE)
static void bta_dm_set_eir (char *local_name) static void bta_dm_set_eir (char *local_name)
{ {
BT_HDR *p_buf; BT_HDR *p_buf;
@ -4232,6 +4239,7 @@ static void bta_dm_set_eir (char *local_name)
p_bta_dm_eir_cfg->config_eir_callback(status, eir_type_num, eir_type); p_bta_dm_eir_cfg->config_eir_callback(status, eir_type_num, eir_type);
} }
} }
#endif
/******************************************************************************* /*******************************************************************************
** **
@ -4329,8 +4337,9 @@ void bta_dm_eir_update_uuid(UINT16 uuid16, BOOLEAN adding)
BTM_RemoveEirService( bta_dm_cb.eir_uuid, uuid16 ); BTM_RemoveEirService( bta_dm_cb.eir_uuid, uuid16 );
} }
#if CLASSIC_BT_INCLUDED
bta_dm_set_eir (NULL); bta_dm_set_eir (NULL);
#endif
APPL_TRACE_EVENT("bta_dm_eir_update_uuid UUID bit mask=0x%08X %08X", APPL_TRACE_EVENT("bta_dm_eir_update_uuid UUID bit mask=0x%08X %08X",
bta_dm_cb.eir_uuid[1], bta_dm_cb.eir_uuid[0] ); bta_dm_cb.eir_uuid[1], bta_dm_cb.eir_uuid[0] );
@ -5501,7 +5510,186 @@ void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data)
p_data->ble_multi_adv_disable.inst_id, p_ref, BTA_FAILURE); p_data->ble_multi_adv_disable.inst_id, p_ref, BTA_FAILURE);
} }
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void bta_dm_ble_gap_read_phy(tBTA_DM_MSG *p_data)
{
//tBTM_STATUS btm_status = 0;
UINT8 tx_phy = 0, rx_phy = 0;
BTM_BleReadPhy(p_data->ble_read_phy.bd_addr, &tx_phy, &rx_phy);
}
void bta_dm_ble_gap_set_prefer_default_phy(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, tx_phy_mask = %d, rx_phy_mask = %d", __func__, p_data->ble_set_per_def_phy.tx_phy_mask, p_data->ble_set_per_def_phy.rx_phy_mask);
BTM_BleSetPreferDefaultPhy(p_data->ble_set_per_def_phy.tx_phy_mask, p_data->ble_set_per_def_phy.rx_phy_mask);
}
void bta_dm_ble_gap_set_prefer_phy(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, tx_phy_mask = %d, rx_phy_mask = %d, phy_options = %d",
__func__, p_data->ble_set_per_phy.tx_phy_mask,
p_data->ble_set_per_phy.rx_phy_mask, p_data->ble_set_per_phy.phy_options);
BTM_BleSetPreferPhy(p_data->ble_set_per_phy.bd_addr, p_data->ble_set_per_phy.all_phys,
p_data->ble_set_per_phy.tx_phy_mask, p_data->ble_set_per_phy.rx_phy_mask,
p_data->ble_set_per_phy.phy_options);
}
void bta_dm_ble_gap_ext_adv_set_rand_addr(tBTA_DM_MSG *p_data)
{
BTM_BleSetExtendedAdvRandaddr(p_data->ble_set_ext_adv_rand_addr.instance, p_data->ble_set_ext_adv_rand_addr.rand_addr);
}
void bta_dm_ble_gap_ext_adv_set_params(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, instance = %d", __func__, p_data->ble_set_ext_adv_params.instance);
BTM_BleSetExtendedAdvParams(p_data->ble_set_ext_adv_params.instance,
(tBTM_BLE_GAP_EXT_ADV_PARAMS *)&p_data->ble_set_ext_adv_params.params);
}
void bta_dm_ble_gap_config_ext_adv_data_raw(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, instance = %d, len = %d", __func__, p_data->ble_cfg_ext_adv_data.instance,
p_data->ble_cfg_ext_adv_data.length);
BTM_BleConfigExtendedAdvDataRaw(p_data->ble_cfg_ext_adv_data.is_scan_rsp,
p_data->ble_cfg_ext_adv_data.instance,
p_data->ble_cfg_ext_adv_data.length,
p_data->ble_cfg_ext_adv_data.data);
}
void bta_dm_ble_gap_start_ext_adv(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, enable = %d, num = %d", __func__, p_data->ble_start_ext_adv.enable,
p_data->ble_start_ext_adv.num);
BTM_BleStartExtAdv(p_data->ble_start_ext_adv.enable, p_data->ble_start_ext_adv.num,
(tBTM_BLE_EXT_ADV *)p_data->ble_start_ext_adv.ext_adv);
}
void bta_dm_ble_gap_ext_adv_set_remove(tBTA_DM_MSG *p_data)
{
BTM_BleExtAdvSetRemove(p_data->ble_ext_adv_set_remove.instance);
}
void bta_dm_ble_gap_ext_adv_set_clear(tBTA_DM_MSG *p_data)
{
BTM_BleExtAdvSetClear();
}
void bta_dm_ble_gap_periodic_adv_set_params(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, instance = %d", __func__, p_data->ble_set_periodic_adv_params.instance);
BTM_BlePeriodicAdvSetParams(p_data->ble_set_periodic_adv_params.instance,
(tBTM_BLE_Periodic_Adv_Params *)&p_data->ble_set_periodic_adv_params.params);
}
void bta_dm_ble_gap_periodic_adv_cfg_data_raw(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, instance = %d, length = %d", __func__, p_data->ble_cfg_periodic_adv_data.instance,
p_data->ble_cfg_periodic_adv_data.length);
BTM_BlePeriodicAdvCfgDataRaw(p_data->ble_cfg_periodic_adv_data.instance,
p_data->ble_cfg_periodic_adv_data.length,
p_data->ble_cfg_periodic_adv_data.data);
}
void bta_dm_ble_gap_periodic_adv_enable(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, instance = %d, enable = %d", __func__, p_data->ble_enable_periodic_adv.instance,
p_data->ble_enable_periodic_adv.enable);
BTM_BlePeriodicAdvEnable(p_data->ble_enable_periodic_adv.instance,
p_data->ble_enable_periodic_adv.enable);
}
void bta_dm_ble_gap_periodic_adv_create_sync(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s", __func__);
BTM_BlePeriodicAdvCreateSync((tBTM_BLE_Periodic_Sync_Params *)&p_data->ble_periodic_adv_sync.params);
}
void bta_dm_ble_gap_periodic_adv_sync_cancel(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s", __func__);
BTM_BlePeriodicAdvSyncCancel();
}
void bta_dm_ble_gap_periodic_adv_sync_terminate(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s", __func__);
BTM_BlePeriodicAdvSyncTerm(p_data->ble_periodic_adv_sync_term.sync_handle);
}
void bta_dm_ble_gap_periodic_adv_add_dev_to_list(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, addr_type = %d, sid = %d", __func__, p_data->ble_periodic_adv_add_dev_to_list.addr_type,
p_data->ble_periodic_adv_add_dev_to_list.sid);
BTM_BlePeriodicAdvAddDevToList(p_data->ble_periodic_adv_add_dev_to_list.addr_type,
p_data->ble_periodic_adv_add_dev_to_list.addr,
p_data->ble_periodic_adv_add_dev_to_list.sid);
}
void bta_dm_ble_gap_periodic_adv_remove_dev_from_list(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, addr_type = %d, sid = %d", __func__, p_data->ble_periodic_adv_remove_dev_from_list.addr_type,
p_data->ble_periodic_adv_remove_dev_from_list.sid);
BTM_BlePeriodicAdvRemoveDevFromList(p_data->ble_periodic_adv_remove_dev_from_list.addr_type,
p_data->ble_periodic_adv_remove_dev_from_list.addr,
p_data->ble_periodic_adv_remove_dev_from_list.sid);
}
void bta_dm_ble_gap_periodic_adv_clear_dev(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s", __func__);
BTM_BlePeriodicAdvClearDev();
}
void bta_dm_ble_gap_set_ext_scan_params(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s", __func__);
BTM_BleSetExtendedScanParams((tBTM_BLE_EXT_SCAN_PARAMS *)&p_data->ble_set_ext_scan_params.params);
}
void bta_dm_ble_gap_ext_scan(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, start = %d, duration = %d, period = %d", __func__, p_data->ble_ext_scan.start, p_data->ble_ext_scan.duration,
p_data->ble_ext_scan.period);
BTM_BleExtendedScan(p_data->ble_ext_scan.start, p_data->ble_ext_scan.duration,
p_data->ble_ext_scan.period);
}
void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data)
{
tBTM_EXT_CONN_PARAMS conn_params;
conn_params.phy_mask = p_data->ble_set_per_ext_conn_params.phy_mask;
APPL_TRACE_API("%s, start = %d, duration = %d, period = %d", __func__, p_data->ble_ext_scan.start, p_data->ble_ext_scan.duration,
p_data->ble_ext_scan.period);
if (conn_params.phy_mask & BTA_PHY_1M_MASK) {
memcpy(&conn_params.phy_1m_conn_params, &p_data->ble_set_per_ext_conn_params.phy_1m_conn_params,
sizeof(tBTA_DM_BLE_CONN_PARAMS));
}
if (conn_params.phy_mask & BTA_PHY_2M_MASK) {
memcpy(&conn_params.phy_2m_conn_params, &p_data->ble_set_per_ext_conn_params.phy_2m_conn_params,
sizeof(tBTA_DM_BLE_CONN_PARAMS));
}
if (conn_params.phy_mask & BTAS_PHY_CODED_MASK) {
memcpy(&conn_params.phy_coded_conn_params, &p_data->ble_set_per_ext_conn_params.phy_coded_conn_params,
sizeof(tBTA_DM_BLE_CONN_PARAMS));
}
BTM_BleSetPreferExtenedConnParams(p_data->ble_set_per_ext_conn_params.bd_addr, &conn_params);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/******************************************************************************* /*******************************************************************************
** **
** Function bta_dm_ble_setup_storage ** Function bta_dm_ble_setup_storage
@ -6088,7 +6276,7 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id); btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id);
} else { } else {
//TODO need to add addr_type in future //TODO need to add addr_type in future
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE); BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE);
} }
} }
#endif /* #if (GATTC_INCLUDED == TRUE) */ #endif /* #if (GATTC_INCLUDED == TRUE) */

View File

@ -181,6 +181,8 @@ void BTA_DmSetDeviceName(const char *p_name)
} }
} }
#if (CLASSIC_BT_INCLUDED == TRUE)
void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config) void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
{ {
tBTA_DM_API_CONFIG_EIR *p_msg; tBTA_DM_API_CONFIG_EIR *p_msg;
@ -223,7 +225,7 @@ void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
} }
} }
#if (CLASSIC_BT_INCLUDED == TRUE)
/******************************************************************************* /*******************************************************************************
** **
** Function BTA_DmSetAfhChannels ** Function BTA_DmSetAfhChannels
@ -2674,9 +2676,415 @@ void BTA_VendorCleanup (void)
} }
#endif #endif
if (cmn_ble_vsc_cb.adv_inst_max > 0) {
btm_ble_multi_adv_cleanup(); btm_ble_multi_adv_cleanup();
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void BTA_DmBleGapReadPHY(BD_ADDR addr)
{
tBTA_DM_API_READ_PHY *p_msg;
APPL_TRACE_API("%s, read phy.", __func__);
if ((p_msg = (tBTA_DM_API_READ_PHY *) osi_malloc(sizeof(tBTA_DM_API_READ_PHY))) != NULL) {
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
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__);
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr,
UINT8 all_phys,
tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask,
tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask,
UINT16 phy_options)
{
tBTA_DM_API_SET_PER_PHY *p_msg;
APPL_TRACE_API("%s, Set prefered 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;
memcpy(p_msg->bd_addr, addr, BD_ADDR_LEN);
p_msg->all_phys = all_phys;
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
} }
} }
void BTA_DmBleGapExtAdvSetRandaddr(UINT16 instance, BD_ADDR addr)
{
tBTA_DM_API_EXT_ADV_SET_RAND_ADDR *p_msg;
APPL_TRACE_API("%s, Set extended ADV parameters.", __func__);
if ((p_msg = (tBTA_DM_API_EXT_ADV_SET_RAND_ADDR *) osi_malloc(sizeof(tBTA_DM_API_EXT_ADV_SET_RAND_ADDR))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_EXT_ADV_SET_RAND_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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapExtAdvSetParams(UINT16 instance,
const tBTA_DM_BLE_GAP_EXT_ADV_PARAMS *params)
{
tBTA_DM_API_EXT_ADV_SET_PARAMS *p_msg;
APPL_TRACE_API("%s, Set extended ADV parameters.", __func__);
if ((p_msg = (tBTA_DM_API_EXT_ADV_SET_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_EXT_ADV_SET_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_EXT_ADV_SET_PARAMS));
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 length,
const UINT8 *data)
{
tBTA_DM_API_CFG_EXT_ADV_DATA *p_msg;
APPL_TRACE_API("%s, Config extended %s data.", __func__, is_scan_rsp ? "Scan rsp" : "Adv");
if ((p_msg = (tBTA_DM_API_CFG_EXT_ADV_DATA *) osi_malloc(sizeof(tBTA_DM_API_CFG_EXT_ADV_DATA) + length)) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_CFG_EXT_ADV_DATA) + length);
p_msg->hdr.event = BTA_DM_API_CFG_ADV_DATA_RAW_EVT;
p_msg->is_scan_rsp = is_scan_rsp;
p_msg->instance = instance;
p_msg->length = length;
p_msg->data = (UINT8 *)(p_msg + 1);
if (data) {
memcpy(p_msg->data, data, length);
}
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapExtAdvEnable(BOOLEAN enable, UINT8 num, tBTA_DM_BLE_EXT_ADV *ext_adv)
{
tBTA_DM_API_BLE_EXT_ADV *p_msg;
APPL_TRACE_API("%s, Start extended ADV", __func__);
if ((p_msg = (tBTA_DM_API_BLE_EXT_ADV *) osi_malloc(sizeof(tBTA_DM_API_BLE_EXT_ADV) + sizeof(tBTA_DM_BLE_EXT_ADV)*num)) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_EXT_ADV) + sizeof(tBTA_DM_BLE_EXT_ADV)*num);
p_msg->hdr.event = BTA_DM_API_EXT_ADV_ENABLE_EVT;
p_msg->enable = enable;
p_msg->num = num;
p_msg->ext_adv = (tBTA_DM_BLE_EXT_ADV *)(p_msg + 1);
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapExtAdvSetRemove(UINT8 instance)
{
tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE *p_msg;
APPL_TRACE_API("%s, Remove extended ADV", __func__);
if ((p_msg = (tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE *) osi_malloc(sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE))) != NULL) {
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;
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapExtAdvSetClear(void)
{
tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR *p_msg;
APPL_TRACE_API("%s, Clear extended ADV", __func__);
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance,
tBTA_DM_BLE_Periodic_Adv_Params *params)
{
tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS *p_msg;
APPL_TRACE_API("%s, Periodic ADV set parameters.", __func__);
if ((p_msg = (tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS));
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length,
const UINT8 *data)
{
tBTA_DM_API_CFG_PERIODIC_ADV_DATA *p_msg;
APPL_TRACE_API("%s, Periodic ADV config data raw.", __func__);
if ((p_msg = (tBTA_DM_API_CFG_PERIODIC_ADV_DATA *) osi_malloc(sizeof(tBTA_DM_API_CFG_PERIODIC_ADV_DATA) + length)) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_CFG_PERIODIC_ADV_DATA) + length);
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_CFG_DATA_EVT;
p_msg->instance = instance;
p_msg->length = length;
p_msg->data = (UINT8 *)(p_msg + 1);
memcpy(p_msg->data, data, length);
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvEnable(BOOLEAN enable, UINT8 instance)
{
tBTA_DM_API_ENABLE_PERIODIC_ADV *p_msg;
APPL_TRACE_API("%s, Periodic ADV %s.", __func__, enable ? "start" : "stop");
if ((p_msg = (tBTA_DM_API_ENABLE_PERIODIC_ADV *) osi_malloc(sizeof(tBTA_DM_API_ENABLE_PERIODIC_ADV))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_ENABLE_PERIODIC_ADV));
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params)
{
tBTA_DM_API_PERIODIC_ADV_SYNC *p_msg;
APPL_TRACE_API("%s, Periodic ADV create sync.", __func__);
if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_SYNC *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC))) != NULL) {
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvSyncCancel(void)
{
tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL *p_msg;
APPL_TRACE_API("%s, Periodic ADV sync cancel.", __func__);
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvSyncTerm(UINT16 sync_handle)
{
tBTA_DM_API_PERIODIC_ADV_SYNC_TERM *p_msg;
APPL_TRACE_API("%s, Periodic ADV sync terminat.", __func__);
if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_SYNC_TERM *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_TERM))) != NULL) {
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type,
BD_ADDR addr,
UINT16 sid)
{
tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST *p_msg;
APPL_TRACE_API("%s, Periodic ADV add device to list.", __func__);
if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST));
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LSIT_EVT;
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type,
BD_ADDR addr,
UINT16 sid)
{
tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST *p_msg;
APPL_TRACE_API("%s, Periodic ADV remove device from list.", __func__);
if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST));
p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LSIT_EVT;
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPeriodicAdvClearDev(void)
{
tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR *p_msg;
APPL_TRACE_API("%s, Periodic ADV clear device from list.", __func__);
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapSetExtScanParams(tBTA_DM_BLE_EXT_SCAN_PARAMS *params)
{
tBTA_DM_API_SET_EXT_SCAN_PARAMS *p_msg;
APPL_TRACE_API("%s, Set extended scan parameters.", __func__);
if ((p_msg = (tBTA_DM_API_SET_EXT_SCAN_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_SET_EXT_SCAN_PARAMS))) != NULL) {
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapExtScan(BOOLEAN start, UINT32 duration, UINT16 period)
{
tBTA_DM_API_EXT_SCAN *p_msg;
APPL_TRACE_API("%s, %s extended scan.", __func__, start ? "Start" : "Stop");
if ((p_msg = (tBTA_DM_API_EXT_SCAN *) osi_malloc(sizeof(tBTA_DM_API_EXT_SCAN))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_EXT_SCAN));
p_msg->hdr.event = BTA_DM_API_START_EXT_SCAN_EVT;
p_msg->start = start;
p_msg->duration = duration;
p_msg->period = period;
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr,
UINT8 phy_mask,
const tBTA_DM_BLE_CONN_PARAMS *phy_1m_conn_params,
const tBTA_DM_BLE_CONN_PARAMS *phy_2m_conn_params,
const tBTA_DM_BLE_CONN_PARAMS *phy_coded_conn_params)
{
tBTA_DM_API_SET_PER_EXT_CONN_PARAMS *p_msg;
APPL_TRACE_API("%s, Set prefer extended connection parameters.", __func__);
if ((p_msg = (tBTA_DM_API_SET_PER_EXT_CONN_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_SET_PER_EXT_CONN_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_PER_EXT_CONN_PARAMS));
p_msg->hdr.event = BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT;
p_msg->phy_mask = phy_mask;
memcpy(p_msg->bd_addr, bd_addr, sizeof(BD_ADDR));
if (phy_1m_conn_params) {
memcpy(&p_msg->phy_1m_conn_params, phy_1m_conn_params, sizeof(tBTA_DM_BLE_CONN_PARAMS));
}
if (phy_2m_conn_params) {
memcpy(&p_msg->phy_2m_conn_params, phy_2m_conn_params, sizeof(tBTA_DM_BLE_CONN_PARAMS));
}
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_addr)
{
tBTA_DM_API_EXT_CONN *p_msg;
APPL_TRACE_API("%s, Start Extended connect.", __func__);
APPL_TRACE_API("%s, Set prefer extended connection parameters.", __func__);
if ((p_msg = (tBTA_DM_API_EXT_CONN *) osi_malloc(sizeof(tBTA_DM_API_EXT_CONN))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_EXT_CONN));
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
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif

View File

@ -57,7 +57,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */ bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */
bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */ bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */
bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */ bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */
#if (CLASSIC_BT_INCLUDED == TRUE)
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */ bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
#endif
bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */ bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */
#if (SDP_INCLUDED == TRUE) #if (SDP_INCLUDED == TRUE)
bta_dm_read_rmt_name, /* BTA_DM_API_GET_REMOTE_NAME_EVT*/ bta_dm_read_rmt_name, /* BTA_DM_API_GET_REMOTE_NAME_EVT*/
@ -174,6 +176,29 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE
bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */ bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */
#endif #endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
bta_dm_ble_gap_read_phy, /* BTA_DM_API_READ_PHY_EVT */
bta_dm_ble_gap_set_prefer_default_phy, /* BTA_DM_API_SET_PER_DEF_PHY_EVT */
bta_dm_ble_gap_set_prefer_phy, /* BTA_DM_API_SET_PER_PHY_EVT */
bta_dm_ble_gap_ext_adv_set_rand_addr, /* BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT */
bta_dm_ble_gap_ext_adv_set_params, /* BTA_DM_API_SET_EXT_ADV_PARAMS_EVT */
bta_dm_ble_gap_config_ext_adv_data_raw, /* BTA_DM_API_CFG_ADV_DATA_RAW_EVT */
bta_dm_ble_gap_start_ext_adv, /* BTA_DM_API_EXT_ADV_ENABLE_EVT */
bta_dm_ble_gap_ext_adv_set_remove, /* BTA_DM_API_EXT_ADV_SET_REMOVE_EVT */
bta_dm_ble_gap_ext_adv_set_clear, /* BTA_DM_API_EXT_ADV_SET_CLEAR_EVT */
bta_dm_ble_gap_periodic_adv_set_params, /* BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT */
bta_dm_ble_gap_periodic_adv_cfg_data_raw, /* BTA_DM_API_PERIODIC_ADV_CFG_DATA_EVT */
bta_dm_ble_gap_periodic_adv_enable, /* BTA_DM_API_PERIODIC_ADV_ENABLE_EVT */
bta_dm_ble_gap_periodic_adv_create_sync, /* BTA_DM_API_PERIODIC_ADV_SYNC_EVT */
bta_dm_ble_gap_periodic_adv_sync_cancel, /* BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT */
bta_dm_ble_gap_periodic_adv_sync_terminate, /* BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT */
bta_dm_ble_gap_periodic_adv_add_dev_to_list, /* BTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LSIT_EVT */
bta_dm_ble_gap_periodic_adv_remove_dev_from_list, /* BTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LSIT_EVT */
bta_dm_ble_gap_periodic_adv_clear_dev, /* BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT */
bta_dm_ble_gap_set_ext_scan_params, /* BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT */
bta_dm_ble_gap_ext_scan, /* BTA_DM_API_START_EXT_SCAN_EVT */
bta_dm_ble_gap_set_prefer_ext_conn_params, /* BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT */
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
}; };

View File

@ -52,7 +52,9 @@ enum {
BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM), BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM),
BTA_DM_API_DISABLE_EVT, BTA_DM_API_DISABLE_EVT,
BTA_DM_API_SET_NAME_EVT, BTA_DM_API_SET_NAME_EVT,
#if (CLASSIC_BT_INCLUDED == TRUE)
BTA_DM_API_CONFIG_EIR_EVT, BTA_DM_API_CONFIG_EIR_EVT,
#endif
BTA_DM_API_SET_AFH_CHANNELS_EVT, BTA_DM_API_SET_AFH_CHANNELS_EVT,
#if (SDP_INCLUDED == TRUE) #if (SDP_INCLUDED == TRUE)
BTA_DM_API_GET_REMOTE_NAME_EVT, BTA_DM_API_GET_REMOTE_NAME_EVT,
@ -170,6 +172,30 @@ enum {
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE
BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT, BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT,
#endif #endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTA_DM_API_READ_PHY_EVT,
BTA_DM_API_SET_PER_DEF_PHY_EVT,
BTA_DM_API_SET_PER_PHY_EVT,
BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT,
BTA_DM_API_SET_EXT_ADV_PARAMS_EVT,
BTA_DM_API_CFG_ADV_DATA_RAW_EVT,
BTA_DM_API_EXT_ADV_ENABLE_EVT,
BTA_DM_API_EXT_ADV_SET_REMOVE_EVT,
BTA_DM_API_EXT_ADV_SET_CLEAR_EVT,
BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT,
BTA_DM_API_PERIODIC_ADV_CFG_DATA_EVT,
BTA_DM_API_PERIODIC_ADV_ENABLE_EVT,
BTA_DM_API_PERIODIC_ADV_SYNC_EVT,
BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT,
BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT,
BTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LSIT_EVT,
BTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LSIT_EVT,
BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT,
BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT,
BTA_DM_API_START_EXT_SCAN_EVT,
BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT,
BTA_DM_API_EXT_CONN_EVT,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BTA_DM_MAX_EVT BTA_DM_MAX_EVT
}; };
@ -840,7 +866,146 @@ typedef struct {
tBTA_DM_BLE_REF_VALUE ref_value; tBTA_DM_BLE_REF_VALUE ref_value;
} tBTA_DM_API_SCAN_FILTER_PARAM_SETUP; } tBTA_DM_API_SCAN_FILTER_PARAM_SETUP;
#endif #endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define BTA_PHY_1M_MASK (1 << 0)
#define BTA_PHY_2M_MASK (1 << 1)
#define BTAS_PHY_CODED_MASK (1 << 2)
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
} tBTA_DM_API_READ_PHY;
typedef struct {
BT_HDR hdr;
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;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
UINT8 all_phys;
tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask;
tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask;
UINT16 phy_options;
} tBTA_DM_API_SET_PER_PHY;
typedef struct {
BT_HDR hdr;
UINT16 instance;
BD_ADDR rand_addr;
} tBTA_DM_API_EXT_ADV_SET_RAND_ADDR;
typedef struct {
BT_HDR hdr;
UINT16 instance;
tBTA_DM_BLE_GAP_EXT_ADV_PARAMS params;
} tBTA_DM_API_EXT_ADV_SET_PARAMS;
typedef struct {
BT_HDR hdr;
BOOLEAN is_scan_rsp;
UINT8 instance;
UINT16 length;
UINT8 *data;
} tBTA_DM_API_CFG_EXT_ADV_DATA;
typedef struct {
BT_HDR hdr;
BOOLEAN enable;
UINT8 num;
tBTA_DM_BLE_EXT_ADV *ext_adv;
} tBTA_DM_API_BLE_EXT_ADV;
typedef struct {
BT_HDR hdr;
UINT16 instance;
} tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE;
typedef struct {
BT_HDR hdr;
} tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR;
typedef struct {
BT_HDR hdr;
UINT8 instance;
tBTA_DM_BLE_Periodic_Adv_Params params;
} tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS;
typedef struct {
BT_HDR hdr;
UINT8 instance;
UINT16 length;
UINT8 *data;
} tBTA_DM_API_CFG_PERIODIC_ADV_DATA;
typedef struct {
BT_HDR hdr;
UINT8 instance;
BOOLEAN enable;
} tBTA_DM_API_ENABLE_PERIODIC_ADV;
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_Periodic_Sync_Params params;
} tBTA_DM_API_PERIODIC_ADV_SYNC;
typedef struct {
BT_HDR hdr;
} tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL;
typedef struct {
BT_HDR hdr;
UINT16 sync_handle;
} tBTA_DM_API_PERIODIC_ADV_SYNC_TERM;
typedef struct {
BT_HDR hdr;
tBLE_ADDR_TYPE addr_type;
BD_ADDR addr;
UINT16 sid;
} tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST;
typedef struct {
BT_HDR hdr;
tBLE_ADDR_TYPE addr_type;
BD_ADDR addr;
UINT16 sid;
} tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST;
typedef struct {
BT_HDR hdr;
} tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR;
typedef struct {
BT_HDR hdr;
tBTA_DM_BLE_EXT_SCAN_PARAMS params;
} tBTA_DM_API_SET_EXT_SCAN_PARAMS;
typedef struct {
BT_HDR hdr;
BOOLEAN start;
UINT32 duration;
UINT16 period;
} tBTA_DM_API_EXT_SCAN;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
UINT8 phy_mask;
tBTA_DM_BLE_CONN_PARAMS phy_1m_conn_params;
tBTA_DM_BLE_CONN_PARAMS phy_2m_conn_params;
tBTA_DM_BLE_CONN_PARAMS phy_coded_conn_params;
} tBTA_DM_API_SET_PER_EXT_CONN_PARAMS;
typedef struct {
BT_HDR hdr;
tBLE_ADDR_TYPE own_addr_type;
BD_ADDR peer_addr;
} tBTA_DM_API_EXT_CONN;
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
/* union of all data types */ /* union of all data types */
typedef union { typedef union {
/* event buffer header */ /* event buffer header */
@ -956,6 +1121,29 @@ typedef union {
tBTA_DM_API_ENERGY_INFO ble_energy_info; tBTA_DM_API_ENERGY_INFO ble_energy_info;
tBTA_DM_API_BLE_DISCONNECT ble_disconnect; tBTA_DM_API_BLE_DISCONNECT ble_disconnect;
tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST ble_duplicate_exceptional_list; tBTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST ble_duplicate_exceptional_list;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
tBTA_DM_API_READ_PHY ble_read_phy;
tBTA_DM_API_SET_PER_DEF_PHY ble_set_per_def_phy;
tBTA_DM_API_SET_PER_PHY ble_set_per_phy;
tBTA_DM_API_EXT_ADV_SET_RAND_ADDR ble_set_ext_adv_rand_addr;
tBTA_DM_API_EXT_ADV_SET_PARAMS ble_set_ext_adv_params;
tBTA_DM_API_CFG_EXT_ADV_DATA ble_cfg_ext_adv_data;
tBTA_DM_API_BLE_EXT_ADV ble_start_ext_adv;
tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE ble_ext_adv_set_remove;
tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR ble_ext_adv_set_clear;
tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS ble_set_periodic_adv_params;
tBTA_DM_API_CFG_PERIODIC_ADV_DATA ble_cfg_periodic_adv_data;
tBTA_DM_API_ENABLE_PERIODIC_ADV ble_enable_periodic_adv;
tBTA_DM_API_PERIODIC_ADV_SYNC ble_periodic_adv_sync;
tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL ble_periodic_adv_sync_cancel;
tBTA_DM_API_PERIODIC_ADV_SYNC_TERM ble_periodic_adv_sync_term;
tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST ble_periodic_adv_add_dev_to_list;
tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST ble_periodic_adv_remove_dev_from_list;
tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR ble_periodic_adv_clear_dev;
tBTA_DM_API_SET_EXT_SCAN_PARAMS ble_set_ext_scan_params;
tBTA_DM_API_EXT_SCAN ble_ext_scan;
tBTA_DM_API_SET_PER_EXT_CONN_PARAMS ble_set_per_ext_conn_params;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif
tBTA_DM_API_REMOVE_ACL remove_acl; tBTA_DM_API_REMOVE_ACL remove_acl;
@ -1318,7 +1506,9 @@ extern void bta_dm_search_sm_disable( void );
extern void bta_dm_enable (tBTA_DM_MSG *p_data); extern void bta_dm_enable (tBTA_DM_MSG *p_data);
extern void bta_dm_disable (tBTA_DM_MSG *p_data); extern void bta_dm_disable (tBTA_DM_MSG *p_data);
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data); extern void bta_dm_set_dev_name (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_config_eir (tBTA_DM_MSG *p_data);
#endif
extern void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data); extern void bta_dm_set_afh_channels (tBTA_DM_MSG *p_data);
extern void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data); extern void bta_dm_read_rmt_name(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_channels (tBTA_DM_MSG *p_data);
@ -1384,7 +1574,17 @@ extern void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data); extern void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data); extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data); extern void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void bta_dm_ble_gap_read_phy(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_default_phy(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_phy(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_adv_set_rand_addr(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_adv_set_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_config_ext_adv_data_raw(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_ext_scan_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void bta_dm_ble_setup_storage(tBTA_DM_MSG *p_data); extern void bta_dm_ble_setup_storage(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG *p_data); extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_disable_batch_scan(tBTA_DM_MSG *p_data); extern void bta_dm_ble_disable_batch_scan(tBTA_DM_MSG *p_data);
@ -1448,4 +1648,48 @@ extern void bta_dm_execute_callback(tBTA_DM_MSG *p_data);
extern void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data); extern void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void bta_dm_ble_gap_read_phy(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_default_phy(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_phy(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_adv_set_rand_addr(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_adv_set_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_config_ext_adv_data_raw(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_start_ext_adv(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_adv_set_remove(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_adv_set_clear(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_set_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_cfg_data_raw(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_enable(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_create_sync(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_sync_cancel(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_sync_terminate(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_add_dev_to_list(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_remove_dev_from_list(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_periodic_adv_clear_dev(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_ext_scan_params(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_ext_scan(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif /* BTA_DM_INT_H */ #endif /* BTA_DM_INT_H */

View File

@ -68,6 +68,8 @@ static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested);
static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data); static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data);
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda); static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda);
extern void btc_gattc_congest_callback(tBTA_GATTC *param);
static const tGATT_CBACK bta_gattc_cl_cback = { static const tGATT_CBACK bta_gattc_cl_cback = {
bta_gattc_conn_cback, bta_gattc_conn_cback,
bta_gattc_cmpl_cback, bta_gattc_cmpl_cback,
@ -495,7 +497,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
} }
/* open/hold a connection */ /* open/hold a connection */
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type, if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type,
TRUE, p_data->api_conn.transport)) { TRUE, p_data->api_conn.transport, p_data->api_conn.is_aux)) {
APPL_TRACE_ERROR("Connection open failure"); APPL_TRACE_ERROR("Connection open failure");
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data); bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_OPEN_FAIL_EVT, p_data);
@ -530,7 +532,9 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) { if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) {
/* always call open to hold a connection */ /* always call open to hold a connection */
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, p_data->transport)) { if (!GATT_Connect(p_data->client_if, p_data->remote_bda,
p_data->remote_addr_type, FALSE,
p_data->transport, p_data->is_aux)) {
#if (!CONFIG_BT_STACK_NO_LOG) #if (!CONFIG_BT_STACK_NO_LOG)
uint8_t *bda = (uint8_t *)p_data->remote_bda; uint8_t *bda = (uint8_t *)p_data->remote_bda;
#endif #endif
@ -1154,12 +1158,16 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
memset(&read_param, 0, sizeof(tGATT_READ_PARAM)); memset(&read_param, 0, sizeof(tGATT_READ_PARAM));
if (status == BTA_GATT_OK) { if (status == BTA_GATT_OK) {
if(p_data->api_read_multi.num_attr < GATT_MAX_READ_MULTI_HANDLES) {
read_param.read_multiple.num_handles = p_data->api_read_multi.num_attr; read_param.read_multiple.num_handles = p_data->api_read_multi.num_attr;
read_param.read_multiple.auth_req = p_data->api_read_multi.auth_req; read_param.read_multiple.auth_req = p_data->api_read_multi.auth_req;
memcpy(&read_param.read_multiple.handles, p_data->api_read_multi.handles, memcpy(&read_param.read_multiple.handles, p_data->api_read_multi.handles,
sizeof(UINT16) * p_data->api_read_multi.num_attr); sizeof(UINT16) * p_data->api_read_multi.num_attr);
status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_MULTIPLE, &read_param); status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_MULTIPLE, &read_param);
} else {
status = GATT_ILLEGAL_PARAMETER;
}
} }
/* read fail */ /* read fail */
@ -2164,17 +2172,10 @@ static void bta_gattc_cmpl_sendmsg(UINT16 conn_id, tGATTC_OPTYPE op,
********************************************************************************/ ********************************************************************************/
static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested) static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested)
{ {
tBTA_GATTC_CLCB *p_clcb;
tBTA_GATTC cb_data; tBTA_GATTC cb_data;
if ((p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id)) != NULL) {
if (p_clcb->p_rcb->p_cback) {
cb_data.congest.conn_id = conn_id; cb_data.congest.conn_id = conn_id;
cb_data.congest.congested = congested; cb_data.congest.congested = congested;
btc_gattc_congest_callback(&cb_data);
(*p_clcb->p_rcb->p_cback)(BTA_GATTC_CONGEST_EVT, &cb_data);
}
}
} }
/******************************************************************************* /*******************************************************************************

View File

@ -143,7 +143,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
** **
*******************************************************************************/ *******************************************************************************/
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport) BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux)
{ {
tBTA_GATTC_API_OPEN *p_buf; tBTA_GATTC_API_OPEN *p_buf;
@ -153,6 +153,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE
p_buf->client_if = client_if; p_buf->client_if = client_if;
p_buf->is_direct = is_direct; p_buf->is_direct = is_direct;
p_buf->transport = transport; p_buf->transport = transport;
p_buf->is_aux = is_aux;
p_buf->remote_addr_type = remote_addr_type; p_buf->remote_addr_type = remote_addr_type;
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);

View File

@ -746,7 +746,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) { if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) {
/* should always get the connection ID */ /* should always get the connection ID */
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda, BLE_ADDR_UNKNOWN_TYPE, if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda, BLE_ADDR_UNKNOWN_TYPE,
p_msg->api_open.is_direct, p_msg->api_open.transport)) { p_msg->api_open.is_direct, p_msg->api_open.transport, FALSE)) {
status = BTA_GATT_OK; status = BTA_GATT_OK;
if (GATT_GetConnIdIfConnected(p_rcb->gatt_if, p_msg->api_open.remote_bda, if (GATT_GetConnIdIfConnected(p_rcb->gatt_if, p_msg->api_open.remote_bda,

View File

@ -130,6 +130,7 @@ typedef struct {
tBTA_ADDR_TYPE remote_addr_type; tBTA_ADDR_TYPE remote_addr_type;
tBTA_GATTC_IF client_if; tBTA_GATTC_IF client_if;
BOOLEAN is_direct; BOOLEAN is_direct;
BOOLEAN is_aux;
tBTA_TRANSPORT transport; tBTA_TRANSPORT transport;
} tBTA_GATTC_API_OPEN; } tBTA_GATTC_API_OPEN;

View File

@ -334,7 +334,7 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda)
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index; bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
p_cb->in_use = TRUE; p_cb->in_use = TRUE;
BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE); BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE, FALSE);
} }
/******************************************************************************* /*******************************************************************************
@ -2601,7 +2601,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond)
if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/ if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/
!p_cb->in_bg_conn && to_add) { !p_cb->in_bg_conn && to_add) {
/* add device into BG connection to accept remote initiated connection */ /* add device into BG connection to accept remote initiated connection */
BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE); BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE, FALSE);
p_cb->in_bg_conn = TRUE; p_cb->in_bg_conn = TRUE;
BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL); BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL);

View File

@ -1415,6 +1415,155 @@ typedef UINT8 tBTA_DM_LINK_TYPE;
#define BATCH_DELY_MODE 0x02 #define BATCH_DELY_MODE 0x02
#define ALLOW_ALL_FILTER 0x00 #define ALLOW_ALL_FILTER 0x00
#define LOWEST_RSSI_VALUE 129 #define LOWEST_RSSI_VALUE 129
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
#define BTA_DM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY)
typedef UINT16 tBTA_DM_BLE_EXT_ADV_TYPE_MASK;
#define BTA_DM_BLE_GAP_PHY_1M 1
#define BTA_DM_BLE_GAP_PHY_2M 2
#define BTA_DM_BLE_GAP_PHY_CODED 3
typedef UINT8 tBTA_DM_BLE_GAP_PHY;
#define BTA_DM_BLE_GAP_PHY_NO_TX_PREF_MASK (0x01)
#define BTA_DM_BLE_GAP_PHY_NO_RX_PREF_MASK (0x02)
#define BTA_DM_BLE_GAP_PHY_1M_PREF_MASK (0x03)
#define BTA_DM_BLE_GAP_PHY_2M_PREF_MASK (0x04)
#define BTA_DM_BLE_GAP_PHY_CODED_PREF_MASK (0x05)
typedef UINT8 tBTA_DM_BLE_GAP_PHY_MASK;
#define BTA_DM_BLE_GAP_EXT_SCAN_UNCODE_MASK 0x01
#define BTA_DM_BLE_GAP_EXT_SCAN_CODE_MASK 0x02
typedef UINT8 tBTA_DM_BLE_EXT_SCAN_CFG_MASK;
typedef struct {
tBTA_DM_BLE_EXT_ADV_TYPE_MASK type;
UINT32 interval_min;
UINT32 interval_max;
tBTA_BLE_ADV_CHNL_MAP channel_map;
tBLE_ADDR_TYPE own_addr_type;
tBLE_ADDR_TYPE peer_addr_type;
BD_ADDR peer_addr;
tBTA_BLE_AFP filter_policy;
UINT8 tx_power;
tBTA_DM_BLE_GAP_PHY primary_phy;
UINT8 max_skip;
tBTA_DM_BLE_GAP_PHY secondary_phy;
UINT8 sid;
BOOLEAN scan_req_notif;
} tBTA_DM_BLE_GAP_EXT_ADV_PARAMS;
typedef struct {
UINT8 instance;
int duration;
int max_events;
} tBTA_DM_BLE_EXT_ADV;
typedef struct {
UINT16 interval_min;
UINT16 interval_max;
UINT8 properties;
} tBTA_DM_BLE_Periodic_Adv_Params;
typedef struct {
UINT8 filter_policy;
UINT8 sid;
tBLE_ADDR_TYPE addr_type;
BD_ADDR addr;
UINT16 skip;
UINT16 sync_timeout;
} tBTA_DM_BLE_Periodic_Sync_Params;
typedef struct {
tBLE_SCAN_MODE scan_type;
UINT16 scan_interval;
UINT16 scan_window;
} tBTA_DM_BLE_EXT_SCAN_CFG;
typedef struct {
tBLE_ADDR_TYPE own_addr_type;
UINT8 filter_policy;
UINT8 scan_duplicate;
tBTA_DM_BLE_EXT_SCAN_CFG_MASK cfg_mask;
tBTA_DM_BLE_EXT_SCAN_CFG uncoded_cfg;
tBTA_DM_BLE_EXT_SCAN_CFG coded_cfg;
} tBTA_DM_BLE_EXT_SCAN_PARAMS;
typedef struct {
UINT16 scan_interval;
UINT16 scan_window;
UINT16 interval_min;
UINT16 interval_max;
UINT16 latency;
UINT16 supervision_timeout;
UINT16 min_ce_len;
UINT16 max_ce_len;
} tBTA_DM_BLE_CONN_PARAMS;
#define BTA_DM_BLE_5_GAP_READ_PHY_COMPLETE_EVT BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT
#define BTA_DM_BLE_5_GAP_SCAN_TIMEOUT_EVT BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT
#define BTA_DM_BLE_5_GAP_ADV_TERMINATED_EVT BTM_BLE_5_GAP_ADV_TERMINATED_EVT
#define BTA_DM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT
#define BTA_DM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT
#define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT
#define BTA_DM_BLE_5_GAP_UNKNOWN_EVT BTM_BLE_5_GAP_UNKNOWN_EVT
typedef tBTM_BLE_5_GAP_EVENT tBTA_DM_BLE_5_GAP_EVENT;
typedef tBTM_BLE_5_GAP_CB_PARAMS tBTA_DM_BLE_5_GAP_CB_PARAMS;
typedef tBTM_BLE_5_HCI_CBACK tBTA_DM_BLE_5_HCI_CBCAK;
extern tBTM_BLE_5_HCI_CBACK ble_5_hci_cb;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/***************************************************************************** /*****************************************************************************
** External Function Declarations ** External Function Declarations
@ -2719,6 +2868,72 @@ extern void BTA_VendorInit (void);
** **
*******************************************************************************/ *******************************************************************************/
extern void BTA_VendorCleanup (void); extern void BTA_VendorCleanup (void);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void BTA_DmBleGapReadPHY(BD_ADDR addr);
extern void BTA_DmBleGapSetPreferedDefaultPHY(tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask,
tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask);
extern void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr,
UINT8 all_phys,
tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask,
tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask,
UINT16 phy_options);
extern void BTA_DmBleGapExtAdvSetRandaddr(UINT16 instance, BD_ADDR addr);
extern void BTA_DmBleGapExtAdvSetParams(UINT16 instance,
const tBTA_DM_BLE_GAP_EXT_ADV_PARAMS *params);
extern void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 length,
const UINT8 *data);
extern void BTA_DmBleGapStartExtAdv(UINT8 num, tBTA_DM_BLE_EXT_ADV *ext_adv);
extern void BTA_DmBleGapExtAdvEnable(BOOLEAN enable, UINT8 num, tBTA_DM_BLE_EXT_ADV *ext_adv);
extern void BTA_DmBleGapExtAdvSetRemove(UINT8 instance);
extern void BTA_DmBleGapExtAdvSetClear(void);
extern void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance,
tBTA_DM_BLE_Periodic_Adv_Params *params);
extern void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length,
const UINT8 *data);
extern void BTA_DmBleGapPeriodicAdvEnable(BOOLEAN enable, UINT8 instance);
extern void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params);
extern void BTA_DmBleGapPeriodicAdvSyncCancel(void);
extern void BTA_DmBleGapPeriodicAdvSyncTerm(UINT16 sync_handle);
extern void BTA_DmBleGapPeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type,
BD_ADDR addr,
UINT16 sid);
extern void BTA_DmBleGapPeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type,
BD_ADDR addr,
UINT16 sid);
extern void BTA_DmBleGapPeriodicAdvClearDev(void);
extern void BTA_DmBleGapSetExtScanParams(tBTA_DM_BLE_EXT_SCAN_PARAMS *params);
extern void BTA_DmBleGapExtScan(BOOLEAN start, UINT32 duration, UINT16 period);
extern void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr,
UINT8 phy_mask,
const tBTA_DM_BLE_CONN_PARAMS *phy_1m_conn_params,
const tBTA_DM_BLE_CONN_PARAMS *phy_2m_conn_params,
const tBTA_DM_BLE_CONN_PARAMS *phy_coded_conn_params);
extern void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_addr);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif
enum { enum {

View File

@ -794,7 +794,7 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if);
** **
*******************************************************************************/ *******************************************************************************/
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type, extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport); BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport, BOOLEAN is_aux);
/******************************************************************************* /*******************************************************************************
** **

View File

@ -32,6 +32,7 @@
#include "esp_bt.h" #include "esp_bt.h"
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
#if (BLE_42_FEATURE_SUPPORT == TRUE)
#if BTC_DYNAMIC_MEMORY == FALSE #if BTC_DYNAMIC_MEMORY == FALSE
static tBTA_BLE_ADV_DATA gl_bta_adv_data; static tBTA_BLE_ADV_DATA gl_bta_adv_data;
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data; static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
@ -39,6 +40,7 @@ static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
tBTA_BLE_ADV_DATA *gl_bta_adv_data_ptr; tBTA_BLE_ADV_DATA *gl_bta_adv_data_ptr;
tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr;
#endif #endif
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if SCAN_QUEUE_CONGEST_CHECK #if SCAN_QUEUE_CONGEST_CHECK
static list_t *adv_filter_list; static list_t *adv_filter_list;
@ -61,7 +63,7 @@ static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_g
btc_gap_ble_cb(event, param); btc_gap_ble_cb(event, param);
} }
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
static void btc_gap_adv_point_cleanup(void **buf) static void btc_gap_adv_point_cleanup(void **buf)
{ {
if (NULL == *buf) { if (NULL == *buf) {
@ -538,7 +540,7 @@ static void btc_ble_set_scan_params(esp_ble_scan_params_t *scan_params, tBLE_SCA
if (BLE_ISVALID_PARAM(scan_params->scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) && if (BLE_ISVALID_PARAM(scan_params->scan_interval, BTM_BLE_SCAN_INT_MIN, BTM_BLE_SCAN_INT_MAX) &&
BLE_ISVALID_PARAM(scan_params->scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) && BLE_ISVALID_PARAM(scan_params->scan_window, BTM_BLE_SCAN_WIN_MIN, BTM_BLE_SCAN_WIN_MAX) &&
BLE_ISVALID_PARAM(scan_params->own_addr_type, BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_RPA_RANDOM) && BLE_ISVALID_PARAM(scan_params->own_addr_type, BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_RPA_RANDOM) &&
BLE_ISVALID_PARAM(scan_params->scan_filter_policy, BLE_SCAN_FILTER_ALLOW_ALL, BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR) && BLE_ISVALID_PARAM(scan_params->scan_filter_policy, BLE_SCAN_FILTER_ALLOW_ALL, BLE_SCAN_FILTER_ALLOW_WLIST_RPA_DIR) &&
BLE_ISVALID_PARAM(scan_params->scan_duplicate, BLE_SCAN_DUPLICATE_DISABLE, BLE_SCAN_DUPLICATE_MAX -1) && BLE_ISVALID_PARAM(scan_params->scan_duplicate, BLE_SCAN_DUPLICATE_DISABLE, BLE_SCAN_DUPLICATE_MAX -1) &&
(scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS)) { (scan_params->scan_type == BTM_BLE_SCAN_MODE_ACTI || scan_params->scan_type == BTM_BLE_SCAN_MODE_PASS)) {
BTA_DmSetBleScanFilterParams(ESP_DEFAULT_GATT_IF, /*client_if*/ BTA_DmSetBleScanFilterParams(ESP_DEFAULT_GATT_IF, /*client_if*/
@ -661,7 +663,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
btc_adv_list_refresh(); btc_adv_list_refresh();
#endif #endif
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params) void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params)
{ {
esp_ble_gap_cb_param_t param; esp_ble_gap_cb_param_t param;
@ -810,12 +812,222 @@ static void btc_read_ble_rssi_cmpl_callback(void *p_data)
} }
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
tBTA_DM_BLE_5_GAP_CB_PARAMS *params)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
switch(event) {
case BTA_DM_BLE_5_GAP_READ_PHY_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_READ_PHY_COMPLETE_EVT;
param.read_phy.status = btc_btm_status_to_esp_status(params->read_phy.status);
memcpy(param.read_phy.bda, params->read_phy.addr, BD_ADDR_LEN);
param.read_phy.tx_phy = params->read_phy.tx_phy;
param.read_phy.rx_phy = params->read_phy.rx_phy;
break;
}
case BTA_DM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT;
param.set_perf_def_phy.status = btc_btm_status_to_esp_status(params->set_perf_def_phy.status);
break;
}
case BTA_DM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_SET_PREFERED_PHY_COMPLETE_EVT;
param.set_perf_phy.status = btc_btm_status_to_esp_status(params->set_perf_phy.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT;
param.ext_adv_set_rand_addr.status = btc_btm_status_to_esp_status(params->set_ext_rand_addr.status);
break;
case BTA_DM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_EXT_ADV_SET_PARAMS_COMPLETE_EVT;
param.ext_adv_set_rand_addr.status = btc_btm_status_to_esp_status(params->set_params.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_EXT_ADV_DATA_SET_COMPLETE_EVT;
param.ext_adv_data_set.status = btc_btm_status_to_esp_status(params->adv_data_set.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT;
param.scan_rsp_set.status = btc_btm_status_to_esp_status(params->scan_rsp_data_set.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_EXT_ADV_START_COMPLETE_EVT;
param.ext_adv_start.status = btc_btm_status_to_esp_status(params->adv_start.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_EXT_ADV_STOP_COMPLETE_EVT;
param.ext_adv_stop.status = btc_btm_status_to_esp_status(params->adv_start.status);
break;
case BTA_DM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_EXT_ADV_SET_REMOVE_COMPLETE_EVT;
param.ext_adv_remove.status = btc_btm_status_to_esp_status(params->adv_start.status);
break;
case BTA_DM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT;
param.ext_adv_clear.status = btc_btm_status_to_esp_status(params->adv_start.status);
break;
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT;
param.peroid_adv_set_params.status = btc_btm_status_to_esp_status(params->per_adv_set_params.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_DATA_SET_COMPLETE_EVT;
param.period_adv_data_set.status = btc_btm_status_to_esp_status(params->per_adv_data_set.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_START_COMPLETE_EVT;
param.period_adv_start.status = btc_btm_status_to_esp_status(params->per_adv_start.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_STOP_COMPLETE_EVT;
param.period_adv_stop.status = btc_btm_status_to_esp_status(params->per_adv_stop.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT;
param.period_adv_create_sync.status = btc_btm_status_to_esp_status(params->per_adv_sync_create.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT;
param.period_adv_sync_cancel.status = btc_btm_status_to_esp_status(params->per_adv_sync_cancel.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT;
param.period_adv_sync_term.status = btc_btm_status_to_esp_status(params->per_adv_sync_term.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT;
param.period_adv_add_dev.status = btc_btm_status_to_esp_status(params->per_adv_add_dev.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT;
param.period_adv_remove_dev.status = btc_btm_status_to_esp_status(params->per_adv_remove_dev.status);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT;
param.period_adv_clear_dev.status = btc_btm_status_to_esp_status(params->per_adv_clear_dev.status);
break;
}
case BTA_DM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_SET_EXT_SCAN_PARAMS_COMPLETE_EVT;
param.set_ext_scan_params.status = btc_btm_status_to_esp_status(params->ext_scan.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_EXT_SCAN_START_COMPLETE_EVT;
param.ext_scan_start.status = btc_btm_status_to_esp_status(params->scan_start.status);
break;
}
case BTA_DM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_EXT_SCAN_STOP_COMPLETE_EVT;
param.ext_scan_stop.status = btc_btm_status_to_esp_status(params->scan_stop.status);
break;
}
case BTA_DM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT;
param.ext_conn_params_set.status = btc_btm_status_to_esp_status(params->ext_conn_set_params.status);
break;
}
case BTA_DM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT:
msg.act = ESP_GAP_BLE_PHY_UPDATE_COMPLETE_EVT;
param.phy_update.status = btc_btm_status_to_esp_status(params->phy_update.status);
memcpy(param.phy_update.bda, params->phy_update.addr, BD_ADDR_LEN);
param.phy_update.tx_phy = params->phy_update.tx_phy;
param.phy_update.rx_phy = params->phy_update.rx_phy;
break;
case BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT:
msg.act = ESP_GAP_BLE_EXT_ADV_REPORT_EVT;
memcpy(&param.ext_adv_report.params, &params->ext_adv_report, sizeof(esp_ble_gap_ext_adv_reprot_t));
memcpy(param.ext_adv_report.params.adv_data,
params->ext_adv_report.adv_data, params->ext_adv_report.adv_data_len);
break;
case BTA_DM_BLE_5_GAP_SCAN_TIMEOUT_EVT:
msg.act = ESP_GAP_BLE_SCAN_TIMEOUT_EVT;
break;
case BTA_DM_BLE_5_GAP_ADV_TERMINATED_EVT: {
param.adv_terminate.status = params->adv_term.status;
param.adv_terminate.adv_instance = params->adv_term.adv_handle;
param.adv_terminate.conn_idx = params->adv_term.conn_handle;
param.adv_terminate.completed_event = params->adv_term.completed_event;
msg.act = ESP_GAP_BLE_ADV_TERMINATED_EVT;
break;
}
case BTA_DM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT: {
msg.act = ESP_GAP_BLE_SCAN_REQ_RECEIVED_EVT;
param.scan_req_received.adv_instance = params->scan_req.adv_handle;
param.scan_req_received.scan_addr_type = params->scan_req.scan_addr_type;
memcpy(param.scan_req_received.scan_addr, params->scan_req.scan_addr, sizeof(BD_ADDR));
break;
}
case BTA_DM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT: {
msg.act = ESP_GAP_BLE_CHANNEL_SELETE_ALGORITHM_EVT;
param.channel_sel_alg.conn_handle = params->channel_sel.conn_handle;
param.channel_sel_alg.channel_sel_alg = params->channel_sel.channel_sel_alg;
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT;
memcpy(&param.period_adv_report, &params->period_adv_report,
sizeof(esp_ble_gap_periodic_adv_report_t));
memcpy(param.period_adv_report.params.data, params->period_adv_report.data,
params->period_adv_report.data_length);
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SYNC_LOST_EVT;
param.periodic_adv_sync_lost.sync_handle = params->sync_lost.sync_handle;
break;
}
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT: {
msg.act = ESP_GAP_BLE_PERIODIC_ADV_SYNC_ESTAB_EVT;
param.periodic_adv_sync_estab.status = btc_btm_status_to_esp_status(params->sync_estab.status);
param.periodic_adv_sync_estab.sync_handle = params->sync_estab.sync_handle;
param.periodic_adv_sync_estab.sid = params->sync_estab.sid;
param.periodic_adv_sync_estab.adv_addr_type = params->sync_estab.adv_addr_type;
memcpy(param.periodic_adv_sync_estab.adv_addr, params->sync_estab.adv_addr,
sizeof(BD_ADDR));
param.periodic_adv_sync_estab.adv_phy = params->sync_estab.adv_phy;
param.periodic_adv_sync_estab.period_adv_interval = params->sync_estab.period_adv_interval;
param.periodic_adv_sync_estab.adv_clk_accuracy = params->sync_estab.adv_clk_accuracy;
break;
}
default:
break;
}
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
void btc_get_whitelist_size(uint16_t *length) void btc_get_whitelist_size(uint16_t *length)
{ {
BTM_BleGetWhiteListSize(length); BTM_BleGetWhiteListSize(length);
return; return;
} }
#if (BLE_42_FEATURE_SUPPORT == TRUE)
static void btc_ble_start_scanning(uint32_t duration, static void btc_ble_start_scanning(uint32_t duration,
tBTA_DM_SEARCH_CBACK *results_cb, tBTA_DM_SEARCH_CBACK *results_cb,
tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb) tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb)
@ -844,7 +1056,7 @@ static void btc_ble_stop_advertising(tBTA_START_STOP_ADV_CMPL_CBACK *stop_adv_cb
BTA_DmBleBroadcast(stop_adv, stop_adv_cb); BTA_DmBleBroadcast(stop_adv, stop_adv_cb);
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int, static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int,
uint16_t max_int, uint16_t latency, uint16_t timeout) uint16_t max_int, uint16_t latency, uint16_t timeout)
{ {
@ -957,6 +1169,7 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
{ {
switch (msg->act) { switch (msg->act) {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { case BTC_GAP_BLE_ACT_CFG_ADV_DATA: {
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src; 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; btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
@ -1002,6 +1215,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
} }
break; break;
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: { case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: {
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src; 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; btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
@ -1032,6 +1246,67 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
} }
break; break;
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW:
case BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW: {
btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src;
btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest;
uint16_t length = 0;
if (src->ext_adv_cfg_data.data) {
length = src->ext_adv_cfg_data.length;
dst->ext_adv_cfg_data.data = osi_malloc(length);
if (dst->ext_adv_cfg_data.data) {
memcpy(dst->ext_adv_cfg_data.data, src->ext_adv_cfg_data.data, length);
} else {
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
}
}
break;
}
case BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW: {
btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src;
btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest;
uint16_t length = 0;
if (src->periodic_adv_cfg_data.data) {
length = src->periodic_adv_cfg_data.len;
dst->periodic_adv_cfg_data.data = osi_malloc(length);
if (dst->periodic_adv_cfg_data.data) {
memcpy(dst->periodic_adv_cfg_data.data, src->periodic_adv_cfg_data.data, length);
} else {
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
}
}
break;
}
case BTC_GAP_BLE_EXT_ADV_START: {
btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src;
btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest;
if (src->ext_adv_start.ext_adv) {
dst->ext_adv_start.ext_adv = osi_malloc(src->ext_adv_start.num_adv*sizeof(esp_ble_gap_ext_adv_t));
if (dst->ext_adv_start.ext_adv) {
memcpy(dst->ext_adv_start.ext_adv, src->ext_adv_start.ext_adv,
src->ext_adv_start.num_adv*sizeof(esp_ble_gap_ext_adv_t));
}
}
break;
}
case BTC_GAP_BLE_EXT_ADV_STOP: {
btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src;
btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest;
if (src->ext_adv_stop.ext_adv_inst) {
dst->ext_adv_stop.ext_adv_inst = osi_malloc(src->ext_adv_stop.num_adv*sizeof(uint8_t));
if (dst->ext_adv_stop.ext_adv_inst) {
memcpy(dst->ext_adv_stop.ext_adv_inst, src->ext_adv_stop.ext_adv_inst,
src->ext_adv_stop.num_adv * sizeof(uint8_t));
}
}
break;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
default: default:
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act); BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
break; break;
@ -1051,6 +1326,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
{ {
BTC_TRACE_DEBUG("%s \n", __func__); BTC_TRACE_DEBUG("%s \n", __func__);
switch (msg->act) { switch (msg->act) {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { case BTC_GAP_BLE_ACT_CFG_ADV_DATA: {
esp_ble_adv_data_t *adv = &((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data.adv_data; esp_ble_adv_data_t *adv = &((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data.adv_data;
if (adv->p_service_data) { if (adv->p_service_data) {
@ -1080,6 +1356,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
} }
break; break;
} }
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: { case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: {
uint8_t *value = ((btc_ble_gap_args_t *)msg->arg)->set_security_param.value; uint8_t *value = ((btc_ble_gap_args_t *)msg->arg)->set_security_param.value;
if (value) { if (value) {
@ -1094,6 +1371,37 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
} }
break; break;
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW:
case BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW: {
uint8_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->ext_adv_cfg_data.data;
if (value) {
osi_free(value);
}
break;
}
case BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW: {
uint8_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->periodic_adv_cfg_data.data;
if (value) {
osi_free(value);
}
break;
}
case BTC_GAP_BLE_EXT_ADV_START: {
esp_ble_gap_ext_adv_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->ext_adv_start.ext_adv;
if (value) {
osi_free(value);
}
break;
}
case BTC_GAP_BLE_EXT_ADV_STOP: {
uint8_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->ext_adv_stop.ext_adv_inst;
if (value) {
osi_free(value);
}
break;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
default: default:
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act); BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
break; break;
@ -1113,10 +1421,14 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg)
void btc_gap_ble_call_handler(btc_msg_t *msg) void btc_gap_ble_call_handler(btc_msg_t *msg)
{ {
btc_ble_gap_args_t *arg = (btc_ble_gap_args_t *)msg->arg; btc_ble_gap_args_t *arg = (btc_ble_gap_args_t *)msg->arg;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
btc_ble_5_gap_args_t *arg_5 = (btc_ble_5_gap_args_t *)msg->arg;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act); BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
switch (msg->act) { switch (msg->act) {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { case BTC_GAP_BLE_ACT_CFG_ADV_DATA: {
if (arg->cfg_adv_data.adv_data.set_scan_rsp == false) { if (arg->cfg_adv_data.adv_data.set_scan_rsp == false) {
btc_ble_set_adv_data(&arg->cfg_adv_data.adv_data, btc_adv_data_callback); btc_ble_set_adv_data(&arg->cfg_adv_data.adv_data, btc_adv_data_callback);
@ -1140,6 +1452,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_STOP_ADV: case BTC_GAP_BLE_ACT_STOP_ADV:
btc_ble_stop_advertising(btc_stop_adv_callback); btc_ble_stop_advertising(btc_stop_adv_callback);
break; break;
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM: case BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM:
btc_ble_update_conn_params(arg->conn_update_params.conn_params.bda, btc_ble_update_conn_params(arg->conn_update_params.conn_params.bda,
arg->conn_update_params.conn_params.min_int, arg->conn_update_params.conn_params.min_int,
@ -1175,14 +1488,17 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_READ_RSSI: case BTC_GAP_BLE_ACT_READ_RSSI:
BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback); BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
break; break;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_SET_CONN_PARAMS: case BTC_GAP_BLE_ACT_SET_CONN_PARAMS:
BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int, BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int,
arg->set_conn_params.max_conn_int, arg->set_conn_params.slave_latency, arg->set_conn_params.max_conn_int, arg->set_conn_params.slave_latency,
arg->set_conn_params.supervision_tout); arg->set_conn_params.supervision_tout);
break; break;
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_SET_DEV_NAME: case BTC_GAP_BLE_ACT_SET_DEV_NAME:
BTA_DmSetDeviceName(arg->set_dev_name.device_name); BTA_DmSetDeviceName(arg->set_dev_name.device_name);
break; break;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv, btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv,
arg->cfg_adv_data_raw.raw_adv_len, arg->cfg_adv_data_raw.raw_adv_len,
@ -1199,6 +1515,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
arg->update_duplicate_exceptional_list.device_info, arg->update_duplicate_exceptional_list.device_info,
btc_update_duplicate_exceptional_list_callback); btc_update_duplicate_exceptional_list_callback);
break; break;
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
#if (SMP_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE)
case BTC_GAP_BLE_SET_ENCRYPTION_EVT: { case BTC_GAP_BLE_SET_ENCRYPTION_EVT: {
BD_ADDR bd_addr; BD_ADDR bd_addr;
@ -1319,6 +1636,199 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_SET_AFH_CHANNELS: case BTC_GAP_BLE_SET_AFH_CHANNELS:
btc_gap_ble_set_channels(arg->set_channels.channels); btc_gap_ble_set_channels(arg->set_channels.channels);
break; break;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case BTC_GAP_BLE_READ_PHY:
BTC_TRACE_DEBUG("BTC_GAP_BLE_READ_PHY");
BTA_DmBleGapReadPHY(arg_5->read_phy.bd_addr);
break;
case BTC_GAP_BLE_SET_PREFERED_DEF_PHY:
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_PREFERED_DEF_PHY");
BTA_DmBleGapSetPreferedDefaultPHY(arg_5->set_perf_def_phy.tx_phy_mask,
arg_5->set_perf_def_phy.rx_phy_mask);
break;
case BTC_GAP_BLE_SET_DEF_PHY:
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_DEF_PHY");
BTA_DmBleGapSetPreferedPHY(arg_5->set_def_phy.bd_addr,
arg_5->set_def_phy.all_phys_mask,
arg_5->set_def_phy.tx_phy_mask,
arg_5->set_def_phy.rx_phy_mask,
arg_5->set_def_phy.phy_options);
break;
case BTC_GAP_BLE_SET_EXT_ADV_RAND_ADDR:
BTA_DmBleGapExtAdvSetRandaddr(arg_5->ext_adv_set_rand_addr.instance, arg_5->ext_adv_set_rand_addr.rand_addr);
break;
case BTC_GAP_BLE_SET_EXT_ADV_PARAMS: {
tBTA_DM_BLE_GAP_EXT_ADV_PARAMS params = {0};
params.type = arg_5->ext_adv_set_params.params.type;
params.interval_min = arg_5->ext_adv_set_params.params.interval_min;
params.interval_max = arg_5->ext_adv_set_params.params.interval_max;
params.channel_map = arg_5->ext_adv_set_params.params.channel_map;
params.own_addr_type = arg_5->ext_adv_set_params.params.own_addr_type;
params.peer_addr_type = arg_5->ext_adv_set_params.params.peer_addr_type;
params.filter_policy = arg_5->ext_adv_set_params.params.filter_policy;
params.tx_power = arg_5->ext_adv_set_params.params.tx_power;
params.primary_phy = arg_5->ext_adv_set_params.params.primary_phy;
params.max_skip = arg_5->ext_adv_set_params.params.max_skip;
params.secondary_phy = arg_5->ext_adv_set_params.params.secondary_phy;
params.sid = arg_5->ext_adv_set_params.params.sid;
params.scan_req_notif = arg_5->ext_adv_set_params.params.scan_req_notif;
memcpy(params.peer_addr, arg_5->ext_adv_set_params.params.peer_addr, sizeof(BD_ADDR));
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_EXT_ADV_PARAMS");
BTA_DmBleGapExtAdvSetParams(arg_5->ext_adv_set_params.instance,
(const tBTA_DM_BLE_GAP_EXT_ADV_PARAMS *)&params);
break;
}
case BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW:
BTC_TRACE_DEBUG("BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW");
BTA_DmBleGapConfigExtAdvDataRaw(FALSE, arg_5->ext_adv_cfg_data.instance,
arg_5->ext_adv_cfg_data.length,
(const UINT8 *)arg_5->ext_adv_cfg_data.data);
break;
case BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW:
BTC_TRACE_DEBUG("BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW");
BTA_DmBleGapConfigExtAdvDataRaw(TRUE, arg_5->ext_adv_cfg_data.instance,
arg_5->ext_adv_cfg_data.length,
(const UINT8 *)arg_5->ext_adv_cfg_data.data);
break;
case BTC_GAP_BLE_EXT_ADV_START: {
BTC_TRACE_DEBUG("BTC_GAP_BLE_EXT_ADV_START");
for (int k = 0; k < arg_5->ext_adv_start.num_adv; k++) {
BTC_TRACE_DEBUG("adv_handle[%d] = %d, duration[%d] = %d, max_adv_evt[%d] = %d", k, arg_5->ext_adv_start.ext_adv[k].instance, k,
arg_5->ext_adv_start.ext_adv[k].duration, k, arg_5->ext_adv_start.ext_adv[k].max_events);
}
BTA_DmBleGapExtAdvEnable(TRUE, arg_5->ext_adv_start.num_adv,
(tBTA_DM_BLE_EXT_ADV *)arg_5->ext_adv_start.ext_adv);
break;
}
case BTC_GAP_BLE_EXT_ADV_STOP: {
BTC_TRACE_DEBUG("BTC_GAP_BLE_EXT_ADV_STOP");
uint8_t num_adv = arg_5->ext_adv_stop.num_adv;
if(num_adv > 0) {
tBTA_DM_BLE_EXT_ADV *ext_adv = osi_malloc(num_adv * sizeof(esp_ble_gap_ext_adv_t));
if(ext_adv) {
for (uint8_t i = 0; i < num_adv; i++) {
ext_adv[i].instance = arg_5->ext_adv_stop.ext_adv_inst[i];
ext_adv[i].duration = 0;
ext_adv[i].max_events = 0;
}
BTA_DmBleGapExtAdvEnable(FALSE, num_adv, ext_adv);
osi_free(ext_adv);
} else {
BTC_TRACE_ERROR("%s no mem\n", __func__);
}
} else {
BTA_DmBleGapExtAdvEnable(FALSE, 0, NULL);
}
break;
}
case BTC_GAP_BLE_EXT_ADV_SET_REMOVE:
BTA_DmBleGapExtAdvSetRemove(arg_5->ext_adv_set_remove.instance);
break;
case BTC_GAP_BLE_EXT_ADV_SET_CLEAR:
BTA_DmBleGapExtAdvSetClear();
break;
case BTC_GAP_BLE_SET_PERIODIC_ADV_PARAMS: {
tBTA_DM_BLE_Periodic_Adv_Params params = {0};
params.interval_min = arg_5->peridic_adv_set_params.params.interval_min;
params.interval_max = arg_5->peridic_adv_set_params.params.interval_max;
params.properties = arg_5->peridic_adv_set_params.params.properties;
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_PERIODIC_ADV_PARAMS");
BTA_DmBleGapPeriodicAdvSetParams(arg_5->peridic_adv_set_params.instance,
&params);
break;
}
case BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW:
BTC_TRACE_DEBUG("BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW");
BTA_DmBleGapPeriodicAdvCfgDataRaw(arg_5->periodic_adv_cfg_data.instance,
arg_5->periodic_adv_cfg_data.len,
(const UINT8 *)arg_5->periodic_adv_cfg_data.data);
break;
case BTC_GAP_BLE_PERIODIC_ADV_START:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_START");
BTA_DmBleGapPeriodicAdvEnable(TRUE, arg_5->periodic_adv_start.instance);
break;
case BTC_GAP_BLE_PERIODIC_ADV_STOP:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_STOP");
BTA_DmBleGapPeriodicAdvEnable(FALSE, arg_5->periodic_adv_stop.instance);
break;
case BTC_GAP_BLE_PERIODIC_ADV_CREATE_SYNC: {
tBTA_DM_BLE_Periodic_Sync_Params params = {0};
params.filter_policy = arg_5->periodic_adv_create_sync.params.filter_policy;
params.sid = arg_5->periodic_adv_create_sync.params.sid;
params.addr_type = arg_5->periodic_adv_create_sync.params.addr_type;
params.skip = arg_5->periodic_adv_create_sync.params.skip;
params.sync_timeout = arg_5->periodic_adv_create_sync.params.sync_timeout;
memcpy(params.addr, arg_5->periodic_adv_create_sync.params.addr, sizeof(BD_ADDR));
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_CREATE_SYNC");
BTA_DmBleGapPeriodicAdvCreateSync(&params);
break;
}
case BTC_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL");
BTA_DmBleGapPeriodicAdvSyncCancel();
break;
case BTC_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE");
BTA_DmBleGapPeriodicAdvSyncTerm(arg_5->periodic_adv_sync_term.sync_handle);
break;
case BTC_GAP_BLE_PERIODIC_ADV_ADD_DEV_TO_LIST:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_ADD_DEV_TO_LIST");
BTA_DmBleGapPeriodicAdvAddDevToList(arg_5->periodic_adv_add_dev.addr_type,
arg_5->periodic_adv_add_dev.addr,
arg_5->periodic_adv_add_dev.sid);
break;
case BTC_GAP_BLE_PERIODIC_REMOVE_ADD_DEV_FROM_LIST:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_REMOVE_ADD_DEV_FROM_LIST");
BTA_DmBleGapPeriodicAdvRemoveDevFromList(arg_5->periodic_adv_remove_dev.addr_type,
arg_5->periodic_adv_remove_dev.addr,
arg_5->periodic_adv_remove_dev.sid);
break;
case BTC_GAP_BLE_PERIODIC_CLEAR_DEV:
BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_CLEAR_DEV");
BTA_DmBleGapPeriodicAdvClearDev();
break;
case BTC_GAP_BLE_SET_EXT_SCAN_PARAMS: {
tBTA_DM_BLE_EXT_SCAN_PARAMS params = {0};
params.own_addr_type = arg_5->set_ext_scan_params.params.own_addr_type;
params.filter_policy = arg_5->set_ext_scan_params.params.filter_policy;
params.scan_duplicate = arg_5->set_ext_scan_params.params.scan_duplicate;
params.cfg_mask = arg_5->set_ext_scan_params.params.cfg_mask;
if (params.cfg_mask & BTA_DM_BLE_GAP_EXT_SCAN_UNCODE_MASK) {
params.uncoded_cfg.scan_type = arg_5->set_ext_scan_params.params.uncoded_cfg.scan_type;
params.uncoded_cfg.scan_interval = arg_5->set_ext_scan_params.params.uncoded_cfg.scan_interval;
params.uncoded_cfg.scan_window = arg_5->set_ext_scan_params.params.uncoded_cfg.scan_window;
}
if (params.cfg_mask & BTA_DM_BLE_GAP_EXT_SCAN_CODE_MASK) {
params.coded_cfg.scan_type = arg_5->set_ext_scan_params.params.coded_cfg.scan_type;
params.coded_cfg.scan_interval = arg_5->set_ext_scan_params.params.coded_cfg.scan_interval;
params.coded_cfg.scan_window = arg_5->set_ext_scan_params.params.coded_cfg.scan_window;
}
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_EXT_SCAN_PARAMS");
BTA_DmBleGapSetExtScanParams(&params);
break;
}
case BTC_GAP_BLE_START_EXT_SCAN:
BTC_TRACE_DEBUG("BTC_GAP_BLE_START_EXT_SCAN");
BTA_DmBleGapExtScan(TRUE, arg_5->start_ext_scan.duration, arg_5->start_ext_scan.period);
break;
case BTC_GAP_BLE_STOP_EXT_SCAN:
BTC_TRACE_DEBUG("BTC_GAP_BLE_STOP_EXT_SCAN");
BTA_DmBleGapExtScan(FALSE, 0, 0);
break;
case BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS:
BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS");
BTA_DmBleGapPreferExtConnectParamsSet(arg_5->set_ext_conn_params.addr,
arg_5->set_ext_conn_params.phy_mask,
(const tBTA_DM_BLE_CONN_PARAMS *)&arg_5->set_ext_conn_params.phy_1m_conn_params,
(const tBTA_DM_BLE_CONN_PARAMS *)&arg_5->set_ext_conn_params.phy_2m_conn_params,
(const tBTA_DM_BLE_CONN_PARAMS *)&arg_5->set_ext_conn_params.phy_coded_conn_params);
break;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
default: default:
break; break;
} }
@ -1330,13 +1840,17 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
void btc_gap_callback_init(void) void btc_gap_callback_init(void)
{ {
BTM_BleRegiseterConnParamCallback(btc_update_conn_param_callback); BTM_BleRegiseterConnParamCallback(btc_update_conn_param_callback);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTM_BleGapRegisterCallback(btc_ble_5_gap_callback);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
} }
void btc_gap_ble_deinit(void) void btc_gap_ble_deinit(void)
{ {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
btc_cleanup_adv_data(&gl_bta_adv_data); btc_cleanup_adv_data(&gl_bta_adv_data);
btc_cleanup_adv_data(&gl_bta_scan_rsp_data); btc_cleanup_adv_data(&gl_bta_scan_rsp_data);
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
} }
#if SCAN_QUEUE_CONGEST_CHECK #if SCAN_QUEUE_CONGEST_CHECK

View File

@ -214,7 +214,9 @@ static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg)
static void btc_gattc_open(btc_ble_gattc_args_t *arg) static void btc_gattc_open(btc_ble_gattc_args_t *arg)
{ {
tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE; tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
BTA_GATTC_Open(arg->open.gattc_if, arg->open.remote_bda, arg->open.remote_addr_type, arg->open.is_direct, transport); BTA_GATTC_Open(arg->open.gattc_if, arg->open.remote_bda,
arg->open.remote_addr_type, arg->open.is_direct,
transport, arg->open.is_aux);
} }
static void btc_gattc_close(btc_ble_gattc_args_t *arg) static void btc_gattc_close(btc_ble_gattc_args_t *arg)
@ -711,6 +713,9 @@ void btc_gattc_call_handler(btc_msg_t *msg)
btc_gattc_app_unregister(arg); btc_gattc_app_unregister(arg);
break; break;
case BTC_GATTC_ACT_OPEN: case BTC_GATTC_ACT_OPEN:
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case BTC_GATTC_ACT_AUX_OPEN:
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
btc_gattc_open(arg); btc_gattc_open(arg);
break; break;
case BTC_GATTC_ACT_CLOSE: case BTC_GATTC_ACT_CLOSE:
@ -1012,4 +1017,16 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
btc_gattc_free_req_data(msg); btc_gattc_free_req_data(msg);
} }
void btc_gattc_congest_callback(tBTA_GATTC *param)
{
esp_ble_gattc_cb_param_t esp_param = {0};
memset(&esp_param, 0, sizeof(esp_ble_gattc_cb_param_t));
uint8_t gattc_if = BTC_GATT_GET_GATT_IF(param->congest.conn_id);
esp_param.congest.conn_id = BTC_GATT_GET_CONN_ID(param->congest.conn_id);
esp_param.congest.congested = (param->congest.congested == TRUE) ? true : false;
btc_gattc_cb_to_app(ESP_GATTC_CONGEST_EVT, gattc_if, &esp_param);
}
#endif ///GATTC_INCLUDED == TRUE #endif ///GATTC_INCLUDED == TRUE

View File

@ -29,13 +29,15 @@ extern tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr;
#define BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF)) #define BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
typedef enum { typedef enum {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0, BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0,
BTC_GAP_BLE_ACT_SET_SCAN_PARAM, BTC_GAP_BLE_ACT_SET_SCAN_PARAM,
BTC_GAP_BLE_ACT_START_SCAN, BTC_GAP_BLE_ACT_START_SCAN,
BTC_GAP_BLE_ACT_STOP_SCAN, BTC_GAP_BLE_ACT_STOP_SCAN,
BTC_GAP_BLE_ACT_START_ADV, BTC_GAP_BLE_ACT_START_ADV,
BTC_GAP_BLE_ACT_STOP_ADV, BTC_GAP_BLE_ACT_STOP_ADV,
BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM, #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM = 6,
BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN, BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN,
BTC_GAP_BLE_ACT_SET_RAND_ADDRESS, BTC_GAP_BLE_ACT_SET_RAND_ADDRESS,
BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS, BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS,
@ -43,11 +45,15 @@ typedef enum {
BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON, BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON,
BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST, BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST,
BTC_GAP_BLE_ACT_CLEAR_WHITE_LIST, BTC_GAP_BLE_ACT_CLEAR_WHITE_LIST,
#if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_SET_CONN_PARAMS, BTC_GAP_BLE_ACT_SET_CONN_PARAMS,
BTC_GAP_BLE_ACT_SET_DEV_NAME, #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_SET_DEV_NAME = 15,
#if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW, BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW, BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW,
BTC_GAP_BLE_ACT_READ_RSSI, #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_ACT_READ_RSSI = 18,
BTC_GAP_BLE_SET_ENCRYPTION_EVT, BTC_GAP_BLE_SET_ENCRYPTION_EVT,
BTC_GAP_BLE_SET_SECURITY_PARAM_EVT, BTC_GAP_BLE_SET_SECURITY_PARAM_EVT,
BTC_GAP_BLE_SECURITY_RSP_EVT, BTC_GAP_BLE_SECURITY_RSP_EVT,
@ -58,10 +64,38 @@ typedef enum {
BTC_GAP_BLE_OOB_REQ_REPLY_EVT, BTC_GAP_BLE_OOB_REQ_REPLY_EVT,
BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST, BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST,
BTC_GAP_BLE_SET_AFH_CHANNELS, BTC_GAP_BLE_SET_AFH_CHANNELS,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTC_GAP_BLE_READ_PHY,
BTC_GAP_BLE_SET_PREFERED_DEF_PHY,
BTC_GAP_BLE_SET_DEF_PHY,
BTC_GAP_BLE_SET_EXT_ADV_RAND_ADDR,
BTC_GAP_BLE_SET_EXT_ADV_PARAMS,
BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW,
BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW,
BTC_GAP_BLE_EXT_ADV_START,
BTC_GAP_BLE_EXT_ADV_STOP,
BTC_GAP_BLE_EXT_ADV_SET_REMOVE,
BTC_GAP_BLE_EXT_ADV_SET_CLEAR,
BTC_GAP_BLE_SET_PERIODIC_ADV_PARAMS,
BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW,
BTC_GAP_BLE_PERIODIC_ADV_START,
BTC_GAP_BLE_PERIODIC_ADV_STOP,
BTC_GAP_BLE_PERIODIC_ADV_CREATE_SYNC,
BTC_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL,
BTC_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE,
BTC_GAP_BLE_PERIODIC_ADV_ADD_DEV_TO_LIST,
BTC_GAP_BLE_PERIODIC_REMOVE_ADD_DEV_FROM_LIST,
BTC_GAP_BLE_PERIODIC_CLEAR_DEV,
BTC_GAP_BLE_SET_EXT_SCAN_PARAMS,
BTC_GAP_BLE_START_EXT_SCAN,
BTC_GAP_BLE_STOP_EXT_SCAN,
BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
} btc_gap_ble_act_t; } btc_gap_ble_act_t;
/* btc_ble_gap_args_t */ /* btc_ble_gap_args_t */
typedef union { typedef union {
#if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0, //BTC_GAP_BLE_ACT_CFG_ADV_DATA = 0,
struct config_adv_data_args { struct config_adv_data_args {
esp_ble_adv_data_t adv_data; esp_ble_adv_data_t adv_data;
@ -80,6 +114,7 @@ typedef union {
esp_ble_adv_params_t adv_params; esp_ble_adv_params_t adv_params;
} start_adv; } start_adv;
//BTC_GAP_BLE_ACT_STOP_ADV, no args //BTC_GAP_BLE_ACT_STOP_ADV, no args
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM, //BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM,
struct conn_update_params_args { struct conn_update_params_args {
esp_ble_conn_update_params_t conn_params; esp_ble_conn_update_params_t conn_params;
@ -107,6 +142,7 @@ typedef union {
esp_bd_addr_t remote_bda; esp_bd_addr_t remote_bda;
esp_ble_wl_addr_type_t wl_addr_type; esp_ble_wl_addr_type_t wl_addr_type;
} update_white_list; } update_white_list;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST //BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST
struct update_duplicate_exceptional_list_args { struct update_duplicate_exceptional_list_args {
uint8_t subcode; uint8_t subcode;
@ -121,11 +157,13 @@ typedef union {
uint16_t slave_latency; uint16_t slave_latency;
uint16_t supervision_tout; uint16_t supervision_tout;
} set_conn_params; } set_conn_params;
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_ACT_SET_DEV_NAME, //BTC_GAP_BLE_ACT_SET_DEV_NAME,
struct set_dev_name_args { struct set_dev_name_args {
#define ESP_GAP_DEVICE_NAME_MAX (32) #define ESP_GAP_DEVICE_NAME_MAX (32)
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1]; char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
} set_dev_name; } set_dev_name;
#if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW, //BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
struct config_adv_data_raw_args { struct config_adv_data_raw_args {
uint8_t *raw_adv; uint8_t *raw_adv;
@ -136,6 +174,7 @@ typedef union {
uint8_t *raw_scan_rsp; uint8_t *raw_scan_rsp;
uint32_t raw_scan_rsp_len; uint32_t raw_scan_rsp_len;
} cfg_scan_rsp_data_raw; } cfg_scan_rsp_data_raw;
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
//BTC_GAP_BLE_SET_ENCRYPTION_EVT //BTC_GAP_BLE_SET_ENCRYPTION_EVT
struct set_encryption_args { struct set_encryption_args {
esp_bd_addr_t bd_addr; esp_bd_addr_t bd_addr;
@ -186,6 +225,125 @@ typedef union {
esp_gap_ble_channels channels; esp_gap_ble_channels channels;
} set_channels; } set_channels;
} btc_ble_gap_args_t; } btc_ble_gap_args_t;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
typedef union {
struct read_phy_args {
esp_bd_addr_t bd_addr;
} read_phy;
struct set_perf_def_phy_args {
esp_ble_gap_phy_mask_t tx_phy_mask;
esp_ble_gap_phy_mask_t rx_phy_mask;
} set_perf_def_phy;
struct set_def_phy_args {
esp_bd_addr_t bd_addr;
esp_ble_gap_all_phys_t all_phys_mask;
esp_ble_gap_phy_mask_t tx_phy_mask;
esp_ble_gap_phy_mask_t rx_phy_mask;
uint16_t phy_options;
} set_def_phy;
struct ext_adv_set_rand_addr_args {
uint8_t instance;
esp_bd_addr_t rand_addr;
} ext_adv_set_rand_addr;
struct ext_adv_set_params_args {
uint8_t instance;
esp_ble_gap_ext_adv_params_t params;
} ext_adv_set_params;
struct ext_adv_cfg_data_args {
uint8_t instance;
uint16_t length;
uint8_t *data;
} ext_adv_cfg_data;
struct ext_adv_cfg_scan_rsp_args {
uint8_t instance;
uint16_t length;
uint8_t *data;
} cfg_scan_rsp;
struct ext_adv_start_args {
uint8_t num_adv;
esp_ble_gap_ext_adv_t *ext_adv;
} ext_adv_start;
struct ext_adv_stop_args {
uint8_t num_adv;
uint8_t *ext_adv_inst;
} ext_adv_stop;
struct ext_adv_set_remove_args {
uint8_t instance;
} ext_adv_set_remove;
struct peridic_adv_set_params_args {
uint8_t instance;
esp_ble_gap_periodic_adv_params_t params;
} peridic_adv_set_params;
struct periodic_adv_cfg_data_args {
uint8_t instance;
uint16_t len;
uint8_t *data;
} periodic_adv_cfg_data;
struct periodic_adv_start_args {
uint8_t instance;
} periodic_adv_start;
struct periodic_adv_stop_args {
uint8_t instance;
} periodic_adv_stop;
struct periodic_adv_create_sync_args {
esp_ble_gap_periodic_adv_sync_params_t params;
} periodic_adv_create_sync;
struct periodic_adv_sync_term_args {
uint16_t sync_handle;
} periodic_adv_sync_term;
struct periodic_adv_add_dev_args {
esp_ble_addr_type_t addr_type;
esp_bd_addr_t addr;
uint16_t sid;
} periodic_adv_add_dev;
struct periodic_adv_remove_dev_args {
esp_ble_addr_type_t addr_type;
esp_bd_addr_t addr;
uint16_t sid;
} periodic_adv_remove_dev;
struct set_ext_scan_params_args {
esp_ble_ext_scan_params_t params;
} set_ext_scan_params;
struct start_ext_scan_args {
uint32_t duration;
uint16_t period;
} start_ext_scan;
struct set_ext_conn_params_args {
esp_bd_addr_t addr;
uint8_t phy_mask;
esp_ble_gap_conn_params_t phy_1m_conn_params;
esp_ble_gap_conn_params_t phy_2m_conn_params;
esp_ble_gap_conn_params_t phy_coded_conn_params;
} set_ext_conn_params;
struct ext_conn_args {
esp_ble_addr_type_t own_addr_type;
esp_bd_addr_t peer_addr;
} ext_conn;
} btc_ble_5_gap_args_t;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
void btc_gap_ble_call_handler(btc_msg_t *msg); void btc_gap_ble_call_handler(btc_msg_t *msg);
void btc_gap_ble_cb_handler(btc_msg_t *msg); void btc_gap_ble_cb_handler(btc_msg_t *msg);

View File

@ -24,6 +24,9 @@ typedef enum {
BTC_GATTC_ACT_APP_REGISTER = 0, BTC_GATTC_ACT_APP_REGISTER = 0,
BTC_GATTC_ACT_APP_UNREGISTER, BTC_GATTC_ACT_APP_UNREGISTER,
BTC_GATTC_ACT_OPEN, BTC_GATTC_ACT_OPEN,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTC_GATTC_ACT_AUX_OPEN,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BTC_GATTC_ACT_CLOSE, BTC_GATTC_ACT_CLOSE,
BTC_GATTC_ACT_CFG_MTU, BTC_GATTC_ACT_CFG_MTU,
BTC_GATTC_ACT_SEARCH_SERVICE, BTC_GATTC_ACT_SEARCH_SERVICE,
@ -60,6 +63,7 @@ typedef union {
esp_bd_addr_t remote_bda; esp_bd_addr_t remote_bda;
esp_ble_addr_type_t remote_addr_type; esp_ble_addr_type_t remote_addr_type;
bool is_direct; bool is_direct;
bool is_aux;
} open; } open;
//BTC_GATTC_ACT_CLOSE, //BTC_GATTC_ACT_CLOSE,
struct close_arg { struct close_arg {

View File

@ -88,6 +88,24 @@
#define UC_BT_BLE_ENABLED FALSE #define UC_BT_BLE_ENABLED FALSE
#endif #endif
#ifdef CONFIG_BT_BLE_RPA_SUPPORTED
#define UC_BT_BLE_RPA_SUPPORTED CONFIG_BT_BLE_RPA_SUPPORTED
#else
#define UC_BT_BLE_RPA_SUPPORTED FALSE
#endif
#ifdef CONFIG_BT_BLE_50_FEATURES_SUPPORTED
#define UC_BT_BLE_50_FEATURES_SUPPORTED CONFIG_BT_BLE_50_FEATURES_SUPPORTED
#else
#define UC_BT_BLE_50_FEATURES_SUPPORTED FALSE
#endif
#ifdef CONFIG_BT_BLE_42_FEATURES_SUPPORTED
#define UC_BT_BLE_42_FEATURES_SUPPORTED CONFIG_BT_BLE_42_FEATURES_SUPPORTED
#else
#define UC_BT_BLE_42_FEATURES_SUPPORTED FALSE
#endif
//GATTS //GATTS
#ifdef CONFIG_BT_GATTS_ENABLE #ifdef CONFIG_BT_GATTS_ENABLE
#define UC_BT_GATTS_ENABLE CONFIG_BT_GATTS_ENABLE #define UC_BT_GATTS_ENABLE CONFIG_BT_GATTS_ENABLE

View File

@ -160,6 +160,24 @@
#define BLE_INCLUDED FALSE #define BLE_INCLUDED FALSE
#endif /* UC_BT_BLE_ENABLED */ #endif /* UC_BT_BLE_ENABLED */
#if (UC_BT_BLE_50_FEATURES_SUPPORTED == TRUE)
#define BLE_50_FEATURE_SUPPORT TRUE
#else
#define BLE_50_FEATURE_SUPPORT FALSE
#endif
#if (UC_BT_BLE_42_FEATURES_SUPPORTED == TRUE || BLE_50_FEATURE_SUPPORT == FALSE)
#define BLE_42_FEATURE_SUPPORT TRUE
#else
#define BLE_42_FEATURE_SUPPORT FALSE
#endif
#if (UC_BT_BLE_RPA_SUPPORTED == TRUE)
#define CONTROLLER_RPA_LIST_ENABLE TRUE
#else
#define CONTROLLER_RPA_LIST_ENABLE FALSE
#endif
#if (UC_BT_GATTS_ENABLE) #if (UC_BT_GATTS_ENABLE)
#define GATTS_INCLUDED TRUE #define GATTS_INCLUDED TRUE
#else #else
@ -203,7 +221,7 @@
#endif /* UC_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE */ #endif /* UC_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE */
#ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP #ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
#define BLE_ADV_REPORT_FLOW_CONTROL UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP #define BLE_ADV_REPORT_FLOW_CONTROL (UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP && BLE_INCLUDED)
#endif /* UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP */ #endif /* UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP */
#ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM #ifdef UC_BTDM_BLE_ADV_REPORT_FLOW_CTRL_NUM

View File

@ -29,8 +29,11 @@
#include "stack/btm_ble_api.h" #include "stack/btm_ble_api.h"
#include "device/version.h" #include "device/version.h"
#include "osi/future.h" #include "osi/future.h"
#if (BLE_50_FEATURE_SUPPORT == TRUE)
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x0f\xff\xff" };
#else
const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" }; const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" };
#endif
#if (BLE_INCLUDED) #if (BLE_INCLUDED)
const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT }; const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT };
@ -45,6 +48,7 @@ const uint8_t SCO_HOST_BUFFER_SIZE = 0xff;
#define MAX_FEATURES_CLASSIC_PAGE_COUNT 3 #define MAX_FEATURES_CLASSIC_PAGE_COUNT 3
#define BLE_SUPPORTED_STATES_SIZE 8 #define BLE_SUPPORTED_STATES_SIZE 8
#define BLE_SUPPORTED_FEATURES_SIZE 8 #define BLE_SUPPORTED_FEATURES_SIZE 8
#define BLE_EXT_ADV_DATA_LEN_MAX 1650
typedef struct { typedef struct {
const hci_t *hci; const hci_t *hci;
@ -77,6 +81,9 @@ typedef struct {
bool ble_supported; bool ble_supported;
bool simple_pairing_supported; bool simple_pairing_supported;
bool secure_connections_supported; bool secure_connections_supported;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
uint16_t ble_ext_adv_data_max_len;
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
} controller_local_param_t; } controller_local_param_t;
#if BT_BLE_DYNAMIC_ENV_MEMORY == FALSE #if BT_BLE_DYNAMIC_ENV_MEMORY == FALSE
@ -98,11 +105,13 @@ static void start_up(void)
response = AWAIT_COMMAND(controller_param.packet_factory->make_reset()); response = AWAIT_COMMAND(controller_param.packet_factory->make_reset());
controller_param.packet_parser->parse_generic_command_complete(response); controller_param.packet_parser->parse_generic_command_complete(response);
#if (CLASSIC_BT_INCLUDED)
// Request the classic buffer size next // Request the classic buffer size next
response = AWAIT_COMMAND(controller_param.packet_factory->make_read_buffer_size()); response = AWAIT_COMMAND(controller_param.packet_factory->make_read_buffer_size());
controller_param.packet_parser->parse_read_buffer_size_response( controller_param.packet_parser->parse_read_buffer_size_response(
response, &controller_param.acl_data_size_classic, &controller_param.acl_buffer_count_classic, response, &controller_param.acl_data_size_classic, &controller_param.acl_buffer_count_classic,
&controller_param.sco_data_size, &controller_param.sco_buffer_count); &controller_param.sco_data_size, &controller_param.sco_buffer_count);
#endif
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE) #if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
// Enable controller to host flow control // Enable controller to host flow control
@ -144,6 +153,7 @@ static void start_up(void)
HCI_SUPPORTED_COMMANDS_ARRAY_SIZE HCI_SUPPORTED_COMMANDS_ARRAY_SIZE
); );
#if (CLASSIC_BT_INCLUDED)
// Read page 0 of the controller features next // Read page 0 of the controller features next
uint8_t page_number = 0; uint8_t page_number = 0;
response = AWAIT_COMMAND(controller_param.packet_factory->make_read_local_extended_features(page_number)); response = AWAIT_COMMAND(controller_param.packet_factory->make_read_local_extended_features(page_number));
@ -157,6 +167,7 @@ static void start_up(void)
assert(page_number == 0); assert(page_number == 0);
page_number++; page_number++;
#endif
// Inform the controller what page 0 features we support, based on what // Inform the controller what page 0 features we support, based on what
// it told us it supports. We need to do this first before we request the // it told us it supports. We need to do this first before we request the
@ -184,6 +195,7 @@ static void start_up(void)
} }
#endif #endif
#if (CLASSIC_BT_INCLUDED)
// Done telling the controller about what page 0 features we support // Done telling the controller about what page 0 features we support
// Request the remaining feature pages // Request the remaining feature pages
while (page_number <= controller_param.last_features_classic_page_index && while (page_number <= controller_param.last_features_classic_page_index &&
@ -199,6 +211,7 @@ static void start_up(void)
page_number++; page_number++;
} }
#endif
#if (SC_MODE_INCLUDED == TRUE) #if (SC_MODE_INCLUDED == TRUE)
controller_param.secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(controller_param.features_classic[2].as_array); controller_param.secure_connections_supported = HCI_SC_CTRLR_SUPPORTED(controller_param.features_classic[2].as_array);
@ -209,7 +222,11 @@ static void start_up(void)
#endif #endif
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
#if (CLASSIC_BT_INCLUDED)
controller_param.ble_supported = controller_param.last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(controller_param.features_classic[1].as_array); controller_param.ble_supported = controller_param.last_features_classic_page_index >= 1 && HCI_LE_HOST_SUPPORTED(controller_param.features_classic[1].as_array);
#else
controller_param.ble_supported = true;
#endif
if (controller_param.ble_supported) { if (controller_param.ble_supported) {
// Request the ble white list size next // Request the ble white list size next
response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_white_list_size()); response = AWAIT_COMMAND(controller_param.packet_factory->make_ble_read_white_list_size());
@ -249,6 +266,18 @@ static void start_up(void)
response, response,
&controller_param.ble_resolving_list_max_size); &controller_param.ble_resolving_list_max_size);
} }
#if BLE_50_FEATURE_SUPPORT == TRUE
controller_param.ble_ext_adv_data_max_len = BLE_EXT_ADV_DATA_LEN_MAX;
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
if (HCI_LE_ENHANCED_PRIVACY_SUPPORTED(controller_param.features_ble.as_array)) {
response = AWAIT_COMMAND(controller_param.packet_factory->make_read_max_adv_data_len());
controller_param.packet_parser->parse_ble_read_adv_max_len_response(
response,
&controller_param.ble_ext_adv_data_max_len);
}
#endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) { if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) {
/* set default tx data length to MAX 251 */ /* set default tx data length to MAX 251 */
@ -480,7 +509,15 @@ static void set_ble_resolving_list_max_size(int resolving_list_max_size)
assert(controller_param.ble_supported); assert(controller_param.ble_supported);
controller_param.ble_resolving_list_max_size = resolving_list_max_size; controller_param.ble_resolving_list_max_size = resolving_list_max_size;
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static uint16_t ble_get_ext_adv_data_max_len(void)
{
assert(controller_param.readable);
assert(controller_param.ble_supported);
return controller_param.ble_ext_adv_data_max_len;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
static uint8_t get_sco_data_size(void) static uint8_t get_sco_data_size(void)
{ {
@ -538,6 +575,9 @@ static const controller_t interface = {
get_ble_resolving_list_max_size, get_ble_resolving_list_max_size,
set_ble_resolving_list_max_size, set_ble_resolving_list_max_size,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
ble_get_ext_adv_data_max_len,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
get_sco_data_size, get_sco_data_size,
get_sco_buffer_count, get_sco_buffer_count,

View File

@ -79,6 +79,11 @@ typedef struct controller_t {
uint8_t (*get_ble_resolving_list_max_size)(void); uint8_t (*get_ble_resolving_list_max_size)(void);
void (*set_ble_resolving_list_max_size)(int resolving_list_max_size); void (*set_ble_resolving_list_max_size)(int resolving_list_max_size);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
uint16_t (*ble_get_ext_adv_data_max_len)(void);
#endif // BLE_50_FEATURE_SUPPORT
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
// Get the number of sco packets the controller can buffer // Get the number of sco packets the controller can buffer
uint8_t (*get_sco_data_size)(void); uint8_t (*get_sco_data_size)(void);

View File

@ -16,7 +16,9 @@
* *
******************************************************************************/ ******************************************************************************/
#include <string.h> #include <string.h>
#include "sdkconfig.h"
#include "esp_bt.h" #include "esp_bt.h"
#include "common/bt_defs.h" #include "common/bt_defs.h"
#include "common/bt_trace.h" #include "common/bt_trace.h"
#include "stack/hcidefs.h" #include "stack/hcidefs.h"
@ -178,6 +180,9 @@ static int hci_layer_init_env(void)
HCI_TRACE_ERROR("%s unable to create command response timer.", __func__); HCI_TRACE_ERROR("%s unable to create command response timer.", __func__);
return -1; return -1;
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
btsnd_hcic_ble_sync_sem_init();
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
return 0; return 0;
} }
@ -198,6 +203,9 @@ static void hci_layer_deinit_env(void)
osi_mutex_free(&cmd_wait_q->commands_pending_response_lock); osi_mutex_free(&cmd_wait_q->commands_pending_response_lock);
osi_alarm_free(cmd_wait_q->command_response_timer); osi_alarm_free(cmd_wait_q->command_response_timer);
cmd_wait_q->command_response_timer = NULL; cmd_wait_q->command_response_timer = NULL;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
btsnd_hcic_ble_sync_sem_deinit();
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
} }
static void hci_host_thread_handler(void *arg) static void hci_host_thread_handler(void *arg)
@ -431,6 +439,11 @@ static bool filter_incoming_event(BT_HDR *packet)
HCI_TRACE_WARNING("%s command complete event with no matching command. opcode: 0x%x.", __func__, opcode); HCI_TRACE_WARNING("%s command complete event with no matching command. opcode: 0x%x.", __func__, opcode);
} else if (wait_entry->complete_callback) { } else if (wait_entry->complete_callback) {
wait_entry->complete_callback(packet, wait_entry->context); wait_entry->complete_callback(packet, wait_entry->context);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
if (wait_entry->command->sem) {
osi_sem_give(&wait_entry->command->sem);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
} else if (wait_entry->complete_future) { } else if (wait_entry->complete_future) {
future_ready(wait_entry->complete_future, packet); future_ready(wait_entry->complete_future, packet);
} }

View File

@ -93,6 +93,11 @@ static BT_HDR *make_read_local_supported_commands(void)
return make_command_no_params(HCI_READ_LOCAL_SUPPORTED_CMDS); return make_command_no_params(HCI_READ_LOCAL_SUPPORTED_CMDS);
} }
static BT_HDR *make_read_local_supported_features(void)
{
return make_command_no_params(HCI_READ_LOCAL_FEATURES);
}
static BT_HDR *make_read_local_extended_features(uint8_t page_number) static BT_HDR *make_read_local_extended_features(uint8_t page_number)
{ {
uint8_t *stream; uint8_t *stream;
@ -214,6 +219,12 @@ static BT_HDR *make_write_default_erroneous_data_report(uint8_t enable)
UINT8_TO_STREAM(stream, enable); UINT8_TO_STREAM(stream, enable);
return packet; return packet;
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static BT_HDR *make_read_max_adv_data_len(void)
{
return make_command_no_params(HCI_BLE_RD_MAX_ADV_DATA_LEN);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
// Internal functions // Internal functions
static BT_HDR *make_command_no_params(uint16_t opcode) static BT_HDR *make_command_no_params(uint16_t opcode)
@ -256,6 +267,7 @@ static const hci_packet_factory_t interface = {
make_read_local_version_info, make_read_local_version_info,
make_read_bd_addr, make_read_bd_addr,
make_read_local_supported_commands, make_read_local_supported_commands,
make_read_local_supported_features,
make_read_local_extended_features, make_read_local_extended_features,
make_write_simple_pairing_mode, make_write_simple_pairing_mode,
make_write_secure_connections_host_support, make_write_secure_connections_host_support,
@ -266,6 +278,9 @@ static const hci_packet_factory_t interface = {
make_ble_read_supported_states, make_ble_read_supported_states,
make_ble_read_local_supported_features, make_ble_read_local_supported_features,
make_ble_read_resolving_list_size, make_ble_read_resolving_list_size,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
make_read_max_adv_data_len,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
make_ble_read_suggested_default_data_length, make_ble_read_suggested_default_data_length,
make_ble_write_suggested_default_data_length, make_ble_write_suggested_default_data_length,
make_ble_set_event_mask, make_ble_set_event_mask,

View File

@ -95,6 +95,17 @@ static void parse_read_local_supported_commands_response(
osi_free(response); osi_free(response);
} }
static void parse_read_local_supported_features_response(
BT_HDR *response,
bt_device_features_t *feature_pages)
{
uint8_t *stream = read_command_complete_header(response, HCI_READ_LOCAL_FEATURES, sizeof(bt_device_features_t) /* bytes after */);
if (stream != NULL) {
STREAM_TO_ARRAY(feature_pages->as_array, stream, (int)sizeof(bt_device_features_t));
}
osi_free(response);
}
static void parse_read_local_extended_features_response( static void parse_read_local_extended_features_response(
BT_HDR *response, BT_HDR *response,
uint8_t *page_number_ptr, uint8_t *page_number_ptr,
@ -191,6 +202,19 @@ static void parse_ble_read_suggested_default_data_length_response(
STREAM_TO_UINT16(*ble_default_packet_txtime_ptr, stream); STREAM_TO_UINT16(*ble_default_packet_txtime_ptr, stream);
osi_free(response); osi_free(response);
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static void parse_ble_read_adv_max_len_response(
BT_HDR *response,
uint16_t *adv_max_len_ptr)
{
uint8_t *stream = read_command_complete_header(response, HCI_BLE_RD_MAX_ADV_DATA_LEN, 1 /* bytes after */);
STREAM_TO_UINT8(*adv_max_len_ptr, stream);
osi_free(response);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
// Internal functions // Internal functions
@ -241,12 +265,16 @@ static const hci_packet_parser_t interface = {
parse_read_local_version_info_response, parse_read_local_version_info_response,
parse_read_bd_addr_response, parse_read_bd_addr_response,
parse_read_local_supported_commands_response, parse_read_local_supported_commands_response,
parse_read_local_supported_features_response,
parse_read_local_extended_features_response, parse_read_local_extended_features_response,
parse_ble_read_white_list_size_response, parse_ble_read_white_list_size_response,
parse_ble_read_buffer_size_response, parse_ble_read_buffer_size_response,
parse_ble_read_supported_states_response, parse_ble_read_supported_states_response,
parse_ble_read_local_supported_features_response, parse_ble_read_local_supported_features_response,
parse_ble_read_resolving_list_size_response, parse_ble_read_resolving_list_size_response,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
parse_ble_read_adv_max_len_response,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
parse_ble_read_suggested_default_data_length_response parse_ble_read_suggested_default_data_length_response
}; };

View File

@ -31,6 +31,7 @@ typedef struct {
BT_HDR *(*make_read_local_version_info)(void); BT_HDR *(*make_read_local_version_info)(void);
BT_HDR *(*make_read_bd_addr)(void); BT_HDR *(*make_read_bd_addr)(void);
BT_HDR *(*make_read_local_supported_commands)(void); BT_HDR *(*make_read_local_supported_commands)(void);
BT_HDR *(*make_read_local_supported_features)(void);
BT_HDR *(*make_read_local_extended_features)(uint8_t page_number); BT_HDR *(*make_read_local_extended_features)(uint8_t page_number);
BT_HDR *(*make_write_simple_pairing_mode)(uint8_t mode); BT_HDR *(*make_write_simple_pairing_mode)(uint8_t mode);
BT_HDR *(*make_write_secure_connections_host_support)(uint8_t mode); BT_HDR *(*make_write_secure_connections_host_support)(uint8_t mode);
@ -41,6 +42,9 @@ typedef struct {
BT_HDR *(*make_ble_read_supported_states)(void); BT_HDR *(*make_ble_read_supported_states)(void);
BT_HDR *(*make_ble_read_local_supported_features)(void); BT_HDR *(*make_ble_read_local_supported_features)(void);
BT_HDR *(*make_ble_read_resolving_list_size)(void); BT_HDR *(*make_ble_read_resolving_list_size)(void);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BT_HDR *(*make_read_max_adv_data_len)(void);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BT_HDR *(*make_ble_read_suggested_default_data_length)(void); BT_HDR *(*make_ble_read_suggested_default_data_length)(void);
BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime); BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime);
BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask); BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask);

View File

@ -55,6 +55,11 @@ typedef struct {
size_t supported_commands_length size_t supported_commands_length
); );
void (*parse_read_local_supported_features_response)(
BT_HDR *response,
bt_device_features_t *feature_pages
);
void (*parse_read_local_extended_features_response)( void (*parse_read_local_extended_features_response)(
BT_HDR *response, BT_HDR *response,
uint8_t *page_number_ptr, uint8_t *page_number_ptr,
@ -89,7 +94,12 @@ typedef struct {
BT_HDR *response, BT_HDR *response,
uint8_t *resolving_list_size_ptr uint8_t *resolving_list_size_ptr
); );
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void (*parse_ble_read_adv_max_len_response) (
BT_HDR *respone,
uint16_t *ble_ext_adv_data_max_len_ptr
);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
void (*parse_ble_read_suggested_default_data_length_response)( void (*parse_ble_read_suggested_default_data_length_response)(
BT_HDR *response, BT_HDR *response,
uint16_t *ble_default_packet_length_ptr, uint16_t *ble_default_packet_length_ptr,

View File

@ -781,6 +781,52 @@ void btm_ble_test_command_complete(UINT8 *p)
} }
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
/*******************************************************************************
**
** Function BTM_BleEnhancedReceiverTest
**
** Description This function is called to start the LE Enhanced Receiver test
**
** Parameter rx_freq - Frequency Range
** phy - The type of phy that receives data
** modulation_index - modulation index
** p_cmd_cmpl_cback - Command Complete callback
**
*******************************************************************************/
void BTM_BleEnhancedReceiverTest(UINT8 rx_freq, UINT8 phy, UINT8 modulation_index, tBTM_CMPL_CB *p_cmd_cmpl_cback)
{
btm_cb.devcb.p_le_test_cmd_cmpl_cb = p_cmd_cmpl_cback;
if (btsnd_hcic_ble_enhand_rx_test(rx_freq, phy, modulation_index) == FALSE) {
BTM_TRACE_ERROR("%s: Unable to Trigger LE enhanced receiver test", __FUNCTION__);
}
}
/*******************************************************************************
**
** Function BTM_BleEnhancedTransmitterTest
**
** Description This function is called to start the LE Enhanced Transmitter test
**
** Parameter tx_freq - Frequency Range
** test_data_len - Length in bytes of payload data in each packet
** packet_payload - Pattern to use in the payload
** phy - The type of phy that sends data
** p_cmd_cmpl_cback - Command Complete callback
**
*******************************************************************************/
void BTM_BleEnhancedTransmitterTest(UINT8 tx_freq, UINT8 test_data_len,
UINT8 packet_payload, UINT8 phy, tBTM_CMPL_CB *p_cmd_cmpl_cback)
{
btm_cb.devcb.p_le_test_cmd_cmpl_cb = p_cmd_cmpl_cback;
if (btsnd_hcic_ble_enhand_tx_test(tx_freq, test_data_len, packet_payload, phy) == FALSE) {
BTM_TRACE_ERROR("%s: Unable to Trigger LE enhanced transmitter test", __FUNCTION__);
}
}
#endif // BLE_50_FEATURE_SUPPORT
/******************************************************************************* /*******************************************************************************
** **
** Function BTM_UseLeLink ** Function BTM_UseLeLink
@ -1956,8 +2002,11 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
* Once the connection is successful, resolve device address whether it is * Once the connection is successful, resolve device address whether it is
* slave or master*/ * slave or master*/
/* if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) { */ #if CONTROLLER_RPA_LIST_ENABLE
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) { if (!match && role == HCI_ROLE_SLAVE && bda_type != BLE_ADDR_PUBLIC && BTM_BLE_IS_RESOLVE_BDA(bda)) {
#else
if (!match && bda_type != BLE_ADDR_PUBLIC && BTM_BLE_IS_RESOLVE_BDA(bda)) {
#endif
// save the enhanced value to used in btm_ble_resolve_random_addr_on_conn_cmpl func. // save the enhanced value to used in btm_ble_resolve_random_addr_on_conn_cmpl func.
temp_enhanced = enhanced; temp_enhanced = enhanced;
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl, p_data); btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl, p_data);

File diff suppressed because it is too large Load Diff

View File

@ -285,6 +285,20 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
} }
return FALSE; return FALSE;
} }
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR));
memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR));
// look for public address information
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
// p_dev_rec is created at bluetooth initialization, p_dev_rec->ble.static_addr maybe be all 0 before pairing
if(p_dev_rec && memcmp(invalid_rand_addr_b, p_dev_rec->ble.static_addr, BD_ADDR_LEN) != 0) {
memcpy(bd_addr, p_dev_rec->ble.static_addr, BD_ADDR_LEN);
addr_type = p_dev_rec->ble.static_addr_type;
}
// white list must be public address or static random address
if(addr_type == BLE_ADDR_RANDOM) { if(addr_type == BLE_ADDR_RANDOM) {
/* /*
A static address is a 48-bit randomly generated address and shall meet the following requirements: A static address is a 48-bit randomly generated address and shall meet the following requirements:
@ -292,9 +306,6 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
All bits of the random part of the address shall not be equal to 1 All bits of the random part of the address shall not be equal to 1
All bits of the random part of the address shall not be equal to 0 All bits of the random part of the address shall not be equal to 0
*/ */
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR));
memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR));
invalid_rand_addr_b[0] = invalid_rand_addr_b[0] | BT_STATIC_RAND_ADDR_MASK; invalid_rand_addr_b[0] = invalid_rand_addr_b[0] | BT_STATIC_RAND_ADDR_MASK;
if((bd_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK if((bd_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK
&& memcmp(invalid_rand_addr_a, bd_addr, BD_ADDR_LEN) != 0 && memcmp(invalid_rand_addr_a, bd_addr, BD_ADDR_LEN) != 0
@ -624,7 +635,7 @@ void btm_ble_initiate_select_conn(BD_ADDR bda)
BTM_TRACE_EVENT ("btm_ble_initiate_select_conn"); BTM_TRACE_EVENT ("btm_ble_initiate_select_conn");
/* use direct connection procedure to initiate connection */ /* use direct connection procedure to initiate connection */
if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE)) { if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE, FALSE)) {
BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed"); BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed");
} }
} }

View File

@ -463,7 +463,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
/* assume observe always not using white list */ /* assume observe always not using white list */
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* enable resolving list */ /* enable resolving list */
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN); //btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
#endif #endif
if (cmn_ble_gap_vsc_cb.extended_scan_support == 0) { if (cmn_ble_gap_vsc_cb.extended_scan_support == 0) {
@ -539,7 +539,7 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
/* assume observe always not using white list */ /* assume observe always not using white list */
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* enable resolving list */ /* enable resolving list */
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN); //btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
#endif #endif
// if not set scan params, set default scan params // if not set scan params, set default scan params
if (!p_inq->scan_params_set) { if (!p_inq->scan_params_set) {
@ -874,6 +874,8 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
(*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS); (*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS);
random_cb->set_local_privacy_cback = NULL; random_cb->set_local_privacy_cback = NULL;
} }
// Disable RPA function
btsnd_hcic_ble_set_addr_resolution_enable(FALSE);
} else { /* privacy is turned on*/ } else { /* privacy is turned on*/
/* always set host random address, used when privacy 1.1 or priavcy 1.2 is disabled */ /* always set host random address, used when privacy 1.1 or priavcy 1.2 is disabled */
btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low); btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low);
@ -892,6 +894,8 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
} else { /* 4.1/4.0 controller */ } else { /* 4.1/4.0 controller */
p_cb->privacy_mode = BTM_PRIVACY_1_1; p_cb->privacy_mode = BTM_PRIVACY_1_1;
} }
// Disable RPA function
btsnd_hcic_ble_set_addr_resolution_enable(TRUE);
} }
#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) #if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE)
@ -1193,7 +1197,7 @@ static UINT8 btm_set_conn_mode_adv_init_addr(tBTM_BLE_INQ_CB *p_cb,
/* only do so for bonded device */ /* only do so for bonded device */
if ((p_dev_rec = btm_find_or_alloc_dev (p_cb->direct_bda.bda)) != NULL && if ((p_dev_rec = btm_find_or_alloc_dev (p_cb->direct_bda.bda)) != NULL &&
p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) { p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) {
btm_ble_enable_resolving_list(BTM_BLE_RL_ADV); //btm_ble_enable_resolving_list(BTM_BLE_RL_ADV);
memcpy(p_peer_addr_ptr, p_dev_rec->ble.static_addr, BD_ADDR_LEN); memcpy(p_peer_addr_ptr, p_dev_rec->ble.static_addr, BD_ADDR_LEN);
*p_peer_addr_type = p_dev_rec->ble.static_addr_type; *p_peer_addr_type = p_dev_rec->ble.static_addr_type;
*p_own_addr_type = BLE_ADDR_RANDOM_ID; *p_own_addr_type = BLE_ADDR_RANDOM_ID;
@ -2707,7 +2711,7 @@ tBTM_STATUS btm_ble_start_inquiry (UINT8 mode, UINT8 duration)
SP_ADV_ALL); SP_ADV_ALL);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* enable IRK list */ /* enable IRK list */
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN); //btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
#endif #endif
status = btm_ble_start_scan(); status = btm_ble_start_scan();
} else if ((p_ble_cb->inq_var.scan_interval != BTM_BLE_LOW_LATENCY_SCAN_INT) || } else if ((p_ble_cb->inq_var.scan_interval != BTM_BLE_LOW_LATENCY_SCAN_INT) ||
@ -3003,7 +3007,7 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
{ {
tBTM_BLE_INQ_CB *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var; tBTM_BLE_INQ_CB *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
UINT8 *p_cache; UINT8 *p_cache;
UINT8 length; //UINT8 length;
/* cache adv report/scan response data */ /* cache adv report/scan response data */
if (evt_type != BTM_BLE_SCAN_RSP_EVT) { if (evt_type != BTM_BLE_SCAN_RSP_EVT) {
@ -3024,17 +3028,9 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
if (data_len > 0) { if (data_len > 0) {
p_cache = &p_le_inq_cb->adv_data_cache[p_le_inq_cb->adv_len]; p_cache = &p_le_inq_cb->adv_data_cache[p_le_inq_cb->adv_len];
STREAM_TO_UINT8(length, p); if((data_len + p_le_inq_cb->adv_len) <= BTM_BLE_CACHE_ADV_DATA_MAX) {
while ( length && ((p_le_inq_cb->adv_len + length + 1) <= BTM_BLE_CACHE_ADV_DATA_MAX)) { memcpy(p_cache, p, data_len);
/* copy from the length byte & data into cache */ p_le_inq_cb->adv_len += data_len;
memcpy(p_cache, p - 1, length + 1);
/* advance the cache pointer past data */
p_cache += length + 1;
/* increment cache length */
p_le_inq_cb->adv_len += length + 1;
/* skip the length of data */
p += length;
STREAM_TO_UINT8(length, p);
} }
} }
@ -3443,9 +3439,11 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
UINT8 data_len; UINT8 data_len;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
BOOLEAN match = FALSE; BOOLEAN match = FALSE;
#if (!CONTROLLER_RPA_LIST_ENABLE)
BD_ADDR temp_bda; BD_ADDR temp_bda;
UINT8 temp_addr_type = 0; UINT8 temp_addr_type = 0;
#endif #endif // (!CONTROLLER_RPA_LIST_ENABLE)
#endif//(defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* Only process the results if the inquiry is still active */ /* Only process the results if the inquiry is still active */
if (!BTM_BLE_IS_SCAN_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) { if (!BTM_BLE_IS_SCAN_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) {
@ -3463,8 +3461,11 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
//BTM_TRACE_ERROR("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x\n", //BTM_TRACE_ERROR("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x\n",
// bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]); // bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
#if (!CONTROLLER_RPA_LIST_ENABLE)
temp_addr_type = addr_type; temp_addr_type = addr_type;
memcpy(temp_bda, bda, BD_ADDR_LEN); memcpy(temp_bda, bda, BD_ADDR_LEN);
#endif // (!CONTROLLER_RPA_LIST_ENABLE)
/* map address to security record */ /* map address to security record */
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE); match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
@ -3477,7 +3478,7 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
} else } else
#endif #endif
btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p); btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE && (!CONTROLLER_RPA_LIST_ENABLE))
//save current adv addr information if p_dev_rec!= NULL //save current adv addr information if p_dev_rec!= NULL
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
if(p_dev_rec) { if(p_dev_rec) {
@ -3946,7 +3947,7 @@ tBTM_STATUS btm_ble_start_adv(void)
p_cb->evt_type != BTM_BLE_CONNECT_DIR_EVT) p_cb->evt_type != BTM_BLE_CONNECT_DIR_EVT)
/* enable resolving list is desired */ /* enable resolving list is desired */
{ {
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_ADV); //btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_ADV);
} }
#endif #endif
if (p_cb->afp != AP_SCAN_CONN_ALL) { if (p_cb->afp != AP_SCAN_CONN_ALL) {

View File

@ -840,10 +840,14 @@ void btm_ble_multi_adv_cleanup(void)
} }
#if BTM_DYNAMIC_MEMORY == TRUE #if BTM_DYNAMIC_MEMORY == TRUE
if(btm_multi_adv_cb_ptr) {
osi_free(btm_multi_adv_cb_ptr); osi_free(btm_multi_adv_cb_ptr);
osi_free(btm_multi_adv_idx_q_ptr);
btm_multi_adv_cb_ptr = NULL; btm_multi_adv_cb_ptr = NULL;
}
if(btm_multi_adv_idx_q_ptr) {
osi_free(btm_multi_adv_idx_q_ptr);
btm_multi_adv_idx_q_ptr = NULL; btm_multi_adv_idx_q_ptr = NULL;
}
#endif #endif
} }

View File

@ -295,7 +295,7 @@ void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
} }
} else if (status == HCI_ERR_MEMORY_FULL) { /* BT_ERROR_CODE_MEMORY_CAPACITY_EXCEEDED */ } else if (status == HCI_ERR_MEMORY_FULL) { /* BT_ERROR_CODE_MEMORY_CAPACITY_EXCEEDED */
btm_cb.ble_ctr_cb.resolving_list_avail_size = 0; btm_cb.ble_ctr_cb.resolving_list_avail_size = 0;
BTM_TRACE_WARNING("%s Resolving list Full ", __func__); BTM_TRACE_ERROR("%s Resolving list Full ", __func__);
} else { } else {
BTM_TRACE_ERROR("%s Add resolving list error %d ", __func__, status); BTM_TRACE_ERROR("%s Add resolving list error %d ", __func__, status);
} }
@ -334,6 +334,8 @@ void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
} else { } else {
btm_cb.ble_ctr_cb.resolving_list_avail_size++; btm_cb.ble_ctr_cb.resolving_list_avail_size++;
} }
} else {
BTM_TRACE_ERROR("%s remove resolving list error 0x%x", __func__, status);
} }
} }
@ -663,7 +665,7 @@ BOOLEAN btm_ble_exe_disable_resolving_list(void)
if (!controller_get_interface()->supports_ble_privacy()) { if (!controller_get_interface()->supports_ble_privacy()) {
btm_ble_vendor_enable_irk_feature(FALSE); btm_ble_vendor_enable_irk_feature(FALSE);
} else { } else {
btsnd_hcic_ble_set_addr_resolution_enable(FALSE); //btsnd_hcic_ble_set_addr_resolution_enable(FALSE);
} }
return TRUE; return TRUE;
@ -687,7 +689,7 @@ void btm_ble_exe_enable_resolving_list(void)
if (!controller_get_interface()->supports_ble_privacy()) { if (!controller_get_interface()->supports_ble_privacy()) {
btm_ble_vendor_enable_irk_feature(TRUE); btm_ble_vendor_enable_irk_feature(TRUE);
} else { } else {
btsnd_hcic_ble_set_addr_resolution_enable(TRUE); //btsnd_hcic_ble_set_addr_resolution_enable(TRUE);
} }
} }
@ -776,18 +778,23 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
memcpy(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, BD_ADDR_LEN); memcpy(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
p_dev_rec->ble.static_addr_type = p_dev_rec->ble.ble_addr_type; p_dev_rec->ble.static_addr_type = p_dev_rec->ble.ble_addr_type;
} }
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller. #if CONTROLLER_RPA_LIST_ENABLE
* It is a hardware limitation. The preliminary solution is not to
* send key to the controller, but to resolve the random address in host. */
/*
BTM_TRACE_DEBUG("%s:adding device to controller resolving list\n", __func__); BTM_TRACE_DEBUG("%s:adding device to controller resolving list\n", __func__);
UINT8 *peer_irk = p_dev_rec->ble.keys.irk; UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
UINT8 *local_irk = btm_cb.devcb.id_keys.irk; UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
//use identical IRK for now //use identical IRK for now
rt = btsnd_hcic_ble_add_device_resolving_list(p_dev_rec->ble.static_addr_type, rt = btsnd_hcic_ble_add_device_resolving_list(p_dev_rec->ble.static_addr_type,
p_dev_rec->ble.static_addr, peer_irk, local_irk); p_dev_rec->ble.static_addr, peer_irk, local_irk);
*/ #else
// do nothing
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a hardware limitation. The preliminary solution is not to
* send key to the controller, but to resolve the random address in host. */
#endif
} else { } else {
UINT8 param[40] = {0}; UINT8 param[40] = {0};
UINT8 *p = param; UINT8 *p = param;
@ -812,11 +819,11 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
} }
/* if resolving list has been turned on, re-enable it */ /* if resolving list has been turned on, re-enable it */
if (rl_mask) { // if (rl_mask) {
btm_ble_enable_resolving_list(rl_mask); // btm_ble_enable_resolving_list(rl_mask);
} else { // } else {
btm_ble_enable_resolving_list(BTM_BLE_RL_INIT); // btm_ble_enable_resolving_list(BTM_BLE_RL_INIT);
} // }
} else { } else {
BTM_TRACE_WARNING("%s Resolving list full ", __func__); BTM_TRACE_WARNING("%s Resolving list full ", __func__);
} }
@ -863,9 +870,9 @@ void btm_ble_resolving_list_remove_dev(tBTM_SEC_DEV_REC *p_dev_rec)
} }
/* if resolving list has been turned on, re-enable it */ /* if resolving list has been turned on, re-enable it */
if (rl_mask) { // if (rl_mask) {
btm_ble_enable_resolving_list(rl_mask); // btm_ble_enable_resolving_list(rl_mask);
} // }
} }
/******************************************************************************* /*******************************************************************************

View File

@ -467,10 +467,12 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
#else #else
p = (UINT8 *)p_name; p = (UINT8 *)p_name;
#endif #endif
#if CLASSIC_BT_INCLUDED
if (btsnd_hcic_change_name(p)) { if (btsnd_hcic_change_name(p)) {
return (BTM_CMD_STARTED); return (BTM_CMD_STARTED);
} else { } else
#endif
{
return (BTM_NO_RESOURCES); return (BTM_NO_RESOURCES);
} }
} }

View File

@ -4573,7 +4573,9 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason)
/* If page was delayed for disc complete, can do it now */ /* If page was delayed for disc complete, can do it now */
btm_cb.discing = FALSE; btm_cb.discing = FALSE;
#if (CLASSIC_BT_INCLUDED == TRUE)
btm_acl_resubmit_page(); btm_acl_resubmit_page();
#endif
if (!p_dev_rec) { if (!p_dev_rec) {
return; return;

View File

@ -132,6 +132,16 @@ typedef struct {
#define BTM_BLE_ADV_DATA_LEN_MAX 31 #define BTM_BLE_ADV_DATA_LEN_MAX 31
#define BTM_BLE_CACHE_ADV_DATA_MAX 62 #define BTM_BLE_CACHE_ADV_DATA_MAX 62
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define BTM_BLE_EXT_ADV_DATA_LEN_MAX 251
#define BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX 252
#define BTM_BLE_ADV_DATA_OP_INTERMEDIATE_FRAG 0
#define BTM_BLE_ADV_DATA_OP_FIRST_FRAG 1
#define BTM_BLE_ADV_DATA_OP_LAST_FRAG 2
#define BTM_BLE_ADV_DATA_OP_COMPLETE 3
#define BTM_BLE_ADV_DATA_OP_UNCHANGED_DATA 4
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#define BTM_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF)) #define BTM_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))
@ -508,6 +518,18 @@ void btm_ble_set_keep_rfu_in_auth_req(BOOLEAN keep_rfu);
BOOLEAN btm_get_current_conn_params(BD_ADDR bda, UINT16 *interval, UINT16 *latency, UINT16 *timeout); BOOLEAN btm_get_current_conn_params(BD_ADDR bda, UINT16 *interval, UINT16 *latency, UINT16 *timeout);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void btm_ble_update_phy_evt(tBTM_BLE_UPDATE_PHY *params);
void btm_ble_scan_timeout_evt(void);
void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params);
void btm_ble_ext_adv_report_evt(tBTM_BLE_EXT_ADV_REPORT *params);
void btm_ble_scan_req_received_evt(tBTM_BLE_SCAN_REQ_RECEIVED *params);
void btm_ble_channel_select_algorithm_evt(tBTM_BLE_CHANNEL_SEL_ALG *params);
void btm_ble_periodic_adv_report_evt(tBTM_PERIOD_ADV_REPORT *params);
void btm_ble_periodic_adv_sync_lost_evt(tBTM_BLE_PERIOD_ADV_SYNC_LOST *params);
void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *params);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/* /*
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -550,7 +550,7 @@ typedef struct {
#endif #endif
UINT16 auth_mode; /* Authentication mode */ UINT16 auth_mode; /* Authentication mode */
#endif #endif
#if (BLE_PRIVACY_SPT == TRUE) #if (BLE_PRIVACY_SPT == TRUE && (!CONTROLLER_RPA_LIST_ENABLE))
tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/ tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/
BD_ADDR current_addr; /* current adv addr*/ BD_ADDR current_addr; /* current adv addr*/
bool current_addr_valid; /* current addr info is valid or not*/ bool current_addr_valid; /* current addr info is valid or not*/
@ -669,6 +669,9 @@ struct tBTM_SEC_DEV_REC{
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE
tBTM_SEC_BLE ble; tBTM_SEC_BLE ble;
tBTM_LE_CONN_PRAMS conn_params; tBTM_LE_CONN_PRAMS conn_params;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
tBTM_EXT_CONN_PARAMS ext_conn_params;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif
// btla-specific ++ // btla-specific ++
@ -1071,6 +1074,11 @@ void btm_qos_setup_complete (UINT8 status, UINT16 handle, FLOW_SPEC *p_flow);
void btm_qos_setup_timeout (void *p_tle); void btm_qos_setup_timeout (void *p_tle);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void btm_create_sync_callback(UINT8 status);
void btm_set_phy_callback(UINT8 status);
void btm_read_phy_callback(uint8_t hci_status, uint16_t conn_handle, uint8_t tx_phy, uint8_t rx_phy);
#endif
/* Internal functions provided by btm_sco.c /* Internal functions provided by btm_sco.c
******************************************** ********************************************
*/ */

View File

@ -137,6 +137,17 @@ static void btu_ble_rc_param_req_evt(UINT8 *p);
//#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) //#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
static void btu_ble_proc_enhanced_conn_cmpl (UINT8 *p, UINT16 evt_len); static void btu_ble_proc_enhanced_conn_cmpl (UINT8 *p, UINT16 evt_len);
//#endif //#endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static void btu_ble_phy_update_complete_evt(UINT8 *p);
static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len);
static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p);
static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len);
static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p);
static void btu_ble_scan_timeout_evt(UINT8 *p);
static void btu_ble_adv_set_terminate_evt(UINT8 *p);
static void btu_ble_scan_req_received_evt(UINT8 *p);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
extern osi_sem_t adv_enable_sem; extern osi_sem_t adv_enable_sem;
extern osi_sem_t adv_data_sem; extern osi_sem_t adv_data_sem;
@ -373,6 +384,35 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
case HCI_BLE_DATA_LENGTH_CHANGE_EVT: case HCI_BLE_DATA_LENGTH_CHANGE_EVT:
btu_ble_data_length_change_evt(p, hci_evt_len); btu_ble_data_length_change_evt(p, hci_evt_len);
break; break;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case HCI_BLE_PHY_UPDATE_COMPLETE_EVT:
btu_ble_phy_update_complete_evt(p);
break;
case HCI_BLE_EXT_ADV_REPORT_EVT:
//HCI_TRACE_ERROR("%s, HCI_BLE_EXT_ADV_REPORT_EVT.", __func__);
btu_ble_ext_adv_report_evt(p, hci_evt_len);
break;
case HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT:
btu_ble_periodic_adv_sync_establish_evt(p);
break;
case HCI_BLE_PERIOD_ADV_REPORT_EVT:
btu_ble_periodic_adv_report_evt(p, hci_evt_len);
break;
case HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT:
btu_ble_periodic_adv_sync_lost_evt(p);
break;
case HCI_BLE_SCAN_TIMEOUT_EVT:
btu_ble_scan_timeout_evt(p);
break;
case HCI_BLE_ADV_SET_TERMINATED_EVT:
btu_ble_adv_set_terminate_evt(p);
break;
case HCI_BLE_SCAN_REQ_RECEIVED_EVT:
btu_ble_scan_req_received_evt(p);
break;
case HCI_BLE_CHANNEL_SELECT_ALG:
break;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
} }
break; break;
#endif /* BLE_INCLUDED */ #endif /* BLE_INCLUDED */
@ -395,6 +435,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf) void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf)
{ {
if (!p_buf) { if (!p_buf) {
HCI_TRACE_ERROR("%s p_buf is NULL", __func__);
return; return;
} }
@ -404,6 +445,48 @@ void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf)
STREAM_TO_UINT16(opcode, stream); STREAM_TO_UINT16(opcode, stream);
// Eww...horrible hackery here
/* If command was a VSC, then extract command_complete callback */
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC
#if BLE_INCLUDED == TRUE
|| (opcode == HCI_BLE_RAND)
|| (opcode == HCI_BLE_ENCRYPT)
#endif
) {
vsc_callback = *((void **)(p_buf + 1));
}
p_buf->sem = NULL;
hci_layer_get_interface()->transmit_command(
p_buf,
btu_hcif_command_complete_evt,
btu_hcif_command_status_evt,
vsc_callback);
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
btu_check_bt_sleep ();
#endif
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf)
{
if (!p_buf) {
HCI_TRACE_ERROR("%s p_buf is NULL", __func__);
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}
osi_sem_t *p_sem = btsnd_hcic_ble_get_sync_sem();
if((*p_sem) == NULL) {
HCI_TRACE_ERROR("%s semaphore is NULL", __func__);
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}
uint16_t opcode;
uint8_t *stream = p_buf->data + p_buf->offset;
void *vsc_callback = NULL;
p_buf->sem = (*p_sem);
STREAM_TO_UINT16(opcode, stream);
// Eww...horrible hackery here // Eww...horrible hackery here
/* If command was a VSC, then extract command_complete callback */ /* If command was a VSC, then extract command_complete callback */
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC
@ -421,10 +504,14 @@ void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf)
btu_hcif_command_status_evt, btu_hcif_command_status_evt,
vsc_callback); vsc_callback);
osi_sem_take(p_sem, OSI_SEM_MAX_TIMEOUT);
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE) #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
btu_check_bt_sleep (); btu_check_bt_sleep ();
#endif #endif
return btsnd_hcic_ble_get_status();
} }
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/******************************************************************************* /*******************************************************************************
@ -1003,6 +1090,33 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
case HCI_BLE_SET_ADDR_RESOLUTION_ENABLE: case HCI_BLE_SET_ADDR_RESOLUTION_ENABLE:
case HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT: case HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT:
break; break;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case HCI_BLE_SET_EXT_ADV_PARAM:
case HCI_BLE_SET_EXT_ADV_DATA:
case HCI_BLE_SET_EXT_SCAN_RSP_DATA:
case HCI_BLE_SET_EXT_ADV_ENABLE: {
uint8_t status;
STREAM_TO_UINT8 (status, p);
HCI_TRACE_EVENT("%s opcode 0x%x status 0x%x", __func__, opcode, status);
break;
}
case HCI_BLE_READ_PHY: {
uint8_t status;
uint16_t conn_handle;
uint8_t tx_phy;
uint8_t rx_phy;
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT16(conn_handle, p);
STREAM_TO_UINT8(tx_phy, p);
STREAM_TO_UINT8(rx_phy, p);
btm_read_phy_callback(status, conn_handle, tx_phy, rx_phy);
break;
}
case HCI_BLE_ENH_RX_TEST:
case HCI_BLE_ENH_TX_TEST:
btm_ble_test_command_complete(p);
break;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif
#endif /* (BLE_INCLUDED == TRUE) */ #endif /* (BLE_INCLUDED == TRUE) */
@ -1085,7 +1199,12 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context)
#endif #endif
BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t)); BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t));
command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0]; command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0];
#if (BLE_50_FEATURE_SUPPORT == TRUE)
UINT8 status = 0;
stream = response->data + response->offset + 3 + 2; // 2 to skip the event headers, 1 to skip the command credits, 2 to opcode.
STREAM_TO_UINT8(status, stream);
btsnd_hci_ble_set_status(status);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
HCI_TRACE_DEBUG("btu_hcif_command_complete_evt\n"); HCI_TRACE_DEBUG("btu_hcif_command_complete_evt\n");
hack->callback = btu_hcif_command_complete_evt_on_task; hack->callback = btu_hcif_command_complete_evt_on_task;
@ -1136,7 +1255,28 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
case HCI_PARK_MODE: case HCI_PARK_MODE:
btm_pm_proc_cmd_status(status); btm_pm_proc_cmd_status(status);
break; break;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case HCI_BLE_PERIOD_ADV_CREATE_SYNC:
{
uint8_t btm_status = BTM_SUCCESS;
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("%s, Create sync error, the error code = 0x%x", __func__, status);
btm_status = BTM_ILLEGAL_VALUE;
}
btm_create_sync_callback(btm_status);
break;
}
case HCI_BLE_SET_PHY:
{
uint8_t btm_status = BTM_SUCCESS;
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("%s, Set phy error, the error code = 0x%x", __func__, status);
btm_status = BTM_ILLEGAL_VALUE;
}
btm_set_phy_callback(btm_status);
break;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
default: default:
/* If command failed to start, we may need to tell BTM */ /* If command failed to start, we may need to tell BTM */
if (status != HCI_SUCCESS) { if (status != HCI_SUCCESS) {
@ -1903,7 +2043,186 @@ static void btu_ble_data_length_change_evt(UINT8 *p, UINT16 evt_len)
l2cble_process_data_length_change_event(handle, tx_data_len, rx_data_len); l2cble_process_data_length_change_event(handle, tx_data_len, rx_data_len);
} }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static void btu_ble_phy_update_complete_evt(UINT8 *p)
{
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
tBTM_BLE_UPDATE_PHY update_phy = {0};
STREAM_TO_UINT8(update_phy.status, p);
STREAM_TO_UINT16(update_phy.conn_idx, p);
STREAM_TO_UINT8(update_phy.tx_phy, p);
STREAM_TO_UINT8(update_phy.rx_phy, p);
btm_ble_update_phy_evt(&update_phy);
}
static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
{
tBTM_BLE_EXT_ADV_REPORT ext_adv_report = {0};
UINT8 num_reports = {0};
//UINT8 legacy_event_type = 0;
UINT16 evt_type = 0;
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
STREAM_TO_UINT8(num_reports, p);
if (num_reports == 0) {
HCI_TRACE_ERROR("%s, Invalid number reports is 0", __func__);
}
while (num_reports--) {
STREAM_TO_UINT16(evt_type, p);
ext_adv_report.event_type = evt_type & 0x1F;
if(ext_adv_report.event_type & BTM_BLE_ADV_LEGACY_MASK) {
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_COMPLETE;
} else {
switch(evt_type & BTM_BLE_ADV_DATA_STATUS_MASK) {
case BTM_BLE_ADV_DATA_COMPLETE_MASK:
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_COMPLETE;
break;
case BTM_BLE_ADV_DATA_INCOMPLETE_MASK:
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_INCOMPLETE;
break;
case BTM_BLE_ADV_DATA_TRUNCATED_MASK:
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_TRUNCATED;
break;
}
}
STREAM_TO_UINT8(ext_adv_report.addr_type, p);
STREAM_TO_BDADDR(ext_adv_report.addr, p);
STREAM_TO_UINT8(ext_adv_report.primary_phy, p);
STREAM_TO_UINT8(ext_adv_report.secondry_phy, p);
STREAM_TO_UINT8(ext_adv_report.sid, p);
STREAM_TO_UINT8(ext_adv_report.tx_power, p);
STREAM_TO_UINT8(ext_adv_report.rssi, p);
STREAM_TO_UINT16(ext_adv_report.per_adv_interval, p);
STREAM_TO_UINT8(ext_adv_report.dir_addr_type, p);
STREAM_TO_BDADDR(ext_adv_report.dir_addr, p);
STREAM_TO_UINT8(ext_adv_report.adv_data_len, p);
ext_adv_report.adv_data = p;
btm_ble_ext_adv_report_evt(&ext_adv_report);
p += ext_adv_report.adv_data_len;
}
}
static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p)
{
tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
STREAM_TO_UINT8(sync_estab.status, p);
STREAM_TO_UINT16(sync_estab.sync_handle, p);
STREAM_TO_UINT8(sync_estab.sid, p);
STREAM_TO_UINT8(sync_estab.adv_addr_type, p);
STREAM_TO_BDADDR(sync_estab.adv_addr, p);
STREAM_TO_UINT8(sync_estab.adv_phy, p);
STREAM_TO_UINT16(sync_estab.period_adv_interval, p);
STREAM_TO_UINT8(sync_estab.adv_clk_accuracy, p);
btm_ble_periodic_adv_sync_establish_evt(&sync_estab);
}
static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len)
{
tBTM_PERIOD_ADV_REPORT adv_report = {0};
/* This parameter is intended to be used in a future feature. */
UINT8 unused = 0;
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
if (evt_len < sizeof(tBTM_PERIOD_ADV_REPORT)) {
HCI_TRACE_ERROR("%s, Invalid params, the adv len is to short.", __func__);
return;
}
STREAM_TO_UINT16(adv_report.sync_handle, p);
STREAM_TO_UINT8(adv_report.tx_power, p);
STREAM_TO_UINT8(adv_report.rssi, p);
STREAM_TO_UINT8(unused, p);
STREAM_TO_UINT8(adv_report.data_status, p);
STREAM_TO_UINT8(adv_report.data_length, p);
if (evt_len <= adv_report.data_length) {
HCI_TRACE_ERROR("%s, Invalid ev_len = %d is less than adv len = %d", __func__, evt_len, adv_report.data_length);
return;
}
adv_report.data = p;
btm_ble_periodic_adv_report_evt(&adv_report);
UNUSED(unused);
}
static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p)
{
tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
STREAM_TO_UINT16(sync_lost.sync_handle, p);
btm_ble_periodic_adv_sync_lost_evt(&sync_lost);
}
static void btu_ble_scan_timeout_evt(UINT8 *p)
{
UNUSED(p);
btm_ble_scan_timeout_evt();
}
static void btu_ble_adv_set_terminate_evt(UINT8 *p)
{
tBTM_BLE_ADV_TERMINAT adv_term = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
STREAM_TO_UINT8(adv_term.status, p);
STREAM_TO_UINT8(adv_term.adv_handle, p);
STREAM_TO_UINT16(adv_term.conn_handle, p);
STREAM_TO_UINT8(adv_term.completed_event, p);
btm_ble_adv_set_terminated_evt(&adv_term);
}
static void btu_ble_scan_req_received_evt(UINT8 *p)
{
tBTM_BLE_SCAN_REQ_RECEIVED req_received = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}
STREAM_TO_UINT8(req_received.adv_handle, p);
STREAM_TO_UINT8(req_received.scan_addr_type, p);
STREAM_TO_BDADDR(req_received.scan_addr, p);
btm_ble_scan_req_received_evt(&req_received);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/********************************************** /**********************************************
** End of BLE Events Handler ** End of BLE Events Handler
***********************************************/ ***********************************************/
@ -1922,5 +2241,4 @@ static void btu_ble_rc_param_req_evt(UINT8 *p)
l2cble_process_rc_param_request_evt(handle, int_min, int_max, latency, timeout); l2cble_process_rc_param_request_evt(handle, int_min, int_max, latency, timeout);
} }
#endif /* BLE_LLT_INCLUDED */ #endif /* BLE_LLT_INCLUDED */
#endif /* BLE_INCLUDED */ #endif /* BLE_INCLUDED */

View File

@ -697,7 +697,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL
} }
/* hold the link here */ /* hold the link here */
if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE)) { if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE)) {
return started; return started;
} }

View File

@ -1360,7 +1360,8 @@ void GATT_StartIf (tGATT_IF gatt_if)
** Returns TRUE if connection started; FALSE if connection start failure. ** Returns TRUE if connection started; FALSE if connection start failure.
** **
*******************************************************************************/ *******************************************************************************/
BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_direct, tBT_TRANSPORT transport) BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type,
BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux)
{ {
tGATT_REG *p_reg; tGATT_REG *p_reg;
BOOLEAN status = FALSE; BOOLEAN status = FALSE;
@ -1374,7 +1375,7 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_
} }
if (is_direct) { if (is_direct) {
status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport); status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport, is_aux);
} else { } else {
if (transport == BT_TRANSPORT_LE) { if (transport == BT_TRANSPORT_LE) {
status = gatt_update_auto_connect_dev(gatt_if, TRUE, bd_addr, TRUE); status = gatt_update_auto_connect_dev(gatt_if, TRUE, bd_addr, TRUE);

View File

@ -564,7 +564,7 @@ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSP
p_clcb->connected = TRUE; p_clcb->connected = TRUE;
} }
/* hold the link here */ /* hold the link here */
GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport); GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport, FALSE);
p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING; p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING;
if (!p_clcb->connected) { if (!p_clcb->connected) {

View File

@ -161,7 +161,6 @@ void gatt_init (void)
#if (GATT_INCLUDED == TRUE) #if (GATT_INCLUDED == TRUE)
void gatt_free(void) void gatt_free(void)
{ {
int i;
GATT_TRACE_DEBUG("gatt_free()"); GATT_TRACE_DEBUG("gatt_free()");
fixed_queue_free(gatt_cb.sign_op_queue, NULL); fixed_queue_free(gatt_cb.sign_op_queue, NULL);
gatt_cb.sign_op_queue = NULL; gatt_cb.sign_op_queue = NULL;
@ -197,7 +196,7 @@ void gatt_free(void)
#endif //(GATTC_INCLUDED == TRUE) #endif //(GATTC_INCLUDED == TRUE)
#if (GATTS_INCLUDED == TRUE) #if (GATTS_INCLUDED == TRUE)
for (i = 0; i < GATT_MAX_SR_PROFILES; i++) { for (int i = 0; i < GATT_MAX_SR_PROFILES; i++) {
gatt_remove_an_item_from_list(&gatt_cb.hdl_list_info, &gatt_cb.hdl_list[i]); gatt_remove_an_item_from_list(&gatt_cb.hdl_list_info, &gatt_cb.hdl_list[i]);
gatt_free_attr_value_buffer(&gatt_cb.hdl_list[i]); gatt_free_attr_value_buffer(&gatt_cb.hdl_list[i]);
gatt_free_hdl_buffer(&gatt_cb.hdl_list[i]); gatt_free_hdl_buffer(&gatt_cb.hdl_list[i]);
@ -220,7 +219,7 @@ void gatt_free(void)
** Returns TRUE if connection is started, otherwise return FALSE. ** Returns TRUE if connection is started, otherwise return FALSE.
** **
*******************************************************************************/ *******************************************************************************/
BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport) BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux)
{ {
BOOLEAN gatt_ret = FALSE; BOOLEAN gatt_ret = FALSE;
@ -230,7 +229,7 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p
if (transport == BT_TRANSPORT_LE) { if (transport == BT_TRANSPORT_LE) {
p_tcb->att_lcid = L2CAP_ATT_CID; p_tcb->att_lcid = L2CAP_ATT_CID;
gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type); gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type, is_aux);
#if (CLASSIC_BT_GATT_INCLUDED == TRUE) #if (CLASSIC_BT_GATT_INCLUDED == TRUE)
} else { } else {
if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) { if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) {
@ -375,7 +374,8 @@ void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN
** Returns void. ** Returns void.
** **
*******************************************************************************/ *******************************************************************************/
BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport) BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr,
tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux)
{ {
BOOLEAN ret = FALSE; BOOLEAN ret = FALSE;
tGATT_TCB *p_tcb; tGATT_TCB *p_tcb;
@ -388,20 +388,35 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_a
/* before link down, another app try to open a GATT connection */ /* before link down, another app try to open a GATT connection */
if (st == GATT_CH_OPEN && gatt_num_apps_hold_link(p_tcb) == 0 && if (st == GATT_CH_OPEN && gatt_num_apps_hold_link(p_tcb) == 0 &&
transport == BT_TRANSPORT_LE ) { transport == BT_TRANSPORT_LE ) {
if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport)) { if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux)) {
ret = FALSE; ret = FALSE;
} }
} else if (st == GATT_CH_CLOSING) { } else if (st == GATT_CH_CLOSING) {
/* need to complete the closing first */ /* need to complete the closing first */
ret = FALSE; ret = FALSE;
} else {
GATT_TRACE_WARNING("gatt_connect wrong state %d", st);
} }
} else { } else {
if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, transport)) != NULL) { if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, transport)) != NULL) {
if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport)) { if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport, is_aux)) {
GATT_TRACE_ERROR("gatt_connect failed"); GATT_TRACE_ERROR("gatt_connect failed");
// code enter here if create connection failed. if disconnect after connection, code will not enter here
// p_tcb, p_tcb->pending_enc_clcb, and p_tcb->pending_ind_q have been freed in gatt_cleanup_upon_disc(),
// but here p_tcb is get from gatt_allocate_tcb_by_bdaddr(), is too old, so we get p_tcb again
p_tcb = gatt_find_tcb_by_addr(bd_addr, transport);
if(p_tcb != NULL) {
if(p_tcb->pending_enc_clcb != NULL) {
fixed_queue_free(p_tcb->pending_enc_clcb, NULL); fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
}
if(p_tcb->pending_ind_q != NULL) {
fixed_queue_free(p_tcb->pending_ind_q, NULL); fixed_queue_free(p_tcb->pending_ind_q, NULL);
}
gatt_tcb_free(p_tcb); gatt_tcb_free(p_tcb);
}
} else { } else {
ret = TRUE; ret = TRUE;
} }

View File

@ -527,6 +527,7 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
if (ll != 0) { if (ll != 0) {
GATT_TRACE_ERROR("max attribute handle reached in ReadMultiple Request."); GATT_TRACE_ERROR("max attribute handle reached in ReadMultiple Request.");
err = GATT_INVALID_HANDLE;
} }
if (p_tcb->sr_cmd.multi_req.num_handles == 0) { if (p_tcb->sr_cmd.multi_req.num_handles == 0) {

View File

@ -576,8 +576,8 @@ extern void gatt_free(void);
/* from gatt_main.c */ /* from gatt_main.c */
extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb); extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb);
extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport); extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport, BOOLEAN is_aux);
extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport); extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport, BOOLEAN is_aux);
extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf); extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf);
extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link); extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link);

View File

@ -34,6 +34,36 @@
#include <string.h> #include <string.h>
#define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)osi_malloc(HCIC_PREAMBLE_SIZE + sizeof(BT_HDR) + paramlen)) #define HCI_GET_CMD_BUF(paramlen) ((BT_HDR *)osi_malloc(HCIC_PREAMBLE_SIZE + sizeof(BT_HDR) + paramlen))
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static uint8_t status;
static osi_sem_t sync_sem;
void btsnd_hcic_ble_sync_sem_init(void)
{
osi_sem_new(&sync_sem, 1, 0);
}
void btsnd_hcic_ble_sync_sem_deinit(void)
{
osi_sem_free(&sync_sem);
}
osi_sem_t *btsnd_hcic_ble_get_sync_sem(void)
{
return &sync_sem;
}
uint8_t btsnd_hcic_ble_get_status(void)
{
return status;
}
void btsnd_hci_ble_set_status(UINT8 hci_status)
{
status = hci_status;
return;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) #if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
@ -1046,4 +1076,702 @@ BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels)
return (TRUE); return (TRUE);
} }
#define HCIC_BLE_CMD_CREATED(p, pp, size) do{\
if ((p = HCI_GET_CMD_BUF(size)) == NULL) { \
return FALSE; \
} \
pp = p->data; \
p->len = HCIC_PREAMBLE_SIZE + size;\
p->offset = 0; \
} while(0)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BOOLEAN btsnd_hcic_ble_read_phy(UINT16 conn_handle)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, conn_handle = %d", __func__, conn_handle);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_READ_PHY);
UINT16_TO_STREAM(pp, HCI_BLE_READ_PHY);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_READ_PHY);
UINT16_TO_STREAM(pp, conn_handle);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
UINT8 btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys,
UINT8 tx_phys,
UINT8 rx_phys)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, all_phys = %d, tx_phys = %d, rx_phys = %d", __func__, all_phys, tx_phys, rx_phys);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_PHY);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
UINT8_TO_STREAM(pp, all_phys);
UINT8_TO_STREAM(pp, tx_phys);
UINT8_TO_STREAM(pp, rx_phys);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
BOOLEAN btsnd_hcic_ble_set_phy(UINT16 conn_handle,
UINT8 all_phys, UINT8 tx_phys,
UINT8 rx_phys, UINT16 phy_options)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, conn_handle = %d, all_phys = %d, tx_phys = %d, rx_phys = %d, phy_options = %d", __func__,
conn_handle, all_phys, tx_phys, rx_phys, phy_options);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_SET_PHY);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PHY);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_PHY);
UINT16_TO_STREAM(pp, conn_handle);
UINT8_TO_STREAM(pp, all_phys);
UINT8_TO_STREAM(pp, tx_phys);
UINT8_TO_STREAM(pp, rx_phys);
UINT16_TO_STREAM(pp, phy_options);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
UINT8 btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel, UINT8 phy,
UINT8 modulation_idx)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, rx_channel = %d, phy = %d, modulation_idx = %d", __func__,
rx_channel, phy, modulation_idx);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ENH_RX_TEST);
UINT16_TO_STREAM(pp, HCI_BLE_ENH_RX_TEST);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ENH_RX_TEST);
UINT8_TO_STREAM(pp, rx_channel);
UINT8_TO_STREAM(pp, phy);
UINT8_TO_STREAM(pp, modulation_idx);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel, UINT8 len,
UINT8 packect,
UINT8 phy)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, tx_channel = %d, len = %d, packect = %d, phy = %d", __func__,
tx_channel, len, packect, phy);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ENH_TX_TEST);
UINT16_TO_STREAM(pp, HCI_BLE_ENH_TX_TEST);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ENH_TX_TEST);
UINT8_TO_STREAM(pp, tx_channel);
UINT8_TO_STREAM(pp, len);
UINT8_TO_STREAM(pp, packect);
UINT8_TO_STREAM(pp, phy);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d", __func__, adv_handle);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_RAND_ADDR);
UINT16_TO_STREAM (pp, HCI_BLE_SET_ADV_RAND_ADDR);
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_EXT_RAND_ADDR);
UINT8_TO_STREAM(pp, adv_handle);
BDADDR_TO_STREAM (pp, rand_addr);
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UINT32 interval_min,
UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type,
UINT8 peer_addr_type, BD_ADDR peer_addr,
UINT8 adv_filter_policy, UINT8 adv_tx_power,
UINT8 primary_adv_phy, UINT8 secondary_adv_max_skip,
UINT8 secondary_adv_phy,
UINT8 adv_sid, UINT8 scan_req_ntf_enable)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d, properties = %d, interval_min = %d, interval_max = %d, channel_map = %d,\n\
own_addr_type = %d, peer_addr_type = %d, adv_filter_policy = %d,\n\
adv_tx_power = %d, primary_adv_phy = %d, secondary_adv_max_skip = %d, secondary_adv_phy = %d,\n\
adv_sid = %d, scan_req_ntf_enable = %d", __func__, adv_handle, properties, interval_min, interval_max,
channel_map, own_addr_type, peer_addr_type, adv_filter_policy, adv_tx_power,
primary_adv_phy, secondary_adv_max_skip, secondary_adv_phy, adv_sid, scan_req_ntf_enable);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_PARAM);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
UINT8_TO_STREAM(pp, adv_handle);
UINT16_TO_STREAM(pp, properties);
UINT24_TO_STREAM(pp, interval_min);
UINT24_TO_STREAM(pp, interval_max);
UINT8_TO_STREAM(pp, channel_map);
UINT8_TO_STREAM(pp, own_addr_type);
UINT8_TO_STREAM(pp, peer_addr_type);
BDADDR_TO_STREAM (pp, peer_addr);
UINT8_TO_STREAM(pp, adv_filter_policy);
UINT8_TO_STREAM(pp, adv_tx_power);
UINT8_TO_STREAM(pp, primary_adv_phy);
UINT8_TO_STREAM(pp, secondary_adv_max_skip);
UINT8_TO_STREAM(pp, secondary_adv_phy);
UINT8_TO_STREAM(pp, adv_sid);
UINT8_TO_STREAM(pp, scan_req_ntf_enable);
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
bool ext_adv_flag = false;
UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,
UINT8 operation, UINT8 fragment_prefrence,
UINT8 data_len, UINT8 *p_data)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\
data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len);
ext_adv_flag = true;
HCIC_BLE_CMD_CREATED(p, pp, data_len + 4);
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_DATA);
UINT8_TO_STREAM(pp, data_len + 4);
UINT8_TO_STREAM(pp, adv_handle);
UINT8_TO_STREAM(pp, operation);
UINT8_TO_STREAM(pp, fragment_prefrence);
if (p_data != NULL && data_len > 0) {
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
}
UINT8_TO_STREAM (pp, data_len);
ARRAY_TO_STREAM (pp, p_data, data_len);
} else {
return FALSE;
}
uint8_t status = btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
return status;
}
UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
UINT8 operation, UINT8 fragment_prefrence,
UINT8 data_len, UINT8 *p_data)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\n\
data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len);
HCIC_BLE_CMD_CREATED(p, pp, data_len + 4);
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_RSP_DATA);
UINT8_TO_STREAM(pp, data_len + 4);
UINT8_TO_STREAM(pp, adv_handle);
UINT8_TO_STREAM(pp, operation);
UINT8_TO_STREAM(pp, fragment_prefrence);
memset(pp, 0, data_len);
if (p_data != NULL && data_len > 0) {
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
}
UINT8_TO_STREAM (pp, data_len);
ARRAY_TO_STREAM (pp, p_data, data_len);
} else {
return FALSE;
}
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_ext_adv_enable(UINT8 enable, UINT8 num_of_sets, UINT8 *adv_handle,
UINT16 *duration, UINT8 *max_adv_evt)
{
BT_HDR *p;
UINT8 *pp;
UINT8 ext_adv_size = num_of_sets*4 + 2;
HCIC_BLE_CMD_CREATED(p, pp, ext_adv_size);
HCI_TRACE_EVENT("%s, enable = %d, num_of_sets = %d", __func__, enable, num_of_sets);
for (int k = 0; k < num_of_sets; k++) {
HCI_TRACE_EVENT("adv_handle[%d] = %d, duration[%d] = %d, max_adv_evt[%d] = %d", k, adv_handle[k],
k, duration[k], k, max_adv_evt[k]);
}
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_ENABLE);
UINT8_TO_STREAM(pp, ext_adv_size);
UINT8_TO_STREAM(pp, enable);
UINT8_TO_STREAM(pp, num_of_sets);
for (int i = 0; i < num_of_sets; i++) {
UINT8_TO_STREAM(pp, adv_handle[i]);
UINT16_TO_STREAM(pp, duration[i]);
UINT8_TO_STREAM(pp, max_adv_evt[i]);
}
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_read_max_adv_len(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE + 1);
UINT16_TO_STREAM(pp, HCI_BLE_RD_MAX_ADV_DATA_LEN);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE);
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_read_num_support_adv_set(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET + 1);
UINT16_TO_STREAM(pp, HCI_BLE_RD_NUM_OF_ADV_SETS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET);
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_remove_adv_set(UINT8 adv_handle)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d", __func__, adv_handle);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_REMOVE_ADV_SET + 1);
UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_ADV_SET);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_REMOVE_ADV_SET);
UINT8_TO_STREAM(pp, adv_handle);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_clear_adv_set(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CLEAR_ADV_SET + 1);
UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_ADV_SETS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_ADV_SET);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle,
UINT16 interval_min,
UINT16 interval_max,
UINT8 propertics)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d, interval_min = %d, interval_max = %d, propertics = %d",
__func__, adv_handle, interval_min, interval_max, propertics);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_PARAMS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
UINT8_TO_STREAM(pp, adv_handle);
UINT16_TO_STREAM(pp, interval_min);
UINT16_TO_STREAM(pp, interval_max);
UINT16_TO_STREAM(pp, propertics);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,
UINT8 operation,
UINT8 len,
UINT8 *p_data)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, len = %d",
__func__, adv_handle, operation, len);
HCIC_BLE_CMD_CREATED(p, pp, len + 3);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_DATA);
UINT8_TO_STREAM(pp, len + 3);
UINT8_TO_STREAM(pp, adv_handle);
UINT8_TO_STREAM(pp, operation);
//memset(pp, 0, len);
if (p_data != NULL && len > 0) {
if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) {
len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA;
}
UINT8_TO_STREAM (pp, len);
ARRAY_TO_STREAM (pp, p_data, len);
} else {
return FALSE;
}
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_periodic_adv_enable(UINT8 enable, UINT8 adv_handle)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, enable = %d, adv_handle = %d",
__func__, enable, adv_handle);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_ENABLE);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
UINT8_TO_STREAM(pp, enable);
UINT8_TO_STREAM(pp, adv_handle);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type, UINT8 filter_policy,
UINT8 phy_mask, UINT8 phy_count,
tHCI_EXT_SCAN_PARAMS *params)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, own_addr_type = %d, filter_policy = %d, phy_mask = %d, phy_count = %d",
__func__, own_addr_type, filter_policy, phy_mask, phy_count);
UINT8 params_size = HCIC_PARAM_SIZE_SET_EXT_SCAN_PARAMS + phy_count*5;
HCIC_BLE_CMD_CREATED(p, pp, params_size);
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_PARAMS);
UINT8_TO_STREAM(pp, params_size);
UINT8_TO_STREAM(pp, own_addr_type);
UINT8_TO_STREAM(pp, filter_policy);
UINT8_TO_STREAM(pp, phy_mask);
for (int i = 0; i < phy_count; i++) {
UINT8_TO_STREAM(pp, params[i].scan_type);
UINT16_TO_STREAM(pp, params[i].scan_interval);
UINT16_TO_STREAM(pp, params[i].scan_window);
}
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups,
UINT16 duration, UINT16 period)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, enable = %d, filter_dups = %d, duration = %d, period = %d",
__func__, enable, filter_dups, duration, period);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_ENABLE);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
UINT8_TO_STREAM(pp, enable);
UINT8_TO_STREAM(pp, filter_dups);
UINT16_TO_STREAM(pp, duration);
UINT16_TO_STREAM(pp, period);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn)
{
BT_HDR *p;
UINT8 *pp;
tHCI_ExtConnParams *params;
HCI_TRACE_EVENT("%s", __func__);
uint8_t size = HCIC_PARAM_SIZE_EXT_CONN_CREATE_BASE;
if (p_conn->init_phy_mask & 0x01) {
size += sizeof(tHCI_ExtConnParams);
}
if (p_conn->init_phy_mask & 0x02) {
size += sizeof(tHCI_ExtConnParams);
}
if (p_conn->init_phy_mask & 0x04) {
size += sizeof(tHCI_ExtConnParams);
}
HCIC_BLE_CMD_CREATED(p, pp, size);
UINT16_TO_STREAM(pp, HCI_BLE_EXT_CREATE_CONN);
UINT8_TO_STREAM(pp, size);
UINT8_TO_STREAM(pp, p_conn->filter_policy);
UINT8_TO_STREAM(pp, p_conn->own_addr_type);
UINT8_TO_STREAM(pp, p_conn->peer_addr_type);
BDADDR_TO_STREAM(pp, p_conn->peer_addr);
UINT8_TO_STREAM(pp, p_conn->init_phy_mask);
if (p_conn->init_phy_mask & 0x01) {
params = &p_conn->params[0];
UINT16_TO_STREAM(pp, params->scan_interval);
UINT16_TO_STREAM(pp, params->scan_window);
UINT16_TO_STREAM(pp, params->conn_interval_min);
UINT16_TO_STREAM(pp, params->conn_interval_max);
UINT16_TO_STREAM(pp, params->conn_latency);
UINT16_TO_STREAM(pp, params->sup_timeout);
UINT16_TO_STREAM(pp, params->min_ce_len);
UINT16_TO_STREAM(pp, params->max_ce_len);
}
if (p_conn->init_phy_mask & 0x02) {
params = &p_conn->params[1];
UINT16_TO_STREAM(pp, params->scan_interval);
UINT16_TO_STREAM(pp, params->scan_window);
UINT16_TO_STREAM(pp, params->conn_interval_min);
UINT16_TO_STREAM(pp, params->conn_interval_max);
UINT16_TO_STREAM(pp, params->conn_latency);
UINT16_TO_STREAM(pp, params->sup_timeout);
UINT16_TO_STREAM(pp, params->min_ce_len);
UINT16_TO_STREAM(pp, params->max_ce_len);
}
if (p_conn->init_phy_mask & 0x04) {
params = &p_conn->params[2];
UINT16_TO_STREAM(pp, params->scan_interval);
UINT16_TO_STREAM(pp, params->scan_window);
UINT16_TO_STREAM(pp, params->conn_interval_min);
UINT16_TO_STREAM(pp, params->conn_interval_max);
UINT16_TO_STREAM(pp, params->conn_latency);
UINT16_TO_STREAM(pp, params->sup_timeout);
UINT16_TO_STREAM(pp, params->min_ce_len);
UINT16_TO_STREAM(pp, params->max_ce_len);
}
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid,
UINT8 adv_addr_type, BD_ADDR adv_addr,
UINT16 sync_timeout, UINT8 unused)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, filter_policy = %d, adv_sid = %d, adv_addr_type = %d, sync_timeout = %d, unused = %d",
__func__, filter_policy, adv_sid, adv_addr_type, sync_timeout, unused);
HCI_TRACE_EVENT("addr %02x %02x %02x %02x %02x %02x", adv_addr[0], adv_addr[1], adv_addr[2], adv_addr[3], adv_addr[4], adv_addr[5]);
uint16_t skip = 0;
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC + 2);
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_CREATE_SYNC);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC + 2);
UINT8_TO_STREAM(pp, filter_policy);
UINT8_TO_STREAM(pp, adv_sid);
UINT8_TO_STREAM(pp, adv_addr_type);
BDADDR_TO_STREAM(pp, adv_addr);
UINT16_TO_STREAM(pp, skip);
UINT16_TO_STREAM(pp, sync_timeout);
UINT8_TO_STREAM(pp, unused);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_CREATE_SYNC_CANCEL);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_periodic_adv_term_sync(UINT16 sync_handle)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, sync_handle = %d", __func__, sync_handle);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_TERM_SYNC);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
UINT16_TO_STREAM(pp, sync_handle);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_add_dev_to_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
UINT8 adv_sid)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_addr_type = %d, adv_sid = %d", __func__, adv_addr_type, adv_sid);
esp_log_buffer_hex_internal("addr", adv_addr, sizeof(BD_ADDR), ESP_LOG_WARN);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
UINT16_TO_STREAM(pp, HCI_BLE_ADV_DEV_TO_PERIOD_ADV_LIST);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
UINT8_TO_STREAM(pp, adv_addr_type);
BDADDR_TO_STREAM(pp, adv_addr);
UINT8_TO_STREAM(pp, adv_sid);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_rm_dev_from_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
UINT8 adv_sid)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, adv_addr_type = %d, adv_sid = %d", __func__, adv_addr_type, adv_sid);
esp_log_buffer_hex_internal("addr", adv_addr, sizeof(BD_ADDR), ESP_LOG_WARN);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_DEV_FROM_PERIOD_ADV_LIST);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
UINT8_TO_STREAM(pp, adv_addr_type);
BDADDR_TO_STREAM(pp, adv_addr);
UINT8_TO_STREAM(pp, adv_sid);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_clear_periodic_adv_list(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_PERIOD_ADV_LIST);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_read_periodic_adv_list_size(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
UINT16_TO_STREAM(pp, HCI_BLE_RD_PERIOD_ADV_LIST_SIZE);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_read_trans_power(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_TRANS_POWER);
UINT16_TO_STREAM(pp, HCI_BLE_RD_TRANSMIT_POWER);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_TRANS_POWER);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_read_rf_path_compensation(void)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s", __func__);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
UINT16_TO_STREAM(pp, HCI_BLE_RD_RF_PATH_COMPENSATION);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_path)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_EVENT("%s, rf_tx_path = %d, rf_rx_path = %d", __func__, rf_tx_path, rf_rx_path);
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
pp = (UINT8 *)(p + 1);
p->len = HCIC_PREAMBLE_SIZE + HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION;
p->offset = 0;
UINT16_TO_STREAM(pp, HCI_BLE_WR_RF_PATH_COMPENSATION);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION);
UINT16_TO_STREAM(pp, rf_tx_path);
UINT16_TO_STREAM(pp, rf_tx_path);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif

View File

@ -22,6 +22,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "bt_common.h" #include "bt_common.h"
#include "osi/semaphore.h"
typedef uint8_t UINT8; typedef uint8_t UINT8;
typedef uint16_t UINT16; typedef uint16_t UINT16;
@ -194,6 +195,7 @@ typedef struct {
uint16_t len; uint16_t len;
uint16_t offset; uint16_t offset;
uint16_t layer_specific; uint16_t layer_specific;
osi_sem_t sem;
uint8_t data[]; uint8_t data[];
} BT_HDR; } BT_HDR;

View File

@ -105,7 +105,7 @@ typedef UINT8 tBTM_BLE_SFP;
#endif #endif
/* adv parameter boundary values */ /* adv parameter boundary values */
#define BTM_BLE_ADV_INT_MIN 0x0010 #define BTM_BLE_ADV_INT_MIN 0x0020
#define BTM_BLE_ADV_INT_MAX 0x4000 #define BTM_BLE_ADV_INT_MAX 0x4000
/* Full scan boundary values */ /* Full scan boundary values */
@ -373,7 +373,11 @@ typedef UINT8 tBTM_BLE_AD_TYPE;
/* Preferred maximum number of microseconds that the local Controller /* Preferred maximum number of microseconds that the local Controller
should use to transmit a single Link Layer Data Channel PDU. */ should use to transmit a single Link Layer Data Channel PDU. */
#define BTM_BLE_DATA_TX_TIME_MIN 0x0148 #define BTM_BLE_DATA_TX_TIME_MIN 0x0148
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define BTM_BLE_DATA_TX_TIME_MAX 0x04290 // define by spec v5.0
#else
#define BTM_BLE_DATA_TX_TIME_MAX 0x0848 #define BTM_BLE_DATA_TX_TIME_MAX 0x0848
#endif
/* adv tx power level */ /* adv tx power level */
#define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */ #define BTM_BLE_ADV_TX_POWER_MIN 0 /* minimum tx power */
@ -692,7 +696,127 @@ typedef void (tBTM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTM_STATUS status,
typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type, typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type,
tBTM_BLE_PF_AVBL_SPACE avbl_space, tBTM_BLE_PF_AVBL_SPACE avbl_space,
tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status); tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define MAX_BLE_ADV_INSTANCE 10
typedef struct {
UINT8 inst_id;
BOOLEAN in_use;
UINT8 adv_evt;
BOOLEAN configured;
BOOLEAN legacy_pdu;
BOOLEAN directed;
BOOLEAN scannable;
BOOLEAN connetable;
} tBTM_BLE_EXTENDED_INST;
typedef struct {
tBTM_BLE_EXTENDED_INST inst[MAX_BLE_ADV_INSTANCE]; /* dynamic array to store adv instance */
UINT8 scan_duplicate;
tBTM_BLE_MULTI_ADV_OPQ op_q;
} tBTM_BLE_EXTENDED_CB;
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE (1 << 0)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE (1 << 1)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED (1 << 2)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED (1 << 3)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY (1 << 4)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_ANON_ADV (1 << 5)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_INCLUDE_TX_PWR (1 << 6)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_MASK (0x7F)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_LD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_DIRECTED)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_HD_DIR (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_HD_DIRECTED)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_SCAN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY |\
ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE)
#define BTM_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_NONCONN (ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY)
typedef UINT16 tBTM_BLE_EXT_ADV_TYPE_MASK;
#define BTM_BLE_GAP_PHY_1M 1
#define BTM_BLE_GAP_PHY_2M 2
#define BTM_BLE_GAP_PHY_CODED 3
typedef UINT8 tBTM_BLE_GAP_PHY;
#define BTM_BLE_GAP_PHY_NO_TX_PREF_MASK (0x01)
#define BTM_BLE_GAP_PHY_NO_RX_PREF_MASK (0x02)
#define BTM_BLE_GAP_PHY_1M_PREF_MASK (0x03)
#define BTM_BLE_GAP_PHY_2M_PREF_MASK (0x04)
#define BTM_BLE_GAP_PHY_CODED_PREF_MASK (0x05)
typedef UINT8 tBTM_BLE_GAP_PHY_MASK;
#define BTM_BLE_GAP_EXT_SCAN_UNCODE_MASK 0x01
#define BTM_BLE_GAP_EXT_SCAN_CODE_MASK 0x02
typedef UINT8 tBTM_BLE_EXT_SCAN_CFG_MASK;
typedef struct {
tBTM_BLE_EXT_ADV_TYPE_MASK type;
UINT32 interval_min;
UINT32 interval_max;
tBTM_BLE_ADV_CHNL_MAP channel_map;
tBLE_ADDR_TYPE own_addr_type;
tBLE_ADDR_TYPE peer_addr_type;
BD_ADDR peer_addr;
tBTM_BLE_AFP filter_policy;
UINT8 tx_power;
tBTM_BLE_GAP_PHY primary_phy;
UINT8 max_skip;
tBTM_BLE_GAP_PHY secondary_phy;
UINT8 sid;
BOOLEAN scan_req_notif;
} tBTM_BLE_GAP_EXT_ADV_PARAMS;
typedef struct {
UINT8 instance;
int duration;
int max_events;
} tBTM_BLE_EXT_ADV;
typedef struct {
tBLE_SCAN_MODE scan_type;
UINT16 scan_interval;
UINT16 scan_window;
} tBTM_BLE_EXT_SCAN_CFG;
typedef struct {
tBLE_ADDR_TYPE own_addr_type;
UINT8 filter_policy;
UINT8 scan_duplicate;
tBTM_BLE_EXT_SCAN_CFG_MASK cfg_mask;
tBTM_BLE_EXT_SCAN_CFG uncoded_cfg;
tBTM_BLE_EXT_SCAN_CFG coded_cfg;
} tBTM_BLE_EXT_SCAN_PARAMS;
typedef struct {
UINT16 interval_min;
UINT16 interval_max;
UINT8 properties;
} tBTM_BLE_Periodic_Adv_Params;
typedef struct {
UINT8 filter_policy;
UINT8 sid;
tBLE_ADDR_TYPE addr_type;
BD_ADDR addr;
UINT16 skip;
UINT16 sync_timeout;
} tBTM_BLE_Periodic_Sync_Params;
typedef struct {
uint8_t status;
uint16_t conn_idx;
uint8_t tx_phy;
uint8_t rx_phy;
} tBTM_BLE_UPDATE_PHY;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
typedef union { typedef union {
UINT16 uuid16_mask; UINT16 uuid16_mask;
UINT32 uuid32_mask; UINT32 uuid32_mask;
@ -870,7 +994,297 @@ typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status); typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info); typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1
#define BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT 2
#define BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT 3
#define BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT 4
#define BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT 5
#define BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT 6
#define BTM_BLE_5_GAP_EXT_SCAN_RSP_DATA_SET_COMPLETE_EVT 7
#define BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT 8
#define BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT 9
#define BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT 10
#define BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT 11
#define BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT 12
#define BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT 13
#define BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT 14
#define BTM_BLE_5_GAP_PERIODIC_ADV_STOP_COMPLETE_EVT 15
#define BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT 16
#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_CANCEL_COMPLETE_EVT 17
#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_TERMINATE_COMPLETE_EVT 18
#define BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT 19
#define BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT 20
#define BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT 21
#define BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT 22
#define BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT 23
#define BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT 24
#define BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT 25
#define BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT 26
#define BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT 27
#define BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT 28
#define BTM_BLE_5_GAP_ADV_TERMINATED_EVT 29
#define BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT 30
#define BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT 31
#define BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT 32
#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT 33
#define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT 34
#define BTM_BLE_5_GAP_UNKNOWN_EVT 35
typedef UINT8 tBTM_BLE_5_GAP_EVENT;
#define BTM_BLE_EXT_ADV_DATA_COMPLETE 0x00
#define BTM_BLE_EXT_ADV_DATA_INCOMPLETE 0x01
#define BTM_BLE_EXT_ADV_DATA_TRUNCATED 0x02
typedef UINT8 tBTM_BLE_EXT_ADV_DATA_STATUS;
#define BTM_BLE_ADV_DATA_COMPLETE_MASK (0x0000)
#define BTM_BLE_ADV_DATA_INCOMPLETE_MASK (0x0020)
#define BTM_BLE_ADV_DATA_TRUNCATED_MASK (0x0040)
#define BTM_BLE_ADV_DATA_STATUS_MASK (0x0060)
//#define BTM_BLE_ADV_CONN_MASK (0x0001)
//#define BTM_BLE_ADV_SCAN_MASK (0x0002)
//#define BTM_BLE_ADV_DIRECT_MASK (0x0004)
//#define BTM_BLE_SCAN_RSP_MASK (0x0008)
#define BTM_BLE_ADV_LEGACY_MASK (0x0010)
typedef UINT8 tBTM_BLE_ADV_MASK;
// /* Advertising report */
// #define BTM_BLE_ADV_REPORT_ADV_IND (0)
// #define BTM_BLE_ADV_REPORT_DIR_IND (1)
// #define BTM_BLE_ADV_REPORT_SCAN_IND (2)
// #define BTM_BLE_ADV_REPORT_NONCONN_IND (3)
// #define BTM_BLE_ADV_REPORT_SCAN_RSP (4)
// /* Bluetooth 5.0, Vol 2, Part E, 7.7.65.13 */
// #define BTM_BLE_LEGACY_ADV_TYPE_IND (0x13)
// #define BTM_BLE_LEGACY_ADV_TYPE_DIRECT_IND (0x15)
// #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_IND (0x12)
// #define BTM_BLE_LEGACY_ADV_TYPE_NONCON_IND (0x10)
// #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_IND (0x1b)
// #define BTM_BLE_LEGACY_ADV_TYPE_SCAN_RSP_ADV_SCAN_IND (0x1a)
typedef struct {
UINT8 status;
BD_ADDR addr;
UINT8 tx_phy;
UINT8 rx_phy;
} tBTM_BLE_READ_PHY_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_SET_PREF_DEF_PHY_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_SET_PERF_PHY_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_ADV_DATA_SET_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_ADV_START_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_ADV_STOP_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_START_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_STOP_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_SCAN_START_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_EXT_SCAN_STOP_CMPL;
typedef struct {
UINT8 status;
} tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL;
typedef struct {
uint8_t status;
BD_ADDR addr;
uint8_t tx_phy;
uint8_t rx_phy;
} tBTM_BLE_PHY_UPDATE_CMPL;
typedef struct {
// UINT8 props;
// UINT8 legacy_event_type;
UINT8 event_type;
tBLE_ADDR_TYPE addr_type;
BD_ADDR addr;
UINT8 primary_phy;
UINT8 secondry_phy;
UINT8 sid;
UINT8 tx_power;
UINT8 rssi;
UINT16 per_adv_interval;
tBLE_ADDR_TYPE dir_addr_type;
BD_ADDR dir_addr;
tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
UINT8 adv_data_len;
UINT8 *adv_data;
} tBTM_BLE_EXT_ADV_REPORT;
typedef struct {
UINT8 status;
UINT8 adv_handle;
UINT16 conn_handle;
UINT8 completed_event;
} tBTM_BLE_ADV_TERMINAT;
typedef struct {
UINT8 adv_handle;
tBLE_ADDR_TYPE scan_addr_type;
BD_ADDR scan_addr;
} tBTM_BLE_SCAN_REQ_RECEIVED;
typedef struct {
UINT16 conn_handle;
UINT8 channel_sel_alg;
} tBTM_BLE_CHANNEL_SEL_ALG;
typedef struct {
UINT16 sync_handle;
UINT8 tx_power;
INT8 rssi;
tBTM_BLE_EXT_ADV_DATA_STATUS data_status;
UINT8 data_length;
UINT8 *data;
} tBTM_PERIOD_ADV_REPORT;
typedef struct {
UINT16 sync_handle;
} tBTM_BLE_PERIOD_ADV_SYNC_LOST;
typedef struct {
UINT8 status;
UINT16 sync_handle;
UINT8 sid;
tBLE_ADDR_TYPE adv_addr_type;
BD_ADDR adv_addr;
UINT8 adv_phy;
UINT16 period_adv_interval;
UINT8 adv_clk_accuracy;
} tBTM_BLE_PERIOD_ADV_SYNC_ESTAB;
typedef struct {
UINT16 scan_interval;
UINT16 scan_window;
UINT16 interval_min;
UINT16 interval_max;
UINT16 latency;
UINT16 supervision_timeout;
UINT16 min_ce_len;
UINT16 max_ce_len;
} tBTM_BLE_CONN_PARAMS;
typedef union {
UINT8 status;
tBTM_BLE_READ_PHY_CMPL read_phy;
tBTM_BLE_SET_PREF_DEF_PHY_CMPL set_perf_def_phy;
tBTM_BLE_SET_PERF_PHY_CMPL set_perf_phy;
tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL set_ext_rand_addr;
tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL set_params;
tBTM_BLE_EXT_ADV_DATA_SET_CMPL adv_data_set;
tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL scan_rsp_data_set;
tBTM_BLE_EXT_ADV_START_CMPL adv_start;
tBTM_BLE_EXT_ADV_STOP_CMPL adv_stop;
tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL per_adv_set_params;
tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL per_adv_data_set;
tBTM_BLE_PERIOD_ADV_START_CMPL per_adv_start;
tBTM_BLE_PERIOD_ADV_STOP_CMPL per_adv_stop;
tBTM_BLE_PERIOD_ADV_SYNC_CREATE_CMPL per_adv_sync_create;
tBTM_BLE_PERIOD_ADV_SYNC_CANCEL_CMPL per_adv_sync_cancel;
tBTM_BLE_PERIOD_ADV_SYNC_TEMINAT_CMPL per_adv_sync_term;
tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL per_adv_add_dev;
tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL per_adv_remove_dev;
tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL per_adv_clear_dev;
tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL ext_scan;
tBTM_BLE_EXT_SCAN_START_CMPL scan_start;
tBTM_BLE_EXT_SCAN_STOP_CMPL scan_stop;
tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL ext_conn_set_params;
tBTM_BLE_PHY_UPDATE_CMPL phy_update;
tBTM_BLE_EXT_ADV_REPORT ext_adv_report;
tBTM_BLE_ADV_TERMINAT adv_term;
tBTM_BLE_SCAN_REQ_RECEIVED scan_req;
tBTM_BLE_CHANNEL_SEL_ALG channel_sel;
tBTM_PERIOD_ADV_REPORT period_adv_report;
tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost;
tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab;
} tBTM_BLE_5_GAP_CB_PARAMS;
typedef struct {
UINT8 phy_mask;
tBTM_BLE_CONN_PARAMS phy_1m_conn_params;
tBTM_BLE_CONN_PARAMS phy_2m_conn_params;
tBTM_BLE_CONN_PARAMS phy_coded_conn_params;
} tBTM_EXT_CONN_PARAMS;
typedef void (*tBTM_BLE_5_HCI_CBACK)(tBTM_BLE_5_GAP_EVENT event, tBTM_BLE_5_GAP_CB_PARAMS *params);
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
/***************************************************************************** /*****************************************************************************
** EXTERNAL FUNCTION DECLARATIONS ** EXTERNAL FUNCTION DECLARATIONS
@ -2153,5 +2567,52 @@ BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize);
} }
#endif #endif
*/ */
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void BTM_BleGapRegisterCallback(tBTM_BLE_5_HCI_CBACK cb);
tBTM_STATUS BTM_BleReadPhy(BD_ADDR bd_addr, UINT8 *tx_phy, UINT8 *rx_phy);
tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask);
tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_mask,
UINT8 rx_phy_mask, UINT16 phy_options);
tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr);
tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PARAMS *params);
tBTM_STATUS BTM_BleConfigExtendedAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 len, UINT8 *data);
tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_adv);
tBTM_STATUS BTM_BleExtAdvSetRemove(UINT8 instance);
tBTM_STATUS BTM_BleExtAdvSetClear(void);
tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params);
tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data);
tBTM_STATUS BTM_BlePeriodicAdvEnable(UINT8 instance, BOOLEAN enable);
tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params);
tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void);
tBTM_STATUS BTM_BlePeriodicAdvSyncTerm(UINT16 sync_handle);
tBTM_STATUS BTM_BlePeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
tBTM_STATUS BTM_BlePeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, BD_ADDR addr, UINT16 sid);
tBTM_STATUS BTM_BlePeriodicAdvClearDev(void);
tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params);
tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period);
void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif #endif

View File

@ -274,6 +274,9 @@ void btu_check_bt_sleep (void);
*/ */
void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf); void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg); void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
void btu_hcif_send_host_rdy_for_data(void); void btu_hcif_send_host_rdy_for_data(void);
void btu_hcif_cmd_timeout (UINT8 controller_id); void btu_hcif_cmd_timeout (UINT8 controller_id);

View File

@ -1111,7 +1111,7 @@ extern void GATT_StartIf (tGATT_IF gatt_if);
** **
*******************************************************************************/ *******************************************************************************/
extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type,
BOOLEAN is_direct, tBT_TRANSPORT transport); BOOLEAN is_direct, tBT_TRANSPORT transport, BOOLEAN is_aux);
/******************************************************************************* /*******************************************************************************

View File

@ -352,6 +352,39 @@
#define HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL (0x002C | HCI_GRP_BLE_CMDS) #define HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL (0x002C | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_ADDR_RESOLUTION_ENABLE (0x002D | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_ADDR_RESOLUTION_ENABLE (0x002D | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT (0x002E | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT (0x002E | HCI_GRP_BLE_CMDS)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define HCI_BLE_READ_PHY (0x0030 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_DEFAULT_PHY (0x0031 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PHY (0x0032 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_ENH_RX_TEST (0x0033 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_ENH_TX_TEST (0x0034 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_ADV_RAND_ADDR (0x0035 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_EXT_ADV_PARAM (0x0036 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_EXT_ADV_DATA (0x0037 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_EXT_SCAN_RSP_DATA (0x0038 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_EXT_ADV_ENABLE (0x0039 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_RD_MAX_ADV_DATA_LEN (0x003A | HCI_GRP_BLE_CMDS)
#define HCI_BLE_RD_NUM_OF_ADV_SETS (0x003B | HCI_GRP_BLE_CMDS)
#define HCI_BLE_REMOVE_ADV_SET (0x003C | HCI_GRP_BLE_CMDS)
#define HCI_BLE_CLEAR_ADV_SETS (0x003D | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PERIOD_ADV_PARAMS (0x003E | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PERIOD_ADV_DATA (0x003F | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PERIOD_ADV_ENABLE (0x0040 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_EXT_SCAN_PARAMS (0x0041 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_EXT_SCAN_ENABLE (0x0042 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_EXT_CREATE_CONN (0x0043 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_PERIOD_ADV_CREATE_SYNC (0x0044 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_PERIOD_ADV_CREATE_SYNC_CANCEL (0x0045 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_PERIOD_ADV_TERM_SYNC (0x0046 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_ADV_DEV_TO_PERIOD_ADV_LIST (0x0047 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_REMOVE_DEV_FROM_PERIOD_ADV_LIST (0x0048 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_CLEAR_PERIOD_ADV_LIST (0x0049 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_RD_PERIOD_ADV_LIST_SIZE (0x004A | HCI_GRP_BLE_CMDS)
#define HCI_BLE_RD_TRANSMIT_POWER (0x004B | HCI_GRP_BLE_CMDS)
#define HCI_BLE_RD_RF_PATH_COMPENSATION (0x004C | HCI_GRP_BLE_CMDS)
#define HCI_BLE_WR_RF_PATH_COMPENSATION (0x004D | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_PRIVACY_MODE (0x004E | HCI_GRP_BLE_CMDS)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
// Vendor OGF define // Vendor OGF define
#define HCI_VENDOR_OGF 0x3F #define HCI_VENDOR_OGF 0x3F
@ -755,6 +788,17 @@
#define HCI_BLE_DIRECT_ADV_EVT 0x0b #define HCI_BLE_DIRECT_ADV_EVT 0x0b
/* ESP vendor BLE Event sub code */ /* ESP vendor BLE Event sub code */
#define HCI_BLE_ADV_DISCARD_REPORT_EVT 0XF0 #define HCI_BLE_ADV_DISCARD_REPORT_EVT 0XF0
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define HCI_BLE_PHY_UPDATE_COMPLETE_EVT 0x0c
#define HCI_BLE_EXT_ADV_REPORT_EVT 0x0d
#define HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT 0x0e
#define HCI_BLE_PERIOD_ADV_REPORT_EVT 0x0f
#define HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT 0x10
#define HCI_BLE_SCAN_TIMEOUT_EVT 0x11
#define HCI_BLE_ADV_SET_TERMINATED_EVT 0x12
#define HCI_BLE_SCAN_REQ_RECEIVED_EVT 0x13
#define HCI_BLE_CHANNEL_SELECT_ALG 0x14
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/* Definitions for LE Channel Map */ /* Definitions for LE Channel Map */
#define HCI_BLE_CHNL_MAP_SIZE 5 #define HCI_BLE_CHNL_MAP_SIZE 5
@ -845,6 +889,9 @@
#define HCI_ERR_ESP_VENDOR_FAIL 0xE0 #define HCI_ERR_ESP_VENDOR_FAIL 0xE0
#define HCI_HINT_TO_RECREATE_AMP_PHYS_LINK 0xFF #define HCI_HINT_TO_RECREATE_AMP_PHYS_LINK 0xFF
#if (BLE_50_FEATURE_SUPPORT == TRUE)
typedef UINT8 tHCI_STATUS;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/* /*
** Definitions for HCI enable event ** Definitions for HCI enable event
@ -913,6 +960,15 @@
0x20000000 00000000 LE Meta Event 0x20000000 00000000 LE Meta Event
*/ */
#define HCI_LE_ONLY_EVENT_MASK "\x20\x00\x80\x00\x02\x00\x88\x90"
/* 0x00000000 00000010 Disconnection complete event
0x00000000 00000080 Encryption change event
0x00000000 00000800 Read remote version information complete event
0x00000000 00008000 Hardware error event
0x00000000 02000000 Data buffer overflow event
0x00008000 00000000 Encryption key refresh complete event
0x20000000 00000000 LE Meta Event
*/
/* the event mask for AMP controllers */ /* the event mask for AMP controllers */
#define HCI_AMP_EVENT_MASK_3_0 "\x00\x00\x00\x00\x00\x00\x3F\xFF" #define HCI_AMP_EVENT_MASK_3_0 "\x00\x00\x00\x00\x00\x00\x3F\xFF"

View File

@ -657,6 +657,9 @@ void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
#define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8 #define HCIC_PARAM_SIZE_SET_USED_FEAT_CMD 8
#define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6 #define HCIC_PARAM_SIZE_WRITE_RANDOM_ADDR_CMD 6
#define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15 #define HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS 15
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define HCIC_PARAM_SIZE_BLE_WRITE_EXT_ADV_PARAMS 25
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP 31
#define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1 #define HCIC_PARAM_SIZE_WRITE_ADV_ENABLE 1
#define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7 #define HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM 7
@ -693,6 +696,44 @@ void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode,
#define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6 #define HCIC_PARAM_SIZE_BLE_SET_DATA_LENGTH 6
#define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11 #define HCIC_PARAM_SIZE_BLE_WRITE_EXTENDED_SCAN_PARAM 11
#define HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL 2 #define HCIC_PARAM_SIZE_BLE_UPDATE_ADV_FLOW_CONTROL 2
#if (BLE_50_FEATURE_SUPPORT == TRUE)
#define HCIC_PARAM_SIZE_BLE_READ_PHY 2
#define HCIC_PARAM_SIZE_BLE_SET_DEF_PHY 3
#define HCIC_PARAM_SIZE_BLE_SET_PHY 7
#define HCIC_PARAM_SIZE_ENH_RX_TEST 3
#define HCIC_PARAM_SIZE_ENH_TX_TEST 4
#define HCIC_PARAM_SIZE_EXT_RAND_ADDR 7
#define HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS 25
#define HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA 251
#define HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE 0
#define HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET 0
#define HCIC_PARAM_SIZE_REMOVE_ADV_SET 1
#define HCIC_PARAM_SIZE_CLEAR_ADV_SET 0
#define HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS 7
#define HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA 252
#define HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE 2
#define HCIC_PARAM_SIZE_SET_EXT_SCAN_PARAMS 3
#define HCIC_PARAM_SIZE_EXT_SCAN_ENABLE 6
#define HCIC_PARAM_SIZE_EXT_CONN_CREATE_BASE 10
#define HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC 12
#define HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL 0
#define HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC 2
#define HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST 8
#define HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST 8
#define HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST 0
#define HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST 0
#define HCIC_PARAM_SIZE_READ_TRANS_POWER 0
#define HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION 0
#define HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION 4
osi_sem_t *btsnd_hcic_ble_get_sync_sem(void);
void btsnd_hcic_ble_sync_sem_init(void);
void btsnd_hcic_ble_sync_sem_deinit(void);
uint8_t btsnd_hcic_ble_get_status(void);
void btsnd_hci_ble_set_status(UINT8 hci_status);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
/* ULP HCI command */ /* ULP HCI command */
BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask); BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);
@ -809,14 +850,131 @@ BOOLEAN btsnd_hcic_ble_set_addr_resolution_enable (UINT8 addr_resolution_enable)
BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout); BOOLEAN btsnd_hcic_ble_set_rand_priv_addr_timeout (UINT16 rpa_timout);
#endif /* BLE_INCLUDED */ #endif /* BLE_INCLUDED */
#if (BLE_50_FEATURE_SUPPORT == TRUE)
typedef struct {
UINT8 scan_type;
UINT16 scan_interval;
UINT16 scan_window;
} tHCI_EXT_SCAN_PARAMS;
typedef struct {
UINT16 scan_interval;
UINT16 scan_window;
UINT16 conn_interval_min;
UINT16 conn_interval_max;
UINT16 conn_latency;
UINT16 sup_timeout;
UINT16 min_ce_len;
UINT16 max_ce_len;
} tHCI_ExtConnParams;
typedef struct {
UINT8 filter_policy;
UINT8 own_addr_type;
UINT8 peer_addr_type;
BD_ADDR peer_addr;
UINT8 init_phy_mask;
tHCI_ExtConnParams params[3];
} tHCI_CreatExtConn;
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle); BOOLEAN btsnd_hcic_read_authenticated_payload_tout(UINT16 handle);
BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle, BOOLEAN btsnd_hcic_write_authenticated_payload_tout(UINT16 handle,
UINT16 timeout); UINT16 timeout);
BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num); BOOLEAN btsnd_hcic_ble_update_adv_report_flow_control (UINT16 num);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BOOLEAN btsnd_hcic_ble_read_phy(UINT16 conn_handle);
UINT8 btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys,
UINT8 tx_phys,
UINT8 rx_phys);
BOOLEAN btsnd_hcic_ble_set_phy(UINT16 conn_handle,
UINT8 all_phys, UINT8 tx_phys,
UINT8 rx_phys, UINT16 phy_options);
UINT8 btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel, UINT8 phy,
UINT8 modulation_idx);
UINT8 btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel, UINT8 len,
UINT8 packect,
UINT8 phy);
UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr);
UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UINT32 interval_min,
UINT32 interval_max, UINT8 channel_map, UINT8 own_addr_type,
UINT8 peer_addr_type, BD_ADDR peer_addr,
UINT8 adv_filter_policy, UINT8 adv_tx_power,
UINT8 primary_adv_phy, UINT8 secondary_adv_max_skip,
UINT8 secondary_adv_phy,
UINT8 adv_sid, UINT8 scan_req_ntf_enable);
UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,
UINT8 operation, UINT8 fragment_prefrence,
UINT8 data_len, UINT8 *p_data);
UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
UINT8 operation, UINT8 fragment_prefrence,
UINT8 data_len, UINT8 *p_data);
UINT8 btsnd_hcic_ble_ext_adv_enable(UINT8 enable, UINT8 num_of_sets, UINT8 *adv_handle,
UINT16 *duration, UINT8 *max_adv_evt);
UINT8 btsnd_hcic_ble_read_max_adv_len(void);
UINT8 btsnd_hcic_ble_read_num_support_adv_set(void);
UINT8 btsnd_hcic_ble_remove_adv_set(UINT8 adv_handle);
UINT8 btsnd_hcic_ble_clear_adv_set(void);
UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle,
UINT16 interval_min,
UINT16 interval_max,
UINT8 propertics);
UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,
UINT8 operation,
UINT8 len,
UINT8 *p_data);
UINT8 btsnd_hcic_ble_periodic_adv_enable(UINT8 enable, UINT8 adv_handle);
UINT8 btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type, UINT8 filter_policy,
UINT8 phy_mask, UINT8 phy_count,
tHCI_EXT_SCAN_PARAMS *params);
UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups,
UINT16 duration, UINT16 period);
BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn);
BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid,
UINT8 adv_addr_type, BD_ADDR adv_addr,
UINT16 sync_timeout, UINT8 unused);
UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void);
UINT8 btsnd_hcic_ble_periodic_adv_term_sync(UINT16 sync_handle);
UINT8 btsnd_hcic_ble_add_dev_to_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
UINT8 adv_sid);
UINT8 btsnd_hcic_ble_rm_dev_from_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR adv_addr,
UINT8 adv_sid);
UINT8 btsnd_hcic_ble_clear_periodic_adv_list(void);
UINT8 btsnd_hcic_ble_read_periodic_adv_list_size(void);
UINT8 btsnd_hcic_ble_read_trans_power(void);
UINT8 btsnd_hcic_ble_read_rf_path_compensation(void);
UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_path);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4 #define HCIC_PARAM_SIZE_WRITE_AUTHENT_PAYLOAD_TOUT 4
#define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0 #define HCI__WRITE_AUTHENT_PAYLOAD_TOUT_HANDLE_OFF 0

View File

@ -1085,7 +1085,7 @@ extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_R
** Return value: TRUE if connection started ** Return value: TRUE if connection started
** **
*******************************************************************************/ *******************************************************************************/
extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type); extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux);
/******************************************************************************* /*******************************************************************************
** **
@ -1227,7 +1227,7 @@ extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
*******************************************************************************/ *******************************************************************************/
extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport); extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport);
extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, UINT16 handle); extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, BD_ADDR addr);
#define L2CA_GET_ATT_NUM 0 #define L2CA_GET_ATT_NUM 0
#define L2CA_ADD_BTC_NUM 1 #define L2CA_ADD_BTC_NUM 1

View File

@ -378,7 +378,7 @@ typedef struct {
typedef struct t_l2c_linkcb { typedef struct t_l2c_linkcb {
BOOLEAN in_use; /* TRUE when in use, FALSE when not */ BOOLEAN in_use; /* TRUE when in use, FALSE when not */
tL2C_LINK_STATE link_state; tL2C_LINK_STATE link_state;
BOOLEAN is_aux; /* This variable used for BLE 5.0 or higher version when do auxiliary connection */
TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */ TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */
UINT16 handle; /* The handle used with LM */ UINT16 handle; /* The handle used with LM */
UINT16 completed_packets; /* The number of conpleted packets */ UINT16 completed_packets; /* The number of conpleted packets */
@ -609,6 +609,7 @@ extern void l2cu_change_pri_ccb (tL2C_CCB *p_ccb, tL2CAP_CHNL_PRIORITY prior
extern tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid); extern tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid);
extern void l2cu_release_ccb (tL2C_CCB *p_ccb); extern void l2cu_release_ccb (tL2C_CCB *p_ccb);
extern tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid); extern tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid);
extern tL2C_CCB *l2cu_find_free_ccb(void);
extern tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid); extern tL2C_CCB *l2cu_find_ccb_by_remote_cid (tL2C_LCB *p_lcb, UINT16 remote_cid);
extern void l2cu_adj_id (tL2C_LCB *p_lcb, UINT8 adj_mask); extern void l2cu_adj_id (tL2C_LCB *p_lcb, UINT8 adj_mask);
extern BOOLEAN l2c_is_cmd_rejected (UINT8 cmd_code, UINT8 id, tL2C_LCB *p_lcb); extern BOOLEAN l2c_is_cmd_rejected (UINT8 cmd_code, UINT8 id, tL2C_LCB *p_lcb);

View File

@ -1649,7 +1649,7 @@ BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_f
** Return value: TRUE if connection started ** Return value: TRUE if connection started
** **
*******************************************************************************/ *******************************************************************************/
BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type) BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux)
{ {
tL2C_LCB *p_lcb; tL2C_LCB *p_lcb;
tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR; tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
@ -1740,6 +1740,7 @@ BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE
return FALSE; return FALSE;
} }
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
p_lcb->is_aux = is_aux;
p_lcb->open_addr_type = bd_addr_type; p_lcb->open_addr_type = bd_addr_type;
#endif #endif
if (!l2cu_create_conn(p_lcb, transport)) { if (!l2cu_create_conn(p_lcb, transport)) {
@ -1838,7 +1839,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
fixed_queue_length(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q), fixed_queue_length(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q),
p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota); p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
osi_free(p_buf); osi_free(p_buf);
return (L2CAP_DW_FAILED); return (L2CAP_DW_CONGESTED);
} }
l2c_enqueue_peer_data (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL], p_buf); l2c_enqueue_peer_data (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL], p_buf);
@ -1857,10 +1858,10 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
return (L2CAP_DW_SUCCESS); return (L2CAP_DW_SUCCESS);
} }
BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, UINT16 handle) BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, BD_ADDR addr)
{ {
tL2C_LCB *p_lcb; tL2C_LCB *p_lcb;
p_lcb = l2cu_find_lcb_by_handle(handle); p_lcb = l2cu_find_lcb_by_bd_addr(addr, BT_TRANSPORT_LE);
if (p_lcb != NULL && p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] != NULL) { if (p_lcb != NULL && p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL] != NULL) {
return p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent; return p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent;

View File

@ -33,6 +33,23 @@
#include "device/controller.h" #include "device/controller.h"
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
const tHCI_ExtConnParams ext_conn_params = {
.scan_interval = 0x40,
.scan_window = 0x40,
.conn_interval_min = 320, // 306-> 362Kbps
.conn_interval_max = 320,
.conn_latency = 0,
.sup_timeout = 600,
.min_ce_len = 0,
.max_ce_len = 0,
};
#define BLE_PHY_NO_PREF 0
#define BLE_PHY_PREF_MASK ((1 << 2) | (1 << 1) | (1 << 0))
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
static BOOLEAN l2cble_start_conn_update (tL2C_LCB *p_lcb); static BOOLEAN l2cble_start_conn_update (tL2C_LCB *p_lcb);
/******************************************************************************* /*******************************************************************************
@ -332,7 +349,7 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type,
(conn_interval > p_dev_rec->conn_params.max_conn_int) || (conn_interval > p_dev_rec->conn_params.max_conn_int) ||
(conn_latency > p_dev_rec->conn_params.slave_latency) || (conn_latency > p_dev_rec->conn_params.slave_latency) ||
(conn_timeout > p_dev_rec->conn_params.supervision_tout))) { (conn_timeout > p_dev_rec->conn_params.supervision_tout))) {
L2CAP_TRACE_WARNING ("upd_ll_conn_params: HANDLE=%d min_conn_int=%d max_conn_int=%d slave_latency=%d supervision_tout=%d", L2CAP_TRACE_ERROR ("upd_ll_conn_params: HANDLE=%d min_conn_int=%d max_conn_int=%d slave_latency=%d supervision_tout=%d",
handle, p_dev_rec->conn_params.min_conn_int, p_dev_rec->conn_params.max_conn_int, handle, p_dev_rec->conn_params.min_conn_int, p_dev_rec->conn_params.max_conn_int,
p_dev_rec->conn_params.slave_latency, p_dev_rec->conn_params.supervision_tout); p_dev_rec->conn_params.slave_latency, p_dev_rec->conn_params.supervision_tout);
@ -753,7 +770,7 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
*******************************************************************************/ *******************************************************************************/
BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
{ {
#if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE)) #if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE) && (!CONTROLLER_RPA_LIST_ENABLE))
//check for security device information in the cache //check for security device information in the cache
bool dev_rec_exist = true; bool dev_rec_exist = true;
tBTM_SEC_DEV_REC *find_dev_rec = btm_find_dev (p_lcb->remote_bd_addr); tBTM_SEC_DEV_REC *find_dev_rec = btm_find_dev (p_lcb->remote_bd_addr);
@ -761,7 +778,7 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
dev_rec_exist = false; dev_rec_exist = false;
} }
#endif #endif // ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE) && (!CONTROLLER_RPA_LIST_ENABLE))
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_lcb->remote_bd_addr); tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_lcb->remote_bd_addr);
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
UINT16 scan_int; UINT16 scan_int;
@ -784,6 +801,8 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
#if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE)) #if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE))
own_addr_type = btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type; own_addr_type = btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type;
#if (!CONTROLLER_RPA_LIST_ENABLE)
if(dev_rec_exist) { if(dev_rec_exist) {
// if the current address information is valid, get the real address information // if the current address information is valid, get the real address information
if(p_dev_rec->ble.current_addr_valid) { if(p_dev_rec->ble.current_addr_valid) {
@ -803,19 +822,25 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
* It is a hardware limitation. The preliminary solution is not to * It is a hardware limitation. The preliminary solution is not to
* send key to the controller, but to resolve the random address in host. * send key to the controller, but to resolve the random address in host.
* so we need send the real address information to controller. */ * so we need send the real address information to controller. */
/*
#endif // (!CONTROLLER_RPA_LIST_ENABLE)
#if CONTROLLER_RPA_LIST_ENABLE
if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) { if (p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) {
if (btm_cb.ble_ctr_cb.privacy_mode >= BTM_PRIVACY_1_2) { if (btm_cb.ble_ctr_cb.privacy_mode >= BTM_PRIVACY_1_2) {
own_addr_type |= BLE_ADDR_TYPE_ID_BIT; own_addr_type |= BLE_ADDR_TYPE_ID_BIT;
} }
btm_ble_enable_resolving_list(BTM_BLE_RL_INIT); //btm_ble_enable_resolving_list(BTM_BLE_RL_INIT);
btm_random_pseudo_to_identity_addr(peer_addr, &peer_addr_type); btm_random_pseudo_to_identity_addr(peer_addr, &peer_addr_type);
} else { } else {
btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, TRUE); btm_ble_disable_resolving_list(BTM_BLE_RL_INIT, TRUE);
} }
*/
#endif #endif // CONTROLLER_RPA_LIST_ENABLE
#endif // (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE)
if (!btm_ble_topology_check(BTM_BLE_STATE_INIT)) { if (!btm_ble_topology_check(BTM_BLE_STATE_INIT)) {
l2cu_release_lcb (p_lcb); l2cu_release_lcb (p_lcb);
@ -823,6 +848,7 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
return FALSE; return FALSE;
} }
if (!p_lcb->is_aux) {
if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int */ if (!btsnd_hcic_ble_create_ll_conn (scan_int,/* UINT16 scan_int */
scan_win, /* UINT16 scan_win */ scan_win, /* UINT16 scan_win */
FALSE, /* UINT8 white_list */ FALSE, /* UINT8 white_list */
@ -849,6 +875,39 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_BLE_LINK_CONNECT_TOUT); btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_BLE_LINK_CONNECT_TOUT);
btm_ble_set_conn_st (BLE_DIR_CONN); btm_ble_set_conn_st (BLE_DIR_CONN);
return (TRUE);
}
} else {
#if (BLE_50_FEATURE_SUPPORT == TRUE)
tHCI_CreatExtConn aux_conn = {0};
aux_conn.filter_policy = FALSE;
aux_conn.own_addr_type = own_addr_type;
aux_conn.peer_addr_type = peer_addr_type;
memcpy(aux_conn.peer_addr, peer_addr, sizeof(BD_ADDR));
if (p_dev_rec->ext_conn_params.phy_mask == BLE_PHY_NO_PREF) {
L2CAP_TRACE_WARNING("No extend connection parameters set, use default parameters");
aux_conn.init_phy_mask = BLE_PHY_PREF_MASK;
memcpy(&aux_conn.params[0], &ext_conn_params, sizeof(tHCI_ExtConnParams));
memcpy(&aux_conn.params[1], &ext_conn_params, sizeof(tHCI_ExtConnParams));
memcpy(&aux_conn.params[2], &ext_conn_params, sizeof(tHCI_ExtConnParams));
} else {
aux_conn.init_phy_mask = p_dev_rec->ext_conn_params.phy_mask;
memcpy(&aux_conn.params[0], &p_dev_rec->ext_conn_params.phy_1m_conn_params, sizeof(tHCI_ExtConnParams));
memcpy(&aux_conn.params[1], &p_dev_rec->ext_conn_params.phy_2m_conn_params, sizeof(tHCI_ExtConnParams));
memcpy(&aux_conn.params[2], &p_dev_rec->ext_conn_params.phy_coded_conn_params, sizeof(tHCI_ExtConnParams));
}
p_lcb->link_state = LST_CONNECTING;
l2cb.is_ble_connecting = TRUE;
memcpy (l2cb.ble_connecting_bda, p_lcb->remote_bd_addr, BD_ADDR_LEN);
btu_start_timer (&p_lcb->timer_entry, BTU_TTYPE_L2CAP_LINK, L2CAP_BLE_LINK_CONNECT_TOUT);
btm_ble_set_conn_st (BLE_DIR_CONN);
if(!btsnd_hcic_ble_create_ext_conn(&aux_conn)) {
l2cu_release_lcb (p_lcb);
L2CAP_TRACE_ERROR("initate Aux connection failed, no resources");
}
#else
L2CAP_TRACE_ERROR("BLE 5.0 not support!\n");
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
return (TRUE); return (TRUE);
} }
} }
@ -1220,7 +1279,7 @@ UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb)
UINT32 timeout = 6; UINT32 timeout = 6;
if (p_lcb != NULL){ if (p_lcb != NULL){
//1.25 * conn_int *(1+ latency) *32 //1.25 * conn_int *(1+ latency) *32
timeout = (40 * ( 1 + p_lcb->current_used_conn_latency) * p_lcb->current_used_conn_interval + 500) / 1000; timeout = (40 * ( 1 + p_lcb->current_used_conn_latency) * p_lcb->current_used_conn_interval + 1000) / 1000;
if (timeout < 1){ if (timeout < 1){
timeout = 1; timeout = 1;
}else if (timeout > 120){ }else if (timeout > 120){

View File

@ -888,13 +888,40 @@ void l2c_init (void)
l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL); l2ble_update_att_acl_pkt_num(L2CA_BUFF_INI, NULL);
#endif #endif
} }
void l2c_free_p_lcb_pool(void)
{
list_node_t *p_node = NULL;
tL2C_LCB *p_lcb = NULL;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if (p_lcb) {
l2cu_release_lcb (p_lcb);
}
}
list_free(l2cb.p_lcb_pool);
}
void l2c_free_p_ccb_pool(void)
{
list_node_t *p_node = NULL;
tL2C_CCB *p_ccb = NULL;
for (p_node = list_begin(l2cb.p_ccb_pool); p_node; p_node = list_next(p_node)) {
p_ccb = list_node(p_node);
if (p_ccb) {
l2cu_release_ccb (p_ccb);
}
}
list_free(l2cb.p_ccb_pool);
}
void l2c_free(void) void l2c_free(void)
{ {
list_free(l2cb.rcv_pending_q); list_free(l2cb.rcv_pending_q);
l2cb.rcv_pending_q = NULL; l2cb.rcv_pending_q = NULL;
list_free(l2cb.p_lcb_pool); l2c_free_p_lcb_pool();
list_free(l2cb.p_ccb_pool); l2c_free_p_ccb_pool();
#if L2C_DYNAMIC_MEMORY #if L2C_DYNAMIC_MEMORY
FREE_AND_RESET(l2c_cb_ptr); FREE_AND_RESET(l2c_cb_ptr);
#endif #endif

View File

@ -52,7 +52,13 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
{ {
tL2C_LCB *p_lcb = NULL; tL2C_LCB *p_lcb = NULL;
bool list_ret = false; bool list_ret = false;
if (list_length(l2cb.p_lcb_pool) < MAX_L2CAP_LINKS) { extern tL2C_LCB *l2cu_find_free_lcb (void);
// temp solution
p_lcb = l2cu_find_free_lcb();
if(p_lcb != NULL) {
list_ret = true;
}
if(p_lcb == NULL && list_length(l2cb.p_lcb_pool) < MAX_L2CAP_LINKS) {
p_lcb = (tL2C_LCB *)osi_malloc(sizeof(tL2C_LCB)); p_lcb = (tL2C_LCB *)osi_malloc(sizeof(tL2C_LCB));
if (p_lcb) { if (p_lcb) {
memset (p_lcb, 0, sizeof(tL2C_LCB)); memset (p_lcb, 0, sizeof(tL2C_LCB));
@ -272,14 +278,6 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE) #if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
p_lcb->completed_packets = 0; p_lcb->completed_packets = 0;
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE #endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
{
if (list_remove(l2cb.p_lcb_pool, p_lcb)) {
p_lcb = NULL;
}
else {
L2CAP_TRACE_ERROR("Error in removing L2CAP Link Control Block");
}
}
} }
@ -312,6 +310,20 @@ tL2C_LCB *l2cu_find_lcb_by_bd_addr (BD_ADDR p_bd_addr, tBT_TRANSPORT transport)
return (NULL); return (NULL);
} }
tL2C_LCB *l2cu_find_free_lcb (void)
{
list_node_t *p_node = NULL;
tL2C_LCB *p_lcb = NULL;
for (p_node = list_begin(l2cb.p_lcb_pool); p_node; p_node = list_next(p_node)) {
p_lcb = list_node(p_node);
if (!p_lcb->in_use) {
return (p_lcb);
}
}
/* If here, no match found */
return (NULL);
}
/******************************************************************************* /*******************************************************************************
** **
** Function l2cu_get_conn_role ** Function l2cu_get_conn_role
@ -1438,14 +1450,17 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
tL2C_CCB *p_ccb = NULL; tL2C_CCB *p_ccb = NULL;
L2CAP_TRACE_DEBUG ("l2cu_allocate_ccb: cid 0x%04x", cid); L2CAP_TRACE_DEBUG ("l2cu_allocate_ccb: cid 0x%04x", cid);
p_ccb = l2cu_find_free_ccb ();
if(p_ccb == NULL) {
if (list_length(l2cb.p_ccb_pool) < MAX_L2CAP_CHANNELS) { if (list_length(l2cb.p_ccb_pool) < MAX_L2CAP_CHANNELS) {
p_ccb = (tL2C_CCB *)osi_malloc(sizeof(tL2C_CCB)); p_ccb = (tL2C_CCB *)osi_malloc(sizeof(tL2C_CCB));
if (p_ccb) { if (p_ccb) {
memset (p_ccb, 0, sizeof(tL2C_CCB)); memset (p_ccb, 0, sizeof(tL2C_CCB));
list_append(l2cb.p_ccb_pool, p_ccb); list_append(l2cb.p_ccb_pool, p_ccb);
} }
} }
}
if (p_ccb == NULL) { if (p_ccb == NULL) {
return (NULL); return (NULL);
} }
@ -1674,14 +1689,7 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb)
/* Flag as not in use */ /* Flag as not in use */
p_ccb->in_use = FALSE; p_ccb->in_use = FALSE;
{
if (list_remove(l2cb.p_ccb_pool, p_ccb)) {
p_ccb = NULL;
}
else {
L2CAP_TRACE_ERROR("Error in removing L2CAP Channel Control Block");
}
}
/* If no channels on the connection, start idle timeout */ /* If no channels on the connection, start idle timeout */
if ((p_lcb) && p_lcb->in_use && (p_lcb->link_state == LST_CONNECTED)) { if ((p_lcb) && p_lcb->in_use && (p_lcb->link_state == LST_CONNECTED)) {
if (!p_lcb->ccb_queue.p_first_ccb) { if (!p_lcb->ccb_queue.p_first_ccb) {
@ -3256,6 +3264,23 @@ tL2C_CCB *l2cu_find_ccb_by_cid (tL2C_LCB *p_lcb, UINT16 local_cid)
return (p_ccb); return (p_ccb);
} }
tL2C_CCB *l2cu_find_free_ccb (void)
{
tL2C_CCB *p_ccb = NULL;
list_node_t *p_node = NULL;
for (p_node = list_begin(l2cb.p_ccb_pool); p_node; p_node = list_next(p_node))
{
p_ccb = list_node(p_node);
if(p_ccb && !p_ccb->in_use ) {
return p_ccb;
}
}
return (NULL);
}
#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE && CLASSIC_BT_INCLUDED == TRUE) #if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE && CLASSIC_BT_INCLUDED == TRUE)
/****************************************************************************** /******************************************************************************

View File

@ -161,7 +161,7 @@ tSMP_STATUS SMP_Pair (BD_ADDR bd_addr)
memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN); memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN);
if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE)) { if (!L2CA_ConnectFixedChnl (L2CAP_SMP_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) {
SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.\n", __FUNCTION__); SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.\n", __FUNCTION__);
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status); smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
return status; return status;
@ -205,7 +205,7 @@ tSMP_STATUS SMP_BR_PairWith (BD_ADDR bd_addr)
memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN); memcpy (p_cb->pairing_bda, bd_addr, BD_ADDR_LEN);
if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE)) { if (!L2CA_ConnectFixedChnl (L2CAP_SMP_BR_CID, bd_addr, BLE_ADDR_UNKNOWN_TYPE, FALSE)) {
SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __FUNCTION__); SMP_TRACE_ERROR("%s: L2C connect fixed channel failed.", __FUNCTION__);
smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status); smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &status);
return status; return status;

View File

@ -59,14 +59,14 @@ the adv packet will be discarded until the memory is restored. */
/* enable controller log debug when adv lost */ /* enable controller log debug when adv lost */
#define CONTROLLER_ADV_LOST_DEBUG_BIT (0<<0) #define CONTROLLER_ADV_LOST_DEBUG_BIT (0<<0)
#ifdef CONFIG_BT_HCI_UART_NO #ifdef CONFIG_BTDM_CTRL_HCI_UART_NO
#define BT_HCI_UART_NO_DEFAULT CONFIG_BT_HCI_UART_NO #define BT_HCI_UART_NO_DEFAULT CONFIG_BTDM_CTRL_HCI_UART_NO
#else #else
#define BT_HCI_UART_NO_DEFAULT 1 #define BT_HCI_UART_NO_DEFAULT 1
#endif /* BT_HCI_UART_NO_DEFAULT */ #endif /* BT_HCI_UART_NO_DEFAULT */
#ifdef CONFIG_BT_HCI_UART_BAUDRATE #ifdef CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE
#define BT_HCI_UART_BAUDRATE_DEFAULT CONFIG_BT_HCI_UART_BAUDRATE #define BT_HCI_UART_BAUDRATE_DEFAULT CONFIG_BTDM_CTRL_HCI_UART_BAUDRATE
#else #else
#define BT_HCI_UART_BAUDRATE_DEFAULT 921600 #define BT_HCI_UART_BAUDRATE_DEFAULT 921600
#endif /* BT_HCI_UART_BAUDRATE_DEFAULT */ #endif /* BT_HCI_UART_BAUDRATE_DEFAULT */
@ -457,7 +457,7 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
* There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only. * There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only.
* *
* For ORIG mode: * For ORIG mode:
* Bluetooth modem sleep is enabled in controller start up by default if CONFIG_BTDM_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request". * Bluetooth modem sleep is enabled in controller start up by default if CONFIG_CTRL_BTDM_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request".
* *
* @return * @return
* - ESP_OK : success * - ESP_OK : success

View File

@ -0,0 +1,512 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_BT_H__
#define __ESP_BT_H__
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "sdkconfig.h"
#include "esp_task.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BT_CTRL_CONFIG_VERSION 0x02004260
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
#define ESP_BT_HCI_TL_VERSION 0x00010000
/**
* @brief Bluetooth mode for controller enable/disable
*/
typedef enum {
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
} esp_bt_mode_t;
/**
* @brief Type of controller HCI transport layer
*/
typedef enum {
ESP_BT_CTRL_HCI_TL_UART = 0, /*!< HCI UART h4 transport layer */
ESP_BT_CTRL_HCI_TL_VHCI = 1, /*!< VHCI interface */
} esp_bt_ctrl_hci_tl_t;
/**
* @breif type of BLE connection event length computation
*/
typedef enum {
ESP_BLE_CE_LEN_TYPE_ORIG = 0, /*!< original */
ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use CE_LEN parameter from HCI commands */
ESP_BLE_CE_LEN_TYPE_SD = 1, /*!< Espressif vendor defined */
} esp_ble_ce_len_t;
/**
* @brief Bluetooth sleep mode
*/
typedef enum {
ESP_BT_SLEEP_MODE_NONE = 0, /*!< Bluetooth sleep mode disabled */
ESP_BT_SLEEP_MODE_1 = 1, /*!< Bluetooth sleep mode 1 */
} esp_bt_sleep_mode_t;
/**
* @brief Bluetooth sleep clock
*/
typedef enum {
ESP_BT_SLEEP_CLOCK_NONE = 0, /*!< Sleep clock not configured */
ESP_BT_SLEEP_CLOCK_MAIN_XTAL = 1, /*!< SoC main crystal */
ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL = 2, /*!< External 32.768kHz crystal */
ESP_BT_SLEEP_CLOCK_FPGA_32K = 3, /*!< Hardwired 32KHz clock temporarily used for FPGA */
} esp_bt_sleep_clock_t;
/**
* @brief antenna index used for bluetooth
*/
enum {
ESP_BT_ANT_IDX_0 = 0, /*!< anntena NO 0 */
ESP_BT_ANT_IDX_1 = 1, /*!< anntena NO 1 */
};
#ifdef CONFIG_BT_ENABLED
#ifdef CONFIG_BT_CTRL_COEX_PARAMETERS_ENABLE
#define BT_CTRL_COEX_PARAMETERS_ENABLE true
#else
#define BT_CTRL_COEX_PARAMETERS_ENABLE false
#endif
#ifdef CONFIG_BT_CTRL_COEX_USE_HOOKS
#define BT_CTRL_COEX_USE_HOOKS true
#else
#define BT_CTRL_COEX_USE_HOOKS false
#endif
#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
#ifdef CONFIG_BT_CTRL_SCAN_DUPL_TYPE
#define SCAN_DUPLICATE_TYPE_VALUE CONFIG_BT_CTRL_SCAN_DUPL_TYPE
#else
#define SCAN_DUPLICATE_TYPE_VALUE 0
#endif
/* normal adv cache size */
#ifdef CONFIG_BT_SCAN_DUPL_CACHE_SIZE
#define NORMAL_SCAN_DUPLICATE_CACHE_SIZE CONFIG_BT_SCAN_DUPL_CACHE_SIZE
#else
#define NORMAL_SCAN_DUPLICATE_CACHE_SIZE 20
#endif
#ifndef CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN
#define CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN FALSE
#endif
#define SCAN_DUPLICATE_MODE_NORMAL_ADV_ONLY 0
#define SCAN_DUPLICATE_MODE_NORMAL_ADV_MESH_ADV 1
#if CONFIG_BT_CTRL_BLE_MESH_SCAN_DUPL_EN
#define SCAN_DUPLICATE_MODE SCAN_DUPLICATE_MODE_NORMAL_ADV_MESH_ADV
#ifdef CONFIG_BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
#define MESH_DUPLICATE_SCAN_CACHE_SIZE CONFIG_BT_CTRL_MESH_DUPL_SCAN_CACHE_SIZE
#else
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 50
#endif
#else
#define SCAN_DUPLICATE_MODE SCAN_DUPLICATE_MODE_NORMAL_ADV_ONLY
#define MESH_DUPLICATE_SCAN_CACHE_SIZE 0
#endif
#define CFG_MASK_BIT_SCAN_DUPLICATE_OPTION (1<<0)
#define CFG_NASK CFG_MASK_BIT_SCAN_DUPLICATE_OPTION
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \
.version = ESP_BT_CTRL_CONFIG_VERSION, \
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.controller_task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.bluetooth_mode = CONFIG_BT_CTRL_MODE_EFF, \
.ble_max_act = CONFIG_BT_CTRL_BLE_MAX_ACT_EFF, \
.sleep_mode = CONFIG_BT_CTRL_SLEEP_MODE_EFF, \
.sleep_clock = CONFIG_BT_CTRL_SLEEP_CLOCK_EFF, \
.ble_st_acl_tx_buf_nb = CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB, \
.ble_hw_cca_check = CONFIG_BT_CTRL_HW_CCA_EFF, \
.ble_adv_dup_filt_max = CONFIG_BT_CTRL_ADV_DUP_FILT_MAX, \
.coex_param_en = BT_CTRL_COEX_PARAMETERS_ENABLE, \
.ce_len_type = CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF, \
.coex_use_hooks = BT_CTRL_COEX_USE_HOOKS, \
.hci_tl_type = CONFIG_BT_CTRL_HCI_TL_EFF, \
.hci_tl_funcs = NULL, \
.txant_dft = CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF, \
.rxant_dft = CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF, \
.txpwr_dft = CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF, \
.cfg_mask = CFG_NASK, \
.scan_duplicate_mode = SCAN_DUPLICATE_MODE, \
.scan_duplicate_type = SCAN_DUPLICATE_TYPE_VALUE, \
.normal_adv_size = NORMAL_SCAN_DUPLICATE_CACHE_SIZE, \
.mesh_adv_size = MESH_DUPLICATE_SCAN_CACHE_SIZE, \
};
#else
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable bluetooth in menuconfig to use bt.h");
#endif
/**
* @brief Controller HCI transport layer function structure
* This structure shall be registered when HCI transport layer is UART
*/
typedef struct {
uint32_t _magic; /* Magic number */
uint32_t _version; /* version number of the defined structure */
uint32_t _reserved; /* reserved for future use */
int (* _open)(void); /* hci tl open */
void (* _close)(void); /* hci tl close */
void (* _finish_transfers)(void); /* hci tl finish trasnfers */
void (* _recv)(uint8_t *buf, uint32_t len, void (*callback) (void*, uint8_t), void* dummy); /* hci tl recv */
void (* _send)(uint8_t *buf, uint32_t len, void (*callback) (void*, uint8_t), void* dummy); /* hci tl send */
bool (* _flow_off)(void); /* hci tl flow off */
void (* _flow_on)(void); /* hci tl flow on */
} esp_bt_hci_tl_t;
/**
* @brief Controller config options, depend on config mask.
* Config mask indicate which functions enabled, this means
* some options or parameters of some functions enabled by config mask.
*/
typedef struct {
/*
* Following parameters can not be configured runtime when call esp_bt_controller_init()
* They will be overwritten by constant values from menuconfig options or from macros.
* So, do not modify the value when esp_bt_controller_init()
*/
uint32_t magic; /*!< Magic number */
uint32_t version; /*!< version number of the defined structure */
/*
* Following parameters can be configured runtime, when call esp_bt_controller_init()
*/
uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
uint8_t controller_task_run_cpu; /*!< CPU num that Bluetooth controller task runs on */
uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
uint8_t ble_max_act; /*!< BLE maximum number of air activities */
uint8_t sleep_mode; /*!< controller sleep mode */
uint8_t sleep_clock; /*!< controller sleep clock */
uint8_t ble_st_acl_tx_buf_nb; /*!< controller static ACL TX BUFFER number */
uint8_t ble_hw_cca_check; /*!< controller hardware triggered CCA check */
uint16_t ble_adv_dup_filt_max; /*!< maxinum number of duplicate scan filter */
bool coex_param_en; /*!< init coex parameters*/
uint8_t ce_len_type; /*!< connection event length computation method */
bool coex_use_hooks; /*!< use hooks in bluetooth to assist WiFi behavouir determination */
uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */
esp_bt_hci_tl_t *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */
uint8_t txant_dft; /*!< default Tx antenna */
uint8_t rxant_dft; /*!< default Rx antenna */
uint8_t txpwr_dft; /*!< default Tx power */
uint32_t cfg_mask;
uint8_t scan_duplicate_mode; /*!< scan duplicate mode */
uint8_t scan_duplicate_type; /*!< scan duplicate type */
uint16_t normal_adv_size; /*!< Normal adv size for scan duplicate */
uint16_t mesh_adv_size; /*!< Mesh adv size for scan duplicate */
} esp_bt_controller_config_t;
/**
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
*/
typedef enum {
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
ESP_BT_CONTROLLER_STATUS_INITED,
ESP_BT_CONTROLLER_STATUS_ENABLED,
ESP_BT_CONTROLLER_STATUS_NUM,
} esp_bt_controller_status_t;
/**
* @brief BLE tx power type
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
* when disconnect, the correspond TX power is not effected.
* ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
* ESP_BLE_PWR_TYPE_SCAN : for scan.
* ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
* if neither in scan mode nor in adv mode, it will use this default value.
* If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
*/
typedef enum {
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
} esp_ble_power_type_t;
/**
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9dbm */
ESP_PWR_LVL_N14 = ESP_PWR_LVL_N12, /*!< Backward compatibility! Setting to -14dbm will actually result to -12dbm */
ESP_PWR_LVL_N11 = ESP_PWR_LVL_N9, /*!< Backward compatibility! Setting to -11dbm will actually result to -9dbm */
ESP_PWR_LVL_N8 = ESP_PWR_LVL_N6, /*!< Backward compatibility! Setting to -8dbm will actually result to -6dbm */
ESP_PWR_LVL_N5 = ESP_PWR_LVL_N3, /*!< Backward compatibility! Setting to -5dbm will actually result to -3dbm */
ESP_PWR_LVL_N2 = ESP_PWR_LVL_N0, /*!< Backward compatibility! Setting to -2dbm will actually result to 0dbm */
ESP_PWR_LVL_P1 = ESP_PWR_LVL_P3, /*!< Backward compatibility! Setting to +1dbm will actually result to +3dbm */
ESP_PWR_LVL_P4 = ESP_PWR_LVL_P6, /*!< Backward compatibility! Setting to +4dbm will actually result to +6dbm */
ESP_PWR_LVL_P7 = ESP_PWR_LVL_P9, /*!< Backward compatibility! Setting to +7dbm will actually result to +9dbm */
} esp_power_level_t;
/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
/**
* @brief Get BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
/**
* @brief Initialize BT controller to allocate task and other resource.
* This function should be called only once, before any other BT functions are called.
* @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some
* connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
/**
* @brief De-initialize BT controller to free resource and delete task.
*
* This function should be called only once, after any other BT functions are called.
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_deinit(void);
/**
* @brief Enable BT controller.
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
* to change the controller mode dynamically. To change controller mode, call
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
* @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be
* equal as the mode in "cfg" of esp_bt_controller_init().
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/**
* @brief Disable BT controller
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_disable(void);
/**
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
* @return status value
*/
esp_bt_controller_status_t esp_bt_controller_get_status(void);
uint16_t esp_bt_get_tx_buf_num(void);
/** @brief esp_vhci_host_callback
* used for vhci call host function to notify what host need to do
*/
typedef struct esp_vhci_host_callback {
void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
} esp_vhci_host_callback_t;
/** @brief esp_vhci_host_check_send_available
* used for check actively if the host can send packet to controller or not.
* @return true for ready to send, false means cannot send packet
*/
bool esp_vhci_host_check_send_available(void);
/** @brief esp_vhci_host_send_packet
* host send packet to controller
*
* Should not call this function from within a critical section
* or when the scheduler is suspended.
*
* @param data the packet point
* @param len the packet length
*/
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
/** @brief esp_vhci_host_register_callback
* register the vhci reference callback
* struct defined by vhci_host_callback structure.
* @param callback esp_vhci_host_callback type variable
* @return ESP_OK - success, ESP_FAIL - failed
*/
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/** @brief esp_bt_controller_mem_release
* release the controller memory as per the mode
*
* This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes.
*
* esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
* or after esp_bt_controller_deinit().
*
* Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
* esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory.
*
* If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead,
* which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data
* consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of
* esp_bt_mem_release() function
*
* @param mode : the mode want to release memory
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
/** @brief esp_bt_mem_release
* release controller memory and BSS and data section of the BT/BLE host stack as per the mode
*
* This function first releases controller memory by internally calling esp_bt_controller_mem_release().
* Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap
*
* Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM)
* before esp_bt_controller_init or after esp_bt_controller_deinit.
*
* For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation".
* In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory.
* Below is the sequence of APIs to be called for such scenarios:
*
* esp_bluedroid_disable();
* esp_bluedroid_deinit();
* esp_bt_controller_disable();
* esp_bt_controller_deinit();
* esp_bt_mem_release(ESP_BT_MODE_BTDM);
*
* @param mode : the mode whose memory is to be released
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
/**
* @brief enable bluetooth to enter modem sleep
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
*
* There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only.
*
* For ORIG mode:
* Bluetooth modem sleep is enabled in controller start up by default if CONFIG_BTDM_CONTROLLER_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request".
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_sleep_enable(void);
/**
* @brief disable bluetooth modem sleep
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
*
* If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep;
*
* If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then.
* In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup.
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_sleep_disable(void);
/**
* @brief to check whether bluetooth controller is sleeping at the instant, if modem sleep is enabled
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
* This function is supposed to be used ORIG mode of modem sleep
*
* @return true if in modem sleep state, false otherwise
*/
bool esp_bt_controller_is_sleeping(void);
/**
* @brief request controller to wakeup from sleeping state during sleep mode
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
* Note that this function is supposed to be used ORIG mode of modem sleep
* Note that after this request, bluetooth controller may again enter sleep as long as the modem sleep is enabled
*
* Profiling shows that it takes several milliseconds to wakeup from modem sleep after this request.
* Generally it takes longer if 32kHz XTAL is used than the main XTAL, due to the lower frequency of the former as the bluetooth low power clock source.
*/
void esp_bt_controller_wakeup_request(void);
/**
* @brief notify bluetooth controller task to process the event upon Tx or Rx done
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
* This function can be called in both ISR and non-ISR context
*
*/
int esp_bt_h4tl_eif_io_event_notify(int event);
/**
* @brief Get BT MAC address.
* @return Array pointer of length 6 storing MAC address value.
*/
uint8_t* esp_bt_get_mac(void);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_BT_H__ */

View File

@ -0,0 +1,459 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __ESP_BT_H__
#define __ESP_BT_H__
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"
#include "sdkconfig.h"
#include "esp_task.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
#define ESP_BT_CTRL_CONFIG_VERSION 0x02004260
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
#define ESP_BT_HCI_TL_VERSION 0x00010000
/**
* @brief Bluetooth mode for controller enable/disable
*/
typedef enum {
ESP_BT_MODE_IDLE = 0x00, /*!< Bluetooth is not running */
ESP_BT_MODE_BLE = 0x01, /*!< Run BLE mode */
ESP_BT_MODE_CLASSIC_BT = 0x02, /*!< Run Classic BT mode */
ESP_BT_MODE_BTDM = 0x03, /*!< Run dual mode */
} esp_bt_mode_t;
/**
* @brief Type of controller HCI transport layer
*/
typedef enum {
ESP_BT_CTRL_HCI_TL_UART = 0, /*!< HCI UART h4 transport layer */
ESP_BT_CTRL_HCI_TL_VHCI = 1, /*!< VHCI interface */
} esp_bt_ctrl_hci_tl_t;
/**
* @breif type of BLE connection event length computation
*/
typedef enum {
ESP_BLE_CE_LEN_TYPE_ORIG = 0, /*!< original */
ESP_BLE_CE_LEN_TYPE_CE = 1, /*!< use CE_LEN parameter from HCI commands */
ESP_BLE_CE_LEN_TYPE_SD = 1, /*!< Espressif vendor defined */
} esp_ble_ce_len_t;
/**
* @brief Bluetooth sleep mode
*/
typedef enum {
ESP_BT_SLEEP_MODE_NONE = 0, /*!< Bluetooth sleep mode disabled */
ESP_BT_SLEEP_MODE_1 = 1, /*!< Bluetooth sleep mode 1 */
} esp_bt_sleep_mode_t;
/**
* @brief Bluetooth sleep clock
*/
typedef enum {
ESP_BT_SLEEP_CLOCK_NONE = 0, /*!< Sleep clock not configured */
ESP_BT_SLEEP_CLOCK_MAIN_XTAL = 1, /*!< SoC main crystal */
ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL = 2, /*!< External 32.768kHz crystal */
ESP_BT_SLEEP_CLOCK_FPGA_32K = 3, /*!< Hardwired 32KHz clock temporarily used for FPGA */
} esp_bt_sleep_clock_t;
/**
* @brief antenna index used for bluetooth
*/
enum {
ESP_BT_ANT_IDX_0 = 0, /*!< anntena NO 0 */
ESP_BT_ANT_IDX_1 = 1, /*!< anntena NO 1 */
};
#ifdef CONFIG_BT_ENABLED
#ifdef CONFIG_BT_CTRL_COEX_PARAMETERS_ENABLE
#define BT_CTRL_COEX_PARAMETERS_ENABLE true
#else
#define BT_CTRL_COEX_PARAMETERS_ENABLE false
#endif
#ifdef CONFIG_BT_CTRL_COEX_USE_HOOKS
#define BT_CTRL_COEX_USE_HOOKS true
#else
#define BT_CTRL_COEX_USE_HOOKS false
#endif
#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \
.version = ESP_BT_CTRL_CONFIG_VERSION, \
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.controller_task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE, \
.bluetooth_mode = CONFIG_BT_CTRL_MODE_EFF, \
.ble_max_act = CONFIG_BT_CTRL_BLE_MAX_ACT_EFF, \
.sleep_mode = CONFIG_BT_CTRL_SLEEP_MODE_EFF, \
.sleep_clock = CONFIG_BT_CTRL_SLEEP_CLOCK_EFF, \
.ble_st_acl_tx_buf_nb = CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB, \
.ble_hw_cca_check = CONFIG_BT_CTRL_HW_CCA_EFF, \
.ble_adv_dup_filt_max = CONFIG_BT_CTRL_ADV_DUP_FILT_MAX, \
.coex_param_en = BT_CTRL_COEX_PARAMETERS_ENABLE, \
.ce_len_type = CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF, \
.coex_use_hooks = BT_CTRL_COEX_USE_HOOKS, \
.hci_tl_type = CONFIG_BT_CTRL_HCI_TL_EFF, \
.hci_tl_funcs = NULL, \
.txant_dft = CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF, \
.rxant_dft = CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF, \
.txpwr_dft = CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF, \
};
#else
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable bluetooth in menuconfig to use bt.h");
#endif
/**
* @brief Controller HCI transport layer function structure
* This structure shall be registered when HCI transport layer is UART
*/
typedef struct {
uint32_t _magic; /* Magic number */
uint32_t _version; /* version number of the defined structure */
uint32_t _reserved; /* reserved for future use */
int (* _open)(void); /* hci tl open */
void (* _close)(void); /* hci tl close */
void (* _finish_transfers)(void); /* hci tl finish trasnfers */
void (* _recv)(uint8_t *buf, uint32_t len, void (*callback) (void*, uint8_t), void* dummy); /* hci tl recv */
void (* _send)(uint8_t *buf, uint32_t len, void (*callback) (void*, uint8_t), void* dummy); /* hci tl send */
bool (* _flow_off)(void); /* hci tl flow off */
void (* _flow_on)(void); /* hci tl flow on */
} esp_bt_hci_tl_t;
/**
* @brief Controller config options, depend on config mask.
* Config mask indicate which functions enabled, this means
* some options or parameters of some functions enabled by config mask.
*/
typedef struct {
/*
* Following parameters can not be configured runtime when call esp_bt_controller_init()
* They will be overwritten by constant values from menuconfig options or from macros.
* So, do not modify the value when esp_bt_controller_init()
*/
uint32_t magic; /*!< Magic number */
uint32_t version; /*!< version number of the defined structure */
/*
* Following parameters can be configured runtime, when call esp_bt_controller_init()
*/
uint16_t controller_task_stack_size; /*!< Bluetooth controller task stack size */
uint8_t controller_task_prio; /*!< Bluetooth controller task priority */
uint8_t controller_task_run_cpu; /*!< CPU num that Bluetooth controller task runs on */
uint8_t bluetooth_mode; /*!< Controller mode: BR/EDR, BLE or Dual Mode */
uint8_t ble_max_act; /*!< BLE maximum number of air activities */
uint8_t sleep_mode; /*!< controller sleep mode */
uint8_t sleep_clock; /*!< controller sleep clock */
uint8_t ble_st_acl_tx_buf_nb; /*!< controller static ACL TX BUFFER number */
uint8_t ble_hw_cca_check; /*!< controller hardware triggered CCA check */
uint16_t ble_adv_dup_filt_max; /*!< maxinum number of duplicate scan filter */
bool coex_param_en; /*!< init coex parameters*/
uint8_t ce_len_type; /*!< connection event length computation method */
bool coex_use_hooks; /*!< use hooks in bluetooth to assist WiFi behavouir determination */
uint8_t hci_tl_type; /*!< HCI transport layer, UART, VHCI, etc */
esp_bt_hci_tl_t *hci_tl_funcs; /*!< hci transport functions used, must be set when hci_tl_type is UART */
uint8_t txant_dft; /*!< default Tx antenna */
uint8_t rxant_dft; /*!< default Rx antenna */
uint8_t txpwr_dft; /*!< default Tx power */
} esp_bt_controller_config_t;
/**
* @brief Bluetooth controller enable/disable/initialised/de-initialised status
*/
typedef enum {
ESP_BT_CONTROLLER_STATUS_IDLE = 0,
ESP_BT_CONTROLLER_STATUS_INITED,
ESP_BT_CONTROLLER_STATUS_ENABLED,
ESP_BT_CONTROLLER_STATUS_NUM,
} esp_bt_controller_status_t;
/**
* @brief BLE tx power type
* ESP_BLE_PWR_TYPE_CONN_HDL0-8: for each connection, and only be set after connection completed.
* when disconnect, the correspond TX power is not effected.
* ESP_BLE_PWR_TYPE_ADV : for advertising/scan response.
* ESP_BLE_PWR_TYPE_SCAN : for scan.
* ESP_BLE_PWR_TYPE_DEFAULT : if each connection's TX power is not set, it will use this default value.
* if neither in scan mode nor in adv mode, it will use this default value.
* If none of power type is set, system will use ESP_PWR_LVL_P3 as default for ADV/SCAN/CONN0-9.
*/
typedef enum {
ESP_BLE_PWR_TYPE_CONN_HDL0 = 0, /*!< For connection handle 0 */
ESP_BLE_PWR_TYPE_CONN_HDL1 = 1, /*!< For connection handle 1 */
ESP_BLE_PWR_TYPE_CONN_HDL2 = 2, /*!< For connection handle 2 */
ESP_BLE_PWR_TYPE_CONN_HDL3 = 3, /*!< For connection handle 3 */
ESP_BLE_PWR_TYPE_CONN_HDL4 = 4, /*!< For connection handle 4 */
ESP_BLE_PWR_TYPE_CONN_HDL5 = 5, /*!< For connection handle 5 */
ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */
ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */
ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */
ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */
ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */
ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */
ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */
} esp_ble_power_type_t;
/**
* @brief Bluetooth TX power level(index), it's just a index corresponding to power(dbm).
*/
typedef enum {
ESP_PWR_LVL_N12 = 0, /*!< Corresponding to -12dbm */
ESP_PWR_LVL_N9 = 1, /*!< Corresponding to -9dbm */
ESP_PWR_LVL_N6 = 2, /*!< Corresponding to -6dbm */
ESP_PWR_LVL_N3 = 3, /*!< Corresponding to -3dbm */
ESP_PWR_LVL_N0 = 4, /*!< Corresponding to 0dbm */
ESP_PWR_LVL_P3 = 5, /*!< Corresponding to +3dbm */
ESP_PWR_LVL_P6 = 6, /*!< Corresponding to +6dbm */
ESP_PWR_LVL_P9 = 7, /*!< Corresponding to +9dbm */
} esp_power_level_t;
/**
* @brief Set BLE TX power
* Connection Tx power should only be set after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @param power_level: Power level(index) corresponding to absolute value(dbm)
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level);
/**
* @brief Get BLE TX power
* Connection Tx power should only be get after connection created.
* @param power_type : The type of which tx power, could set Advertising/Connection/Default and etc
* @return >= 0 - Power level, < 0 - Invalid
*/
esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type);
/**
* @brief Initialize BT controller to allocate task and other resource.
* This function should be called only once, before any other BT functions are called.
* @param cfg: Initial configuration of BT controller. Different from previous version, there's a mode and some
* connection configuration in "cfg" to configure controller work mode and allocate the resource which is needed.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg);
/**
* @brief De-initialize BT controller to free resource and delete task.
*
* This function should be called only once, after any other BT functions are called.
* This function is not whole completed, esp_bt_controller_init cannot called after this function.
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_deinit(void);
/**
* @brief Enable BT controller.
* Due to a known issue, you cannot call esp_bt_controller_enable() a second time
* to change the controller mode dynamically. To change controller mode, call
* esp_bt_controller_disable() and then call esp_bt_controller_enable() with the new mode.
* @param mode : the mode(BLE/BT/BTDM) to enable. For compatible of API, retain this argument. This mode must be
* equal as the mode in "cfg" of esp_bt_controller_init().
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode);
/**
* @brief Disable BT controller
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_disable(void);
/**
* @brief Get BT controller is initialised/de-initialised/enabled/disabled
* @return status value
*/
esp_bt_controller_status_t esp_bt_controller_get_status(void);
uint16_t esp_bt_get_tx_buf_num(void);
/** @brief esp_vhci_host_callback
* used for vhci call host function to notify what host need to do
*/
typedef struct esp_vhci_host_callback {
void (*notify_host_send_available)(void); /*!< callback used to notify that the host can send packet to controller */
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< callback used to notify that the controller has a packet to send to the host*/
} esp_vhci_host_callback_t;
/** @brief esp_vhci_host_check_send_available
* used for check actively if the host can send packet to controller or not.
* @return true for ready to send, false means cannot send packet
*/
bool esp_vhci_host_check_send_available(void);
/** @brief esp_vhci_host_send_packet
* host send packet to controller
*
* Should not call this function from within a critical section
* or when the scheduler is suspended.
*
* @param data the packet point
* @param len the packet length
*/
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len);
/** @brief esp_vhci_host_register_callback
* register the vhci reference callback
* struct defined by vhci_host_callback structure.
* @param callback esp_vhci_host_callback type variable
* @return ESP_OK - success, ESP_FAIL - failed
*/
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/** @brief esp_bt_controller_mem_release
* release the controller memory as per the mode
*
* This function releases the BSS, data and other sections of the controller to heap. The total size is about 70k bytes.
*
* esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
* or after esp_bt_controller_deinit().
*
* Note that once BT controller memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
* esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialization time to free unused BT Classic memory.
*
* If the mode is ESP_BT_MODE_BTDM, then it may be useful to call API esp_bt_mem_release(ESP_BT_MODE_BTDM) instead,
* which internally calls esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) and additionally releases the BSS and data
* consumed by the BT/BLE host stack to heap. For more details about usage please refer to the documentation of
* esp_bt_mem_release() function
*
* @param mode : the mode want to release memory
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode);
/** @brief esp_bt_mem_release
* release controller memory and BSS and data section of the BT/BLE host stack as per the mode
*
* This function first releases controller memory by internally calling esp_bt_controller_mem_release().
* Additionally, if the mode is set to ESP_BT_MODE_BTDM, it also releases the BSS and data consumed by the BT/BLE host stack to heap
*
* Note that once BT memory is released, the process cannot be reversed. It means you cannot use the bluetooth
* mode which you have released by this function.
*
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
* then do not call this function.
*
* If you never intend to use bluetooth in a current boot-up cycle, you can call esp_bt_mem_release(ESP_BT_MODE_BTDM)
* before esp_bt_controller_init or after esp_bt_controller_deinit.
*
* For example, if a user only uses bluetooth for setting the WiFi configuration, and does not use bluetooth in the rest of the product operation".
* In such cases, after receiving the WiFi configuration, you can disable/deinit bluetooth and release its memory.
* Below is the sequence of APIs to be called for such scenarios:
*
* esp_bluedroid_disable();
* esp_bluedroid_deinit();
* esp_bt_controller_disable();
* esp_bt_controller_deinit();
* esp_bt_mem_release(ESP_BT_MODE_BTDM);
*
* @param mode : the mode whose memory is to be released
* @return ESP_OK - success, other - failed
*/
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode);
/**
* @brief enable bluetooth to enter modem sleep
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
*
* There are currently two options for bluetooth modem sleep, one is ORIG mode, and another is EVED Mode. EVED Mode is intended for BLE only.
*
* For ORIG mode:
* Bluetooth modem sleep is enabled in controller start up by default if CONFIG_BTDM_CONTROLLER_MODEM_SLEEP is set and "ORIG mode" is selected. In ORIG modem sleep mode, bluetooth controller will switch off some components and pause to work every now and then, if there is no event to process; and wakeup according to the scheduled interval and resume the work. It can also wakeup earlier upon external request using function "esp_bt_controller_wakeup_request".
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_sleep_enable(void);
/**
* @brief disable bluetooth modem sleep
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
*
* If esp_bt_sleep_disable() is called, bluetooth controller will not be allowed to enter modem sleep;
*
* If ORIG modem sleep mode is in use, if this function is called, bluetooth controller may not immediately wake up if it is dormant then.
* In this case, esp_bt_controller_wakeup_request() can be used to shorten the time for wakeup.
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_bt_sleep_disable(void);
/**
* @brief to check whether bluetooth controller is sleeping at the instant, if modem sleep is enabled
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
* This function is supposed to be used ORIG mode of modem sleep
*
* @return true if in modem sleep state, false otherwise
*/
bool esp_bt_controller_is_sleeping(void);
/**
* @brief request controller to wakeup from sleeping state during sleep mode
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
* Note that this function is supposed to be used ORIG mode of modem sleep
* Note that after this request, bluetooth controller may again enter sleep as long as the modem sleep is enabled
*
* Profiling shows that it takes several milliseconds to wakeup from modem sleep after this request.
* Generally it takes longer if 32kHz XTAL is used than the main XTAL, due to the lower frequency of the former as the bluetooth low power clock source.
*/
void esp_bt_controller_wakeup_request(void);
/**
* @brief notify bluetooth controller task to process the event upon Tx or Rx done
*
* Note that this function shall not be invoked before esp_bt_controller_enable()
* This function can be called in both ISR and non-ISR context
*
*/
int esp_bt_h4tl_eif_io_event_notify(int event);
/**
* @brief Get BT MAC address.
* @return Array pointer of length 6 storing MAC address value.
*/
uint8_t* esp_bt_get_mac(void);
#ifdef __cplusplus
}
#endif
#endif /* __ESP_BT_H__ */

View File

@ -17,7 +17,7 @@ CONFIG_BTDM_CONTROLLER_HCI_MODE_CHOICE CONFIG_BTDM_CTRL_HCI
CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI CONFIG_BTDM_CTRL_HCI_MODE_VHCI CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI CONFIG_BTDM_CTRL_HCI_MODE_VHCI
CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 CONFIG_BTDM_CTRL_HCI_MODE_UART_H4 CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4 CONFIG_BTDM_CTRL_HCI_MODE_UART_H4
CONFIG_BTDM_CONTROLLER_MODEM_SLEEP CONFIG_BTDM_MODEM_SLEEP CONFIG_BTDM_CONTROLLER_MODEM_SLEEP CONFIG_BTDM_CTRL_MODEM_SLEEP
CONFIG_BLE_SCAN_DUPLICATE CONFIG_BTDM_BLE_SCAN_DUPL CONFIG_BLE_SCAN_DUPLICATE CONFIG_BTDM_BLE_SCAN_DUPL
CONFIG_SCAN_DUPLICATE_TYPE CONFIG_BTDM_SCAN_DUPL_TYPE CONFIG_SCAN_DUPLICATE_TYPE CONFIG_BTDM_SCAN_DUPL_TYPE

View File

@ -91,8 +91,11 @@ void IRAM_ATTR esp_restart_noos(void)
// Reset wifi/bluetooth/ethernet/sdio (bb/mac) // Reset wifi/bluetooth/ethernet/sdio (bb/mac)
SET_PERI_REG_MASK(SYSTEM_CORE_RST_EN_REG, SET_PERI_REG_MASK(SYSTEM_CORE_RST_EN_REG,
SYSTEM_BB_RST | SYSTEM_FE_RST | SYSTEM_MAC_RST | SYSTEM_BB_RST | SYSTEM_FE_RST | SYSTEM_MAC_RST |
SYSTEM_BT_RST | SYSTEM_BTMAC_RST | SYSTEM_MACPWR_RST | SYSTEM_BT_RST | SYSTEM_BTMAC_RST | SYSTEM_SDIO_RST |
SYSTEM_RW_BTMAC_RST | SYSTEM_RW_BTLP_RST); SYSTEM_EMAC_RST | SYSTEM_MACPWR_RST |
SYSTEM_RW_BTMAC_RST | SYSTEM_RW_BTLP_RST | BLE_REG_REST_BIT
|BLE_PWR_REG_REST_BIT | BLE_BB_REG_REST_BIT);
REG_WRITE(SYSTEM_CORE_RST_EN_REG, 0); REG_WRITE(SYSTEM_CORE_RST_EN_REG, 0);
// Reset timer/spi/uart // Reset timer/spi/uart

View File

@ -4,6 +4,10 @@
* *
* Note: These are all weak symbols that could be overwritten from the ESP-IDF side. * Note: These are all weak symbols that could be overwritten from the ESP-IDF side.
*/ */
PROVIDE ( _bss_end_btdm = 0x3fcefba8 );
PROVIDE ( _bss_start_btdm = 0x3fcef454 );
PROVIDE ( r_ke_mem_is_in_heap = 0x40009688 );
PROVIDE ( BasePoint_x_256 = 0x3ff08238 ); PROVIDE ( BasePoint_x_256 = 0x3ff08238 );
PROVIDE ( BasePoint_y_256 = 0x3ff08218 ); PROVIDE ( BasePoint_y_256 = 0x3ff08218 );
PROVIDE ( Cache_Address_Through_DCache = 0x40051ebc ); PROVIDE ( Cache_Address_Through_DCache = 0x40051ebc );

View File

@ -220,6 +220,12 @@ IRAM_ATTR void esp_phy_enable(void)
#if CONFIG_IDF_TARGET_ESP32 #if CONFIG_IDF_TARGET_ESP32
coex_bt_high_prio(); coex_bt_high_prio();
#endif #endif
#if CONFIG_BT_ENABLED && CONFIG_IDF_TARGET_ESP32C3
extern void coex_pti_v2(void);
coex_pti_v2();
#endif
} }
s_phy_access_ref++; s_phy_access_ref++;

View File

@ -19,8 +19,8 @@
#pragma once #pragma once
#include <stdio.h> #include <stdio.h>
#include "uhci_types.h" #include "uhci_types.h"
#include "uhci_struct.h" #include "soc/uhci_struct.h"
#include "gdma_struct.h" #include "soc/gdma_struct.h"
#define UHCI_DMA_INDEX 0 #define UHCI_DMA_INDEX 0
@ -93,15 +93,15 @@ static inline void uhci_ll_set_swflow_ctrl_sub_chr(uhci_dev_t *hw, uhci_swflow_c
static inline void uhci_ll_dma_in_reset(uhci_dev_t *hw) static inline void uhci_ll_dma_in_reset(uhci_dev_t *hw)
{ {
(void)hw; (void)hw;
GDMA.conf0[UHCI_DMA_INDEX].in_rst = 1; GDMA.channel[UHCI_DMA_INDEX].in.in_conf0.in_rst = 1;
GDMA.conf0[UHCI_DMA_INDEX].in_rst = 0; GDMA.channel[UHCI_DMA_INDEX].in.in_conf0.in_rst = 0;
} }
static inline void uhci_ll_dma_out_reset(uhci_dev_t *hw) static inline void uhci_ll_dma_out_reset(uhci_dev_t *hw)
{ {
(void)hw; (void)hw;
GDMA.conf0[UHCI_DMA_INDEX].out_rst = 1; GDMA.channel[UHCI_DMA_INDEX].out.out_conf0.out_rst = 1;
GDMA.conf0[UHCI_DMA_INDEX].out_rst = 0; GDMA.channel[UHCI_DMA_INDEX].out.out_conf0.out_rst = 0;
} }
static inline void uhci_ll_enable_intr(uhci_dev_t *hw, uint32_t intr_mask) static inline void uhci_ll_enable_intr(uhci_dev_t *hw, uint32_t intr_mask)
@ -127,37 +127,37 @@ static inline uint32_t uhci_ll_get_intr(uhci_dev_t *hw)
static inline void uhci_ll_set_rx_dma(uhci_dev_t *hw, uint32_t addr) static inline void uhci_ll_set_rx_dma(uhci_dev_t *hw, uint32_t addr)
{ {
(void)hw; (void)hw;
GDMA.in_link[UHCI_DMA_INDEX].addr = addr; GDMA.channel[UHCI_DMA_INDEX].in.in_link.addr = addr;
} }
static inline void uhci_ll_set_tx_dma(uhci_dev_t *hw, uint32_t addr) static inline void uhci_ll_set_tx_dma(uhci_dev_t *hw, uint32_t addr)
{ {
(void)hw; (void)hw;
GDMA.out_link[UHCI_DMA_INDEX].addr = addr; GDMA.channel[UHCI_DMA_INDEX].out.out_link.addr = addr;
} }
static inline void uhci_ll_rx_dma_start(uhci_dev_t *hw) static inline void uhci_ll_rx_dma_start(uhci_dev_t *hw)
{ {
(void)hw; (void)hw;
GDMA.in_link[UHCI_DMA_INDEX].start = 1; GDMA.channel[UHCI_DMA_INDEX].in.in_link.start = 1;
} }
static inline void uhci_ll_tx_dma_start(uhci_dev_t *hw) static inline void uhci_ll_tx_dma_start(uhci_dev_t *hw)
{ {
(void)hw; (void)hw;
GDMA.out_link[UHCI_DMA_INDEX].start = 1; GDMA.channel[UHCI_DMA_INDEX].out.out_link.start = 1;
} }
static inline void uhci_ll_rx_dma_stop(uhci_dev_t *hw) static inline void uhci_ll_rx_dma_stop(uhci_dev_t *hw)
{ {
(void)hw; (void)hw;
GDMA.in_link[UHCI_DMA_INDEX].stop = 1; GDMA.channel[UHCI_DMA_INDEX].in.in_link.stop = 1;
} }
static inline void uhci_ll_tx_dma_stop(uhci_dev_t *hw) static inline void uhci_ll_tx_dma_stop(uhci_dev_t *hw)
{ {
(void)hw; (void)hw;
GDMA.out_link[UHCI_DMA_INDEX].stop = 1; GDMA.channel[UHCI_DMA_INDEX].out.out_link.stop = 1;
} }
static inline void uhci_ll_set_eof_mode(uhci_dev_t *hw, uint32_t eof_mode) static inline void uhci_ll_set_eof_mode(uhci_dev_t *hw, uint32_t eof_mode)

View File

@ -15,7 +15,7 @@
#include <freertos/FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <esp_system.h> #include <esp_system.h>
#include <esp_log.h> #include <esp_log.h>
#include <esp_bt.h> #include "esp_bt.h"
#include <esp_gap_ble_api.h> #include <esp_gap_ble_api.h>
#include <esp_gatts_api.h> #include <esp_gatts_api.h>
#include <esp_bt_main.h> #include <esp_bt_main.h>

View File

@ -15,7 +15,7 @@
#include <string.h> #include <string.h>
#include <esp_log.h> #include <esp_log.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_bt.h> #include "esp_bt.h"
#include <protocomm.h> #include <protocomm.h>
#include <protocomm_ble.h> #include <protocomm_ble.h>

View File

@ -45,7 +45,7 @@ INPUT = \
$(IDF_PATH)/components/esp_event/include/esp_event_legacy.h \ $(IDF_PATH)/components/esp_event/include/esp_event_legacy.h \
## Bluetooth - API Reference ## Bluetooth - API Reference
## Controller && VHCI ## Controller && VHCI
$(IDF_PATH)/components/bt/include/esp_bt.h \ $(IDF_PATH)/components/bt/include/esp32/include/esp_bt.h \
## Bluetooth COMMON ## Bluetooth COMMON
## Issue with __attribute__ ## Issue with __attribute__
$(IDF_PATH)/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h \ $(IDF_PATH)/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h \

View File

@ -110,7 +110,7 @@ The following drivers will hold the ``ESP_PM_APB_FREQ_MAX`` lock while the drive
- **Ethernet**: between calls to :cpp:func:`esp_eth_driver_install` and :cpp:func:`esp_eth_driver_uninstall`. - **Ethernet**: between calls to :cpp:func:`esp_eth_driver_install` and :cpp:func:`esp_eth_driver_uninstall`.
- **WiFi**: between calls to :cpp:func:`esp_wifi_start` and :cpp:func:`esp_wifi_stop`. If modem sleep is enabled, the lock will be released for the periods of time when radio is disabled. - **WiFi**: between calls to :cpp:func:`esp_wifi_start` and :cpp:func:`esp_wifi_stop`. If modem sleep is enabled, the lock will be released for the periods of time when radio is disabled.
- **TWAI**: between calls to :cpp:func:`twai_driver_install` and :cpp:func:`twai_driver_uninstall`. - **TWAI**: between calls to :cpp:func:`twai_driver_install` and :cpp:func:`twai_driver_uninstall`.
:SOC_BT_SUPPORTED: - **Bluetooth**: between calls to :cpp:func:`esp_bt_controller_enable` and :cpp:func:`esp_bt_controller_disable`. If Bluetooth modem sleep is enabled, the ``ESP_PM_APB_FREQ_MAX`` lock will be released for the periods of time when radio is disabled. However the ``ESP_PM_NO_LIGHT_SLEEP`` lock will still be held, unless :ref:`CONFIG_BTDM_LOW_POWER_CLOCK` option is set to "External 32kHz crystal". :SOC_BT_SUPPORTED: - **Bluetooth**: between calls to :cpp:func:`esp_bt_controller_enable` and :cpp:func:`esp_bt_controller_disable`. If Bluetooth modem sleep is enabled, the ``ESP_PM_APB_FREQ_MAX`` lock will be released for the periods of time when radio is disabled. However the ``ESP_PM_NO_LIGHT_SLEEP`` lock will still be held, unless :ref:`CONFIG_BTDM_CTRL_LOW_POWER_CLOCK` option is set to "External 32kHz crystal".
The following peripheral drivers are not aware of DFS yet. Applications need to acquire/release locks themselves, when necessary: The following peripheral drivers are not aware of DFS yet. Applications need to acquire/release locks themselves, when necessary:

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | | Supported Targets | ESP32 | ESP32-C3 |
| ----------------- | ----- | | ----------------- | ----- | -------- |
ESP-IDF BLE ANCS Example ESP-IDF BLE ANCS Example
========================== ==========================

View File

@ -22,6 +22,7 @@
#include "esp_gatt_defs.h" #include "esp_gatt_defs.h"
#include "esp_gatt_common_api.h" #include "esp_gatt_common_api.h"
#include "ble_ancs.h" #include "ble_ancs.h"
#include "esp_timer.h"
#define BLE_ANCS_TAG "BLE_ANCS" #define BLE_ANCS_TAG "BLE_ANCS"
#define EXAMPLE_DEVICE_NAME "ESP_BLE_ANCS" #define EXAMPLE_DEVICE_NAME "ESP_BLE_ANCS"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | | Supported Targets | ESP32 | ESP32-C3 |
| ----------------- | ----- | | ----------------- | ----- | -------- |
ESP-IDF BLE Compatibility Test Example ESP-IDF BLE Compatibility Test Example
======================================= =======================================

View File

@ -13,13 +13,13 @@
*********************************************************************************/ *********************************************************************************/
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "freertos/event_groups.h" #include "freertos/event_groups.h"
#include "esp_system.h" #include "esp_system.h"
#include "esp_log.h" #include "esp_log.h"
#include "nvs_flash.h" #include "nvs_flash.h"
#include "esp_bt.h" #include "esp_bt.h"
#include "esp_gap_ble_api.h" #include "esp_gap_ble_api.h"
#include "esp_gatts_api.h" #include "esp_gatts_api.h"

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | | Supported Targets | ESP32 | ESP32-C3 |
| ----------------- | ----- | | ----------------- | ----- | -------- |
ESP-IDF Eddystone demo ESP-IDF Eddystone demo
======================== ========================

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | | Supported Targets | ESP32 | ESP32-C3 |
| ----------------- | ----- | | ----------------- | ----- | -------- |
ESP-IDF BLE HID device demo ESP-IDF BLE HID device demo
======================== ========================

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | | Supported Targets | ESP32 | ESP32-C3 |
| ----------------- | ----- | | ----------------- | ----- | -------- |
# ESP-IDF iBeacon demo # ESP-IDF iBeacon demo

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More