forked from espressif/esp-idf
Compare commits
387 Commits
v3.1-beta1
...
v3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22da5f6de9 | ||
|
|
0ec9d3ec7d | ||
|
|
70764a4cf9 | ||
|
|
2ad5686937 | ||
|
|
84d10d8dad | ||
|
|
7f8de47631 | ||
|
|
16add00668 | ||
|
|
a83c918946 | ||
|
|
9f791e06f6 | ||
|
|
c3ba237846 | ||
|
|
17c4a76395 | ||
|
|
114b16f0d5 | ||
|
|
e1fc259600 | ||
|
|
1d537d29d5 | ||
|
|
09f5854c9a | ||
|
|
200d8d235b | ||
|
|
84a32f3288 | ||
|
|
bfc8142c99 | ||
|
|
bcebf3e6f1 | ||
|
|
4577270fc3 | ||
|
|
2d22fbd4ff | ||
|
|
9f6af0ad4b | ||
|
|
c060853f70 | ||
|
|
501d81ce32 | ||
|
|
f9a770134b | ||
|
|
b4fc5b0e8f | ||
|
|
a821805ddc | ||
|
|
cb9fa1f295 | ||
|
|
7ffd68cac2 | ||
|
|
dd77a4c65d | ||
|
|
a47cc3dd46 | ||
|
|
7cd75f30f2 | ||
|
|
3d2cd911f0 | ||
|
|
da94560ec5 | ||
|
|
21ef7ed82c | ||
|
|
125da7a1c2 | ||
|
|
ceca7b741c | ||
|
|
ab95d5cdd7 | ||
|
|
bc6a193130 | ||
|
|
7cc5888583 | ||
|
|
0743361da3 | ||
|
|
c16fbbf614 | ||
|
|
b64815be4c | ||
|
|
885df4c90f | ||
|
|
d376105e8e | ||
|
|
7f50bb7e7f | ||
|
|
53509c7bfd | ||
|
|
1bbe9538ef | ||
|
|
39dd71d958 | ||
|
|
2dfe58e1b3 | ||
|
|
2e60a4b751 | ||
|
|
fc18d2cea5 | ||
|
|
8b6060e24e | ||
|
|
640f690def | ||
|
|
cce9fa970e | ||
|
|
f63ab0792b | ||
|
|
f4c8df2635 | ||
|
|
db5c542e96 | ||
|
|
bb8ecf8a7b | ||
|
|
c2e424e7af | ||
|
|
a0191b28b2 | ||
|
|
fa8dc32800 | ||
|
|
cf3e89c1b2 | ||
|
|
810aa5427c | ||
|
|
08b9551494 | ||
|
|
92b29923cb | ||
|
|
48bd67524d | ||
|
|
70288f864e | ||
|
|
04238fa5e5 | ||
|
|
191557db02 | ||
|
|
695d95c983 | ||
|
|
d91c425178 | ||
|
|
0da8e99580 | ||
|
|
c6b4fa5a9a | ||
|
|
281877ada5 | ||
|
|
9a273863ba | ||
|
|
abbc13af62 | ||
|
|
9fb746824a | ||
|
|
8a1adb0d50 | ||
|
|
ddb2570849 | ||
|
|
7f4b77ca5b | ||
|
|
d421663d3f | ||
|
|
c455d6f2a0 | ||
|
|
b3eee7d58f | ||
|
|
271e2f9419 | ||
|
|
70f15bd28e | ||
|
|
607a1abefd | ||
|
|
8122f7162c | ||
|
|
cd31a5e3c6 | ||
|
|
8a6c1df041 | ||
|
|
7e02cd3498 | ||
|
|
ef30229e52 | ||
|
|
6ee884c861 | ||
|
|
002189cd1a | ||
|
|
fbe792f33f | ||
|
|
b88ae6c39f | ||
|
|
45d7039623 | ||
|
|
d9a1b5faae | ||
|
|
b2901d7e2f | ||
|
|
a3b5a23b87 | ||
|
|
eaa48f380a | ||
|
|
78c083325f | ||
|
|
a8d34b8e20 | ||
|
|
66e7027e7a | ||
|
|
6210272bfd | ||
|
|
57ed12a019 | ||
|
|
a4270573e7 | ||
|
|
ae5cb25f11 | ||
|
|
bf76c1bc1a | ||
|
|
cb05e152b9 | ||
|
|
f999688f2c | ||
|
|
762c5fe996 | ||
|
|
ac19aef689 | ||
|
|
d88b705562 | ||
|
|
7d9d4d16e5 | ||
|
|
1e92ad77c4 | ||
|
|
e136fb7e18 | ||
|
|
4225b9794f | ||
|
|
76b9e36f2b | ||
|
|
b490f05b95 | ||
|
|
c7ca7872cb | ||
|
|
97655e05b5 | ||
|
|
512e4d5836 | ||
|
|
9d8a85e2ab | ||
|
|
8a940ccd65 | ||
|
|
c983bc4d12 | ||
|
|
b8582d977d | ||
|
|
c4ffb39ccc | ||
|
|
485ed4cc22 | ||
|
|
d4e38152ef | ||
|
|
e5abec310d | ||
|
|
2c483a6b52 | ||
|
|
bf281b31ec | ||
|
|
3c359763da | ||
|
|
f81e71f622 | ||
|
|
a1dadda7d6 | ||
|
|
cfde037f9a | ||
|
|
3fcc3689ce | ||
|
|
497b123958 | ||
|
|
7995ba6433 | ||
|
|
5019ff3345 | ||
|
|
b270638868 | ||
|
|
3576a634c7 | ||
|
|
d8a1080bdf | ||
|
|
c209efa4e2 | ||
|
|
d78452ed29 | ||
|
|
acb3b6fee2 | ||
|
|
c237beff1d | ||
|
|
34a4a96ded | ||
|
|
2ef6bcaedd | ||
|
|
1928a4a638 | ||
|
|
d85b1fb091 | ||
|
|
970502f904 | ||
|
|
d3cb687936 | ||
|
|
dbb82a413f | ||
|
|
b28db50786 | ||
|
|
7999c06f68 | ||
|
|
490d7cbba9 | ||
|
|
a8b92d560b | ||
|
|
1884151ca8 | ||
|
|
b86c8b3260 | ||
|
|
2d31597fa9 | ||
|
|
715dfac07e | ||
|
|
bf72ed92a9 | ||
|
|
146a959706 | ||
|
|
fa9c836f02 | ||
|
|
609e39a620 | ||
|
|
3956fe30c0 | ||
|
|
831e8d653f | ||
|
|
35a3ef6892 | ||
|
|
5637424aff | ||
|
|
0fc888cf78 | ||
|
|
b37f08f961 | ||
|
|
62682a681a | ||
|
|
3e2d5f6292 | ||
|
|
e9112a9489 | ||
|
|
e00d9425da | ||
|
|
3eaf8f1a84 | ||
|
|
ef38eb0323 | ||
|
|
c6be772242 | ||
|
|
c892c96f9a | ||
|
|
7f2edf8528 | ||
|
|
9b6769411a | ||
|
|
e55f55531c | ||
|
|
0f665dfb0d | ||
|
|
b2f1dd6a16 | ||
|
|
989396ef27 | ||
|
|
b3a2f85c70 | ||
|
|
bd768edca2 | ||
|
|
fdf61f7c45 | ||
|
|
ccd431c7ed | ||
|
|
e1e4e08fa8 | ||
|
|
f8b191cfae | ||
|
|
487ae78235 | ||
|
|
4314b00289 | ||
|
|
650e1f79d1 | ||
|
|
b87c822d59 | ||
|
|
90c6ea59a6 | ||
|
|
7fbfb0fc9b | ||
|
|
447890247a | ||
|
|
d360f6d95d | ||
|
|
7edc392d7c | ||
|
|
071f7cdb49 | ||
|
|
89b423658a | ||
|
|
6d0a9fe95e | ||
|
|
afdc73c8ab | ||
|
|
1dc9be01c4 | ||
|
|
cffd28ad83 | ||
|
|
f4c57eb764 | ||
|
|
346d6b0eaa | ||
|
|
0a357a4838 | ||
|
|
76a46a0f68 | ||
|
|
8dbf96a471 | ||
|
|
60080d4893 | ||
|
|
3716e3e8c4 | ||
|
|
0b1c461e63 | ||
|
|
ec73cebb59 | ||
|
|
ce634ef221 | ||
|
|
af2a6ee826 | ||
|
|
2a581e3fab | ||
|
|
7b0a926574 | ||
|
|
f2c543785b | ||
|
|
fdfe38a779 | ||
|
|
ed27e75f50 | ||
|
|
ea30c54cda | ||
|
|
c71c8aea55 | ||
|
|
46001bf6d4 | ||
|
|
3e5053b778 | ||
|
|
0db9b87d66 | ||
|
|
a9aaabae21 | ||
|
|
f43dd79e11 | ||
|
|
dff911da69 | ||
|
|
31ca811240 | ||
|
|
febb0cb3da | ||
|
|
d128ff3ecd | ||
|
|
debe83c3b5 | ||
|
|
5752e4d588 | ||
|
|
66dad0c506 | ||
|
|
fffbcbb78b | ||
|
|
b8937e5522 | ||
|
|
0a2e4967ef | ||
|
|
cbc5ef4bc6 | ||
|
|
aec8dfdc8e | ||
|
|
3ad712ba86 | ||
|
|
b31e16039e | ||
|
|
16bb663c74 | ||
|
|
4bd6486b41 | ||
|
|
1340de576e | ||
|
|
92ea676c38 | ||
|
|
8335933cdf | ||
|
|
f198339ec0 | ||
|
|
f4f563bc7b | ||
|
|
a95678bfcd | ||
|
|
dadfcc35b3 | ||
|
|
7535226679 | ||
|
|
35364c365f | ||
|
|
2d7798e091 | ||
|
|
d945191e08 | ||
|
|
a0014d91b9 | ||
|
|
ebc3df0038 | ||
|
|
85127bcbbd | ||
|
|
364e587b46 | ||
|
|
6752163800 | ||
|
|
ddb05d0719 | ||
|
|
125828edaf | ||
|
|
d7f5c3e55f | ||
|
|
eebbe2d008 | ||
|
|
9ca4dc0626 | ||
|
|
dd73e2a453 | ||
|
|
07b1e2053c | ||
|
|
999f86320e | ||
|
|
3c188abdd7 | ||
|
|
698d3bafa5 | ||
|
|
fcf0324a66 | ||
|
|
3c4c838c2b | ||
|
|
36adefc8a8 | ||
|
|
e8ff79d6b4 | ||
|
|
baa6c19700 | ||
|
|
e3dedb74c5 | ||
|
|
f406174be5 | ||
|
|
5ebb70ecc5 | ||
|
|
8437b63845 | ||
|
|
b17defd6cb | ||
|
|
26e1136fc5 | ||
|
|
6b5a15e3da | ||
|
|
f9affb9fb8 | ||
|
|
21fd581265 | ||
|
|
6c87d104c0 | ||
|
|
7634d9a991 | ||
|
|
c59f7687ca | ||
|
|
0f0833e350 | ||
|
|
e7faa1d851 | ||
|
|
bf10447b82 | ||
|
|
be829afe6e | ||
|
|
950dd8e3e5 | ||
|
|
330c6a50e1 | ||
|
|
6065d2fd08 | ||
|
|
754cd7bd56 | ||
|
|
46b723e5ed | ||
|
|
4667fb2495 | ||
|
|
8c5f1c866b | ||
|
|
8bb4c694ce | ||
|
|
fdccc19485 | ||
|
|
6b9784cc45 | ||
|
|
f5f966d91a | ||
|
|
cfa8ed15c0 | ||
|
|
c70f9db369 | ||
|
|
2909fc182b | ||
|
|
e100acbb73 | ||
|
|
2f433e4342 | ||
|
|
580cfeaaae | ||
|
|
955e84a3bc | ||
|
|
f6cd55d2ac | ||
|
|
11980a9ad4 | ||
|
|
6cc5971516 | ||
|
|
61aff5162c | ||
|
|
8cf82be917 | ||
|
|
ed1f4e50df | ||
|
|
be4956fe7c | ||
|
|
a1fac97f1a | ||
|
|
979568fa0b | ||
|
|
f07c1ca94f | ||
|
|
cc104eb05b | ||
|
|
2f4079ebb2 | ||
|
|
829e6c44f1 | ||
|
|
81e48ca31f | ||
|
|
526496ba20 | ||
|
|
6f31674b28 | ||
|
|
b7ddb0c3d3 | ||
|
|
c7f19e76d7 | ||
|
|
8453806a8c | ||
|
|
48c3ad37f1 | ||
|
|
9ec14decce | ||
|
|
68282cf80b | ||
|
|
2fadf8a000 | ||
|
|
c7307de63e | ||
|
|
c42b791aaa | ||
|
|
f6db61e4f4 | ||
|
|
918c4b4c48 | ||
|
|
d5a5897140 | ||
|
|
99e02d4e42 | ||
|
|
381be65472 | ||
|
|
858b95a924 | ||
|
|
1cb5712463 | ||
|
|
4a2f1f0354 | ||
|
|
56902f0054 | ||
|
|
f1d3bfc0c7 | ||
|
|
2a3e2b8eed | ||
|
|
b44c8b125f | ||
|
|
2ea359ad0c | ||
|
|
6bdc49b6e4 | ||
|
|
800bffb8b0 | ||
|
|
9d88d13f77 | ||
|
|
2816cf1d67 | ||
|
|
b57843b66a | ||
|
|
12be399762 | ||
|
|
bc1693aae3 | ||
|
|
88df8fd293 | ||
|
|
15d5e88618 | ||
|
|
9f8cdd3572 | ||
|
|
95e17d6d92 | ||
|
|
7d9ba66f83 | ||
|
|
4d7bc8e8ba | ||
|
|
abef220b13 | ||
|
|
04a944598f | ||
|
|
e94db98e73 | ||
|
|
efb5928934 | ||
|
|
7eaf2f4bdb | ||
|
|
cb99531d15 | ||
|
|
0bdc12256e | ||
|
|
1f8e07fd8f | ||
|
|
be962a9444 | ||
|
|
4f1a856dbf | ||
|
|
3fac2b2ddc | ||
|
|
674d398c93 | ||
|
|
3ae4822115 | ||
|
|
97e01a4c4d | ||
|
|
ce6748873d | ||
|
|
134f2238bd | ||
|
|
7f29593a7d | ||
|
|
067a19ad88 | ||
|
|
f04525095f | ||
|
|
68e75dd0df | ||
|
|
35f521afb6 | ||
|
|
99a2359c5c | ||
|
|
c671a0c3eb | ||
|
|
a538644560 |
@@ -32,3 +32,8 @@ insert_final_newline = false
|
||||
|
||||
[*.py]
|
||||
max_line_length = 119
|
||||
|
||||
[{*.cmake,CMakeLists.txt}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -52,4 +52,11 @@ examples/protocols/aws_iot/*/main/certs/*.pem.*
|
||||
coverage.info
|
||||
coverage_report/
|
||||
|
||||
# Windows tools installer build
|
||||
tools/windows/tool_setup/.*
|
||||
tools/windows/tool_setup/input
|
||||
tools/windows/tool_setup/dl
|
||||
tools/windows/tool_setup/Output
|
||||
|
||||
test_multi_heap_host
|
||||
|
||||
|
||||
202
.gitlab-ci.yml
202
.gitlab-ci.yml
@@ -1,9 +1,9 @@
|
||||
stages:
|
||||
- build
|
||||
- assign_test
|
||||
- host_test
|
||||
- unit_test
|
||||
- test
|
||||
- test_report
|
||||
- integration_test
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
@@ -151,6 +151,8 @@ build_ssc_01:
|
||||
build_ssc_02:
|
||||
<<: *build_ssc_template
|
||||
|
||||
# If you want to add new build ssc jobs, please add it into dependencies of `assign_test` and `.test_template`
|
||||
|
||||
build_esp_idf_tests:
|
||||
<<: *build_template
|
||||
artifacts:
|
||||
@@ -158,7 +160,7 @@ build_esp_idf_tests:
|
||||
- tools/unit-test-app/output
|
||||
- components/idf_test/unit_test/TestCaseAll.yml
|
||||
- components/idf_test/unit_test/CIConfigs/*.yml
|
||||
expire_in: 6 mos
|
||||
expire_in: 1 mos
|
||||
script:
|
||||
- cd tools/unit-test-app
|
||||
- MAKEFLAGS= make help # make sure kconfig tools are built in single process
|
||||
@@ -193,6 +195,12 @@ build_esp_idf_tests:
|
||||
# build some of examples
|
||||
- mkdir -p ${LOG_PATH}
|
||||
- ${IDF_PATH}/tools/ci/build_examples.sh "${CI_JOB_NAME}"
|
||||
# and again, with cmake!
|
||||
- rm -rf ../build_examples_cmake
|
||||
- mkdir ../build_examples_cmake
|
||||
- cd ../build_examples_cmake
|
||||
- mkdir -p ${LOG_PATH}_cmake
|
||||
- LOG_PATH=${LOG_PATH}_cmake ${IDF_PATH}/tools/ci/build_examples_cmake.sh "${CI_JOB_NAME}"
|
||||
|
||||
build_examples_00:
|
||||
<<: *build_examples_template
|
||||
@@ -218,6 +226,7 @@ build_examples_06:
|
||||
build_examples_07:
|
||||
<<: *build_examples_template
|
||||
|
||||
# If you want to add new build example jobs, please add it into dependencies of `.example_test_template`
|
||||
|
||||
build_docs:
|
||||
stage: build
|
||||
@@ -250,22 +259,27 @@ build_docs:
|
||||
- make html
|
||||
- ../check_doc_warnings.sh
|
||||
|
||||
test_nvs_on_host:
|
||||
stage: test
|
||||
verify_cmake_style:
|
||||
stage: build
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
script:
|
||||
tools/cmake/run_cmake_lint.sh
|
||||
|
||||
.host_test_template: &host_test_template
|
||||
stage: host_test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
|
||||
test_nvs_on_host:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- cd components/nvs_flash/test_nvs_host
|
||||
- make test
|
||||
|
||||
test_nvs_coverage:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
<<: *host_test_template
|
||||
artifacts:
|
||||
paths:
|
||||
- components/nvs_flash/test_nvs_host/coverage_report
|
||||
@@ -279,63 +293,52 @@ test_nvs_coverage:
|
||||
- make coverage_report
|
||||
|
||||
test_partition_table_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
<<: *host_test_template
|
||||
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$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
<<: *host_test_template
|
||||
artifacts:
|
||||
paths:
|
||||
- components/wear_levelling/test_wl_host/coverage_report.zip
|
||||
dependencies: []
|
||||
script:
|
||||
- cd components/wear_levelling/test_wl_host
|
||||
- make test
|
||||
|
||||
test_fatfs_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
<<: *host_test_template
|
||||
tags:
|
||||
- wl_host_test
|
||||
dependencies: []
|
||||
script:
|
||||
- cd components/fatfs/test_fatfs_host/
|
||||
- make test
|
||||
|
||||
test_spiffs_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
<<: *host_test_template
|
||||
tags:
|
||||
- wl_host_test
|
||||
dependencies: []
|
||||
script:
|
||||
- cd components/spiffs/test_spiffs_host/
|
||||
- make test
|
||||
|
||||
test_multi_heap_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- cd components/heap/test_multi_heap_host
|
||||
- ./test_all_configs.sh
|
||||
|
||||
test_confserver:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- cd tools/kconfig_new/test
|
||||
- ./test_confserver.py
|
||||
|
||||
test_build_system:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
|
||||
- rm -rf test_build_system
|
||||
@@ -343,73 +346,23 @@ test_build_system:
|
||||
- cd test_build_system
|
||||
- ${IDF_PATH}/tools/ci/test_build_system.sh
|
||||
|
||||
test_report:
|
||||
stage: test_report
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- report
|
||||
only:
|
||||
- master
|
||||
- triggers
|
||||
- schedules
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
variables:
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
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
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- $REPORT_PATH
|
||||
- $LOG_PATH
|
||||
expire_in: 12 mos
|
||||
test_build_system_cmake:
|
||||
<<: *host_test_template
|
||||
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`
|
||||
- REVISION="${VER_NUM}_${SHA_ID}"
|
||||
# replace / to _ in branch name
|
||||
- ESCAPED_BRANCH_NAME=`echo $CI_COMMIT_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"
|
||||
# clone test bench
|
||||
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
|
||||
- cd auto_test_script
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script
|
||||
# generate report
|
||||
- TEST_RESULT=Pass
|
||||
- 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"
|
||||
- cp -R $CI_PROJECT_NAME CI-test-result/RawData
|
||||
- cd CI-test-result
|
||||
# config git user
|
||||
- git config --global user.email "ci-test-result@espressif.com"
|
||||
- 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 push origin master
|
||||
- test "${TEST_RESULT}" = "Pass" || exit 1
|
||||
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
|
||||
- rm -rf test_build_system
|
||||
- mkdir test_build_system
|
||||
- cd test_build_system
|
||||
- ${IDF_PATH}/tools/ci/test_build_system_cmake.sh
|
||||
|
||||
test_esp_err_to_name_on_host:
|
||||
stage: test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- cd tools/
|
||||
- ./gen_esp_err_to_name.py
|
||||
- git diff --exit-code -- ../components/esp32/esp_err_to_name.c || (echo 'Differences found. Please run gen_esp_err_to_name.py and commit the changes.'; exit 1)
|
||||
|
||||
push_master_to_github:
|
||||
push_to_github:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
@@ -420,8 +373,6 @@ push_master_to_github:
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
when: on_success
|
||||
dependencies: []
|
||||
variables:
|
||||
GITHUB_PUSH_REFS: refs/remotes/origin/release refs/remotes/origin/master
|
||||
before_script: *do_nothing_before
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
@@ -432,15 +383,12 @@ push_master_to_github:
|
||||
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- git remote remove github &>/dev/null || true
|
||||
- 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
|
||||
# (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)
|
||||
|
||||
# Need separate push commands for tag builds and for branch builds
|
||||
- "[ -n \"${CI_COMMIT_TAG}\" ] && git push github ${CI_COMMIT_TAG}"
|
||||
- "[ -z \"${CI_COMMIT_TAG}\" ] && git push github ${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}"
|
||||
|
||||
deploy_docs:
|
||||
stage: assign_test
|
||||
stage: host_test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- deploy
|
||||
@@ -475,7 +423,7 @@ deploy_docs:
|
||||
- echo "[document preview][zh_CN] $CI_DOCKER_REGISTRY/docs/esp-idf/zh_CN/${GIT_VER}/index.html"
|
||||
|
||||
check_doc_links:
|
||||
stage: test
|
||||
stage: host_test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- check_doc_links
|
||||
@@ -525,6 +473,20 @@ check_permissions:
|
||||
script:
|
||||
- tools/ci/check-executable.sh
|
||||
|
||||
check_examples_cmake_make:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- build
|
||||
except:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before
|
||||
script:
|
||||
- tools/ci/check_examples_cmake_make.sh
|
||||
|
||||
check_submodule_sync:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
@@ -577,7 +539,7 @@ assign_test:
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
|
||||
|
||||
.example_test_template: &example_test_template
|
||||
stage: test
|
||||
stage: integration_test
|
||||
when: on_success
|
||||
only:
|
||||
- master
|
||||
@@ -585,14 +547,21 @@ assign_test:
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
# gitlab ci do not support match job with RegEx or wildcard now in dependencies.
|
||||
# we have a lot build example jobs and the binaries them exceed the limitation of artifacts.
|
||||
# we can't artifact them in one job. For example test jobs, download all artifacts from previous stages.
|
||||
dependencies:
|
||||
- assign_test
|
||||
- build_examples_00
|
||||
- build_examples_01
|
||||
- build_examples_02
|
||||
- build_examples_03
|
||||
- build_examples_04
|
||||
- build_examples_05
|
||||
- build_examples_06
|
||||
- build_examples_07
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
expire_in: 6 mos
|
||||
expire_in: 1 mos
|
||||
variables:
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/examples"
|
||||
@@ -624,7 +593,7 @@ assign_test:
|
||||
ENV_FILE: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
|
||||
|
||||
.test_template: &test_template
|
||||
stage: test
|
||||
stage: integration_test
|
||||
when: on_success
|
||||
only:
|
||||
- master
|
||||
@@ -632,7 +601,6 @@ assign_test:
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
allow_failure: true
|
||||
dependencies:
|
||||
- assign_test
|
||||
- build_ssc_00
|
||||
@@ -642,7 +610,7 @@ assign_test:
|
||||
when: always
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
expire_in: 6 mos
|
||||
expire_in: 1 mos
|
||||
variables:
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
@@ -671,7 +639,7 @@ nvs_compatible_test:
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
- nvs_wifi.bin
|
||||
expire_in: 6 mos
|
||||
expire_in: 1 mos
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- NVS_Compatible
|
||||
@@ -1082,6 +1050,12 @@ UT_010_04:
|
||||
- UT_T1_RMT
|
||||
- psram
|
||||
|
||||
UT_601_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
IT_001_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
@@ -1250,6 +1224,12 @@ IT_010_01:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_011_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T50_1
|
||||
|
||||
IT_501_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
|
||||
143
Kconfig
143
Kconfig
@@ -4,6 +4,9 @@
|
||||
#
|
||||
mainmenu "Espressif IoT Development Framework Configuration"
|
||||
|
||||
config IDF_CMAKE
|
||||
bool
|
||||
option env="IDF_CMAKE"
|
||||
|
||||
menu "SDK tool configuration"
|
||||
config TOOLPREFIX
|
||||
@@ -15,11 +18,15 @@ config TOOLPREFIX
|
||||
|
||||
config PYTHON
|
||||
string "Python 2 interpreter"
|
||||
depends on !IDF_CMAKE
|
||||
default "python"
|
||||
help
|
||||
The executable name/path that is used to run python. On some systems Python 2.x
|
||||
may need to be invoked as python2.
|
||||
|
||||
(Note: This option is used with the GNU Make build system only, not idf.py
|
||||
or CMake-based builds.)
|
||||
|
||||
config MAKE_WARN_UNDEFINED_VARIABLES
|
||||
bool "'make' warns on undefined variables"
|
||||
default "y"
|
||||
@@ -35,7 +42,141 @@ endmenu # SDK tool configuration
|
||||
|
||||
source "$COMPONENT_KCONFIGS_PROJBUILD"
|
||||
|
||||
source "$IDF_PATH/Kconfig.compiler"
|
||||
menu "Compiler options"
|
||||
|
||||
choice OPTIMIZATION_COMPILER
|
||||
prompt "Optimization Level"
|
||||
default OPTIMIZATION_LEVEL_DEBUG
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
|
||||
config OPTIMIZATION_LEVEL_DEBUG
|
||||
bool "Debug (-Og)"
|
||||
config OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Assertions can be:
|
||||
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
menuconfig CXX_EXCEPTIONS
|
||||
bool "Enable C++ exceptions"
|
||||
default n
|
||||
help
|
||||
Enabling this option compiles all IDF C++ files with exception support enabled.
|
||||
|
||||
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
|
||||
an exception will abort instead.
|
||||
|
||||
Enabling this option currently adds an additional ~500 bytes of heap overhead
|
||||
when an exception is thrown in user code for the first time.
|
||||
|
||||
config CXX_EXCEPTIONS_EMG_POOL_SIZE
|
||||
int "Emergency Pool Size"
|
||||
default 0
|
||||
depends on CXX_EXCEPTIONS
|
||||
help
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
choice STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
|
||||
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
|
||||
The guards are initialized when a function is entered and then checked when the function exits.
|
||||
If a guard check fails, program is halted. Protection has the following modes:
|
||||
|
||||
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca,
|
||||
and functions with buffers larger than 8 bytes are protected.
|
||||
|
||||
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes
|
||||
additional functions to be protected -- those that have local array definitions,
|
||||
or have references to local frame addresses.
|
||||
|
||||
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
|
||||
|
||||
Modes have the following impact on code performance and coverage:
|
||||
|
||||
- performance: NORMAL > STRONG > OVERALL
|
||||
|
||||
- coverage: NORMAL < STRONG < OVERALL
|
||||
|
||||
|
||||
config STACK_CHECK_NONE
|
||||
bool "None"
|
||||
config STACK_CHECK_NORM
|
||||
bool "Normal"
|
||||
config STACK_CHECK_STRONG
|
||||
bool "Strong"
|
||||
config STACK_CHECK_ALL
|
||||
bool "Overall"
|
||||
endchoice
|
||||
|
||||
config STACK_CHECK
|
||||
bool
|
||||
default !STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection.
|
||||
|
||||
config WARN_WRITE_STRINGS
|
||||
bool "Enable -Wwrite-strings warning flag"
|
||||
default "n"
|
||||
help
|
||||
Adds -Wwrite-strings flag for the C/C++ compilers.
|
||||
|
||||
For C, this gives string constants the type ``const char[]`` so that
|
||||
copying the address of one into a non-const ``char *`` pointer
|
||||
produces a warning. This warning helps to find at compile time code
|
||||
that tries to write into a string constant.
|
||||
|
||||
For C++, this warns about the deprecated conversion from string
|
||||
literals to ``char *``.
|
||||
|
||||
endmenu # Compiler Options
|
||||
|
||||
menu "Component config"
|
||||
source "$COMPONENT_KCONFIGS"
|
||||
|
||||
135
Kconfig.compiler
135
Kconfig.compiler
@@ -1,135 +0,0 @@
|
||||
menu "Compiler options"
|
||||
|
||||
choice OPTIMIZATION_COMPILER
|
||||
prompt "Optimization Level"
|
||||
default OPTIMIZATION_LEVEL_DEBUG
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
|
||||
config OPTIMIZATION_LEVEL_DEBUG
|
||||
bool "Debug (-Og)"
|
||||
config OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Assertions can be:
|
||||
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
menuconfig CXX_EXCEPTIONS
|
||||
bool "Enable C++ exceptions"
|
||||
default n
|
||||
help
|
||||
Enabling this option compiles all IDF C++ files with exception support enabled.
|
||||
|
||||
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
|
||||
an exception will abort instead.
|
||||
|
||||
Enabling this option currently adds an additional ~500 bytes of heap overhead
|
||||
when an exception is thrown in user code for the first time.
|
||||
|
||||
config CXX_EXCEPTIONS_EMG_POOL_SIZE
|
||||
int "Emergency Pool Size"
|
||||
default 0
|
||||
depends on CXX_EXCEPTIONS
|
||||
help
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
choice STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
|
||||
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
|
||||
The guards are initialized when a function is entered and then checked when the function exits.
|
||||
If a guard check fails, program is halted. Protection has the following modes:
|
||||
|
||||
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca,
|
||||
and functions with buffers larger than 8 bytes are protected.
|
||||
|
||||
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes
|
||||
additional functions to be protected -- those that have local array definitions,
|
||||
or have references to local frame addresses.
|
||||
|
||||
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
|
||||
|
||||
Modes have the following impact on code performance and coverage:
|
||||
|
||||
- performance: NORMAL > STRONG > OVERALL
|
||||
|
||||
- coverage: NORMAL < STRONG < OVERALL
|
||||
|
||||
|
||||
config STACK_CHECK_NONE
|
||||
bool "None"
|
||||
config STACK_CHECK_NORM
|
||||
bool "Normal"
|
||||
config STACK_CHECK_STRONG
|
||||
bool "Strong"
|
||||
config STACK_CHECK_ALL
|
||||
bool "Overall"
|
||||
endchoice
|
||||
|
||||
config STACK_CHECK
|
||||
bool
|
||||
default !STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection.
|
||||
|
||||
config WARN_WRITE_STRINGS
|
||||
bool "Enable -Wwrite-strings warning flag"
|
||||
default "n"
|
||||
help
|
||||
Adds -Wwrite-strings flag for the C/C++ compilers.
|
||||
|
||||
For C, this gives string constants the type ``const char[]`` so that
|
||||
copying the address of one into a non-const ``char *`` pointer
|
||||
produces a warning. This warning helps to find at compile time code
|
||||
that tries to write into a string constant.
|
||||
|
||||
For C++, this warns about the deprecated conversion from string
|
||||
literals to ``char *``.
|
||||
|
||||
endmenu # Compiler Options
|
||||
34
README.md
34
README.md
@@ -4,22 +4,27 @@
|
||||
|
||||
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
|
||||
|
||||
# Developing With the ESP-IDF
|
||||
# Developing With ESP-IDF
|
||||
|
||||
## Setting Up ESP-IDF
|
||||
|
||||
See setup guides for detailed instructions to set up the ESP-IDF:
|
||||
|
||||
* [Windows Setup Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/windows-setup.html)
|
||||
* [Mac OS Setup Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/macos-setup.html)
|
||||
* [Linux Setup Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/linux-setup.html)
|
||||
* [Getting Started Guide for the stable ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/)
|
||||
* [Getting Started Guide for the latest (master branch) ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/)
|
||||
|
||||
## Finding a Project
|
||||
|
||||
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in the setup guide, ESP-IDF comes with some example projects in the [examples](examples) directory.
|
||||
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in Getting Started, ESP-IDF comes with some example projects in the [examples](examples) directory.
|
||||
|
||||
Once you've found the project you want to work with, change to its directory and you can configure and build it.
|
||||
|
||||
To start your own project based on an example, copy the example project directory outside of the ESP-IDF directory.
|
||||
|
||||
# Quick Reference
|
||||
|
||||
See the Getting Started guide links above for a detailed setup guide. This is a quick reference for common commands when working with ESP-IDF projects:
|
||||
|
||||
## Configuring the Project
|
||||
|
||||
`make menuconfig`
|
||||
@@ -36,15 +41,17 @@ Once done configuring, press Escape multiple times to exit and say "Yes" to save
|
||||
|
||||
## Compiling the Project
|
||||
|
||||
`make all`
|
||||
`make -j4 all`
|
||||
|
||||
... will compile app, bootloader and generate a partition table based on the config.
|
||||
|
||||
NOTE: The `-j4` option causes `make` to run 4 parallel jobs. This is much faster than the default single job. The recommended number to pass to this option is `-j(number of CPUs + 1)`.
|
||||
|
||||
## Flashing the Project
|
||||
|
||||
When `make all` finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this from make by running:
|
||||
When the build finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this automatically by running:
|
||||
|
||||
`make flash`
|
||||
`make -j4 flash`
|
||||
|
||||
This will flash the entire project (app, bootloader and partition table) to a new chip. The settings for serial port flashing can be configured with `make menuconfig`.
|
||||
|
||||
@@ -56,24 +63,24 @@ The `make monitor` target uses the [idf_monitor tool](https://docs.espressif.com
|
||||
|
||||
Exit the monitor by typing Ctrl-].
|
||||
|
||||
To flash and monitor output in one pass, you can run:
|
||||
To build, flash and monitor output in one pass, you can run:
|
||||
|
||||
`make flash monitor`
|
||||
`make -j4 flash monitor`
|
||||
|
||||
## Compiling & Flashing Just the App
|
||||
## Compiling & Flashing Only the App
|
||||
|
||||
After the initial flash, you may just want to build and flash just your app, not the bootloader and partition table:
|
||||
|
||||
* `make app` - build just the app.
|
||||
* `make app-flash` - flash just the app.
|
||||
|
||||
`make app-flash` will automatically rebuild the app if it needs it.
|
||||
`make app-flash` will automatically rebuild the app if any source files have changed.
|
||||
|
||||
(In normal development there's no downside to reflashing the bootloader and partition table each time, if they haven't changed.)
|
||||
|
||||
## Parallel Builds
|
||||
|
||||
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to or one more than the number of CPU cores in your system.)
|
||||
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to the number of CPU cores in your system, plus one.)
|
||||
|
||||
Multiple make functions can be combined into one. For example: to build the app & bootloader using 5 jobs in parallel, then flash everything, and then display serial output from the ESP32 run:
|
||||
|
||||
@@ -81,6 +88,7 @@ Multiple make functions can be combined into one. For example: to build the app
|
||||
make -j5 flash monitor
|
||||
```
|
||||
|
||||
|
||||
## The Partition Table
|
||||
|
||||
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.
|
||||
|
||||
24
components/app_trace/CMakeLists.txt
Normal file
24
components/app_trace/CMakeLists.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
set(COMPONENT_SRCDIRS "." "gcov")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
if(CONFIG_SYSVIEW_ENABLE)
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS
|
||||
sys_view/Config
|
||||
sys_view/SEGGER
|
||||
sys_view/Sample/OS)
|
||||
|
||||
list(APPEND COMPONENT_SRCDIRS
|
||||
"sys_view/SEGGER"
|
||||
"sys_view/Sample/OS"
|
||||
"sys_view/Sample/Config"
|
||||
"sys_view/esp32")
|
||||
endif()
|
||||
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_PRIV_REQUIRES xtensa-debug-module)
|
||||
|
||||
register_component()
|
||||
|
||||
# disable --coverage for this component, as it is used as transport
|
||||
# for gcov
|
||||
component_compile_options("-fno-profile-arcs" "-fno-test-coverage")
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "rom/ets_sys.h"
|
||||
#include "esp_app_trace.h"
|
||||
|
||||
#define LOG_LOCAL_LEVEL ESP_LOG_ERROR
|
||||
#include "esp_log.h"
|
||||
const static char *TAG = "segger_rtt";
|
||||
|
||||
@@ -125,7 +124,7 @@ unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, u
|
||||
uint8_t event_id = *pbuf;
|
||||
|
||||
if (NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
|
||||
ESP_LOGE(TAG, "Too large event %d bytes!", NumBytes);
|
||||
ESP_LOGE(TAG, "Too large event %u bytes!", NumBytes);
|
||||
return 0;
|
||||
}
|
||||
if (xPortGetCoreID()) { // dual core specific code
|
||||
|
||||
7
components/app_update/CMakeLists.txt
Normal file
7
components/app_update/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
set(COMPONENT_SRCDIRS ".")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
set(COMPONENT_REQUIRES spi_flash)
|
||||
set(COMPONENT_PRIV_REQUIRES bootloader_support)
|
||||
|
||||
register_component()
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "esp_ota_ops.h"
|
||||
@@ -240,14 +241,6 @@ esp_err_t esp_ota_end(esp_ota_handle_t handle)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
ret = esp_secure_boot_verify_signature(it->part->address, data.image_len);
|
||||
if (ret != ESP_OK) {
|
||||
ret = ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
cleanup:
|
||||
LIST_REMOVE(it, entries);
|
||||
free(it);
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
||||
11
components/aws_iot/CMakeLists.txt
Normal file
11
components/aws_iot/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
if(CONFIG_AWS_IOT_SDK)
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
|
||||
set(COMPONENT_SRCDIRS "aws-iot-device-sdk-embedded-C/src port")
|
||||
else()
|
||||
message(STATUS "Building empty aws_iot component due to configuration")
|
||||
endif()
|
||||
|
||||
set(COMPONENT_REQUIRES "mbedtls")
|
||||
set(COMPONENT_PRIV_REQUIRES "jsmn")
|
||||
|
||||
register_component()
|
||||
7
components/bootloader/CMakeLists.txt
Normal file
7
components/bootloader/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
# bootloader component logic is all in project_include.cmake,
|
||||
# and subproject/CMakeLists.txt.
|
||||
#
|
||||
# This file is only included so the build system finds the
|
||||
# component
|
||||
|
||||
|
||||
@@ -275,6 +275,13 @@ config SECURE_BOOT_ALLOW_JTAG
|
||||
|
||||
Only set this option in testing environments.
|
||||
|
||||
config SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
|
||||
bool "Allow app partition length not 64KB aligned"
|
||||
depends on SECURE_BOOT_INSECURE
|
||||
help
|
||||
If not set (default), app partition size must be a multiple of 64KB. App images are padded to 64KB length, and the bootloader checks any trailing bytes after the signature (before the next 64KB boundary) have not been written. This is because flash cache maps entire 64KB pages into the address space. This prevents an attacker from appending unverified data after the app image in the flash, causing it to be mapped into the address space.
|
||||
|
||||
Setting this option allows the app partition length to be unaligned, and disables padding of the app image to this length. It is generally not recommended to set this option, unless you have a legacy partitioning scheme which doesn't support 64KB aligned partition lengths.
|
||||
|
||||
config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_ENCRYPT
|
||||
bool "Leave UART bootloader encryption enabled"
|
||||
|
||||
@@ -107,7 +107,7 @@ bootloader: $(BOOTLOADER_DIGEST_BIN)
|
||||
|
||||
$(BOOTLOADER_DIGEST_BIN): $(BOOTLOADER_BIN) $(SECURE_BOOTLOADER_KEY)
|
||||
@echo "DIGEST $(notdir $@)"
|
||||
$(Q) $(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
|
||||
$(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
|
||||
|
||||
else # CONFIG_SECURE_BOOT_ENABLED && !CONFIG_SECURE_BOOTLOADER_REFLASHABLE && !CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
|
||||
bootloader:
|
||||
|
||||
33
components/bootloader/project_include.cmake
Normal file
33
components/bootloader/project_include.cmake
Normal file
@@ -0,0 +1,33 @@
|
||||
if(BOOTLOADER_BUILD)
|
||||
return() # don't keep recursing!
|
||||
endif()
|
||||
|
||||
# Glue to build the bootloader subproject binary as an external
|
||||
# cmake project under this one
|
||||
#
|
||||
#
|
||||
set(bootloader_build_dir "${CMAKE_BINARY_DIR}/bootloader")
|
||||
set(bootloader_binary_files
|
||||
"${bootloader_build_dir}/bootloader.elf"
|
||||
"${bootloader_build_dir}/bootloader.bin"
|
||||
"${bootloader_build_dir}/bootloader.map"
|
||||
)
|
||||
|
||||
externalproject_add(bootloader
|
||||
# TODO: support overriding the bootloader in COMPONENT_PATHS
|
||||
SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject"
|
||||
BINARY_DIR "${bootloader_build_dir}"
|
||||
CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH}
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_ALWAYS 1 # no easy way around this...
|
||||
BUILD_BYPRODUCTS ${bootloader_binary_files}
|
||||
)
|
||||
|
||||
# this is a hack due to an (annoying) shortcoming in cmake, it can't
|
||||
# extend the 'clean' target to the external project
|
||||
# see thread: https://cmake.org/pipermail/cmake/2016-December/064660.html
|
||||
#
|
||||
# So for now we just have the top-level build remove the final build products...
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
|
||||
ADDITIONAL_MAKE_CLEAN_FILES
|
||||
${bootloader_binary_files})
|
||||
30
components/bootloader/subproject/CMakeLists.txt
Normal file
30
components/bootloader/subproject/CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if(NOT SDKCONFIG)
|
||||
message(FATAL_ERROR "Bootloader subproject expects the SDKCONFIG variable to be passed "
|
||||
"in by the parent build process.")
|
||||
endif()
|
||||
|
||||
if(NOT IDF_PATH)
|
||||
message(FATAL_ERROR "Bootloader subproject expects the IDF_PATH variable to be passed "
|
||||
"in by the parent build process.")
|
||||
endif()
|
||||
|
||||
set(COMPONENTS bootloader esptool_py esp32 partition_table soc bootloader_support log spi_flash micro-ecc soc)
|
||||
set(BOOTLOADER_BUILD 1)
|
||||
add_definitions(-DBOOTLOADER_BUILD=1)
|
||||
|
||||
set(COMPONENT_REQUIRES_COMMON log esp32 soc)
|
||||
|
||||
set(MAIN_SRCS main/bootloader_start.c)
|
||||
|
||||
include("${IDF_PATH}/tools/cmake/project.cmake")
|
||||
project(bootloader)
|
||||
|
||||
target_linker_script(bootloader.elf
|
||||
"main/esp32.bootloader.ld"
|
||||
"main/esp32.bootloader.rom.ld")
|
||||
# Imported from esp32 component
|
||||
target_linker_script(bootloader.elf ${ESP32_BOOTLOADER_LINKER_SCRIPTS})
|
||||
|
||||
target_link_libraries(bootloader.elf gcc)
|
||||
@@ -36,19 +36,25 @@ SECTIONS
|
||||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*liblog.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_utility.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:esp_image_format.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_partitions.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_sha.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:efuse.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot_signatures.*(.literal .text .literal.* .text.*)
|
||||
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
} > iram_loader_seg
|
||||
|
||||
|
||||
.iram.text :
|
||||
{
|
||||
. = ALIGN (16);
|
||||
@@ -113,13 +119,13 @@ SECTIONS
|
||||
. = (. + 3) & ~ 3;
|
||||
/* C++ constructor and destructor tables, properly ordered: */
|
||||
__init_array_start = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*crtbegin.*(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__init_array_end = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*crtbegin.*(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
/* C++ exception handlers table: */
|
||||
|
||||
14
components/bootloader_support/CMakeLists.txt
Normal file
14
components/bootloader_support/CMakeLists.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
set(COMPONENT_SRCDIRS "src")
|
||||
|
||||
if(${BOOTLOADER_BUILD})
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include include_priv")
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_PRIV_REQUIRES spi_flash micro-ecc)
|
||||
else()
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
set(COMPONENT_PRIV_INCLUDEDIRS "include_priv")
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_PRIV_REQUIRES spi_flash mbedtls micro-ecc)
|
||||
endif()
|
||||
|
||||
register_component()
|
||||
@@ -17,7 +17,9 @@
|
||||
#include <stdbool.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#include "esp_spi_flash.h"
|
||||
#endif
|
||||
#include "soc/efuse_reg.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define ESP_PARTITION_TABLE_MAX_LEN 0xC00 /* Maximum length of partition table data */
|
||||
#define ESP_PARTITION_TABLE_MAX_ENTRIES (ESP_PARTITION_TABLE_MAX_LEN / sizeof(esp_partition_info_t)) /* Maximum length of partition table data, including terminating entry */
|
||||
|
||||
/* @brief Verify the partition table (does not include verifying secure boot cryptographic signature)
|
||||
/* @brief Verify the partition table
|
||||
*
|
||||
* @param partition_table Pointer to at least ESP_PARTITION_TABLE_MAX_ENTRIES of potential partition table data. (ESP_PARTITION_TABLE_MAX_LEN bytes.)
|
||||
* @param log_errors Log errors if the partition table is invalid.
|
||||
@@ -35,6 +35,13 @@
|
||||
*
|
||||
* @return ESP_OK on success, ESP_ERR_INVALID_STATE if partition table is not valid.
|
||||
*/
|
||||
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
|
||||
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
|
||||
|
||||
|
||||
/* This function is included for compatibility with the ESP-IDF v3.x API */
|
||||
inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||
{
|
||||
return esp_partition_table_verify(partition_table, log_errors, num_partitions);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
|
||||
static const char* TAG = "boot_comm";
|
||||
|
||||
@@ -42,6 +43,9 @@ bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s)
|
||||
esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec)
|
||||
{
|
||||
gpio_pad_select_gpio(num_pin);
|
||||
if (GPIO_PIN_MUX_REG[num_pin]) {
|
||||
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[num_pin]);
|
||||
}
|
||||
gpio_pad_pullup(num_pin);
|
||||
uint32_t tm_start = esp_log_early_timestamp();
|
||||
if (GPIO_INPUT_GET(num_pin) == 1) {
|
||||
@@ -96,18 +100,6 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat
|
||||
int num_partitions;
|
||||
bool ret = true;
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "Verifying partition table signature...");
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table signature.");
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "Partition table signature verified");
|
||||
}
|
||||
#endif
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
@@ -115,7 +107,7 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
|
||||
|
||||
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
|
||||
err = esp_partition_table_verify(partitions, true, &num_partitions);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table");
|
||||
ret = false;
|
||||
|
||||
@@ -28,7 +28,10 @@ bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
return NULL;
|
||||
}
|
||||
mbedtls_sha256_init(ctx);
|
||||
assert(mbedtls_sha256_starts_ret(ctx, false) == 0);
|
||||
int ret = mbedtls_sha256_starts_ret(ctx, false);
|
||||
if (ret != 0) {
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -36,7 +39,8 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
|
||||
{
|
||||
assert(handle != NULL);
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
|
||||
assert(mbedtls_sha256_update_ret(ctx, data, data_len) == 0);
|
||||
int ret = mbedtls_sha256_update_ret(ctx, data, data_len);
|
||||
assert(ret == 0);
|
||||
}
|
||||
|
||||
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
|
||||
@@ -44,7 +48,8 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
|
||||
assert(handle != NULL);
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
|
||||
if (digest != NULL) {
|
||||
assert(mbedtls_sha256_finish_ret(ctx, digest) == 0);
|
||||
int ret = mbedtls_sha256_finish_ret(ctx, digest);
|
||||
assert(ret == 0);
|
||||
}
|
||||
mbedtls_sha256_free(ctx);
|
||||
free(handle);
|
||||
|
||||
@@ -72,18 +72,6 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
esp_err_t err;
|
||||
int num_partitions;
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if(esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "Verifying partition table signature...");
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table signature.");
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "Partition table signature verified");
|
||||
}
|
||||
#endif
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
@@ -91,7 +79,7 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
|
||||
|
||||
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
|
||||
err = esp_partition_table_verify(partitions, true, &num_partitions);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table");
|
||||
return false;
|
||||
@@ -222,8 +210,8 @@ int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs)
|
||||
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 == UINT32_MAX && sb.ota_seq == UINT32_MAX) {
|
||||
ESP_LOGD(TAG, "OTA sequence numbers both empty (all-0xFF)");
|
||||
if ((sa.ota_seq == UINT32_MAX && sb.ota_seq == UINT32_MAX) || (bs->app_count == 0)) {
|
||||
ESP_LOGD(TAG, "OTA sequence numbers both empty (all-0xFF) or partition table does not have bootable ota_apps (app_count=%d)", bs->app_count);
|
||||
if (bs->factory.offset != 0) {
|
||||
ESP_LOGI(TAG, "Defaulting to factory image");
|
||||
return FACTORY_INDEX;
|
||||
|
||||
@@ -254,7 +254,7 @@ static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partitio
|
||||
ESP_LOGE(TAG, "Failed to read partition table data");
|
||||
return err;
|
||||
}
|
||||
if (esp_partition_table_basic_verify(partition_table, false, num_partitions) == ESP_OK) {
|
||||
if (esp_partition_table_verify(partition_table, false, num_partitions) == ESP_OK) {
|
||||
ESP_LOGD(TAG, "partition table is plaintext. Encrypting...");
|
||||
esp_err_t err = esp_flash_encrypt_region(ESP_PARTITION_TABLE_OFFSET,
|
||||
FLASH_SECTOR_SIZE);
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
static const char *TAG = "flash_parts";
|
||||
|
||||
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||
{
|
||||
int md5_found = 0;
|
||||
int num_parts;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#define CMD_WRDI 0x04
|
||||
#define CMD_RDSR 0x05
|
||||
#define CMD_RDSR2 0x35 /* Not all SPI flash uses this command */
|
||||
#define CMD_OTPEN 0x3A /* Enable OTP mode, not all SPI flash uses this command */
|
||||
|
||||
static const char *TAG = "qio_mode";
|
||||
|
||||
@@ -65,6 +66,11 @@ static void write_status_8b_wrsr2(unsigned new_status);
|
||||
/* Write 16 bit status using WRSR */
|
||||
static void write_status_16b_wrsr(unsigned new_status);
|
||||
|
||||
/* Read 8 bit status of XM25QU64A */
|
||||
static unsigned read_status_8b_xmc25qu64a();
|
||||
/* Write 8 bit status of XM25QU64A */
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status);
|
||||
|
||||
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
|
||||
|
||||
#ifndef CONFIG_BOOTLOADER_SPI_WP_PIN // Set in menuconfig if SPI flasher config is set to a quad mode
|
||||
@@ -84,11 +90,12 @@ static void write_status_16b_wrsr(unsigned new_status);
|
||||
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 },
|
||||
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
/* 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 },
|
||||
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
{ "XM25QU64A", 0x20, 0x3817, 0xFFFF, read_status_8b_xmc25qu64a, write_status_8b_xmc25qu64a, 6 },
|
||||
|
||||
/* Final entry is default entry, if no other IDs have matched.
|
||||
|
||||
@@ -96,7 +103,7 @@ const static qio_info_t chip_data[] = {
|
||||
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 },
|
||||
{ NULL, 0xFF, 0xFFFF, 0xFFFF, read_status_8b_rdsr2, write_status_8b_wrsr2, 1 },
|
||||
};
|
||||
|
||||
#define NUM_CHIPS (sizeof(chip_data) / sizeof(qio_info_t))
|
||||
@@ -246,6 +253,24 @@ static void write_status_16b_wrsr(unsigned new_status)
|
||||
execute_flash_command(CMD_WRSR, new_status, 16, 0);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_xmc25qu64a()
|
||||
{
|
||||
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
uint32_t read_status = execute_flash_command(CMD_RDSR, 0, 0, 8);
|
||||
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
|
||||
return read_status;
|
||||
}
|
||||
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status)
|
||||
{
|
||||
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
execute_flash_command(CMD_WRSR, new_status, 8, 0);
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
|
||||
}
|
||||
|
||||
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
|
||||
{
|
||||
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
|
||||
@@ -84,10 +84,13 @@ esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Verifying secure boot signature");
|
||||
|
||||
is_valid = uECC_verify(signature_verification_key_start,
|
||||
image_digest,
|
||||
DIGEST_LEN,
|
||||
sig_block->signature,
|
||||
uECC_secp256r1());
|
||||
ESP_LOGD(TAG, "Verification result %d", is_valid);
|
||||
return is_valid ? ESP_OK : ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
|
||||
92
components/bt/CMakeLists.txt
Normal file
92
components/bt/CMakeLists.txt
Normal file
@@ -0,0 +1,92 @@
|
||||
if(CONFIG_BT_ENABLED)
|
||||
|
||||
set(COMPONENT_SRCDIRS .)
|
||||
set(COMPONENT_ADD_INCLUDEDIRS include)
|
||||
|
||||
if(CONFIG_BLUEDROID_ENABLED)
|
||||
|
||||
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
|
||||
bluedroid/bta/include
|
||||
bluedroid/bta/ar/include
|
||||
bluedroid/bta/av/include
|
||||
bluedroid/bta/dm/include
|
||||
bluedroid/bta/gatt/include
|
||||
bluedroid/bta/hh/include
|
||||
bluedroid/bta/jv/include
|
||||
bluedroid/bta/sdp/include
|
||||
bluedroid/bta/sys/include
|
||||
bluedroid/device/include
|
||||
bluedroid/hci/include
|
||||
bluedroid/osi/include
|
||||
bluedroid/external/sbc/decoder/include
|
||||
bluedroid/external/sbc/encoder/include
|
||||
bluedroid/btc/profile/esp/blufi/include
|
||||
bluedroid/btc/profile/esp/include
|
||||
bluedroid/btc/profile/std/a2dp/include
|
||||
bluedroid/btc/profile/std/include
|
||||
bluedroid/btc/include
|
||||
bluedroid/stack/btm/include
|
||||
bluedroid/stack/gap/include
|
||||
bluedroid/stack/gatt/include
|
||||
bluedroid/stack/l2cap/include
|
||||
bluedroid/stack/sdp/include
|
||||
bluedroid/stack/smp/include
|
||||
bluedroid/stack/avct/include
|
||||
bluedroid/stack/avrc/include
|
||||
bluedroid/stack/avdt/include
|
||||
bluedroid/stack/a2dp/include
|
||||
bluedroid/stack/rfcomm/include
|
||||
bluedroid/stack/include
|
||||
bluedroid/common/include)
|
||||
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS bluedroid/api/include/api)
|
||||
|
||||
list(APPEND COMPONENT_SRCDIRS
|
||||
bluedroid/bta/dm
|
||||
bluedroid/bta/gatt
|
||||
bluedroid/bta/hh
|
||||
bluedroid/bta/sdp
|
||||
bluedroid/bta/av
|
||||
bluedroid/bta/ar
|
||||
bluedroid/bta/sys
|
||||
bluedroid/bta/jv
|
||||
bluedroid/device
|
||||
bluedroid/hci
|
||||
bluedroid/main
|
||||
bluedroid/osi
|
||||
bluedroid/external/sbc/decoder/srce
|
||||
bluedroid/external/sbc/encoder/srce
|
||||
bluedroid/btc/core
|
||||
bluedroid/btc/profile/esp/blufi
|
||||
bluedroid/btc/profile/std/gap
|
||||
bluedroid/btc/profile/std/gatt
|
||||
bluedroid/btc/profile/std/a2dp
|
||||
bluedroid/btc/profile/std/avrc
|
||||
bluedroid/btc/profile/std/spp
|
||||
bluedroid/stack/btm
|
||||
bluedroid/stack/btu
|
||||
bluedroid/stack/gap
|
||||
bluedroid/stack/gatt
|
||||
bluedroid/stack/hcic
|
||||
bluedroid/stack/l2cap
|
||||
bluedroid/stack/sdp
|
||||
bluedroid/stack/smp
|
||||
bluedroid/stack/avct
|
||||
bluedroid/stack/avrc
|
||||
bluedroid/stack/avdt
|
||||
bluedroid/stack/a2dp
|
||||
bluedroid/stack/rfcomm
|
||||
bluedroid/api
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# requirements can't depend on config
|
||||
set(COMPONENT_PRIV_REQUIRES nvs_flash)
|
||||
|
||||
register_component()
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
target_link_libraries(bt "-L${CMAKE_CURRENT_LIST_DIR}/lib")
|
||||
target_link_libraries(bt btdm_app)
|
||||
endif()
|
||||
@@ -1004,8 +1004,17 @@ config BT_BLE_DYNAMIC_ENV_MEMORY
|
||||
help
|
||||
This select can make the allocation of memory will become more flexible
|
||||
|
||||
config BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
bool "BLE queue congestion check"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around or application layer
|
||||
handling adv packets is slow, it will cause the controller memory to run out. if enabled, adv packets will be
|
||||
lost when host queue is congested.
|
||||
|
||||
config BLE_SCAN_DUPLICATE
|
||||
bool "BLE Scan Duplicate Options "
|
||||
bool "BLE Scan Duplicate Options"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
@@ -1014,8 +1023,8 @@ config BLE_SCAN_DUPLICATE
|
||||
config DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of devices in scan duplicate filter"
|
||||
depends on BLE_SCAN_DUPLICATE
|
||||
range 10 200
|
||||
default 20
|
||||
range 10 1000
|
||||
default 50
|
||||
help
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
@@ -1030,8 +1039,8 @@ config BLE_MESH_SCAN_DUPLICATE_EN
|
||||
config MESH_DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of Mesh adv packets in scan duplicate filter"
|
||||
depends on BLE_MESH_SCAN_DUPLICATE_EN
|
||||
range 10 200
|
||||
default 50
|
||||
range 10 1000
|
||||
default 100
|
||||
help
|
||||
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
|
||||
@@ -164,6 +164,7 @@ esp_gatt_status_t esp_ble_gattc_get_all_char(esp_gatt_if_t gattc_if,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if ((start_handle == 0) && (end_handle == 0)) {
|
||||
*count = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -206,6 +207,7 @@ esp_gatt_status_t esp_ble_gattc_get_char_by_uuid(esp_gatt_if_t gattc_if,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (start_handle == 0 && end_handle == 0) {
|
||||
*count = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -247,6 +249,7 @@ esp_gatt_status_t esp_ble_gattc_get_descr_by_char_handle(esp_gatt_if_t gattc_if,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (char_handle == 0) {
|
||||
*count = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -269,6 +272,7 @@ esp_gatt_status_t esp_ble_gattc_get_include_service(esp_gatt_if_t gattc_if,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (start_handle == 0 && end_handle == 0) {
|
||||
*count = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -291,6 +295,7 @@ esp_gatt_status_t esp_ble_gattc_get_attr_count(esp_gatt_if_t gattc_if,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if ((start_handle == 0 && end_handle == 0) && (type != ESP_GATT_DB_DESCRIPTOR)) {
|
||||
*count = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@@ -308,6 +313,7 @@ esp_gatt_status_t esp_ble_gattc_get_db(esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (start_handle == 0 && end_handle == 0) {
|
||||
*count = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_ERROR("%s, the l2cap chanel is congest.", __func__);
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -350,7 +350,8 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
|
||||
uint8_t max_nb_attr,
|
||||
uint8_t srvc_inst_id);
|
||||
/**
|
||||
* @brief This function is called to add an included service. After included
|
||||
* @brief This function is called to add an included service. This function have to be called between
|
||||
* 'esp_ble_gatts_create_service' and 'esp_ble_gatts_add_char'. After included
|
||||
* service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
|
||||
* is reported the included service ID.
|
||||
*
|
||||
|
||||
@@ -602,16 +602,16 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
|
||||
if (p_data->read_tx_power.read_tx_power_cb != NULL) {
|
||||
BTM_BleReadAdvTxPower(p_data->read_tx_power.read_tx_power_cb);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s(), the callback function cann't be NULL.", __func__);
|
||||
APPL_TRACE_ERROR("%s(), the callback function can't be NULL.", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
if (p_data->rssi.read_rssi_cb != NULL) {
|
||||
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.read_rssi_cb);
|
||||
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s(), the callback function cann't be NULL.", __func__);
|
||||
APPL_TRACE_ERROR("%s(), the callback function can't be NULL.", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,7 +698,7 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
** Description Removes device, Disconnects ACL link if required.
|
||||
****
|
||||
*******************************************************************************/
|
||||
void bta_dm_process_remove_device(BD_ADDR bd_addr)
|
||||
static void bta_dm_process_remove_device(BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
{
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection before unpair */
|
||||
@@ -711,12 +711,16 @@ void bta_dm_process_remove_device(BD_ADDR bd_addr)
|
||||
/* remove all cached GATT information */
|
||||
BTA_GATTC_Refresh(bd_addr, false);
|
||||
#endif
|
||||
|
||||
if (bta_dm_cb.p_sec_cback) {
|
||||
tBTA_DM_SEC sec_event;
|
||||
bdcpy(sec_event.link_down.bd_addr, bd_addr);
|
||||
sec_event.link_down.status = HCI_SUCCESS;
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &sec_event);
|
||||
if (transport == BT_TRANSPORT_LE){
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_BLE_DEV_UNPAIRED_EVT, &sec_event);
|
||||
} else {
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &sec_event);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -734,15 +738,11 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
|
||||
return;
|
||||
}
|
||||
|
||||
BD_ADDR other_address;
|
||||
bdcpy(other_address, p_dev->bd_addr);
|
||||
|
||||
/* If ACL exists for the device in the remove_bond message*/
|
||||
BOOLEAN continue_delete_dev = FALSE;
|
||||
UINT8 other_transport = BT_TRANSPORT_INVALID;
|
||||
UINT8 transport = p_dev->transport;
|
||||
|
||||
if (BTM_IsAclConnectionUp(p_dev->bd_addr, BT_TRANSPORT_LE) ||
|
||||
BTM_IsAclConnectionUp(p_dev->bd_addr, BT_TRANSPORT_BR_EDR)) {
|
||||
if (BTM_IsAclConnectionUp(p_dev->bd_addr, transport)) {
|
||||
APPL_TRACE_DEBUG("%s: ACL Up count %d", __func__, bta_dm_cb.device_list.count);
|
||||
continue_delete_dev = FALSE;
|
||||
|
||||
@@ -753,13 +753,6 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
|
||||
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
|
||||
bta_dm_cb.device_list.peer_device[i].transport);
|
||||
|
||||
/* save the other transport to check if device is connected on other_transport */
|
||||
if (bta_dm_cb.device_list.peer_device[i].transport == BT_TRANSPORT_LE) {
|
||||
other_transport = BT_TRANSPORT_BR_EDR;
|
||||
} else {
|
||||
other_transport = BT_TRANSPORT_LE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -767,35 +760,9 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
|
||||
continue_delete_dev = TRUE;
|
||||
}
|
||||
|
||||
// If it is DUMO device and device is paired as different address, unpair that device
|
||||
// if different address
|
||||
BOOLEAN continue_delete_other_dev = FALSE;
|
||||
if ((other_transport && (BTM_ReadConnectedTransportAddress(other_address, other_transport))) ||
|
||||
(!other_transport && (BTM_ReadConnectedTransportAddress(other_address, BT_TRANSPORT_BR_EDR) ||
|
||||
BTM_ReadConnectedTransportAddress(other_address, BT_TRANSPORT_LE)))) {
|
||||
continue_delete_other_dev = FALSE;
|
||||
/* Take the link down first, and mark the device for removal when disconnected */
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, other_address)) {
|
||||
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
|
||||
btm_remove_acl(other_address, bta_dm_cb.device_list.peer_device[i].transport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("%s: continue to delete the other dev ", __func__);
|
||||
continue_delete_other_dev = TRUE;
|
||||
}
|
||||
|
||||
/* Delete the device mentioned in the msg */
|
||||
if (continue_delete_dev) {
|
||||
bta_dm_process_remove_device(p_dev->bd_addr);
|
||||
}
|
||||
|
||||
/* Delete the other paired device too */
|
||||
BD_ADDR dummy_bda = {0};
|
||||
if (continue_delete_other_dev && (bdcmp(other_address, dummy_bda) != 0)) {
|
||||
bta_dm_process_remove_device(other_address);
|
||||
bta_dm_process_remove_device(p_dev->bd_addr, transport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3351,7 +3318,11 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
|
||||
if ( bta_dm_cb.p_sec_cback ) {
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_LINK_DOWN_EVT, &conn);
|
||||
if ( issue_unpair_cb ) {
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &conn);
|
||||
if (p_data->acl_change.transport == BT_TRANSPORT_LE) {
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_BLE_DEV_UNPAIRED_EVT, &conn);
|
||||
} else {
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4665,7 +4636,7 @@ void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data)
|
||||
void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
if (p_data->hdr.event != BTA_DM_API_BLE_STOP_ADV_EVT) {
|
||||
APPL_TRACE_ERROR("Invalid BTA event,cann't stop the BLE adverting\n");
|
||||
APPL_TRACE_ERROR("Invalid BTA event,can't stop the BLE adverting\n");
|
||||
}
|
||||
|
||||
btm_ble_stop_adv();
|
||||
|
||||
@@ -206,12 +206,13 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
|
||||
}
|
||||
}
|
||||
|
||||
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb)
|
||||
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
|
||||
{
|
||||
tBTA_DM_API_READ_RSSI *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT;
|
||||
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
|
||||
p_msg->transport = transport;
|
||||
p_msg->read_rssi_cb = cmpl_cb;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
@@ -569,7 +570,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
|
||||
tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
{
|
||||
tBTA_DM_API_REMOVE_DEVICE *p_msg;
|
||||
|
||||
@@ -578,6 +579,7 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT;
|
||||
bdcpy(p_msg->bd_addr, bd_addr);
|
||||
p_msg->transport = transport;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
return BTA_FAILURE;
|
||||
|
||||
@@ -196,6 +196,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_addr;
|
||||
tBTA_TRANSPORT transport;
|
||||
tBTA_CMPL_CB *read_rssi_cb;
|
||||
}tBTA_DM_API_READ_RSSI;
|
||||
|
||||
@@ -391,6 +392,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 transport;
|
||||
} tBTA_DM_API_REMOVE_DEVICE;
|
||||
|
||||
/* data type for BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
|
||||
@@ -672,6 +672,8 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
if (bta_gattc_cache_load(p_clcb)) {
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
|
||||
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
|
||||
//register service change
|
||||
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
|
||||
} else
|
||||
#endif
|
||||
{ /* cache is building */
|
||||
@@ -1296,6 +1298,7 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
|
||||
cb_data.write.conn_id = p_clcb->bta_conn_id;
|
||||
if (p_conn && p_conn->svc_change_descr_handle == cb_data.write.handle) {
|
||||
if(cb_data.write.status != BTA_GATT_OK) {
|
||||
p_conn->write_remote_svc_change_ccc_done = FALSE;
|
||||
APPL_TRACE_ERROR("service change write ccc failed");
|
||||
}
|
||||
return;
|
||||
@@ -1875,6 +1878,10 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
|
||||
|
||||
/* if connection available, refresh cache by doing discovery now */
|
||||
if (p_clcb != NULL) {
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_clcb->bda);
|
||||
if(p_conn) {
|
||||
p_conn->write_remote_svc_change_ccc_done = FALSE;
|
||||
}
|
||||
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
|
||||
}
|
||||
}
|
||||
@@ -2280,6 +2287,10 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
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}};
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find_alloc(remote_bda);
|
||||
if(p_conn && p_conn->write_remote_svc_change_ccc_done) {
|
||||
return SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
|
||||
}
|
||||
|
||||
p_srcb = bta_gattc_find_srcb(remote_bda);
|
||||
if ((p_srcb != NULL) && (p_srcb->p_srvc_cache != NULL)) {
|
||||
@@ -2344,9 +2355,9 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
}
|
||||
|
||||
if (gatt_ccc_found == TRUE){
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find_alloc(remote_bda);
|
||||
if (p_conn) {
|
||||
p_conn->svc_change_descr_handle = p_desc->handle;
|
||||
p_conn->write_remote_svc_change_ccc_done = TRUE;
|
||||
}
|
||||
result = SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
|
||||
uint16_t indicate_value = GATT_CLT_CONFIG_INDICATION;
|
||||
|
||||
@@ -376,14 +376,8 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
isvc->included_service = bta_gattc_find_matching_service(
|
||||
p_srvc_cb->p_srvc_cache, incl_srvc_s_handle);
|
||||
if (!isvc->included_service) {
|
||||
// if it is a secondary service, wait to update later
|
||||
if(property == 0){
|
||||
p_srvc_cb->update_sec_sev = true;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s: Illegal action to add non-existing included service!", __func__);
|
||||
osi_free(isvc);
|
||||
return GATT_WRONG_STATE;
|
||||
}
|
||||
// if can't find included service, wait to update later
|
||||
p_srvc_cb->update_incl_srvc = true;
|
||||
}
|
||||
|
||||
list_append(service->included_svc, isvc);
|
||||
@@ -606,10 +600,10 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
||||
return;
|
||||
}
|
||||
}
|
||||
//update include service when have secondary service
|
||||
if(p_srvc_cb->update_sec_sev) {
|
||||
// if update_incl_srvc is true, update include service
|
||||
if(p_srvc_cb->update_incl_srvc) {
|
||||
bta_gattc_update_include_service(p_srvc_cb->p_srvc_cache);
|
||||
p_srvc_cb->update_sec_sev = false;
|
||||
p_srvc_cb->update_incl_srvc = false;
|
||||
}
|
||||
/* no service found at all, the end of server discovery*/
|
||||
APPL_TRACE_DEBUG("%s no more services found", __func__);
|
||||
@@ -1658,7 +1652,8 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL) {
|
||||
return NULL;
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
|
||||
@@ -702,6 +702,10 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
APPL_TRACE_ERROR("%s, malloc failed", __func__);
|
||||
}
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
|
||||
if (cb_data.req_data.value != NULL) {
|
||||
osi_free(cb_data.req_data.value);
|
||||
cb_data.req_data.value = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x",
|
||||
|
||||
@@ -300,7 +300,7 @@ typedef struct {
|
||||
UINT16 attr_index; /* cahce NV saving/loading attribute index */
|
||||
|
||||
UINT16 mtu;
|
||||
bool update_sec_sev;
|
||||
bool update_incl_srvc;
|
||||
} tBTA_GATTC_SERV;
|
||||
|
||||
#ifndef BTA_GATTC_NOTIF_REG_MAX
|
||||
@@ -365,7 +365,8 @@ typedef struct {
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
UINT16 svc_change_descr_handle;
|
||||
UINT16 svc_change_descr_handle;
|
||||
BOOLEAN write_remote_svc_change_ccc_done;
|
||||
} tBTA_GATTC_CONN;
|
||||
|
||||
enum {
|
||||
|
||||
@@ -46,7 +46,7 @@ static const tBTM_ESCO_PARAMS bta_hf_client_esco_params[] = {
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
|
||||
BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
|
||||
.retrans_effort = BTM_ESCO_RETRANS_POWER,
|
||||
.retrans_effort = BTM_ESCO_RETRANS_OFF,
|
||||
},
|
||||
/* ESCO CVSD */
|
||||
{
|
||||
|
||||
@@ -631,10 +631,11 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK;
|
||||
#define BTA_DM_SP_RMT_OOB_EXT_EVT 23 /* Simple Pairing Remote OOB Extended Data request. */
|
||||
#define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */
|
||||
// btla-specific --
|
||||
#define BTA_DM_DEV_UNPAIRED_EVT 25
|
||||
#define BTA_DM_DEV_UNPAIRED_EVT 25 /* BT unpair event */
|
||||
#define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
|
||||
#define BTA_DM_LE_FEATURES_READ 27 /* Cotroller specific LE features are read */
|
||||
#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
|
||||
#define BTA_DM_BLE_DEV_UNPAIRED_EVT 29 /* BLE unpair event */
|
||||
typedef UINT8 tBTA_DM_SEC_EVT;
|
||||
|
||||
/* Structure associated with BTA_DM_ENABLE_EVT */
|
||||
@@ -1428,7 +1429,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA
|
||||
|
||||
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb);
|
||||
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1632,7 +1633,7 @@ extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
|
||||
** BTA_FAIL if operation failed.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr);
|
||||
extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
@@ -182,6 +182,10 @@ static void btc_dm_remove_ble_bonding_keys(void)
|
||||
|
||||
static void btc_dm_save_ble_bonding_keys(void)
|
||||
{
|
||||
if(!(pairing_cb.ble.is_penc_key_rcvd || pairing_cb.ble.is_pid_key_rcvd || pairing_cb.ble.is_pcsrk_key_rcvd ||
|
||||
pairing_cb.ble.is_lenc_key_rcvd || pairing_cb.ble.is_lcsrk_key_rcvd || pairing_cb.ble.is_lidk_key_rcvd)) {
|
||||
return ;
|
||||
}
|
||||
bt_bdaddr_t bd_addr;
|
||||
|
||||
bdcpy(bd_addr.address, pairing_cb.bd_addr);
|
||||
@@ -495,10 +499,23 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
case BTA_DM_DEV_UNPAIRED_EVT: {
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bd_addr;
|
||||
rsp_app = true;
|
||||
BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT");
|
||||
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
||||
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
|
||||
if (p_data->link_down.status == HCI_SUCCESS) {
|
||||
//remove the bonded key in the config and nvs flash.
|
||||
btc_storage_remove_bonded_device(&bd_addr);
|
||||
}
|
||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||
break;
|
||||
}
|
||||
case BTA_DM_BLE_DEV_UNPAIRED_EVT: {
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bd_addr;
|
||||
rsp_app = true;
|
||||
BTC_TRACE_DEBUG("BTA_DM_BLE_DEV_UNPAIRED_EVT");
|
||||
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
||||
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
|
||||
param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
|
||||
|
||||
if (p_data->link_down.status == HCI_SUCCESS) {
|
||||
|
||||
@@ -170,6 +170,9 @@ int btc_init(void)
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
btc_gap_callback_init();
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_init();
|
||||
#endif
|
||||
/* TODO: initial the profile_tab */
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -178,7 +181,18 @@ void btc_deinit(void)
|
||||
{
|
||||
vTaskDelete(xBtcTaskHandle);
|
||||
vQueueDelete(xBtcQueue);
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_deinit();
|
||||
#endif
|
||||
xBtcTaskHandle = NULL;
|
||||
xBtcQueue = 0;
|
||||
}
|
||||
|
||||
bool btc_check_queue_is_congest(void)
|
||||
{
|
||||
UBaseType_t wait_size = uxQueueMessagesWaiting(xBtcQueue);
|
||||
if(wait_size >= QUEUE_CONGEST_SIZE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ typedef struct btc_msg {
|
||||
void *arg; //param for btc function or function param
|
||||
} btc_msg_t;
|
||||
|
||||
typedef struct btc_adv_packet {
|
||||
uint8_t addr[6];
|
||||
uint8_t addr_type;
|
||||
} btc_adv_packet_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_SIG_API_CALL = 0, // APP TO STACK
|
||||
BTC_SIG_API_CB, // STACK TO APP
|
||||
@@ -72,5 +77,6 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
||||
|
||||
int btc_init(void);
|
||||
void btc_deinit(void);
|
||||
bool btc_check_queue_is_congest(void);
|
||||
|
||||
#endif /* __BTC_TASK_H__ */
|
||||
|
||||
@@ -209,10 +209,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE;
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
BLUFI_TRACE_DEBUG("CONIRM EVT\n");
|
||||
if (p_data && p_data->req_data.value){
|
||||
osi_free(p_data->req_data.value);
|
||||
}
|
||||
BLUFI_TRACE_DEBUG("CONFIRM EVT\n");
|
||||
/* Nothing */
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
|
||||
@@ -586,7 +586,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
|
||||
OI_STATUS status;
|
||||
int num_sbc_frames = p_msg->num_frames_to_be_processed;
|
||||
UINT32 sbc_frame_len = p_msg->len - 1;
|
||||
availPcmBytes = 2 * sizeof(pcmData);
|
||||
availPcmBytes = sizeof(pcmData);
|
||||
|
||||
/* XXX: Check if the below check is correct, we are checking for peer to be sink when we are sink */
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK || (btc_aa_snk_cb.rx_flush)) {
|
||||
@@ -617,7 +617,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
|
||||
p_msg->len = sbc_frame_len + 1;
|
||||
}
|
||||
|
||||
btc_a2d_data_cb_to_app((uint8_t *)pcmData, (2 * sizeof(pcmData) - availPcmBytes));
|
||||
btc_a2d_data_cb_to_app((uint8_t *)pcmData, (sizeof(pcmData) - availPcmBytes));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -763,7 +763,7 @@ static void btc_a2dp_sink_thread_init(UNUSED_ATTR void *context)
|
||||
|
||||
btc_a2dp_sink_state = BTC_A2DP_SINK_STATE_ON;
|
||||
|
||||
btc_aa_snk_cb.RxSbcQ = fixed_queue_new(SIZE_MAX);
|
||||
btc_aa_snk_cb.RxSbcQ = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
btc_a2dp_control_init();
|
||||
}
|
||||
|
||||
@@ -1616,7 +1616,7 @@ static void btc_a2dp_source_thread_init(UNUSED_ATTR void *context)
|
||||
|
||||
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_ON;
|
||||
|
||||
btc_aa_src_cb.TxAaQ = fixed_queue_new(SIZE_MAX);
|
||||
btc_aa_src_cb.TxAaQ = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
btc_a2dp_control_init();
|
||||
}
|
||||
|
||||
@@ -28,9 +28,23 @@
|
||||
#include "btc/btc_ble_storage.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_util.h"
|
||||
#include "osi/mutex.h"
|
||||
|
||||
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
|
||||
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
static list_t *adv_filter_list;
|
||||
static osi_mutex_t adv_list_lock;
|
||||
bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type);
|
||||
uint32_t btc_get_adv_list_length(void);
|
||||
void btc_adv_list_refresh(void);
|
||||
void btc_adv_list_lock(void);
|
||||
void btc_adv_list_unlock(void);
|
||||
static uint16_t btc_adv_list_count = 0;
|
||||
|
||||
#define BTC_ADV_LIST_MAX_LENGTH 50
|
||||
#define BTC_ADV_LIST_MAX_COUNT 200
|
||||
#endif
|
||||
|
||||
static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
|
||||
{
|
||||
@@ -510,6 +524,19 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
|
||||
param.scan_rst.search_evt = event;
|
||||
switch (event) {
|
||||
case BTA_DM_INQ_RES_EVT: {
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
if(btc_check_queue_is_congest()) {
|
||||
BTC_TRACE_DEBUG("BtcQueue is congested");
|
||||
if(btc_get_adv_list_length() > BTC_ADV_LIST_MAX_LENGTH || btc_adv_list_count > BTC_ADV_LIST_MAX_COUNT) {
|
||||
btc_adv_list_refresh();
|
||||
btc_adv_list_count = 0;
|
||||
}
|
||||
if(btc_check_adv_list(p_data->inq_res.bd_addr, p_data->inq_res.ble_addr_type)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
btc_adv_list_count ++;
|
||||
#endif
|
||||
bdcpy(param.scan_rst.bda, p_data->inq_res.bd_addr);
|
||||
param.scan_rst.dev_type = p_data->inq_res.device_type;
|
||||
param.scan_rst.rssi = p_data->inq_res.rssi;
|
||||
@@ -585,6 +612,9 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_refresh();
|
||||
#endif
|
||||
}
|
||||
|
||||
void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params)
|
||||
@@ -725,6 +755,9 @@ static void btc_ble_start_scanning(uint32_t duration,
|
||||
tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb)
|
||||
{
|
||||
if ((results_cb != NULL) && (start_scan_cb != NULL)) {
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_refresh();
|
||||
#endif
|
||||
//Start scan the device
|
||||
BTA_DmBleScan(true, duration, results_cb, start_scan_cb);
|
||||
} else {
|
||||
@@ -1018,7 +1051,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_READ_RSSI:
|
||||
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, btc_read_ble_rssi_cmpl_callback);
|
||||
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_SET_CONN_PARAMS:
|
||||
BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int,
|
||||
@@ -1108,7 +1141,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
case BTC_GAP_BLE_REMOVE_BOND_DEV_EVT: {
|
||||
BD_ADDR bd_addr;
|
||||
memcpy(bd_addr, arg->remove_bond_device.bd_addr, sizeof(BD_ADDR));
|
||||
BTA_DmRemoveDevice(bd_addr);
|
||||
BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_LE);
|
||||
break;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
@@ -1134,3 +1167,99 @@ void btc_gap_ble_deinit(void)
|
||||
btc_cleanup_adv_data(&gl_bta_adv_data);
|
||||
btc_cleanup_adv_data(&gl_bta_scan_rsp_data);
|
||||
}
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
void btc_adv_list_free(void *data)
|
||||
{
|
||||
osi_free(data);
|
||||
}
|
||||
|
||||
void btc_adv_list_init(void)
|
||||
{
|
||||
osi_mutex_new(&adv_list_lock);
|
||||
adv_filter_list = list_new(btc_adv_list_free);
|
||||
}
|
||||
|
||||
void btc_adv_list_deinit(void)
|
||||
{
|
||||
osi_mutex_free(&adv_list_lock);
|
||||
if(adv_filter_list) {
|
||||
list_free(adv_filter_list);
|
||||
adv_filter_list = NULL;
|
||||
}
|
||||
}
|
||||
void btc_adv_list_add_packet(void * data)
|
||||
{
|
||||
if(!data) {
|
||||
BTC_TRACE_ERROR("%s data is NULL", __func__);
|
||||
return;
|
||||
}
|
||||
btc_adv_list_lock();
|
||||
list_prepend(adv_filter_list, data);
|
||||
btc_adv_list_unlock();
|
||||
}
|
||||
|
||||
uint32_t btc_get_adv_list_length(void)
|
||||
{
|
||||
if(!adv_filter_list) {
|
||||
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
|
||||
return 0;
|
||||
}
|
||||
btc_adv_list_lock();
|
||||
size_t length = list_length(adv_filter_list);
|
||||
btc_adv_list_unlock();
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void btc_adv_list_refresh(void)
|
||||
{
|
||||
if(!adv_filter_list) {
|
||||
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
|
||||
return ;
|
||||
}
|
||||
btc_adv_list_lock();
|
||||
list_clear(adv_filter_list);
|
||||
btc_adv_list_unlock();
|
||||
}
|
||||
|
||||
bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type)
|
||||
{
|
||||
bool found = false;
|
||||
if(!adv_filter_list || !addr) {
|
||||
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
|
||||
return found;
|
||||
}
|
||||
|
||||
btc_adv_list_lock();
|
||||
for (const list_node_t *node = list_begin(adv_filter_list); node != list_end(adv_filter_list); node = list_next(node)) {
|
||||
btc_adv_packet_t *packet = (btc_adv_packet_t *)list_node(node);
|
||||
if(!bdcmp(addr, packet->addr) && packet->addr_type == addr_type) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
btc_adv_list_unlock();
|
||||
if(!found) {
|
||||
btc_adv_packet_t *adv_packet = osi_malloc(sizeof(btc_adv_packet_t));
|
||||
if(adv_packet) {
|
||||
adv_packet->addr_type = addr_type;
|
||||
bdcpy(adv_packet->addr, addr);
|
||||
btc_adv_list_add_packet(adv_packet);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s adv_packet malloc failed", __func__);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void btc_adv_list_lock(void)
|
||||
{
|
||||
osi_mutex_lock(&adv_list_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
void btc_adv_list_unlock(void)
|
||||
{
|
||||
osi_mutex_unlock(&adv_list_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -151,7 +151,7 @@ static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
switch (p_dest_data->event) {
|
||||
case BTA_DM_INQ_RES_EVT: {
|
||||
if (p_src_data->p_data->inq_res.p_eir) {
|
||||
p_dest_data->p_data->inq_res.p_eir = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
p_dest_data->p_data->inq_res.p_eir = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
|
||||
memcpy(p_dest_data->p_data->inq_res.p_eir, p_src_data->p_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN);
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->p_data->disc_res.raw_data_size && p_src_data->p_data->disc_res.p_raw_data) {
|
||||
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
|
||||
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.raw_data_size);
|
||||
@@ -194,7 +194,7 @@ static void search_service_record_copy_cb(btc_msg_t *msg, void *p_dest, void *p_
|
||||
switch (p_dest_data->event) {
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->p_data->disc_res.p_raw_data && p_src_data->p_data->disc_res.raw_data_size > 0) {
|
||||
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
|
||||
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.p_raw_data,
|
||||
p_src_data->p_data->disc_res.raw_data_size);
|
||||
@@ -566,7 +566,7 @@ static void search_services_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case BTA_DM_DISC_RES_EVT: {
|
||||
if (p_src_data->p_data->disc_res.result == BTA_SUCCESS) {
|
||||
if (p_src_data->p_data->disc_res.num_uuids > 0) {
|
||||
p_dest_data->p_data->disc_res.p_uuid_list = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
|
||||
p_dest_data->p_data->disc_res.p_uuid_list = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
|
||||
memcpy(p_dest_data->p_data->disc_res.p_uuid_list, p_src_data->p_data->disc_res.p_uuid_list,
|
||||
p_src_data->p_data->disc_res.num_uuids * MAX_UUID_SIZE);
|
||||
osi_free(p_src_data->p_data->disc_res.p_uuid_list);
|
||||
@@ -632,15 +632,14 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
|
||||
|
||||
static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
}
|
||||
|
||||
esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BD_ADDR bd_addr;
|
||||
memcpy(bd_addr, arg->rm_bond_device.bda.address, sizeof(BD_ADDR));
|
||||
if(BTA_DmRemoveDevice(bd_addr) == BTA_SUCCESS){
|
||||
btc_storage_remove_bonded_device(&(arg->rm_bond_device.bda));
|
||||
if(BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_BR_EDR) == BTA_SUCCESS){
|
||||
return ESP_BT_STATUS_SUCCESS;
|
||||
}
|
||||
return ESP_BT_STATUS_FAIL;
|
||||
|
||||
@@ -331,6 +331,7 @@ esp_gatt_status_t btc_ble_gattc_get_service(uint16_t conn_id, esp_bt_uuid_t *svc
|
||||
if (bta_uuid) {
|
||||
osi_free(bta_uuid);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
} else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)svc_num, ESP_GATT_DB_PRIMARY_SERVICE, offset, (void *)result, db);
|
||||
@@ -362,6 +363,7 @@ esp_gatt_status_t btc_ble_gattc_get_all_char(uint16_t conn_id,
|
||||
if (db) {
|
||||
osi_free(db);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
} else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)char_num, ESP_GATT_DB_CHARACTERISTIC, offset, (void *)result, db);
|
||||
@@ -389,6 +391,7 @@ esp_gatt_status_t btc_ble_gattc_get_all_descr(uint16_t conn_id,
|
||||
if (db) {
|
||||
osi_free(db);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
} else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, offset, (void *)result, db);
|
||||
@@ -420,6 +423,7 @@ esp_gatt_status_t btc_ble_gattc_get_char_by_uuid(uint16_t conn_id,
|
||||
if (db) {
|
||||
osi_free(db);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
} else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)char_num, ESP_GATT_DB_CHARACTERISTIC, 0, (void *)result, db);
|
||||
@@ -456,6 +460,7 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_uuid(uint16_t conn_id,
|
||||
if (db) {
|
||||
osi_free(db);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
} else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
|
||||
@@ -487,6 +492,7 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_char_handle(uint16_t conn_id,
|
||||
if (db) {
|
||||
osi_free(db);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
} else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
|
||||
@@ -524,6 +530,7 @@ esp_gatt_status_t btc_ble_gattc_get_include_service(uint16_t conn_id,
|
||||
if (db) {
|
||||
osi_free(db);
|
||||
}
|
||||
*count = 0;
|
||||
return status;
|
||||
}else {
|
||||
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)incl_num, ESP_GATT_DB_INCLUDED_SERVICE, 0, (void *)result, db);
|
||||
@@ -566,6 +573,7 @@ esp_gatt_status_t btc_ble_gattc_get_db(uint16_t conn_id, uint16_t start_handle,
|
||||
if (get_db) {
|
||||
osi_free(get_db);
|
||||
}
|
||||
*count = 0;
|
||||
return ESP_GATT_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -579,7 +587,7 @@ esp_gatt_status_t btc_ble_gattc_get_db(uint16_t conn_id, uint16_t start_handle,
|
||||
btc128_to_bta_uuid(&bta_uuid, get_db[i].uuid.uu);
|
||||
bta_to_btc_uuid(&db[i].uuid, &bta_uuid);
|
||||
}
|
||||
*count = num;
|
||||
*count = db_size;
|
||||
//don't forget to free the db buffer after used.
|
||||
if (get_db) {
|
||||
osi_free(get_db);
|
||||
|
||||
@@ -530,9 +530,6 @@ static void btc_gatts_cb_param_copy_free(btc_msg_t *msg, tBTA_GATTS *p_data)
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
if (p_data && p_data->req_data.value){
|
||||
osi_free(p_data->req_data.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -166,5 +166,7 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg);
|
||||
void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_gap_callback_init(void);
|
||||
void btc_gap_ble_deinit(void);
|
||||
void btc_adv_list_init(void);
|
||||
void btc_adv_list_deinit(void);
|
||||
|
||||
#endif /* __BTC_GAP_BLE_H__ */
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX 254
|
||||
#endif
|
||||
/*Timer Related Defination*/
|
||||
|
||||
//by Snake.T
|
||||
|
||||
@@ -307,6 +307,16 @@
|
||||
#define BTA_AV_CO_CP_SCMS_T FALSE//FALSE
|
||||
#endif
|
||||
|
||||
#ifndef QUEUE_CONGEST_SIZE
|
||||
#define QUEUE_CONGEST_SIZE 40
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
#define SCAN_QUEUE_CONGEST_CHECK FALSE
|
||||
#else
|
||||
#define SCAN_QUEUE_CONGEST_CHECK CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
#endif
|
||||
|
||||
/* This feature is used to eanble interleaved scan*/
|
||||
#ifndef BTA_HOST_INTERLEAVE_SEARCH
|
||||
#define BTA_HOST_INTERLEAVE_SEARCH FALSE//FALSE
|
||||
@@ -581,7 +591,7 @@
|
||||
#define BTM_DEFAULT_DISC_INTERVAL 0x0800
|
||||
#endif
|
||||
|
||||
/*
|
||||
/*
|
||||
* {SERVICE_CLASS, MAJOR_CLASS, MINOR_CLASS}
|
||||
*
|
||||
* SERVICE_CLASS:0x5A (Bit17 -Networking,Bit19 - Capturing,Bit20 -Object Transfer,Bit22 -Telephony)
|
||||
@@ -754,6 +764,14 @@
|
||||
#define BTM_BLE_CONFORMANCE_TESTING FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** CONTROLLER TO HOST FLOW CONTROL
|
||||
**
|
||||
******************************************************************************/
|
||||
|
||||
#define C2H_FLOW_CONTROL_INCLUDED TRUE
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** L2CAP
|
||||
|
||||
@@ -95,6 +95,12 @@ static void start_up(void)
|
||||
response, &acl_data_size_classic, &acl_buffer_count_classic,
|
||||
&sco_data_size, &sco_buffer_count);
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
// Enable controller to host flow control
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
// Tell the controller about our buffer sizes and buffer counts next
|
||||
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
|
||||
response = AWAIT_COMMAND(
|
||||
@@ -252,6 +258,9 @@ static void start_up(void)
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
response = AWAIT_COMMAND(packet_factory->make_write_sync_flow_control_enable(1));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
|
||||
response = AWAIT_COMMAND(packet_factory->make_write_default_erroneous_data_report(1));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif
|
||||
readable = true;
|
||||
// return future_new_immediate(FUTURE_SUCCESS);
|
||||
|
||||
@@ -27,10 +27,16 @@
|
||||
#include "osi/thread.h"
|
||||
#include "esp_bt.h"
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
#include "l2c_int.h"
|
||||
#include "stack/hcimsgs.h"
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
#define HCI_HAL_SERIAL_BUFFER_SIZE 1026
|
||||
#define HCI_BLE_EVENT 0x3e
|
||||
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
|
||||
#define PACKET_TYPE_TO_INDEX(type) ((type) - 1)
|
||||
extern bool BTU_check_queue_is_congest(void);
|
||||
|
||||
|
||||
static const uint8_t preamble_sizes[] = {
|
||||
@@ -92,6 +98,7 @@ static void hci_hal_env_init(
|
||||
static void hci_hal_env_deinit(void)
|
||||
{
|
||||
fixed_queue_free(hci_hal_env.rx_q, hci_hal_env.allocator->free);
|
||||
hci_hal_env.rx_q = NULL;
|
||||
}
|
||||
|
||||
static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
|
||||
@@ -99,7 +106,7 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
|
||||
assert(upper_callbacks != NULL);
|
||||
callbacks = upper_callbacks;
|
||||
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, SIZE_MAX);
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
|
||||
|
||||
xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
|
||||
xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
|
||||
@@ -165,6 +172,7 @@ static void hci_hal_h4_rx_handler(void *arg)
|
||||
if (pdTRUE == xQueueReceive(xHciH4Queue, &e, (portTickType)portMAX_DELAY)) {
|
||||
if (e.sig == SIG_HCI_HAL_RECV_PACKET) {
|
||||
fixed_queue_process(hci_hal_env.rx_q);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,13 +186,51 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout)
|
||||
evt.par = 0;
|
||||
|
||||
if (xQueueSend(xHciH4Queue, &evt, timeout) != pdTRUE) {
|
||||
HCI_TRACE_ERROR("xHciH4Queue failed\n");
|
||||
return TASK_POST_SUCCESS;
|
||||
}
|
||||
|
||||
return TASK_POST_FAIL;
|
||||
}
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
static void hci_packet_complete(BT_HDR *packet){
|
||||
uint8_t type, num_handle;
|
||||
uint16_t handle;
|
||||
uint16_t handles[MAX_L2CAP_LINKS + 4];
|
||||
uint16_t num_packets[MAX_L2CAP_LINKS + 4];
|
||||
uint8_t *stream = packet->data + packet->offset;
|
||||
tL2C_LCB *p_lcb = NULL;
|
||||
|
||||
STREAM_TO_UINT8(type, stream);
|
||||
if (type == DATA_TYPE_ACL/* || type == DATA_TYPE_SCO*/) {
|
||||
STREAM_TO_UINT16(handle, stream);
|
||||
handle = handle & HCI_DATA_HANDLE_MASK;
|
||||
p_lcb = l2cu_find_lcb_by_handle(handle);
|
||||
if (p_lcb) {
|
||||
p_lcb->completed_packets++;
|
||||
}
|
||||
if (esp_vhci_host_check_send_available()){
|
||||
num_handle = l2cu_find_completed_packets(handles, num_packets);
|
||||
if (num_handle > 0){
|
||||
btsnd_hcic_host_num_xmitted_pkts (num_handle, handles, num_packets);
|
||||
}
|
||||
} else {
|
||||
//Send HCI_Host_Number_of_Completed_Packets next time.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
bool host_recv_adv_packet(BT_HDR *packet)
|
||||
{
|
||||
assert(packet);
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
{
|
||||
uint8_t type, hdr_size;
|
||||
@@ -194,6 +240,11 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
if (!packet) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
hci_packet_complete(packet);
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
STREAM_TO_UINT8(type, stream);
|
||||
packet->offset++;
|
||||
packet->len--;
|
||||
@@ -233,6 +284,13 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
hci_hal_env.allocator->free(packet);
|
||||
return;
|
||||
}
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
|
||||
HCI_TRACE_ERROR("BtuQueue is congested");
|
||||
hci_hal_env.allocator->free(packet);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
|
||||
callbacks->packet_ready(packet);
|
||||
@@ -260,6 +318,10 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
BT_HDR *pkt;
|
||||
size_t pkt_size;
|
||||
|
||||
if (hci_hal_env.rx_q == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
pkt_size = BT_HDR_SIZE + len;
|
||||
pkt = (BT_HDR *)hci_hal_env.allocator->alloc(pkt_size);
|
||||
if (!pkt) {
|
||||
@@ -271,7 +333,7 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
pkt->layer_specific = 0;
|
||||
memcpy(pkt->data, data, len);
|
||||
fixed_queue_enqueue(hci_hal_env.rx_q, pkt);
|
||||
hci_hal_h4_task_post(TASK_POST_BLOCKING);
|
||||
hci_hal_h4_task_post(100 / portTICK_PERIOD_MS);
|
||||
|
||||
BTTRC_DUMP_BUFFER("Recv Pkt", pkt->data, len);
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ static int hci_layer_init_env(void)
|
||||
// as per the Bluetooth spec, Volume 2, Part E, 4.4 (Command Flow Control)
|
||||
// This value can change when you get a command complete or command status event.
|
||||
hci_host_env.command_credits = 1;
|
||||
hci_host_env.command_queue = fixed_queue_new(SIZE_MAX);
|
||||
hci_host_env.command_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
if (hci_host_env.command_queue) {
|
||||
fixed_queue_register_dequeue(hci_host_env.command_queue, event_command_ready);
|
||||
} else {
|
||||
@@ -166,7 +166,7 @@ static int hci_layer_init_env(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
hci_host_env.packet_queue = fixed_queue_new(SIZE_MAX);
|
||||
hci_host_env.packet_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
if (hci_host_env.packet_queue) {
|
||||
fixed_queue_register_dequeue(hci_host_env.packet_queue, event_packet_ready);
|
||||
} else {
|
||||
@@ -274,6 +274,7 @@ static void transmit_command(
|
||||
|
||||
fixed_queue_enqueue(hci_host_env.command_queue, wait_entry);
|
||||
hci_host_task_post(TASK_POST_BLOCKING);
|
||||
|
||||
}
|
||||
|
||||
static future_t *transmit_command_futured(BT_HDR *command)
|
||||
@@ -317,8 +318,14 @@ static void event_command_ready(fixed_queue_t *queue)
|
||||
command_waiting_response_t *cmd_wait_q = &hci_host_env.cmd_waiting_q;
|
||||
|
||||
wait_entry = fixed_queue_dequeue(queue);
|
||||
hci_host_env.command_credits--;
|
||||
|
||||
if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE){
|
||||
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
|
||||
buffer_allocator->free(wait_entry->command);
|
||||
osi_free(wait_entry);
|
||||
return;
|
||||
}
|
||||
hci_host_env.command_credits--;
|
||||
// Move it to the list of commands awaiting response
|
||||
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
list_append(cmd_wait_q->commands_pending_response, wait_entry);
|
||||
@@ -435,7 +442,6 @@ static bool filter_incoming_event(BT_HDR *packet)
|
||||
if (event_code == HCI_COMMAND_COMPLETE_EVT) {
|
||||
STREAM_TO_UINT8(hci_host_env.command_credits, stream);
|
||||
STREAM_TO_UINT16(opcode, stream);
|
||||
|
||||
wait_entry = get_waiting_command(opcode);
|
||||
if (!wait_entry) {
|
||||
HCI_TRACE_WARNING("%s command complete event with no matching command. opcode: 0x%x.", __func__, opcode);
|
||||
|
||||
@@ -45,6 +45,16 @@ static BT_HDR *make_read_buffer_size(void)
|
||||
return make_command_no_params(HCI_READ_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
static BT_HDR *make_set_c2h_flow_control(uint8_t enable)
|
||||
{
|
||||
uint8_t *stream;
|
||||
const uint8_t parameter_size = 1;
|
||||
BT_HDR *packet = make_command(HCI_SET_HC_TO_HOST_FLOW_CTRL, parameter_size, &stream);
|
||||
|
||||
UINT8_TO_STREAM(stream, enable);
|
||||
return packet;
|
||||
}
|
||||
|
||||
static BT_HDR *make_host_buffer_size(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count)
|
||||
{
|
||||
uint8_t *stream;
|
||||
@@ -184,6 +194,16 @@ static BT_HDR *make_write_sync_flow_control_enable(uint8_t enable)
|
||||
UINT8_TO_STREAM(stream, enable);
|
||||
return packet;
|
||||
}
|
||||
|
||||
static BT_HDR *make_write_default_erroneous_data_report(uint8_t enable)
|
||||
{
|
||||
uint8_t *stream;
|
||||
const uint8_t parameter_size = 1;
|
||||
BT_HDR *packet = make_command(HCI_WRITE_ERRONEOUS_DATA_RPT, parameter_size, &stream);
|
||||
|
||||
UINT8_TO_STREAM(stream, enable);
|
||||
return packet;
|
||||
}
|
||||
// Internal functions
|
||||
|
||||
static BT_HDR *make_command_no_params(uint16_t opcode)
|
||||
@@ -220,6 +240,7 @@ static BT_HDR *make_packet(size_t data_size)
|
||||
static const hci_packet_factory_t interface = {
|
||||
make_reset,
|
||||
make_read_buffer_size,
|
||||
make_set_c2h_flow_control,
|
||||
make_host_buffer_size,
|
||||
make_read_local_version_info,
|
||||
make_read_bd_addr,
|
||||
@@ -237,7 +258,8 @@ static const hci_packet_factory_t interface = {
|
||||
make_ble_read_suggested_default_data_length,
|
||||
make_ble_write_suggested_default_data_length,
|
||||
make_ble_set_event_mask,
|
||||
make_write_sync_flow_control_enable
|
||||
make_write_sync_flow_control_enable,
|
||||
make_write_default_erroneous_data_report,
|
||||
};
|
||||
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface()
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
typedef struct {
|
||||
BT_HDR *(*make_reset)(void);
|
||||
BT_HDR *(*make_read_buffer_size)(void);
|
||||
BT_HDR *(*make_set_c2h_flow_control)(uint8_t enable);
|
||||
BT_HDR *(*make_host_buffer_size)(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count);
|
||||
BT_HDR *(*make_read_local_version_info)(void);
|
||||
BT_HDR *(*make_read_bd_addr)(void);
|
||||
@@ -43,6 +44,7 @@ typedef struct {
|
||||
BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime);
|
||||
BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask);
|
||||
BT_HDR *(*make_write_sync_flow_control_enable)(uint8_t enable);
|
||||
BT_HDR *(*make_write_default_erroneous_data_report)(uint8_t enable);
|
||||
} hci_packet_factory_t;
|
||||
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface();
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
#include <stdbool.h>
|
||||
#include "osi/list.h"
|
||||
|
||||
#ifndef QUEUE_SIZE_MAX
|
||||
#define QUEUE_SIZE_MAX 254
|
||||
#endif
|
||||
|
||||
struct fixed_queue_t;
|
||||
|
||||
typedef struct fixed_queue_t fixed_queue_t;
|
||||
|
||||
@@ -69,7 +69,7 @@ typedef enum {
|
||||
#define HCI_H4_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define HCI_H4_TASK_PRIO (configMAX_PRIORITIES - 4)
|
||||
#define HCI_H4_TASK_NAME "hciH4T"
|
||||
#define HCI_H4_QUEUE_LEN 60
|
||||
#define HCI_H4_QUEUE_LEN 1
|
||||
|
||||
#define BTU_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
#define BTU_TASK_STACK_SIZE (4096 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
|
||||
@@ -313,7 +313,7 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
|
||||
p_lcb->allocated = (UINT8)(i + 1);
|
||||
memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN);
|
||||
AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated);
|
||||
p_lcb->tx_q = fixed_queue_new(SIZE_MAX);
|
||||
p_lcb->tx_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,8 +376,8 @@ tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr)
|
||||
if (!p_ccb->allocated) {
|
||||
p_ccb->allocated = TRUE;
|
||||
memcpy(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN);
|
||||
p_ccb->cmd_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->rsp_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->cmd_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->rsp_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->timer_entry.param = (UINT32) p_ccb;
|
||||
AVDT_TRACE_DEBUG("avdt_ccb_alloc %d\n", i);
|
||||
break;
|
||||
|
||||
@@ -412,6 +412,7 @@ void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
|
||||
{
|
||||
tAVDT_TC_TBL *p_tbl;
|
||||
UINT16 disc_rsn = AVDT_DISC_RSN_NORMAL;
|
||||
tAVDT_CCB *p_ccb;
|
||||
AVDT_TRACE_DEBUG("avdt_l2c_disconnect_ind_cback lcid: %d, ack_needed: %d\n",
|
||||
lcid, ack_needed);
|
||||
/* look up info for this channel */
|
||||
@@ -420,7 +421,13 @@ void avdt_l2c_disconnect_ind_cback(UINT16 lcid, BOOLEAN ack_needed)
|
||||
/* send L2CAP disconnect response */
|
||||
L2CA_DisconnectRsp(lcid);
|
||||
} else {
|
||||
disc_rsn = AVDT_DISC_RSN_ABNORMAL;
|
||||
if ((p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx)) != NULL) {
|
||||
UINT16 rsn = L2CA_GetDisconnectReason(p_ccb->peer_addr, BT_TRANSPORT_BR_EDR);
|
||||
if (rsn != 0 && rsn != HCI_ERR_PEER_USER) {
|
||||
disc_rsn = AVDT_DISC_RSN_ABNORMAL;
|
||||
AVDT_TRACE_EVENT("avdt link disc rsn 0x%x", rsn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
avdt_ad_tc_close_ind(p_tbl, disc_rsn);
|
||||
|
||||
@@ -603,7 +603,7 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
|
||||
memcpy(&p_scb->cs, p_cs, sizeof(tAVDT_CS));
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
/* initialize fragments gueue */
|
||||
p_scb->frag_q = fixed_queue_new(SIZE_MAX);
|
||||
p_scb->frag_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
if (p_cs->cfg.psc_mask & AVDT_PSC_MUX) {
|
||||
p_scb->cs.cfg.mux_tcid_media = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
|
||||
|
||||
@@ -1905,14 +1905,10 @@ void btm_qos_setup_complete (UINT8 status, UINT16 handle, FLOW_SPEC *p_flow)
|
||||
** Returns BTM_CMD_STARTED if successfully initiated or error code
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
|
||||
tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tACL_CONN *p;
|
||||
tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBT_DEVICE_TYPE dev_type;
|
||||
tBLE_ADDR_TYPE addr_type;
|
||||
#endif
|
||||
|
||||
BTM_TRACE_API ("BTM_ReadRSSI: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
remote_bda[0], remote_bda[1], remote_bda[2],
|
||||
remote_bda[3], remote_bda[4], remote_bda[5]);
|
||||
@@ -1924,13 +1920,6 @@ tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
|
||||
return (BTM_BUSY);
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
BTM_ReadDevInfo(remote_bda, &dev_type, &addr_type);
|
||||
if (dev_type == BT_DEVICE_TYPE_BLE) {
|
||||
transport = BT_TRANSPORT_LE;
|
||||
}
|
||||
#endif
|
||||
|
||||
p = btm_bda_to_acl(remote_bda, transport);
|
||||
if (p != (tACL_CONN *)NULL) {
|
||||
btu_start_timer (&btm_cb.devcb.rssi_timer, BTU_TTYPE_BTM_ACL,
|
||||
|
||||
@@ -1225,7 +1225,7 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY
|
||||
|
||||
/* Set that link key is known since this shares field with BTM_SEC_FLAG_LKEY_KNOWN flag in stack/btm_api.h*/
|
||||
p_rec->sec_flags |= BTM_SEC_LE_LINK_KEY_KNOWN;
|
||||
if ( p_keys->pcsrk_key.sec_level == SMP_SEC_AUTHENTICATED) {
|
||||
if ( p_keys->lenc_key.sec_level == SMP_SEC_AUTHENTICATED) {
|
||||
p_rec->sec_flags |= BTM_SEC_LE_LINK_KEY_AUTHED;
|
||||
} else {
|
||||
p_rec->sec_flags &= ~BTM_SEC_LE_LINK_KEY_AUTHED;
|
||||
@@ -1948,14 +1948,6 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
handle = HCID_GET_HANDLE (handle);
|
||||
|
||||
btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type, match);
|
||||
if(role == HCI_ROLE_SLAVE) {
|
||||
//clear p_cb->state, controller will stop adv when ble connected.
|
||||
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
if(p_cb) {
|
||||
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
p_cb->state = BTM_BLE_STOP_ADV;
|
||||
}
|
||||
}
|
||||
l2cble_conn_comp (handle, role, bda, bda_type, conn_interval,
|
||||
conn_latency, conn_timeout);
|
||||
|
||||
|
||||
@@ -1439,7 +1439,8 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
|
||||
|
||||
if (BTM_BLE_ISVALID_PARAM(scan_interval, BTM_BLE_SCAN_INT_MIN, max_scan_interval) &&
|
||||
BTM_BLE_ISVALID_PARAM(scan_window, BTM_BLE_SCAN_WIN_MIN, max_scan_window) &&
|
||||
(scan_mode == BTM_BLE_SCAN_MODE_ACTI || scan_mode == BTM_BLE_SCAN_MODE_PASS)) {
|
||||
(scan_mode == BTM_BLE_SCAN_MODE_ACTI || scan_mode == BTM_BLE_SCAN_MODE_PASS) &&
|
||||
(scan_duplicate_filter < BTM_BLE_SCAN_DUPLICATE_MAX)) {
|
||||
p_cb->scan_type = scan_mode;
|
||||
p_cb->scan_interval = scan_interval;
|
||||
p_cb->scan_window = scan_window;
|
||||
@@ -2637,7 +2638,7 @@ static void btm_ble_parse_adv_data(tBTM_INQ_INFO *p_info, UINT8 *p_data,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_cache_adv_data(tBTM_INQ_RESULTS *p_cur, UINT8 data_len, UINT8 *p, UINT8 evt_type)
|
||||
void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len, UINT8 *p, UINT8 evt_type)
|
||||
{
|
||||
tBTM_BLE_INQ_CB *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
UINT8 *p_cache;
|
||||
@@ -2649,6 +2650,15 @@ void btm_ble_cache_adv_data(tBTM_INQ_RESULTS *p_cur, UINT8 data_len, UINT8 *p, U
|
||||
memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX);
|
||||
p_cur->adv_data_len = 0;
|
||||
p_cur->scan_rsp_len = 0;
|
||||
}
|
||||
|
||||
//Clear the adv cache if the addresses are not equal
|
||||
if(memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) != 0) {
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memcpy(p_le_inq_cb->adv_addr, bda, BD_ADDR_LEN);
|
||||
memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX);
|
||||
p_cur->adv_data_len = 0;
|
||||
p_cur->scan_rsp_len = 0;
|
||||
}
|
||||
|
||||
if (data_len > 0) {
|
||||
@@ -2878,7 +2888,7 @@ static void btm_ble_appearance_to_cod(UINT16 appearance, UINT8 *dev_class)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btm_ble_update_inq_result(tINQ_DB_ENT *p_i, UINT8 addr_type, UINT8 evt_type, UINT8 *p)
|
||||
BOOLEAN btm_ble_update_inq_result(BD_ADDR bda, tINQ_DB_ENT *p_i, UINT8 addr_type, UINT8 evt_type, UINT8 *p)
|
||||
{
|
||||
BOOLEAN to_report = TRUE;
|
||||
tBTM_INQ_RESULTS *p_cur = &p_i->inq_info.results;
|
||||
@@ -2896,7 +2906,7 @@ BOOLEAN btm_ble_update_inq_result(tINQ_DB_ENT *p_i, UINT8 addr_type, UINT8 evt_t
|
||||
BTM_TRACE_WARNING("EIR data too long %d. discard", data_len);
|
||||
return FALSE;
|
||||
}
|
||||
btm_ble_cache_adv_data(p_cur, data_len, p, evt_type);
|
||||
btm_ble_cache_adv_data(bda, p_cur, data_len, p, evt_type);
|
||||
|
||||
p1 = (p + data_len);
|
||||
STREAM_TO_UINT8 (rssi, p1);
|
||||
@@ -3120,6 +3130,71 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_process_last_adv_pkt
|
||||
**
|
||||
** Description This function is called to report last adv packet
|
||||
**
|
||||
** Parameters
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
static void btm_ble_process_last_adv_pkt(void)
|
||||
{
|
||||
UINT8 result = 0;
|
||||
UINT8 null_bda[6] = {0};
|
||||
tBTM_INQUIRY_VAR_ST *p_inq = &btm_cb.btm_inq_vars;
|
||||
tBTM_INQ_RESULTS_CB *p_inq_results_cb = p_inq->p_inq_results_cb;
|
||||
tBTM_INQ_RESULTS_CB *p_obs_results_cb = btm_cb.ble_ctr_cb.p_obs_results_cb;
|
||||
tBTM_INQ_RESULTS_CB *p_scan_results_cb = btm_cb.ble_ctr_cb.p_scan_results_cb;
|
||||
tBTM_BLE_INQ_CB *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
tINQ_DB_ENT *p_i = btm_inq_db_find (p_le_inq_cb->adv_addr);
|
||||
|
||||
if(memcmp(null_bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(p_i == NULL) {
|
||||
BTM_TRACE_DEBUG("no last adv");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((result = btm_ble_is_discoverable(p_le_inq_cb->adv_addr, p_i->inq_info.results.ble_evt_type, NULL)) == 0) {
|
||||
BTM_TRACE_WARNING("%s device is no longer discoverable so discarding advertising packet pkt",
|
||||
__func__);
|
||||
return;
|
||||
}
|
||||
/* background connection in selective connection mode */
|
||||
if (btm_cb.ble_ctr_cb.bg_conn_type == BTM_BLE_CONN_SELECTIVE) {
|
||||
//do nothing
|
||||
} else {
|
||||
if (p_inq_results_cb && (result & BTM_BLE_INQ_RESULT)) {
|
||||
(p_inq_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache);
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memset(p_le_inq_cb->adv_addr, 0, BD_ADDR_LEN);
|
||||
p_i->inq_info.results.adv_data_len = 0;
|
||||
p_i->inq_info.results.scan_rsp_len = 0;
|
||||
}
|
||||
if (p_obs_results_cb && (result & BTM_BLE_OBS_RESULT)) {
|
||||
(p_obs_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache);
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memset(p_le_inq_cb->adv_addr, 0, BD_ADDR_LEN);
|
||||
p_i->inq_info.results.adv_data_len = 0;
|
||||
p_i->inq_info.results.scan_rsp_len = 0;
|
||||
}
|
||||
if (p_scan_results_cb && (result & BTM_BLE_DISCO_RESULT)) {
|
||||
(p_scan_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache);
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memset(p_le_inq_cb->adv_addr, 0, BD_ADDR_LEN);
|
||||
p_i->inq_info.results.adv_data_len = 0;
|
||||
p_i->inq_info.results.scan_rsp_len = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_process_adv_pkt_cont
|
||||
@@ -3144,6 +3219,13 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
BOOLEAN update = TRUE;
|
||||
UINT8 result = 0;
|
||||
|
||||
//if scan duplicate is enabled, the adv packet without scan response is allowed to report to upper layer
|
||||
if(p_le_inq_cb->scan_duplicate_filter == BTM_BLE_SCAN_DUPLICATE_ENABLE) {
|
||||
if(memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) != 0) {
|
||||
btm_ble_process_last_adv_pkt();
|
||||
}
|
||||
}
|
||||
|
||||
p_i = btm_inq_db_find (bda);
|
||||
|
||||
/* Check if this address has already been processed for this inquiry */
|
||||
@@ -3172,7 +3254,7 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
p_inq->inq_cmpl_info.num_resp++;
|
||||
}
|
||||
/* update the LE device information in inquiry database */
|
||||
if (!btm_ble_update_inq_result(p_i, addr_type, evt_type, p)) {
|
||||
if (!btm_ble_update_inq_result(bda, p_i, addr_type, evt_type, p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3216,12 +3298,24 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
} else {
|
||||
if (p_inq_results_cb && (result & BTM_BLE_INQ_RESULT)) {
|
||||
(p_inq_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache);
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memset(p_le_inq_cb->adv_addr, 0, BD_ADDR_LEN);
|
||||
p_i->inq_info.results.adv_data_len = 0;
|
||||
p_i->inq_info.results.scan_rsp_len = 0;
|
||||
}
|
||||
if (p_obs_results_cb && (result & BTM_BLE_OBS_RESULT)) {
|
||||
(p_obs_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache);
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memset(p_le_inq_cb->adv_addr, 0, BD_ADDR_LEN);
|
||||
p_i->inq_info.results.adv_data_len = 0;
|
||||
p_i->inq_info.results.scan_rsp_len = 0;
|
||||
}
|
||||
if (p_scan_results_cb && (result & BTM_BLE_DISCO_RESULT)) {
|
||||
(p_scan_results_cb)((tBTM_INQ_RESULTS *) &p_i->inq_info.results, p_le_inq_cb->adv_data_cache);
|
||||
p_le_inq_cb->adv_len = 0;
|
||||
memset(p_le_inq_cb->adv_addr, 0, BD_ADDR_LEN);
|
||||
p_i->inq_info.results.adv_data_len = 0;
|
||||
p_i->inq_info.results.scan_rsp_len = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3492,15 +3586,30 @@ tBTM_STATUS btm_ble_stop_adv(void)
|
||||
tBTM_STATUS rt = BTM_SUCCESS;
|
||||
|
||||
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
|
||||
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
|
||||
p_cb->fast_adv_on = FALSE;
|
||||
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
p_cb->state = BTM_BLE_ADV_PENDING;
|
||||
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_ADV;
|
||||
UINT8 temp_adv_mode = p_cb->adv_mode;
|
||||
BOOLEAN temp_fast_adv_on = p_cb->fast_adv_on;
|
||||
tBTM_BLE_GAP_STATE temp_state = p_cb->state;
|
||||
tBTM_BLE_WL_STATE temp_wl_state = btm_cb.ble_ctr_cb.wl_state;
|
||||
tBTM_BLE_STATE_MASK temp_mask = btm_ble_get_topology_mask ();
|
||||
|
||||
p_cb->fast_adv_on = FALSE;
|
||||
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
p_cb->state = BTM_BLE_ADV_PENDING;
|
||||
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_ADV;
|
||||
|
||||
/* clear all adv states */
|
||||
btm_ble_clear_topology_mask (BTM_BLE_STATE_ALL_ADV_MASK);
|
||||
|
||||
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
|
||||
|
||||
/* clear all adv states */
|
||||
btm_ble_clear_topology_mask (BTM_BLE_STATE_ALL_ADV_MASK);
|
||||
} else {
|
||||
// reset state
|
||||
p_cb->fast_adv_on = temp_fast_adv_on;
|
||||
p_cb->adv_mode = temp_adv_mode;
|
||||
p_cb->state = temp_state;
|
||||
btm_cb.ble_ctr_cb.wl_state = temp_wl_state;
|
||||
btm_ble_set_topology_mask (temp_mask);
|
||||
|
||||
rt = BTM_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
@@ -3745,6 +3854,20 @@ BOOLEAN btm_ble_clear_topology_mask (tBTM_BLE_STATE_MASK request_state_mask)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_get_topology_mask
|
||||
**
|
||||
** Description Get BLE topology bit mask
|
||||
**
|
||||
** Returns state mask.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_BLE_STATE_MASK btm_ble_get_topology_mask (void)
|
||||
{
|
||||
return btm_cb.ble_ctr_cb.cur_states;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_update_link_topology_mask
|
||||
@@ -3838,7 +3961,7 @@ void btm_ble_init (void)
|
||||
btm_cb.cmn_ble_vsc_cb.values_read = FALSE;
|
||||
p_cb->cur_states = 0;
|
||||
|
||||
p_cb->conn_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
p_cb->conn_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
p_cb->inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
p_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
|
||||
|
||||
@@ -56,8 +56,8 @@ void btm_init (void)
|
||||
#endif /* #if BTM_DYNAMIC_MEMORY */
|
||||
/* All fields are cleared; nonzero fields are reinitialized in appropriate function */
|
||||
memset(&btm_cb, 0, sizeof(tBTM_CB));
|
||||
btm_cb.page_queue = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.page_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
#if defined(BTM_INITIAL_TRACE_LEVEL)
|
||||
btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
|
||||
|
||||
@@ -113,7 +113,7 @@ void btm_sco_init (void)
|
||||
#endif
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
for (int i = 0; i < BTM_MAX_SCO_LINKS; i++) {
|
||||
btm_cb.sco_cb.sco_db[i].xmit_data_q = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.sco_cb.sco_db[i].xmit_data_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
#endif
|
||||
/* Initialize nonzero defaults */
|
||||
@@ -319,9 +319,8 @@ void btm_sco_process_num_completed_pkts (UINT8 *p)
|
||||
STREAM_TO_UINT8 (num_handles, p);
|
||||
for (xx = 0; xx < num_handles; xx++) {
|
||||
STREAM_TO_UINT16 (handle, p);
|
||||
handle &= 0x7ff; // walk around for bad handle bit mask from controller
|
||||
STREAM_TO_UINT16 (num_sent, p);
|
||||
if ((sco_inx = btm_find_scb_by_handle(handle & 0x7ff)) == BTM_MAX_SCO_LINKS) {
|
||||
if ((sco_inx = btm_find_scb_by_handle(handle)) == BTM_MAX_SCO_LINKS) {
|
||||
continue;
|
||||
}
|
||||
BTM_TRACE_DEBUG("%s, %d, %u", __FUNCTION__, handle, p_cb->xmit_window_size); //debug
|
||||
|
||||
@@ -1361,7 +1361,7 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
|
||||
return (BTM_SUCCESS);
|
||||
}
|
||||
|
||||
p_dev_rec->enc_init_by_we = TRUE;
|
||||
/* enqueue security request if security is active */
|
||||
if (p_dev_rec->p_callback || (p_dev_rec->sec_state != BTM_SEC_STATE_IDLE)) {
|
||||
BTM_TRACE_WARNING ("Security Manager: BTM_SetEncryption busy, enqueue request\n");
|
||||
@@ -2762,7 +2762,7 @@ void btm_sec_check_pending_reqs (void)
|
||||
/* Now, re-submit anything in the mux queue */
|
||||
bq = btm_cb.sec_pending_q;
|
||||
if (!btm_cb.sec_pending_q) {
|
||||
btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
btm_cb.sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
while ((p_e = (tBTM_SEC_QUEUE_ENTRY *)fixed_queue_try_dequeue(bq)) != NULL) {
|
||||
@@ -4018,7 +4018,6 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
|
||||
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
|
||||
tACL_CONN *p_acl = NULL;
|
||||
UINT8 acl_idx = btm_handle_to_acl_index(handle);
|
||||
tGATT_TCB *p_tcb = NULL;
|
||||
#endif
|
||||
BTM_TRACE_EVENT ("Security Manager: encrypt_change status:%d State:%d, encr_enable = %d\n",
|
||||
status, (p_dev_rec) ? p_dev_rec->sec_state : 0, encr_enable);
|
||||
@@ -4046,14 +4045,6 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
|
||||
p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED;
|
||||
}
|
||||
} else {
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* Before the application layer has received the connection event, the device has received an
|
||||
encrypted request from the peer device. The device should wait until the application layer
|
||||
receives the connection event before updating 'sec_flags'. */
|
||||
if ((p_tcb = gatt_find_tcb_by_addr(p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE)) == NULL) {
|
||||
//do nothing
|
||||
} else
|
||||
#endif
|
||||
p_dev_rec->sec_flags |= (BTM_SEC_LE_AUTHENTICATED | BTM_SEC_LE_ENCRYPTED);
|
||||
}
|
||||
}
|
||||
@@ -4543,7 +4534,7 @@ void btm_sec_disconnected (UINT16 handle, UINT8 reason)
|
||||
if (!p_dev_rec) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_dev_rec->enc_init_by_we = FALSE;
|
||||
transport = (handle == p_dev_rec->hci_handle) ? BT_TRANSPORT_BR_EDR : BT_TRANSPORT_LE;
|
||||
|
||||
p_dev_rec->rs_disc_pending = BTM_SEC_RS_NOT_PENDING; /* reset flag */
|
||||
|
||||
@@ -162,7 +162,7 @@ typedef struct {
|
||||
|
||||
UINT8 adv_len;
|
||||
UINT8 adv_data_cache[BTM_BLE_CACHE_ADV_DATA_MAX];
|
||||
|
||||
BD_ADDR adv_addr;
|
||||
/* inquiry BD addr database */
|
||||
UINT8 num_bd_entries;
|
||||
UINT8 max_bd_entries;
|
||||
@@ -481,6 +481,7 @@ void btm_ble_adv_filter_cleanup(void);
|
||||
BOOLEAN btm_ble_topology_check(tBTM_BLE_STATE_MASK request);
|
||||
BOOLEAN btm_ble_clear_topology_mask(tBTM_BLE_STATE_MASK request_state);
|
||||
BOOLEAN btm_ble_set_topology_mask(tBTM_BLE_STATE_MASK request_state);
|
||||
tBTM_BLE_STATE_MASK btm_ble_get_topology_mask(void);
|
||||
|
||||
#if BTM_BLE_CONFORMANCE_TESTING == TRUE
|
||||
void btm_ble_set_no_disc_if_pair_fail (BOOLEAN disble_disc);
|
||||
|
||||
@@ -618,7 +618,7 @@ typedef struct {
|
||||
// btla-specific --
|
||||
#define BTM_SEC_NO_LAST_SERVICE_ID 0
|
||||
UINT8 last_author_service_id; /* ID of last serviced authorized: Reset after each l2cap connection */
|
||||
|
||||
BOOLEAN enc_init_by_we;
|
||||
} tBTM_SEC_DEV_REC;
|
||||
|
||||
#define BTM_SEC_IS_SM4(sm) ((BOOLEAN)(BTM_SM4_TRUE == ((sm)&BTM_SM4_TRUE)))
|
||||
|
||||
@@ -236,3 +236,13 @@ UINT16 BTU_BleAclPktSize(void)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
bool BTU_check_queue_is_congest(void)
|
||||
{
|
||||
UBaseType_t wait_size = uxQueueMessagesWaiting(xBtuQueue);
|
||||
if(wait_size >= QUEUE_CONGEST_SIZE ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -242,23 +242,6 @@ void btu_task_thread_handler(void *arg)
|
||||
case SIG_BTU_ONESHOT_ALARM: {
|
||||
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)e.par;
|
||||
btu_general_alarm_process(p_tle);
|
||||
|
||||
switch (p_tle->event) {
|
||||
#if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE)
|
||||
case BTU_TTYPE_BLE_RANDOM_ADDR:
|
||||
btm_ble_timeout(p_tle);
|
||||
break;
|
||||
#endif
|
||||
case BTU_TTYPE_USER_FUNC: {
|
||||
tUSER_TIMEOUT_FUNC *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param;
|
||||
(*p_uf)(p_tle);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// FAIL
|
||||
HCI_TRACE_ERROR("Received unexpected oneshot timer event:0x%x\n", p_tle->event);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SIG_BTU_L2CAP_ALARM:
|
||||
|
||||
@@ -1120,8 +1120,8 @@ static tGAP_CCB *gap_allocate_ccb (void)
|
||||
for (xx = 0, p_ccb = gap_cb.conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) {
|
||||
if (p_ccb->con_state == GAP_CCB_STATE_IDLE) {
|
||||
memset (p_ccb, 0, sizeof (tGAP_CCB));
|
||||
p_ccb->tx_queue = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->rx_queue = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->tx_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->rx_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
p_ccb->gap_handle = xx;
|
||||
p_ccb->rem_mtu_size = L2CAP_MTU_SIZE;
|
||||
|
||||
@@ -354,7 +354,7 @@ tGATT_STATUS attp_send_msg_to_l2cap(tGATT_TCB *p_tcb, BT_HDR *p_toL2CAP)
|
||||
}
|
||||
|
||||
if (l2cap_ret == L2CAP_DW_FAILED) {
|
||||
GATT_TRACE_ERROR("ATT failed to pass msg:0x%0x to L2CAP",
|
||||
GATT_TRACE_DEBUG("ATT failed to pass msg:0x%0x to L2CAP",
|
||||
*((UINT8 *)(p_toL2CAP + 1) + p_toL2CAP->offset));
|
||||
return GATT_INTERNAL_ERROR;
|
||||
} else if (l2cap_ret == L2CAP_DW_CONGESTED) {
|
||||
|
||||
@@ -1038,7 +1038,10 @@ BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb)
|
||||
if (att_ret == GATT_SUCCESS || att_ret == GATT_CONGESTED) {
|
||||
sent = TRUE;
|
||||
p_cmd->to_send = FALSE;
|
||||
p_cmd->p_cmd = NULL;
|
||||
if(p_cmd->p_cmd) {
|
||||
osi_free(p_cmd->p_cmd);
|
||||
p_cmd->p_cmd = NULL;
|
||||
}
|
||||
|
||||
/* dequeue the request if is write command or sign write */
|
||||
if (p_cmd->op_code != GATT_CMD_WRITE && p_cmd->op_code != GATT_SIGN_CMD_WRITE) {
|
||||
|
||||
@@ -64,7 +64,7 @@ BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, BOOLEAN
|
||||
UINT16 s_hdl, UINT16 num_handle)
|
||||
{
|
||||
if (p_db->svc_buffer == NULL) { //in case already alloc
|
||||
p_db->svc_buffer = fixed_queue_new(SIZE_MAX);
|
||||
p_db->svc_buffer = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
if (!allocate_svc_db_buf(p_db)) {
|
||||
|
||||
@@ -108,9 +108,9 @@ void gatt_init (void)
|
||||
gatt_cb.trace_level = BT_TRACE_LEVEL_NONE; /* No traces */
|
||||
#endif
|
||||
gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE;
|
||||
gatt_cb.sign_op_queue = fixed_queue_new(SIZE_MAX);
|
||||
gatt_cb.srv_chg_clt_q = fixed_queue_new(SIZE_MAX);
|
||||
gatt_cb.pending_new_srv_start_q = fixed_queue_new(SIZE_MAX);
|
||||
gatt_cb.sign_op_queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
gatt_cb.srv_chg_clt_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
gatt_cb.pending_new_srv_start_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
/* First, register fixed L2CAP channel for ATT over BLE */
|
||||
fixed_reg.fixed_chnl_opts.mode = L2CAP_FCR_BASIC_MODE;
|
||||
fixed_reg.fixed_chnl_opts.max_transmit = 0xFF;
|
||||
@@ -179,7 +179,7 @@ void gatt_free(void)
|
||||
|
||||
btu_free_timer(&gatt_cb.tcb[i].ind_ack_timer_ent);
|
||||
memset(&gatt_cb.tcb[i].ind_ack_timer_ent, 0, sizeof(TIMER_LIST_ENT));
|
||||
|
||||
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
fixed_queue_free(gatt_cb.tcb[i].sr_cmd.multi_rsp_q, NULL);
|
||||
gatt_cb.tcb[i].sr_cmd.multi_rsp_q = NULL;
|
||||
@@ -979,7 +979,12 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GATT_TRACE_ERROR ("ATT - Rcvd L2CAP data, unknown cmd: 0x%x\n", op_code);
|
||||
if (op_code & GATT_COMMAND_FLAG) {
|
||||
GATT_TRACE_ERROR ("ATT - Rcvd L2CAP data, unknown cmd: 0x%x\n", op_code);
|
||||
} else {
|
||||
GATT_TRACE_ERROR ("ATT - Rcvd L2CAP data, unknown req: 0x%x\n", op_code);
|
||||
gatt_send_error_rsp (p_tcb, GATT_REQ_NOT_SUPPORTED, op_code, 0, FALSE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GATT_TRACE_ERROR ("invalid data length, ignore\n");
|
||||
|
||||
@@ -167,7 +167,7 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
|
||||
GATT_TRACE_DEBUG ("process_read_multi_rsp status=%d mtu=%d", status, mtu);
|
||||
|
||||
if (p_cmd->multi_rsp_q == NULL) {
|
||||
p_cmd->multi_rsp_q = fixed_queue_new(SIZE_MAX);
|
||||
p_cmd->multi_rsp_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
/* Enqueue the response */
|
||||
@@ -1290,7 +1290,7 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand
|
||||
queue_data->offset = offset;
|
||||
memcpy(queue_data->value, p, len);
|
||||
if (prepare_record->queue == NULL) {
|
||||
prepare_record->queue = fixed_queue_new(SIZE_MAX);
|
||||
prepare_record->queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
fixed_queue_enqueue(prepare_record->queue, queue_data);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void)
|
||||
if (!p_cb->hdl_list[i].in_use) {
|
||||
memset(p_elem, 0, sizeof(tGATT_HDL_LIST_ELEM));
|
||||
p_elem->in_use = TRUE;
|
||||
p_elem->svc_db.svc_buffer = fixed_queue_new(SIZE_MAX);
|
||||
p_elem->svc_db.svc_buffer = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
return p_elem;
|
||||
}
|
||||
}
|
||||
@@ -1007,8 +1007,8 @@ tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
|
||||
|
||||
if (allocated) {
|
||||
memset(p_tcb, 0, sizeof(tGATT_TCB));
|
||||
p_tcb->pending_enc_clcb = fixed_queue_new(SIZE_MAX);
|
||||
p_tcb->pending_ind_q = fixed_queue_new(SIZE_MAX);
|
||||
p_tcb->pending_enc_clcb = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_tcb->pending_ind_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_tcb->in_use = TRUE;
|
||||
p_tcb->tcb_idx = i;
|
||||
p_tcb->transport = transport;
|
||||
@@ -2258,6 +2258,7 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
|
||||
GATT_TRACE_DEBUG ("exit gatt_cleanup_upon_disc ");
|
||||
BTM_Recovery_Pre_State();
|
||||
}
|
||||
gatt_delete_dev_from_srv_chg_clt_list(bda);
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -2811,8 +2811,8 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
|
||||
**
|
||||
** Function BTM_ReadRSSI
|
||||
**
|
||||
** Description This function is called to read the link policy settings.
|
||||
** The address of link policy results are returned in the callback.
|
||||
** Description This function is called to read the RSSI for a particular transport.
|
||||
** The RSSI of results are returned in the callback.
|
||||
** (tBTM_RSSI_RESULTS)
|
||||
**
|
||||
** Returns BTM_CMD_STARTED if command issued to controller.
|
||||
@@ -2822,7 +2822,7 @@ tBTM_STATUS BTM_SwitchRole (BD_ADDR remote_bd_addr,
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
|
||||
tBTM_STATUS BTM_ReadRSSI (BD_ADDR remote_bda, tBT_TRANSPORT transport, tBTM_CMPL_CB *p_cb);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -582,6 +582,12 @@ typedef struct {
|
||||
tBTM_BLE_REF_VALUE ref_value;
|
||||
} tBTM_BLE_BATCH_SCAN_CB;
|
||||
|
||||
/// Ble scan duplicate type
|
||||
enum {
|
||||
BTM_BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */
|
||||
BTM_BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */
|
||||
BTM_BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */
|
||||
};
|
||||
/* filter selection bit index */
|
||||
#define BTM_BLE_PF_ADDR_FILTER 0
|
||||
#define BTM_BLE_PF_SRVC_DATA 1
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
#define GATT_NOT_ENCRYPTED 0x8e
|
||||
#define GATT_CONGESTED 0x8f
|
||||
|
||||
#define GATT_DUP_REG 0x90
|
||||
#define GATT_DUP_REG 0x90
|
||||
#define GATT_ALREADY_OPEN 0x91
|
||||
#define GATT_CANCEL 0x92
|
||||
|
||||
@@ -111,6 +111,7 @@ typedef UINT8 tGATT_STATUS;
|
||||
#define GATT_SIGN_CMD_WRITE 0xD2 /* changed in V4.0 1101-0010 (signed write) see write cmd above*/
|
||||
#define GATT_OP_CODE_MAX GATT_HANDLE_VALUE_CONF + 1 /* 0x1E = 30 + 1 = 31*/
|
||||
|
||||
#define GATT_COMMAND_FLAG 0x40 /* Command Flag: set to one means commond */
|
||||
|
||||
#define GATT_HANDLE_IS_VALID(x) ((x) != 0)
|
||||
|
||||
@@ -766,7 +767,7 @@ extern UINT16 GATTS_AddIncludeService (UINT16 service_handle,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
|
||||
tGATT_PERM perm, tGATT_CHAR_PROP property,
|
||||
tGATT_PERM perm, tGATT_CHAR_PROP property,
|
||||
tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control);
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -793,7 +793,7 @@
|
||||
#define HCI_ERR_MAX_ERR 0x43
|
||||
|
||||
//ESP vendor error code
|
||||
#define HCI_ERR_ESP_VENDOR_FAIL 0xE0
|
||||
#define HCI_ERR_ESP_VENDOR_FAIL 0xE0
|
||||
|
||||
#define HCI_HINT_TO_RECREATE_AMP_PHYS_LINK 0xFF
|
||||
|
||||
|
||||
@@ -376,6 +376,7 @@ typedef struct t_l2c_linkcb {
|
||||
|
||||
TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */
|
||||
UINT16 handle; /* The handle used with LM */
|
||||
UINT16 completed_packets; /* The number of conpleted packets */
|
||||
|
||||
tL2C_CCB_Q ccb_queue; /* Queue of CCBs on this LCB */
|
||||
|
||||
@@ -667,6 +668,10 @@ extern void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb);
|
||||
|
||||
#endif
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
extern UINT8 l2cu_find_completed_packets(UINT16 *handles, UINT16 *num_packets);
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr);
|
||||
extern void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb);
|
||||
extern void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
|
||||
|
||||
@@ -1816,7 +1816,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
|
||||
|
||||
// If already congested, do not accept any more packets
|
||||
if (p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->cong_sent) {
|
||||
L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested\
|
||||
L2CAP_TRACE_DEBUG ("L2CAP - CID: 0x%04x cannot send, already congested\
|
||||
xmit_hold_q.count: %u buff_quota: %u", fixed_cid,
|
||||
fixed_queue_length(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q),
|
||||
p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
|
||||
@@ -1887,7 +1887,7 @@ BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda)
|
||||
p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, transport);
|
||||
|
||||
if ( ((p_lcb) == NULL) || (!p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]) ) {
|
||||
L2CAP_TRACE_WARNING ("L2CA_RemoveFixedChnl() CID: 0x%04x BDA: %08x%04x not connected", fixed_cid,
|
||||
L2CAP_TRACE_DEBUG ("L2CA_RemoveFixedChnl() CID: 0x%04x BDA: %08x%04x not connected", fixed_cid,
|
||||
(rem_bda[0] << 24) + (rem_bda[1] << 16) + (rem_bda[2] << 8) + rem_bda[3], (rem_bda[4] << 8) + rem_bda[5]);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
@@ -261,6 +261,15 @@ void l2cble_notify_le_connection (BD_ADDR bda)
|
||||
tACL_CONN *p_acl = btm_bda_to_acl(bda, BT_TRANSPORT_LE) ;
|
||||
|
||||
if (p_lcb != NULL && p_acl != NULL && p_lcb->link_state != LST_CONNECTED) {
|
||||
|
||||
if(p_acl->link_role == HCI_ROLE_SLAVE) {
|
||||
//clear p_cb->state, controller will stop adv when ble connected.
|
||||
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
if(p_cb) {
|
||||
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
p_cb->state = BTM_BLE_STOP_ADV;
|
||||
}
|
||||
}
|
||||
/* update link status */
|
||||
btm_establish_continue(p_acl);
|
||||
/* update l2cap link status and send callback */
|
||||
|
||||
@@ -750,7 +750,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
|
||||
if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) &&
|
||||
(!fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q))) {
|
||||
fixed_queue_t *temp_q = p_ccb->fcrb.srej_rcv_hold_q;
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(temp_q)) != NULL) {
|
||||
if (p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN)) {
|
||||
|
||||
@@ -966,7 +966,7 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
|
||||
|
||||
/* If already congested, do not accept any more packets */
|
||||
if (p_ccb->cong_sent) {
|
||||
L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested xmit_hold_q.count: %u buff_quota: %u",
|
||||
L2CAP_TRACE_DEBUG ("L2CAP - CID: 0x%04x cannot send, already congested xmit_hold_q.count: %u buff_quota: %u",
|
||||
p_ccb->local_cid,
|
||||
fixed_queue_length(p_ccb->xmit_hold_q),
|
||||
p_ccb->buff_quota);
|
||||
|
||||
@@ -57,7 +57,7 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
|
||||
btu_free_timer(&p_lcb->timer_entry);
|
||||
btu_free_timer(&p_lcb->info_timer_entry);
|
||||
btu_free_timer(&p_lcb->upda_con_timer);
|
||||
|
||||
|
||||
memset (p_lcb, 0, sizeof (tL2C_LCB));
|
||||
memcpy (p_lcb->remote_bd_addr, p_bd_addr, BD_ADDR_LEN);
|
||||
|
||||
@@ -74,7 +74,7 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
p_lcb->transport = transport;
|
||||
p_lcb->tx_data_len = controller_get_interface()->get_ble_default_data_packet_length();
|
||||
p_lcb->le_sec_pending_q = fixed_queue_new(SIZE_MAX);
|
||||
p_lcb->le_sec_pending_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
l2cb.num_ble_links_active++;
|
||||
@@ -86,6 +86,9 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
|
||||
l2c_link_adjust_allocation();
|
||||
}
|
||||
p_lcb->link_xmit_data_q = list_new(NULL);
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
p_lcb->completed_packets = 0;
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
return (p_lcb);
|
||||
}
|
||||
}
|
||||
@@ -137,7 +140,7 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
||||
memset(&p_lcb->info_timer_entry, 0, sizeof(TIMER_LIST_ENT));
|
||||
btu_free_timer(&p_lcb->upda_con_timer);
|
||||
memset(&p_lcb->upda_con_timer, 0, sizeof(TIMER_LIST_ENT));
|
||||
|
||||
|
||||
/* Release any unfinished L2CAP packet on this link */
|
||||
if (p_lcb->p_hcit_rcv_acl) {
|
||||
osi_free(p_lcb->p_hcit_rcv_acl);
|
||||
@@ -250,6 +253,11 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
||||
fixed_queue_free(p_lcb->le_sec_pending_q, NULL);
|
||||
p_lcb->le_sec_pending_q = NULL;
|
||||
}
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
p_lcb->completed_packets = 0;
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1488,7 +1496,7 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
|
||||
btu_free_quick_timer(&p_ccb->fcrb.ack_timer);
|
||||
memset(&p_ccb->fcrb.ack_timer, 0, sizeof(TIMER_LIST_ENT));
|
||||
p_ccb->fcrb.ack_timer.param = (TIMER_PARAM_TYPE)p_ccb;
|
||||
|
||||
|
||||
btu_free_quick_timer(&p_ccb->fcrb.mon_retrans_timer);
|
||||
memset(&p_ccb->fcrb.mon_retrans_timer, 0, sizeof(TIMER_LIST_ENT));
|
||||
p_ccb->fcrb.mon_retrans_timer.param = (TIMER_PARAM_TYPE)p_ccb;
|
||||
@@ -1511,11 +1519,11 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
|
||||
p_ccb->max_rx_mtu = L2CAP_MTU_SIZE;
|
||||
p_ccb->tx_mps = L2CAP_FCR_TX_BUF_SIZE - 32;
|
||||
|
||||
p_ccb->xmit_hold_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->xmit_hold_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.retrans_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(SIZE_MAX);
|
||||
p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->fcrb.retrans_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
p_ccb->cong_sent = FALSE;
|
||||
@@ -3140,6 +3148,35 @@ void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb)
|
||||
|
||||
#endif /* BLE_INCLUDED == TRUE */
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function l2cu_find_completed_packets
|
||||
**
|
||||
** Description Find the completed packets,
|
||||
** Then set it to zero
|
||||
**
|
||||
** Returns The num of handles
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 l2cu_find_completed_packets(UINT16 *handles, UINT16 *num_packets)
|
||||
{
|
||||
int xx;
|
||||
UINT8 num = 0;
|
||||
tL2C_LCB *p_lcb = &l2cb.lcb_pool[0];
|
||||
|
||||
for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) {
|
||||
if ((p_lcb->in_use) && (p_lcb->completed_packets > 0)) {
|
||||
*(handles++) = p_lcb->handle;
|
||||
*(num_packets++) = p_lcb->completed_packets;
|
||||
num++;
|
||||
p_lcb->completed_packets = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
** Functions used by both Full and Light Stack
|
||||
|
||||
@@ -128,8 +128,8 @@ void port_set_defaults (tPORT *p_port)
|
||||
memset (&p_port->rx, 0, sizeof (p_port->rx));
|
||||
memset (&p_port->tx, 0, sizeof (p_port->tx));
|
||||
|
||||
p_port->tx.queue = fixed_queue_new(SIZE_MAX);
|
||||
p_port->rx.queue = fixed_queue_new(SIZE_MAX);
|
||||
p_port->tx.queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
p_port->rx.queue = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -175,7 +175,7 @@ tRFC_MCB *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, BOOLEAN is_initiator)
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d, create new p_mcb:%p, index:%d",
|
||||
is_initiator, &rfc_cb.port.rfc_mcb[j], j);
|
||||
|
||||
p_mcb->cmd_q = fixed_queue_new(SIZE_MAX);
|
||||
p_mcb->cmd_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
|
||||
p_mcb->is_initiator = is_initiator;
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ extern elliptic_curve_t curve_p256;
|
||||
|
||||
void ECC_PointMult_Bin_NAF(Point *q, Point *p, DWORD *n, uint32_t keyLength);
|
||||
|
||||
bool ECC_CheckPointIsInElliCur_P256(Point *p);
|
||||
|
||||
#define ECC_PointMult(q, p, n, keyLength) ECC_PointMult_Bin_NAF(q, p, n, keyLength)
|
||||
|
||||
void p_256_init_curve(UINT32 keyLength);
|
||||
|
||||
@@ -240,4 +240,40 @@ void ECC_PointMult_Bin_NAF(Point *q, Point *p, DWORD *n, uint32_t keyLength)
|
||||
multiprecision_mersenns_mult_mod(q->y, q->y, q->z, keyLength);
|
||||
}
|
||||
|
||||
bool ECC_CheckPointIsInElliCur_P256(Point *p)
|
||||
{
|
||||
/* y^2 % q */
|
||||
DWORD y_y_q[KEY_LENGTH_DWORDS_P256] = {0x0};
|
||||
/* x^2 % q */
|
||||
DWORD x_x_q[KEY_LENGTH_DWORDS_P256] = {0x0};
|
||||
/* x % q */
|
||||
DWORD x_q[KEY_LENGTH_DWORDS_P256] = {0x0};
|
||||
/* x^2, To prevent overflow, the length of the x square here needs to
|
||||
be expanded to two times the original one. */
|
||||
DWORD x_x[2*KEY_LENGTH_DWORDS_P256] = {0x0};
|
||||
/* y_y_q =(p->y)^2(mod q) */
|
||||
multiprecision_mersenns_squa_mod(y_y_q, p->y, KEY_LENGTH_DWORDS_P256);
|
||||
/* Calculate the value of p->x square, x_x = (p->x)^2 */
|
||||
multiprecision_mult(x_x, p->x, p->x, KEY_LENGTH_DWORDS_P256);
|
||||
/* The function of the elliptic curve is y^2 = x^3 - 3x + b (mod q) ==>
|
||||
y^2 = (x^2 - 3)*x + b (mod q),
|
||||
so we calculate the x^2 - 3 value here */
|
||||
x_x[0] -= 3;
|
||||
/* Using math relations. (a*b) % q = ((a%q)*(b%q)) % q ==>
|
||||
(x^2 - 3)*x = (((x^2 - 3) % q) * x % q) % q */
|
||||
multiprecision_fast_mod_P256(x_x_q, x_x);
|
||||
/* x_x = x_x_q * x_q */
|
||||
multiprecision_mult(x_x, x_x_q, p->x, KEY_LENGTH_DWORDS_P256);
|
||||
/* x_q = x_x % q */
|
||||
multiprecision_fast_mod_P256(x_q, x_x);
|
||||
/* Save the result in x_x_q */
|
||||
multiprecision_add_mod(x_x_q, x_q, curve_p256.b, KEY_LENGTH_DWORDS_P256);
|
||||
/* compare the y_y_q and x_x_q, see if they are on a given elliptic curve. */
|
||||
if (multiprecision_compare(y_y_q, x_x_q, KEY_LENGTH_DWORDS_P256)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "btm_int.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "smp_int.h"
|
||||
#include "p_256_ecc_pp.h"
|
||||
//#include "utils/include/bt_utils.h"
|
||||
|
||||
#if SMP_INCLUDED == TRUE
|
||||
@@ -668,6 +669,12 @@ void smp_process_pairing_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
|
||||
STREAM_TO_ARRAY(p_cb->peer_publ_key.x, p, BT_OCTET32_LEN);
|
||||
STREAM_TO_ARRAY(p_cb->peer_publ_key.y, p, BT_OCTET32_LEN);
|
||||
/* In order to prevent the x and y coordinates of the public key from being modified,
|
||||
we need to check whether the x and y coordinates are on the given elliptic curve. */
|
||||
if (!ECC_CheckPointIsInElliCur_P256((Point *)&p_cb->peer_publ_key)) {
|
||||
SMP_TRACE_ERROR("%s, Invalid Public key.", __func__);
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
|
||||
}
|
||||
p_cb->flags |= SMP_PAIR_FLAG_HAVE_PEER_PUBL_KEY;
|
||||
|
||||
smp_wait_for_both_public_keys(p_cb, NULL);
|
||||
@@ -1831,7 +1838,7 @@ void smp_set_local_oob_random_commitment(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable)
|
||||
{
|
||||
tSMP_CB *p_cb = &smp_cb;
|
||||
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
|
||||
SMP_TRACE_DEBUG("%s encr_enable=%d\n", __func__, encr_enable);
|
||||
|
||||
if (memcmp(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN) == 0) {
|
||||
@@ -1842,6 +1849,18 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable)
|
||||
btm_ble_update_sec_key_size(bda, p_cb->loc_enc_size);
|
||||
}
|
||||
|
||||
smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable);
|
||||
}
|
||||
else if(p_dev_rec && !p_dev_rec->enc_init_by_we){
|
||||
|
||||
/*
|
||||
if enc_init_by_we is false, it means that client initiates encryption before slave calls esp_ble_set_encryption()
|
||||
we need initiate pairing_bda and p_cb->role then encryption, for example iPhones
|
||||
*/
|
||||
memcpy(&smp_cb.pairing_bda[0], bda, BD_ADDR_LEN);
|
||||
p_cb->state = SMP_STATE_ENCRYPTION_PENDING;
|
||||
p_cb->role = HCI_ROLE_SLAVE;
|
||||
p_dev_rec->enc_init_by_we = FALSE;
|
||||
smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,10 @@ static void smp_connect_callback (UINT16 channel, BD_ADDR bd_addr, BOOLEAN conne
|
||||
if (transport == BT_TRANSPORT_BR_EDR || memcmp(bd_addr, dummy_bda, BD_ADDR_LEN) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!connected && &p_cb->rsp_timer_ent) {
|
||||
//free timer
|
||||
btu_free_timer(&p_cb->rsp_timer_ent);
|
||||
}
|
||||
if (memcmp(bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) == 0) {
|
||||
SMP_TRACE_EVENT ("%s() for pairing BDA: %08x%04x Event: %s\n",
|
||||
__FUNCTION__,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user