mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'master' into feature/cmake_update
This commit is contained in:
commit
6b9784cc45
3
.gitignore
vendored
3
.gitignore
vendored
@ -57,3 +57,6 @@ tools/windows/tool_setup/.*
|
||||
tools/windows/tool_setup/input
|
||||
tools/windows/tool_setup/dl
|
||||
tools/windows/tool_setup/Output
|
||||
|
||||
test_multi_heap_host
|
||||
|
||||
|
279
.gitlab-ci.yml
279
.gitlab-ci.yml
@ -501,6 +501,20 @@ check_commit_msg:
|
||||
# commit start with "WIP: " need to be squashed before merge
|
||||
- 'git log --pretty=%s master.. -- | grep "^WIP: " && exit 1 || exit 0'
|
||||
|
||||
check_permissions:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- build
|
||||
except:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before
|
||||
script:
|
||||
- tools/ci/check-executable.sh
|
||||
|
||||
check_submodule_sync:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
@ -519,28 +533,28 @@ check_submodule_sync:
|
||||
- git submodule update --init --recursive
|
||||
|
||||
assign_test:
|
||||
<<: *build_template
|
||||
tags:
|
||||
- assign_test
|
||||
image: $CI_DOCKER_REGISTRY/ubuntu-test-env$BOT_DOCKER_IMAGE_TAG
|
||||
stage: assign_test
|
||||
# gitlab ci do not support match job with RegEx or wildcard now in dependencies.
|
||||
# we have a lot build example jobs. now we don't use dependencies, just download all artificats of build stage.
|
||||
dependencies:
|
||||
- build_ssc_00
|
||||
- build_ssc_01
|
||||
- build_ssc_02
|
||||
- build_esp_idf_tests
|
||||
variables:
|
||||
UT_BIN_PATH: "tools/unit-test-app/output"
|
||||
OUTPUT_BIN_PATH: "test_bins/ESP32_IDF"
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs"
|
||||
artifacts:
|
||||
paths:
|
||||
- $OUTPUT_BIN_PATH
|
||||
- components/idf_test/*/CIConfigs
|
||||
- components/idf_test/*/TC.sqlite
|
||||
- $EXAMPLE_CONFIG_OUTPUT_PATH
|
||||
- tools/unit-test-app/output
|
||||
expire_in: 1 mos
|
||||
before_script: *add_gitlab_key_before
|
||||
script:
|
||||
# first move test bins together: test_bins/CHIP_SDK/TestApp/bin_files
|
||||
- mkdir -p $OUTPUT_BIN_PATH
|
||||
- cp -r SSC/ssc_bin/* $OUTPUT_BIN_PATH
|
||||
# assign example tests
|
||||
- python $TEST_FW_PATH/CIAssignExampleTest.py $IDF_PATH/examples $IDF_PATH/.gitlab-ci.yml $EXAMPLE_CONFIG_OUTPUT_PATH
|
||||
# assign unit test cases
|
||||
@ -574,23 +588,30 @@ assign_test:
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/examples"
|
||||
CONFIG_FILE: "$CI_PROJECT_DIR/examples/test_configs/$CI_JOB_NAME.yml"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/TEST_LOGS"
|
||||
ENV_FILE: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
|
||||
script:
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- cd ci-test-runner-configs
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs
|
||||
- cd $TEST_FW_PATH
|
||||
# run test
|
||||
- python Runner.py $TEST_CASE_PATH -c $CONFIG_FILE
|
||||
- python Runner.py $TEST_CASE_PATH -c $CONFIG_FILE -e $ENV_FILE
|
||||
|
||||
.unit_test_template: &unit_test_template
|
||||
<<: *example_test_template
|
||||
stage: unit_test
|
||||
dependencies:
|
||||
- assign_test
|
||||
- build_esp_idf_tests
|
||||
variables:
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/tools/unit-test-app"
|
||||
CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/unit_test/CIConfigs/$CI_JOB_NAME.yml"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/TEST_LOGS"
|
||||
ENV_FILE: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
|
||||
|
||||
.test_template: &test_template
|
||||
stage: test
|
||||
@ -664,257 +685,261 @@ example_test_001_01:
|
||||
- ESP32
|
||||
- Example_WIFI
|
||||
|
||||
example_test_002_01:
|
||||
<<: *example_test_template
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_ShieldBox
|
||||
|
||||
UT_001_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_04:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_05:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SDMODE
|
||||
- UT_default
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_06:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SPIMODE
|
||||
- UT_default
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_07:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_08:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_09:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_default
|
||||
|
||||
UT_001_10:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_11:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_12:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_13:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_14:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_15:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_16:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_17:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_18:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_19:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_20:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_21:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_22:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_23:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_24:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_002_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
- UT_T1_SDMODE
|
||||
|
||||
UT_002_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
- UT_T1_SDMODE
|
||||
|
||||
UT_002_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
|
||||
UT_002_04:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
|
||||
UT_002_05:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SDMODE
|
||||
- UT_release
|
||||
|
||||
UT_002_06:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SPIMODE
|
||||
- UT_release
|
||||
|
||||
UT_002_07:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
|
||||
UT_002_08:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
|
||||
UT_002_09:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_release
|
||||
|
||||
UT_003_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
- UT_T1_SPIMODE
|
||||
|
||||
UT_003_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
- UT_T1_SPIMODE
|
||||
|
||||
UT_003_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
|
||||
UT_003_04:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
|
||||
UT_003_05:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SDMODE
|
||||
- UT_single_core
|
||||
|
||||
UT_003_06:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SPIMODE
|
||||
- UT_single_core
|
||||
|
||||
UT_003_07:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
|
||||
UT_003_08:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
|
||||
UT_003_09:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_single_core
|
||||
|
||||
UT_004_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- psram
|
||||
|
||||
UT_004_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- psram
|
||||
|
||||
UT_004_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- psram
|
||||
|
||||
UT_004_04:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- psram
|
||||
|
||||
UT_004_05:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SDMODE
|
||||
- UT_psram
|
||||
- UT_T1_1
|
||||
- psram
|
||||
|
||||
UT_004_06:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SPIMODE
|
||||
- UT_psram
|
||||
- UT_T1_1
|
||||
- psram
|
||||
|
||||
UT_004_07:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- psram
|
||||
|
||||
UT_004_08:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- psram
|
||||
|
||||
UT_004_09:
|
||||
UT_005_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- UT_psram
|
||||
- UT_T1_SDMODE
|
||||
- psram
|
||||
|
||||
UT_005_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_SPIMODE
|
||||
- psram
|
||||
|
||||
IT_001_01:
|
||||
<<: *test_template
|
||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -37,3 +37,7 @@
|
||||
[submodule "components/json/cJSON"]
|
||||
path = components/json/cJSON
|
||||
url = https://github.com/DaveGamble/cJSON.git
|
||||
|
||||
[submodule "components/mbedtls/mbedtls"]
|
||||
path = components/mbedtls/mbedtls
|
||||
url = https://github.com/espressif/mbedtls.git
|
||||
|
@ -190,4 +190,12 @@ config SYSVIEW_EVT_TIMER_EXIT_ENABLE
|
||||
Enables "Timer Exit" event.
|
||||
|
||||
endmenu
|
||||
|
||||
config ESP32_GCOV_ENABLE
|
||||
bool "GCOV to Host Enable"
|
||||
depends on ESP32_DEBUG_STUBS_ENABLE && ESP32_APPTRACE_ENABLE && !SYSVIEW_ENABLE
|
||||
default y
|
||||
help
|
||||
Enables support for GCOV data transfer to host.
|
||||
|
||||
endmenu
|
||||
|
@ -336,6 +336,8 @@ typedef struct {
|
||||
uint8_t *(*get_down_buffer)(uint32_t *, esp_apptrace_tmo_t *);
|
||||
esp_err_t (*put_down_buffer)(uint8_t *, esp_apptrace_tmo_t *);
|
||||
bool (*host_is_connected)(void);
|
||||
esp_err_t (*status_reg_set)(uint32_t val);
|
||||
esp_err_t (*status_reg_get)(uint32_t *val);
|
||||
} esp_apptrace_hw_t;
|
||||
|
||||
static uint32_t esp_apptrace_trax_down_buffer_write_nolock(uint8_t *data, uint32_t size);
|
||||
@ -345,6 +347,8 @@ static esp_err_t esp_apptrace_trax_put_buffer(uint8_t *ptr, esp_apptrace_tmo_t *
|
||||
static bool esp_apptrace_trax_host_is_connected(void);
|
||||
static uint8_t *esp_apptrace_trax_down_buffer_get(uint32_t *size, esp_apptrace_tmo_t *tmo);
|
||||
static esp_err_t esp_apptrace_trax_down_buffer_put(uint8_t *ptr, esp_apptrace_tmo_t *tmo);
|
||||
static esp_err_t esp_apptrace_trax_status_reg_set(uint32_t val);
|
||||
static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val);
|
||||
|
||||
static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = {
|
||||
{
|
||||
@ -353,7 +357,9 @@ static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = {
|
||||
.flush_up_buffer = esp_apptrace_trax_flush,
|
||||
.get_down_buffer = esp_apptrace_trax_down_buffer_get,
|
||||
.put_down_buffer = esp_apptrace_trax_down_buffer_put,
|
||||
.host_is_connected = esp_apptrace_trax_host_is_connected
|
||||
.host_is_connected = esp_apptrace_trax_host_is_connected,
|
||||
.status_reg_set = esp_apptrace_trax_status_reg_set,
|
||||
.status_reg_get = esp_apptrace_trax_status_reg_get
|
||||
}
|
||||
};
|
||||
|
||||
@ -416,6 +422,8 @@ static void esp_apptrace_trax_init()
|
||||
eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TRSTP);
|
||||
eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TMEN);
|
||||
eri_write(ESP_APPTRACE_TRAX_CTRL_REG, ESP_APPTRACE_TRAX_BLOCK_ID(ESP_APPTRACE_TRAX_INBLOCK_START));
|
||||
// this is for OpenOCD to let him know where stub entries vector is resided
|
||||
// must be read by host before any transfer using TRAX
|
||||
eri_write(ESP_APPTRACE_TRAX_STAT_REG, 0);
|
||||
|
||||
ESP_APPTRACE_LOGI("Initialized TRAX on CPU%d", xPortGetCoreID());
|
||||
@ -828,6 +836,18 @@ static bool esp_apptrace_trax_host_is_connected(void)
|
||||
return eri_read(ESP_APPTRACE_TRAX_CTRL_REG) & ESP_APPTRACE_TRAX_HOST_CONNECT ? true : false;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_status_reg_set(uint32_t val)
|
||||
{
|
||||
eri_write(ESP_APPTRACE_TRAX_STAT_REG, val);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val)
|
||||
{
|
||||
*val = eri_read(ESP_APPTRACE_TRAX_STAT_REG);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_dest_init()
|
||||
{
|
||||
for (int i = 0; i < ESP_APPTRACE_TRAX_BLOCKS_NUM; i++) {
|
||||
@ -1159,6 +1179,24 @@ bool esp_apptrace_host_is_connected(esp_apptrace_dest_t dest)
|
||||
{
|
||||
esp_apptrace_hw_t *hw = NULL;
|
||||
|
||||
if (dest == ESP_APPTRACE_DEST_TRAX) {
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
hw = ESP_APPTRACE_HW(ESP_APPTRACE_HW_TRAX);
|
||||
#else
|
||||
ESP_APPTRACE_LOGE("Application tracing via TRAX is disabled in menuconfig!");
|
||||
return false;
|
||||
#endif
|
||||
} else {
|
||||
ESP_APPTRACE_LOGE("Trace destinations other then TRAX are not supported yet!");
|
||||
return false;
|
||||
}
|
||||
return hw->host_is_connected();
|
||||
}
|
||||
|
||||
esp_err_t esp_apptrace_status_reg_set(esp_apptrace_dest_t dest, uint32_t val)
|
||||
{
|
||||
esp_apptrace_hw_t *hw = NULL;
|
||||
|
||||
if (dest == ESP_APPTRACE_DEST_TRAX) {
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
hw = ESP_APPTRACE_HW(ESP_APPTRACE_HW_TRAX);
|
||||
@ -1170,7 +1208,25 @@ bool esp_apptrace_host_is_connected(esp_apptrace_dest_t dest)
|
||||
ESP_APPTRACE_LOGE("Trace destinations other then TRAX are not supported yet!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return hw->host_is_connected();
|
||||
return hw->status_reg_set(val);
|
||||
}
|
||||
|
||||
esp_err_t esp_apptrace_status_reg_get(esp_apptrace_dest_t dest, uint32_t *val)
|
||||
{
|
||||
esp_apptrace_hw_t *hw = NULL;
|
||||
|
||||
if (dest == ESP_APPTRACE_DEST_TRAX) {
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
hw = ESP_APPTRACE_HW(ESP_APPTRACE_HW_TRAX);
|
||||
#else
|
||||
ESP_APPTRACE_LOGE("Application tracing via TRAX is disabled in menuconfig!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
} else {
|
||||
ESP_APPTRACE_LOGE("Trace destinations other then TRAX are not supported yet!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return hw->status_reg_get(val);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -21,20 +21,92 @@
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_dbg_stubs.h"
|
||||
|
||||
#if CONFIG_ESP32_APPTRACE_ENABLE
|
||||
#if CONFIG_ESP32_GCOV_ENABLE
|
||||
|
||||
#define ESP_GCOV_DOWN_BUF_SIZE 4200
|
||||
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
|
||||
#include "esp_log.h"
|
||||
const static char *TAG = "esp_gcov_rtio";
|
||||
|
||||
static void (*s_gcov_exit)(void);
|
||||
static uint8_t s_gcov_down_buf[256];
|
||||
|
||||
/* TODO: remove code extracted from GCC when IDF toolchain will be updated */
|
||||
/*=============== GCC CODE START ====================*/
|
||||
/* Root of a program/shared-object state */
|
||||
struct gcov_root
|
||||
{
|
||||
void *list;
|
||||
unsigned dumped : 1; /* counts have been dumped. */
|
||||
unsigned run_counted : 1; /* run has been accounted for. */
|
||||
struct gcov_root *next;
|
||||
struct gcov_root *prev;
|
||||
};
|
||||
|
||||
/* Per-dynamic-object gcov state. */
|
||||
extern struct gcov_root __gcov_root;
|
||||
|
||||
static void esp_gcov_reset_status(void)
|
||||
{
|
||||
__gcov_root.dumped = 0;
|
||||
__gcov_root.run_counted = 0;
|
||||
}
|
||||
/*=============== GCC CODE END ====================*/
|
||||
|
||||
static int esp_dbg_stub_gcov_dump_do(void)
|
||||
{
|
||||
int ret = ESP_OK;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "Check for dump handler %p", s_gcov_exit);
|
||||
if (s_gcov_exit) {
|
||||
ESP_EARLY_LOGV(TAG, "Alloc apptrace down buf %d bytes", ESP_GCOV_DOWN_BUF_SIZE);
|
||||
void *down_buf = malloc(ESP_GCOV_DOWN_BUF_SIZE);
|
||||
if (down_buf == NULL) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
ESP_EARLY_LOGV(TAG, "Config apptrace down buf");
|
||||
esp_apptrace_down_buffer_config(down_buf, ESP_GCOV_DOWN_BUF_SIZE);
|
||||
ESP_EARLY_LOGV(TAG, "Dump data... %p", s_gcov_exit);
|
||||
s_gcov_exit();
|
||||
ESP_EARLY_LOGV(TAG, "Free apptrace down buf");
|
||||
free(down_buf);
|
||||
}
|
||||
ESP_EARLY_LOGV(TAG, "Finish file transfer session");
|
||||
ret = esp_apptrace_fstop(ESP_APPTRACE_DEST_TRAX);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Triggers gcov info dump.
|
||||
* This function is to be called by OpenOCD, not by normal user code.
|
||||
* TODO: what about interrupted flash access (when cache disabled)???
|
||||
*
|
||||
* @return ESP_OK on success, otherwise see esp_err_t
|
||||
*/
|
||||
static int esp_dbg_stub_gcov_entry(void)
|
||||
{
|
||||
int ret = ESP_OK;
|
||||
|
||||
// disable IRQs on this CPU, other CPU is halted by OpenOCD
|
||||
unsigned irq_state = portENTER_CRITICAL_NESTED();
|
||||
ret = esp_dbg_stub_gcov_dump_do();
|
||||
// reset dump status to allow incremental data accumulation
|
||||
esp_gcov_reset_status();
|
||||
portEXIT_CRITICAL_NESTED(irq_state);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void esp_gcov_dump()
|
||||
{
|
||||
#if CONFIG_FREERTOS_UNICORE == 0
|
||||
esp_cpu_stall(!xPortGetCoreID());
|
||||
int other_core = xPortGetCoreID() ? 0 : 1;
|
||||
esp_cpu_stall(other_core);
|
||||
#endif
|
||||
|
||||
while (!esp_apptrace_host_is_connected(ESP_APPTRACE_DEST_TRAX)) {
|
||||
@ -48,46 +120,59 @@ void esp_gcov_dump()
|
||||
TIMERG1.wdt_wprotect=0;
|
||||
}
|
||||
|
||||
if (s_gcov_exit) {
|
||||
esp_apptrace_down_buffer_config(s_gcov_down_buf, sizeof(s_gcov_down_buf));
|
||||
s_gcov_exit();
|
||||
}
|
||||
|
||||
int ret = esp_apptrace_fstop(ESP_APPTRACE_DEST_TRAX);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!\n", ret);
|
||||
}
|
||||
esp_dbg_stub_gcov_dump_do();
|
||||
// reset dump status to allow incremental data accumulation
|
||||
esp_gcov_reset_status();
|
||||
#if CONFIG_FREERTOS_UNICORE == 0
|
||||
esp_cpu_unstall(other_core);
|
||||
#endif
|
||||
}
|
||||
|
||||
int gcov_rtio_atexit(void (*function)(void))
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s %p", __FUNCTION__, function);
|
||||
s_gcov_exit = function;
|
||||
esp_dbg_stub_entry_set(ESP_DBG_STUB_ENTRY_GCOV, (uint32_t)&esp_dbg_stub_gcov_entry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *gcov_rtio_fopen(const char *path, const char *mode)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fopen(ESP_APPTRACE_DEST_TRAX, path, mode);
|
||||
}
|
||||
|
||||
int gcov_rtio_fclose(void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fclose(ESP_APPTRACE_DEST_TRAX, stream);
|
||||
}
|
||||
|
||||
size_t gcov_rtio_fread(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fread(ESP_APPTRACE_DEST_TRAX, ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
size_t gcov_rtio_fwrite(const void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fwrite(ESP_APPTRACE_DEST_TRAX, ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
int gcov_rtio_fseek(void *stream, long offset, int whence)
|
||||
{
|
||||
return esp_apptrace_fseek(ESP_APPTRACE_DEST_TRAX, stream, offset, whence);
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
int ret = esp_apptrace_fseek(ESP_APPTRACE_DEST_TRAX, stream, offset, whence);
|
||||
ESP_EARLY_LOGV(TAG, "%s EXIT", __FUNCTION__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
long gcov_rtio_ftell(void *stream)
|
||||
{
|
||||
return esp_apptrace_ftell(ESP_APPTRACE_DEST_TRAX, stream);
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
long ret = esp_apptrace_ftell(ESP_APPTRACE_DEST_TRAX, stream);
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -87,6 +87,7 @@ static esp_err_t esp_apptrace_file_cmd_send(esp_apptrace_dest_t dest, uint8_t cm
|
||||
esp_err_t ret;
|
||||
esp_apptrace_fcmd_hdr_t *hdr;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "%s %d", __func__, cmd);
|
||||
uint8_t *ptr = esp_apptrace_buffer_get(dest, sizeof(*hdr) + args_len, ESP_APPTRACE_TMO_INFINITE); //TODO: finite tmo
|
||||
if (ptr == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
@ -101,13 +102,13 @@ static esp_err_t esp_apptrace_file_cmd_send(esp_apptrace_dest_t dest, uint8_t cm
|
||||
// now indicate that this buffer is ready to be sent off to host
|
||||
ret = esp_apptrace_buffer_put(dest, ptr, ESP_APPTRACE_TMO_INFINITE);//TODO: finite tmo
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to put apptrace buffer (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to put apptrace buffer (%d)!", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = esp_apptrace_flush(dest, ESP_APPTRACE_TMO_INFINITE);//TODO: finite tmo
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to flush apptrace buffer (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to flush apptrace buffer (%d)!", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -119,11 +120,12 @@ static esp_err_t esp_apptrace_file_rsp_recv(esp_apptrace_dest_t dest, uint8_t *b
|
||||
uint32_t tot_rd = 0;
|
||||
while (tot_rd < buf_len) {
|
||||
uint32_t rd_size = buf_len - tot_rd;
|
||||
esp_err_t ret = esp_apptrace_read(dest, buf, &rd_size, ESP_APPTRACE_TMO_INFINITE); //TODO: finite tmo
|
||||
esp_err_t ret = esp_apptrace_read(dest, buf + tot_rd, &rd_size, ESP_APPTRACE_TMO_INFINITE); //TODO: finite tmo
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read (%d)!", ret);
|
||||
return ret;
|
||||
}
|
||||
ESP_EARLY_LOGV(TAG, "%s read %d bytes", __FUNCTION__, rd_size);
|
||||
tot_rd += rd_size;
|
||||
}
|
||||
|
||||
@ -142,6 +144,8 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
||||
{
|
||||
esp_apptrace_fopen_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fopen '%s' '%s'", path, mode);
|
||||
|
||||
cmd_args.path = path;
|
||||
cmd_args.path_len = strlen(path) + 1;
|
||||
cmd_args.mode = mode;
|
||||
@ -150,7 +154,7 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FOPEN, esp_apptrace_fopen_args_prepare,
|
||||
&cmd_args, cmd_args.path_len+cmd_args.mode_len);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -158,7 +162,7 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
||||
void *resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -180,7 +184,7 @@ int esp_apptrace_fclose(esp_apptrace_dest_t dest, void *stream)
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FCLOSE, esp_apptrace_fclose_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
@ -188,7 +192,7 @@ int esp_apptrace_fclose(esp_apptrace_dest_t dest, void *stream)
|
||||
int resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
@ -207,13 +211,15 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
||||
{
|
||||
esp_apptrace_fwrite_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fwrite f %p l %d", stream, size*nmemb);
|
||||
|
||||
cmd_args.buf = (void *)ptr;
|
||||
cmd_args.size = size * nmemb;
|
||||
cmd_args.file = stream;
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FWRITE, esp_apptrace_fwrite_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args.file)+cmd_args.size);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -221,7 +227,7 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
||||
size_t resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -240,12 +246,14 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
||||
{
|
||||
esp_apptrace_fread_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fread f %p l %d", stream, size*nmemb);
|
||||
|
||||
cmd_args.size = size * nmemb;
|
||||
cmd_args.file = stream;
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FREAD, esp_apptrace_fread_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -253,13 +261,13 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
||||
size_t resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
if (resp > 0) {
|
||||
ret = esp_apptrace_file_rsp_recv(dest, ptr, resp);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read file data (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read file data (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -277,13 +285,15 @@ int esp_apptrace_fseek(esp_apptrace_dest_t dest, void *stream, long offset, int
|
||||
{
|
||||
esp_apptrace_fseek_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fseek f %p o 0x%lx w %d", stream, offset, whence);
|
||||
|
||||
cmd_args.file = stream;
|
||||
cmd_args.offset = offset;
|
||||
cmd_args.whence = whence;
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FSEEK, esp_apptrace_fseek_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -291,7 +301,7 @@ int esp_apptrace_fseek(esp_apptrace_dest_t dest, void *stream, long offset, int
|
||||
int resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -313,7 +323,7 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FTELL, esp_apptrace_ftell_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -321,7 +331,7 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
||||
int resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -330,9 +340,10 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
||||
|
||||
int esp_apptrace_fstop(esp_apptrace_dest_t dest)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __func__);
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_STOP, NULL, NULL, 0);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
0
components/app_update/component.mk
Executable file → Normal file
0
components/app_update/component.mk
Executable file → Normal file
0
components/app_update/include/esp_ota_ops.h
Executable file → Normal file
0
components/app_update/include/esp_ota_ops.h
Executable file → Normal file
@ -236,6 +236,15 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) {
|
||||
|
||||
mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), pNetwork->tlsConnectParams.timeout_ms);
|
||||
|
||||
/* Use the AWS IoT ALPN extension for MQTT, if port 443 is requested */
|
||||
if (pNetwork->tlsConnectParams.DestinationPort == 443) {
|
||||
const char *alpnProtocols[] = { "x-amzn-mqtt-ca", NULL };
|
||||
if ((ret = mbedtls_ssl_conf_alpn_protocols(&(tlsDataParams->conf), alpnProtocols)) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_conf_alpn_protocols returned -0x%x", -ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if((ret = mbedtls_ssl_setup(&(tlsDataParams->ssl), &(tlsDataParams->conf))) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_setup returned -0x%x", -ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
|
@ -62,6 +62,71 @@ config BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
bool "1.9V"
|
||||
endchoice
|
||||
|
||||
config BOOTLOADER_FACTORY_RESET
|
||||
bool "GPIO triggers factory reset"
|
||||
default N
|
||||
help
|
||||
Allows to reset the device to factory settings:
|
||||
- clear one or more data partitions;
|
||||
- boot from "factory" partition.
|
||||
The factory reset will occur if there is a GPIO input pulled low while device starts up.
|
||||
See settings below.
|
||||
|
||||
config BOOTLOADER_NUM_PIN_FACTORY_RESET
|
||||
int "Number of the GPIO input for factory reset"
|
||||
depends on BOOTLOADER_FACTORY_RESET
|
||||
range 0 39
|
||||
default 4
|
||||
help
|
||||
The selected GPIO will be configured as an input with internal pull-up enabled.
|
||||
To trigger a factory reset, this GPIO must be pulled low on reset.
|
||||
Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
|
||||
|
||||
config BOOTLOADER_OTA_DATA_ERASE
|
||||
bool "Clear OTA data on factory reset (select factory partition)"
|
||||
depends on BOOTLOADER_FACTORY_RESET
|
||||
help
|
||||
The device will boot from "factory" partition (or OTA slot 0 if no factory partition is present) after a factory reset.
|
||||
|
||||
config BOOTLOADER_DATA_FACTORY_RESET
|
||||
string "Comma-separated names of partitions to clear on factory reset"
|
||||
depends on BOOTLOADER_FACTORY_RESET
|
||||
default "nvs"
|
||||
help
|
||||
Allows customers to select which data partitions will be erased while factory reset.
|
||||
|
||||
Specify the names of partitions as a comma-delimited with optional spaces for readability. (Like this: "nvs, phy_init, ...")
|
||||
Make sure that the name specified in the partition table and here are the same.
|
||||
Partitions of type "app" cannot be specified here.
|
||||
|
||||
config BOOTLOADER_APP_TEST
|
||||
bool "GPIO triggers boot from test app partition"
|
||||
default N
|
||||
help
|
||||
Allows to run the test app from "TEST" partition.
|
||||
A boot from "test" partition will occur if there is a GPIO input pulled low while device starts up.
|
||||
See settings below.
|
||||
|
||||
config BOOTLOADER_NUM_PIN_APP_TEST
|
||||
int "Number of the GPIO input to boot TEST partition"
|
||||
depends on BOOTLOADER_APP_TEST
|
||||
range 0 39
|
||||
default 18
|
||||
help
|
||||
The selected GPIO will be configured as an input with internal pull-up enabled.
|
||||
To trigger a test app, this GPIO must be pulled low on reset.
|
||||
After the GPIO input is deactivated and the device reboots, the old application will boot.
|
||||
(factory or OTA[x]).
|
||||
Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
|
||||
|
||||
config BOOTLOADER_HOLD_TIME_GPIO
|
||||
int "Hold time of GPIO for reset/test mode (seconds)"
|
||||
depends on BOOTLOADER_FACTORY_RESET || BOOTLOADER_APP_TEST
|
||||
default 5
|
||||
help
|
||||
The GPIO must be held low continuously for this period of time after reset
|
||||
before a factory reset or test partition boot (as applicable) is performed.
|
||||
|
||||
endmenu # Bootloader
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_init.h"
|
||||
#include "bootloader_utility.h"
|
||||
@ -83,7 +84,35 @@ static int selected_boot_partition(const bootloader_state_t *bs)
|
||||
if (boot_index == INVALID_INDEX) {
|
||||
return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
|
||||
} else {
|
||||
// Check for reset to the factory firmware or for launch OTA[x] firmware.
|
||||
// Factory firmware.
|
||||
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
|
||||
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {
|
||||
ESP_LOGI(TAG, "Detect a condition of the factory reset");
|
||||
bool ota_data_erase = false;
|
||||
#ifdef CONFIG_BOOTLOADER_OTA_DATA_ERASE
|
||||
ota_data_erase = true;
|
||||
#endif
|
||||
const char *list_erase = CONFIG_BOOTLOADER_DATA_FACTORY_RESET;
|
||||
ESP_LOGI(TAG, "Data partitions to erase: %s", list_erase);
|
||||
if (bootloader_common_erase_part_type_data(list_erase, ota_data_erase) == false) {
|
||||
ESP_LOGE(TAG, "Not all partitions were erased");
|
||||
}
|
||||
return bootloader_utility_get_selected_boot_partition(bs);
|
||||
}
|
||||
#endif
|
||||
// TEST firmware.
|
||||
#ifdef CONFIG_BOOTLOADER_APP_TEST
|
||||
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_APP_TEST, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {
|
||||
ESP_LOGI(TAG, "Detect a boot condition of the test firmware");
|
||||
if (bs->test.offset != 0) {
|
||||
boot_index = TEST_APP_INDEX;
|
||||
return boot_index;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Test firmware is not found in partition table");
|
||||
return INVALID_INDEX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Customer implementation.
|
||||
// if (gpio_pin_1 == true && ...){
|
||||
// boot_index = required_boot_partition;
|
||||
|
0
components/bootloader_support/component.mk
Executable file → Normal file
0
components/bootloader_support/component.mk
Executable file → Normal file
@ -13,6 +13,14 @@
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
#include "esp_flash_data_types.h"
|
||||
|
||||
/// Type of hold a GPIO in low state
|
||||
typedef enum {
|
||||
GPIO_LONG_HOLD = 1, /*!< The long hold GPIO */
|
||||
GPIO_SHORT_HOLD = -1, /*!< The short hold GPIO */
|
||||
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
|
||||
} esp_comm_gpio_hold_t;
|
||||
|
||||
/**
|
||||
* @brief Calculate crc for the OTA data partition.
|
||||
@ -29,3 +37,34 @@ uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s);
|
||||
* @return Returns true on valid, false otherwise.
|
||||
*/
|
||||
bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s);
|
||||
|
||||
/**
|
||||
* @brief Check if the GPIO input is a long hold or a short hold.
|
||||
*
|
||||
* Number of the GPIO input will be configured as an input with internal pull-up enabled.
|
||||
* If the GPIO input is held low continuously for delay_sec period then it is a long hold.
|
||||
* If the GPIO input is held low for less period then it is a short hold.
|
||||
*
|
||||
* @param[in] num_pin Number of the GPIO input.
|
||||
* @param[in] delay_sec Input must be driven low for at least this long, continuously.
|
||||
* @return esp_comm_gpio_hold_t Defines type of hold a GPIO in low state.
|
||||
*/
|
||||
esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec);
|
||||
|
||||
/**
|
||||
* @brief Erase the partition data that is specified in the transferred list.
|
||||
*
|
||||
* @param[in] list_erase String containing a list of cleared partitions. Like this "nvs, phy". The string must be null-terminal.
|
||||
* @param[in] ota_data_erase If true then the OTA data partition will be cleared (if there is it in partition table).
|
||||
* @return Returns true on success, false otherwise.
|
||||
*/
|
||||
bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_data_erase);
|
||||
|
||||
/**
|
||||
* @brief Determines if the list contains the label
|
||||
*
|
||||
* @param[in] list A string of names delimited by commas or spaces. Like this "nvs, phy, data". The string must be null-terminated.
|
||||
* @param[in] label The substring that will be searched in the list.
|
||||
* @return Returns true if the list contains the label, false otherwise.
|
||||
*/
|
||||
bool bootloader_common_label_search(const char *list, char *label);
|
||||
|
@ -24,6 +24,14 @@ extern "C" {
|
||||
*/
|
||||
void bootloader_enable_qio_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Read flash ID by sending 0x9F command
|
||||
* @return flash raw ID
|
||||
* mfg_id = (ID >> 16) & 0xFF;
|
||||
flash_id = ID & 0xffff;
|
||||
*/
|
||||
uint32_t bootloader_read_flash_id();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -12,8 +12,22 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "string.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/crc.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "esp_flash_data_types.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
static const char* TAG = "boot_comm";
|
||||
|
||||
uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s)
|
||||
{
|
||||
@ -24,3 +38,118 @@ bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s)
|
||||
{
|
||||
return s->ota_seq != UINT32_MAX && s->crc == bootloader_common_ota_select_crc(s);
|
||||
}
|
||||
|
||||
esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec)
|
||||
{
|
||||
gpio_pad_select_gpio(num_pin);
|
||||
gpio_pad_pullup(num_pin);
|
||||
uint32_t tm_start = esp_log_early_timestamp();
|
||||
if (GPIO_INPUT_GET(num_pin) == 1) {
|
||||
return GPIO_NOT_HOLD;
|
||||
}
|
||||
do {
|
||||
if (GPIO_INPUT_GET(num_pin) != 0) {
|
||||
return GPIO_SHORT_HOLD;
|
||||
}
|
||||
} while (delay_sec > ((esp_log_early_timestamp() - tm_start) / 1000L));
|
||||
return GPIO_LONG_HOLD;
|
||||
}
|
||||
|
||||
// Search for a label in the list. list = "nvs1, nvs2, otadata, nvs"; label = "nvs".
|
||||
bool bootloader_common_label_search(const char *list, char *label)
|
||||
{
|
||||
if (list == NULL || label == NULL) {
|
||||
return false;
|
||||
}
|
||||
const char *sub_list_start_like_label = strstr(list, label);
|
||||
while (sub_list_start_like_label != NULL) {
|
||||
|
||||
// ["," or " "] + label + ["," or " " or "\0"]
|
||||
// first character before the label found there must be a delimiter ["," or " "].
|
||||
int idx_first = sub_list_start_like_label - list;
|
||||
if (idx_first == 0 || (idx_first != 0 && (list[idx_first - 1] == ',' || list[idx_first - 1] == ' '))) {
|
||||
// next character after the label found there must be a delimiter ["," or " " or "\0"].
|
||||
int len_label = strlen(label);
|
||||
if (sub_list_start_like_label[len_label] == 0 ||
|
||||
sub_list_start_like_label[len_label] == ',' ||
|
||||
sub_list_start_like_label[len_label] == ' ') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// [start_delim] + label + [end_delim] was not found.
|
||||
// Position is moving to next delimiter if it is not the end of list.
|
||||
int pos_delim = strcspn(sub_list_start_like_label, ", ");
|
||||
if (pos_delim == strlen(sub_list_start_like_label)) {
|
||||
break;
|
||||
}
|
||||
sub_list_start_like_label = strstr(&sub_list_start_like_label[pos_delim], label);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_data_erase)
|
||||
{
|
||||
const esp_partition_info_t *partitions;
|
||||
const char *marker;
|
||||
esp_err_t err;
|
||||
int num_partitions;
|
||||
bool ret = true;
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "Verifying partition table signature...");
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table signature.");
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "Partition table signature verified");
|
||||
}
|
||||
#endif
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_ADDR, (intptr_t)partitions);
|
||||
|
||||
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table");
|
||||
ret = false;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "## Label Usage Offset Length Cleaned");
|
||||
for (int i = 0; i < num_partitions; i++) {
|
||||
const esp_partition_info_t *partition = &partitions[i];
|
||||
char label[sizeof(partition->label) + 1] = {0};
|
||||
if (partition->type == PART_TYPE_DATA) {
|
||||
bool fl_ota_data_erase = false;
|
||||
if (ota_data_erase == true && partition->subtype == PART_SUBTYPE_DATA_OTA) {
|
||||
fl_ota_data_erase = true;
|
||||
}
|
||||
// partition->label is not null-terminated string.
|
||||
strncpy(label, (char *)&partition->label, sizeof(partition->label));
|
||||
if (fl_ota_data_erase == true || (bootloader_common_label_search(list_erase, label) == true)) {
|
||||
err = esp_rom_spiflash_erase_area(partition->pos.offset, partition->pos.size);
|
||||
if (err != ESP_OK) {
|
||||
ret = false;
|
||||
marker = "err";
|
||||
} else {
|
||||
marker = "yes";
|
||||
}
|
||||
} else {
|
||||
marker = "no";
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "%2d %-16s data %08x %08x [%s]", i, partition->label,
|
||||
partition->pos.offset, partition->pos.size, marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootloader_munmap(partitions);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ static esp_err_t bootloader_main();
|
||||
static void print_flash_info(const esp_image_header_t* pfhdr);
|
||||
static void update_flash_config(const esp_image_header_t* pfhdr);
|
||||
static void vddsdio_configure();
|
||||
static void flash_gpio_configure();
|
||||
static void flash_gpio_configure(const esp_image_header_t* pfhdr);
|
||||
static void uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
|
||||
@ -118,7 +118,14 @@ esp_err_t bootloader_init()
|
||||
static esp_err_t bootloader_main()
|
||||
{
|
||||
vddsdio_configure();
|
||||
flash_gpio_configure();
|
||||
/* Read and keep flash ID, for further use. */
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
esp_image_header_t fhdr;
|
||||
if (bootloader_flash_read(ESP_BOOTLOADER_OFFSET, &fhdr, sizeof(esp_image_header_t), true) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
flash_gpio_configure(&fhdr);
|
||||
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
|
||||
//Check if ESP32 is rated for a CPU frequency of 160MHz only
|
||||
if (REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_RATED) &&
|
||||
@ -132,8 +139,6 @@ static esp_err_t bootloader_main()
|
||||
wdt_reset_check();
|
||||
ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER);
|
||||
|
||||
esp_image_header_t fhdr;
|
||||
|
||||
ESP_LOGI(TAG, "compile time " __TIME__ );
|
||||
ets_set_appcpu_boot_addr(0);
|
||||
|
||||
@ -158,11 +163,6 @@ static esp_err_t bootloader_main()
|
||||
bootloader_enable_qio_mode();
|
||||
#endif
|
||||
|
||||
if (bootloader_flash_read(ESP_BOOTLOADER_OFFSET, &fhdr, sizeof(esp_image_header_t), true) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
print_flash_info(&fhdr);
|
||||
|
||||
update_flash_config(&fhdr);
|
||||
@ -276,7 +276,7 @@ static void vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.enable == 1 && cfg.tieh == 0) { // VDDSDIO regulator is enabled @ 1.8V
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) { // VDDSDIO regulator is enabled @ 1.8V
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
@ -295,31 +295,49 @@ static void vddsdio_configure()
|
||||
#define FLASH_SPIHD_IO 9
|
||||
#define FLASH_IO_MATRIX_DUMMY_40M 1
|
||||
#define FLASH_IO_MATRIX_DUMMY_80M 2
|
||||
static void IRAM_ATTR flash_gpio_configure()
|
||||
#define FLASH_IO_DRIVE_GD_WITH_1V8PSRAM 3
|
||||
|
||||
/*
|
||||
* Bootloader reads SPI configuration from bin header, so that
|
||||
* the burning configuration can be different with compiling configuration.
|
||||
*/
|
||||
static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
int spi_cache_dummy = 0;
|
||||
int drv = 2;
|
||||
#if CONFIG_FLASHMODE_QIO
|
||||
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN; //qio 3
|
||||
#elif CONFIG_FLASHMODE_QOUT
|
||||
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN; //qout 7
|
||||
#elif CONFIG_FLASHMODE_DIO
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN; //dio 3
|
||||
#elif CONFIG_FLASHMODE_DOUT
|
||||
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN; //dout 7
|
||||
#endif
|
||||
switch (pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN; //qio 3
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
case ESP_IMAGE_SPI_MODE_DOUT:
|
||||
default:
|
||||
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN;
|
||||
break;
|
||||
}
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
#if CONFIG_ESPTOOLPY_FLASHFREQ_40M
|
||||
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_40M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_40M;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_40M, SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
#elif CONFIG_ESPTOOLPY_FLASHFREQ_80M
|
||||
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_80M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_80M;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M, SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
drv = 3;
|
||||
#endif
|
||||
switch (pfhdr->spi_speed) {
|
||||
case ESP_IMAGE_SPI_SPEED_80M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_80M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_80M;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M,
|
||||
SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
drv = 3;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_40M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_40M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_40M;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_40M,
|
||||
SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
@ -361,6 +379,19 @@ static void IRAM_ATTR flash_gpio_configure()
|
||||
// set drive ability for clock
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
|
||||
#if CONFIG_SPIRAM_TYPE_ESPPSRAM32
|
||||
uint32_t flash_id = g_rom_flashchip.device_id;
|
||||
if (flash_id == FLASH_ID_GD25LQ32C) {
|
||||
// Set drive ability for 1.8v flash in 80Mhz.
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA0_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA1_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA2_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA3_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CMD_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
return NULL;
|
||||
}
|
||||
mbedtls_sha256_init(ctx);
|
||||
mbedtls_sha256_starts(ctx, false);
|
||||
assert(mbedtls_sha256_starts_ret(ctx, false) == 0);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
|
||||
{
|
||||
assert(handle != NULL);
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
|
||||
mbedtls_sha256_update(ctx, data, data_len);
|
||||
assert(mbedtls_sha256_update_ret(ctx, data, data_len) == 0);
|
||||
}
|
||||
|
||||
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
|
||||
@ -44,7 +44,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
|
||||
assert(handle != NULL);
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
|
||||
if (digest != NULL) {
|
||||
mbedtls_sha256_finish(ctx, digest);
|
||||
assert(mbedtls_sha256_finish_ret(ctx, digest) == 0);
|
||||
}
|
||||
mbedtls_sha256_free(ctx);
|
||||
free(handle);
|
||||
|
@ -67,7 +67,6 @@ static void set_cache_and_start_app(uint32_t drom_addr,
|
||||
bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
{
|
||||
const esp_partition_info_t *partitions;
|
||||
const int ESP_PARTITION_TABLE_DATA_LEN = 0xC00; /* length of actual data (signature is appended to this) */
|
||||
const char *partition_usage;
|
||||
esp_err_t err;
|
||||
int num_partitions;
|
||||
@ -75,7 +74,7 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if(esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "Verifying partition table signature...");
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_DATA_LEN);
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table signature.");
|
||||
return false;
|
||||
@ -84,9 +83,9 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
}
|
||||
#endif
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_DATA_LEN);
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_DATA_LEN);
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_ADDR, (intptr_t)partitions);
|
||||
@ -292,7 +291,14 @@ bool bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_
|
||||
{
|
||||
int index = start_index;
|
||||
esp_partition_pos_t part;
|
||||
|
||||
if(start_index == TEST_APP_INDEX) {
|
||||
if (try_load_partition(&bs->test, result)) {
|
||||
return true;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "No bootable test partition in the partition table");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* work backwards from start_index, down to the factory app */
|
||||
for(index = start_index; index >= FACTORY_INDEX; index--) {
|
||||
part = index_to_partition(bs, index);
|
||||
|
@ -114,10 +114,15 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
uint32_t bootloader_read_flash_id()
|
||||
{
|
||||
uint32_t id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00);
|
||||
return id;
|
||||
}
|
||||
|
||||
void bootloader_enable_qio_mode(void)
|
||||
{
|
||||
uint32_t old_ctrl_reg;
|
||||
uint32_t raw_flash_id;
|
||||
uint8_t mfg_id;
|
||||
uint16_t flash_id;
|
||||
@ -126,20 +131,11 @@ void bootloader_enable_qio_mode(void)
|
||||
ESP_LOGD(TAG, "Probing for QIO mode enable...");
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
||||
/* Set up some of the SPIFLASH user/ctrl variables which don't change
|
||||
while we're probing using execute_flash_command() */
|
||||
old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
SPIFLASH.ctrl.val = SPI_WP_REG; // keep WP high while idle, otherwise leave DIO mode
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user.usr_addr = 0;
|
||||
SPIFLASH.user.usr_command = 1;
|
||||
SPIFLASH.user2.usr_command_bitlen = 7;
|
||||
|
||||
raw_flash_id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
raw_flash_id = g_rom_flashchip.device_id;
|
||||
ESP_LOGD(TAG, "Raw SPI flash chip id 0x%x", raw_flash_id);
|
||||
|
||||
mfg_id = raw_flash_id & 0xFF;
|
||||
flash_id = (raw_flash_id >> 16) | (raw_flash_id & 0xFF00);
|
||||
mfg_id = (raw_flash_id >> 16) & 0xFF;
|
||||
flash_id = raw_flash_id & 0xFFFF;
|
||||
ESP_LOGD(TAG, "Manufacturer ID 0x%02x chip ID 0x%04x", mfg_id, flash_id);
|
||||
|
||||
for (i = 0; i < NUM_CHIPS-1; i++) {
|
||||
@ -154,13 +150,9 @@ void bootloader_enable_qio_mode(void)
|
||||
ESP_LOGI(TAG, "Enabling default flash chip QIO");
|
||||
}
|
||||
|
||||
esp_err_t res = enable_qio_mode(chip_data[i].read_status_fn,
|
||||
chip_data[i].write_status_fn,
|
||||
chip_data[i].status_qio_bit);
|
||||
if (res != ESP_OK) {
|
||||
// Restore SPI flash CTRL setting, to keep us in DIO/DOUT mode
|
||||
SPIFLASH.ctrl.val = old_ctrl_reg;
|
||||
}
|
||||
enable_qio_mode(chip_data[i].read_status_fn,
|
||||
chip_data[i].write_status_fn,
|
||||
chip_data[i].status_qio_bit);
|
||||
}
|
||||
|
||||
static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
@ -256,6 +248,13 @@ static void write_status_16b_wrsr(unsigned new_status)
|
||||
|
||||
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
|
||||
{
|
||||
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user.usr_addr = 0;
|
||||
SPIFLASH.user.usr_command = 1;
|
||||
SPIFLASH.user2.usr_command_bitlen = 7;
|
||||
|
||||
SPIFLASH.user2.usr_command_value = command;
|
||||
SPIFLASH.user.usr_miso = miso_len > 0;
|
||||
SPIFLASH.miso_dlen.usr_miso_dbitlen = miso_len ? (miso_len - 1) : 0;
|
||||
@ -278,5 +277,6 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
while(SPIFLASH.cmd.usr != 0)
|
||||
{ }
|
||||
|
||||
SPIFLASH.ctrl.val = old_ctrl_reg;
|
||||
return SPIFLASH.data_buf[0];
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <esp_types.h>
|
||||
#include <stdio.h>
|
||||
#include "string.h"
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@ -12,7 +13,7 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
|
||||
#include "bootloader_common.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_image_format.h"
|
||||
@ -47,3 +48,47 @@ TEST_CASE("Verify unit test app image", "[bootloader_support]")
|
||||
TEST_ASSERT_TRUE(data.image_len <= running->size);
|
||||
}
|
||||
|
||||
void check_label_search (int num_test, const char *list, const char *t_label, bool result)
|
||||
{
|
||||
// gen_esp32part.py trims up to 16 characters
|
||||
// and the string may not have a null terminal symbol.
|
||||
// below is cutting as it does the generator.
|
||||
char label[16 + 1] = {0};
|
||||
strncpy(label, t_label, sizeof(label) - 1);
|
||||
|
||||
bool ret = bootloader_common_label_search(list, label);
|
||||
if (ret != result) {
|
||||
printf("%d) %s | %s \n", num_test, list, label);
|
||||
}
|
||||
TEST_ASSERT_MESSAGE(ret == result, "Test failed");
|
||||
}
|
||||
|
||||
TEST_CASE("Test label_search", "[bootloader_support]")
|
||||
{
|
||||
TEST_ASSERT_FALSE(bootloader_common_label_search(NULL, NULL));
|
||||
TEST_ASSERT_FALSE(bootloader_common_label_search("nvs", NULL));
|
||||
|
||||
check_label_search(1, "nvs", "nvs", true);
|
||||
check_label_search(2, "nvs, ", "nvs", true);
|
||||
check_label_search(3, "nvs1", "nvs", false);
|
||||
check_label_search(3, "nvs1, ", "nvs", false);
|
||||
check_label_search(4, "nvs1nvs1, phy", "nvs1", false);
|
||||
check_label_search(5, "nvs1, nvs1, phy", "nvs1", true);
|
||||
check_label_search(6, "nvs12, nvs12, phy", "nvs1", false);
|
||||
check_label_search(7, "nvs12, nvs1, phy", "nvs1", true);
|
||||
check_label_search(8, "nvs12, nvs3, phy, nvs1","nvs1", true);
|
||||
check_label_search(9, "nvs1nvs1, phy, nvs", "nvs", true);
|
||||
check_label_search(10, "nvs1nvs1, phy, nvs1", "nvs", false);
|
||||
check_label_search(11, "nvs1, nvs, phy, nvs1", "nvs", true);
|
||||
check_label_search(12, "nvs1, nvs2, phy, nvs","nvs", true);
|
||||
check_label_search(13, "ota_data, backup_nvs", "nvs", false);
|
||||
check_label_search(14, "nvs1, nvs2, ota, nvs", "vs1", false);
|
||||
|
||||
check_label_search(20, "12345678901234, phy, nvs1", "12345678901234", true);
|
||||
check_label_search(21, "123456789012345, phy, nvs1", "123456789012345", true);
|
||||
check_label_search(22, "1234567890123456, phy, nvs1", "1234567890123456", true);
|
||||
check_label_search(23, "12345678901234567, phy, nvs1", "12345678901234567", false);
|
||||
check_label_search(24, "1234567890123456, phy, nvs1", "12345678901234567", true);
|
||||
check_label_search(25, "phy, 1234567890123456, nvs1", "12345678901234567", true);
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,48 @@ config BT_HCI_UART_BAUDRATE
|
||||
UART Baudrate for HCI. Please use standard baudrate.
|
||||
endmenu
|
||||
|
||||
menu "MODEM SLEEP Options"
|
||||
visible if BT_ENABLED
|
||||
|
||||
config BTDM_CONTROLLER_MODEM_SLEEP
|
||||
bool "Bluetooth modem sleep"
|
||||
depends on BT_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable/disable bluetooth controller low power mode.
|
||||
Note that currently there is problem in the combination use of bluetooth modem sleep and Dynamic Frequency Scaling(DFS). So do not enable DFS if bluetooth modem sleep is in use.
|
||||
|
||||
choice BTDM_MODEM_SLEEP_MODE
|
||||
prompt "Bluetooth Modem sleep mode"
|
||||
depends on BTDM_CONTROLLER_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 deep 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 "
|
||||
help
|
||||
This mode is for BLE only.
|
||||
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
|
||||
|
||||
config BTDM_LPCLK_SEL_MAIN_XTAL
|
||||
bool "Main crystal"
|
||||
config BTDM_LPCLK_SEL_EXT_32K_XTAL
|
||||
bool "External 32kHz crystal"
|
||||
depends on ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
bool "Bluedroid Enable"
|
||||
depends on BTDM_CONTROLLER_HCI_MODE_VHCI
|
||||
@ -120,24 +162,14 @@ config A2DP_ENABLE
|
||||
help
|
||||
Advanced Audio Distrubution Profile
|
||||
|
||||
choice A2DP_ROLE
|
||||
prompt "A2DP ROLE config"
|
||||
depends on A2DP_ENABLE
|
||||
|
||||
config A2DP_SINK_ENABLE
|
||||
bool "SINK"
|
||||
config A2DP_SRC_ENABLE
|
||||
bool "SOURCE"
|
||||
endchoice
|
||||
|
||||
config A2DP_SINK_TASK_STACK_SIZE
|
||||
int "A2DP sink (audio stream decoding) task stack size"
|
||||
depends on A2DP_ENABLE && A2DP_SINK_ENABLE
|
||||
depends on A2DP_ENABLE
|
||||
default 2048
|
||||
|
||||
config A2DP_SOURCE_TASK_STACK_SIZE
|
||||
int "A2DP source (audio stream encoding) task stack size"
|
||||
depends on A2DP_ENABLE && A2DP_SRC_ENABLE
|
||||
depends on A2DP_ENABLE
|
||||
default 2048
|
||||
|
||||
config BT_SPP_ENABLED
|
||||
@ -147,6 +179,33 @@ config BT_SPP_ENABLED
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
|
||||
config HFP_ENABLE
|
||||
bool "Hands Free/Handset Profile"
|
||||
depends on CLASSIC_BT_ENABLED
|
||||
default n
|
||||
|
||||
choice HFP_ROLE
|
||||
prompt "Hands-free Profile Role configuration"
|
||||
depends on HFP_ENABLE
|
||||
|
||||
config HFP_CLIENT_ENABLE
|
||||
bool "Hands Free Unit"
|
||||
endchoice
|
||||
|
||||
choice HFP_AUDIO_DATA_PATH
|
||||
prompt "audio(SCO) data path"
|
||||
depends on HFP_ENABLE
|
||||
|
||||
config HFP_AUDIO_DATA_PATH_PCM
|
||||
bool "PCM"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
config HFP_AUDIO_DATA_PATH_HCI
|
||||
bool "HCI"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
endchoice
|
||||
|
||||
config GATTS_ENABLE
|
||||
bool "Include GATT server module(GATTS)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
@ -168,22 +227,754 @@ config BLE_SMP_ENABLE
|
||||
help
|
||||
This option can be close when the app not used the ble security connect.
|
||||
|
||||
config BLE_ENABLE_SRVCHG_REG
|
||||
bool "Enable automatic service change notify registration"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
This option enables automatic registration of service change notification
|
||||
after connect. Be careful, it can may collide with your command sequences
|
||||
and lead to GATT_BUSY.
|
||||
|
||||
config BT_STACK_NO_LOG
|
||||
bool "Close the bluedroid bt stack log print"
|
||||
bool "Disable BT debug logs (minimize bin size)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
This select can save the rodata code size
|
||||
|
||||
menu "BT DEBUG LOG LEVEL"
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
|
||||
choice HCI_INITIAL_TRACE_LEVEL
|
||||
prompt "HCI layer"
|
||||
default HCI_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for HCI layer
|
||||
|
||||
config HCI_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config HCI_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config HCI_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config HCI_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config HCI_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config HCI_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config HCI_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config HCI_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if HCI_TRACE_LEVEL_NONE
|
||||
default 1 if HCI_TRACE_LEVEL_ERROR
|
||||
default 2 if HCI_TRACE_LEVEL_WARNING
|
||||
default 3 if HCI_TRACE_LEVEL_API
|
||||
default 4 if HCI_TRACE_LEVEL_EVENT
|
||||
default 5 if HCI_TRACE_LEVEL_DEBUG
|
||||
default 6 if HCI_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BTM_INITIAL_TRACE_LEVEL
|
||||
prompt "BTM layer"
|
||||
default BTM_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BTM layer
|
||||
|
||||
config BTM_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BTM_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BTM_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BTM_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BTM_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BTM_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BTM_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BTM_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BTM_TRACE_LEVEL_NONE
|
||||
default 1 if BTM_TRACE_LEVEL_ERROR
|
||||
default 2 if BTM_TRACE_LEVEL_WARNING
|
||||
default 3 if BTM_TRACE_LEVEL_API
|
||||
default 4 if BTM_TRACE_LEVEL_EVENT
|
||||
default 5 if BTM_TRACE_LEVEL_DEBUG
|
||||
default 6 if BTM_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice L2CAP_INITIAL_TRACE_LEVEL
|
||||
prompt "L2CAP layer"
|
||||
default L2CAP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for L2CAP layer
|
||||
|
||||
config L2CAP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config L2CAP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config L2CAP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config L2CAP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config L2CAP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config L2CAP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config L2CAP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config L2CAP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if L2CAP_TRACE_LEVEL_NONE
|
||||
default 1 if L2CAP_TRACE_LEVEL_ERROR
|
||||
default 2 if L2CAP_TRACE_LEVEL_WARNING
|
||||
default 3 if L2CAP_TRACE_LEVEL_API
|
||||
default 4 if L2CAP_TRACE_LEVEL_EVENT
|
||||
default 5 if L2CAP_TRACE_LEVEL_DEBUG
|
||||
default 6 if L2CAP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice RFCOMM_INITIAL_TRACE_LEVEL
|
||||
prompt "RFCOMM layer"
|
||||
default RFCOMM_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for RFCOMM layer
|
||||
|
||||
config RFCOMM_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config RFCOMM_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config RFCOMM_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config RFCOMM_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config RFCOMM_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config RFCOMM_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config RFCOMM_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config RFCOMM_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if RFCOMM_TRACE_LEVEL_NONE
|
||||
default 1 if RFCOMM_TRACE_LEVEL_ERROR
|
||||
default 2 if RFCOMM_TRACE_LEVEL_WARNING
|
||||
default 3 if RFCOMM_TRACE_LEVEL_API
|
||||
default 4 if RFCOMM_TRACE_LEVEL_EVENT
|
||||
default 5 if RFCOMM_TRACE_LEVEL_DEBUG
|
||||
default 6 if RFCOMM_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice SDP_INITIAL_TRACE_LEVEL
|
||||
prompt "SDP layer"
|
||||
default SDP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for SDP layer
|
||||
|
||||
config SDP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config SDP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config SDP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config SDP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config SDP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config SDP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config SDP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config SDP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if SDP_TRACE_LEVEL_NONE
|
||||
default 1 if SDP_TRACE_LEVEL_ERROR
|
||||
default 2 if SDP_TRACE_LEVEL_WARNING
|
||||
default 3 if SDP_TRACE_LEVEL_API
|
||||
default 4 if SDP_TRACE_LEVEL_EVENT
|
||||
default 5 if SDP_TRACE_LEVEL_DEBUG
|
||||
default 6 if SDP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice GAP_INITIAL_TRACE_LEVEL
|
||||
prompt "GAP layer"
|
||||
default GAP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for GAP layer
|
||||
|
||||
config GAP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config GAP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config GAP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config GAP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config GAP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config GAP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config GAP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config GAP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if GAP_TRACE_LEVEL_NONE
|
||||
default 1 if GAP_TRACE_LEVEL_ERROR
|
||||
default 2 if GAP_TRACE_LEVEL_WARNING
|
||||
default 3 if GAP_TRACE_LEVEL_API
|
||||
default 4 if GAP_TRACE_LEVEL_EVENT
|
||||
default 5 if GAP_TRACE_LEVEL_DEBUG
|
||||
default 6 if GAP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BNEP_INITIAL_TRACE_LEVEL
|
||||
prompt "BNEP layer"
|
||||
default BNEP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BNEP layer
|
||||
|
||||
config BNEP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BNEP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BNEP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BNEP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BNEP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BNEP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BNEP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BNEP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BNEP_TRACE_LEVEL_NONE
|
||||
default 1 if BNEP_TRACE_LEVEL_ERROR
|
||||
default 2 if BNEP_TRACE_LEVEL_WARNING
|
||||
default 3 if BNEP_TRACE_LEVEL_API
|
||||
default 4 if BNEP_TRACE_LEVEL_EVENT
|
||||
default 5 if BNEP_TRACE_LEVEL_DEBUG
|
||||
default 6 if BNEP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice PAN_INITIAL_TRACE_LEVEL
|
||||
prompt "PAN layer"
|
||||
default PAN_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for PAN layer
|
||||
|
||||
config PAN_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config PAN_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config PAN_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config PAN_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config PAN_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config PAN_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config PAN_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config PAN_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if PAN_TRACE_LEVEL_NONE
|
||||
default 1 if PAN_TRACE_LEVEL_ERROR
|
||||
default 2 if PAN_TRACE_LEVEL_WARNING
|
||||
default 3 if PAN_TRACE_LEVEL_API
|
||||
default 4 if PAN_TRACE_LEVEL_EVENT
|
||||
default 5 if PAN_TRACE_LEVEL_DEBUG
|
||||
default 6 if PAN_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice A2D_INITIAL_TRACE_LEVEL
|
||||
prompt "A2D layer"
|
||||
default A2D_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for A2D layer
|
||||
|
||||
config A2D_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config A2D_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config A2D_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config A2D_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config A2D_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config A2D_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config A2D_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config A2D_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if A2D_TRACE_LEVEL_NONE
|
||||
default 1 if A2D_TRACE_LEVEL_ERROR
|
||||
default 2 if A2D_TRACE_LEVEL_WARNING
|
||||
default 3 if A2D_TRACE_LEVEL_API
|
||||
default 4 if A2D_TRACE_LEVEL_EVENT
|
||||
default 5 if A2D_TRACE_LEVEL_DEBUG
|
||||
default 6 if A2D_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice AVDT_INITIAL_TRACE_LEVEL
|
||||
prompt "AVDT layer"
|
||||
default AVDT_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for AVDT layer
|
||||
|
||||
config AVDT_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config AVDT_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config AVDT_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config AVDT_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config AVDT_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config AVDT_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config AVDT_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config AVDT_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if AVDT_TRACE_LEVEL_NONE
|
||||
default 1 if AVDT_TRACE_LEVEL_ERROR
|
||||
default 2 if AVDT_TRACE_LEVEL_WARNING
|
||||
default 3 if AVDT_TRACE_LEVEL_API
|
||||
default 4 if AVDT_TRACE_LEVEL_EVENT
|
||||
default 5 if AVDT_TRACE_LEVEL_DEBUG
|
||||
default 6 if AVDT_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice AVCT_INITIAL_TRACE_LEVEL
|
||||
prompt "AVCT layer"
|
||||
default AVCT_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for AVCT layer
|
||||
|
||||
config AVCT_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config AVCT_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config AVCT_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config AVCT_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config AVCT_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config AVCT_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config AVCT_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config AVCT_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if AVCT_TRACE_LEVEL_NONE
|
||||
default 1 if AVCT_TRACE_LEVEL_ERROR
|
||||
default 2 if AVCT_TRACE_LEVEL_WARNING
|
||||
default 3 if AVCT_TRACE_LEVEL_API
|
||||
default 4 if AVCT_TRACE_LEVEL_EVENT
|
||||
default 5 if AVCT_TRACE_LEVEL_DEBUG
|
||||
default 6 if AVCT_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice AVRC_INITIAL_TRACE_LEVEL
|
||||
prompt "AVRC layer"
|
||||
default AVRC_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for AVRC layer
|
||||
|
||||
config AVRC_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config AVRC_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config AVRC_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config AVRC_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config AVRC_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config AVRC_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config AVRC_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config AVRC_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if AVRC_TRACE_LEVEL_NONE
|
||||
default 1 if AVRC_TRACE_LEVEL_ERROR
|
||||
default 2 if AVRC_TRACE_LEVEL_WARNING
|
||||
default 3 if AVRC_TRACE_LEVEL_API
|
||||
default 4 if AVRC_TRACE_LEVEL_EVENT
|
||||
default 5 if AVRC_TRACE_LEVEL_DEBUG
|
||||
default 6 if AVRC_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice MCA_INITIAL_TRACE_LEVEL
|
||||
prompt "MCA layer"
|
||||
default MCA_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for MCA layer
|
||||
|
||||
config MCA_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config MCA_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config MCA_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config MCA_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config MCA_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config MCA_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config MCA_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config MCA_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if MCA_TRACE_LEVEL_NONE
|
||||
default 1 if MCA_TRACE_LEVEL_ERROR
|
||||
default 2 if MCA_TRACE_LEVEL_WARNING
|
||||
default 3 if MCA_TRACE_LEVEL_API
|
||||
default 4 if MCA_TRACE_LEVEL_EVENT
|
||||
default 5 if MCA_TRACE_LEVEL_DEBUG
|
||||
default 6 if MCA_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice HID_INITIAL_TRACE_LEVEL
|
||||
prompt "HID layer"
|
||||
default HID_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for HID layer
|
||||
|
||||
config HID_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config HID_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config HID_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config HID_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config HID_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config HID_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config HID_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config HID_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if HID_TRACE_LEVEL_NONE
|
||||
default 1 if HID_TRACE_LEVEL_ERROR
|
||||
default 2 if HID_TRACE_LEVEL_WARNING
|
||||
default 3 if HID_TRACE_LEVEL_API
|
||||
default 4 if HID_TRACE_LEVEL_EVENT
|
||||
default 5 if HID_TRACE_LEVEL_DEBUG
|
||||
default 6 if HID_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice APPL_INITIAL_TRACE_LEVEL
|
||||
prompt "APPL layer"
|
||||
default APPL_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for APPL layer
|
||||
|
||||
config APPL_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config APPL_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config APPL_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config APPL_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config APPL_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config APPL_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config APPL_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config APPL_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if APPL_TRACE_LEVEL_NONE
|
||||
default 1 if APPL_TRACE_LEVEL_ERROR
|
||||
default 2 if APPL_TRACE_LEVEL_WARNING
|
||||
default 3 if APPL_TRACE_LEVEL_API
|
||||
default 4 if APPL_TRACE_LEVEL_EVENT
|
||||
default 5 if APPL_TRACE_LEVEL_DEBUG
|
||||
default 6 if APPL_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice GATT_INITIAL_TRACE_LEVEL
|
||||
prompt "GATT layer"
|
||||
default GATT_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for GATT layer
|
||||
|
||||
config GATT_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config GATT_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config GATT_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config GATT_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config GATT_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config GATT_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config GATT_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config GATT_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if GATT_TRACE_LEVEL_NONE
|
||||
default 1 if GATT_TRACE_LEVEL_ERROR
|
||||
default 2 if GATT_TRACE_LEVEL_WARNING
|
||||
default 3 if GATT_TRACE_LEVEL_API
|
||||
default 4 if GATT_TRACE_LEVEL_EVENT
|
||||
default 5 if GATT_TRACE_LEVEL_DEBUG
|
||||
default 6 if GATT_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice SMP_INITIAL_TRACE_LEVEL
|
||||
prompt "SMP layer"
|
||||
default SMP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for SMP layer
|
||||
|
||||
config SMP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config SMP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config SMP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config SMP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config SMP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config SMP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config SMP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config SMP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if SMP_TRACE_LEVEL_NONE
|
||||
default 1 if SMP_TRACE_LEVEL_ERROR
|
||||
default 2 if SMP_TRACE_LEVEL_WARNING
|
||||
default 3 if SMP_TRACE_LEVEL_API
|
||||
default 4 if SMP_TRACE_LEVEL_EVENT
|
||||
default 5 if SMP_TRACE_LEVEL_DEBUG
|
||||
default 6 if SMP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BTIF_INITIAL_TRACE_LEVEL
|
||||
prompt "BTIF layer"
|
||||
default BTIF_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BTIF layer
|
||||
|
||||
config BTIF_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BTIF_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BTIF_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BTIF_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BTIF_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BTIF_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BTIF_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BTIF_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BTIF_TRACE_LEVEL_NONE
|
||||
default 1 if BTIF_TRACE_LEVEL_ERROR
|
||||
default 2 if BTIF_TRACE_LEVEL_WARNING
|
||||
default 3 if BTIF_TRACE_LEVEL_API
|
||||
default 4 if BTIF_TRACE_LEVEL_EVENT
|
||||
default 5 if BTIF_TRACE_LEVEL_DEBUG
|
||||
default 6 if BTIF_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BTC_INITIAL_TRACE_LEVEL
|
||||
prompt "BTC layer"
|
||||
default BTC_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BTC layer
|
||||
|
||||
config BTC_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BTC_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BTC_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BTC_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BTC_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BTC_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BTC_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BTC_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BTC_TRACE_LEVEL_NONE
|
||||
default 1 if BTC_TRACE_LEVEL_ERROR
|
||||
default 2 if BTC_TRACE_LEVEL_WARNING
|
||||
default 3 if BTC_TRACE_LEVEL_API
|
||||
default 4 if BTC_TRACE_LEVEL_EVENT
|
||||
default 5 if BTC_TRACE_LEVEL_DEBUG
|
||||
default 6 if BTC_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice OSI_INITIAL_TRACE_LEVEL
|
||||
prompt "OSI layer"
|
||||
default OSI_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for OSI layer
|
||||
|
||||
config OSI_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config OSI_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config OSI_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config OSI_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config OSI_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config OSI_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config OSI_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config OSI_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if OSI_TRACE_LEVEL_NONE
|
||||
default 1 if OSI_TRACE_LEVEL_ERROR
|
||||
default 2 if OSI_TRACE_LEVEL_WARNING
|
||||
default 3 if OSI_TRACE_LEVEL_API
|
||||
default 4 if OSI_TRACE_LEVEL_EVENT
|
||||
default 5 if OSI_TRACE_LEVEL_DEBUG
|
||||
default 6 if OSI_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BLUFI_INITIAL_TRACE_LEVEL
|
||||
prompt "BLUFI layer"
|
||||
default BLUFI_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BLUFI layer
|
||||
|
||||
config BLUFI_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BLUFI_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BLUFI_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BLUFI_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BLUFI_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BLUFI_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BLUFI_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BLUFI_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BLUFI_TRACE_LEVEL_NONE
|
||||
default 1 if BLUFI_TRACE_LEVEL_ERROR
|
||||
default 2 if BLUFI_TRACE_LEVEL_WARNING
|
||||
default 3 if BLUFI_TRACE_LEVEL_API
|
||||
default 4 if BLUFI_TRACE_LEVEL_EVENT
|
||||
default 5 if BLUFI_TRACE_LEVEL_DEBUG
|
||||
default 6 if BLUFI_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
endmenu #BT DEBUG LOG LEVEL
|
||||
|
||||
|
||||
config BT_ACL_CONNECTIONS
|
||||
int "BT/BLE MAX ACL CONNECTIONS(1~7)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
@ -206,6 +997,38 @@ config BT_BLE_DYNAMIC_ENV_MEMORY
|
||||
help
|
||||
This select can make the allocation of memory will become more flexible
|
||||
|
||||
config BLE_SCAN_DUPLICATE
|
||||
bool "BLE Scan Duplicate Options"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
This select enables parameters setting of BLE scan duplicate.
|
||||
|
||||
config DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of devices in scan duplicate filter"
|
||||
depends on BLE_SCAN_DUPLICATE
|
||||
range 10 200
|
||||
default 20
|
||||
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 BLE_MESH_SCAN_DUPLICATE_EN
|
||||
bool "Special duplicate scan mechanism for BLE Mesh scan"
|
||||
depends on BLE_SCAN_DUPLICATE
|
||||
default n
|
||||
help
|
||||
This enables the BLE scan duplicate for special BLE Mesh scan.
|
||||
|
||||
config MESH_DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of Mesh adv packets in scan duplicate filter"
|
||||
depends on BLE_MESH_SCAN_DUPLICATE_EN
|
||||
range 10 200
|
||||
default 50
|
||||
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 SMP_ENABLE
|
||||
bool
|
||||
depends on BLUEDROID_ENABLED
|
||||
|
@ -35,7 +35,7 @@ esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (adv_data == NULL) {
|
||||
@ -60,7 +60,7 @@ esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (scan_params == NULL) {
|
||||
@ -197,17 +197,82 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
|
||||
esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
{
|
||||
esp_err_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
|
||||
arg.cfg_local_icon.icon = icon;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
switch (icon) {
|
||||
case ESP_BLE_APPEARANCE_GENERIC_PHONE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_COMPUTER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_REMOTE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_THERMOMETER:
|
||||
case ESP_BLE_APPEARANCE_THERMOMETER_EAR:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_HEART_RATE:
|
||||
case ESP_BLE_APPEARANCE_HEART_RATE_BELT:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE:
|
||||
case ESP_BLE_APPEARANCE_BLOOD_PRESSURE_ARM:
|
||||
case ESP_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER:
|
||||
case ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP:
|
||||
case ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_GLUCOSE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_WEIGHT:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_WALKING:
|
||||
case ESP_BLE_APPEARANCE_WALKING_IN_SHOE:
|
||||
case ESP_BLE_APPEARANCE_WALKING_ON_SHOE:
|
||||
case ESP_BLE_APPEARANCE_WALKING_ON_HIP:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_WATCH:
|
||||
case ESP_BLE_APPEARANCE_SPORTS_WATCH:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_EYEGLASSES:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_DISPLAY:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER:
|
||||
case ESP_BLE_APPEARANCE_HID_BARCODE_SCANNER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_HID:
|
||||
case ESP_BLE_APPEARANCE_HID_KEYBOARD:
|
||||
case ESP_BLE_APPEARANCE_HID_MOUSE:
|
||||
case ESP_BLE_APPEARANCE_HID_JOYSTICK:
|
||||
case ESP_BLE_APPEARANCE_HID_GAMEPAD:
|
||||
case ESP_BLE_APPEARANCE_HID_DIGITIZER_TABLET:
|
||||
case ESP_BLE_APPEARANCE_HID_CARD_READER:
|
||||
case ESP_BLE_APPEARANCE_HID_DIGITAL_PEN:
|
||||
case ESP_BLE_APPEARANCE_UNKNOWN:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_CLOCK:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_TAG:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_KEYRING:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_CYCLING:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_COMPUTER:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_SPEED:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_CADENCE:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_POWER:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE:
|
||||
case ESP_BLE_APPEARANCE_POWERED_WHEELCHAIR:
|
||||
case ESP_BLE_APPEARANCE_MOBILITY_SCOOTER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_INSULIN_PUMP:
|
||||
case ESP_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP:
|
||||
case ESP_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP:
|
||||
case ESP_BLE_APPEARANCE_INSULIN_PEN:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV:
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
|
||||
arg.cfg_local_icon.icon = icon;
|
||||
ret = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
break;
|
||||
default:
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda)
|
||||
@ -288,7 +353,7 @@ esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t
|
||||
if(esp_bluedroid_get_status() != (ESP_BLUEDROID_STATUS_ENABLED)) {
|
||||
LOG_ERROR("%s, bluedroid status error", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
if(!BTM_BleGetCurrentAddress(local_used_addr, addr_type)) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@ -477,7 +542,9 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
|
||||
int esp_ble_get_bond_device_num(void)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return btc_storage_get_num_ble_bond_devices();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "common/bt_trace.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_gap_bt.h"
|
||||
#include "btc/btc_storage.h"
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
|
||||
@ -178,4 +179,65 @@ esp_err_t esp_bt_gap_get_cod(esp_bt_cod_t *cod)
|
||||
return btc_gap_bt_get_cod(cod);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_bt_gap_read_rssi_delta(esp_bd_addr_t remote_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_READ_RSSI_DELTA;
|
||||
memcpy(arg.read_rssi_delta.bda.address, remote_addr, sizeof(esp_bd_addr_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE;
|
||||
|
||||
memcpy(arg.rm_bond_device.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
int esp_bt_gap_get_bond_device_num(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return btc_storage_get_num_bt_bond_devices();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
||||
{
|
||||
int ret;
|
||||
int dev_num_total;
|
||||
|
||||
if (dev_num == NULL || dev_list == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
dev_num_total = btc_storage_get_num_bt_bond_devices();
|
||||
if (*dev_num > dev_num_total) {
|
||||
*dev_num = dev_num_total;
|
||||
}
|
||||
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, *dev_num);
|
||||
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
476
components/bt/bluedroid/api/esp_hf_client_api.c
Normal file
476
components/bt/bluedroid/api/esp_hf_client_api.c
Normal file
@ -0,0 +1,476 @@
|
||||
// Copyright 2018 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.
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_hf_client_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_hf_client.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
esp_err_t esp_hf_client_register_callback(esp_hf_client_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_HF_CLIENT, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_init(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_INIT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_deinit(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DEINIT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_connect(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_CONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.connect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_disconnect(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DISCONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.disconnect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_connect_audio(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_CONNECT_AUDIO_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.connect_audio), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_disconnect_audio(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DISCONNECT_AUDIO_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.disconnect_audio), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_hf_client_start_voice_recognition(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_START_VOICE_RECOGNITION_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_stop_voice_recognition(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_STOP_VOICE_RECOGNITION_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_volume_update(esp_hf_volume_control_target_t type, int volume)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_VOLUME_UPDATE_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.volume_update.type = type;
|
||||
arg.volume_update.volume = volume;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_dial(const char *number)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
if (number != NULL && strlen(number) > ESP_BT_HF_CLIENT_NUMBER_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DIAL_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
if (number != NULL) {
|
||||
strcpy(arg.dial.number, number);
|
||||
} else {
|
||||
arg.dial.number[0] = '\0';
|
||||
}
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_dial_memory(int location)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DIAL_MEMORY_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.dial_memory.location = location;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_send_chld_cmd(esp_hf_chld_type_t chld, int idx)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_SEND_CHLD_CMD_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.chld.type = chld;
|
||||
arg.chld.idx = idx;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_send_btrh_cmd(esp_hf_btrh_cmd_t btrh)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_SEND_BTRH_CMD_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.btrh.cmd = btrh;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_answer_call(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_ANSWER_CALL_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_reject_call(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_REJECT_CALL_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_query_current_calls(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_QUERY_CURRENT_CALLS_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_query_current_operator_name(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_QUERY_CURRENT_OPERATOR_NAME_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_retrieve_subscriber_info(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_RETRIEVE_SUBSCRIBER_INFO_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_send_dtmf(char code)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_SEND_DTMF_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.send_dtmf.code = code;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_request_last_voice_tag_number(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_REQUEST_LAST_VOICE_TAG_NUMBER_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t recv,
|
||||
esp_hf_client_outgoing_data_cb_t send)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_REGISTER_DATA_CALLBACK_EVT;
|
||||
|
||||
btc_hf_client_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.reg_data_cb.recv = recv;
|
||||
arg.reg_data_cb.send = send;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
void esp_hf_client_outgoing_data_ready(void)
|
||||
{
|
||||
BTA_HfClientCiData();
|
||||
}
|
||||
|
||||
void esp_hf_client_pcm_resample_init(uint32_t src_sps, uint32_t bits, uint32_t channels)
|
||||
{
|
||||
BTA_DmPcmInitSamples(src_sps, bits, channels);
|
||||
}
|
||||
|
||||
int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst)
|
||||
{
|
||||
return BTA_DmPcmResample(src, in_bytes, dst);
|
||||
}
|
||||
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
|
||||
#endif /* BTC_HF_CLIENT_INCLUDED */
|
@ -168,8 +168,7 @@ esp_err_t esp_spp_vfs_register()
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
btc_spp_vfs_register();
|
||||
return ESP_OK;
|
||||
return btc_spp_vfs_register();
|
||||
}
|
||||
|
||||
#endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
|
||||
|
@ -44,7 +44,7 @@ const uint8_t *esp_bt_dev_get_address(void);
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_ARG : if name is NULL pointer or empty, or string length out of limit
|
||||
* - ESP_INVALID_STATE : if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_STATE : if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL : others
|
||||
*/
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name);
|
||||
|
@ -66,6 +66,66 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
|
||||
#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */ /* relate to BTM_IO_CAP_IN in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */ /* relate to BTM_IO_CAP_NONE in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ /* relate to BTM_IO_CAP_KBDISP in stack/btm_api.h */
|
||||
|
||||
#define ESP_BLE_APPEARANCE_UNKNOWN 0x0000 /* relate to BTM_BLE_APPEARANCE_UNKNOWN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PHONE 0x0040 /* relate to BTM_BLE_APPEARANCE_GENERIC_PHONE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080 /* relate to BTM_BLE_APPEARANCE_GENERIC_COMPUTER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_WATCH 0x00C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_WATCH in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_SPORTS_WATCH 0x00C1 /* relate to BTM_BLE_APPEARANCE_SPORTS_WATCH in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_CLOCK 0x0100 /* relate to BTM_BLE_APPEARANCE_GENERIC_CLOCK in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140 /* relate to BTM_BLE_APPEARANCE_GENERIC_DISPLAY in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_REMOTE 0x0180 /* relate to BTM_BLE_APPEARANCE_GENERIC_REMOTE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_TAG 0x0200 /* relate to BTM_BLE_APPEARANCE_GENERIC_TAG in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_KEYRING 0x0240 /* relate to BTM_BLE_APPEARANCE_GENERIC_KEYRING in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 /* relate to BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300 /* relate to BTM_BLE_APPEARANCE_GENERIC_THERMOMETER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_THERMOMETER_EAR 0x0301 /* relate to BTM_BLE_APPEARANCE_THERMOMETER_EAR in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340 /* relate to BTM_BLE_APPEARANCE_GENERIC_HEART_RATE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HEART_RATE_BELT 0x0341 /* relate to BTM_BLE_APPEARANCE_HEART_RATE_BELT in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 /* relate to BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 /* relate to BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 /* relate to BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_HID 0x03C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_HID in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_KEYBOARD 0x03C1 /* relate to BTM_BLE_APPEARANCE_HID_KEYBOARD in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_MOUSE 0x03C2 /* relate to BTM_BLE_APPEARANCE_HID_MOUSE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_JOYSTICK 0x03C3 /* relate to BTM_BLE_APPEARANCE_HID_JOYSTICK in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_GAMEPAD 0x03C4 /* relate to BTM_BLE_APPEARANCE_HID_GAMEPAD in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5 /* relate to BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_CARD_READER 0x03C6 /* relate to BTM_BLE_APPEARANCE_HID_CARD_READER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7 /* relate to BTM_BLE_APPEARANCE_HID_DIGITAL_PEN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8 /* relate to BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400 /* relate to BTM_BLE_APPEARANCE_GENERIC_GLUCOSE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_WALKING 0x0440 /* relate to BTM_BLE_APPEARANCE_GENERIC_WALKING in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441 /* relate to BTM_BLE_APPEARANCE_WALKING_IN_SHOE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442 /* relate to BTM_BLE_APPEARANCE_WALKING_ON_SHOE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_WALKING_ON_HIP 0x0443 /* relate to BTM_BLE_APPEARANCE_WALKING_ON_HIP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_CYCLING 0x0480 /* relate to BTM_BLE_APPEARANCE_GENERIC_CYCLING in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481 /* relate to BTM_BLE_APPEARANCE_CYCLING_COMPUTER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_SPEED 0x0482 /* relate to BTM_BLE_APPEARANCE_CYCLING_SPEED in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 /* relate to BTM_BLE_APPEARANCE_CYCLING_CADENCE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_POWER 0x0484 /* relate to BTM_BLE_APPEARANCE_CYCLING_POWER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 /* relate to BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 /* relate to BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 /* relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 /* relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80 /* relate to BTM_BLE_APPEARANCE_GENERIC_WEIGHT in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE 0x0CC0 /* relate to BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_POWERED_WHEELCHAIR 0x0CC1 /* relate to BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_MOBILITY_SCOOTER 0x0CC2 /* relate to BTM_BLE_APPEARANCE_MOBILITY_SCOOTER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR 0x0D00 /* relate to BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_INSULIN_PUMP 0x0D40 /* relate to BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP 0x0D41 /* relate to BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP 0x0D44 /* relate to BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_INSULIN_PEN 0x0D48 /* relate to BTM_BLE_APPEARANCE_INSULIN_PEN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY 0x0D80 /* relate to BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440 /* relate to BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV in stack/btm_ble_api.h */
|
||||
|
||||
typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */
|
||||
|
||||
/// GAP BLE callback event type
|
||||
@ -264,6 +324,13 @@ typedef enum {
|
||||
3. directed advertising packets addressed to this device.*/
|
||||
} esp_ble_scan_filter_t;
|
||||
|
||||
/// Ble scan duplicate type
|
||||
typedef enum {
|
||||
BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */
|
||||
BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */
|
||||
BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */
|
||||
} esp_ble_scan_duplicate_t;
|
||||
|
||||
/// Ble scan parameters
|
||||
typedef struct {
|
||||
esp_ble_scan_type_t scan_type; /*!< Scan type */
|
||||
@ -279,6 +346,9 @@ typedef struct {
|
||||
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
|
||||
Time = N * 0.625 msec
|
||||
Time Range: 2.5 msec to 10240 msec */
|
||||
esp_ble_scan_duplicate_t scan_duplicate; /*!< The Scan_Duplicates parameter controls whether the Link Layer should filter out
|
||||
duplicate advertising reports (BLE_SCAN_DUPLICATE_ENABLE) to the Host, or if the Link Layer should generate
|
||||
advertising reports for each packet received */
|
||||
} esp_ble_scan_params_t;
|
||||
|
||||
/// Connection update parameters
|
||||
@ -777,11 +847,11 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
/**
|
||||
* @brief set local gap appearance icon
|
||||
*
|
||||
*
|
||||
* @param[in] icon - Appearance value, these vlues are Defined by the Bluetooth organization, please refer to
|
||||
*
|
||||
* @param[in] icon - External appearance value, these values are defined by the Bluetooth SIG, please refer to
|
||||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.gap.appearance.xml
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
@ -996,7 +1066,7 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
* It will return the device bonded number immediately.
|
||||
*
|
||||
* @return - >= 0 : bonded devices number.
|
||||
* - < 0 : failed
|
||||
* - ESP_FAIL : failed
|
||||
*
|
||||
*/
|
||||
int esp_ble_get_bond_device_num(void);
|
||||
|
@ -23,13 +23,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// RSSI threshold
|
||||
#define ESP_BT_GAP_RSSI_HIGH_THRLD -20 /*!< High RSSI threshold */
|
||||
#define ESP_BT_GAP_RSSI_LOW_THRLD -45 /*!< Low RSSI threshold */
|
||||
|
||||
/// Class of device
|
||||
typedef struct {
|
||||
uint32_t reserved_2: 2; /*!< undefined */
|
||||
uint32_t minor: 6; /*!< minor class */
|
||||
uint32_t major: 5; /*!< major class */
|
||||
uint32_t service: 11; /*!< service class */
|
||||
uint32_t reserved_8: 8; /*!< undefined */
|
||||
uint32_t reserved_2: 2; /*!< undefined */
|
||||
uint32_t minor: 6; /*!< minor class */
|
||||
uint32_t major: 5; /*!< major class */
|
||||
uint32_t service: 11; /*!< service class */
|
||||
uint32_t reserved_8: 8; /*!< undefined */
|
||||
} esp_bt_cod_t;
|
||||
|
||||
/// class of device settings
|
||||
@ -144,6 +148,9 @@ typedef enum {
|
||||
ESP_BT_GAP_DISC_STATE_CHANGED_EVT, /*!< discovery state changed event */
|
||||
ESP_BT_GAP_RMT_SRVCS_EVT, /*!< get remote services event */
|
||||
ESP_BT_GAP_RMT_SRVC_REC_EVT, /*!< get remote service record event */
|
||||
ESP_BT_GAP_AUTH_CMPL_EVT, /*!< AUTH complete event */
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
/** Inquiry Mode */
|
||||
@ -192,6 +199,23 @@ typedef union {
|
||||
esp_bt_status_t stat; /*!< service search status */
|
||||
} rmt_srvc_rec; /*!< specific service record from remote device parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_READ_RSSI_DELTA_EVT *
|
||||
*/
|
||||
struct read_rssi_delta_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< read rssi status */
|
||||
int8_t rssi_delta; /*!< rssi delta value range -128 ~127, The value zero indicates that the RSSI is inside the Golden Receive Power Range, the Golden Receive Power Range is from ESP_BT_GAP_RSSI_LOW_THRLD to ESP_BT_GAP_RSSI_HIGH_THRLD */
|
||||
} read_rssi_delta; /*!< read rssi parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_AUTH_CMPL_EVT
|
||||
*/
|
||||
struct auth_cmpl_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< authentication complete status */
|
||||
uint8_t device_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< device name */
|
||||
} auth_cmpl; /*!< authentication complete parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@ -372,6 +396,57 @@ esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode);
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_cod(esp_bt_cod_t *cod);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read RSSI delta by address after connected. The RSSI value returned by ESP_BT_GAP_READ_RSSI_DELTA_EVT.
|
||||
*
|
||||
*
|
||||
* @param[in] remote_addr - remote device address, corresponding to a certain connection handle.
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_read_rssi_delta(esp_bd_addr_t remote_addr);
|
||||
|
||||
/**
|
||||
* @brief Removes a device from the security database list of
|
||||
* peer device.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer device
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_FAIL : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the device number from the security database list of peer device.
|
||||
* It will return the device bonded number immediately.
|
||||
*
|
||||
* @return - >= 0 : bonded devices number.
|
||||
* - ESP_FAIL : failed
|
||||
*
|
||||
*/
|
||||
int esp_bt_gap_get_bond_device_num(void);
|
||||
|
||||
/**
|
||||
* @brief Get the device from the security database list of peer device.
|
||||
* It will return the device bonded information immediately.
|
||||
* @param[inout] dev_num: Indicate the dev_list array(buffer) size as input.
|
||||
* If dev_num is large enough, it means the actual number as output.
|
||||
* Suggest that dev_num value equal to esp_ble_get_bond_device_num().
|
||||
*
|
||||
* @param[out] dev_list: an array(buffer) of `esp_bd_addr_t` type. Use for storing the bonded devices address.
|
||||
* The dev_list should be allocated by who call this API.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -450,7 +450,8 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t handle; /*!< The include service current attribute handle */
|
||||
uint16_t incl_srvc_s_handle; /*!< The start hanlde of the service which has been included */
|
||||
uint16_t incl_srvc_s_handle; /*!< The start handle of the service which has been included */
|
||||
uint16_t incl_srvc_e_handle; /*!< The end handle of the service which has been included */
|
||||
esp_bt_uuid_t uuid; /*!< The include service uuid */
|
||||
} esp_gattc_incl_svc_elem_t; /*!< The gattc inclue service element */
|
||||
|
||||
|
635
components/bt/bluedroid/api/include/api/esp_hf_client_api.h
Normal file
635
components/bt/bluedroid/api/include/api/esp_hf_client_api.h
Normal file
@ -0,0 +1,635 @@
|
||||
// Copyright 2018 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_HF_CLIENT_API_H__
|
||||
#define __ESP_HF_CLIENT_API_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_hf_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_HF_CLIENT_NUMBER_LEN (32)
|
||||
#define ESP_BT_HF_CLIENT_OPERATOR_NAME_LEN (16)
|
||||
|
||||
/// Bluetooth HFP RFCOMM connection and service level connection status
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0, /*!< RFCOMM data link channel released */
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING, /*!< connecting remote device on the RFCOMM data link*/
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_CONNECTED, /*!< RFCOMM connection established */
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_SLC_CONNECTED, /*!< service level connection established */
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTING, /*!< disconnecting with remote device on the RFCOMM dat link*/
|
||||
} esp_hf_client_connection_state_t;
|
||||
|
||||
/// Bluetooth HFP audio connection status
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED = 0, /*!< audio connection released */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTING, /*!< audio connection has been initiated */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTED, /*!< audio connection is established */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, /*!< mSBC audio connection is estalibshed */
|
||||
} esp_hf_client_audio_state_t;
|
||||
|
||||
/// in-band ring tone state
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0,
|
||||
ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
|
||||
} esp_hf_client_in_band_ring_state_t;
|
||||
|
||||
/* features masks of AG */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_3WAY 0x01 /* Three-way calling */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_ECNR 0x02 /* Echo cancellation and/or noise reduction */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_VREC 0x04 /* Voice recognition */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_INBAND 0x08 /* In-band ring tone */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_VTAG 0x10 /* Attach a phone number to a voice tag */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_REJECT 0x20 /* Ability to reject incoming call */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_ECS 0x40 /* Enhanced Call Status */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */
|
||||
|
||||
/* CHLD feature masks of AG */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_REL_ACC 0x02 /* 1 Release active calls and accept other waiting or held call */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_REL_X 0x04 /* 1x Release specified active call only */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_HOLD_ACC 0x08 /* 2 Active calls on hold and accept other waiting or held call */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_PRIV_X 0x10 /* 2x Request private mode with specified call(put the rest on hold */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_MERGE 0x20 /* 3 Add held call to multiparty */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_MERGE_DETACH 0x40 /* 4 Connect two calls and leave(disconnct from multiparty */
|
||||
|
||||
/// HF CLIENT callback events
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_EVT, /*!< audio connection state change event */
|
||||
ESP_HF_CLIENT_BVRA_EVT, /*!< voice recognition state change event */
|
||||
ESP_HF_CLIENT_CIND_CALL_EVT, /*!< call indication */
|
||||
ESP_HF_CLIENT_CIND_CALL_SETUP_EVT, /*!< call setup indication */
|
||||
ESP_HF_CLIENT_CIND_CALL_HELD_EVT, /*!< call held indication */
|
||||
ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT, /*!< network service availability indication */
|
||||
ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT, /*!< signal strength indication */
|
||||
ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT, /*!< roaming status indication */
|
||||
ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT, /*!< battery level indication */
|
||||
ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT, /*!< current operator information */
|
||||
ESP_HF_CLIENT_BTRH_EVT, /*!< call response and hold event */
|
||||
ESP_HF_CLIENT_CLIP_EVT, /*!< Calling Line Identification notification */
|
||||
ESP_HF_CLIENT_CCWA_EVT, /*!< call waiting notification */
|
||||
ESP_HF_CLIENT_CLCC_EVT, /*!< list of current calls notification */
|
||||
ESP_HF_CLIENT_VOLUME_CONTROL_EVT, /*!< audio volume control command from AG, provided by +VGM or +VGS message */
|
||||
ESP_HF_CLIENT_AT_RESPONSE_EVT, /*!< AT command response event */
|
||||
ESP_HF_CLIENT_CNUM_EVT, /*!< subscriber information response from AG */
|
||||
ESP_HF_CLIENT_BSIR_EVT, /*!< setting of in-band ring tone */
|
||||
ESP_HF_CLIENT_BINP_EVT, /*!< requested number of last voice tag from AG */
|
||||
ESP_HF_CLIENT_RING_IND_EVT, /*!< ring indication event */
|
||||
} esp_hf_client_cb_event_t;
|
||||
|
||||
/// HFP client callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CONNECTION_STATE_EVT
|
||||
*/
|
||||
struct hf_client_conn_stat_param {
|
||||
esp_hf_client_connection_state_t state; /*!< HF connection state */
|
||||
uint32_t peer_feat; /*!< AG supported features */
|
||||
uint32_t chld_feat; /*!< AG supported features on call hold and multiparty services */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} conn_stat; /*!< HF callback param of ESP_HF_CLIENT_CONNECTION_STATE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_AUDIO_STATE_EVT
|
||||
*/
|
||||
struct hf_client_audio_stat_param {
|
||||
esp_hf_client_audio_state_t state; /*!< audio connection state */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} audio_stat; /*!< HF callback param of ESP_HF_CLIENT_AUDIO_STATE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BVRA_EVT
|
||||
*/
|
||||
struct hf_client_bvra_param {
|
||||
esp_hf_vr_state_t value; /*!< voice recognition state */
|
||||
} bvra; /*!< HF callback param of ESP_HF_CLIENT_BVRA_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT
|
||||
*/
|
||||
struct hf_client_service_availability_param {
|
||||
esp_hf_service_availability_status_t status; /*!< service availability status */
|
||||
} service_availability; /*!< HF callback param of ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT
|
||||
*/
|
||||
struct hf_client_network_roaming_param {
|
||||
esp_hf_roaming_status_t status; /*!< roaming status */
|
||||
} roaming; /*!< HF callback param of ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT
|
||||
*/
|
||||
struct hf_client_signal_strength_ind_param {
|
||||
int value; /*!< singal strength value, ranges from 0 to 5 */
|
||||
} signal_strength; /*!< HF callback param of ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT
|
||||
*/
|
||||
struct hf_client_battery_level_ind_param {
|
||||
int value; /*!< battery charge value, ranges from 0 to 5 */
|
||||
} battery_level; /*!< HF callback param of ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT
|
||||
*/
|
||||
struct hf_client_current_operator_param {
|
||||
const char *name; /*!< name of the network operator */
|
||||
} cops; /*!< HF callback param of ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_CALL_EVT
|
||||
*/
|
||||
struct hf_client_call_ind_param {
|
||||
esp_hf_call_status_t status; /*!< call status indicator */
|
||||
} call; /*!< HF callback param of ESP_HF_CLIENT_CIND_CALL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_CALL_SETUP_EVT
|
||||
*/
|
||||
struct hf_client_call_setup_ind_param {
|
||||
esp_hf_call_setup_status_t status; /*!< call setup status indicator */
|
||||
} call_setup; /*!< HF callback param of ESP_HF_CLIENT_BVRA_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_CALL_HELD_EVT
|
||||
*/
|
||||
struct hf_client_call_held_ind_param {
|
||||
esp_hf_call_held_status_t status; /*!< bluetooth proprietary call hold status indocator */
|
||||
} call_held; /*!< HF callback param of ESP_HF_CLIENT_CIND_CALL_HELD_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BTRH_EVT
|
||||
*/
|
||||
struct hf_client_btrh_param {
|
||||
esp_hf_btrh_status_t status; /*!< call hold and response status result code */
|
||||
} btrh; /*!< HF callback param of ESP_HF_CLIENT_BRTH_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CLIP_EVT
|
||||
*/
|
||||
struct hf_client_clip_param {
|
||||
const char *number; /*!< phone number string of call */
|
||||
} clip; /*!< HF callback param of ESP_HF_CLIENT_CLIP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CCWA_EVT
|
||||
*/
|
||||
struct hf_client_ccwa_param {
|
||||
const char *number; /*!< phone number string of waiting call */
|
||||
} ccwa; /*!< HF callback param of ESP_HF_CLIENT_BVRA_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CLCC_EVT
|
||||
*/
|
||||
struct hf_client_clcc_param {
|
||||
int idx; /*!< numbering(starting with 1) of the call */
|
||||
esp_hf_current_call_direction_t dir; /*!< direction of the call */
|
||||
esp_hf_current_call_status_t status; /*!< status of the call */
|
||||
esp_hf_current_call_mpty_type_t mpty; /*!< multi-party flag */
|
||||
char *number; /*!< phone number(optional) */
|
||||
} clcc; /*!< HF callback param of ESP_HF_CLIENT_CLCC_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_VOLUME_CONTROL_EVT
|
||||
*/
|
||||
struct hf_client_volume_control_param {
|
||||
esp_hf_volume_control_target_t type; /*!< volume control target, speaker or microphone */
|
||||
int volume; /*!< gain, ranges from 0 to 15 */
|
||||
} volume_control; /*!< HF callback param of ESP_HF_CLIENT_VOLUME_CONTROL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_AT_RESPONSE_EVT
|
||||
*/
|
||||
struct hf_client_at_response_param {
|
||||
esp_hf_at_response_code_t code; /*!< AT response code */
|
||||
esp_hf_cme_err_t cme; /*!< Extended Audio Gateway Error Result Code */
|
||||
} at_response; /*!< HF callback param of ESP_HF_CLIENT_AT_RESPONSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CNUM_EVT
|
||||
*/
|
||||
struct hf_client_cnum_param {
|
||||
const char *number; /*!< phone number string */
|
||||
esp_hf_subscriber_service_type_t type; /*!< service type that the phone number relates to */
|
||||
} cnum; /*!< HF callback param of ESP_HF_CLIENT_CNUM_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BSIR_EVT
|
||||
*/
|
||||
struct hf_client_bsirparam {
|
||||
esp_hf_client_in_band_ring_state_t state; /*!< setting state of in-band ring tone */
|
||||
} bsir; /*!< HF callback param of ESP_HF_CLIENT_BSIR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BINP_EVT
|
||||
*/
|
||||
struct hf_client_binp_param {
|
||||
const char *number; /*!< phone number corresponding to the last voice tag in the HF */
|
||||
} binp; /*!< HF callback param of ESP_HF_CLIENT_BINP_EVT */
|
||||
|
||||
} esp_hf_client_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief HFP client incoming data callback function, the callback is useful in case of
|
||||
* Voice Over HCI.
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*/
|
||||
typedef void (* esp_hf_client_incoming_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief HFP client outgoing data callback function, the callback is useful in case of
|
||||
* Voice Over HCI. Once audio connection is set up and the application layer has
|
||||
* prepared data to send, the lower layer will call this function to read data
|
||||
* and then send. This callback is supposed to be implemented as non-blocking,
|
||||
* and if data is not enough, return value 0 is supposed.
|
||||
*
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
* @param[out] length of data successfully read
|
||||
*/
|
||||
typedef uint32_t (* esp_hf_client_outgoing_data_cb_t)(uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief HFP client callback function type
|
||||
*
|
||||
* @param event : Event type
|
||||
*
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_hf_client_cb_t)(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to HFP client module. This function should be called
|
||||
* only after esp_bluedroid_enable() completes successfully, used by HFP client
|
||||
*
|
||||
* @param[in] callback: HFP client event callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_register_callback(esp_hf_client_cb_t callback);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth HFP client module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for HFP client module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect to remote bluetooth HFP audio gateway(AG) device, must after esp_a2d_hf_client_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: connect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect from the remote HFP audio gateway
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Create audio connection with remote HFP AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_connect_audio(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Release the established audio connection with remote HFP AG.
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_disconnect_audio(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Enable voice recognition in the AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_start_voice_recognition(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disable voice recognition in the AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_stop_voice_recognition(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Volume synchronization with AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] type: volume control target, speaker or microphone
|
||||
* @param[in] volume: gain of the speaker of microphone, ranges 0 to 15
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_volume_update(esp_hf_volume_control_target_t type, int volume);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Place a call with a specified number, if number is NULL, last called number is
|
||||
* called. As a precondition to use this API, Service Level Connection shall
|
||||
* exist with AG
|
||||
*
|
||||
* @param[in] number: number string of the call. If NULL, the last number is called(aka re-dial)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_dial(const char *number);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Place a call with number specified by location(speed dial). As a precondition,
|
||||
* to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] location: location of the number in the memory
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
|
||||
esp_err_t esp_hf_client_dial_memory(int location);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Send call hold and multiparty commands, or enhanced call control commands(Use AT+CHLD).
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] chld: AT+CHLD call hold and multiparty handling AT command.
|
||||
* @param[in] idx: used in Enhanced Call Control Mechanisms, used if chld is
|
||||
* ESP_HF_CHLD_TYPE_REL_X or ESP_HF_CHLD_TYPE_PRIV_X
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_send_chld_cmd(esp_hf_chld_type_t chld, int idx);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Send response and hold action command(Send AT+BTRH command)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] btrh: response and hold action to send
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_send_btrh_cmd(esp_hf_btrh_cmd_t btrh);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Answer an incoming call(send ATA command). As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_answer_call(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Reject an incoming call(send AT+CHUP command), As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_reject_call(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Query list of current calls in AG(send AT+CLCC command), As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_query_current_calls(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Query the name of currently selected network operator in AG(use AT+COPS commands)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_query_current_operator_name(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get subscriber information number from AG(send AT+CNUM command)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_retrieve_subscriber_info(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Transmit DTMF codes during an ongoing call(use AT+VTS commands)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] code: dtmf code, single ascii character in the set 0-9, #, *, A-D
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_send_dtmf(char code);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Request a phone number from AG corresponding to last voice tag recorded
|
||||
* (send AT+BINP command). As a precondition to use this API, Service Level
|
||||
* Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_request_last_voice_tag_number(void);
|
||||
|
||||
/**
|
||||
* @brief Register HFP client data output function; the callback is only used in
|
||||
* the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] recv: HFP client incoming data callback function
|
||||
* @param[in] send: HFP client outgoing data callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t recv,
|
||||
esp_hf_client_outgoing_data_cb_t send);
|
||||
|
||||
/**
|
||||
* @brief Trigger the lower-layer to fetch and send audio data. This function is only
|
||||
* only used in the case that Voice Over HCI is enabled. Precondition is that
|
||||
* the HFP audio connection is connected. After this function is called, lower
|
||||
* layer will invoke esp_hf_client_outgoing_data_cb_t to fetch data
|
||||
*
|
||||
*/
|
||||
void esp_hf_client_outgoing_data_ready(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the down sampling converter. This is a utility function that can
|
||||
* only be used in the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] src_sps: original samples per second(source audio data, i.e. 48000, 32000,
|
||||
* 16000, 44100, 22050, 11025)
|
||||
* @param[in] bits: number of bits per pcm sample (16)
|
||||
* @param[in] channels: number of channels (i.e. mono(1), stereo(2)...)
|
||||
*/
|
||||
void esp_hf_client_pcm_resample_init(uint32_t src_sps, uint32_t bits, uint32_t channels);
|
||||
|
||||
/**
|
||||
* @brief Down sampling utility to convert high sampling rate into 8K/16bits 1-channel mode PCM
|
||||
* samples. This can only be used in the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] src: pointer to the buffer where the original smapling PCM are stored
|
||||
* @param[in] in_bytes: length of the input PCM sample buffer in byte
|
||||
* @param[in] dst: pointer to the buffer which is to be used to store the converted PCM samples
|
||||
*
|
||||
* @return number of samples converted
|
||||
*/
|
||||
int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_HF_CLIENT_API_H__ */
|
181
components/bt/bluedroid/api/include/api/esp_hf_defs.h
Normal file
181
components/bt/bluedroid/api/include/api/esp_hf_defs.h
Normal file
@ -0,0 +1,181 @@
|
||||
// Copyright 2018 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_HF_DEFS_H__
|
||||
#define __ESP_HF_DEFS_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/// Bluetooth HFP audio volume control target
|
||||
typedef enum {
|
||||
ESP_HF_VOLUME_CONTROL_TARGET_SPK = 0, /*!< speaker */
|
||||
ESP_HF_VOLUME_CONTROL_TARGET_MIC, /*!< microphone */
|
||||
} esp_hf_volume_control_target_t;
|
||||
|
||||
/// +CIND roaming status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_ROAMING_STATUS_INACTIVE = 0, /*!< roaming is not active */
|
||||
ESP_HF_ROAMING_STATUS_ACTIVE, /*!< a roaming is active */
|
||||
} esp_hf_roaming_status_t;
|
||||
|
||||
/// +CIND call status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_STATUS_NO_CALLS = 0, /*!< no call in progress */
|
||||
ESP_HF_CALL_STATUS_CALL_IN_PROGRESS = 1, /*!< call is present(active or held) */
|
||||
} esp_hf_call_status_t;
|
||||
|
||||
/// +CIND call setup status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_SETUP_STATUS_NONE = 0, /*!< no call setup in progress */
|
||||
ESP_HF_CALL_SETUP_STATUS_INCOMING = 1, /*!< incoming call setup in progress */
|
||||
ESP_HF_CALL_SETUP_STATUS_OUTGOING_DIALING = 2, /*!< outgoing call setup in dialing state */
|
||||
ESP_HF_CALL_SETUP_STATUS_OUTGOING_ALERTING = 3, /*!< outgoing call setup in alerting state */
|
||||
} esp_hf_call_setup_status_t;
|
||||
|
||||
/// +CIND call held indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_HELD_STATUS_NONE = 0, /*!< no calls held */
|
||||
ESP_HF_CALL_HELD_STATUS_HELD_AND_ACTIVE = 1, /*!< both active and held call */
|
||||
ESP_HF_CALL_HELD_STATUS_HELD = 2, /*!< call on hold, no active call*/
|
||||
} esp_hf_call_held_status_t;
|
||||
|
||||
/// +CIND network service availability status
|
||||
typedef enum {
|
||||
ESP_HF_SERVICE_AVAILABILITY_STATUS_UNAVAILABLE = 0, /*!< service not available */
|
||||
ESP_HF_SERVICE_AVAILABILITY_STATUS_AVAILABLE, /*!< service available */
|
||||
} esp_hf_service_availability_status_t;
|
||||
|
||||
/// +CLCC status of the call
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_STATUS_ACTIVE = 0, /*!< active */
|
||||
ESP_HF_CURRENT_CALL_STATUS_HELD = 1, /*!< held */
|
||||
ESP_HF_CURRENT_CALL_STATUS_DIALING = 2, /*!< dialing (outgoing calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_ALERTING = 3, /*!< alerting (outgoing calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_INCOMING = 4, /*!< incoming (incoming calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_WAITING = 5, /*!< waiting (incoming calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_HELD_BY_RESP_HOLD = 6, /*!< call held by response and hold */
|
||||
} esp_hf_current_call_status_t;
|
||||
|
||||
/// +CLCC direction of the call
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_DIRECTION_OUTGOING = 0, /*!< outgoing */
|
||||
ESP_HF_CURRENT_CALL_DIRECTION_INCOMING = 1, /*!< incoming */
|
||||
} esp_hf_current_call_direction_t;
|
||||
|
||||
/// +CLCC multi-party call flag
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_MPTY_TYPE_SINGLE = 0, /*!< not a member of a multi-party call */
|
||||
ESP_HF_CURRENT_CALL_MPTY_TYPE_MULTI = 1, /*!< member of a multi-party call */
|
||||
} esp_hf_current_call_mpty_type_t;
|
||||
|
||||
/// +CLCC call mode
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_MODE_VOICE = 0,
|
||||
ESP_HF_CURRENT_CALL_MODE_DATA = 1,
|
||||
ESP_HF_CURRENT_CALL_MODE_FAX = 2,
|
||||
} esp_hf_current_call_mode_t;
|
||||
|
||||
/// +CLCC address type
|
||||
typedef enum {
|
||||
ESP_HF_CALL_ADDR_TYPE_UNKNOWN = 0x81, /*!< unkown address type */
|
||||
ESP_HF_CALL_ADDR_TYPE_INTERNATIONAL = 0x91, /*!< international address */
|
||||
} esp_hf_call_addr_type_t;
|
||||
|
||||
/// +CNUM service type of the phone number
|
||||
typedef enum {
|
||||
ESP_HF_SUBSCRIBER_SERVICE_TYPE_UNKNOWN = 0, /*!< unknown */
|
||||
ESP_HF_SUBSCRIBER_SERVICE_TYPE_VOICE, /*!< voice service */
|
||||
ESP_HF_SUBSCRIBER_SERVICE_TYPE_FAX, /*!< fax service */
|
||||
} esp_hf_subscriber_service_type_t;
|
||||
|
||||
/// +BTRH response and hold result code
|
||||
typedef enum {
|
||||
ESP_HF_BTRH_STATUS_HELD = 0, /*!< incoming call is put on held in AG */
|
||||
ESP_HF_BTRH_STATUS_ACCEPTED, /*!< held incoming call is accepted in AG */
|
||||
ESP_HF_BTRH_STATUS_REJECTED, /*!< held incoming call is rejected in AG */
|
||||
} esp_hf_btrh_status_t;
|
||||
|
||||
/// AT+BTRH response and hold action code
|
||||
typedef enum {
|
||||
ESP_HF_BTRH_CMD_HOLD = 0, /*!< put the incoming call on hold */
|
||||
ESP_HF_BTRH_CMD_ACCEPT = 1, /*!< accept a held incoming call */
|
||||
ESP_HF_BTRH_CMD_REJECT = 2, /*!< reject a held incoming call */
|
||||
} esp_hf_btrh_cmd_t;
|
||||
|
||||
/// response indication codes for AT commands
|
||||
typedef enum {
|
||||
ESP_HF_AT_RESPONSE_CODE_OK = 0, /*!< acknoweledges execution of a command line */
|
||||
ESP_HF_AT_RESPONSE_CODE_ERR, /*!< command not accepted */
|
||||
ESP_HF_AT_RESPONSE_CODE_NO_CARRIER, /*!< connection terminated */
|
||||
ESP_HF_AT_RESPONSE_CODE_BUSY, /*!< busy signal detected */
|
||||
ESP_HF_AT_RESPONSE_CODE_NO_ANSWER, /*!< connection completion timeout */
|
||||
ESP_HF_AT_RESPONSE_CODE_DELAYED, /*!< delayed */
|
||||
ESP_HF_AT_RESPONSE_CODE_BLACKLISTED, /*!< blacklisted */
|
||||
ESP_HF_AT_RESPONSE_CODE_CME, /*!< CME error */
|
||||
} esp_hf_at_response_code_t;
|
||||
|
||||
/// voice recognition state
|
||||
typedef enum {
|
||||
ESP_HF_VR_STATE_DISABLED = 0, /*!< voice recognition disabled */
|
||||
ESP_HF_VR_STATE_ENABLED, /*!< voice recognition enabled */
|
||||
} esp_hf_vr_state_t;
|
||||
|
||||
/// AT+CHLD command values
|
||||
typedef enum {
|
||||
ESP_HF_CHLD_TYPE_REL = 0, /*!< <0>, Terminate all held or set UDUB("busy") to a waiting call */
|
||||
ESP_HF_CHLD_TYPE_REL_ACC, /*!< <1>, Terminate all active calls and accepts a waiting/held call */
|
||||
ESP_HF_CHLD_TYPE_HOLD_ACC, /*!< <2>, Hold all active calls and accepts a waiting/held call */
|
||||
ESP_HF_CHLD_TYPE_MERGE, /*!< <3>, Add all held calls to a conference */
|
||||
ESP_HF_CHLD_TYPE_MERGE_DETACH, /*!< <4>, connect the two calls and disconnects the subscriber from both calls */
|
||||
ESP_HF_CHLD_TYPE_REL_X, /*!< <1x>, releases specified calls only */
|
||||
ESP_HF_CHLD_TYPE_PRIV_X, /*!< <2x>, request private consultation mode with specified call */
|
||||
} esp_hf_chld_type_t;
|
||||
|
||||
/// Extended Audio Gateway Error Result Code Response
|
||||
typedef enum {
|
||||
ESP_HF_CME_AG_FAILURE = 0, /*!< ag failure */
|
||||
ESP_HF_CME_NO_CONNECTION_TO_PHONE = 1, /*!< no connection to phone */
|
||||
ESP_HF_CME_OPERATION_NOT_ALLOWED = 3, /*!< operation not allowed */
|
||||
ESP_HF_CME_OPERATION_NOT_SUPPORTED = 4, /*!< operation not supported */
|
||||
ESP_HF_CME_PH_SIM_PIN_REQUIRED = 5, /*!< PH-SIM PIN Required */
|
||||
ESP_HF_CME_SIM_NOT_INSERTED = 10, /*!< SIM not inserted */
|
||||
ESP_HF_CME_SIM_PIN_REQUIRED = 11, /*!< SIM PIN required */
|
||||
ESP_HF_CME_SIM_PUK_REQUIRED = 12, /*!< SIM PUK required */
|
||||
ESP_HF_CME_SIM_FAILURE = 13, /*!< SIM failure */
|
||||
ESP_HF_CME_SIM_BUSY = 14, /*!< SIM busy */
|
||||
ESP_HF_CME_INCORRECT_PASSWORD = 16, /*!< incorrect password */
|
||||
ESP_HF_CME_SIM_PIN2_REQUIRED = 17, /*!< SIM PIN2 required */
|
||||
ESP_HF_CME_SIM_PUK2_REQUIRED = 18, /*!< SIM PUK2 required */
|
||||
ESP_HF_CME_MEMEORY_FULL = 20, /*!< memory full */
|
||||
ESP_HF_CME_INVALID_INDEX = 21, /*!< invalid index */
|
||||
ESP_HF_CME_MEMEORY_FAILURE = 23, /*!< memory failure */
|
||||
ESP_HF_CME_TEXT_STRING_TOO_LONG = 24, /*!< test string too long */
|
||||
ESP_HF_CME_INVALID_CHARACTERS_IN_TEXT_STRING = 25, /*!< invalid characters in text string */
|
||||
ESP_HF_CME_DIAL_STRING_TOO_LONG = 26, /*!< dial string too long*/
|
||||
ESP_HF_CME_INVALID_CHARACTERS_IN_DIAL_STRING = 27, /*!< invalid characters in dial string */
|
||||
ESP_HF_CME_NO_NETWORK_SERVICE = 30, /*!< no network service */
|
||||
ESP_HF_CME_NETWORK_TIMEOUT = 31, /*!< network timeout */
|
||||
ESP_HF_CME_NETWORK_NOT_ALLOWED = 32, /*!< network not allowed --emergency calls only */
|
||||
} esp_hf_cme_err_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_HF_DEFS_H__ */
|
@ -396,9 +396,7 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
#endif
|
||||
/* hw is ready, go on with BTA DM initialization */
|
||||
memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb));
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs));
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
|
||||
|
||||
memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class));
|
||||
@ -443,10 +441,12 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
BTM_ReadLocalDeviceNameFromController((tBTM_CMPL_CB *)bta_dm_local_name_cback);
|
||||
|
||||
bta_sys_rm_register((tBTA_SYS_CONN_CBACK *)bta_dm_rm_cback);
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* initialize bluetooth low power manager */
|
||||
bta_dm_init_pm();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
bta_sys_policy_register((tBTA_SYS_CONN_CBACK *)bta_dm_policy_cback);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
@ -483,9 +483,11 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
|
||||
|
||||
BTM_SetDiscoverability(BTM_NON_DISCOVERABLE, 0, 0);
|
||||
BTM_SetConnectability(BTM_NON_CONNECTABLE, 0, 0);
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
bta_dm_disable_pm();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
bta_dm_disable_search_and_disc();
|
||||
bta_dm_cb.disabling = TRUE;
|
||||
|
||||
@ -1070,12 +1072,12 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
|
||||
p_dev->link_policy &= (~policy);
|
||||
BTM_SetLinkPolicy(p_dev->peer_bdaddr, &(p_dev->link_policy));
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
if (policy & (HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)) {
|
||||
/* if clearing sniff/park, wake the link */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_pm_active(p_dev->peer_bdaddr);
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
}
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
break;
|
||||
|
||||
case BTA_SYS_PLCY_DEF_SET:
|
||||
@ -3365,10 +3367,12 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
UNUSED(p_tle);
|
||||
tBTA_SYS_HW_MSG *sys_enable_event;
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* disable the power managment module */
|
||||
bta_dm_disable_pm();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* register our callback to SYS HW manager */
|
||||
bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
|
||||
|
||||
@ -3431,9 +3435,7 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
}
|
||||
/* AV calls bta_sys_conn_open with the A2DP stream count as app_id */
|
||||
if (BTA_ID_AV == id) {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_cb.cur_av_count = bta_dm_get_av_count();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
}
|
||||
} else if ( status == BTA_SYS_CONN_IDLE) {
|
||||
if (p_dev) {
|
||||
@ -3442,9 +3444,7 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
|
||||
/* get cur_av_count from connected services */
|
||||
if (BTA_ID_AV == id) {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_cb.cur_av_count = bta_dm_get_av_count();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
}
|
||||
}
|
||||
APPL_TRACE_EVENT("bta_dm_rm_cback:%d, status:%d", bta_dm_cb.cur_av_count, status);
|
||||
@ -4567,6 +4567,7 @@ void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data)
|
||||
p_data->ble_set_scan_fil_params.scan_window,
|
||||
p_data->ble_set_scan_fil_params.scan_mode,
|
||||
p_data->ble_set_scan_fil_params.addr_type_own,
|
||||
p_data->ble_set_scan_fil_params.scan_duplicate_filter,
|
||||
p_data->ble_set_scan_fil_params.scan_filter_policy,
|
||||
p_data->ble_set_scan_fil_params.scan_param_setup_cback);
|
||||
}
|
||||
@ -4684,9 +4685,9 @@ void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_config_local_privacy
|
||||
** Function bta_dm_ble_config_local_icon
|
||||
**
|
||||
** Description This function set the local device LE privacy settings.
|
||||
** Description This function sets the local icon value.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -5529,7 +5530,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id)
|
||||
APPL_TRACE_ERROR("%s out of room to accomodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used );
|
||||
}
|
||||
|
||||
LOG_INFO("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len);
|
||||
APPL_TRACE_API("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len);
|
||||
if ( bta_dm_search_cb.state != BTA_DM_SEARCH_IDLE) {
|
||||
|
||||
/* send result back to app now, one by one */
|
||||
|
@ -166,7 +166,7 @@ void BTA_DisableTestMode(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetDeviceName(char *p_name)
|
||||
void BTA_DmSetDeviceName(const char *p_name)
|
||||
{
|
||||
|
||||
tBTA_DM_API_SET_NAME *p_msg;
|
||||
@ -968,6 +968,7 @@ void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
** scan_interval - scan interval
|
||||
** scan_window - scan window
|
||||
** scan_mode - scan mode
|
||||
** scan_duplicate_filter - scan duplicate filter
|
||||
** scan_param_setup_status_cback - Set scan param status callback
|
||||
**
|
||||
** Returns void
|
||||
@ -975,7 +976,7 @@ void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy,
|
||||
UINT8 addr_type_own, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
|
||||
UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback)
|
||||
{
|
||||
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS *p_msg;
|
||||
|
||||
@ -987,6 +988,7 @@ void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
p_msg->scan_window = scan_window;
|
||||
p_msg->scan_mode = scan_mode;
|
||||
p_msg->addr_type_own = addr_type_own;
|
||||
p_msg->scan_duplicate_filter = scan_duplicate_filter;
|
||||
p_msg->scan_filter_policy = scan_fil_poilcy;
|
||||
p_msg->scan_param_setup_cback = scan_param_setup_cback;
|
||||
|
||||
|
@ -116,39 +116,24 @@ tBTA_DM_CFG *p_bta_dm_cfg = (tBTA_DM_CFG *) &bta_dm_cfg;
|
||||
tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *) &bta_dm_rm_cfg;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
# define BTA_DM_NUM_PM_ENTRY 21 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 15 /* number of entries in bta_dm_pm_spec */
|
||||
# define BTA_DM_NUM_PM_ENTRY 6 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 6 /* number of entries in bta_dm_pm_spec */
|
||||
#else
|
||||
# define BTA_DM_NUM_PM_ENTRY 19 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 13 /* number of entries in bta_dm_pm_spec */
|
||||
# define BTA_DM_NUM_PM_ENTRY 4 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 4 /* number of entries in bta_dm_pm_spec */
|
||||
#endif
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1] = {
|
||||
{BTA_ID_SYS, BTA_DM_NUM_PM_ENTRY, 0}, /* reserved: specifies length of this table. */
|
||||
{BTA_ID_AG, BTA_ALL_APP_ID, 0}, /* ag uses first spec table for app id 0 */
|
||||
{BTA_ID_CT, 1, 1}, /* ct (BTA_ID_CT,APP ID=1) spec table */
|
||||
{BTA_ID_CG, BTA_ALL_APP_ID, 1}, /* cg resue ct spec table */
|
||||
{BTA_ID_DG, BTA_ALL_APP_ID, 2}, /* dg spec table */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 4}, /* av spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 12}, /* avk spec table */
|
||||
{BTA_ID_FTC, BTA_ALL_APP_ID, 6}, /* ftc spec table */
|
||||
{BTA_ID_FTS, BTA_ALL_APP_ID, 7}, /* fts spec table */
|
||||
{BTA_ID_HD, BTA_ALL_APP_ID, 3}, /* hd spec table */
|
||||
{BTA_ID_HH, BTA_ALL_APP_ID, 5}, /* hh spec table */
|
||||
{BTA_ID_PBC, BTA_ALL_APP_ID, 2}, /* reuse dg spec table */
|
||||
{BTA_ID_PBS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_OPC, BTA_ALL_APP_ID, 6}, /* reuse ftc spec table */
|
||||
{BTA_ID_OPS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
// {BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
|
||||
// {BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_HL, BTA_ALL_APP_ID, 8}, /* reuse fts spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_PANU, 9}, /* PANU spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_NAP, 10}, /* NAP spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 11} /* HS spec table */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 1}, /* av spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 2}, /* HS spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 3} /* avk spec table */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
, {BTA_ID_GATTC, BTA_ALL_APP_ID, 13} /* gattc spec table */
|
||||
, {BTA_ID_GATTS, BTA_ALL_APP_ID, 14} /* gatts spec table */
|
||||
, {BTA_ID_GATTC, BTA_ALL_APP_ID, 4} /* gattc spec table */
|
||||
, {BTA_ID_GATTS, BTA_ALL_APP_ID, 5} /* gatts spec table */
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -173,64 +158,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* CT, CG : 1 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_PARK, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open park */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
|
||||
{{BTA_DM_PM_PARK, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close park */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* DG, PBC : 2 */
|
||||
{
|
||||
(BTA_DM_PM_ACTIVE), /* no power saving mode allowed */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF, 1000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HD : 3 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR3), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_HD_IDLE_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* AV : 4 */
|
||||
/* AV : 1 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@ -249,122 +177,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* HH : 5 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR1), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close, used for HH suspend */
|
||||
{{BTA_DM_PM_SNIFF_HH_IDLE_IDX, BTA_DM_PM_HH_IDLE_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* FTC, OPC, JV : 6 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* FTS, PBS, OPS, MSE, BTA_JV_PM_ID_1 : 7 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HL : 8 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* PANU : 9 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* NAP : 10 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HS : 11 */
|
||||
/* HS : 2 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@ -383,7 +196,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* AVK : 12 */
|
||||
/* AVK : 3 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@ -403,7 +216,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* GATTC : 13 */
|
||||
/* GATTC : 4 */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@ -424,7 +237,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
/* GATTS : 14 */
|
||||
/* GATTS : 5 */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@ -528,6 +341,8 @@ tBTA_DM_PM_CFG *p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG *) &bta_dm_pm_cfg;
|
||||
tBTA_DM_PM_SPEC *p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC *) &bta_dm_pm_spec;
|
||||
tBTM_PM_PWR_MD *p_bta_dm_pm_md = (tBTM_PM_PWR_MD *) &bta_dm_pm_md;
|
||||
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* The performance impact of EIR packet size
|
||||
**
|
||||
** When BTM_EIR_DEFAULT_FEC_REQUIRED is TRUE,
|
||||
|
@ -83,32 +83,3 @@ void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16
|
||||
}
|
||||
}
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_ci_data_ready
|
||||
**
|
||||
** Description This function sends an event to indicating that the phone
|
||||
** has SCO data ready.
|
||||
**
|
||||
** Parameters event: is obtained from bta_dm_sco_co_open() function, which
|
||||
** is the BTA event we want to send back to BTA module
|
||||
** when there is encoded data ready.
|
||||
** sco_handle: is the BTA sco handle which indicate a specific
|
||||
** SCO connection.
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = event;
|
||||
p_buf->layer_specific = sco_handle;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -205,149 +205,6 @@ void bta_dm_co_rmt_oob(BD_ADDR bd_addr)
|
||||
|
||||
// REMOVE FOR BLUEDROID ?
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE ) && (BTM_SCO_INCLUDED == TRUE)
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btui_sco_codec_callback
|
||||
**
|
||||
** Description Callback for btui codec.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void btui_sco_codec_callback(UINT16 event, UINT16 sco_handle)
|
||||
{
|
||||
bta_dm_sco_ci_data_ready(event, sco_handle);
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_init
|
||||
**
|
||||
** Description This function can be used by the phone to initialize audio
|
||||
** codec or for other initialization purposes before SCO connection
|
||||
** is opened.
|
||||
**
|
||||
**
|
||||
** Returns tBTA_DM_SCO_ROUTE_TYPE: SCO routing configuration type.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
|
||||
tBTA_CODEC_INFO *p_codec_type, UINT8 app_id)
|
||||
{
|
||||
tBTM_SCO_ROUTE_TYPE route = BTA_DM_SCO_ROUTE_PCM;
|
||||
|
||||
BTIF_TRACE_DEBUG("bta_dm_sco_co_init");
|
||||
|
||||
/* set up SCO routing configuration if SCO over HCI app ID is used and run time
|
||||
configuration is set to SCO over HCI */
|
||||
/* HS invoke this call-out */
|
||||
if (
|
||||
#if (BTA_HS_INCLUDED == TRUE ) && (BTA_HS_INCLUDED == TRUE)
|
||||
(app_id == BTUI_DM_SCO_4_HS_APP_ID && btui_cfg.hs_sco_over_hci) ||
|
||||
#endif
|
||||
/* AG invoke this call-out */
|
||||
(app_id != BTUI_DM_SCO_4_HS_APP_ID && btui_cfg.ag_sco_over_hci )) {
|
||||
route = btui_cb.sco_hci = BTA_DM_SCO_ROUTE_HCI;
|
||||
}
|
||||
/* no codec is is used for the SCO data */
|
||||
if (p_codec_type->codec_type == BTA_SCO_CODEC_PCM && route == BTA_DM_SCO_ROUTE_HCI) {
|
||||
/* initialize SCO codec */
|
||||
if (!btui_sco_codec_init(rx_bw, tx_bw)) {
|
||||
BTIF_TRACE_ERROR("codec initialization exception!");
|
||||
}
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_open
|
||||
**
|
||||
** Description This function is executed when a SCO connection is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event)
|
||||
{
|
||||
tBTUI_SCO_CODEC_CFG cfg;
|
||||
|
||||
if (btui_cb.sco_hci) {
|
||||
BTIF_TRACE_DEBUG("bta_dm_sco_co_open handle:%d pkt_size:%d", handle, pkt_size);
|
||||
/* use dedicated SCO buffer pool for SCO TX data */
|
||||
cfg.pool_id = HCI_SCO_POOL_ID;
|
||||
cfg.p_cback = btui_sco_codec_callback;
|
||||
cfg.pkt_size = pkt_size;
|
||||
cfg.cb_event = event;
|
||||
/* open and start the codec */
|
||||
btui_sco_codec_open(&cfg);
|
||||
btui_sco_codec_start(handle);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_close
|
||||
**
|
||||
** Description This function is called when a SCO connection is closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sco_co_close(void)
|
||||
{
|
||||
if (btui_cb.sco_hci) {
|
||||
BTIF_TRACE_DEBUG("bta_dm_sco_co_close close codec");
|
||||
/* close sco codec */
|
||||
btui_sco_codec_close();
|
||||
|
||||
btui_cb.sco_hci = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_in_data
|
||||
**
|
||||
** Description This function is called to send incoming SCO data to application.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sco_co_in_data(BT_HDR *p_buf)
|
||||
{
|
||||
if (btui_cfg.sco_use_mic) {
|
||||
btui_sco_codec_inqdata (p_buf);
|
||||
} else {
|
||||
osi_free(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_out_data
|
||||
**
|
||||
** Description This function is called to send SCO data over HCI.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sco_co_out_data(BT_HDR **p_buf)
|
||||
{
|
||||
btui_sco_codec_readbuf(p_buf);
|
||||
}
|
||||
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) && (BTM_SCO_INCLUDED == TRUE)*/
|
||||
|
||||
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -66,11 +66,11 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
/* simple pairing events */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
|
||||
|
@ -30,9 +30,11 @@
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_mode,
|
||||
tBTA_DM_PM_REQ pm_req);
|
||||
@ -45,18 +47,15 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive);
|
||||
static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable);
|
||||
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
UINT8 timer_idx);
|
||||
#endif///BTM_SSR_INCLUDED == TRUE
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
#if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE)
|
||||
#include "../hh/bta_hh_int.h"
|
||||
/* BTA_DM_PM_SSR1 will be dedicated for HH SSR setting entry, no other profile can use it */
|
||||
#define BTA_DM_PM_SSR_HH BTA_DM_PM_SSR1
|
||||
#endif
|
||||
#endif /* (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE) */
|
||||
static void bta_dm_pm_ssr(BD_ADDR peer_addr);
|
||||
|
||||
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
#endif /* (BTM_SSR_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -118,27 +117,6 @@ void bta_dm_disable_pm(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_get_av_count
|
||||
**
|
||||
** Description Get the number of connected AV
|
||||
**
|
||||
**
|
||||
** Returns number of av connections
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_dm_get_av_count(void)
|
||||
{
|
||||
UINT8 count = 0;
|
||||
for (int i = 0; i < bta_dm_conn_srvcs.count; i++) {
|
||||
if (bta_dm_conn_srvcs.conn_srvc[i].id == BTA_ID_AV) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_stop_timer
|
||||
@ -337,10 +315,10 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
{
|
||||
|
||||
UINT8 i, j;
|
||||
UINT8 *p = NULL;
|
||||
tBTA_DM_PEER_DEVICE *p_dev;
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
UINT8 *p = NULL;
|
||||
int index = BTA_DM_PM_SSR0;
|
||||
#endif
|
||||
|
||||
@ -492,7 +470,6 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
tBTA_DM_PM_REQ pm_req )
|
||||
{
|
||||
@ -595,7 +572,7 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
remaining_ticks = bta_dm_pm_get_remaining_ticks(&bta_dm_cb.pm_timer[i].timer[timer_idx]);
|
||||
if (remaining_ticks < timeout) {
|
||||
LOG_DEBUG("%s remain 0\n", __func__);
|
||||
APPL_TRACE_DEBUG("%s remain 0\n", __func__);
|
||||
/* Cancel and restart the timer */
|
||||
/*
|
||||
* TODO: The value of pm_action[timer_idx] is
|
||||
@ -702,8 +679,6 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
BTM_ReadPowerMode(p_peer_dev->peer_bdaddr, &mode);
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
p_rem_feat = BTM_ReadRemoteFeatures (p_peer_dev->peer_bdaddr);
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_sniff cur:%d, idx:%d, info:x%x", mode, index, p_peer_dev->info);
|
||||
if (mode != BTM_PM_MD_SNIFF ||
|
||||
(HCI_SNIFF_SUB_RATE_SUPPORTED(BTM_ReadLocalFeatures ()) && p_rem_feat &&
|
||||
@ -805,6 +780,7 @@ static void bta_dm_pm_ssr(BD_ADDR peer_addr)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_active
|
||||
@ -824,11 +800,8 @@ void bta_dm_pm_active(BD_ADDR peer_addr)
|
||||
/* switch to active mode */
|
||||
pm.mode = BTM_PM_MD_ACTIVE;
|
||||
BTM_SetPowerMode (bta_dm_cb.pm_id, peer_addr, &pm);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_btm_cback
|
||||
@ -901,6 +874,7 @@ static void bta_dm_pm_timer_cback(void *p_tle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_btm_status
|
||||
@ -995,11 +969,9 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_timer
|
||||
@ -1015,33 +987,7 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data)
|
||||
APPL_TRACE_EVENT("%s", __func__);
|
||||
bta_dm_pm_set_mode(p_data->pm_timer.bd_addr, p_data->pm_timer.pm_request, BTA_DM_PM_EXECUTE);
|
||||
}
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_find_peer_device
|
||||
**
|
||||
** Description Given an address, find the associated control block.
|
||||
**
|
||||
** Returns tBTA_DM_PEER_DEVICE
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTA_DM_PEER_DEVICE *p_dev = NULL;
|
||||
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, peer_addr)) {
|
||||
p_dev = &bta_dm_cb.device_list.peer_device[i];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return p_dev;
|
||||
}
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_is_sco_active
|
||||
@ -1138,7 +1084,52 @@ static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisa
|
||||
BTM_SetLinkPolicy(p_dev->peer_bdaddr, &policy_setting);
|
||||
|
||||
}
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_get_av_count
|
||||
**
|
||||
** Description Get the number of connected AV
|
||||
**
|
||||
**
|
||||
** Returns number of av connections
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_dm_get_av_count(void)
|
||||
{
|
||||
UINT8 count = 0;
|
||||
for (int i = 0; i < bta_dm_conn_srvcs.count; i++) {
|
||||
if (bta_dm_conn_srvcs.conn_srvc[i].id == BTA_ID_AV) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_find_peer_device
|
||||
**
|
||||
** Description Given an address, find the associated control block.
|
||||
**
|
||||
** Returns tBTA_DM_PEER_DEVICE
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTA_DM_PEER_DEVICE *p_dev = NULL;
|
||||
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, peer_addr)) {
|
||||
p_dev = &bta_dm_cb.device_list.peer_device[i];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return p_dev;
|
||||
}
|
||||
|
||||
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
@ -1161,5 +1152,6 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void)
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_obtain_controller_state: %d", cur_state);
|
||||
return cur_state;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -650,6 +650,6 @@ INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst)
|
||||
APPL_TRACE_DEBUG("bta_pcm_resample : outsamples %d", out_sample);
|
||||
#endif
|
||||
|
||||
return (out_sample * bta_dm_pcm_cb.sample_size);
|
||||
return (out_sample);
|
||||
}
|
||||
#endif
|
||||
|
@ -63,11 +63,11 @@ enum {
|
||||
BTA_DM_API_BOND_CANCEL_EVT,
|
||||
BTA_DM_API_PIN_REPLY_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
BTA_DM_PM_BTM_STATUS_EVT,
|
||||
BTA_DM_PM_TIMER_EVT,
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/* simple pairing events */
|
||||
BTA_DM_API_CONFIRM_EVT,
|
||||
@ -350,6 +350,7 @@ typedef struct {
|
||||
#endif
|
||||
} tBTA_DM_ACL_CHANGE;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* data type for BTA_DM_PM_BTM_STATUS_EVT */
|
||||
typedef struct {
|
||||
|
||||
@ -367,7 +368,7 @@ typedef struct {
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_DM_PM_ACTION pm_request;
|
||||
} tBTA_DM_PM_TIMER;
|
||||
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* data type for BTA_DM_API_ADD_DEVICE_EVT */
|
||||
typedef struct {
|
||||
@ -491,6 +492,7 @@ typedef struct {
|
||||
UINT32 scan_window;
|
||||
tBLE_SCAN_MODE scan_mode;
|
||||
UINT8 addr_type_own;
|
||||
UINT8 scan_duplicate_filter;
|
||||
UINT8 scan_filter_policy;
|
||||
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
|
||||
} tBTA_DM_API_BLE_SCAN_FILTER_PARAMS;
|
||||
@ -757,9 +759,11 @@ typedef union {
|
||||
|
||||
tBTA_DM_ACL_CHANGE acl_change;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
tBTA_DM_PM_BTM_STATUS pm_status;
|
||||
|
||||
tBTA_DM_PM_TIMER pm_timer;
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
tBTA_DM_API_DI_DISC di_disc;
|
||||
|
||||
@ -889,6 +893,10 @@ typedef struct {
|
||||
|
||||
} tBTA_DM_CONNECTED_SRVCS;
|
||||
|
||||
extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
|
||||
typedef struct {
|
||||
#define BTA_DM_PM_SNIFF_TIMER_IDX 0
|
||||
#define BTA_DM_PM_PARK_TIMER_IDX 1
|
||||
@ -908,9 +916,8 @@ typedef struct {
|
||||
BOOLEAN in_use;
|
||||
} tBTA_PM_TIMER;
|
||||
|
||||
extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
#define BTA_DM_NUM_PM_TIMER 7
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* DM control block */
|
||||
typedef struct {
|
||||
@ -931,10 +938,10 @@ typedef struct {
|
||||
UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */
|
||||
UINT8 wbt_scn; /* WIDCOMM Extensions SCN */
|
||||
UINT8 num_master_only;
|
||||
#if BTM_SSR_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
UINT8 pm_id;
|
||||
tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */
|
||||
UINT16 cur_policy; /* current default link policy */
|
||||
UINT16 rs_event; /* the event waiting for role switch */
|
||||
@ -1101,12 +1108,14 @@ typedef struct {
|
||||
UINT8 lmp_version;
|
||||
} tBTA_DM_LMP_VER_INFO;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
extern tBTA_DM_PM_CFG *p_bta_dm_pm_cfg;
|
||||
extern tBTA_DM_PM_SPEC *p_bta_dm_pm_spec;
|
||||
extern tBTM_PM_PWR_MD *p_bta_dm_pm_md;
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
extern tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec;
|
||||
#endif
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* update dynamic BRCM Aware EIR data */
|
||||
extern const tBTA_DM_EIR_CONF bta_dm_eir_cfg;
|
||||
@ -1161,9 +1170,6 @@ extern void bta_dm_add_device (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_remove_device (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_close_acl(tBTA_DM_MSG *p_data);
|
||||
|
||||
|
||||
extern void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_pm_timer(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_add_ampkey (tBTA_DM_MSG *p_data);
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
@ -1223,8 +1229,13 @@ extern void bta_dm_ci_io_req_act(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data);
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
extern void bta_dm_init_pm(void);
|
||||
extern void bta_dm_disable_pm(void);
|
||||
extern void bta_dm_pm_active(BD_ADDR peer_addr);
|
||||
extern void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_pm_timer(tBTA_DM_MSG *p_data);
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
extern UINT8 bta_dm_get_av_count(void);
|
||||
extern void bta_dm_search_start (tBTA_DM_MSG *p_data);
|
||||
@ -1251,9 +1262,6 @@ extern void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data);
|
||||
extern tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr);
|
||||
|
||||
extern void bta_dm_pm_active(BD_ADDR peer_addr);
|
||||
|
||||
void bta_dm_eir_update_uuid(UINT16 uuid16, BOOLEAN adding);
|
||||
|
||||
extern void bta_dm_enable_test_mode(tBTA_DM_MSG *p_data);
|
||||
|
@ -65,10 +65,7 @@ static void bta_gattc_pop_command_to_send(tBTA_GATTC_CLCB *p_clcb);
|
||||
static void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB *p_clreg);
|
||||
static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda);
|
||||
static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested);
|
||||
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda, BOOLEAN *need_timer);
|
||||
static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle);
|
||||
static void bta_gattc_start_service_change_ccc_timer(UINT16 conn_id, BD_ADDR bda,UINT32 timeout_ms,
|
||||
UINT8 timer_cnt, UINT8 last_status, TIMER_LIST_ENT *ccc_timer);
|
||||
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda);
|
||||
|
||||
static tGATT_CBACK bta_gattc_cl_cback = {
|
||||
bta_gattc_conn_cback,
|
||||
@ -126,8 +123,6 @@ static void bta_gattc_enable(tBTA_GATTC_CB *p_cb)
|
||||
/* initialize control block */
|
||||
memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
|
||||
p_cb->state = BTA_GATTC_STATE_ENABLED;
|
||||
// Create a write ccc mutex when the gatt client enable
|
||||
osi_mutex_new(&bta_gattc_cb.write_ccc_mutex);
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("GATTC is already enabled");
|
||||
}
|
||||
@ -154,8 +149,6 @@ void bta_gattc_disable(tBTA_GATTC_CB *p_cb)
|
||||
APPL_TRACE_ERROR("not enabled or disable in pogress");
|
||||
return;
|
||||
}
|
||||
// Free the write ccc mutex when the gatt client disable
|
||||
osi_mutex_free(&bta_gattc_cb.write_ccc_mutex);
|
||||
|
||||
for (i = 0; i < BTA_GATTC_CL_MAX; i ++) {
|
||||
if (p_cb->cl_rcb[i].in_use) {
|
||||
@ -1054,6 +1047,10 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
p_q_cmd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//register service change
|
||||
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1270,23 +1267,34 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
|
||||
{
|
||||
tBTA_GATTC cb_data = {0};
|
||||
UINT8 event;
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_clcb->bda);
|
||||
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
cb_data.write.status = p_data->status;
|
||||
cb_data.write.handle = p_data->p_cmpl->att_value.handle;
|
||||
|
||||
if (p_clcb->p_q_cmd->api_write.hdr.event == BTA_GATTC_API_WRITE_EVT &&
|
||||
p_clcb->p_q_cmd->api_write.write_type == BTA_GATTC_WRITE_PREPARE) {
|
||||
// Should check the value received from the peer device is correct or not.
|
||||
if (memcmp(p_clcb->p_q_cmd->api_write.p_value, p_data->p_cmpl->att_value.value,
|
||||
p_data->p_cmpl->att_value.len) != 0) {
|
||||
cb_data.write.status = BTA_GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
event = BTA_GATTC_PREP_WRITE_EVT;
|
||||
} else {
|
||||
} else {
|
||||
event = p_clcb->p_q_cmd->api_write.cmpl_evt;
|
||||
}
|
||||
}
|
||||
//free the command data store in the queue.
|
||||
bta_gattc_free_command_data(p_clcb);
|
||||
bta_gattc_pop_command_to_send(p_clcb);
|
||||
cb_data.write.conn_id = p_clcb->bta_conn_id;
|
||||
if (p_conn && p_conn->svc_change_descr_handle == cb_data.write.handle) {
|
||||
if(cb_data.write.status != BTA_GATT_OK) {
|
||||
APPL_TRACE_ERROR("service change write ccc failed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* write complete, callback */
|
||||
( *p_clcb->p_rcb->p_cback)(event, (tBTA_GATTC *)&cb_data);
|
||||
|
||||
@ -1613,60 +1621,12 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
|
||||
tBT_TRANSPORT transport)
|
||||
{
|
||||
tBTA_GATTC_DATA *p_buf;
|
||||
BOOLEAN start_ccc_timer = FALSE;
|
||||
tBTA_GATTC_CONN *p_conn = NULL;
|
||||
tBTA_GATTC_FIND_SERVICE_CB result;
|
||||
|
||||
if (reason != 0) {
|
||||
APPL_TRACE_WARNING("%s() - cif=%d connected=%d conn_id=%d reason=0x%04x",
|
||||
__FUNCTION__, gattc_if, connected, conn_id, reason);
|
||||
}
|
||||
|
||||
if (connected == TRUE){
|
||||
p_conn = bta_gattc_conn_find_alloc(bda);
|
||||
}
|
||||
else if (connected == FALSE){
|
||||
p_conn = bta_gattc_conn_find(bda);
|
||||
}
|
||||
|
||||
if (p_conn == NULL){
|
||||
APPL_TRACE_ERROR("p_conn is NULL in %s\n", __func__);
|
||||
}
|
||||
|
||||
if ((transport == BT_TRANSPORT_LE) && (connected == TRUE) && (p_conn != NULL) \
|
||||
&& (p_conn->service_change_ccc_written == FALSE) && (p_conn->ccc_timer_used == FALSE)) {
|
||||
#ifdef CONFIG_BLE_ENABLE_SRVCHG_REG
|
||||
result = bta_gattc_register_service_change_notify(conn_id, bda, &start_ccc_timer);
|
||||
#endif
|
||||
if (start_ccc_timer == TRUE) {
|
||||
TIMER_LIST_ENT *ccc_timer = &(p_conn->service_change_ccc_timer);
|
||||
/* start a 1000ms timer to wait for service discovery finished */
|
||||
bta_gattc_start_service_change_ccc_timer(conn_id, bda, 1000, 0, result, ccc_timer);
|
||||
p_conn->ccc_timer_used = TRUE;
|
||||
}
|
||||
else {
|
||||
/* Has written service change ccc; or service change ccc doesn't exist in remote device's gatt database */
|
||||
p_conn->service_change_ccc_written = TRUE;
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((transport == BT_TRANSPORT_LE) && (connected == FALSE) && (p_conn != NULL)){
|
||||
p_conn->service_change_ccc_written = FALSE;
|
||||
if (p_conn->ccc_timer_used == TRUE){
|
||||
assert(bta_gattc_cb.write_ccc_mutex != NULL);
|
||||
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
if (p_conn->service_change_ccc_timer.param != 0) {
|
||||
osi_free((void *)p_conn->service_change_ccc_timer.param);
|
||||
p_conn->service_change_ccc_timer.param = (TIMER_PARAM_TYPE)0;
|
||||
}
|
||||
bta_sys_stop_timer(&(p_conn->service_change_ccc_timer));
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
bt_bdaddr_t bdaddr;
|
||||
bdcpy(bdaddr.address, bda);
|
||||
|
||||
@ -1886,7 +1846,7 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
|
||||
UINT16 s_handle = ((UINT16)(*(p )) + (((UINT16)(*(p + 1))) << 8));
|
||||
UINT16 e_handle = ((UINT16)(*(p + 2)) + (((UINT16)(*(p + 3))) << 8));
|
||||
|
||||
APPL_TRACE_ERROR("%s: service changed s_handle:0x%04x e_handle:0x%04x",
|
||||
APPL_TRACE_DEBUG("%s: service changed s_handle:0x%04x e_handle:0x%04x",
|
||||
__func__, s_handle, e_handle);
|
||||
|
||||
processed = TRUE;
|
||||
@ -2238,7 +2198,7 @@ void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
}
|
||||
/* if listen to all */
|
||||
else {
|
||||
LOG_DEBUG("Listen For All now");
|
||||
APPL_TRACE_DEBUG("Listen For All now");
|
||||
/* go through all connected device and send
|
||||
callback for all connected slave connection */
|
||||
bta_gattc_process_listen_all(p_msg->api_listen.client_if);
|
||||
@ -2271,58 +2231,28 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_start_service_change_ccc_timer
|
||||
**
|
||||
** Description start a timer to wait for service change ccc discovered
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_start_service_change_ccc_timer(UINT16 conn_id, BD_ADDR bda,UINT32 timeout_ms,
|
||||
UINT8 timer_cnt, UINT8 last_status, TIMER_LIST_ENT *ccc_timer)
|
||||
{
|
||||
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) osi_malloc(sizeof(tBTA_GATTC_WAIT_CCC_TIMER));
|
||||
if (p_timer_param != NULL) {
|
||||
p_timer_param->conn_id = conn_id;
|
||||
memcpy(p_timer_param->remote_bda, bda, sizeof(BD_ADDR));
|
||||
p_timer_param->count = timer_cnt;
|
||||
p_timer_param->last_status = last_status;
|
||||
ccc_timer->param = (UINT32)p_timer_param;
|
||||
ccc_timer->p_cback = (TIMER_CBACK *)&bta_gattc_wait4_service_change_ccc_cback;
|
||||
bta_sys_start_timer(ccc_timer, 0, timeout_ms);
|
||||
}
|
||||
else {
|
||||
APPL_TRACE_ERROR("%s, allocate p_timer_param failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_register_service_change_notify
|
||||
**
|
||||
** Description Find remote device's gatt service change characteristic ccc's handle and write 2 to this
|
||||
** this ccc. If not found, start a timer to wait for service discovery finished.
|
||||
** this ccc.
|
||||
**
|
||||
** Returns Return result of service change ccc service discovery result result and written operate result
|
||||
** Returns Return result of service change ccc service discovery result
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda, BOOLEAN *need_timer)
|
||||
tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda)
|
||||
{
|
||||
tBTA_GATTC_SERV *p_srcb = NULL;
|
||||
list_t *p_cache = NULL;
|
||||
tBTA_GATTC_SERVICE *p_service = NULL;
|
||||
tBTA_GATTC_CHARACTERISTIC *p_char = NULL;
|
||||
tBTA_GATTC_DESCRIPTOR *p_desc = NULL;
|
||||
tGATT_STATUS write_status;
|
||||
tGATT_VALUE ccc_value;
|
||||
tBTA_GATTC_FIND_SERVICE_CB result;
|
||||
BOOLEAN gatt_cache_found = FALSE;
|
||||
BOOLEAN gatt_service_found = FALSE;
|
||||
BOOLEAN gatt_service_change_found = FALSE;
|
||||
BOOLEAN gatt_ccc_found = FALSE;
|
||||
BOOLEAN start_find_ccc_timer = FALSE;
|
||||
|
||||
tBT_UUID gatt_service_uuid = {LEN_UUID_16, {UUID_SERVCLASS_GATT_SERVER}};
|
||||
tBT_UUID gatt_service_change_uuid = {LEN_UUID_16, {GATT_UUID_GATT_SRV_CHGD}};
|
||||
@ -2334,7 +2264,6 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
gatt_cache_found = TRUE;
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CACHE_NOT_FOUND;
|
||||
}
|
||||
/* start to find gatt service */
|
||||
@ -2349,7 +2278,6 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
}
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CACHE_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -2368,7 +2296,6 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
}
|
||||
else if (gatt_cache_found == TRUE) {
|
||||
/* Gatt service not found, start a timer to wait for service discovery */
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_SERVICE_NOT_FOUND;
|
||||
}
|
||||
/* start to find gatt service change characteristic ccc */
|
||||
@ -2390,29 +2317,21 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
* wait for service discovery
|
||||
* Case2: remote device exist service change char, we have found gatt service, but have not found
|
||||
* service change char, we need to start a timer here*/
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CHAR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (gatt_ccc_found == TRUE){
|
||||
ccc_value.handle = p_desc->handle;
|
||||
ccc_value.len = 2;
|
||||
ccc_value.value[0] = GATT_CLT_CONFIG_INDICATION;
|
||||
ccc_value.auth_req = GATT_AUTH_REQ_NONE;
|
||||
if (gatt_is_clcb_allocated(conn_id)) {
|
||||
APPL_TRACE_DEBUG("%s, GATTC_Write GATT_BUSY conn_id = %d", __func__, conn_id);
|
||||
write_status = GATT_BUSY;
|
||||
} else {
|
||||
write_status = GATTC_Write (conn_id, GATT_WRITE, &ccc_value);
|
||||
}
|
||||
if (write_status != GATT_SUCCESS) {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_WRITE_CCC_FAILED;
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = FALSE;
|
||||
result = SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find_alloc(remote_bda);
|
||||
if (p_conn) {
|
||||
p_conn->svc_change_descr_handle = p_desc->handle;
|
||||
}
|
||||
result = SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
|
||||
uint16_t indicate_value = GATT_CLT_CONFIG_INDICATION;
|
||||
tBTA_GATT_UNFMT indicate_v;
|
||||
indicate_v.len = 2;
|
||||
indicate_v.p_value = (uint8_t *)&indicate_value;
|
||||
BTA_GATTC_WriteCharDescr (conn_id, p_desc->handle, BTA_GATTC_TYPE_WRITE, &indicate_v, BTA_GATT_AUTH_REQ_NONE);
|
||||
|
||||
}
|
||||
else if (gatt_service_change_found == TRUE) {
|
||||
/* Gatt service char found, but service change char ccc not found,
|
||||
@ -2420,81 +2339,11 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
* wait for service discovery
|
||||
* Case2: remote device exist service change char ccc, we have found gatt service change char, but have not found
|
||||
* service change char ccc, we need to start a timer here */
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CCC_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (need_timer != NULL) {
|
||||
*need_timer = start_find_ccc_timer;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_wait4_service_change_ccc_cback
|
||||
**
|
||||
** Description callback function of service_change_ccc_timer
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
tBTA_GATTC_FIND_SERVICE_CB result;
|
||||
BOOLEAN start_ccc_timer = FALSE;
|
||||
UINT32 new_timeout;
|
||||
|
||||
assert(bta_gattc_cb.write_ccc_mutex != NULL);
|
||||
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) p_tle->param;
|
||||
p_tle->param = (TIMER_PARAM_TYPE)0;
|
||||
if (p_timer_param == NULL){
|
||||
APPL_TRACE_ERROR("p_timer_param is NULL in %s\n", __func__);
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_timer_param->remote_bda);
|
||||
if (p_conn == NULL){
|
||||
APPL_TRACE_ERROR("p_conn is NULL in %s\n", __func__);
|
||||
osi_free(p_timer_param);
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
result = bta_gattc_register_service_change_notify(p_timer_param->conn_id, p_timer_param->remote_bda, &start_ccc_timer);
|
||||
/* If return SERVICE_CHANGE_CHAR_NOT_FOUND or SERVICE_CHANGE_CCC_NOT_FOUND twice, means remote device doesn't have
|
||||
* service change char or ccc, stop timer */
|
||||
if ((result == p_timer_param->last_status) \
|
||||
&& ((result == SERVICE_CHANGE_CHAR_NOT_FOUND) || (result == SERVICE_CHANGE_CCC_NOT_FOUND))){
|
||||
start_ccc_timer = FALSE;
|
||||
}
|
||||
|
||||
if ((start_ccc_timer == TRUE) && (p_timer_param->count < 10)){
|
||||
TIMER_LIST_ENT *ccc_timer = &(p_conn->service_change_ccc_timer);
|
||||
if (result == SERVICE_CHANGE_WRITE_CCC_FAILED){
|
||||
/* retry to write service change ccc, needn't to add counter */
|
||||
new_timeout = 200;
|
||||
}
|
||||
else {
|
||||
/* retry to find service change ccc */
|
||||
new_timeout = 1000;
|
||||
p_timer_param->count ++;
|
||||
}
|
||||
bta_gattc_start_service_change_ccc_timer(p_timer_param->conn_id, p_timer_param->remote_bda, \
|
||||
new_timeout, p_timer_param->count, result, ccc_timer);
|
||||
}
|
||||
else {
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
p_conn->service_change_ccc_written = TRUE;
|
||||
}
|
||||
|
||||
osi_free(p_timer_param);
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif ///GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "btm_int.h"
|
||||
#include "errno.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_gattc"
|
||||
// #include "osi/include/log.h"
|
||||
|
||||
static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb);
|
||||
@ -106,7 +105,7 @@ bool display_cache_attribute(void *data, void *context)
|
||||
bool display_cache_service(void *data, void *context)
|
||||
{
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = data;
|
||||
LOG_INFO("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
|
||||
APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
|
||||
p_cur_srvc->s_handle, p_cur_srvc->e_handle,
|
||||
((p_cur_srvc->uuid.len == 2) ? "uuid16" : "uuid128"),
|
||||
p_cur_srvc->uuid.uu.uuid16,
|
||||
@ -611,7 +610,7 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
||||
p_srvc_cb->update_sec_sev = false;
|
||||
}
|
||||
/* no service found at all, the end of server discovery*/
|
||||
LOG_DEBUG("%s no more services found", __func__);
|
||||
APPL_TRACE_DEBUG("%s no more services found", __func__);
|
||||
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
bta_gattc_display_cache_server(p_srvc_cb->p_srvc_cache);
|
||||
|
@ -331,7 +331,9 @@ void bta_gattc_co_cache_addr_init(void)
|
||||
cache_env.addr_fp = fp;
|
||||
// Read previously saved blob if available
|
||||
if ((err_code = nvs_get_blob(fp, cache_key, p_buf, &length)) != ESP_OK) {
|
||||
APPL_TRACE_ERROR("%s, Line = %d, nvs flash get blob data fail, err_code = %x", __func__, __LINE__, err_code);
|
||||
if(err_code != ESP_ERR_NVS_NOT_FOUND) {
|
||||
APPL_TRACE_ERROR("%s, Line = %d, nvs flash get blob data fail, err_code = 0x%x", __func__, __LINE__, err_code);
|
||||
}
|
||||
osi_free(p_buf);
|
||||
return;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "stack/l2c_api.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_gattc"
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
@ -863,10 +862,6 @@ BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda)
|
||||
if (p_conn != NULL) {
|
||||
p_conn->in_use = FALSE;
|
||||
memset(p_conn->remote_bda, 0, BD_ADDR_LEN);
|
||||
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
bta_sys_free_timer(&p_conn->service_change_ccc_timer);
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@ -967,7 +962,7 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_src->len);
|
||||
APPL_TRACE_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_src->len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -365,9 +365,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
TIMER_LIST_ENT service_change_ccc_timer; /* wait for discovering remote device's service change ccc handle */
|
||||
BOOLEAN ccc_timer_used; /* service_change_ccc_timer started */
|
||||
BOOLEAN service_change_ccc_written; /* has written remote device's service change ccc */
|
||||
UINT16 svc_change_descr_handle;
|
||||
} tBTA_GATTC_CONN;
|
||||
|
||||
enum {
|
||||
@ -379,7 +377,6 @@ enum {
|
||||
|
||||
typedef struct {
|
||||
UINT8 state;
|
||||
osi_mutex_t write_ccc_mutex;
|
||||
tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX];
|
||||
tBTA_GATTC_BG_TCK bg_track[BTA_GATTC_KNOWN_SR_MAX];
|
||||
tBTA_GATTC_RCB cl_rcb[BTA_GATTC_CL_MAX];
|
||||
|
772
components/bt/bluedroid/bta/hf_client/bta_hf_client_act.c
Normal file
772
components/bt/bluedroid/bta/hf_client/bta_hf_client_act.c
Normal file
@ -0,0 +1,772 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains action functions for the handsfree client.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
#include "bta_hf_client_int.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "stack/port_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/utl.h"
|
||||
#include "common/bt_defs.h"
|
||||
#include <string.h>
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* maximum length of data to read from RFCOMM */
|
||||
#define BTA_HF_CLIENT_RFC_READ_MAX 512
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_register
|
||||
**
|
||||
** Description This function initializes values of the scb and sets up
|
||||
** the SDP record for the services.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_register(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
tBTA_HF_CLIENT_REGISTER evt;
|
||||
tBTA_UTL_COD cod;
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
/* initialize control block */
|
||||
bta_hf_client_scb_init();
|
||||
|
||||
bta_hf_client_cb.scb.serv_sec_mask = p_data->api_register.sec_mask;
|
||||
bta_hf_client_cb.scb.features = p_data->api_register.features;
|
||||
|
||||
/* initialize AT control block */
|
||||
bta_hf_client_at_init();
|
||||
|
||||
/* create SDP records */
|
||||
bta_hf_client_create_record(p_data);
|
||||
|
||||
/* Set the Audio service class bit */
|
||||
cod.service = BTM_COD_SERVICE_AUDIO;
|
||||
utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
|
||||
|
||||
/* start RFCOMM server */
|
||||
bta_hf_client_start_server();
|
||||
|
||||
/* call app callback with register event */
|
||||
evt.status = BTA_HF_CLIENT_SUCCESS;
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_REGISTER_EVT, &evt);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_deregister
|
||||
**
|
||||
** Description This function removes the sdp records, closes the RFCOMM
|
||||
** servers, and deallocates the service control block.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_deregister(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
bta_hf_client_cb.scb.deregister = TRUE;
|
||||
|
||||
/* remove sdp record */
|
||||
bta_hf_client_del_record(p_data);
|
||||
|
||||
/* remove rfcomm server */
|
||||
bta_hf_client_close_server();
|
||||
|
||||
/* disable */
|
||||
bta_hf_client_scb_disable();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_start_dereg
|
||||
**
|
||||
** Description Start a deregister event.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_start_dereg(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
bta_hf_client_cb.scb.deregister = TRUE;
|
||||
|
||||
/* remove sdp record */
|
||||
bta_hf_client_del_record(p_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_start_close
|
||||
**
|
||||
** Description Start the process of closing SCO and RFCOMM connection.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_start_close(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
/* Take the link out of sniff and set L2C idle time to 0 */
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
bta_dm_pm_active(bta_hf_client_cb.scb.peer_addr);
|
||||
#endif /* (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
L2CA_SetIdleTimeoutByBdAddr(bta_hf_client_cb.scb.peer_addr, 0, BT_TRANSPORT_BR_EDR);
|
||||
|
||||
/* if SCO is open close SCO and wait on RFCOMM close */
|
||||
if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_OPEN_ST) {
|
||||
bta_hf_client_cb.scb.sco_close_rfc = TRUE;
|
||||
} else {
|
||||
bta_hf_client_rfc_do_close(p_data);
|
||||
}
|
||||
|
||||
/* always do SCO shutdown to handle all SCO corner cases */
|
||||
bta_hf_client_sco_shutdown(NULL);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_start_open
|
||||
**
|
||||
** Description This starts an HF Client open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_start_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
BD_ADDR pending_bd_addr;
|
||||
|
||||
/* store parameters */
|
||||
if (p_data) {
|
||||
bdcpy(bta_hf_client_cb.scb.peer_addr, p_data->api_open.bd_addr);
|
||||
bta_hf_client_cb.scb.cli_sec_mask = p_data->api_open.sec_mask;
|
||||
}
|
||||
|
||||
/* Check if RFCOMM has any incoming connection to avoid collision. */
|
||||
if (PORT_IsOpening (pending_bd_addr)) {
|
||||
/* Let the incoming connection goes through. */
|
||||
/* Issue collision for now. */
|
||||
/* We will decide what to do when we find incoming connection later.*/
|
||||
bta_hf_client_collision_cback (0, BTA_ID_HS, 0, bta_hf_client_cb.scb.peer_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* close server */
|
||||
bta_hf_client_close_server();
|
||||
|
||||
/* set role */
|
||||
bta_hf_client_cb.scb.role = BTA_HF_CLIENT_INT;
|
||||
|
||||
/* do service search */
|
||||
bta_hf_client_do_disc();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_cback_open
|
||||
**
|
||||
** Description Send open callback event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_cback_open(tBTA_HF_CLIENT_DATA *p_data, tBTA_HF_CLIENT_STATUS status)
|
||||
{
|
||||
tBTA_HF_CLIENT_OPEN evt;
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
/* call app callback with open event */
|
||||
evt.status = status;
|
||||
if (p_data) {
|
||||
/* if p_data is provided then we need to pick the bd address from the open api structure */
|
||||
bdcpy(evt.bd_addr, p_data->api_open.bd_addr);
|
||||
} else {
|
||||
bdcpy(evt.bd_addr, bta_hf_client_cb.scb.peer_addr);
|
||||
}
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_OPEN_EVT, &evt);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_open
|
||||
**
|
||||
** Description Handle RFCOMM channel open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
bta_sys_conn_open(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
|
||||
bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_SUCCESS);
|
||||
|
||||
/* start SLC procedure */
|
||||
bta_hf_client_slc_seq(FALSE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_acp_open
|
||||
**
|
||||
** Description Handle RFCOMM channel open when accepting connection.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_acp_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UINT16 lcid;
|
||||
BD_ADDR dev_addr;
|
||||
int status;
|
||||
|
||||
/* set role */
|
||||
bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP;
|
||||
|
||||
APPL_TRACE_DEBUG ("bta_hf_client_rfc_acp_open: serv_handle = %d rfc.port_handle = %d",
|
||||
bta_hf_client_cb.scb.serv_handle, p_data->rfc.port_handle);
|
||||
|
||||
/* get bd addr of peer */
|
||||
if (PORT_SUCCESS != (status = PORT_CheckConnection(p_data->rfc.port_handle, dev_addr, &lcid))) {
|
||||
APPL_TRACE_DEBUG ("bta_hf_client_rfc_acp_open error PORT_CheckConnection returned status %d", status);
|
||||
}
|
||||
|
||||
/* Collision Handling */
|
||||
if (bta_hf_client_cb.scb.colli_tmr_on) {
|
||||
/* stop collision timer */
|
||||
bta_hf_client_cb.scb.colli_tmr_on = FALSE;
|
||||
bta_sys_free_timer (&bta_hf_client_cb.scb.colli_timer);
|
||||
|
||||
if (bdcmp (dev_addr, bta_hf_client_cb.scb.peer_addr) == 0) {
|
||||
/* If incoming and outgoing device are same, nothing more to do. */
|
||||
/* Outgoing conn will be aborted because we have successful incoming conn. */
|
||||
} else {
|
||||
/* Resume outgoing connection. */
|
||||
bta_hf_client_resume_open ();
|
||||
}
|
||||
}
|
||||
|
||||
bdcpy (bta_hf_client_cb.scb.peer_addr, dev_addr);
|
||||
bta_hf_client_cb.scb.conn_handle = p_data->rfc.port_handle;
|
||||
|
||||
/* do service discovery to get features */
|
||||
bta_hf_client_do_disc();
|
||||
|
||||
/* continue with open processing */
|
||||
bta_hf_client_rfc_open(p_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_fail
|
||||
**
|
||||
** Description RFCOMM connection failed.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_fail(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
/* reinitialize stuff */
|
||||
bta_hf_client_cb.scb.conn_handle = 0;
|
||||
bta_hf_client_cb.scb.peer_features = 0;
|
||||
bta_hf_client_cb.scb.chld_features = 0;
|
||||
bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP;
|
||||
bta_hf_client_cb.scb.svc_conn = FALSE;
|
||||
bta_hf_client_cb.scb.send_at_reply = FALSE;
|
||||
bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
|
||||
|
||||
bta_hf_client_at_reset();
|
||||
|
||||
/* reopen server */
|
||||
bta_hf_client_start_server();
|
||||
|
||||
/* call open cback w. failure */
|
||||
bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_FAIL_RFCOMM);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_disc_fail
|
||||
**
|
||||
** Description This function handles a discovery failure.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_disc_fail(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
/* reopen server */
|
||||
bta_hf_client_start_server();
|
||||
|
||||
/* reinitialize stuff */
|
||||
|
||||
/* call open cback w. failure */
|
||||
bta_hf_client_cback_open(NULL, BTA_HF_CLIENT_FAIL_SDP);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_open_fail
|
||||
**
|
||||
** Description open connection failed.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_open_fail(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
/* call open cback w. failure */
|
||||
bta_hf_client_cback_open(p_data, BTA_HF_CLIENT_FAIL_RESOURCES);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_close
|
||||
**
|
||||
** Description RFCOMM connection closed.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_close(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
/* reinitialize stuff */
|
||||
bta_hf_client_cb.scb.peer_features = 0;
|
||||
bta_hf_client_cb.scb.chld_features = 0;
|
||||
bta_hf_client_cb.scb.role = BTA_HF_CLIENT_ACP;
|
||||
bta_hf_client_cb.scb.svc_conn = FALSE;
|
||||
bta_hf_client_cb.scb.send_at_reply = FALSE;
|
||||
bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
|
||||
|
||||
bta_hf_client_at_reset();
|
||||
|
||||
bta_sys_conn_close(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
|
||||
/* call close cback */
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CLOSE_EVT, NULL);
|
||||
|
||||
/* if not deregistering reopen server */
|
||||
if (bta_hf_client_cb.scb.deregister == FALSE) {
|
||||
/* Clear peer bd_addr so instance can be reused */
|
||||
bdcpy(bta_hf_client_cb.scb.peer_addr, bd_addr_null);
|
||||
|
||||
/* start server as it might got closed on open*/
|
||||
bta_hf_client_start_server();
|
||||
|
||||
bta_hf_client_cb.scb.conn_handle = 0;
|
||||
|
||||
/* Make sure SCO is shutdown */
|
||||
bta_hf_client_sco_shutdown(NULL);
|
||||
|
||||
bta_sys_sco_unuse(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
}
|
||||
/* else close port and deallocate scb */
|
||||
else {
|
||||
bta_hf_client_close_server();
|
||||
bta_hf_client_scb_disable();
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_disc_int_res
|
||||
**
|
||||
** Description This function handles a discovery result when initiator.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_disc_int_res(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UINT16 event = BTA_HF_CLIENT_DISC_FAIL_EVT;
|
||||
|
||||
APPL_TRACE_DEBUG ("bta_hf_client_disc_int_res: Status: %d", p_data->disc_result.status);
|
||||
|
||||
/* if found service */
|
||||
if (p_data->disc_result.status == SDP_SUCCESS ||
|
||||
p_data->disc_result.status == SDP_DB_FULL) {
|
||||
/* get attributes */
|
||||
if (bta_hf_client_sdp_find_attr()) {
|
||||
event = BTA_HF_CLIENT_DISC_OK_EVT;
|
||||
}
|
||||
}
|
||||
|
||||
/* free discovery db */
|
||||
bta_hf_client_free_db(p_data);
|
||||
|
||||
/* send ourselves sdp ok/fail event */
|
||||
bta_hf_client_sm_execute(event, p_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_disc_acp_res
|
||||
**
|
||||
** Description This function handles a discovery result when acceptor.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_disc_acp_res(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
/* if found service */
|
||||
if (p_data->disc_result.status == SDP_SUCCESS ||
|
||||
p_data->disc_result.status == SDP_DB_FULL) {
|
||||
/* get attributes */
|
||||
bta_hf_client_sdp_find_attr();
|
||||
}
|
||||
|
||||
/* free discovery db */
|
||||
bta_hf_client_free_db(p_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_data
|
||||
**
|
||||
** Description Read and process data from RFCOMM.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_data(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UINT16 len;
|
||||
char *buf = osi_calloc(BTA_HF_CLIENT_RFC_READ_MAX);
|
||||
if (buf == NULL) {
|
||||
APPL_TRACE_ERROR("No mem %s", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
UNUSED(p_data);
|
||||
|
||||
/* read data from rfcomm; if bad status, we're done */
|
||||
while (PORT_ReadData(bta_hf_client_cb.scb.conn_handle, buf, BTA_HF_CLIENT_RFC_READ_MAX, &len) == PORT_SUCCESS) {
|
||||
/* if no data, we're done */
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
bta_hf_client_at_parse(buf, len);
|
||||
|
||||
/* no more data to read, we're done */
|
||||
if (len < BTA_HF_CLIENT_RFC_READ_MAX) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
osi_free(buf);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_svc_conn_open
|
||||
**
|
||||
** Description Service level connection opened
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_svc_conn_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
tBTA_HF_CLIENT_CONN evt;
|
||||
UNUSED(p_data);
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
if (!bta_hf_client_cb.scb.svc_conn) {
|
||||
/* set state variable */
|
||||
bta_hf_client_cb.scb.svc_conn = TRUE;
|
||||
|
||||
/* call callback */
|
||||
evt.peer_feat = bta_hf_client_cb.scb.peer_features;
|
||||
evt.chld_feat = bta_hf_client_cb.scb.chld_features;
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CONN_EVT, &evt);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_cback_ind
|
||||
**
|
||||
** Description Send indicator callback event to application.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_ind(tBTA_HF_CLIENT_IND_TYPE type, UINT16 value)
|
||||
{
|
||||
tBTA_HF_CLIENT_IND evt;
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
evt.type = type;
|
||||
evt.value = value;
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_IND_EVT, &evt);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_evt_val
|
||||
**
|
||||
** Description Send event to application.
|
||||
** This is a generic helper for events with common data.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_evt_val(tBTA_HF_CLIENT_EVT type, UINT16 value)
|
||||
{
|
||||
tBTA_HF_CLIENT_VAL evt;
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
evt.value = value;
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(type, &evt);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_operator_name
|
||||
**
|
||||
** Description Send operator name event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_operator_name(char *name)
|
||||
{
|
||||
tBTA_HF_CLIENT_OPERATOR_NAME *evt;
|
||||
|
||||
if ((evt = osi_calloc(sizeof(tBTA_HF_CLIENT_OPERATOR_NAME))) != NULL) {
|
||||
strlcpy(evt->name, name, BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1);
|
||||
evt->name[BTA_HF_CLIENT_OPERATOR_NAME_LEN] = '\0';
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_OPERATOR_NAME_EVT, evt);
|
||||
osi_free(evt);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No mem: %s", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_clip
|
||||
**
|
||||
** Description Send CLIP event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_clip(char *number)
|
||||
{
|
||||
tBTA_HF_CLIENT_NUMBER *evt;
|
||||
|
||||
if ((evt = osi_calloc(sizeof(tBTA_HF_CLIENT_NUMBER))) != NULL) {
|
||||
strlcpy(evt->number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
||||
evt->number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CLIP_EVT, evt);
|
||||
osi_free(evt);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No mem: %s", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_ccwa
|
||||
**
|
||||
** Description Send CLIP event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_ccwa(char *number)
|
||||
{
|
||||
tBTA_HF_CLIENT_NUMBER *evt;
|
||||
|
||||
if ((evt = osi_calloc(sizeof(tBTA_HF_CLIENT_NUMBER))) != NULL) {
|
||||
strlcpy(evt->number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
||||
evt->number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
||||
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CCWA_EVT, evt);
|
||||
osi_free(evt);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No mem: %s", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_at_result
|
||||
**
|
||||
** Description Send AT result event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_at_result(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT16 cme)
|
||||
{
|
||||
tBTA_HF_CLIENT_AT_RESULT evt;
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
evt.type = type;
|
||||
evt.cme = cme;
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_AT_RESULT_EVT, &evt);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_clcc
|
||||
**
|
||||
** Description Send clcc event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_clcc(UINT32 idx, BOOLEAN incoming, UINT8 status, BOOLEAN mpty, char *number)
|
||||
{
|
||||
tBTA_HF_CLIENT_CLCC *evt;
|
||||
|
||||
if ((evt = osi_calloc(sizeof(tBTA_HF_CLIENT_CLCC))) != NULL) {
|
||||
evt->idx = idx;
|
||||
evt->inc = incoming;
|
||||
evt->status = status;
|
||||
evt->mpty = mpty;
|
||||
|
||||
if (number) {
|
||||
evt->number_present = TRUE;
|
||||
strlcpy(evt->number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
||||
evt->number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
||||
}
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CLCC_EVT, evt);
|
||||
osi_free(evt);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No mem, %s\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_cnum
|
||||
**
|
||||
** Description Send cnum event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_cnum(char *number, UINT16 service)
|
||||
{
|
||||
tBTA_HF_CLIENT_CNUM *evt;
|
||||
|
||||
if ((evt = osi_calloc(sizeof(tBTA_HF_CLIENT_CNUM))) != NULL) {
|
||||
|
||||
evt->service = service;
|
||||
strlcpy(evt->number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
||||
evt->number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_CNUM_EVT, evt);
|
||||
osi_free(evt);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No mem, %s", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_binp
|
||||
**
|
||||
** Description Send BINP event to application.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_binp(char *number)
|
||||
{
|
||||
tBTA_HF_CLIENT_NUMBER *evt;
|
||||
|
||||
if ((evt = osi_calloc(sizeof(tBTA_HF_CLIENT_NUMBER))) != NULL) {
|
||||
strlcpy(evt->number, number, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
||||
evt->number[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_BINP_EVT, evt);
|
||||
osi_free(evt);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No mem: %s", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
312
components/bt/bluedroid/bta/hf_client/bta_hf_client_api.c
Normal file
312
components/bt/bluedroid/bta/hf_client/bta_hf_client_api.c
Normal file
@ -0,0 +1,312 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the implementation of the API for the handsfree (HF role)
|
||||
* subsystem of BTA
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
#include "bta_hf_client_int.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
static const tBTA_SYS_REG bta_hf_client_reg = {
|
||||
bta_hf_client_hdl_event,
|
||||
BTA_HfClientDisable
|
||||
};
|
||||
|
||||
static const uint8_t bta_hf_client_cb_data_size[] = {
|
||||
0, // #define BTA_HF_CLIENT_ENABLE_EVT 0
|
||||
sizeof(tBTA_HF_CLIENT_REGISTER), // #define BTA_HF_CLIENT_REGISTER_EVT 1
|
||||
sizeof(tBTA_HF_CLIENT_OPEN), // #define BTA_HF_CLIENT_OPEN_EVT 2
|
||||
0, // #define BTA_HF_CLIENT_CLOSE_EVT 3
|
||||
sizeof(tBTA_HF_CLIENT_CONN), // #define BTA_HF_CLIENT_CONN_EVT 4
|
||||
sizeof(tBTA_HF_CLIENT_HDR), // #define BTA_HF_CLIENT_AUDIO_OPEN_EVT 5
|
||||
sizeof(tBTA_HF_CLIENT_HDR), //#define BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT 6
|
||||
sizeof(tBTA_HF_CLIENT_HDR), // #define BTA_HF_CLIENT_AUDIO_CLOSE_EVT 7
|
||||
sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_SPK_EVT 8
|
||||
sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_MIC_EVT 9
|
||||
sizeof(tBTA_HF_CLIENT_IND), //#define BTA_HF_CLIENT_IND_EVT 10
|
||||
sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_VOICE_REC_EVT 11
|
||||
sizeof(tBTA_HF_CLIENT_OPERATOR_NAME), // #define BTA_HF_CLIENT_OPERATOR_NAME_EVT 12
|
||||
sizeof(tBTA_HF_CLIENT_NUMBER), // #define BTA_HF_CLIENT_CLIP_EVT 13
|
||||
sizeof(tBTA_HF_CLIENT_NUMBER), // #define BTA_HF_CLIENT_CCWA_EVT 14
|
||||
sizeof(tBTA_HF_CLIENT_AT_RESULT), // #define BTA_HF_CLIENT_AT_RESULT_EVT 15
|
||||
sizeof(tBTA_HF_CLIENT_CLCC), // #define BTA_HF_CLIENT_CLCC_EVT 16
|
||||
sizeof(tBTA_HF_CLIENT_CNUM), //#define BTA_HF_CLIENT_CNUM_EVT 17
|
||||
sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_BTRH_EVT 18
|
||||
sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_BSIR_EVT 19
|
||||
sizeof(tBTA_HF_CLIENT_NUMBER), // #define BTA_HF_CLIENT_BINP_EVT 20
|
||||
sizeof(tBTA_HF_CLIENT_VAL), // #define BTA_HF_CLIENT_RING_INDICATION 21
|
||||
0, // #define BTA_HF_CLIENT_DISABLE_EVT 30
|
||||
};
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientEnable
|
||||
**
|
||||
** Description Enable the HF CLient service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_HF_CLIENT_ENABLE_EVT. This function must
|
||||
** be called before other function in the HF CLient API are
|
||||
** called.
|
||||
**
|
||||
** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback)
|
||||
{
|
||||
tBTA_HF_CLIENT_API_ENABLE *p_buf;
|
||||
|
||||
if (bta_sys_is_register (BTA_ID_HS)) {
|
||||
APPL_TRACE_ERROR("BTA HF Client is already enabled, ignoring ...");
|
||||
return BTA_FAILURE;
|
||||
}
|
||||
|
||||
/* register with BTA system manager */
|
||||
bta_sys_register(BTA_ID_HS, &bta_hf_client_reg);
|
||||
|
||||
if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) osi_malloc(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_HF_CLIENT_API_ENABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
|
||||
return BTA_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientDisable
|
||||
**
|
||||
** Description Disable the HF Client service
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientDisable(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_API_DISABLE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientRegister
|
||||
**
|
||||
** Description Register an HF Client service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
|
||||
char *p_service_name)
|
||||
{
|
||||
tBTA_HF_CLIENT_API_REGISTER *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) osi_malloc(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL) {
|
||||
p_buf->hdr.event = BTA_HF_CLIENT_API_REGISTER_EVT;
|
||||
p_buf->features = features;
|
||||
p_buf->sec_mask = sec_mask;
|
||||
if (p_service_name) {
|
||||
BCM_STRNCPY_S(p_buf->name, BTA_SERVICE_NAME_LEN + 1, p_service_name, BTA_SERVICE_NAME_LEN);
|
||||
p_buf->name[BTA_SERVICE_NAME_LEN] = 0;
|
||||
} else {
|
||||
p_buf->name[0] = '\0';
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientDeregister
|
||||
**
|
||||
** Description Deregister an HF Client service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientDeregister(UINT16 handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_API_DEREGISTER_EVT;
|
||||
p_buf->layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientOpen
|
||||
**
|
||||
** Description Opens a connection to an audio gateway.
|
||||
** When connection is open callback function is called
|
||||
** with a BTA_AG_OPEN_EVT. Only the data connection is
|
||||
** opened. The audio connection is not opened.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask)
|
||||
{
|
||||
tBTA_HF_CLIENT_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) osi_malloc(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_HF_CLIENT_API_OPEN_EVT;
|
||||
p_buf->hdr.layer_specific = handle;
|
||||
bdcpy(p_buf->bd_addr, bd_addr);
|
||||
p_buf->sec_mask = sec_mask;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientClose
|
||||
**
|
||||
** Description Close the current connection to an audio gateway.
|
||||
** Any current audio connection will also be closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientClose(UINT16 handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_API_CLOSE_EVT;
|
||||
p_buf->layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfCllientAudioOpen
|
||||
**
|
||||
** Description Opens an audio connection to the currently connected
|
||||
** audio gateway
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientAudioOpen(UINT16 handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_API_AUDIO_OPEN_EVT;
|
||||
p_buf->layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientAudioClose
|
||||
**
|
||||
** Description Close the currently active audio connection to an audio
|
||||
** gateway. The data connection remains open
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientAudioClose(UINT16 handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT;
|
||||
p_buf->layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientSendAT
|
||||
**
|
||||
** Description send AT command
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str)
|
||||
{
|
||||
tBTA_HF_CLIENT_DATA_VAL *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) osi_malloc(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL) {
|
||||
p_buf->hdr.event = BTA_HF_CLIENT_SEND_AT_CMD_EVT;
|
||||
p_buf->uint8_val = at;
|
||||
p_buf->uint32_val1 = val1;
|
||||
p_buf->uint32_val2 = val2;
|
||||
|
||||
if (str) {
|
||||
strlcpy(p_buf->str, str, BTA_HF_CLIENT_NUMBER_LEN + 1);
|
||||
p_buf->str[BTA_HF_CLIENT_NUMBER_LEN] = '\0';
|
||||
} else {
|
||||
p_buf->str[0] = '\0';
|
||||
}
|
||||
|
||||
p_buf->hdr.layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
void BTA_HfClientCiData(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_CI_SCO_DATA_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
|
||||
int BTA_HfClientGetCbDataSize(tBTA_HF_CLIENT_EVT event)
|
||||
{
|
||||
return bta_hf_client_cb_data_size[event];
|
||||
}
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
1795
components/bt/bluedroid/bta/hf_client/bta_hf_client_at.c
Normal file
1795
components/bt/bluedroid/bta/hf_client/bta_hf_client_at.c
Normal file
File diff suppressed because it is too large
Load Diff
85
components/bt/bluedroid/bta/hf_client/bta_hf_client_cmd.c
Normal file
85
components/bt/bluedroid/bta/hf_client/bta_hf_client_cmd.c
Normal file
@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta_hf_client_int.h"
|
||||
#include "stdio.h"
|
||||
#include "common/bt_target.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
|
||||
void bta_hf_client_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
tBTA_HF_CLIENT_DATA_VAL *p_val = (tBTA_HF_CLIENT_DATA_VAL *)p_data;
|
||||
|
||||
switch (p_val->uint8_val) {
|
||||
case BTA_HF_CLIENT_AT_CMD_VTS:
|
||||
bta_hf_client_send_at_vts((char)p_val->uint32_val1);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_BTRH:
|
||||
bta_hf_client_send_at_btrh(FALSE, p_val->uint32_val1);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_CHUP:
|
||||
bta_hf_client_send_at_chup();
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_CHLD:
|
||||
/* expects ascii code for command */
|
||||
bta_hf_client_send_at_chld('0' + p_val->uint32_val1, p_val->uint32_val2);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_BCC:
|
||||
bta_hf_client_send_at_bcc();
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_CNUM:
|
||||
bta_hf_client_send_at_cnum();
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_ATA:
|
||||
bta_hf_client_send_at_ata();
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_COPS:
|
||||
bta_hf_client_send_at_cops(TRUE);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_ATD:
|
||||
bta_hf_client_send_at_atd(p_val->str, p_val->uint32_val1);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_VGM:
|
||||
bta_hf_client_send_at_vgm(p_val->uint32_val1);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_VGS:
|
||||
bta_hf_client_send_at_vgs(p_val->uint32_val1);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_BVRA:
|
||||
bta_hf_client_send_at_bvra(p_val->uint32_val1 == 0 ? FALSE : TRUE);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_CLCC:
|
||||
bta_hf_client_send_at_clcc();
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_BINP:
|
||||
bta_hf_client_send_at_binp(p_val->uint32_val1);
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_BLDN:
|
||||
bta_hf_client_send_at_bldn();
|
||||
break;
|
||||
case BTA_HF_CLIENT_AT_CMD_NREC:
|
||||
bta_hf_client_send_at_nrec();
|
||||
break;
|
||||
default:
|
||||
APPL_TRACE_ERROR("Default case, %s", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
662
components/bt/bluedroid/bta/hf_client/bta_hf_client_main.c
Normal file
662
components/bt/bluedroid/bta/hf_client/bta_hf_client_main.c
Normal file
@ -0,0 +1,662 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "common/bt_defs.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
#include "bta_hf_client_int.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/* uncomment to enable extra debug */
|
||||
/* #define BTA_HF_CLIENT_DEBUG TRUE */
|
||||
|
||||
#ifndef BTA_HF_CLIENT_DEBUG
|
||||
#define BTA_HF_CLIENT_DEBUG FALSE
|
||||
#endif
|
||||
|
||||
#if BTA_HF_CLIENT_DEBUG == TRUE
|
||||
static char *bta_hf_client_evt_str(UINT16 event);
|
||||
static char *bta_hf_client_state_str(UINT8 state);
|
||||
#endif
|
||||
|
||||
/* state machine states */
|
||||
enum {
|
||||
BTA_HF_CLIENT_INIT_ST,
|
||||
BTA_HF_CLIENT_OPENING_ST,
|
||||
BTA_HF_CLIENT_OPEN_ST,
|
||||
BTA_HF_CLIENT_CLOSING_ST
|
||||
};
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum {
|
||||
BTA_HF_CLIENT_REGISTER,
|
||||
BTA_HF_CLIENT_DEREGISTER,
|
||||
BTA_HF_CLIENT_START_DEREG,
|
||||
BTA_HF_CLIENT_RFC_DO_CLOSE,
|
||||
BTA_HF_CLIENT_START_CLOSE,
|
||||
BTA_HF_CLIENT_START_OPEN,
|
||||
BTA_HF_CLIENT_RFC_ACP_OPEN,
|
||||
BTA_HF_CLIENT_SCO_LISTEN,
|
||||
BTA_HF_CLIENT_SCO_CONN_OPEN,
|
||||
BTA_HF_CLIENT_SCO_CONN_CLOSE,
|
||||
BTA_HF_CLIENT_SCO_OPEN,
|
||||
BTA_HF_CLIENT_SCO_CLOSE,
|
||||
BTA_HF_CLIENT_SCO_SHUTDOWN,
|
||||
BTA_HF_CLIENT_FREE_DB,
|
||||
BTA_HF_CLIENT_OPEN_FAIL,
|
||||
BTA_HF_CLIENT_RFC_OPEN,
|
||||
BTA_HF_CLIENT_RFC_FAIL,
|
||||
BTA_HF_CLIENT_DISC_INT_RES,
|
||||
BTA_HF_CLIENT_RFC_DO_OPEN,
|
||||
BTA_HF_CLIENT_DISC_FAIL,
|
||||
BTA_HF_CLIENT_RFC_CLOSE,
|
||||
BTA_HF_CLIENT_RFC_DATA,
|
||||
BTA_HF_CLIENT_DISC_ACP_RES,
|
||||
BTA_HF_CLIENT_SVC_CONN_OPEN,
|
||||
BTA_HF_CLIENT_SEND_AT_CMD,
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
BTA_HF_CLIENT_CI_SCO_DATA,
|
||||
#endif
|
||||
BTA_HF_CLIENT_NUM_ACTIONS,
|
||||
};
|
||||
|
||||
#define BTA_HF_CLIENT_IGNORE BTA_HF_CLIENT_NUM_ACTIONS
|
||||
|
||||
/* type for action functions */
|
||||
typedef void (*tBTA_HF_CLIENT_ACTION)(tBTA_HF_CLIENT_DATA *p_data);
|
||||
|
||||
/* action functions table, indexed with action enum */
|
||||
const tBTA_HF_CLIENT_ACTION bta_hf_client_action[] = {
|
||||
/* BTA_HF_CLIENT_REGISTER */ bta_hf_client_register,
|
||||
/* BTA_HF_CLIENT_DEREGISTER */ bta_hf_client_deregister,
|
||||
/* BTA_HF_CLIENT_START_DEREG */ bta_hf_client_start_dereg,
|
||||
/* BTA_HF_CLIENT_RFC_DO_CLOSE */ bta_hf_client_rfc_do_close,
|
||||
/* BTA_HF_CLIENT_START_CLOSE */ bta_hf_client_start_close,
|
||||
/* BTA_HF_CLIENT_START_OPEN */ bta_hf_client_start_open,
|
||||
/* BTA_HF_CLIENT_RFC_ACP_OPEN */ bta_hf_client_rfc_acp_open,
|
||||
/* BTA_HF_CLIENT_SCO_LISTEN */ bta_hf_client_sco_listen,
|
||||
/* BTA_HF_CLIENT_SCO_CONN_OPEN */ bta_hf_client_sco_conn_open,
|
||||
/* BTA_HF_CLIENT_SCO_CONN_CLOSE*/ bta_hf_client_sco_conn_close,
|
||||
/* BTA_HF_CLIENT_SCO_OPEN */ bta_hf_client_sco_open,
|
||||
/* BTA_HF_CLIENT_SCO_CLOSE */ bta_hf_client_sco_close,
|
||||
/* BTA_HF_CLIENT_SCO_SHUTDOWN */ bta_hf_client_sco_shutdown,
|
||||
/* BTA_HF_CLIENT_FREE_DB */ bta_hf_client_free_db,
|
||||
/* BTA_HF_CLIENT_OPEN_FAIL */ bta_hf_client_open_fail,
|
||||
/* BTA_HF_CLIENT_RFC_OPEN */ bta_hf_client_rfc_open,
|
||||
/* BTA_HF_CLIENT_RFC_FAIL */ bta_hf_client_rfc_fail,
|
||||
/* BTA_HF_CLIENT_DISC_INT_RES */ bta_hf_client_disc_int_res,
|
||||
/* BTA_HF_CLIENT_RFC_DO_OPEN */ bta_hf_client_rfc_do_open,
|
||||
/* BTA_HF_CLIENT_DISC_FAIL */ bta_hf_client_disc_fail,
|
||||
/* BTA_HF_CLIENT_RFC_CLOSE */ bta_hf_client_rfc_close,
|
||||
/* BTA_HF_CLIENT_RFC_DATA */ bta_hf_client_rfc_data,
|
||||
/* BTA_HF_CLIENT_DISC_ACP_RES */ bta_hf_client_disc_acp_res,
|
||||
/* BTA_HF_CLIENT_SVC_CONN_OPEN */ bta_hf_client_svc_conn_open,
|
||||
/* BTA_HF_CLIENT_SEND_AT_CMD */ bta_hf_client_send_at_cmd,
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* BTA_HF_CLIENT_CI_SCO_DATA */ bta_hf_client_ci_sco_data,
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
};
|
||||
|
||||
/* state table information */
|
||||
#define BTA_HF_CLIENT_ACTIONS 2 /* number of actions */
|
||||
#define BTA_HF_CLIENT_NEXT_STATE 2 /* position of next state */
|
||||
#define BTA_HF_CLIENT_NUM_COLS 3 /* number of columns in state tables */
|
||||
|
||||
/* state table for init state */
|
||||
const UINT8 bta_hf_client_st_init[][BTA_HF_CLIENT_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* API_REGISTER_EVT */ {BTA_HF_CLIENT_REGISTER, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_DEREGISTER, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* API_OPEN_EVT */ {BTA_HF_CLIENT_START_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* API_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_RFC_ACP_OPEN, BTA_HF_CLIENT_SCO_LISTEN, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* RFC_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_FREE_DB, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
};
|
||||
|
||||
/* state table for opening state */
|
||||
const UINT8 bta_hf_client_st_opening[][BTA_HF_CLIENT_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* API_REGISTER_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_RFC_DO_CLOSE, BTA_HF_CLIENT_START_DEREG, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_OPEN_EVT */ {BTA_HF_CLIENT_OPEN_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* API_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_DO_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_RFC_OPEN, BTA_HF_CLIENT_SCO_LISTEN, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* RFC_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_DISC_INT_RES, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* DISC_OK_EVT */ {BTA_HF_CLIENT_RFC_DO_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_DISC_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPENING_ST},
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
};
|
||||
|
||||
/* state table for open state */
|
||||
const UINT8 bta_hf_client_st_open[][BTA_HF_CLIENT_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* API_REGISTER_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_START_CLOSE, BTA_HF_CLIENT_START_DEREG, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_OPEN_EVT */ {BTA_HF_CLIENT_OPEN_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* API_CLOSE_EVT */ {BTA_HF_CLIENT_START_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_SCO_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_SCO_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* RFC_DATA_EVT */ {BTA_HF_CLIENT_RFC_DATA, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_DISC_ACP_RES, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_SCO_CONN_OPEN, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_SCO_CONN_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_SEND_AT_CMD, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_CI_SCO_DATA, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_OPEN_ST},
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
};
|
||||
|
||||
/* state table for closing state */
|
||||
const UINT8 bta_hf_client_st_closing[][BTA_HF_CLIENT_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* API_REGISTER_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_DEREGISTER_EVT */ {BTA_HF_CLIENT_START_DEREG, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_OPEN_EVT */ {BTA_HF_CLIENT_OPEN_FAIL, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_AUDIO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* API_AUDIO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* RFC_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* RFC_CLOSE_EVT */ {BTA_HF_CLIENT_RFC_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* RFC_SRV_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* RFC_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* DISC_ACP_RES_EVT */ {BTA_HF_CLIENT_FREE_DB, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* DISC_INT_RES_EVT */ {BTA_HF_CLIENT_FREE_DB, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_INIT_ST},
|
||||
/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
};
|
||||
|
||||
/* type for state table */
|
||||
typedef const UINT8 (*tBTA_HF_CLIENT_ST_TBL)[BTA_HF_CLIENT_NUM_COLS];
|
||||
|
||||
/* state table */
|
||||
const tBTA_HF_CLIENT_ST_TBL bta_hf_client_st_tbl[] = {
|
||||
bta_hf_client_st_init,
|
||||
bta_hf_client_st_opening,
|
||||
bta_hf_client_st_open,
|
||||
bta_hf_client_st_closing
|
||||
};
|
||||
|
||||
/* HF Client control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_HF_CLIENT_CB bta_hf_client_cb;
|
||||
#else
|
||||
tBTA_HF_CLIENT_CB *bta_hf_client_cb_ptr;
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_scb_init
|
||||
**
|
||||
** Description Initialize an HF_Client service control block.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_scb_init(void)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
memset(&bta_hf_client_cb.scb, 0, sizeof(tBTA_HF_CLIENT_SCB));
|
||||
bta_hf_client_cb.scb.sco_idx = BTM_INVALID_SCO_INDEX;
|
||||
bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_scb_disable
|
||||
**
|
||||
** Description Disable a service control block.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_scb_disable(void)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
bta_hf_client_scb_init();
|
||||
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_DISABLE_EVT, NULL);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_resume_open
|
||||
**
|
||||
** Description Resume opening process.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_resume_open (void)
|
||||
{
|
||||
APPL_TRACE_DEBUG ("%s", __FUNCTION__);
|
||||
|
||||
/* resume opening process. */
|
||||
if (bta_hf_client_cb.scb.state == BTA_HF_CLIENT_INIT_ST) {
|
||||
bta_hf_client_cb.scb.state = BTA_HF_CLIENT_OPENING_ST;
|
||||
bta_hf_client_start_open (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_colli_timer_cback
|
||||
**
|
||||
** Description HF Client connection collision timer callback
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_colli_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
if (p_tle) {
|
||||
bta_hf_client_cb.scb.colli_tmr_on = FALSE;
|
||||
|
||||
/* If the peer haven't opened connection, restart opening process */
|
||||
bta_hf_client_resume_open ();
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_collision_cback
|
||||
**
|
||||
** Description Get notified about collision.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
|
||||
UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
UNUSED(status);
|
||||
UNUSED(app_id);
|
||||
UNUSED(peer_addr);
|
||||
|
||||
if (bta_hf_client_cb.scb.state == BTA_HF_CLIENT_OPENING_ST) {
|
||||
if (id == BTA_ID_SYS) { /* ACL collision */
|
||||
APPL_TRACE_WARNING ("HF Client found collision (ACL) ...");
|
||||
} else if (id == BTA_ID_HS) { /* RFCOMM collision */
|
||||
APPL_TRACE_WARNING ("HF Client found collision (RFCOMM) ...");
|
||||
} else {
|
||||
APPL_TRACE_WARNING ("HF Client found collision (\?\?\?) ...");
|
||||
}
|
||||
|
||||
bta_hf_client_cb.scb.state = BTA_HF_CLIENT_INIT_ST;
|
||||
|
||||
/* Cancel SDP if it had been started. */
|
||||
if (bta_hf_client_cb.scb.p_disc_db) {
|
||||
(void)SDP_CancelServiceSearch (bta_hf_client_cb.scb.p_disc_db);
|
||||
bta_hf_client_free_db(NULL);
|
||||
}
|
||||
|
||||
/* reopen registered server */
|
||||
/* Collision may be detected before or after we close servers. */
|
||||
bta_hf_client_start_server();
|
||||
|
||||
/* Start timer to handle connection opening restart */
|
||||
bta_hf_client_cb.scb.colli_timer.p_cback = (TIMER_CBACK *)&bta_hf_client_colli_timer_cback;
|
||||
bta_sys_start_timer(&bta_hf_client_cb.scb.colli_timer, 0, BTA_HF_CLIENT_COLLISION_TIMER);
|
||||
bta_hf_client_cb.scb.colli_tmr_on = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_api_enable
|
||||
**
|
||||
** Description Handle an API enable event.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_api_enable(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
/* initialize control block */
|
||||
memset(&bta_hf_client_cb, 0, sizeof(tBTA_HF_CLIENT_CB));
|
||||
|
||||
/* store callback function */
|
||||
bta_hf_client_cb.p_cback = p_data->api_enable.p_cback;
|
||||
|
||||
/* check if mSBC support enabled */
|
||||
#if 0 // todo
|
||||
char value[PROPERTY_VALUE_MAX];
|
||||
property_get("ro.bluetooth.hfp.ver", value, "0");
|
||||
if (strcmp(value, "1.6") == 0) {
|
||||
bta_hf_client_cb.msbc_enabled = TRUE;
|
||||
}
|
||||
#else
|
||||
bta_hf_client_cb.msbc_enabled = FALSE;
|
||||
#endif
|
||||
|
||||
bta_hf_client_cb.scb.negotiated_codec = BTM_SCO_CODEC_CVSD;
|
||||
|
||||
/* set same setting as AG does */
|
||||
BTM_WriteVoiceSettings(AG_VOICE_SETTINGS);
|
||||
|
||||
bta_sys_collision_register (BTA_ID_HS, bta_hf_client_collision_cback);
|
||||
|
||||
/* call callback with enable event */
|
||||
(*bta_hf_client_cb.p_cback)(BTA_HF_CLIENT_ENABLE_EVT, NULL);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_api_disable
|
||||
**
|
||||
** Description Handle an API disable event.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_api_disable(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
if (!bta_sys_is_register (BTA_ID_HS)) {
|
||||
APPL_TRACE_ERROR("BTA HF Client is already disabled, ignoring ...");
|
||||
return;
|
||||
}
|
||||
|
||||
/* De-register with BTA system manager */
|
||||
bta_sys_deregister(BTA_ID_HS);
|
||||
|
||||
bta_hf_client_sm_execute(BTA_HF_CLIENT_API_DEREGISTER_EVT, p_data);
|
||||
|
||||
bta_sys_collision_register (BTA_ID_HS, NULL);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_hdl_event
|
||||
**
|
||||
** Description Data HF Client main event handling function.
|
||||
**
|
||||
**
|
||||
** Returns BOOLEAN
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_hf_client_hdl_event(BT_HDR *p_msg)
|
||||
{
|
||||
#if BTA_HF_CLIENT_DEBUG == TRUE
|
||||
APPL_TRACE_DEBUG("bta_hf_client_hdl_event %s (0x%x)", bta_hf_client_evt_str(p_msg->event), p_msg->event);
|
||||
#endif
|
||||
|
||||
switch (p_msg->event) {
|
||||
/* handle enable event */
|
||||
case BTA_HF_CLIENT_API_ENABLE_EVT:
|
||||
bta_hf_client_api_enable((tBTA_HF_CLIENT_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
/* handle disable event */
|
||||
case BTA_HF_CLIENT_API_DISABLE_EVT:
|
||||
bta_hf_client_api_disable((tBTA_HF_CLIENT_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
bta_hf_client_sm_execute(p_msg->event, (tBTA_HF_CLIENT_DATA *) p_msg);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sm_execute
|
||||
**
|
||||
** Description State machine event handling function for HF Client
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sm_execute(UINT16 event, tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
tBTA_HF_CLIENT_ST_TBL state_table;
|
||||
UINT8 action;
|
||||
int i;
|
||||
|
||||
#if BTA_HF_CLIENT_DEBUG == TRUE
|
||||
UINT16 in_event = event;
|
||||
UINT8 in_state = bta_hf_client_cb.scb.state;
|
||||
|
||||
/* Ignore displaying of AT results when not connected (Ignored in state machine) */
|
||||
if (bta_hf_client_cb.scb.state == BTA_HF_CLIENT_OPEN_ST) {
|
||||
APPL_TRACE_EVENT("HF Client evt : State %d (%s), Event 0x%04x (%s)",
|
||||
bta_hf_client_cb.scb.state,
|
||||
bta_hf_client_state_str(bta_hf_client_cb.scb.state),
|
||||
event, bta_hf_client_evt_str(event));
|
||||
}
|
||||
#endif
|
||||
|
||||
event &= 0x00FF;
|
||||
if (event >= (BTA_HF_CLIENT_MAX_EVT & 0x00FF)) {
|
||||
APPL_TRACE_ERROR("HF Client evt out of range, ignoring...");
|
||||
return;
|
||||
}
|
||||
|
||||
/* look up the state table for the current state */
|
||||
state_table = bta_hf_client_st_tbl[bta_hf_client_cb.scb.state];
|
||||
|
||||
/* set next state */
|
||||
bta_hf_client_cb.scb.state = state_table[event][BTA_HF_CLIENT_NEXT_STATE];
|
||||
|
||||
/* execute action functions */
|
||||
for (i = 0; i < BTA_HF_CLIENT_ACTIONS; i++) {
|
||||
if ((action = state_table[event][i]) != BTA_HF_CLIENT_IGNORE) {
|
||||
(*bta_hf_client_action[action])(p_data);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if BTA_HF_CLIENT_DEBUG == TRUE
|
||||
if (bta_hf_client_cb.scb.state != in_state) {
|
||||
APPL_TRACE_EVENT("BTA HF Client State Change: [%s] -> [%s] after Event [%s]",
|
||||
bta_hf_client_state_str(in_state),
|
||||
bta_hf_client_state_str(bta_hf_client_cb.scb.state),
|
||||
bta_hf_client_evt_str(in_event));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void send_post_slc_cmd(void)
|
||||
{
|
||||
bta_hf_client_cb.scb.at_cb.current_cmd = BTA_HF_CLIENT_AT_NONE;
|
||||
|
||||
bta_hf_client_send_at_bia();
|
||||
bta_hf_client_send_at_ccwa(TRUE);
|
||||
bta_hf_client_send_at_cmee(TRUE);
|
||||
bta_hf_client_send_at_cops(FALSE);
|
||||
bta_hf_client_send_at_btrh(TRUE, 0);
|
||||
bta_hf_client_send_at_clip(TRUE);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_slc_seq
|
||||
**
|
||||
** Description Handles AT commands sequence required for SLC creation
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_slc_seq(BOOLEAN error)
|
||||
{
|
||||
APPL_TRACE_DEBUG("bta_hf_client_slc_seq cmd: %u", bta_hf_client_cb.scb.at_cb.current_cmd);
|
||||
|
||||
if (error) {
|
||||
/* SLC establishment error, sent close rfcomm event */
|
||||
APPL_TRACE_ERROR("HFPClient: Failed to create SLC due to AT error, disconnecting (%u)",
|
||||
bta_hf_client_cb.scb.at_cb.current_cmd);
|
||||
|
||||
bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bta_hf_client_cb.scb.svc_conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (bta_hf_client_cb.scb.at_cb.current_cmd) {
|
||||
case BTA_HF_CLIENT_AT_NONE:
|
||||
bta_hf_client_send_at_brsf();
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_AT_BRSF:
|
||||
if (bta_hf_client_cb.scb.peer_features & BTA_HF_CLIENT_PEER_CODEC) {
|
||||
bta_hf_client_send_at_bac();
|
||||
break;
|
||||
}
|
||||
|
||||
bta_hf_client_send_at_cind(FALSE);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_AT_BAC:
|
||||
bta_hf_client_send_at_cind(FALSE);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_AT_CIND:
|
||||
bta_hf_client_send_at_cind(TRUE);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_AT_CIND_STATUS:
|
||||
bta_hf_client_send_at_cmer(TRUE);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_AT_CMER:
|
||||
if (bta_hf_client_cb.scb.peer_features & BTA_HF_CLIENT_PEER_FEAT_3WAY) {
|
||||
bta_hf_client_send_at_chld('?', 0);
|
||||
} else {
|
||||
bta_hf_client_svc_conn_open(NULL);
|
||||
send_post_slc_cmd();
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_AT_CHLD:
|
||||
bta_hf_client_svc_conn_open(NULL);
|
||||
send_post_slc_cmd();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* If happen there is a bug in SLC creation procedure... */
|
||||
APPL_TRACE_ERROR("HFPClient: Failed to create SLCdue to unexpected AT command, disconnecting (%u)",
|
||||
bta_hf_client_cb.scb.at_cb.current_cmd);
|
||||
|
||||
bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if BTA_HF_CLIENT_DEBUG == TRUE
|
||||
|
||||
#ifndef CASE_RETURN_STR
|
||||
#define CASE_RETURN_STR(const) case const: return #const;
|
||||
#endif
|
||||
|
||||
static char *bta_hf_client_evt_str(UINT16 event)
|
||||
{
|
||||
switch (event) {
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_REGISTER_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_DEREGISTER_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_OPEN_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_CLOSE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_AUDIO_OPEN_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_RFC_OPEN_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_RFC_CLOSE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_RFC_DATA_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_DISC_ACP_RES_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_DISC_INT_RES_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_DISC_OK_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_DISC_FAIL_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_ENABLE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_API_DISABLE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_SCO_OPEN_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_SCO_CLOSE_EVT)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_SEND_AT_CMD_EVT)
|
||||
default:
|
||||
return "Unknown HF Client Event";
|
||||
}
|
||||
}
|
||||
|
||||
static char *bta_hf_client_state_str(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_INIT_ST)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_OPENING_ST)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_OPEN_ST)
|
||||
CASE_RETURN_STR(BTA_HF_CLIENT_CLOSING_ST)
|
||||
default:
|
||||
return "Unknown HF Client State";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
246
components/bt/bluedroid/bta/hf_client/bta_hf_client_rfc.c
Normal file
246
components/bt/bluedroid/bta/hf_client/bta_hf_client_rfc.c
Normal file
@ -0,0 +1,246 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2004-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the audio gateway functions controlling the RFCOMM
|
||||
* connections.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "common/bt_defs.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_hf_client_int.h"
|
||||
#include "stack/port_api.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_port_cback
|
||||
**
|
||||
** Description RFCOMM Port callback
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_port_cback(UINT32 code, UINT16 port_handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
UNUSED(code);
|
||||
|
||||
/* ignore port events for port handles other than connected handle */
|
||||
if (port_handle != bta_hf_client_cb.scb.conn_handle) {
|
||||
APPL_TRACE_DEBUG("bta_hf_client_port_cback ignoring handle:%d conn_handle = %d",
|
||||
port_handle, bta_hf_client_cb.scb.conn_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_RFC_DATA_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_mgmt_cback
|
||||
**
|
||||
** Description RFCOMM management callback
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_mgmt_cback(UINT32 code, UINT16 port_handle)
|
||||
{
|
||||
tBTA_HF_CLIENT_RFC *p_buf;
|
||||
UINT16 event;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_hf_client_mgmt_cback : code = %d, port_handle = %d, conn_handle = %d, serv_handle = %d",
|
||||
code, port_handle, bta_hf_client_cb.scb.conn_handle, bta_hf_client_cb.scb.serv_handle);
|
||||
|
||||
/* ignore close event for port handles other than connected handle */
|
||||
if ((code != PORT_SUCCESS) && (port_handle != bta_hf_client_cb.scb.conn_handle)) {
|
||||
APPL_TRACE_DEBUG("bta_hf_client_mgmt_cback ignoring handle:%d", port_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (code == PORT_SUCCESS) {
|
||||
if ((bta_hf_client_cb.scb.conn_handle && (port_handle == bta_hf_client_cb.scb.conn_handle)) || /* outgoing connection */
|
||||
(port_handle == bta_hf_client_cb.scb.serv_handle)) { /* incoming connection */
|
||||
event = BTA_HF_CLIENT_RFC_OPEN_EVT;
|
||||
} else {
|
||||
APPL_TRACE_ERROR ("bta_hf_client_mgmt_cback: PORT_SUCCESS, ignoring handle = %d", port_handle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* distinguish server close events */
|
||||
else if (port_handle == bta_hf_client_cb.scb.conn_handle) {
|
||||
event = BTA_HF_CLIENT_RFC_CLOSE_EVT;
|
||||
} else {
|
||||
event = BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT;
|
||||
}
|
||||
|
||||
if ((p_buf = (tBTA_HF_CLIENT_RFC *) osi_malloc(sizeof(tBTA_HF_CLIENT_RFC))) != NULL) {
|
||||
p_buf->hdr.event = event;
|
||||
p_buf->port_handle = port_handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_setup_port
|
||||
**
|
||||
** Description Setup RFCOMM port for use by HF Client.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_setup_port(UINT16 handle)
|
||||
{
|
||||
PORT_SetEventMask(handle, PORT_EV_RXCHAR);
|
||||
PORT_SetEventCallback(handle, bta_hf_client_port_cback);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_start_server
|
||||
**
|
||||
** Description Setup RFCOMM server for use by HF Client.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_start_server(void)
|
||||
{
|
||||
int port_status;
|
||||
|
||||
if (bta_hf_client_cb.scb.serv_handle > 0) {
|
||||
APPL_TRACE_DEBUG("%s already started, handle: %d", __FUNCTION__, bta_hf_client_cb.scb.serv_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_HF_HANDSFREE, bta_hf_client_cb.scb.serv_sec_mask,
|
||||
BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, bta_hf_client_cb.scn);
|
||||
|
||||
port_status = RFCOMM_CreateConnection(UUID_SERVCLASS_HF_HANDSFREE, bta_hf_client_cb.scn,
|
||||
TRUE, BTA_HF_CLIENT_MTU, (UINT8 *) bd_addr_any, &(bta_hf_client_cb.scb.serv_handle),
|
||||
bta_hf_client_mgmt_cback);
|
||||
|
||||
if (port_status == PORT_SUCCESS) {
|
||||
bta_hf_client_setup_port(bta_hf_client_cb.scb.serv_handle);
|
||||
} else {
|
||||
/* TODO: can we handle this better? */
|
||||
APPL_TRACE_DEBUG("bta_hf_client_start_server: RFCOMM_CreateConnection returned error:%d", port_status);
|
||||
}
|
||||
|
||||
APPL_TRACE_DEBUG("bta_hf_client_start_server handle: %d", bta_hf_client_cb.scb.serv_handle);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_close_server
|
||||
**
|
||||
** Description Close RFCOMM server port for use by HF Client.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_close_server(void)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s %d", __FUNCTION__, bta_hf_client_cb.scb.serv_handle);
|
||||
|
||||
if (bta_hf_client_cb.scb.serv_handle == 0) {
|
||||
APPL_TRACE_DEBUG("%s already stopped", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
RFCOMM_RemoveServer(bta_hf_client_cb.scb.serv_handle);
|
||||
bta_hf_client_cb.scb.serv_handle = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_do_open
|
||||
**
|
||||
** Description Open an RFCOMM connection to the peer device.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_do_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_HF_HANDSFREE,
|
||||
bta_hf_client_cb.scb.cli_sec_mask, BT_PSM_RFCOMM,
|
||||
BTM_SEC_PROTO_RFCOMM, bta_hf_client_cb.scb.peer_scn);
|
||||
|
||||
if (RFCOMM_CreateConnection(UUID_SERVCLASS_HF_HANDSFREE, bta_hf_client_cb.scb.peer_scn,
|
||||
FALSE, BTA_HF_CLIENT_MTU, bta_hf_client_cb.scb.peer_addr, &(bta_hf_client_cb.scb.conn_handle),
|
||||
bta_hf_client_mgmt_cback) == PORT_SUCCESS) {
|
||||
bta_hf_client_setup_port(bta_hf_client_cb.scb.conn_handle);
|
||||
APPL_TRACE_DEBUG("bta_hf_client_rfc_do_open : conn_handle = %d", bta_hf_client_cb.scb.conn_handle);
|
||||
}
|
||||
/* RFCOMM create connection failed; send ourselves RFCOMM close event */
|
||||
else {
|
||||
bta_hf_client_sm_execute(BTA_HF_CLIENT_RFC_CLOSE_EVT, p_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_rfc_do_close
|
||||
**
|
||||
** Description Close RFCOMM connection.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_rfc_do_close(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
tBTA_HF_CLIENT_RFC *p_buf;
|
||||
UNUSED(p_data);
|
||||
|
||||
if (bta_hf_client_cb.scb.conn_handle) {
|
||||
RFCOMM_RemoveConnection(bta_hf_client_cb.scb.conn_handle);
|
||||
} else {
|
||||
/* Close API was called while HF Client is in Opening state. */
|
||||
/* Need to trigger the state machine to send callback to the app */
|
||||
/* and move back to INIT state. */
|
||||
if ((p_buf = (tBTA_HF_CLIENT_RFC *) osi_malloc(sizeof(tBTA_HF_CLIENT_RFC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_HF_CLIENT_RFC_CLOSE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
|
||||
/* Cancel SDP if it had been started. */
|
||||
if (bta_hf_client_cb.scb.p_disc_db) {
|
||||
(void)SDP_CancelServiceSearch (bta_hf_client_cb.scb.p_disc_db);
|
||||
bta_hf_client_free_db(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
825
components/bt/bluedroid/bta/hf_client/bta_hf_client_sco.c
Normal file
825
components/bt/bluedroid/bta/hf_client/bta_hf_client_sco.c
Normal file
@ -0,0 +1,825 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2004-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta_hf_client_int.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include <string.h>
|
||||
#include "common/bt_defs.h"
|
||||
#include "common/bt_target.h"
|
||||
#include "osi/allocator.h"
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
#include "bta/bta_hf_client_co.h"
|
||||
#include "hci/hci_audio.h"
|
||||
#endif
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
#define BTA_HF_CLIENT_NO_EDR_ESCO (BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 | \
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 | \
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 | \
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV5)
|
||||
|
||||
static const tBTM_ESCO_PARAMS bta_hf_client_esco_params[] = {
|
||||
/* SCO CVSD */
|
||||
{
|
||||
.rx_bw = BTM_64KBITS_RATE,
|
||||
.tx_bw = BTM_64KBITS_RATE,
|
||||
.max_latency = 10,
|
||||
.voice_contfmt = BTM_VOICE_SETTING_CVSD,
|
||||
.packet_types = (BTM_SCO_LINK_ONLY_MASK |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_2_EV3 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
|
||||
.retrans_effort = BTM_ESCO_RETRANS_POWER,
|
||||
},
|
||||
/* ESCO CVSD */
|
||||
{
|
||||
.rx_bw = BTM_64KBITS_RATE,
|
||||
.tx_bw = BTM_64KBITS_RATE,
|
||||
.max_latency = 10,
|
||||
.voice_contfmt = BTM_VOICE_SETTING_CVSD,
|
||||
/* Allow controller to use all types available except 5-slot EDR */
|
||||
.packet_types = (BTM_SCO_LINK_ALL_PKT_MASK |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
|
||||
.retrans_effort = BTM_ESCO_RETRANS_POWER,
|
||||
},
|
||||
/* ESCO mSBC */
|
||||
{
|
||||
.rx_bw = BTM_64KBITS_RATE,
|
||||
.tx_bw = BTM_64KBITS_RATE,
|
||||
.max_latency = 13,
|
||||
.voice_contfmt = BTM_VOICE_SETTING_TRANS,
|
||||
/* Packet Types : EV3 + 2-EV3 */
|
||||
.packet_types = (BTM_SCO_PKT_TYPES_MASK_EV3 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
|
||||
.retrans_effort = BTM_ESCO_RETRANS_QUALITY,
|
||||
}
|
||||
};
|
||||
|
||||
enum {
|
||||
BTA_HF_CLIENT_SCO_LISTEN_E,
|
||||
BTA_HF_CLIENT_SCO_OPEN_E, /* open request */
|
||||
BTA_HF_CLIENT_SCO_CLOSE_E, /* close request */
|
||||
BTA_HF_CLIENT_SCO_SHUTDOWN_E, /* shutdown request */
|
||||
BTA_HF_CLIENT_SCO_CONN_OPEN_E, /* sco opened */
|
||||
BTA_HF_CLIENT_SCO_CONN_CLOSE_E, /* sco closed */
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
BTA_HF_CLIENT_SCO_CI_DATA_E, /* sco data ready */
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
};
|
||||
|
||||
static void bta_hf_client_sco_event(UINT8 event);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_remove_sco
|
||||
**
|
||||
** Description Removes the specified SCO from the system.
|
||||
** If only_active is TRUE, then SCO is only removed if connected
|
||||
**
|
||||
** Returns BOOLEAN - TRUE if Sco removal was started
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BOOLEAN bta_hf_client_sco_remove(BOOLEAN only_active)
|
||||
{
|
||||
BOOLEAN removed_started = FALSE;
|
||||
tBTM_STATUS status;
|
||||
|
||||
APPL_TRACE_DEBUG("%s %d", __FUNCTION__, only_active);
|
||||
|
||||
if (bta_hf_client_cb.scb.sco_idx != BTM_INVALID_SCO_INDEX) {
|
||||
status = BTM_RemoveSco(bta_hf_client_cb.scb.sco_idx);
|
||||
|
||||
APPL_TRACE_DEBUG("%s idx 0x%04x, status:0x%x", __FUNCTION__, bta_hf_client_cb.scb.sco_idx, status);
|
||||
|
||||
if (status == BTM_CMD_STARTED) {
|
||||
removed_started = TRUE;
|
||||
}
|
||||
/* If no connection reset the sco handle */
|
||||
else if ( (status == BTM_SUCCESS) || (status == BTM_UNKNOWN_ADDR) ) {
|
||||
bta_hf_client_cb.scb.sco_idx = BTM_INVALID_SCO_INDEX;
|
||||
}
|
||||
}
|
||||
return removed_started;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_cback_sco
|
||||
**
|
||||
** Description Call application callback function with SCO event.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_cback_sco(UINT8 event)
|
||||
{
|
||||
tBTA_HF_CLIENT_HDR evt;
|
||||
|
||||
memset(&evt, 0, sizeof(evt));
|
||||
|
||||
/* call app cback */
|
||||
(*bta_hf_client_cb.p_cback)(event, (tBTA_HF_CLIENT_HDR *) &evt);
|
||||
}
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_read_cback
|
||||
**
|
||||
** Description Callback function is the callback function for incoming
|
||||
** SCO data over HCI.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sco_read_cback (UINT16 sco_idx, BT_HDR *p_data, tBTM_SCO_DATA_FLAG status)
|
||||
{
|
||||
if (status != BTM_SCO_DATA_CORRECT)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s: status(%d)", __FUNCTION__, status);
|
||||
}
|
||||
|
||||
bta_hf_client_sco_co_in_data (p_data, status);
|
||||
osi_free(p_data);
|
||||
}
|
||||
#endif /* BTM_SCO_HCI_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_conn_rsp
|
||||
**
|
||||
** Description Process the SCO connection request
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sco_conn_rsp(tBTM_ESCO_CONN_REQ_EVT_DATA *p_data)
|
||||
{
|
||||
tBTM_ESCO_PARAMS resp;
|
||||
UINT8 hci_status = HCI_SUCCESS;
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTA_HFP_CODEC_INFO codec_info = {BTA_HFP_SCO_CODEC_PCM};
|
||||
UINT32 pcm_sample_rate;
|
||||
#endif
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_LISTEN_ST) {
|
||||
if (p_data->link_type == BTM_LINK_TYPE_SCO) {
|
||||
resp = bta_hf_client_esco_params[0];
|
||||
} else {
|
||||
resp = bta_hf_client_esco_params[bta_hf_client_cb.scb.negotiated_codec];
|
||||
}
|
||||
|
||||
/* tell sys to stop av if any */
|
||||
bta_sys_sco_use(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
bta_hf_client_co_audio_state(bta_hf_client_cb.scb.sco_idx, SCO_STATE_SETUP, 0);
|
||||
pcm_sample_rate = BTA_HFP_SCO_SAMP_RATE_8K;
|
||||
|
||||
/* initialize SCO setup, no voice setting for AG, data rate <==> sample rate */
|
||||
BTM_ConfigScoPath(bta_hf_client_sco_co_init(pcm_sample_rate, pcm_sample_rate, &codec_info, 0),
|
||||
bta_hf_client_sco_read_cback, NULL, TRUE);
|
||||
#endif
|
||||
} else {
|
||||
hci_status = HCI_ERR_HOST_REJECT_DEVICE;
|
||||
}
|
||||
|
||||
BTM_EScoConnRsp(p_data->sco_inx, hci_status, &resp);
|
||||
}
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ag_ci_sco_data
|
||||
**
|
||||
** Description Process the SCO data ready callin event
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_ci_sco_data(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CI_DATA_E);
|
||||
}
|
||||
#endif
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_connreq_cback
|
||||
**
|
||||
** Description BTM eSCO connection requests and eSCO change requests
|
||||
** Only the connection requests are processed by BTA.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_esco_connreq_cback(tBTM_ESCO_EVT event, tBTM_ESCO_EVT_DATA *p_data)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s %d", __FUNCTION__, event);
|
||||
|
||||
if (event != BTM_ESCO_CONN_REQ_EVT) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO check remote bdaddr, should allow connect only from device with
|
||||
* active SLC */
|
||||
|
||||
bta_hf_client_cb.scb.sco_idx = p_data->conn_evt.sco_inx;
|
||||
|
||||
bta_hf_client_sco_conn_rsp(&p_data->conn_evt);
|
||||
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_conn_cback
|
||||
**
|
||||
** Description BTM SCO connection callback.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sco_conn_cback(UINT16 sco_idx)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
UINT8 *rem_bd;
|
||||
|
||||
APPL_TRACE_DEBUG("%s %d", __FUNCTION__, sco_idx);
|
||||
|
||||
rem_bd = BTM_ReadScoBdAddr(sco_idx);
|
||||
|
||||
if (rem_bd && bdcmp(bta_hf_client_cb.scb.peer_addr, rem_bd) == 0 &&
|
||||
bta_hf_client_cb.scb.svc_conn && bta_hf_client_cb.scb.sco_idx == sco_idx) {
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_SCO_OPEN_EVT;
|
||||
p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
/* no match found; disconnect sco, init sco variables */
|
||||
else {
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
|
||||
BTM_RemoveSco(sco_idx);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_disc_cback
|
||||
**
|
||||
** Description BTM SCO disconnection callback.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
APPL_TRACE_DEBUG("%s %d", __FUNCTION__, sco_idx);
|
||||
|
||||
if (bta_hf_client_cb.scb.sco_idx == sco_idx) {
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTM_STATUS status = BTM_ConfigScoPath(BTM_SCO_ROUTE_PCM, NULL, NULL, TRUE);
|
||||
APPL_TRACE_DEBUG("%s close config status = %d", __FUNCTION__, status);
|
||||
/* SCO clean up here */
|
||||
bta_hf_client_sco_co_close();
|
||||
#endif
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HF_CLIENT_SCO_CLOSE_EVT;
|
||||
p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_create_sco
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sco_create(BOOLEAN is_orig)
|
||||
{
|
||||
tBTM_STATUS status;
|
||||
UINT8 *p_bd_addr = NULL;
|
||||
tBTM_ESCO_PARAMS params;
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTM_SCO_ROUTE_TYPE sco_route;
|
||||
tBTA_HFP_CODEC_INFO codec_info = {BTA_HFP_SCO_CODEC_PCM};
|
||||
UINT32 pcm_sample_rate;
|
||||
#endif
|
||||
APPL_TRACE_DEBUG("%s %d", __FUNCTION__, is_orig);
|
||||
|
||||
/* Make sure this sco handle is not already in use */
|
||||
if (bta_hf_client_cb.scb.sco_idx != BTM_INVALID_SCO_INDEX) {
|
||||
APPL_TRACE_WARNING("%s: Index 0x%04x already in use", __FUNCTION__,
|
||||
bta_hf_client_cb.scb.sco_idx);
|
||||
return;
|
||||
}
|
||||
|
||||
params = bta_hf_client_esco_params[1];
|
||||
|
||||
/* if initiating set current scb and peer bd addr */
|
||||
if (is_orig) {
|
||||
/* Attempt to use eSCO if remote host supports HFP >= 1.5 */
|
||||
if (bta_hf_client_cb.scb.peer_version >= HFP_VERSION_1_5 && !bta_hf_client_cb.scb.retry_with_sco_only) {
|
||||
BTM_SetEScoMode(BTM_LINK_TYPE_ESCO, ¶ms);
|
||||
/* If ESCO or EDR ESCO, retry with SCO only in case of failure */
|
||||
if ((params.packet_types & BTM_ESCO_LINK_ONLY_MASK)
|
||||
|| !((params.packet_types & ~(BTM_ESCO_LINK_ONLY_MASK | BTM_SCO_LINK_ONLY_MASK)) ^ BTA_HF_CLIENT_NO_EDR_ESCO)) {
|
||||
bta_hf_client_cb.scb.retry_with_sco_only = TRUE;
|
||||
APPL_TRACE_API("Setting retry_with_sco_only to TRUE");
|
||||
}
|
||||
} else {
|
||||
if (bta_hf_client_cb.scb.retry_with_sco_only) {
|
||||
APPL_TRACE_API("retrying with SCO only");
|
||||
}
|
||||
bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
|
||||
|
||||
BTM_SetEScoMode(BTM_LINK_TYPE_SCO, ¶ms);
|
||||
}
|
||||
|
||||
/* tell sys to stop av if any */
|
||||
bta_sys_sco_use(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* Allow any platform specific pre-SCO set up to take place */
|
||||
bta_hf_client_co_audio_state(bta_hf_client_cb.scb.sco_idx, SCO_STATE_SETUP, 0);
|
||||
|
||||
pcm_sample_rate = BTA_HFP_SCO_SAMP_RATE_8K;
|
||||
sco_route = bta_hf_client_sco_co_init(pcm_sample_rate, pcm_sample_rate, &codec_info, 0);
|
||||
|
||||
/* initialize SCO setup, no voice setting for AG, data rate <==> sample rate */
|
||||
BTM_ConfigScoPath(sco_route, bta_hf_client_sco_read_cback, NULL, TRUE);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
|
||||
}
|
||||
|
||||
p_bd_addr = bta_hf_client_cb.scb.peer_addr;
|
||||
|
||||
status = BTM_CreateSco(p_bd_addr, is_orig, params.packet_types,
|
||||
&bta_hf_client_cb.scb.sco_idx, bta_hf_client_sco_conn_cback,
|
||||
bta_hf_client_sco_disc_cback);
|
||||
if (status == BTM_CMD_STARTED && !is_orig) {
|
||||
if (!BTM_RegForEScoEvts(bta_hf_client_cb.scb.sco_idx, bta_hf_client_esco_connreq_cback)) {
|
||||
APPL_TRACE_DEBUG("%s SCO registration success", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
APPL_TRACE_API("%s: orig %d, inx 0x%04x, status 0x%x, pkt types 0x%04x",
|
||||
__FUNCTION__, is_orig, bta_hf_client_cb.scb.sco_idx,
|
||||
status, params.packet_types);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_event
|
||||
**
|
||||
** Description Handle SCO events
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sco_event(UINT8 event)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s state: %d event: %d", __FUNCTION__,
|
||||
bta_hf_client_cb.scb.sco_state, event);
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTA_HF_CLIENT_SCB *p_scb = &bta_hf_client_cb.scb;
|
||||
BT_HDR *p_buf;
|
||||
#endif
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
if (event == BTA_HF_CLIENT_SCO_CI_DATA_E) {
|
||||
uint16_t pkt_offset = 1 + HCI_SCO_PREAMBLE_SIZE;
|
||||
uint16_t len_to_send = 0;
|
||||
uint8_t *p;
|
||||
while (true)
|
||||
{
|
||||
p_buf = osi_malloc(sizeof(BT_HDR) + pkt_offset + BTM_SCO_DATA_SIZE_MAX);
|
||||
if (!p_buf) {
|
||||
APPL_TRACE_WARNING("%s, no mem", __FUNCTION__);
|
||||
break;
|
||||
}
|
||||
|
||||
p_buf->offset = pkt_offset;
|
||||
len_to_send = bta_hf_client_sco_co_out_data(p_buf->data + pkt_offset, BTM_SCO_DATA_SIZE_MAX);
|
||||
if (len_to_send) {
|
||||
if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_OPEN_ST) {
|
||||
p = (UINT8 *)(p_buf->data + pkt_offset -1);
|
||||
*p = len_to_send; // set SCO packet length;
|
||||
tBTM_STATUS write_stat = BTM_WriteScoData(p_scb->sco_idx, p_buf);
|
||||
if (write_stat != BTM_SUCCESS && write_stat != BTM_SCO_BAD_LENGTH) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
osi_free(p_buf);
|
||||
}
|
||||
} else {
|
||||
osi_free(p_buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (bta_hf_client_cb.scb.sco_state) {
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_LISTEN_E:
|
||||
/* create sco listen connection */
|
||||
bta_hf_client_sco_create(FALSE);
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_SHUTDOWN_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_LISTEN_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_LISTEN_E:
|
||||
/* create sco listen connection (Additional channel) */
|
||||
bta_hf_client_sco_create(FALSE);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_OPEN_E:
|
||||
/* remove listening connection */
|
||||
bta_hf_client_sco_remove(FALSE);
|
||||
|
||||
/* create sco connection to peer */
|
||||
bta_hf_client_sco_create(TRUE);
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
/* remove listening connection */
|
||||
bta_hf_client_sco_remove(FALSE);
|
||||
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CLOSE_E:
|
||||
/* remove listening connection */
|
||||
/* Ignore the event. We need to keep listening SCO for the active SLC */
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_LISTEN_ST: Ignoring event %d", event);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
/* sco failed; create sco listen connection */
|
||||
bta_hf_client_sco_create(FALSE);
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_LISTEN_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_OPENING_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_CLOSE_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPEN_CL_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_OPEN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPEN_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
/* sco failed; create sco listen connection */
|
||||
bta_hf_client_sco_create(FALSE);
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_OPENING_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_OPEN_CL_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_OPEN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_OPEN_E:
|
||||
/* close sco connection */
|
||||
bta_hf_client_sco_remove(TRUE);
|
||||
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
/* sco failed; create sco listen connection */
|
||||
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_OPEN_CL_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_OPEN_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_CLOSE_E:
|
||||
/* close sco connection if active */
|
||||
if (bta_hf_client_sco_remove(TRUE)) {
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSING_ST;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
/* remove all listening connections */
|
||||
bta_hf_client_sco_remove(FALSE);
|
||||
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
/* peer closed sco; create sco listen connection */
|
||||
bta_hf_client_sco_create(FALSE);
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_OPEN_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CLOSING_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_OPEN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSE_OP_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
/* peer closed sco; create sco listen connection */
|
||||
bta_hf_client_sco_create(FALSE);
|
||||
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_LISTEN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_CLOSING_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CLOSE_OP_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_CLOSE_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_CLOSING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTTING_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
/* open sco connection */
|
||||
bta_hf_client_sco_create(TRUE);
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_OPENING_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_CLOSE_OP_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTTING_ST:
|
||||
switch (event) {
|
||||
case BTA_HF_CLIENT_SCO_CONN_OPEN_E:
|
||||
/* close sco connection; wait for conn close event */
|
||||
bta_hf_client_sco_remove(TRUE);
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_CONN_CLOSE_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
|
||||
break;
|
||||
|
||||
case BTA_HF_CLIENT_SCO_SHUTDOWN_E:
|
||||
bta_hf_client_cb.scb.sco_state = BTA_HF_CLIENT_SCO_SHUTDOWN_ST;
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_WARNING("BTA_HF_CLIENT_SCO_SHUTTING_ST: Ignoring event %d", event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_listen
|
||||
**
|
||||
** Description Initialize SCO listener
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_listen(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_LISTEN_E);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_shutdown
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_shutdown(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_SHUTDOWN_E);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_conn_open
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_conn_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CONN_OPEN_E);
|
||||
|
||||
bta_sys_sco_open(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
bta_hf_client_co_audio_state(bta_hf_client_cb.scb.sco_idx, SCO_STATE_ON, 0);
|
||||
/* open SCO codec if SCO is routed through transport */
|
||||
bta_hf_client_sco_co_open(bta_hf_client_cb.scb.sco_idx, BTA_HFP_SCO_OUT_PKT_SIZE, BTA_HF_CLIENT_CI_SCO_DATA_EVT);
|
||||
#endif
|
||||
|
||||
if (bta_hf_client_cb.scb.negotiated_codec == BTM_SCO_CODEC_MSBC) {
|
||||
bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT);
|
||||
} else {
|
||||
bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_OPEN_EVT);
|
||||
}
|
||||
|
||||
bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_conn_close
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_conn_close(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
/* clear current scb */
|
||||
bta_hf_client_cb.scb.sco_idx = BTM_INVALID_SCO_INDEX;
|
||||
|
||||
/* retry_with_sco_only, will be set only when initiator
|
||||
** and HFClient is first trying to establish an eSCO connection */
|
||||
if (bta_hf_client_cb.scb.retry_with_sco_only && bta_hf_client_cb.scb.svc_conn) {
|
||||
bta_hf_client_sco_create(TRUE);
|
||||
} else {
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CONN_CLOSE_E);
|
||||
|
||||
bta_sys_sco_close(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
|
||||
bta_sys_sco_unuse(BTA_ID_HS, 1, bta_hf_client_cb.scb.peer_addr);
|
||||
|
||||
/* call app callback */
|
||||
bta_hf_client_cback_sco(BTA_HF_CLIENT_AUDIO_CLOSE_EVT);
|
||||
|
||||
if (bta_hf_client_cb.scb.sco_close_rfc == TRUE) {
|
||||
bta_hf_client_cb.scb.sco_close_rfc = FALSE;
|
||||
bta_hf_client_rfc_do_close(p_data);
|
||||
}
|
||||
}
|
||||
bta_hf_client_cb.scb.retry_with_sco_only = FALSE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_open
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_open(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_OPEN_E);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_close
|
||||
**
|
||||
** Description
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_close(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
APPL_TRACE_DEBUG("%s 0x%x", __FUNCTION__, bta_hf_client_cb.scb.sco_idx);
|
||||
|
||||
if (bta_hf_client_cb.scb.sco_idx != BTM_INVALID_SCO_INDEX) {
|
||||
bta_hf_client_sco_event(BTA_HF_CLIENT_SCO_CLOSE_E);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
367
components/bt/bluedroid/bta/hf_client/bta_hf_client_sdp.c
Normal file
367
components/bt/bluedroid/bta/hf_client/bta_hf_client_sdp.c
Normal file
@ -0,0 +1,367 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the audio gateway functions performing SDP
|
||||
* operations.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "common/bt_defs.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
#include "bta_hf_client_int.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/* Number of protocol elements in protocol element list. */
|
||||
#define BTA_HF_CLIENT_NUM_PROTO_ELEMS 2
|
||||
|
||||
/* Number of elements in service class id list. */
|
||||
#define BTA_HF_CLIENT_NUM_SVC_ELEMS 2
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sdp_cback
|
||||
**
|
||||
** Description SDP callback function.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_hf_client_sdp_cback(UINT16 status)
|
||||
{
|
||||
tBTA_HF_CLIENT_DISC_RESULT *p_buf;
|
||||
UINT16 event;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_hf_client_sdp_cback status:0x%x", status);
|
||||
|
||||
/* set event according to int/acp */
|
||||
if (bta_hf_client_cb.scb.role == BTA_HF_CLIENT_ACP) {
|
||||
event = BTA_HF_CLIENT_DISC_ACP_RES_EVT;
|
||||
} else {
|
||||
event = BTA_HF_CLIENT_DISC_INT_RES_EVT;
|
||||
}
|
||||
|
||||
if ((p_buf = (tBTA_HF_CLIENT_DISC_RESULT *) osi_malloc(sizeof(tBTA_HF_CLIENT_DISC_RESULT))) != NULL) {
|
||||
p_buf->hdr.event = event;
|
||||
p_buf->status = status;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_add_record
|
||||
**
|
||||
** Description This function is called by a server application to add
|
||||
** HFP Client information to an SDP record. Prior to
|
||||
** calling this function the application must call
|
||||
** SDP_CreateRecord() to create an SDP record.
|
||||
**
|
||||
** Returns TRUE if function execution succeeded,
|
||||
** FALSE if function execution failed.
|
||||
**
|
||||
******************************************************************************/
|
||||
BOOLEAN bta_hf_client_add_record(char *p_service_name, UINT8 scn,
|
||||
tBTA_HF_CLIENT_FEAT features, UINT32 sdp_handle)
|
||||
{
|
||||
tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HF_CLIENT_NUM_PROTO_ELEMS];
|
||||
UINT16 svc_class_id_list[BTA_HF_CLIENT_NUM_SVC_ELEMS];
|
||||
UINT16 browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP};
|
||||
UINT16 version;
|
||||
UINT16 profile_uuid;
|
||||
BOOLEAN result = TRUE;
|
||||
UINT8 buf[2];
|
||||
UINT16 sdp_features = 0;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_hf_client_add_record");
|
||||
|
||||
memset( proto_elem_list, 0 , BTA_HF_CLIENT_NUM_PROTO_ELEMS * sizeof(tSDP_PROTOCOL_ELEM));
|
||||
|
||||
/* add the protocol element sequence */
|
||||
proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP;
|
||||
proto_elem_list[0].num_params = 0;
|
||||
proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_RFCOMM;
|
||||
proto_elem_list[1].num_params = 1;
|
||||
proto_elem_list[1].params[0] = scn;
|
||||
result &= SDP_AddProtocolList(sdp_handle, BTA_HF_CLIENT_NUM_PROTO_ELEMS, proto_elem_list);
|
||||
|
||||
/* add service class id list */
|
||||
svc_class_id_list[0] = UUID_SERVCLASS_HF_HANDSFREE;
|
||||
svc_class_id_list[1] = UUID_SERVCLASS_GENERIC_AUDIO;
|
||||
result &= SDP_AddServiceClassIdList(sdp_handle, BTA_HF_CLIENT_NUM_SVC_ELEMS, svc_class_id_list);
|
||||
|
||||
/* add profile descriptor list */
|
||||
profile_uuid = UUID_SERVCLASS_HF_HANDSFREE;
|
||||
version = HFP_VERSION_1_6;
|
||||
|
||||
result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version);
|
||||
|
||||
/* add service name */
|
||||
if (p_service_name != NULL && p_service_name[0] != 0) {
|
||||
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
|
||||
(UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name);
|
||||
}
|
||||
|
||||
/* add features */
|
||||
if (features & BTA_HF_CLIENT_FEAT_ECNR) {
|
||||
sdp_features |= BTA_HF_CLIENT_FEAT_ECNR;
|
||||
}
|
||||
|
||||
if (features & BTA_HF_CLIENT_FEAT_3WAY) {
|
||||
sdp_features |= BTA_HF_CLIENT_FEAT_3WAY;
|
||||
}
|
||||
|
||||
if (features & BTA_HF_CLIENT_FEAT_CLI) {
|
||||
sdp_features |= BTA_HF_CLIENT_FEAT_CLI;
|
||||
}
|
||||
|
||||
if (features & BTA_HF_CLIENT_FEAT_VREC) {
|
||||
sdp_features |= BTA_HF_CLIENT_FEAT_VREC;
|
||||
}
|
||||
|
||||
if (features & BTA_HF_CLIENT_FEAT_VOL) {
|
||||
sdp_features |= BTA_HF_CLIENT_FEAT_VOL;
|
||||
}
|
||||
|
||||
/* Codec bit position is different in SDP (bit 5) and in BRSF (bit 7) */
|
||||
if (features & BTA_HF_CLIENT_FEAT_CODEC) {
|
||||
sdp_features |= 0x0020;
|
||||
}
|
||||
|
||||
UINT16_TO_BE_FIELD(buf, sdp_features);
|
||||
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, 2, buf);
|
||||
|
||||
/* add browse group list */
|
||||
result &= SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_create_record
|
||||
**
|
||||
** Description Create SDP record for registered service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_create_record(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
/* add sdp record if not already registered */
|
||||
if (bta_hf_client_cb.sdp_handle == 0) {
|
||||
bta_hf_client_cb.sdp_handle = SDP_CreateRecord();
|
||||
bta_hf_client_cb.scn = BTM_AllocateSCN();
|
||||
bta_hf_client_add_record(p_data->api_register.name,
|
||||
bta_hf_client_cb.scn,
|
||||
p_data->api_register.features,
|
||||
bta_hf_client_cb.sdp_handle);
|
||||
|
||||
bta_sys_add_uuid(UUID_SERVCLASS_HF_HANDSFREE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_del_record
|
||||
**
|
||||
** Description Delete SDP record for registered service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_del_record(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
APPL_TRACE_DEBUG("bta_hf_client_del_record");
|
||||
|
||||
if (bta_hf_client_cb.sdp_handle != 0) {
|
||||
SDP_DeleteRecord(bta_hf_client_cb.sdp_handle);
|
||||
bta_hf_client_cb.sdp_handle = 0;
|
||||
BTM_FreeSCN(bta_hf_client_cb.scn);
|
||||
BTM_SecClrService(BTM_SEC_SERVICE_HF_HANDSFREE);
|
||||
bta_sys_remove_uuid(UUID_SERVCLASS_HF_HANDSFREE);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sdp_find_attr
|
||||
**
|
||||
** Description Process SDP discovery results to find requested attribute
|
||||
**
|
||||
**
|
||||
** Returns TRUE if results found, FALSE otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_hf_client_sdp_find_attr(void)
|
||||
{
|
||||
tSDP_DISC_REC *p_rec = NULL;
|
||||
tSDP_DISC_ATTR *p_attr;
|
||||
tSDP_PROTOCOL_ELEM pe;
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
bta_hf_client_cb.scb.peer_version = HFP_VERSION_1_1; /* Default version */
|
||||
|
||||
/* loop through all records we found */
|
||||
while (TRUE) {
|
||||
/* get next record; if none found, we're done */
|
||||
if ((p_rec = SDP_FindServiceInDb(bta_hf_client_cb.scb.p_disc_db, UUID_SERVCLASS_AG_HANDSFREE, p_rec)) == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* get scn from proto desc list if initiator */
|
||||
if (bta_hf_client_cb.scb.role == BTA_HF_CLIENT_INT) {
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
bta_hf_client_cb.scb.peer_scn = (UINT8) pe.params[0];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* get profile version (if failure, version parameter is not updated) */
|
||||
SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_HF_HANDSFREE, &bta_hf_client_cb.scb.peer_version);
|
||||
|
||||
/* get features */
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FEATURES)) != NULL) {
|
||||
/* Found attribute. Get value. */
|
||||
/* There might be race condition between SDP and BRSF. */
|
||||
/* Do not update if we already received BRSF. */
|
||||
if (bta_hf_client_cb.scb.peer_features == 0) {
|
||||
bta_hf_client_cb.scb.peer_features = p_attr->attr_value.v.u16;
|
||||
|
||||
/* SDP and BRSF WBS bit are different, correct it if set */
|
||||
if (bta_hf_client_cb.scb.peer_features & 0x0020) {
|
||||
bta_hf_client_cb.scb.peer_features &= ~0x0020;
|
||||
bta_hf_client_cb.scb.peer_features |= BTA_HF_CLIENT_PEER_CODEC;
|
||||
}
|
||||
|
||||
/* get network for ability to reject calls */
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_NETWORK)) != NULL) {
|
||||
if (p_attr->attr_value.v.u16 == 0x01) {
|
||||
bta_hf_client_cb.scb.peer_features |= BTA_HF_CLIENT_PEER_REJECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* found what we needed */
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
APPL_TRACE_DEBUG("%s peer_version=0x%x peer_features=0x%x",
|
||||
__FUNCTION__, bta_hf_client_cb.scb.peer_version,
|
||||
bta_hf_client_cb.scb.peer_features);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_do_disc
|
||||
**
|
||||
** Description Do service discovery.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_do_disc(void)
|
||||
{
|
||||
tSDP_UUID uuid_list[2];
|
||||
UINT16 num_uuid = 1;
|
||||
UINT16 attr_list[4];
|
||||
UINT8 num_attr;
|
||||
BOOLEAN db_inited = FALSE;
|
||||
|
||||
/* initiator; get proto list and features */
|
||||
if (bta_hf_client_cb.scb.role == BTA_HF_CLIENT_INT) {
|
||||
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
|
||||
attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
|
||||
attr_list[2] = ATTR_ID_BT_PROFILE_DESC_LIST;
|
||||
attr_list[3] = ATTR_ID_SUPPORTED_FEATURES;
|
||||
num_attr = 4;
|
||||
uuid_list[0].uu.uuid16 = UUID_SERVCLASS_AG_HANDSFREE;
|
||||
}
|
||||
/* acceptor; get features */
|
||||
else {
|
||||
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
|
||||
attr_list[1] = ATTR_ID_BT_PROFILE_DESC_LIST;
|
||||
attr_list[2] = ATTR_ID_SUPPORTED_FEATURES;
|
||||
num_attr = 3;
|
||||
uuid_list[0].uu.uuid16 = UUID_SERVCLASS_AG_HANDSFREE;
|
||||
}
|
||||
|
||||
/* allocate buffer for sdp database */
|
||||
bta_hf_client_cb.scb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_malloc(BT_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
if (bta_hf_client_cb.scb.p_disc_db) {
|
||||
/* set up service discovery database; attr happens to be attr_list len */
|
||||
uuid_list[0].len = LEN_UUID_16;
|
||||
uuid_list[1].len = LEN_UUID_16;
|
||||
db_inited = SDP_InitDiscoveryDb(bta_hf_client_cb.scb.p_disc_db, BT_DEFAULT_BUFFER_SIZE, num_uuid,
|
||||
uuid_list, num_attr, attr_list);
|
||||
}
|
||||
|
||||
if (db_inited) {
|
||||
/*Service discovery not initiated */
|
||||
db_inited = SDP_ServiceSearchAttributeRequest(bta_hf_client_cb.scb.peer_addr,
|
||||
bta_hf_client_cb.scb.p_disc_db, bta_hf_client_sdp_cback);
|
||||
}
|
||||
|
||||
if (!db_inited) {
|
||||
/*free discover db */
|
||||
bta_hf_client_free_db(NULL);
|
||||
/* sent failed event */
|
||||
bta_hf_client_sm_execute(BTA_HF_CLIENT_DISC_FAIL_EVT, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_free_db
|
||||
**
|
||||
** Description Free discovery database.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_free_db(tBTA_HF_CLIENT_DATA *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
if (bta_hf_client_cb.scb.p_disc_db != NULL) {
|
||||
osi_free(bta_hf_client_cb.scb.p_disc_db);
|
||||
bta_hf_client_cb.scb.p_disc_db = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
117
components/bt/bluedroid/bta/hf_client/include/bta_hf_client_at.h
Normal file
117
components/bt/bluedroid/bta/hf_client/include/bta_hf_client_at.h
Normal file
@ -0,0 +1,117 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
** Data types
|
||||
*****************************************************************************/
|
||||
#include "common/bt_target.h"
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
|
||||
/* ASCII character string of arguments to the AT command */
|
||||
#define BTA_HF_CLIENT_AT_MAX_LEN 512
|
||||
|
||||
/* AT command table element */
|
||||
typedef struct {
|
||||
const char *p_cmd; /* AT command string */
|
||||
UINT8 arg_type; /* allowable argument type syntax */
|
||||
UINT8 fmt; /* whether arg is int or string */
|
||||
UINT8 min; /* minimum value for int arg */
|
||||
INT16 max; /* maximum value for int arg */
|
||||
} tBTA_AG_AT_CMD;
|
||||
|
||||
/* callback function executed when command is parsed */
|
||||
typedef void (tBTA_AG_AT_CMD_CBACK)(void *p_user, UINT16 cmd, UINT8 arg_type,
|
||||
char *p_arg, INT16 int_arg);
|
||||
|
||||
/* callback function executed to send "ERROR" result code */
|
||||
typedef void (tBTA_AG_AT_ERR_CBACK)(void *p_user, BOOLEAN unknown, char *p_arg);
|
||||
|
||||
enum {
|
||||
BTA_HF_CLIENT_AT_NONE,
|
||||
BTA_HF_CLIENT_AT_BRSF,
|
||||
BTA_HF_CLIENT_AT_BAC,
|
||||
BTA_HF_CLIENT_AT_CIND,
|
||||
BTA_HF_CLIENT_AT_CIND_STATUS,
|
||||
BTA_HF_CLIENT_AT_CMER,
|
||||
BTA_HF_CLIENT_AT_CHLD,
|
||||
BTA_HF_CLIENT_AT_CMEE,
|
||||
BTA_HF_CLIENT_AT_BIA,
|
||||
BTA_HF_CLIENT_AT_CLIP,
|
||||
BTA_HF_CLIENT_AT_CCWA,
|
||||
BTA_HF_CLIENT_AT_COPS,
|
||||
BTA_HF_CLIENT_AT_CLCC,
|
||||
BTA_HF_CLIENT_AT_BVRA,
|
||||
BTA_HF_CLIENT_AT_VGS,
|
||||
BTA_HF_CLIENT_AT_VGM,
|
||||
BTA_HF_CLIENT_AT_ATD,
|
||||
BTA_HF_CLIENT_AT_BLDN,
|
||||
BTA_HF_CLIENT_AT_ATA,
|
||||
BTA_HF_CLIENT_AT_CHUP,
|
||||
BTA_HF_CLIENT_AT_BTRH,
|
||||
BTA_HF_CLIENT_AT_VTS,
|
||||
BTA_HF_CLIENT_AT_BCC,
|
||||
BTA_HF_CLIENT_AT_BCS,
|
||||
BTA_HF_CLIENT_AT_CNUM,
|
||||
BTA_HF_CLIENT_AT_NREC,
|
||||
BTA_HF_CLIENT_AT_BINP,
|
||||
};
|
||||
|
||||
typedef UINT8 tBTA_HF_CLIENT_AT_CMD;
|
||||
|
||||
/* Maximum combined buffer for received AT events string */
|
||||
#define BTA_HF_CLIENT_AT_PARSER_MAX_LEN 4096
|
||||
|
||||
/* This structure holds prepared AT command queued for sending */
|
||||
struct queued_at_cmd {
|
||||
tBTA_HF_CLIENT_AT_CMD cmd;
|
||||
char buf[BTA_HF_CLIENT_AT_MAX_LEN];
|
||||
UINT16 buf_len;
|
||||
struct queued_at_cmd *next;
|
||||
};
|
||||
typedef struct queued_at_cmd tBTA_HF_CLIENT_AT_QCMD;
|
||||
|
||||
/* Maximum number of indicators */
|
||||
#define BTA_HF_CLIENT_AT_INDICATOR_COUNT 20
|
||||
|
||||
/* AT command parsing control block */
|
||||
typedef struct {
|
||||
char buf[BTA_HF_CLIENT_AT_PARSER_MAX_LEN + 1]; /* extra byte to always have \0 at the end */
|
||||
unsigned int offset;
|
||||
tBTA_HF_CLIENT_AT_CMD current_cmd;
|
||||
tBTA_HF_CLIENT_AT_QCMD *queued_cmd;
|
||||
|
||||
TIMER_LIST_ENT resp_timer; /* AT response timer */
|
||||
BOOLEAN resp_timer_on; /* TRUE if AT response timer is active */
|
||||
|
||||
TIMER_LIST_ENT hold_timer; /* AT hold timer */
|
||||
BOOLEAN hold_timer_on; /* TRUE if AT hold timer is active */
|
||||
|
||||
/* CIND: lookup table to store the sequence of incoming indicators and their values
|
||||
so when their values come later, we know which value in sequence match certain indicator */
|
||||
int indicator_lookup[BTA_HF_CLIENT_AT_INDICATOR_COUNT];
|
||||
|
||||
} tBTA_HF_CLIENT_AT_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Functions
|
||||
*****************************************************************************/
|
||||
|
||||
void bta_hf_client_at_init(void);
|
||||
void bta_hf_client_at_reset(void);
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
@ -0,0 +1,296 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
#include "bta_hf_client_at.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
#define HFP_VERSION_1_1 0x0101
|
||||
#define HFP_VERSION_1_5 0x0105
|
||||
#define HFP_VERSION_1_6 0x0106
|
||||
|
||||
/* RFCOMM MTU SIZE */
|
||||
#define BTA_HF_CLIENT_MTU 256
|
||||
|
||||
/* profile role for connection */
|
||||
#define BTA_HF_CLIENT_ACP 0 /* accepted connection */
|
||||
#define BTA_HF_CLIENT_INT 1 /* initiating connection */
|
||||
|
||||
/* Timer to wait for retry in case of collision */
|
||||
#ifndef BTA_HF_CLIENT_COLLISION_TIMER
|
||||
#define BTA_HF_CLIENT_COLLISION_TIMER 2411
|
||||
#endif
|
||||
|
||||
enum {
|
||||
/* these events are handled by the state machine */
|
||||
BTA_HF_CLIENT_API_REGISTER_EVT = BTA_SYS_EVT_START(BTA_ID_HS),
|
||||
BTA_HF_CLIENT_API_DEREGISTER_EVT,
|
||||
BTA_HF_CLIENT_API_OPEN_EVT,
|
||||
BTA_HF_CLIENT_API_CLOSE_EVT,
|
||||
BTA_HF_CLIENT_API_AUDIO_OPEN_EVT,
|
||||
BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT,
|
||||
BTA_HF_CLIENT_RFC_OPEN_EVT,
|
||||
BTA_HF_CLIENT_RFC_CLOSE_EVT,
|
||||
BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT,
|
||||
BTA_HF_CLIENT_RFC_DATA_EVT,
|
||||
BTA_HF_CLIENT_DISC_ACP_RES_EVT,
|
||||
BTA_HF_CLIENT_DISC_INT_RES_EVT,
|
||||
BTA_HF_CLIENT_DISC_OK_EVT,
|
||||
BTA_HF_CLIENT_DISC_FAIL_EVT,
|
||||
BTA_HF_CLIENT_SCO_OPEN_EVT,
|
||||
BTA_HF_CLIENT_SCO_CLOSE_EVT,
|
||||
BTA_HF_CLIENT_SEND_AT_CMD_EVT,
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
BTA_HF_CLIENT_CI_SCO_DATA_EVT,
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
BTA_HF_CLIENT_MAX_EVT,
|
||||
|
||||
/* these events are handled outside of the state machine */
|
||||
BTA_HF_CLIENT_API_ENABLE_EVT,
|
||||
BTA_HF_CLIENT_API_DISABLE_EVT
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
** Data types
|
||||
*****************************************************************************/
|
||||
|
||||
/* data type for BTA_HF_CLIENT_API_ENABLE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_HF_CLIENT_CBACK *p_cback;
|
||||
} tBTA_HF_CLIENT_API_ENABLE;
|
||||
|
||||
/* data type for BTA_HF_CLIENT_API_REGISTER_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_HF_CLIENT_CBACK *p_cback;
|
||||
tBTA_SEC sec_mask;
|
||||
tBTA_HF_CLIENT_FEAT features;
|
||||
char name[BTA_SERVICE_NAME_LEN + 1];
|
||||
} tBTA_HF_CLIENT_API_REGISTER;
|
||||
|
||||
/* data type for BTA_HF_CLIENT_API_OPEN_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_SEC sec_mask;
|
||||
} tBTA_HF_CLIENT_API_OPEN;
|
||||
|
||||
/* data type for BTA_HF_CLIENT_DISC_RESULT_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 status;
|
||||
} tBTA_HF_CLIENT_DISC_RESULT;
|
||||
|
||||
/* data type for RFCOMM events */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 port_handle;
|
||||
} tBTA_HF_CLIENT_RFC;
|
||||
|
||||
/* generic purpose data type for other events */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN bool_val;
|
||||
UINT8 uint8_val;
|
||||
UINT32 uint32_val1;
|
||||
UINT32 uint32_val2;
|
||||
char str[BTA_HF_CLIENT_NUMBER_LEN + 1];
|
||||
} tBTA_HF_CLIENT_DATA_VAL;
|
||||
|
||||
/* union of all event datatypes */
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_HF_CLIENT_API_ENABLE api_enable;
|
||||
tBTA_HF_CLIENT_API_REGISTER api_register;
|
||||
tBTA_HF_CLIENT_API_OPEN api_open;
|
||||
tBTA_HF_CLIENT_DISC_RESULT disc_result;
|
||||
tBTA_HF_CLIENT_RFC rfc;
|
||||
tBTA_HF_CLIENT_DATA_VAL val;
|
||||
|
||||
} tBTA_HF_CLIENT_DATA;
|
||||
|
||||
/* type for each service control block */
|
||||
typedef struct {
|
||||
UINT16 serv_handle; /* RFCOMM server handle */
|
||||
BD_ADDR peer_addr; /* peer bd address */
|
||||
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
|
||||
UINT16 conn_handle; /* RFCOMM handle of connected service */
|
||||
tBTA_SEC serv_sec_mask; /* server security mask */
|
||||
tBTA_SEC cli_sec_mask; /* client security mask */
|
||||
tBTA_HF_CLIENT_FEAT features; /* features registered by application */
|
||||
tBTA_HF_CLIENT_PEER_FEAT peer_features; /* peer device features */
|
||||
tBTA_HF_CLIENT_CHLD_FEAT chld_features; /* call handling features */
|
||||
UINT16 peer_version; /* profile version of peer device */
|
||||
UINT8 peer_scn; /* peer scn */
|
||||
UINT8 role; /* initiator/acceptor role */
|
||||
UINT16 sco_idx; /* SCO handle */
|
||||
UINT8 sco_state; /* SCO state variable */
|
||||
BOOLEAN sco_close_rfc; /* TRUE if also close RFCOMM after SCO */
|
||||
BOOLEAN retry_with_sco_only;
|
||||
BOOLEAN deregister; /* TRUE if service shutting down */
|
||||
BOOLEAN svc_conn; /* set to TRUE when service level connection is up */
|
||||
BOOLEAN send_at_reply; /* set to TRUE to notify framework about AT results */
|
||||
tBTA_HF_CLIENT_AT_CB at_cb; /* AT Parser control block */
|
||||
UINT8 state; /* state machine state */
|
||||
tBTM_SCO_CODEC_TYPE negotiated_codec; /* negotiated codec */
|
||||
TIMER_LIST_ENT colli_timer; /* Collision timer */
|
||||
BOOLEAN colli_tmr_on; /* TRUE if collision timer is active */
|
||||
} tBTA_HF_CLIENT_SCB;
|
||||
|
||||
/* sco states */
|
||||
enum {
|
||||
BTA_HF_CLIENT_SCO_SHUTDOWN_ST, /* no listening, no connection */
|
||||
BTA_HF_CLIENT_SCO_LISTEN_ST, /* listening */
|
||||
BTA_HF_CLIENT_SCO_OPENING_ST, /* connection opening */
|
||||
BTA_HF_CLIENT_SCO_OPEN_CL_ST, /* opening connection being closed */
|
||||
BTA_HF_CLIENT_SCO_OPEN_ST, /* open */
|
||||
BTA_HF_CLIENT_SCO_CLOSING_ST, /* closing */
|
||||
BTA_HF_CLIENT_SCO_CLOSE_OP_ST, /* closing sco being opened */
|
||||
BTA_HF_CLIENT_SCO_SHUTTING_ST /* sco shutting down */
|
||||
};
|
||||
|
||||
/* type for AG control block */
|
||||
typedef struct {
|
||||
tBTA_HF_CLIENT_SCB scb; /* service control block */
|
||||
UINT32 sdp_handle;
|
||||
UINT8 scn;
|
||||
tBTA_HF_CLIENT_CBACK *p_cback; /* application callback */
|
||||
BOOLEAN msbc_enabled;
|
||||
} tBTA_HF_CLIENT_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
|
||||
/* control block declaration */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_HF_CLIENT_CB bta_hf_client_cb;
|
||||
#else
|
||||
extern tBTA_HF_CLIENT_CB *bta_hf_client_cb_ptr;
|
||||
#define bta_hf_client_cb (*bta_hf_client_cb_ptr)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** Function prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/* main functions */
|
||||
extern void bta_hf_client_scb_init(void);
|
||||
extern void bta_hf_client_scb_disable(void);
|
||||
extern BOOLEAN bta_hf_client_hdl_event(BT_HDR *p_msg);
|
||||
extern void bta_hf_client_sm_execute(UINT16 event,
|
||||
tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_slc_seq(BOOLEAN error);
|
||||
extern void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
|
||||
UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_hf_client_resume_open ();
|
||||
|
||||
/* SDP functions */
|
||||
extern BOOLEAN bta_hf_client_add_record(char *p_service_name,
|
||||
UINT8 scn, tBTA_HF_CLIENT_FEAT features,
|
||||
UINT32 sdp_handle);
|
||||
extern void bta_hf_client_create_record(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_del_record(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern BOOLEAN bta_hf_client_sdp_find_attr(void);
|
||||
extern void bta_hf_client_do_disc(void);
|
||||
extern void bta_hf_client_free_db(tBTA_HF_CLIENT_DATA *p_data);
|
||||
|
||||
/* RFCOMM functions */
|
||||
extern void bta_hf_client_setup_port(UINT16 handle);
|
||||
extern void bta_hf_client_start_server(void);
|
||||
extern void bta_hf_client_close_server(void);
|
||||
extern void bta_hf_client_rfc_do_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_rfc_do_close(tBTA_HF_CLIENT_DATA *p_data);
|
||||
|
||||
/* SCO functions */
|
||||
extern void bta_hf_client_sco_listen(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_sco_shutdown(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_sco_conn_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_sco_conn_close(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_sco_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_sco_close(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_cback_sco(UINT8 event);
|
||||
|
||||
/* AT command functions */
|
||||
extern void bta_hf_client_at_parse(char *buf, unsigned int len);
|
||||
extern void bta_hf_client_send_at_brsf(void);
|
||||
extern void bta_hf_client_send_at_bac(void);
|
||||
extern void bta_hf_client_send_at_cind(BOOLEAN status);
|
||||
extern void bta_hf_client_send_at_cmer(BOOLEAN activate);
|
||||
extern void bta_hf_client_send_at_chld(char cmd, UINT32 idx);
|
||||
extern void bta_hf_client_send_at_clip(BOOLEAN activate);
|
||||
extern void bta_hf_client_send_at_ccwa(BOOLEAN activate);
|
||||
extern void bta_hf_client_send_at_cmee(BOOLEAN activate);
|
||||
extern void bta_hf_client_send_at_cops(BOOLEAN query);
|
||||
extern void bta_hf_client_send_at_clcc(void);
|
||||
extern void bta_hf_client_send_at_bvra(BOOLEAN enable);
|
||||
extern void bta_hf_client_send_at_vgs(UINT32 volume);
|
||||
extern void bta_hf_client_send_at_vgm(UINT32 volume);
|
||||
extern void bta_hf_client_send_at_atd(char *number, UINT32 memory);
|
||||
extern void bta_hf_client_send_at_bldn(void);
|
||||
extern void bta_hf_client_send_at_ata(void);
|
||||
extern void bta_hf_client_send_at_chup(void);
|
||||
extern void bta_hf_client_send_at_btrh(BOOLEAN query, UINT32 val);
|
||||
extern void bta_hf_client_send_at_vts(char code);
|
||||
extern void bta_hf_client_send_at_bcc(void);
|
||||
extern void bta_hf_client_send_at_bcs(UINT32 codec);
|
||||
extern void bta_hf_client_send_at_cnum(void);
|
||||
extern void bta_hf_client_send_at_nrec(void);
|
||||
extern void bta_hf_client_send_at_binp(UINT32 action);
|
||||
extern void bta_hf_client_send_at_bia(void);
|
||||
|
||||
/* Action functions */
|
||||
extern void bta_hf_client_register(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_deregister(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_start_dereg(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_start_close(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_start_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_rfc_acp_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_rfc_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_rfc_fail(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_disc_fail(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_open_fail(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_rfc_close(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_disc_acp_res(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_rfc_data(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_disc_int_res(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_svc_conn_open(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_ind(tBTA_HF_CLIENT_IND_TYPE type, UINT16 value);
|
||||
extern void bta_hf_client_evt_val(tBTA_HF_CLIENT_EVT type, UINT16 value);
|
||||
extern void bta_hf_client_operator_name(char *name);
|
||||
extern void bta_hf_client_clip(char *number);
|
||||
extern void bta_hf_client_ccwa(char *number);
|
||||
extern void bta_hf_client_at_result(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT16 cme);
|
||||
extern void bta_hf_client_clcc(UINT32 idx, BOOLEAN incoming, UINT8 status, BOOLEAN mpty, char *number);
|
||||
extern void bta_hf_client_cnum(char *number, UINT16 service);
|
||||
extern void bta_hf_client_binp(char *number);
|
||||
|
||||
/* Commands handling functions */
|
||||
extern void bta_hf_client_dial(tBTA_HF_CLIENT_DATA *p_data);
|
||||
extern void bta_hf_client_send_at_cmd(tBTA_HF_CLIENT_DATA *p_data);
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
extern void bta_hf_client_ci_sco_data(tBTA_HF_CLIENT_DATA *p_data);
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
@ -35,7 +35,6 @@
|
||||
#include "stack/l2c_api.h"
|
||||
#include "bta/utl.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_hh"
|
||||
#include "osi/include/log.h"
|
||||
|
||||
/*****************************************************************************
|
||||
@ -67,7 +66,7 @@ void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback)
|
||||
/* register with BTA system manager */
|
||||
bta_sys_register(BTA_ID_HH, &bta_hh_reg);
|
||||
|
||||
LOG_INFO("%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback);
|
||||
APPL_TRACE_API("%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback);
|
||||
p_buf = (tBTA_HH_API_ENABLE *)osi_malloc((UINT16)sizeof(tBTA_HH_API_ENABLE));
|
||||
|
||||
if (p_buf != NULL) {
|
||||
|
@ -613,7 +613,7 @@ tBTA_HH_STATUS bta_hh_le_read_char_dscrpt(tBTA_HH_DEV_CB *p_cb, UINT16 srvc_uuid
|
||||
status = BTA_HH_OK;
|
||||
} else {
|
||||
#if BTA_HH_DEBUG == TRUE
|
||||
LOG_WARN("%s No descriptor exists: %s(0x%04x)", __func__,
|
||||
APPL_TRACE_WARNING("%s No descriptor exists: %s(0x%04x)", __func__,
|
||||
bta_hh_uuid_to_str(char_descp_uuid), char_descp_uuid);
|
||||
#endif
|
||||
}
|
||||
@ -1092,7 +1092,7 @@ void bta_hh_le_expl_rpt(tBTA_HH_DEV_CB *p_dev_cb,
|
||||
p_char_id = &char_result;
|
||||
} while (1);
|
||||
|
||||
LOG_INFO("%s all BLE reports searched", __func__);
|
||||
APPL_TRACE_API("%s all BLE reports searched", __func__);
|
||||
bta_hh_le_read_rpt_ref_descr(p_dev_cb,
|
||||
&p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].report[0]);
|
||||
|
||||
|
@ -1022,7 +1022,7 @@ typedef struct {
|
||||
/* If the device name is known to application BTA skips the remote name request */
|
||||
BOOLEAN is_limited; /* TRUE, if the limited inquiry bit is set in the CoD */
|
||||
INT8 rssi; /* The rssi value */
|
||||
UINT8 *p_eir; /* received EIR */
|
||||
UINT8 *p_eir; /* Received EIR */
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
UINT8 inq_result_type;
|
||||
UINT8 ble_addr_type;
|
||||
@ -1054,7 +1054,7 @@ typedef struct {
|
||||
tBTA_SERVICE_MASK services; /* Services found on peer device. */
|
||||
// btla-specific ++
|
||||
UINT8 *p_raw_data; /* Raw data for discovery DB */
|
||||
UINT32 raw_data_size; /* size of raw data */
|
||||
UINT32 raw_data_size; /* Size of raw data */
|
||||
tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
|
||||
UINT32 num_uuids;
|
||||
UINT8 *p_uuid_list;
|
||||
@ -1075,11 +1075,17 @@ typedef union {
|
||||
tBTA_DM_INQ_RES inq_res; /* Inquiry result for a peer device. */
|
||||
tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
|
||||
tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
|
||||
tBTA_DM_DISC_BLE_RES disc_ble_res; /* discovery result for GATT based service */
|
||||
tBTA_DM_DISC_BLE_RES disc_ble_res; /* Discovery result for GATT based service */
|
||||
tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
|
||||
|
||||
} tBTA_DM_SEARCH;
|
||||
|
||||
/* Structure of search callback event and structures */
|
||||
typedef struct {
|
||||
tBTA_DM_SEARCH_EVT event; /* Search callback events */
|
||||
UINT16 len; /* Length of p_data */
|
||||
tBTA_DM_SEARCH *p_data; /* Union of all search callback structures */
|
||||
} tBTA_DM_SEARCH_PARAM;
|
||||
|
||||
/* Search callback */
|
||||
typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
|
||||
|
||||
@ -1089,7 +1095,7 @@ typedef void (tBTA_DM_EXEC_CBACK) (void *p_param);
|
||||
/* Encryption callback*/
|
||||
typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS result);
|
||||
|
||||
/* relate to ESP_BLE_SEC_xxx in esp_gatt_defs.h */
|
||||
/* Relate to ESP_BLE_SEC_xxx in esp_gatt_defs.h */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
|
||||
#define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT
|
||||
@ -1416,7 +1422,7 @@ extern void BTA_DisableTestMode(void);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(char *p_name);
|
||||
extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
|
||||
extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA_ADD_WHITELIST_CBACK *add_wl_cb);
|
||||
|
||||
@ -1902,6 +1908,7 @@ extern void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
** scan_interval - scan interval
|
||||
** scan_window - scan window
|
||||
** scan_mode - scan mode
|
||||
** scan_duplicate_filter - scan duplicate filter
|
||||
** scan_param_setup_status_cback - Set scan param status callback
|
||||
**
|
||||
** Returns void
|
||||
@ -1909,7 +1916,7 @@ extern void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy,
|
||||
UINT8 addr_type_own, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback);
|
||||
UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -61,18 +61,6 @@ extern void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr,
|
||||
BT_OCTET16 c, BT_OCTET16 r);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_ci_data_ready
|
||||
**
|
||||
** Description This function sends an event to indicating that the phone
|
||||
** has SCO data ready..
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -26,29 +26,6 @@
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
|
||||
|
||||
#ifndef BTA_SCO_OUT_PKT_SIZE
|
||||
#define BTA_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX
|
||||
#endif
|
||||
|
||||
#define BTA_SCO_CODEC_PCM 0 /* used for regular SCO */
|
||||
#define BTA_SCO_CODEC_SBC 1 /* used for WBS */
|
||||
typedef UINT8 tBTA_SCO_CODEC_TYPE;
|
||||
|
||||
#define BTA_DM_SCO_SAMP_RATE_8K 8000
|
||||
#define BTA_DM_SCO_SAMP_RATE_16K 16000
|
||||
|
||||
/* SCO codec information */
|
||||
typedef struct {
|
||||
tBTA_SCO_CODEC_TYPE codec_type;
|
||||
} tBTA_CODEC_INFO;
|
||||
|
||||
#define BTA_DM_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM
|
||||
#define BTA_DM_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI
|
||||
|
||||
typedef tBTM_SCO_ROUTE_TYPE tBTA_DM_SCO_ROUTE_TYPE;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
@ -135,72 +112,6 @@ extern void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r);
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_co_rmt_oob(BD_ADDR bd_addr);
|
||||
|
||||
/*****************************************************************************
|
||||
** SCO over HCI Function Declarations
|
||||
*****************************************************************************/
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_init
|
||||
**
|
||||
** Description This function can be used by the phone to initialize audio
|
||||
** codec or for other initialization purposes before SCO connection
|
||||
** is opened.
|
||||
**
|
||||
**
|
||||
** Returns Void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
|
||||
tBTA_CODEC_INFO *p_codec_info, UINT8 app_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_open
|
||||
**
|
||||
** Description This function is executed when a SCO connection is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_close
|
||||
**
|
||||
** Description This function is called when a SCO connection is closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_close(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_out_data
|
||||
**
|
||||
** Description This function is called to send SCO data over HCI.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_out_data(BT_HDR **p_buf);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_co_in_data
|
||||
**
|
||||
** Description This function is called to send incoming SCO data to application.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dm_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
378
components/bt/bluedroid/bta/include/bta/bta_hf_client_api.h
Normal file
378
components/bt/bluedroid/bta/include/bta/bta_hf_client_api.h
Normal file
@ -0,0 +1,378 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (c) 2014 The Android Open Source Project
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the public interface file for the handsfree (HF role) subsystem
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_HF_CLIENT_API_H
|
||||
#define BTA_HF_CLIENT_API_H
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "bta_hfp_defs.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
|
||||
/* HFP peer (AG) features*/
|
||||
#define BTA_HF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */
|
||||
#define BTA_HF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */
|
||||
#define BTA_HF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */
|
||||
#define BTA_HF_CLIENT_PEER_INBAND 0x00000008 /* In-band ring tone */
|
||||
#define BTA_HF_CLIENT_PEER_VTAG 0x00000010 /* Attach a phone number to a voice tag */
|
||||
#define BTA_HF_CLIENT_PEER_REJECT 0x00000020 /* Ability to reject incoming call */
|
||||
#define BTA_HF_CLIENT_PEER_ECS 0x00000040 /* Enhanced Call Status */
|
||||
#define BTA_HF_CLIENT_PEER_ECC 0x00000080 /* Enhanced Call Control */
|
||||
#define BTA_HF_CLIENT_PEER_EXTERR 0x00000100 /* Extended error codes */
|
||||
#define BTA_HF_CLIENT_PEER_CODEC 0x00000200 /* Codec Negotiation */
|
||||
|
||||
typedef UINT16 tBTA_HF_CLIENT_PEER_FEAT;
|
||||
|
||||
/* HFP HF features */
|
||||
#define BTA_HF_CLIENT_FEAT_ECNR 0x00000001 /* Echo cancellation and/or noise reduction */
|
||||
#define BTA_HF_CLIENT_FEAT_3WAY 0x00000002 /* Call waiting and three-way calling */
|
||||
#define BTA_HF_CLIENT_FEAT_CLI 0x00000004 /* Caller ID presentation capability */
|
||||
#define BTA_HF_CLIENT_FEAT_VREC 0x00000008 /* Voice recognition activation */
|
||||
#define BTA_HF_CLIENT_FEAT_VOL 0x00000010 /* Remote volume control */
|
||||
#define BTA_HF_CLIENT_FEAT_ECS 0x00000020 /* Enhanced Call Status */
|
||||
#define BTA_HF_CLIENT_FEAT_ECC 0x00000040 /* Enhanced Call Control */
|
||||
#define BTA_HF_CLIENT_FEAT_CODEC 0x00000080 /* Codec Negotiation */
|
||||
|
||||
/* HFP HF extended call handling - masks not related to any spec */
|
||||
#define BTA_HF_CLIENT_CHLD_REL 0x00000001 /* 0 Release waiting call or held calls */
|
||||
#define BTA_HF_CLIENT_CHLD_REL_ACC 0x00000002 /* 1 Release active calls and accept other (waiting or held) cal */
|
||||
#define BTA_HF_CLIENT_CHLD_REL_X 0x00000004 /* 1x Release x call*/
|
||||
#define BTA_HF_CLIENT_CHLD_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other call */
|
||||
#define BTA_HF_CLIENT_CHLD_PRIV_X 0x00000010 /* 2x Active multiparty call on hold except call x */
|
||||
#define BTA_HF_CLIENT_CHLD_MERGE 0x00000020 /* 3 Add held call to multiparty */
|
||||
#define BTA_HF_CLIENT_CHLD_MERGE_DETACH 0x00000040 /* 4 Add held call to multiparty */
|
||||
|
||||
typedef UINT16 tBTA_HF_CLIENT_CHLD_FEAT;
|
||||
|
||||
/* HFP AG errors ot OK sent to HF Unit */
|
||||
#define BTA_HF_CLIENT_AT_RESULT_OK 0
|
||||
#define BTA_HF_CLIENT_AT_RESULT_ERROR 1
|
||||
#define BTA_HF_CLIENT_AT_RESULT_NO_CARRIER 2
|
||||
#define BTA_HF_CLIENT_AT_RESULT_BUSY 3
|
||||
#define BTA_HF_CLIENT_AT_RESULT_NO_ANSWER 4
|
||||
#define BTA_HF_CLIENT_AT_RESULT_DELAY 5
|
||||
#define BTA_HF_CLIENT_AT_RESULT_BLACKLISTED 6
|
||||
#define BTA_HF_CLIENT_AT_RESULT_CME 7
|
||||
|
||||
typedef UINT8 tBTA_HF_CLIENT_AT_RESULT_TYPE;
|
||||
|
||||
/* HF Client callback events */
|
||||
#define BTA_HF_CLIENT_ENABLE_EVT 0 /* HF Client enabled */
|
||||
#define BTA_HF_CLIENT_REGISTER_EVT 1 /* HF Client registered */
|
||||
#define BTA_HF_CLIENT_OPEN_EVT 2 /* HF Client connection open */
|
||||
#define BTA_HF_CLIENT_CLOSE_EVT 3 /* HF Client connection closed */
|
||||
#define BTA_HF_CLIENT_CONN_EVT 4 /* Service level connection opened */
|
||||
#define BTA_HF_CLIENT_AUDIO_OPEN_EVT 5 /* Audio connection open */
|
||||
#define BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT 6 /* Audio connection with mSBC codec open */
|
||||
#define BTA_HF_CLIENT_AUDIO_CLOSE_EVT 7 /* Audio connection closed */
|
||||
#define BTA_HF_CLIENT_SPK_EVT 8 /* Speaker volume changed */
|
||||
#define BTA_HF_CLIENT_MIC_EVT 9 /* Microphone volume changed */
|
||||
#define BTA_HF_CLIENT_IND_EVT 10 /* Indicator */
|
||||
#define BTA_HF_CLIENT_VOICE_REC_EVT 11 /* AG changed voice recognition setting */
|
||||
#define BTA_HF_CLIENT_OPERATOR_NAME_EVT 12 /* Operator name acquired */
|
||||
#define BTA_HF_CLIENT_CLIP_EVT 13 /* Calling line identification event */
|
||||
#define BTA_HF_CLIENT_CCWA_EVT 14 /* Call waiting notification */
|
||||
#define BTA_HF_CLIENT_AT_RESULT_EVT 15 /* Call waiting notification */
|
||||
#define BTA_HF_CLIENT_CLCC_EVT 16 /* current call event */
|
||||
#define BTA_HF_CLIENT_CNUM_EVT 17 /* subscriber information event */
|
||||
#define BTA_HF_CLIENT_BTRH_EVT 18 /* bluetooth response and hold event */
|
||||
#define BTA_HF_CLIENT_BSIR_EVT 19 /* in-band ring tone setting changed event */
|
||||
#define BTA_HF_CLIENT_BINP_EVT 20 /* binp number event */
|
||||
#define BTA_HF_CLIENT_RING_INDICATION 21 /* HF Client ring indication */
|
||||
#define BTA_HF_CLIENT_DISABLE_EVT 30 /* HF Client disabled */
|
||||
|
||||
typedef UINT8 tBTA_HF_CLIENT_EVT;
|
||||
|
||||
/* HF Client open status */
|
||||
#define BTA_HF_CLIENT_SUCCESS 0 /* Connection successfully opened */
|
||||
#define BTA_HF_CLIENT_FAIL_SDP 1 /* Open failed due to SDP */
|
||||
#define BTA_HF_CLIENT_FAIL_RFCOMM 2 /* Open failed due to RFCOMM */
|
||||
#define BTA_HF_CLIENT_FAIL_RESOURCES 3 /* out of resources failure */
|
||||
|
||||
typedef UINT8 tBTA_HF_CLIENT_STATUS;
|
||||
|
||||
/* indicator type */
|
||||
#define BTA_HF_CLIENT_IND_BATTCH 0 /* Battery charge indicator */
|
||||
#define BTA_HF_CLIENT_IND_SIGNAL 1 /* Signal Strength indicator */
|
||||
#define BTA_HF_CLIENT_IND_SERVICE 2 /* Service availability indicator */
|
||||
#define BTA_HF_CLIENT_IND_CALL 3 /* Standard call status indicator*/
|
||||
#define BTA_HF_CLIENT_IND_ROAM 4 /* Roaming status indicator */
|
||||
#define BTA_HF_CLIENT_IND_CALLSETUP 5 /* Call setup status indicator */
|
||||
#define BTA_HF_CLIENT_IND_CALLHELD 6 /* Call hold status indicator */
|
||||
|
||||
typedef UINT8 tBTA_HF_CLIENT_IND_TYPE;
|
||||
|
||||
/* AT commands */
|
||||
#define BTA_HF_CLIENT_AT_CMD_VTS 0
|
||||
#define BTA_HF_CLIENT_AT_CMD_BTRH 1
|
||||
#define BTA_HF_CLIENT_AT_CMD_CHUP 2
|
||||
#define BTA_HF_CLIENT_AT_CMD_CHLD 3
|
||||
#define BTA_HF_CLIENT_AT_CMD_BCC 4
|
||||
#define BTA_HF_CLIENT_AT_CMD_CNUM 5
|
||||
#define BTA_HF_CLIENT_AT_CMD_ATA 6
|
||||
#define BTA_HF_CLIENT_AT_CMD_COPS 7
|
||||
#define BTA_HF_CLIENT_AT_CMD_ATD 8
|
||||
#define BTA_HF_CLIENT_AT_CMD_VGM 9
|
||||
#define BTA_HF_CLIENT_AT_CMD_VGS 10
|
||||
#define BTA_HF_CLIENT_AT_CMD_BVRA 11
|
||||
#define BTA_HF_CLIENT_AT_CMD_CLCC 12
|
||||
#define BTA_HF_CLIENT_AT_CMD_BINP 13
|
||||
#define BTA_HF_CLIENT_AT_CMD_BLDN 14
|
||||
#define BTA_HF_CLIENT_AT_CMD_NREC 15
|
||||
|
||||
typedef UINT8 tBTA_HF_CLIENT_AT_CMD_TYPE;
|
||||
|
||||
/* data associated with most non-AT events */
|
||||
/* placeholder, if not needed should be removed*/
|
||||
typedef struct {
|
||||
} tBTA_HF_CLIENT_HDR;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_REGISTER_EVT */
|
||||
typedef struct {
|
||||
tBTA_HF_CLIENT_HDR hdr;
|
||||
UINT16 handle;
|
||||
tBTA_HF_CLIENT_STATUS status;
|
||||
} tBTA_HF_CLIENT_REGISTER;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_HF_CLIENT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_HF_CLIENT_STATUS status;
|
||||
} tBTA_HF_CLIENT_OPEN;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_CONN_EVT */
|
||||
typedef struct {
|
||||
tBTA_HF_CLIENT_HDR hdr;
|
||||
tBTA_HF_CLIENT_PEER_FEAT peer_feat;
|
||||
tBTA_HF_CLIENT_CHLD_FEAT chld_feat;
|
||||
} tBTA_HF_CLIENT_CONN;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_IND_EVT event */
|
||||
typedef struct {
|
||||
tBTA_HF_CLIENT_HDR hdr;
|
||||
tBTA_HF_CLIENT_IND_TYPE type;
|
||||
UINT16 value;
|
||||
} tBTA_HF_CLIENT_IND;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_OPERATOR_NAME_EVT */
|
||||
#define BTA_HF_CLIENT_OPERATOR_NAME_LEN 16
|
||||
typedef struct {
|
||||
char name[BTA_HF_CLIENT_OPERATOR_NAME_LEN + 1];
|
||||
} tBTA_HF_CLIENT_OPERATOR_NAME;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_CLIP_EVT and BTA_HF_CLIENT_CCWA_EVT*/
|
||||
#define BTA_HF_CLIENT_NUMBER_LEN 32
|
||||
typedef struct {
|
||||
char number[BTA_HF_CLIENT_NUMBER_LEN + 1];
|
||||
} tBTA_HF_CLIENT_NUMBER;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_AT_RESULT_EVT event */
|
||||
typedef struct {
|
||||
tBTA_HF_CLIENT_AT_RESULT_TYPE type;
|
||||
UINT16 cme;
|
||||
} tBTA_HF_CLIENT_AT_RESULT;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_CLCC_EVT event */
|
||||
typedef struct {
|
||||
UINT32 idx;
|
||||
BOOLEAN inc;
|
||||
UINT8 status;
|
||||
BOOLEAN mpty;
|
||||
BOOLEAN number_present;
|
||||
char number[BTA_HF_CLIENT_NUMBER_LEN + 1];
|
||||
} tBTA_HF_CLIENT_CLCC;
|
||||
|
||||
/* data associated with BTA_HF_CLIENT_CNUM_EVT event */
|
||||
typedef struct {
|
||||
UINT16 service;
|
||||
char number[BTA_HF_CLIENT_NUMBER_LEN + 1];
|
||||
} tBTA_HF_CLIENT_CNUM;
|
||||
|
||||
/* data associated with other events */
|
||||
typedef struct {
|
||||
UINT16 value;
|
||||
} tBTA_HF_CLIENT_VAL;
|
||||
|
||||
/* union of data associated with AG callback */
|
||||
typedef union {
|
||||
tBTA_HF_CLIENT_HDR hdr;
|
||||
tBTA_HF_CLIENT_REGISTER reg;
|
||||
tBTA_HF_CLIENT_OPEN open;
|
||||
tBTA_HF_CLIENT_CONN conn;
|
||||
tBTA_HF_CLIENT_IND ind;
|
||||
tBTA_HF_CLIENT_VAL val;
|
||||
tBTA_HF_CLIENT_OPERATOR_NAME operator;
|
||||
tBTA_HF_CLIENT_NUMBER number;
|
||||
tBTA_HF_CLIENT_AT_RESULT result;
|
||||
tBTA_HF_CLIENT_CLCC clcc;
|
||||
tBTA_HF_CLIENT_CNUM cnum;
|
||||
} tBTA_HF_CLIENT;
|
||||
|
||||
typedef UINT32 tBTA_HF_CLIENT_FEAT;
|
||||
|
||||
/* HF Client callback */
|
||||
typedef void (tBTA_HF_CLIENT_CBACK)(tBTA_HF_CLIENT_EVT event, void *p_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientEnable
|
||||
**
|
||||
** Description Enable the HF CLient service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_HF_CLIENT_ENABLE_EVT. This function must
|
||||
** be called before other function in the HF CLient API are
|
||||
** called.
|
||||
**
|
||||
** Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientDisable
|
||||
**
|
||||
** Description Disable the HF Client service
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientDisable(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientRegister
|
||||
**
|
||||
** Description Register an HF Client service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
|
||||
char *p_service_name);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientDeregister
|
||||
**
|
||||
** Description Deregister an HF Client service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientDeregister(UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientOpen
|
||||
**
|
||||
** Description Opens a connection to an audio gateway.
|
||||
** When connection is open callback function is called
|
||||
** with a BTA_HF_CLIENT_OPEN_EVT. Only the data connection is
|
||||
** opened. The audio connection is not opened.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientClose
|
||||
**
|
||||
** Description Close the current connection to an audio gateway.
|
||||
** Any current audio connection will also be closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientClose(UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfCllientAudioOpen
|
||||
**
|
||||
** Description Opens an audio connection to the currently connected
|
||||
** audio gateway
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientAudioOpen(UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientAudioClose
|
||||
**
|
||||
** Description Close the currently active audio connection to an audio
|
||||
** gateway. The data connection remains open
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientAudioClose(UINT16 handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_HfClientSendAT
|
||||
**
|
||||
** Description send AT command
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val1, UINT32 val2, const char *str);
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
void BTA_HfClientCiData(void);
|
||||
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
|
||||
int BTA_HfClientGetCbDataSize(tBTA_HF_CLIENT_EVT event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
||||
#endif /* BTA_HF_CLIENT_API_H */
|
115
components/bt/bluedroid/bta/include/bta/bta_hf_client_co.h
Normal file
115
components/bt/bluedroid/bta/include/bta/bta_hf_client_co.h
Normal file
@ -0,0 +1,115 @@
|
||||
// Copyright 2018 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.
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the interface file for hf client call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_HF_CLIENT_CO_H
|
||||
#define BTA_HF_CLIENT_CO_H
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_co_audio_state
|
||||
**
|
||||
** Description This function is called by the HF CLIENT before the audio connection
|
||||
** is brought up, after it comes up, and after it goes down.
|
||||
**
|
||||
** Parameters handle - handle of the AG instance
|
||||
** state - Audio state
|
||||
** codec - if WBS support is compiled in, codec to going to be used is provided
|
||||
** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with
|
||||
** the correct platform parameters.
|
||||
** in the other states codec type should not be ignored
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_co_audio_state(UINT16 handle, UINT8 state, tBTA_HFP_PEER_CODEC codec);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_init
|
||||
**
|
||||
** Description This function can be used by the phone to initialize audio
|
||||
** codec or for other initialization purposes before SCO connection
|
||||
** is opened.
|
||||
**
|
||||
**
|
||||
** Returns Void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_HFP_SCO_ROUTE_TYPE bta_hf_client_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
|
||||
tBTA_HFP_CODEC_INFO *p_codec_info, UINT8 app_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_open
|
||||
**
|
||||
** Description This function is executed when a SCO connection is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_close
|
||||
**
|
||||
** Description This function is called when a SCO connection is closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_co_close(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_out_data
|
||||
**
|
||||
** Description This function is called to send SCO data over HCI.
|
||||
**
|
||||
** Returns number of bytes got from application
|
||||
**
|
||||
*******************************************************************************/
|
||||
uint32_t bta_hf_client_sco_co_out_data(uint8_t *p_buf, uint32_t sz);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_in_data
|
||||
**
|
||||
** Description This function is called to send incoming SCO data to application.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hf_client_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status);
|
||||
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
|
||||
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
||||
#endif /* BTA_HF_CLIENT_CO_H */
|
47
components/bt/bluedroid/bta/include/bta/bta_hfp_defs.h
Normal file
47
components/bt/bluedroid/bta/include/bta/bta_hfp_defs.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Copyright 2018 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 __BTA_HFP_DEFS_H__
|
||||
#define __BTA_HFP_DEFS_H__
|
||||
|
||||
#include "stack/btm_api.h"
|
||||
|
||||
#define BTA_HFP_CODEC_NONE BTM_SCO_CODEC_NONE
|
||||
#define BTA_HFP_CODEC_CVSD BTM_SCO_CODEC_CVSD /* CVSD */
|
||||
#define BTA_HFP_CODEC_MSBC BTM_SCO_CODEC_MSBC /* mSBC */
|
||||
|
||||
typedef UINT16 tBTA_HFP_PEER_CODEC;
|
||||
|
||||
#ifndef BTA_HFP_SCO_OUT_PKT_SIZE
|
||||
#define BTA_HFP_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX
|
||||
#endif
|
||||
|
||||
#define BTA_HFP_SCO_CODEC_PCM 0 /* used for regular SCO */
|
||||
#define BTA_HFP_SCO_CODEC_SBC 1 /* used for WBS */
|
||||
typedef UINT8 tBTA_HFP_SCO_CODEC_TYPE;
|
||||
|
||||
#define BTA_HFP_SCO_SAMP_RATE_8K 8000
|
||||
#define BTA_HFP_SCO_SAMP_RATE_16K 16000
|
||||
|
||||
/* SCO codec information */
|
||||
typedef struct {
|
||||
tBTA_HFP_SCO_CODEC_TYPE codec_type;
|
||||
} tBTA_HFP_CODEC_INFO;
|
||||
|
||||
#define BTA_HFP_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM
|
||||
#define BTA_HFP_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI
|
||||
|
||||
typedef tBTM_SCO_ROUTE_TYPE tBTA_HFP_SCO_ROUTE_TYPE;
|
||||
|
||||
#endif /* __BTA_HFP_DEFS_H__ */
|
@ -951,7 +951,7 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
|
||||
proto_list[2].num_params = 0;
|
||||
}
|
||||
|
||||
char *stage = "protocol_list";
|
||||
const char *stage = "protocol_list";
|
||||
if (!SDP_AddProtocolList(sdp_handle, num_proto_elements, proto_list)){
|
||||
APPL_TRACE_ERROR("create_base_record: failed to create base service "
|
||||
"record, stage: %s, scn: %d, name: %s, with_obex: %d",
|
||||
@ -1000,7 +1000,7 @@ static int add_spp_sdp(const char *name, const int channel) {
|
||||
}
|
||||
|
||||
// Create the base SDP record.
|
||||
char *stage = "create_base_record";
|
||||
const char *stage = "create_base_record";
|
||||
if (!create_base_record(handle, name, channel, FALSE /* with_obex */)){
|
||||
SDP_DeleteRecord(handle);
|
||||
APPL_TRACE_ERROR("add_spp_sdp: failed to register SPP service, "
|
||||
@ -2769,4 +2769,4 @@ extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data)
|
||||
}
|
||||
|
||||
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
|
@ -59,8 +59,8 @@ static osi_mutex_t bta_alarm_lock;
|
||||
|
||||
/* trace level */
|
||||
/* TODO Bluedroid - Hard-coded trace levels - Needs to be configurable */
|
||||
UINT8 appl_trace_level = BT_TRACE_LEVEL_WARNING; //APPL_INITIAL_TRACE_LEVEL;
|
||||
UINT8 btif_trace_level = BT_TRACE_LEVEL_WARNING;
|
||||
UINT8 appl_trace_level = APPL_INITIAL_TRACE_LEVEL;
|
||||
UINT8 btif_trace_level = BTIF_INITIAL_TRACE_LEVEL;
|
||||
|
||||
void btu_bta_alarm_ready(fixed_queue_t *queue);
|
||||
|
||||
@ -607,7 +607,7 @@ void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)
|
||||
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_ERROR("%s unable to create alarm.", __func__);
|
||||
APPL_TRACE_ERROR("%s unable to create alarm.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -651,7 +651,7 @@ void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle)
|
||||
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
|
||||
APPL_TRACE_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
|
||||
return;
|
||||
}
|
||||
osi_alarm_cancel(alarm);
|
||||
@ -672,7 +672,7 @@ void bta_sys_free_timer(TIMER_LIST_ENT *p_tle)
|
||||
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
|
||||
APPL_TRACE_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
|
||||
return;
|
||||
}
|
||||
osi_alarm_cancel(alarm);
|
||||
|
@ -19,7 +19,7 @@ void btc_alarm_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_alarm_args_t *arg = (btc_alarm_args_t *)msg->arg;
|
||||
|
||||
LOG_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
|
||||
|
||||
if (arg->cb) {
|
||||
arg->cb(arg->cb_data);
|
||||
|
@ -645,7 +645,7 @@ static void _btc_read_le_key(const uint8_t key_type, const size_t key_len, bt_bd
|
||||
}
|
||||
|
||||
char bd_str[20] = {0};
|
||||
LOG_DEBUG("%s() Adding key type %d for %s", __func__,
|
||||
BTC_TRACE_DEBUG("%s() Adding key type %d for %s", __func__,
|
||||
key_type, bdaddr_to_string(&bd_addr, bd_str, sizeof(bd_str)));
|
||||
BTA_DmAddBleKey(bta_bd_addr, (tBTA_LE_KEY_VALUE *)buffer, key_type);
|
||||
}
|
||||
@ -663,7 +663,7 @@ static bt_status_t _btc_storage_in_fetch_bonded_ble_device(const char *remote_bd
|
||||
bool key_found = false;
|
||||
|
||||
if (!btc_config_get_int(remote_bd_addr, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type)) {
|
||||
LOG_ERROR("%s, device_type = %x", __func__, device_type);
|
||||
BTC_TRACE_ERROR("%s, device_type = %x", __func__, device_type);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
@ -715,9 +715,9 @@ static bt_status_t btc_storage_in_fetch_bonded_ble_devices(int add)
|
||||
((device_type & BT_DEVICE_TYPE_BLE) != BT_DEVICE_TYPE_BLE)) {
|
||||
continue;
|
||||
}
|
||||
LOG_DEBUG("%s, name = %s", __func__, name);
|
||||
BTC_TRACE_DEBUG("%s, name = %s", __func__, name);
|
||||
if (_btc_storage_in_fetch_bonded_ble_device(name, add) != BT_STATUS_SUCCESS) {
|
||||
LOG_DEBUG("Remote device:%s, no link key or ble key found", name);
|
||||
BTC_TRACE_DEBUG("Remote device:%s, no link key or ble key found", name);
|
||||
} else {
|
||||
status = BT_STATUS_SUCCESS;
|
||||
}
|
||||
@ -743,7 +743,7 @@ bt_status_t btc_storage_load_bonded_ble_devices(void)
|
||||
{
|
||||
bt_status_t status;
|
||||
status = btc_storage_in_fetch_bonded_ble_devices(1);
|
||||
LOG_DEBUG("Storage load rslt %d\n", status);
|
||||
BTC_TRACE_DEBUG("Storage load rslt %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -73,10 +73,10 @@ bool btc_config_init(void)
|
||||
osi_mutex_new(&lock);
|
||||
config = config_new(CONFIG_FILE_PATH);
|
||||
if (!config) {
|
||||
LOG_WARN("%s unable to load config file; starting unconfigured.\n", __func__);
|
||||
BTC_TRACE_WARNING("%s unable to load config file; starting unconfigured.\n", __func__);
|
||||
config = config_new_empty();
|
||||
if (!config) {
|
||||
LOG_ERROR("%s unable to allocate a config object.\n", __func__);
|
||||
BTC_TRACE_ERROR("%s unable to allocate a config object.\n", __func__);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ error:;
|
||||
config_free(config);
|
||||
osi_mutex_free(&lock);
|
||||
config = NULL;
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ void btc_dev_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_dev_args_t *arg = (btc_dev_args_t *)msg->arg;
|
||||
|
||||
LOG_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:
|
||||
|
@ -27,11 +27,12 @@
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
#include "btc_gap_bt.h"
|
||||
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
||||
/******************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
@ -56,6 +57,9 @@ static btc_dm_local_key_cb_t ble_local_key_cb;
|
||||
extern bt_status_t btc_av_execute_service(BOOLEAN b_enable);
|
||||
extern bt_status_t btc_av_sink_execute_service(BOOLEAN b_enable);
|
||||
#endif
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
extern bt_status_t btc_hf_client_execute_service(BOOLEAN b_enable);
|
||||
#endif
|
||||
/******************************************************************************
|
||||
** Functions
|
||||
******************************************************************************/
|
||||
@ -119,7 +123,7 @@ static void btc_enable_bluetooth_evt(tBTA_STATUS status)
|
||||
|
||||
static void btc_disable_bluetooth_evt(void)
|
||||
{
|
||||
LOG_DEBUG("%s", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_SUCCESS);
|
||||
}
|
||||
@ -132,7 +136,7 @@ void btc_dm_load_ble_local_keys(void)
|
||||
if (btc_storage_get_ble_local_key(BTC_LE_LOCAL_KEY_ER,(char*)&ble_local_key_cb.er[0],
|
||||
BT_OCTET16_LEN)== BT_STATUS_SUCCESS) {
|
||||
ble_local_key_cb.is_er_rcvd = TRUE;
|
||||
LOG_DEBUG("%s BLE ER key loaded",__func__ );
|
||||
BTC_TRACE_DEBUG("%s BLE ER key loaded",__func__ );
|
||||
}
|
||||
|
||||
if ((btc_storage_get_ble_local_key(BTC_LE_LOCAL_KEY_IR,(char*)&ble_local_key_cb.id_keys.ir[0],
|
||||
@ -142,7 +146,7 @@ void btc_dm_load_ble_local_keys(void)
|
||||
(btc_storage_get_ble_local_key(BTC_LE_LOCAL_KEY_DHK,(char*)&ble_local_key_cb.id_keys.dhk[0],
|
||||
BT_OCTET16_LEN)== BT_STATUS_SUCCESS)) {
|
||||
ble_local_key_cb.is_id_keys_rcvd = TRUE;
|
||||
LOG_DEBUG("%s BLE ID keys loaded", __func__);
|
||||
BTC_TRACE_DEBUG("%s BLE ID keys loaded", __func__);
|
||||
}
|
||||
|
||||
}
|
||||
@ -160,14 +164,14 @@ void btc_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET1
|
||||
memcpy(&p_id_keys->dhk[0], &ble_local_key_cb.id_keys.dhk[0], sizeof(BT_OCTET16));
|
||||
*p_key_mask |= BTA_BLE_LOCAL_KEY_TYPE_ID;
|
||||
}
|
||||
LOG_DEBUG("%s *p_key_mask=0x%02x",__func__, *p_key_mask);
|
||||
BTC_TRACE_DEBUG("%s *p_key_mask=0x%02x",__func__, *p_key_mask);
|
||||
}
|
||||
|
||||
|
||||
static void btc_dm_remove_ble_bonding_keys(void)
|
||||
{
|
||||
bt_bdaddr_t bd_addr;
|
||||
LOG_DEBUG("%s\n",__func__);
|
||||
BTC_TRACE_DEBUG("%s\n",__func__);
|
||||
|
||||
bdcpy(bd_addr.address, pairing_cb.bd_addr);
|
||||
|
||||
@ -183,7 +187,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
bdcpy(bd_addr.address, pairing_cb.bd_addr);
|
||||
|
||||
btc_storage_set_ble_dev_type(&bd_addr, false);
|
||||
LOG_DEBUG("%s, penc = %d, pid = %d", __func__, pairing_cb.ble.is_penc_key_rcvd, pairing_cb.ble.is_pid_key_rcvd);
|
||||
BTC_TRACE_DEBUG("%s, penc = %d, pid = %d", __func__, pairing_cb.ble.is_penc_key_rcvd, pairing_cb.ble.is_pid_key_rcvd);
|
||||
if (pairing_cb.ble.is_penc_key_rcvd) {
|
||||
btc_storage_add_ble_bonding_key(&bd_addr,
|
||||
(char *) &pairing_cb.ble.penc_key,
|
||||
@ -232,7 +236,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
{
|
||||
/* Save link key, if not temporary */
|
||||
LOG_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success);
|
||||
BTC_TRACE_DEBUG("%s, status = %d", __func__, p_auth_cmpl->success);
|
||||
bt_status_t status = BT_STATUS_FAIL;
|
||||
int addr_type;
|
||||
bt_bdaddr_t bdaddr;
|
||||
@ -241,10 +245,10 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
|
||||
if (p_auth_cmpl->success) {
|
||||
status = BT_STATUS_SUCCESS;
|
||||
LOG_DEBUG ("%s, - p_auth_cmpl->bd_addr: %08x%04x", __func__,
|
||||
BTC_TRACE_DEBUG ("%s, - p_auth_cmpl->bd_addr: %08x%04x", __func__,
|
||||
(p_auth_cmpl->bd_addr[0] << 24) + (p_auth_cmpl->bd_addr[1] << 16) + (p_auth_cmpl->bd_addr[2] << 8) + p_auth_cmpl->bd_addr[3],
|
||||
(p_auth_cmpl->bd_addr[4] << 8) + p_auth_cmpl->bd_addr[5]);
|
||||
LOG_DEBUG ("%s, - pairing_cb.bd_addr: %08x%04x", __func__,
|
||||
BTC_TRACE_DEBUG ("%s, - pairing_cb.bd_addr: %08x%04x", __func__,
|
||||
(pairing_cb.bd_addr[0] << 24) + (pairing_cb.bd_addr[1] << 16) + (pairing_cb.bd_addr[2] << 8) + pairing_cb.bd_addr[3],
|
||||
(pairing_cb.bd_addr[4] << 8) + pairing_cb.bd_addr[5]);
|
||||
if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) {
|
||||
@ -270,7 +274,7 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s, authentication status = %x", __func__, status);
|
||||
BTC_TRACE_DEBUG("%s, authentication status = %x", __func__, status);
|
||||
return;
|
||||
|
||||
}
|
||||
@ -281,7 +285,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
/* Save link key, if not temporary */
|
||||
bt_bdaddr_t bd_addr;
|
||||
bt_status_t status;
|
||||
LOG_DEBUG("%s: bond state success %d, present %d, type%d\n", __func__, p_auth_cmpl->success,
|
||||
BTC_TRACE_DEBUG("%s: bond state success %d, present %d, type%d\n", __func__, p_auth_cmpl->success,
|
||||
p_auth_cmpl->key_present, p_auth_cmpl->key_type);
|
||||
|
||||
bdcpy(bd_addr.address, p_auth_cmpl->bd_addr);
|
||||
@ -295,25 +299,26 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
#endif
|
||||
if (1) {
|
||||
bt_status_t ret;
|
||||
LOG_DEBUG("%s: Storing link key. key_type=0x%x",
|
||||
BTC_TRACE_DEBUG("%s: Storing link key. key_type=0x%x",
|
||||
__FUNCTION__, p_auth_cmpl->key_type);
|
||||
ret = btc_storage_add_bonded_device(&bd_addr,
|
||||
p_auth_cmpl->key, p_auth_cmpl->key_type,
|
||||
16);
|
||||
BTC_ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret);
|
||||
} else {
|
||||
LOG_DEBUG("%s: Temporary key. Not storing. key_type=0x%x",
|
||||
BTC_TRACE_DEBUG("%s: Temporary key. Not storing. key_type=0x%x",
|
||||
__FUNCTION__, p_auth_cmpl->key_type);
|
||||
}
|
||||
}
|
||||
|
||||
// Skip SDP for certain HID Devices
|
||||
if (p_auth_cmpl->success) {
|
||||
status = BT_STATUS_SUCCESS;
|
||||
} else {
|
||||
// Map the HCI fail reason to bt status
|
||||
switch (p_auth_cmpl->fail_reason) {
|
||||
case HCI_ERR_PAGE_TIMEOUT:
|
||||
LOG_WARN("%s() - Pairing timeout; retrying () ...", __FUNCTION__);
|
||||
BTC_TRACE_WARNING("%s() - Pairing timeout; retrying () ...", __FUNCTION__);
|
||||
return;
|
||||
/* Fall-through */
|
||||
case HCI_ERR_CONNECTION_TOUT:
|
||||
@ -339,7 +344,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
case HCI_ERR_INSUFFCIENT_SECURITY:
|
||||
case HCI_ERR_PEER_USER:
|
||||
case HCI_ERR_UNSPECIFIED:
|
||||
LOG_DEBUG(" %s() Authentication fail reason %d",
|
||||
BTC_TRACE_DEBUG(" %s() Authentication fail reason %d",
|
||||
__FUNCTION__, p_auth_cmpl->fail_reason);
|
||||
/* if autopair attempts are more than 1, or not attempted */
|
||||
status = BT_STATUS_AUTH_FAILURE;
|
||||
@ -348,6 +353,25 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
status = BT_STATUS_FAIL;
|
||||
}
|
||||
}
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_AUTH_CMPL_EVT;
|
||||
param.auth_cmpl.stat = status;
|
||||
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
|
||||
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_DEBUG("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
|
||||
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
|
||||
(void) status;
|
||||
}
|
||||
|
||||
@ -364,7 +388,7 @@ void btc_clear_services_mask(void)
|
||||
static bt_status_t btc_in_execute_service_request(tBTA_SERVICE_ID service_id,
|
||||
BOOLEAN b_enable)
|
||||
{
|
||||
LOG_DEBUG("%s service_id: %d\n", __FUNCTION__, service_id);
|
||||
BTC_TRACE_DEBUG("%s service_id: %d\n", __FUNCTION__, service_id);
|
||||
/* Check the service_ID and invoke the profile's BT state changed API */
|
||||
switch (service_id) {
|
||||
#if BTC_AV_INCLUDED
|
||||
@ -375,8 +399,13 @@ static bt_status_t btc_in_execute_service_request(tBTA_SERVICE_ID service_id,
|
||||
btc_av_sink_execute_service(b_enable);
|
||||
break;
|
||||
#endif
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
case BTA_HFP_HS_SERVICE_ID:
|
||||
btc_hf_client_execute_service(b_enable);
|
||||
break;
|
||||
#endif /* #if BTC_HF_CLIENT_INCLUDED */
|
||||
default:
|
||||
LOG_ERROR("%s: Unknown service being enabled\n", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s: Unknown service being enabled\n", __FUNCTION__);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
return BT_STATUS_SUCCESS;
|
||||
@ -393,7 +422,7 @@ bt_status_t btc_dm_enable_service(tBTA_SERVICE_ID service_id)
|
||||
|
||||
btc_enabled_services |= (1 << service_id);
|
||||
|
||||
LOG_DEBUG("%s: current services:0x%x", __FUNCTION__, btc_enabled_services);
|
||||
BTC_TRACE_DEBUG("%s: current services:0x%x", __FUNCTION__, btc_enabled_services);
|
||||
|
||||
btc_dm_execute_service_request(TRUE, (char *)p_id);
|
||||
|
||||
@ -406,7 +435,7 @@ bt_status_t btc_dm_disable_service(tBTA_SERVICE_ID service_id)
|
||||
|
||||
btc_enabled_services &= (tBTA_SERVICE_MASK)(~(1 << service_id));
|
||||
|
||||
LOG_DEBUG("%s: Current Services:0x%x", __FUNCTION__, btc_enabled_services);
|
||||
BTC_TRACE_DEBUG("%s: Current Services:0x%x", __FUNCTION__, btc_enabled_services);
|
||||
|
||||
btc_dm_execute_service_request(FALSE, (char *)p_id);
|
||||
|
||||
@ -424,7 +453,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
ble_msg.sig = BTC_SIG_API_CB;
|
||||
ble_msg.pid = BTC_PID_GAP_BLE;
|
||||
// tBTA_SERVICE_MASK service_mask;
|
||||
LOG_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act);
|
||||
BTC_TRACE_DEBUG("btc_dm_upstreams_cback ev: %d\n", msg->act);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTA_DM_ENABLE_EVT: {
|
||||
@ -437,7 +466,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
|
||||
/* Set initial device name, it can be overwritten later */
|
||||
if (p_data->enable.status == BTA_SUCCESS) {
|
||||
char *initial_device_name = "ESP32";
|
||||
const char *initial_device_name = "ESP32";
|
||||
BTA_DmSetDeviceName(initial_device_name);
|
||||
}
|
||||
btc_enable_bluetooth_evt(p_data->enable.status);
|
||||
@ -467,7 +496,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bd_addr;
|
||||
rsp_app = true;
|
||||
LOG_ERROR("BTA_DM_DEV_UNPAIRED_EVT");
|
||||
BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT");
|
||||
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
||||
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
|
||||
param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
|
||||
@ -495,7 +524,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
case BTA_DM_LINK_DOWN_EVT:
|
||||
case BTA_DM_HW_ERROR_EVT:
|
||||
LOG_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
break;
|
||||
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
case BTA_DM_BLE_AUTH_CMPL_EVT: {
|
||||
@ -519,7 +548,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
memcpy(param.ble_security.ble_key.bd_addr, p_data->ble_key.bd_addr, BD_ADDR_LEN);
|
||||
switch (p_data->ble_key.key_type) {
|
||||
case BTM_LE_KEY_PENC: {
|
||||
LOG_DEBUG("Rcv BTA_LE_KEY_PENC");
|
||||
BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_PENC");
|
||||
pairing_cb.ble.is_penc_key_rcvd = TRUE;
|
||||
pairing_cb.ble.penc_key = p_data->ble_key.p_key_value->penc_key;
|
||||
memcpy(&pairing_cb.ble.penc_key, &p_data->ble_key.p_key_value->penc_key,
|
||||
@ -529,7 +558,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTM_LE_KEY_PID: {
|
||||
LOG_DEBUG("Rcv BTA_LE_KEY_PID");
|
||||
BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_PID");
|
||||
pairing_cb.ble.is_pid_key_rcvd = TRUE;
|
||||
memcpy(&pairing_cb.ble.pid_key, &p_data->ble_key.p_key_value->pid_key,
|
||||
sizeof(tBTM_LE_PID_KEYS));
|
||||
@ -538,7 +567,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTM_LE_KEY_PCSRK: {
|
||||
LOG_DEBUG("Rcv BTA_LE_KEY_PCSRK");
|
||||
BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_PCSRK");
|
||||
pairing_cb.ble.is_pcsrk_key_rcvd = TRUE;
|
||||
memcpy(&pairing_cb.ble.pcsrk_key, &p_data->ble_key.p_key_value->pcsrk_key,
|
||||
sizeof(tBTM_LE_PCSRK_KEYS));
|
||||
@ -547,7 +576,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTM_LE_KEY_LENC: {
|
||||
LOG_DEBUG("Rcv BTA_LE_KEY_LENC");
|
||||
BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_LENC");
|
||||
pairing_cb.ble.is_lenc_key_rcvd = TRUE;
|
||||
memcpy(&pairing_cb.ble.lenc_key, &p_data->ble_key.p_key_value->lenc_key,
|
||||
sizeof(tBTM_LE_LENC_KEYS));
|
||||
@ -556,7 +585,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTM_LE_KEY_LCSRK: {
|
||||
LOG_DEBUG("Rcv BTA_LE_KEY_LCSRK");
|
||||
BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_LCSRK");
|
||||
pairing_cb.ble.is_lcsrk_key_rcvd = TRUE;
|
||||
memcpy(&pairing_cb.ble.lcsrk_key, &p_data->ble_key.p_key_value->lcsrk_key,
|
||||
sizeof(tBTM_LE_LCSRK_KEYS));
|
||||
@ -565,7 +594,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTM_LE_KEY_LID: {
|
||||
LOG_DEBUG("Rcv BTA_LE_KEY_LID");
|
||||
BTC_TRACE_DEBUG("Rcv BTA_LE_KEY_LID");
|
||||
pairing_cb.ble.is_lidk_key_rcvd = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -604,7 +633,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
rsp_app = true;
|
||||
ble_msg.act = ESP_GAP_BLE_LOCAL_IR_EVT;
|
||||
memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS));
|
||||
LOG_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
|
||||
BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_IR_EVT. ");
|
||||
ble_local_key_cb.is_id_keys_rcvd = TRUE;
|
||||
memcpy(&ble_local_key_cb.id_keys.irk[0],
|
||||
&p_data->ble_id_keys.irk[0], sizeof(BT_OCTET16));
|
||||
@ -627,7 +656,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
rsp_app = true;
|
||||
ble_msg.act = ESP_GAP_BLE_LOCAL_ER_EVT;
|
||||
memcpy(¶m.ble_security.ble_id_keys, &p_data->ble_id_keys, sizeof(tBTA_BLE_LOCAL_ID_KEYS));
|
||||
LOG_DEBUG("BTA_DM_BLE_LOCAL_ER_EVT. ");
|
||||
BTC_TRACE_DEBUG("BTA_DM_BLE_LOCAL_ER_EVT. ");
|
||||
ble_local_key_cb.is_er_rcvd = TRUE;
|
||||
memcpy(&ble_local_key_cb.er[0], &p_data->ble_er[0], sizeof(BT_OCTET16));
|
||||
btc_storage_add_ble_local_key( (char *)&ble_local_key_cb.er[0],
|
||||
@ -649,10 +678,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
case BTA_DM_SP_RMT_OOB_EVT:
|
||||
case BTA_DM_SP_KEYPRESS_EVT:
|
||||
case BTA_DM_ROLE_CHG_EVT:
|
||||
LOG_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
break;
|
||||
default:
|
||||
LOG_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -661,7 +690,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
btc_dm_sec_arg_deep_free(msg);
|
||||
|
@ -44,7 +44,9 @@ static void btc_enable_bluetooth(void)
|
||||
|
||||
static void btc_disable_bluetooth(void)
|
||||
{
|
||||
#if (SMP_INCLUDED)
|
||||
btc_config_shut_down();
|
||||
#endif
|
||||
if (BTA_DisableBluetooth() != BTA_SUCCESS) {
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_FAIL);
|
||||
}
|
||||
@ -89,7 +91,7 @@ static void btc_deinit_bluetooth(void)
|
||||
|
||||
void btc_main_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
LOG_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_MAIN_ACT_INIT:
|
||||
@ -105,7 +107,7 @@ void btc_main_call_handler(btc_msg_t *msg)
|
||||
btc_disable_bluetooth();
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ static void queue_int_add(connect_node_t *p_param)
|
||||
|
||||
for (const list_node_t *node = list_begin(connect_queue); node != list_end(connect_queue); node = list_next(node)) {
|
||||
if (((connect_node_t *)list_node(node))->uuid == p_param->uuid) {
|
||||
LOG_DEBUG("%s dropping duplicate connect request for uuid: %04x", __func__, p_param->uuid);
|
||||
BTC_TRACE_DEBUG("%s dropping duplicate connect request for uuid: %04x", __func__, p_param->uuid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ btc_sm_handle_t btc_sm_init(const btc_sm_handler_t *p_handlers, btc_sm_state_t i
|
||||
btc_sm_cb_t *p_cb;
|
||||
|
||||
if (p_handlers == NULL) {
|
||||
LOG_ERROR("%s : p_handlers is NULL", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s : p_handlers is NULL", __FUNCTION__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ void btc_sm_shutdown(btc_sm_handle_t handle)
|
||||
btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle;
|
||||
|
||||
if (p_cb == NULL) {
|
||||
LOG_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
osi_free(p_cb);
|
||||
@ -120,7 +120,7 @@ btc_sm_state_t btc_sm_get_state(btc_sm_handle_t handle)
|
||||
btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle;
|
||||
|
||||
if (p_cb == NULL) {
|
||||
LOG_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ bt_status_t btc_sm_dispatch(btc_sm_handle_t handle, btc_sm_event_t event,
|
||||
btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle;
|
||||
|
||||
if (p_cb == NULL) {
|
||||
LOG_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ bt_status_t btc_sm_change_state(btc_sm_handle_t handle, btc_sm_state_t state)
|
||||
btc_sm_cb_t *p_cb = (btc_sm_cb_t *)handle;
|
||||
|
||||
if (p_cb == NULL) {
|
||||
LOG_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s : Invalid handle", __FUNCTION__);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
// 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.
|
||||
#include <string.h>
|
||||
|
||||
#include "btc/btc_storage.h"
|
||||
#include "btc/btc_util.h"
|
||||
@ -41,7 +42,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
||||
bdstr_t bdstr;
|
||||
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||
LOG_DEBUG("add to storage: Remote device:%s\n", bdstr);
|
||||
BTC_TRACE_DEBUG("add to storage: Remote device:%s\n", bdstr);
|
||||
|
||||
btc_config_lock();
|
||||
int ret = btc_config_set_int(bdstr, BTC_STORAGE_LINK_KEY_TYPE_STR, (int)key_type);
|
||||
@ -51,7 +52,7 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
||||
btc_config_flush();
|
||||
btc_config_unlock();
|
||||
|
||||
LOG_DEBUG("Storage add rslt %d\n", ret);
|
||||
BTC_TRACE_DEBUG("Storage add rslt %d\n", ret);
|
||||
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
@ -76,7 +77,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG_DEBUG("Remote device:%s\n", name);
|
||||
BTC_TRACE_DEBUG("Remote device:%s\n", name);
|
||||
LINK_KEY link_key;
|
||||
size_t size = sizeof(link_key);
|
||||
if (btc_config_get_bin(name, BTC_STORAGE_LINK_KEY_STR, link_key, &size)) {
|
||||
@ -99,11 +100,11 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
}
|
||||
bt_linkkey_file_found = TRUE;
|
||||
} else {
|
||||
LOG_ERROR("bounded device:%s, LinkKeyType or PinLength is invalid\n", name);
|
||||
BTC_TRACE_ERROR("bounded device:%s, LinkKeyType or PinLength is invalid\n", name);
|
||||
}
|
||||
}
|
||||
if (!bt_linkkey_file_found) {
|
||||
LOG_DEBUG("Remote device:%s, no link key\n", name);
|
||||
BTC_TRACE_DEBUG("Remote device:%s, no link key\n", name);
|
||||
}
|
||||
}
|
||||
btc_config_unlock();
|
||||
@ -128,7 +129,7 @@ bt_status_t btc_storage_load_bonded_devices(void)
|
||||
{
|
||||
bt_status_t status;
|
||||
status = btc_in_fetch_bonded_devices(1);
|
||||
LOG_DEBUG("Storage load rslt %d\n", status);
|
||||
BTC_TRACE_DEBUG("Storage load rslt %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -147,7 +148,7 @@ bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr)
|
||||
bdstr_t bdstr;
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||
int ret = 1;
|
||||
LOG_DEBUG("Add to storage: Remote device:%s\n", bdstr);
|
||||
BTC_TRACE_DEBUG("Add to storage: Remote device:%s\n", bdstr);
|
||||
|
||||
btc_config_lock();
|
||||
if (btc_config_exist(bdstr, BTC_STORAGE_LINK_KEY_TYPE_STR)) {
|
||||
@ -165,3 +166,70 @@ bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr)
|
||||
|
||||
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_get_num_bt_bond_devices
|
||||
**
|
||||
** Description BTC storage API - get the num of the bonded device from NVRAM
|
||||
**
|
||||
** Returns the num of the bonded device
|
||||
**
|
||||
*******************************************************************************/
|
||||
int btc_storage_get_num_bt_bond_devices(void)
|
||||
{
|
||||
int num_dev = 0;
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end();
|
||||
iter = btc_config_section_next(iter)) {
|
||||
const char *name = btc_config_section_name(iter);
|
||||
if (string_is_bdaddr(name) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
||||
num_dev++;
|
||||
}
|
||||
}
|
||||
btc_config_unlock();
|
||||
|
||||
return num_dev;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_get_bonded_bt_devices_list
|
||||
**
|
||||
** Description BTC storage API - get the list of the bonded device from NVRAM
|
||||
**
|
||||
** Returns BT_STATUS_SUCCESS if get the list successful,
|
||||
** BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num)
|
||||
{
|
||||
bt_bdaddr_t bd_addr;
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end();
|
||||
iter = btc_config_section_next(iter)) {
|
||||
|
||||
if (dev_num-- <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
const char *name = btc_config_section_name(iter);
|
||||
|
||||
if (string_is_bdaddr(name) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_TYPE_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_PIN_LENGTH_STR) &&
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
||||
string_to_bdaddr(name, &bd_addr);
|
||||
memcpy(bond_dev, &bd_addr, sizeof(bt_bdaddr_t));
|
||||
bond_dev++;
|
||||
}
|
||||
}
|
||||
btc_config_unlock();
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
@ -42,6 +42,9 @@
|
||||
#if CONFIG_BT_SPP_ENABLED
|
||||
#include "btc_spp.h"
|
||||
#endif /* #if CONFIG_BT_SPP_ENABLED */
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
#include "btc_hf_client.h"
|
||||
#endif /* #if BTC_HF_CLIENT_INCLUDED */
|
||||
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
|
||||
|
||||
|
||||
@ -70,7 +73,7 @@ static btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
|
||||
#if CONFIG_CLASSIC_BT_ENABLED
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, NULL },
|
||||
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, btc_gap_bt_cb_handler },
|
||||
#endif /* (BTC_GAP_BT_INCLUDED == TRUE) */
|
||||
[BTC_PID_PRF_QUE] = {btc_profile_queue_handler, NULL },
|
||||
#if BTC_AV_INCLUDED
|
||||
@ -80,6 +83,9 @@ static btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
#if CONFIG_BT_SPP_ENABLED
|
||||
[BTC_PID_SPP] = {btc_spp_call_handler, btc_spp_cb_handler },
|
||||
#endif /* #if CONFIG_BT_SPP_ENABLED */
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
[BTC_PID_HF_CLIENT] = {btc_hf_client_call_handler, btc_hf_client_cb_handler},
|
||||
#endif /* #if BTC_HF_CLIENT_INCLUDED */
|
||||
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
|
||||
};
|
||||
|
||||
@ -95,7 +101,7 @@ static void btc_task(void *arg)
|
||||
|
||||
for (;;) {
|
||||
if (pdTRUE == xQueueReceive(xBtcQueue, &msg, (portTickType)portMAX_DELAY)) {
|
||||
LOG_DEBUG("%s msg %u %u %u %p\n", __func__, msg.sig, msg.pid, msg.act, msg.arg);
|
||||
BTC_TRACE_DEBUG("%s msg %u %u %u %p\n", __func__, msg.sig, msg.pid, msg.act, msg.arg);
|
||||
switch (msg.sig) {
|
||||
case BTC_SIG_API_CALL:
|
||||
profile_tab[msg.pid].btc_call(&msg);
|
||||
@ -120,7 +126,7 @@ static bt_status_t btc_task_post(btc_msg_t *msg, task_post_t timeout)
|
||||
}
|
||||
|
||||
if (xQueueSend(xBtcQueue, msg, timeout) != pdTRUE) {
|
||||
LOG_ERROR("Btc Post failed\n");
|
||||
BTC_TRACE_ERROR("Btc Post failed\n");
|
||||
return BT_STATUS_BUSY;
|
||||
}
|
||||
|
||||
@ -135,7 +141,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg);
|
||||
BTC_TRACE_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg);
|
||||
|
||||
memcpy(&lmsg, msg, sizeof(btc_msg_t));
|
||||
if (arg) {
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "bta/bta_av_api.h"
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
#include "common/bt_defs.h"
|
||||
#include "stack/btm_api.h"
|
||||
|
||||
/************************************************************************************
|
||||
** Constants & Macros
|
||||
@ -179,3 +180,69 @@ void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str)
|
||||
ntohl(uuid4), ntohs(uuid5));
|
||||
return;
|
||||
}
|
||||
|
||||
esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
|
||||
{
|
||||
esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL;
|
||||
switch(hci_status) {
|
||||
case HCI_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case HCI_ERR_HOST_TIMEOUT:
|
||||
esp_status = ESP_BT_STATUS_TIMEOUT;
|
||||
break;
|
||||
case HCI_ERR_ILLEGAL_COMMAND:
|
||||
esp_status = ESP_BT_STATUS_PENDING;
|
||||
break;
|
||||
case HCI_ERR_UNACCEPT_CONN_INTERVAL:
|
||||
esp_status = ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL;
|
||||
break;
|
||||
case HCI_ERR_PARAM_OUT_OF_RANGE:
|
||||
esp_status = ESP_BT_STATUS_PARAM_OUT_OF_RANGE;
|
||||
break;
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
esp_status = ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
return esp_status;
|
||||
}
|
||||
|
||||
esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status)
|
||||
{
|
||||
esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL;
|
||||
switch(btm_status){
|
||||
case BTM_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case BTM_BUSY:
|
||||
esp_status = ESP_BT_STATUS_BUSY;
|
||||
break;
|
||||
case BTM_NO_RESOURCES:
|
||||
esp_status = ESP_BT_STATUS_NOMEM;
|
||||
break;
|
||||
case BTM_ERR_PROCESSING:
|
||||
esp_status = ESP_BT_STATUS_PENDING;
|
||||
break;
|
||||
case BTM_PEER_LE_DATA_LEN_UNSUPPORTED:
|
||||
esp_status = ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED;
|
||||
break;
|
||||
case BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED:
|
||||
esp_status = ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED;
|
||||
break;
|
||||
case BTM_SET_PRIVACY_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case BTM_SET_PRIVACY_FAIL:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
return esp_status;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include "common/bt_defs.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
|
||||
|
||||
#define BTC_STORAGE_DEV_CLASS_STR "DevClass"
|
||||
@ -65,4 +66,27 @@ bt_status_t btc_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr);
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_load_bonded_devices(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_get_num_bt_bond_devices
|
||||
**
|
||||
** Description BTC storage API - get the num of the bonded device from NVRAM
|
||||
**
|
||||
** Returns the num of the bonded device
|
||||
**
|
||||
*******************************************************************************/
|
||||
int btc_storage_get_num_bt_bond_devices(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_storage_get_bonded_bt_devices_list
|
||||
**
|
||||
** Description BTC storage API - get the list of the bonded device from NVRAM
|
||||
**
|
||||
** Returns BT_STATUS_SUCCESS if get the list successful,
|
||||
** BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num);
|
||||
|
||||
#endif /* BTC_STORAGE_H */
|
||||
|
@ -54,6 +54,9 @@ typedef enum {
|
||||
BTC_PID_A2DP,
|
||||
BTC_PID_AVRC,
|
||||
BTC_PID_SPP,
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
BTC_PID_HF_CLIENT,
|
||||
#endif /* BTC_HF_CLIENT_INCLUDED */
|
||||
#endif /* CONFIG_CLASSIC_BT_ENABLED */
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
@ -44,4 +44,7 @@ void uuid128_be_to_esp_uuid(esp_bt_uuid_t *u, uint8_t* uuid128);
|
||||
|
||||
void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
|
||||
|
||||
esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status);
|
||||
esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status);
|
||||
|
||||
#endif /* __BTC_UTIL_H__ */
|
||||
|
@ -63,19 +63,19 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
uint8_t net_event = 0xff;
|
||||
uint8_t len = 0;
|
||||
uint8_t *p_rec_data = NULL;
|
||||
//LOG_ERROR("p_data->status = %x\n",p_data->status);
|
||||
//BTC_TRACE_ERROR("p_data->status = %x\n",p_data->status);
|
||||
//if(p_data->status != BTA_GATT_OK){
|
||||
// LOG_ERROR("button profile register failed\n");
|
||||
// BTC_TRACE_ERROR("button profile register failed\n");
|
||||
// return;
|
||||
//}
|
||||
LOG_ERROR("button profile cb event = %x\n", event);
|
||||
BTC_TRACE_ERROR("button profile cb event = %x\n", event);
|
||||
switch (event) {
|
||||
case ESP_GATTS_REG_EVT:
|
||||
|
||||
LOG_ERROR("p_data->reg_oper.status = %x\n", p_data->reg_oper.status);
|
||||
LOG_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n", p_data->reg_oper.uuid.uu.uuid16);
|
||||
BTC_TRACE_ERROR("p_data->reg_oper.status = %x\n", p_data->reg_oper.status);
|
||||
BTC_TRACE_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n", p_data->reg_oper.uuid.uu.uuid16);
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("button profile register failed\n");
|
||||
BTC_TRACE_ERROR("button profile register failed\n");
|
||||
}
|
||||
button_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
button_cb_env.enabled = true;
|
||||
@ -96,11 +96,11 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
LOG_ERROR("Received button data:");
|
||||
BTC_TRACE_ERROR("Received button data:");
|
||||
for (int i = 0; i < p_data->req_data.p_data->write_req.len; i++) {
|
||||
LOG_ERROR("%x", p_data->req_data.p_data->write_req.value[i]);
|
||||
BTC_TRACE_ERROR("%x", p_data->req_data.p_data->write_req.value[i]);
|
||||
}
|
||||
LOG_ERROR("\n");
|
||||
BTC_TRACE_ERROR("\n");
|
||||
if (p_data->req_data.p_data->write_req.handle == button_cb_env.button_inst.but_wirt_hdl) {
|
||||
|
||||
p_rec_data = &p_data->req_data.p_data->write_req.value[0];
|
||||
@ -154,12 +154,12 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
button_cb_env.button_inst.but_cfg_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
///Start advertising
|
||||
LOG_ERROR("\n*******Start sent the ADV.*************\n");
|
||||
BTC_TRACE_ERROR("\n*******Start sent the ADV.*************\n");
|
||||
//esp_ble_start_advertising (&adv_params);
|
||||
//BTA_GATTS_Listen(button_cb_env.gatt_if, true, NULL);
|
||||
break;
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
LOG_ERROR("############BUTTON CONNCET EVT################\n");
|
||||
BTC_TRACE_ERROR("############BUTTON CONNCET EVT################\n");
|
||||
//esp_ble_stop_advertising();
|
||||
//set the connection flag to true
|
||||
button_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
|
||||
@ -205,7 +205,7 @@ void Button_CreateService(void)
|
||||
button_cb_env.inst_id = inst;
|
||||
//if(!button_cb_env.enabled)
|
||||
//{
|
||||
// LOG_ERROR("button service added error.");
|
||||
// BTC_TRACE_ERROR("button service added error.");
|
||||
//}
|
||||
esp_ble_gatts_create_srvc(server_if, &uuid, inst, num_handle, true);
|
||||
|
||||
@ -228,7 +228,7 @@ but_clcb_t *button_env_clcb_alloc (uint16_t conn_id, BD_ADDR remote_bda)
|
||||
if (!p_clcb->in_use) {
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
LOG_ERROR("p_clcb->conn_id = %x\n", conn_id);
|
||||
BTC_TRACE_ERROR("p_clcb->conn_id = %x\n", conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN);
|
||||
}
|
||||
@ -295,9 +295,9 @@ esp_gatt_status_t button_init (but_prf_cb_t call_back)
|
||||
{
|
||||
tBT_UUID app_uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
|
||||
LOG_ERROR("\n=============================button_init==============================================\n");
|
||||
BTC_TRACE_ERROR("\n=============================button_init==============================================\n");
|
||||
if (button_cb_env.enabled) {
|
||||
LOG_ERROR("button svc already initaliezd\n");
|
||||
BTC_TRACE_ERROR("button svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
} else {
|
||||
memset(&button_cb_env, 0, sizeof(button_env_cb_t));
|
||||
@ -331,7 +331,7 @@ void button_msg_notify(uint16_t len, uint8_t *button_msg)
|
||||
//notify rsp==false; indicate rsp==true.
|
||||
BOOLEAN rsp = false;
|
||||
if (!conn_status && button_cb_env.clcb.congest) {
|
||||
LOG_ERROR("the conneciton for button profile has been loss\n");
|
||||
BTC_TRACE_ERROR("the conneciton for button profile has been loss\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ static inline void btc_blufi_cb_to_app(esp_blufi_cb_event_t event, esp_blufi_cb_
|
||||
static void blufi_create_service(void)
|
||||
{
|
||||
if (!blufi_env.enabled) {
|
||||
LOG_ERROR("blufi service added error.");
|
||||
BTC_TRACE_ERROR("blufi service added error.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -91,14 +91,14 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
{
|
||||
tBTA_GATTS_RSP rsp;
|
||||
|
||||
LOG_DEBUG("blufi profile cb event = %x\n", event);
|
||||
BLUFI_TRACE_DEBUG("blufi profile cb event = %x\n", event);
|
||||
|
||||
switch (event) {
|
||||
case BTA_GATTS_REG_EVT:
|
||||
LOG_DEBUG("REG: status %d, app_uuid %04x, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.uuid.uu.uuid16, p_data->reg_oper.server_if);
|
||||
BLUFI_TRACE_DEBUG("REG: status %d, app_uuid %04x, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.uuid.uu.uuid16, p_data->reg_oper.server_if);
|
||||
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("BLUFI profile register failed\n");
|
||||
BLUFI_TRACE_ERROR("BLUFI profile register failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
|
||||
//create the blufi service to the service data base.
|
||||
if (p_data->reg_oper.uuid.uu.uuid16 == BLUFI_APP_UUID) {
|
||||
LOG_DEBUG("%s %d\n", __func__, __LINE__);
|
||||
BLUFI_TRACE_DEBUG("%s %d\n", __func__, __LINE__);
|
||||
blufi_create_service();
|
||||
}
|
||||
break;
|
||||
@ -115,10 +115,10 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
esp_blufi_cb_param_t param;
|
||||
btc_msg_t msg;
|
||||
|
||||
LOG_DEBUG("DEREG: status %d, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.server_if);
|
||||
BLUFI_TRACE_DEBUG("DEREG: status %d, gatt_if %d\n", p_data->reg_oper.status, p_data->reg_oper.server_if);
|
||||
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("BLUFI profile unregister failed\n");
|
||||
BLUFI_TRACE_ERROR("BLUFI profile unregister failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
if (blufi_env.prepare_buf == NULL) {
|
||||
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE);
|
||||
if (blufi_env.prepare_buf == NULL) {
|
||||
LOG_ERROR("Blufi prep no mem\n");
|
||||
BLUFI_TRACE_ERROR("Blufi prep no mem\n");
|
||||
status = GATT_NO_RESOURCES;
|
||||
}
|
||||
} else {
|
||||
@ -165,7 +165,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
rsp.attr_value.offset = p_data->req_data.p_data->write_req.offset;
|
||||
memcpy(rsp.attr_value.value, p_data->req_data.p_data->write_req.value, p_data->req_data.p_data->write_req.len);
|
||||
|
||||
LOG_DEBUG("prep write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset);
|
||||
BLUFI_TRACE_DEBUG("prep write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset);
|
||||
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
status, &rsp);
|
||||
@ -177,7 +177,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
|
||||
return;
|
||||
} else {
|
||||
LOG_DEBUG("norm write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset);
|
||||
BLUFI_TRACE_DEBUG("norm write, len=%d, offset=%d\n", p_data->req_data.p_data->write_req.len, p_data->req_data.p_data->write_req.offset);
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
}
|
||||
@ -189,7 +189,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_EXEC_WRITE_EVT:
|
||||
LOG_DEBUG("exec write exec %d\n", p_data->req_data.p_data->exec_write);
|
||||
BLUFI_TRACE_DEBUG("exec write exec %d\n", p_data->req_data.p_data->exec_write);
|
||||
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
GATT_SUCCESS, NULL);
|
||||
@ -205,11 +205,11 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
|
||||
break;
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
LOG_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu);
|
||||
BLUFI_TRACE_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu);
|
||||
blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE;
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
LOG_DEBUG("CONIRM EVT\n");
|
||||
BLUFI_TRACE_DEBUG("CONIRM EVT\n");
|
||||
if (p_data && p_data->req_data.value){
|
||||
osi_free(p_data->req_data.value);
|
||||
}
|
||||
@ -268,7 +268,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
esp_blufi_cb_param_t param;
|
||||
|
||||
//set the connection flag to true
|
||||
LOG_INFO("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BLUFI_TRACE_API("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
|
||||
@ -291,7 +291,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
|
||||
blufi_env.is_connected = false;
|
||||
//set the connection flag to true
|
||||
LOG_INFO("\ndevice is disconnected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BLUFI_TRACE_API("\ndevice is disconnected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
|
||||
@ -324,7 +324,7 @@ static tGATT_STATUS btc_blufi_profile_init(void)
|
||||
esp_blufi_callbacks_t *store_p = blufi_env.cbs;
|
||||
|
||||
if (blufi_env.enabled) {
|
||||
LOG_ERROR("BLUFI already initialized");
|
||||
BLUFI_TRACE_ERROR("BLUFI already initialized");
|
||||
return GATT_ERROR;
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ static tGATT_STATUS btc_blufi_profile_init(void)
|
||||
static tGATT_STATUS btc_blufi_profile_deinit(void)
|
||||
{
|
||||
if (!blufi_env.enabled) {
|
||||
LOG_ERROR("BLUFI already de-initialized");
|
||||
BTC_TRACE_ERROR("BLUFI already de-initialized");
|
||||
return GATT_ERROR;
|
||||
}
|
||||
|
||||
@ -381,7 +381,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
|
||||
int ret;
|
||||
|
||||
if (hdr->seq != blufi_env.recv_seq) {
|
||||
LOG_ERROR("%s seq %d is not expect %d\n", __func__, hdr->seq, blufi_env.recv_seq + 1);
|
||||
BTC_TRACE_ERROR("%s seq %d is not expect %d\n", __func__, hdr->seq, blufi_env.recv_seq + 1);
|
||||
btc_blufi_report_error(ESP_BLUFI_SEQUENCE_ERROR);
|
||||
return;
|
||||
}
|
||||
@ -393,7 +393,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
|
||||
&& (blufi_env.cbs && blufi_env.cbs->decrypt_func)) {
|
||||
ret = blufi_env.cbs->decrypt_func(hdr->seq, hdr->data, hdr->data_len);
|
||||
if (ret != hdr->data_len) { /* enc must be success and enc len must equal to plain len */
|
||||
LOG_ERROR("%s decrypt error %d\n", __func__, ret);
|
||||
BTC_TRACE_ERROR("%s decrypt error %d\n", __func__, ret);
|
||||
btc_blufi_report_error(ESP_BLUFI_DECRYPT_ERROR);
|
||||
return;
|
||||
}
|
||||
@ -405,7 +405,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
|
||||
checksum = blufi_env.cbs->checksum_func(hdr->seq, &hdr->seq, hdr->data_len + 2);
|
||||
checksum_pkt = hdr->data[hdr->data_len] | (((uint16_t) hdr->data[hdr->data_len + 1]) << 8);
|
||||
if (checksum != checksum_pkt) {
|
||||
LOG_ERROR("%s checksum error %04x, pkt %04x\n", __func__, checksum, checksum_pkt);
|
||||
BTC_TRACE_ERROR("%s checksum error %04x, pkt %04x\n", __func__, checksum, checksum_pkt);
|
||||
btc_blufi_report_error(ESP_BLUFI_CHECKSUM_ERROR);
|
||||
return;
|
||||
}
|
||||
@ -420,7 +420,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
|
||||
blufi_env.total_len = hdr->data[0] | (((uint16_t) hdr->data[1]) << 8);
|
||||
blufi_env.aggr_buf = osi_malloc(blufi_env.total_len);
|
||||
if (blufi_env.aggr_buf == NULL) {
|
||||
LOG_ERROR("%s no mem, len %d\n", __func__, blufi_env.total_len);
|
||||
BTC_TRACE_ERROR("%s no mem, len %d\n", __func__, blufi_env.total_len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -451,7 +451,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
|
||||
if (remain_len > blufi_env.frag_size) {
|
||||
hdr = osi_malloc(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);
|
||||
if (hdr == NULL) {
|
||||
LOG_ERROR("%s no mem\n", __func__);
|
||||
BTC_TRACE_ERROR("%s no mem\n", __func__);
|
||||
return;
|
||||
}
|
||||
hdr->fc = 0x0;
|
||||
@ -463,7 +463,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
|
||||
} else {
|
||||
hdr = osi_malloc(sizeof(struct blufi_hdr) + remain_len + 2);
|
||||
if (hdr == NULL) {
|
||||
LOG_ERROR("%s no mem\n", __func__);
|
||||
BTC_TRACE_ERROR("%s no mem\n", __func__);
|
||||
return;
|
||||
}
|
||||
hdr->fc = 0x0;
|
||||
@ -496,7 +496,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
|
||||
if (ret == hdr->data_len) { /* enc must be success and enc len must equal to plain len */
|
||||
hdr->fc |= BLUFI_FC_ENC;
|
||||
} else {
|
||||
LOG_ERROR("%s encrypt error %d\n", __func__, ret);
|
||||
BTC_TRACE_ERROR("%s encrypt error %d\n", __func__, ret);
|
||||
btc_blufi_report_error(ESP_BLUFI_ENCRYPT_ERROR);
|
||||
osi_free(hdr);
|
||||
return;
|
||||
@ -586,7 +586,7 @@ static void btc_blufi_wifi_conn_report(uint8_t opmode, uint8_t sta_conn_state, u
|
||||
}
|
||||
}
|
||||
if (p - data > data_len) {
|
||||
LOG_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len);
|
||||
BTC_TRACE_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len);
|
||||
}
|
||||
|
||||
btc_blufi_send_encap(type, data, data_len);
|
||||
@ -603,7 +603,7 @@ void btc_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list)
|
||||
uint malloc_size = (1 + 1 + sizeof(list->ssid)) * apCount;
|
||||
p = data = osi_malloc(malloc_size);
|
||||
if (data == NULL) {
|
||||
LOG_ERROR("malloc error\n");
|
||||
BTC_TRACE_ERROR("malloc error\n");
|
||||
return;
|
||||
}
|
||||
type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_WIFI_LIST);
|
||||
@ -613,7 +613,7 @@ void btc_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list)
|
||||
data_len = (p - data);
|
||||
//current_len + ssid + rssi + total_len_value
|
||||
if((data_len + len + 1 + 1) > malloc_size) {
|
||||
LOG_ERROR("%s len error", __func__);
|
||||
BTC_TRACE_ERROR("%s len error", __func__);
|
||||
osi_free(data);
|
||||
return;
|
||||
}
|
||||
@ -653,7 +653,7 @@ static void btc_blufi_send_error_info(uint8_t state)
|
||||
type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_ERROR_INFO);
|
||||
*p++ = state;
|
||||
if (p - data > data_len) {
|
||||
LOG_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len);
|
||||
BTC_TRACE_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len);
|
||||
}
|
||||
|
||||
btc_blufi_send_encap(type, data, data_len);
|
||||
@ -663,12 +663,12 @@ static void btc_blufi_send_error_info(uint8_t state)
|
||||
static void btc_blufi_send_custom_data(uint8_t *value, uint32_t value_len)
|
||||
{
|
||||
if(value == NULL || value_len == 0) {
|
||||
LOG_ERROR("%s value or value len error", __func__);
|
||||
BTC_TRACE_ERROR("%s value or value len error", __func__);
|
||||
return;
|
||||
}
|
||||
uint8_t *data = osi_malloc(value_len);
|
||||
if (data == NULL) {
|
||||
LOG_ERROR("%s mem malloc error", __func__);
|
||||
BTC_TRACE_ERROR("%s mem malloc error", __func__);
|
||||
return;
|
||||
}
|
||||
uint8_t type = BLUFI_BUILD_TYPE(BLUFI_TYPE_DATA, BLUFI_TYPE_DATA_SUBTYPE_CUSTOM_DATA);
|
||||
@ -686,77 +686,77 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case ESP_BLUFI_EVENT_RECV_STA_SSID:
|
||||
dst->sta_ssid.ssid = osi_malloc(src->sta_ssid.ssid_len);
|
||||
if (dst->sta_ssid.ssid == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->sta_ssid.ssid, src->sta_ssid.ssid, src->sta_ssid.ssid_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_STA_PASSWD:
|
||||
dst->sta_passwd.passwd = osi_malloc(src->sta_passwd.passwd_len);
|
||||
if (dst->sta_passwd.passwd == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->sta_passwd.passwd, src->sta_passwd.passwd, src->sta_passwd.passwd_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_SOFTAP_SSID:
|
||||
dst->softap_ssid.ssid = osi_malloc(src->softap_ssid.ssid_len);
|
||||
if (dst->softap_ssid.ssid == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->softap_ssid.ssid, src->softap_ssid.ssid, src->softap_ssid.ssid_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD:
|
||||
dst->softap_passwd.passwd = osi_malloc(src->softap_passwd.passwd_len);
|
||||
if (dst->softap_passwd.passwd == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->softap_passwd.passwd, src->softap_passwd.passwd, src->softap_passwd.passwd_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_USERNAME:
|
||||
dst->username.name = osi_malloc(src->username.name_len);
|
||||
if (dst->username.name == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->username.name, src->username.name, src->username.name_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_CA_CERT:
|
||||
dst->ca.cert = osi_malloc(src->ca.cert_len);
|
||||
if (dst->ca.cert == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->ca.cert, src->ca.cert, src->ca.cert_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_CLIENT_CERT:
|
||||
dst->client_cert.cert = osi_malloc(src->client_cert.cert_len);
|
||||
if (dst->client_cert.cert == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->client_cert.cert, src->client_cert.cert, src->client_cert.cert_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_SERVER_CERT:
|
||||
dst->server_cert.cert = osi_malloc(src->server_cert.cert_len);
|
||||
if (dst->server_cert.cert == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->server_cert.cert, src->server_cert.cert, src->server_cert.cert_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY:
|
||||
dst->client_pkey.pkey = osi_malloc(src->client_pkey.pkey_len);
|
||||
if (dst->client_pkey.pkey == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->client_pkey.pkey, src->client_pkey.pkey, src->client_pkey.pkey_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY:
|
||||
dst->server_pkey.pkey = osi_malloc(src->server_pkey.pkey_len);
|
||||
if (dst->server_pkey.pkey == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
memcpy(dst->server_pkey.pkey, src->server_pkey.pkey, src->server_pkey.pkey_len);
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_RECV_CUSTOM_DATA:
|
||||
dst->custom_data.data = osi_malloc(src->custom_data.data_len);
|
||||
if (dst->custom_data.data == NULL) {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
memcpy(dst->custom_data.data, src->custom_data.data, src->custom_data.data_len);
|
||||
@ -898,7 +898,7 @@ void btc_blufi_cb_handler(btc_msg_t *msg)
|
||||
btc_blufi_cb_to_app(ESP_BLUFI_EVENT_RECV_CUSTOM_DATA, param);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -995,12 +995,12 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case BTC_BLUFI_ACT_SEND_CUSTOM_DATA:{
|
||||
uint8_t *data = src->custom_data.data;
|
||||
if(data == NULL) {
|
||||
LOG_ERROR("custom data is NULL\n");
|
||||
BTC_TRACE_ERROR("custom data is NULL\n");
|
||||
break;
|
||||
}
|
||||
dst->custom_data.data = osi_malloc(src->custom_data.data_len);
|
||||
if(dst->custom_data.data == NULL) {
|
||||
LOG_ERROR("custom data malloc error\n");
|
||||
BTC_TRACE_ERROR("custom data malloc error\n");
|
||||
break;
|
||||
}
|
||||
memcpy(dst->custom_data.data, src->custom_data.data, src->custom_data.data_len);
|
||||
@ -1085,7 +1085,7 @@ void btc_blufi_call_handler(btc_msg_t *msg)
|
||||
btc_blufi_send_custom_data(arg->custom_data.data, arg->custom_data.data_len);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
btc_blufi_call_deep_free(msg);
|
||||
|
@ -113,7 +113,7 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len)
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type);
|
||||
BTC_TRACE_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -260,7 +260,7 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len)
|
||||
btc_transfer_context(&msg, ¶m, sizeof(esp_blufi_cb_param_t), btc_blufi_cb_deep_copy);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type);
|
||||
BTC_TRACE_ERROR("%s Unkown Ctrl pkt %02x\n", __func__, type);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -57,12 +57,12 @@ static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst;
|
||||
|
||||
|
||||
LOG_ERROR("airsync profile cb event = %x\n", event);
|
||||
BTC_TRACE_ERROR("airsync profile cb event = %x\n", event);
|
||||
switch (event) {
|
||||
case ESP_GATTS_REG_EVT:
|
||||
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("button profile register failed\n");
|
||||
BTC_TRACE_ERROR("button profile register failed\n");
|
||||
}
|
||||
airsync_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
airsync_cb_env.enabled = true;
|
||||
@ -203,7 +203,7 @@ tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda)
|
||||
if (!p_clcb->in_use) {
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
LOG_ERROR("p_clcb->conn_id = %x\n", conn_id);
|
||||
BTC_TRACE_ERROR("p_clcb->conn_id = %x\n", conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN);
|
||||
}
|
||||
@ -248,7 +248,7 @@ tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back)
|
||||
|
||||
|
||||
if (airsync_cb_env.enabled) {
|
||||
LOG_ERROR("airsync svc already initaliezd\n");
|
||||
BTC_TRACE_ERROR("airsync svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
} else {
|
||||
memset(&airsync_cb_env, 0, sizeof(tAIRSYNC_CB_ENV));
|
||||
|
@ -49,9 +49,10 @@ void btc_a2dp_on_init(void)
|
||||
|
||||
void btc_a2dp_on_idle(void)
|
||||
{
|
||||
APPL_TRACE_EVENT("## ON A2DP IDLE ## peer_sep = %d", btc_av_get_peer_sep());
|
||||
APPL_TRACE_EVENT("## ON A2DP IDLE ## peer_sep = %d, service id = %d", btc_av_get_peer_sep(),
|
||||
btc_av_get_service_id());
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
btc_a2dp_source_on_idle();
|
||||
}
|
||||
#endif // BTC_AV_SRC_INCLUDED
|
||||
@ -59,7 +60,7 @@ void btc_a2dp_on_idle(void)
|
||||
bta_av_co_init();
|
||||
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_a2dp_sink_on_idle();
|
||||
}
|
||||
#endif // BTC_AV_SINK_INCLUDED
|
||||
@ -120,7 +121,7 @@ void btc_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
|
||||
{
|
||||
APPL_TRACE_EVENT("## ON A2DP STOPPED ##");
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_a2dp_sink_on_stopped(p_av);
|
||||
return;
|
||||
}
|
||||
@ -140,7 +141,7 @@ void btc_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av)
|
||||
{
|
||||
APPL_TRACE_EVENT("## ON A2DP SUSPENDED ##");
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_a2dp_sink_on_suspended(p_av);
|
||||
return;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ void btc_a2dp_control_command_ack(int status)
|
||||
static void btc_a2dp_datapath_open(void)
|
||||
{
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
/* Start the media task to encode SBC */
|
||||
btc_a2dp_source_start_audio_req();
|
||||
|
||||
@ -147,7 +147,7 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
|
||||
btc_a2dp_dispatch_datapath_evt(BTC_AV_DATAPATH_OPEN_EVT);
|
||||
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
@ -160,7 +160,8 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
break;
|
||||
case ESP_A2D_MEDIA_CTRL_STOP:
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming()) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() &&
|
||||
btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
/* we are already stopped, just ack back*/
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
break;
|
||||
@ -168,7 +169,7 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
btc_dispatch_sm_event(BTC_AV_STOP_STREAM_REQ_EVT, NULL, 0);
|
||||
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC) {
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
|
@ -588,6 +588,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
|
||||
UINT32 sbc_frame_len = p_msg->len - 1;
|
||||
availPcmBytes = 2 * sizeof(pcmData);
|
||||
|
||||
/* XXX: Check if the below check is correct, we are checking for peer to be sink when we are sink */
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK || (btc_aa_snk_cb.rx_flush)) {
|
||||
APPL_TRACE_DEBUG(" State Changed happened in this tick ");
|
||||
return;
|
||||
|
@ -1136,7 +1136,7 @@ static UINT8 btc_get_num_aa_frame(void)
|
||||
}
|
||||
btc_aa_src_cb.media_feeding_state.pcm.counter -= result * pcm_bytes_per_frame;
|
||||
|
||||
LOG_VERBOSE("WRITE %d FRAMES", result);
|
||||
BTC_TRACE_VERBOSE("WRITE %d FRAMES", result);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1461,7 +1461,7 @@ static void btc_a2dp_source_send_aa_frame(void)
|
||||
}
|
||||
|
||||
/* send it */
|
||||
LOG_VERBOSE("%s: send %d frames", __FUNCTION__, nb_frame_2_send);
|
||||
BTC_TRACE_VERBOSE("%s: send %d frames", __FUNCTION__, nb_frame_2_send);
|
||||
bta_av_ci_src_data_ready(BTA_AV_CHNL_AUDIO);
|
||||
}
|
||||
|
||||
@ -1540,7 +1540,7 @@ static void btc_a2dp_source_aa_start_tx(void)
|
||||
btc_aa_src_cb.media_alarm = osi_alarm_new("aaTx", btc_a2dp_source_alarm_cb, NULL, BTC_MEDIA_TIME_TICK_MS);
|
||||
|
||||
if (!btc_aa_src_cb.media_alarm) {
|
||||
LOG_ERROR("%s unable to allocate media alarm.", __func__);
|
||||
BTC_TRACE_ERROR("%s unable to allocate media alarm.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "btc_a2dp_sink.h"
|
||||
#include "btc_a2dp_source.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
#include "osi/alarm.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
@ -71,6 +72,7 @@ typedef enum {
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
int service_id;
|
||||
tBTA_AV_HNDL bta_handle;
|
||||
bt_bdaddr_t peer_bda;
|
||||
btc_sm_handle_t sm_handle;
|
||||
@ -80,7 +82,7 @@ typedef struct {
|
||||
} btc_av_cb_t;
|
||||
|
||||
typedef struct {
|
||||
bt_bdaddr_t *target_bda;
|
||||
bt_bdaddr_t target_bda;
|
||||
uint16_t uuid;
|
||||
} btc_av_connect_req_t;
|
||||
|
||||
@ -88,7 +90,10 @@ typedef struct {
|
||||
** Static variables
|
||||
******************************************************************************/
|
||||
static btc_av_cb_t btc_av_cb = {0};
|
||||
static TIMER_LIST_ENT tle_av_open_on_rc;
|
||||
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
static osi_alarm_t *tle_av_open_on_rc = NULL;
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
|
||||
/* both interface and media task needs to be ready to alloc incoming request */
|
||||
#define CHECK_BTAV_INIT() do \
|
||||
@ -204,6 +209,7 @@ UNUSED_ATTR static const char *dump_av_sm_event_name(btc_av_sm_event_t event)
|
||||
/****************************************************************************
|
||||
** Local helper functions
|
||||
*****************************************************************************/
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_initiate_av_open_tmr_hdlr
|
||||
@ -215,23 +221,23 @@ UNUSED_ATTR static const char *dump_av_sm_event_name(btc_av_sm_event_t event)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void btc_initiate_av_open_tmr_hdlr(TIMER_LIST_ENT *tle)
|
||||
static void btc_initiate_av_open_tmr_hdlr(void *arg)
|
||||
{
|
||||
UNUSED(arg);
|
||||
BD_ADDR peer_addr;
|
||||
UNUSED(tle);
|
||||
btc_av_connect_req_t connect_req;
|
||||
UNUSED(tle);
|
||||
/* is there at least one RC connection - There should be */
|
||||
if (btc_rc_get_connected_peer(peer_addr)) {
|
||||
LOG_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__);
|
||||
/* In case of AVRCP connection request, we will initiate SRC connection */
|
||||
connect_req.target_bda = (bt_bdaddr_t *)&peer_addr;
|
||||
memcpy(connect_req.target_bda.address, peer_addr, sizeof(bt_bdaddr_t));
|
||||
connect_req.uuid = UUID_SERVCLASS_AUDIO_SOURCE;
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_CONNECT_REQ_EVT, (char *)&connect_req);
|
||||
btc_dispatch_sm_event(BTC_AV_CONNECT_REQ_EVT, &connect_req, sizeof(btc_av_connect_req_t));
|
||||
} else {
|
||||
LOG_ERROR("%s No connected RC peers", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s No connected RC peers", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
|
||||
/*****************************************************************************
|
||||
** Static functions
|
||||
@ -278,7 +284,7 @@ static void btc_report_audio_state(esp_a2d_audio_state_t state, bt_bdaddr_t *bd_
|
||||
|
||||
static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@ -303,7 +309,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
case BTA_AV_PENDING_EVT:
|
||||
case BTC_AV_CONNECT_REQ_EVT: {
|
||||
if (event == BTC_AV_CONNECT_REQ_EVT) {
|
||||
memcpy(&btc_av_cb.peer_bda, ((btc_av_connect_req_t *)p_data)->target_bda,
|
||||
memcpy(&btc_av_cb.peer_bda, &((btc_av_connect_req_t *)p_data)->target_bda,
|
||||
sizeof(bt_bdaddr_t));
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
||||
@ -326,11 +332,11 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
* TODO: We may need to do this only on an AVRCP Play. FixMe
|
||||
*/
|
||||
|
||||
LOG_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
|
||||
memset(&tle_av_open_on_rc, 0, sizeof(tle_av_open_on_rc));
|
||||
tle_av_open_on_rc.param = (UINT32)btc_initiate_av_open_tmr_hdlr;
|
||||
btu_start_timer(&tle_av_open_on_rc, BTU_TTYPE_USER_FUNC,
|
||||
BTC_TIMEOUT_AV_OPEN_ON_RC_SECS);
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
BTC_TRACE_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
|
||||
tle_av_open_on_rc = osi_alarm_new("AVconn", btc_initiate_av_open_tmr_hdlr, NULL, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000);
|
||||
osi_alarm_set(tle_av_open_on_rc, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000);
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
btc_rc_handler(event, p_data);
|
||||
break;
|
||||
|
||||
@ -343,15 +349,17 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTA_AV_RC_CLOSE_EVT:
|
||||
if (tle_av_open_on_rc.in_use) {
|
||||
LOG_DEBUG("BTA_AV_RC_CLOSE_EVT: Stopping AV timer.");
|
||||
btu_stop_timer(&tle_av_open_on_rc);
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (tle_av_open_on_rc) {
|
||||
osi_alarm_free(tle_av_open_on_rc);
|
||||
tle_av_open_on_rc = NULL;
|
||||
}
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
btc_rc_handler(event, p_data);
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
@ -372,7 +380,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@ -385,7 +393,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTA_AV_REJECT_EVT:
|
||||
LOG_DEBUG(" Received BTA_AV_REJECT_EVT \n");
|
||||
BTC_TRACE_DEBUG(" Received BTA_AV_REJECT_EVT \n");
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda), 0);
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||
break;
|
||||
@ -394,7 +402,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
tBTA_AV *p_bta_data = (tBTA_AV *)p_data;
|
||||
esp_a2d_connection_state_t state;
|
||||
btc_sm_state_t av_state;
|
||||
LOG_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status,
|
||||
BTC_TRACE_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status,
|
||||
p_bta_data->open.edr);
|
||||
|
||||
if (p_bta_data->open.status == BTA_AV_SUCCESS) {
|
||||
@ -404,7 +412,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
btc_av_cb.peer_sep = p_bta_data->open.sep;
|
||||
} else {
|
||||
LOG_WARN("BTA_AV_OPEN_EVT::FAILED status: %d\n",
|
||||
BTC_TRACE_WARNING("BTA_AV_OPEN_EVT::FAILED status: %d\n",
|
||||
p_bta_data->open.status );
|
||||
state = ESP_A2D_CONNECTION_STATE_DISCONNECTED;
|
||||
av_state = BTC_AV_STATE_IDLE;
|
||||
@ -440,11 +448,11 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
// Check for device, if same device which moved to opening then ignore callback
|
||||
if (memcmp ((bt_bdaddr_t *)p_data, &(btc_av_cb.peer_bda),
|
||||
sizeof(btc_av_cb.peer_bda)) == 0) {
|
||||
LOG_DEBUG("%s: Same device moved to Opening state,ignore Connect Req\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s: Same device moved to Opening state,ignore Connect Req\n", __func__);
|
||||
btc_queue_advance();
|
||||
break;
|
||||
} else {
|
||||
LOG_DEBUG("%s: Moved from idle by Incoming Connection request\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s: Moved from idle by Incoming Connection request\n", __func__);
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, (bt_bdaddr_t *)p_data, 0);
|
||||
btc_queue_advance();
|
||||
break;
|
||||
@ -454,10 +462,10 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
// Check for device, if same device which moved to opening then ignore callback
|
||||
if (memcmp (((tBTA_AV *)p_data)->pend.bd_addr, &(btc_av_cb.peer_bda),
|
||||
sizeof(btc_av_cb.peer_bda)) == 0) {
|
||||
LOG_DEBUG("%s: Same device moved to Opening state,ignore Pending Req\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s: Same device moved to Opening state,ignore Pending Req\n", __func__);
|
||||
break;
|
||||
} else {
|
||||
LOG_DEBUG("%s: Moved from idle by outgoing Connection request\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s: Moved from idle by outgoing Connection request\n", __func__);
|
||||
BTA_AvDisconnect(((tBTA_AV *)p_data)->pend.bd_addr);
|
||||
break;
|
||||
}
|
||||
@ -465,7 +473,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
@ -487,7 +495,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@ -541,7 +549,7 @@ static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
}
|
||||
@ -563,12 +571,12 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
tBTA_AV *p_av = (tBTA_AV *)p_data;
|
||||
|
||||
LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
if ( (event == BTA_AV_REMOTE_CMD_EVT) && (btc_av_cb.flags & BTC_AV_FLAG_REMOTE_SUSPEND) &&
|
||||
(p_av->remote_cmd.rc_id == BTA_AV_RC_PLAY) ) {
|
||||
LOG_INFO("%s: Resetting remote suspend flag on RC PLAY\n", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: Resetting remote suspend flag on RC PLAY\n", __FUNCTION__);
|
||||
btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND;
|
||||
}
|
||||
|
||||
@ -593,7 +601,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTA_AV_START_EVT: {
|
||||
LOG_INFO("BTA_AV_START_EVT status %d, suspending %d, init %d\n",
|
||||
BTC_TRACE_DEBUG("BTA_AV_START_EVT status %d, suspending %d, init %d\n",
|
||||
p_av->start.status, p_av->start.suspending, p_av->start.initiator);
|
||||
|
||||
if ((p_av->start.status == BTA_SUCCESS) && (p_av->start.suspending == TRUE)) {
|
||||
@ -606,7 +614,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
*/
|
||||
if (!(btc_av_cb.flags & BTC_AV_FLAG_PENDING_START)) {
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
||||
LOG_INFO("%s: trigger suspend as remote initiated!!", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: trigger suspend as remote initiated!!", __FUNCTION__);
|
||||
btc_dispatch_sm_event(BTC_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
|
||||
}
|
||||
}
|
||||
@ -672,7 +680,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
case BTA_AV_RECONFIG_EVT:
|
||||
if ((btc_av_cb.flags & BTC_AV_FLAG_PENDING_START) &&
|
||||
(p_av->reconfig.status == BTA_AV_SUCCESS)) {
|
||||
LOG_WARN("reconfig done BTA_AVstart()\n");
|
||||
BTC_TRACE_WARNING("reconfig done BTA_AVstart()\n");
|
||||
BTA_AvStart();
|
||||
} else if (btc_av_cb.flags & BTC_AV_FLAG_PENDING_START) {
|
||||
btc_av_cb.flags &= ~BTC_AV_FLAG_PENDING_START;
|
||||
@ -681,11 +689,11 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTC_AV_CONNECT_REQ_EVT:
|
||||
if (memcmp ((bt_bdaddr_t *)p_data, &(btc_av_cb.peer_bda),
|
||||
if (memcmp (&((btc_av_connect_req_t *)p_data)->target_bda, &(btc_av_cb.peer_bda),
|
||||
sizeof(btc_av_cb.peer_bda)) == 0) {
|
||||
LOG_DEBUG("%s: Ignore BTC_AVCONNECT_REQ_EVT for same device\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s: Ignore BTC_AVCONNECT_REQ_EVT for same device\n", __func__);
|
||||
} else {
|
||||
LOG_DEBUG("%s: Moved to opened by Other Incoming Conn req\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s: Moved to opened by Other Incoming Conn req\n", __func__);
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED,
|
||||
(bt_bdaddr_t *)p_data, ESP_A2D_DISC_RSN_NORMAL);
|
||||
}
|
||||
@ -695,7 +703,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
@ -717,7 +725,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
tBTA_AV *p_av = (tBTA_AV *)p_data;
|
||||
|
||||
LOG_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@ -792,7 +800,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
case BTA_AV_SUSPEND_EVT:
|
||||
|
||||
LOG_INFO("BTA_AV_SUSPEND_EVT status %d, init %d\n",
|
||||
BTC_TRACE_DEBUG("BTA_AV_SUSPEND_EVT status %d, init %d\n",
|
||||
p_av->suspend.status, p_av->suspend.initiator);
|
||||
|
||||
/* a2dp suspended, stop media task until resumed */
|
||||
@ -864,7 +872,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
@ -950,6 +958,7 @@ static void btc_av_event_free_data(btc_sm_event_t event, void *p_data)
|
||||
static bt_status_t btc_av_init(int service_id)
|
||||
{
|
||||
if (btc_av_cb.sm_handle == NULL) {
|
||||
btc_av_cb.service_id = service_id;
|
||||
bool stat = false;
|
||||
if (service_id == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
@ -996,9 +1005,9 @@ static bt_status_t btc_av_init(int service_id)
|
||||
static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
|
||||
{
|
||||
btc_av_connect_req_t connect_req;
|
||||
connect_req.target_bda = bd_addr;
|
||||
memcpy(&connect_req.target_bda, bd_addr, sizeof(bt_bdaddr_t));
|
||||
connect_req.uuid = uuid;
|
||||
LOG_DEBUG("%s\n", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s\n", __FUNCTION__);
|
||||
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_CONNECT_REQ_EVT, (char *)&connect_req);
|
||||
|
||||
@ -1016,11 +1025,15 @@ static bt_status_t connect_int(bt_bdaddr_t *bd_addr, uint16_t uuid)
|
||||
*******************************************************************************/
|
||||
static void clean_up(int service_id)
|
||||
{
|
||||
LOG_DEBUG("%s\n", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s\n", __FUNCTION__);
|
||||
|
||||
if (service_id == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
btc_a2dp_source_shutdown();
|
||||
if (tle_av_open_on_rc) {
|
||||
osi_alarm_free(tle_av_open_on_rc);
|
||||
tle_av_open_on_rc = NULL;
|
||||
}
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
}
|
||||
|
||||
@ -1070,7 +1083,7 @@ BOOLEAN btc_av_stream_ready(void)
|
||||
{
|
||||
btc_sm_state_t state = btc_sm_get_state(btc_av_cb.sm_handle);
|
||||
|
||||
LOG_DEBUG("btc_av_stream_ready : sm hdl %d, state %d, flags %x\n",
|
||||
BTC_TRACE_DEBUG("btc_av_stream_ready : sm hdl %d, state %d, flags %x\n",
|
||||
(int)btc_av_cb.sm_handle, state, btc_av_cb.flags);
|
||||
|
||||
/* check if we are remotely suspended or stop is pending */
|
||||
@ -1095,7 +1108,7 @@ BOOLEAN btc_av_stream_started_ready(void)
|
||||
{
|
||||
btc_sm_state_t state = btc_sm_get_state(btc_av_cb.sm_handle);
|
||||
|
||||
LOG_DEBUG("btc_av_stream_started : sm hdl %d, state %d, flags %x\n",
|
||||
BTC_TRACE_DEBUG("btc_av_stream_started : sm hdl %d, state %d, flags %x\n",
|
||||
(int)btc_av_cb.sm_handle, state, btc_av_cb.flags);
|
||||
|
||||
/* disallow media task to start if we have pending actions */
|
||||
@ -1138,7 +1151,7 @@ static void bte_av_callback(tBTA_AV_EVT event, tBTA_AV *p_data)
|
||||
stat = btc_transfer_context(&msg, p_data, sizeof(tBTA_AV), btc_av_event_deep_copy);
|
||||
|
||||
if (stat) {
|
||||
LOG_ERROR("%s transfer failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s transfer failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1155,7 +1168,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
if ( (state == BTC_AV_STATE_STARTED) || /* send SBC packets only in Started State */
|
||||
(state == BTC_AV_STATE_OPENED) ) {
|
||||
que_len = btc_a2dp_sink_enque_buf((BT_HDR *)p_data);
|
||||
LOG_DEBUG(" Packets in Que %d\n", que_len);
|
||||
BTC_TRACE_DEBUG(" Packets in Que %d\n", que_len);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -1180,14 +1193,14 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
memcpy(arg.mcc.cie.sbc, (uint8_t *)p_data + 3, ESP_A2D_CIE_LEN_SBC);
|
||||
btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
} else {
|
||||
LOG_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status);
|
||||
BTC_TRACE_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
{
|
||||
LOG_WARN("%s : event %u\n", __func__, event);
|
||||
BTC_TRACE_WARNING("%s : event %u\n", __func__, event);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1254,6 +1267,21 @@ BOOLEAN btc_av_is_connected(void)
|
||||
return ((state == BTC_AV_STATE_OPENED) || (state == BTC_AV_STATE_STARTED));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function btc_av_get_service_id
|
||||
*
|
||||
* Description Get the current AV service ID.
|
||||
*
|
||||
* Returns The stream endpoint type: either BTA_A2DP_SOURCE_SERVICE_ID or
|
||||
* BTA_A2DP_SINK_SERVICE_ID.
|
||||
*
|
||||
******************************************************************************/
|
||||
uint8_t btc_av_get_service_id(void)
|
||||
{
|
||||
return btc_av_cb.service_id;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Function btc_av_get_peer_sep
|
||||
@ -1302,7 +1330,7 @@ BOOLEAN btc_av_is_peer_edr(void)
|
||||
******************************************************************************/
|
||||
void btc_av_clear_remote_suspend_flag(void)
|
||||
{
|
||||
LOG_DEBUG("%s: flag :%x\n", __func__, btc_av_cb.flags);
|
||||
BTC_TRACE_DEBUG("%s: flag :%x\n", __func__, btc_av_cb.flags);
|
||||
btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND;
|
||||
}
|
||||
|
||||
@ -1371,6 +1399,9 @@ void btc_a2dp_call_handler(btc_msg_t *msg)
|
||||
btc_a2dp_control_datapath_ctrl(arg->dp_evt);
|
||||
break;
|
||||
}
|
||||
case BTC_AV_CONNECT_REQ_EVT:
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, msg->act, (char *)msg->arg);
|
||||
break;
|
||||
// case BTC_AV_DISCONNECT_REQ_EVT:
|
||||
case BTC_AV_START_STREAM_REQ_EVT:
|
||||
case BTC_AV_STOP_STREAM_REQ_EVT:
|
||||
@ -1379,7 +1410,7 @@ void btc_a2dp_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1402,14 +1433,14 @@ void btc_a2dp_cb_handler(btc_msg_t *msg)
|
||||
*******************************************************************************/
|
||||
static bt_status_t btc_a2d_sink_init(void)
|
||||
{
|
||||
LOG_DEBUG("%s()\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s()\n", __func__);
|
||||
|
||||
return btc_av_init(BTA_A2DP_SINK_SERVICE_ID);
|
||||
}
|
||||
|
||||
static bt_status_t btc_a2d_sink_connect(bt_bdaddr_t *remote_bda)
|
||||
{
|
||||
LOG_DEBUG("%s\n", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s\n", __FUNCTION__);
|
||||
CHECK_BTAV_INIT();
|
||||
|
||||
return btc_queue_connect(UUID_SERVCLASS_AUDIO_SINK, remote_bda, connect_int);
|
||||
@ -1435,7 +1466,7 @@ static void btc_a2d_sink_deinit(void)
|
||||
*******************************************************************************/
|
||||
static bt_status_t btc_a2d_src_init(void)
|
||||
{
|
||||
LOG_DEBUG("%s()\n", __func__);
|
||||
BTC_TRACE_DEBUG("%s()\n", __func__);
|
||||
|
||||
return btc_av_init(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
}
|
||||
@ -1447,7 +1478,7 @@ static void btc_a2d_src_deinit(void)
|
||||
|
||||
static bt_status_t btc_a2d_src_connect(bt_bdaddr_t *remote_bda)
|
||||
{
|
||||
LOG_DEBUG("%s\n", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s\n", __FUNCTION__);
|
||||
CHECK_BTAV_INIT();
|
||||
|
||||
return btc_queue_connect(UUID_SERVCLASS_AUDIO_SOURCE, remote_bda, connect_int);
|
||||
|
@ -47,9 +47,9 @@
|
||||
#define MAX_CMD_QUEUE_LEN 8
|
||||
|
||||
#define CHECK_ESP_RC_CONNECTED do { \
|
||||
LOG_DEBUG("## %s ##", __FUNCTION__); \
|
||||
BTC_TRACE_DEBUG("## %s ##", __FUNCTION__); \
|
||||
if (btc_rc_vb.rc_connected == FALSE) { \
|
||||
LOG_WARN("Function %s() called when RC is not connected", __FUNCTION__); \
|
||||
BTC_TRACE_WARNING("Function %s() called when RC is not connected", __FUNCTION__); \
|
||||
return ESP_ERR_INVALID_STATE; \
|
||||
} \
|
||||
} while (0)
|
||||
@ -138,17 +138,17 @@ static void handle_rc_features(void)
|
||||
***************************************************************************/
|
||||
static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
|
||||
{
|
||||
LOG_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle);
|
||||
BTC_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle);
|
||||
bt_bdaddr_t rc_addr;
|
||||
|
||||
if (p_rc_open->status == BTA_AV_SUCCESS) {
|
||||
//check if already some RC is connected
|
||||
if (btc_rc_vb.rc_connected) {
|
||||
LOG_ERROR("Got RC OPEN in connected state, Connected RC: %d \
|
||||
BTC_TRACE_ERROR("Got RC OPEN in connected state, Connected RC: %d \
|
||||
and Current RC: %d", btc_rc_vb.rc_handle, p_rc_open->rc_handle );
|
||||
if ((btc_rc_vb.rc_handle != p_rc_open->rc_handle)
|
||||
&& (bdcmp(btc_rc_vb.rc_addr, p_rc_open->peer_addr))) {
|
||||
LOG_DEBUG("Got RC connected for some other handle");
|
||||
BTC_TRACE_DEBUG("Got RC connected for some other handle");
|
||||
BTA_AvCloseRc(p_rc_open->rc_handle);
|
||||
return;
|
||||
}
|
||||
@ -174,7 +174,7 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
|
||||
handle_rc_features();
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("%s Connect failed with error code: %d",
|
||||
BTC_TRACE_ERROR("%s Connect failed with error code: %d",
|
||||
__FUNCTION__, p_rc_open->status);
|
||||
btc_rc_vb.rc_connected = FALSE;
|
||||
}
|
||||
@ -192,10 +192,10 @@ static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close)
|
||||
{
|
||||
bt_bdaddr_t rc_addr;
|
||||
|
||||
LOG_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle);
|
||||
BTC_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle);
|
||||
if ((p_rc_close->rc_handle != btc_rc_vb.rc_handle)
|
||||
&& (bdcmp(btc_rc_vb.rc_addr, p_rc_close->peer_addr))) {
|
||||
LOG_ERROR("Got disconnect of unknown device");
|
||||
BTC_TRACE_ERROR("Got disconnect of unknown device");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ static void handle_rc_metadata_rsp ( tBTA_AV_META_MSG *p_remote_rsp)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
LOG_ERROR("%s AVRCP metadata is not enabled", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s AVRCP metadata is not enabled", __FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
|
||||
key_state = 0;
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s: rc_id=%d status=%s", __FUNCTION__, p_remote_rsp->rc_id, status);
|
||||
BTC_TRACE_DEBUG("%s: rc_id=%d status=%s", __FUNCTION__, p_remote_rsp->rc_id, status);
|
||||
|
||||
do {
|
||||
esp_avrc_ct_cb_param_t param;
|
||||
@ -333,10 +333,10 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
|
||||
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_PASSTHROUGH_RSP_EVT, ¶m);
|
||||
} while (0);
|
||||
} else {
|
||||
LOG_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__);
|
||||
}
|
||||
#else
|
||||
LOG_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__);
|
||||
BTC_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -350,10 +350,10 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
|
||||
***************************************************************************/
|
||||
void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data)
|
||||
{
|
||||
LOG_DEBUG ("%s event:%s", __FUNCTION__, dump_rc_event(event));
|
||||
BTC_TRACE_DEBUG ("%s event:%s", __FUNCTION__, dump_rc_event(event));
|
||||
switch (event) {
|
||||
case BTA_AV_RC_OPEN_EVT: {
|
||||
LOG_DEBUG("Peer_features:%x", p_data->rc_open.peer_features);
|
||||
BTC_TRACE_DEBUG("Peer_features:%x", p_data->rc_open.peer_features);
|
||||
handle_rc_connect( &(p_data->rc_open) );
|
||||
} break;
|
||||
|
||||
@ -363,14 +363,14 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data)
|
||||
|
||||
#if (AVRC_CTLR_INCLUDED == TRUE)
|
||||
case BTA_AV_REMOTE_RSP_EVT: {
|
||||
LOG_DEBUG("RSP: rc_id:0x%x key_state:%d", p_data->remote_rsp.rc_id,
|
||||
BTC_TRACE_DEBUG("RSP: rc_id:0x%x key_state:%d", p_data->remote_rsp.rc_id,
|
||||
p_data->remote_rsp.key_state);
|
||||
handle_rc_passthrough_rsp( (&p_data->remote_rsp) );
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case BTA_AV_RC_FEAT_EVT: {
|
||||
LOG_DEBUG("Peer_features:%x", p_data->rc_feat.peer_features);
|
||||
BTC_TRACE_DEBUG("Peer_features:%x", p_data->rc_feat.peer_features);
|
||||
btc_rc_vb.rc_features = p_data->rc_feat.peer_features;
|
||||
handle_rc_features();
|
||||
}
|
||||
@ -384,7 +384,7 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data)
|
||||
// below events are not handled for now
|
||||
case BTA_AV_REMOTE_CMD_EVT:
|
||||
default:
|
||||
LOG_DEBUG("Unhandled RC event : 0x%x", event);
|
||||
BTC_TRACE_DEBUG("Unhandled RC event : 0x%x", event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,7 +419,7 @@ BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
static void btc_avrc_ct_init(void)
|
||||
{
|
||||
LOG_DEBUG("## %s ##", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("## %s ##", __FUNCTION__);
|
||||
|
||||
memset (&btc_rc_vb, 0, sizeof(btc_rc_vb));
|
||||
btc_rc_vb.rc_vol_label = MAX_LABEL;
|
||||
@ -438,10 +438,10 @@ static void btc_avrc_ct_init(void)
|
||||
***************************************************************************/
|
||||
static void btc_avrc_ct_deinit(void)
|
||||
{
|
||||
LOG_INFO("## %s ##", __FUNCTION__);
|
||||
BTC_TRACE_API("## %s ##", __FUNCTION__);
|
||||
|
||||
memset(&btc_rc_vb, 0, sizeof(btc_rc_cb_t));
|
||||
LOG_INFO("## %s ## completed", __FUNCTION__);
|
||||
BTC_TRACE_API("## %s ## completed", __FUNCTION__);
|
||||
}
|
||||
|
||||
static bt_status_t btc_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t attr_id, uint8_t value_id)
|
||||
@ -471,12 +471,12 @@ static bt_status_t btc_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t att
|
||||
status = BT_STATUS_SUCCESS;
|
||||
} else {
|
||||
status = BT_STATUS_FAIL;
|
||||
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
return status;
|
||||
@ -505,12 +505,12 @@ static bt_status_t btc_avrc_ct_send_register_notification_cmd(uint8_t tl, uint8_
|
||||
status = BT_STATUS_SUCCESS;
|
||||
} else {
|
||||
status = BT_STATUS_FAIL;
|
||||
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
return status;
|
||||
@ -547,12 +547,12 @@ static bt_status_t btc_avrc_ct_send_metadata_cmd (uint8_t tl, uint8_t attr_mask)
|
||||
status = BT_STATUS_SUCCESS;
|
||||
} else {
|
||||
status = BT_STATUS_FAIL;
|
||||
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
return status;
|
||||
@ -564,19 +564,19 @@ static bt_status_t btc_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code
|
||||
|
||||
#if (AVRC_CTLR_INCLUDED == TRUE)
|
||||
CHECK_ESP_RC_CONNECTED;
|
||||
LOG_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__,
|
||||
key_code, key_state);
|
||||
if (btc_rc_vb.rc_features & BTA_AV_FEAT_RCTG) {
|
||||
BTA_AvRemoteCmd(btc_rc_vb.rc_handle, tl,
|
||||
(tBTA_AV_RC)key_code, (tBTA_AV_STATE)key_state);
|
||||
status = BT_STATUS_SUCCESS;
|
||||
LOG_INFO("%s: succesfully sent passthrough command to BTA", __FUNCTION__);
|
||||
BTC_TRACE_API("%s: succesfully sent passthrough command to BTA", __FUNCTION__);
|
||||
} else {
|
||||
status = BT_STATUS_FAIL;
|
||||
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not supported", __FUNCTION__);
|
||||
}
|
||||
#else
|
||||
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s: feature not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
||||
return status;
|
||||
@ -614,7 +614,7 @@ void btc_avrc_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_WARN("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_WARNING("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
case ESP_GATTS_REG_EVT: {
|
||||
esp_gatt_status_t status = p_data->reg_oper.status;
|
||||
server_if = p_data->reg_oper.server_if;
|
||||
LOG_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n",
|
||||
BTC_TRACE_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n",
|
||||
event, status, server_if);
|
||||
|
||||
UINT8 app_id = 0xff;
|
||||
@ -77,18 +77,18 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
|
||||
/*connect callback*/
|
||||
case ESP_GATTS_CONNECT_EVT: {
|
||||
LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BTC_TRACE_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
/*return whether the remote device is currently connected*/
|
||||
int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda);
|
||||
LOG_ERROR("is_connected=%d\n", is_connected);
|
||||
BTC_TRACE_ERROR("is_connected=%d\n", is_connected);
|
||||
}
|
||||
break;
|
||||
|
||||
/*create service callback*/
|
||||
case ESP_GATTS_CREATE_EVT: {
|
||||
LOG_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n",
|
||||
BTC_TRACE_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n",
|
||||
p_data->create.server_if, p_data->create.service_id,
|
||||
p_data->create.uuid.uu.uuid16);
|
||||
UINT16 service_uuid = p_data->create.uuid.uu.uuid16;
|
||||
@ -107,7 +107,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT: {
|
||||
LOG_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n",
|
||||
BTC_TRACE_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
p_data->add_result.char_uuid.uu.uuid16);
|
||||
UINT16 char_uuid = p_data->add_result.char_uuid.uu.uuid16;
|
||||
@ -144,7 +144,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT: {
|
||||
|
||||
LOG_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n",
|
||||
BTC_TRACE_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
p_data->add_result.attr_id, p_data->add_result.char_uuid.uu.uuid16);
|
||||
bas_AddCharDescr(p_data->add_result.service_id, p_data->add_result.attr_id);
|
||||
@ -152,7 +152,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
break;
|
||||
|
||||
case ESP_GATTS_START_EVT: {
|
||||
LOG_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if,
|
||||
BTC_TRACE_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if,
|
||||
p_data->srvc_oper.service_id);
|
||||
bas_service_cmpl(p_data->srvc_oper.service_id, p_data->srvc_oper.status);
|
||||
|
||||
@ -168,7 +168,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->read_req.handle;
|
||||
bool is_long = p_data->req_data.p_data->read_req.is_long;
|
||||
LOG_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
BTC_TRACE_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
|
||||
if (dis_valid_handle_range(handle)) {
|
||||
@ -188,7 +188,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->write_req.handle;
|
||||
LOG_ERROR("write request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
BTC_TRACE_ERROR("write request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
bas_s_write_attr_value(p_data->req_data.p_data, trans_id, conn_id,
|
||||
p_data->req_data.remote_bda);
|
||||
@ -199,7 +199,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT8 exec_write = p_data->req_data.p_data->exec_write;
|
||||
LOG_ERROR("execute write request:event=0x%x,exce_write=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
BTC_TRACE_ERROR("execute write request:event=0x%x,exce_write=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, exec_write, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
@ -208,7 +208,7 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 mtu = p_data->req_data.p_data->mtu;
|
||||
LOG_ERROR("exchange mtu request:event=0x%x,mtu=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
BTC_TRACE_ERROR("exchange mtu request:event=0x%x,mtu=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, mtu, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
@ -217,13 +217,13 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
LOG_ERROR("configue request:trans_id=0x%x,conn_id=0x%x\n",
|
||||
BTC_TRACE_ERROR("configue request:trans_id=0x%x,conn_id=0x%x\n",
|
||||
trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR("unsettled event: %d\n", event);
|
||||
BTC_TRACE_ERROR("unsettled event: %d\n", event);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -240,32 +240,32 @@ static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
tGATT_STATUS st = ESP_GATT_OK;
|
||||
switch (event) {
|
||||
case BA_READ_LEVEL_REQ : {
|
||||
LOG_ERROR("read battery level\n");
|
||||
BTC_TRACE_ERROR("read battery level\n");
|
||||
p_rsp.ba_level = 60; //battery level
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp);
|
||||
}
|
||||
break;
|
||||
|
||||
case BA_READ_PRE_FMT_REQ : {
|
||||
LOG_ERROR("read presentation format\n");
|
||||
BTC_TRACE_ERROR("read presentation format\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case BA_READ_CLT_CFG_REQ : {
|
||||
LOG_ERROR("read client characteristic configuration request\n");
|
||||
BTC_TRACE_ERROR("read client characteristic configuration request\n");
|
||||
p_rsp.clt_cfg = 0x0001; //notification
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp);
|
||||
}
|
||||
break;
|
||||
|
||||
case BA_READ_RPT_REF_REQ : {
|
||||
LOG_ERROR("read report reference descriptor\n");
|
||||
BTC_TRACE_ERROR("read report reference descriptor\n");
|
||||
}
|
||||
break;
|
||||
|
||||
/*battery level notify*/
|
||||
case BA_WRITE_CLT_CFG_REQ : {
|
||||
LOG_ERROR("write client characteristic configuration request\n");
|
||||
BTC_TRACE_ERROR("write client characteristic configuration request\n");
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, NULL);
|
||||
|
||||
int battery_level = 50;
|
||||
@ -398,8 +398,8 @@ void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id)
|
||||
|
||||
p_inst = &battery_cb.battery_inst[battery_cb.inst_id];
|
||||
|
||||
LOG_ERROR("create battery service\n");
|
||||
LOG_ERROR("inst_id=%d\n", battery_cb.inst_id);
|
||||
BTC_TRACE_ERROR("create battery service\n");
|
||||
BTC_TRACE_ERROR("inst_id=%d\n", battery_cb.inst_id);
|
||||
esp_ble_gatts_create_srvc (gatt_if, &bas_uuid, battery_cb.inst_id ,
|
||||
BA_MAX_ATTR_NUM, ba_reg_info.is_pri);
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "btc/btc_ble_storage.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_util.h"
|
||||
|
||||
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
|
||||
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
|
||||
@ -107,85 +108,6 @@ static void btc_cleanup_adv_data(tBTA_BLE_ADV_DATA *bta_adv_data)
|
||||
btc_gap_adv_point_cleanup((void **) &bta_adv_data->p_sol_service_128b);
|
||||
}
|
||||
|
||||
|
||||
static esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
|
||||
{
|
||||
esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL;
|
||||
switch(hci_status) {
|
||||
case HCI_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case HCI_ERR_ESP_VENDOR_FAIL:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
case HCI_ERR_HOST_TIMEOUT:
|
||||
esp_status = ESP_BT_STATUS_TIMEOUT;
|
||||
break;
|
||||
case HCI_ERR_ILLEGAL_COMMAND:
|
||||
esp_status = ESP_BT_STATUS_PENDING;
|
||||
break;
|
||||
case HCI_ERR_UNACCEPT_CONN_INTERVAL:
|
||||
esp_status = ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL;
|
||||
break;
|
||||
case HCI_ERR_PARAM_OUT_OF_RANGE:
|
||||
esp_status = ESP_BT_STATUS_PARAM_OUT_OF_RANGE;
|
||||
break;
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
esp_status = ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT;
|
||||
break;
|
||||
case HCI_ERR_MEMORY_FULL:
|
||||
esp_status = ESP_BT_STATUS_MEMORY_FULL;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
return esp_status;
|
||||
}
|
||||
|
||||
static esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status)
|
||||
{
|
||||
esp_bt_status_t esp_status = ESP_BT_STATUS_FAIL;
|
||||
switch(btm_status){
|
||||
case BTM_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case BTM_BUSY:
|
||||
esp_status = ESP_BT_STATUS_BUSY;
|
||||
break;
|
||||
case BTM_NO_RESOURCES:
|
||||
esp_status = ESP_BT_STATUS_NOMEM;
|
||||
break;
|
||||
case BTM_ERR_PROCESSING:
|
||||
esp_status = ESP_BT_STATUS_PENDING;
|
||||
break;
|
||||
case BTM_PEER_LE_DATA_LEN_UNSUPPORTED:
|
||||
esp_status = ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED;
|
||||
break;
|
||||
case BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED:
|
||||
esp_status = ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED;
|
||||
break;
|
||||
case BTM_SET_PRIVACY_SUCCESS:
|
||||
esp_status = ESP_BT_STATUS_SUCCESS;
|
||||
break;
|
||||
case BTM_SET_PRIVACY_FAIL:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
case BTM_INVALID_STATIC_RAND_ADDR:
|
||||
esp_status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
|
||||
break;
|
||||
case BTM_SET_STATIC_RAND_ADDR_FAIL:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
return esp_status;
|
||||
}
|
||||
|
||||
static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DATA *bta_adv_data, uint32_t *data_mask)
|
||||
{
|
||||
uint32_t mask;
|
||||
@ -289,7 +211,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
|
||||
}
|
||||
|
||||
if (NULL != bta_adv_data->p_services->p_uuid) {
|
||||
LOG_DEBUG("%s - In 16-UUID_data", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s - In 16-UUID_data", __FUNCTION__);
|
||||
mask |= BTM_BLE_AD_BIT_SERVICE;
|
||||
++bta_adv_data->p_services->num_service;
|
||||
*p_uuid_out16++ = bt_uuid.uu.uuid16;
|
||||
@ -309,7 +231,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
|
||||
}
|
||||
|
||||
if (NULL != bta_adv_data->p_service_32b->p_uuid) {
|
||||
LOG_DEBUG("%s - In 32-UUID_data", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s - In 32-UUID_data", __FUNCTION__);
|
||||
mask |= BTM_BLE_AD_BIT_SERVICE_32;
|
||||
++bta_adv_data->p_service_32b->num_service;
|
||||
*p_uuid_out32++ = bt_uuid.uu.uuid32;
|
||||
@ -323,11 +245,11 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
|
||||
bta_adv_data->p_services_128b =
|
||||
osi_malloc(sizeof(tBTA_BLE_128SERVICE));
|
||||
if (NULL != bta_adv_data->p_services_128b) {
|
||||
LOG_DEBUG("%s - In 128-UUID_data", __FUNCTION__);
|
||||
BTC_TRACE_DEBUG("%s - In 128-UUID_data", __FUNCTION__);
|
||||
mask |= BTM_BLE_AD_BIT_SERVICE_128;
|
||||
memcpy(bta_adv_data->p_services_128b->uuid128,
|
||||
bt_uuid.uu.uuid128, LEN_UUID_128);
|
||||
LOG_DEBUG("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x", bt_uuid.uu.uuid128[0],
|
||||
BTC_TRACE_DEBUG("%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x", bt_uuid.uu.uuid128[0],
|
||||
bt_uuid.uu.uuid128[1], bt_uuid.uu.uuid128[2], bt_uuid.uu.uuid128[3],
|
||||
bt_uuid.uu.uuid128[4], bt_uuid.uu.uuid128[5], bt_uuid.uu.uuid128[6],
|
||||
bt_uuid.uu.uuid128[7], bt_uuid.uu.uuid128[8], bt_uuid.uu.uuid128[9],
|
||||
@ -363,7 +285,7 @@ static void btc_adv_data_callback(tBTA_STATUS status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,7 +304,7 @@ static void btc_scan_rsp_data_callback(tBTA_STATUS status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,7 +323,7 @@ static void btc_adv_data_raw_callback(tBTA_STATUS status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,7 +342,7 @@ static void btc_scan_rsp_data_raw_callback(tBTA_STATUS status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +387,7 @@ static void btc_start_adv_callback(uint8_t status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -484,7 +406,7 @@ static void btc_stop_adv_callback(uint8_t status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,24 +417,24 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT
|
||||
if (!BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
|
||||
!BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
|
||||
status = ESP_BT_STATUS_PARM_INVALID;
|
||||
LOG_ERROR("Invalid advertisting interval parameters.\n");
|
||||
BTC_TRACE_ERROR("Invalid advertisting interval parameters.\n");
|
||||
}
|
||||
|
||||
if ((ble_adv_params->adv_type < ADV_TYPE_IND) ||
|
||||
(ble_adv_params->adv_type > ADV_TYPE_DIRECT_IND_LOW) ) {
|
||||
status = ESP_BT_STATUS_PARM_INVALID;
|
||||
LOG_ERROR("Invalid advertisting type parameters.\n");
|
||||
BTC_TRACE_ERROR("Invalid advertisting type parameters.\n");
|
||||
}
|
||||
|
||||
if ((ble_adv_params->adv_filter_policy < ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY) ||
|
||||
(ble_adv_params->adv_filter_policy > ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST) ) {
|
||||
status = ESP_BT_STATUS_PARM_INVALID;
|
||||
LOG_ERROR("Invalid advertisting type parameters.\n");
|
||||
BTC_TRACE_ERROR("Invalid advertisting type parameters.\n");
|
||||
}
|
||||
|
||||
if((ble_adv_params->channel_map | ADV_CHNL_ALL) != ADV_CHNL_ALL || ble_adv_params->channel_map == 0) {
|
||||
status = ESP_BT_STATUS_PARM_INVALID;
|
||||
LOG_ERROR("Invalid advertisting channel map parameters.\n");
|
||||
BTC_TRACE_ERROR("Invalid advertisting channel map parameters.\n");
|
||||
}
|
||||
if(status != ESP_BT_STATUS_SUCCESS) {
|
||||
if(start_adv_cback) {
|
||||
@ -520,8 +442,8 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_DEBUG("API_Ble_AppStartAdvertising\n");
|
||||
|
||||
BTC_TRACE_DEBUG("API_Ble_AppStartAdvertising\n");
|
||||
|
||||
memcpy(peer_addr.bda, ble_adv_params->peer_addr, ESP_BD_ADDR_LEN);
|
||||
peer_addr.type = ble_adv_params->peer_addr_type;
|
||||
@ -551,7 +473,7 @@ static void btc_scan_params_callback(tGATT_IF gatt_if, tBTM_STATUS status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,6 +483,7 @@ static void btc_ble_set_scan_params(esp_ble_scan_params_t *scan_params, tBLE_SCA
|
||||
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->scan_filter_policy, BLE_SCAN_FILTER_ALLOW_ALL, BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR) &&
|
||||
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)) {
|
||||
BTA_DmSetBleScanFilterParams(ESP_DEFAULT_GATT_IF, /*client_if*/
|
||||
scan_params->scan_interval,
|
||||
@ -568,6 +491,7 @@ static void btc_ble_set_scan_params(esp_ble_scan_params_t *scan_params, tBLE_SCA
|
||||
scan_params->scan_type,
|
||||
scan_params->scan_filter_policy,
|
||||
scan_params->own_addr_type,
|
||||
scan_params->scan_duplicate,
|
||||
scan_param_setup_cback);
|
||||
} else {
|
||||
btc_scan_params_callback(ESP_DEFAULT_GATT_IF, BTM_ILLEGAL_VALUE);
|
||||
@ -600,26 +524,26 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
|
||||
}
|
||||
case BTA_DM_INQ_CMPL_EVT: {
|
||||
param.scan_rst.num_resps = p_data->inq_cmpl.num_resps;
|
||||
LOG_DEBUG("%s BLE observe complete. Num Resp %d\n", __FUNCTION__, p_data->inq_cmpl.num_resps);
|
||||
BTC_TRACE_DEBUG("%s BLE observe complete. Num Resp %d\n", __FUNCTION__, p_data->inq_cmpl.num_resps);
|
||||
break;
|
||||
}
|
||||
case BTA_DM_DISC_RES_EVT:
|
||||
LOG_DEBUG("BTA_DM_DISC_RES_EVT\n");
|
||||
BTC_TRACE_DEBUG("BTA_DM_DISC_RES_EVT\n");
|
||||
break;
|
||||
case BTA_DM_DISC_BLE_RES_EVT:
|
||||
LOG_DEBUG("BTA_DM_DISC_BLE_RES_EVT\n");
|
||||
BTC_TRACE_DEBUG("BTA_DM_DISC_BLE_RES_EVT\n");
|
||||
break;
|
||||
case BTA_DM_DISC_CMPL_EVT:
|
||||
LOG_DEBUG("BTA_DM_DISC_CMPL_EVT\n");
|
||||
BTC_TRACE_DEBUG("BTA_DM_DISC_CMPL_EVT\n");
|
||||
break;
|
||||
case BTA_DM_DI_DISC_CMPL_EVT:
|
||||
LOG_DEBUG("BTA_DM_DI_DISC_CMPL_EVT\n");
|
||||
BTC_TRACE_DEBUG("BTA_DM_DI_DISC_CMPL_EVT\n");
|
||||
break;
|
||||
case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
|
||||
LOG_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n");
|
||||
BTC_TRACE_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n");
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event);
|
||||
BTC_TRACE_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event);
|
||||
return;
|
||||
}
|
||||
btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
@ -640,7 +564,7 @@ static void btc_start_scan_callback(uint8_t status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,7 +583,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -682,7 +606,7 @@ void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDA
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -701,7 +625,7 @@ static void btc_set_pkt_length_callback(UINT8 status, tBTM_LE_SET_PKT_DATA_LENGT
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -719,16 +643,16 @@ static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_set_rand_addr_callback(UINT8 status)
|
||||
static void btc_set_rand_addr_callback(UINT8 status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
param.set_rand_addr_cmpl.status = btc_btm_status_to_esp_status(status); //todo status
|
||||
param.set_rand_addr_cmpl.status = btc_btm_status_to_esp_status(status); //todo status
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT;
|
||||
@ -736,7 +660,7 @@ static void btc_set_rand_addr_callback(UINT8 status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
|
||||
}
|
||||
@ -754,7 +678,7 @@ static void btc_set_local_privacy_callback(UINT8 status)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -764,7 +688,7 @@ static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transpor
|
||||
{
|
||||
UNUSED(bd_addr);
|
||||
UNUSED(transport);
|
||||
LOG_DEBUG("enc_status = %x\n", enc_status);
|
||||
BTC_TRACE_DEBUG("enc_status = %x\n", enc_status);
|
||||
return;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
@ -786,7 +710,7 @@ static void btc_read_ble_rssi_cmpl_callback(void *p_data)
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -804,7 +728,7 @@ static void btc_ble_start_scanning(uint32_t duration,
|
||||
//Start scan the device
|
||||
BTA_DmBleScan(true, duration, results_cb, start_scan_cb);
|
||||
} else {
|
||||
LOG_ERROR("The start_scan_cb or results_cb invalid\n");
|
||||
BTC_TRACE_ERROR("The start_scan_cb or results_cb invalid\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -830,7 +754,7 @@ static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int,
|
||||
}
|
||||
|
||||
if (min_int < BTM_BLE_CONN_INT_MIN || max_int > BTM_BLE_CONN_INT_MAX) {
|
||||
LOG_ERROR("Invalid interval value.\n");
|
||||
BTC_TRACE_ERROR("Invalid interval value.\n");
|
||||
}
|
||||
|
||||
BTA_DmBleUpdateConnectionParams(bd_addr, min_int, max_int,
|
||||
@ -872,11 +796,11 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *
|
||||
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
LOG_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0");
|
||||
BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0");
|
||||
}
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
LOG_ERROR("Invalid random addressm, the address value is NULL");
|
||||
BTC_TRACE_ERROR("Invalid random addressm, the address value is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
@ -897,7 +821,7 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
|
||||
if (msg->act < ESP_GAP_BLE_EVT_MAX) {
|
||||
btc_gap_ble_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, unknow msg->act = %d", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s, unknow msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_gap_ble_cb_deep_free(msg);
|
||||
@ -962,13 +886,13 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->set_security_param.value != NULL) {
|
||||
memcpy(dst->set_security_param.value, src->set_security_param.value, length);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -977,14 +901,14 @@ void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
switch (msg->act) {
|
||||
default:
|
||||
LOG_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
LOG_DEBUG("%s \n", __func__);
|
||||
BTC_TRACE_DEBUG("%s \n", __func__);
|
||||
switch (msg->act) {
|
||||
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;
|
||||
@ -1015,18 +939,25 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: {
|
||||
uint8_t *value = ((btc_ble_gap_args_t *)msg->arg)->set_security_param.value;
|
||||
if (value) {
|
||||
osi_free(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_ble_cb_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
LOG_DEBUG("%s", __func__);
|
||||
BTC_TRACE_DEBUG("%s", __func__);
|
||||
switch (msg->act) {
|
||||
default:
|
||||
LOG_DEBUG("Unhandled deep free %d", msg->act);
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d", msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1035,7 +966,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_gap_args_t *arg = (btc_ble_gap_args_t *)msg->arg;
|
||||
|
||||
LOG_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s act %d\n", __FUNCTION__, msg->act);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA: {
|
||||
@ -1116,36 +1047,37 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: {
|
||||
uint8_t *value = arg->set_security_param.value;
|
||||
switch(arg->set_security_param.param_type) {
|
||||
case ESP_BLE_SM_PASSKEY:
|
||||
break;
|
||||
case ESP_BLE_SM_AUTHEN_REQ_MODE: {
|
||||
uint8_t authen_req = 0;
|
||||
STREAM_TO_UINT8(authen_req, arg->set_security_param.value);
|
||||
STREAM_TO_UINT8(authen_req, value);
|
||||
bta_dm_co_ble_set_auth_req(authen_req);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_IOCAP_MODE: {
|
||||
uint8_t iocap = 0;
|
||||
STREAM_TO_UINT8(iocap, arg->set_security_param.value);
|
||||
STREAM_TO_UINT8(iocap, value);
|
||||
bta_dm_co_ble_set_io_cap(iocap);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_SET_INIT_KEY: {
|
||||
uint8_t init_key = 0;
|
||||
STREAM_TO_UINT8(init_key, arg->set_security_param.value);
|
||||
STREAM_TO_UINT8(init_key, value);
|
||||
bta_dm_co_ble_set_init_key_req(init_key);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_SET_RSP_KEY: {
|
||||
uint8_t rsp_key = 0;
|
||||
STREAM_TO_UINT8(rsp_key, arg->set_security_param.value);
|
||||
STREAM_TO_UINT8(rsp_key, value);
|
||||
bta_dm_co_ble_set_rsp_key_req(rsp_key);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_MAX_KEY_SIZE: {
|
||||
uint8_t key_size = 0;
|
||||
STREAM_TO_UINT8(key_size, arg->set_security_param.value);
|
||||
STREAM_TO_UINT8(key_size, value);
|
||||
bta_dm_co_ble_set_max_key_size(key_size);
|
||||
break;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "btc_gap_bt.h"
|
||||
#include "btc/btc_storage.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "common/bt_target.h"
|
||||
@ -68,7 +69,7 @@ static void btc_bt_set_scan_mode(esp_bt_scan_mode_t mode)
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("invalid scan mode (0x%x)", mode);
|
||||
BTC_TRACE_WARNING("invalid scan mode (0x%x)", mode);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,31 +138,35 @@ static void btc_gap_bt_get_remote_service_record(btc_gap_bt_args_t *arg)
|
||||
*******************************************************************************/
|
||||
static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest;
|
||||
tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src;
|
||||
|
||||
tBTA_DM_SEARCH_PARAM *p_dest_data = (tBTA_DM_SEARCH_PARAM *) p_dest;
|
||||
tBTA_DM_SEARCH_PARAM *p_src_data = (tBTA_DM_SEARCH_PARAM *) p_src;
|
||||
if (!p_src) {
|
||||
return;
|
||||
}
|
||||
p_dest_data->p_data = (void *)osi_malloc(p_dest_data->len);
|
||||
memset(p_dest_data->p_data, 0x00, p_dest_data->len);
|
||||
memcpy(p_dest_data->p_data, p_src_data->p_data, p_dest_data->len);
|
||||
|
||||
switch (msg->aid) {
|
||||
case BTA_DM_INQ_RES_EVT: {
|
||||
if (p_src_data->inq_res.p_eir) {
|
||||
p_dest_data->inq_res.p_eir = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->inq_res.p_eir, p_src_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN);
|
||||
if ( p_dest_data->len > sizeof(tBTA_DM_SEARCH)){
|
||||
switch (p_dest_data->event) {
|
||||
case BTA_DM_INQ_RES_EVT: {
|
||||
if (p_src_data->p_data->inq_res.p_eir) {
|
||||
p_dest_data->p_data->inq_res.p_eir = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->p_data->inq_res.p_eir, p_src_data->p_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->disc_res.raw_data_size && p_src_data->disc_res.p_raw_data) {
|
||||
p_dest_data->disc_res.p_raw_data = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->disc_res.p_raw_data,
|
||||
p_src_data->disc_res.p_raw_data,
|
||||
p_src_data->disc_res.raw_data_size);
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->p_data->disc_res.raw_data_size && p_src_data->p_data->disc_res.p_raw_data) {
|
||||
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.raw_data_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,26 +181,30 @@ static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
*******************************************************************************/
|
||||
static void search_service_record_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest;
|
||||
tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src;
|
||||
tBTA_DM_SEARCH_PARAM *p_dest_data = (tBTA_DM_SEARCH_PARAM *) p_dest;
|
||||
tBTA_DM_SEARCH_PARAM *p_src_data = (tBTA_DM_SEARCH_PARAM *) p_src;
|
||||
|
||||
if (!p_src) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->aid) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->disc_res.p_raw_data && p_src_data->disc_res.raw_data_size > 0) {
|
||||
p_dest_data->disc_res.p_raw_data = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->disc_res.p_raw_data,
|
||||
p_src_data->disc_res.p_raw_data,
|
||||
p_src_data->disc_res.raw_data_size);
|
||||
p_dest_data->p_data = osi_malloc(p_dest_data->len);
|
||||
memset(p_dest_data->p_data, 0x00, p_dest_data->len);
|
||||
memcpy(p_dest_data->p_data, p_src_data->p_data, p_dest_data->len);
|
||||
if ( p_dest_data->len > sizeof(tBTA_DM_SEARCH)){
|
||||
switch (p_dest_data->event) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->p_data->disc_res.p_raw_data && p_src_data->p_data->disc_res.raw_data_size > 0) {
|
||||
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.raw_data_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,6 +263,10 @@ static BOOLEAN check_eir_remote_name(tBTA_DM_SEARCH *p_search_data,
|
||||
*******************************************************************************/
|
||||
static void bte_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
|
||||
{
|
||||
tBTA_DM_SEARCH_PARAM search;
|
||||
search.event = event;
|
||||
search.p_data = p_data;
|
||||
|
||||
UINT16 param_len = 0;
|
||||
|
||||
if (p_data) {
|
||||
@ -281,31 +294,30 @@ static void bte_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_d
|
||||
p_data->inq_res.remt_name_not_required = check_eir_remote_name(p_data, NULL, NULL);
|
||||
}
|
||||
|
||||
search.len = param_len;
|
||||
do {
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SEARCH_DEVICES;
|
||||
msg.aid = event;
|
||||
msg.act = BTC_GAP_BT_SEARCH_DEVICES_EVT;
|
||||
|
||||
btc_transfer_context(&msg, p_data, param_len,
|
||||
(param_len > sizeof(tBTA_DM_SEARCH)) ? search_devices_copy_cb : NULL);
|
||||
btc_transfer_context(&msg, &search, sizeof(tBTA_DM_SEARCH_PARAM), search_devices_copy_cb);
|
||||
} while (0);
|
||||
}
|
||||
|
||||
static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
|
||||
static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_PARAM *p_data)
|
||||
{
|
||||
switch (event) {
|
||||
switch (p_data->event) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
/* remote name update */
|
||||
uint32_t bdname_len = strlen((const char *)p_data->disc_res.bd_name);
|
||||
uint32_t bdname_len = strlen((const char *)p_data->p_data->disc_res.bd_name);
|
||||
if (bdname_len) {
|
||||
esp_bt_gap_dev_prop_t prop[1];
|
||||
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[0], ESP_BT_GAP_DEV_PROP_BDNAME, bdname_len + 1, p_data->disc_res.bd_name);
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[0], ESP_BT_GAP_DEV_PROP_BDNAME, bdname_len + 1, p_data->p_data->disc_res.bd_name);
|
||||
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bdcpy(param.disc_res.bda, p_data->disc_res.bd_addr);
|
||||
bdcpy(param.disc_res.bda, p_data->p_data->disc_res.bd_addr);
|
||||
param.disc_res.num_prop = 1;
|
||||
param.disc_res.prop = prop;
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_RES_EVT, ¶m);
|
||||
@ -314,10 +326,10 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR
|
||||
}
|
||||
case BTA_DM_INQ_RES_EVT: {
|
||||
/* inquiry result */
|
||||
uint32_t cod = devclass2uint (p_data->inq_res.dev_class);
|
||||
uint32_t cod = devclass2uint (p_data->p_data->inq_res.dev_class);
|
||||
|
||||
if (cod == 0) {
|
||||
LOG_DEBUG("%s cod is 0, set as unclassified", __func__);
|
||||
BTC_TRACE_DEBUG("%s cod is 0, set as unclassified", __func__);
|
||||
cod = COD_UNCLASSIFIED;
|
||||
}
|
||||
|
||||
@ -329,17 +341,17 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[0], ESP_BT_GAP_DEV_PROP_COD, sizeof(cod), &cod);
|
||||
num_prop++;
|
||||
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[1], ESP_BT_GAP_DEV_PROP_RSSI, 1, &(p_data->inq_res.rssi));
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[1], ESP_BT_GAP_DEV_PROP_RSSI, 1, &(p_data->p_data->inq_res.rssi));
|
||||
num_prop++;
|
||||
|
||||
if (p_data->inq_res.p_eir) {
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[2], ESP_BT_GAP_DEV_PROP_EIR, HCI_EXT_INQ_RESPONSE_LEN, p_data->inq_res.p_eir);
|
||||
if (p_data->p_data->inq_res.p_eir) {
|
||||
BTC_STORAGE_FILL_PROPERTY(&prop[2], ESP_BT_GAP_DEV_PROP_EIR, HCI_EXT_INQ_RESPONSE_LEN, p_data->p_data->inq_res.p_eir);
|
||||
num_prop++;
|
||||
}
|
||||
|
||||
/* Callback to notify upper layer of device */
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bdcpy(param.disc_res.bda, p_data->inq_res.bd_addr);
|
||||
bdcpy(param.disc_res.bda, p_data->p_data->inq_res.bd_addr);
|
||||
param.disc_res.num_prop = num_prop;
|
||||
param.disc_res.prop = prop;
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_DISC_RES_EVT, ¶m);
|
||||
@ -381,18 +393,18 @@ static void btc_gap_bt_search_devices_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEAR
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void btc_gap_bt_search_service_record(UINT16 event, char *p_param)
|
||||
static void btc_gap_bt_search_service_record(char *p_param)
|
||||
{
|
||||
tBTA_DM_SEARCH *p_data = (tBTA_DM_SEARCH *)p_param;
|
||||
tBTA_DM_SEARCH_PARAM *p_data = (tBTA_DM_SEARCH_PARAM *)p_param;
|
||||
|
||||
switch (event) {
|
||||
switch (p_data->event) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
esp_bt_gap_cb_param_t param;
|
||||
memcpy(param.rmt_srvcs.bda, p_data->disc_res.bd_addr, BD_ADDR_LEN);
|
||||
if (p_data->disc_res.p_raw_data && p_data->disc_res.raw_data_size > 0) {
|
||||
memcpy(param.rmt_srvcs.bda, p_data->p_data->disc_res.bd_addr, BD_ADDR_LEN);
|
||||
if (p_data->p_data->disc_res.p_raw_data && p_data->p_data->disc_res.raw_data_size > 0) {
|
||||
param.rmt_srvc_rec.stat = ESP_BT_STATUS_SUCCESS;
|
||||
// param.rmt_srvc_rec.raw_data_size = p_data->disc_res.raw_data_size;
|
||||
// param.rmt_srvc_rec.raw_data = p_data->disc_res.p_raw_data;
|
||||
// param.rmt_srvc_rec.raw_data_size = p_data->p_data->disc_res.raw_data_size;
|
||||
// param.rmt_srvc_rec.raw_data = p_data->p_data->disc_res.p_raw_data;
|
||||
} else {
|
||||
param.rmt_srvc_rec.stat = ESP_BT_STATUS_FAIL;
|
||||
// param.rmt_srvc_rec.raw_data_size = 0;
|
||||
@ -420,6 +432,9 @@ static void btc_gap_bt_search_service_record(UINT16 event, char *p_param)
|
||||
*******************************************************************************/
|
||||
static void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
|
||||
{
|
||||
tBTA_DM_SEARCH_PARAM search;
|
||||
search.event = event;
|
||||
search.p_data = p_data;
|
||||
UINT16 param_len = 0;
|
||||
|
||||
if (p_data) {
|
||||
@ -431,17 +446,13 @@ static void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_S
|
||||
param_len += p_data->disc_res.raw_data_size;
|
||||
}
|
||||
}
|
||||
|
||||
search.len = param_len;
|
||||
do {
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SEARCH_SERVICE_RECORD;
|
||||
msg.aid = event;
|
||||
|
||||
btc_transfer_context(&msg, p_data, param_len,
|
||||
(param_len > sizeof(tBTA_DM_SEARCH)) ? search_service_record_copy_cb : NULL);
|
||||
|
||||
msg.act = BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT;
|
||||
btc_transfer_context(&msg, &search, sizeof(tBTA_DM_SEARCH_PARAM), search_service_record_copy_cb);
|
||||
} while (0);
|
||||
|
||||
}
|
||||
@ -455,27 +466,27 @@ static void bte_dm_remote_service_record_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_S
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void btc_gap_bt_search_services(UINT16 event, char *p_param)
|
||||
static void btc_gap_bt_search_services(char *p_param)
|
||||
{
|
||||
tBTA_DM_SEARCH *p_data = (tBTA_DM_SEARCH *)p_param;
|
||||
tBTA_DM_SEARCH_PARAM *p_data = (tBTA_DM_SEARCH_PARAM *)p_param;
|
||||
|
||||
switch (event) {
|
||||
switch (p_data->event) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
esp_bt_gap_cb_param_t param;
|
||||
esp_bt_uuid_t *uuid_list = NULL;
|
||||
memcpy(param.rmt_srvcs.bda, p_data->disc_res.bd_addr, BD_ADDR_LEN);
|
||||
memcpy(param.rmt_srvcs.bda, p_data->p_data->disc_res.bd_addr, BD_ADDR_LEN);
|
||||
|
||||
param.rmt_srvcs.stat = ESP_BT_STATUS_FAIL;
|
||||
if (p_data->disc_res.result == BTA_SUCCESS) {
|
||||
uuid_list = malloc(sizeof(esp_bt_uuid_t) * p_data->disc_res.num_uuids);
|
||||
if (p_data->p_data->disc_res.result == BTA_SUCCESS) {
|
||||
uuid_list = malloc(sizeof(esp_bt_uuid_t) * p_data->p_data->disc_res.num_uuids);
|
||||
if (uuid_list) {
|
||||
param.rmt_srvcs.stat = ESP_BT_STATUS_SUCCESS;
|
||||
param.rmt_srvcs.num_uuids = p_data->disc_res.num_uuids;
|
||||
param.rmt_srvcs.num_uuids = p_data->p_data->disc_res.num_uuids;
|
||||
param.rmt_srvcs.uuid_list = uuid_list;
|
||||
// copy UUID list
|
||||
uint8_t *i_uu = (uint8_t *)p_data->disc_res.p_uuid_list;
|
||||
uint8_t *i_uu = (uint8_t *)p_data->p_data->disc_res.p_uuid_list;
|
||||
esp_bt_uuid_t *o_uu = uuid_list;
|
||||
for (int i = 0; i < p_data->disc_res.num_uuids; i++, i_uu += ESP_UUID_LEN_128, o_uu++) {
|
||||
for (int i = 0; i < p_data->p_data->disc_res.num_uuids; i++, i_uu += ESP_UUID_LEN_128, o_uu++) {
|
||||
uuid128_be_to_esp_uuid(o_uu, i_uu);
|
||||
}
|
||||
}
|
||||
@ -512,6 +523,10 @@ static void btc_gap_bt_search_services(UINT16 event, char *p_param)
|
||||
*******************************************************************************/
|
||||
static void bte_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
|
||||
{
|
||||
tBTA_DM_SEARCH_PARAM search;
|
||||
search.event = event;
|
||||
search.p_data = p_data;
|
||||
|
||||
UINT16 param_len = 0;
|
||||
if (p_data) {
|
||||
param_len += sizeof(tBTA_DM_SEARCH);
|
||||
@ -524,46 +539,46 @@ static void bte_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
/* TODO: The only other member that needs a deep copy is the p_raw_data. But not sure
|
||||
* if raw_data is needed. */
|
||||
search.len = param_len;
|
||||
do {
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SEARCH_SERVICES;
|
||||
msg.aid = event;
|
||||
|
||||
btc_transfer_context(&msg, p_data, param_len,
|
||||
(param_len > sizeof(tBTA_DM_SEARCH)) ? search_services_copy_cb : NULL);
|
||||
msg.act = BTC_GAP_BT_SEARCH_SERVICES_EVT;
|
||||
btc_transfer_context(&msg, &search, sizeof(tBTA_DM_SEARCH_PARAM), search_services_copy_cb);
|
||||
} while (0);
|
||||
}
|
||||
|
||||
static void search_services_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
tBTA_DM_SEARCH *p_dest_data = (tBTA_DM_SEARCH *) p_dest;
|
||||
tBTA_DM_SEARCH *p_src_data = (tBTA_DM_SEARCH *) p_src;
|
||||
tBTA_DM_SEARCH_PARAM *p_dest_data = (tBTA_DM_SEARCH_PARAM *) p_dest;
|
||||
tBTA_DM_SEARCH_PARAM *p_src_data = (tBTA_DM_SEARCH_PARAM *) p_src;
|
||||
|
||||
if (!p_src) {
|
||||
return;
|
||||
}
|
||||
p_dest_data->p_data = osi_malloc(p_dest_data->len);
|
||||
memset(p_dest_data->p_data, 0x00, p_dest_data->len);
|
||||
memcpy(p_dest_data->p_data, p_src_data->p_data, p_dest_data->len);
|
||||
|
||||
switch (msg->aid) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->disc_res.result == BTA_SUCCESS) {
|
||||
if (p_src_data->disc_res.num_uuids > 0) {
|
||||
p_dest_data->disc_res.p_uuid_list = (UINT8 *)(p_dest + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->disc_res.p_uuid_list, p_src_data->disc_res.p_uuid_list,
|
||||
p_src_data->disc_res.num_uuids * MAX_UUID_SIZE);
|
||||
osi_free(p_src_data->disc_res.p_uuid_list);
|
||||
p_src_data->disc_res.p_uuid_list = NULL;
|
||||
}
|
||||
if (p_src_data->disc_res.p_raw_data != NULL) {
|
||||
osi_free(p_src_data->disc_res.p_raw_data);
|
||||
p_src_data->disc_res.p_raw_data = NULL;
|
||||
if ( p_dest_data->len > sizeof(tBTA_DM_SEARCH)){
|
||||
switch (p_dest_data->event) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->p_data->disc_res.result == BTA_SUCCESS) {
|
||||
if (p_src_data->p_data->disc_res.num_uuids > 0) {
|
||||
p_dest_data->p_data->disc_res.p_uuid_list = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
memcpy(p_dest_data->p_data->disc_res.p_uuid_list, p_src_data->p_data->disc_res.p_uuid_list,
|
||||
p_src_data->p_data->disc_res.num_uuids * MAX_UUID_SIZE);
|
||||
osi_free(p_src_data->p_data->disc_res.p_uuid_list);
|
||||
p_src_data->p_data->disc_res.p_uuid_list = NULL;
|
||||
}
|
||||
if (p_src_data->p_data->disc_res.p_raw_data != NULL) {
|
||||
osi_free(p_src_data->p_data->disc_res.p_raw_data);
|
||||
p_src_data->p_data->disc_res.p_raw_data = NULL;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,7 +591,7 @@ static void btc_gap_bt_set_cod(btc_gap_bt_args_t *arg)
|
||||
p_cod.service = cod->service << 5;
|
||||
bool ret = utl_set_device_class(&p_cod, arg->set_cod.mode);
|
||||
if (!ret){
|
||||
LOG_ERROR("%s set class of device failed!",__func__);
|
||||
BTC_TRACE_ERROR("%s set class of device failed!",__func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -585,7 +600,7 @@ esp_err_t btc_gap_bt_get_cod(esp_bt_cod_t *cod)
|
||||
tBTA_UTL_COD p_cod;
|
||||
bool ret = utl_get_device_class(&p_cod);
|
||||
if (!ret){
|
||||
LOG_ERROR("%s get class of device failed!",__func__);
|
||||
BTC_TRACE_ERROR("%s get class of device failed!",__func__);
|
||||
return ESP_BT_STATUS_FAIL;
|
||||
}
|
||||
cod->minor = p_cod.minor >> 2;
|
||||
@ -594,10 +609,47 @@ esp_err_t btc_gap_bt_get_cod(esp_bt_cod_t *cod)
|
||||
return ESP_BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
|
||||
{
|
||||
tBTA_RSSI_RESULTS *result = (tBTA_RSSI_RESULTS *)p_data;
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_READ_RSSI_DELTA_EVT;
|
||||
memcpy(param.read_rssi_delta.bda, result->rem_bda, sizeof(BD_ADDR));
|
||||
param.read_rssi_delta.stat = btc_btm_status_to_esp_status(result->status);
|
||||
param.read_rssi_delta.rssi_delta = result->rssi;
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
}
|
||||
|
||||
esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BD_ADDR bd_addr;
|
||||
memcpy(bd_addr, arg->rm_bond_device.bda.address, sizeof(BD_ADDR));
|
||||
if(BTA_DmRemoveDevice(bd_addr) == BTA_SUCCESS){
|
||||
btc_storage_remove_bonded_device(&(arg->rm_bond_device.bda));
|
||||
return ESP_BT_STATUS_SUCCESS;
|
||||
}
|
||||
return ESP_BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_gap_bt_args_t *arg = (btc_gap_bt_args_t *)msg->arg;
|
||||
LOG_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
switch (msg->act) {
|
||||
case BTC_GAP_BT_ACT_SET_SCAN_MODE: {
|
||||
btc_bt_set_scan_mode(arg->set_scan_mode.mode);
|
||||
@ -607,10 +659,6 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_start_discovery(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SEARCH_DEVICES: {
|
||||
btc_gap_bt_search_devices_evt(msg->aid, msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_CANCEL_DISCOVERY: {
|
||||
btc_gap_bt_cancel_discovery();
|
||||
break;
|
||||
@ -619,22 +667,22 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_get_remote_services(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SEARCH_SERVICES: {
|
||||
btc_gap_bt_search_services(msg->aid, msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD: {
|
||||
btc_gap_bt_get_remote_service_record(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SEARCH_SERVICE_RECORD: {
|
||||
btc_gap_bt_search_service_record(msg->aid, msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_COD: {
|
||||
btc_gap_bt_set_cod(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_READ_RSSI_DELTA: {
|
||||
btc_gap_bt_read_rssi_delta(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE:{
|
||||
btc_gap_bt_remove_bond_device(msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -658,4 +706,50 @@ void btc_gap_bt_busy_level_updated(uint8_t bl_flags)
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
switch (msg->act) {
|
||||
case BTC_GAP_BT_SEARCH_DEVICES_EVT:
|
||||
case BTC_GAP_BT_SEARCH_SERVICES_EVT:
|
||||
case BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT:
|
||||
osi_free(((tBTA_DM_SEARCH_PARAM *) (msg->arg)) ->p_data);
|
||||
break;
|
||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
switch (msg->act) {
|
||||
case BTC_GAP_BT_SEARCH_DEVICES_EVT: {
|
||||
btc_gap_bt_search_devices_evt(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_SEARCH_SERVICES_EVT: {
|
||||
btc_gap_bt_search_services(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT: {
|
||||
btc_gap_bt_search_service_record(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_READ_RSSI_DELTA_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
}
|
||||
btc_gap_bt_cb_deep_free(msg);
|
||||
}
|
||||
#endif /* (BTC_GAP_BT_INCLUDED == TRUE) */
|
||||
|
@ -31,7 +31,7 @@ static void btc_set_local_mtu(uint16_t mtu)
|
||||
|
||||
void btc_gatt_com_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
LOG_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
switch (msg->act) {
|
||||
case BTC_GATT_ACT_SET_LOCAL_MTU:
|
||||
{
|
||||
@ -40,7 +40,7 @@ void btc_gatt_com_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src)
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_dest->len);
|
||||
BTC_TRACE_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_dest->len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src)
|
||||
} else if (p_src->len == 0) {
|
||||
/* do nothing for now, there's some scenario will input 0 */
|
||||
} else {
|
||||
LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len);
|
||||
BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
/* do nothing for now, there's some scenario will input 0
|
||||
such as, receive notify, the descriptor may be 0 */
|
||||
} else {
|
||||
LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len);
|
||||
BTC_TRACE_ERROR("%s UUID len is invalid %d\n", __func__, p_src->len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ uint16_t set_read_value(uint8_t *gattc_if, esp_ble_gattc_cb_param_t *p_dest, tBT
|
||||
|
||||
if (( p_src->status == BTA_GATT_OK ) && (p_src->p_value != NULL))
|
||||
{
|
||||
LOG_DEBUG("%s len = %d ", __func__, p_src->p_value->len);
|
||||
BTC_TRACE_DEBUG("%s len = %d ", __func__, p_src->p_value->len);
|
||||
p_dest->read.value_len = p_src->p_value->len;
|
||||
if ( p_src->p_value->len > 0 && p_src->p_value->p_value != NULL ) {
|
||||
p_dest->read.value = p_src->p_value->p_value;
|
||||
|
@ -43,7 +43,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->write_char.value) {
|
||||
memcpy(dst->write_char.value, src->write_char.value, src->write_char.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -52,7 +52,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->write_descr.value) {
|
||||
memcpy(dst->write_descr.value, src->write_descr.value, src->write_descr.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -61,7 +61,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->prep_write.value) {
|
||||
memcpy(dst->prep_write.value, src->prep_write.value, src->prep_write.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -70,12 +70,12 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->prep_write_descr.value) {
|
||||
memcpy(dst->prep_write_descr.value, src->prep_write_descr.value, src->prep_write_descr.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ void btc_gattc_arg_deep_free(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
p_dest_data->read.p_value->len = p_src_data->read.p_value->len;
|
||||
memcpy(p_dest_data->read.p_value->p_value, p_src_data->read.p_value->p_value, p_src_data->read.p_value->len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -149,7 +149,7 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (p_dest_data->get_addr_list.bda_list) {
|
||||
memcpy(p_dest_data->get_addr_list.bda_list, p_src_data->get_addr_list.bda_list, sizeof(BD_ADDR) * num_addr);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -194,7 +194,7 @@ static void btc_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
ret = btc_transfer_context(&msg, p_data, sizeof(tBTA_GATTC), btc_gattc_copy_req_data);
|
||||
|
||||
if (ret) {
|
||||
LOG_ERROR("%s transfer failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s transfer failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,6 +284,7 @@ static void btc_gattc_fill_gatt_db_conversion(uint16_t count, uint16_t num, esp_
|
||||
for (int i = 0; i < db_size; i++) {
|
||||
incl_result->handle = db[offset + i].attribute_handle;
|
||||
incl_result->incl_srvc_s_handle = db[offset + i].start_handle;
|
||||
incl_result->incl_srvc_e_handle = db[offset + i].end_handle;
|
||||
btc128_to_bta_uuid(&bta_uuid, db[offset + i].uuid.uu);
|
||||
bta_to_btc_uuid(&incl_result->uuid, &bta_uuid);
|
||||
incl_result++;
|
||||
@ -291,7 +292,7 @@ static void btc_gattc_fill_gatt_db_conversion(uint16_t count, uint16_t num, esp_
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_WARN("%s(), Not support type(%d)", __func__, type);
|
||||
BTC_TRACE_WARNING("%s(), Not support type(%d)", __func__, type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -749,7 +750,7 @@ void btc_gattc_call_handler(btc_msg_t *msg)
|
||||
BTA_GATTC_CacheGetAddrList(arg->get_addr_list.gattc_if);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -971,7 +972,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s: Unhandled event (%d)!", __FUNCTION__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ static inline void btc_gatts_uuid_format_convert(esp_bt_uuid_t* dest_uuid, uint1
|
||||
memcpy(dest_uuid->uuid.uuid128, src_uuid_p, src_uuid_len);
|
||||
}
|
||||
else{
|
||||
LOG_ERROR("%s wrong uuid length %d\n", __func__, src_uuid_len);
|
||||
BTC_TRACE_ERROR("%s wrong uuid length %d\n", __func__, src_uuid_len);
|
||||
}
|
||||
|
||||
}
|
||||
@ -85,7 +85,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->send_ind.value) {
|
||||
memcpy(dst->send_ind.value, src->send_ind.value, src->send_ind.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -95,7 +95,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if (dst->send_rsp.rsp) {
|
||||
memcpy(dst->send_rsp.rsp, src->send_rsp.rsp, sizeof(esp_gatt_rsp_t));
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -108,7 +108,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
memcpy(dst->add_char.char_val.attr_value, src->add_char.char_val.attr_value,
|
||||
src->add_char.char_val.attr_len);
|
||||
}else{
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -120,7 +120,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
memcpy(dst->add_descr.descr_val.attr_value, src->add_descr.descr_val.attr_value,
|
||||
src->add_descr.descr_val.attr_len);
|
||||
}else{
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -133,7 +133,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
memcpy(dst->create_attr_tab.gatts_attr_db, src->create_attr_tab.gatts_attr_db,
|
||||
sizeof(esp_gatts_attr_db_t)*num_attr);
|
||||
}else{
|
||||
LOG_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -145,13 +145,13 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
if(dst->set_attr_val.value != NULL){
|
||||
memcpy(dst->set_attr_val.value, src->set_attr_val.value, len);
|
||||
}else{
|
||||
LOG_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ void btc_gatts_arg_deep_free(btc_msg_t *msg)
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
BTC_TRACE_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
}
|
||||
future_p = future_new();
|
||||
if (future_p == NULL) {
|
||||
LOG_ERROR("%s failed:no mem\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed:no mem\n", __func__);
|
||||
return ;
|
||||
}
|
||||
btc_creat_tab_env.complete_future = future_p;
|
||||
@ -265,7 +265,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
srvc_inst_id, max_nb_attr, true);
|
||||
btc_creat_tab_env.is_use_svc = true;
|
||||
} else {
|
||||
LOG_ERROR("Each service table can only created one primary service.");
|
||||
BTC_TRACE_ERROR("Each service table can only created one primary service.");
|
||||
param.add_attr_tab.status = ESP_GATT_ERROR;
|
||||
btc_gatts_cb_to_app(ESP_GATTS_CREAT_ATTR_TAB_EVT, gatts_if, ¶m);
|
||||
//reset the env after sent the data to app
|
||||
@ -274,7 +274,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
}
|
||||
|
||||
if (future_await(future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@ -292,7 +292,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
srvc_inst_id, max_nb_attr, false);
|
||||
btc_creat_tab_env.is_use_svc = true;
|
||||
} else {
|
||||
LOG_ERROR("Each service table can only created one secondary service.");
|
||||
BTC_TRACE_ERROR("Each service table can only created one secondary service.");
|
||||
param.add_attr_tab.status = ESP_GATT_ERROR;
|
||||
btc_gatts_cb_to_app(ESP_GATTS_CREAT_ATTR_TAB_EVT, gatts_if, ¶m);
|
||||
//reset the env after sent the data to app
|
||||
@ -300,7 +300,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
return;
|
||||
}
|
||||
if (future_await(future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@ -314,7 +314,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
incl_svc_desc->start_hdl);
|
||||
|
||||
if (future_await(future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -333,7 +333,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
if(btc_creat_tab_env.svc_start_hdl != 0){
|
||||
svc_hal = btc_creat_tab_env.svc_start_hdl;
|
||||
if((gatts_attr_db[i].att_desc.value) == NULL){
|
||||
LOG_ERROR("%s Characteristic declaration should not be NULL\n", __func__);
|
||||
BTC_TRACE_ERROR("%s Characteristic declaration should not be NULL\n", __func__);
|
||||
}
|
||||
else{
|
||||
char_property = (uint8_t)(*(uint8_t*)(gatts_attr_db[i].att_desc.value));
|
||||
@ -348,7 +348,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
perm, char_property, &attr_val, &control);
|
||||
|
||||
if (future_await(future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
BTA_GATTS_AddCharDescriptor(svc_hal, perm, &bta_char_uuid, &attr_val, &control);
|
||||
|
||||
if (future_await(future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -424,18 +424,18 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat
|
||||
case ESP_GATT_UUID_PRI_SERVICE:
|
||||
case ESP_GATT_UUID_SEC_SERVICE:
|
||||
if (++svc_num > 1) {
|
||||
LOG_ERROR("Each service table can only created one primary service or secondly service.");
|
||||
BTC_TRACE_ERROR("Each service table can only created one primary service or secondly service.");
|
||||
return ESP_GATT_ERROR;
|
||||
}
|
||||
break;
|
||||
case ESP_GATT_UUID_INCLUDE_SERVICE: {
|
||||
esp_gatts_incl_svc_desc_t *svc_desc = (esp_gatts_incl_svc_desc_t *)gatts_attr_db[i].att_desc.value;
|
||||
if(svc_desc == NULL) {
|
||||
LOG_ERROR("%s, The include service attribute should not be NULL.", __func__);
|
||||
BTC_TRACE_ERROR("%s, The include service attribute should not be NULL.", __func__);
|
||||
return ESP_GATT_INVALID_PDU;
|
||||
} else if((svc_desc->start_hdl == 0) || (svc_desc->end_hdl == 0) ||
|
||||
(svc_desc->start_hdl == svc_desc->end_hdl)) {
|
||||
LOG_ERROR("%s, The include service attribute handle is invalid, start_hanlde = %d, end_handle = %d",\
|
||||
BTC_TRACE_ERROR("%s, The include service attribute handle is invalid, start_hanlde = %d, end_handle = %d",\
|
||||
__func__, svc_desc->start_hdl, svc_desc->end_hdl);
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
@ -443,14 +443,14 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat
|
||||
}
|
||||
case ESP_GATT_UUID_CHAR_DECLARE:
|
||||
if((gatts_attr_db[i].att_desc.value) == NULL) {
|
||||
LOG_ERROR("%s, Characteristic declaration should not be NULL.", __func__);
|
||||
BTC_TRACE_ERROR("%s, Characteristic declaration should not be NULL.", __func__);
|
||||
return ESP_GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
if(gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_16 &&
|
||||
gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_32 &&
|
||||
gatts_attr_db[i+1].att_desc.uuid_length != ESP_UUID_LEN_128) {
|
||||
LOG_ERROR("%s, The Charateristic uuid length = %d is invalid", __func__,\
|
||||
BTC_TRACE_ERROR("%s, The Charateristic uuid length = %d is invalid", __func__,\
|
||||
gatts_attr_db[i+1].att_desc.uuid_length);
|
||||
return ESP_GATT_INVALID_ATTR_LEN;
|
||||
}
|
||||
@ -462,7 +462,7 @@ static esp_gatt_status_t btc_gatts_check_valid_attr_tab(esp_gatts_attr_db_t *gat
|
||||
uuid == ESP_GATT_UUID_CHAR_SRVR_CONFIG || uuid == ESP_GATT_UUID_CHAR_PRESENT_FORMAT ||
|
||||
uuid == ESP_GATT_UUID_CHAR_AGG_FORMAT || uuid == ESP_GATT_UUID_CHAR_VALID_RANGE ||
|
||||
uuid == ESP_GATT_UUID_EXT_RPT_REF_DESCR || uuid == ESP_GATT_UUID_RPT_REF_DESCR) {
|
||||
LOG_ERROR("%s, The charateristic value uuid = %d is invalid", __func__, uuid);
|
||||
BTC_TRACE_ERROR("%s, The charateristic value uuid = %d is invalid", __func__, uuid);
|
||||
return ESP_GATT_INVALID_PDU;
|
||||
}
|
||||
}
|
||||
@ -584,7 +584,7 @@ static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
sizeof(tBTA_GATTS), btc_gatts_cb_param_copy_req);
|
||||
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,137 @@
|
||||
// Copyright 2018 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.
|
||||
|
||||
#include "bta/bta_hf_client_co.h"
|
||||
#include "hci/hci_audio.h"
|
||||
#include "btc_hf_client.h"
|
||||
#if (BTA_HF_INCLUDED == TRUE)
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_co_audio_state
|
||||
**
|
||||
** Description This function is called by the HF CLIENT before the audio connection
|
||||
** is brought up, after it comes up, and after it goes down.
|
||||
**
|
||||
** Parameters handle - handle of the AG instance
|
||||
** state - Audio state
|
||||
** codec - if WBS support is compiled in, codec to going to be used is provided
|
||||
** and when in SCO_STATE_SETUP, BTM_I2SPCMConfig() must be called with
|
||||
** the correct platform parameters.
|
||||
** in the other states codec type should not be ignored
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_co_audio_state(UINT16 handle, UINT8 state, tBTA_HFP_PEER_CODEC codec)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case SCO_STATE_ON:
|
||||
case SCO_STATE_OFF:
|
||||
case SCO_STATE_OFF_TRANSFER:
|
||||
case SCO_STATE_SETUP:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_init
|
||||
**
|
||||
** Description This function can be used by the phone to initialize audio
|
||||
** codec or for other initialization purposes before SCO connection
|
||||
** is opened.
|
||||
**
|
||||
**
|
||||
** Returns Void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_HFP_SCO_ROUTE_TYPE bta_hf_client_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
|
||||
tBTA_HFP_CODEC_INFO *p_codec_info, UINT8 app_id)
|
||||
{
|
||||
APPL_TRACE_EVENT("%s rx_bw %d, tx_bw %d, codec %d", __FUNCTION__, rx_bw, tx_bw,
|
||||
p_codec_info->codec_type);
|
||||
return BTA_HFP_SCO_ROUTE_HCI;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_open
|
||||
**
|
||||
** Description This function is executed when a SCO connection is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event)
|
||||
{
|
||||
APPL_TRACE_EVENT("%s hdl %x, pkt_sz %u, event %u", __FUNCTION__, handle,
|
||||
pkt_size, event);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_close
|
||||
**
|
||||
** Description This function is called when a SCO connection is closed
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_co_close(void)
|
||||
{
|
||||
APPL_TRACE_EVENT("%s", __FUNCTION__);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_out_data
|
||||
**
|
||||
** Description This function is called to send SCO data over HCI.
|
||||
**
|
||||
** Returns number of bytes got from application
|
||||
**
|
||||
*******************************************************************************/
|
||||
uint32_t bta_hf_client_sco_co_out_data(uint8_t *p_buf, uint32_t sz)
|
||||
{
|
||||
return btc_hf_client_outgoing_data_cb_to_app(p_buf, sz);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_hf_client_sco_co_in_data
|
||||
**
|
||||
** Description This function is called to send incoming SCO data to application.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hf_client_sco_co_in_data(BT_HDR *p_buf, tBTM_SCO_DATA_FLAG status)
|
||||
{
|
||||
UINT8 *p = (UINT8 *)(p_buf + 1) + p_buf->offset;
|
||||
UINT8 pkt_size = 0;
|
||||
|
||||
STREAM_SKIP_UINT16(p);
|
||||
STREAM_TO_UINT8 (pkt_size, p);
|
||||
btc_hf_client_incoming_data_cb_to_app(p, pkt_size);
|
||||
}
|
||||
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
|
||||
|
||||
#endif /* #if (BTA_HF_INCLUDED == TRUE) */
|
1089
components/bt/bluedroid/btc/profile/std/hf_client/btc_hf_client.c
Normal file
1089
components/bt/bluedroid/btc/profile/std/hf_client/btc_hf_client.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -265,12 +265,12 @@ static void hidd_add_characterisitc(const char_desc_t *char_desc)
|
||||
{
|
||||
uint16_t service_id;
|
||||
if (char_desc == NULL) {
|
||||
LOG_ERROR("Invalid hid characteristic\n");
|
||||
BTC_TRACE_ERROR("Invalid hid characteristic\n");
|
||||
return;
|
||||
}
|
||||
//check the hid device serivce has been register to the data base or not
|
||||
if (!hidd_le_env.enabled) {
|
||||
LOG_ERROR("The hid device didn't register yet\n");
|
||||
BTC_TRACE_ERROR("The hid device didn't register yet\n");
|
||||
return;
|
||||
}
|
||||
//get the service id from the env whitch has been register
|
||||
@ -306,7 +306,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
case ESP_GATTS_REG_EVT:
|
||||
//check the register of the hid device profile has been succeess or not
|
||||
if (p_data->reg_oper.status != ESP_GATT_OK) {
|
||||
LOG_ERROR("hidd profile register failed\n");
|
||||
BTC_TRACE_ERROR("hidd profile register failed\n");
|
||||
}
|
||||
hidd_le_env.hidd_inst.app_id = app_id;
|
||||
//save the gatt interface in the hid device ENV
|
||||
@ -337,9 +337,9 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
//save the charateristic handle to the env
|
||||
hidd_le_env.hidd_inst.att_tbl[hid_char_idx - 1] = p_data->add_result.attr_id;
|
||||
LOG_ERROR("hanlder = %x, p_data->add_result.char_uuid.uu.uuid16 = %x\n", p_data->add_result.attr_id,
|
||||
BTC_TRACE_ERROR("hanlder = %x, p_data->add_result.char_uuid.uu.uuid16 = %x\n", p_data->add_result.attr_id,
|
||||
p_data->add_result.char_uuid.uu.uuid16);
|
||||
LOG_ERROR("hid_char_idx=%x\n", hid_char_idx);
|
||||
BTC_TRACE_ERROR("hid_char_idx=%x\n", hid_char_idx);
|
||||
if (hid_char_idx <= HIDD_LE_CHAR_MAX) { //added the characteristic until the index overflow
|
||||
|
||||
if ((p_data->add_result.char_uuid.uu.uuid16 == CHAR_BOOT_KB_IN_REPORT_UUID) ||
|
||||
@ -347,7 +347,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
// add the gattc config descriptor to the notify charateristic
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
LOG_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n",
|
||||
BTC_TRACE_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n",
|
||||
p_data->add_result.char_uuid.uu.uuid16);
|
||||
esp_ble_gatts_add_char_descr (hidd_le_env.hidd_clcb.cur_srvc_id,
|
||||
GATT_PERM_WRITE,
|
||||
@ -366,7 +366,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
BTA_GATTS_AddCharDescriptor (hidd_le_env.hidd_clcb.cur_srvc_id,
|
||||
GATT_PERM_READ,
|
||||
&uuid);
|
||||
LOG_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n",
|
||||
BTC_TRACE_ERROR("p_data->add_result.char_uuid.uu.uuid16 = %x\n",
|
||||
p_data->add_result.char_uuid.uu.uuid16);
|
||||
}
|
||||
if (p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_RPT_REF_DESCR) {
|
||||
@ -377,12 +377,12 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT: {
|
||||
LOG_ERROR("Hidd profile BTA_GATTS_READ_EVT\n");
|
||||
BTC_TRACE_ERROR("Hidd profile BTA_GATTS_READ_EVT\n");
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->read_req.handle;
|
||||
bool is_long = p_data->req_data.p_data->read_req.is_long;
|
||||
LOG_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
BTC_TRACE_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
|
||||
hidd_read_attr_value(p_data->req_data.p_data, trans_id);
|
||||
@ -398,7 +398,7 @@ static void hidd_le_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
if (!p_clcb->in_use) {
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = p_data->conn.conn_id;;
|
||||
LOG_ERROR("hidd->conn_id = %x\n", p_data->conn.conn_id);
|
||||
BTC_TRACE_ERROR("hidd->conn_id = %x\n", p_data->conn.conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda, p_data->conn.remote_bda, BD_ADDR_LEN);
|
||||
}
|
||||
@ -510,7 +510,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
hidd_inst_t *p_inst = &hidd_le_env.hidd_inst;
|
||||
tGATTS_RSP rsp;
|
||||
uint8_t *pp;
|
||||
LOG_ERROR("conn_id = %x, trans_id = %x, event = %x\n",
|
||||
BTC_TRACE_ERROR("conn_id = %x, trans_id = %x, event = %x\n",
|
||||
conn_id, trans_id, event);
|
||||
|
||||
if (p_inst->app_id == app_id) {
|
||||
@ -522,7 +522,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
if (p_inst->pending_evt == event) {
|
||||
switch (event) {
|
||||
case HIDD_LE_READ_INFO_EVT:
|
||||
LOG_ERROR(" p_inst->att_tbl[HIDD_LE_INFO_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR(" p_inst->att_tbl[HIDD_LE_INFO_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_INFO_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_INFO_CHAR];
|
||||
rsp.attr_value.len = HID_INFORMATION_LEN;
|
||||
@ -533,7 +533,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
break;
|
||||
|
||||
case HIDD_LE_READ_CTNL_PT_EVT:
|
||||
LOG_ERROR(" p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR(" p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_CTNL_PT_CHAR];
|
||||
rsp.attr_value.len = 0;
|
||||
@ -542,7 +542,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
break;
|
||||
|
||||
case HIDD_LE_READ_REPORT_MAP_EVT:
|
||||
LOG_ERROR("p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_REPORT_MAP_CHAR];
|
||||
rsp.attr_value.len = hidReportMapLen;
|
||||
@ -552,7 +552,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp);
|
||||
break;
|
||||
case HIDD_LE_READ_REPORT_EVT:
|
||||
LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR];
|
||||
rsp.attr_value.len = 0;
|
||||
@ -560,7 +560,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp);
|
||||
break;
|
||||
case HIDD_LE_READ_PROTO_MODE_EVT:
|
||||
LOG_ERROR("p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_PROTO_MODE_CHAR];
|
||||
rsp.attr_value.len = 1;
|
||||
@ -570,7 +570,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp);
|
||||
break;
|
||||
case HIDD_LE_BOOT_KB_IN_REPORT_EVT:
|
||||
LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR];
|
||||
rsp.attr_value.len = 0;
|
||||
@ -578,7 +578,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp);
|
||||
break;
|
||||
case HIDD_LE_BOOT_KB_OUT_REPORT_EVT:
|
||||
LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR];
|
||||
rsp.attr_value.len = 0;
|
||||
@ -586,7 +586,7 @@ void hidd_rsp (uint32_t trans_id, uint16_t conn_id, uint8_t app_id,
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, status, &rsp);
|
||||
break;
|
||||
case HIDD_LE_BOOT_MOUSE_IN_REPORT_EVT:
|
||||
LOG_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
BTC_TRACE_ERROR("p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR] = %x\n",
|
||||
p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR]);
|
||||
rsp.attr_value.handle = p_inst->att_tbl[HIDD_LE_BOOT_KB_IN_REPORT_CHAR];
|
||||
rsp.attr_value.len = 0;
|
||||
@ -616,7 +616,7 @@ esp_gatt_status_t hidd_le_init (void)
|
||||
tBT_UUID app_uuid = {LEN_UUID_16, {ATT_SVC_HID}};
|
||||
|
||||
if (hidd_le_env.enabled) {
|
||||
LOG_ERROR("hid device svc already initaliezd\n");
|
||||
BTC_TRACE_ERROR("hid device svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
} else {
|
||||
memset(&hidd_le_env, 0, sizeof(hidd_le_env_t));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user