forked from espressif/esp-idf
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024ef51d1a | ||
|
|
4d9778e208 | ||
|
|
6181af2a0b | ||
|
|
abf0cd8421 | ||
|
|
7a83c87c44 | ||
|
|
6ad86f0d67 | ||
|
|
fddebe4bcc | ||
|
|
2102acf266 | ||
|
|
a4ac9bf80b | ||
|
|
6e2601f389 | ||
|
|
ea48f43f87 | ||
|
|
1b0b34247a | ||
|
|
4aaa453b31 | ||
|
|
fe69377782 | ||
|
|
1c9d8744ab | ||
|
|
7db3370e20 | ||
|
|
eece22d075 | ||
|
|
2cc668bbb1 | ||
|
|
ad4a1b600a | ||
|
|
877b407c8c | ||
|
|
5850f423d5 | ||
|
|
ea74033d1e | ||
|
|
7cd1e0ef4b | ||
|
|
f72888544e | ||
|
|
a513ac4dec | ||
|
|
b337b20270 | ||
|
|
8ab96b13af | ||
|
|
50f414f54c | ||
|
|
0dfef8c16c | ||
|
|
6bb1367fe5 | ||
|
|
a286846095 | ||
|
|
2b2dd845ae | ||
|
|
b9f9e681ba | ||
|
|
3429241e1a | ||
|
|
455a7784a9 | ||
|
|
7d9a20e714 | ||
|
|
a6980fce4c | ||
|
|
4bd41d4082 | ||
|
|
3302a38432 | ||
|
|
82ef2b9485 | ||
|
|
de461671aa | ||
|
|
aa2f5e4ae5 |
11
.gitignore
vendored
11
.gitignore
vendored
@@ -19,14 +19,13 @@ GPATH
|
||||
.settings
|
||||
|
||||
# Example project files
|
||||
examples/**/sdkconfig
|
||||
examples/**/sdkconfig.old
|
||||
examples/**/build
|
||||
examples/*/*/sdkconfig
|
||||
examples/*/*/sdkconfig.old
|
||||
examples/*/*/build
|
||||
|
||||
#Doc build artifacts
|
||||
docs/_build/
|
||||
docs/doxygen-warning-log.txt
|
||||
docs/sphinx-warning-log.txt
|
||||
docs/xml/
|
||||
docs/man/
|
||||
|
||||
@@ -34,7 +33,3 @@ docs/man/
|
||||
tools/unit-test-app/sdkconfig
|
||||
tools/unit-test-app/sdkconfig.old
|
||||
tools/unit-test-app/build
|
||||
|
||||
# AWS IoT Examples require device-specific certs/keys
|
||||
examples/protocols/aws_iot/*/main/certs/*.pem.*
|
||||
|
||||
|
||||
585
.gitlab-ci.yml
585
.gitlab-ci.yml
@@ -1,27 +1,10 @@
|
||||
stages:
|
||||
- build
|
||||
- assign_test
|
||||
- unit_test
|
||||
- test
|
||||
- test_report
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
# System environment
|
||||
|
||||
# Common parameters for the 'make' during CI tests
|
||||
MAKEFLAGS: "-j5 --no-keep-going"
|
||||
|
||||
# GitLab-CI environment
|
||||
|
||||
# more attempts for more robust
|
||||
GET_SOURCES_ATTEMPTS: "10"
|
||||
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
|
||||
|
||||
# IDF environment
|
||||
|
||||
IDF_PATH: "$CI_PROJECT_DIR"
|
||||
|
||||
before_script:
|
||||
# add gitlab ssh key
|
||||
- mkdir -p ~/.ssh
|
||||
@@ -41,20 +24,23 @@ before_script:
|
||||
|
||||
build_template_app:
|
||||
stage: build
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
image: espressif/esp32-ci-env
|
||||
tags:
|
||||
- build
|
||||
|
||||
variables:
|
||||
SDK_PATH: "$CI_PROJECT_DIR"
|
||||
IDF_PATH: "$CI_PROJECT_DIR"
|
||||
GIT_STRATEGY: clone
|
||||
BATCH_BUILD: "1"
|
||||
IDF_CI_BUILD: "1"
|
||||
|
||||
script:
|
||||
- git clone https://github.com/espressif/esp-idf-template.git
|
||||
- cd esp-idf-template
|
||||
# Try to use the same branch name for esp-idf-template that we're
|
||||
# using on esp-idf. If it doesn't exist then just stick to the default
|
||||
# branch
|
||||
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using esp-idf-template default branch..."
|
||||
- git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-idf-template default branch..."
|
||||
# Test debug build (default)
|
||||
- make all V=1
|
||||
# Now test release build
|
||||
@@ -67,34 +53,40 @@ build_template_app:
|
||||
- test $(xtensa-esp32-elf-nm *.a | grep -w ets_printf | wc -l) -eq 0
|
||||
|
||||
|
||||
.build_template: &build_template
|
||||
.build_gitlab: &build_template
|
||||
stage: build
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- build
|
||||
image: espressif/esp32-ci-env
|
||||
|
||||
variables:
|
||||
SDK_PATH: "$CI_PROJECT_DIR"
|
||||
IDF_PATH: "$CI_PROJECT_DIR"
|
||||
GIT_STRATEGY: clone
|
||||
BATCH_BUILD: "1"
|
||||
V: "0"
|
||||
|
||||
|
||||
build_ssc:
|
||||
<<: *build_template
|
||||
artifacts:
|
||||
paths:
|
||||
- SSC/ssc_bin
|
||||
- ./SSC/ssc_bin
|
||||
expire_in: 6 mos
|
||||
|
||||
script:
|
||||
- git clone $SSC_REPOSITORY
|
||||
- git clone $GITLAB_SSH_SERVER/yinling/SSC.git
|
||||
- cd SSC
|
||||
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using SSC default branch..."
|
||||
- MAKEFLAGS= ./gen_misc_ng.sh
|
||||
- git checkout ${CI_BUILD_REF_NAME} || echo "Using SSC default branch..."
|
||||
- make defconfig
|
||||
- chmod +x gen_misc_ng.sh
|
||||
- ./gen_misc_ng.sh
|
||||
|
||||
build_at:
|
||||
<<: *build_template
|
||||
script:
|
||||
- git clone $GITLAB_SSH_SERVER/application/esp-at.git
|
||||
- cd esp-at
|
||||
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using esp-at default branch..."
|
||||
- git checkout ${CI_BUILD_REF_NAME} || echo "Using esp-at default branch..."
|
||||
- make defconfig
|
||||
- make
|
||||
|
||||
@@ -102,65 +94,42 @@ build_esp_idf_tests:
|
||||
<<: *build_template
|
||||
artifacts:
|
||||
paths:
|
||||
- tools/unit-test-app/build/*.bin
|
||||
- tools/unit-test-app/build/*.elf
|
||||
- tools/unit-test-app/build/*.map
|
||||
- tools/unit-test-app/build/download.config
|
||||
- tools/unit-test-app/build/bootloader/*.bin
|
||||
- components/idf_test/unit_test/TestCaseAll.yml
|
||||
- components/idf_test/unit_test/CIConfigs/*.yml
|
||||
- ./tools/unit-test-app/build/*.bin
|
||||
- ./tools/unit-test-app/build/*.elf
|
||||
- ./tools/unit-test-app/build/*.map
|
||||
- ./tools/unit-test-app/build/bootloader/*.bin
|
||||
- ./components/idf_test/unit_test/TestCaseAll.yml
|
||||
- ./components/idf_test/unit_test/CIConfigs/*.yml
|
||||
expire_in: 6 mos
|
||||
|
||||
script:
|
||||
- cd tools/unit-test-app
|
||||
- git checkout ${CI_BUILD_REF_NAME} || echo "Using default branch..."
|
||||
- make TESTS_ALL=1
|
||||
# cut last line in case make V=0/1 is set by default
|
||||
- make print_flash_cmd | tail -n 1 > build/download.config
|
||||
- python tools/UnitTestParser.py
|
||||
- python UnitTestParser.py
|
||||
|
||||
.build_examples_template: &build_examples_template
|
||||
build_examples:
|
||||
<<: *build_template
|
||||
artifacts:
|
||||
paths:
|
||||
- build_examples/*/*/*/build/*.bin
|
||||
- build_examples/*/*/*/build/*.elf
|
||||
- build_examples/*/*/*/build/*.map
|
||||
- build_examples/*/*/*/build/bootloader/*.bin
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
IDF_CI_BUILD: "1"
|
||||
GIT_STRATEGY: fetch
|
||||
- build_examples/*/*/build/*.bin
|
||||
- build_examples/*/*/build/*.elf
|
||||
- build_examples/*/*/build/*.map
|
||||
- build_examples/*/*/build/bootloader/*.bin
|
||||
expire_in: 6 mos
|
||||
|
||||
script:
|
||||
# it's not possible to build 100% out-of-tree and have the "artifacts"
|
||||
# mechanism work, but this is the next best thing
|
||||
- mkdir build_examples
|
||||
- cd build_examples
|
||||
# build some of examples
|
||||
- ${IDF_PATH}/make/build_examples.sh "${CI_JOB_NAME}"
|
||||
|
||||
build_examples_00:
|
||||
<<: *build_examples_template
|
||||
|
||||
build_examples_01:
|
||||
<<: *build_examples_template
|
||||
|
||||
build_examples_02:
|
||||
<<: *build_examples_template
|
||||
|
||||
build_examples_03:
|
||||
<<: *build_examples_template
|
||||
|
||||
build_examples_04:
|
||||
<<: *build_examples_template
|
||||
- ${IDF_PATH}/make/build_examples.sh
|
||||
|
||||
build_docs:
|
||||
stage: build
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
image: espressif/esp32-ci-env
|
||||
tags:
|
||||
- build_docs
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/html
|
||||
expire_in: 1 mos
|
||||
script:
|
||||
- cd docs
|
||||
- doxygen
|
||||
@@ -168,67 +137,47 @@ build_docs:
|
||||
- test -n $IS_PRIVATE && test $(cat doxygen-warning-log.txt | wc -l) -eq 0 || ( echo "Doxygen pass had some warnings:" && cat doxygen-warning-log.txt && false )
|
||||
- make gh-linkcheck
|
||||
- make html
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/html
|
||||
expire_in: 1 mos
|
||||
|
||||
|
||||
test_nvs_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
image: espressif/esp32-ci-env
|
||||
tags:
|
||||
- nvs_host_test
|
||||
dependencies: []
|
||||
script:
|
||||
- cd components/nvs_flash/test_nvs_host
|
||||
- make test
|
||||
|
||||
test_partition_table_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- build
|
||||
dependencies: []
|
||||
script:
|
||||
- cd components/partition_table/test_gen_esp32part_host
|
||||
- ./gen_esp32part_tests.py
|
||||
|
||||
test_wl_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- wl_host_test
|
||||
artifacts:
|
||||
paths:
|
||||
- components/wear_levelling/test_wl_host/coverage_report.zip
|
||||
dependencies: []
|
||||
script:
|
||||
- cd components/wear_levelling/test_wl_host
|
||||
- make test
|
||||
|
||||
test_build_system:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
image: espressif/esp32-ci-env
|
||||
tags:
|
||||
- build_test
|
||||
dependencies: []
|
||||
variables:
|
||||
IDF_PATH: "$CI_PROJECT_DIR"
|
||||
script:
|
||||
- ./make/test_configure_ci_environment.sh
|
||||
- ./make/test_build_system.sh
|
||||
|
||||
test_report:
|
||||
stage: test_report
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- report
|
||||
image: espressif/esp32-ci-env
|
||||
only:
|
||||
- master
|
||||
- triggers
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
tags:
|
||||
- report
|
||||
variables:
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test"
|
||||
REPORT_PATH: "$CI_PROJECT_DIR/CI_Test_Report"
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/tools/unit-test-app/tools/ModuleDefinition.yml"
|
||||
#dependencies:
|
||||
#We need all UT* and IT* artifacts except for only a few other
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/tools/unit-test-app/ModuleDefinition.yml"
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
@@ -238,13 +187,13 @@ test_report:
|
||||
script:
|
||||
# calc log path
|
||||
- VER_NUM=`git rev-list HEAD | wc -l | awk '{print $1}'`
|
||||
- SHA_ID=`echo $CI_COMMIT_SHA | cut -c 1-7`
|
||||
- SHA_ID=`echo $CI_BUILD_REF | cut -c 1-7`
|
||||
- REVISION="${VER_NUM}_${SHA_ID}"
|
||||
# replace / to _ in branch name
|
||||
- ESCAPED_BRANCH_NAME=`echo $CI_COMMIT_REF_NAME | sed 's/\//___/g'`
|
||||
- ESCAPED_BRANCH_NAME=`echo $CI_BUILD_REF_NAME | sed 's/\//___/g'`
|
||||
# result path and artifacts path
|
||||
- RESULT_PATH="$CI_PROJECT_NAME/$ESCAPED_BRANCH_NAME/$REVISION"
|
||||
- ARTIFACTS_PATH="$GITLAB_HTTP_SERVER/idf/esp-idf/builds/$CI_JOB_ID/artifacts/browse/$CI_COMMIT_SHA"
|
||||
- ARTIFACTS_PATH="$GITLAB_HTTP_SERVER/idf/esp-idf/builds/$CI_BUILD_ID/artifacts/browse/$CI_BUILD_REF"
|
||||
# clone test bench
|
||||
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
|
||||
- cd auto_test_script
|
||||
@@ -253,7 +202,7 @@ test_report:
|
||||
- python CITestReport.py -l $LOG_PATH -t $TEST_CASE_FILE_PATH -p $REPORT_PATH -r $RESULT_PATH -a $ARTIFACTS_PATH -m $MODULE_UPDATE_FILE || TEST_RESULT=Fail
|
||||
# commit to CI-test-result project
|
||||
- git clone $GITLAB_SSH_SERVER/qa/CI-test-result.git
|
||||
- rm -rf "CI-test-result/RawData/$RESULT_PATH"
|
||||
- rm -rf CI-test-result/RawData/$RESULT_PATH
|
||||
- cp -R $CI_PROJECT_NAME CI-test-result/RawData
|
||||
- cd CI-test-result
|
||||
# config git user
|
||||
@@ -261,7 +210,7 @@ test_report:
|
||||
- git config --global user.name "ci-test-result"
|
||||
# commit test result
|
||||
- git add .
|
||||
- git commit . -m "update test result for $CI_PROJECT_NAME/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHA, pipeline ID $CI_PIPELINE_ID" || exit 0
|
||||
- git commit . -m "update test result for $CI_PROJECT_NAME/$CI_BUILD_REF_NAME/$CI_BUILD_REF, pipeline ID $CI_PIPELINE_ID" || exit 0
|
||||
- git push origin master
|
||||
- test "${TEST_RESULT}" = "Pass" || exit 1
|
||||
|
||||
@@ -269,15 +218,14 @@ push_master_to_github:
|
||||
before_script:
|
||||
- echo "Not setting up GitLab key, not fetching submodules"
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- deploy
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
tags:
|
||||
- deploy
|
||||
when: on_success
|
||||
dependencies: []
|
||||
image: espressif/esp32-ci-env
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master
|
||||
@@ -290,26 +238,27 @@ push_master_to_github:
|
||||
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- git remote add github git@github.com:espressif/esp-idf.git
|
||||
# What the next line of script does: goes through the list of refs for all branches we push to github,
|
||||
# generates a snippet of shell which is evaluated. The snippet checks CI_COMMIT_SHA against the SHA
|
||||
# generates a snippet of shell which is evaluated. The snippet checks CI_BUILD_REF against the SHA
|
||||
# (aka objectname) at tip of each branch, and if any SHAs match then it checks out the local branch
|
||||
# and then pushes that ref to a corresponding github branch
|
||||
- eval $(git for-each-ref --shell bash --format 'if [ $CI_COMMIT_SHA == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)
|
||||
#
|
||||
# NB: In gitlab 9.x, CI_BUILD_REF was deprecated. New name is CI_COMMIT_REF. If below command suddenly
|
||||
# generates bash syntax errors, this is probably why.
|
||||
- eval $(git for-each-ref --shell bash --format 'if [ $CI_BUILD_REF == %(objectname) ]; then git checkout -B %(refname:strip=3); git push --follow-tags github %(refname:strip=3); fi;' $GITHUB_PUSH_REFS)
|
||||
|
||||
|
||||
deploy_docs:
|
||||
before_script:
|
||||
- echo "Not setting up GitLab key, not fetching submodules"
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- deploy
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
dependencies:
|
||||
- build_docs
|
||||
tags:
|
||||
- deploy
|
||||
image: espressif/esp32-ci-env
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
@@ -326,86 +275,28 @@ deploy_docs:
|
||||
|
||||
check_doc_links:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
image: espressif/esp32-ci-env
|
||||
tags:
|
||||
- check_doc_links
|
||||
only:
|
||||
# can only be triggered
|
||||
- triggers
|
||||
script:
|
||||
# must be triggered with CHECK_LINKS=Yes, otherwise exit without test
|
||||
- test $CHECK_LINKS = "Yes" || exit 0
|
||||
# can only run on master branch (otherwise the commit is not on Github yet)
|
||||
- test "${CI_BUILD_REF_NAME}" = "master" || exit 0
|
||||
- cd docs
|
||||
- make linkcheck
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/linkcheck
|
||||
expire_in: 1 mos
|
||||
script:
|
||||
# must be triggered with CHECK_LINKS=Yes, otherwise exit without test
|
||||
- test "$CHECK_LINKS" = "Yes" || exit 0
|
||||
# can only run on master branch (otherwise the commit is not on Github yet)
|
||||
- test "${CI_COMMIT_REF_NAME}" = "master" || exit 0
|
||||
- cd docs
|
||||
- make linkcheck
|
||||
|
||||
check_commit_msg:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- build
|
||||
except:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
before_script:
|
||||
- echo "skip update submodule"
|
||||
script:
|
||||
- git checkout ${CI_COMMIT_REF_NAME}
|
||||
# commit start with "WIP: " need to be squashed before merge
|
||||
- 'git log --pretty=%s master..${CI_COMMIT_REF_NAME} | grep "^WIP: " || exit 0 && exit 1'
|
||||
|
||||
check_submodule_sync:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env:v2.1
|
||||
tags:
|
||||
- build
|
||||
except:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
before_script:
|
||||
- echo "do not use gitlab submodule repository"
|
||||
script:
|
||||
# check if all submodules are correctly synced to public repostory
|
||||
- git submodule update --init --recursive
|
||||
|
||||
assign_test:
|
||||
<<: *build_template
|
||||
stage: assign_test
|
||||
dependencies:
|
||||
- build_esp_idf_tests
|
||||
- build_ssc
|
||||
artifacts:
|
||||
paths:
|
||||
- test_bins
|
||||
- components/idf_test/*/CIConfigs
|
||||
- components/idf_test/*/TC.sqlite
|
||||
expire_in: 1 mos
|
||||
script:
|
||||
# first move test bins together: test_bins/CHIP_SDK/TestApp/bin_files
|
||||
- mkdir -p test_bins/ESP32_IDF/UT
|
||||
- cp -r tools/unit-test-app/build/* test_bins/ESP32_IDF/UT
|
||||
- cp -r SSC/ssc_bin/* test_bins/ESP32_IDF
|
||||
# clone test script to assign tests
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- cd auto_test_script
|
||||
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
|
||||
# assign unit test cases
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/unit_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/test_bins
|
||||
# assgin integration test cases
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/test_bins
|
||||
|
||||
# AUTO GENERATED PART START, DO NOT MODIFY CONTENT BELOW
|
||||
# template for test jobs
|
||||
.test_template: &test_template
|
||||
before_script:
|
||||
- echo "Skip cloning submodule here"
|
||||
stage: test
|
||||
when: on_success
|
||||
only:
|
||||
@@ -414,26 +305,26 @@ assign_test:
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
allow_failure: true
|
||||
dependencies:
|
||||
- assign_test
|
||||
|
||||
variables:
|
||||
LOCAL_ENV_CONFIG_PATH: $CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF
|
||||
BIN_PATH: "$CI_PROJECT_DIR/SSC/ssc_bin/SSC"
|
||||
APP_NAME: "ssc"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
|
||||
# append test level folder to TEST_CASE_FILE_PATH in before_script of test job
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
||||
# jobs MUST set CONFIG_FILE in before_script, and overwrite the variables above if necessary
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/unit_test/ModuleDefinition.yml"
|
||||
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
expire_in: 6 mos
|
||||
variables:
|
||||
# set git strategy to fetch so we can get esptool without update submodule
|
||||
GIT_STRATEGY: fetch
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
|
||||
CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/integration_test/CIConfigs/$CI_JOB_NAME.yml"
|
||||
|
||||
script:
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# remove artifacts from the 'unit_test' stage
|
||||
- rm -rf "$LOG_PATH"
|
||||
# remove artifacts from last stage (UT logs)
|
||||
- rm -rf $LOG_PATH
|
||||
# add gitlab ssh key
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
@@ -442,237 +333,295 @@ assign_test:
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
# clone local test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- git clone $GITLAB_SSH_SERVER/qa/ci-test-runner-configs.git
|
||||
# clone test bench
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
|
||||
- cd auto_test_script
|
||||
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
|
||||
# run test
|
||||
- python CIRunner.py -l "$LOG_PATH/$CI_JOB_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE
|
||||
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE bin_path $APP_NAME $BIN_PATH
|
||||
|
||||
|
||||
# template for overnight test jobs
|
||||
.test_template_night: &test_template_night
|
||||
<<: *test_template
|
||||
only:
|
||||
# can only be triggered
|
||||
- triggers
|
||||
script:
|
||||
# remove artifacts from last stage (UT logs)
|
||||
- rm -rf $LOG_PATH
|
||||
# must be night build triggers, otherwise exit without test
|
||||
- test $NIGHT_BUILD = "Yes" || exit 0
|
||||
# add gitlab ssh key
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
# clone local test env configs
|
||||
- git clone $GITLAB_SSH_SERVER/qa/ci-test-runner-configs.git
|
||||
# clone test bench
|
||||
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
|
||||
- cd auto_test_script
|
||||
# run test
|
||||
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE bin_path $APP_NAME $BIN_PATH
|
||||
|
||||
# template for unit test jobs
|
||||
.unit_test_template: &unit_test_template
|
||||
<<: *test_template
|
||||
allow_failure: false
|
||||
stage: unit_test
|
||||
|
||||
variables:
|
||||
GIT_STRATEGY: fetch
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
LOCAL_ENV_CONFIG_PATH: $CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF
|
||||
BIN_PATH: "$CI_PROJECT_DIR/tools/unit-test-app/build/"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
|
||||
APP_NAME: "ut"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/unit_test"
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
|
||||
CONFIG_FILE: "$CI_PROJECT_DIR/components/idf_test/unit_test/CIConfigs/$CI_JOB_NAME.yml"
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/tools/unit-test-app/ModuleDefinition.yml"
|
||||
|
||||
dependencies:
|
||||
- build_esp_idf_tests
|
||||
|
||||
nvs_compatible_test:
|
||||
<<: *test_template
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
- nvs_wifi.bin
|
||||
expire_in: 6 mos
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- NVS_Compatible
|
||||
script:
|
||||
# remove artifacts from the 'unit_test' stage
|
||||
- rm -rf "$LOG_PATH"
|
||||
# add gitlab ssh key
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
# clone local test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
# clone test bench
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- cd auto_test_script
|
||||
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
|
||||
# prepare nvs bins
|
||||
- ./Tools/prepare_nvs_bin.sh
|
||||
# run test
|
||||
- python CIRunner.py -l "$LOG_PATH/$CI_JOB_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE
|
||||
|
||||
UT_001_01:
|
||||
UT_Function_SYS_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/UT_Function_SYS_01.yml
|
||||
|
||||
UT_001_02:
|
||||
UT_Function_SYS_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/UT_Function_SYS_02.yml
|
||||
|
||||
UT_001_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_04:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
IT_001_01:
|
||||
IT_Function_SYS_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_SYS_01.yml
|
||||
|
||||
IT_001_02:
|
||||
IT_Function_WIFI_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_01.yml
|
||||
|
||||
IT_001_03:
|
||||
IT_Function_WIFI_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_02.yml
|
||||
|
||||
IT_001_04:
|
||||
IT_Function_TCPIP_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_01.yml
|
||||
|
||||
IT_001_05:
|
||||
IT_Function_TCPIP_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_02.yml
|
||||
|
||||
IT_001_06:
|
||||
IT_Function_TCPIP_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_03.yml
|
||||
|
||||
IT_001_07:
|
||||
IT_Function_TCPIP_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_04.yml
|
||||
|
||||
IT_001_08:
|
||||
IT_Function_TCPIP_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_05.yml
|
||||
|
||||
IT_002_01:
|
||||
<<: *test_template
|
||||
IT_Stress_WIFI_01:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_2
|
||||
- SSC_T5_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_WIFI_01.yml
|
||||
|
||||
IT_003_01:
|
||||
<<: *test_template
|
||||
IT_Stress_TCPIP_01:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_01.yml
|
||||
|
||||
IT_Stress_TCPIP_02:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_02.yml
|
||||
|
||||
IT_003_02:
|
||||
<<: *test_template
|
||||
IT_Stress_TCPIP_03:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_03.yml
|
||||
|
||||
IT_Stress_TCPIP_04:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_04.yml
|
||||
|
||||
IT_003_03:
|
||||
<<: *test_template
|
||||
IT_Stable_TCPIP_01:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T5_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stable_TCPIP_01.yml
|
||||
|
||||
IT_004_01:
|
||||
IT_Stable_TCPIP_02:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stable_TCPIP_02.yml
|
||||
|
||||
IT_Stable_TCPIP_03:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stable_TCPIP_03.yml
|
||||
|
||||
IT_Function_TCPIP_06:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_06.yml
|
||||
|
||||
IT_Function_WIFI_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_APC
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_03.yml
|
||||
|
||||
IT_005_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WEP
|
||||
|
||||
IT_006_01:
|
||||
IT_Function_WIFI_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T3_PhyMode
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_04.yml
|
||||
|
||||
IT_007_01:
|
||||
IT_Function_WIFI_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WEP
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_05.yml
|
||||
|
||||
IT_Function_WIFI_06:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_PhyMode
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_06.yml
|
||||
|
||||
IT_008_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_PhyMode
|
||||
|
||||
IT_501_01:
|
||||
IT_Function_TCPIP_07:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- stress_test
|
||||
- SSC_T1_2
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_07.yml
|
||||
|
||||
IT_501_02:
|
||||
IT_Function_TCPIP_08:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- stress_test
|
||||
|
||||
IT_501_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- stress_test
|
||||
|
||||
IT_502_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- stress_test
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_08.yml
|
||||
|
||||
IT_502_02:
|
||||
IT_Function_TCPIP_09:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- stress_test
|
||||
- SSC_T1_1
|
||||
- SSC_T1_2
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_09.yml
|
||||
|
||||
IT_503_01:
|
||||
IT_Function_TCPIP_10:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
- stress_test
|
||||
- SSC_T1_1
|
||||
- SSC_T1_2
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_10.yml
|
||||
|
||||
IT_503_02:
|
||||
IT_Function_TCPIP_11:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
- stress_test
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_11.yml
|
||||
|
||||
IT_503_03:
|
||||
IT_Function_TCPIP_12:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
- stress_test
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_12.yml
|
||||
|
||||
|
||||
16
.gitmodules
vendored
16
.gitmodules
vendored
@@ -1,31 +1,15 @@
|
||||
[submodule "components/esp32/lib"]
|
||||
path = components/esp32/lib
|
||||
url = https://github.com/espressif/esp32-wifi-lib.git
|
||||
|
||||
[submodule "components/esptool_py/esptool"]
|
||||
path = components/esptool_py/esptool
|
||||
url = https://github.com/espressif/esptool.git
|
||||
|
||||
[submodule "components/bt/lib"]
|
||||
path = components/bt/lib
|
||||
url = https://github.com/espressif/esp32-bt-lib.git
|
||||
|
||||
[submodule "components/micro-ecc/micro-ecc"]
|
||||
path = components/micro-ecc/micro-ecc
|
||||
url = https://github.com/kmackay/micro-ecc.git
|
||||
|
||||
[submodule "components/coap/libcoap"]
|
||||
path = components/coap/libcoap
|
||||
url = https://github.com/obgm/libcoap.git
|
||||
|
||||
[submodule "components/aws_iot/aws-iot-device-sdk-embedded-C"]
|
||||
path = components/aws_iot/aws-iot-device-sdk-embedded-C
|
||||
url = https://github.com/espressif/aws-iot-device-sdk-embedded-C.git
|
||||
|
||||
[submodule "components/nghttp/nghttp2"]
|
||||
path = components/nghttp/nghttp2
|
||||
url = https://github.com/nghttp2/nghttp2.git
|
||||
|
||||
[submodule "components/libsodium/libsodium"]
|
||||
path = components/libsodium/libsodium
|
||||
url = https://github.com/jedisct1/libsodium.git
|
||||
|
||||
@@ -43,13 +43,5 @@ Legal Part
|
||||
|
||||
Before a contribution can be accepted, you will need to sign our :doc:`contributor-agreement`. You will be prompted for this automatically as part of the Pull Request process.
|
||||
|
||||
Related Documents
|
||||
-----------------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
style-guide
|
||||
documenting-code
|
||||
../api-reference/template
|
||||
contributor-agreement
|
||||
16
README.md
16
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
[](http://esp-idf.readthedocs.io/en/latest/?badge=latest)
|
||||
|
||||
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
|
||||
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview>) chip.
|
||||
|
||||
# Developing With the ESP-IDF
|
||||
|
||||
@@ -10,9 +10,9 @@ ESP-IDF is the official development framework for the [ESP32](https://espressif.
|
||||
|
||||
See setup guides for detailed instructions to set up the ESP-IDF:
|
||||
|
||||
* [Windows Setup Guide](http://esp-idf.readthedocs.io/en/latest/get-started/windows-setup.html)
|
||||
* [Mac OS Setup Guide](http://esp-idf.readthedocs.io/en/latest/get-started/macos-setup.html)
|
||||
* [Linux Setup Guide](http://esp-idf.readthedocs.io/en/latest/get-started/linux-setup.html)
|
||||
* [Windows Setup Guide](http://esp-idf.readthedocs.io/en/latest/windows-setup.html)
|
||||
* [Mac OS Setup Guide](http://esp-idf.readthedocs.io/en/latest/macos-setup.html)
|
||||
* [Linux Setup Guide](http://esp-idf.readthedocs.io/en/latest/linux-setup.html)
|
||||
|
||||
## Finding a Project
|
||||
|
||||
@@ -52,9 +52,9 @@ You don't need to run `make all` before running `make flash`, `make flash` will
|
||||
|
||||
## Viewing Serial Output
|
||||
|
||||
The `make monitor` target uses the [idf_monitor tool](http://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html) to display serial output from the ESP32. idf_monitor also has a range of features to decode crash output and interact with the device. [Check the documentation page for details](http://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html).
|
||||
The `make monitor` target will use the already-installed [miniterm](http://pyserial.readthedocs.io/en/latest/tools.html#module-serial.tools.miniterm) (a part of pyserial) to display serial output from the ESP32 on the terminal console.
|
||||
|
||||
Exit the monitor by typing Ctrl-].
|
||||
Exit miniterm by typing Ctrl-].
|
||||
|
||||
To flash and monitor output in one pass, you can run:
|
||||
|
||||
@@ -85,7 +85,7 @@ make -j5 flash monitor
|
||||
|
||||
Once you've compiled your project, the "build" directory will contain a binary file with a name like "my_app.bin". This is an ESP32 image binary that can be loaded by the bootloader.
|
||||
|
||||
A single ESP32's flash can contain multiple apps, as well as many different kinds of data (calibration data, filesystems, parameter storage, etc). For this reason a partition table is flashed to offset 0x8000 in the flash.
|
||||
A single ESP32's flash can contain multiple apps, as well as many different kinds of data (calibration data, filesystems, parameter storage, etc). For this reason a partition table is flashed to offset 0x4000 in the flash.
|
||||
|
||||
Each entry in the partition table has a name (label), type (app, data, or something else), subtype and the offset in flash where the partition is loaded.
|
||||
|
||||
@@ -112,5 +112,5 @@ This can be combined with other targets, ie `make erase_flash flash` will erase
|
||||
|
||||
* [Check the Issues section on github](https://github.com/espressif/esp-idf/issues) if you find a bug or have a feature request. Please check existing Issues before opening a new one.
|
||||
|
||||
* If you're interested in contributing to ESP-IDF, please check the [Contributions Guide](http://esp-idf.readthedocs.io/en/latest/contribute/index.html).
|
||||
* If you're interested in contributing to ESP-IDF, please check the [Contributions Guide](http://esp-idf.readthedocs.io/en/latest/contributing.html>).
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "esp_ota_ops.h"
|
||||
#include "rom/queue.h"
|
||||
#include "rom/crc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
|
||||
@@ -43,11 +42,13 @@
|
||||
|
||||
typedef struct ota_ops_entry_ {
|
||||
uint32_t handle;
|
||||
const esp_partition_t *part;
|
||||
esp_partition_t part;
|
||||
uint32_t erased_size;
|
||||
uint32_t wrote_size;
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
uint8_t partial_bytes;
|
||||
uint8_t partial_data[16];
|
||||
#endif
|
||||
LIST_ENTRY(ota_ops_entry_) entries;
|
||||
} ota_ops_entry_t;
|
||||
|
||||
@@ -67,38 +68,21 @@ static ota_select s_ota_select[2];
|
||||
|
||||
const static char *TAG = "esp_ota_ops";
|
||||
|
||||
/* Return true if this is an OTA app partition */
|
||||
static bool is_ota_partition(const esp_partition_t *p)
|
||||
{
|
||||
return (p != NULL
|
||||
&& p->type == ESP_PARTITION_TYPE_APP
|
||||
&& p->subtype >= ESP_PARTITION_SUBTYPE_APP_OTA_0
|
||||
&& p->subtype < ESP_PARTITION_SUBTYPE_APP_OTA_MAX);
|
||||
}
|
||||
|
||||
esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp_ota_handle_t *out_handle)
|
||||
{
|
||||
ota_ops_entry_t *new_entry;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if ((partition == NULL) || (out_handle == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
partition = esp_partition_verify(partition);
|
||||
if (partition == NULL) {
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
ota_ops_entry_t *new_entry = (ota_ops_entry_t *) calloc(sizeof(ota_ops_entry_t), 1);
|
||||
|
||||
if (new_entry == 0) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
if (!is_ota_partition(partition)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (partition == esp_ota_get_running_partition()) {
|
||||
return ESP_ERR_OTA_PARTITION_CONFLICT;
|
||||
}
|
||||
|
||||
// If input image size is 0 or OTA_SIZE_UNKNOWN, erase entire partition
|
||||
// if input image size is 0 or OTA_SIZE_UNKNOWN, will erase all areas in this partition
|
||||
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
|
||||
ret = esp_partition_erase_range(partition, 0, partition->size);
|
||||
} else {
|
||||
@@ -106,14 +90,11 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
|
||||
}
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
free(new_entry);
|
||||
new_entry = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
new_entry = (ota_ops_entry_t *) calloc(sizeof(ota_ops_entry_t), 1);
|
||||
if (new_entry == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
LIST_INSERT_HEAD(&s_ota_ops_entries_head, new_entry, entries);
|
||||
|
||||
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
|
||||
@@ -122,7 +103,7 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
|
||||
new_entry->erased_size = image_size;
|
||||
}
|
||||
|
||||
new_entry->part = partition;
|
||||
memcpy(&new_entry->part, partition, sizeof(esp_partition_t));
|
||||
new_entry->handle = ++s_ota_ops_last_handle;
|
||||
*out_handle = new_entry->handle;
|
||||
return ESP_OK;
|
||||
@@ -150,6 +131,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
if (esp_flash_encryption_enabled()) {
|
||||
/* Can only write 16 byte blocks to flash, so need to cache anything else */
|
||||
size_t copy_len;
|
||||
@@ -163,7 +145,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
return ESP_OK; /* nothing to write yet, just filling buffer */
|
||||
}
|
||||
/* write 16 byte to partition */
|
||||
ret = esp_partition_write(it->part, it->wrote_size, it->partial_data, 16);
|
||||
ret = esp_partition_write(&it->part, it->wrote_size, it->partial_data, 16);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -181,8 +163,9 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
memcpy(it->partial_data, data_bytes + size, it->partial_bytes);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = esp_partition_write(it->part, it->wrote_size, data_bytes, size);
|
||||
ret = esp_partition_write(&it->part, it->wrote_size, data_bytes, size);
|
||||
if(ret == ESP_OK){
|
||||
it->wrote_size += size;
|
||||
}
|
||||
@@ -219,9 +202,10 @@ esp_err_t esp_ota_end(esp_ota_handle_t handle)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (it->partial_bytes > 0) {
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
if (it->partial_bytes > 0 && esp_flash_encryption_enabled()) {
|
||||
/* Write out last 16 bytes, if necessary */
|
||||
ret = esp_partition_write(it->part, it->wrote_size, it->partial_data, 16);
|
||||
ret = esp_partition_write(&it->part, it->wrote_size, it->partial_data, 16);
|
||||
if (ret != ESP_OK) {
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
goto cleanup;
|
||||
@@ -229,14 +213,15 @@ esp_err_t esp_ota_end(esp_ota_handle_t handle)
|
||||
it->wrote_size += 16;
|
||||
it->partial_bytes = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (esp_image_basic_verify(it->part->address, true, &image_size) != ESP_OK) {
|
||||
if (esp_image_basic_verify(it->part.address, true, &image_size) != ESP_OK) {
|
||||
ret = ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
ret = esp_secure_boot_verify_signature(it->part->address, image_size);
|
||||
ret = esp_secure_boot_verify_signature(it->part.address, image_size);
|
||||
if (ret != ESP_OK) {
|
||||
ret = ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
goto cleanup;
|
||||
@@ -316,7 +301,7 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
|
||||
//so current ota app sub type id is x , dest bin subtype is y,total ota app count is n
|
||||
//seq will add (x + n*1 + 1 - seq)%n
|
||||
if (SUB_TYPE_ID(subtype) >= ota_app_count) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
ret = esp_partition_mmap(find_partition, 0, find_partition->size, SPI_FLASH_MMAP_DATA, &result, &ota_data_map);
|
||||
@@ -336,9 +321,9 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
|
||||
}
|
||||
|
||||
if (s_ota_select[0].ota_seq >= s_ota_select[1].ota_seq) {
|
||||
return rewrite_ota_seq((SUB_TYPE_ID(subtype) + 1) % ota_app_count + i * ota_app_count, 1, find_partition);
|
||||
} else {
|
||||
return rewrite_ota_seq((SUB_TYPE_ID(subtype) + 1) % ota_app_count + i * ota_app_count, 0, find_partition);
|
||||
} else {
|
||||
return rewrite_ota_seq((SUB_TYPE_ID(subtype) + 1) % ota_app_count + i * ota_app_count, 1, find_partition);
|
||||
}
|
||||
|
||||
} else if (ota_select_valid(&s_ota_select[0])) {
|
||||
@@ -461,79 +446,3 @@ const esp_partition_t *esp_ota_get_boot_partition(void)
|
||||
return esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const esp_partition_t* esp_ota_get_running_partition(void)
|
||||
{
|
||||
/* Find the flash address of this exact function. By definition that is part
|
||||
of the currently running firmware. Then find the enclosing partition. */
|
||||
|
||||
size_t phys_offs = spi_flash_cache2phys(esp_ota_get_running_partition);
|
||||
|
||||
assert (phys_offs != SPI_FLASH_CACHE2PHYS_FAIL); /* indicates cache2phys lookup is buggy */
|
||||
|
||||
esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_APP,
|
||||
ESP_PARTITION_SUBTYPE_ANY,
|
||||
NULL);
|
||||
assert(it != NULL); /* has to be at least one app partition */
|
||||
|
||||
while (it != NULL) {
|
||||
const esp_partition_t *p = esp_partition_get(it);
|
||||
if (p->address <= phys_offs && p->address + p->size > phys_offs) {
|
||||
esp_partition_iterator_release(it);
|
||||
return p;
|
||||
}
|
||||
it = esp_partition_next(it);
|
||||
}
|
||||
|
||||
abort(); /* Partition table is invalid or corrupt */
|
||||
}
|
||||
|
||||
|
||||
const esp_partition_t* esp_ota_get_next_update_partition(const esp_partition_t *start_from)
|
||||
{
|
||||
const esp_partition_t *default_ota = NULL;
|
||||
bool next_is_result = false;
|
||||
if (start_from == NULL) {
|
||||
start_from = esp_ota_get_running_partition();
|
||||
} else {
|
||||
start_from = esp_partition_verify(start_from);
|
||||
}
|
||||
assert (start_from != NULL);
|
||||
/* at this point, 'start_from' points to actual partition table data in flash */
|
||||
|
||||
|
||||
/* Two possibilities: either we want the OTA partition immediately after the current running OTA partition, or we
|
||||
want the first OTA partition in the table (for the case when the last OTA partition is the running partition, or
|
||||
if the current running partition is not OTA.)
|
||||
|
||||
This loop iterates subtypes instead of using esp_partition_find, so we
|
||||
get all OTA partitions in a known order (low slot to high slot).
|
||||
*/
|
||||
|
||||
for (esp_partition_subtype_t t = ESP_PARTITION_SUBTYPE_APP_OTA_0;
|
||||
t != ESP_PARTITION_SUBTYPE_APP_OTA_MAX;
|
||||
t++) {
|
||||
const esp_partition_t *p = esp_partition_find_first(ESP_PARTITION_TYPE_APP, t, NULL);
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (default_ota == NULL) {
|
||||
/* Default to first OTA partition we find,
|
||||
will be used if nothing else matches */
|
||||
default_ota = p;
|
||||
}
|
||||
|
||||
if (p == start_from) {
|
||||
/* Next OTA partition is the one to use */
|
||||
next_is_result = true;
|
||||
}
|
||||
else if (next_is_result) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return default_ota;
|
||||
|
||||
}
|
||||
|
||||
@@ -27,76 +27,57 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define OTA_SIZE_UNKNOWN 0xffffffff /*!< Used for esp_ota_begin() if new image size is unknown */
|
||||
#define OTA_SIZE_UNKNOWN 0xffffffff
|
||||
|
||||
#define ESP_ERR_OTA_BASE 0x1500 /*!< Base error code for ota_ops api */
|
||||
#define ESP_ERR_OTA_PARTITION_CONFLICT (ESP_ERR_OTA_BASE + 0x01) /*!< Error if request was to write or erase the current running partition */
|
||||
#define ESP_ERR_OTA_SELECT_INFO_INVALID (ESP_ERR_OTA_BASE + 0x02) /*!< Error if OTA data partition contains invalid content */
|
||||
#define ESP_ERR_OTA_VALIDATE_FAILED (ESP_ERR_OTA_BASE + 0x03) /*!< Error if OTA app image is invalid */
|
||||
#define ESP_ERR_OTA_BASE 0x1500 /*!< base error code for ota_ops api */
|
||||
#define ESP_ERR_OTA_PARTITION_CONFLICT (ESP_ERR_OTA_BASE + 0x01) /*!< want to write or erase current running partition */
|
||||
#define ESP_ERR_OTA_SELECT_INFO_INVALID (ESP_ERR_OTA_BASE + 0x02) /*!< ota data partition info is error */
|
||||
#define ESP_ERR_OTA_VALIDATE_FAILED (ESP_ERR_OTA_BASE + 0x03) /*!< validate ota image failed */
|
||||
|
||||
/**
|
||||
* @brief Opaque handle for an application OTA update
|
||||
*
|
||||
* esp_ota_begin() returns a handle which is then used for subsequent
|
||||
* calls to esp_ota_write() and esp_ota_end().
|
||||
* @brief Opaque handle for application update obtained from app_ops.
|
||||
*/
|
||||
typedef uint32_t esp_ota_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Commence an OTA update writing to the specified partition.
|
||||
* @brief format input partition in flash to 0xFF as input image size,
|
||||
* if unkown image size ,pass 0x0 or 0xFFFFFFFF, it will erase all the
|
||||
* partition ,Otherwise, erase the required range
|
||||
*
|
||||
* @param partition Pointer to partition structure which need to be updated
|
||||
* Must be non-NULL.
|
||||
* @param image_size size of image need to be updated
|
||||
* @param out_handle handle which should be used for esp_ota_write or esp_ota_end call
|
||||
|
||||
* The specified partition is erased to the specified image size.
|
||||
*
|
||||
* If image size is not yet known, pass OTA_SIZE_UNKNOWN which will
|
||||
* cause the entire partition to be erased.
|
||||
*
|
||||
* On success, this function allocates memory that remains in use
|
||||
* until esp_ota_end() is called with the returned handle.
|
||||
*
|
||||
* @param partition Pointer to info for partition which will receive the OTA update. Required.
|
||||
* @param image_size Size of new OTA app image. Partition will be erased in order to receive this size of image. If 0 or OTA_SIZE_UNKNOWN, the entire partition is erased.
|
||||
* @param out_handle On success, returns a handle which should be used for subsequent esp_ota_write() and esp_ota_end() calls.
|
||||
|
||||
* @return
|
||||
* - ESP_OK: OTA operation commenced successfully.
|
||||
* - ESP_ERR_INVALID_ARG: partition or out_handle arguments were NULL, or partition doesn't point to an OTA app partition.
|
||||
* - ESP_ERR_NO_MEM: Cannot allocate memory for OTA operation.
|
||||
* - ESP_ERR_OTA_PARTITION_CONFLICT: Partition holds the currently running firmware, cannot update in place.
|
||||
* - ESP_ERR_NOT_FOUND: Partition argument not found in partition table.
|
||||
* - ESP_ERR_OTA_SELECT_INFO_INVALID: The OTA data partition contains invalid data.
|
||||
* - ESP_ERR_INVALID_SIZE: Partition doesn't fit in configured flash size.
|
||||
* - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash write failed.
|
||||
* @return:
|
||||
* - ESP_OK: if format ota image OK
|
||||
* - ESP_ERR_OTA_PARTITION_CONFLICT: operate current running bin
|
||||
* - ESP_ERR_OTA_SELECT_INFO_INVALID: ota bin select info invalid
|
||||
*/
|
||||
esp_err_t esp_ota_begin(const esp_partition_t* partition, size_t image_size, esp_ota_handle_t* out_handle);
|
||||
|
||||
/**
|
||||
* @brief Write OTA update data to partition
|
||||
* @brief Write data to input input partition
|
||||
*
|
||||
* This function can be called multiple times as
|
||||
* data is received during the OTA operation. Data is written
|
||||
* sequentially to the partition.
|
||||
* @param handle Handle obtained from esp_ota_begin
|
||||
* @param data Pointer to data write to flash
|
||||
* @param size data size of recieved data
|
||||
*
|
||||
* @param handle Handle obtained from esp_ota_begin
|
||||
* @param data Data buffer to write
|
||||
* @param size Size of data buffer in bytes.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Data was written to flash successfully.
|
||||
* - ESP_ERR_INVALID_ARG: handle is invalid.
|
||||
* - ESP_ERR_OTA_VALIDATE_FAILED: First byte of image contains invalid app image magic byte.
|
||||
* - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash write failed.
|
||||
* - ESP_ERR_OTA_SELECT_INFO_INVALID: OTA data partition has invalid contents
|
||||
* @return:
|
||||
* - ESP_OK: if write flash data OK
|
||||
* - ESP_ERR_OTA_PARTITION_CONFLICT: operate current running bin
|
||||
* - ESP_ERR_OTA_SELECT_INFO_INVALID: ota bin select info invalid
|
||||
*/
|
||||
esp_err_t esp_ota_write(esp_ota_handle_t handle, const void* data, size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Finish OTA update and validate newly written app image.
|
||||
* @brief Finish the update and validate written data
|
||||
*
|
||||
* @param handle Handle obtained from esp_ota_begin().
|
||||
* @param handle Handle obtained from esp_ota_begin.
|
||||
*
|
||||
* @note After calling esp_ota_end(), the handle is no longer valid and any memory associated with it is freed (regardless of result).
|
||||
*
|
||||
* @return
|
||||
* @return:
|
||||
* - ESP_OK: Newly written OTA app image is valid.
|
||||
* - ESP_ERR_NOT_FOUND: OTA handle was not found.
|
||||
* - ESP_ERR_INVALID_ARG: Handle was never written to.
|
||||
@@ -106,61 +87,27 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void* data, size_t size);
|
||||
esp_err_t esp_ota_end(esp_ota_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Configure OTA data for a new boot partition
|
||||
* @brief Set next boot partition, call system_restart() will switch to run it
|
||||
*
|
||||
* @note If this function returns ESP_OK, calling esp_restart() will boot the newly configured app partition.
|
||||
* @note if you want switch to run a bin file
|
||||
* has never been checked before,please validate it's signature firstly
|
||||
*
|
||||
* @param partition Pointer to info for partition containing app image to boot.
|
||||
* @param partition Pointer to partition structure which need to boot
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: OTA data updated, next reboot will use specified partition.
|
||||
* - ESP_ERR_INVALID_ARG: partition argument was NULL or didn't point to a valid OTA partition of type "app".
|
||||
* - ESP_ERR_OTA_VALIDATE_FAILED: Partition contained invalid app image. Also returned if secure boot is enabled and signature validation failed.
|
||||
* - ESP_ERR_NOT_FOUND: OTA data partition not found.
|
||||
* - ESP_ERR_FLASH_OP_TIMEOUT or ESP_ERR_FLASH_OP_FAIL: Flash erase or write failed.
|
||||
* @return:
|
||||
* - ESP_OK: if set next boot partition OK
|
||||
* - ESP_ERR_OTA_SELECT_INFO_INVALID: ota bin select info invalid
|
||||
*/
|
||||
esp_err_t esp_ota_set_boot_partition(const esp_partition_t* partition);
|
||||
|
||||
/**
|
||||
* @brief Get partition info of currently configured boot app
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has been called, the partition which was set by that function will be returned.
|
||||
*
|
||||
* If esp_ota_set_boot_partition() has not been called, the result is
|
||||
* equivalent to esp_ota_get_running_partition().
|
||||
*
|
||||
* @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application.
|
||||
* @brief Get partition info of current running image
|
||||
*
|
||||
* @return pointer to esp_partition_t structure, or NULL if no partition is found or
|
||||
* operate flash failed,This pointer is valid for the lifetime of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_boot_partition(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get partition info of currently running app
|
||||
*
|
||||
* This function is different to esp_ota_get_boot_partition() in that
|
||||
* it ignores any change of selected boot partition caused by
|
||||
* esp_ota_set_boot_partition(). Only the app whose code is currently
|
||||
* running will have its partition information returned.
|
||||
*
|
||||
* @return Pointer to info for partition structure, or NULL if no partition is found or flash read operation failed. Returned pointer is valid for the lifetime of the application.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_running_partition(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return the next OTA app partition which should be written with a new firmware.
|
||||
*
|
||||
* Call this function to find an OTA app partition which can be passed to esp_ota_begin().
|
||||
*
|
||||
* Finds next partition round-robin, starting from the current running partition.
|
||||
*
|
||||
* @param start_from If set, treat this partition info as describing the current running partition. Can be NULL, in which case esp_ota_get_running_partition() is used to find the currently running partition. The result of this function is never the same as this argument.
|
||||
*
|
||||
* @return Pointer to info for partition which should be updated next. NULL result indicates invalid OTA data partition, or that no eligible OTA app slot partition was found.
|
||||
*
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_next_update_partition(const esp_partition_t *start_from);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#
|
||||
#Component Makefile
|
||||
#
|
||||
|
||||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
||||
@@ -1,86 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/semphr.h>
|
||||
|
||||
#include <unity.h>
|
||||
#include <test_utils.h>
|
||||
#include <esp_ota_ops.h>
|
||||
|
||||
|
||||
/* These OTA tests currently don't assume an OTA partition exists
|
||||
on the device, so they're a bit limited
|
||||
*/
|
||||
|
||||
TEST_CASE("esp_ota_begin() verifies arguments", "[ota]")
|
||||
{
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
esp_partition_t partition;
|
||||
static esp_ota_handle_t handle = 0;
|
||||
|
||||
if (handle != 0) { /* clean up from any previous test */
|
||||
esp_ota_end(handle);
|
||||
handle = 0;
|
||||
}
|
||||
|
||||
/* running partition & configured boot partition are same */
|
||||
TEST_ASSERT_NOT_NULL(running);
|
||||
|
||||
/* trying to 'begin' on running partition fails */
|
||||
TEST_ASSERT_NOT_EQUAL(ESP_OK, esp_ota_begin(running, OTA_SIZE_UNKNOWN, &handle));
|
||||
TEST_ASSERT_EQUAL(0, handle);
|
||||
|
||||
memcpy(&partition, running, sizeof(esp_partition_t));
|
||||
partition.address--;
|
||||
|
||||
/* non existent partition fails */
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_ERR_NOT_FOUND, esp_ota_begin(&partition, OTA_SIZE_UNKNOWN, &handle));
|
||||
TEST_ASSERT_EQUAL(0, handle);
|
||||
}
|
||||
|
||||
TEST_CASE("esp_ota_get_next_update_partition logic", "[ota]")
|
||||
{
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
const esp_partition_t *factory = esp_partition_find_first(ESP_PARTITION_TYPE_APP,
|
||||
ESP_PARTITION_SUBTYPE_APP_FACTORY, NULL);
|
||||
const esp_partition_t *ota_0 = esp_partition_find_first(ESP_PARTITION_TYPE_APP,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_0, NULL);
|
||||
const esp_partition_t *ota_1 = esp_partition_find_first(ESP_PARTITION_TYPE_APP,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_1, NULL);
|
||||
const esp_partition_t *ota_2 = esp_partition_find_first(ESP_PARTITION_TYPE_APP,
|
||||
ESP_PARTITION_SUBTYPE_APP_OTA_2, NULL);
|
||||
|
||||
TEST_ASSERT_NOT_NULL(running);
|
||||
TEST_ASSERT_NOT_NULL(factory);
|
||||
TEST_ASSERT_NOT_NULL(ota_0);
|
||||
TEST_ASSERT_NOT_NULL(ota_1);
|
||||
TEST_ASSERT_NULL(ota_2); /* this partition shouldn't exist in test partition table */
|
||||
|
||||
TEST_ASSERT_EQUAL_PTR(factory, running); /* this may not be true if/when we get OTA tests that do OTA updates */
|
||||
|
||||
/* (The test steps verify subtypes before verifying pointer equality, because the failure messages are more readable
|
||||
this way.)
|
||||
*/
|
||||
|
||||
/* Factory app OTA updates OTA 0 slot */
|
||||
const esp_partition_t *p = esp_ota_get_next_update_partition(NULL);
|
||||
TEST_ASSERT_EQUAL_HEX8(ESP_PARTITION_SUBTYPE_APP_OTA_0, p->subtype);
|
||||
TEST_ASSERT_EQUAL_PTR(ota_0, p);
|
||||
|
||||
p = esp_ota_get_next_update_partition(factory);
|
||||
TEST_ASSERT_EQUAL_HEX8(ESP_PARTITION_SUBTYPE_APP_OTA_0, p->subtype);
|
||||
TEST_ASSERT_EQUAL_PTR(ota_0, p);
|
||||
|
||||
|
||||
/* OTA slot 0 updates OTA slot 1 */
|
||||
p = esp_ota_get_next_update_partition(ota_0);
|
||||
TEST_ASSERT_EQUAL_HEX8(ESP_PARTITION_SUBTYPE_APP_OTA_1, p->subtype);
|
||||
TEST_ASSERT_EQUAL_PTR(ota_1, p);
|
||||
/* OTA slot 1 updates OTA slot 0 */
|
||||
p = esp_ota_get_next_update_partition(ota_1);
|
||||
TEST_ASSERT_EQUAL_HEX8(ESP_PARTITION_SUBTYPE_APP_OTA_0, p->subtype);;
|
||||
TEST_ASSERT_EQUAL_PTR(ota_0, p);
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
menuconfig AWS_IOT_SDK
|
||||
bool "Amazon Web Services IoT Platform"
|
||||
help
|
||||
Select this option to enable support for the AWS IoT platform,
|
||||
via the esp-idf component for the AWS IoT Device C SDK.
|
||||
|
||||
config AWS_IOT_MQTT_HOST
|
||||
string "AWS IoT Endpoint Hostname"
|
||||
depends on AWS_IOT_SDK
|
||||
default ""
|
||||
help
|
||||
Default endpoint host name to connect to AWS IoT MQTT/S gateway
|
||||
|
||||
This is the custom endpoint hostname and is specific to an AWS
|
||||
IoT account. You can find it by logging into your AWS IoT
|
||||
Console and clicking the Settings button. The endpoint hostname
|
||||
is shown under the "Custom Endpoint" heading on this page.
|
||||
|
||||
If you need per-device hostnames for different regions or
|
||||
accounts, you can override the default hostname in your app.
|
||||
|
||||
config AWS_IOT_MQTT_PORT
|
||||
int "AWS IoT MQTT Port"
|
||||
depends on AWS_IOT_SDK
|
||||
default 8883
|
||||
range 0 65535
|
||||
help
|
||||
Default port number to connect to AWS IoT MQTT/S gateway
|
||||
|
||||
If you need per-device port numbers for different regions, you can
|
||||
override the default port number in your app.
|
||||
|
||||
Submodule components/aws_iot/aws-iot-device-sdk-embedded-C deleted from 7132505b00
@@ -1,20 +0,0 @@
|
||||
#
|
||||
# Component Makefile
|
||||
#
|
||||
|
||||
ifdef CONFIG_AWS_IOT_SDK
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS := include aws-iot-device-sdk-embedded-C/include
|
||||
|
||||
COMPONENT_SRCDIRS := aws-iot-device-sdk-embedded-C/src port
|
||||
|
||||
# Check the submodule is initialised
|
||||
COMPONENT_SUBMODULES := aws-iot-device-sdk-embedded-C
|
||||
|
||||
|
||||
else
|
||||
# Disable AWS IoT support
|
||||
COMPONENT_ADD_INCLUDEDIRS :=
|
||||
COMPONENT_ADD_LDFLAGS :=
|
||||
COMPONENT_SRCDIRS :=
|
||||
endif
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file aws_iot_config.h
|
||||
* @brief AWS IoT specific configuration file
|
||||
*/
|
||||
|
||||
#ifndef _AWS_IOT_CONFIG_H_
|
||||
#define _AWS_IOT_CONFIG_H_
|
||||
|
||||
#include "aws_iot_log.h"
|
||||
|
||||
// This configuration macro needs to be available globally to enable threading
|
||||
#define _ENABLE_THREAD_SUPPORT_
|
||||
|
||||
// These values are defined in the menuconfig of the AWS IoT component.
|
||||
// However, you can override these constants from your own code.
|
||||
#define AWS_IOT_MQTT_HOST CONFIG_AWS_IOT_MQTT_HOST ///< Customer specific MQTT HOST. The same will be used for Thing Shadow
|
||||
#define AWS_IOT_MQTT_PORT CONFIG_AWS_IOT_MQTT_PORT ///< default port for MQTT/S
|
||||
|
||||
// These values are defaults and are used for ShadowConnectParametersDefault.
|
||||
// You should override them from your own code.
|
||||
#define AWS_IOT_MQTT_CLIENT_ID "ESP32" ///< MQTT client ID should be unique for every device
|
||||
#define AWS_IOT_MY_THING_NAME "ESP32" ///< Thing Name of the Shadow this device is associated with
|
||||
|
||||
// MQTT PubSub
|
||||
#define AWS_IOT_MQTT_TX_BUF_LEN 512 ///< Any time a message is sent out through the MQTT layer. The message is copied into this buffer anytime a publish is done. This will also be used in the case of Thing Shadow
|
||||
#define AWS_IOT_MQTT_RX_BUF_LEN 512 ///< Any message that comes into the device should be less than this buffer size. If a received message is bigger than this buffer size the message will be dropped.
|
||||
#define AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS 5 ///< Maximum number of topic filters the MQTT client can handle at any given time. This should be increased appropriately when using Thing Shadow
|
||||
|
||||
// Thing Shadow specific configs
|
||||
#define SHADOW_MAX_SIZE_OF_RX_BUFFER (AWS_IOT_MQTT_RX_BUF_LEN + 1) ///< Maximum size of the SHADOW buffer to store the received Shadow message
|
||||
#define MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES 80 ///< Maximum size of the Unique Client Id. For More info on the Client Id refer \ref response "Acknowledgments"
|
||||
#define MAX_SIZE_CLIENT_ID_WITH_SEQUENCE (MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES + 10) ///< This is size of the extra sequence number that will be appended to the Unique client Id
|
||||
#define MAX_SIZE_CLIENT_TOKEN_CLIENT_SEQUENCE (MAX_SIZE_CLIENT_ID_WITH_SEQUENCE + 20) ///< This is size of the the total clientToken key and value pair in the JSON
|
||||
#define MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME 10 ///< At Any given time we will wait for this many responses. This will correlate to the rate at which the shadow actions are requested
|
||||
#define MAX_THINGNAME_HANDLED_AT_ANY_GIVEN_TIME 10 ///< We could perform shadow action on any thing Name and this is maximum Thing Names we can act on at any given time
|
||||
#define MAX_JSON_TOKEN_EXPECTED 120 ///< These are the max tokens that is expected to be in the Shadow JSON document. Include the metadata that gets published
|
||||
#define MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME 60 ///< All shadow actions have to be published or subscribed to a topic which is of the formablogt $aws/things/{thingName}/shadow/update/accepted. This refers to the size of the topic without the Thing Name
|
||||
#define MAX_SIZE_OF_THING_NAME 20 ///< The Thing Name should not be bigger than this value. Modify this if the Thing Name needs to be bigger
|
||||
#define MAX_SHADOW_TOPIC_LENGTH_BYTES (MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME + MAX_SIZE_OF_THING_NAME) ///< This size includes the length of topic with Thing Name
|
||||
|
||||
// Auto Reconnect specific config
|
||||
#define AWS_IOT_MQTT_MIN_RECONNECT_WAIT_INTERVAL 1000 ///< Minimum time before the First reconnect attempt is made as part of the exponential back-off algorithm
|
||||
#define AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL 128000 ///< Maximum time interval after which exponential back-off will stop attempting to reconnect.
|
||||
|
||||
#endif /* _AWS_IOT_CONFIG_H_ */
|
||||
@@ -1,44 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
/* (these two headers aren't used here, but AWS IoT SDK code relies on them
|
||||
being included from here...) */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
/* This is a stub replacement for the aws_iot_log.h header in the AWS IoT SDK,
|
||||
which redirects their logging framework into the esp-idf logging framework.
|
||||
|
||||
The current (2.1.1) upstream AWS IoT SDK doesn't allow this as some of its
|
||||
headers include aws_iot_log.h, but our modified fork does.
|
||||
*/
|
||||
|
||||
// redefine the AWS IoT log functions to call into the IDF log layer
|
||||
#define IOT_DEBUG(format, ...) ESP_LOGD("aws_iot", format, ##__VA_ARGS__)
|
||||
#define IOT_INFO(format, ...) ESP_LOGI("aws_iot", format, ##__VA_ARGS__)
|
||||
#define IOT_WARN(format, ...) ESP_LOGW("aws_iot", format, ##__VA_ARGS__)
|
||||
#define IOT_ERROR(format, ...) ESP_LOGE("aws_iot", format, ##__VA_ARGS__)
|
||||
|
||||
/* Function tracing macros used in AWS IoT SDK,
|
||||
mapped to "verbose" level output
|
||||
*/
|
||||
#define FUNC_ENTRY ESP_LOGV("aws_iot", "FUNC_ENTRY: %s L#%d \n", __func__, __LINE__)
|
||||
#define FUNC_EXIT_RC(x) \
|
||||
do { \
|
||||
ESP_LOGV("aws_iot", "FUNC_EXIT: %s L#%d Return Code : %d \n", __func__, __LINE__, x); \
|
||||
return x; \
|
||||
} while(0)
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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 IOTSDKC_NETWORK_MBEDTLS_PLATFORM_H_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/net.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/certs.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/debug.h"
|
||||
#include "mbedtls/timing.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief TLS Connection Parameters
|
||||
*
|
||||
* Defines a type containing TLS specific parameters to be passed down to the
|
||||
* TLS networking layer to create a TLS secured socket.
|
||||
*/
|
||||
typedef struct _TLSDataParams {
|
||||
mbedtls_entropy_context entropy;
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
mbedtls_ssl_context ssl;
|
||||
mbedtls_ssl_config conf;
|
||||
uint32_t flags;
|
||||
mbedtls_x509_crt cacert;
|
||||
mbedtls_x509_crt clicert;
|
||||
mbedtls_pk_context pkey;
|
||||
mbedtls_net_context server_fd;
|
||||
}TLSDataParams;
|
||||
|
||||
#define IOTSDKC_NETWORK_MBEDTLS_PLATFORM_H_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //IOTSDKC_NETWORK_MBEDTLS_PLATFORM_H_H
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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 "threads_interface.h"
|
||||
|
||||
#ifndef AWS_IOTSDK_THREADS_PLATFORM_H
|
||||
#define AWS_IOTSDK_THREADS_PLATFORM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
/**
|
||||
* @brief Mutex Type
|
||||
*
|
||||
* definition of the Mutex struct. Platform specific
|
||||
*
|
||||
*/
|
||||
struct _IoT_Mutex_t {
|
||||
SemaphoreHandle_t mutex;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AWS_IOTSDK_THREADS_PLATFORM_H */
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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 AWS_IOT_PLATFORM_H
|
||||
#define AWS_IOT_PLATFORM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "timer_interface.h"
|
||||
|
||||
/**
|
||||
* definition of the Timer struct. Platform specific
|
||||
*/
|
||||
struct Timer {
|
||||
uint32_t start_ticks;
|
||||
uint32_t timeout_ticks;
|
||||
uint32_t last_polled_ticks;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AWS_IOT_PLATFORM_H */
|
||||
@@ -1,408 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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 <sys/param.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <timer_platform.h>
|
||||
#include <network_interface.h>
|
||||
|
||||
#include "aws_iot_config.h"
|
||||
#include "aws_iot_error.h"
|
||||
#include "network_interface.h"
|
||||
#include "network_platform.h"
|
||||
|
||||
#include "mbedtls/esp_debug.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_vfs.h"
|
||||
|
||||
static const char *TAG = "aws_iot";
|
||||
|
||||
/* This is the value used for ssl read timeout */
|
||||
#define IOT_SSL_READ_TIMEOUT 10
|
||||
|
||||
/*
|
||||
* This is a function to do further verification if needed on the cert received.
|
||||
*
|
||||
* Currently used to print debug-level information about each cert.
|
||||
*/
|
||||
static int _iot_tls_verify_cert(void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags) {
|
||||
char buf[256];
|
||||
((void) data);
|
||||
|
||||
if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) {
|
||||
ESP_LOGD(TAG, "Verify requested for (Depth %d):", depth);
|
||||
mbedtls_x509_crt_info(buf, sizeof(buf) - 1, "", crt);
|
||||
ESP_LOGD(TAG, "%s", buf);
|
||||
|
||||
if((*flags) == 0) {
|
||||
ESP_LOGD(TAG, " This certificate has no flags");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Verify result:%s", buf);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _iot_tls_set_connect_params(Network *pNetwork, const char *pRootCALocation, const char *pDeviceCertLocation,
|
||||
const char *pDevicePrivateKeyLocation, const char *pDestinationURL,
|
||||
uint16_t destinationPort, uint32_t timeout_ms, bool ServerVerificationFlag) {
|
||||
pNetwork->tlsConnectParams.DestinationPort = destinationPort;
|
||||
pNetwork->tlsConnectParams.pDestinationURL = pDestinationURL;
|
||||
pNetwork->tlsConnectParams.pDeviceCertLocation = pDeviceCertLocation;
|
||||
pNetwork->tlsConnectParams.pDevicePrivateKeyLocation = pDevicePrivateKeyLocation;
|
||||
pNetwork->tlsConnectParams.pRootCALocation = pRootCALocation;
|
||||
pNetwork->tlsConnectParams.timeout_ms = timeout_ms;
|
||||
pNetwork->tlsConnectParams.ServerVerificationFlag = ServerVerificationFlag;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_init(Network *pNetwork, const char *pRootCALocation, const char *pDeviceCertLocation,
|
||||
const char *pDevicePrivateKeyLocation, const char *pDestinationURL,
|
||||
uint16_t destinationPort, uint32_t timeout_ms, bool ServerVerificationFlag) {
|
||||
_iot_tls_set_connect_params(pNetwork, pRootCALocation, pDeviceCertLocation, pDevicePrivateKeyLocation,
|
||||
pDestinationURL, destinationPort, timeout_ms, ServerVerificationFlag);
|
||||
|
||||
pNetwork->connect = iot_tls_connect;
|
||||
pNetwork->read = iot_tls_read;
|
||||
pNetwork->write = iot_tls_write;
|
||||
pNetwork->disconnect = iot_tls_disconnect;
|
||||
pNetwork->isConnected = iot_tls_is_connected;
|
||||
pNetwork->destroy = iot_tls_destroy;
|
||||
|
||||
pNetwork->tlsDataParams.flags = 0;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_is_connected(Network *pNetwork) {
|
||||
/* Use this to add implementation which can check for physical layer disconnect */
|
||||
return NETWORK_PHYSICAL_LAYER_CONNECTED;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) {
|
||||
int ret = SUCCESS;
|
||||
TLSDataParams *tlsDataParams = NULL;
|
||||
char portBuffer[6];
|
||||
char info_buf[256];
|
||||
|
||||
if(NULL == pNetwork) {
|
||||
return NULL_VALUE_ERROR;
|
||||
}
|
||||
|
||||
if(NULL != params) {
|
||||
_iot_tls_set_connect_params(pNetwork, params->pRootCALocation, params->pDeviceCertLocation,
|
||||
params->pDevicePrivateKeyLocation, params->pDestinationURL,
|
||||
params->DestinationPort, params->timeout_ms, params->ServerVerificationFlag);
|
||||
}
|
||||
|
||||
tlsDataParams = &(pNetwork->tlsDataParams);
|
||||
|
||||
mbedtls_net_init(&(tlsDataParams->server_fd));
|
||||
mbedtls_ssl_init(&(tlsDataParams->ssl));
|
||||
mbedtls_ssl_config_init(&(tlsDataParams->conf));
|
||||
|
||||
#ifdef CONFIG_MBEDTLS_DEBUG
|
||||
mbedtls_esp_enable_debug_log(&(tlsDataParams->conf), 4);
|
||||
#endif
|
||||
|
||||
mbedtls_ctr_drbg_init(&(tlsDataParams->ctr_drbg));
|
||||
mbedtls_x509_crt_init(&(tlsDataParams->cacert));
|
||||
mbedtls_x509_crt_init(&(tlsDataParams->clicert));
|
||||
mbedtls_pk_init(&(tlsDataParams->pkey));
|
||||
|
||||
ESP_LOGD(TAG, "Seeding the random number generator...");
|
||||
mbedtls_entropy_init(&(tlsDataParams->entropy));
|
||||
if((ret = mbedtls_ctr_drbg_seed(&(tlsDataParams->ctr_drbg), mbedtls_entropy_func, &(tlsDataParams->entropy),
|
||||
(const unsigned char *) TAG, strlen(TAG))) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ctr_drbg_seed returned -0x%x", -ret);
|
||||
return NETWORK_MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED;
|
||||
}
|
||||
|
||||
/* Load root CA...
|
||||
|
||||
Certs/keys can be paths or they can be raw data. These use a
|
||||
very basic heuristic: if the cert starts with '/' then it's a
|
||||
path, if it's longer than this then it's raw cert data (PEM or DER,
|
||||
neither of which can start with a slash. */
|
||||
if (pNetwork->tlsConnectParams.pRootCALocation[0] == '/') {
|
||||
ESP_LOGD(TAG, "Loading CA root certificate from file ...");
|
||||
ret = mbedtls_x509_crt_parse_file(&(tlsDataParams->cacert), pNetwork->tlsConnectParams.pRootCALocation);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Loading embedded CA root certificate ...");
|
||||
ret = mbedtls_x509_crt_parse(&(tlsDataParams->cacert), (const unsigned char *)pNetwork->tlsConnectParams.pRootCALocation,
|
||||
strlen(pNetwork->tlsConnectParams.pRootCALocation)+1);
|
||||
}
|
||||
|
||||
if(ret < 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_x509_crt_parse returned -0x%x while parsing root cert", -ret);
|
||||
return NETWORK_X509_ROOT_CRT_PARSE_ERROR;
|
||||
}
|
||||
ESP_LOGD(TAG, "ok (%d skipped)", ret);
|
||||
|
||||
/* Load client certificate... */
|
||||
if (pNetwork->tlsConnectParams.pDeviceCertLocation[0] == '/') {
|
||||
ESP_LOGD(TAG, "Loading client cert from file...");
|
||||
ret = mbedtls_x509_crt_parse_file(&(tlsDataParams->clicert),
|
||||
pNetwork->tlsConnectParams.pDeviceCertLocation);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Loading embedded client certificate...");
|
||||
ret = mbedtls_x509_crt_parse(&(tlsDataParams->clicert),
|
||||
(const unsigned char *)pNetwork->tlsConnectParams.pDeviceCertLocation,
|
||||
strlen(pNetwork->tlsConnectParams.pDeviceCertLocation)+1);
|
||||
}
|
||||
if(ret != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_x509_crt_parse returned -0x%x while parsing device cert", -ret);
|
||||
return NETWORK_X509_DEVICE_CRT_PARSE_ERROR;
|
||||
}
|
||||
|
||||
/* Parse client private key... */
|
||||
if (pNetwork->tlsConnectParams.pDevicePrivateKeyLocation[0] == '/') {
|
||||
ESP_LOGD(TAG, "Loading client private key from file...");
|
||||
ret = mbedtls_pk_parse_keyfile(&(tlsDataParams->pkey),
|
||||
pNetwork->tlsConnectParams.pDevicePrivateKeyLocation,
|
||||
"");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Loading embedded client private key...");
|
||||
ret = mbedtls_pk_parse_key(&(tlsDataParams->pkey),
|
||||
(const unsigned char *)pNetwork->tlsConnectParams.pDevicePrivateKeyLocation,
|
||||
strlen(pNetwork->tlsConnectParams.pDevicePrivateKeyLocation)+1,
|
||||
(const unsigned char *)"", 0);
|
||||
}
|
||||
if(ret != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_pk_parse_key returned -0x%x while parsing private key", -ret);
|
||||
return NETWORK_PK_PRIVATE_KEY_PARSE_ERROR;
|
||||
}
|
||||
|
||||
/* Done parsing certs */
|
||||
ESP_LOGD(TAG, "ok");
|
||||
snprintf(portBuffer, 6, "%d", pNetwork->tlsConnectParams.DestinationPort);
|
||||
ESP_LOGD(TAG, "Connecting to %s/%s...", pNetwork->tlsConnectParams.pDestinationURL, portBuffer);
|
||||
if((ret = mbedtls_net_connect(&(tlsDataParams->server_fd), pNetwork->tlsConnectParams.pDestinationURL,
|
||||
portBuffer, MBEDTLS_NET_PROTO_TCP)) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_net_connect returned -0x%x", -ret);
|
||||
switch(ret) {
|
||||
case MBEDTLS_ERR_NET_SOCKET_FAILED:
|
||||
return NETWORK_ERR_NET_SOCKET_FAILED;
|
||||
case MBEDTLS_ERR_NET_UNKNOWN_HOST:
|
||||
return NETWORK_ERR_NET_UNKNOWN_HOST;
|
||||
case MBEDTLS_ERR_NET_CONNECT_FAILED:
|
||||
default:
|
||||
return NETWORK_ERR_NET_CONNECT_FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
ret = mbedtls_net_set_block(&(tlsDataParams->server_fd));
|
||||
if(ret != 0) {
|
||||
ESP_LOGE(TAG, "failed! net_set_(non)block() returned -0x%x", -ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
} ESP_LOGD(TAG, "ok");
|
||||
|
||||
ESP_LOGD(TAG, "Setting up the SSL/TLS structure...");
|
||||
if((ret = mbedtls_ssl_config_defaults(&(tlsDataParams->conf), MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT)) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_config_defaults returned -0x%x", -ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
}
|
||||
|
||||
mbedtls_ssl_conf_verify(&(tlsDataParams->conf), _iot_tls_verify_cert, NULL);
|
||||
|
||||
if(pNetwork->tlsConnectParams.ServerVerificationFlag == true) {
|
||||
mbedtls_ssl_conf_authmode(&(tlsDataParams->conf), MBEDTLS_SSL_VERIFY_REQUIRED);
|
||||
} else {
|
||||
mbedtls_ssl_conf_authmode(&(tlsDataParams->conf), MBEDTLS_SSL_VERIFY_OPTIONAL);
|
||||
}
|
||||
mbedtls_ssl_conf_rng(&(tlsDataParams->conf), mbedtls_ctr_drbg_random, &(tlsDataParams->ctr_drbg));
|
||||
|
||||
mbedtls_ssl_conf_ca_chain(&(tlsDataParams->conf), &(tlsDataParams->cacert), NULL);
|
||||
ret = mbedtls_ssl_conf_own_cert(&(tlsDataParams->conf), &(tlsDataParams->clicert), &(tlsDataParams->pkey));
|
||||
if(ret != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_conf_own_cert returned %d", ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
}
|
||||
|
||||
mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), pNetwork->tlsConnectParams.timeout_ms);
|
||||
|
||||
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;
|
||||
}
|
||||
if((ret = mbedtls_ssl_set_hostname(&(tlsDataParams->ssl), pNetwork->tlsConnectParams.pDestinationURL)) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_set_hostname returned %d", ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
}
|
||||
ESP_LOGD(TAG, "SSL state connect : %d ", tlsDataParams->ssl.state);
|
||||
mbedtls_ssl_set_bio(&(tlsDataParams->ssl), &(tlsDataParams->server_fd), mbedtls_net_send, NULL,
|
||||
mbedtls_net_recv_timeout);
|
||||
ESP_LOGD(TAG, "ok");
|
||||
|
||||
ESP_LOGD(TAG, "SSL state connect : %d ", tlsDataParams->ssl.state);
|
||||
ESP_LOGD(TAG, "Performing the SSL/TLS handshake...");
|
||||
while((ret = mbedtls_ssl_handshake(&(tlsDataParams->ssl))) != 0) {
|
||||
if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_handshake returned -0x%x", -ret);
|
||||
if(ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) {
|
||||
ESP_LOGE(TAG, " Unable to verify the server's certificate. ");
|
||||
}
|
||||
return SSL_CONNECTION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "ok [ Protocol is %s ] [ Ciphersuite is %s ]", mbedtls_ssl_get_version(&(tlsDataParams->ssl)),
|
||||
mbedtls_ssl_get_ciphersuite(&(tlsDataParams->ssl)));
|
||||
if((ret = mbedtls_ssl_get_record_expansion(&(tlsDataParams->ssl))) >= 0) {
|
||||
ESP_LOGD(TAG, " [ Record expansion is %d ]", ret);
|
||||
} else {
|
||||
ESP_LOGD(TAG, " [ Record expansion is unknown (compression) ]");
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Verifying peer X.509 certificate...");
|
||||
|
||||
if(pNetwork->tlsConnectParams.ServerVerificationFlag == true) {
|
||||
if((tlsDataParams->flags = mbedtls_ssl_get_verify_result(&(tlsDataParams->ssl))) != 0) {
|
||||
ESP_LOGE(TAG, "failed");
|
||||
mbedtls_x509_crt_verify_info(info_buf, sizeof(info_buf), " ! ", tlsDataParams->flags);
|
||||
ESP_LOGE(TAG, "%s", info_buf);
|
||||
ret = SSL_CONNECTION_ERROR;
|
||||
} else {
|
||||
ESP_LOGD(TAG, "ok");
|
||||
ret = SUCCESS;
|
||||
}
|
||||
} else {
|
||||
ESP_LOGW(TAG, " Server Verification skipped");
|
||||
ret = SUCCESS;
|
||||
}
|
||||
|
||||
if(LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) {
|
||||
if (mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)) != NULL) {
|
||||
ESP_LOGD(TAG, "Peer certificate information:");
|
||||
mbedtls_x509_crt_info((char *) info_buf, sizeof(info_buf) - 1, " ", mbedtls_ssl_get_peer_cert(&(tlsDataParams->ssl)));
|
||||
ESP_LOGD(TAG, "%s", info_buf);
|
||||
}
|
||||
}
|
||||
|
||||
return (IoT_Error_t) ret;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_write(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *written_len) {
|
||||
size_t written_so_far;
|
||||
bool isErrorFlag = false;
|
||||
int frags, ret = 0;
|
||||
TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
|
||||
|
||||
for(written_so_far = 0, frags = 0;
|
||||
written_so_far < len && !has_timer_expired(timer); written_so_far += ret, frags++) {
|
||||
while(!has_timer_expired(timer) &&
|
||||
(ret = mbedtls_ssl_write(&(tlsDataParams->ssl), pMsg + written_so_far, len - written_so_far)) <= 0) {
|
||||
if(ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_write returned -0x%x", -ret);
|
||||
/* All other negative return values indicate connection needs to be reset.
|
||||
* Will be caught in ping request so ignored here */
|
||||
isErrorFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isErrorFlag) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*written_len = written_so_far;
|
||||
|
||||
if(isErrorFlag) {
|
||||
return NETWORK_SSL_WRITE_ERROR;
|
||||
} else if(has_timer_expired(timer) && written_so_far != len) {
|
||||
return NETWORK_SSL_WRITE_TIMEOUT_ERROR;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_read(Network *pNetwork, unsigned char *pMsg, size_t len, Timer *timer, size_t *read_len) {
|
||||
TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
|
||||
mbedtls_ssl_context *ssl = &(tlsDataParams->ssl);
|
||||
mbedtls_ssl_config *ssl_conf = &(tlsDataParams->conf);
|
||||
uint32_t read_timeout;
|
||||
size_t rxLen = 0;
|
||||
int ret;
|
||||
|
||||
read_timeout = ssl_conf->read_timeout;
|
||||
|
||||
while (len > 0) {
|
||||
|
||||
/* Make sure we never block on read for longer than timer has left,
|
||||
but also that we don't block indefinitely (ie read_timeout > 0) */
|
||||
mbedtls_ssl_conf_read_timeout(ssl_conf, MAX(1, MIN(read_timeout, left_ms(timer))));
|
||||
|
||||
ret = mbedtls_ssl_read(ssl, pMsg, len);
|
||||
|
||||
/* Restore the old timeout */
|
||||
mbedtls_ssl_conf_read_timeout(ssl_conf, read_timeout);
|
||||
|
||||
if (ret > 0) {
|
||||
rxLen += ret;
|
||||
pMsg += ret;
|
||||
len -= ret;
|
||||
} else if (ret == 0 || (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_TIMEOUT)) {
|
||||
return NETWORK_SSL_READ_ERROR;
|
||||
}
|
||||
|
||||
// Evaluate timeout after the read to make sure read is done at least once
|
||||
if (has_timer_expired(timer)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
*read_len = rxLen;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
if (rxLen == 0) {
|
||||
return NETWORK_SSL_NOTHING_TO_READ;
|
||||
} else {
|
||||
return NETWORK_SSL_READ_TIMEOUT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_disconnect(Network *pNetwork) {
|
||||
mbedtls_ssl_context *ssl = &(pNetwork->tlsDataParams.ssl);
|
||||
int ret = 0;
|
||||
do {
|
||||
ret = mbedtls_ssl_close_notify(ssl);
|
||||
} while(ret == MBEDTLS_ERR_SSL_WANT_WRITE);
|
||||
|
||||
/* All other negative return values indicate connection needs to be reset.
|
||||
* No further action required since this is disconnect call */
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
IoT_Error_t iot_tls_destroy(Network *pNetwork) {
|
||||
TLSDataParams *tlsDataParams = &(pNetwork->tlsDataParams);
|
||||
|
||||
mbedtls_net_free(&(tlsDataParams->server_fd));
|
||||
|
||||
mbedtls_x509_crt_free(&(tlsDataParams->clicert));
|
||||
mbedtls_x509_crt_free(&(tlsDataParams->cacert));
|
||||
mbedtls_pk_free(&(tlsDataParams->pkey));
|
||||
mbedtls_ssl_free(&(tlsDataParams->ssl));
|
||||
mbedtls_ssl_config_free(&(tlsDataParams->conf));
|
||||
mbedtls_ctr_drbg_free(&(tlsDataParams->ctr_drbg));
|
||||
mbedtls_entropy_free(&(tlsDataParams->entropy));
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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 "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "threads_platform.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the provided mutex
|
||||
*
|
||||
* Call this function to initialize the mutex
|
||||
*
|
||||
* @param IoT_Mutex_t - pointer to the mutex to be initialized
|
||||
* @return IoT_Error_t - error code indicating result of operation
|
||||
*/
|
||||
IoT_Error_t aws_iot_thread_mutex_init(IoT_Mutex_t *pMutex) {
|
||||
|
||||
pMutex->mutex = xSemaphoreCreateRecursiveMutex();
|
||||
return pMutex->mutex ? SUCCESS : MUTEX_INIT_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Lock the provided mutex
|
||||
*
|
||||
* Call this function to lock the mutex before performing a state change
|
||||
* Blocking, thread will block until lock request fails
|
||||
*
|
||||
* @param IoT_Mutex_t - pointer to the mutex to be locked
|
||||
* @return IoT_Error_t - error code indicating result of operation
|
||||
*/
|
||||
IoT_Error_t aws_iot_thread_mutex_lock(IoT_Mutex_t *pMutex) {
|
||||
xSemaphoreTakeRecursive(pMutex->mutex, portMAX_DELAY);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Try to lock the provided mutex
|
||||
*
|
||||
* Call this function to attempt to lock the mutex before performing a state change
|
||||
* Non-Blocking, immediately returns with failure if lock attempt fails
|
||||
*
|
||||
* @param IoT_Mutex_t - pointer to the mutex to be locked
|
||||
* @return IoT_Error_t - error code indicating result of operation
|
||||
*/
|
||||
IoT_Error_t aws_iot_thread_mutex_trylock(IoT_Mutex_t *pMutex) {
|
||||
if (xSemaphoreTakeRecursive(pMutex->mutex, 0)) {
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return MUTEX_LOCK_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unlock the provided mutex
|
||||
*
|
||||
* Call this function to unlock the mutex before performing a state change
|
||||
*
|
||||
* @param IoT_Mutex_t - pointer to the mutex to be unlocked
|
||||
* @return IoT_Error_t - error code indicating result of operation
|
||||
*/
|
||||
IoT_Error_t aws_iot_thread_mutex_unlock(IoT_Mutex_t *pMutex) {
|
||||
if (xSemaphoreGiveRecursive(pMutex->mutex)) {
|
||||
return SUCCESS;
|
||||
} else {
|
||||
return MUTEX_UNLOCK_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Destroy the provided mutex
|
||||
*
|
||||
* Call this function to destroy the mutex
|
||||
*
|
||||
* @param IoT_Mutex_t - pointer to the mutex to be destroyed
|
||||
* @return IoT_Error_t - error code indicating result of operation
|
||||
*/
|
||||
IoT_Error_t aws_iot_thread_mutex_destroy(IoT_Mutex_t *pMutex) {
|
||||
vSemaphoreDelete(pMutex->mutex);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* Additions Copyright 2016 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License").
|
||||
* You may not use this file except in compliance with the License.
|
||||
* A copy of the License is located at
|
||||
*
|
||||
* http://aws.amazon.com/apache2.0
|
||||
*
|
||||
* or in the "license" file accompanying this file. This file 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file timer.c
|
||||
* @brief FreeRTOS implementation of the timer interface uses ticks.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "timer_platform.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
const static char *TAG = "aws_timer";
|
||||
|
||||
bool has_timer_expired(Timer *timer) {
|
||||
uint32_t now = xTaskGetTickCount();
|
||||
bool expired = (now - timer->start_ticks) >= timer->timeout_ticks;
|
||||
|
||||
/* AWS IoT SDK isn't very RTOS friendly because it polls for "done
|
||||
timers" a lot without ever sleeping on them. So we hack in some
|
||||
amount of sleeping here: if it seems like the caller is polling
|
||||
an unexpired timer in a tight loop then we delay a tick to let
|
||||
things progress elsewhere.
|
||||
*/
|
||||
if(!expired && now == timer->last_polled_ticks) {
|
||||
vTaskDelay(1);
|
||||
}
|
||||
timer->last_polled_ticks = now;
|
||||
return expired;
|
||||
}
|
||||
|
||||
void countdown_ms(Timer *timer, uint32_t timeout) {
|
||||
timer->start_ticks = xTaskGetTickCount();
|
||||
timer->timeout_ticks = timeout / portTICK_PERIOD_MS;
|
||||
timer->last_polled_ticks = 0;
|
||||
}
|
||||
|
||||
uint32_t left_ms(Timer *timer) {
|
||||
uint32_t now = xTaskGetTickCount();
|
||||
uint32_t elapsed = now - timer->start_ticks;
|
||||
if (elapsed < timer->timeout_ticks) {
|
||||
return (timer->timeout_ticks - elapsed) * portTICK_PERIOD_MS;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void countdown_sec(Timer *timer, uint32_t timeout) {
|
||||
if (timeout > UINT32_MAX / 1000) {
|
||||
ESP_LOGE(TAG, "timeout is out of range: %ds", timeout);
|
||||
}
|
||||
countdown_ms(timer, timeout * 1000);
|
||||
}
|
||||
|
||||
void init_timer(Timer *timer) {
|
||||
timer->start_ticks = 0;
|
||||
timer->timeout_ticks = 0;
|
||||
timer->last_polled_ticks = 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -28,17 +28,8 @@ config LOG_BOOTLOADER_LEVEL
|
||||
default 4 if LOG_BOOTLOADER_LEVEL_DEBUG
|
||||
default 5 if LOG_BOOTLOADER_LEVEL_VERBOSE
|
||||
|
||||
config BOOTLOADER_VDDSDIO_BOOST
|
||||
bool "Increase VDDSDIO LDO voltage to 1.9V"
|
||||
default y
|
||||
help
|
||||
If this option is enabled, and VDDSDIO LDO is set to 1.8V (using EFUSE
|
||||
or MTDI bootstrapping pin), bootloader will change LDO settings to
|
||||
output 1.9V instead. This helps prevent flash chip from browning out
|
||||
during flash programming operations.
|
||||
For 3.3V flash, this option has no effect.
|
||||
endmenu
|
||||
|
||||
endmenu # Bootloader
|
||||
|
||||
|
||||
menu "Security features"
|
||||
|
||||
@@ -23,7 +23,7 @@ BOOTLOADER_OFFSET := 0x1000
|
||||
|
||||
# Custom recursive make for bootloader sub-project
|
||||
BOOTLOADER_MAKE=+$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
|
||||
V=$(V) BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) TEST_COMPONENTS= TESTS_ALL=
|
||||
V=$(V) BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) TEST_COMPONENTS=
|
||||
|
||||
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ PROJECT_NAME := bootloader
|
||||
|
||||
#We cannot include the esp32 component directly but we need its includes.
|
||||
#This is fixed by adding CFLAGS from Makefile.projbuild
|
||||
COMPONENTS := esptool_py bootloader bootloader_support log spi_flash micro-ecc soc
|
||||
COMPONENTS := esptool_py bootloader bootloader_support log spi_flash micro-ecc
|
||||
|
||||
# The bootloader pseudo-component is also included in this build, for its Kconfig.projbuild to be included.
|
||||
#
|
||||
|
||||
@@ -22,9 +22,16 @@ extern "C"
|
||||
#endif
|
||||
|
||||
#include "esp_flash_data_types.h"
|
||||
#include "soc/soc.h"
|
||||
|
||||
#define SPI_SEC_SIZE 0x1000
|
||||
#define IROM_LOW 0x400D0000
|
||||
#define IROM_HIGH 0x40400000
|
||||
#define DROM_LOW 0x3F400000
|
||||
#define DROM_HIGH 0x3F800000
|
||||
#define RTC_IRAM_LOW 0x400C0000
|
||||
#define RTC_IRAM_HIGH 0x400C2000
|
||||
#define RTC_DATA_LOW 0x50000000
|
||||
#define RTC_DATA_HIGH 0x50002000
|
||||
|
||||
#define SPI_ERROR_LOG "spi flash error"
|
||||
|
||||
|
||||
@@ -14,13 +14,11 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "rom/cache.h"
|
||||
#include "rom/efuse.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/crc.h"
|
||||
@@ -31,7 +29,6 @@
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
@@ -48,8 +45,7 @@
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_config.h"
|
||||
|
||||
#include "flash_qio_mode.h"
|
||||
#include "rtc.h"
|
||||
|
||||
extern int _bss_start;
|
||||
extern int _bss_end;
|
||||
@@ -60,6 +56,8 @@ We arrive here after the bootloader finished loading the program from flash. The
|
||||
flash cache is down and the app CPU is in reset. We do have a stack, so we can do the initialization in C.
|
||||
*/
|
||||
|
||||
// TODO: make a nice header file for ROM functions instead of adding externs all over the place
|
||||
extern void Cache_Flush(int);
|
||||
|
||||
void bootloader_main();
|
||||
static void unpack_load_app(const esp_partition_pos_t *app_node);
|
||||
@@ -72,11 +70,7 @@ static void set_cache_and_start_app(uint32_t drom_addr,
|
||||
uint32_t irom_size,
|
||||
uint32_t entry_addr);
|
||||
static void update_flash_config(const esp_image_header_t* pfhdr);
|
||||
static void vddsdio_configure();
|
||||
static void flash_gpio_configure();
|
||||
static void clock_configure(void);
|
||||
static void uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
|
||||
void IRAM_ATTR call_start_cpu0()
|
||||
{
|
||||
@@ -92,9 +86,9 @@ void IRAM_ATTR call_start_cpu0()
|
||||
Cache_Flush(0);
|
||||
Cache_Flush(1);
|
||||
mmu_init(0);
|
||||
DPORT_REG_SET_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
REG_SET_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
mmu_init(1);
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
/* (above steps probably unnecessary for most serial bootloader
|
||||
usage, all that's absolutely needed is that we unmask DROM0
|
||||
cache on the following two lines - normal ROM boot exits with
|
||||
@@ -105,20 +99,21 @@ void IRAM_ATTR call_start_cpu0()
|
||||
The lines which manipulate DPORT_APP_CACHE_MMU_IA_CLR bit are
|
||||
necessary to work around a hardware bug.
|
||||
*/
|
||||
DPORT_REG_CLR_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MASK_DROM0);
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MASK_DROM0);
|
||||
REG_CLR_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MASK_DROM0);
|
||||
REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MASK_DROM0);
|
||||
|
||||
bootloader_main();
|
||||
}
|
||||
|
||||
|
||||
/** @brief Load partition table
|
||||
/**
|
||||
* @function : load_partition_table
|
||||
* @description: Parse partition table, get useful data such as location of
|
||||
* OTA info sector, factory app sector, and test app sector.
|
||||
*
|
||||
* Parse partition table, get useful data such as location of
|
||||
* OTA data partition, factory app partition, and test app partition.
|
||||
* @inputs: bs bootloader state structure used to save the data
|
||||
* @return: return true, if the partition table is loaded (and MD5 checksum is valid)
|
||||
*
|
||||
* @param bs bootloader state structure used to save read data
|
||||
* @return return true if the partition table was succesfully loaded and MD5 checksum is valid.
|
||||
*/
|
||||
bool load_partition_table(bootloader_state_t* bs)
|
||||
{
|
||||
@@ -239,47 +234,35 @@ static bool ota_select_valid(const esp_ota_select_entry_t *s)
|
||||
|
||||
void bootloader_main()
|
||||
{
|
||||
vddsdio_configure();
|
||||
flash_gpio_configure();
|
||||
clock_configure();
|
||||
/* Set CPU to 80MHz.
|
||||
Start by ensuring it is set to XTAL, as PLL must be off first
|
||||
(may still be on due to soft reset.)
|
||||
*/
|
||||
rtc_set_cpu_freq(CPU_XTAL);
|
||||
rtc_set_cpu_freq(CPU_80M);
|
||||
|
||||
uart_console_configure();
|
||||
wdt_reset_check();
|
||||
ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER);
|
||||
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_FLASH_ENCRYPTION_ENABLED)
|
||||
esp_err_t err;
|
||||
#endif
|
||||
esp_image_header_t fhdr;
|
||||
bootloader_state_t bs;
|
||||
esp_rom_spiflash_result_t spiRet1,spiRet2;
|
||||
SpiFlashOpResult spiRet1,spiRet2;
|
||||
esp_ota_select_entry_t sa,sb;
|
||||
const esp_ota_select_entry_t *ota_select_map;
|
||||
|
||||
memset(&bs, 0, sizeof(bs));
|
||||
|
||||
ESP_LOGI(TAG, "compile time " __TIME__ );
|
||||
ets_set_appcpu_boot_addr(0);
|
||||
|
||||
/* disable watch dog here */
|
||||
REG_CLR_BIT( RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN );
|
||||
REG_CLR_BIT( TIMG_WDTCONFIG0_REG(0), TIMG_WDT_FLASHBOOT_MOD_EN );
|
||||
|
||||
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
if(spiconfig != EFUSE_SPICONFIG_SPI_DEFAULTS && spiconfig != EFUSE_SPICONFIG_HSPI_DEFAULTS) {
|
||||
ESP_LOGE(TAG, "SPI flash pins are overridden. \"Enable SPI flash ROM driver patched functions\" must be enabled in menuconfig");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_rom_spiflash_unlock();
|
||||
SPIUnlock();
|
||||
|
||||
ESP_LOGI(TAG, "Enabling RNG early entropy source...");
|
||||
bootloader_random_enable();
|
||||
|
||||
#if CONFIG_FLASHMODE_QIO || CONFIG_FLASHMODE_QOUT
|
||||
bootloader_enable_qio_mode();
|
||||
#endif
|
||||
|
||||
if(esp_image_load_header(0x1000, true, &fhdr) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return;
|
||||
@@ -310,46 +293,39 @@ void bootloader_main()
|
||||
memcpy(&sa, ota_select_map, sizeof(esp_ota_select_entry_t));
|
||||
memcpy(&sb, (uint8_t *)ota_select_map + SPI_SEC_SIZE, sizeof(esp_ota_select_entry_t));
|
||||
bootloader_munmap(ota_select_map);
|
||||
ESP_LOGD(TAG, "OTA sequence values A 0x%08x B 0x%08x", sa.ota_seq, sb.ota_seq);
|
||||
if(sa.ota_seq == 0xFFFFFFFF && sb.ota_seq == 0xFFFFFFFF) {
|
||||
ESP_LOGD(TAG, "OTA sequence numbers both empty (all-0xFF");
|
||||
// init status flash
|
||||
// init status flash
|
||||
if (bs.factory.offset != 0) { // if have factory bin,boot factory bin
|
||||
ESP_LOGD(TAG, "Defaulting to factory image");
|
||||
load_part_pos = bs.factory;
|
||||
} else {
|
||||
ESP_LOGD(TAG, "No factory image, defaulting to OTA 0");
|
||||
load_part_pos = bs.ota[0];
|
||||
sa.ota_seq = 0x01;
|
||||
sa.crc = ota_select_crc(&sa);
|
||||
sb.ota_seq = 0x00;
|
||||
sb.crc = ota_select_crc(&sb);
|
||||
|
||||
Cache_Read_Disable(0);
|
||||
spiRet1 = esp_rom_spiflash_erase_sector(bs.ota_info.offset/0x1000);
|
||||
spiRet2 = esp_rom_spiflash_erase_sector(bs.ota_info.offset/0x1000+1);
|
||||
if (spiRet1 != ESP_ROM_SPIFLASH_RESULT_OK || spiRet2 != ESP_ROM_SPIFLASH_RESULT_OK ) {
|
||||
Cache_Read_Disable(0);
|
||||
spiRet1 = SPIEraseSector(bs.ota_info.offset/0x1000);
|
||||
spiRet2 = SPIEraseSector(bs.ota_info.offset/0x1000+1);
|
||||
if (spiRet1 != SPI_FLASH_RESULT_OK || spiRet2 != SPI_FLASH_RESULT_OK ) {
|
||||
ESP_LOGE(TAG, SPI_ERROR_LOG);
|
||||
return;
|
||||
}
|
||||
spiRet1 = esp_rom_spiflash_write(bs.ota_info.offset,(uint32_t *)&sa,sizeof(esp_ota_select_entry_t));
|
||||
spiRet2 = esp_rom_spiflash_write(bs.ota_info.offset + 0x1000,(uint32_t *)&sb,sizeof(esp_ota_select_entry_t));
|
||||
if (spiRet1 != ESP_ROM_SPIFLASH_RESULT_OK || spiRet2 != ESP_ROM_SPIFLASH_RESULT_OK ) {
|
||||
}
|
||||
spiRet1 = SPIWrite(bs.ota_info.offset,(uint32_t *)&sa,sizeof(esp_ota_select_entry_t));
|
||||
spiRet2 = SPIWrite(bs.ota_info.offset + 0x1000,(uint32_t *)&sb,sizeof(esp_ota_select_entry_t));
|
||||
if (spiRet1 != SPI_FLASH_RESULT_OK || spiRet2 != SPI_FLASH_RESULT_OK ) {
|
||||
ESP_LOGE(TAG, SPI_ERROR_LOG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Cache_Read_Enable(0);
|
||||
}
|
||||
//TODO:write data in ota info
|
||||
} else {
|
||||
if(ota_select_valid(&sa) && ota_select_valid(&sb)) {
|
||||
ESP_LOGD(TAG, "Both OTA sequence valid, using OTA slot %d", MAX(sa.ota_seq, sb.ota_seq)-1);
|
||||
load_part_pos = bs.ota[(MAX(sa.ota_seq, sb.ota_seq) - 1)%bs.app_count];
|
||||
load_part_pos = bs.ota[(((sa.ota_seq > sb.ota_seq)?sa.ota_seq:sb.ota_seq) - 1)%bs.app_count];
|
||||
} else if(ota_select_valid(&sa)) {
|
||||
ESP_LOGD(TAG, "Only OTA sequence A is valid, using OTA slot %d", sa.ota_seq - 1);
|
||||
load_part_pos = bs.ota[(sa.ota_seq - 1) % bs.app_count];
|
||||
} else if(ota_select_valid(&sb)) {
|
||||
ESP_LOGD(TAG, "Only OTA sequence B is valid, using OTA slot %d", sa.ota_seq - 1);
|
||||
load_part_pos = bs.ota[(sb.ota_seq - 1) % bs.app_count];
|
||||
} else if (bs.factory.offset != 0) {
|
||||
ESP_LOGE(TAG, "ota data partition invalid, falling back to factory");
|
||||
@@ -480,7 +456,7 @@ static void unpack_load_app(const esp_partition_pos_t* partition)
|
||||
// TODO: actually check md5
|
||||
}
|
||||
|
||||
if (address >= SOC_DROM_LOW && address < SOC_DROM_HIGH) {
|
||||
if (address >= DROM_LOW && address < DROM_HIGH) {
|
||||
ESP_LOGD(TAG, "found drom segment, map from %08x to %08x", data_offs,
|
||||
segment_header.load_addr);
|
||||
drom_addr = data_offs;
|
||||
@@ -490,7 +466,7 @@ static void unpack_load_app(const esp_partition_pos_t* partition)
|
||||
map = true;
|
||||
}
|
||||
|
||||
if (address >= SOC_IROM_LOW && address < SOC_IROM_HIGH) {
|
||||
if (address >= IROM_LOW && address < IROM_HIGH) {
|
||||
ESP_LOGD(TAG, "found irom segment, map from %08x to %08x", data_offs,
|
||||
segment_header.load_addr);
|
||||
irom_addr = data_offs;
|
||||
@@ -500,12 +476,12 @@ static void unpack_load_app(const esp_partition_pos_t* partition)
|
||||
map = true;
|
||||
}
|
||||
|
||||
if (!load_rtc_memory && address >= SOC_RTC_IRAM_LOW && address < SOC_RTC_IRAM_HIGH) {
|
||||
if (!load_rtc_memory && address >= RTC_IRAM_LOW && address < RTC_IRAM_HIGH) {
|
||||
ESP_LOGD(TAG, "Skipping RTC code segment at %08x\n", data_offs);
|
||||
load = false;
|
||||
}
|
||||
|
||||
if (!load_rtc_memory && address >= SOC_RTC_DATA_LOW && address < SOC_RTC_DATA_HIGH) {
|
||||
if (!load_rtc_memory && address >= RTC_DATA_LOW && address < RTC_DATA_HIGH) {
|
||||
ESP_LOGD(TAG, "Skipping RTC data segment at %08x\n", data_offs);
|
||||
load = false;
|
||||
}
|
||||
@@ -565,7 +541,7 @@ static void set_cache_and_start_app(
|
||||
uint32_t drom_size,
|
||||
uint32_t irom_addr,
|
||||
uint32_t irom_load_addr,
|
||||
uint32_t irom_size,
|
||||
uint32_t irom_size,
|
||||
uint32_t entry_addr)
|
||||
{
|
||||
ESP_LOGD(TAG, "configure drom and irom and start");
|
||||
@@ -583,8 +559,8 @@ static void set_cache_and_start_app(
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
rc = cache_flash_mmu_set( 1, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG, (DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) | (DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 | DPORT_PRO_CACHE_MASK_DRAM1 );
|
||||
DPORT_REG_CLR_BIT( DPORT_APP_CACHE_CTRL1_REG, (DPORT_APP_CACHE_MASK_IRAM0) | (DPORT_APP_CACHE_MASK_IRAM1 & 0) | (DPORT_APP_CACHE_MASK_IROM0 & 0) | DPORT_APP_CACHE_MASK_DROM0 | DPORT_APP_CACHE_MASK_DRAM1 );
|
||||
REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG, (DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) | (DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 | DPORT_PRO_CACHE_MASK_DRAM1 );
|
||||
REG_CLR_BIT( DPORT_APP_CACHE_CTRL1_REG, (DPORT_APP_CACHE_MASK_IRAM0) | (DPORT_APP_CACHE_MASK_IRAM1 & 0) | (DPORT_APP_CACHE_MASK_IROM0 & 0) | DPORT_APP_CACHE_MASK_DROM0 | DPORT_APP_CACHE_MASK_DRAM1 );
|
||||
Cache_Read_Enable( 0 );
|
||||
|
||||
// Application will need to do Cache_Flush(1) and Cache_Read_Enable(1)
|
||||
@@ -622,7 +598,7 @@ static void update_flash_config(const esp_image_header_t* pfhdr)
|
||||
}
|
||||
Cache_Read_Disable( 0 );
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(g_rom_flashchip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
SPIParamCfg(g_rom_flashchip.deviceId, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
// TODO: set mode
|
||||
// TODO: set frequency
|
||||
Cache_Flush(0);
|
||||
@@ -659,21 +635,28 @@ void print_flash_info(const esp_image_header_t* phdr)
|
||||
}
|
||||
ESP_LOGI(TAG, "SPI Speed : %s", str );
|
||||
|
||||
/* SPI mode could have been set to QIO during boot already,
|
||||
so test the SPI registers not the flash header */
|
||||
uint32_t spi_ctrl = REG_READ(SPI_CTRL_REG(0));
|
||||
if (spi_ctrl & SPI_FREAD_QIO) {
|
||||
switch ( phdr->spi_mode ) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
str = "QIO";
|
||||
} else if (spi_ctrl & SPI_FREAD_QUAD) {
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
str = "QOUT";
|
||||
} else if (spi_ctrl & SPI_FREAD_DIO) {
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
str = "DIO";
|
||||
} else if (spi_ctrl & SPI_FREAD_DUAL) {
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DOUT:
|
||||
str = "DOUT";
|
||||
} else if (spi_ctrl & SPI_FASTRD_MODE) {
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
str = "FAST READ";
|
||||
} else {
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
str = "SLOW READ";
|
||||
break;
|
||||
default:
|
||||
str = "DIO";
|
||||
break;
|
||||
}
|
||||
ESP_LOGI(TAG, "SPI Mode : %s", str );
|
||||
|
||||
@@ -701,140 +684,6 @@ void print_flash_info(const esp_image_header_t* phdr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.tieh == 0) { // 1.8V is used
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
cfg.enable = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
ets_delay_us(10); // wait for regulator to become stable
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
|
||||
#define FLASH_CLK_IO 6
|
||||
#define FLASH_CS_IO 11
|
||||
#define FLASH_SPIQ_IO 7
|
||||
#define FLASH_SPID_IO 8
|
||||
#define FLASH_SPIWP_IO 10
|
||||
#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()
|
||||
{
|
||||
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
|
||||
/* 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
|
||||
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
|
||||
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
|
||||
// For ESP32D2WD the SPI pins are already configured
|
||||
ESP_LOGI(TAG, "Detected ESP32D2WD");
|
||||
//flash clock signal should come from IO MUX.
|
||||
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);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
|
||||
// For ESP32PICOD2 the SPI pins are already configured
|
||||
ESP_LOGI(TAG, "Detected ESP32PICOD2");
|
||||
//flash clock signal should come from IO MUX.
|
||||
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);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
|
||||
// For ESP32PICOD4 the SPI pins are already configured
|
||||
ESP_LOGI(TAG, "Detected ESP32PICOD4");
|
||||
//flash clock signal should come from IO MUX.
|
||||
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);
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Detected ESP32");
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
|
||||
gpio_matrix_out(FLASH_CS_IO, SPICS0_OUT_IDX, 0, 0);
|
||||
gpio_matrix_out(FLASH_SPIQ_IO, SPIQ_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPIQ_IO, SPIQ_IN_IDX, 0);
|
||||
gpio_matrix_out(FLASH_SPID_IO, SPID_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPID_IO, SPID_IN_IDX, 0);
|
||||
gpio_matrix_out(FLASH_SPIWP_IO, SPIWP_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPIWP_IO, SPIWP_IN_IDX, 0);
|
||||
gpio_matrix_out(FLASH_SPIHD_IO, SPIHD_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPIHD_IO, SPIHD_IN_IDX, 0);
|
||||
//select pin function gpio
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, PIN_FUNC_GPIO);
|
||||
// flash clock signal should come from IO MUX.
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void clock_configure(void)
|
||||
{
|
||||
/* Set CPU to 80MHz. Keep other clocks unmodified. */
|
||||
rtc_cpu_freq_t cpu_freq = RTC_CPU_FREQ_80M;
|
||||
|
||||
/* On ESP32 rev 0, switching to 80MHz if clock was previously set to
|
||||
* 240 MHz may cause the chip to lock up (see section 3.5 of the errata
|
||||
* document). For rev. 0, switch to 240 instead if it was chosen in
|
||||
* menuconfig.
|
||||
*/
|
||||
uint32_t chip_ver_reg = REG_READ(EFUSE_BLK0_RDATA3_REG);
|
||||
if ((chip_ver_reg & EFUSE_RD_CHIP_VER_REV1_M) == 0 &&
|
||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240) {
|
||||
cpu_freq = RTC_CPU_FREQ_240M;
|
||||
}
|
||||
|
||||
uart_tx_wait_idle(0);
|
||||
rtc_clk_config_t clk_cfg = RTC_CLK_CONFIG_DEFAULT();
|
||||
clk_cfg.xtal_freq = CONFIG_ESP32_XTAL_FREQ;
|
||||
clk_cfg.cpu_freq = cpu_freq;
|
||||
clk_cfg.slow_freq = rtc_clk_slow_freq_get();
|
||||
clk_cfg.fast_freq = rtc_clk_fast_freq_get();
|
||||
rtc_clk_init(clk_cfg);
|
||||
/* As a slight optimization, if 32k XTAL was enabled in sdkconfig, we enable
|
||||
* it here. Usually it needs some time to start up, so we amortize at least
|
||||
* part of the start up time by enabling 32k XTAL early.
|
||||
* App startup code will wait until the oscillator has started up.
|
||||
*/
|
||||
#ifdef CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||
if (!rtc_clk_32k_enabled()) {
|
||||
rtc_clk_32k_bootstrap();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void uart_console_configure(void)
|
||||
{
|
||||
#if CONFIG_CONSOLE_UART_NONE
|
||||
@@ -876,84 +725,16 @@ static void uart_console_configure(void)
|
||||
|
||||
// Set configured UART console baud rate
|
||||
const int uart_baud = CONFIG_CONSOLE_UART_BAUDRATE;
|
||||
uart_div_modify(uart_num, (rtc_clk_apb_freq_get() << 4) / uart_baud);
|
||||
uart_div_modify(uart_num, (APB_CLK_FREQ << 4) / uart_baud);
|
||||
|
||||
#endif // CONFIG_CONSOLE_UART_NONE
|
||||
}
|
||||
|
||||
static void wdt_reset_cpu0_info_enable(void)
|
||||
/* empty rtc_printf implementation, to work with librtc
|
||||
linking. Can be removed once -lrtc is removed from bootloader's
|
||||
main component.mk.
|
||||
*/
|
||||
int rtc_printf(void)
|
||||
{
|
||||
//We do not reset core1 info here because it didn't work before cpu1 was up. So we put it into call_start_cpu1.
|
||||
DPORT_REG_SET_BIT(DPORT_PRO_CPU_RECORD_CTRL_REG, DPORT_PRO_CPU_PDEBUG_ENABLE | DPORT_PRO_CPU_RECORD_ENABLE);
|
||||
DPORT_REG_CLR_BIT(DPORT_PRO_CPU_RECORD_CTRL_REG, DPORT_PRO_CPU_RECORD_ENABLE);
|
||||
}
|
||||
|
||||
static void wdt_reset_info_dump(int cpu)
|
||||
{
|
||||
uint32_t inst = 0, pid = 0, stat = 0, data = 0, pc = 0,
|
||||
lsstat = 0, lsaddr = 0, lsdata = 0, dstat = 0;
|
||||
char *cpu_name = cpu ? "APP" : "PRO";
|
||||
|
||||
if (cpu == 0) {
|
||||
stat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_STATUS_REG);
|
||||
pid = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PID_REG);
|
||||
inst = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGINST_REG);
|
||||
dstat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGSTATUS_REG);
|
||||
data = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGDATA_REG);
|
||||
pc = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGPC_REG);
|
||||
lsstat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGLS0STAT_REG);
|
||||
lsaddr = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGLS0ADDR_REG);
|
||||
lsdata = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGLS0DATA_REG);
|
||||
|
||||
} else {
|
||||
stat = DPORT_REG_READ(DPORT_APP_CPU_RECORD_STATUS_REG);
|
||||
pid = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PID_REG);
|
||||
inst = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGINST_REG);
|
||||
dstat = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGSTATUS_REG);
|
||||
data = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGDATA_REG);
|
||||
pc = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGPC_REG);
|
||||
lsstat = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGLS0STAT_REG);
|
||||
lsaddr = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGLS0ADDR_REG);
|
||||
lsdata = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGLS0DATA_REG);
|
||||
}
|
||||
if (DPORT_RECORD_PDEBUGINST_SZ(inst) == 0 &&
|
||||
DPORT_RECORD_PDEBUGSTATUS_BBCAUSE(dstat) == DPORT_RECORD_PDEBUGSTATUS_BBCAUSE_WAITI) {
|
||||
ESP_LOGW(TAG, "WDT reset info: %s CPU PC=0x%x (waiti mode)", cpu_name, pc);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "WDT reset info: %s CPU PC=0x%x", cpu_name, pc);
|
||||
}
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU STATUS 0x%08x", cpu_name, stat);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PID 0x%08x", cpu_name, pid);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGINST 0x%08x", cpu_name, inst);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGSTATUS 0x%08x", cpu_name, dstat);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGDATA 0x%08x", cpu_name, data);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGPC 0x%08x", cpu_name, pc);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0STAT 0x%08x", cpu_name, lsstat);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0ADDR 0x%08x", cpu_name, lsaddr);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0DATA 0x%08x", cpu_name, lsdata);
|
||||
}
|
||||
|
||||
static void wdt_reset_check(void)
|
||||
{
|
||||
int wdt_rst = 0;
|
||||
RESET_REASON rst_reas[2];
|
||||
|
||||
rst_reas[0] = rtc_get_reset_reason(0);
|
||||
rst_reas[1] = rtc_get_reset_reason(1);
|
||||
if (rst_reas[0] == RTCWDT_SYS_RESET || rst_reas[0] == TG0WDT_SYS_RESET || rst_reas[0] == TG1WDT_SYS_RESET ||
|
||||
rst_reas[0] == TGWDT_CPU_RESET || rst_reas[0] == RTCWDT_CPU_RESET) {
|
||||
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
|
||||
wdt_rst = 1;
|
||||
}
|
||||
if (rst_reas[1] == RTCWDT_SYS_RESET || rst_reas[1] == TG0WDT_SYS_RESET || rst_reas[1] == TG1WDT_SYS_RESET ||
|
||||
rst_reas[1] == TGWDT_CPU_RESET || rst_reas[1] == RTCWDT_CPU_RESET) {
|
||||
ESP_LOGW(TAG, "APP CPU has been reset by WDT.");
|
||||
wdt_rst = 1;
|
||||
}
|
||||
if (wdt_rst) {
|
||||
// if reset by WDT dump info from trace port
|
||||
wdt_reset_info_dump(0);
|
||||
wdt_reset_info_dump(1);
|
||||
}
|
||||
wdt_reset_cpu0_info_enable();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,16 @@
|
||||
LINKER_SCRIPTS := \
|
||||
esp32.bootloader.ld \
|
||||
$(IDF_PATH)/components/esp32/ld/esp32.rom.ld \
|
||||
$(IDF_PATH)/components/esp32/ld/esp32.peripherals.ld \
|
||||
esp32.bootloader.rom.ld
|
||||
|
||||
ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
||||
LINKER_SCRIPTS += $(IDF_PATH)/components/esp32/ld/esp32.rom.spiflash.ld
|
||||
endif
|
||||
|
||||
COMPONENT_ADD_LDFLAGS := -L $(COMPONENT_PATH) -lmain $(addprefix -T ,$(LINKER_SCRIPTS))
|
||||
|
||||
COMPONENT_ADD_LINKER_DEPS := $(LINKER_SCRIPTS)
|
||||
|
||||
# following lines are a workaround to link librtc into the
|
||||
# bootloader, until clock setting code is in a source-based esp-idf
|
||||
# component. See also rtc_printf() in bootloader_start.c
|
||||
#
|
||||
# See also matching COMPONENT_SUBMODULES line in Makefile.projbuild
|
||||
COMPONENT_ADD_LDFLAGS += -L $(IDF_PATH)/components/esp32/lib/ -lrtc_clk -lrtc
|
||||
COMPONENT_EXTRA_INCLUDES += $(IDF_PATH)/components/esp32/
|
||||
|
||||
@@ -1,266 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "flash_qio_mode.h"
|
||||
#include "esp_log.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/efuse.h"
|
||||
#include "soc/spi_struct.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/* SPI flash controller */
|
||||
#define SPIFLASH SPI1
|
||||
|
||||
/* SPI commands (actual on-wire commands not SPI controller bitmasks)
|
||||
Suitable for use with the execute_flash_command static function.
|
||||
*/
|
||||
#define CMD_RDID 0x9F
|
||||
#define CMD_WRSR 0x01
|
||||
#define CMD_WRSR2 0x31 /* Not all SPI flash uses this command */
|
||||
#define CMD_WREN 0x06
|
||||
#define CMD_WRDI 0x04
|
||||
#define CMD_RDSR 0x05
|
||||
#define CMD_RDSR2 0x35 /* Not all SPI flash uses this command */
|
||||
|
||||
|
||||
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
|
||||
|
||||
static const char *TAG = "qio_mode";
|
||||
|
||||
typedef unsigned (*read_status_fn_t)();
|
||||
typedef void (*write_status_fn_t)(unsigned);
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
const char *manufacturer;
|
||||
uint8_t mfg_id; /* 8-bit JEDEC manufacturer ID */
|
||||
uint16_t flash_id; /* 16-bit JEDEC flash chip ID */
|
||||
uint16_t id_mask; /* Bits to match on in flash chip ID */
|
||||
read_status_fn_t read_status_fn;
|
||||
write_status_fn_t write_status_fn;
|
||||
uint8_t status_qio_bit;
|
||||
} qio_info_t;
|
||||
|
||||
/* Read 8 bit status using RDSR command */
|
||||
static unsigned read_status_8b_rdsr();
|
||||
/* Read 8 bit status (second byte) using RDSR2 command */
|
||||
static unsigned read_status_8b_rdsr2();
|
||||
/* read 16 bit status using RDSR & RDSR2 (low and high bytes) */
|
||||
static unsigned read_status_16b_rdsr_rdsr2();
|
||||
|
||||
/* Write 8 bit status using WRSR */
|
||||
static void write_status_8b_wrsr(unsigned new_status);
|
||||
/* Write 8 bit status (second byte) using WRSR2 */
|
||||
static void write_status_8b_wrsr2(unsigned new_status);
|
||||
/* Write 16 bit status using WRSR */
|
||||
static void write_status_16b_wrsr(unsigned new_status);
|
||||
|
||||
/* Array of known flash chips and data to enable Quad I/O mode
|
||||
|
||||
Manufacturer & flash ID can be tested by running "esptool.py
|
||||
flash_id"
|
||||
|
||||
If manufacturer ID matches, and flash ID ORed with flash ID mask
|
||||
matches, enable_qio_mode() will execute "Read Cmd", test if bit
|
||||
number "QIE Bit" is set, and if not set it will call "Write Cmd"
|
||||
with this bit set.
|
||||
|
||||
Searching of this table stops when the first match is found.
|
||||
*/
|
||||
const static qio_info_t chip_data[] = {
|
||||
/* Manufacturer, mfg_id, flash_id, id mask, Read Status, Write Status, QIE Bit */
|
||||
{ "MXIC", 0xC2, 0x2000, 0xFF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 },
|
||||
{ "ISSI", 0x9D, 0x4000, 0xCF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 }, /* IDs 0x40xx, 0x70xx */
|
||||
{ "WinBond", 0xEF, 0x4000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
|
||||
/* Final entry is default entry, if no other IDs have matched.
|
||||
|
||||
This approach works for chips including:
|
||||
GigaDevice (mfg ID 0xC8, flash IDs including 4016),
|
||||
FM25Q32 (QOUT mode only, mfg ID 0xA1, flash IDs including 4016)
|
||||
*/
|
||||
{ NULL, 0xFF, 0xFFFF, 0xFFFF, read_status_8b_rdsr2, write_status_8b_wrsr2, 1 },
|
||||
};
|
||||
|
||||
#define NUM_CHIPS (sizeof(chip_data) / sizeof(qio_info_t))
|
||||
|
||||
static void enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
write_status_fn_t write_status_fn,
|
||||
uint8_t status_qio_bit);
|
||||
|
||||
/* Generic function to use the "user command" SPI controller functionality
|
||||
to send commands to the SPI flash and read the respopnse.
|
||||
|
||||
The command passed here is always the on-the-wire command given to the SPI flash unit.
|
||||
*/
|
||||
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len);
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
|
||||
void bootloader_enable_qio_mode(void)
|
||||
{
|
||||
uint32_t raw_flash_id;
|
||||
uint8_t mfg_id;
|
||||
uint16_t flash_id;
|
||||
int i;
|
||||
|
||||
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() */
|
||||
SPIFLASH.ctrl.val = 0;
|
||||
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);
|
||||
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);
|
||||
ESP_LOGD(TAG, "Manufacturer ID 0x%02x chip ID 0x%04x", mfg_id, flash_id);
|
||||
|
||||
for (i = 0; i < NUM_CHIPS-1; i++) {
|
||||
const qio_info_t *chip = &chip_data[i];
|
||||
if (mfg_id == chip->mfg_id && (flash_id & chip->id_mask) == (chip->flash_id & chip->id_mask)) {
|
||||
ESP_LOGI(TAG, "Enabling QIO for flash chip %s", chip_data[i].manufacturer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == NUM_CHIPS - 1) {
|
||||
ESP_LOGI(TAG, "Enabling default flash chip QIO");
|
||||
}
|
||||
|
||||
enable_qio_mode(chip_data[i].read_status_fn,
|
||||
chip_data[i].write_status_fn,
|
||||
chip_data[i].status_qio_bit);
|
||||
}
|
||||
|
||||
static void enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
write_status_fn_t write_status_fn,
|
||||
uint8_t status_qio_bit)
|
||||
{
|
||||
uint32_t status;
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
|
||||
if (spiconfig != EFUSE_SPICONFIG_SPI_DEFAULTS && spiconfig != EFUSE_SPICONFIG_HSPI_DEFAULTS) {
|
||||
// spiconfig specifies a custom efuse pin configuration. This config defines all pins -except- WP.
|
||||
//
|
||||
// For now, in this situation we only support Quad I/O mode for ESP32-D2WD where WP pin is known.
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
const uint32_t PKG_VER_ESP32_D2WD = 2; // TODO: use chip detection API once available
|
||||
if (pkg_ver != PKG_VER_ESP32_D2WD) {
|
||||
ESP_LOGE(TAG, "Quad I/O is only supported for standard pin numbers or ESP32-D2WD. Falling back to Dual I/O.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
||||
status = read_status_fn();
|
||||
ESP_LOGD(TAG, "Initial flash chip status 0x%x", status);
|
||||
|
||||
if ((status & (1<<status_qio_bit)) == 0) {
|
||||
execute_flash_command(CMD_WREN, 0, 0, 0);
|
||||
write_status_fn(status | (1<<status_qio_bit));
|
||||
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
||||
status = read_status_fn();
|
||||
ESP_LOGD(TAG, "Updated flash chip status 0x%x", status);
|
||||
if ((status & (1<<status_qio_bit)) == 0) {
|
||||
ESP_LOGE(TAG, "Failed to set QIE bit, not enabling QIO mode");
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
ESP_LOGD(TAG, "QIO mode already enabled in flash");
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Enabling QIO mode...");
|
||||
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
#if CONFIG_FLASHMODE_QOUT
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
#else
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
#endif
|
||||
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
|
||||
esp_rom_spiflash_select_qio_pins(ESP32_D2WD_WP_GPIO, spiconfig);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_rdsr()
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR, 0, 0, 8);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_rdsr2()
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR2, 0, 0, 8);
|
||||
}
|
||||
|
||||
static unsigned read_status_16b_rdsr_rdsr2()
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR, 0, 0, 8) | (execute_flash_command(CMD_RDSR2, 0, 0, 8) << 8);
|
||||
}
|
||||
|
||||
static void write_status_8b_wrsr(unsigned new_status)
|
||||
{
|
||||
execute_flash_command(CMD_WRSR, new_status, 8, 0);
|
||||
}
|
||||
|
||||
static void write_status_8b_wrsr2(unsigned new_status)
|
||||
{
|
||||
execute_flash_command(CMD_WRSR2, new_status, 8, 0);
|
||||
}
|
||||
|
||||
static void write_status_16b_wrsr(unsigned new_status)
|
||||
{
|
||||
execute_flash_command(CMD_WRSR, new_status, 16, 0);
|
||||
}
|
||||
|
||||
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
|
||||
{
|
||||
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;
|
||||
SPIFLASH.user.usr_mosi = mosi_len > 0;
|
||||
SPIFLASH.mosi_dlen.usr_mosi_dbitlen = mosi_len ? (mosi_len - 1) : 0;
|
||||
SPIFLASH.data_buf[0] = mosi_data;
|
||||
|
||||
if (g_rom_spiflash_dummy_len_plus[1]) {
|
||||
/* When flash pins are mapped via GPIO matrix, need a dummy cycle before reading via MISO */
|
||||
if (miso_len > 0) {
|
||||
SPIFLASH.user.usr_dummy = 1;
|
||||
SPIFLASH.user1.usr_dummy_cyclelen = g_rom_spiflash_dummy_len_plus[1] - 1;
|
||||
} else {
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user1.usr_dummy_cyclelen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
SPIFLASH.cmd.usr = 1;
|
||||
while(SPIFLASH.cmd.usr != 0)
|
||||
{ }
|
||||
|
||||
return SPIFLASH.data_buf[0];
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Enable Quad I/O mode in bootloader (if configured)
|
||||
*
|
||||
* Queries attached SPI flash ID and sends correct SPI flash
|
||||
* commands to enable QIO or QOUT mode, then enables this mode.
|
||||
*/
|
||||
void bootloader_enable_qio_mode(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -33,7 +33,7 @@
|
||||
*
|
||||
* @return true if flash encryption is enabled.
|
||||
*/
|
||||
static inline /** @cond */ IRAM_ATTR /** @endcond */ bool esp_flash_encryption_enabled(void) {
|
||||
static inline IRAM_ATTR bool esp_flash_encryption_enabled(void) {
|
||||
uint32_t flash_crypt_cnt = REG_GET_FIELD(EFUSE_BLK0_RDATA0_REG, EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
/* __builtin_parity is in flash, so we calculate parity inline */
|
||||
bool enabled = false;
|
||||
|
||||
@@ -107,13 +107,8 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
Cache_Read_Disable(0);
|
||||
Cache_Flush(0);
|
||||
ESP_LOGD(TAG, "mmu set paddr=%08x count=%d", src_addr_aligned, count );
|
||||
int e = cache_flash_mmu_set(0, 0, MMU_BLOCK0_VADDR, src_addr_aligned, 64, count);
|
||||
if (e != 0) {
|
||||
ESP_LOGE(TAG, "cache_flash_mmu_set failed: %d\n", e);
|
||||
Cache_Read_Enable(0);
|
||||
return NULL;
|
||||
}
|
||||
Cache_Read_Enable(0);
|
||||
cache_flash_mmu_set( 0, 0, MMU_BLOCK0_VADDR, src_addr_aligned, 64, count );
|
||||
Cache_Read_Enable( 0 );
|
||||
|
||||
mapped = true;
|
||||
|
||||
@@ -132,14 +127,14 @@ void bootloader_munmap(const void *mapping)
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t spi_to_esp_err(esp_rom_spiflash_result_t r)
|
||||
static esp_err_t spi_to_esp_err(SpiFlashOpResult r)
|
||||
{
|
||||
switch(r) {
|
||||
case ESP_ROM_SPIFLASH_RESULT_OK:
|
||||
case SPI_FLASH_RESULT_OK:
|
||||
return ESP_OK;
|
||||
case ESP_ROM_SPIFLASH_RESULT_ERR:
|
||||
case SPI_FLASH_RESULT_ERR:
|
||||
return ESP_ERR_FLASH_OP_FAIL;
|
||||
case ESP_ROM_SPIFLASH_RESULT_TIMEOUT:
|
||||
case SPI_FLASH_RESULT_TIMEOUT:
|
||||
return ESP_ERR_FLASH_OP_TIMEOUT;
|
||||
default:
|
||||
return ESP_FAIL;
|
||||
@@ -150,7 +145,7 @@ static esp_err_t bootloader_flash_read_no_decrypt(size_t src_addr, void *dest, s
|
||||
{
|
||||
Cache_Read_Disable(0);
|
||||
Cache_Flush(0);
|
||||
esp_rom_spiflash_result_t r = esp_rom_spiflash_read(src_addr, dest, size);
|
||||
SpiFlashOpResult r = SPIRead(src_addr, dest, size);
|
||||
Cache_Read_Enable(0);
|
||||
|
||||
return spi_to_esp_err(r);
|
||||
@@ -226,21 +221,21 @@ esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
err = spi_to_esp_err(esp_rom_spiflash_unlock());
|
||||
err = spi_to_esp_err(SPIUnlock());
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if (write_encrypted) {
|
||||
return spi_to_esp_err(esp_rom_spiflash_write_encrypted(dest_addr, src, size));
|
||||
return spi_to_esp_err(SPI_Encrypt_Write(dest_addr, src, size));
|
||||
} else {
|
||||
return spi_to_esp_err(esp_rom_spiflash_write(dest_addr, src, size));
|
||||
return spi_to_esp_err(SPIWrite(dest_addr, src, size));
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t bootloader_flash_erase_sector(size_t sector)
|
||||
{
|
||||
return spi_to_esp_err(esp_rom_spiflash_erase_sector(sector));
|
||||
return spi_to_esp_err(SPIEraseSector(sector));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,7 @@ void bootloader_random_enable(void)
|
||||
/* Ensure the hardware RNG is enabled following a soft reset. This should always be the case already (this clock is
|
||||
never disabled while the CPU is running), this is a "belts and braces" type check.
|
||||
*/
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, DPORT_WIFI_CLK_RNG_EN);
|
||||
SET_PERI_REG_MASK(DPORT_WIFI_CLK_EN_REG, DPORT_WIFI_CLK_RNG_EN);
|
||||
|
||||
/* Enable SAR ADC in test mode to feed ADC readings of the 1.1V
|
||||
reference via I2S into the RNG entropy input.
|
||||
@@ -77,7 +77,7 @@ void bootloader_random_enable(void)
|
||||
SET_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
|
||||
SET_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_SAR2_EN_TEST);
|
||||
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_FORCE_START_TOP);
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_START_FORCE_REG, SENS_ULP_CP_START_TOP);
|
||||
// Test pattern configuration byte 0xAD:
|
||||
@@ -115,7 +115,7 @@ void bootloader_random_enable(void)
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
/* Disable i2s clock */
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
|
||||
|
||||
/* Reset some i2s configuration (possibly redundant as we reset entire
|
||||
@@ -138,8 +138,8 @@ void bootloader_random_disable(void)
|
||||
SET_PERI_REG_BITS(SYSCON_SARADC_FSM_REG, SYSCON_SARADC_START_WAIT, 8, SYSCON_SARADC_START_WAIT_S);
|
||||
|
||||
/* Reset i2s peripheral */
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
|
||||
SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
|
||||
CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_I2S0_RST);
|
||||
|
||||
/* Disable pull supply voltage to SAR ADC */
|
||||
CLEAR_PERI_REG_MASK(RTC_CNTL_TEST_MUX_REG, RTC_CNTL_ENT_RTC);
|
||||
|
||||
@@ -123,21 +123,6 @@ esp_err_t esp_image_basic_verify(uint32_t src_addr, bool log_errors, uint32_t *p
|
||||
return err;
|
||||
}
|
||||
|
||||
uint32_t load_addr = segment_header.load_addr;
|
||||
bool map_segment = (load_addr >= SOC_DROM_LOW && load_addr < SOC_DROM_HIGH)
|
||||
|| (load_addr >= SOC_IROM_LOW && load_addr < SOC_IROM_HIGH);
|
||||
|
||||
|
||||
/* Check that flash cache mapped segment aligns correctly from flash it's mapped address,
|
||||
relative to the 64KB page mapping size.
|
||||
*/
|
||||
ESP_LOGV(TAG, "segment %d map_segment %d segment_data_offs 0x%x load_addr 0x%x",
|
||||
i, map_segment, segment_data_offs, load_addr);
|
||||
if (map_segment && ((segment_data_offs % SPI_FLASH_MMU_PAGE_SIZE) != (load_addr % SPI_FLASH_MMU_PAGE_SIZE))) {
|
||||
ESP_LOGE(TAG, "Segment %d has load address 0x%08x, conflict with segment data at 0x%08x",
|
||||
i, load_addr, segment_data_offs);
|
||||
}
|
||||
|
||||
for (int i = 0; i < segment_header.data_len; i += sizeof(buf)) {
|
||||
err = bootloader_flash_read(segment_data_offs + i, buf, sizeof(buf), true);
|
||||
if (err != ESP_OK) {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#
|
||||
#Component Makefile
|
||||
#
|
||||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Tests for bootloader_support esp_image_basic_verify()
|
||||
*/
|
||||
|
||||
#include <esp_types.h>
|
||||
#include <stdio.h>
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
|
||||
#include "esp_partition.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_image_format.h"
|
||||
|
||||
TEST_CASE("Verify bootloader image in flash", "[bootloader_support]")
|
||||
{
|
||||
uint32_t image_len = 0;
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_OK, esp_image_basic_verify(0x1000, true, &image_len));
|
||||
TEST_ASSERT_NOT_EQUAL(0, image_len);
|
||||
}
|
||||
|
||||
TEST_CASE("Verify unit test app image", "[bootloader_support]")
|
||||
{
|
||||
uint32_t image_len = 0;
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, running);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_OK, esp_image_basic_verify(running->address, true, &image_len));
|
||||
TEST_ASSERT_NOT_EQUAL(0, image_len);
|
||||
TEST_ASSERT_TRUE(image_len <= running->size);
|
||||
}
|
||||
|
||||
@@ -1,124 +1,31 @@
|
||||
menuconfig BT_ENABLED
|
||||
bool "Bluetooth"
|
||||
help
|
||||
Select this option to enable Bluetooth and show the submenu with Bluetooth configuration choices.
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
bool "Bluedroid Bluetooth stack enabled"
|
||||
depends on BT_ENABLED
|
||||
default y
|
||||
help
|
||||
This enables the default Bluedroid Bluetooth stack
|
||||
Select this option to enable Bluetooth stack and show the submenu with Bluetooth configuration choices.
|
||||
|
||||
config BTC_TASK_STACK_SIZE
|
||||
int "Bluetooth event (callback to application) task stack size"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 3072
|
||||
help
|
||||
This select btc task stack size
|
||||
int "Bluetooth event (callback to application) task stack size"
|
||||
depends on BT_ENABLED
|
||||
default 3072
|
||||
help
|
||||
This select btc task stack size
|
||||
|
||||
config BLUEDROID_MEM_DEBUG
|
||||
bool "Bluedroid memory debug"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
Bluedroid memory debug
|
||||
|
||||
config CLASSIC_BT_ENABLED
|
||||
bool "Classic Bluetooth"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
For now this option needs "SMP_ENABLE" to be set to yes
|
||||
bool "Bluedroid memory debug"
|
||||
depends on BT_ENABLED
|
||||
default n
|
||||
help
|
||||
Bluedroid memory debug
|
||||
|
||||
config BT_DRAM_RELEASE
|
||||
bool "Release DRAM from Classic BT controller"
|
||||
depends on BT_ENABLED && (!BLUEDROID_ENABLED || (BLUEDROID_ENABLED && !CLASSIC_BT_ENABLED))
|
||||
default n
|
||||
help
|
||||
This option should only be used when BLE only.
|
||||
Enabling this option will release about 30K DRAM from Classic BT.
|
||||
The released DRAM will be used as system heap memory.
|
||||
|
||||
config GATTS_ENABLE
|
||||
bool "Include GATT server module(GATTS)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
This option can be disabled when the app work only on gatt client mode
|
||||
|
||||
config GATTC_ENABLE
|
||||
bool "Include GATT client module(GATTC)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
This option can be close when the app work only on gatt server mode
|
||||
|
||||
config BLE_SMP_ENABLE
|
||||
bool "Include BLE security module(SMP)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
This option can be close when the app not used the ble security connect.
|
||||
|
||||
config BT_STACK_NO_LOG
|
||||
bool "Close the bluedroid bt stack log print"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
This select can save the rodata code size
|
||||
|
||||
config BT_ACL_CONNECTIONS
|
||||
int "BT/BLE MAX ACL CONNECTIONS(1~7)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
range 1 7
|
||||
default 4
|
||||
help
|
||||
Maximum BT/BLE connection count
|
||||
|
||||
#disable now for app cpu due to a known issue
|
||||
config BTDM_CONTROLLER_RUN_APP_CPU
|
||||
bool "Run controller on APP CPU"
|
||||
depends on BT_ENABLED && !FREERTOS_UNICORE && 0
|
||||
default n
|
||||
help
|
||||
Run controller on APP CPU.
|
||||
|
||||
config BTDM_CONTROLLER_RUN_CPU
|
||||
int
|
||||
bool "Release DRAM from Classic BT controller"
|
||||
depends on BT_ENABLED
|
||||
default 1 if BTDM_CONTROLLER_RUN_APP_CPU
|
||||
default 0
|
||||
default n
|
||||
help
|
||||
This option should only be used when BLE only.
|
||||
Open this option will release about 30K DRAM from Classic BT.
|
||||
The released DRAM will be used as system heap memory.
|
||||
|
||||
menuconfig BT_HCI_UART
|
||||
bool "HCI use UART as IO"
|
||||
depends on BT_ENABLED && !BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
Default HCI use VHCI, if this option choose, HCI will use UART(0/1/2) as IO.
|
||||
Besides, it can set uart number and uart baudrate.
|
||||
|
||||
config BT_HCI_UART_NO
|
||||
int "UART Number for HCI"
|
||||
depends on BT_HCI_UART
|
||||
range 1 2
|
||||
default 1
|
||||
help
|
||||
Uart number for HCI.
|
||||
|
||||
config BT_HCI_UART_BAUDRATE
|
||||
int "UART Baudrate for HCI"
|
||||
depends on BT_HCI_UART
|
||||
range 115200 921600
|
||||
default 921600
|
||||
help
|
||||
UART Baudrate for HCI. Please use standard baudrate.
|
||||
|
||||
config SMP_ENABLE
|
||||
bool
|
||||
depends on BLUEDROID_ENABLED
|
||||
default CLASSIC_BT_ENABLED || BLE_SMP_ENABLE
|
||||
|
||||
# Memory reserved at start of DRAM for Bluetooth stack
|
||||
config BT_RESERVE_DRAM
|
||||
hex
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_av.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
esp_err_t esp_a2d_register_callback(esp_a2d_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_A2DP, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_sink_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_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_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_a2d_sink_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_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_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_a2d_register_data_callback(esp_a2d_data_cb_t callback)
|
||||
{
|
||||
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_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_REG_DATA_CB_EVT;
|
||||
|
||||
btc_av_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
arg.data_cb = callback;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_msg_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_sink_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_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_CONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.connect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_sink_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_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_DISCONNECT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
#endif /* #if BTC_AV_INCLUDED */
|
||||
@@ -1,96 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_avrc_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_avrc.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_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_AVRC, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_avrc_ct_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_AVRC;
|
||||
msg.act = BTC_AVRC_CTRL_API_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_avrc_ct_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_AVRC;
|
||||
msg.act = BTC_AVRC_CTRL_API_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_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t key_state)
|
||||
{
|
||||
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_AVRC;
|
||||
msg.act = BTC_AVRC_CTRL_API_SND_PTCMD_EVT;
|
||||
|
||||
btc_avrc_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_avrc_args_t));
|
||||
|
||||
arg.pt_cmd.tl = tl;
|
||||
arg.pt_cmd.key_code = key_code;
|
||||
arg.pt_cmd.key_state = key_state;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_avrc_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
#endif /* #if BTC_AV_INCLUDED */
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "btc_manage.h"
|
||||
#include "btc_main.h"
|
||||
#include "future.h"
|
||||
#include "btc_gatts.h"
|
||||
|
||||
esp_err_t esp_blufi_register_callbacks(esp_blufi_callbacks_t *callbacks)
|
||||
{
|
||||
@@ -93,17 +92,3 @@ uint16_t esp_blufi_get_version(void)
|
||||
return btc_blufi_get_version();
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_close(esp_gatt_if_t gatts_if, uint16_t conn_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_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_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CLOSE;
|
||||
arg.close.conn_id = conn_id;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -12,13 +12,10 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_bt_device.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "controller.h"
|
||||
#include "btc_task.h"
|
||||
#include "btc_dev.h"
|
||||
|
||||
const uint8_t *esp_bt_dev_get_address(void)
|
||||
{
|
||||
@@ -27,24 +24,3 @@ const uint8_t *esp_bt_dev_get_address(void)
|
||||
}
|
||||
return controller_get_interface()->get_address()->address;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_dev_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (strlen(name) > ESP_DEV_DEVICE_NAME_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_DEV;
|
||||
msg.act = BTC_DEV_ACT_SET_DEVICE_NAME;
|
||||
strcpy(arg.set_dev_name.device_name, name);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -60,11 +60,7 @@ esp_err_t esp_bluedroid_enable(void)
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_ENABLE;
|
||||
|
||||
if (btc_transfer_context(&msg, NULL, 0, NULL) != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid enable failed\n");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("Bluedroid enable failed\n");
|
||||
@@ -96,11 +92,7 @@ esp_err_t esp_bluedroid_disable(void)
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_DISABLE;
|
||||
|
||||
if (btc_transfer_context(&msg, NULL, 0, NULL) != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid disable failed\n");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("Bluedroid disable failed\n");
|
||||
@@ -127,10 +119,6 @@ esp_err_t esp_bluedroid_init(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
|
||||
osi_mem_dbg_init();
|
||||
#endif
|
||||
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_INIT_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
@@ -143,11 +131,7 @@ esp_err_t esp_bluedroid_init(void)
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_INIT;
|
||||
|
||||
if (btc_transfer_context(&msg, NULL, 0, NULL) != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid initialise failed\n");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("Bluedroid initialise failed\n");
|
||||
@@ -185,11 +169,7 @@ esp_err_t esp_bluedroid_deinit(void)
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_DEINIT;
|
||||
|
||||
if (btc_transfer_context(&msg, NULL, 0, NULL) != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid de-initialise failed\n");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("Bluedroid de-initialise failed\n");
|
||||
|
||||
@@ -13,20 +13,20 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "esp_bt_device.h"
|
||||
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "bta_api.h"
|
||||
#include "bt_trace.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gap_ble.h"
|
||||
#include "btc_ble_storage.h"
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -36,8 +36,10 @@ 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 (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (adv_data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -61,8 +63,10 @@ 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 (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (scan_params == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -80,7 +84,9 @@ esp_err_t esp_ble_gap_start_scanning(uint32_t duration)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
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_BLE;
|
||||
@@ -95,8 +101,10 @@ esp_err_t esp_ble_gap_stop_scanning(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_STOP_SCAN;
|
||||
@@ -108,8 +116,10 @@ esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_START_ADV;
|
||||
@@ -122,8 +132,10 @@ esp_err_t esp_ble_gap_stop_advertising(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_STOP_ADV;
|
||||
@@ -137,8 +149,10 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
@@ -152,8 +166,10 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN;
|
||||
@@ -169,8 +185,10 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_RAND_ADDRESS;
|
||||
@@ -185,8 +203,10 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
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_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY;
|
||||
@@ -197,9 +217,23 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
|
||||
esp_err_t esp_ble_gap_set_device_name(const char *name)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
return esp_bt_dev_set_device_name(name);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (strlen(name) > ESP_GAP_DEVICE_NAME_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
|
||||
strcpy(arg.set_dev_name.device_name, name);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length)
|
||||
@@ -223,7 +257,9 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (raw_data == NULL
|
||||
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_ADV_DATA_LEN_MAX)) {
|
||||
@@ -245,7 +281,9 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (raw_data == NULL
|
||||
|| (raw_data_len <= 0 || raw_data_len > ESP_BLE_SCAN_RSP_DATA_LEN_MAX)) {
|
||||
@@ -261,154 +299,3 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED)
|
||||
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
|
||||
void *value, uint8_t len)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_SET_SECURITY_PARAM_EVT;
|
||||
arg.set_security_param.param_type = param_type;
|
||||
arg.set_security_param.len = len;
|
||||
arg.set_security_param.value = value;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_set_encryption(esp_bd_addr_t bd_addr, esp_ble_sec_act_t sec_act)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_SET_ENCRYPTION_EVT;
|
||||
arg.set_encryption.sec_act = sec_act;
|
||||
memcpy(arg.set_encryption.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_security_rsp(esp_bd_addr_t bd_addr, bool accept)
|
||||
{
|
||||
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_SECURITY_RSP_EVT;
|
||||
arg.sec_rsp.accept = accept;
|
||||
memcpy(arg.sec_rsp.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t passkey)
|
||||
{
|
||||
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_PASSKEY_REPLY_EVT;
|
||||
arg.enc_passkey_replay.accept = accept;
|
||||
arg.enc_passkey_replay.passkey = passkey;
|
||||
memcpy(arg.enc_passkey_replay.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
|
||||
{
|
||||
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_CONFIRM_REPLY_EVT;
|
||||
arg.enc_comfirm_replay.accept = accept;
|
||||
memcpy(arg.enc_comfirm_replay.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_REMOVE_BOND_DEV_EVT;
|
||||
memcpy(arg.remove_bond_device.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
int esp_ble_get_bond_device_num(void)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
return btc_storage_get_num_ble_bond_devices();
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_get_bond_device_list(int *dev_num, esp_ble_bond_dev_t *dev_list)
|
||||
{
|
||||
int ret;
|
||||
int dev_num_total;
|
||||
|
||||
if (dev_num == NULL || dev_list == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
dev_num_total = btc_storage_get_num_ble_bond_devices();
|
||||
if (*dev_num > dev_num_total) {
|
||||
*dev_num = dev_num_total;
|
||||
}
|
||||
|
||||
ret = btc_storage_get_bonded_ble_devices_list(dev_list, *dev_num);
|
||||
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* #if (SMP_INCLUDED) */
|
||||
|
||||
esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device)
|
||||
{
|
||||
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_DISCONNECT_EVT;
|
||||
memcpy(arg.disconnect.remote_device, remote_device, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "bt_trace.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gap_bt.h"
|
||||
|
||||
#if BTC_GAP_BT_INCLUDED
|
||||
|
||||
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode)
|
||||
{
|
||||
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_SET_SCAN_MODE;
|
||||
arg.set_scan_mode.mode = mode;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED */
|
||||
@@ -20,10 +20,11 @@
|
||||
#include "btc_gattc.h"
|
||||
#include "btc_gatt_util.h"
|
||||
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
@@ -38,7 +39,9 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (app_id > ESP_APP_ID_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
@@ -57,7 +60,9 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -72,7 +77,9 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, b
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -89,7 +96,9 @@ esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -104,7 +113,9 @@ esp_err_t esp_ble_gattc_config_mtu (esp_gatt_if_t gattc_if, uint16_t conn_id, ui
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
|
||||
return ESP_GATT_ILLEGAL_PARAMETER;
|
||||
@@ -124,7 +135,9 @@ esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -149,7 +162,9 @@ esp_err_t esp_ble_gattc_get_characteristic(esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -176,7 +191,9 @@ esp_err_t esp_ble_gattc_get_descriptor(esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -205,7 +222,9 @@ esp_err_t esp_ble_gattc_get_included_service(esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -233,7 +252,9 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -256,7 +277,9 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -282,7 +305,9 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -298,21 +323,23 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_WRITE_CHAR_DESCR;
|
||||
@@ -337,11 +364,14 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
//TODO: Review this function
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_PREPARE_WRITE;
|
||||
@@ -356,42 +386,14 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR;
|
||||
arg.prep_write_descr.conn_id = BTC_GATT_CREATE_CONN_ID(gattc_if, conn_id);
|
||||
memcpy(&arg.prep_write_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.prep_write_descr.char_id, char_id, sizeof(esp_gatt_id_t));
|
||||
memcpy(&arg.prep_write_descr.descr_id, descr_id, sizeof(esp_gatt_id_t));
|
||||
arg.prep_write_descr.offset = offset;
|
||||
arg.prep_write_descr.value_len = value_len > ESP_GATT_MAX_ATTR_LEN ? ESP_GATT_MAX_ATTR_LEN : value_len; // length check ?
|
||||
arg.prep_write_descr.value = value;
|
||||
arg.prep_write_descr.auth_req = auth_req;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id, bool is_execute)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -402,7 +404,7 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id)
|
||||
@@ -410,7 +412,9 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -423,7 +427,7 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id)
|
||||
@@ -431,7 +435,9 @@ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -444,20 +450,3 @@ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_CACHE_REFRESH;
|
||||
memcpy(arg.cache_refresh.remote_bda, remote_bda, sizeof(esp_bd_addr_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif ///GATTC_INCLUDED == TRUE
|
||||
|
||||
|
||||
@@ -19,17 +19,15 @@
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gatts.h"
|
||||
#include "btc_gatt_util.h"
|
||||
#include "bt_target.h"
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
#define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type))
|
||||
|
||||
static esp_err_t esp_ble_gatts_add_char_desc_param_check(esp_attr_value_t *char_val, esp_attr_control_t *control);
|
||||
#define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type))
|
||||
|
||||
|
||||
esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
return (btc_profile_cb_set(BTC_PID_GATTS, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -38,7 +36,9 @@ esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
//if (app_id < ESP_APP_ID_MIN || app_id > ESP_APP_ID_MAX) {
|
||||
if (app_id > ESP_APP_ID_MAX) {
|
||||
@@ -59,7 +59,9 @@ esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -75,7 +77,9 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -95,8 +99,6 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CREATE_ATTR_TAB;
|
||||
@@ -115,7 +117,9 @@ esp_err_t esp_ble_gatts_add_included_service(uint16_t service_handle, uint16_t i
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -133,14 +137,30 @@ esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
esp_err_t status;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* parameter validation check */
|
||||
status = esp_ble_gatts_add_char_desc_param_check(char_val, control);
|
||||
if (status != ESP_OK){
|
||||
return status;
|
||||
if ((control != NULL) && (control->auto_rsp == GATT_STACK_RSP)){
|
||||
if (char_val == NULL){
|
||||
LOG_ERROR("Error in %s, line=%d, for stack respond attribute, char_val should not be NULL here\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
} else if (char_val->attr_max_len == 0){
|
||||
LOG_ERROR("Error in %s, line=%d, for stack respond attribute, attribute max length should not be 0\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
if (char_val != NULL){
|
||||
if (char_val->attr_len > char_val->attr_max_len){
|
||||
LOG_ERROR("Error in %s, line=%d,attribute actual length (%d) should not be larger than max length (%d)\n",\
|
||||
__func__, __LINE__, char_val->attr_len, char_val->attr_max_len);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&arg, 0, sizeof(btc_ble_gatts_args_t));
|
||||
@@ -172,15 +192,33 @@ esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
esp_err_t status;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
/* parameter validation check */
|
||||
status = esp_ble_gatts_add_char_desc_param_check(char_descr_val, control);
|
||||
if (status != ESP_OK){
|
||||
return status;
|
||||
if ((control != NULL) && (control->auto_rsp == GATT_STACK_RSP)){
|
||||
if (char_descr_val == NULL){
|
||||
LOG_ERROR("Error in %s, line=%d, for stack respond attribute, char_descr_val should not be NULL here\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
else if (char_descr_val->attr_max_len == 0){
|
||||
LOG_ERROR("Error in %s, line=%d, for stack respond attribute, attribute max length should not be 0\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
if (char_descr_val != NULL){
|
||||
if (char_descr_val->attr_len > char_descr_val->attr_max_len){
|
||||
LOG_ERROR("Error in %s, line=%d,attribute actual length (%d) should not be larger than max length (%d)\n",\
|
||||
__func__, __LINE__, char_descr_val->attr_len, char_descr_val->attr_max_len);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
memset(&arg, 0, sizeof(btc_ble_gatts_args_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -208,7 +246,9 @@ esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -223,7 +263,9 @@ esp_err_t esp_ble_gatts_start_service(uint16_t service_handle)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -238,7 +280,9 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -255,7 +299,9 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -276,7 +322,9 @@ esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -295,12 +343,9 @@ esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, co
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_SET_ATTR_VALUE;
|
||||
arg.set_attr_val.handle = attr_handle;
|
||||
arg.set_attr_val.length = length;
|
||||
arg.set_attr_val.value = (uint8_t *)value;
|
||||
|
||||
@@ -308,15 +353,13 @@ esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, co
|
||||
btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value)
|
||||
esp_err_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (attr_handle == ESP_GATT_ILLEGAL_HANDLE) {
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return btc_gatts_get_attr_value(attr_handle, length, (uint8_t **)value);
|
||||
btc_gatts_get_attr_value(attr_handle, length, (uint8_t **)value);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, bool is_direct)
|
||||
@@ -324,7 +367,9 @@ esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, b
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -342,7 +387,9 @@ esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id)
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -352,29 +399,3 @@ esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t esp_ble_gatts_add_char_desc_param_check(esp_attr_value_t *char_val, esp_attr_control_t *control)
|
||||
{
|
||||
if ((control != NULL) && ((control->auto_rsp != ESP_GATT_AUTO_RSP) && (control->auto_rsp != ESP_GATT_RSP_BY_APP))){
|
||||
LOG_ERROR("Error in %s, line=%d, control->auto_rsp should be set to ESP_GATT_AUTO_RSP or ESP_GATT_RSP_BY_APP\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if ((control != NULL) && (control->auto_rsp == ESP_GATT_AUTO_RSP)){
|
||||
if (char_val == NULL){
|
||||
LOG_ERROR("Error in %s, line=%d, for stack respond attribute, char_val should not be NULL here\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
} else if (char_val->attr_max_len == 0){
|
||||
LOG_ERROR("Error in %s, line=%d, for stack respond attribute, attribute max length should not be 0\n",\
|
||||
__func__, __LINE__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif ///GATTS_INCLUDED
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_A2DP_API_H__
|
||||
#define __ESP_A2DP_API_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// Media codec types supported by A2DP
|
||||
#define ESP_A2D_MCT_SBC (0) /*!< SBC */
|
||||
#define ESP_A2D_MCT_M12 (0x01) /*!< MPEG-1, 2 Audio */
|
||||
#define ESP_A2D_MCT_M24 (0x02) /*!< MPEG-2, 4 AAC */
|
||||
#define ESP_A2D_MCT_ATRAC (0x04) /*!< ATRAC family */
|
||||
#define ESP_A2D_MCT_NON_A2DP (0xff)
|
||||
|
||||
typedef uint8_t esp_a2d_mct_t;
|
||||
|
||||
/// A2DP media codec capabilities union
|
||||
typedef struct {
|
||||
esp_a2d_mct_t type; /*!< A2DP media codec type */
|
||||
#define ESP_A2D_CIE_LEN_SBC (4)
|
||||
#define ESP_A2D_CIE_LEN_M12 (4)
|
||||
#define ESP_A2D_CIE_LEN_M24 (6)
|
||||
#define ESP_A2D_CIE_LEN_ATRAC (7)
|
||||
union {
|
||||
uint8_t sbc[ESP_A2D_CIE_LEN_SBC];
|
||||
uint8_t m12[ESP_A2D_CIE_LEN_M12];
|
||||
uint8_t m24[ESP_A2D_CIE_LEN_M24];
|
||||
uint8_t atrac[ESP_A2D_CIE_LEN_ATRAC];
|
||||
} cie; /*!< A2DP codec information element */
|
||||
} __attribute__((packed)) esp_a2d_mcc_t;
|
||||
|
||||
/// Bluetooth A2DP connection states
|
||||
typedef enum {
|
||||
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0, /*!< connection released */
|
||||
ESP_A2D_CONNECTION_STATE_CONNECTING, /*!< connecting remote device */
|
||||
ESP_A2D_CONNECTION_STATE_CONNECTED, /*!< connection established */
|
||||
ESP_A2D_CONNECTION_STATE_DISCONNECTING /*!< disconnecting remote device */
|
||||
} esp_a2d_connection_state_t;
|
||||
|
||||
/// Bluetooth A2DP disconnection reason
|
||||
typedef enum {
|
||||
ESP_A2D_DISC_RSN_NORMAL = 0, /*!< Finished disconnection that is initiated by local or remote device */
|
||||
ESP_A2D_DISC_RSN_ABNORMAL /*!< Abnormal disconnection caused by signal loss */
|
||||
} esp_a2d_disc_rsn_t;
|
||||
|
||||
/// Bluetooth A2DP datapath states
|
||||
typedef enum {
|
||||
ESP_A2D_AUDIO_STATE_REMOTE_SUSPEND = 0, /*!< audio stream datapath suspended by remote device */
|
||||
ESP_A2D_AUDIO_STATE_STOPPED, /*!< audio stream datapath stopped */
|
||||
ESP_A2D_AUDIO_STATE_STARTED, /*!< audio stream datapath started */
|
||||
} esp_a2d_audio_state_t;
|
||||
|
||||
/// A2DP callback events
|
||||
typedef enum {
|
||||
ESP_A2D_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_A2D_AUDIO_STATE_EVT = 1, /*!< audio stream transmission state changed event */
|
||||
ESP_A2D_AUDIO_CFG_EVT = 2 /*!< audio codec is configured */
|
||||
} esp_a2d_cb_event_t;
|
||||
|
||||
/// A2DP state callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_A2D_CONNECTION_STATE_EVT
|
||||
*/
|
||||
struct a2d_conn_stat_param {
|
||||
esp_a2d_connection_state_t state; /*!< one of values from esp_a2d_connection_state_t */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
esp_a2d_disc_rsn_t disc_rsn; /*!< reason of disconnection for "DISCONNECTED" */
|
||||
} conn_stat; /*!< A2DP connection status */
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_AUDIO_STATE_EVT
|
||||
*/
|
||||
struct a2d_audio_stat_param {
|
||||
esp_a2d_audio_state_t state; /*!< one of the values from esp_a2d_audio_state_t */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} audio_stat; /*!< audio stream playing state */
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_AUDIO_CFG_EVT
|
||||
*/
|
||||
struct a2d_audio_cfg_param {
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
esp_a2d_mcc_t mcc; /*!< A2DP media codec capability information */
|
||||
} audio_cfg; /*!< media codec configuration infomation */
|
||||
} esp_a2d_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief A2DP profile callback function type
|
||||
* @param event : Event type
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief A2DP profile data callback function
|
||||
*
|
||||
* @param[in] buf : data received from A2DP source device and is PCM format decoder from SBC decoder;
|
||||
* buf references to a static memory block and can be overwritten by upcoming data
|
||||
*
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*
|
||||
*/
|
||||
typedef void (* esp_a2d_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to A2DP module. This function should be called
|
||||
* only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @param[in] callback: A2DP sink 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_a2d_register_callback(esp_a2d_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register A2DP sink data output function; For now the output is PCM data stream decoded
|
||||
* from SBC format. This function should be called only after esp_bluedroid_enable()
|
||||
* completes successfully
|
||||
*
|
||||
* @param[in] callback: A2DP 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_a2d_register_data_callback(esp_a2d_data_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth A2DP sink 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_a2d_sink_init(void);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for A2DP sink 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_a2d_sink_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect the remote bluetooth device bluetooth, must after esp_a2d_sink_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_a2d_sink_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect the remote bluetooth device
|
||||
*
|
||||
* @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_a2d_sink_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_A2DP_API_H__ */
|
||||
@@ -1,153 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_AVRC_API_H__
|
||||
#define __ESP_AVRC_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// AVRC feature bit mask
|
||||
typedef enum {
|
||||
ESP_AVRC_FEAT_RCTG = 0x0001, /*!< remote control target */
|
||||
ESP_AVRC_FEAT_RCCT = 0x0002, /*!< remote control controller */
|
||||
ESP_AVRC_FEAT_VENDOR = 0x0008, /*!< remote control vendor dependent commands */
|
||||
ESP_AVRC_FEAT_BROWSE = 0x0010, /*!< use browsing channel */
|
||||
ESP_AVRC_FEAT_META_DATA = 0x0040, /*!< remote control metadata transfer command/response */
|
||||
ESP_AVRC_FEAT_ADV_CTRL = 0x0200, /*!< remote control advanced control commmand/response */
|
||||
} esp_avrc_features_t;
|
||||
|
||||
/// AVRC passthrough command code
|
||||
typedef enum {
|
||||
ESP_AVRC_PT_CMD_PLAY = 0x44, /*!< play */
|
||||
ESP_AVRC_PT_CMD_STOP = 0x45, /*!< stop */
|
||||
ESP_AVRC_PT_CMD_PAUSE = 0x46, /*!< pause */
|
||||
ESP_AVRC_PT_CMD_FORWARD = 0x4B, /*!< forward */
|
||||
ESP_AVRC_PT_CMD_BACKWARD = 0x4C /*!< backward */
|
||||
} esp_avrc_pt_cmd_t;
|
||||
|
||||
/// AVRC passthrough command state
|
||||
typedef enum {
|
||||
ESP_AVRC_PT_CMD_STATE_PRESSED = 0, /*!< key pressed */
|
||||
ESP_AVRC_PT_CMD_STATE_RELEASED = 1 /*!< key released */
|
||||
} esp_avrc_pt_cmd_state_t;
|
||||
|
||||
/// AVRC Controller callback events
|
||||
typedef enum {
|
||||
ESP_AVRC_CT_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_AVRC_CT_PASSTHROUGH_RSP_EVT = 1, /*!< passthrough response event */
|
||||
ESP_AVRC_CT_MAX_EVT
|
||||
} esp_avrc_ct_cb_event_t;
|
||||
|
||||
/// AVRC controller callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_AVRC_CT_CONNECTION_STATE_EVT
|
||||
*/
|
||||
struct avrc_ct_conn_stat_param {
|
||||
bool connected; /*!< whether AVRC connection is set up */
|
||||
uint32_t feat_mask; /*!< AVRC feature mask of remote device */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} conn_stat; /*!< AVRC connection status */
|
||||
|
||||
/**
|
||||
* @brief ESP_AVRC_CT_PASSTHROUGH_RSP_EVT
|
||||
*/
|
||||
struct avrc_ct_psth_rsp_param {
|
||||
uint8_t tl; /*!< transaction label, 0 to 15 */
|
||||
uint8_t key_code; /*!< passthrough command code */
|
||||
uint8_t key_state; /*!< 0 for PRESSED, 1 for RELEASED */
|
||||
} psth_rsp; /*!< passthrough command response */
|
||||
} esp_avrc_ct_cb_param_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief AVRCP controller callback function type
|
||||
* @param event : Event type
|
||||
* @param param : Pointer to callback parameter union
|
||||
*/
|
||||
typedef void (* esp_avrc_ct_cb_t)(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *param);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register application callbacks to AVRCP module; for now only AVRCP Controller
|
||||
* role is supported. This function should be called after esp_bluedroid_enable()
|
||||
* completes successfully
|
||||
*
|
||||
* @param[in] callback: AVRCP controller callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth AVRCP controller module, This function should be called
|
||||
* 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_avrc_ct_init(void);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize AVRCP controller module. This function should be called after
|
||||
* 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_avrc_ct_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send passthrough command to AVRCP target, This function should be called after
|
||||
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
|
||||
*
|
||||
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
|
||||
* @param[in] key_code : passthrough command code, e.g. ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STOP, etc.
|
||||
* @param[in] key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or
|
||||
* ESP_AVRC_PT_CMD_STATE_PRESSED
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t key_state);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_AVRC_API_H__ */
|
||||
@@ -49,7 +49,6 @@ typedef enum {
|
||||
ESP_BLUFI_EVENT_RECV_SERVER_CERT, /*<! When Phone send Server certificate to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY, /*<! When Phone send Client Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY, /*<! When Phone send Server Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE, /*<! When Phone send Disconnect key to ESP32, this event happen */
|
||||
} esp_blufi_cb_event_t;
|
||||
|
||||
/// BLUFI config status
|
||||
@@ -123,8 +122,6 @@ typedef union {
|
||||
*/
|
||||
struct blufi_connect_evt_param {
|
||||
esp_bd_addr_t remote_bda; /*!< Blufi Remote bluetooth device address */
|
||||
uint8_t server_if; /*!< server interface */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} connect; /*!< Blufi callback param of ESP_BLUFI_EVENT_CONNECT */
|
||||
|
||||
/**
|
||||
@@ -356,18 +353,6 @@ esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn
|
||||
*/
|
||||
uint16_t esp_blufi_get_version(void);
|
||||
|
||||
/**
|
||||
* @brief Close a connection a remote device.
|
||||
*
|
||||
* @param[in] gatts_if: GATT server access interface
|
||||
* @param[in] conn_id: connection ID to be closed.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_close(esp_gatt_if_t gatts_if, uint16_t conn_id);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,47 +22,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BLUEDROID_STATUS_CHECK(status) \
|
||||
if (esp_bluedroid_get_status() != (status)) { \
|
||||
return ESP_ERR_INVALID_STATE; \
|
||||
}
|
||||
|
||||
|
||||
/* relate to BT_STATUS_xxx in bt_def.h */
|
||||
/// Status Return Value
|
||||
typedef enum {
|
||||
ESP_BT_STATUS_SUCCESS = 0, /* relate to BT_STATUS_SUCCESS in bt_def.h */
|
||||
ESP_BT_STATUS_FAIL, /* relate to BT_STATUS_FAIL in bt_def.h */
|
||||
ESP_BT_STATUS_NOT_READY, /* relate to BT_STATUS_NOT_READY in bt_def.h */
|
||||
ESP_BT_STATUS_NOMEM, /* relate to BT_STATUS_NOMEM in bt_def.h */
|
||||
ESP_BT_STATUS_BUSY, /* relate to BT_STATUS_BUSY in bt_def.h */
|
||||
ESP_BT_STATUS_DONE = 5, /* relate to BT_STATUS_DONE in bt_def.h */
|
||||
ESP_BT_STATUS_UNSUPPORTED, /* relate to BT_STATUS_UNSUPPORTED in bt_def.h */
|
||||
ESP_BT_STATUS_PARM_INVALID, /* relate to BT_STATUS_PARM_INVALID in bt_def.h */
|
||||
ESP_BT_STATUS_UNHANDLED, /* relate to BT_STATUS_UNHANDLED in bt_def.h */
|
||||
ESP_BT_STATUS_AUTH_FAILURE, /* relate to BT_STATUS_AUTH_FAILURE in bt_def.h */
|
||||
ESP_BT_STATUS_RMT_DEV_DOWN = 10, /* relate to BT_STATUS_RMT_DEV_DOWN in bt_def.h */
|
||||
ESP_BT_STATUS_AUTH_REJECTED, /* relate to BT_STATUS_AUTH_REJECTED in bt_def.h */
|
||||
ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR, /* relate to BT_STATUS_INVALID_STATIC_RAND_ADDR in bt_def.h */
|
||||
ESP_BT_STATUS_PENDING, /* relate to BT_STATUS_PENDING in bt_def.h */
|
||||
ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL, /* relate to BT_UNACCEPT_CONN_INTERVAL in bt_def.h */
|
||||
ESP_BT_STATUS_PARAM_OUT_OF_RANGE, /* relate to BT_PARAM_OUT_OF_RANGE in bt_def.h */
|
||||
ESP_BT_STATUS_TIMEOUT, /* relate to BT_STATUS_TIMEOUT in bt_def.h */
|
||||
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
||||
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
||||
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in hcidefs.h */
|
||||
ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
|
||||
ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
|
||||
ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
|
||||
ESP_BT_STATUS_BUSY = 3,
|
||||
ESP_BT_STATUS_NO_RESOURCES = 4,
|
||||
ESP_BT_STATUS_WRONG_MODE = 5,
|
||||
} esp_bt_status_t;
|
||||
|
||||
|
||||
/*Define the bt octet 16 bit size*/
|
||||
#define ESP_BT_OCTET16_LEN 16
|
||||
typedef uint8_t esp_bt_octet16_t[ESP_BT_OCTET16_LEN]; /* octet array: size 16 */
|
||||
|
||||
#define ESP_BT_OCTET8_LEN 8
|
||||
typedef uint8_t esp_bt_octet8_t[ESP_BT_OCTET8_LEN]; /* octet array: size 8 */
|
||||
|
||||
typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
|
||||
|
||||
/// Default GATT interface id
|
||||
#define ESP_DEFAULT_GATT_IF 0xff
|
||||
|
||||
@@ -98,6 +67,22 @@ typedef enum {
|
||||
/// Bluetooth device address
|
||||
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN];
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
BD_ADDR_PUBLIC,
|
||||
/// Provided random address
|
||||
BD_ADDR_PROVIDED_RND,
|
||||
/// Provided static random address
|
||||
BD_ADDR_GEN_STATIC_RND,
|
||||
/// Generated resolvable private random address
|
||||
BD_ADDR_GEN_RSLV,
|
||||
/// Generated non-resolvable private random address
|
||||
BD_ADDR_GEN_NON_RSLV,
|
||||
/// Provided Reconnection address
|
||||
BD_ADDR_PROVIDED_RECON,
|
||||
} esp_bd_addr_type_t;
|
||||
|
||||
/// BLE device address type
|
||||
typedef enum {
|
||||
BLE_ADDR_TYPE_PUBLIC = 0x00,
|
||||
@@ -106,16 +91,6 @@ typedef enum {
|
||||
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
|
||||
} esp_ble_addr_type_t;
|
||||
|
||||
/// Used to exchange the encrytyption key in the init key & response key
|
||||
#define ESP_BLE_ENC_KEY_MASK (1 << 0) /* relate to BTM_BLE_ENC_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the IRK key in the init key & response key
|
||||
#define ESP_BLE_ID_KEY_MASK (1 << 1) /* relate to BTM_BLE_ID_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the CSRK key in the init key & response key
|
||||
#define ESP_BLE_CSR_KEY_MASK (1 << 2) /* relate to BTM_BLE_CSR_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the link key(this key just used in the BLE & BR/EDR coexist mode) in the init key & response key
|
||||
#define ESP_BLE_LINK_KEY_MASK (1 << 3) /* relate to BTM_BLE_LINK_KEY_MASK in btm_api.h */
|
||||
typedef uint8_t esp_ble_key_mask_t; /* the key mask type */
|
||||
|
||||
/// Minimum of the application id
|
||||
#define ESP_APP_ID_MIN 0x0000
|
||||
/// Maximum of the application id
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -32,21 +30,6 @@ extern "C" {
|
||||
*/
|
||||
const uint8_t *esp_bt_dev_get_address(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set bluetooth device name. This function should be called after esp_bluedroid_enable()
|
||||
* completes successfully
|
||||
*
|
||||
* @param[in] name : device name to be set
|
||||
*
|
||||
* @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_FAIL : others
|
||||
*/
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,37 +38,6 @@ extern "C" {
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* relate to BTM_LE_KEY_xxx in btm_api.h */
|
||||
#define ESP_LE_KEY_NONE 0 /* relate to BTM_LE_KEY_NONE in btm_api.h */
|
||||
#define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */ /* relate to BTM_LE_KEY_PENC in btm_api.h */
|
||||
#define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */ /* relate to BTM_LE_KEY_PID in btm_api.h */
|
||||
#define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */ /* relate to BTM_LE_KEY_PCSRK in btm_api.h */
|
||||
#define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/ /* relate to BTM_LE_KEY_PLK in btm_api.h */
|
||||
#define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4) /* relate to BTM_LE_KEY_LLK in btm_api.h */
|
||||
#define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */ /* relate to BTM_LE_KEY_LENC in btm_api.h */
|
||||
#define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */ /* relate to BTM_LE_KEY_LID in btm_api.h */
|
||||
#define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */ /* relate to BTM_LE_KEY_LCSRK in btm_api.h */
|
||||
typedef uint8_t esp_ble_key_type_t;
|
||||
|
||||
/* relate to BTM_LE_AUTH_xxx in btm_api.h */
|
||||
#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/ /* relate to BTM_LE_AUTH_NO_BOND in btm_api.h */
|
||||
#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */ /* relate to BTM_LE_AUTH_BOND in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */ /* relate to BTM_LE_AUTH_REQ_MITM in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */ /* relate to BTM_LE_AUTH_REQ_SC_ONLY in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */ /* relate to BTM_LE_AUTH_REQ_SC_BOND in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM_BOND in btm_api.h */
|
||||
typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */
|
||||
|
||||
/* relate to BTM_IO_CAP_xxx in btm_api.h */
|
||||
#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ /* relate to BTM_IO_CAP_OUT in btm_api.h */
|
||||
#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ /* relate to BTM_IO_CAP_IO in btm_api.h */
|
||||
#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */ /* relate to BTM_IO_CAP_IN in btm_api.h */
|
||||
#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */ /* relate to BTM_IO_CAP_NONE in btm_api.h */
|
||||
#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ /* relate to BTM_IO_CAP_KBDISP in btm_api.h */
|
||||
typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */
|
||||
|
||||
|
||||
/// GAP BLE callback event type
|
||||
typedef enum {
|
||||
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT = 0, /*!< When advertising data set complete, the event comes */
|
||||
@@ -79,23 +48,6 @@ typedef enum {
|
||||
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
|
||||
ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When start advertising complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When start scan complete, the event comes */
|
||||
ESP_GAP_BLE_AUTH_CMPL_EVT, /* Authentication complete indication. */
|
||||
ESP_GAP_BLE_KEY_EVT, /* BLE key event for peer device keys */
|
||||
ESP_GAP_BLE_SEC_REQ_EVT, /* BLE security request */
|
||||
ESP_GAP_BLE_PASSKEY_NOTIF_EVT, /* passkey notification event */
|
||||
ESP_GAP_BLE_PASSKEY_REQ_EVT, /* passkey request event */
|
||||
ESP_GAP_BLE_OOB_REQ_EVT, /* OOB request event */
|
||||
ESP_GAP_BLE_LOCAL_IR_EVT, /* BLE local IR event */
|
||||
ESP_GAP_BLE_LOCAL_ER_EVT, /* BLE local ER event */
|
||||
ESP_GAP_BLE_NC_REQ_EVT, /* Numeric Comparison request event */
|
||||
ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */
|
||||
ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT, /*!< When stop scan complete, the event comes */
|
||||
ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT, /*!< When set the static rand address complete, the event comes */
|
||||
ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT, /*!< When update connection parameters complete, the event comes */
|
||||
ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT, /*!< When set pkt lenght complete, the event comes */
|
||||
ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT, /*!< When Enable/disable privacy on the local device complete, the event comes */
|
||||
ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< When remove the bond device complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX,
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
/// Advertising data maximum length
|
||||
@@ -103,45 +55,33 @@ typedef enum {
|
||||
/// Scan response data maximum length
|
||||
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
|
||||
|
||||
/* relate to BTM_BLE_AD_TYPE_xxx in btm_ble_api.h */
|
||||
/// The type of advertising data(not adv_type)
|
||||
typedef enum {
|
||||
ESP_BLE_AD_TYPE_FLAG = 0x01, /* relate to BTM_BLE_AD_TYPE_FLAG in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_16SRV_PART = 0x02, /* relate to BTM_BLE_AD_TYPE_16SRV_PART in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03, /* relate to BTM_BLE_AD_TYPE_16SRV_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SRV_PART = 0x04, /* relate to BTM_BLE_AD_TYPE_32SRV_PART in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05, /* relate to BTM_BLE_AD_TYPE_32SRV_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SRV_PART = 0x06, /* relate to BTM_BLE_AD_TYPE_128SRV_PART in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07, /* relate to BTM_BLE_AD_TYPE_128SRV_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_NAME_SHORT = 0x08, /* relate to BTM_BLE_AD_TYPE_NAME_SHORT in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_NAME_CMPL = 0x09, /* relate to BTM_BLE_AD_TYPE_NAME_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_TX_PWR = 0x0A, /* relate to BTM_BLE_AD_TYPE_TX_PWR in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D, /* relate to BTM_BLE_AD_TYPE_DEV_CLASS in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SM_TK = 0x10, /* relate to BTM_BLE_AD_TYPE_SM_TK in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11, /* relate to BTM_BLE_AD_TYPE_SM_OOB_FLAG in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_INT_RANGE = 0x12, /* relate to BTM_BLE_AD_TYPE_INT_RANGE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14, /* relate to BTM_BLE_AD_TYPE_SOL_SRV_UUID in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15, /* relate to BTM_BLE_AD_TYPE_128SOL_SRV_UUID in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16, /* relate to BTM_BLE_AD_TYPE_SERVICE_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17, /* relate to BTM_BLE_AD_TYPE_PUBLIC_TARGET in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18, /* relate to BTM_BLE_AD_TYPE_RANDOM_TARGET in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_APPEARANCE = 0x19, /* relate to BTM_BLE_AD_TYPE_APPEARANCE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_ADV_INT = 0x1A, /* relate to BTM_BLE_AD_TYPE_ADV_INT in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_DEV_ADDR = 0x1b, /* relate to BTM_BLE_AD_TYPE_LE_DEV_ADDR in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_ROLE = 0x1c, /* relate to BTM_BLE_AD_TYPE_LE_ROLE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SPAIR_C256 = 0x1d, /* relate to BTM_BLE_AD_TYPE_SPAIR_C256 in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SPAIR_R256 = 0x1e, /* relate to BTM_BLE_AD_TYPE_SPAIR_R256 in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1f, /* relate to BTM_BLE_AD_TYPE_32SOL_SRV_UUID in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x20, /* relate to BTM_BLE_AD_TYPE_32SERVICE_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x21, /* relate to BTM_BLE_AD_TYPE_128SERVICE_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SECURE_CONFIRM = 0x22, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SECURE_RANDOM = 0x23, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_RANDOM in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_URI = 0x24, /* relate to BTM_BLE_AD_TYPE_URI in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_INDOOR_POSITION = 0x25, /* relate to BTM_BLE_AD_TYPE_INDOOR_POSITION in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_TRANS_DISC_DATA = 0x26, /* relate to BTM_BLE_AD_TYPE_TRANS_DISC_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SUPPORT_FEATURE = 0x27, /* relate to BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_CHAN_MAP_UPDATE = 0x28, /* relate to BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE in btm_ble_api.h */
|
||||
ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF, /* relate to BTM_BLE_AD_MANUFACTURER_SPECIFIC_TYPE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_FLAG = 0x01,
|
||||
ESP_BLE_AD_TYPE_16SRV_PART = 0x02,
|
||||
ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03,
|
||||
ESP_BLE_AD_TYPE_32SRV_PART = 0x04,
|
||||
ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05,
|
||||
ESP_BLE_AD_TYPE_128SRV_PART = 0x06,
|
||||
ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07,
|
||||
ESP_BLE_AD_TYPE_NAME_SHORT = 0x08,
|
||||
ESP_BLE_AD_TYPE_NAME_CMPL = 0x09,
|
||||
ESP_BLE_AD_TYPE_TX_PWR = 0x0A,
|
||||
ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D,
|
||||
ESP_BLE_AD_TYPE_SM_TK = 0x10,
|
||||
ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11,
|
||||
ESP_BLE_AD_TYPE_INT_RANGE = 0x12,
|
||||
ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14,
|
||||
ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15,
|
||||
ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16,
|
||||
ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17,
|
||||
ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18,
|
||||
ESP_BLE_AD_TYPE_APPEARANCE = 0x19,
|
||||
ESP_BLE_AD_TYPE_ADV_INT = 0x1A,
|
||||
ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1B,
|
||||
ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x1C,
|
||||
ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x1D,
|
||||
ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF,
|
||||
} esp_ble_adv_data_type;
|
||||
|
||||
/// Advertising mode
|
||||
@@ -173,24 +113,6 @@ typedef enum {
|
||||
///Enumeration end value for advertising filter policy value check
|
||||
} esp_ble_adv_filter_t;
|
||||
|
||||
|
||||
/* relate to BTA_DM_BLE_SEC_xxx in bta_api.h */
|
||||
typedef enum {
|
||||
ESP_BLE_SEC_NONE = 0, /* relate to BTA_DM_BLE_SEC_NONE in bta_api.h */
|
||||
ESP_BLE_SEC_ENCRYPT, /* relate to BTA_DM_BLE_SEC_ENCRYPT in bta_api.h */
|
||||
ESP_BLE_SEC_ENCRYPT_NO_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_NO_MITM in bta_api.h */
|
||||
ESP_BLE_SEC_ENCRYPT_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_MITM in bta_api.h */
|
||||
}esp_ble_sec_act_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLE_SM_PASSKEY = 0,
|
||||
ESP_BLE_SM_AUTHEN_REQ_MODE,
|
||||
ESP_BLE_SM_IOCAP_MODE,
|
||||
ESP_BLE_SM_SET_INIT_KEY,
|
||||
ESP_BLE_SM_SET_RSP_KEY,
|
||||
ESP_BLE_SM_MAX_KEY_SIZE,
|
||||
} esp_ble_sm_param_t;
|
||||
|
||||
/// Advertising parameters
|
||||
typedef struct {
|
||||
uint16_t adv_int_min; /*!< Minimum advertising interval for
|
||||
@@ -226,6 +148,22 @@ typedef struct {
|
||||
uint8_t flag; /*!< Advertising flag of discovery mode, see BLE_ADV_DATA_FLAG detail */
|
||||
} esp_ble_adv_data_t;
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
ESP_PUBLIC_ADDR,
|
||||
/// Provided random address
|
||||
ESP_PROVIDED_RND_ADDR,
|
||||
/// Provided static random address
|
||||
ESP_GEN_STATIC_RND_ADDR,
|
||||
/// Generated resolvable private random address
|
||||
ESP_GEN_RSLV_ADDR,
|
||||
/// Generated non-resolvable private random address
|
||||
ESP_GEN_NON_RSLV_ADDR,
|
||||
/// Provided Reconnection address
|
||||
ESP_PROVIDED_RECON_ADDR,
|
||||
} esp_ble_own_addr_src_t;
|
||||
|
||||
/// Ble scan type
|
||||
typedef enum {
|
||||
BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */
|
||||
@@ -277,166 +215,6 @@ typedef struct {
|
||||
Time Range: 100 msec to 32 seconds */
|
||||
} esp_ble_conn_update_params_t;
|
||||
|
||||
/**
|
||||
* @brief BLE pkt date length keys
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t rx_len; /*!< pkt rx data length value */
|
||||
uint16_t tx_len; /*!< pkt tx data length value */
|
||||
}esp_ble_pkt_data_length_params_t;
|
||||
|
||||
/**
|
||||
* @brief BLE encryption keys
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bt_octet16_t ltk; /*!< The long term key*/
|
||||
esp_bt_octet8_t rand; /*!< The random number*/
|
||||
uint16_t ediv; /*!< The ediv value*/
|
||||
uint8_t sec_level; /*!< The security level of the security link*/
|
||||
uint8_t key_size; /*!< The key size(7~16) of the security link*/
|
||||
} esp_ble_penc_keys_t; /*!< The key type*/
|
||||
|
||||
/**
|
||||
* @brief BLE CSRK keys
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t counter; /*!< The counter */
|
||||
esp_bt_octet16_t csrk; /*!< The csrk key */
|
||||
uint8_t sec_level; /*!< The security level */
|
||||
} esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */
|
||||
|
||||
/**
|
||||
* @brief BLE pid keys
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bt_octet16_t irk; /*!< The irk value */
|
||||
esp_ble_addr_type_t addr_type; /*!< The address type */
|
||||
esp_bd_addr_t static_addr; /*!< The static address */
|
||||
} esp_ble_pid_keys_t; /*!< The pid key type */
|
||||
|
||||
/**
|
||||
* @brief BLE Encryption reproduction keys
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bt_octet16_t ltk; /*!< The long term key */
|
||||
uint16_t div; /*!< The div value */
|
||||
uint8_t key_size; /*!< The key size of the security link */
|
||||
uint8_t sec_level; /*!< The security level of the security link */
|
||||
} esp_ble_lenc_keys_t; /*!< The key type */
|
||||
|
||||
/**
|
||||
* @brief BLE SRK keys
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t counter; /*!< The counter value */
|
||||
uint16_t div; /*!< The div value */
|
||||
uint8_t sec_level; /*!< The security level of the security link */
|
||||
esp_bt_octet16_t csrk; /*!< The csrk key value */
|
||||
} esp_ble_lcsrk_keys; /*!< The csrk key type */
|
||||
|
||||
/**
|
||||
* @brief Structure associated with ESP_KEY_NOTIF_EVT
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
uint32_t passkey; /*!< the numeric value for comparison. If just_works, do not show this number to UI */
|
||||
} esp_ble_sec_key_notif_t; /*!< BLE key notify type*/
|
||||
|
||||
/**
|
||||
* @brief Structure of the security request
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
} esp_ble_sec_req_t; /*!< BLE security request type*/
|
||||
|
||||
/**
|
||||
* @brief union type of the security key value
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */
|
||||
esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */
|
||||
esp_ble_pid_keys_t pid_key; /*!< peer device ID key */
|
||||
esp_ble_lenc_keys_t lenc_key; /*!< local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
|
||||
esp_ble_lcsrk_keys lcsrk_key; /*!< local device CSRK = d1(ER,DIV,1)*/
|
||||
} esp_ble_key_value_t; /*!< ble key value type*/
|
||||
|
||||
/**
|
||||
* @brief struct type of the bond key informatuon value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_ble_key_mask_t key_mask; /*!< the key mask to indicate witch key is present */
|
||||
esp_ble_penc_keys_t penc_key; /*!< received peer encryption key */
|
||||
esp_ble_pcsrk_keys_t pcsrk_key; /*!< received peer device SRK */
|
||||
esp_ble_pid_keys_t pid_key; /*!< peer device ID key */
|
||||
} esp_ble_bond_key_info_t; /*!< ble bond key information value type */
|
||||
|
||||
/**
|
||||
* @brief struct type of the bond device value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
esp_ble_bond_key_info_t bond_key; /*!< the bond key information */
|
||||
} esp_ble_bond_dev_t; /*!< the ble bond device type */
|
||||
|
||||
|
||||
/**
|
||||
* @brief union type of the security key value
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< peer address */
|
||||
esp_ble_key_type_t key_type; /*!< key type of the security link */
|
||||
esp_ble_key_value_t p_key_value; /*!< the pointer to the key value */
|
||||
} esp_ble_key_t; /*!< the union to the ble key value type*/
|
||||
|
||||
/**
|
||||
* @brief structure type of the ble local id keys value
|
||||
*/
|
||||
typedef struct {
|
||||
esp_bt_octet16_t ir; /*!< the 16 bits of the ir value */
|
||||
esp_bt_octet16_t irk; /*!< the 16 bits of the ir key value */
|
||||
esp_bt_octet16_t dhk; /*!< the 16 bits of the dh key value */
|
||||
} esp_ble_local_id_keys_t; /*!< the structure of the ble local id keys value type*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Structure associated with ESP_AUTH_CMPL_EVT
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_bd_addr_t bd_addr; /*!< BD address peer device. */
|
||||
bool key_present; /*!< Valid link key value in key element */
|
||||
esp_link_key key; /*!< Link key associated with peer device. */
|
||||
uint8_t key_type; /*!< The type of Link Key */
|
||||
bool success; /*!< TRUE of authentication succeeded, FALSE if failed. */
|
||||
uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */
|
||||
esp_ble_addr_type_t addr_type; /*!< Peer device address type */
|
||||
esp_bt_dev_type_t dev_type; /*!< Device type */
|
||||
} esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */
|
||||
|
||||
/**
|
||||
* @brief union associated with ble security
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
esp_ble_sec_key_notif_t key_notif; /*!< passkey notification */
|
||||
esp_ble_sec_req_t ble_req; /*!< BLE SMP related request */
|
||||
esp_ble_key_t ble_key; /*!< BLE SMP keys used when pairing */
|
||||
esp_ble_local_id_keys_t ble_id_keys; /*!< BLE IR event */
|
||||
esp_ble_auth_cmpl_t auth_cmpl; /*!< Authentication complete indication. */
|
||||
} esp_ble_sec_t; /*!< Ble secutity type */
|
||||
|
||||
/// Sub Event of ESP_GAP_BLE_SCAN_RESULT_EVT
|
||||
typedef enum {
|
||||
ESP_GAP_SEARCH_INQ_RES_EVT = 0, /*!< Inquiry result for a peer device. */
|
||||
@@ -495,8 +273,6 @@ typedef union {
|
||||
uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX]; /*!< Received EIR */
|
||||
int flag; /*!< Advertising data flag bit */
|
||||
int num_resps; /*!< Scan result number */
|
||||
uint8_t adv_data_len; /*!< Adv data length */
|
||||
uint8_t scan_rsp_len; /*!< Scan response length */
|
||||
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
|
||||
@@ -522,59 +298,6 @@ typedef union {
|
||||
struct ble_scan_start_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate scan start operation success status */
|
||||
} scan_start_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_START_COMPLETE_EVT */
|
||||
|
||||
esp_ble_sec_t ble_security; /*!< ble gap security union type */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_scan_stop_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate scan stop operation success status */
|
||||
} scan_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_adv_stop_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate adv stop operation success status */
|
||||
} adv_stop_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT
|
||||
*/
|
||||
struct ble_set_rand_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate set static rand address operation success status */
|
||||
} set_rand_addr_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT
|
||||
*/
|
||||
struct ble_update_conn_params_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate update connection parameters success status */
|
||||
esp_bd_addr_t bda; /*!< Bluetooth device address */
|
||||
uint16_t min_int; /*!< Min connection interval */
|
||||
uint16_t max_int; /*!< Max connection interval */
|
||||
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
|
||||
uint16_t conn_int; /*!< Current connection interval */
|
||||
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
|
||||
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec */
|
||||
}update_conn_params; /*!< Event parameter of ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_pkt_data_length_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set pkt data length operation success status */
|
||||
esp_ble_pkt_data_length_params_t params; /*!< pkt data length value */
|
||||
} pkt_data_lenth_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_local_privacy_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */
|
||||
} local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_remove_bond_dev_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */
|
||||
esp_bd_addr_t bd_addr; /*!< The device address which has been remove from the bond list */
|
||||
}remove_bond_dev_cmpl; /*!< Event parameter of ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -780,125 +503,6 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set a GAP security parameter value. Overrides the default value.
|
||||
*
|
||||
* @param[in] param_type :L the type of the param which to be set
|
||||
* @param[in] value : the param value
|
||||
* @param[out] len : the length of the param value
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
|
||||
void *value, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief Grant security request access.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer
|
||||
* @param[in] accept : accept the security request or not
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_security_rsp(esp_bd_addr_t bd_addr, bool accept);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set a gap parameter value. Use this function to change
|
||||
* the default GAP parameter values.
|
||||
*
|
||||
* @param[in] bd_addr : the address of the peer device need to encryption
|
||||
* @param[in] sec_act : This is the security action to indicate
|
||||
* what kind of BLE security level is required for
|
||||
* the BLE link if the BLE is supported
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_set_encryption(esp_bd_addr_t bd_addr, esp_ble_sec_act_t sec_act);
|
||||
|
||||
/**
|
||||
* @brief Reply the key value to the peer device in the lagecy connection stage.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer
|
||||
* @param[in] accept : passkey entry sucessful or declined.
|
||||
* @param[in] passkey : passkey value, must be a 6 digit number,
|
||||
* can be lead by 0.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t passkey);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reply the comfirm value to the peer device in the lagecy connection stage.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer device
|
||||
* @param[in] accept : numbers to compare are the same or different.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
|
||||
|
||||
/**
|
||||
* @brief Removes a device from the security database list of
|
||||
* peer device. It manages unpairing event while connected.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer device
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_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.
|
||||
* - < 0 : failed
|
||||
*
|
||||
*/
|
||||
int esp_ble_get_bond_device_num(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the device from the security database list of peer device.
|
||||
* It will return the device bonded information immediately.
|
||||
* @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_ble_bond_dev_t` type. Use for storing the bonded devices address.
|
||||
* The dev_list should be allocated by who call this API.
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_get_bond_device_list(int *dev_num, esp_ble_bond_dev_t *dev_list);
|
||||
|
||||
/**
|
||||
* @brief This function is to disconnect the physical connection of the peer device
|
||||
*
|
||||
* @param[in] remote_device : BD address of the peer device
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_GAP_BT_API_H__
|
||||
#define __ESP_GAP_BT_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/// Discoverability and Connectability mode
|
||||
typedef enum {
|
||||
ESP_BT_SCAN_MODE_NONE = 0, /*!< Neither discoverable nor connectable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE, /*!< Connectable but not discoverable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE /*!< both discoverable and connectaable */
|
||||
} esp_bt_scan_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Set discoverability and connectability mode for legacy bluetooth. This function should
|
||||
* be called after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @param[in] mode : one of the enums of bt_scan_mode_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_ARG: if argument invalid
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GAP_BT_API_H__ */
|
||||
@@ -153,81 +153,75 @@ extern "C" {
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* relate to BTA_GATT_PREP_WRITE_xxx in bta_gatt_api.h */
|
||||
/// Attribute write data type from the client
|
||||
typedef enum {
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */ /* relate to BTA_GATT_PREP_WRITE_CANCEL in bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */ /* relate to BTA_GATT_PREP_WRITE_EXEC in bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */
|
||||
} esp_gatt_prep_write_type;
|
||||
|
||||
/* relate to BTA_GATT_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief GATT success code and error codes
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_OK = 0x0, /* relate to BTA_GATT_OK in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */ /* relate to BTA_GATT_INVALID_HANDLE in bta_gatt_api.h */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */ /* relate to BTA_GATT_READ_NOT_PERMIT in bta_gatt_api.h */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */ /* relate to BTA_GATT_WRITE_NOT_PERMIT in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */ /* relate to BTA_GATT_INVALID_PDU in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */ /* relate to BTA_GATT_INSUF_AUTHENTICATION in bta_gatt_api.h */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */ /* relate to BTA_GATT_REQ_NOT_SUPPORTED in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */ /* relate to BTA_GATT_INVALID_OFFSET in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */ /* relate to BTA_GATT_INSUF_AUTHORIZATION in bta_gatt_api.h */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */ /* relate to BTA_GATT_PREPARE_Q_FULL in bta_gatt_api.h */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */ /* relate to BTA_GATT_NOT_FOUND in bta_gatt_api.h */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */ /* relate to BTA_GATT_NOT_LONG in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */ /* relate to BTA_GATT_INSUF_KEY_SIZE in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */ /* relate to BTA_GATT_INVALID_ATTR_LEN in bta_gatt_api.h */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */ /* relate to BTA_GATT_ERR_UNLIKELY in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */ /* relate to BTA_GATT_INSUF_ENCRYPTION in bta_gatt_api.h */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */ /* relate to BTA_GATT_UNSUPPORT_GRP_TYPE in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */ /* relate to BTA_GATT_INSUF_RESOURCE in bta_gatt_api.h */
|
||||
ESP_GATT_OK = 0x0,
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK,
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */ /* relate to BTA_GATT_NO_RESOURCES in bta_gatt_api.h */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */ /* relate to BTA_GATT_INTERNAL_ERROR in bta_gatt_api.h */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */ /* relate to BTA_GATT_WRONG_STATE in bta_gatt_api.h */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */ /* relate to BTA_GATT_DB_FULL in bta_gatt_api.h */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */ /* relate to BTA_GATT_BUSY in bta_gatt_api.h */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */ /* relate to BTA_GATT_ERROR in bta_gatt_api.h */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */ /* relate to BTA_GATT_CMD_STARTED in bta_gatt_api.h */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */ /* relate to BTA_GATT_ILLEGAL_PARAMETER in bta_gatt_api.h */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */ /* relate to BTA_GATT_PENDING in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */ /* relate to BTA_GATT_AUTH_FAIL in bta_gatt_api.h */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */ /* relate to BTA_GATT_MORE in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */ /* relate to BTA_GATT_INVALID_CFG in bta_gatt_api.h */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */ /* relate to BTA_GATT_SERVICE_STARTED in bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK, /* relate to BTA_GATT_ENCRYPED_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */ /* relate to BTA_GATT_ENCRYPED_NO_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */ /* relate to BTA_GATT_NOT_ENCRYPTED in bta_gatt_api.h */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */ /* relate to BTA_GATT_CONGESTED in bta_gatt_api.h */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */ /* relate to BTA_GATT_DUP_REG in bta_gatt_api.h */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */ /* relate to BTA_GATT_ALREADY_OPEN in bta_gatt_api.h */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */ /* relate to BTA_GATT_CANCEL in bta_gatt_api.h */
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_STACK_RSP = 0xe0, /* 0xe0 */ /* relate to BTA_GATT_STACK_RSP in bta_gatt_api.h */
|
||||
ESP_GATT_APP_RSP = 0xe1, /* 0xe1 */ /* relate to BTA_GATT_APP_RSP in bta_gatt_api.h */
|
||||
//Error caused by customer application or stack bug
|
||||
ESP_GATT_UNKNOWN_ERROR = 0xef, /* 0xef */ /* relate to BTA_GATT_UNKNOWN_ERROR in bta_gatt_api.h */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ /* relate to BTA_GATT_CCC_CFG_ERR in bta_gatt_api.h */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */ /* relate to BTA_GATT_PRC_IN_PROGRESS in bta_gatt_api.h */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */ /* relate to BTA_GATT_OUT_OF_RANGE in bta_gatt_api.h */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */
|
||||
} esp_gatt_status_t;
|
||||
|
||||
/* relate to BTA_GATT_CONN_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Gatt Connection reason enum
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */ /* relate to BTA_GATT_CONN_UNKNOWN in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */ /* relate to BTA_GATT_CONN_L2C_FAILURE in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */ /* relate to BTA_GATT_CONN_TIMEOUT in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */ /* relate to BTA_GATT_CONN_TERMINATE_PEER_USER in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */ /* relate to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */ /* relate to BTA_GATT_CONN_FAIL_ESTABLISH in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */ /* relate to BTA_GATT_CONN_LMP_TIMEOUT in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */ /* relate to BTA_GATT_CONN_CONN_CANCEL in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */ /* relate to BTA_GATT_CONN_NONE in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */
|
||||
} esp_gatt_conn_reason_t;
|
||||
|
||||
/**
|
||||
@@ -247,43 +241,42 @@ typedef struct {
|
||||
bool is_primary; /*!< This service is primary or not */
|
||||
} __attribute__((packed)) esp_gatt_srvc_id_t;
|
||||
|
||||
/* relate to BTA_GATT_AUTH_REQ_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Gatt authentication request type
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_AUTH_REQ_NONE = 0, /* relate to BTA_GATT_AUTH_REQ_NONE in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_NO_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /* relate to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /* relate to BTA_GATT_AUTH_REQ_SIGNED_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NONE = 0,
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3,
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4,
|
||||
} esp_gatt_auth_req_t;
|
||||
|
||||
/* relate to BTA_GATT_PERM_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Attribute permissions
|
||||
*/
|
||||
#define ESP_GATT_PERM_READ (1 << 0) /* bit 0 - 0x0001 */ /* relate to BTA_GATT_PERM_READ in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 - 0x0002 */ /* relate to BTA_GATT_PERM_READ_ENCRYPTED in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 - 0x0004 */ /* relate to BTA_GATT_PERM_READ_ENC_MITM in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE (1 << 4) /* bit 4 - 0x0010 */ /* relate to BTA_GATT_PERM_WRITE in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 - 0x0020 */ /* relate to BTA_GATT_PERM_WRITE_ENCRYPTED in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta_gatt_api.h */
|
||||
typedef uint16_t esp_gatt_perm_t;
|
||||
typedef enum {
|
||||
ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */
|
||||
ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */
|
||||
ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */
|
||||
ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */
|
||||
ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */
|
||||
ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */
|
||||
} esp_gatt_perm_t;
|
||||
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta_gatt_api.h */
|
||||
/* definition of characteristic properties */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0) /* 0x01 */ /* relate to BTA_GATT_CHAR_PROP_BIT_BROADCAST in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1) /* 0x02 */ /* relate to BTA_GATT_CHAR_PROP_BIT_READ in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2) /* 0x04 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE_NR in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3) /* 0x08 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4) /* 0x10 */ /* relate to BTA_GATT_CHAR_PROP_BIT_NOTIFY in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5) /* 0x20 */ /* relate to BTA_GATT_CHAR_PROP_BIT_INDICATE in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6) /* 0x40 */ /* relate to BTA_GATT_CHAR_PROP_BIT_AUTH in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) /* 0x80 */ /* relate to BTA_GATT_CHAR_PROP_BIT_EXT_PROP in bta_gatt_api.h */
|
||||
typedef uint8_t esp_gatt_char_prop_t;
|
||||
typedef enum {
|
||||
ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */
|
||||
ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */
|
||||
ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */
|
||||
ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */
|
||||
ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */
|
||||
ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
|
||||
} esp_gatt_char_prop_t;
|
||||
|
||||
/// GATT maximum attribute length
|
||||
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
|
||||
@@ -304,17 +297,13 @@ typedef uint8_t esp_gatt_char_prop_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief attribute auto response flag
|
||||
* @brief attribute auto respose flag
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#define ESP_GATT_RSP_BY_APP 0
|
||||
#define ESP_GATT_AUTO_RSP 1
|
||||
/**
|
||||
* @brief if auto_rsp set to ESP_GATT_RSP_BY_APP, means the response of Write/Read operation will by replied by application.
|
||||
if auto_rsp set to ESP_GATT_AUTO_RSP, means the response of Write/Read operation will be replied by GATT stack automatically.
|
||||
*/
|
||||
uint8_t auto_rsp;
|
||||
uint8_t auto_rsp; /*!< need the app response to the client if need_rsp set to 1*/
|
||||
} esp_attr_control_t;
|
||||
|
||||
|
||||
@@ -323,8 +312,8 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
esp_attr_control_t attr_control; /*!< The attribute control type*/
|
||||
esp_attr_desc_t att_desc; /*!< The attribute type*/
|
||||
esp_attr_control_t attr_control; /*!< The attribue control type*/
|
||||
esp_attr_desc_t att_desc; /*!< The attribue type*/
|
||||
} esp_gatts_attr_db_t;
|
||||
|
||||
|
||||
|
||||
@@ -25,47 +25,45 @@ extern "C" {
|
||||
|
||||
/// GATT Client callback function events
|
||||
typedef enum {
|
||||
ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */
|
||||
ESP_GATTC_UNREG_EVT = 1, /*!< When GATT client is unregistered, the event comes */
|
||||
ESP_GATTC_OPEN_EVT = 2, /*!< When GATT virtual connection is set up, the event comes */
|
||||
ESP_GATTC_READ_CHAR_EVT = 3, /*!< When GATT characteristic is read, the event comes */
|
||||
ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< When GATT characteristic write operation completes, the event comes */
|
||||
ESP_GATTC_CLOSE_EVT = 5, /*!< When GATT virtual connection is closed, the event comes */
|
||||
ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< When GATT service discovery is completed, the event comes */
|
||||
ESP_GATTC_SEARCH_RES_EVT = 7, /*!< When GATT service discovery result is got, the event comes */
|
||||
ESP_GATTC_READ_DESCR_EVT = 8, /*!< When GATT characteristic descriptor read completes, the event comes */
|
||||
ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< When GATT characteristic descriptor write completes, the event comes */
|
||||
ESP_GATTC_NOTIFY_EVT = 10, /*!< When GATT notification or indication arrives, the event comes */
|
||||
ESP_GATTC_PREP_WRITE_EVT = 11, /*!< When GATT prepare-write operation completes, the event comes */
|
||||
ESP_GATTC_EXEC_EVT = 12, /*!< When write execution completes, the event comes */
|
||||
ESP_GATTC_ACL_EVT = 13, /*!< When ACL connection is up, the event comes */
|
||||
ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< When GATT client ongoing connection is cancelled, the event comes */
|
||||
ESP_GATTC_SRVC_CHG_EVT = 15, /*!< When "service changed" occurs, the event comes */
|
||||
ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< When encryption procedure completes, the event comes */
|
||||
ESP_GATTC_CFG_MTU_EVT = 18, /*!< When configuration of MTU completes, the event comes */
|
||||
ESP_GATTC_ADV_DATA_EVT = 19, /*!< When advertising of data, the event comes */
|
||||
ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< When multi-advertising is enabled, the event comes */
|
||||
ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< When multi-advertising parameters are updated, the event comes */
|
||||
ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< When multi-advertising data arrives, the event comes */
|
||||
ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< When multi-advertising is disabled, the event comes */
|
||||
ESP_GATTC_CONGEST_EVT = 24, /*!< When GATT connection congestion comes, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< When batch scan is enabled, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< When batch scan storage is configured, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< When Batch scan read event is reported, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< When Batch scan threshold is set, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< When Batch scan parameters are set, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< When Batch scan is disabled, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< When Scan filter configuration completes, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */
|
||||
ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */
|
||||
ESP_GATTC_GET_CHAR_EVT = 35, /*!< When characteristic is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_DESCR_EVT = 36, /*!< When characteristic descriptor is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_INCL_SRVC_EVT = 37, /*!< When included service is got from GATT server, the event comes */
|
||||
ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */
|
||||
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
||||
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
|
||||
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
|
||||
ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */
|
||||
ESP_GATTC_UNREG_EVT = 1, /*!< When GATT client is unregistered, the event comes */
|
||||
ESP_GATTC_OPEN_EVT = 2, /*!< When GATT connection is set up, the event comes */
|
||||
ESP_GATTC_READ_CHAR_EVT = 3, /*!< When GATT characteristic is read, the event comes */
|
||||
ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< When GATT characteristic write operation completes, the event comes */
|
||||
ESP_GATTC_CLOSE_EVT = 5, /*!< When GATT connection is closed, the event comes */
|
||||
ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< When GATT service discovery is completed, the event comes */
|
||||
ESP_GATTC_SEARCH_RES_EVT = 7, /*!< When GATT service discovery result is got, the event comes */
|
||||
ESP_GATTC_READ_DESCR_EVT = 8, /*!< When GATT characteristic descriptor read completes, the event comes */
|
||||
ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< When GATT characteristic descriptor write completes, the event comes */
|
||||
ESP_GATTC_NOTIFY_EVT = 10, /*!< When GATT notification or indication arrives, the event comes */
|
||||
ESP_GATTC_PREP_WRITE_EVT = 11, /*!< When GATT prepare-write operation completes, the event comes */
|
||||
ESP_GATTC_EXEC_EVT = 12, /*!< When write execution completes, the event comes */
|
||||
ESP_GATTC_ACL_EVT = 13, /*!< When ACL connection is up, the event comes */
|
||||
ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< When GATT client ongoing connection is cancelled, the event comes */
|
||||
ESP_GATTC_SRVC_CHG_EVT = 15, /*!< When "service changed" occurs, the event comes */
|
||||
ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< When encryption procedure completes, the event comes */
|
||||
ESP_GATTC_CFG_MTU_EVT = 18, /*!< When configuration of MTU completes, the event comes */
|
||||
ESP_GATTC_ADV_DATA_EVT = 19, /*!< When advertising of data, the event comes */
|
||||
ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< When multi-advertising is enabled, the event comes */
|
||||
ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< When multi-advertising parameters are updated, the event comes */
|
||||
ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< When multi-advertising data arrives, the event comes */
|
||||
ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< When multi-advertising is disabled, the event comes */
|
||||
ESP_GATTC_CONGEST_EVT = 24, /*!< When GATT connection congestion comes, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< When batch scan is enabled, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< When batch scan storage is configured, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< When Batch scan read event is reported, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< When Batch scan threshold is set, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< When Batch scan parameters are set, the event comes */
|
||||
ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< When Batch scan is disabled, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< When Scan filter configuration completes, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */
|
||||
ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */
|
||||
ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */
|
||||
ESP_GATTC_GET_CHAR_EVT = 35, /*!< When characteristic is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_DESCR_EVT = 36, /*!< When characteristic descriptor is got from GATT server, the event comes */
|
||||
ESP_GATTC_GET_INCL_SRVC_EVT = 37, /*!< When included service is got from GATT server, the event comes */
|
||||
ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */
|
||||
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
||||
} esp_gattc_cb_event_t;
|
||||
|
||||
/// Maximum Transmission Unit used in GATT
|
||||
@@ -135,22 +133,15 @@ typedef union {
|
||||
* @brief ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT
|
||||
*/
|
||||
struct gattc_read_char_evt_param {
|
||||
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
uint8_t *value; /*!< Characteristic value */
|
||||
uint16_t value_type; /*!< Characteristic value type, there is two value for this type:
|
||||
ESP_GATTC_READ_VALUE_TYPE_VALUE(0x0000) and
|
||||
ESP_GATTC_READ_VALUE_TYPE_AGG_FORMAT(0x2905).
|
||||
If the value is ESP_GATTC_READ_VALUE_TYPE_VALUE means it is a generally
|
||||
value type, and if is the type of ESP_GATTC_READ_VALUE_TYPE_AGG_FORMAT,
|
||||
the unit of the value will indicate in the Characteristic
|
||||
aggregate format descriptor */
|
||||
uint16_t value_len; /*!< Characteristic value length */
|
||||
} read; /*!< Gatt client callback param of ESP_GATTC_READ_CHAR_EVT */
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_gatt_srvc_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
esp_gatt_id_t descr_id; /*!< Descriptor id, include descriptor uuid and other information */
|
||||
uint8_t *value; /*!< Characteristic value */
|
||||
uint16_t value_type; /*!< Characteristic value type */
|
||||
uint16_t value_len; /*!< Characteristic value length */
|
||||
} read; /*!< Gatt client callback param of ESP_GATTC_READ_CHAR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_WRITE_CHAR_EVT, ESP_GATTC_PREP_WRITE_EVT, ESP_GATTC_WRITE_DESCR_EVT
|
||||
@@ -250,23 +241,6 @@ typedef union {
|
||||
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
|
||||
} unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_CONNECT_EVT
|
||||
*/
|
||||
struct gattc_connect_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} connect; /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_DISCONNECT_EVT
|
||||
*/
|
||||
struct gattc_disconnect_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
|
||||
|
||||
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
|
||||
|
||||
@@ -337,10 +311,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, b
|
||||
|
||||
|
||||
/**
|
||||
* @brief Close a virtual connection to a GATT server. gattc maybe have multiple virtual GATT server connections when multiple app_id registed,
|
||||
* this API only close one virtual GATT server connection. if there exist other virtual GATT server connections,
|
||||
* it does not disconnect the physical connection.
|
||||
* if you want to disconnect the physical connection directly, you can use esp_ble_gap_disconnect(esp_bd_addr_t remote_device).
|
||||
* @brief Close a connection to a GATT server.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id: connection ID to be closed.
|
||||
@@ -539,15 +510,15 @@ esp_err_t esp_ble_gattc_write_char( esp_gatt_if_t gattc_if,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
@@ -577,35 +548,6 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to prepare write a characteristic descriptor value.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] srvc_id : service ID.
|
||||
* @param[in] char_id : GATT characteristic ID of the service.
|
||||
* @param[in] descr_id : characteristic descriptor ID to write.
|
||||
* @param[in] offset : offset of the write value.
|
||||
* @param[in] value_len: length of the value to be written.
|
||||
* @param[in] value : the value to be written.
|
||||
* @param[in] auth_req : authentication request.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to execute write a prepare write sequence.
|
||||
*
|
||||
@@ -634,7 +576,7 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
@@ -653,24 +595,11 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Refresh the server cache store in the gattc stack of the remote device
|
||||
*
|
||||
* @param[in] remote_bda: remote device BD address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -208,25 +208,12 @@ typedef union {
|
||||
/**
|
||||
* @brief ESP_GATTS_OPEN_EVT
|
||||
*/
|
||||
struct gatts_open_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
} open; /*!< Gatt server callback param of ESP_GATTS_OPEN_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_CANCEL_OPEN_EVT
|
||||
*/
|
||||
struct gatts_cancel_open_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
} cancel_open; /*!< Gatt server callback param of ESP_GATTS_CANCEL_OPEN_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_CLOSE_EVT
|
||||
*/
|
||||
struct gatts_close_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
} close; /*!< Gatt server callback param of ESP_GATTS_CLOSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTS_LISTEN_EVT
|
||||
*/
|
||||
@@ -514,11 +501,11 @@ esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, co
|
||||
* @param[out] value: Pointer to attribute value payload, the value cannot be modified by user
|
||||
*
|
||||
* @return
|
||||
* - ESP_GATT_OK : success
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
|
||||
esp_err_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,316 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008-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 for the audio/video registration module.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "bta_ar_api.h"
|
||||
#include "bta_ar_int.h"
|
||||
|
||||
#if BTA_AR_INCLUDED
|
||||
|
||||
/* AV control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_AR_CB bta_ar_cb;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_id
|
||||
**
|
||||
** Description This function maps sys_id to ar id mask.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static UINT8 bta_ar_id(tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = 0;
|
||||
if (sys_id == BTA_ID_AV) {
|
||||
mask = BTA_AR_AV_MASK;
|
||||
} else if (sys_id == BTA_ID_AVK) {
|
||||
mask = BTA_AR_AVK_MASK;
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_init
|
||||
**
|
||||
** Description This function is called to register to AVDTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_ar_init(void)
|
||||
{
|
||||
/* initialize control block */
|
||||
memset(&bta_ar_cb, 0, sizeof(tBTA_AR_CB));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avdt
|
||||
**
|
||||
** Description This function is called to register to AVDTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_ar_avdt_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data)
|
||||
{
|
||||
/* route the AVDT registration callback to av or avk */
|
||||
if (bta_ar_cb.p_av_conn_cback) {
|
||||
(*bta_ar_cb.p_av_conn_cback)(handle, bd_addr, event, p_data);
|
||||
}
|
||||
if (bta_ar_cb.p_avk_conn_cback) {
|
||||
(*bta_ar_cb.p_avk_conn_cback)(handle, bd_addr, event, p_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avdt
|
||||
**
|
||||
** Description AR module registration to AVDT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_ar_reg_avdt(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback, tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = 0;
|
||||
|
||||
if (sys_id == BTA_ID_AV) {
|
||||
bta_ar_cb.p_av_conn_cback = p_cback;
|
||||
mask = BTA_AR_AV_MASK;
|
||||
} else if (sys_id == BTA_ID_AVK) {
|
||||
bta_ar_cb.p_avk_conn_cback = p_cback;
|
||||
mask = BTA_AR_AVK_MASK;
|
||||
}
|
||||
#if (BTA_AR_DEBUG == TRUE)
|
||||
else {
|
||||
APPL_TRACE_ERROR("bta_ar_reg_avdt: the registration is from wrong sys_id:%d", sys_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mask) {
|
||||
if (bta_ar_cb.avdt_registered == 0) {
|
||||
AVDT_Register(p_reg, bta_ar_avdt_cback);
|
||||
}
|
||||
bta_ar_cb.avdt_registered |= mask;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_dereg_avdt
|
||||
**
|
||||
** Description This function is called to de-register from AVDTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_ar_dereg_avdt(tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = 0;
|
||||
|
||||
if (sys_id == BTA_ID_AV) {
|
||||
bta_ar_cb.p_av_conn_cback = NULL;
|
||||
mask = BTA_AR_AV_MASK;
|
||||
} else if (sys_id == BTA_ID_AVK) {
|
||||
bta_ar_cb.p_avk_conn_cback = NULL;
|
||||
mask = BTA_AR_AVK_MASK;
|
||||
}
|
||||
bta_ar_cb.avdt_registered &= ~mask;
|
||||
|
||||
if (bta_ar_cb.avdt_registered == 0) {
|
||||
AVDT_Deregister();
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_avdt_conn
|
||||
**
|
||||
** Description This function is called to let ar know that some AVDTP profile
|
||||
** is connected for this sys_id.
|
||||
** If the other sys modules started a timer for PENDING_EVT,
|
||||
** the timer can be stopped now.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_ar_avdt_conn(tBTA_SYS_ID sys_id, BD_ADDR bd_addr)
|
||||
{
|
||||
UINT8 event = BTA_AR_AVDT_CONN_EVT;
|
||||
tAVDT_CTRL data;
|
||||
|
||||
if (sys_id == BTA_ID_AV) {
|
||||
if (bta_ar_cb.p_avk_conn_cback) {
|
||||
(*bta_ar_cb.p_avk_conn_cback)(0, bd_addr, event, &data);
|
||||
}
|
||||
} else if (sys_id == BTA_ID_AVK) {
|
||||
if (bta_ar_cb.p_av_conn_cback) {
|
||||
(*bta_ar_cb.p_av_conn_cback)(0, bd_addr, event, &data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avct
|
||||
**
|
||||
** Description This function is called to register to AVCTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_ar_reg_avct(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask, tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = bta_ar_id (sys_id);
|
||||
|
||||
if (mask) {
|
||||
if (bta_ar_cb.avct_registered == 0) {
|
||||
AVCT_Register(mtu, mtu_br, sec_mask);
|
||||
}
|
||||
bta_ar_cb.avct_registered |= mask;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_dereg_avct
|
||||
**
|
||||
** Description This function is called to deregister from AVCTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_ar_dereg_avct(tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = bta_ar_id (sys_id);
|
||||
|
||||
bta_ar_cb.avct_registered &= ~mask;
|
||||
|
||||
if (bta_ar_cb.avct_registered == 0) {
|
||||
AVCT_Deregister();
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avrc
|
||||
**
|
||||
** Description This function is called to register an SDP record for AVRCP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
******************************************************************************/
|
||||
void bta_ar_reg_avrc(UINT16 service_uuid, char *service_name, char *provider_name,
|
||||
UINT16 categories, tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = bta_ar_id (sys_id);
|
||||
UINT8 temp[8], *p;
|
||||
|
||||
if (!mask || !categories) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
|
||||
if (bta_ar_cb.sdp_tg_handle == 0) {
|
||||
bta_ar_cb.tg_registered = mask;
|
||||
bta_ar_cb.sdp_tg_handle = SDP_CreateRecord();
|
||||
AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_tg_handle);
|
||||
bta_sys_add_uuid(service_uuid);
|
||||
}
|
||||
/* only one TG is allowed (first-come, first-served).
|
||||
* If sdp_tg_handle is non-0, ignore this request */
|
||||
} else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) || (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL)) {
|
||||
bta_ar_cb.ct_categories [mask - 1] = categories;
|
||||
categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
|
||||
if (bta_ar_cb.sdp_ct_handle == 0) {
|
||||
bta_ar_cb.sdp_ct_handle = SDP_CreateRecord();
|
||||
AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_ct_handle);
|
||||
bta_sys_add_uuid(service_uuid);
|
||||
} else {
|
||||
/* multiple CTs are allowed.
|
||||
* Change supported categories on the second one */
|
||||
p = temp;
|
||||
UINT16_TO_BE_STREAM(p, categories);
|
||||
SDP_AddAttribute(bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
|
||||
(UINT32)2, (UINT8 *)temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function bta_ar_dereg_avrc
|
||||
**
|
||||
** Description This function is called to de-register/delete an SDP record for AVRCP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
******************************************************************************/
|
||||
void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id)
|
||||
{
|
||||
UINT8 mask = bta_ar_id (sys_id);
|
||||
UINT16 categories = 0;
|
||||
UINT8 temp[8], *p;
|
||||
|
||||
if (!mask) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
|
||||
if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered) {
|
||||
bta_ar_cb.tg_registered = 0;
|
||||
SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle);
|
||||
bta_ar_cb.sdp_tg_handle = 0;
|
||||
bta_sys_remove_uuid(service_uuid);
|
||||
}
|
||||
} else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
|
||||
if (bta_ar_cb.sdp_ct_handle) {
|
||||
bta_ar_cb.ct_categories [mask - 1] = 0;
|
||||
categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
|
||||
if (!categories) {
|
||||
/* no CT is still registered - cleaup */
|
||||
SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle);
|
||||
bta_ar_cb.sdp_ct_handle = 0;
|
||||
bta_sys_remove_uuid(service_uuid);
|
||||
} else {
|
||||
/* change supported categories to the remaning one */
|
||||
p = temp;
|
||||
UINT16_TO_BE_STREAM(p, categories);
|
||||
SDP_AddAttribute(bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
|
||||
(UINT32)2, (UINT8 *)temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* #if BTA_AR_INCLUDED */
|
||||
@@ -1,66 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2008-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 private interface file for the BTA audio/video registration
|
||||
* module.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AR_INT_H
|
||||
#define BTA_AR_INT_H
|
||||
|
||||
#include "bta_av_api.h"
|
||||
|
||||
#if (BTA_AR_INCLUDED == TRUE)
|
||||
|
||||
#ifndef BTA_AR_DEBUG
|
||||
#define BTA_AR_DEBUG FALSE
|
||||
#endif
|
||||
|
||||
#define BTA_AR_AV_MASK 0x01
|
||||
#define BTA_AR_AVK_MASK 0x02
|
||||
|
||||
/* data associated with BTA_AR */
|
||||
typedef struct {
|
||||
tAVDT_CTRL_CBACK *p_av_conn_cback; /* av connection callback function */
|
||||
tAVDT_CTRL_CBACK *p_avk_conn_cback; /* avk connection callback function */
|
||||
UINT8 avdt_registered;
|
||||
UINT8 avct_registered;
|
||||
UINT32 sdp_tg_handle;
|
||||
UINT32 sdp_ct_handle;
|
||||
UINT16 ct_categories[2];
|
||||
UINT8 tg_registered;
|
||||
tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */
|
||||
} tBTA_AR_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
|
||||
/* control block declaration */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_AR_CB bta_ar_cb;
|
||||
#else
|
||||
extern tBTA_AR_CB *bta_ar_cb_ptr;
|
||||
#define bta_ar_cb (*bta_ar_cb_ptr)
|
||||
#endif
|
||||
|
||||
#endif ///BTA_AR_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AR_INT_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,573 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2011-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 advanced audio/video (AV)
|
||||
* subsystem of BTA, Broadcom's Bluetooth application layer for mobile
|
||||
* phones.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_av_api.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "gki.h"
|
||||
#include <string.h>
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
static const tBTA_SYS_REG bta_av_reg = {
|
||||
bta_av_hdl_event,
|
||||
BTA_AvDisable
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvEnable
|
||||
**
|
||||
** Description Enable the advanced audio/video service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_AV_ENABLE_EVT. This function must
|
||||
** be called before other function in the AV API are
|
||||
** called.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, tBTA_AV_CBACK *p_cback)
|
||||
{
|
||||
tBTA_AV_API_ENABLE *p_buf;
|
||||
|
||||
/* register with BTA system manager */
|
||||
bta_sys_register(BTA_ID_AV, &bta_av_reg);
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
p_buf->features = features;
|
||||
p_buf->sec_mask = sec_mask;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDisable
|
||||
**
|
||||
** Description Disable the advanced audio/video service.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDisable(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
bta_sys_deregister(BTA_ID_AV);
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_DISABLE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvRegister
|
||||
**
|
||||
** Description Register the audio or video service to stack. When the
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_AV_REGISTER_EVT. This function must
|
||||
** be called before AVDT stream is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos)
|
||||
{
|
||||
tBTA_AV_API_REG *p_buf;
|
||||
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_REG *) GKI_getbuf(sizeof(tBTA_AV_API_REG))) != NULL) {
|
||||
p_buf->hdr.layer_specific = chnl;
|
||||
p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
|
||||
if (p_service_name) {
|
||||
BCM_STRNCPY_S(p_buf->p_service_name, sizeof(p_buf->p_service_name), p_service_name, BTA_SERVICE_NAME_LEN);
|
||||
p_buf->p_service_name[BTA_SERVICE_NAME_LEN - 1] = 0;
|
||||
} else {
|
||||
p_buf->p_service_name[0] = 0;
|
||||
}
|
||||
p_buf->app_id = app_id;
|
||||
p_buf->p_app_data_cback = p_data_cback;
|
||||
p_buf->bta_av_cos = bta_av_cos;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDeregister
|
||||
**
|
||||
** Description Deregister the audio or video service
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDeregister(tBTA_AV_HNDL hndl)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->layer_specific = hndl;
|
||||
p_buf->event = BTA_AV_API_DEREGISTER_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvOpen
|
||||
**
|
||||
** Description Opens an advanced audio/video connection to a peer device.
|
||||
** When connection is open callback function is called
|
||||
** with a BTA_AV_OPEN_EVT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC sec_mask,
|
||||
UINT16 uuid)
|
||||
{
|
||||
tBTA_AV_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
|
||||
p_buf->hdr.layer_specific = handle;
|
||||
bdcpy(p_buf->bd_addr, bd_addr);
|
||||
p_buf->use_rc = use_rc;
|
||||
p_buf->sec_mask = sec_mask;
|
||||
p_buf->switch_res = BTA_AV_RS_NONE;
|
||||
p_buf->uuid = uuid;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvClose
|
||||
**
|
||||
** Description Close the current streams.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvClose(tBTA_AV_HNDL handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_CLOSE_EVT;
|
||||
p_buf->layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDisconnect
|
||||
**
|
||||
** Description Close the connection to the address.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDisconnect(BD_ADDR bd_addr)
|
||||
{
|
||||
tBTA_AV_API_DISCNT *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_DISCNT *) GKI_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
|
||||
bdcpy(p_buf->bd_addr, bd_addr);
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvStart
|
||||
**
|
||||
** Description Start audio/video stream data transfer.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvStart(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_START_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvEnable_Sink
|
||||
**
|
||||
** Description Enable/Disable A2DP Sink..
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvEnable_Sink(int enable)
|
||||
{
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
BT_HDR *p_buf;
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
|
||||
p_buf->layer_specific = enable;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvStop
|
||||
**
|
||||
** Description Stop audio/video stream data transfer.
|
||||
** If suspend is TRUE, this function sends AVDT suspend signal
|
||||
** to the connected peer(s).
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvStop(BOOLEAN suspend)
|
||||
{
|
||||
tBTA_AV_API_STOP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_STOP *) GKI_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_STOP_EVT;
|
||||
p_buf->flush = TRUE;
|
||||
p_buf->suspend = suspend;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvReconfig
|
||||
**
|
||||
** Description Reconfigure the audio/video stream.
|
||||
** If suspend is TRUE, this function tries the suspend/reconfigure
|
||||
** procedure first.
|
||||
** If suspend is FALSE or when suspend/reconfigure fails,
|
||||
** this function closes and re-opens the AVDT connection.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
|
||||
UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info)
|
||||
{
|
||||
tBTA_AV_API_RCFG *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_RCFG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = BTA_AV_API_RECONFIG_EVT;
|
||||
p_buf->num_protect = num_protect;
|
||||
p_buf->suspend = suspend;
|
||||
p_buf->sep_info_idx = sep_info_idx;
|
||||
p_buf->p_protect_info = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->codec_info, p_codec_info, AVDT_CODEC_SIZE);
|
||||
memcpy(p_buf->p_protect_info, p_protect_info, num_protect);
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvProtectReq
|
||||
**
|
||||
** Description Send a content protection request. This function can only
|
||||
** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len)
|
||||
{
|
||||
tBTA_AV_API_PROTECT_REQ *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT;
|
||||
p_buf->len = len;
|
||||
if (p_data == NULL) {
|
||||
p_buf->p_data = NULL;
|
||||
} else {
|
||||
p_buf->p_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->p_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvProtectRsp
|
||||
**
|
||||
** Description Send a content protection response. This function must
|
||||
** be called if a BTA_AV_PROTECT_REQ_EVT is received.
|
||||
** This function can only be used if AV is enabled with
|
||||
** feature BTA_AV_FEAT_PROTECT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, UINT16 len)
|
||||
{
|
||||
tBTA_AV_API_PROTECT_RSP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = BTA_AV_API_PROTECT_RSP_EVT;
|
||||
p_buf->len = len;
|
||||
p_buf->error_code = error_code;
|
||||
if (p_data == NULL) {
|
||||
p_buf->p_data = NULL;
|
||||
} else {
|
||||
p_buf->p_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->p_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvRemoteCmd
|
||||
**
|
||||
** Description Send a remote control command. This function can only
|
||||
** be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, tBTA_AV_STATE key_state)
|
||||
{
|
||||
tBTA_AV_API_REMOTE_CMD *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) GKI_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->msg.op_id = rc_id;
|
||||
p_buf->msg.state = key_state;
|
||||
p_buf->msg.p_pass_data = NULL;
|
||||
p_buf->msg.pass_len = 0;
|
||||
p_buf->label = label;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvVendorCmd
|
||||
**
|
||||
** Description Send a vendor dependent remote control command. This
|
||||
** function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_VENDOR.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, UINT8 *p_data, UINT16 len)
|
||||
{
|
||||
tBTA_AV_API_VENDOR *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->msg.hdr.ctype = cmd_code;
|
||||
p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
|
||||
p_buf->msg.hdr.subunit_id = 0;
|
||||
p_buf->msg.company_id = p_bta_av_cfg->company_id;
|
||||
p_buf->label = label;
|
||||
p_buf->msg.vendor_len = len;
|
||||
if (p_data == NULL) {
|
||||
p_buf->msg.p_vendor_data = NULL;
|
||||
} else {
|
||||
p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->msg.p_vendor_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvVendorRsp
|
||||
**
|
||||
** Description Send a vendor dependent remote control response.
|
||||
** This function must be called if a BTA_AV_VENDOR_CMD_EVT
|
||||
** is received. This function can only be used if AV is
|
||||
** enabled with feature BTA_AV_FEAT_VENDOR.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, UINT8 *p_data, UINT16 len, UINT32 company_id)
|
||||
{
|
||||
tBTA_AV_API_VENDOR *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->msg.hdr.ctype = rsp_code;
|
||||
p_buf->msg.hdr.subunit_type = AVRC_SUB_PANEL;
|
||||
p_buf->msg.hdr.subunit_id = 0;
|
||||
if (company_id) {
|
||||
p_buf->msg.company_id = company_id;
|
||||
} else {
|
||||
p_buf->msg.company_id = p_bta_av_cfg->company_id;
|
||||
}
|
||||
p_buf->label = label;
|
||||
p_buf->msg.vendor_len = len;
|
||||
if (p_data == NULL) {
|
||||
p_buf->msg.p_vendor_data = NULL;
|
||||
} else {
|
||||
p_buf->msg.p_vendor_data = (UINT8 *) (p_buf + 1);
|
||||
memcpy(p_buf->msg.p_vendor_data, p_data, len);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvOpenRc
|
||||
**
|
||||
** Description Open an AVRCP connection toward the device with the
|
||||
** specified handle
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvOpenRc(tBTA_AV_HNDL handle)
|
||||
{
|
||||
tBTA_AV_API_OPEN_RC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_OPEN_RC *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
|
||||
p_buf->hdr.layer_specific = handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvCloseRc
|
||||
**
|
||||
** Description Close an AVRCP connection
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvCloseRc(UINT8 rc_handle)
|
||||
{
|
||||
tBTA_AV_API_CLOSE_RC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_CLOSE_RC *) GKI_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvMetaRsp
|
||||
**
|
||||
** Description Send a Metadata/Advanced Control response. The message contained
|
||||
** in p_pkt can be composed with AVRC utility functions.
|
||||
** This function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_METADATA.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
tBTA_AV_API_META_RSP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->rsp_code = rsp_code;
|
||||
p_buf->p_pkt = p_pkt;
|
||||
p_buf->is_rsp = TRUE;
|
||||
p_buf->label = label;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
} else if (p_pkt) {
|
||||
GKI_freebuf(p_pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvMetaCmd
|
||||
**
|
||||
** Description Send a Metadata/Advanced Control command. The message contained
|
||||
** in p_pkt can be composed with AVRC utility functions.
|
||||
** This function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_METADATA.
|
||||
** This message is sent only when the peer supports the TG role.
|
||||
*8 The only command makes sense right now is the absolute volume command.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt)
|
||||
{
|
||||
tBTA_AV_API_META_RSP *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
|
||||
p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
|
||||
p_buf->hdr.layer_specific = rc_handle;
|
||||
p_buf->p_pkt = p_pkt;
|
||||
p_buf->rsp_code = cmd_code;
|
||||
p_buf->is_rsp = FALSE;
|
||||
p_buf->label = label;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BTA_AV_INCLUDED */
|
||||
@@ -1,208 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-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 compile-time configurable constants for advanced
|
||||
* audio/video
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_av_int.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#ifndef BTA_AV_RC_PASS_RSP_CODE
|
||||
#define BTA_AV_RC_PASS_RSP_CODE BTA_AV_RSP_NOT_IMPL
|
||||
#endif
|
||||
|
||||
const UINT32 bta_av_meta_caps_co_ids[] = {
|
||||
AVRC_CO_METADATA,
|
||||
AVRC_CO_BROADCOM
|
||||
};
|
||||
|
||||
/* AVRCP cupported categories */
|
||||
#define BTA_AV_RC_SUPF_CT (AVRC_SUPF_CT_CAT2)
|
||||
|
||||
/* Added to modify
|
||||
** 1. flush timeout
|
||||
** 2. Remove Group navigation support in SupportedFeatures
|
||||
** 3. GetCapabilities supported event_ids list
|
||||
** 4. GetCapabilities supported event_ids count
|
||||
*/
|
||||
/* Flushing partial avdtp packets can cause some headsets to disconnect the link
|
||||
if receiving partial a2dp frames */
|
||||
const UINT16 bta_av_audio_flush_to[] = {
|
||||
0, /* 1 stream */
|
||||
0, /* 2 streams */
|
||||
0, /* 3 streams */
|
||||
0, /* 4 streams */
|
||||
0 /* 5 streams */
|
||||
}; /* AVDTP audio transport channel flush timeout */
|
||||
|
||||
/* Note: Android doesnt support AVRC_SUPF_TG_GROUP_NAVI */
|
||||
/* Note: if AVRC_SUPF_TG_GROUP_NAVI is set, bta_av_cfg.avrc_group should be TRUE */
|
||||
#if AVRC_METADATA_INCLUDED == TRUE
|
||||
#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1) /* TODO: | AVRC_SUPF_TG_APP_SETTINGS) */
|
||||
#else
|
||||
#define BTA_AV_RC_SUPF_TG (AVRC_SUPF_TG_CAT1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the number of event IDs is changed in this array, BTA_AV_ NUM_RC_EVT_IDS also needs to be changed.
|
||||
*/
|
||||
const UINT8 bta_av_meta_caps_evt_ids[] = {
|
||||
AVRC_EVT_PLAY_STATUS_CHANGE,
|
||||
AVRC_EVT_TRACK_CHANGE,
|
||||
AVRC_EVT_PLAY_POS_CHANGED,
|
||||
/* TODO: Add support for these events
|
||||
AVRC_EVT_APP_SETTING_CHANGE,
|
||||
*/
|
||||
};
|
||||
#ifndef BTA_AV_NUM_RC_EVT_IDS
|
||||
#define BTA_AV_NUM_RC_EVT_IDS (sizeof(bta_av_meta_caps_evt_ids) / sizeof(bta_av_meta_caps_evt_ids[0]))
|
||||
#endif /* BTA_AV_NUM_RC_EVT_IDS */
|
||||
|
||||
/* the MTU for the AVRCP browsing channel */
|
||||
#ifndef BTA_AV_MAX_RC_BR_MTU
|
||||
#define BTA_AV_MAX_RC_BR_MTU 1008
|
||||
#endif
|
||||
|
||||
const tBTA_AV_CFG bta_av_cfg = {
|
||||
AVRC_CO_BROADCOM, /* AVRCP Company ID */
|
||||
#if AVRC_METADATA_INCLUDED == TRUE
|
||||
512, /* AVRCP MTU at L2CAP for control channel */
|
||||
#else
|
||||
48, /* AVRCP MTU at L2CAP for control channel */
|
||||
#endif
|
||||
BTA_AV_MAX_RC_BR_MTU, /* AVRCP MTU at L2CAP for browsing channel */
|
||||
BTA_AV_RC_SUPF_CT, /* AVRCP controller categories */
|
||||
BTA_AV_RC_SUPF_TG, /* AVRCP target categories */
|
||||
672, /* AVDTP signaling channel MTU at L2CAP */
|
||||
BTA_AV_MAX_A2DP_MTU, /* AVDTP audio transport channel MTU at L2CAP */
|
||||
bta_av_audio_flush_to, /* AVDTP audio transport channel flush timeout */
|
||||
6, /* AVDTP audio channel max data queue size */
|
||||
BTA_AV_MAX_VDP_MTU, /* AVDTP video transport channel MTU at L2CAP */
|
||||
600, /* AVDTP video transport channel flush timeout */
|
||||
FALSE, /* TRUE, to accept AVRC 1.3 group nevigation command */
|
||||
2, /* company id count in p_meta_co_ids */
|
||||
BTA_AV_NUM_RC_EVT_IDS, /* event id count in p_meta_evt_ids */
|
||||
BTA_AV_RC_PASS_RSP_CODE,/* the default response code for pass through commands */
|
||||
bta_av_meta_caps_co_ids,/* the metadata Get Capabilities response for company id */
|
||||
bta_av_meta_caps_evt_ids,/* the the metadata Get Capabilities response for event id */
|
||||
NULL, /* the action function table for VDP stream */
|
||||
NULL, /* action function to register VDP */
|
||||
{0}, /* Default AVRCP controller name */
|
||||
{0}, /* Default AVRCP target name */
|
||||
};
|
||||
|
||||
tBTA_AV_CFG *p_bta_av_cfg = (tBTA_AV_CFG *) &bta_av_cfg;
|
||||
|
||||
const UINT16 bta_av_rc_id[] = {
|
||||
0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
|
||||
4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
|
||||
8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
|
||||
12=FAV_MENU, 13=EXIT */
|
||||
|
||||
0, /* not used */
|
||||
|
||||
0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
|
||||
4=4, 5=5, 6=6, 7=7,
|
||||
8=8, 9=9, 10=DOT, 11=ENTER,
|
||||
12=CLEAR */
|
||||
|
||||
0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
|
||||
4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
|
||||
8=PAGE_DOWN */
|
||||
|
||||
#if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM)
|
||||
/* btui_app provides an example of how to leave the decision of rejecting a command or not
|
||||
* based on which media player is currently addressed (this is only applicable for AVRCP 1.4 or later)
|
||||
* If the decision is per player for a particular rc_id, the related bit is clear (not set) */
|
||||
0x0070, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
|
||||
4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
|
||||
8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
|
||||
12=BACKWARD */
|
||||
#else
|
||||
#if (defined BTA_AVRCP_FF_RW_SUPPORT) && (BTA_AVRCP_FF_RW_SUPPORT == TRUE)
|
||||
0x1b70, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
|
||||
4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
|
||||
8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
|
||||
12=BACKWARD */
|
||||
#else
|
||||
0x1870, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
|
||||
4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
|
||||
8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
|
||||
12=BACKWARD */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
|
||||
|
||||
0, /* not used */
|
||||
|
||||
0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
|
||||
4=F4, 5=F5 */
|
||||
};
|
||||
|
||||
#if (BTA_AV_RC_PASS_RSP_CODE == BTA_AV_RSP_INTERIM)
|
||||
const UINT16 bta_av_rc_id_ac[] = {
|
||||
0x0000, /* bit mask: 0=SELECT, 1=UP, 2=DOWN, 3=LEFT,
|
||||
4=RIGHT, 5=RIGHT_UP, 6=RIGHT_DOWN, 7=LEFT_UP,
|
||||
8=LEFT_DOWN, 9=ROOT_MENU, 10=SETUP_MENU, 11=CONT_MENU,
|
||||
12=FAV_MENU, 13=EXIT */
|
||||
|
||||
0, /* not used */
|
||||
|
||||
0x0000, /* bit mask: 0=0, 1=1, 2=2, 3=3,
|
||||
4=4, 5=5, 6=6, 7=7,
|
||||
8=8, 9=9, 10=DOT, 11=ENTER,
|
||||
12=CLEAR */
|
||||
|
||||
0x0000, /* bit mask: 0=CHAN_UP, 1=CHAN_DOWN, 2=PREV_CHAN, 3=SOUND_SEL,
|
||||
4=INPUT_SEL, 5=DISP_INFO, 6=HELP, 7=PAGE_UP,
|
||||
8=PAGE_DOWN */
|
||||
|
||||
/* btui_app provides an example of how to leave the decision of rejecting a command or not
|
||||
* based on which media player is currently addressed (this is only applicable for AVRCP 1.4 or later)
|
||||
* If the decision is per player for a particular rc_id, the related bit is set */
|
||||
0x1800, /* bit mask: 0=POWER, 1=VOL_UP, 2=VOL_DOWN, 3=MUTE,
|
||||
4=PLAY, 5=STOP, 6=PAUSE, 7=RECORD,
|
||||
8=REWIND, 9=FAST_FOR, 10=EJECT, 11=FORWARD,
|
||||
12=BACKWARD */
|
||||
|
||||
0x0000, /* bit mask: 0=ANGLE, 1=SUBPICT */
|
||||
|
||||
0, /* not used */
|
||||
|
||||
0x0000 /* bit mask: 0=not used, 1=F1, 2=F2, 3=F3,
|
||||
4=F4, 5=F5 */
|
||||
};
|
||||
UINT16 *p_bta_av_rc_id_ac = (UINT16 *) bta_av_rc_id_ac;
|
||||
#else
|
||||
UINT16 *p_bta_av_rc_id_ac = NULL;
|
||||
#endif
|
||||
|
||||
UINT16 *p_bta_av_rc_id = (UINT16 *) bta_av_rc_id;
|
||||
|
||||
#endif /* if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
|
||||
@@ -1,97 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-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 file for advanced audio/video call-in
|
||||
* functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "bta_av_ci.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ci_src_data_ready
|
||||
**
|
||||
** Description This function sends an event to the AV indicating that
|
||||
** the phone has audio stream data ready to send and AV
|
||||
** should call bta_av_co_audio_src_data_path() or
|
||||
** bta_av_co_video_src_data_path().
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->layer_specific = chnl;
|
||||
p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ci_setconfig
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig.
|
||||
** Parameter err_code is set to an AVDTP status value;
|
||||
** AVDT_SUCCESS if the codec configuration is ok,
|
||||
** otherwise error.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
|
||||
UINT8 num_seid, UINT8 *p_seid, BOOLEAN recfg_needed, UINT8 avdt_handle)
|
||||
{
|
||||
tBTA_AV_CI_SETCONFIG *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_AV_CI_SETCONFIG *) GKI_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL) {
|
||||
p_buf->hdr.layer_specific = hndl;
|
||||
p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
|
||||
BTA_AV_CI_SETCONFIG_OK_EVT : BTA_AV_CI_SETCONFIG_FAIL_EVT;
|
||||
p_buf->err_code = err_code;
|
||||
p_buf->category = category;
|
||||
p_buf->recfg_needed = recfg_needed;
|
||||
p_buf->num_seid = num_seid;
|
||||
p_buf->avdt_handle = avdt_handle;
|
||||
if (p_seid && num_seid) {
|
||||
p_buf->p_seid = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->p_seid, p_seid, num_seid);
|
||||
} else {
|
||||
p_buf->p_seid = NULL;
|
||||
p_buf->num_seid = 0;
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
|
||||
@@ -1,708 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 is the private interface file for the BTA advanced audio/video.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AV_INT_H
|
||||
#define BTA_AV_INT_H
|
||||
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_av_api.h"
|
||||
#include "avdt_api.h"
|
||||
#include "bta_av_co.h"
|
||||
#include "list.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#define BTA_AV_DEBUG TRUE
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
enum {
|
||||
/* these events are handled by the AV main state machine */
|
||||
BTA_AV_API_DISABLE_EVT = BTA_SYS_EVT_START(BTA_ID_AV),
|
||||
BTA_AV_API_REMOTE_CMD_EVT,
|
||||
BTA_AV_API_VENDOR_CMD_EVT,
|
||||
BTA_AV_API_VENDOR_RSP_EVT,
|
||||
BTA_AV_API_META_RSP_EVT,
|
||||
BTA_AV_API_RC_CLOSE_EVT,
|
||||
BTA_AV_AVRC_OPEN_EVT,
|
||||
BTA_AV_AVRC_MSG_EVT,
|
||||
BTA_AV_AVRC_NONE_EVT,
|
||||
|
||||
/* these events are handled by the AV stream state machine */
|
||||
BTA_AV_API_OPEN_EVT,
|
||||
BTA_AV_API_CLOSE_EVT,
|
||||
BTA_AV_AP_START_EVT, /* the following 2 events must be in the same order as the *API_*EVT */
|
||||
BTA_AV_AP_STOP_EVT,
|
||||
BTA_AV_API_RECONFIG_EVT,
|
||||
BTA_AV_API_PROTECT_REQ_EVT,
|
||||
BTA_AV_API_PROTECT_RSP_EVT,
|
||||
BTA_AV_API_RC_OPEN_EVT,
|
||||
BTA_AV_SRC_DATA_READY_EVT,
|
||||
BTA_AV_CI_SETCONFIG_OK_EVT,
|
||||
BTA_AV_CI_SETCONFIG_FAIL_EVT,
|
||||
BTA_AV_SDP_DISC_OK_EVT,
|
||||
BTA_AV_SDP_DISC_FAIL_EVT,
|
||||
BTA_AV_STR_DISC_OK_EVT,
|
||||
BTA_AV_STR_DISC_FAIL_EVT,
|
||||
BTA_AV_STR_GETCAP_OK_EVT,
|
||||
BTA_AV_STR_GETCAP_FAIL_EVT,
|
||||
BTA_AV_STR_OPEN_OK_EVT,
|
||||
BTA_AV_STR_OPEN_FAIL_EVT,
|
||||
BTA_AV_STR_START_OK_EVT,
|
||||
BTA_AV_STR_START_FAIL_EVT,
|
||||
BTA_AV_STR_CLOSE_EVT,
|
||||
BTA_AV_STR_CONFIG_IND_EVT,
|
||||
BTA_AV_STR_SECURITY_IND_EVT,
|
||||
BTA_AV_STR_SECURITY_CFM_EVT,
|
||||
BTA_AV_STR_WRITE_CFM_EVT,
|
||||
BTA_AV_STR_SUSPEND_CFM_EVT,
|
||||
BTA_AV_STR_RECONFIG_CFM_EVT,
|
||||
BTA_AV_AVRC_TIMER_EVT,
|
||||
BTA_AV_AVDT_CONNECT_EVT,
|
||||
BTA_AV_AVDT_DISCONNECT_EVT,
|
||||
BTA_AV_ROLE_CHANGE_EVT,
|
||||
BTA_AV_AVDT_DELAY_RPT_EVT,
|
||||
BTA_AV_ACP_CONNECT_EVT,
|
||||
|
||||
/* these events are handled outside of the state machine */
|
||||
BTA_AV_API_ENABLE_EVT,
|
||||
BTA_AV_API_REGISTER_EVT,
|
||||
BTA_AV_API_DEREGISTER_EVT,
|
||||
BTA_AV_API_DISCONNECT_EVT,
|
||||
BTA_AV_CI_SRC_DATA_READY_EVT,
|
||||
BTA_AV_SIG_CHG_EVT,
|
||||
BTA_AV_SIG_TIMER_EVT,
|
||||
BTA_AV_SDP_AVRC_DISC_EVT,
|
||||
BTA_AV_AVRC_CLOSE_EVT,
|
||||
BTA_AV_CONN_CHG_EVT,
|
||||
BTA_AV_DEREG_COMP_EVT,
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
BTA_AV_API_SINK_ENABLE_EVT,
|
||||
#endif
|
||||
#if (AVDT_REPORTING == TRUE)
|
||||
BTA_AV_AVDT_RPT_CONN_EVT,
|
||||
#endif
|
||||
BTA_AV_API_START_EVT, /* the following 2 events must be in the same order as the *AP_*EVT */
|
||||
BTA_AV_API_STOP_EVT
|
||||
};
|
||||
|
||||
/* events for AV control block state machine */
|
||||
#define BTA_AV_FIRST_SM_EVT BTA_AV_API_DISABLE_EVT
|
||||
#define BTA_AV_LAST_SM_EVT BTA_AV_AVRC_NONE_EVT
|
||||
|
||||
/* events for AV stream control block state machine */
|
||||
#define BTA_AV_FIRST_SSM_EVT BTA_AV_API_OPEN_EVT
|
||||
|
||||
/* events that do not go through state machine */
|
||||
#define BTA_AV_FIRST_NSM_EVT BTA_AV_API_ENABLE_EVT
|
||||
#define BTA_AV_LAST_NSM_EVT BTA_AV_API_STOP_EVT
|
||||
|
||||
/* API events passed to both SSMs (by bta_av_api_to_ssm) */
|
||||
#define BTA_AV_FIRST_A2S_API_EVT BTA_AV_API_START_EVT
|
||||
#define BTA_AV_FIRST_A2S_SSM_EVT BTA_AV_AP_START_EVT
|
||||
|
||||
#define BTA_AV_LAST_EVT BTA_AV_API_STOP_EVT
|
||||
|
||||
/* maximum number of SEPS in stream discovery results */
|
||||
#define BTA_AV_NUM_SEPS 32
|
||||
|
||||
/* initialization value for AVRC handle */
|
||||
#define BTA_AV_RC_HANDLE_NONE 0xFF
|
||||
|
||||
/* size of database for service discovery */
|
||||
#define BTA_AV_DISC_BUF_SIZE 1000
|
||||
|
||||
/* offset of media type in codec info byte array */
|
||||
#define BTA_AV_MEDIA_TYPE_IDX 1
|
||||
|
||||
/* maximum length of AVDTP security data */
|
||||
#define BTA_AV_SECURITY_MAX_LEN 400
|
||||
|
||||
/* check number of buffers queued at L2CAP when this amount of buffers are queued to L2CAP */
|
||||
#define BTA_AV_QUEUE_DATA_CHK_NUM L2CAP_HIGH_PRI_MIN_XMIT_QUOTA
|
||||
|
||||
/* the number of ACL links with AVDT */
|
||||
#define BTA_AV_NUM_LINKS AVDT_NUM_LINKS
|
||||
|
||||
#define BTA_AV_CO_ID_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
|
||||
#define BTA_AV_BE_STREAM_TO_CO_ID(u32, p) {u32 = (((UINT32)(*((p) + 2))) + (((UINT32)(*((p) + 1))) << 8) + (((UINT32)(*(p))) << 16)); (p) += 3;}
|
||||
|
||||
/* these bits are defined for bta_av_cb.multi_av */
|
||||
#define BTA_AV_MULTI_AV_SUPPORTED 0x01
|
||||
#define BTA_AV_MULTI_AV_IN_USE 0x02
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Data types
|
||||
*****************************************************************************/
|
||||
#if 0
|
||||
/* function types for call-out functions */
|
||||
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
|
||||
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
|
||||
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
|
||||
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info);
|
||||
typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
|
||||
UINT8 num_protect, UINT8 *p_protect_info,
|
||||
UINT8 t_local_sep, UINT8 avdt_handle);
|
||||
typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl,
|
||||
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
|
||||
UINT16 mtu);
|
||||
typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu);
|
||||
typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
|
||||
typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
|
||||
typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
|
||||
UINT32 *p_len, UINT32 *p_timestamp);
|
||||
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
|
||||
|
||||
/* the call-out functions for one stream */
|
||||
typedef struct {
|
||||
tBTA_AV_CO_INIT init;
|
||||
tBTA_AV_CO_DISC_RES disc_res;
|
||||
tBTA_AV_CO_GETCFG getcfg;
|
||||
tBTA_AV_CO_SETCFG setcfg;
|
||||
tBTA_AV_CO_OPEN open;
|
||||
tBTA_AV_CO_CLOSE close;
|
||||
tBTA_AV_CO_START start;
|
||||
tBTA_AV_CO_STOP stop;
|
||||
tBTA_AV_CO_DATAPATH data;
|
||||
tBTA_AV_CO_DELAY delay;
|
||||
} tBTA_AV_CO_FUNCTS;
|
||||
#endif
|
||||
|
||||
/* data type for BTA_AV_API_ENABLE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_AV_CBACK *p_cback;
|
||||
tBTA_AV_FEAT features;
|
||||
tBTA_SEC sec_mask;
|
||||
} tBTA_AV_API_ENABLE;
|
||||
|
||||
/* data type for BTA_AV_API_REG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
char p_service_name[BTA_SERVICE_NAME_LEN + 1];
|
||||
UINT8 app_id;
|
||||
tBTA_AV_DATA_CBACK *p_app_data_cback;
|
||||
tBTA_AV_CO_FUNCTS *bta_av_cos;
|
||||
} tBTA_AV_API_REG;
|
||||
|
||||
|
||||
enum {
|
||||
BTA_AV_RS_NONE, /* straight API call */
|
||||
BTA_AV_RS_OK, /* the role switch result - successful */
|
||||
BTA_AV_RS_FAIL, /* the role switch result - failed */
|
||||
BTA_AV_RS_DONE /* the role switch is done - continue */
|
||||
};
|
||||
typedef UINT8 tBTA_AV_RS_RES;
|
||||
/* data type for BTA_AV_API_OPEN_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BOOLEAN use_rc;
|
||||
tBTA_SEC sec_mask;
|
||||
tBTA_AV_RS_RES switch_res;
|
||||
UINT16 uuid; /* uuid of initiator */
|
||||
} tBTA_AV_API_OPEN;
|
||||
|
||||
/* data type for BTA_AV_API_STOP_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN suspend;
|
||||
BOOLEAN flush;
|
||||
} tBTA_AV_API_STOP;
|
||||
|
||||
/* data type for BTA_AV_API_DISCONNECT_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
} tBTA_AV_API_DISCNT;
|
||||
|
||||
/* data type for BTA_AV_API_PROTECT_REQ_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 *p_data;
|
||||
UINT16 len;
|
||||
} tBTA_AV_API_PROTECT_REQ;
|
||||
|
||||
/* data type for BTA_AV_API_PROTECT_RSP_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 *p_data;
|
||||
UINT16 len;
|
||||
UINT8 error_code;
|
||||
} tBTA_AV_API_PROTECT_RSP;
|
||||
|
||||
/* data type for BTA_AV_API_REMOTE_CMD_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVRC_MSG_PASS msg;
|
||||
UINT8 label;
|
||||
} tBTA_AV_API_REMOTE_CMD;
|
||||
|
||||
/* data type for BTA_AV_API_VENDOR_CMD_EVT and RSP */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVRC_MSG_VENDOR msg;
|
||||
UINT8 label;
|
||||
} tBTA_AV_API_VENDOR;
|
||||
|
||||
/* data type for BTA_AV_API_RC_OPEN_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_AV_API_OPEN_RC;
|
||||
|
||||
/* data type for BTA_AV_API_RC_CLOSE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_AV_API_CLOSE_RC;
|
||||
|
||||
/* data type for BTA_AV_API_META_RSP_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN is_rsp;
|
||||
UINT8 label;
|
||||
tBTA_AV_CODE rsp_code;
|
||||
BT_HDR *p_pkt;
|
||||
} tBTA_AV_API_META_RSP;
|
||||
|
||||
|
||||
/* data type for BTA_AV_API_RECONFIG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE]; /* codec configuration */
|
||||
UINT8 *p_protect_info;
|
||||
UINT8 num_protect;
|
||||
BOOLEAN suspend;
|
||||
UINT8 sep_info_idx;
|
||||
} tBTA_AV_API_RCFG;
|
||||
|
||||
/* data type for BTA_AV_CI_SETCONFIG_OK_EVT and BTA_AV_CI_SETCONFIG_FAIL_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_AV_HNDL hndl;
|
||||
UINT8 err_code;
|
||||
UINT8 category;
|
||||
UINT8 num_seid;
|
||||
UINT8 *p_seid;
|
||||
BOOLEAN recfg_needed;
|
||||
UINT8 avdt_handle; /* local sep type for which this stream will be set up */
|
||||
} tBTA_AV_CI_SETCONFIG;
|
||||
|
||||
/* data type for all stream events from AVDTP */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVDT_CFG cfg; /* configuration/capabilities parameters */
|
||||
tAVDT_CTRL msg; /* AVDTP callback message parameters */
|
||||
BD_ADDR bd_addr; /* bd address */
|
||||
UINT8 handle;
|
||||
UINT8 avdt_event;
|
||||
BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */
|
||||
} tBTA_AV_STR_MSG;
|
||||
|
||||
/* data type for BTA_AV_AVRC_MSG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tAVRC_MSG msg;
|
||||
UINT8 handle;
|
||||
UINT8 label;
|
||||
UINT8 opcode;
|
||||
} tBTA_AV_RC_MSG;
|
||||
|
||||
/* data type for BTA_AV_AVRC_OPEN_EVT, BTA_AV_AVRC_CLOSE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_addr;
|
||||
UINT8 handle;
|
||||
} tBTA_AV_RC_CONN_CHG;
|
||||
|
||||
/* data type for BTA_AV_CONN_CHG_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_addr;
|
||||
BOOLEAN is_up;
|
||||
} tBTA_AV_CONN_CHG;
|
||||
|
||||
/* data type for BTA_AV_ROLE_CHANGE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 new_role;
|
||||
UINT8 hci_status;
|
||||
} tBTA_AV_ROLE_RES;
|
||||
|
||||
/* data type for BTA_AV_SDP_DISC_OK_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 avdt_version; /* AVDTP protocol version */
|
||||
} tBTA_AV_SDP_RES;
|
||||
|
||||
/* type for SEP control block */
|
||||
typedef struct {
|
||||
UINT8 av_handle; /* AVDTP handle */
|
||||
tBTA_AV_CODEC codec_type; /* codec type */
|
||||
UINT8 tsep; /* SEP type of local SEP */
|
||||
tBTA_AV_DATA_CBACK *p_app_data_cback; /* Application callback for media packets */
|
||||
} tBTA_AV_SEP;
|
||||
|
||||
|
||||
/* initiator/acceptor role for adaption */
|
||||
#define BTA_AV_ROLE_AD_INT 0x00 /* initiator */
|
||||
#define BTA_AV_ROLE_AD_ACP 0x01 /* acceptor */
|
||||
|
||||
/* initiator/acceptor signaling roles */
|
||||
#define BTA_AV_ROLE_START_ACP 0x00
|
||||
#define BTA_AV_ROLE_START_INT 0x10 /* do not change this value */
|
||||
|
||||
#define BTA_AV_ROLE_SUSPEND 0x20 /* suspending on start */
|
||||
#define BTA_AV_ROLE_SUSPEND_OPT 0x40 /* Suspend on Start option is set */
|
||||
|
||||
/* union of all event datatypes */
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_AV_API_ENABLE api_enable;
|
||||
tBTA_AV_API_REG api_reg;
|
||||
tBTA_AV_API_OPEN api_open;
|
||||
tBTA_AV_API_STOP api_stop;
|
||||
tBTA_AV_API_DISCNT api_discnt;
|
||||
tBTA_AV_API_PROTECT_REQ api_protect_req;
|
||||
tBTA_AV_API_PROTECT_RSP api_protect_rsp;
|
||||
tBTA_AV_API_REMOTE_CMD api_remote_cmd;
|
||||
tBTA_AV_API_VENDOR api_vendor;
|
||||
tBTA_AV_API_RCFG api_reconfig;
|
||||
tBTA_AV_CI_SETCONFIG ci_setconfig;
|
||||
tBTA_AV_STR_MSG str_msg;
|
||||
tBTA_AV_RC_MSG rc_msg;
|
||||
tBTA_AV_RC_CONN_CHG rc_conn_chg;
|
||||
tBTA_AV_CONN_CHG conn_chg;
|
||||
tBTA_AV_ROLE_RES role_res;
|
||||
tBTA_AV_SDP_RES sdp_res;
|
||||
tBTA_AV_API_META_RSP api_meta_rsp;
|
||||
} tBTA_AV_DATA;
|
||||
|
||||
typedef void (tBTA_AV_VDP_DATA_ACT)(void *p_scb);
|
||||
|
||||
typedef struct {
|
||||
tBTA_AV_VDP_DATA_ACT *p_act;
|
||||
UINT8 *p_frame;
|
||||
UINT16 buf_size;
|
||||
UINT32 len;
|
||||
UINT32 offset;
|
||||
UINT32 timestamp;
|
||||
} tBTA_AV_VF_INFO;
|
||||
|
||||
typedef union {
|
||||
tBTA_AV_VF_INFO vdp; /* used for video channels only */
|
||||
tBTA_AV_API_OPEN open; /* used only before open and role switch
|
||||
is needed on another AV channel */
|
||||
} tBTA_AV_Q_INFO;
|
||||
|
||||
#define BTA_AV_Q_TAG_OPEN 0x01 /* after API_OPEN, before STR_OPENED */
|
||||
#define BTA_AV_Q_TAG_START 0x02 /* before start sending media packets */
|
||||
#define BTA_AV_Q_TAG_STREAM 0x03 /* during streaming */
|
||||
|
||||
#define BTA_AV_WAIT_ACP_CAPS_ON 0x01 /* retriving the peer capabilities */
|
||||
#define BTA_AV_WAIT_ACP_CAPS_STARTED 0x02 /* started while retriving peer capabilities */
|
||||
#define BTA_AV_WAIT_ROLE_SW_RES_OPEN 0x04 /* waiting for role switch result after API_OPEN, before STR_OPENED */
|
||||
#define BTA_AV_WAIT_ROLE_SW_RES_START 0x08 /* waiting for role switch result before streaming */
|
||||
#define BTA_AV_WAIT_ROLE_SW_STARTED 0x10 /* started while waiting for role switch result */
|
||||
#define BTA_AV_WAIT_ROLE_SW_RETRY 0x20 /* set when retry on timeout */
|
||||
#define BTA_AV_WAIT_CHECK_RC 0x40 /* set when the timer is used by role switch */
|
||||
#define BTA_AV_WAIT_ROLE_SW_FAILED 0x80 /* role switch failed */
|
||||
|
||||
#define BTA_AV_WAIT_ROLE_SW_BITS (BTA_AV_WAIT_ROLE_SW_RES_OPEN|BTA_AV_WAIT_ROLE_SW_RES_START|BTA_AV_WAIT_ROLE_SW_STARTED|BTA_AV_WAIT_ROLE_SW_RETRY)
|
||||
|
||||
/* Bitmap for collision, coll_mask */
|
||||
#define BTA_AV_COLL_INC_TMR 0x01 /* Timer is running for incoming L2C connection */
|
||||
#define BTA_AV_COLL_API_CALLED 0x02 /* API open was called while incoming timer is running */
|
||||
|
||||
/* type for AV stream control block */
|
||||
typedef struct {
|
||||
const tBTA_AV_ACT *p_act_tbl; /* the action table for stream state machine */
|
||||
const tBTA_AV_CO_FUNCTS *p_cos; /* the associated callout functions */
|
||||
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
|
||||
tBTA_AV_SEP seps[BTA_AV_MAX_SEPS];
|
||||
tAVDT_CFG *p_cap; /* buffer used for get capabilities */
|
||||
list_t *a2d_list; /* used for audio channels only */
|
||||
tBTA_AV_Q_INFO q_info;
|
||||
tAVDT_SEP_INFO sep_info[BTA_AV_NUM_SEPS]; /* stream discovery results */
|
||||
tAVDT_CFG cfg; /* local SEP configuration */
|
||||
TIMER_LIST_ENT timer; /* delay timer for AVRC CT */
|
||||
BD_ADDR peer_addr; /* peer BD address */
|
||||
UINT16 l2c_cid; /* L2CAP channel ID */
|
||||
UINT16 stream_mtu; /* MTU of stream */
|
||||
UINT16 avdt_version; /* the avdt version of peer device */
|
||||
tBTA_SEC sec_mask; /* security mask */
|
||||
tBTA_AV_CODEC codec_type; /* codec type */
|
||||
UINT8 media_type; /* Media type */
|
||||
BOOLEAN cong; /* TRUE if AVDTP congested */
|
||||
tBTA_AV_STATUS open_status; /* open failure status */
|
||||
tBTA_AV_CHNL chnl; /* the channel: audio/video */
|
||||
tBTA_AV_HNDL hndl; /* the handle: ((hdi + 1)|chnl) */
|
||||
UINT16 cur_psc_mask; /* Protocol service capabilities mask for current connection */
|
||||
UINT8 avdt_handle; /* AVDTP handle */
|
||||
UINT8 hdi; /* the index to SCB[] */
|
||||
UINT8 num_seps; /* number of seps returned by stream discovery */
|
||||
UINT8 num_disc_snks; /* number of discovered snks */
|
||||
UINT8 num_disc_srcs; /* number of discovered srcs */
|
||||
UINT8 sep_info_idx; /* current index into sep_info */
|
||||
UINT8 sep_idx; /* current index into local seps[] */
|
||||
UINT8 rcfg_idx; /* reconfig requested index into sep_info */
|
||||
UINT8 state; /* state machine state */
|
||||
UINT8 avdt_label; /* AVDTP label */
|
||||
UINT8 app_id; /* application id */
|
||||
UINT8 num_recfg; /* number of reconfigure sent */
|
||||
UINT8 role;
|
||||
UINT8 l2c_bufs; /* the number of buffers queued to L2CAP */
|
||||
UINT8 rc_handle; /* connected AVRCP handle */
|
||||
BOOLEAN use_rc; /* TRUE if AVRCP is allowed */
|
||||
BOOLEAN started; /* TRUE if stream started */
|
||||
UINT8 co_started; /* non-zero, if stream started from call-out perspective */
|
||||
BOOLEAN recfg_sup; /* TRUE if the first attempt to reconfigure the stream was successfull, else False if command fails */
|
||||
BOOLEAN suspend_sup; /* TRUE if Suspend stream is supported, else FALSE if suspend command fails */
|
||||
BOOLEAN deregistring; /* TRUE if deregistering */
|
||||
BOOLEAN sco_suspend; /* TRUE if SUSPEND is issued automatically for SCO */
|
||||
UINT8 coll_mask; /* Mask to check incoming and outgoing collision */
|
||||
tBTA_AV_API_OPEN open_api; /* Saved OPEN api message */
|
||||
UINT8 wait; /* set 0x1, when getting Caps as ACP, set 0x2, when started */
|
||||
UINT8 q_tag; /* identify the associated q_info union member */
|
||||
BOOLEAN no_rtp_hdr; /* TRUE if add no RTP header*/
|
||||
UINT8 disc_rsn; /* disconenction reason */
|
||||
UINT16 uuid_int; /*intended UUID of Initiator to connect to */
|
||||
} tBTA_AV_SCB;
|
||||
|
||||
#define BTA_AV_RC_ROLE_MASK 0x10
|
||||
#define BTA_AV_RC_ROLE_INT 0x00
|
||||
#define BTA_AV_RC_ROLE_ACP 0x10
|
||||
|
||||
#define BTA_AV_RC_CONN_MASK 0x20
|
||||
|
||||
/* type for AV RCP control block */
|
||||
/* index to this control block is the rc handle */
|
||||
typedef struct {
|
||||
UINT8 status;
|
||||
UINT8 handle;
|
||||
UINT8 shdl; /* stream handle (hdi + 1) */
|
||||
UINT8 lidx; /* (index+1) to LCB */
|
||||
tBTA_AV_FEAT peer_features; /* peer features mask */
|
||||
} tBTA_AV_RCB;
|
||||
#define BTA_AV_NUM_RCB (BTA_AV_NUM_STRS + 2)
|
||||
|
||||
enum {
|
||||
BTA_AV_LCB_FREE,
|
||||
BTA_AV_LCB_FIND
|
||||
};
|
||||
|
||||
/* type for AV ACL Link control block */
|
||||
typedef struct {
|
||||
BD_ADDR addr; /* peer BD address */
|
||||
UINT8 conn_msk; /* handle mask of connected stream handle */
|
||||
UINT8 lidx; /* index + 1 */
|
||||
} tBTA_AV_LCB;
|
||||
|
||||
/* type for stream state machine action functions */
|
||||
typedef void (*tBTA_AV_SACT)(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
|
||||
|
||||
/* type for AV control block */
|
||||
typedef struct {
|
||||
tBTA_AV_SCB *p_scb[BTA_AV_NUM_STRS]; /* stream control block */
|
||||
tSDP_DISCOVERY_DB *p_disc_db; /* pointer to discovery database */
|
||||
tBTA_AV_CBACK *p_cback; /* application callback function */
|
||||
tBTA_AV_RCB rcb[BTA_AV_NUM_RCB]; /* RCB control block */
|
||||
tBTA_AV_LCB lcb[BTA_AV_NUM_LINKS + 1]; /* link control block */
|
||||
TIMER_LIST_ENT sig_tmr; /* link timer */
|
||||
TIMER_LIST_ENT acp_sig_tmr; /* timer to monitor signalling when accepting */
|
||||
UINT32 sdp_a2d_handle; /* SDP record handle for audio src */
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
UINT32 sdp_a2d_snk_handle; /* SDP record handle for audio snk */
|
||||
#endif
|
||||
UINT32 sdp_vdp_handle; /* SDP record handle for video src */
|
||||
tBTA_AV_FEAT features; /* features mask */
|
||||
tBTA_SEC sec_mask; /* security mask */
|
||||
tBTA_AV_HNDL handle; /* the handle for SDP activity */
|
||||
BOOLEAN disabling; /* TRUE if api disabled called */
|
||||
UINT8 disc; /* (hdi+1) or (rc_handle|BTA_AV_CHNL_MSK) if p_disc_db is in use */
|
||||
UINT8 state; /* state machine state */
|
||||
UINT8 conn_rc; /* handle mask of connected RCP channels */
|
||||
UINT8 conn_audio; /* handle mask of connected audio channels */
|
||||
UINT8 conn_video; /* handle mask of connected video channels */
|
||||
UINT8 conn_lcb; /* index mask of used LCBs */
|
||||
UINT8 audio_open_cnt; /* number of connected audio channels */
|
||||
UINT8 reg_audio; /* handle mask of registered audio channels */
|
||||
UINT8 reg_video; /* handle mask of registered video channels */
|
||||
UINT8 rc_acp_handle;
|
||||
UINT8 rc_acp_idx; /* (index + 1) to RCB */
|
||||
UINT8 rs_idx; /* (index + 1) to SCB for the one waiting for RS on open */
|
||||
BOOLEAN sco_occupied; /* TRUE if SCO is being used or call is in progress */
|
||||
UINT8 audio_streams; /* handle mask of streaming audio channels */
|
||||
UINT8 video_streams; /* handle mask of streaming video channels */
|
||||
} tBTA_AV_CB;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
|
||||
/* control block declaration */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
extern tBTA_AV_CB bta_av_cb;
|
||||
#else
|
||||
extern tBTA_AV_CB *bta_av_cb_ptr;
|
||||
#define bta_av_cb (*bta_av_cb_ptr)
|
||||
#endif
|
||||
|
||||
/* config struct */
|
||||
extern tBTA_AV_CFG *p_bta_av_cfg;
|
||||
|
||||
/* rc id config struct */
|
||||
extern UINT16 *p_bta_av_rc_id;
|
||||
extern UINT16 *p_bta_av_rc_id_ac;
|
||||
|
||||
extern const tBTA_AV_SACT bta_av_a2d_action[];
|
||||
// extern const tBTA_AV_CO_FUNCTS bta_av_a2d_cos;
|
||||
extern const tBTA_AV_SACT bta_av_vdp_action[];
|
||||
extern tAVDT_CTRL_CBACK *const bta_av_dt_cback[];
|
||||
extern void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_pt);
|
||||
|
||||
/*****************************************************************************
|
||||
** Function prototypes
|
||||
*****************************************************************************/
|
||||
/* utility functions */
|
||||
extern tBTA_AV_SCB *bta_av_hndl_to_scb(UINT16 handle);
|
||||
extern BOOLEAN bta_av_chk_start(tBTA_AV_SCB *p_scb);
|
||||
extern void bta_av_restore_switch (void);
|
||||
extern UINT16 bta_av_chk_mtu(tBTA_AV_SCB *p_scb, UINT16 mtu);
|
||||
extern void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p_data);
|
||||
extern UINT8 bta_av_rc_create(tBTA_AV_CB *p_cb, UINT8 role, UINT8 shdl, UINT8 lidx);
|
||||
extern void bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started);
|
||||
extern BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb);
|
||||
extern BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb);
|
||||
extern void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb);
|
||||
extern BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb);
|
||||
extern void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb);
|
||||
extern tBTA_AV_LCB *bta_av_find_lcb(BD_ADDR addr, UINT8 op);
|
||||
|
||||
|
||||
/* main functions */
|
||||
extern void bta_av_api_deregister(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf);
|
||||
extern void bta_av_sm_execute(tBTA_AV_CB *p_cb, UINT16 event, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data);
|
||||
extern BOOLEAN bta_av_hdl_event(BT_HDR *p_msg);
|
||||
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
|
||||
extern char *bta_av_evt_code(UINT16 evt_code);
|
||||
#endif
|
||||
extern BOOLEAN bta_av_switch_if_needed(tBTA_AV_SCB *p_scb);
|
||||
extern BOOLEAN bta_av_link_role_ok(tBTA_AV_SCB *p_scb, UINT8 bits);
|
||||
extern BOOLEAN bta_av_is_rcfg_sst(tBTA_AV_SCB *p_scb);
|
||||
|
||||
/* nsm action functions */
|
||||
extern void bta_av_api_disconnect(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_sig_chg(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_sig_timer(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_disc_done(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_closed(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_disc(UINT8 disc);
|
||||
extern void bta_av_conn_chg(tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_dereg_comp(tBTA_AV_DATA *p_data);
|
||||
|
||||
/* sm action functions */
|
||||
extern void bta_av_disable (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_opened (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_remote_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_vendor_cmd (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_vendor_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_close (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_meta_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rc_free_msg (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data);
|
||||
|
||||
extern tBTA_AV_RCB *bta_av_get_rcb_by_shdl(UINT8 shdl);
|
||||
extern void bta_av_del_rc(tBTA_AV_RCB *p_rcb);
|
||||
|
||||
/* ssm action functions */
|
||||
extern void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_cleanup (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_free_sdb (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_config_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_disconnect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_ind (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_do_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_connect_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_sdp_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_disc_res_as_acp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_getcap_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_setconfig_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_discover_req (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_conn_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_do_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_data_path (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_start_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_clr_cong (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_str_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_connect (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_discntd (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_suspend_cont (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rcfg_open (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_security_rej (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_chk_2nd_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_save_caps (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_rej_conn (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_set_use_rc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_cco_close (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
|
||||
/* ssm action functions - vdp specific */
|
||||
extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_vdp_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_reg_vdp (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AV_INT_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,614 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 module contains utility functions for dealing with SBC data frames
|
||||
* and codec capabilities.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "a2d_api.h"
|
||||
#include "a2d_sbc.h"
|
||||
#include "bta_av_sbc.h"
|
||||
#include "utl.h"
|
||||
#include "bt_utils.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
typedef int (tBTA_AV_SBC_ACT)(void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
typedef struct {
|
||||
INT32 cur_pos; /* current position */
|
||||
UINT32 src_sps; /* samples per second (source audio data) */
|
||||
UINT32 dst_sps; /* samples per second (converted audio data) */
|
||||
tBTA_AV_SBC_ACT *p_act; /* the action function to do the conversion */
|
||||
UINT16 bits; /* number of bits per pcm sample */
|
||||
UINT16 n_channels; /* number of channels (i.e. mono(1), stereo(2)...) */
|
||||
INT16 worker1;
|
||||
INT16 worker2;
|
||||
UINT8 div;
|
||||
} tBTA_AV_SBC_UPS_CB;
|
||||
|
||||
tBTA_AV_SBC_UPS_CB bta_av_sbc_ups_cb;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_init_up_sample
|
||||
**
|
||||
** Description initialize the up sample
|
||||
**
|
||||
** src_sps: samples per second (source audio data)
|
||||
** dst_sps: samples per second (converted audio data)
|
||||
** bits: number of bits per pcm sample
|
||||
** n_channels: number of channels (i.e. mono(1), stereo(2)...)
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps, UINT16 bits, UINT16 n_channels)
|
||||
{
|
||||
bta_av_sbc_ups_cb.cur_pos = -1;
|
||||
bta_av_sbc_ups_cb.src_sps = src_sps;
|
||||
bta_av_sbc_ups_cb.dst_sps = dst_sps;
|
||||
bta_av_sbc_ups_cb.bits = bits;
|
||||
bta_av_sbc_ups_cb.n_channels = n_channels;
|
||||
|
||||
if (n_channels == 1) {
|
||||
/* mono */
|
||||
if (bits == 8) {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8m;
|
||||
bta_av_sbc_ups_cb.div = 1;
|
||||
} else {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16m;
|
||||
bta_av_sbc_ups_cb.div = 2;
|
||||
}
|
||||
} else {
|
||||
/* stereo */
|
||||
if (bits == 8) {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_8s;
|
||||
bta_av_sbc_ups_cb.div = 2;
|
||||
} else {
|
||||
bta_av_sbc_ups_cb.p_act = bta_av_sbc_up_sample_16s;
|
||||
bta_av_sbc_ups_cb.div = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (number of bytes)
|
||||
** dst_samples: The size of p_dst (number of bytes)
|
||||
**
|
||||
** Note: An AE reported an issue with this function.
|
||||
** When called with bta_av_sbc_up_sample(src, uint8_array_dst..)
|
||||
** the byte before uint8_array_dst may get overwritten.
|
||||
** Using uint16_array_dst avoids the problem.
|
||||
** This issue is related to endian-ness and is hard to resolve
|
||||
** in a generic manner.
|
||||
** **************** Please use uint16 array as dst.
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
UINT32 src;
|
||||
UINT32 dst;
|
||||
|
||||
if (bta_av_sbc_ups_cb.p_act) {
|
||||
src = src_samples / bta_av_sbc_ups_cb.div;
|
||||
dst = dst_samples / bta_av_sbc_ups_cb.div;
|
||||
return (*bta_av_sbc_ups_cb.p_act)(p_src, p_dst, src, dst, p_ret);
|
||||
} else {
|
||||
*p_ret = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_16s (16bits-stereo)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 4 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 4 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
INT16 *p_src_tmp = (INT16 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker1 = &bta_av_sbc_ups_cb.worker1;
|
||||
INT16 *p_worker2 = &bta_av_sbc_ups_cb.worker2;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
}
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples-- && dst_samples) {
|
||||
*p_worker1 = *p_src_tmp++;
|
||||
*p_worker2 = *p_src_tmp++;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_16m (16bits-mono)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 2 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 2 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
INT16 *p_src_tmp = (INT16 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker = &bta_av_sbc_ups_cb.worker1;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
}
|
||||
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples-- && dst_samples) {
|
||||
*p_worker = *p_src_tmp++;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_8s (8bits-stereo)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 2 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 2 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
UINT8 *p_src_tmp = (UINT8 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker1 = &bta_av_sbc_ups_cb.worker1;
|
||||
INT16 *p_worker2 = &bta_av_sbc_ups_cb.worker2;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
}
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples -- && dst_samples) {
|
||||
*p_worker1 = *(UINT8 *)p_src_tmp++;
|
||||
*p_worker1 -= 0x80;
|
||||
*p_worker1 <<= 8;
|
||||
*p_worker2 = *(UINT8 *)p_src_tmp++;
|
||||
*p_worker2 -= 0x80;
|
||||
*p_worker2 <<= 8;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker1;
|
||||
*p_dst_tmp++ = *p_worker2;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples--;
|
||||
dst_samples--;
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_8m (8bits-mono)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (number of bytes)
|
||||
** dst_samples: The size of p_dst (number of bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret)
|
||||
{
|
||||
UINT8 *p_src_tmp = (UINT8 *)p_src;
|
||||
INT16 *p_dst_tmp = (INT16 *)p_dst;
|
||||
INT16 *p_worker = &bta_av_sbc_ups_cb.worker1;
|
||||
UINT32 src_sps = bta_av_sbc_ups_cb.src_sps;
|
||||
UINT32 dst_sps = bta_av_sbc_ups_cb.dst_sps;
|
||||
|
||||
while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples) {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples -= 4;
|
||||
}
|
||||
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos = dst_sps;
|
||||
|
||||
while (src_samples-- && dst_samples) {
|
||||
*p_worker = *(UINT8 *)p_src_tmp++;
|
||||
*p_worker -= 0x80;
|
||||
*p_worker <<= 8;
|
||||
|
||||
do {
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
*p_dst_tmp++ = *p_worker;
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos -= src_sps;
|
||||
dst_samples -= 4;
|
||||
|
||||
} while (bta_av_sbc_ups_cb.cur_pos > 0 && dst_samples);
|
||||
|
||||
bta_av_sbc_ups_cb.cur_pos += dst_sps;
|
||||
}
|
||||
|
||||
if (bta_av_sbc_ups_cb.cur_pos == (INT32)dst_sps) {
|
||||
bta_av_sbc_ups_cb.cur_pos = 0;
|
||||
}
|
||||
|
||||
*p_ret = ((char *)p_src_tmp - (char *)p_src);
|
||||
return ((char *)p_dst_tmp - (char *)p_dst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_for_cap
|
||||
**
|
||||
** Description Determine the preferred SBC codec configuration for the
|
||||
** given codec capabilities. The function is passed the
|
||||
** preferred codec configuration and the peer codec
|
||||
** capabilities for the stream. The function attempts to
|
||||
** match the preferred capabilities with the configuration
|
||||
** as best it can. The resulting codec configuration is
|
||||
** returned in the same memory used for the capabilities.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
** Codec configuration in p_cap.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref)
|
||||
{
|
||||
UINT8 status = A2D_SUCCESS;
|
||||
tA2D_SBC_CIE peer_cie;
|
||||
UNUSED(p_cap);
|
||||
|
||||
/* parse peer capabilities */
|
||||
if ((status = A2D_ParsSbcInfo(&peer_cie, p_peer, TRUE)) != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our channel mode */
|
||||
if (peer_cie.ch_mode & p_pref->ch_mode) {
|
||||
peer_cie.ch_mode = p_pref->ch_mode;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: ch_mode(0x%02X) not supported", p_pref->ch_mode);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our sampling freq */
|
||||
if (peer_cie.samp_freq & p_pref->samp_freq) {
|
||||
peer_cie.samp_freq = p_pref->samp_freq;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: samp_freq(0x%02X) not supported", p_pref->samp_freq);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our block len */
|
||||
if (peer_cie.block_len & p_pref->block_len) {
|
||||
peer_cie.block_len = p_pref->block_len;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: block_len(0x%02X) not supported", p_pref->block_len);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our num subbands */
|
||||
if (peer_cie.num_subbands & p_pref->num_subbands) {
|
||||
peer_cie.num_subbands = p_pref->num_subbands;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: num_subbands(0x%02X) not supported", p_pref->num_subbands);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* Check if the peer supports our alloc method */
|
||||
if (peer_cie.alloc_mthd & p_pref->alloc_mthd) {
|
||||
peer_cie.alloc_mthd = p_pref->alloc_mthd;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_av_sbc_cfg_for_cap: alloc_mthd(0x%02X) not supported", p_pref->alloc_mthd);
|
||||
return A2D_FAIL;
|
||||
}
|
||||
|
||||
/* max bitpool */
|
||||
if (p_pref->max_bitpool != 0 && p_pref->max_bitpool < peer_cie.max_bitpool) {
|
||||
peer_cie.max_bitpool = p_pref->max_bitpool;
|
||||
}
|
||||
|
||||
/* min bitpool */
|
||||
if (p_pref->min_bitpool != 0 && p_pref->min_bitpool > peer_cie.min_bitpool) {
|
||||
peer_cie.min_bitpool = p_pref->min_bitpool;
|
||||
}
|
||||
|
||||
if (status == A2D_SUCCESS) {
|
||||
/* build configuration */
|
||||
A2D_BldSbcInfo(A2D_MEDIA_TYPE_AUDIO, &peer_cie, p_peer);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_matches_cap
|
||||
**
|
||||
** Description This function checks whether an SBC codec configuration
|
||||
** matched with capabilities. Here we check subset.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
|
||||
{
|
||||
UINT8 status = 0;
|
||||
tA2D_SBC_CIE cfg_cie;
|
||||
|
||||
/* parse configuration */
|
||||
if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, TRUE)) != 0) {
|
||||
APPL_TRACE_ERROR(" bta_av_sbc_cfg_matches_cap Parsing Failed %d", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* verify that each parameter is in range */
|
||||
|
||||
APPL_TRACE_DEBUG(" FREQ peer: 0%x, capability 0%x", cfg_cie.samp_freq, p_cap->samp_freq);
|
||||
APPL_TRACE_DEBUG(" CH_MODE peer: 0%x, capability 0%x", cfg_cie.ch_mode, p_cap->ch_mode);
|
||||
APPL_TRACE_DEBUG(" BLOCK_LEN peer: 0%x, capability 0%x", cfg_cie.block_len, p_cap->block_len);
|
||||
APPL_TRACE_DEBUG(" SUB_BAND peer: 0%x, capability 0%x", cfg_cie.num_subbands, p_cap->num_subbands);
|
||||
APPL_TRACE_DEBUG(" ALLOC_MTHD peer: 0%x, capability 0%x", cfg_cie.alloc_mthd, p_cap->alloc_mthd);
|
||||
APPL_TRACE_DEBUG(" MAX_BitPool peer: 0%x, capability 0%x", cfg_cie.max_bitpool, p_cap->max_bitpool);
|
||||
APPL_TRACE_DEBUG(" Min_bitpool peer: 0%x, capability 0%x", cfg_cie.min_bitpool, p_cap->min_bitpool);
|
||||
|
||||
/* sampling frequency */
|
||||
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) {
|
||||
status = A2D_NS_SAMP_FREQ;
|
||||
}
|
||||
/* channel mode */
|
||||
else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) {
|
||||
status = A2D_NS_CH_MODE;
|
||||
}
|
||||
/* block length */
|
||||
else if ((cfg_cie.block_len & p_cap->block_len) == 0) {
|
||||
status = A2D_BAD_BLOCK_LEN;
|
||||
}
|
||||
/* subbands */
|
||||
else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) {
|
||||
status = A2D_NS_SUBBANDS;
|
||||
}
|
||||
/* allocation method */
|
||||
else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) {
|
||||
status = A2D_NS_ALLOC_MTHD;
|
||||
}
|
||||
/* max bitpool */
|
||||
else if (cfg_cie.max_bitpool > p_cap->max_bitpool) {
|
||||
status = A2D_NS_MAX_BITPOOL;
|
||||
}
|
||||
/* min bitpool */
|
||||
else if (cfg_cie.min_bitpool < p_cap->min_bitpool) {
|
||||
status = A2D_NS_MIN_BITPOOL;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_in_cap
|
||||
**
|
||||
** Description This function checks whether an SBC codec configuration
|
||||
** is allowable for the given codec capabilities.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap)
|
||||
{
|
||||
UINT8 status = 0;
|
||||
tA2D_SBC_CIE cfg_cie;
|
||||
|
||||
/* parse configuration */
|
||||
if ((status = A2D_ParsSbcInfo(&cfg_cie, p_cfg, FALSE)) != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* verify that each parameter is in range */
|
||||
|
||||
|
||||
/* sampling frequency */
|
||||
if ((cfg_cie.samp_freq & p_cap->samp_freq) == 0) {
|
||||
status = A2D_NS_SAMP_FREQ;
|
||||
}
|
||||
/* channel mode */
|
||||
else if ((cfg_cie.ch_mode & p_cap->ch_mode) == 0) {
|
||||
status = A2D_NS_CH_MODE;
|
||||
}
|
||||
/* block length */
|
||||
else if ((cfg_cie.block_len & p_cap->block_len) == 0) {
|
||||
status = A2D_BAD_BLOCK_LEN;
|
||||
}
|
||||
/* subbands */
|
||||
else if ((cfg_cie.num_subbands & p_cap->num_subbands) == 0) {
|
||||
status = A2D_NS_SUBBANDS;
|
||||
}
|
||||
/* allocation method */
|
||||
else if ((cfg_cie.alloc_mthd & p_cap->alloc_mthd) == 0) {
|
||||
status = A2D_NS_ALLOC_MTHD;
|
||||
}
|
||||
/* max bitpool */
|
||||
else if (cfg_cie.max_bitpool > p_cap->max_bitpool) {
|
||||
status = A2D_NS_MAX_BITPOOL;
|
||||
}
|
||||
/* min bitpool */
|
||||
else if (cfg_cie.min_bitpool < p_cap->min_bitpool) {
|
||||
status = A2D_NS_MIN_BITPOOL;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_bld_hdr
|
||||
**
|
||||
** Description This function builds the packet header for MPF1.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt)
|
||||
{
|
||||
UINT8 *p;
|
||||
|
||||
p_buf->offset -= BTA_AV_SBC_HDR_SIZE;
|
||||
p = (UINT8 *) (p_buf + 1) + p_buf->offset;
|
||||
p_buf->len += BTA_AV_SBC_HDR_SIZE;
|
||||
A2D_BldSbcMplHdr(p, FALSE, FALSE, FALSE, (UINT8) fr_per_pkt);
|
||||
}
|
||||
|
||||
#endif /* #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE) */
|
||||
@@ -1,580 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 is the stream state machine for the BTA advanced audio/video.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta_av_co.h"
|
||||
#include "bta_av_int.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
*****************************************************************************/
|
||||
|
||||
/* state machine states */
|
||||
enum {
|
||||
BTA_AV_INIT_SST,
|
||||
BTA_AV_INCOMING_SST,
|
||||
BTA_AV_OPENING_SST,
|
||||
BTA_AV_OPEN_SST,
|
||||
BTA_AV_RCFG_SST,
|
||||
BTA_AV_CLOSING_SST
|
||||
};
|
||||
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum {
|
||||
BTA_AV_DO_DISC,
|
||||
BTA_AV_CLEANUP,
|
||||
BTA_AV_FREE_SDB,
|
||||
BTA_AV_CONFIG_IND,
|
||||
BTA_AV_DISCONNECT_REQ,
|
||||
BTA_AV_SECURITY_REQ,
|
||||
BTA_AV_SECURITY_RSP,
|
||||
BTA_AV_SETCONFIG_RSP,
|
||||
BTA_AV_ST_RC_TIMER,
|
||||
BTA_AV_STR_OPENED,
|
||||
BTA_AV_SECURITY_IND,
|
||||
BTA_AV_SECURITY_CFM,
|
||||
BTA_AV_DO_CLOSE,
|
||||
BTA_AV_CONNECT_REQ,
|
||||
BTA_AV_SDP_FAILED,
|
||||
BTA_AV_DISC_RESULTS,
|
||||
BTA_AV_DISC_RES_AS_ACP,
|
||||
BTA_AV_OPEN_FAILED,
|
||||
BTA_AV_GETCAP_RESULTS,
|
||||
BTA_AV_SETCONFIG_REJ,
|
||||
BTA_AV_DISCOVER_REQ,
|
||||
BTA_AV_CONN_FAILED,
|
||||
BTA_AV_DO_START,
|
||||
BTA_AV_STR_STOPPED,
|
||||
BTA_AV_RECONFIG,
|
||||
BTA_AV_DATA_PATH,
|
||||
BTA_AV_START_OK,
|
||||
BTA_AV_START_FAILED,
|
||||
BTA_AV_STR_CLOSED,
|
||||
BTA_AV_CLR_CONG,
|
||||
BTA_AV_SUSPEND_CFM,
|
||||
BTA_AV_RCFG_STR_OK,
|
||||
BTA_AV_RCFG_FAILED,
|
||||
BTA_AV_RCFG_CONNECT,
|
||||
BTA_AV_RCFG_DISCNTD,
|
||||
BTA_AV_SUSPEND_CONT,
|
||||
BTA_AV_RCFG_CFM,
|
||||
BTA_AV_RCFG_OPEN,
|
||||
BTA_AV_SECURITY_REJ,
|
||||
BTA_AV_OPEN_RC,
|
||||
BTA_AV_CHK_2ND_START,
|
||||
BTA_AV_SAVE_CAPS,
|
||||
BTA_AV_SET_USE_RC,
|
||||
BTA_AV_CCO_CLOSE,
|
||||
BTA_AV_SWITCH_ROLE,
|
||||
BTA_AV_ROLE_RES,
|
||||
BTA_AV_DELAY_CO,
|
||||
BTA_AV_OPEN_AT_INC,
|
||||
BTA_AV_NUM_SACTIONS
|
||||
};
|
||||
|
||||
#define BTA_AV_SIGNORE BTA_AV_NUM_SACTIONS
|
||||
|
||||
|
||||
/* state table information */
|
||||
/* #define BTA_AV_SACTION_COL 0 position of actions */
|
||||
#define BTA_AV_SACTIONS 2 /* number of actions */
|
||||
#define BTA_AV_SNEXT_STATE 2 /* position of next state */
|
||||
#define BTA_AV_NUM_COLS 3 /* number of columns in state tables */
|
||||
|
||||
/* state table for init state */
|
||||
static const UINT8 bta_av_sst_init[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_DO_DISC, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_CLEANUP, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST }
|
||||
};
|
||||
|
||||
/* state table for incoming state */
|
||||
static const UINT8 bta_av_sst_incoming[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_OPEN_AT_INC, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_DISCONNECT_REQ, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SETCONFIG_RSP, BTA_AV_ST_RC_TIMER, BTA_AV_INCOMING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RES_AS_ACP, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_STR_OPENED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_CCO_CLOSE, BTA_AV_CLEANUP, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST }
|
||||
};
|
||||
|
||||
/* state table for opening state */
|
||||
static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_ST_RC_TIMER, BTA_AV_STR_OPENED, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_CONFIG_IND, BTA_AV_SIGNORE, BTA_AV_INCOMING_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SWITCH_ROLE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_DISCOVER_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_CONN_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST }
|
||||
};
|
||||
|
||||
/* state table for open state */
|
||||
static const UINT8 bta_av_sst_open[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_DO_START, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_STR_STOPPED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_RECONFIG, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SECURITY_REQ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SECURITY_RSP, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SET_USE_RC, BTA_AV_OPEN_RC, BTA_AV_OPEN_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_DATA_PATH, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SAVE_CAPS, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_START_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_START_FAILED, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_IND, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SECURITY_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_CLR_CONG, BTA_AV_DATA_PATH, BTA_AV_OPEN_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SUSPEND_CFM, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_OPEN_RC, BTA_AV_CHK_2ND_START, BTA_AV_OPEN_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_ROLE_RES, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPEN_SST }
|
||||
};
|
||||
|
||||
/* state table for reconfig state */
|
||||
static const UINT8 bta_av_sst_rcfg[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_RCFG_STR_OK, BTA_AV_SIGNORE, BTA_AV_OPEN_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_RCFG_FAILED, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_RCFG_CONNECT, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SUSPEND_CONT, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_RCFG_CFM, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_RCFG_OPEN, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_RCFG_DISCNTD, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_DELAY_CO, BTA_AV_SIGNORE, BTA_AV_RCFG_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_RCFG_SST }
|
||||
};
|
||||
|
||||
/* state table for closing state */
|
||||
static const UINT8 bta_av_sst_closing[][BTA_AV_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next state */
|
||||
/* AP_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_START_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AP_STOP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_RECONFIG_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_PROTECT_REQ_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_PROTECT_RSP_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* API_RC_OPEN_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* SRC_DATA_READY_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_SDP_FAILED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_OPEN_OK_EVT */ {BTA_AV_DO_CLOSE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_OPEN_FAIL_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_START_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_START_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_CLOSE_EVT */ {BTA_AV_DISCONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_CONFIG_IND_EVT */ {BTA_AV_SETCONFIG_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_SECURITY_IND_EVT */ {BTA_AV_SECURITY_REJ, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_SECURITY_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_WRITE_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_SUSPEND_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_RECONFIG_CFM_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVRC_TIMER_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVDT_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVDT_DISCONNECT_EVT */ {BTA_AV_STR_CLOSED, BTA_AV_SIGNORE, BTA_AV_INIT_SST },
|
||||
/* ROLE_CHANGE_EVT*/ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* AVDT_DELAY_RPT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* ACP_CONNECT_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST }
|
||||
};
|
||||
|
||||
/* type for state table */
|
||||
typedef const UINT8 (*tBTA_AV_SST_TBL)[BTA_AV_NUM_COLS];
|
||||
|
||||
/* state table */
|
||||
static const tBTA_AV_SST_TBL bta_av_sst_tbl[] = {
|
||||
bta_av_sst_init,
|
||||
bta_av_sst_incoming,
|
||||
bta_av_sst_opening,
|
||||
bta_av_sst_open,
|
||||
bta_av_sst_rcfg,
|
||||
bta_av_sst_closing
|
||||
};
|
||||
|
||||
|
||||
|
||||
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
|
||||
static char *bta_av_sst_code(UINT8 state);
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_rcfg_sst
|
||||
**
|
||||
** Description Check if stream state machine is in reconfig state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if stream state machine is in reconfig state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_rcfg_sst (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_rcfg_sst = FALSE;
|
||||
|
||||
if (p_scb != NULL) {
|
||||
if (p_scb->state == BTA_AV_RCFG_SST) {
|
||||
is_rcfg_sst = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_rcfg_sst;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ssm_execute
|
||||
**
|
||||
** Description Stream state machine event handling function for AV
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_ssm_execute(tBTA_AV_SCB *p_scb, UINT16 event, tBTA_AV_DATA *p_data)
|
||||
{
|
||||
tBTA_AV_SST_TBL state_table;
|
||||
UINT8 action;
|
||||
int i, xx;
|
||||
|
||||
if (p_scb == NULL) {
|
||||
/* this stream is not registered */
|
||||
APPL_TRACE_EVENT("AV channel not registered");
|
||||
return;
|
||||
}
|
||||
|
||||
/* In case incoming connection is for VDP, we need to swap scb. */
|
||||
/* When ACP_CONNECT_EVT was received, we put first available scb to */
|
||||
/* to Incoming state. Later, when STR_CONFIG_IND_EVT is coming, we */
|
||||
/* know if it is A2DP or VDP. */
|
||||
if ((p_scb->state == BTA_AV_INIT_SST) && (event == BTA_AV_STR_CONFIG_IND_EVT)) {
|
||||
for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
|
||||
if (bta_av_cb.p_scb[xx]) {
|
||||
if (bta_av_cb.p_scb[xx]->state == BTA_AV_INCOMING_SST) {
|
||||
bta_av_cb.p_scb[xx]->state = BTA_AV_INIT_SST;
|
||||
bta_av_cb.p_scb[xx]->coll_mask = 0;
|
||||
p_scb->state = BTA_AV_INCOMING_SST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
|
||||
APPL_TRACE_VERBOSE("AV Sevent(0x%x)=0x%x(%s) state=%d(%s)",
|
||||
p_scb->hndl, event, bta_av_evt_code(event), p_scb->state, bta_av_sst_code(p_scb->state));
|
||||
#else
|
||||
APPL_TRACE_VERBOSE("AV Sevent=0x%x state=%d", event, p_scb->state);
|
||||
#endif
|
||||
|
||||
/* look up the state table for the current state */
|
||||
state_table = bta_av_sst_tbl[p_scb->state];
|
||||
|
||||
event -= BTA_AV_FIRST_SSM_EVT;
|
||||
|
||||
/* set next state */
|
||||
p_scb->state = state_table[event][BTA_AV_SNEXT_STATE];
|
||||
|
||||
/* execute action functions */
|
||||
for (i = 0; i < BTA_AV_SACTIONS; i++) {
|
||||
if ((action = state_table[event][i]) != BTA_AV_SIGNORE) {
|
||||
(*p_scb->p_act_tbl[action])(p_scb, p_data);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_scb_opening
|
||||
**
|
||||
** Description Returns TRUE is scb is in opening state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if scb is in opening state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_scb_opening (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_opening = FALSE;
|
||||
|
||||
if (p_scb) {
|
||||
if (p_scb->state == BTA_AV_OPENING_SST) {
|
||||
is_opening = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_opening;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_scb_incoming
|
||||
**
|
||||
** Description Returns TRUE is scb is in incoming state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if scb is in incoming state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_scb_incoming (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_incoming = FALSE;
|
||||
|
||||
if (p_scb) {
|
||||
if (p_scb->state == BTA_AV_INCOMING_SST) {
|
||||
is_incoming = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_incoming;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_set_scb_sst_init
|
||||
**
|
||||
** Description Set SST state to INIT.
|
||||
** Use this function to change SST outside of state machine.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_set_scb_sst_init (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
if (p_scb) {
|
||||
p_scb->state = BTA_AV_INIT_SST;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_is_scb_init
|
||||
**
|
||||
** Description Returns TRUE is scb is in init state.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if scb is in incoming state.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_is_scb_init (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
BOOLEAN is_init = FALSE;
|
||||
|
||||
if (p_scb) {
|
||||
if (p_scb->state == BTA_AV_INIT_SST) {
|
||||
is_init = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return is_init;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_set_scb_sst_incoming
|
||||
**
|
||||
** Description Set SST state to incoming.
|
||||
** Use this function to change SST outside of state machine.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
|
||||
{
|
||||
if (p_scb) {
|
||||
p_scb->state = BTA_AV_INCOMING_SST;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** Debug Functions
|
||||
*****************************************************************************/
|
||||
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sst_code
|
||||
**
|
||||
** Description
|
||||
**
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_sst_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_SST: return "INIT";
|
||||
case BTA_AV_INCOMING_SST: return "INCOMING";
|
||||
case BTA_AV_OPENING_SST: return "OPENING";
|
||||
case BTA_AV_OPEN_SST: return "OPEN";
|
||||
case BTA_AV_RCFG_SST: return "RCFG";
|
||||
case BTA_AV_CLOSING_SST: return "CLOSING";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* BTA_AV_INCLUDED */
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "utl.h"
|
||||
#include "gap_api.h" /* For GAP_BleReadPeerPrefConnParams */
|
||||
#include <string.h>
|
||||
#include "controller.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_dm"
|
||||
// #include "osi/include/log.h"
|
||||
@@ -51,19 +50,13 @@ static void bta_dm_inq_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
|
||||
static void bta_dm_inq_cmpl_cb (void *p_result);
|
||||
static void bta_dm_service_search_remname_cback (BD_ADDR bd_addr, DEV_CLASS dc, BD_NAME bd_name);
|
||||
static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name);
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static void bta_dm_find_services ( BD_ADDR bd_addr);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
static void bta_dm_discover_next_device(void);
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static void bta_dm_sdp_callback (UINT16 sdp_status);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator);
|
||||
static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, BOOLEAN min_16_digit);
|
||||
static UINT8 bta_dm_new_link_key_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, LINK_KEY key, UINT8 key_type);
|
||||
static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name, int result);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
static void bta_dm_local_name_cback(BD_ADDR bd_addr);
|
||||
static BOOLEAN bta_dm_check_av(UINT16 event);
|
||||
static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data);
|
||||
@@ -72,45 +65,37 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data);
|
||||
static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE && SMP_INCLUDED == TRUE)
|
||||
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
|
||||
#endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */
|
||||
|
||||
static void bta_dm_set_eir (char *local_name);
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result,
|
||||
tBTA_SERVICE_MASK *p_services_to_search,
|
||||
tBTA_SERVICE_MASK *p_services_found);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle);
|
||||
static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle);
|
||||
static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
static void bta_dm_adjust_roles(BOOLEAN delay_role_switch);
|
||||
#if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE)
|
||||
static char *bta_dm_get_remname(void);
|
||||
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport);
|
||||
static void bta_dm_discover_device(BD_ADDR remote_bd_addr);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status );
|
||||
static void bta_dm_disable_search_and_disc(void);
|
||||
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||
#if ((defined SMP_INCLUDED) && (SMP_INCLUDED == TRUE))
|
||||
static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_DATA *p_data);
|
||||
#endif
|
||||
static void bta_dm_ble_id_key_cback (UINT8 key_type, tBTM_BLE_LOCAL_KEYS *p_key);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
static void bta_dm_gattc_register(void);
|
||||
static void btm_dm_start_gatt_discovery(BD_ADDR bd_addr);
|
||||
static void bta_dm_cancel_gatt_discovery(BD_ADDR bd_addr);
|
||||
static void bta_dm_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data);
|
||||
#endif // (GATTC_INCLUDED == TRUE)
|
||||
extern tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void);
|
||||
#endif
|
||||
|
||||
@@ -122,9 +107,8 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result);
|
||||
#define BTA_DM_BLE_ADV_CHNL_MAP (BTM_BLE_ADV_CHNL_37|BTM_BLE_ADV_CHNL_38|BTM_BLE_ADV_CHNL_39)
|
||||
#endif
|
||||
#endif
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
|
||||
static void bta_dm_observe_cmpl_cb(void *p_result);
|
||||
static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
|
||||
@@ -211,7 +195,6 @@ const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl [BTA_MAX_SERVICE_ID] = {
|
||||
};
|
||||
|
||||
/* bta security callback */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
const tBTM_APPL_INFO bta_security = {
|
||||
&bta_dm_authorize_cback,
|
||||
&bta_dm_pin_cback,
|
||||
@@ -219,22 +202,22 @@ const tBTM_APPL_INFO bta_security = {
|
||||
&bta_dm_authentication_complete_cback,
|
||||
&bta_dm_bond_cancel_complete_cback,
|
||||
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
&bta_dm_sp_cback,
|
||||
&bta_dm_sp_cback
|
||||
#else
|
||||
NULL,
|
||||
NULL
|
||||
#endif
|
||||
#if BLE_INCLUDED == TRUE
|
||||
&bta_dm_ble_smp_cback,
|
||||
&bta_dm_ble_id_key_cback,
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
#if SMP_INCLUDED == TRUE
|
||||
, &bta_dm_ble_smp_cback
|
||||
#endif
|
||||
, &bta_dm_ble_id_key_cback
|
||||
#endif
|
||||
|
||||
};
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
#define MAX_DISC_RAW_DATA_BUF (1024)
|
||||
UINT8 g_disc_raw_data_buf[MAX_DISC_RAW_DATA_BUF];
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
extern DEV_CLASS local_device_default_class;
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -340,9 +323,7 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
|
||||
/* 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));
|
||||
@@ -358,13 +339,12 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
if (key_mask & BTA_BLE_LOCAL_KEY_TYPE_ID) {
|
||||
BTM_BleLoadLocalKeys(BTA_BLE_LOCAL_KEY_TYPE_ID, (tBTM_BLE_LOCAL_KEYS *)&id_key);
|
||||
}
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
bta_dm_search_cb.conn_id = BTA_GATT_INVALID_CONN_ID;
|
||||
#endif
|
||||
#endif
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
BTM_SecRegister((tBTM_APPL_INFO *)&bta_security);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
BTM_SetDefaultLinkSuperTout(p_bta_dm_cfg->link_timeout);
|
||||
BTM_WritePageTimeout(p_bta_dm_cfg->page_timeout);
|
||||
bta_dm_cb.cur_policy = p_bta_dm_cfg->policy_settings;
|
||||
@@ -383,13 +363,13 @@ 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)
|
||||
|
||||
/* initialize bluetooth low power manager */
|
||||
bta_dm_init_pm();
|
||||
#endif ///BTM_SSR_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)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
bta_dm_gattc_register();
|
||||
#endif
|
||||
|
||||
@@ -423,9 +403,8 @@ 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)
|
||||
|
||||
bta_dm_disable_pm();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
bta_dm_disable_search_and_disc();
|
||||
bta_dm_cb.disabling = TRUE;
|
||||
|
||||
@@ -609,14 +588,14 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_dm_process_remove_device(BD_ADDR bd_addr)
|
||||
{
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection before unpair */
|
||||
BTA_GATTC_CancelOpen(0, bd_addr, FALSE);
|
||||
#endif
|
||||
|
||||
BTM_SecDeleteDevice(bd_addr);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
/* remove all cached GATT information */
|
||||
BTA_GATTC_Refresh(bd_addr);
|
||||
#endif
|
||||
@@ -799,7 +778,7 @@ void bta_dm_close_acl(tBTA_DM_MSG *p_data)
|
||||
if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr)) {
|
||||
APPL_TRACE_ERROR("delete device from security database failed.");
|
||||
}
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection if any */
|
||||
BTA_GATTC_CancelOpen(0, p_remove_acl->bd_addr, FALSE);
|
||||
/* remove all cached GATT information */
|
||||
@@ -850,7 +829,6 @@ void bta_dm_remove_all_acl(tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
void bta_dm_bond (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTM_STATUS status;
|
||||
@@ -947,7 +925,6 @@ void bta_dm_pin_reply (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -990,9 +967,7 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
|
||||
|
||||
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
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1025,7 +1000,6 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
void bta_dm_confirm(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTM_STATUS res = BTM_NOT_AUTHORIZED;
|
||||
@@ -1035,7 +1009,6 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
BTM_ConfirmReqReply(res, p_data->confirm.bd_addr);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1046,7 +1019,7 @@ void bta_dm_confirm(tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
void bta_dm_loc_oob(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
@@ -1092,7 +1065,7 @@ void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data)
|
||||
BTM_RemoteOobDataReply(res, p_data->ci_rmt_oob.bd_addr,
|
||||
p_data->ci_rmt_oob.c, p_data->ci_rmt_oob.r );
|
||||
}
|
||||
#endif /* BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE */
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1108,7 +1081,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTM_INQUIRY_CMPL result;
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->search.num_uuid);
|
||||
bta_dm_gattc_register();
|
||||
#endif
|
||||
@@ -1126,7 +1099,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data)
|
||||
bta_dm_search_cb.p_search_cback = p_data->search.p_cback;
|
||||
bta_dm_search_cb.services = p_data->search.services;
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
utl_freebuf((void **)&bta_dm_search_cb.p_srvc_uuid);
|
||||
|
||||
if ((bta_dm_search_cb.num_uuid = p_data->search.num_uuid) != 0 &&
|
||||
@@ -1201,7 +1174,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
if (bta_dm_search_cb.gatt_disc_active) {
|
||||
bta_dm_cancel_gatt_discovery(bta_dm_search_cb.peer_bdaddr);
|
||||
}
|
||||
@@ -1218,10 +1191,9 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_dm_discover (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
UINT16 len = (UINT16)(sizeof(tBT_UUID) * p_data->discover.num_uuid);
|
||||
#endif
|
||||
APPL_TRACE_EVENT("%s services_to_search=0x%04X, sdp_search=%d", __func__,
|
||||
@@ -1230,7 +1202,7 @@ void bta_dm_discover (tBTA_DM_MSG *p_data)
|
||||
/* save the search condition */
|
||||
bta_dm_search_cb.services = p_data->discover.services;
|
||||
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
bta_dm_gattc_register();
|
||||
utl_freebuf((void **)&bta_dm_search_cb.p_srvc_uuid);
|
||||
if ((bta_dm_search_cb.num_uuid = p_data->discover.num_uuid) != 0 &&
|
||||
@@ -1307,7 +1279,7 @@ static void bta_dm_di_disc_callback(UINT16 result)
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_disable_search_and_disc
|
||||
@@ -1321,13 +1293,12 @@ static void bta_dm_di_disc_callback(UINT16 result)
|
||||
*******************************************************************************/
|
||||
static void bta_dm_disable_search_and_disc (void)
|
||||
{
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tBTA_DM_DI_DISC_CMPL di_disc;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
if (bta_dm_search_cb.state != BTA_DM_SEARCH_IDLE) {
|
||||
bta_dm_search_cancel(NULL);
|
||||
}
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
if (bta_dm_di_cb.p_di_db != NULL) {
|
||||
memset(&di_disc, 0, sizeof(tBTA_DM_DI_DISC_CMPL));
|
||||
bdcpy(di_disc.bd_addr, bta_dm_search_cb.peer_bdaddr);
|
||||
@@ -1336,7 +1307,6 @@ static void bta_dm_disable_search_and_disc (void)
|
||||
bta_dm_di_cb.p_di_db = NULL;
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DI_DISC_CMPL_EVT, NULL);
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1349,7 +1319,6 @@ static void bta_dm_disable_search_and_disc (void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_dm_di_disc (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
UINT16 result = BTA_FAILURE;
|
||||
@@ -1376,7 +1345,6 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1387,7 +1355,6 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
|
||||
** Returns TRUE if started to get remote name
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
{
|
||||
tBTM_STATUS btm_status;
|
||||
@@ -1419,7 +1386,6 @@ static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT tr
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1444,9 +1410,7 @@ void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data)
|
||||
/* start name and service discovery from the first device on inquiry result */
|
||||
bta_dm_search_cb.name_discover_done = FALSE;
|
||||
bta_dm_search_cb.peer_name[0] = 0;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_discover_device(bta_dm_search_cb.p_btm_inq_info->results.remote_bd_addr);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
} else {
|
||||
/* no devices, search complete */
|
||||
bta_dm_search_cb.services = 0;
|
||||
@@ -1475,9 +1439,8 @@ void bta_dm_rmt_name (tBTA_DM_MSG *p_data)
|
||||
if ( p_data->rem_name.result.disc_res.bd_name[0] && bta_dm_search_cb.p_btm_inq_info) {
|
||||
bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name = TRUE;
|
||||
}
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
bta_dm_discover_device(bta_dm_search_cb.peer_bdaddr);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1502,9 +1465,8 @@ void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data)
|
||||
p_btm_inq_info->appl_knows_rem_name = TRUE;
|
||||
}
|
||||
}
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
bta_dm_discover_device(p_data->rem_name.result.disc_res.bd_addr);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1516,9 +1478,9 @@ void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
|
||||
tSDP_DISC_REC *p_sdp_rec = NULL;
|
||||
tBTA_DM_MSG *p_msg;
|
||||
BOOLEAN scn_found = FALSE;
|
||||
@@ -1751,7 +1713,6 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDE == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1766,14 +1727,12 @@ void bta_dm_search_cmpl (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_EVENT("%s", __func__);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
utl_freebuf((void **)&bta_dm_search_cb.p_srvc_uuid);
|
||||
#endif
|
||||
|
||||
if (p_data->hdr.layer_specific == BTA_DM_API_DI_DISCOVER_EVT) {
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_di_disc_cmpl(p_data);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
} else {
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, NULL);
|
||||
}
|
||||
@@ -1876,7 +1835,6 @@ static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
@@ -1884,8 +1842,8 @@ void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data)
|
||||
GKI_freebuf(bta_dm_search_cb.p_sdp_db);
|
||||
bta_dm_search_cb.p_sdp_db = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1916,7 +1874,6 @@ void bta_dm_queue_search (tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_dm_queue_disc (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
if (bta_dm_search_cb.p_search_queue) {
|
||||
@@ -1925,8 +1882,8 @@ void bta_dm_queue_disc (tBTA_DM_MSG *p_data)
|
||||
|
||||
bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER));
|
||||
memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER));
|
||||
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1975,7 +1932,6 @@ void bta_dm_search_cancel_cmpl (tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
@@ -1986,7 +1942,6 @@ void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data)
|
||||
|
||||
bta_dm_search_cancel_notify(NULL);
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2007,7 +1962,7 @@ void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data)
|
||||
if (!bta_dm_search_cb.name_discover_done) {
|
||||
BTM_CancelRemoteDeviceName();
|
||||
}
|
||||
#if (BLE_INCLUDED == TRUE) && (BTA_GATT_INCLUDED == TRUE) && (SDP_INCLUDED == TRUE) && (GATTC_INCLUDED) == TRUE
|
||||
#if (BLE_INCLUDED == TRUE) && (BTA_GATT_INCLUDED == TRUE)
|
||||
if (bta_dm_search_cb.gatt_disc_active) {
|
||||
bta_dm_cancel_gatt_discovery(bta_dm_search_cb.peer_bdaddr);
|
||||
}
|
||||
@@ -2024,9 +1979,9 @@ void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
{
|
||||
|
||||
tSDP_UUID uuid;
|
||||
tBTA_DM_MSG *p_msg;
|
||||
|
||||
@@ -2133,7 +2088,6 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2155,9 +2109,7 @@ static void bta_dm_discover_next_device(void)
|
||||
if ((bta_dm_search_cb.p_btm_inq_info = BTM_InqDbNext(bta_dm_search_cb.p_btm_inq_info)) != NULL) {
|
||||
bta_dm_search_cb.name_discover_done = FALSE;
|
||||
bta_dm_search_cb.peer_name[0] = 0;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_discover_device(bta_dm_search_cb.p_btm_inq_info->results.remote_bd_addr);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
} else {
|
||||
/* no devices, search complete */
|
||||
bta_dm_search_cb.services = 0;
|
||||
@@ -2179,7 +2131,6 @@ static void bta_dm_discover_next_device(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
|
||||
{
|
||||
tBTA_DM_MSG *p_msg;
|
||||
@@ -2246,7 +2197,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
|
||||
bta_dm_search_cb.service_index = 0;
|
||||
bta_dm_search_cb.services_found = 0;
|
||||
bta_dm_search_cb.services_to_search = bta_dm_search_cb.services;
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
bta_dm_search_cb.uuid_to_search = bta_dm_search_cb.num_uuid;
|
||||
#endif
|
||||
if ((bta_dm_search_cb.p_btm_inq_info != NULL) &&
|
||||
@@ -2269,7 +2220,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
|
||||
bta_dm_search_cb.wait_disc = TRUE;
|
||||
}
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
if ( bta_dm_search_cb.p_btm_inq_info ) {
|
||||
APPL_TRACE_DEBUG("%s p_btm_inq_info %p results.device_type 0x%x services_to_search 0x%x",
|
||||
__func__,
|
||||
@@ -2340,7 +2291,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status)
|
||||
|
||||
}
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_inq_results_cb
|
||||
@@ -2502,7 +2453,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
|
||||
|
||||
BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
|
||||
|
||||
#if BLE_INCLUDED == TRUE && GATTS_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE
|
||||
if (bta_dm_search_cb.transport == BT_TRANSPORT_LE ) {
|
||||
GAP_BleReadPeerPrefConnParams (bta_dm_search_cb.peer_bdaddr);
|
||||
}
|
||||
@@ -2530,7 +2481,6 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
|
||||
UINT8 *service_name, UINT8 service_id, BOOLEAN is_originator)
|
||||
{
|
||||
@@ -2574,7 +2524,8 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
|
||||
return BTM_NOT_AUTHORIZED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2587,7 +2538,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_dm_pinname_cback (void *p_data)
|
||||
static void bta_dm_pinname_cback (void *p_data)
|
||||
{
|
||||
tBTM_REMOTE_DEV_NAME *p_result = (tBTM_REMOTE_DEV_NAME *)p_data;
|
||||
tBTA_DM_SEC sec_event;
|
||||
@@ -2763,7 +2714,6 @@ static UINT8 bta_dm_authentication_complete_cback(BD_ADDR bd_addr, DEV_CLASS dev
|
||||
return BTM_SUCCESS;
|
||||
}
|
||||
|
||||
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sp_cback
|
||||
@@ -2918,10 +2868,6 @@ static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data)
|
||||
APPL_TRACE_EVENT("dm status: %d", status);
|
||||
return status;
|
||||
}
|
||||
#endif /* (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) */
|
||||
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3254,7 +3200,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
if (conn.link_down.is_removed) {
|
||||
BTM_SecDeleteDevice(p_bda);
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection */
|
||||
BTA_GATTC_CancelOpen(0, p_bda, FALSE);
|
||||
/* remove all cached GATT information */
|
||||
@@ -3289,10 +3235,10 @@ 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)
|
||||
|
||||
/* disable the power managment module */
|
||||
bta_dm_disable_pm();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
|
||||
/* register our callback to SYS HW manager */
|
||||
bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
|
||||
|
||||
@@ -3355,9 +3301,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) {
|
||||
@@ -3366,9 +3310,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_WARNING("bta_dm_rm_cback:%d, status:%d", bta_dm_cb.cur_av_count, status);
|
||||
@@ -3409,7 +3351,6 @@ static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
|
||||
{
|
||||
UINT16 index = 0;
|
||||
@@ -3417,7 +3358,6 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
|
||||
BTM_IsAclConnectionUp(remote_bd_addr, BT_TRANSPORT_BR_EDR)) {
|
||||
APPL_TRACE_DEBUG("%s ACL is not down. Schedule for Dev Removal when ACL closes",
|
||||
__FUNCTION__);
|
||||
BTM_SecClearSecurityFlags (remote_bd_addr);
|
||||
for (index = 0; index < bta_dm_cb.device_list.count; index ++) {
|
||||
if (!bdcmp( bta_dm_cb.device_list.peer_device[index].peer_bdaddr, remote_bd_addr)) {
|
||||
break;
|
||||
@@ -3430,7 +3370,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
|
||||
}
|
||||
} else {
|
||||
BTM_SecDeleteDevice (remote_bd_addr);
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection */
|
||||
BTA_GATTC_CancelOpen(0, remote_bd_addr, FALSE);
|
||||
/* remove all cached GATT information */
|
||||
@@ -3438,7 +3378,6 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -3531,7 +3470,6 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch)
|
||||
**
|
||||
** Returns char * - Pointer to the remote device name
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE)
|
||||
static char *bta_dm_get_remname(void)
|
||||
{
|
||||
char *p_name = (char *)bta_dm_search_cb.peer_name;
|
||||
@@ -3545,7 +3483,6 @@ static char *bta_dm_get_remname(void)
|
||||
|
||||
return p_name;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3556,7 +3493,6 @@ static char *bta_dm_get_remname(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result)
|
||||
{
|
||||
|
||||
@@ -3572,7 +3508,6 @@ static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result)
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_BOND_CANCEL_CMPL_EVT, &sec_event);
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3842,7 +3777,6 @@ static void bta_dm_set_eir (char *local_name)
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result,
|
||||
tBTA_SERVICE_MASK *p_services_to_search,
|
||||
tBTA_SERVICE_MASK *p_services_found)
|
||||
@@ -3901,7 +3835,6 @@ static void bta_dm_eir_search_services( tBTM_INQ_RESULTS *p_result,
|
||||
APPL_TRACE_ERROR("BTA EIR search result, services_to_search=0x%08X, services_found=0x%08X",
|
||||
*p_services_to_search, *p_services_found);
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
|
||||
/*******************************************************************************
|
||||
@@ -4050,7 +3983,6 @@ void bta_dm_encrypt_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
void bta_dm_set_encryption (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
UINT8 i ;
|
||||
@@ -4082,7 +4014,6 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
@@ -4097,6 +4028,7 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
static void bta_dm_observe_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir)
|
||||
{
|
||||
;
|
||||
tBTA_DM_SEARCH result;
|
||||
tBTM_INQ_INFO *p_inq_info;
|
||||
APPL_TRACE_DEBUG("bta_dm_observe_results_cb")
|
||||
@@ -4107,8 +4039,6 @@ static void bta_dm_observe_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir)
|
||||
result.inq_res.inq_result_type = p_inq->inq_result_type;
|
||||
result.inq_res.device_type = p_inq->device_type;
|
||||
result.inq_res.flag = p_inq->flag;
|
||||
result.inq_res.adv_data_len = p_inq->adv_data_len;
|
||||
result.inq_res.scan_rsp_len = p_inq->scan_rsp_len;
|
||||
|
||||
/* application will parse EIR to find out remote device name */
|
||||
result.inq_res.p_eir = p_eir;
|
||||
@@ -4177,7 +4107,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
|
||||
switch (event) {
|
||||
case BTM_LE_IO_REQ_EVT:
|
||||
// #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
|
||||
bta_dm_co_ble_io_req(bda,
|
||||
&p_data->io_req.io_cap,
|
||||
@@ -4186,7 +4116,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
&p_data->io_req.max_key_size,
|
||||
&p_data->io_req.init_keys,
|
||||
&p_data->io_req.resp_keys);
|
||||
// #endif
|
||||
#endif
|
||||
#if BTM_OOB_INCLUDED == FALSE
|
||||
status = BTM_SUCCESS;
|
||||
#endif
|
||||
@@ -4265,7 +4195,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
} else {
|
||||
sec_event.auth_cmpl.success = TRUE;
|
||||
if (!p_data->complt.smp_over_br) {
|
||||
|
||||
GATT_ConfigServiceChangeCCC(bda, TRUE, BT_TRANSPORT_LE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4282,6 +4212,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
}
|
||||
return status;
|
||||
}
|
||||
#endif /* SMP_INCLUDED == TRUE */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -4418,7 +4349,6 @@ void bta_dm_security_grant (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_SecurityGrant(p_data->ble_sec_grant.bd_addr, p_data->ble_sec_grant.res);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -4525,19 +4455,6 @@ void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data)
|
||||
APPL_TRACE_ERROR("Update connection parameters failed!");
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_disconnect
|
||||
**
|
||||
** Description This function disconnect the ble connection.
|
||||
**
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_data->ble_disconnect.remote_bda);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -4550,15 +4467,17 @@ void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BOOLEAN set_flag = false;
|
||||
UINT8 len = sizeof(p_data->set_addr);
|
||||
if (len != BD_ADDR_LEN) {
|
||||
APPL_TRACE_ERROR("Invalid random adress");
|
||||
return;
|
||||
}
|
||||
if (p_data->set_addr.addr_type != BLE_ADDR_RANDOM) {
|
||||
APPL_TRACE_ERROR("Invalid random adress type = %d\n", p_data->set_addr.addr_type);
|
||||
return;
|
||||
}
|
||||
//send the setting random address to BTM layer
|
||||
if ((set_flag = BTM_BleSetRandAddress(p_data->set_addr.address) != TRUE)){
|
||||
APPL_TRACE_ERROR("%s,set random address fail.", __func__);
|
||||
}
|
||||
BTM_BleSetRandAddress(p_data->set_addr.address);
|
||||
|
||||
}
|
||||
|
||||
@@ -4594,7 +4513,7 @@ void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_BleConfigPrivacy (p_data->ble_local_privacy.privacy_enable, p_data->ble_local_privacy.set_local_privacy_cback);
|
||||
BTM_BleConfigPrivacy (p_data->ble_local_privacy.privacy_enable);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4613,28 +4532,17 @@ void bta_dm_ble_observe (tBTA_DM_MSG *p_data)
|
||||
if (p_data->ble_observe.start) {
|
||||
/*Save the callback to be called when a scan results are available */
|
||||
bta_dm_search_cb.p_scan_cback = p_data->ble_observe.p_cback;
|
||||
|
||||
if ((status = BTM_BleObserve(TRUE, p_data->ble_observe.duration,
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) {
|
||||
APPL_TRACE_WARNING(" %s start observe failed. status=0x%x\n", __FUNCTION__, status);
|
||||
APPL_TRACE_WARNING(" %s BTM_BleObserve failed. status %d\n", __FUNCTION__, status);
|
||||
}
|
||||
|
||||
if (p_data->ble_observe.p_start_scan_cback) {
|
||||
status = (status == BTM_CMD_STARTED ? BTA_SUCCESS : BTA_FAILURE);
|
||||
p_data->ble_observe.p_start_scan_cback(status);
|
||||
}
|
||||
} else {
|
||||
bta_dm_search_cb.p_scan_cback = NULL;
|
||||
status = BTM_BleObserve(FALSE, 0, NULL, NULL);
|
||||
|
||||
if (status != BTM_CMD_STARTED){
|
||||
APPL_TRACE_WARNING(" %s stop observe failed, status=0x%x\n", __FUNCTION__, status);
|
||||
}
|
||||
|
||||
if (p_data->ble_observe.p_stop_scan_cback) {
|
||||
status = (status == BTM_CMD_STARTED ? BTA_SUCCESS : BTA_FAILURE);
|
||||
p_data->ble_observe.p_stop_scan_cback(status);
|
||||
}
|
||||
BTM_BleObserve(FALSE, 0, NULL, NULL );
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
@@ -4788,25 +4696,9 @@ void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_data->ble_set_data_length.remote_bda, BT_TRANSPORT_LE);
|
||||
if (p_acl_cb == NULL) {
|
||||
APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__);
|
||||
return;
|
||||
} else {
|
||||
p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback;
|
||||
}
|
||||
UINT8 status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
|
||||
p_data->ble_set_data_length.tx_data_length);
|
||||
if (status != BTM_SUCCESS) {
|
||||
if (BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
|
||||
p_data->ble_set_data_length.tx_data_length) != BTM_SUCCESS) {
|
||||
APPL_TRACE_ERROR("%s failed\n", __FUNCTION__);
|
||||
if (p_data->ble_set_data_length.p_set_pkt_data_cback) {
|
||||
if (p_acl_cb->data_length_params.tx_len == 0){
|
||||
uint16_t length = controller_get_interface()->get_acl_data_size_ble();
|
||||
p_acl_cb->data_length_params.rx_len = length;
|
||||
p_acl_cb->data_length_params.tx_len = length;
|
||||
}
|
||||
(*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4821,20 +4713,7 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
tBTM_STATUS status = 0;
|
||||
BOOLEAN start = p_data->ble_observe.start;
|
||||
|
||||
status = BTM_BleBroadcast(start);
|
||||
|
||||
if (p_data->ble_observe.p_stop_adv_cback){
|
||||
if (status != BTM_SUCCESS){
|
||||
APPL_TRACE_WARNING("%s, %s, status=0x%x\n", __func__,\
|
||||
(start == TRUE) ? "start adv failed" : "stop adv failed", status);
|
||||
}
|
||||
status = (status == BTM_SUCCESS ? BTA_SUCCESS : BTA_FAILURE);
|
||||
p_data->ble_observe.p_stop_adv_cback(status);
|
||||
}
|
||||
|
||||
BTM_BleBroadcast(p_data->ble_observe.start);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5281,11 +5160,11 @@ static void bta_ble_energy_info_cmpl(tBTM_BLE_TX_TIME_MS tx_time,
|
||||
{
|
||||
tBTA_STATUS st = (status == BTM_SUCCESS) ? BTA_SUCCESS : BTA_FAILURE;
|
||||
tBTA_DM_CONTRL_STATE ctrl_state = 0;
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
|
||||
if (BTA_SUCCESS == st) {
|
||||
ctrl_state = bta_dm_pm_obtain_controller_state();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bta_dm_cb.p_energy_info_cback) {
|
||||
bta_dm_cb.p_energy_info_cback(tx_time, rx_time, idle_time, energy_used, ctrl_state, st);
|
||||
}
|
||||
@@ -5311,7 +5190,7 @@ void bta_dm_ble_get_energy_info(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
#ifndef BTA_DM_GATT_CLOSE_DELAY_TOUT
|
||||
#define BTA_DM_GATT_CLOSE_DELAY_TOUT 1000
|
||||
#endif
|
||||
@@ -5326,7 +5205,6 @@ void bta_dm_ble_get_energy_info(tBTA_DM_MSG *p_data)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
static void bta_dm_gattc_register(void)
|
||||
{
|
||||
tBT_UUID app_uuid = {LEN_UUID_128, {0}};
|
||||
@@ -5336,7 +5214,7 @@ static void bta_dm_gattc_register(void)
|
||||
BTA_GATTC_AppRegister(&app_uuid, bta_dm_gattc_callback);
|
||||
}
|
||||
}
|
||||
#endif /* GATTC_INCLUDED == TRUE */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_dm_start_disc_gatt_services
|
||||
@@ -5367,7 +5245,6 @@ static void btm_dm_start_disc_gatt_services (UINT16 conn_id)
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id)
|
||||
{
|
||||
tBTA_DM_SEARCH result;
|
||||
@@ -5407,7 +5284,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id)
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result);
|
||||
}
|
||||
}
|
||||
#endif /* #if (GATTC_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_gatt_disc_complete
|
||||
@@ -5484,7 +5361,6 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status)
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
@@ -5496,7 +5372,6 @@ void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data)
|
||||
memset(bta_dm_search_cb.pending_close_bda, 0, BD_ADDR_LEN);
|
||||
bta_dm_search_cb.conn_id = BTA_GATT_INVALID_CONN_ID;
|
||||
}
|
||||
#endif /* #if (GATTC_INCLUDED == TRUE) */
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_dm_start_gatt_discovery
|
||||
@@ -5507,7 +5382,6 @@ void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data)
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
|
||||
{
|
||||
bta_dm_search_cb.gatt_disc_active = TRUE;
|
||||
@@ -5522,7 +5396,7 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
|
||||
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, TRUE, BTA_GATT_TRANSPORT_LE);
|
||||
}
|
||||
}
|
||||
#endif /* #if (GATTC_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_cancel_gatt_discovery
|
||||
@@ -5532,7 +5406,6 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
static void bta_dm_cancel_gatt_discovery(BD_ADDR bd_addr)
|
||||
{
|
||||
if (bta_dm_search_cb.conn_id == BTA_GATT_INVALID_CONN_ID) {
|
||||
@@ -5541,7 +5414,7 @@ static void bta_dm_cancel_gatt_discovery(BD_ADDR bd_addr)
|
||||
|
||||
bta_dm_gatt_disc_complete(bta_dm_search_cb.conn_id, (tBTA_GATT_STATUS) BTA_GATT_ERROR);
|
||||
}
|
||||
#endif /* #if (GATTC_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_proc_open_evt
|
||||
@@ -5589,7 +5462,6 @@ void bta_dm_proc_open_evt(tBTA_GATTC_OPEN *p_data)
|
||||
** Parameters:
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
static void bta_dm_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
{
|
||||
APPL_TRACE_DEBUG("bta_dm_gattc_callback event = %d", event);
|
||||
@@ -5632,7 +5504,7 @@ static void bta_dm_gattc_callback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* #if (GATTC_INCLUDED == TRUE) */
|
||||
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
#if BLE_VND_INCLUDED == TRUE
|
||||
|
||||
@@ -276,7 +276,6 @@ void BTA_DmSearchCancel(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
|
||||
{
|
||||
@@ -292,6 +291,7 @@ void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
|
||||
p_msg->sdp_search = sdp_search;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -324,8 +324,8 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
|
||||
memcpy( &p_msg->uuid, uuid, sizeof(tSDP_UUID) );
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -338,7 +338,6 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
void BTA_DmBond(BD_ADDR bd_addr)
|
||||
{
|
||||
tBTA_DM_API_BOND *p_msg;
|
||||
@@ -430,7 +429,7 @@ void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin
|
||||
|
||||
}
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmLocalOob
|
||||
@@ -551,7 +550,6 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
|
||||
|
||||
return BTA_SUCCESS;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -615,7 +613,7 @@ UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr )
|
||||
return (p_dev && p_dev->conn_state == BTA_DM_CONNECTED);
|
||||
}
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
** Device Identification (DI) Server Functions
|
||||
*******************************************************************************/
|
||||
@@ -647,7 +645,7 @@ tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dmexecutecallback
|
||||
@@ -687,10 +685,10 @@ void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK *p_callback, void *p_param)
|
||||
** BTA_FAIL if operation failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#if SMP_INCLUDED == TRUE
|
||||
void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_TYPE key_type)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
||||
tBTA_DM_API_ADD_BLEKEY *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL) {
|
||||
@@ -704,6 +702,7 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -723,6 +722,7 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
|
||||
*******************************************************************************/
|
||||
void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL) {
|
||||
@@ -735,6 +735,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -752,6 +753,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
|
||||
*******************************************************************************/
|
||||
void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_DM_API_PASSKEY_REPLY *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL) {
|
||||
@@ -766,6 +768,7 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
|
||||
}
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -781,6 +784,7 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM));
|
||||
if (p_msg != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
|
||||
@@ -789,6 +793,7 @@ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
|
||||
p_msg->accept = accept;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -805,6 +810,7 @@ void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_DM_API_BLE_SEC_GRANT *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL) {
|
||||
@@ -816,9 +822,8 @@ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1328,7 +1333,7 @@ extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb)
|
||||
extern void BTA_DmBleBroadcast (BOOLEAN start)
|
||||
{
|
||||
tBTA_DM_API_BLE_OBSERVE *p_msg;
|
||||
|
||||
@@ -1339,9 +1344,6 @@ extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT;
|
||||
p_msg->start = start;
|
||||
if (start == FALSE){
|
||||
p_msg->p_stop_adv_cback= p_start_stop_adv_cb;
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
@@ -1388,7 +1390,7 @@ void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
|
||||
tBTA_TRANSPORT transport)
|
||||
@@ -1442,7 +1444,7 @@ void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_service
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search,
|
||||
tBTA_TRANSPORT transport)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport);
|
||||
#endif
|
||||
}
|
||||
@@ -1466,7 +1468,7 @@ void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_service
|
||||
void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services,
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search)
|
||||
{
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, BTA_TRANSPORT_UNKNOWN);
|
||||
#endif
|
||||
|
||||
@@ -1575,7 +1577,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback)
|
||||
void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
|
||||
{
|
||||
///This function used the irk to generate the resolve address
|
||||
#if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
|
||||
@@ -1586,7 +1588,7 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
|
||||
p_msg->privacy_enable = privacy_enable;
|
||||
p_msg->set_local_privacy_cback = set_local_privacy_cback;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
#else
|
||||
@@ -2004,33 +2006,11 @@ void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max
|
||||
p_msg->max_int = max_int;
|
||||
p_msg->latency = latency;
|
||||
p_msg->timeout = timeout;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleDisconnect
|
||||
**
|
||||
** Description Disconnect the ble connection, can only be used when connection is up.
|
||||
**
|
||||
** Parameters: bd_addr - BD address of the peer
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleDisconnect(BD_ADDR bd_addr)
|
||||
{
|
||||
tBTA_DM_API_BLE_DISCONNECT *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_BLE_DISCONNECT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_DISCONNECT))) != NULL) {
|
||||
memset (p_msg, 0, sizeof(tBTA_DM_API_BLE_DISCONNECT));
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_DISCONNECT_EVT;
|
||||
bdcpy(p_msg->remote_bda, bd_addr);
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetDataLength
|
||||
@@ -2041,7 +2021,7 @@ void BTA_DmBleDisconnect(BD_ADDR bd_addr)
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback)
|
||||
void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
|
||||
{
|
||||
tBTA_DM_API_BLE_SET_DATA_LENGTH *p_msg;
|
||||
|
||||
@@ -2050,7 +2030,6 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_S
|
||||
bdcpy(p_msg->remote_bda, remote_device);
|
||||
p_msg->hdr.event = BTA_DM_API_SET_DATA_LENGTH_EVT;
|
||||
p_msg->tx_data_length = tx_data_length;
|
||||
p_msg->p_set_pkt_data_cback = p_set_pkt_data_cback;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
@@ -2080,7 +2059,6 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_S
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback,
|
||||
tBTA_DM_BLE_SEC_ACT sec_act)
|
||||
{
|
||||
@@ -2100,7 +2078,6 @@ void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCR
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2150,9 +2127,9 @@ void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transpor
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration,
|
||||
extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
|
||||
tBTA_DM_SEARCH_CBACK *p_results_cb,
|
||||
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb)
|
||||
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cb)
|
||||
{
|
||||
tBTA_DM_API_BLE_OBSERVE *p_msg;
|
||||
|
||||
@@ -2165,12 +2142,7 @@ extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration,
|
||||
p_msg->start = start;
|
||||
p_msg->duration = duration;
|
||||
p_msg->p_cback = p_results_cb;
|
||||
if (start){
|
||||
p_msg->p_start_scan_cback = p_start_stop_scan_cb;
|
||||
}
|
||||
else {
|
||||
p_msg->p_stop_scan_cback = p_start_stop_scan_cb;
|
||||
}
|
||||
p_msg->p_start_scan_cback = p_start_scan_cb;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,6 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1]
|
||||
#endif
|
||||
};
|
||||
|
||||
#define BTA_DM_PM_SPEC_TO_OFFSET (197) /* timeout offset to avoid conflict with other bluedroid host */
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
/* AG : 0 */
|
||||
{
|
||||
@@ -161,15 +160,15 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_SNIFF_SCO_OPEN_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_SNIFF_SCO_OPEN_IDX, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
{{BTA_DM_PM_RETRY, 7000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
@@ -180,15 +179,15 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(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_PARK, 5000}, {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_SNIFF_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
|
||||
{{BTA_DM_PM_PARK, 5000}, {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 */
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
@@ -199,13 +198,13 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(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_SNIFF, 5000}, {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_SNIFF, 1000}, {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 */
|
||||
}
|
||||
@@ -218,13 +217,13 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(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_SNIFF_HD_ACTIVE_IDX, 5000}, {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_IDLE_IDX, 5000}, {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 */
|
||||
}
|
||||
@@ -237,13 +236,13 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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 */
|
||||
}
|
||||
@@ -256,14 +255,14 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(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_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY}, {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_SNIFF_HH_IDLE_IDX, BTA_DM_PM_HH_IDLE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
@@ -281,7 +280,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
{{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_SNIFF_A2DP_IDX, 5000}, {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 */
|
||||
}
|
||||
@@ -300,7 +299,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
{{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_SNIFF_A2DP_IDX, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS}, {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 */
|
||||
}
|
||||
@@ -313,7 +312,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(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_SNIFF_A2DP_IDX, 5000}, {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 */
|
||||
@@ -338,7 +337,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
{{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_SNIFF_A2DP_IDX, 5000}, {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 */
|
||||
}
|
||||
@@ -357,7 +356,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
{{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_SNIFF_A2DP_IDX, 5000}, {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 */
|
||||
@@ -371,15 +370,15 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {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_SNIFF3, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF3, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
{{BTA_DM_PM_RETRY, 7000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
@@ -390,13 +389,13 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 3000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_SNIFF, 3000}, {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_SNIFF4, 3000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF4, 3000}, {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 */
|
||||
}
|
||||
@@ -410,18 +409,18 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {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, 10000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
#if defined(AMP_INCLUDED) && (AMP_INCLUDED == TRUE)
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
|
||||
#endif
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
/* GATTS : 14 */
|
||||
@@ -442,7 +441,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
#if defined(AMP_INCLUDED) && (AMP_INCLUDED == TRUE)
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
|
||||
#endif
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "bta_dm_ci.h"
|
||||
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ci_io_req
|
||||
|
||||
@@ -57,24 +57,22 @@ enum {
|
||||
BTA_DM_ACL_CHANGE_EVT,
|
||||
BTA_DM_API_ADD_DEVICE_EVT,
|
||||
BTA_DM_API_REMOVE_ACL_EVT,
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
/* security API events */
|
||||
BTA_DM_API_BOND_EVT,
|
||||
BTA_DM_API_BOND_CANCEL_EVT,
|
||||
BTA_DM_API_PIN_REPLY_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
|
||||
/* power manger events */
|
||||
BTA_DM_PM_BTM_STATUS_EVT,
|
||||
BTA_DM_PM_TIMER_EVT,
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
/* simple pairing events */
|
||||
BTA_DM_API_CONFIRM_EVT,
|
||||
|
||||
BTA_DM_API_SET_ENCRYPTION_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
BTA_DM_API_LOC_OOB_EVT,
|
||||
BTA_DM_CI_IO_REQ_EVT,
|
||||
BTA_DM_CI_RMT_OOB_EVT,
|
||||
@@ -82,13 +80,11 @@ enum {
|
||||
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#if SMP_INCLUDED == TRUE
|
||||
BTA_DM_API_ADD_BLEKEY_EVT,
|
||||
BTA_DM_API_ADD_BLEDEVICE_EVT,
|
||||
BTA_DM_API_BLE_PASSKEY_REPLY_EVT,
|
||||
BTA_DM_API_BLE_CONFIRM_REPLY_EVT,
|
||||
BTA_DM_API_BLE_SEC_GRANT_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
BTA_DM_API_BLE_SET_BG_CONN_TYPE,
|
||||
BTA_DM_API_BLE_CONN_PARAM_EVT,
|
||||
BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
|
||||
@@ -136,7 +132,6 @@ enum {
|
||||
BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT,
|
||||
BTA_DM_API_BLE_TRACK_ADVERTISER_EVT,
|
||||
BTA_DM_API_BLE_ENERGY_INFO_EVT,
|
||||
BTA_DM_API_BLE_DISCONNECT_EVT,
|
||||
|
||||
#endif
|
||||
|
||||
@@ -206,7 +201,6 @@ typedef struct {
|
||||
#endif
|
||||
} tBTA_DM_API_SEARCH;
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* data type for BTA_DM_API_DISCOVER_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -221,15 +215,12 @@ typedef struct {
|
||||
#endif
|
||||
tSDP_UUID uuid;
|
||||
} tBTA_DM_API_DISCOVER;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/* data type for BTA_DM_API_DI_DISC_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tBTA_DISCOVERY_DB *p_sdp_db;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
UINT32 len;
|
||||
tBTA_DM_SEARCH_CBACK *p_cback;
|
||||
} tBTA_DM_API_DI_DISC;
|
||||
@@ -444,7 +435,6 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN privacy_enable;
|
||||
tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||
} tBTA_DM_API_LOCAL_PRIVACY;
|
||||
|
||||
/* set scan parameter for BLE connections */
|
||||
@@ -480,18 +470,15 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN start;
|
||||
UINT32 duration;
|
||||
UINT16 duration;
|
||||
tBTA_DM_SEARCH_CBACK *p_cback;
|
||||
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_scan_cback;
|
||||
tBTA_START_STOP_SCAN_CMPL_CBACK *p_stop_scan_cback;
|
||||
tBTA_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback;
|
||||
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cback;
|
||||
} tBTA_DM_API_BLE_OBSERVE;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
UINT16 tx_data_length;
|
||||
tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback;
|
||||
} tBTA_DM_API_BLE_SET_DATA_LENGTH;
|
||||
|
||||
/* set the address for BLE device
|
||||
@@ -616,11 +603,6 @@ typedef struct {
|
||||
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
|
||||
} tBTA_DM_API_ENERGY_INFO;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_DM_API_BLE_DISCONNECT;
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
|
||||
@@ -691,9 +673,9 @@ typedef union {
|
||||
tBTA_DM_API_REMOVE_DEVICE remove_dev;
|
||||
|
||||
tBTA_DM_API_SEARCH search;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
tBTA_DM_API_DISCOVER discover;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
tBTA_DM_API_BOND bond;
|
||||
|
||||
tBTA_DM_API_BOND_CANCEL bond_cancel;
|
||||
@@ -761,7 +743,6 @@ typedef union {
|
||||
tBTA_DM_API_DISABLE_SCAN ble_disable_scan;
|
||||
tBTA_DM_API_TRACK_ADVERTISER ble_track_advert;
|
||||
tBTA_DM_API_ENERGY_INFO ble_energy_info;
|
||||
tBTA_DM_API_BLE_DISCONNECT ble_disconnect;
|
||||
#endif
|
||||
|
||||
tBTA_DM_API_REMOVE_ACL remove_acl;
|
||||
@@ -887,10 +868,8 @@ 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
|
||||
UINT8 pm_id;
|
||||
tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
|
||||
#endif ///BTM_SSR_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 */
|
||||
@@ -937,9 +916,7 @@ typedef struct {
|
||||
tBTA_SERVICE_MASK services;
|
||||
tBTA_SERVICE_MASK services_to_search;
|
||||
tBTA_SERVICE_MASK services_found;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tSDP_DISCOVERY_DB *p_sdp_db;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
UINT16 state;
|
||||
BD_ADDR peer_bdaddr;
|
||||
BOOLEAN name_discover_done;
|
||||
@@ -949,16 +926,14 @@ typedef struct {
|
||||
tBTA_DM_MSG *p_search_queue; /* search or discover commands during search cancel stored here */
|
||||
BOOLEAN wait_disc;
|
||||
BOOLEAN sdp_results;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tSDP_UUID uuid;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
UINT8 peer_scn;
|
||||
BOOLEAN sdp_search;
|
||||
BOOLEAN cancel_pending; /* inquiry cancel is pending */
|
||||
tBTA_TRANSPORT transport;
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||
tBTA_DM_SEARCH_CBACK *p_scan_cback;
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT8 num_uuid;
|
||||
tBT_UUID *p_srvc_uuid;
|
||||
@@ -978,9 +953,7 @@ typedef struct {
|
||||
|
||||
/* DI control block */
|
||||
typedef struct {
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tSDP_DISCOVERY_DB *p_di_db; /* pointer to the DI discovery database */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
UINT8 di_num; /* total local DI record number */
|
||||
UINT32 di_handle[BTA_DI_NUM_MAX]; /* local DI record handle, the first one is primary record */
|
||||
} tBTA_DM_DI_CB;
|
||||
@@ -1129,12 +1102,9 @@ extern void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_conn_scan_params (tBTA_DM_MSG *p_data);
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
|
||||
#endif /* ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE) */
|
||||
extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
||||
@@ -1180,14 +1150,10 @@ extern UINT8 bta_dm_get_av_count(void);
|
||||
extern void bta_dm_search_start (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_search_cancel (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_discover (tBTA_DM_MSG *p_data);
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
extern void bta_dm_di_disc (tBTA_DM_MSG *p_data);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
extern void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_rmt_name (tBTA_DM_MSG *p_data);
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
extern void bta_dm_sdp_result (tBTA_DM_MSG *p_data);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
extern void bta_dm_search_cmpl (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_disc_result (tBTA_DM_MSG *p_data);
|
||||
|
||||
@@ -54,23 +54,22 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_close_acl, /* 10 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
/* security API events */
|
||||
bta_dm_bond, /* 11 BTA_DM_API_BOND_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)
|
||||
|
||||
/* 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
|
||||
|
||||
/* simple pairing events */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
|
||||
|
||||
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
|
||||
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
|
||||
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
|
||||
@@ -78,13 +77,11 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#if SMP_INCLUDED == TRUE
|
||||
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
|
||||
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
|
||||
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
|
||||
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
|
||||
bta_dm_security_grant,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
bta_dm_ble_set_bg_conn_type,
|
||||
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
|
||||
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
|
||||
@@ -131,7 +128,6 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
|
||||
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
|
||||
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
|
||||
bta_dm_ble_disconnect, /* BTA_DM_API_BLE_DISCONNECT_EVT */
|
||||
#endif
|
||||
|
||||
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
|
||||
@@ -148,37 +144,25 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
enum {
|
||||
BTA_DM_API_SEARCH, /* 0 bta_dm_search_start */
|
||||
BTA_DM_API_SEARCH_CANCEL, /* 1 bta_dm_search_cancel */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_API_DISCOVER, /* 2 bta_dm_discover */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_INQUIRY_CMPL, /* 3 bta_dm_inq_cmpl */
|
||||
BTA_DM_REMT_NAME, /* 4 bta_dm_rmt_name */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */
|
||||
BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */
|
||||
BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_QUEUE_DISC, /* 11 bta_dm_queue_disc */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_SEARCH_CLEAR_QUEUE, /* 12 bta_dm_search_clear_queue */
|
||||
BTA_DM_SEARCH_CANCEL_CMPL, /* 13 bta_dm_search_cancel_cmpl */
|
||||
BTA_DM_SEARCH_CANCEL_NOTIFY, /* 14 bta_dm_search_cancel_notify */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, /* 15 bta_dm_search_cancel_transac_cmpl */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_DISC_RMT_NAME, /* 16 bta_dm_disc_rmt_name */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_API_DI_DISCOVER, /* 17 bta_dm_di_disc */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE
|
||||
BTA_DM_CLOSE_GATT_CONN, /* 18 bta_dm_close_gatt_conn */
|
||||
#endif /* BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE */
|
||||
#endif
|
||||
BTA_DM_SEARCH_NUM_ACTIONS /* 19 */
|
||||
};
|
||||
|
||||
@@ -188,35 +172,23 @@ const tBTA_DM_ACTION bta_dm_search_action[] = {
|
||||
|
||||
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
|
||||
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
|
||||
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
|
||||
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
|
||||
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
|
||||
bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
|
||||
bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE
|
||||
, bta_dm_close_gatt_conn
|
||||
#endif
|
||||
};
|
||||
@@ -235,22 +207,15 @@ const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_SEARCH */ {BTA_DM_API_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
// #if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}
|
||||
#endif
|
||||
};
|
||||
const UINT8 bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
@@ -261,14 +226,11 @@ const UINT8 bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
/* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* INQUIRY_CMPL */ {BTA_DM_INQUIRY_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* REMT_NAME_EVT */ {BTA_DM_REMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
// #if BLE_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
#endif
|
||||
|
||||
@@ -279,16 +241,12 @@ const UINT8 bta_dm_search_search_cancelling_st_table[][BTA_DM_SEARCH_NUM_COLS] =
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_SEARCH */ {BTA_DM_QUEUE_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CLEAR_QUEUE, BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_CANCELLING},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* REMT_NAME_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
|
||||
@@ -304,9 +262,7 @@ const UINT8 bta_dm_search_disc_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
/* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* REMT_NAME_EVT */ {BTA_DM_DISC_RMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_DISC_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "bta_dm_int.h"
|
||||
#include "btm_api.h"
|
||||
|
||||
#if (BTM_SSR_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,
|
||||
@@ -46,7 +45,6 @@ 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)
|
||||
@@ -55,6 +53,7 @@ static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
#define BTA_DM_PM_SSR_HH BTA_DM_PM_SSR1
|
||||
#endif
|
||||
static void bta_dm_pm_ssr(BD_ADDR peer_addr);
|
||||
#endif
|
||||
|
||||
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
@@ -701,9 +700,7 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
#endif
|
||||
|
||||
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 ||
|
||||
@@ -1016,8 +1013,6 @@ 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
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1042,7 +1037,6 @@ tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
return p_dev;
|
||||
}
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_is_sco_active
|
||||
@@ -1139,9 +1133,8 @@ 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
|
||||
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_obtain_controller_state
|
||||
@@ -1163,4 +1156,3 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void)
|
||||
return cur_state;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
|
||||
#include "bta_gattc_int.h"
|
||||
#include "l2c_api.h"
|
||||
#include "l2c_int.h"
|
||||
#include "gatt_int.h"
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
#include "bta_hh_int.h"
|
||||
@@ -45,7 +43,7 @@
|
||||
|
||||
// #include "osi/include/log.h"
|
||||
|
||||
#if GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE
|
||||
#if BTA_GATT_INCLUDED && BLE_INCLUDED == TRUE
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
@@ -63,10 +61,6 @@ static void bta_gattc_cmpl_sendmsg(UINT16 conn_id, tGATTC_OPTYPE op,
|
||||
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 tGATT_CBACK bta_gattc_cl_cback = {
|
||||
bta_gattc_conn_cback,
|
||||
@@ -686,45 +680,6 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
p_clcb->bta_conn_id,
|
||||
p_clcb->transport,
|
||||
p_clcb->p_srcb->mtu);
|
||||
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_conncback
|
||||
**
|
||||
** Description receive connection callback from stack
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (p_rcb) {
|
||||
bta_gattc_send_connect_cback(p_rcb,
|
||||
BTA_GATT_OK,
|
||||
p_data->int_conn.remote_bda,
|
||||
p_data->int_conn.hdr.layer_specific);
|
||||
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_disconncback
|
||||
**
|
||||
** Description receive disconnection callback from stack
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (p_rcb) {
|
||||
bta_gattc_send_disconnect_cback(p_rcb,
|
||||
BTA_GATT_OK,
|
||||
p_data->int_conn.remote_bda,
|
||||
p_data->int_conn.hdr.layer_specific);
|
||||
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
@@ -861,6 +816,9 @@ void bta_gattc_set_discover_st(tBTA_GATTC_SERV *p_srcb)
|
||||
tBTA_GATTC_CB *p_cb = &bta_gattc_cb;
|
||||
UINT8 i;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
L2CA_EnableUpdateBleConnParams(p_srcb->server_bda, FALSE);
|
||||
#endif
|
||||
for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++) {
|
||||
if (p_cb->clcb[i].p_srcb == p_srcb) {
|
||||
p_cb->clcb[i].status = BTA_GATT_OK;
|
||||
@@ -990,6 +948,11 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
|
||||
APPL_TRACE_DEBUG("bta_gattc_disc_cmpl conn_id=%d", p_clcb->bta_conn_id);
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
if (p_clcb->transport == BTA_TRANSPORT_LE) {
|
||||
L2CA_EnableUpdateBleConnParams(p_clcb->p_srcb->server_bda, TRUE);
|
||||
}
|
||||
#endif
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
|
||||
p_clcb->disc_active = FALSE;
|
||||
|
||||
@@ -1010,17 +973,13 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
|
||||
if (p_clcb->auto_update == BTA_GATTC_DISC_WAITING) {
|
||||
/* start discovery again */
|
||||
p_clcb->auto_update = BTA_GATTC_REQ_WAITING;
|
||||
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
|
||||
}
|
||||
/* get any queued command to proceed */
|
||||
else if (p_q_cmd != NULL) {
|
||||
p_clcb->p_q_cmd = NULL;
|
||||
/* execute pending operation of link block still present */
|
||||
if (l2cu_find_lcb_by_bd_addr(p_clcb->p_srcb->server_bda,
|
||||
BT_TRANSPORT_LE) != NULL) {
|
||||
bta_gattc_sm_execute(p_clcb, p_q_cmd->hdr.event, p_q_cmd);
|
||||
}
|
||||
|
||||
bta_gattc_sm_execute(p_clcb, p_q_cmd->hdr.event, p_q_cmd);
|
||||
/* if the command executed requeued the cmd, we don't
|
||||
* want to free the underlying buffer that's being
|
||||
* referenced by p_clcb->p_q_cmd
|
||||
@@ -1694,7 +1653,6 @@ static void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB *p_clreg)
|
||||
p_cb->state = BTA_GATTC_STATE_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_conn_cback
|
||||
@@ -1709,54 +1667,20 @@ 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)){
|
||||
result = bta_gattc_register_service_change_notify(conn_id, bda, &start_ccc_timer);
|
||||
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){
|
||||
GKI_freebuf((void *)p_conn->service_change_ccc_timer.param);
|
||||
bta_sys_stop_timer(&(p_conn->service_change_ccc_timer));
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bt_bdaddr_t bdaddr;
|
||||
bdcpy(bdaddr.address, bda);
|
||||
|
||||
/*
|
||||
if (connected)
|
||||
btif_debug_conn_state(bdaddr, BTIF_DEBUG_CONNECTED, GATT_CONN_UNKNOWN);
|
||||
else
|
||||
btif_debug_conn_state(bdaddr, BTIF_DEBUG_DISCONNECTED, reason);
|
||||
*/
|
||||
if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
|
||||
|
||||
@@ -2274,224 +2198,5 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
(*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** 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*) GKI_getbuf(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.
|
||||
**
|
||||
** Returns Return result of service change ccc service discovery result result and written operate result
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda, BOOLEAN *need_timer){
|
||||
tBTA_GATTC_SERV *p_srcb = NULL;
|
||||
tBTA_GATTC_CACHE *p_cache = NULL;
|
||||
tBTA_GATT_ID result_id;
|
||||
tBTA_GATT_ID *p_result = &result_id;
|
||||
tBTA_GATTC_CACHE_ATTR *p_attr = 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}};
|
||||
tBT_UUID gatt_ccc_uuid = {LEN_UUID_16, {GATT_UUID_CHAR_CLIENT_CONFIG}};
|
||||
|
||||
p_srcb = bta_gattc_find_srcb(remote_bda);
|
||||
if ((p_srcb != NULL) && (p_srcb->p_srvc_cache != NULL)){
|
||||
p_cache = p_srcb->p_srvc_cache;
|
||||
gatt_cache_found = TRUE;
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CACHE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* start to find gatt service */
|
||||
if (gatt_cache_found == TRUE){
|
||||
while (p_cache) {
|
||||
if (bta_gattc_uuid_compare(&gatt_service_uuid, &p_cache->service_uuid.id.uuid, TRUE)) {
|
||||
gatt_service_found = TRUE;
|
||||
break;
|
||||
}
|
||||
p_cache = p_cache->p_next;
|
||||
}
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CACHE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* start to find gatt service change characteristic */
|
||||
if (gatt_service_found == TRUE){
|
||||
p_attr = p_cache->p_attr;
|
||||
|
||||
while(p_attr){
|
||||
bta_gattc_pack_attr_uuid(p_attr, &p_result->uuid);
|
||||
if (bta_gattc_uuid_compare(&gatt_service_change_uuid, &p_result->uuid, TRUE)){
|
||||
gatt_service_change_found = TRUE;
|
||||
break;
|
||||
}
|
||||
p_attr = p_attr->p_next;
|
||||
}
|
||||
}
|
||||
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 */
|
||||
if (gatt_service_change_found == TRUE){
|
||||
p_attr = p_attr->p_next;
|
||||
|
||||
while(p_attr && p_attr->attr_type != BTA_GATTC_ATTR_TYPE_CHAR){
|
||||
bta_gattc_pack_attr_uuid(p_attr, &p_result->uuid);
|
||||
if (bta_gattc_uuid_compare(&gatt_ccc_uuid, &p_result->uuid, TRUE)){
|
||||
gatt_ccc_found = TRUE;
|
||||
break;
|
||||
}
|
||||
p_attr = p_attr->p_next;
|
||||
}
|
||||
}
|
||||
else if (gatt_service_found ==TRUE){
|
||||
/* Gatt service found, but service change char not found,
|
||||
* Case1: remote device doesn't have service change char, we don't need to start a timer here to
|
||||
* 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_attr->attr_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;
|
||||
}
|
||||
}
|
||||
else if (gatt_service_change_found == TRUE){
|
||||
/* Gatt service char found, but service change char ccc not found,
|
||||
* Case1: remote device doesn't have service change char ccc, we don't need to start a timer here to
|
||||
* 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;
|
||||
|
||||
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) p_tle->param;
|
||||
if (p_timer_param == NULL){
|
||||
APPL_TRACE_ERROR("p_timer_param is NULL in %s\n", __func__);
|
||||
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__);
|
||||
GKI_freebuf(p_timer_param);
|
||||
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;
|
||||
}
|
||||
|
||||
GKI_freebuf(p_timer_param);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif ///GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "gki.h"
|
||||
@@ -792,58 +792,6 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_PrepareWriteCharDescr
|
||||
**
|
||||
** Description This function is called to prepare write a characteristic descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_descr_id - GATT characteritic descriptor ID of the service.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
|
||||
UINT16 offset,tBTA_GATT_UNFMT *p_data,
|
||||
tBTA_GATT_AUTH_REQ auth_req)
|
||||
{
|
||||
tBTA_GATTC_API_WRITE *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTC_API_WRITE) + sizeof(tBTA_GATT_ID);
|
||||
|
||||
if (p_data != NULL) {
|
||||
len += p_data->len;
|
||||
}
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
|
||||
p_buf->hdr.layer_specific = conn_id;
|
||||
p_buf->auth_req = auth_req;
|
||||
|
||||
memcpy(&p_buf->srvc_id, &p_char_descr_id->char_id.srvc_id, sizeof(tBTA_GATT_SRVC_ID));
|
||||
memcpy(&p_buf->char_id, &p_char_descr_id->char_id.char_id, sizeof(tBTA_GATT_ID));
|
||||
p_buf->p_descr_type = (tBTA_GATT_ID *)(p_buf + 1);
|
||||
memcpy(p_buf->p_descr_type, &p_char_descr_id->descr_id, sizeof(tBTA_GATT_ID));
|
||||
p_buf->write_type = BTA_GATTC_WRITE_PREPARE;
|
||||
p_buf->offset = offset;
|
||||
|
||||
if (p_data && p_data->len != 0) {
|
||||
p_buf->p_value = (UINT8 *)(p_buf->p_descr_type + 1);
|
||||
p_buf->len = p_data->len;
|
||||
/* pack the descr data */
|
||||
memcpy(p_buf->p_value, p_data->p_value, p_data->len);
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "utl.h"
|
||||
@@ -36,16 +36,14 @@
|
||||
#include "bta_gattc_int.h"
|
||||
#include "btm_api.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "l2c_api.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);
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb);
|
||||
|
||||
#define BTA_GATT_SDP_DB_SIZE 4096
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
@@ -459,9 +457,7 @@ tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV
|
||||
if (p_clcb->transport == BTA_TRANSPORT_LE) {
|
||||
status = bta_gattc_discover_procedure(conn_id, p_server_cb, disc_type);
|
||||
} else {
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
status = bta_gattc_sdp_service_disc(conn_id, p_server_cb);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,13 +585,6 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
bta_gattc_display_cache_server(p_srvc_cb->p_srvc_cache);
|
||||
#endif
|
||||
//server discover end, update connection parameters
|
||||
#if BLE_INCLUDED == TRUE
|
||||
if (p_clcb->transport == BTA_TRANSPORT_LE) {
|
||||
L2CA_EnableUpdateBleConnParams(p_clcb->p_srcb->server_bda, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* save cache to NV */
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_SAVE;
|
||||
bta_gattc_co_cache_open(p_srvc_cb->server_bda, BTA_GATTC_CI_CACHE_OPEN_EVT,
|
||||
@@ -797,7 +786,6 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_list(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
void bta_gattc_sdp_callback (UINT16 sdp_status)
|
||||
{
|
||||
tSDP_DISC_REC *p_sdp_rec = NULL;
|
||||
@@ -855,8 +843,6 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
|
||||
bta_gattc_cb.p_sdp_db = NULL;
|
||||
bta_gattc_cb.sdp_conn_id = 0;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_sdp_service_disc
|
||||
@@ -866,7 +852,6 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb)
|
||||
{
|
||||
tSDP_UUID uuid;
|
||||
@@ -897,8 +882,6 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
|
||||
}
|
||||
return status;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_disc_res_cback
|
||||
@@ -1521,5 +1504,5 @@ BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif /* GATTC_INCLUDED */
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -133,4 +133,4 @@ void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
|
||||
bta_sys_sendmsg(p_evt);
|
||||
}
|
||||
}
|
||||
#endif /* GATTC_INCLUDED */
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if (GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -400,16 +400,7 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
|
||||
default:
|
||||
if (p_msg->event == BTA_GATTC_INT_CONN_EVT) {
|
||||
p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA *) p_msg);
|
||||
p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->int_conn.client_if);
|
||||
if (p_clreg != NULL){
|
||||
bta_gattc_conncback(p_clreg, (tBTA_GATTC_DATA *) p_msg);
|
||||
}
|
||||
|
||||
} else if (p_msg->event == BTA_GATTC_INT_DISCONN_EVT) {
|
||||
p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->int_conn.client_if);
|
||||
if (p_clreg != NULL){
|
||||
bta_gattc_disconncback(p_clreg, (tBTA_GATTC_DATA *) p_msg);
|
||||
}
|
||||
p_clcb = bta_gattc_find_int_disconn_clcb((tBTA_GATTC_DATA *) p_msg);
|
||||
} else {
|
||||
p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);
|
||||
@@ -531,4 +522,4 @@ static char *gattc_state_code(tBTA_GATTC_STATE state_code)
|
||||
}
|
||||
|
||||
#endif /* Debug Functions */
|
||||
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -770,58 +770,6 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
|
||||
(*p_clreg->p_cback)(BTA_GATTC_OPEN_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_send_connect_cback
|
||||
**
|
||||
** Description send connect callback
|
||||
**
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id)
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if (p_clreg->p_cback) {
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
cb_data.connect.status = status;
|
||||
cb_data.connect.client_if = p_clreg->client_if;
|
||||
cb_data.connect.conn_id = conn_id;
|
||||
bdcpy(cb_data.connect.remote_bda, remote_bda);
|
||||
|
||||
(*p_clreg->p_cback)(BTA_GATTC_CONNECT_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_send_disconnect_cback
|
||||
**
|
||||
** Description send disconnect callback
|
||||
**
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id)
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if (p_clreg->p_cback) {
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
cb_data.disconnect.status = status;
|
||||
cb_data.disconnect.client_if = p_clreg->client_if;
|
||||
cb_data.disconnect.conn_id = conn_id;
|
||||
bdcpy(cb_data.disconnect.remote_bda, remote_bda);
|
||||
|
||||
(*p_clreg->p_cback)(BTA_GATTC_DISCONNECT_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_conn_alloc
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include "utl.h"
|
||||
#include "gki.h"
|
||||
@@ -503,31 +503,26 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_
|
||||
void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
UINT16 service_id = p_srvc_cb->service_id;
|
||||
UINT16 attr_id = 0;
|
||||
tBTA_GATTS cb_data;
|
||||
tBTA_GATT_STATUS gatts_status;
|
||||
gatts_status = GATTS_SetAttributeValue(p_msg->api_set_val.hdr.layer_specific,
|
||||
gatts_status = GATTS_SetAttributeValue(p_msg->api_add_char_descr.hdr.layer_specific,
|
||||
p_msg->api_set_val.length,
|
||||
p_msg->api_set_val.value);
|
||||
|
||||
cb_data.attr_val.server_if = p_rcb->gatt_if;
|
||||
cb_data.attr_val.service_id = service_id;
|
||||
cb_data.attr_val.attr_id = p_msg->api_set_val.hdr.layer_specific;
|
||||
cb_data.attr_val.service_id = p_msg->api_set_val.hdr.layer_specific;
|
||||
cb_data.attr_val.attr_id = attr_id;
|
||||
cb_data.attr_val.status = gatts_status;
|
||||
|
||||
if (p_msg->api_set_val.value != NULL){
|
||||
GKI_freebuf(p_msg->api_set_val.value);
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_SET_ATTR_VAL_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
tGATT_STATUS bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
void bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
{
|
||||
|
||||
return GATTS_GetAttributeValue(attr_handle, length, value);
|
||||
GATTS_GetAttributeValue(attr_handle, length, value);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -611,7 +606,7 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_ms
|
||||
cb_data.srvc_oper.server_if = p_rcb->gatt_if;
|
||||
cb_data.srvc_oper.service_id = p_srvc_cb->service_id;
|
||||
cb_data.srvc_oper.status = BTA_GATT_OK;
|
||||
APPL_TRACE_DEBUG("bta_gatts_stop_service service_id= %d", p_srvc_cb->service_id);
|
||||
APPL_TRACE_ERROR("bta_gatts_stop_service service_id= %d", p_srvc_cb->service_id);
|
||||
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_STOP_EVT, &cb_data);
|
||||
@@ -715,7 +710,6 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
tBTA_GATTS_RCB *p_rcb = NULL;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTS_OPEN open;
|
||||
UNUSED(p_cb);
|
||||
|
||||
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) {
|
||||
@@ -734,9 +728,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
}
|
||||
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
open.status = status;
|
||||
open.server_if = p_msg->api_open.server_if;
|
||||
(*p_rcb->p_cback)(BTA_GATTS_OPEN_EVT, (tBTA_GATTS *)&open);
|
||||
(*p_rcb->p_cback)(BTA_GATTS_OPEN_EVT, (tBTA_GATTS *)&status);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -753,7 +745,6 @@ void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
tBTA_GATTS_CANCEL_OPEN cancel_open;
|
||||
UNUSED(p_cb);
|
||||
|
||||
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_cancel_open.server_if)) != NULL) {
|
||||
@@ -768,10 +759,7 @@ void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
}
|
||||
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
cancel_open.status = status;
|
||||
cancel_open.server_if = p_msg->api_cancel_open.server_if;
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CANCEL_OPEN_EVT, (tBTA_GATTS *)&cancel_open);
|
||||
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CANCEL_OPEN_EVT, (tBTA_GATTS *)&status);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
@@ -790,7 +778,7 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
tGATT_IF gatt_if;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
tBTA_GATTS_CLOSE close;
|
||||
|
||||
UNUSED(p_cb);
|
||||
|
||||
if (GATT_GetConnectionInfor(p_msg->hdr.layer_specific, &gatt_if, remote_bda, &transport)) {
|
||||
@@ -807,9 +795,7 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
bta_sys_conn_close( BTA_ID_GATTS , BTA_ALL_APP_ID, remote_bda);
|
||||
}
|
||||
|
||||
close.status = status;
|
||||
close.conn_id = p_msg->hdr.layer_specific;
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CLOSE_EVT, (tBTA_GATTS *)&close);
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CLOSE_EVT, (tBTA_GATTS *)&status);
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Unknown connection ID: %d", p_msg->hdr.layer_specific);
|
||||
@@ -977,4 +963,4 @@ static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* GATTS_INCLUDED */
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "gki.h"
|
||||
@@ -490,9 +490,9 @@ void BTA_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *value)
|
||||
|
||||
}
|
||||
|
||||
tBTA_GATT_STATUS BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
void BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value)
|
||||
{
|
||||
return bta_gatts_get_attr_value(attr_handle, length, value);
|
||||
bta_gatts_get_attr_value(attr_handle, length, value);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -136,4 +136,4 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#endif /* GATTS_INCLUDED */
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
#if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "utl.h"
|
||||
@@ -222,4 +222,4 @@ BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src)
|
||||
|
||||
|
||||
|
||||
#endif /* GATTS_INCLUDED */
|
||||
#endif
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
#include "bt_target.h"
|
||||
#include "bta_hh_api.h"
|
||||
|
||||
#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
|
||||
|
||||
|
||||
/* max number of device types supported by BTA */
|
||||
#define BTA_HH_MAX_DEVT_SPT 9
|
||||
|
||||
@@ -61,4 +58,3 @@ const tBTA_HH_CFG bta_hh_cfg = {
|
||||
|
||||
|
||||
tBTA_HH_CFG *p_bta_hh_cfg = (tBTA_HH_CFG *) &bta_hh_cfg;
|
||||
#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
|
||||
@@ -32,7 +32,6 @@
|
||||
//#if BTA_HH_LE_INCLUDED == TRUE
|
||||
#include "bta_gatt_api.h"
|
||||
//#endif
|
||||
#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
|
||||
|
||||
/* can be moved to bta_api.h */
|
||||
#define BTA_HH_MAX_RPT_CHARS 8
|
||||
@@ -396,6 +395,5 @@ extern void bta_hh_ci_load_rpt (tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf);
|
||||
extern void bta_hh_trace_dev_db(void);
|
||||
#endif
|
||||
|
||||
#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -402,10 +402,6 @@ typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
|
||||
|
||||
typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
|
||||
|
||||
/* advertising channel map */
|
||||
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
|
||||
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
|
||||
@@ -639,7 +635,7 @@ typedef struct {
|
||||
} tBTA_DM_PIN_REQ;
|
||||
|
||||
/* BLE related definition */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
#define BTA_DM_AUTH_FAIL_BASE (HCI_ERR_MAX_ERR + 10)
|
||||
#define BTA_DM_AUTH_CONVERT_SMP_CODE(x) (BTA_DM_AUTH_FAIL_BASE + (x))
|
||||
#define BTA_DM_AUTH_SMP_PASSKEY_FAIL BTA_DM_AUTH_CONVERT_SMP_CODE (SMP_PASSKEY_ENTRY_FAIL)
|
||||
@@ -659,7 +655,7 @@ typedef struct {
|
||||
#define BTA_DM_AUTH_SMP_BUSY (BTA_DM_AUTH_FAIL_BASE + SMP_BUSY)
|
||||
#define BTA_DM_AUTH_SMP_ENC_FAIL (BTA_DM_AUTH_FAIL_BASE + SMP_ENC_FAIL)
|
||||
#define BTA_DM_AUTH_SMP_RSP_TIMEOUT (BTA_DM_AUTH_FAIL_BASE + SMP_RSP_TIMEOUT)
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
/* connection parameter boundary value and dummy value */
|
||||
#define BTA_DM_BLE_SCAN_INT_MIN BTM_BLE_SCAN_INT_MIN
|
||||
#define BTA_DM_BLE_SCAN_INT_MAX BTM_BLE_SCAN_INT_MAX
|
||||
@@ -672,14 +668,13 @@ typedef struct {
|
||||
#define BTA_DM_BLE_CONN_SUP_TOUT_MAX BTM_BLE_CONN_SUP_TOUT_MAX
|
||||
#define BTA_DM_BLE_CONN_PARAM_UNDEF BTM_BLE_CONN_PARAM_UNDEF /* use this value when a specific value not to be overwritten */
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
#define BTA_LE_KEY_PENC BTM_LE_KEY_PENC /* encryption information of peer device */
|
||||
#define BTA_LE_KEY_PID BTM_LE_KEY_PID /* identity key of the peer device */
|
||||
#define BTA_LE_KEY_PCSRK BTM_LE_KEY_PCSRK /* peer SRK */
|
||||
#define BTA_LE_KEY_LENC BTM_LE_KEY_LENC /* master role security information:div */
|
||||
#define BTA_LE_KEY_LID BTM_LE_KEY_LID /* master device ID key */
|
||||
#define BTA_LE_KEY_LCSRK BTM_LE_KEY_LCSRK /* local CSRK has been deliver to peer */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
typedef UINT8 tBTA_LE_KEY_TYPE; /* can be used as a bit mask */
|
||||
|
||||
|
||||
@@ -707,11 +702,10 @@ typedef struct {
|
||||
BT_OCTET16 irk;
|
||||
BT_OCTET16 dhk;
|
||||
} tBTA_BLE_LOCAL_ID_KEYS;
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
#define BTA_DM_SEC_GRANTED BTA_SUCCESS
|
||||
#define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
|
||||
#define BTA_DM_SEC_REP_ATTEMPTS BTA_DM_AUTH_SMP_REPEATED_ATTEMPT
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
typedef UINT8 tBTA_DM_BLE_SEC_GRANT;
|
||||
|
||||
|
||||
@@ -722,10 +716,6 @@ typedef UINT8 tBTA_DM_BLE_CONN_TYPE;
|
||||
|
||||
typedef BOOLEAN (tBTA_DM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
|
||||
|
||||
typedef tBTM_LE_UPDATE_CONN_PRAMS tBTA_LE_UPDATE_CONN_PRAMS;
|
||||
typedef tBTM_UPDATE_CONN_PARAM_CBACK tBTA_UPDATE_CONN_PARAM_CBACK;
|
||||
|
||||
|
||||
/* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
@@ -820,7 +810,6 @@ typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
|
||||
#define BTA_AUTH_GEN_BOND BTM_AUTH_SPGB_NO /* 4 this bit is set for general bonding */
|
||||
#define BTA_AUTH_BONDS BTM_AUTH_BONDS /* 6 the general/dedicated bonding bits */
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
#define BTA_LE_AUTH_NO_BOND BTM_LE_AUTH_REQ_NO_BOND /* 0*/
|
||||
#define BTA_LE_AUTH_BOND BTM_LE_AUTH_REQ_BOND /* 1 << 0 */
|
||||
#define BTA_LE_AUTH_REQ_MITM BTM_LE_AUTH_REQ_MITM /* 1 << 2 */
|
||||
@@ -829,7 +818,6 @@ typedef tBTM_AUTH_REQ tBTA_AUTH_REQ;
|
||||
#define BTA_LE_AUTH_REQ_SC_BOND BTM_LE_AUTH_REQ_SC_BOND /* 1001 */
|
||||
#define BTA_LE_AUTH_REQ_SC_MITM BTM_LE_AUTH_REQ_SC_MITM /* 1100 */
|
||||
#define BTA_LE_AUTH_REQ_SC_MITM_BOND BTM_LE_AUTH_REQ_SC_MITM_BOND /* 1101 */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
typedef tBTM_LE_AUTH_REQ tBTA_LE_AUTH_REQ; /* combination of the above bit pattern */
|
||||
|
||||
#define BTA_OOB_NONE BTM_OOB_NONE
|
||||
@@ -1015,8 +1003,6 @@ typedef struct {
|
||||
tBTM_BLE_EVT_TYPE ble_evt_type;
|
||||
tBT_DEVICE_TYPE device_type;
|
||||
UINT8 flag;
|
||||
UINT8 adv_data_len;
|
||||
UINT8 scan_rsp_len;
|
||||
#endif
|
||||
|
||||
} tBTA_DM_INQ_RES;
|
||||
@@ -1075,7 +1061,6 @@ 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 */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#define BTA_DM_BLE_SEC_NONE BTM_BLE_SEC_NONE
|
||||
#define BTA_DM_BLE_SEC_ENCRYPT BTM_BLE_SEC_ENCRYPT
|
||||
@@ -1112,9 +1097,7 @@ typedef void (tBTA_BLE_SCAN_SETUP_CBACK) (tBTA_BLE_BATCH_SCAN_EVT evt,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value,
|
||||
tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_START_STOP_SCAN_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_START_STOP_ADV_CMPL_CBACK) (tBTA_STATUS status);
|
||||
typedef void (tBTA_START_SCAN_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status,
|
||||
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
|
||||
@@ -1298,7 +1281,7 @@ typedef void (tBTA_DM_SWITCH_CBACK)(tBTA_DM_SWITCH_EVT event, tBTA_STATUS status
|
||||
|
||||
typedef UINT8 tBTA_DM_ROUTE_PATH;
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
/* Device Identification (DI) data structure
|
||||
*/
|
||||
/* Used to set the DI record */
|
||||
@@ -1307,7 +1290,6 @@ typedef tSDP_DI_RECORD tBTA_DI_RECORD;
|
||||
typedef tSDP_DI_GET_RECORD tBTA_DI_GET_RECORD;
|
||||
/* SDP discovery database */
|
||||
typedef tSDP_DISCOVERY_DB tBTA_DISCOVERY_DB;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
#ifndef BTA_DI_NUM_MAX
|
||||
#define BTA_DI_NUM_MAX 3
|
||||
@@ -1460,9 +1442,9 @@ extern void BTA_DmSearchCancel(void);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
|
||||
|
||||
// btla-specific ++
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1477,7 +1459,7 @@ extern void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
|
||||
tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmGetCachedRemoteName
|
||||
@@ -1633,7 +1615,7 @@ extern void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services );
|
||||
*******************************************************************************/
|
||||
extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmSetLocalDiRecord
|
||||
@@ -1645,7 +1627,7 @@ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
|
||||
*******************************************************************************/
|
||||
extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
|
||||
UINT32 *p_handle );
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
**
|
||||
@@ -2018,9 +2000,9 @@ extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration,
|
||||
extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
|
||||
tBTA_DM_SEARCH_CBACK *p_results_cb,
|
||||
tBTA_START_STOP_SCAN_CMPL_CBACK *p_start_stop_scan_cb);
|
||||
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cb);
|
||||
|
||||
extern void BTA_DmBleStopAdvertising(void);
|
||||
|
||||
@@ -2037,11 +2019,11 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr);
|
||||
** Description Enable/disable privacy on the local device
|
||||
**
|
||||
** Parameters: privacy_enable - enable/disabe privacy on remote device.
|
||||
** set_local_privacy_cback -callback to be called with result
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback);
|
||||
extern void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2127,12 +2109,11 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l
|
||||
** Description This function starts or stops LE broadcasting.
|
||||
**
|
||||
** Parameters start: start or stop broadcast.
|
||||
** p_start_stop_adv_cb: stop broadcast completed event
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p_start_stop_adv_cb);
|
||||
extern void BTA_DmBleBroadcast (BOOLEAN start);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2212,17 +2193,6 @@ extern void BTA_BleDisableAdvInstance(UINT8 inst_id);
|
||||
extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
|
||||
UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleDisconnect
|
||||
**
|
||||
** Description This function is to disconnect the ble connection
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleDisconnect(BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetDataLength
|
||||
@@ -2232,7 +2202,7 @@ extern void BTA_DmBleDisconnect(BD_ADDR bd_addr);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback);
|
||||
extern void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 is the public interface file for the simulatenous advanced
|
||||
* audio/video streaming (AV) source and sink of BTA, Broadcom's Bluetooth
|
||||
* application layer for mobile phones.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AR_API_H
|
||||
#define BTA_AR_API_H
|
||||
|
||||
#include "avdt_api.h"
|
||||
#include "avct_api.h"
|
||||
#include "avrc_api.h"
|
||||
#include "sdp_api.h"
|
||||
#include "bta_av_api.h"
|
||||
#include "bta_sys.h"
|
||||
|
||||
#if (BTA_AR_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
/* This event signal to AR user that other profile is connected */
|
||||
#define BTA_AR_AVDT_CONN_EVT (AVDT_MAX_EVT + 1)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_init
|
||||
**
|
||||
** Description This function is called from bta_sys_init().
|
||||
** to initialize the control block
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_ar_init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avdt
|
||||
**
|
||||
** Description This function is called to register to AVDTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_ar_reg_avdt(tAVDT_REG *p_reg, tAVDT_CTRL_CBACK *p_cback, tBTA_SYS_ID sys_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_dereg_avdt
|
||||
**
|
||||
** Description This function is called to de-register from AVDTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_ar_dereg_avdt(tBTA_SYS_ID sys_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_avdt_conn
|
||||
**
|
||||
** Description This function is called to let ar know that some AVDTP profile
|
||||
** is connected for this sys_id.
|
||||
** If the other sys modules started a timer for PENDING_EVT,
|
||||
** the timer can be stopped now.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_ar_avdt_conn(tBTA_SYS_ID sys_id, BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avct
|
||||
**
|
||||
** Description This function is called to register to AVCTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_ar_reg_avct(UINT16 mtu, UINT16 mtu_br, UINT8 sec_mask, tBTA_SYS_ID sys_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_ar_dereg_avct
|
||||
**
|
||||
** Description This function is called to deregister from AVCTP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_ar_dereg_avct(tBTA_SYS_ID sys_id);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function bta_ar_reg_avrc
|
||||
**
|
||||
** Description This function is called to register an SDP record for AVRCP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
******************************************************************************/
|
||||
extern void bta_ar_reg_avrc(UINT16 service_uuid, char *p_service_name,
|
||||
char *p_provider_name, UINT16 categories, tBTA_SYS_ID sys_id);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function bta_ar_dereg_avrc
|
||||
**
|
||||
** Description This function is called to de-register/delete an SDP record for AVRCP.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
******************************************************************************/
|
||||
extern void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///BTA_AR_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AR_API_H */
|
||||
@@ -1,812 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 is the public interface file for the advanced audio/video streaming
|
||||
* (AV) subsystem of BTA, Broadcom's Bluetooth application layer for mobile
|
||||
* phones.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AV_API_H
|
||||
#define BTA_AV_API_H
|
||||
|
||||
#include "avrc_api.h"
|
||||
#include "avdt_api.h"
|
||||
#include "a2d_api.h"
|
||||
#include "bta_api.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
/* Set to TRUE if seperate authorization prompt desired for AVCTP besides A2DP authorization */
|
||||
/* Typically FALSE when AVRCP is used in conjunction with A2DP */
|
||||
#ifndef BTA_AV_WITH_AVCTP_AUTHORIZATION
|
||||
#define BTA_AV_WITH_AVCTP_AUTHORIZATION FALSE
|
||||
#endif
|
||||
|
||||
/* AV status values */
|
||||
#define BTA_AV_SUCCESS 0 /* successful operation */
|
||||
#define BTA_AV_FAIL 1 /* generic failure */
|
||||
#define BTA_AV_FAIL_SDP 2 /* service not found */
|
||||
#define BTA_AV_FAIL_STREAM 3 /* stream connection failed */
|
||||
#define BTA_AV_FAIL_RESOURCES 4 /* no resources */
|
||||
#define BTA_AV_FAIL_ROLE 5 /* failed due to role management related issues */
|
||||
#define BTA_AV_FAIL_GET_CAP 6 /* get capability failed due to no SEP availale on the peer */
|
||||
|
||||
typedef UINT8 tBTA_AV_STATUS;
|
||||
|
||||
/* AV features masks */
|
||||
#define BTA_AV_FEAT_RCTG 0x0001 /* remote control target */
|
||||
#define BTA_AV_FEAT_RCCT 0x0002 /* remote control controller */
|
||||
#define BTA_AV_FEAT_PROTECT 0x0004 /* streaming media contect protection */
|
||||
#define BTA_AV_FEAT_VENDOR 0x0008 /* remote control vendor dependent commands */
|
||||
#define BTA_AV_FEAT_REPORT 0x0020 /* use reporting service for VDP */
|
||||
#define BTA_AV_FEAT_METADATA 0x0040 /* remote control Metadata Transfer command/response */
|
||||
#define BTA_AV_FEAT_MULTI_AV 0x0080 /* use multi-av, if controller supports it */
|
||||
#define BTA_AV_FEAT_BROWSE 0x0010 /* use browsing channel */
|
||||
#define BTA_AV_FEAT_MASTER 0x0100 /* stream only as master role */
|
||||
#define BTA_AV_FEAT_ADV_CTRL 0x0200 /* remote control Advanced Control command/response */
|
||||
#define BTA_AV_FEAT_DELAY_RPT 0x0400 /* allow delay reporting */
|
||||
#define BTA_AV_FEAT_ACP_START 0x0800 /* start stream when 2nd SNK was accepted */
|
||||
|
||||
/* Internal features */
|
||||
#define BTA_AV_FEAT_NO_SCO_SSPD 0x8000 /* Do not suspend av streaming as to AG events(SCO or Call) */
|
||||
|
||||
typedef UINT16 tBTA_AV_FEAT;
|
||||
|
||||
/* AV channel values */
|
||||
#define BTA_AV_CHNL_MSK 0xC0
|
||||
#define BTA_AV_CHNL_AUDIO 0x40 /* audio channel */
|
||||
#define BTA_AV_CHNL_VIDEO 0x80 /* video channel */
|
||||
typedef UINT8 tBTA_AV_CHNL;
|
||||
|
||||
|
||||
#define BTA_AV_HNDL_MSK 0x3F
|
||||
typedef UINT8 tBTA_AV_HNDL;
|
||||
/* handle index to mask */
|
||||
#define BTA_AV_HNDL_TO_MSK(h) ((UINT8)(1 << (h)))
|
||||
|
||||
/* tBTA_AV_HNDL to mask */
|
||||
#define BTA_AV_HNDL_TYPE_TO_MSK(h) ((UINT8)(1 << (h&BTA_AV_HNDL_MSK)))
|
||||
|
||||
/* offset of codec type in codec info byte array */
|
||||
#define BTA_AV_CODEC_TYPE_IDX AVDT_CODEC_TYPE_INDEX /* 2 */
|
||||
|
||||
|
||||
|
||||
/* maximum number of streams created: 1 for audio, 1 for video */
|
||||
#ifndef BTA_AV_NUM_STRS
|
||||
#define BTA_AV_NUM_STRS 2
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_MAX_SEPS
|
||||
#define BTA_AV_MAX_SEPS 2
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_MAX_A2DP_MTU
|
||||
/*#define BTA_AV_MAX_A2DP_MTU 668 //224 (DM5) * 3 - 4(L2CAP header) */
|
||||
#define BTA_AV_MAX_A2DP_MTU 1008
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_MAX_VDP_MTU
|
||||
#define BTA_AV_MAX_VDP_MTU 1008
|
||||
#endif
|
||||
|
||||
|
||||
/* codec type */
|
||||
#define BTA_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */
|
||||
#define BTA_AV_CODEC_M12 A2D_MEDIA_CT_M12 /* MPEG-1, 2 Audio media codec type */
|
||||
#define BTA_AV_CODEC_M24 A2D_MEDIA_CT_M24 /* MPEG-2, 4 AAC media codec type */
|
||||
#define BTA_AV_CODEC_ATRAC A2D_MEDIA_CT_ATRAC /* ATRAC family media codec type */
|
||||
#define BTA_AV_CODEC_H263_P0 VDP_MEDIA_CT_H263_P0 /* H.263 baseline (profile 0) */
|
||||
#define BTA_AV_CODEC_MPEG4 VDP_MEDIA_CT_MPEG4 /* MPEG-4 Visual Simple Profile */
|
||||
#define BTA_AV_CODEC_H263_P3 VDP_MEDIA_CT_H263_P3 /* H.263 profile 3 */
|
||||
#define BTA_AV_CODEC_H263_P8 VDP_MEDIA_CT_H263_P8 /* H.263 profile 8 */
|
||||
#define BTA_AV_CODEC_VEND VDP_MEDIA_CT_VEND /* Non-VDP */
|
||||
|
||||
typedef UINT8 tBTA_AV_CODEC;
|
||||
|
||||
/* Company ID in BT assigned numbers */
|
||||
#define BTA_AV_BT_VENDOR_ID VDP_BT_VENDOR_ID /* Broadcom Corporation */
|
||||
|
||||
/* vendor specific codec ID */
|
||||
#define BTA_AV_CODEC_ID_H264 VDP_CODEC_ID_H264 /* Non-VDP codec ID - H.264 */
|
||||
#define BTA_AV_CODEC_ID_IMG VDP_CODEC_ID_IMG /* Non-VDP codec ID - images/slideshow */
|
||||
|
||||
/* operation id list for BTA_AvRemoteCmd */
|
||||
#define BTA_AV_RC_SELECT AVRC_ID_SELECT /* select */
|
||||
#define BTA_AV_RC_UP AVRC_ID_UP /* up */
|
||||
#define BTA_AV_RC_DOWN AVRC_ID_DOWN /* down */
|
||||
#define BTA_AV_RC_LEFT AVRC_ID_LEFT /* left */
|
||||
#define BTA_AV_RC_RIGHT AVRC_ID_RIGHT /* right */
|
||||
#define BTA_AV_RC_RIGHT_UP AVRC_ID_RIGHT_UP /* right-up */
|
||||
#define BTA_AV_RC_RIGHT_DOWN AVRC_ID_RIGHT_DOWN /* right-down */
|
||||
#define BTA_AV_RC_LEFT_UP AVRC_ID_LEFT_UP /* left-up */
|
||||
#define BTA_AV_RC_LEFT_DOWN AVRC_ID_LEFT_DOWN /* left-down */
|
||||
#define BTA_AV_RC_ROOT_MENU AVRC_ID_ROOT_MENU /* root menu */
|
||||
#define BTA_AV_RC_SETUP_MENU AVRC_ID_SETUP_MENU /* setup menu */
|
||||
#define BTA_AV_RC_CONT_MENU AVRC_ID_CONT_MENU /* contents menu */
|
||||
#define BTA_AV_RC_FAV_MENU AVRC_ID_FAV_MENU /* favorite menu */
|
||||
#define BTA_AV_RC_EXIT AVRC_ID_EXIT /* exit */
|
||||
#define BTA_AV_RC_0 AVRC_ID_0 /* 0 */
|
||||
#define BTA_AV_RC_1 AVRC_ID_1 /* 1 */
|
||||
#define BTA_AV_RC_2 AVRC_ID_2 /* 2 */
|
||||
#define BTA_AV_RC_3 AVRC_ID_3 /* 3 */
|
||||
#define BTA_AV_RC_4 AVRC_ID_4 /* 4 */
|
||||
#define BTA_AV_RC_5 AVRC_ID_5 /* 5 */
|
||||
#define BTA_AV_RC_6 AVRC_ID_6 /* 6 */
|
||||
#define BTA_AV_RC_7 AVRC_ID_7 /* 7 */
|
||||
#define BTA_AV_RC_8 AVRC_ID_8 /* 8 */
|
||||
#define BTA_AV_RC_9 AVRC_ID_9 /* 9 */
|
||||
#define BTA_AV_RC_DOT AVRC_ID_DOT /* dot */
|
||||
#define BTA_AV_RC_ENTER AVRC_ID_ENTER /* enter */
|
||||
#define BTA_AV_RC_CLEAR AVRC_ID_CLEAR /* clear */
|
||||
#define BTA_AV_RC_CHAN_UP AVRC_ID_CHAN_UP /* channel up */
|
||||
#define BTA_AV_RC_CHAN_DOWN AVRC_ID_CHAN_DOWN /* channel down */
|
||||
#define BTA_AV_RC_PREV_CHAN AVRC_ID_PREV_CHAN /* previous channel */
|
||||
#define BTA_AV_RC_SOUND_SEL AVRC_ID_SOUND_SEL /* sound select */
|
||||
#define BTA_AV_RC_INPUT_SEL AVRC_ID_INPUT_SEL /* input select */
|
||||
#define BTA_AV_RC_DISP_INFO AVRC_ID_DISP_INFO /* display information */
|
||||
#define BTA_AV_RC_HELP AVRC_ID_HELP /* help */
|
||||
#define BTA_AV_RC_PAGE_UP AVRC_ID_PAGE_UP /* page up */
|
||||
#define BTA_AV_RC_PAGE_DOWN AVRC_ID_PAGE_DOWN /* page down */
|
||||
#define BTA_AV_RC_POWER AVRC_ID_POWER /* power */
|
||||
#define BTA_AV_RC_VOL_UP AVRC_ID_VOL_UP /* volume up */
|
||||
#define BTA_AV_RC_VOL_DOWN AVRC_ID_VOL_DOWN /* volume down */
|
||||
#define BTA_AV_RC_MUTE AVRC_ID_MUTE /* mute */
|
||||
#define BTA_AV_RC_PLAY AVRC_ID_PLAY /* play */
|
||||
#define BTA_AV_RC_STOP AVRC_ID_STOP /* stop */
|
||||
#define BTA_AV_RC_PAUSE AVRC_ID_PAUSE /* pause */
|
||||
#define BTA_AV_RC_RECORD AVRC_ID_RECORD /* record */
|
||||
#define BTA_AV_RC_REWIND AVRC_ID_REWIND /* rewind */
|
||||
#define BTA_AV_RC_FAST_FOR AVRC_ID_FAST_FOR /* fast forward */
|
||||
#define BTA_AV_RC_EJECT AVRC_ID_EJECT /* eject */
|
||||
#define BTA_AV_RC_FORWARD AVRC_ID_FORWARD /* forward */
|
||||
#define BTA_AV_RC_BACKWARD AVRC_ID_BACKWARD /* backward */
|
||||
#define BTA_AV_RC_ANGLE AVRC_ID_ANGLE /* angle */
|
||||
#define BTA_AV_RC_SUBPICT AVRC_ID_SUBPICT /* subpicture */
|
||||
#define BTA_AV_RC_F1 AVRC_ID_F1 /* F1 */
|
||||
#define BTA_AV_RC_F2 AVRC_ID_F2 /* F2 */
|
||||
#define BTA_AV_RC_F3 AVRC_ID_F3 /* F3 */
|
||||
#define BTA_AV_RC_F4 AVRC_ID_F4 /* F4 */
|
||||
#define BTA_AV_RC_F5 AVRC_ID_F5 /* F5 */
|
||||
#define BTA_AV_VENDOR AVRC_ID_VENDOR /* vendor unique */
|
||||
|
||||
typedef UINT8 tBTA_AV_RC;
|
||||
|
||||
/* state flag for pass through command */
|
||||
#define BTA_AV_STATE_PRESS AVRC_STATE_PRESS /* key pressed */
|
||||
#define BTA_AV_STATE_RELEASE AVRC_STATE_RELEASE /* key released */
|
||||
|
||||
typedef UINT8 tBTA_AV_STATE;
|
||||
|
||||
/* command codes for BTA_AvVendorCmd */
|
||||
#define BTA_AV_CMD_CTRL AVRC_CMD_CTRL
|
||||
#define BTA_AV_CMD_STATUS AVRC_CMD_STATUS
|
||||
#define BTA_AV_CMD_SPEC_INQ AVRC_CMD_SPEC_INQ
|
||||
#define BTA_AV_CMD_NOTIF AVRC_CMD_NOTIF
|
||||
#define BTA_AV_CMD_GEN_INQ AVRC_CMD_GEN_INQ
|
||||
|
||||
typedef UINT8 tBTA_AV_CMD;
|
||||
|
||||
/* response codes for BTA_AvVendorRsp */
|
||||
#define BTA_AV_RSP_NOT_IMPL AVRC_RSP_NOT_IMPL
|
||||
#define BTA_AV_RSP_ACCEPT AVRC_RSP_ACCEPT
|
||||
#define BTA_AV_RSP_REJ AVRC_RSP_REJ
|
||||
#define BTA_AV_RSP_IN_TRANS AVRC_RSP_IN_TRANS
|
||||
#define BTA_AV_RSP_IMPL_STBL AVRC_RSP_IMPL_STBL
|
||||
#define BTA_AV_RSP_CHANGED AVRC_RSP_CHANGED
|
||||
#define BTA_AV_RSP_INTERIM AVRC_RSP_INTERIM
|
||||
|
||||
typedef UINT8 tBTA_AV_CODE;
|
||||
|
||||
/* error codes for BTA_AvProtectRsp */
|
||||
#define BTA_AV_ERR_NONE A2D_SUCCESS /* Success, no error */
|
||||
#define BTA_AV_ERR_BAD_STATE AVDT_ERR_BAD_STATE /* Message cannot be processed in this state */
|
||||
#define BTA_AV_ERR_RESOURCE AVDT_ERR_RESOURCE /* Insufficient resources */
|
||||
#define BTA_AV_ERR_BAD_CP_TYPE A2D_BAD_CP_TYPE /* The requested Content Protection Type is not supported */
|
||||
#define BTA_AV_ERR_BAD_CP_FORMAT A2D_BAD_CP_FORMAT /* The format of Content Protection Data is not correct */
|
||||
|
||||
typedef UINT8 tBTA_AV_ERR;
|
||||
|
||||
|
||||
/* AV callback events */
|
||||
#define BTA_AV_ENABLE_EVT 0 /* AV enabled */
|
||||
#define BTA_AV_REGISTER_EVT 1 /* registered to AVDT */
|
||||
#define BTA_AV_OPEN_EVT 2 /* connection opened */
|
||||
#define BTA_AV_CLOSE_EVT 3 /* connection closed */
|
||||
#define BTA_AV_START_EVT 4 /* stream data transfer started */
|
||||
#define BTA_AV_STOP_EVT 5 /* stream data transfer stopped */
|
||||
#define BTA_AV_PROTECT_REQ_EVT 6 /* content protection request */
|
||||
#define BTA_AV_PROTECT_RSP_EVT 7 /* content protection response */
|
||||
#define BTA_AV_RC_OPEN_EVT 8 /* remote control channel open */
|
||||
#define BTA_AV_RC_CLOSE_EVT 9 /* remote control channel closed */
|
||||
#define BTA_AV_REMOTE_CMD_EVT 10 /* remote control command */
|
||||
#define BTA_AV_REMOTE_RSP_EVT 11 /* remote control response */
|
||||
#define BTA_AV_VENDOR_CMD_EVT 12 /* vendor dependent remote control command */
|
||||
#define BTA_AV_VENDOR_RSP_EVT 13 /* vendor dependent remote control response */
|
||||
#define BTA_AV_RECONFIG_EVT 14 /* reconfigure response */
|
||||
#define BTA_AV_SUSPEND_EVT 15 /* suspend response */
|
||||
#define BTA_AV_PENDING_EVT 16 /* incoming connection pending:
|
||||
* signal channel is open and stream is not open
|
||||
* after BTA_AV_SIG_TIME_VAL ms */
|
||||
#define BTA_AV_META_MSG_EVT 17 /* metadata messages */
|
||||
#define BTA_AV_REJECT_EVT 18 /* incoming connection rejected */
|
||||
#define BTA_AV_RC_FEAT_EVT 19 /* remote control channel peer supported features update */
|
||||
#define BTA_AV_MEDIA_SINK_CFG_EVT 20 /* command to configure codec */
|
||||
#define BTA_AV_MEDIA_DATA_EVT 21 /* sending data to Media Task */
|
||||
/* Max BTA event */
|
||||
#define BTA_AV_MAX_EVT 22
|
||||
|
||||
|
||||
/* function types for call-out functions */
|
||||
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
|
||||
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
|
||||
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
|
||||
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info);
|
||||
typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
|
||||
UINT8 num_protect, UINT8 *p_protect_info,
|
||||
UINT8 t_local_sep, UINT8 avdt_handle);
|
||||
typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl,
|
||||
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
|
||||
UINT16 mtu);
|
||||
typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu);
|
||||
typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
|
||||
typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
|
||||
typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
|
||||
UINT32 *p_len, UINT32 *p_timestamp);
|
||||
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
|
||||
|
||||
/* the call-out functions for one stream */
|
||||
typedef struct {
|
||||
tBTA_AV_CO_INIT init;
|
||||
tBTA_AV_CO_DISC_RES disc_res;
|
||||
tBTA_AV_CO_GETCFG getcfg;
|
||||
tBTA_AV_CO_SETCFG setcfg;
|
||||
tBTA_AV_CO_OPEN open;
|
||||
tBTA_AV_CO_CLOSE close;
|
||||
tBTA_AV_CO_START start;
|
||||
tBTA_AV_CO_STOP stop;
|
||||
tBTA_AV_CO_DATAPATH data;
|
||||
tBTA_AV_CO_DELAY delay;
|
||||
} tBTA_AV_CO_FUNCTS;
|
||||
|
||||
typedef UINT8 tBTA_AV_EVT;
|
||||
|
||||
/* Event associated with BTA_AV_ENABLE_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_FEAT features;
|
||||
} tBTA_AV_ENABLE;
|
||||
|
||||
/* Event associated with BTA_AV_REGISTER_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl; /* audio/video */
|
||||
tBTA_AV_HNDL hndl; /* Handle associated with the stream. */
|
||||
UINT8 app_id; /* ID associated with call to BTA_AvRegister() */
|
||||
tBTA_AV_STATUS status;
|
||||
tBTA_AV_CO_FUNCTS *p_bta_av_cos;
|
||||
} tBTA_AV_REGISTER;
|
||||
|
||||
/* data associated with BTA_AV_OPEN_EVT */
|
||||
#define BTA_AV_EDR_2MBPS 0x01
|
||||
#define BTA_AV_EDR_3MBPS 0x02
|
||||
typedef UINT8 tBTA_AV_EDR;
|
||||
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_AV_STATUS status;
|
||||
BOOLEAN starting;
|
||||
tBTA_AV_EDR edr; /* 0, if peer device does not support EDR */
|
||||
UINT8 sep; /* sep type of peer device */
|
||||
} tBTA_AV_OPEN;
|
||||
|
||||
/* data associated with BTA_AV_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
UINT8 disc_rsn; /* disconnection reason */
|
||||
} tBTA_AV_CLOSE;
|
||||
|
||||
/* data associated with BTA_AV_START_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
tBTA_AV_STATUS status;
|
||||
BOOLEAN initiator; /* TRUE, if local device initiates the START */
|
||||
BOOLEAN suspending;
|
||||
} tBTA_AV_START;
|
||||
|
||||
/* data associated with BTA_AV_SUSPEND_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
BOOLEAN initiator; /* TRUE, if local device initiates the SUSPEND */
|
||||
tBTA_AV_STATUS status;
|
||||
} tBTA_AV_SUSPEND;
|
||||
|
||||
/* data associated with BTA_AV_RECONFIG_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
tBTA_AV_STATUS status;
|
||||
} tBTA_AV_RECONFIG;
|
||||
|
||||
/* data associated with BTA_AV_PROTECT_REQ_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
UINT8 *p_data;
|
||||
UINT16 len;
|
||||
} tBTA_AV_PROTECT_REQ;
|
||||
|
||||
/* data associated with BTA_AV_PROTECT_RSP_EVT */
|
||||
typedef struct {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_HNDL hndl;
|
||||
UINT8 *p_data;
|
||||
UINT16 len;
|
||||
tBTA_AV_ERR err_code;
|
||||
} tBTA_AV_PROTECT_RSP;
|
||||
|
||||
/* data associated with BTA_AV_RC_OPEN_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
tBTA_AV_FEAT peer_features;
|
||||
BD_ADDR peer_addr;
|
||||
tBTA_AV_STATUS status;
|
||||
} tBTA_AV_RC_OPEN;
|
||||
|
||||
/* data associated with BTA_AV_RC_CLOSE_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
BD_ADDR peer_addr;
|
||||
} tBTA_AV_RC_CLOSE;
|
||||
|
||||
/* data associated with BTA_AV_RC_FEAT_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
tBTA_AV_FEAT peer_features;
|
||||
} tBTA_AV_RC_FEAT;
|
||||
|
||||
/* data associated with BTA_AV_REMOTE_CMD_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
tBTA_AV_RC rc_id;
|
||||
tBTA_AV_STATE key_state;
|
||||
UINT8 len;
|
||||
UINT8 *p_data;
|
||||
tAVRC_HDR hdr; /* Message header. */
|
||||
UINT8 label;
|
||||
} tBTA_AV_REMOTE_CMD;
|
||||
|
||||
/* data associated with BTA_AV_REMOTE_RSP_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
tBTA_AV_RC rc_id;
|
||||
tBTA_AV_STATE key_state;
|
||||
UINT8 len;
|
||||
UINT8 *p_data;
|
||||
tBTA_AV_CODE rsp_code;
|
||||
UINT8 label;
|
||||
} tBTA_AV_REMOTE_RSP;
|
||||
|
||||
/* data associated with BTA_AV_VENDOR_CMD_EVT, BTA_AV_VENDOR_RSP_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
UINT16 len; /* Max vendor dependent message is 512 */
|
||||
UINT8 label;
|
||||
tBTA_AV_CODE code;
|
||||
UINT32 company_id;
|
||||
UINT8 *p_data;
|
||||
} tBTA_AV_VENDOR;
|
||||
|
||||
/* data associated with BTA_AV_META_MSG_EVT */
|
||||
typedef struct {
|
||||
UINT8 rc_handle;
|
||||
UINT16 len;
|
||||
UINT8 label;
|
||||
tBTA_AV_CODE code;
|
||||
UINT32 company_id;
|
||||
UINT8 *p_data;
|
||||
tAVRC_MSG *p_msg;
|
||||
} tBTA_AV_META_MSG;
|
||||
|
||||
/* data associated with BTA_AV_PENDING_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr;
|
||||
} tBTA_AV_PEND;
|
||||
|
||||
/* data associated with BTA_AV_REJECT_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_AV_HNDL hndl; /* Handle associated with the stream that rejected the connection. */
|
||||
} tBTA_AV_REJECT;
|
||||
|
||||
|
||||
/* union of data associated with AV callback */
|
||||
typedef union {
|
||||
tBTA_AV_CHNL chnl;
|
||||
tBTA_AV_ENABLE enable;
|
||||
tBTA_AV_REGISTER registr;
|
||||
tBTA_AV_OPEN open;
|
||||
tBTA_AV_CLOSE close;
|
||||
tBTA_AV_START start;
|
||||
tBTA_AV_PROTECT_REQ protect_req;
|
||||
tBTA_AV_PROTECT_RSP protect_rsp;
|
||||
tBTA_AV_RC_OPEN rc_open;
|
||||
tBTA_AV_RC_CLOSE rc_close;
|
||||
tBTA_AV_REMOTE_CMD remote_cmd;
|
||||
tBTA_AV_REMOTE_RSP remote_rsp;
|
||||
tBTA_AV_VENDOR vendor_cmd;
|
||||
tBTA_AV_VENDOR vendor_rsp;
|
||||
tBTA_AV_RECONFIG reconfig;
|
||||
tBTA_AV_SUSPEND suspend;
|
||||
tBTA_AV_PEND pend;
|
||||
tBTA_AV_META_MSG meta_msg;
|
||||
tBTA_AV_REJECT reject;
|
||||
tBTA_AV_RC_FEAT rc_feat;
|
||||
} tBTA_AV;
|
||||
|
||||
/* union of data associated with AV Media callback */
|
||||
typedef union {
|
||||
BT_HDR *p_data;
|
||||
UINT8 *codec_info;
|
||||
} tBTA_AV_MEDIA;
|
||||
|
||||
|
||||
#define BTA_AVC_PACKET_LEN AVRC_PACKET_LEN
|
||||
#define BTA_VENDOR_DATA_OFFSET 6
|
||||
#define BTA_VENDOR_HEADER_LEN 4
|
||||
#define BTA_MAX_VENDOR_DEPENDENT_DATA_LEN (BTA_AVC_PACKET_LEN-BTA_VENDOR_DATA_OFFSET-BTA_VENDOR_HEADER_LEN)
|
||||
#define BTA_GROUP_NAVI_MSG_OP_DATA_LEN 5
|
||||
|
||||
#define BTA_ERROR_INVALID_CMD AVRC_STS_BAD_CMD
|
||||
#define BTA_ERROR_INVALID_PARAM AVRC_STS_BAD_PARAM
|
||||
#define BTA_ERROR_BAD_CONTENTS AVRC_STS_NOT_FOUND
|
||||
#define BTA_ERROR_INTERNAL AVRC_STS_INTERNAL_ERR
|
||||
|
||||
#define BTA_AV_META_SINGLE_PACKET AVRC_PKT_SINGLE
|
||||
|
||||
#define BTA_AV_CO_METADATA AVRC_CO_METADATA
|
||||
|
||||
/* AV callback */
|
||||
typedef void (tBTA_AV_CBACK)(tBTA_AV_EVT event, tBTA_AV *p_data);
|
||||
typedef void (tBTA_AV_DATA_CBACK)(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data);
|
||||
|
||||
/* type for stream state machine action functions */
|
||||
typedef void (*tBTA_AV_ACT)(void *p_cb, void *p_data);
|
||||
|
||||
/* type for registering VDP */
|
||||
typedef void (tBTA_AV_REG) (tAVDT_CS *p_cs, char *p_service_name, void *p_data);
|
||||
|
||||
/* AV configuration structure */
|
||||
typedef struct {
|
||||
UINT32 company_id; /* AVRCP Company ID */
|
||||
UINT16 avrc_mtu; /* AVRCP MTU at L2CAP for control channel */
|
||||
UINT16 avrc_br_mtu; /* AVRCP MTU at L2CAP for browsing channel */
|
||||
UINT16 avrc_ct_cat; /* AVRCP controller categories */
|
||||
UINT16 avrc_tg_cat; /* AVRCP target categories */
|
||||
UINT16 sig_mtu; /* AVDTP signaling channel MTU at L2CAP */
|
||||
UINT16 audio_mtu; /* AVDTP audio transport channel MTU at L2CAP */
|
||||
const UINT16 *p_audio_flush_to;/* AVDTP audio transport channel flush timeout */
|
||||
UINT16 audio_mqs; /* AVDTP audio channel max data queue size */
|
||||
UINT16 video_mtu; /* AVDTP video transport channel MTU at L2CAP */
|
||||
UINT16 video_flush_to; /* AVDTP video transport channel flush timeout */
|
||||
BOOLEAN avrc_group; /* TRUE, to accept AVRC 1.3 group nevigation command */
|
||||
UINT8 num_co_ids; /* company id count in p_meta_co_ids */
|
||||
UINT8 num_evt_ids; /* event id count in p_meta_evt_ids */
|
||||
tBTA_AV_CODE rc_pass_rsp; /* the default response code for pass through commands */
|
||||
const UINT32 *p_meta_co_ids;/* the metadata Get Capabilities response for company id */
|
||||
const UINT8 *p_meta_evt_ids;/* the the metadata Get Capabilities response for event id */
|
||||
const tBTA_AV_ACT *p_act_tbl;/* the action function table for VDP stream */
|
||||
tBTA_AV_REG *p_reg; /* action function to register VDP */
|
||||
char avrc_controller_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP controller name */
|
||||
char avrc_target_name[BTA_SERVICE_NAME_LEN]; /* Default AVRCP target name*/
|
||||
} tBTA_AV_CFG;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
** External Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvEnable
|
||||
**
|
||||
** Description Enable the advanced audio/video service. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_AV_ENABLE_EVT. This function must
|
||||
** be called before other function in the AV API are
|
||||
** called.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features,
|
||||
tBTA_AV_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDisable
|
||||
**
|
||||
** Description Disable the advanced audio/video service.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDisable(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvRegister
|
||||
**
|
||||
** Description Register the audio or video service to stack. When the
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_AV_REGISTER_EVT. This function must
|
||||
** be called before AVDT stream is open.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
|
||||
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDeregister
|
||||
**
|
||||
** Description Deregister the audio or video service
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDeregister(tBTA_AV_HNDL hndl);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvOpen
|
||||
**
|
||||
** Description Opens an advanced audio/video connection to a peer device.
|
||||
** When connection is open callback function is called
|
||||
** with a BTA_AV_OPEN_EVT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle,
|
||||
BOOLEAN use_rc, tBTA_SEC sec_mask, UINT16 uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvClose
|
||||
**
|
||||
** Description Close the current streams.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvClose(tBTA_AV_HNDL handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvDisconnect
|
||||
**
|
||||
** Description Close the connection to the address.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvDisconnect(BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvEnable_Sink
|
||||
**
|
||||
** Description Enable/Disable A2DP Sink.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvEnable_Sink(int enable);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvStart
|
||||
**
|
||||
** Description Start audio/video stream data transfer.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvStart(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvStop
|
||||
**
|
||||
** Description Stop audio/video stream data transfer.
|
||||
** If suspend is TRUE, this function sends AVDT suspend signal
|
||||
** to the connected peer(s).
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvStop(BOOLEAN suspend);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvReconfig
|
||||
**
|
||||
** Description Reconfigure the audio/video stream.
|
||||
** If suspend is TRUE, this function tries the suspend/reconfigure
|
||||
** procedure first.
|
||||
** If suspend is FALSE or when suspend/reconfigure fails,
|
||||
** this function closes and re-opens the AVDT connection.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
|
||||
UINT8 *p_codec_info, UINT8 num_protect, UINT8 *p_protect_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvProtectReq
|
||||
**
|
||||
** Description Send a content protection request. This function can only
|
||||
** be used if AV is enabled with feature BTA_AV_FEAT_PROTECT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvProtectRsp
|
||||
**
|
||||
** Description Send a content protection response. This function must
|
||||
** be called if a BTA_AV_PROTECT_REQ_EVT is received.
|
||||
** This function can only be used if AV is enabled with
|
||||
** feature BTA_AV_FEAT_PROTECT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data,
|
||||
UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvRemoteCmd
|
||||
**
|
||||
** Description Send a remote control command. This function can only
|
||||
** be used if AV is enabled with feature BTA_AV_FEAT_RCCT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id,
|
||||
tBTA_AV_STATE key_state);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvVendorCmd
|
||||
**
|
||||
** Description Send a vendor dependent remote control command. This
|
||||
** function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_VENDOR.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvVendorRsp
|
||||
**
|
||||
** Description Send a vendor dependent remote control response.
|
||||
** This function must be called if a BTA_AV_VENDOR_CMD_EVT
|
||||
** is received. This function can only be used if AV is
|
||||
** enabled with feature BTA_AV_FEAT_VENDOR.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
|
||||
UINT8 *p_data, UINT16 len, UINT32 company_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvOpenRc
|
||||
**
|
||||
** Description Open an AVRCP connection toward the device with the
|
||||
** specified handle
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvOpenRc(tBTA_AV_HNDL handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvCloseRc
|
||||
**
|
||||
** Description Close an AVRCP connection
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvCloseRc(UINT8 rc_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvMetaRsp
|
||||
**
|
||||
** Description Send a Metadata command/response. The message contained
|
||||
** in p_pkt can be composed with AVRC utility functions.
|
||||
** This function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_METADATA.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
|
||||
BT_HDR *p_pkt);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_AvMetaCmd
|
||||
**
|
||||
** Description Send a Metadata/Advanced Control command. The message contained
|
||||
** in p_pkt can be composed with AVRC utility functions.
|
||||
** This function can only be used if AV is enabled with feature
|
||||
** BTA_AV_FEAT_METADATA.
|
||||
** This message is sent only when the peer supports the TG role.
|
||||
*8 The only command makes sense right now is the absolute volume command.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p_pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AV_API_H */
|
||||
@@ -1,77 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2005-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 interface file for advanced audio/video call-in functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AV_CI_H
|
||||
#define BTA_AV_CI_H
|
||||
|
||||
#include "bta_av_api.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ci_src_data_ready
|
||||
**
|
||||
** Description This function sends an event to the AV indicating that
|
||||
** the phone has audio stream data ready to send and AV
|
||||
** should call bta_av_co_audio_src_data_path() or
|
||||
** bta_av_co_video_src_data_path().
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_ci_setconfig
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_av_co_audio_setconfig() or bta_av_co_video_setconfig.
|
||||
** Parameter err_code is set to an AVDTP status value;
|
||||
** AVDT_SUCCESS if the codec configuration is ok,
|
||||
** otherwise error.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code,
|
||||
UINT8 category, UINT8 num_seid, UINT8 *p_seid,
|
||||
BOOLEAN recfg_needed, UINT8 avdt_handle);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AV_CI_H */
|
||||
@@ -1,393 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 interface file for advanced audio/video call-out functions.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AV_CO_H
|
||||
#define BTA_AV_CO_H
|
||||
|
||||
#include "l2c_api.h"
|
||||
#include "bta_av_api.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
|
||||
/* TRUE to use SCMS-T content protection */
|
||||
#ifndef BTA_AV_CO_CP_SCMS_T
|
||||
#define BTA_AV_CO_CP_SCMS_T FALSE
|
||||
#endif
|
||||
|
||||
/* the content protection IDs assigned by BT SIG */
|
||||
#define BTA_AV_CP_SCMS_T_ID 0x0002
|
||||
#define BTA_AV_CP_DTCP_ID 0x0001
|
||||
|
||||
#define BTA_AV_CP_LOSC 2
|
||||
#define BTA_AV_CP_INFO_LEN 3
|
||||
|
||||
#define BTA_AV_CP_SCMS_COPY_MASK 3
|
||||
#define BTA_AV_CP_SCMS_COPY_FREE 2
|
||||
#define BTA_AV_CP_SCMS_COPY_ONCE 1
|
||||
#define BTA_AV_CP_SCMS_COPY_NEVER 0
|
||||
|
||||
#define BTA_AV_CO_DEFAULT_AUDIO_OFFSET AVDT_MEDIA_OFFSET
|
||||
|
||||
enum {
|
||||
BTA_AV_CO_ST_INIT,
|
||||
BTA_AV_CO_ST_IN,
|
||||
BTA_AV_CO_ST_OUT,
|
||||
BTA_AV_CO_ST_OPEN,
|
||||
BTA_AV_CO_ST_STREAM
|
||||
};
|
||||
|
||||
|
||||
/* data type for the Audio Codec Information*/
|
||||
typedef struct {
|
||||
UINT16 bit_rate; /* SBC encoder bit rate in kbps */
|
||||
UINT16 bit_rate_busy; /* SBC encoder bit rate in kbps */
|
||||
UINT16 bit_rate_swampd;/* SBC encoder bit rate in kbps */
|
||||
UINT8 busy_level; /* Busy level indicating the bit-rate to be used */
|
||||
UINT8 codec_info[AVDT_CODEC_SIZE];
|
||||
UINT8 codec_type; /* Codec type */
|
||||
} tBTA_AV_AUDIO_CODEC_INFO;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_init
|
||||
**
|
||||
** Description This callout function is executed by AV when it is
|
||||
** started by calling BTA_AvEnable(). This function can be
|
||||
** used by the phone to initialize audio paths or for other
|
||||
** initialization purposes.
|
||||
**
|
||||
**
|
||||
** Returns Stream codec and content protection capabilities info.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_disc_res
|
||||
**
|
||||
** Description This callout function is executed by AV to report the
|
||||
** number of stream end points (SEP) were found during the
|
||||
** AVDT stream discovery process.
|
||||
**
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
|
||||
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_disc_res
|
||||
**
|
||||
** Description This callout function is executed by AV to report the
|
||||
** number of stream end points (SEP) were found during the
|
||||
** AVDT stream discovery process.
|
||||
**
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_disc_res(tBTA_AV_HNDL hndl, UINT8 num_seps,
|
||||
UINT8 num_snk, BD_ADDR addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_getconfig
|
||||
**
|
||||
** Description This callout function is executed by AV to retrieve the
|
||||
** desired codec and content protection configuration for the
|
||||
** audio stream.
|
||||
**
|
||||
**
|
||||
** Returns Stream codec and content protection configuration info.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_getconfig
|
||||
**
|
||||
** Description This callout function is executed by AV to retrieve the
|
||||
** desired codec and content protection configuration for the
|
||||
** video stream.
|
||||
**
|
||||
**
|
||||
** Returns Stream codec and content protection configuration info.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 bta_av_co_video_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_setconfig
|
||||
**
|
||||
** Description This callout function is executed by AV to set the
|
||||
** codec and content protection configuration of the audio stream.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
|
||||
UINT8 num_protect, UINT8 *p_protect_info, UINT8 t_local_sep, UINT8 avdt_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_setconfig
|
||||
**
|
||||
** Description This callout function is executed by AV to set the
|
||||
** codec and content protection configuration of the video stream.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
|
||||
UINT8 num_protect, UINT8 *p_protect_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_open
|
||||
**
|
||||
** Description This function is called by AV when the audio stream connection
|
||||
** is opened.
|
||||
** BTA-AV maintains the MTU of A2DP streams.
|
||||
** If this is the 2nd audio stream, mtu is the smaller of the 2
|
||||
** streams.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_open(tBTA_AV_HNDL hndl,
|
||||
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
|
||||
UINT16 mtu);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_open
|
||||
**
|
||||
** Description This function is called by AV when the video stream connection
|
||||
** is opened.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_open(tBTA_AV_HNDL hndl,
|
||||
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
|
||||
UINT16 mtu);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_close
|
||||
**
|
||||
** Description This function is called by AV when the audio stream connection
|
||||
** is closed.
|
||||
** BTA-AV maintains the MTU of A2DP streams.
|
||||
** When one stream is closed and no other audio stream is open,
|
||||
** mtu is reported as 0.
|
||||
** Otherwise, the MTU remains open is reported.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT16 mtu);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_close
|
||||
**
|
||||
** Description This function is called by AV when the video stream connection
|
||||
** is closed.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT16 mtu);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_start
|
||||
**
|
||||
** Description This function is called by AV when the audio streaming data
|
||||
** transfer is started.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_start
|
||||
**
|
||||
** Description This function is called by AV when the video streaming data
|
||||
** transfer is started.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_start(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_stop
|
||||
**
|
||||
** Description This function is called by AV when the audio streaming data
|
||||
** transfer is stopped.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_stop
|
||||
**
|
||||
** Description This function is called by AV when the video streaming data
|
||||
** transfer is stopped.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_src_data_path
|
||||
**
|
||||
** Description This function is called to get the next data buffer from
|
||||
** the audio codec
|
||||
**
|
||||
** Returns NULL if data is not ready.
|
||||
** Otherwise, a GKI buffer (BT_HDR*) containing the audio data.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type,
|
||||
UINT32 *p_len, UINT32 *p_timestamp);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_src_data_path
|
||||
**
|
||||
** Description This function is called to get the next data buffer from
|
||||
** the video codec.
|
||||
**
|
||||
** Returns NULL if data is not ready.
|
||||
** Otherwise, a video data buffer (UINT8*).
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void *bta_av_co_video_src_data_path(tBTA_AV_CODEC codec_type,
|
||||
UINT32 *p_len, UINT32 *p_timestamp);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_drop
|
||||
**
|
||||
** Description An Audio packet is dropped. .
|
||||
** It's very likely that the connected headset with this handle
|
||||
** is moved far away. The implementation may want to reduce
|
||||
** the encoder bit rate setting to reduce the packet size.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_drop(tBTA_AV_HNDL hndl);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_report_conn
|
||||
**
|
||||
** Description This function is called by AV when the reporting channel is
|
||||
** opened (open=TRUE) or closed (open=FALSE).
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_report_conn (BOOLEAN open, UINT8 avdt_handle);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_report_rr
|
||||
**
|
||||
** Description This function is called by AV when a Receiver Report is
|
||||
** received
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_report_rr (UINT32 packet_lost);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_audio_delay
|
||||
**
|
||||
** Description This function is called by AV when the audio stream connection
|
||||
** needs to send the initial delay report to the connected SRC.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_audio_delay(tBTA_AV_HNDL hndl, UINT16 delay);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_co_video_delay
|
||||
**
|
||||
** Description This function is called by AV when the video stream connection
|
||||
** needs to send the initial delay report to the connected SRC.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_co_video_delay(tBTA_AV_HNDL hndl, UINT16 delay);
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AV_CO_H */
|
||||
@@ -1,223 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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 is the interface to utility functions for dealing with SBC data
|
||||
* frames and codec capabilities.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef BTA_AV_SBC_H
|
||||
#define BTA_AV_SBC_H
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** constants
|
||||
*****************************************************************************/
|
||||
|
||||
/* SBC packet header size */
|
||||
#define BTA_AV_SBC_HDR_SIZE A2D_SBC_MPL_HDR_LEN
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_init_up_sample
|
||||
**
|
||||
** Description initialize the up sample
|
||||
**
|
||||
** src_sps: samples per second (source audio data)
|
||||
** dst_sps: samples per second (converted audio data)
|
||||
** bits: number of bits per pcm sample
|
||||
** n_channels: number of channels (i.e. mono(1), stereo(2)...)
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_sbc_init_up_sample (UINT32 src_sps, UINT32 dst_sps,
|
||||
UINT16 bits, UINT16 n_channels);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (number of bytes)
|
||||
** dst_samples: The size of p_dst (number of bytes)
|
||||
**
|
||||
** Note: An AE reported an issue with this function.
|
||||
** When called with bta_av_sbc_up_sample(src, uint8_array_dst..)
|
||||
** the byte before uint8_array_dst may get overwritten.
|
||||
** Using uint16_array_dst avoids the problem.
|
||||
** This issue is related to endian-ness and is hard to resolve
|
||||
** in a generic manner.
|
||||
** **************** Please use uint16 array as dst.
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int bta_av_sbc_up_sample (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_16s (16bits-stereo)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 4 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 4 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int bta_av_sbc_up_sample_16s (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_16m (16bits-mono)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 2 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 2 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int bta_av_sbc_up_sample_16m (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_8s (8bits-stereo)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (in uint of 2 bytes)
|
||||
** dst_samples: The size of p_dst (in uint of 2 bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int bta_av_sbc_up_sample_8s (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_up_sample_8m (8bits-mono)
|
||||
**
|
||||
** Description Given the source (p_src) audio data and
|
||||
** source speed (src_sps, samples per second),
|
||||
** This function converts it to audio data in the desired format
|
||||
**
|
||||
** p_src: the data buffer that holds the source audio data
|
||||
** p_dst: the data buffer to hold the converted audio data
|
||||
** src_samples: The number of source samples (number of bytes)
|
||||
** dst_samples: The size of p_dst (number of bytes)
|
||||
**
|
||||
** Returns The number of bytes used in p_dst
|
||||
** The number of bytes used in p_src (in *p_ret)
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern int bta_av_sbc_up_sample_8m (void *p_src, void *p_dst,
|
||||
UINT32 src_samples, UINT32 dst_samples,
|
||||
UINT32 *p_ret);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_for_cap
|
||||
**
|
||||
** Description Determine the preferred SBC codec configuration for the
|
||||
** given codec capabilities. The function is passed the
|
||||
** preferred codec configuration and the peer codec
|
||||
** capabilities for the stream. The function attempts to
|
||||
** match the preferred capabilities with the configuration
|
||||
** as best it can. The resulting codec configuration is
|
||||
** returned in the same memory used for the capabilities.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
** Codec configuration in p_cap.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 bta_av_sbc_cfg_for_cap(UINT8 *p_peer, tA2D_SBC_CIE *p_cap, tA2D_SBC_CIE *p_pref);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_in_cap
|
||||
**
|
||||
** Description This function checks whether an SBC codec configuration
|
||||
** is allowable for the given codec capabilities.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 bta_av_sbc_cfg_in_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_cfg_matches_cap
|
||||
**
|
||||
** Description This function checks whether an SBC codec configuration
|
||||
** matched with capabilities. Here we check subset.
|
||||
**
|
||||
** Returns 0 if ok, nonzero if error.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT8 bta_av_sbc_cfg_matches_cap(UINT8 *p_cfg, tA2D_SBC_CIE *p_cap);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_sbc_bld_hdr
|
||||
**
|
||||
** Description This function builds the packet header for MPF1.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_av_sbc_bld_hdr(BT_HDR *p_buf, UINT16 fr_per_pkt);
|
||||
|
||||
#endif ///BTA_AV_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_AV_SBC_H */
|
||||
|
||||
@@ -270,13 +270,4 @@ extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
tBTA_LE_KEY_TYPE *p_resp_key );
|
||||
// btla-specific --
|
||||
|
||||
extern void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap);
|
||||
|
||||
extern void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req);
|
||||
|
||||
extern void bta_dm_co_ble_set_init_key_req(UINT8 init_key);
|
||||
|
||||
extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
|
||||
|
||||
extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
|
||||
#endif
|
||||
|
||||
@@ -55,7 +55,6 @@ typedef struct {
|
||||
UINT8 inst_id; /* instance ID */
|
||||
} __attribute__((packed)) tBTA_GATT_ID;
|
||||
|
||||
/* relate to ESP_GATT_xxx in esp_gatt_def.h */
|
||||
/* Success code and error codes */
|
||||
#define BTA_GATT_OK GATT_SUCCESS
|
||||
#define BTA_GATT_INVALID_HANDLE GATT_INVALID_HANDLE /* 0x0001 */
|
||||
@@ -95,19 +94,14 @@ typedef struct {
|
||||
#define BTA_GATT_NOT_ENCRYPTED GATT_NOT_ENCRYPTED /* 0x8e */
|
||||
#define BTA_GATT_CONGESTED GATT_CONGESTED /* 0x8f */
|
||||
|
||||
#define BTA_GATT_DUP_REG GATT_DUP_REG /* 0x90 */
|
||||
#define BTA_GATT_ALREADY_OPEN GATT_ALREADY_OPEN /* 0x91 */
|
||||
#define BTA_GATT_CANCEL GATT_CANCEL /* 0x92 */
|
||||
#define BTA_GATT_DUP_REG 0x90 /* 0x90 */
|
||||
#define BTA_GATT_ALREADY_OPEN 0x91 /* 0x91 */
|
||||
#define BTA_GATT_CANCEL 0x92 /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
#define BTA_GATT_STACK_RSP GATT_STACK_RSP /* 0xE0 */
|
||||
#define BTA_GATT_APP_RSP GATT_APP_RSP /* 0xE1 */
|
||||
//Error caused by customer application or stack bug
|
||||
#define BTA_GATT_UNKNOWN_ERROR GATT_UNKNOWN_ERROR /* 0XEF */
|
||||
|
||||
#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
|
||||
#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
|
||||
#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
|
||||
#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
|
||||
|
||||
typedef UINT8 tBTA_GATT_STATUS;
|
||||
|
||||
@@ -150,8 +144,6 @@ typedef UINT8 tBTA_GATT_STATUS;
|
||||
#define BTA_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */
|
||||
#define BTA_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */
|
||||
#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||
#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
|
||||
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
|
||||
|
||||
typedef UINT8 tBTA_GATTC_EVT;
|
||||
|
||||
@@ -196,7 +188,6 @@ typedef struct {
|
||||
#define BTA_GATTC_TYPE_WRITE_NO_RSP GATT_WRITE_NO_RSP
|
||||
typedef UINT8 tBTA_GATTC_WRITE_TYPE;
|
||||
|
||||
/* relate to ESP_GATT_CONN_xxx in esp_gatt_defs.h */
|
||||
#define BTA_GATT_CONN_UNKNOWN 0
|
||||
#define BTA_GATT_CONN_L2C_FAILURE GATT_CONN_L2C_FAILURE /* general l2cap resource failure */
|
||||
#define BTA_GATT_CONN_TIMEOUT GATT_CONN_TIMEOUT /* 0x08 connection timeout */
|
||||
@@ -249,7 +240,6 @@ typedef struct {
|
||||
|
||||
} tBTA_GATTC_MULTI;
|
||||
|
||||
/* relate to ESP_GATT_xxx in esp_gatt_def.h */
|
||||
#define BTA_GATT_AUTH_REQ_NONE GATT_AUTH_REQ_NONE
|
||||
#define BTA_GATT_AUTH_REQ_NO_MITM GATT_AUTH_REQ_NO_MITM /* unauthenticated encryption */
|
||||
#define BTA_GATT_AUTH_REQ_MITM GATT_AUTH_REQ_MITM /* authenticated encryption */
|
||||
@@ -381,20 +371,6 @@ typedef struct {
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_GATTC_ENC_CMPL_CB;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_GATTC_CONNECT;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BD_ADDR remote_bda;
|
||||
} tBTA_GATTC_DISCONNECT;
|
||||
|
||||
typedef union {
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
@@ -402,9 +378,7 @@ typedef union {
|
||||
tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
|
||||
tBTA_GATTC_REG reg_oper; /* registration data */
|
||||
tBTA_GATTC_OPEN open;
|
||||
tBTA_GATTC_CONNECT connect;
|
||||
tBTA_GATTC_CLOSE close;
|
||||
tBTA_GATTC_DISCONNECT disconnect;
|
||||
tBTA_GATTC_READ read; /* read attribute/descriptor data */
|
||||
tBTA_GATTC_WRITE write; /* write complete data */
|
||||
tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
|
||||
@@ -444,7 +418,7 @@ typedef void (tBTA_GATTC_CBACK)(tBTA_GATTC_EVT event, tBTA_GATTC *p_data);
|
||||
#define BTA_GATTS_CLOSE_EVT 18
|
||||
#define BTA_GATTS_LISTEN_EVT 19
|
||||
#define BTA_GATTS_CONGEST_EVT 20
|
||||
#define BTA_GATTS_SET_ATTR_VAL_EVT 23
|
||||
#define BTA_GATTS_SET_ATTR_VAL_EVT 21
|
||||
|
||||
typedef UINT8 tBTA_GATTS_EVT;
|
||||
typedef tGATT_IF tBTA_GATTS_IF;
|
||||
@@ -515,7 +489,6 @@ typedef tGATT_VALUE tBTA_GATT_VALUE;
|
||||
/* attribute response data */
|
||||
typedef tGATTS_RSP tBTA_GATTS_RSP;
|
||||
|
||||
/* relate to ESP_GATT_PREP_WRITE_xxx in esp_gatt_defs.h */
|
||||
/* attribute request data from the client */
|
||||
#define BTA_GATT_PREP_WRITE_CANCEL 0x00
|
||||
#define BTA_GATT_PREP_WRITE_EXEC 0x01
|
||||
@@ -600,21 +573,6 @@ typedef struct {
|
||||
tBTA_GATT_STATUS status; /* notification/indication status */
|
||||
} tBTA_GATTS_CONF;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 conn_id; /* connection ID */
|
||||
} tBTA_GATTS_CLOSE;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTS_IF server_if;
|
||||
} tBTA_GATTS_OPEN;
|
||||
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTS_IF server_if;
|
||||
} tBTA_GATTS_CANCEL_OPEN;
|
||||
|
||||
/* GATTS callback data */
|
||||
typedef union {
|
||||
tBTA_GATTS_REG_OPER reg_oper;
|
||||
@@ -629,20 +587,8 @@ typedef union {
|
||||
tBTA_GATTS_CONN conn; /* BTA_GATTS_CONN_EVT */
|
||||
tBTA_GATTS_CONGEST congest; /* BTA_GATTS_CONGEST_EVT callback data */
|
||||
tBTA_GATTS_CONF confirm; /* BTA_GATTS_CONF_EVT callback data */
|
||||
tBTA_GATTS_CLOSE close; /* BTA_GATTS_CLOSE_EVT callback data */
|
||||
tBTA_GATTS_OPEN open; /* BTA_GATTS_OPEN_EVT callback data */
|
||||
tBTA_GATTS_CANCEL_OPEN cancel_open; /* tBTA_GATTS_CANCEL_OPEN callback data */
|
||||
|
||||
} tBTA_GATTS;
|
||||
|
||||
/* GATTC wait for service change ccc timer callback data */
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
BD_ADDR remote_bda;
|
||||
UINT8 count;
|
||||
UINT8 last_status;
|
||||
}tBTA_GATTC_WAIT_CCC_TIMER;
|
||||
|
||||
/* GATTS enable callback function */
|
||||
typedef void (tBTA_GATTS_ENB_CBACK)(tBTA_GATT_STATUS status);
|
||||
|
||||
@@ -1038,7 +984,7 @@ extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF
|
||||
** Description This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_id - GATT characteritic ID of the service.
|
||||
** p_char_id - GATT characteritic ID of the service.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
@@ -1055,26 +1001,6 @@ extern void BTA_GATTC_PrepareWrite (UINT16 conn_id,
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_PrepareWriteCharDescr
|
||||
**
|
||||
** Description This function is called to prepare write a characteristic descriptor value.
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** p_char_descr_id - GATT characteritic descriptor ID of the service.
|
||||
** offset - offset of the write value.
|
||||
** len: length of the data to be written.
|
||||
** p_value - the value to be written.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_char_descr_id,
|
||||
UINT16 offset,
|
||||
tBTA_GATT_UNFMT *p_data,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_ExecuteWrite
|
||||
**
|
||||
** Description This function is called to execute write a prepare write sequence.
|
||||
@@ -1409,10 +1335,10 @@ extern void BTA_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *valu
|
||||
** length - the value length which has been set to the attribute.
|
||||
** value - the pointer to the value
|
||||
**
|
||||
** Returns tBTA_GATT_STATUS
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern void BTA_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gattc_ci.h"
|
||||
#include "bta_gattc_co.h"
|
||||
|
||||
#include "gki.h"
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -81,11 +82,7 @@ typedef UINT16 tBTA_GATTC_INT_EVT;
|
||||
|
||||
/* max known devices GATTC can support */
|
||||
#ifndef BTA_GATTC_KNOWN_SR_MAX
|
||||
#if (GATT_MAX_PHY_CHANNEL > 3)
|
||||
#define BTA_GATTC_KNOWN_SR_MAX GATT_MAX_PHY_CHANNEL
|
||||
#else
|
||||
#define BTA_GATTC_KNOWN_SR_MAX 3 // The origin value is 10
|
||||
#endif
|
||||
#define BTA_GATTC_KNOWN_SR_MAX 3 // 10
|
||||
#endif
|
||||
|
||||
#define BTA_GATTC_CONN_MAX GATT_MAX_PHY_CHANNEL
|
||||
@@ -323,7 +320,7 @@ typedef struct {
|
||||
} tBTA_GATTC_SERV;
|
||||
|
||||
#ifndef BTA_GATTC_NOTIF_REG_MAX
|
||||
#define BTA_GATTC_NOTIF_REG_MAX 7//15
|
||||
#define BTA_GATTC_NOTIF_REG_MAX 15
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
@@ -383,9 +380,6 @@ 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 */
|
||||
} tBTA_GATTC_CONN;
|
||||
|
||||
enum {
|
||||
@@ -404,22 +398,11 @@ typedef struct {
|
||||
|
||||
tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX];
|
||||
tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX];
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
tSDP_DISCOVERY_DB *p_sdp_db;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
UINT16 sdp_conn_id;
|
||||
} tBTA_GATTC_CB;
|
||||
|
||||
typedef enum {
|
||||
SERVICE_CHANGE_CCC_WRITTEN_SUCCESS = 0,
|
||||
SERVICE_CHANGE_CACHE_NOT_FOUND,
|
||||
SERVICE_CHANGE_SERVICE_NOT_FOUND,
|
||||
SERVICE_CHANGE_CHAR_NOT_FOUND,
|
||||
SERVICE_CHANGE_CCC_NOT_FOUND,
|
||||
SERVICE_CHANGE_WRITE_CCC_FAILED
|
||||
}tBTA_GATTC_FIND_SERVICE_CB;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
*****************************************************************************/
|
||||
@@ -457,8 +440,7 @@ extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p
|
||||
extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
@@ -485,10 +467,6 @@ extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *
|
||||
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
|
||||
extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu);
|
||||
extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id);
|
||||
extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id);
|
||||
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
||||
@@ -230,7 +230,7 @@ extern void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS
|
||||
extern void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern tGATT_STATUS bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern void bta_gatts_get_attr_value(UINT16 attr_handle, UINT16 *length, UINT8 **value);
|
||||
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "hidh_api.h"
|
||||
#if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
#include "gatt_api.h"
|
||||
@@ -539,7 +538,4 @@ extern void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
|
||||
|
||||
|
||||
#endif /* BTA_HH_API_H */
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "bta_api.h"
|
||||
#include "btm_api.h"
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* status values */
|
||||
#define BTA_SDP_SUCCESS 0 /* Successful operation. */
|
||||
#define BTA_SDP_FAILURE 1 /* Generic failure. */
|
||||
@@ -71,9 +70,7 @@ typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *use
|
||||
/* MCE configuration structure */
|
||||
typedef struct {
|
||||
UINT16 sdp_db_size; /* The size of p_sdp_db */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
} tBTA_SDP_CFG;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -142,6 +139,4 @@ extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
|
||||
#endif /* BTA_SDP_API_H */
|
||||
|
||||
@@ -23,14 +23,12 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "bt_target.h"
|
||||
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_sdp_api.h"
|
||||
#include "bta_sdp_int.h"
|
||||
|
||||
#if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
*****************************************************************************/
|
||||
@@ -77,5 +75,3 @@ BOOLEAN bta_sdp_sm_execute(BT_HDR *p_msg)
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
#endif /* #if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE) */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "bt_defs.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "bt_target.h"
|
||||
|
||||
#include "allocator.h"
|
||||
#include "bt_types.h"
|
||||
#include "gki.h"
|
||||
@@ -39,8 +39,6 @@
|
||||
#include "btm_int.h"
|
||||
#include "sdp_api.h"
|
||||
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
@@ -545,5 +543,3 @@ void bta_sdp_remove_record(tBTA_SDP_MSG *p_data)
|
||||
bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, NULL, p_data->record.user_data);
|
||||
}
|
||||
}
|
||||
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
@@ -22,7 +22,6 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_sdp_api.h"
|
||||
@@ -32,7 +31,6 @@
|
||||
// #include "port_api.h"
|
||||
#include "sdp_api.h"
|
||||
|
||||
#if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE)
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
@@ -167,4 +165,3 @@ tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data)
|
||||
}
|
||||
|
||||
|
||||
#endif /* #if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE) */
|
||||
|
||||
@@ -20,15 +20,12 @@
|
||||
* This file contains compile-time configurable constants for SDP Search
|
||||
******************************************************************************/
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gki.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sdp_api.h"
|
||||
|
||||
#if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE)
|
||||
|
||||
#ifndef BTA_SDP_DB_SIZE
|
||||
#define BTA_SDP_DB_SIZE 1500
|
||||
#define BTA_SDP_DB_SIZE 4500
|
||||
#endif
|
||||
|
||||
static UINT8 __attribute__ ((aligned(4))) bta_sdp_db_data[BTA_SDP_DB_SIZE];
|
||||
@@ -40,5 +37,3 @@ const tBTA_SDP_CFG bta_sdp_cfg = {
|
||||
};
|
||||
|
||||
tBTA_SDP_CFG *p_bta_sdp_cfg = (tBTA_SDP_CFG *) &bta_sdp_cfg;
|
||||
|
||||
#endif /* #if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE) */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user