forked from espressif/esp-idf
Compare commits
308 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a322e6bdad | ||
|
|
99daa62628 | ||
|
|
112488fbcf | ||
|
|
7ec8266e77 | ||
|
|
194b616c36 | ||
|
|
4f6cca6f08 | ||
|
|
d005e71acd | ||
|
|
a328e1a08f | ||
|
|
e573b7cee1 | ||
|
|
8e1cd38970 | ||
|
|
2fc023ef95 | ||
|
|
20a3c78034 | ||
|
|
383a1e8697 | ||
|
|
3f730f2453 | ||
|
|
1aca617c33 | ||
|
|
faf0de3b55 | ||
|
|
8a6c2fe68f | ||
|
|
27e3d41026 | ||
|
|
b3a73d5b63 | ||
|
|
77f5391037 | ||
|
|
9dcc8c9e7d | ||
|
|
aa7d73c8a4 | ||
|
|
12ae1c19d2 | ||
|
|
95b5f1290e | ||
|
|
b0fc0210df | ||
|
|
2d03df48b0 | ||
|
|
56c7df9fbd | ||
|
|
1cd164b8fa | ||
|
|
527ce5eb3b | ||
|
|
4bf00b2ce2 | ||
|
|
5b6fbea041 | ||
|
|
7560b70244 | ||
|
|
fdd1f41836 | ||
|
|
61db22a55a | ||
|
|
e6d7705a67 | ||
|
|
a707ab946f | ||
|
|
fdc6099961 | ||
|
|
34ec96ef23 | ||
|
|
923546b103 | ||
|
|
25290a6c67 | ||
|
|
6e7029016f | ||
|
|
001b8ff92d | ||
|
|
db3aa57a9b | ||
|
|
03da41e7d7 | ||
|
|
fac5596767 | ||
|
|
d786f187e9 | ||
|
|
821185d6ec | ||
|
|
9feab17051 | ||
|
|
b5a2054070 | ||
|
|
aa21e87cd9 | ||
|
|
4df78f9cff | ||
|
|
63ba58e9a8 | ||
|
|
715ee3576e | ||
|
|
3e6adac5bf | ||
|
|
8d6167a9ab | ||
|
|
4df9fa5b50 | ||
|
|
d0afffe8c9 | ||
|
|
ffd01bf73b | ||
|
|
fb9db0b7ea | ||
|
|
4a3f224fe1 | ||
|
|
2e1e17524e | ||
|
|
94ef39472b | ||
|
|
0c8b9f75f4 | ||
|
|
c5759b6d2b | ||
|
|
b69ac0fb27 | ||
|
|
84e44e230b | ||
|
|
c05940a0fb | ||
|
|
7e9a9b35ea | ||
|
|
8a0132aacf | ||
|
|
62dbf69c0a | ||
|
|
7a9b686174 | ||
|
|
f1561c6bc9 | ||
|
|
3c7c5829b7 | ||
|
|
4eaefbab43 | ||
|
|
da6412b216 | ||
|
|
683ec8053d | ||
|
|
bab0fa8a03 | ||
|
|
546e9e0b6e | ||
|
|
7e9fdf598e | ||
|
|
7fafe4a9f4 | ||
|
|
98cbd1fd72 | ||
|
|
08a50af080 | ||
|
|
b2cdc06789 | ||
|
|
dbbe2cf173 | ||
|
|
cb270eebd6 | ||
|
|
7801d5bad0 | ||
|
|
5cb1e9f6f4 | ||
|
|
a3ba6b299d | ||
|
|
768bd4750d | ||
|
|
6b1413c3e9 | ||
|
|
1156370c00 | ||
|
|
fff9980a5b | ||
|
|
cb04df5ddf | ||
|
|
a64744883d | ||
|
|
3a9bf62ed6 | ||
|
|
bec90ce050 | ||
|
|
c923dd4df4 | ||
|
|
1085fece61 | ||
|
|
fdd3f2d734 | ||
|
|
51bc01b557 | ||
|
|
dfb75ff2ac | ||
|
|
f978fc10c0 | ||
|
|
4184b48aa8 | ||
|
|
06cca86017 | ||
|
|
4ddb253788 | ||
|
|
936bba8073 | ||
|
|
0e95c6cd60 | ||
|
|
4d65903602 | ||
|
|
d9de786520 | ||
|
|
e0944287f3 | ||
|
|
471fe41828 | ||
|
|
b07a43e630 | ||
|
|
50b3a35c52 | ||
|
|
86fb02efa4 | ||
|
|
f57ef07e14 | ||
|
|
2f6e45c79b | ||
|
|
f0219b73f9 | ||
|
|
f2ede42191 | ||
|
|
c1f0823795 | ||
|
|
d08b90c5cc | ||
|
|
bf9706dc31 | ||
|
|
3964fb2d04 | ||
|
|
1e2c271bd0 | ||
|
|
0ce4aa114e | ||
|
|
1c2a6712e3 | ||
|
|
d4dd0d4201 | ||
|
|
7ab43c0fbd | ||
|
|
3d8fd79a10 | ||
|
|
d9561b8fc7 | ||
|
|
bc3dcdfc0d | ||
|
|
012506114e | ||
|
|
e23a61a47a | ||
|
|
c0f48a19fc | ||
|
|
7d6f5fa71d | ||
|
|
16acdf1bbb | ||
|
|
e16882f0cd | ||
|
|
7e6e769aed | ||
|
|
8ab1027fee | ||
|
|
65d127da88 | ||
|
|
e8548e7a1a | ||
|
|
6bfe219bb1 | ||
|
|
be718f6849 | ||
|
|
4f5c87a294 | ||
|
|
5a557bb595 | ||
|
|
bc7ef70189 | ||
|
|
2b084b1f6b | ||
|
|
4bd5fa28b4 | ||
|
|
b7c3f01ac8 | ||
|
|
d9de61cbad | ||
|
|
8d2c1a6265 | ||
|
|
eeed231304 | ||
|
|
2cd8335818 | ||
|
|
9e9ff8f17c | ||
|
|
ab9ee3002f | ||
|
|
6b590a7ae2 | ||
|
|
7ab6811a39 | ||
|
|
2193e441c2 | ||
|
|
2719ecbec4 | ||
|
|
202c60bf6b | ||
|
|
04ce3affe9 | ||
|
|
0d3486b07d | ||
|
|
e8d7ecaec8 | ||
|
|
6717fa0304 | ||
|
|
97d87072fc | ||
|
|
81dc597d1f | ||
|
|
cc60b86324 | ||
|
|
c647b3fddb | ||
|
|
0810501755 | ||
|
|
a65db35c13 | ||
|
|
9875bee9d8 | ||
|
|
eae7bba46f | ||
|
|
df558f4f39 | ||
|
|
18d0413087 | ||
|
|
715df99f8c | ||
|
|
9961629d58 | ||
|
|
de6aecf2ab | ||
|
|
48e3103c8c | ||
|
|
2c0d846eaf | ||
|
|
709d8ef685 | ||
|
|
47b7e61dc3 | ||
|
|
6b6ca2d1ca | ||
|
|
0d48a7cda4 | ||
|
|
228c9a7538 | ||
|
|
b79cfdfb7d | ||
|
|
3de398b8c4 | ||
|
|
e368a7ab69 | ||
|
|
9e984cd49e | ||
|
|
ee4fdf8447 | ||
|
|
406e11bea2 | ||
|
|
93ea06fe3e | ||
|
|
6ce28ee59b | ||
|
|
8b08d11e4f | ||
|
|
c1efc55584 | ||
|
|
99552ebd15 | ||
|
|
b43aa0404a | ||
|
|
600bd44c72 | ||
|
|
8b1c532754 | ||
|
|
1181f59158 | ||
|
|
5862b981ed | ||
|
|
38f13b15d3 | ||
|
|
71932c99fc | ||
|
|
2d36710ca1 | ||
|
|
d7f19c4a37 | ||
|
|
585f9a0fc0 | ||
|
|
3549a154b0 | ||
|
|
4beadd4c57 | ||
|
|
51d2f67f02 | ||
|
|
1bd76ee0da | ||
|
|
360ecf5613 | ||
|
|
cc2db3d190 | ||
|
|
4c95aa445d | ||
|
|
79d34bf5d5 | ||
|
|
6f15d6cb1f | ||
|
|
8fbc34a356 | ||
|
|
aeb4711393 | ||
|
|
8a6fe49314 | ||
|
|
80be245982 | ||
|
|
72a8b4e6e8 | ||
|
|
ecedff9884 | ||
|
|
b2dcd46063 | ||
|
|
cc649ea869 | ||
|
|
e10cbd108b | ||
|
|
b8139a609b | ||
|
|
af72c4b94f | ||
|
|
5c30cc24fd | ||
|
|
c924e0cfe4 | ||
|
|
68d2915377 | ||
|
|
7d358754a2 | ||
|
|
024bccbc58 | ||
|
|
fc8d80dfab | ||
|
|
7af929f825 | ||
|
|
d0e94733f0 | ||
|
|
861318b138 | ||
|
|
e0355cd6a8 | ||
|
|
d4db16058d | ||
|
|
ab8ab03537 | ||
|
|
03fb722ca5 | ||
|
|
5ad9e6b87f | ||
|
|
0a0aaa23e0 | ||
|
|
028f174467 | ||
|
|
ed4bf92b8e | ||
|
|
a05e40bfe3 | ||
|
|
dc0f41f7be | ||
|
|
49eab1da5c | ||
|
|
9e472f582b | ||
|
|
e173895618 | ||
|
|
302661ed5f | ||
|
|
7598f31cdd | ||
|
|
d900eed440 | ||
|
|
054f33b386 | ||
|
|
66d7410051 | ||
|
|
f90e5e04e0 | ||
|
|
cc254d8ff3 | ||
|
|
62b84e3169 | ||
|
|
29e1ca5ddd | ||
|
|
5ed6abc5e2 | ||
|
|
9b2e0a2a01 | ||
|
|
217ed6c1bf | ||
|
|
48abf362c0 | ||
|
|
14bb24c3ab | ||
|
|
4ecc978bd6 | ||
|
|
9373d53ce7 | ||
|
|
64b1bd6cb2 | ||
|
|
bc6072c754 | ||
|
|
fdcd6783d7 | ||
|
|
410db7f812 | ||
|
|
de5644f88c | ||
|
|
f096b66d71 | ||
|
|
7503cf2176 | ||
|
|
2b2a838518 | ||
|
|
59d25c4d62 | ||
|
|
1d283490d3 | ||
|
|
306ea38038 | ||
|
|
afe5afd1ba | ||
|
|
6e31efce7f | ||
|
|
9048372138 | ||
|
|
c6a2bdbfa1 | ||
|
|
cf2c7a433d | ||
|
|
5ad9e404dc | ||
|
|
24b3a4ee45 | ||
|
|
47cd6cd23c | ||
|
|
773845be66 | ||
|
|
55f2d9c1ec | ||
|
|
eebdd3f391 | ||
|
|
4573271d2b | ||
|
|
414306bd37 | ||
|
|
8e5347abd5 | ||
|
|
23e9daa239 | ||
|
|
481b63fa6d | ||
|
|
0a2199d81b | ||
|
|
58dd50120f | ||
|
|
871476ad8a | ||
|
|
c784a6915b | ||
|
|
38499caa35 | ||
|
|
33a62c86d3 | ||
|
|
a6a15ad9a4 | ||
|
|
60a9527a71 | ||
|
|
595d8b512f | ||
|
|
65bc495632 | ||
|
|
713546e8bd | ||
|
|
586862e9b2 | ||
|
|
490df3a348 | ||
|
|
9b40d39120 | ||
|
|
71cd4df75a | ||
|
|
42277ac868 | ||
|
|
b5cfc9400c | ||
|
|
a82879367a | ||
|
|
d554768528 |
@@ -516,10 +516,10 @@ build_clang_test_apps_esp32c6:
|
||||
script:
|
||||
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
|
||||
- cd ${IDF_PATH}/tools/test_build_system
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python ${IDF_PATH}/tools/ci/get_known_failure_cases_file.py
|
||||
- pytest --parallel-count ${CI_NODE_TOTAL:-1} --parallel-index ${CI_NODE_INDEX:-1}
|
||||
--work-dir ${CI_PROJECT_DIR}/test_build_system --junitxml=${CI_PROJECT_DIR}/XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
|
||||
pytest_build_system:
|
||||
extends: .test_build_system_template
|
||||
|
||||
@@ -20,8 +20,14 @@ variables:
|
||||
MAKEFLAGS: "-j5 --no-keep-going"
|
||||
|
||||
# GitLab-CI environment
|
||||
|
||||
# now we have pack-objects cache, so clone strategy is faster than fetch
|
||||
# Thanks to pack-objects cache, clone strategy should behave faster than fetch
|
||||
# so we pick "clone" as default git strategy
|
||||
# Shiny runners by default remove the CI_PROJECT_DIR every time at the beginning of one job
|
||||
# and clone with a --depth=1
|
||||
# Brew runners will fetch from locally mirror first, and cache the local CI_PROJECT_DIR
|
||||
# In conclusion
|
||||
# - set GIT_STRATEGY: "clone" to shiny runners
|
||||
# - set GIT_STRATEGY: "fetch" to brew runners
|
||||
GIT_STRATEGY: clone
|
||||
# we will download archive for each submodule instead of clone.
|
||||
# we don't do "recursive" when fetch submodule as they're not used in CI now.
|
||||
@@ -33,7 +39,7 @@ variables:
|
||||
GIT_FETCH_EXTRA_FLAGS: "--no-recurse-submodules --prune --prune-tags"
|
||||
# we're using .cache folder for caches
|
||||
GIT_CLEAN_FLAGS: -ffdx -e .cache/
|
||||
LATEST_GIT_TAG: v5.2-dev
|
||||
LATEST_GIT_TAG: v5.2.1
|
||||
|
||||
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
|
||||
# by default we will fetch all submodules
|
||||
@@ -80,6 +86,9 @@ variables:
|
||||
# This is used only if CI_PYTHON_TOOL_REPO is not empty.
|
||||
CI_PYTHON_TOOL_BRANCH: ""
|
||||
|
||||
# Set this variable to specify the file name for the known failure cases.
|
||||
KNOWN_FAILURE_CASES_FILE_NAME: "5.2.txt"
|
||||
|
||||
IDF_CI_BUILD: 1
|
||||
|
||||
################################################
|
||||
@@ -288,22 +297,6 @@ variables:
|
||||
- *setup_tools_and_idf_python_venv
|
||||
- add_gitlab_ssh_keys
|
||||
|
||||
# git describe requires commit history until the latest tag
|
||||
.before_script:fetch:git_describe:
|
||||
variables:
|
||||
GIT_STRAEGY: none
|
||||
before_script:
|
||||
- *git_init
|
||||
- *git_fetch_from_mirror_url_if_exists
|
||||
- |
|
||||
git fetch origin refs/tags/"${LATEST_GIT_TAG}":refs/tags/"${LATEST_GIT_TAG}" --depth=1
|
||||
git repack -d
|
||||
git fetch origin $CI_COMMIT_SHA --shallow-since=$(git log -1 --format=%as "${LATEST_GIT_TAG}")
|
||||
- *git_checkout_fetch_head
|
||||
- *common-before_scripts
|
||||
- *setup_tools_and_idf_python_venv
|
||||
- add_gitlab_ssh_keys
|
||||
|
||||
# target test runners may locate in different places
|
||||
# for runners set git mirror, we fetch from the mirror first, then fetch the HEAD commit
|
||||
.before_script:fetch:target_test:
|
||||
|
||||
@@ -93,6 +93,7 @@ check_docs_lang_sync:
|
||||
tags:
|
||||
- build_docs
|
||||
script:
|
||||
- if [ -n "${BREATHE_ALT_INSTALL_URL}" ]; then pip uninstall -y breathe && pip install -U ${BREATHE_ALT_INSTALL_URL}; fi
|
||||
- cd docs
|
||||
- build-docs -t $DOCTGT -bs $DOC_BUILDERS -l $DOCLANG build
|
||||
parallel:
|
||||
|
||||
@@ -307,13 +307,13 @@ test_pytest_qemu:
|
||||
--collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
|
||||
--modified-components ${MODIFIED_COMPONENTS}
|
||||
--modified-files ${MODIFIED_FILES}
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python tools/ci/get_known_failure_cases_file.py
|
||||
- run_cmd pytest
|
||||
--target $IDF_TARGET
|
||||
-m qemu
|
||||
--embedded-services idf,qemu
|
||||
--junitxml=XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
--app-info-filepattern \"list_job_*.txt\"
|
||||
|
||||
test_pytest_linux:
|
||||
@@ -337,10 +337,10 @@ test_pytest_linux:
|
||||
--collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
|
||||
--modified-components ${MODIFIED_COMPONENTS}
|
||||
--modified-files ${MODIFIED_FILES}
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python tools/ci/get_known_failure_cases_file.py
|
||||
- run_cmd pytest
|
||||
--target linux
|
||||
-m host_test
|
||||
--junitxml=XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
--app-info-filepattern \"list_job_*.txt\"
|
||||
|
||||
@@ -15,6 +15,7 @@ check_pre_commit:
|
||||
script:
|
||||
- fetch_submodules
|
||||
- pre-commit run --files $MODIFIED_FILES
|
||||
- pre-commit run --hook-stage post-commit validate-sbom-manifest
|
||||
|
||||
check_MR_style_dangerjs:
|
||||
extends:
|
||||
@@ -49,7 +50,13 @@ check_version:
|
||||
extends:
|
||||
- .pre_check_template
|
||||
- .rules:protected
|
||||
- .before_script:fetch:git_describe
|
||||
tags: [ brew, github_sync ]
|
||||
variables:
|
||||
# need a full clone to get the latest tag
|
||||
# the --shallow-since=$(git log -1 --format=%as $LATEST_GIT_TAG) option is not accurate
|
||||
GIT_STRATEGY: fetch
|
||||
SUBMODULES_TO_FETCH: "none"
|
||||
GIT_DEPTH: 0
|
||||
script:
|
||||
- export IDF_PATH=$PWD
|
||||
- tools/ci/check_idf_version.sh
|
||||
@@ -143,7 +150,13 @@ check_version_tag:
|
||||
extends:
|
||||
- .pre_check_template
|
||||
- .rules:tag:release
|
||||
- .before_script:fetch:git_describe
|
||||
tags: [ brew, github_sync ]
|
||||
variables:
|
||||
# need a full clone to get the latest tag
|
||||
# the --shallow-since=$(git log -1 --format=%as $LATEST_GIT_TAG) option is not accurate
|
||||
GIT_STRATEGY: fetch
|
||||
SUBMODULES_TO_FETCH: "none"
|
||||
GIT_DEPTH: 0
|
||||
script:
|
||||
- (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || (echo "ESP-IDF versions must be annotated tags." && exit 1)
|
||||
|
||||
|
||||
@@ -182,7 +182,6 @@
|
||||
- "components/esp_phy/lib"
|
||||
- "components/esp_wifi/lib"
|
||||
- "components/esp_coex/lib"
|
||||
- "components/ieee802154/lib"
|
||||
- "components/json/cJSON"
|
||||
- "components/lwip/lwip"
|
||||
- "components/mbedtls/mbedtls"
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
junit: XUNIT_RESULT.xml
|
||||
expire_in: 1 week
|
||||
script:
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python tools/ci/get_known_failure_cases_file.py
|
||||
# get runner env config file
|
||||
- retry_failed git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
@@ -46,7 +46,7 @@
|
||||
- run_cmd pytest $TEST_DIR
|
||||
-m \"${markers}\"
|
||||
--junitxml=XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
--parallel-count ${CI_NODE_TOTAL:-1}
|
||||
--parallel-index ${CI_NODE_INDEX:-1}
|
||||
${PYTEST_EXTRA_FLAGS}
|
||||
@@ -463,6 +463,15 @@ pytest_examples_esp32_ethernet_vlan:
|
||||
artifacts: false
|
||||
tags: [ esp32, ethernet_vlan ]
|
||||
|
||||
pytest_examples_esp32_ethernet_ip101:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32
|
||||
needs:
|
||||
- job: build_pytest_examples_esp32
|
||||
artifacts: false
|
||||
tags: [ esp32, eth_ip101 ]
|
||||
|
||||
pytest_examples_esp32_ethernet_bridge:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
@@ -715,6 +724,15 @@ pytest_components_esp32_sdio:
|
||||
artifacts: false
|
||||
tags: [ esp32, sdio_master_slave ]
|
||||
|
||||
pytest_components_esp32_ip101:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
- .rules:test:component_ut-esp32
|
||||
needs:
|
||||
- job: build_pytest_components_esp32
|
||||
artifacts: false
|
||||
tags: [ esp32, eth_ip101 ]
|
||||
|
||||
pytest_components_esp32_lan8720:
|
||||
extends:
|
||||
- .pytest_components_dir_template
|
||||
@@ -1261,7 +1279,7 @@ pytest_examples_openthread_br:
|
||||
artifacts: false
|
||||
tags: [ esp32c6, openthread_br ]
|
||||
script:
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python tools/ci/get_known_failure_cases_file.py
|
||||
# get runner env config file
|
||||
- retry_failed git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
@@ -1276,7 +1294,7 @@ pytest_examples_openthread_br:
|
||||
- run_cmd pytest $TEST_DIR
|
||||
-m \"${markers}\"
|
||||
--junitxml=XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
--parallel-count ${CI_NODE_TOTAL:-1}
|
||||
--parallel-index ${CI_NODE_INDEX:-1}
|
||||
${PYTEST_EXTRA_FLAGS}
|
||||
@@ -1295,7 +1313,7 @@ pytest_examples_openthread_bbr:
|
||||
artifacts: false
|
||||
tags: [ esp32c6, openthread_bbr ]
|
||||
script:
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python tools/ci/get_known_failure_cases_file.py
|
||||
# get runner env config file
|
||||
- retry_failed git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
@@ -1310,7 +1328,7 @@ pytest_examples_openthread_bbr:
|
||||
- run_cmd pytest $TEST_DIR
|
||||
-m \"${markers}\"
|
||||
--junitxml=XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
--parallel-count ${CI_NODE_TOTAL:-1}
|
||||
--parallel-index ${CI_NODE_INDEX:-1}
|
||||
${PYTEST_EXTRA_FLAGS}
|
||||
@@ -1327,7 +1345,7 @@ pytest_examples_openthread_sleep:
|
||||
artifacts: false
|
||||
tags: [ esp32c6, openthread_sleep ]
|
||||
script:
|
||||
- retry_failed git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
- python tools/ci/get_known_failure_cases_file.py
|
||||
# get runner env config file
|
||||
- retry_failed git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
@@ -1341,7 +1359,7 @@ pytest_examples_openthread_sleep:
|
||||
- run_cmd pytest $TEST_DIR
|
||||
-m \"${markers}\"
|
||||
--junitxml=XUNIT_RESULT.xml
|
||||
--ignore-result-files known_failure_cases/known_failure_cases.txt
|
||||
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
|
||||
--parallel-count ${CI_NODE_TOTAL:-1}
|
||||
--parallel-index ${CI_NODE_INDEX:-1}
|
||||
${PYTEST_EXTRA_FLAGS}
|
||||
|
||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -120,10 +120,6 @@
|
||||
path = components/openthread/lib
|
||||
url = ../../espressif/esp-thread-lib.git
|
||||
|
||||
[submodule "components/ieee802154/lib"]
|
||||
path = components/ieee802154/lib
|
||||
url = ../../espressif/esp-ieee802154-lib.git
|
||||
|
||||
[submodule "components/bt/controller/lib_esp32h2/esp32h2-bt-lib"]
|
||||
path = components/bt/controller/lib_esp32h2/esp32h2-bt-lib
|
||||
url = ../../espressif/esp32h2-bt-lib.git
|
||||
|
||||
@@ -41,11 +41,12 @@ repos:
|
||||
hooks:
|
||||
- id: flake8
|
||||
args: ['--config=.flake8', '--tee', '--benchmark']
|
||||
- repo: https://github.com/pycqa/isort
|
||||
rev: 5.12.0 # python 3.8 compatible
|
||||
- repo: https://github.com/asottile/reorder-python-imports
|
||||
rev: v3.12.0
|
||||
hooks:
|
||||
- id: isort
|
||||
name: isort (python)
|
||||
- id: reorder-python-imports
|
||||
name: Reorder Python imports
|
||||
args: [--py38-plus]
|
||||
exclude: >
|
||||
(?x)^(
|
||||
.*_pb2.py
|
||||
@@ -69,7 +70,7 @@ repos:
|
||||
entry: tools/ci/check_kconfigs.py
|
||||
language: python
|
||||
additional_dependencies:
|
||||
- esp-idf-kconfig
|
||||
- esp-idf-kconfig>=1.4.2,<2.0.0
|
||||
files: '^Kconfig$|Kconfig.*$'
|
||||
- id: check-deprecated-kconfigs-options
|
||||
name: Check if any Kconfig Options Deprecated
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(app_update_test)
|
||||
|
||||
@@ -23,7 +23,6 @@ menu "Bootloader config"
|
||||
- The default "Size" setting will add the -0s flag to CFLAGS.
|
||||
- The "Debug" setting will add the -Og flag to CFLAGS.
|
||||
- The "Performance" setting will add the -O2 flag to CFLAGS.
|
||||
- The "None" setting will add the -O0 flag to CFLAGS.
|
||||
|
||||
Note that custom optimization levels may be unsupported.
|
||||
|
||||
@@ -34,7 +33,9 @@ menu "Bootloader config"
|
||||
config BOOTLOADER_COMPILER_OPTIMIZATION_PERF
|
||||
bool "Optimize for performance (-O2)"
|
||||
config BOOTLOADER_COMPILER_OPTIMIZATION_NONE
|
||||
bool "Debug without optimization (-O0)"
|
||||
bool "Debug without optimization (-O0) (Deprecated, will be removed in IDF v6.0)"
|
||||
depends on IDF_TARGET_ARCH_XTENSA || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||
|
||||
endchoice
|
||||
|
||||
choice BOOTLOADER_LOG_LEVEL
|
||||
@@ -458,6 +459,21 @@ menu "Bootloader config"
|
||||
(The application and bootoloader must be compiled with the same option).
|
||||
The RTC FAST memory has access only through PRO_CPU.
|
||||
|
||||
config BOOTLOADER_CUSTOM_RESERVE_RTC_IN_CRC
|
||||
bool "Include custom memory in the CRC calculation"
|
||||
depends on BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||
default n
|
||||
help
|
||||
This option allows the customer to use the legacy bootloader behavior when the
|
||||
RTC FAST memory CRC calculation takes place. When this option is enabled, the
|
||||
allocated user custom data will be taken into account in the CRC calculcation.
|
||||
This means that any change to the custom data would need a CRC update to prevent
|
||||
the bootloader from marking this data as corrupted.
|
||||
If this option is disabled, the custom data will not be taken into account when
|
||||
calculating the RTC FAST memory CRC. The user custom data can be changed freely,
|
||||
without the need to update the CRC.
|
||||
THIS OPTION MUST BE THE SAME FOR BOTH THE BOOTLOADER AND THE APPLICATION BUILDS.
|
||||
|
||||
config BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE
|
||||
hex "Size in bytes for custom purposes"
|
||||
default 0
|
||||
@@ -1071,6 +1087,22 @@ menu "Security features"
|
||||
DIS_DOWNLOAD_MANUAL_ENCRYPT, DIS_USB_JTAG, DIS_USB_SERIAL_JTAG, STRAP_JTAG_SEL, USB_PHY_SEL.
|
||||
endmenu # Potentially Insecure
|
||||
|
||||
config SECURE_FLASH_ENCRYPT_ONLY_IMAGE_LEN_IN_APP_PART
|
||||
bool "Encrypt only the app image that is present in the partition of type app"
|
||||
depends on SECURE_FLASH_ENC_ENABLED && !SECURE_FLASH_REQUIRE_ALREADY_ENABLED
|
||||
default n
|
||||
help
|
||||
If set, optimise encryption time for the partition of type APP,
|
||||
by only encrypting the app image that is present in the partition,
|
||||
instead of the whole partition.
|
||||
The image length used for encryption is derived from the image metadata, which
|
||||
includes the size of the app image, checksum, hash and also the signature sector
|
||||
when secure boot is enabled.
|
||||
|
||||
If not set (default), the whole partition of type APP would be encrypted,
|
||||
which increases the encryption time but might be useful if there
|
||||
is any custom data appended to the firmware image.
|
||||
|
||||
config SECURE_FLASH_CHECK_ENC_EN_IN_APP
|
||||
bool "Check Flash Encryption enabled on app startup"
|
||||
depends on SECURE_FLASH_ENC_ENABLED
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef struct {
|
||||
uint32_t segment_data[ESP_IMAGE_MAX_SEGMENTS]; /* Data offsets for each segment */
|
||||
uint32_t image_len; /* Length of image on flash, in bytes */
|
||||
uint8_t image_digest[32]; /* appended SHA-256 digest */
|
||||
uint32_t secure_version; /* secure version for anti-rollback, it is covered by sha256 (set if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK=y) */
|
||||
} esp_image_metadata_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -121,7 +121,7 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
#if CONFIG_BOOTLOADER_RESERVE_RTC_MEM
|
||||
|
||||
static uint32_t rtc_retain_mem_size(void) {
|
||||
#ifdef CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC
|
||||
#if CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC && !CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC_IN_CRC
|
||||
/* A custom memory has been reserved by the user, do not consider this memory into CRC calculation as it may change without
|
||||
* the have the user updating the CRC. Return the offset of the custom field, which is equivalent to size of the structure
|
||||
* minus the size of everything after (including) `custom` */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "esp32s2/rom/usb/usb_common.h"
|
||||
#endif
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
#include "hal/usb_phy_ll.h"
|
||||
#include "hal/usb_fsls_phy_ll.h"
|
||||
#endif
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "esp_rom_uart.h"
|
||||
@@ -106,8 +106,8 @@ void bootloader_console_init(void)
|
||||
esp_rom_uart_set_as_console(ESP_ROM_USB_OTG_NUM);
|
||||
esp_rom_install_channel_putc(1, bootloader_console_write_char_usb);
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED
|
||||
usb_phy_ll_usb_wrap_pad_enable(&USB_WRAP, true);
|
||||
usb_phy_ll_int_otg_enable(&USB_WRAP);
|
||||
usb_fsls_phy_ll_usb_wrap_pad_enable(&USB_WRAP, true);
|
||||
usb_fsls_phy_ll_int_otg_enable(&USB_WRAP);
|
||||
#endif
|
||||
}
|
||||
#endif //CONFIG_ESP_CONSOLE_USB_CDC
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "bootloader_util.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_app_desc.h"
|
||||
#include "bootloader_memory_utils.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/cache_ll.h"
|
||||
@@ -89,10 +91,10 @@ static bool should_map(uint32_t load_addr);
|
||||
|
||||
static esp_err_t process_segments(esp_image_metadata_t *data, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum);
|
||||
/* Load or verify a segment */
|
||||
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum);
|
||||
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum, esp_image_metadata_t *metadata);
|
||||
|
||||
/* split segment and verify if data_len is too long */
|
||||
static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum);
|
||||
static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum, esp_image_metadata_t *metadata);
|
||||
|
||||
/* Verify the main image header */
|
||||
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent);
|
||||
@@ -240,6 +242,21 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
|
||||
cache_ll_writeback_all(CACHE_LL_LEVEL_INT_MEM, CACHE_TYPE_DATA, CACHE_LL_ID_ALL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
|
||||
/* For anti-rollback case, reconfirm security version of the application to prevent FI attacks */
|
||||
bool sec_ver = false;
|
||||
if (do_load) {
|
||||
sec_ver = esp_efuse_check_secure_version(data->secure_version);
|
||||
if (!sec_ver) {
|
||||
err = ESP_FAIL;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
/* Ensure that the security version check passes for image loading scenario */
|
||||
ESP_FAULT_ASSERT(!do_load || sec_ver == true);
|
||||
#endif // CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
|
||||
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
// Success!
|
||||
@@ -522,7 +539,7 @@ static esp_err_t process_segments(esp_image_metadata_t *data, bool silent, bool
|
||||
for (int i = 0; i < data->image.segment_count; i++) {
|
||||
esp_image_segment_header_t *header = &data->segments[i];
|
||||
ESP_LOGV(TAG, "loading segment header %d at offset 0x%"PRIx32, i, next_addr);
|
||||
CHECK_ERR(process_segment(i, next_addr, header, silent, do_load, sha_handle, checksum));
|
||||
CHECK_ERR(process_segment(i, next_addr, header, silent, do_load, sha_handle, checksum, data));
|
||||
next_addr += sizeof(esp_image_segment_header_t);
|
||||
data->segment_data[i] = next_addr;
|
||||
next_addr += header->data_len;
|
||||
@@ -543,7 +560,7 @@ err:
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
|
||||
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum, esp_image_metadata_t *metadata)
|
||||
{
|
||||
esp_err_t err;
|
||||
|
||||
@@ -601,7 +618,7 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
||||
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
|
||||
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
|
||||
data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
|
||||
CHECK_ERR(process_segment_data(load_addr, data_addr, data_len, do_load, sha_handle, checksum));
|
||||
CHECK_ERR(process_segment_data(index, load_addr, data_addr, data_len, do_load, sha_handle, checksum, metadata));
|
||||
data_addr += data_len;
|
||||
data_len_remain -= data_len;
|
||||
}
|
||||
@@ -616,7 +633,42 @@ err:
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
|
||||
#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
|
||||
/* The __attribute__((optimize("O0"))) is used to disable optimizations for this function,
|
||||
* preventing the compiler from potentially optimizing data_buffer and reading data directly from src.
|
||||
* This is crucial as we want to read from Flash only once, ensuring the integrity of the data.
|
||||
*/
|
||||
__attribute__((optimize("O0")))
|
||||
static size_t process_esp_app_desc_data(const uint32_t *src, bootloader_sha256_handle_t sha_handle, uint32_t *checksum, esp_image_metadata_t *metadata)
|
||||
{
|
||||
/* Using data_buffer here helps to securely read secure_version
|
||||
* (for anti-rollback) from esp_app_desc_t, preventing FI attack.
|
||||
* We read data from Flash into this buffer, which is covered by sha256.
|
||||
* Therefore, if the flash is under attackers control and contents are modified
|
||||
* the sha256 comparison will fail.
|
||||
*
|
||||
* The esp_app_desc_t structure is located in DROM and is always in segment #0.
|
||||
*
|
||||
* esp_app_desc_t is always at #0 segment (index==0).
|
||||
* secure_version field of esp_app_desc_t is located at #2 word (w_i==1).
|
||||
*/
|
||||
uint32_t data_buffer[2];
|
||||
memcpy(data_buffer, src, sizeof(data_buffer));
|
||||
assert(data_buffer[0] == ESP_APP_DESC_MAGIC_WORD);
|
||||
metadata->secure_version = data_buffer[1];
|
||||
if (checksum != NULL) {
|
||||
*checksum ^= data_buffer[0] ^ data_buffer[1];
|
||||
}
|
||||
if (sha_handle != NULL) {
|
||||
bootloader_sha256_data(sha_handle, data_buffer, sizeof(data_buffer));
|
||||
}
|
||||
ESP_FAULT_ASSERT(memcmp(data_buffer, src, sizeof(data_buffer)) == 0);
|
||||
ESP_FAULT_ASSERT(memcmp(&metadata->secure_version, &src[1], sizeof(uint32_t)) == 0);
|
||||
return sizeof(data_buffer);
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
|
||||
|
||||
static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum, esp_image_metadata_t *metadata)
|
||||
{
|
||||
// If we are not loading, and the checksum is empty, skip processing this
|
||||
// segment for data
|
||||
@@ -649,10 +701,24 @@ static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, ui
|
||||
#endif
|
||||
}
|
||||
uint32_t *dest = (uint32_t *)load_addr;
|
||||
#endif
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
const uint32_t *src = data;
|
||||
|
||||
#if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
|
||||
// Case I: Bootloader verifying application
|
||||
// Case II: Bootloader verifying bootloader
|
||||
// Anti-rollback check should handle only Case I from above.
|
||||
if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
|
||||
ESP_LOGD(TAG, "additional anti-rollback check 0x%"PRIx32, data_addr);
|
||||
// The esp_app_desc_t structure is located in DROM and is always in segment #0.
|
||||
size_t len = process_esp_app_desc_data(src, sha_handle, checksum, metadata);
|
||||
data_len -= len;
|
||||
src += len / 4;
|
||||
// In BOOTLOADER_BUILD, for DROM (segment #0) we do not load it into dest (only map it), do_load = false.
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
|
||||
|
||||
for (size_t i = 0; i < data_len; i += 4) {
|
||||
int w_i = i / 4; // Word index
|
||||
uint32_t w = src[w_i];
|
||||
@@ -932,9 +998,13 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
|
||||
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME
|
||||
// Adjust image length result to include the appended signature
|
||||
#if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME
|
||||
data->image_len = end - data->start_addr + sizeof(ets_secure_boot_signature_t);
|
||||
#elif defined(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME)
|
||||
if (data->start_addr != ESP_BOOTLOADER_OFFSET) {
|
||||
data->image_len = end - data->start_addr + sizeof(esp_secure_boot_sig_block_t);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SECURE_BOOT_CHECK_SIGNATURE
|
||||
|
||||
@@ -393,14 +393,21 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
|
||||
{
|
||||
esp_err_t err;
|
||||
bool should_encrypt = (partition->flags & PART_FLAG_ENCRYPTED);
|
||||
uint32_t size = partition->pos.size;
|
||||
|
||||
if (partition->type == PART_TYPE_APP) {
|
||||
/* check if the partition holds a valid unencrypted app */
|
||||
esp_image_metadata_t data_ignored;
|
||||
esp_image_metadata_t image_data = {};
|
||||
err = esp_image_verify(ESP_IMAGE_VERIFY,
|
||||
&partition->pos,
|
||||
&data_ignored);
|
||||
&image_data);
|
||||
should_encrypt = (err == ESP_OK);
|
||||
#ifdef SECURE_FLASH_ENCRYPT_ONLY_IMAGE_LEN_IN_APP_PART
|
||||
if (should_encrypt) {
|
||||
// Encrypt only the app image instead of encrypting the whole partition
|
||||
size = image_data.image_len;
|
||||
}
|
||||
#endif
|
||||
} else if ((partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA)
|
||||
|| (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_NVS_KEYS)) {
|
||||
/* check if we have ota data partition and the partition should be encrypted unconditionally */
|
||||
@@ -411,9 +418,9 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
|
||||
return ESP_OK;
|
||||
} else {
|
||||
/* should_encrypt */
|
||||
ESP_LOGI(TAG, "Encrypting partition %d at offset 0x%x (length 0x%x)...", index, partition->pos.offset, partition->pos.size);
|
||||
ESP_LOGI(TAG, "Encrypting partition %d at offset 0x%x (length 0x%x)...", index, partition->pos.offset, size);
|
||||
|
||||
err = esp_flash_encrypt_region(partition->pos.offset, partition->pos.size);
|
||||
err = esp_flash_encrypt_region(partition->pos.offset, size);
|
||||
ESP_LOGI(TAG, "Done encrypting");
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to encrypt partition %d", index);
|
||||
|
||||
@@ -53,7 +53,9 @@ set(ble_mesh_include_dirs
|
||||
|
||||
set(bluedroid_include_dirs host/bluedroid/api/include/api)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_ENABLED OR CONFIG_IDF_DOC_BUILD)
|
||||
set(nimble_hci_include_dirs host/nimble/esp-hci/include)
|
||||
endif()
|
||||
|
||||
if(CONFIG_IDF_DOC_BUILD)
|
||||
list(APPEND include_dirs
|
||||
@@ -567,6 +569,11 @@ if(CONFIG_BT_ENABLED)
|
||||
"porting/nimble/src/os_msys_init.c"
|
||||
)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_DISABLED)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/hal_uart.c"
|
||||
)
|
||||
endif()
|
||||
list(APPEND include_dirs
|
||||
porting/include
|
||||
porting/nimble/include
|
||||
@@ -608,6 +615,7 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND include_dirs
|
||||
|
||||
host/nimble/nimble/nimble/host/include
|
||||
host/nimble/nimble/nimble/include
|
||||
host/nimble/nimble/nimble/host/services/ans/include
|
||||
host/nimble/nimble/nimble/host/services/bas/include
|
||||
host/nimble/nimble/nimble/host/services/dis/include
|
||||
@@ -693,11 +701,21 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c"
|
||||
"host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c"
|
||||
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_gattc_cache.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_gattc_cache_conn.c"
|
||||
)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_DISABLED AND CONFIG_BT_NIMBLE_TRANSPORT_UART)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/nimble/transport/uart_ll/src/hci_uart.c"
|
||||
"host/nimble/nimble/nimble/transport/common/hci_h4/src/hci_h4.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/nimble_port.c"
|
||||
"host/nimble/nimble/porting/npl/freertos/src/nimble_port_freertos.c"
|
||||
"host/nimble/port/src/nvs_port.c"
|
||||
)
|
||||
list(APPEND include_dirs
|
||||
porting/include
|
||||
@@ -706,6 +724,12 @@ if(CONFIG_BT_ENABLED)
|
||||
host/nimble/nimble/nimble/transport/include
|
||||
)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_DISABLED)
|
||||
list(APPEND include_dirs
|
||||
host/nimble/nimble/nimble/transport/common/hci_h4/include
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/endian.c"
|
||||
@@ -715,6 +739,13 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/porting/nimble/src/os_msys_init.c"
|
||||
"host/nimble/nimble/porting/npl/freertos/src/npl_os_freertos.c"
|
||||
)
|
||||
|
||||
if(CONFIG_BT_CONTROLLER_DISABLED AND CONFIG_BT_NIMBLE_TRANSPORT_UART)
|
||||
list(APPEND srcs
|
||||
"host/nimble/nimble/porting/nimble/src/hal_uart.c"
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND include_dirs
|
||||
host/nimble/nimble/porting/npl/freertos/include
|
||||
host/nimble/nimble/porting/nimble/include
|
||||
@@ -722,7 +753,7 @@ if(CONFIG_BT_ENABLED)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
|
||||
if(CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE AND CONFIG_BT_CONTROLLER_ENABLED)
|
||||
list(APPEND srcs
|
||||
"host/nimble/esp-hci/src/esp_nimble_hci.c"
|
||||
)
|
||||
|
||||
@@ -21,7 +21,6 @@ menu "Bluetooth"
|
||||
|
||||
config BT_NIMBLE_ENABLED
|
||||
bool "NimBLE - BLE only"
|
||||
depends on BT_CONTROLLER_ENABLED
|
||||
help
|
||||
This option is recommended for BLE only usecases to save on memory
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ config BTDM_SCAN_DUPL_CACHE_SIZE
|
||||
default 100
|
||||
help
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
When the maximum amount of device in the filter is reached, the oldest device will be refreshed.
|
||||
|
||||
config BTDM_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
int "Duplicate scan list refresh period (seconds)"
|
||||
|
||||
@@ -1024,13 +1024,11 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#define BLE_SM_KEY_ERR 0x17
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#include "mbedtls/aes.h"
|
||||
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "mbedtls/cipher.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
@@ -1038,7 +1036,9 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
#endif
|
||||
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
|
||||
#else
|
||||
#include "tinycrypt/aes.h"
|
||||
@@ -1048,15 +1048,15 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif
|
||||
#endif
|
||||
/* Based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey)
|
||||
@@ -1103,8 +1103,7 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_
|
||||
}
|
||||
|
||||
/* Set PRNG */
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
NULL, 0)) != 0) {
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1148,19 +1147,12 @@ exit:
|
||||
if (rc == TC_CRYPTO_FAIL) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
swap_buf(out_dhkey, dh, 32);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
{
|
||||
@@ -1206,7 +1198,7 @@ exit:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/**
|
||||
* pub: 64 bytes
|
||||
@@ -1222,7 +1214,6 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
uint8_t pk[64];
|
||||
|
||||
do {
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
if (mbedtls_gen_keypair(pk, priv) != 0) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
@@ -1231,17 +1222,17 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Make sure generated key isn't debug key. */
|
||||
} while (memcmp(priv, ble_sm_alg_dbg_priv_key, 32) == 0);
|
||||
|
||||
swap_buf(pub, pk, 32);
|
||||
swap_buf(&pub[32], &pk[32], 32);
|
||||
swap_in_place(priv, 32);
|
||||
#endif
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_SC_DEBUG_KEYS
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
|
||||
@@ -467,3 +467,11 @@ config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
Disable active scan backoff. The bluetooth spec requires that scanners should run a backoff procedure to
|
||||
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
|
||||
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.
|
||||
|
||||
config BT_BLE_ADV_DATA_LENGTH_ZERO_AUX
|
||||
bool "Enable aux packet when ext adv data length is zero"
|
||||
default n
|
||||
help
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
|
||||
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
|
||||
|
||||
@@ -652,7 +652,7 @@ static bool IRAM_ATTR is_in_isr_wrapper(void)
|
||||
|
||||
static void *malloc_internal_wrapper(size_t size)
|
||||
{
|
||||
void *p = heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
|
||||
void *p = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA);
|
||||
if(p == NULL) {
|
||||
ESP_LOGE(BT_LOG_TAG, "Malloc failed");
|
||||
}
|
||||
@@ -721,19 +721,26 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles)
|
||||
return;
|
||||
}
|
||||
|
||||
// start a timer to wake up and acquire the pm_lock before modem_sleep awakes
|
||||
uint32_t us_to_sleep = btdm_lpcycles_2_hus(lpcycles, NULL) >> 1;
|
||||
|
||||
#define BTDM_MIN_TIMER_UNCERTAINTY_US (1800)
|
||||
#define BTDM_RTC_SLOW_CLK_RC_DRIFT_PERCENT 7
|
||||
assert(us_to_sleep > BTDM_MIN_TIMER_UNCERTAINTY_US);
|
||||
// allow a maximum time uncertainty to be about 488ppm(1/2048) at least as clock drift
|
||||
// and set the timer in advance
|
||||
uint32_t uncertainty = (us_to_sleep >> 11);
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) {
|
||||
uncertainty = us_to_sleep * BTDM_RTC_SLOW_CLK_RC_DRIFT_PERCENT / 100;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (uncertainty < BTDM_MIN_TIMER_UNCERTAINTY_US) {
|
||||
uncertainty = BTDM_MIN_TIMER_UNCERTAINTY_US;
|
||||
}
|
||||
|
||||
assert (s_lp_stat.wakeup_timer_started == 0);
|
||||
// start a timer to wake up and acquire the pm_lock before modem_sleep awakes
|
||||
if (esp_timer_start_once(s_btdm_slp_tmr, us_to_sleep - uncertainty) == ESP_OK) {
|
||||
s_lp_stat.wakeup_timer_started = 1;
|
||||
} else {
|
||||
@@ -752,12 +759,12 @@ static void btdm_sleep_enter_phase2_wrapper(void)
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (s_lp_stat.pm_lock_released == 0) {
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_stat.pm_lock_released == 0) {
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif
|
||||
s_lp_stat.pm_lock_released = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,10 +123,10 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int ble_log_deinit_async(void);
|
||||
extern void ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void ble_log_async_output_dump_all(bool output);
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_controller_deinit(void);
|
||||
@@ -140,8 +140,8 @@ extern void esp_unregister_npl_funcs (void);
|
||||
extern void npl_freertos_mempool_deinit(void);
|
||||
extern uint32_t r_os_cputime_get32(void);
|
||||
extern uint32_t r_os_cputime_ticks_to_usecs(uint32_t ticks);
|
||||
extern void ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
@@ -157,6 +157,7 @@ extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -541,10 +542,10 @@ esp_err_t controller_sleep_init(void)
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_LIGHT_SLEEP);
|
||||
#else
|
||||
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_MODEM_SLEEP);
|
||||
#endif /* FREERTOS_USE_TICKLESS_IDLE */
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
@@ -624,16 +625,16 @@ typedef enum {
|
||||
}disc_duplicate_mode_t;
|
||||
|
||||
|
||||
extern void filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
|
||||
extern void filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
|
||||
extern void filter_duplicate_set_ring_list_max_num(uint32_t max_num);
|
||||
extern void scan_duplicate_cache_refresh_set_time(uint32_t period_time);
|
||||
extern void r_filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_set_ring_list_max_num(uint32_t max_num);
|
||||
extern void r_scan_duplicate_cache_refresh_set_time(uint32_t period_time);
|
||||
|
||||
int
|
||||
ble_vhci_disc_duplicate_mode_enable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
filter_duplicate_mode_enable(mode);
|
||||
r_filter_duplicate_mode_enable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -641,19 +642,19 @@ int
|
||||
ble_vhci_disc_duplicate_mode_disable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
filter_duplicate_mode_disable(mode);
|
||||
r_filter_duplicate_mode_disable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size){
|
||||
// TODO: use vendor hci to update
|
||||
filter_duplicate_set_ring_list_max_num(max_cache_size);
|
||||
r_filter_duplicate_set_ring_list_max_num(max_cache_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time){
|
||||
// TODO: use vendor hci to update
|
||||
scan_duplicate_cache_refresh_set_time(refresh_period_time);
|
||||
r_scan_duplicate_cache_refresh_set_time(refresh_period_time);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -785,6 +786,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -796,9 +798,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
|
||||
#else
|
||||
ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
@@ -835,7 +837,7 @@ free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
ble_log_deinit_async();
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
@@ -871,7 +873,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_log_deinit_async();
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
@@ -1191,16 +1193,15 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
ble_log_async_output_dump_all(output);
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#define BLE_SM_KEY_ERR 0x17
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#include "mbedtls/aes.h"
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
@@ -1210,22 +1211,27 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
|
||||
#else
|
||||
#include "tinycrypt/aes.h"
|
||||
#include "tinycrypt/constants.h"
|
||||
#include "tinycrypt/utils.h"
|
||||
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif// CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey)
|
||||
@@ -1272,8 +1278,7 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_
|
||||
}
|
||||
|
||||
/* Set PRNG */
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
NULL, 0)) != 0) {
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1323,19 +1328,10 @@ exit:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
{
|
||||
int rc = BLE_SM_KEY_ERR;
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
mbedtls_entropy_context entropy = {0};
|
||||
mbedtls_ctr_drbg_context ctr_drbg = {0};
|
||||
|
||||
@@ -1357,11 +1353,11 @@ static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp),
|
||||
&keypair.MBEDTLS_PRIVATE(Q),
|
||||
MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp), &keypair.MBEDTLS_PRIVATE(Q), MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1377,7 +1373,7 @@ exit:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/**
|
||||
* pub: 64 bytes
|
||||
@@ -1401,7 +1397,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Make sure generated key isn't debug key. */
|
||||
} while (memcmp(priv, ble_sm_alg_dbg_priv_key, 32) == 0);
|
||||
|
||||
@@ -1409,7 +1405,9 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
swap_buf(&pub[32], &pk[32], 32);
|
||||
swap_in_place(priv, 32);
|
||||
#endif // CONFIG_BT_LE_SM_SC_DEBUG_KEYS
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
|
||||
@@ -117,10 +117,10 @@ typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
|
||||
extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
|
||||
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int ble_log_deinit_async(void);
|
||||
extern void ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void ble_log_async_output_dump_all(bool output);
|
||||
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
|
||||
extern int r_ble_log_deinit_async(void);
|
||||
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
|
||||
extern void r_ble_log_async_output_dump_all(bool output);
|
||||
extern void esp_panic_handler_reconfigure_wdts(uint32_t timeout_ms);
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
extern int ble_controller_deinit(void);
|
||||
@@ -139,8 +139,8 @@ extern const sleep_retention_entries_config_t *esp_ble_mac_retention_link_get(ui
|
||||
extern void esp_ble_set_wakeup_overhead(uint32_t overhead);
|
||||
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
|
||||
extern void esp_ble_change_rtc_freq(uint32_t freq);
|
||||
extern void ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_lll_rfmgmt_set_sleep_cb(void *s_cb, void *w_cb, void *s_arg,
|
||||
void *w_arg, uint32_t us_to_enabled);
|
||||
extern void r_ble_rtc_wake_up_state_clr(void);
|
||||
extern int os_msys_init(void);
|
||||
extern void os_msys_deinit(void);
|
||||
@@ -151,6 +151,7 @@ extern int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv);
|
||||
extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t handle, int power_level);
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
@@ -529,10 +530,10 @@ esp_err_t controller_sleep_init(void)
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "BLE modem sleep is enabled");
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_LIGHT_SLEEP);
|
||||
#else
|
||||
ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0,
|
||||
BLE_RTC_DELAY_US_MODEM_SLEEP);
|
||||
#endif /* FREERTOS_USE_TICKLESS_IDLE */
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
@@ -599,16 +600,16 @@ typedef enum {
|
||||
}disc_duplicate_mode_t;
|
||||
|
||||
|
||||
extern void filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
|
||||
extern void filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
|
||||
extern void filter_duplicate_set_ring_list_max_num(uint32_t max_num);
|
||||
extern void scan_duplicate_cache_refresh_set_time(uint32_t period_time);
|
||||
extern void r_filter_duplicate_mode_enable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_mode_disable(disc_duplicate_mode_t mode);
|
||||
extern void r_filter_duplicate_set_ring_list_max_num(uint32_t max_num);
|
||||
extern void r_scan_duplicate_cache_refresh_set_time(uint32_t period_time);
|
||||
|
||||
int
|
||||
ble_vhci_disc_duplicate_mode_enable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
filter_duplicate_mode_enable(mode);
|
||||
r_filter_duplicate_mode_enable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -616,19 +617,19 @@ int
|
||||
ble_vhci_disc_duplicate_mode_disable(int mode)
|
||||
{
|
||||
// TODO: use vendor hci to update
|
||||
filter_duplicate_mode_disable(mode);
|
||||
r_filter_duplicate_mode_disable(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_max_cache_size(int max_cache_size){
|
||||
// TODO: use vendor hci to update
|
||||
filter_duplicate_set_ring_list_max_num(max_cache_size);
|
||||
r_filter_duplicate_set_ring_list_max_num(max_cache_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ble_vhci_disc_duplicate_set_period_refresh_time(int refresh_period_time){
|
||||
// TODO: use vendor hci to update
|
||||
scan_duplicate_cache_refresh_set_time(refresh_period_time);
|
||||
r_scan_duplicate_cache_refresh_set_time(refresh_period_time);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -758,6 +759,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -769,9 +771,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
buffers |= ESP_BLE_LOG_BUF_HCI;
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
|
||||
ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size);
|
||||
#else
|
||||
ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
|
||||
ret = r_ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size);
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
@@ -809,7 +811,7 @@ free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
ble_log_deinit_async();
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
@@ -843,7 +845,7 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_log_deinit_async();
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
@@ -1163,16 +1165,15 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
portENTER_CRITICAL_SAFE(&spinlock);
|
||||
esp_panic_handler_reconfigure_wdts(5000);
|
||||
BT_ASSERT_PRINT("\r\n[DUMP_START:");
|
||||
ble_log_async_output_dump_all(output);
|
||||
r_ble_log_async_output_dump_all(output);
|
||||
BT_ASSERT_PRINT(":DUMP_END]\r\n");
|
||||
portEXIT_CRITICAL_SAFE(&spinlock);
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
|
||||
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
#if (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
#if CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#define BLE_SM_KEY_ERR 0x17
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#include "mbedtls/aes.h"
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
@@ -1182,22 +1183,27 @@ void esp_ble_controller_log_dump_all(bool output)
|
||||
#include "mbedtls/cmac.h"
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ecp.h"
|
||||
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
|
||||
#else
|
||||
#include "tinycrypt/aes.h"
|
||||
#include "tinycrypt/constants.h"
|
||||
#include "tinycrypt/utils.h"
|
||||
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
#include "tinycrypt/cmac_mode.h"
|
||||
#include "tinycrypt/ecc_dh.h"
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#if CONFIG_BT_LE_SM_SC
|
||||
static mbedtls_ecp_keypair keypair;
|
||||
#endif // CONFIG_BT_LE_SM_SC
|
||||
#endif// CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
|
||||
const uint8_t *our_priv_key, uint8_t *out_dhkey)
|
||||
@@ -1244,8 +1250,7 @@ int ble_sm_alg_gen_dhkey(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_
|
||||
}
|
||||
|
||||
/* Set PRNG */
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
NULL, 0)) != 0) {
|
||||
if ((rc = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, NULL, 0)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1295,19 +1300,10 @@ exit:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* based on Core Specification 4.2 Vol 3. Part H 2.3.5.6.1 */
|
||||
static const uint8_t ble_sm_alg_dbg_priv_key[32] = {
|
||||
0x3f, 0x49, 0xf6, 0xd4, 0xa3, 0xc5, 0x5f, 0x38, 0x74, 0xc9, 0xb3, 0xe3,
|
||||
0xd2, 0x10, 0x3f, 0x50, 0x4a, 0xff, 0x60, 0x7b, 0xeb, 0x40, 0xb7, 0x99,
|
||||
0x58, 0x99, 0xb8, 0xa6, 0xcd, 0x3c, 0x1a, 0xbd
|
||||
};
|
||||
|
||||
#if CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
{
|
||||
int rc = BLE_SM_KEY_ERR;
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
mbedtls_entropy_context entropy = {0};
|
||||
mbedtls_ctr_drbg_context ctr_drbg = {0};
|
||||
|
||||
@@ -1329,11 +1325,11 @@ static int mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
size_t olen = 0;
|
||||
uint8_t pub[65] = {0};
|
||||
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp),
|
||||
&keypair.MBEDTLS_PRIVATE(Q),
|
||||
MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
if ((rc = mbedtls_ecp_point_write_binary(&keypair.MBEDTLS_PRIVATE(grp), &keypair.MBEDTLS_PRIVATE(Q), MBEDTLS_ECP_PF_UNCOMPRESSED,
|
||||
&olen, pub, 65)) != 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
@@ -1349,7 +1345,7 @@ exit:
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
|
||||
/**
|
||||
* pub: 64 bytes
|
||||
@@ -1373,7 +1369,7 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
if (uECC_make_key(pk, priv, &curve_secp256r1) != TC_CRYPTO_SUCCESS) {
|
||||
return BLE_SM_KEY_ERR;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
#endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS
|
||||
/* Make sure generated key isn't debug key. */
|
||||
} while (memcmp(priv, ble_sm_alg_dbg_priv_key, 32) == 0);
|
||||
|
||||
@@ -1381,7 +1377,9 @@ int ble_sm_alg_gen_key_pair(uint8_t *pub, uint8_t *priv)
|
||||
swap_buf(&pub[32], &pk[32], 32);
|
||||
swap_in_place(priv, 32);
|
||||
#endif // CONFIG_BT_LE_SM_SC_DEBUG_KEYS
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED == true)
|
||||
|
||||
#endif // CONFIG_BT_LE_SM_LEGACY || CONFIG_BT_LE_SM_SC
|
||||
#endif // (!CONFIG_BT_NIMBLE_ENABLED) && (CONFIG_BT_CONTROLLER_ENABLED)
|
||||
|
||||
|
||||
Submodule components/bt/controller/lib_esp32 updated: b0f132f17e...e43c9b121f
Submodule components/bt/controller/lib_esp32c3_family updated: 393ac4c33b...e5c0f7256e
Submodule components/bt/controller/lib_esp32c6/esp32c6-bt-lib updated: e4d0d86b6f...19eb534d33
Submodule components/bt/controller/lib_esp32h2/esp32h2-bt-lib updated: 90793e8319...c97e0d84f0
@@ -623,7 +623,7 @@ if BLE_MESH
|
||||
number of each node should also be taken into consideration. For example, if
|
||||
Provisioner can provision up to 20 nodes and each node contains two elements,
|
||||
then the replay protection list size of Provisioner should be at least 40.
|
||||
|
||||
|
||||
config BLE_MESH_NOT_RELAY_REPLAY_MSG
|
||||
bool "Not relay replayed messages in a mesh network"
|
||||
depends on BLE_MESH_EXPERIMENTAL
|
||||
@@ -1625,7 +1625,7 @@ if BLE_MESH
|
||||
config BLE_MESH_EXPERIMENTAL
|
||||
bool "Make BLE Mesh experimental features visible"
|
||||
default n
|
||||
help
|
||||
help
|
||||
Make BLE Mesh Experimental features visible.
|
||||
Experimental features list:
|
||||
- CONFIG_BLE_MESH_NOT_RELAY_REPLAY_MSG
|
||||
|
||||
@@ -65,7 +65,9 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
SemaphoreHandle_t semaphore = NULL;
|
||||
btc_msg_t msg = {0};
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (param == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
@@ -73,13 +75,36 @@ esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
// Create a semaphore
|
||||
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
|
||||
BT_ERR("Failed to create semaphore");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
arg.mesh_deinit.param.erase_flash = param->erase_flash;
|
||||
/* Transport semaphore pointer to BTC layer, and will give the semaphore in the BTC task */
|
||||
arg.mesh_deinit.semaphore = semaphore;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_DEINIT_MESH;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL, NULL) != BT_STATUS_SUCCESS) {
|
||||
vSemaphoreDelete(semaphore);
|
||||
BT_ERR("Failed to start mesh deinit");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Take the Semaphore, wait BLE Mesh de-initialization to finish. */
|
||||
xSemaphoreTake(semaphore, portMAX_DELAY);
|
||||
/* Don't forget to delete the semaphore at the end. */
|
||||
vSemaphoreDelete(semaphore);
|
||||
|
||||
ret = bt_mesh_host_deinit();
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
@@ -71,6 +71,14 @@ typedef uint8_t esp_ble_mesh_octet8_t[ESP_BLE_MESH_OCTET8_LEN];
|
||||
#define ESP_BLE_MESH_KEY_PRIMARY 0x0000
|
||||
#define ESP_BLE_MESH_KEY_ANY 0xFFFF
|
||||
|
||||
/*!< Internal macros used to initialize array members */
|
||||
#define ESP_BLE_MESH_KEY_UNUSED_ELT_(IDX, _) ESP_BLE_MESH_KEY_UNUSED
|
||||
#define ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_(IDX, _) ESP_BLE_MESH_ADDR_UNASSIGNED
|
||||
#define ESP_BLE_MESH_MODEL_KEYS_UNUSED \
|
||||
{ LISTIFY(CONFIG_BLE_MESH_MODEL_KEY_COUNT, ESP_BLE_MESH_KEY_UNUSED_ELT_, (,)) }
|
||||
#define ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED \
|
||||
{ LISTIFY(CONFIG_BLE_MESH_MODEL_GROUP_COUNT, ESP_BLE_MESH_ADDR_UNASSIGNED_ELT_, (,)) }
|
||||
|
||||
/*!< Primary Network Key index */
|
||||
#define ESP_BLE_MESH_NET_PRIMARY 0x000
|
||||
|
||||
@@ -286,26 +294,24 @@ typedef enum {
|
||||
#define ESP_BLE_MESH_SIG_MODEL(_id, _op, _pub, _user_data) \
|
||||
{ \
|
||||
.model_id = (_id), \
|
||||
.op = _op, \
|
||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
||||
ESP_BLE_MESH_KEY_UNUSED }, \
|
||||
.pub = _pub, \
|
||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
||||
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
|
||||
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||
.op = _op, \
|
||||
.user_data = _user_data, \
|
||||
}
|
||||
|
||||
/*!< This macro is associated with BLE_MESH_MODEL_VND_CB in mesh_access.h */
|
||||
#define ESP_BLE_MESH_VENDOR_MODEL(_company, _id, _op, _pub, _user_data) \
|
||||
{ \
|
||||
.vnd.company_id = (_company), \
|
||||
.vnd.model_id = (_id), \
|
||||
.op = _op, \
|
||||
.vnd = { \
|
||||
.company_id = (_company), \
|
||||
.model_id = (_id), \
|
||||
}, \
|
||||
.pub = _pub, \
|
||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
||||
ESP_BLE_MESH_KEY_UNUSED }, \
|
||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
||||
ESP_BLE_MESH_ADDR_UNASSIGNED }, \
|
||||
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||
.op = _op, \
|
||||
.user_data = _user_data, \
|
||||
}
|
||||
|
||||
@@ -324,8 +330,8 @@ typedef enum {
|
||||
{ \
|
||||
.location = (_loc), \
|
||||
.sig_model_count = ARRAY_SIZE(_mods), \
|
||||
.sig_models = (_mods), \
|
||||
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
|
||||
.sig_models = (_mods), \
|
||||
.vnd_models = (_vnd_mods), \
|
||||
}
|
||||
|
||||
@@ -492,8 +498,9 @@ typedef struct {
|
||||
#define ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, _msg_len, _role) \
|
||||
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
|
||||
static esp_ble_mesh_model_pub_t _name = { \
|
||||
.update = (uint32_t)NULL, \
|
||||
.msg = &bt_mesh_pub_msg_##_name, \
|
||||
.update = (uint32_t)NULL, \
|
||||
.dev_role = _role, \
|
||||
}
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_OP
|
||||
|
||||
@@ -2825,6 +2825,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
case BTC_BLE_MESH_ACT_DEINIT_MESH:
|
||||
act = ESP_BLE_MESH_DEINIT_MESH_COMP_EVT;
|
||||
param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param);
|
||||
/* Give the semaphore when BLE Mesh de-initialization is finished. */
|
||||
xSemaphoreGive(arg->mesh_deinit.semaphore);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
default:
|
||||
|
||||
@@ -341,6 +341,7 @@ typedef union {
|
||||
} model_unsub_group_addr;
|
||||
struct ble_mesh_deinit_args {
|
||||
esp_ble_mesh_deinit_param_t param;
|
||||
SemaphoreHandle_t semaphore;
|
||||
} mesh_deinit;
|
||||
} btc_ble_mesh_prov_args_t;
|
||||
|
||||
|
||||
@@ -840,22 +840,22 @@ struct net_buf_pool {
|
||||
#if CONFIG_BLE_MESH_NET_BUF_POOL_USAGE
|
||||
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
||||
{ \
|
||||
.alloc = _alloc, \
|
||||
.__bufs = (struct net_buf *)_bufs, \
|
||||
.buf_count = _count, \
|
||||
.uninit_count = _count, \
|
||||
.avail_count = _count, \
|
||||
.destroy = _destroy, \
|
||||
.name = STRINGIFY(_pool), \
|
||||
.destroy = _destroy, \
|
||||
.alloc = _alloc, \
|
||||
.__bufs = (struct net_buf *)_bufs, \
|
||||
}
|
||||
#else
|
||||
#define NET_BUF_POOL_INITIALIZER(_pool, _alloc, _bufs, _count, _destroy) \
|
||||
{ \
|
||||
.alloc = _alloc, \
|
||||
.__bufs = (struct net_buf *)_bufs, \
|
||||
.buf_count = _count, \
|
||||
.uninit_count = _count, \
|
||||
.destroy = _destroy, \
|
||||
.alloc = _alloc, \
|
||||
.__bufs = (struct net_buf *)_bufs, \
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_NET_BUF_POOL_USAGE */
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <stddef.h>
|
||||
#include "esp_bit_defs.h"
|
||||
#include "mesh/types.h"
|
||||
#include "utils_loops.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -180,6 +181,40 @@ extern "C" {
|
||||
*/
|
||||
#define Z_IS_ENABLED3(ignore_this, val, ...) val
|
||||
|
||||
/* Used to remove brackets from around a single argument. */
|
||||
#define __DEBRACKET(...) __VA_ARGS__
|
||||
|
||||
#define UTIL_CAT(a, ...) UTIL_PRIMITIVE_CAT(a, __VA_ARGS__)
|
||||
#define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
|
||||
|
||||
/**
|
||||
* @brief Generates a sequence of code with configurable separator.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* #define FOO(i, _) MY_PWM ## i
|
||||
* { LISTIFY(PWM_COUNT, FOO, (,)) }
|
||||
*
|
||||
* The above two lines expand to:
|
||||
*
|
||||
* { MY_PWM0 , MY_PWM1 }
|
||||
*
|
||||
* @param LEN The length of the sequence. Must be an integer literal less
|
||||
* than 255.
|
||||
* @param F A macro function that accepts at least two arguments:
|
||||
* <tt>F(i, ...)</tt>. @p F is called repeatedly in the expansion.
|
||||
* Its first argument @p i is the index in the sequence, and
|
||||
* the variable list of arguments passed to LISTIFY are passed
|
||||
* through to @p F.
|
||||
*
|
||||
* @param sep Separator (e.g. comma or semicolon). Must be in parentheses;
|
||||
* this is required to enable providing a comma as separator.
|
||||
*
|
||||
* @note Calling LISTIFY with undefined arguments has undefined
|
||||
* behavior.
|
||||
*/
|
||||
#define LISTIFY(LEN, F, sep, ...) UTIL_CAT(Z_UTIL_LISTIFY_, LEN)(F, sep, __VA_ARGS__)
|
||||
|
||||
const char *bt_hex(const void *buf, size_t len);
|
||||
|
||||
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len);
|
||||
|
||||
1051
components/bt/esp_ble_mesh/common/include/mesh/utils_loops.h
Normal file
1051
components/bt/esp_ble_mesh/common/include/mesh/utils_loops.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -107,6 +107,11 @@ int bt_mesh_host_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_host_deinit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_hci_init(void)
|
||||
{
|
||||
const uint8_t *features = controller_get_interface()->get_features_ble()->as_array;
|
||||
|
||||
@@ -54,8 +54,8 @@ extern "C" {
|
||||
{ \
|
||||
.loc = (_loc), \
|
||||
.model_count = ARRAY_SIZE(_mods), \
|
||||
.models = (_mods), \
|
||||
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
|
||||
.models = (_mods), \
|
||||
.vnd_models = (_vnd_mods), \
|
||||
}
|
||||
|
||||
@@ -306,14 +306,12 @@ struct bt_mesh_model_op {
|
||||
#define BLE_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
|
||||
{ \
|
||||
.id = (_id), \
|
||||
.op = (_op), \
|
||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
||||
BLE_MESH_KEY_UNUSED }, \
|
||||
.pub = (_pub), \
|
||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
||||
BLE_MESH_ADDR_UNASSIGNED }, \
|
||||
.user_data = (_user_data), \
|
||||
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||
.op = (_op), \
|
||||
.cb = (_cb), \
|
||||
.user_data = (_user_data), \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_MODEL_VND_CB
|
||||
@@ -331,14 +329,12 @@ struct bt_mesh_model_op {
|
||||
{ \
|
||||
.vnd.company = (_company), \
|
||||
.vnd.id = (_id), \
|
||||
.op = (_op), \
|
||||
.pub = (_pub), \
|
||||
.keys = { [0 ... (CONFIG_BLE_MESH_MODEL_KEY_COUNT - 1)] = \
|
||||
BLE_MESH_KEY_UNUSED }, \
|
||||
.groups = { [0 ... (CONFIG_BLE_MESH_MODEL_GROUP_COUNT - 1)] = \
|
||||
BLE_MESH_ADDR_UNASSIGNED }, \
|
||||
.user_data = (_user_data), \
|
||||
.keys = ESP_BLE_MESH_MODEL_KEYS_UNUSED, \
|
||||
.groups = ESP_BLE_MESH_MODEL_GROUPS_UNASSIGNED, \
|
||||
.op = (_op), \
|
||||
.cb = (_cb), \
|
||||
.user_data = (_user_data), \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_TRANSMIT
|
||||
@@ -475,8 +471,8 @@ struct bt_mesh_model_pub {
|
||||
#define BLE_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
|
||||
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
|
||||
static struct bt_mesh_model_pub _name = { \
|
||||
.update = _update, \
|
||||
.msg = &bt_mesh_pub_msg_##_name, \
|
||||
.update = _update, \
|
||||
}
|
||||
|
||||
/** Model callback functions. */
|
||||
|
||||
@@ -596,9 +596,9 @@ struct bt_mesh_gatt_attr {
|
||||
#define BLE_MESH_GATT_PRIMARY_SERVICE(_service) \
|
||||
{ \
|
||||
.uuid = BLE_MESH_UUID_GATT_PRIMARY, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
.read = bt_mesh_gatts_attr_read_service, \
|
||||
.user_data = _service, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_GATT_SECONDARY_SERVICE
|
||||
@@ -611,9 +611,9 @@ struct bt_mesh_gatt_attr {
|
||||
#define BLE_MESH_GATT_SECONDARY_SERVICE(_service) \
|
||||
{ \
|
||||
.uuid = BLE_MESH_UUID_GATT_SECONDARY, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
.read = bt_mesh_gatts_attr_read_service, \
|
||||
.user_data = _service, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_GATT_INCLUDE_SERVICE
|
||||
@@ -626,9 +626,9 @@ struct bt_mesh_gatt_attr {
|
||||
#define BLE_MESH_GATT_INCLUDE_SERVICE(_service_incl) \
|
||||
{ \
|
||||
.uuid = BLE_MESH_UUID_GATT_INCLUDE, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
.read = bt_mesh_gatts_attr_read_included, \
|
||||
.user_data = _service_incl, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_GATT_CHARACTERISTIC
|
||||
@@ -642,10 +642,10 @@ struct bt_mesh_gatt_attr {
|
||||
#define BLE_MESH_GATT_CHARACTERISTIC(_uuid, _props) \
|
||||
{ \
|
||||
.uuid = BLE_MESH_UUID_GATT_CHRC, \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
.read = bt_mesh_gatts_attr_read_chrc, \
|
||||
.user_data = (&(struct bt_mesh_gatt_char) { .uuid = _uuid, \
|
||||
.properties = _props, }), \
|
||||
.perm = BLE_MESH_GATT_PERM_READ, \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_GATT_DESCRIPTOR
|
||||
@@ -662,10 +662,10 @@ struct bt_mesh_gatt_attr {
|
||||
#define BLE_MESH_GATT_DESCRIPTOR(_uuid, _perm, _read, _write, _value) \
|
||||
{ \
|
||||
.uuid = _uuid, \
|
||||
.perm = _perm, \
|
||||
.read = _read, \
|
||||
.write = _write, \
|
||||
.user_data = _value, \
|
||||
.perm = _perm, \
|
||||
}
|
||||
|
||||
/** @def BLE_MESH_GATT_SERVICE
|
||||
@@ -682,6 +682,7 @@ struct bt_mesh_gatt_attr {
|
||||
}
|
||||
|
||||
int bt_mesh_host_init(void);
|
||||
int bt_mesh_host_deinit(void);
|
||||
|
||||
int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
||||
const struct bt_mesh_adv_data *ad, size_t ad_len,
|
||||
|
||||
@@ -109,6 +109,11 @@ void bt_mesh_node_reset(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (bt_mesh_prov_active()) {
|
||||
BT_WARN("%s, link is still active", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh.iv_index = 0U;
|
||||
bt_mesh.seq = 0U;
|
||||
|
||||
|
||||
@@ -81,14 +81,15 @@ static struct bt_mesh_conn_cb *bt_mesh_gatts_conn_cb;
|
||||
static uint8_t bt_mesh_gatts_addr[6];
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
|
||||
static bool g_host_init = false;
|
||||
|
||||
int bt_mesh_host_init(void)
|
||||
{
|
||||
static bool init = false;
|
||||
int rc;
|
||||
|
||||
if (init == true) {
|
||||
if (g_host_init == true) {
|
||||
BT_WARN("Already initialized host for mesh!");
|
||||
return 0;
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
rc = btc_init();
|
||||
@@ -102,7 +103,30 @@ int bt_mesh_host_init(void)
|
||||
}
|
||||
|
||||
osi_alarm_init();
|
||||
init = true;
|
||||
g_host_init = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_host_deinit(void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (g_host_init == false) {
|
||||
return -EALREADY;
|
||||
}
|
||||
|
||||
osi_alarm_deinit();
|
||||
|
||||
rc = osi_alarm_delete_mux();
|
||||
if (rc != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
btc_deinit();
|
||||
|
||||
g_host_init = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -895,7 +919,7 @@ int bt_mesh_ble_adv_start(const struct bt_mesh_ble_adv_param *param,
|
||||
break;
|
||||
case BLE_MESH_ADV_NONCONN_IND:
|
||||
adv_params.conn_mode = BLE_GAP_CONN_MODE_NON;
|
||||
adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
|
||||
adv_params.disc_mode = BLE_GAP_DISC_MODE_NON;
|
||||
break;
|
||||
case BLE_MESH_ADV_DIRECT_IND_LOW_DUTY:
|
||||
adv_params.conn_mode = BLE_GAP_CONN_MODE_DIR;
|
||||
|
||||
@@ -141,6 +141,11 @@ bool bt_mesh_prov_pdu_check(uint8_t type, uint16_t length, uint8_t *reason)
|
||||
#define XACT_SEG_DATA(link, _seg) (&link->rx.buf->data[20 + (((_seg) - 1) * 23)])
|
||||
#define XACT_SEG_RECV(link, _seg) (link->rx.seg &= ~(1 << (_seg)))
|
||||
|
||||
static uint8_t bt_mesh_prov_buf_type_get(struct net_buf_simple *buf)
|
||||
{
|
||||
return buf->data[PROV_BUF_HEADROOM];
|
||||
}
|
||||
|
||||
uint8_t node_next_xact_id(struct bt_mesh_prov_link *link)
|
||||
{
|
||||
if (link->tx.id != 0 && link->tx.id != 0xFF) {
|
||||
@@ -677,6 +682,13 @@ int bt_mesh_prov_send(struct bt_mesh_prov_link *link, struct net_buf_simple *buf
|
||||
#endif /* CONFIG_BLE_MESH_PB_GATT */
|
||||
|
||||
#if CONFIG_BLE_MESH_PB_ADV
|
||||
if (bt_mesh_prov_buf_type_get(buf) == PROV_FAILED) {
|
||||
/* For case MESH/NODE/PROV/BV-10-C, Node must send Transaction
|
||||
* ACK before Provisioning Failed message is transmitted.
|
||||
*/
|
||||
bt_mesh_gen_prov_ack_send(link, link->rx.id);
|
||||
}
|
||||
|
||||
return bt_mesh_prov_send_adv(link, buf);
|
||||
#endif /* CONFIG_BLE_MESH_PB_ADV */
|
||||
|
||||
|
||||
@@ -179,12 +179,6 @@ static void prov_send_fail_msg(uint8_t err)
|
||||
{
|
||||
PROV_BUF(buf, 2);
|
||||
|
||||
/**
|
||||
* For the case MESH/NODE/PROV/BV-10-C, Node must send Transaction ACK
|
||||
* before Provisioning Failed message is transmitted.
|
||||
*/
|
||||
bt_mesh_gen_prov_ack_send(&prov_link, prov_link.rx.id);
|
||||
|
||||
bt_mesh_prov_buf_init(&buf, PROV_FAILED);
|
||||
net_buf_simple_add_u8(&buf, err);
|
||||
|
||||
|
||||
@@ -1311,13 +1311,13 @@ void bt_mesh_ext_prov_clear_tx(void *link, bool cancel)
|
||||
|
||||
uint8_t bt_mesh_ext_prov_node_next_xact_id(void *link)
|
||||
{
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
#if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV
|
||||
extern uint8_t node_next_xact_id(struct bt_mesh_prov_link *link);
|
||||
return node_next_xact_id(link);
|
||||
#else
|
||||
assert(0);
|
||||
return 0;
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
#endif /* CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_ADV */
|
||||
}
|
||||
|
||||
void *bt_mesh_ext_prov_node_get_link(void)
|
||||
|
||||
@@ -238,6 +238,11 @@ typedef union {
|
||||
esp_ble_mesh_rpr_link_report_t link_report; /*!< For ESP_BLE_MESH_MODEL_OP_RPR_LINK_REPORT */
|
||||
} esp_ble_mesh_rpr_client_recv_cb_t;
|
||||
|
||||
/** This enum value is the event type of the performed action */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_START_RPR_COMP_SUB_EVT,
|
||||
} esp_ble_mesh_rpr_client_act_evt_t;
|
||||
|
||||
/** Remote Provisioning Client model callback parameters */
|
||||
typedef union {
|
||||
/** Event parameters of sending messages */
|
||||
@@ -252,10 +257,7 @@ typedef union {
|
||||
} recv; /*!< Event parameters of receiving messages */
|
||||
/** Event parameters of performed actions */
|
||||
struct {
|
||||
/** Event type of the performed action */
|
||||
enum {
|
||||
ESP_BLE_MESH_START_RPR_COMP_SUB_EVT,
|
||||
} sub_evt; /*!< Event type of the performed action */
|
||||
esp_ble_mesh_rpr_client_act_evt_t sub_evt; /*!< Event type of the performed action */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_RPR_COMP_SUB_EVT
|
||||
*/
|
||||
|
||||
@@ -1087,6 +1087,14 @@ config BT_SMP_ENABLE
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
default BT_CLASSIC_ENABLED || BT_BLE_SMP_ENABLE
|
||||
|
||||
config BT_SMP_MAX_BONDS
|
||||
int "BT/BLE maximum bond device count"
|
||||
depends on BT_SMP_ENABLE
|
||||
range 1 32
|
||||
default 15
|
||||
help
|
||||
The number of security records for peer devices.
|
||||
|
||||
config BT_BLE_ACT_SCAN_REP_ADV_SCAN
|
||||
bool "Report adv data and scan response individually when BLE active scan"
|
||||
depends on BT_BLUEDROID_ENABLED && BT_BLE_ENABLED
|
||||
@@ -1119,7 +1127,7 @@ config BT_MAX_DEVICE_NAME_LEN
|
||||
|
||||
config BT_BLE_RPA_SUPPORTED
|
||||
bool "Update RPA to Controller"
|
||||
depends on (BT_BLUEDROID_ENABLED && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED))
|
||||
depends on (BT_BLUEDROID_ENABLED && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED)
|
||||
default y if BT_CONTROLLER_DISABLED
|
||||
help
|
||||
@@ -1160,21 +1168,21 @@ config BT_BLE_42_FEATURES_SUPPORTED
|
||||
|
||||
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable BLE periodic advertising sync transfer feature"
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED))
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n
|
||||
help
|
||||
This enables BLE periodic advertising sync transfer feature
|
||||
|
||||
config BT_BLE_FEAT_PERIODIC_ADV_ENH
|
||||
bool "Enable periodic adv enhancements(adi support)"
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED))
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n
|
||||
help
|
||||
Enable the periodic advertising enhancements
|
||||
|
||||
config BT_BLE_FEAT_CREATE_SYNC_ENH
|
||||
bool "Enable create sync enhancements(reporting disable and duplicate filtering enable support)"
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED))
|
||||
depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR
|
||||
default n
|
||||
help
|
||||
Enable the create sync enhancements
|
||||
|
||||
@@ -22,6 +22,11 @@ esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
|
||||
return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_gap_ble_cb_t esp_ble_gap_get_callback(void)
|
||||
{
|
||||
return (esp_gap_ble_cb_t) btc_profile_cb_get(BTC_PID_GAP_BLE);
|
||||
}
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,6 +29,11 @@ esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_gattc_cb_t esp_ble_gattc_get_callback(void)
|
||||
{
|
||||
return (esp_gattc_cb_t) btc_profile_cb_get(BTC_PID_GATTC);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
@@ -29,6 +29,11 @@ esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback)
|
||||
return (btc_profile_cb_set(BTC_PID_GATTS, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_gatts_cb_t esp_ble_gatts_get_callback(void)
|
||||
{
|
||||
return (esp_gatts_cb_t) btc_profile_cb_get(BTC_PID_GATTS);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -109,8 +109,11 @@ esp_err_t esp_spp_connect(esp_spp_sec_t sec_mask,
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (sec_mask != ESP_SPP_SEC_NONE && sec_mask != ESP_SPP_SEC_AUTHORIZE && sec_mask != ESP_SPP_SEC_AUTHENTICATE) {
|
||||
LOG_WARN("Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only\n");
|
||||
if (sec_mask != ESP_SPP_SEC_NONE &&
|
||||
sec_mask != ESP_SPP_SEC_AUTHENTICATE &&
|
||||
sec_mask != (ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT)) {
|
||||
LOG_WARN("Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHENTICATE"
|
||||
"or (ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT) only\n");
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -152,8 +155,16 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (sec_mask != ESP_SPP_SEC_NONE && sec_mask != ESP_SPP_SEC_AUTHORIZE && sec_mask != ESP_SPP_SEC_AUTHENTICATE) {
|
||||
LOG_WARN("Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only\n");
|
||||
if (sec_mask != ESP_SPP_SEC_NONE &&
|
||||
sec_mask != ESP_SPP_SEC_AUTHENTICATE &&
|
||||
sec_mask != (ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT) &&
|
||||
sec_mask != ESP_SPP_SEC_IN_16_DIGITS &&
|
||||
sec_mask != (ESP_SPP_SEC_IN_16_DIGITS | ESP_SPP_SEC_AUTHENTICATE) &&
|
||||
sec_mask != (ESP_SPP_SEC_IN_16_DIGITS | ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT)) {
|
||||
LOG_WARN("Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHENTICATE,"
|
||||
"(ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT),"
|
||||
"ESP_SPP_SEC_IN_16_DIGITS, (ESP_SPP_SEC_IN_16_DIGITS | ESP_SPP_SEC_AUTHENTICATE), or"
|
||||
"(ESP_SPP_SEC_IN_16_DIGITS | ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT) only\n");
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -459,7 +459,10 @@ typedef enum {
|
||||
typedef enum {
|
||||
BLE_SCAN_DUPLICATE_DISABLE = 0x0, /*!< the Link Layer should generate advertising reports to the host for each packet received */
|
||||
BLE_SCAN_DUPLICATE_ENABLE = 0x1, /*!< the Link Layer should filter out duplicate advertising reports to the Host */
|
||||
BLE_SCAN_DUPLICATE_MAX = 0x2, /*!< 0x02 – 0xFF, Reserved for future use */
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
BLE_SCAN_DUPLICATE_ENABLE_RESET, /*!< Duplicate filtering enabled, reset for each scan period, only supported in BLE 5.0. */
|
||||
#endif
|
||||
BLE_SCAN_DUPLICATE_MAX /*!< Reserved for future use. */
|
||||
} esp_ble_scan_duplicate_t;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/// Ble scan parameters
|
||||
@@ -1489,6 +1492,15 @@ typedef void (* esp_gap_ble_cb_t)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_p
|
||||
*/
|
||||
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the current gap callback
|
||||
*
|
||||
* @return
|
||||
* - esp_gap_ble_cb_t : callback function
|
||||
*
|
||||
*/
|
||||
esp_gap_ble_cb_t esp_ble_gap_get_callback(void);
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/**
|
||||
* @brief This function is called to override the BTA default ADV parameters.
|
||||
@@ -2288,8 +2300,9 @@ esp_err_t esp_ble_gap_set_ext_scan_params(const esp_ble_ext_scan_params_t *param
|
||||
/**
|
||||
* @brief This function is used to enable scanning.
|
||||
*
|
||||
* @param[in] duration : Scan duration
|
||||
* @param[in] period : Time interval from when the Controller started its last Scan Duration until it begins the subsequent Scan Duration.
|
||||
* @param[in] duration Scan duration time, where Time = N * 10 ms. Range: 0x0001 to 0xFFFF.
|
||||
* @param[in] period Time interval from when the Controller started its last Scan Duration until it begins the subsequent Scan Duration.
|
||||
* Time = N * 1.28 sec. Range: 0x0001 to 0xFFFF.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
|
||||
@@ -226,6 +226,22 @@ typedef enum {
|
||||
ESP_BT_GAP_DISCOVERY_STARTED, /*!< Device discovery started */
|
||||
} esp_bt_gap_discovery_state_t;
|
||||
|
||||
/// Type of link key
|
||||
#define ESP_BT_LINK_KEY_COMB (0x00) /*!< Combination Key */
|
||||
#define ESP_BT_LINK_KEY_DBG_COMB (0x03) /*!< Debug Combination Key */
|
||||
#define ESP_BT_LINK_KEY_UNAUTHED_COMB_P192 (0x04) /*!< Unauthenticated Combination Key generated from P-192 */
|
||||
#define ESP_BT_LINK_KEY_AUTHED_COMB_P192 (0x05) /*!< Authenticated Combination Key generated from P-192 */
|
||||
#define ESP_BT_LINK_KEY_CHG_COMB (0x06) /*!< Changed Combination Key */
|
||||
#define ESP_BT_LINK_KEY_UNAUTHED_COMB_P256 (0x07) /*!< Unauthenticated Combination Key generated from P-256 */
|
||||
#define ESP_BT_LINK_KEY_AUTHED_COMB_P256 (0x08) /*!< Authenticated Combination Key generated from P-256 */
|
||||
typedef uint8_t esp_bt_link_key_type_t;
|
||||
|
||||
/// Type of encryption
|
||||
#define ESP_BT_ENC_MODE_OFF (0x00) /*!< Link Level Encryption is OFF */
|
||||
#define ESP_BT_ENC_MODE_E0 (0x01) /*!< Link Level Encryption is ON with E0 */
|
||||
#define ESP_BT_ENC_MODE_AES (0x02) /*!< Link Level Encryption is ON with AES-CCM */
|
||||
typedef uint8_t esp_bt_enc_mode_t;
|
||||
|
||||
/// BT GAP callback events
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DISC_RES_EVT = 0, /*!< Device discovery result event */
|
||||
@@ -249,6 +265,7 @@ typedef enum {
|
||||
ESP_BT_GAP_SET_PAGE_TO_EVT, /*!< Set page timeout event */
|
||||
ESP_BT_GAP_GET_PAGE_TO_EVT, /*!< Get page timeout event */
|
||||
ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, /*!< Set ACL packet types event */
|
||||
ESP_BT_GAP_ENC_CHG_EVT, /*!< Encryption change event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
@@ -331,9 +348,18 @@ typedef union {
|
||||
struct auth_cmpl_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< authentication complete status */
|
||||
esp_bt_link_key_type_t lk_type; /*!< type of link key generated */
|
||||
uint8_t device_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< device name */
|
||||
} auth_cmpl; /*!< authentication complete parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_ENC_CHG_EVT
|
||||
*/
|
||||
struct enc_chg_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_enc_mode_t enc_mode; /*!< encryption mode */
|
||||
} enc_chg; /*!< encryption change parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_PIN_REQ_EVT
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -273,6 +273,15 @@ typedef void (* esp_gattc_cb_t)(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the current application callbacks
|
||||
* with BTA GATTC module.
|
||||
*
|
||||
* @return
|
||||
* - esp_gattC_cb_t : current callback
|
||||
*
|
||||
*/
|
||||
esp_gattc_cb_t esp_ble_gattc_get_callback(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to register application callbacks
|
||||
|
||||
@@ -295,6 +295,16 @@ typedef void (* esp_gatts_cb_t)(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_
|
||||
*/
|
||||
esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the current application callbacks
|
||||
* with BTA GATTS module.
|
||||
*
|
||||
* @return
|
||||
* - esp_gatts_cb_t : current callback
|
||||
*
|
||||
*/
|
||||
esp_gatts_cb_t esp_ble_gatts_get_callback(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to register application identifier
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -29,10 +29,18 @@ extern "C" {
|
||||
}
|
||||
|
||||
/* Security Setting Mask
|
||||
Use these three mask mode:
|
||||
Use these three mask modes on both sides:
|
||||
1. ESP_SPP_SEC_NONE
|
||||
2. ESP_SPP_SEC_AUTHENTICATE
|
||||
3. (ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE)
|
||||
3. (ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT)
|
||||
Use these three mask modes only on acceptor side:
|
||||
1. ESP_SPP_SEC_IN_16_DIGITS
|
||||
2. (ESP_SPP_SEC_IN_16_DIGITS | ESP_SPP_SEC_AUTHENTICATE)
|
||||
3. (ESP_SPP_SEC_IN_16_DIGITS | ESP_SPP_SEC_AUTHENTICATE | ESP_SPP_SEC_ENCRYPT)
|
||||
Due to certain limitations, do not use these mask modes:
|
||||
1. ESP_SPP_SEC_AUTHORIZE
|
||||
2. ESP_SPP_SEC_MODE4_LEVEL4
|
||||
3. ESP_SPP_SEC_MITM
|
||||
*/
|
||||
#define ESP_SPP_SEC_NONE 0x0000 /*!< No security. relate to BTA_SEC_NONE in bta/bta_api.h */
|
||||
#define ESP_SPP_SEC_AUTHORIZE 0x0001 /*!< Authorization required (only needed for out going connection ) relate to BTA_SEC_AUTHORIZE in bta/bta_api.h*/
|
||||
|
||||
@@ -77,9 +77,10 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data);
|
||||
static void bta_dm_acl_link_stat_cback(tBTM_ACL_LINK_STAT_EVENT_DATA *p_data);
|
||||
static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
static void bta_dm_encryption_change_cback(BD_ADDR bd_addr, UINT8 enc_mode);
|
||||
static UINT8 bta_dm_sp_cback (tBTM_SP_EVT event, tBTM_SP_EVT_DATA *p_data);
|
||||
/* Extended Inquiry Response */
|
||||
static void bta_dm_set_eir (char *local_name);
|
||||
#endif
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
@@ -231,9 +232,11 @@ const tBTM_APPL_INFO bta_security = {
|
||||
&bta_dm_authentication_complete_cback,
|
||||
&bta_dm_bond_cancel_complete_cback,
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
&bta_dm_encryption_change_cback,
|
||||
&bta_dm_sp_cback,
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
#if BLE_INCLUDED == TRUE
|
||||
&bta_dm_ble_smp_cback,
|
||||
@@ -3093,6 +3096,27 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_PIN_REQ_EVT, &sec_event);
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_new_link_key_cback
|
||||
**
|
||||
** Description Callback from BTM to notify new link key
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_dm_encryption_change_cback(BD_ADDR bd_addr, UINT8 enc_mode)
|
||||
{
|
||||
if (bta_dm_cb.p_sec_cback) {
|
||||
tBTA_DM_SEC sec_event;
|
||||
memset (&sec_event, 0, sizeof(tBTA_DM_SEC));
|
||||
bdcpy(sec_event.enc_chg.bd_addr, bd_addr);
|
||||
sec_event.enc_chg.enc_mode = enc_mode;
|
||||
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_ENC_CHG_EVT, &sec_event);
|
||||
}
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -510,6 +510,10 @@ UINT8 bta_gattc_co_find_hash_in_cache(hash_key_t hash_key)
|
||||
|
||||
UINT8 bta_gattc_co_get_addr_num(void)
|
||||
{
|
||||
if (cache_env == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cache_env->num_addr;
|
||||
}
|
||||
|
||||
|
||||
@@ -534,4 +534,17 @@ void bta_gattc_deinit(void)
|
||||
FREE_AND_RESET(bta_gattc_cb_ptr);
|
||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||
}
|
||||
|
||||
uint8_t bta_gattc_cl_rcb_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < BTA_GATTC_CL_MAX; i ++) {
|
||||
if (bta_gattc_cb.cl_rcb[i].in_use) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */
|
||||
|
||||
@@ -679,7 +679,7 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bdstr[18] = {0};
|
||||
#endif
|
||||
APPL_TRACE_ERROR("%s unable to find the bg connection mask for: %s", __func__,
|
||||
APPL_TRACE_WARNING("%s unable to find the bg connection mask for: %s", __func__,
|
||||
bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
@@ -152,4 +152,17 @@ void bta_gatts_deinit(void)
|
||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||
}
|
||||
|
||||
uint8_t bta_gatts_srvc_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++) {
|
||||
if (bta_gatts_cb.srvc_cb[i].in_use) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif /* GATTS_INCLUDED */
|
||||
|
||||
@@ -669,6 +669,7 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK;
|
||||
#define BTA_DM_ACL_LINK_STAT_EVT 32 /* ACL connection status report event */
|
||||
#define BTA_DM_BLE_SC_OOB_REQ_EVT 33 /* BLE SMP SC OOB request event */
|
||||
#define BTA_DM_BLE_SC_CR_LOC_OOB_EVT 34 /* BLE SMP SC Create Local OOB request event */
|
||||
#define BTA_DM_ENC_CHG_EVT 35 /* Encryption change event */
|
||||
|
||||
typedef UINT8 tBTA_DM_SEC_EVT;
|
||||
|
||||
@@ -993,6 +994,11 @@ typedef struct {
|
||||
BT_OCTET16 local_oob_r; /* Local OOB Data Randomizer */
|
||||
} tBTA_DM_LOC_OOB_DATA;
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device */
|
||||
UINT8 enc_mode; /* Encryption mode */
|
||||
} tBTA_DM_ENC_CHG;
|
||||
|
||||
/* Union of all security callback structures */
|
||||
typedef union {
|
||||
tBTA_DM_ENABLE enable; /* BTA enabled */
|
||||
@@ -1018,6 +1024,7 @@ typedef union {
|
||||
tBTA_DM_MODE_CHG mode_chg; /* mode change event */
|
||||
#endif ///BTA_DM_PM_INCLUDED
|
||||
tBTA_DM_LOC_OOB_DATA local_oob_data; /* Local OOB data generated by us */
|
||||
tBTA_DM_ENC_CHG enc_chg; /* Encryption change event */
|
||||
} tBTA_DM_SEC;
|
||||
|
||||
/* Security callback */
|
||||
|
||||
@@ -847,7 +847,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -294,11 +294,10 @@ tBTA_JV_RFC_CB *bta_jv_rfc_port_to_cb(UINT16 port_handle)
|
||||
return p_cb;
|
||||
}
|
||||
|
||||
static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pcb, BOOLEAN close_server)
|
||||
static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pcb, BOOLEAN close_server, BOOLEAN close_pending)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_SUCCESS;
|
||||
BOOLEAN remove_server = FALSE;
|
||||
int close_pending = 0;
|
||||
|
||||
UINT8 used = 0, i, listen = 0;
|
||||
tPORT_STATE port_state;
|
||||
@@ -321,11 +320,11 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
||||
switch (p_pcb->state) {
|
||||
case BTA_JV_ST_CL_CLOSING:
|
||||
case BTA_JV_ST_SR_CLOSING:
|
||||
APPL_TRACE_WARNING("bta_jv_free_sr_rfc_cb: return on closing, port state:%d, "
|
||||
APPL_TRACE_DEBUG("bta_jv_free_sr_rfc_cb: return on closing, port state:%d, "
|
||||
"scn:%d, p_pcb:%p, user_data:%p", p_pcb->state, p_cb->scn, p_pcb,
|
||||
p_pcb->user_data);
|
||||
status = BTA_JV_FAILURE;
|
||||
return status;
|
||||
break;
|
||||
case BTA_JV_ST_CL_OPEN:
|
||||
case BTA_JV_ST_CL_OPENING:
|
||||
APPL_TRACE_DEBUG("bta_jv_free_sr_rfc_cb: state: %d, scn:%d,"
|
||||
@@ -1729,6 +1728,7 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle, void* dat
|
||||
UINT16 lcid;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback; /* the callback function */
|
||||
tPORT_MGMT_CL_CALLBACK_ARG *p_mgmt_cb_arg = (tPORT_MGMT_CL_CALLBACK_ARG *)data;
|
||||
void *user_data = NULL;
|
||||
|
||||
APPL_TRACE_DEBUG( "bta_jv_port_mgmt_cl_cback:code:%d, port_handle%d", code, port_handle);
|
||||
if (NULL == p_cb || NULL == p_cb->p_cback) {
|
||||
@@ -1758,13 +1758,14 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle, void* dat
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
}
|
||||
//p_pcb->state = BTA_JV_ST_NONE;
|
||||
//p_pcb->cong = FALSE;
|
||||
p_cback = p_cb->p_cback;
|
||||
p_cback(BTA_JV_RFCOMM_CLOSE_EVT, &evt_data, p_pcb->user_data);
|
||||
//bta_jv_free_rfc_cb(p_cb, p_pcb);
|
||||
}
|
||||
user_data = p_pcb->user_data;
|
||||
|
||||
// To free up resources.
|
||||
p_pcb->state = BTA_JV_ST_CL_CLOSING;
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb, FALSE, FALSE);
|
||||
p_cback(BTA_JV_RFCOMM_CLOSE_EVT, &evt_data, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1937,7 +1938,6 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
|
||||
tBTA_JV_API_RFCOMM_CLOSE *cc = &(p_data->rfcomm_close);
|
||||
tBTA_JV_RFC_CB *p_cb = NULL;
|
||||
tBTA_JV_PCB *p_pcb = NULL;
|
||||
tBTA_JV evt_data = {0};
|
||||
APPL_TRACE_DEBUG("%s, rfc handle:%d",__func__, cc->handle);
|
||||
if (!cc->handle) {
|
||||
APPL_TRACE_ERROR("%s, rfc handle is null", __func__);
|
||||
@@ -1948,20 +1948,9 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
|
||||
if (!find_rfc_pcb(user_data, &p_cb, &p_pcb)) {
|
||||
return;
|
||||
}
|
||||
if(cc->p_cback) {
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
evt_data.rfc_close.port_status = PORT_LOCAL_CLOSED;
|
||||
evt_data.rfc_close.handle = cc->handle;
|
||||
evt_data.rfc_close.async = TRUE;
|
||||
if (p_pcb && (p_pcb->state == BTA_JV_ST_SR_LISTEN ||
|
||||
p_pcb->state == BTA_JV_ST_SR_OPEN ||
|
||||
p_pcb->state == BTA_JV_ST_CL_OPEN ||
|
||||
p_pcb->state == BTA_JV_ST_CL_OPENING)) {
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
}
|
||||
cc->p_cback(BTA_JV_RFCOMM_CLOSE_EVT, (tBTA_JV *)&evt_data, user_data);
|
||||
}
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb, FALSE);
|
||||
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb, FALSE, TRUE);
|
||||
|
||||
APPL_TRACE_DEBUG("%s: sec id in use:%d, rfc_cb in use:%d",__func__,
|
||||
get_sec_id_used(), get_rfc_cb_used());
|
||||
}
|
||||
@@ -2062,7 +2051,7 @@ static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle, void *dat
|
||||
APPL_TRACE_ERROR("create new listen port, but upper layer reject connection");
|
||||
p_pcb_new_listen->user_data = NULL;
|
||||
p_pcb->state = BTA_JV_ST_SR_LISTEN;
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb_new_listen, FALSE);
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb_new_listen, FALSE, FALSE);
|
||||
if (p_mgmt_cb_arg) {
|
||||
p_mgmt_cb_arg->accept = FALSE;
|
||||
}
|
||||
@@ -2102,10 +2091,11 @@ static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle, void *dat
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
}
|
||||
//p_pcb->state = BTA_JV_ST_NONE;
|
||||
p_cback(BTA_JV_RFCOMM_CLOSE_EVT, &evt_data, user_data);
|
||||
//bta_jv_free_rfc_cb(p_cb, p_pcb);
|
||||
|
||||
// To free up resources.
|
||||
p_pcb->state = BTA_JV_ST_SR_CLOSING;
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb, FALSE, FALSE);
|
||||
p_cback(BTA_JV_RFCOMM_CLOSE_EVT, &evt_data, user_data);
|
||||
APPL_TRACE_DEBUG("PORT_CLOSED after BTA_JV_RFCOMM_CLOSE_EVT: curr_sess:%d, max_sess:%d",
|
||||
p_cb->curr_sess, p_cb->max_sess);
|
||||
}
|
||||
@@ -2339,7 +2329,7 @@ void bta_jv_rfcomm_stop_server(tBTA_JV_MSG *p_data)
|
||||
}
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_stop_server: p_pcb:%p, p_pcb->port_handle:%d",
|
||||
p_pcb, p_pcb->port_handle);
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb, TRUE);
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb, TRUE, FALSE);
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_stop_server: sec id in use:%d, rfc_cb in use:%d",
|
||||
get_sec_id_used(), get_rfc_cb_used());
|
||||
}
|
||||
|
||||
@@ -939,7 +939,7 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_RFCOMM_CLOSE *p_msg;
|
||||
@@ -954,7 +954,6 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, v
|
||||
p_msg->handle = handle;
|
||||
p_msg->p_cb = &bta_jv_cb.rfc_cb[hi];
|
||||
p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1];
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
status = BTA_JV_SUCCESS;
|
||||
|
||||
@@ -340,7 +340,6 @@ typedef struct {
|
||||
UINT32 handle;
|
||||
tBTA_JV_RFC_CB *p_cb;
|
||||
tBTA_JV_PCB *p_pcb;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_RFCOMM_CLOSE;
|
||||
#endif /* BTA_JV_RFCOMM_INCLUDED */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -72,8 +72,10 @@ static void _btc_storage_save(void)
|
||||
BTA_DmRemoveDevice(bd_addr.address, BT_TRANSPORT_LE);
|
||||
BTA_DmRemoveDevice(bd_addr.address, BT_TRANSPORT_BR_EDR);
|
||||
//delete config info
|
||||
if(btc_config_remove_section(need_remove_section)) {
|
||||
BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section);
|
||||
if (btc_config_remove_section(need_remove_section)) {
|
||||
// The need_remove_section has been freed
|
||||
BTIF_TRACE_WARNING("Exceeded the maximum number of bonded devices. Deleting the last device info: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,6 +413,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
msg->pid = BTC_PID_GAP_BT;
|
||||
msg->act = BTC_GAP_BT_AUTH_CMPL_EVT;
|
||||
param.auth_cmpl.stat = status;
|
||||
param.auth_cmpl.lk_type = p_auth_cmpl->key_type;
|
||||
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
|
||||
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
|
||||
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||
@@ -428,6 +429,34 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
(void) status;
|
||||
}
|
||||
|
||||
static void btc_dm_enc_chg_evt (tBTA_DM_ENC_CHG *p_enc_chg)
|
||||
{
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t *msg;
|
||||
|
||||
msg = (btc_msg_t *)osi_malloc(sizeof(btc_msg_t) + sizeof(esp_bt_gap_cb_param_t));
|
||||
if (msg == NULL) {
|
||||
BTC_TRACE_ERROR("%s malloc fail", __func__);
|
||||
return;
|
||||
}
|
||||
msg->sig = BTC_SIG_API_CB;
|
||||
msg->pid = BTC_PID_GAP_BT;
|
||||
msg->act = BTC_GAP_BT_ENC_CHG_EVT;
|
||||
param.enc_chg.enc_mode = p_enc_chg->enc_mode;
|
||||
memcpy(param.enc_chg.bda, p_enc_chg->bd_addr, ESP_BD_ADDR_LEN);
|
||||
memcpy(msg->arg, ¶m, sizeof(esp_bt_gap_cb_param_t));
|
||||
|
||||
ret = btc_inter_profile_call(msg);
|
||||
osi_free(msg);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
|
||||
{
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
@@ -782,6 +811,9 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
case BTA_DM_AUTH_CMPL_EVT:
|
||||
btc_dm_auth_cmpl_evt(&p_data->auth_cmpl);
|
||||
break;
|
||||
case BTA_DM_ENC_CHG_EVT:
|
||||
btc_dm_enc_chg_evt(&p_data->enc_chg);
|
||||
break;
|
||||
case BTA_DM_BOND_CANCEL_CMPL_EVT:
|
||||
BTC_TRACE_DEBUG("BTA_DM_BOND_CANCEL_CMPL_EVT");
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -116,3 +116,77 @@ void btc_main_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t btc_get_ble_status(void)
|
||||
{
|
||||
uint32_t status = BTC_BLE_STATUS_IDLE;
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
// Number of active advertising
|
||||
extern uint8_t btm_ble_adv_active_count(void);
|
||||
if (btm_ble_adv_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_ADV);
|
||||
}
|
||||
|
||||
// Number of active scanning
|
||||
extern uint8_t btm_ble_scan_active_count(void);
|
||||
if (btm_ble_scan_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_SCAN);
|
||||
}
|
||||
|
||||
// Number of active GATT tcb
|
||||
extern uint8_t gatt_tcb_active_count(void);
|
||||
if (gatt_tcb_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_CONN);
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
// Number of saved bonded devices
|
||||
if (btc_storage_get_num_ble_bond_devices()) {
|
||||
status |= BIT(BTC_BLE_STATUS_BOND);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Number of recorded devices
|
||||
extern uint8_t btdm_sec_dev_active_count(void);
|
||||
if (btdm_sec_dev_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_DEV);
|
||||
}
|
||||
|
||||
// Number of active ACL connection
|
||||
extern uint8_t btm_acl_active_count(void);
|
||||
if (btm_acl_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_CONN);
|
||||
}
|
||||
|
||||
// Number of active L2C plcb
|
||||
extern uint8_t l2cu_plcb_active_count(void);
|
||||
if (l2cu_plcb_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_CONN);
|
||||
}
|
||||
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
// Number of registered GATTC APP
|
||||
extern uint8_t bta_gattc_cl_rcb_active_count(void);
|
||||
if (bta_gattc_cl_rcb_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_GATTC_APP);
|
||||
}
|
||||
|
||||
// Number of saved GATTC cache
|
||||
extern UINT8 bta_gattc_co_get_addr_num(void);
|
||||
if (bta_gattc_co_get_addr_num()) {
|
||||
status |= BIT(BTC_BLE_STATUS_GATTC_CACHE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
// Number of registered GATTS service
|
||||
extern uint8_t bta_gatts_srvc_active_count(void);
|
||||
if (bta_gatts_srvc_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_GATTS_SRVC);
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -57,7 +57,8 @@ bt_status_t btc_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
|
||||
|
||||
// delete config info
|
||||
if (btc_config_remove_section(remove_section)) {
|
||||
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %s\n", remove_section);
|
||||
BTC_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the first device info : %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +132,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
bt_status_t status = BT_STATUS_FAIL;
|
||||
uint16_t dev_cnt = 0;
|
||||
const btc_config_section_iter_t *remove_iter = NULL;
|
||||
bt_bdaddr_t bd_addr;
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end(); iter = btc_config_section_next(iter)) {
|
||||
@@ -157,6 +159,7 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
remove_iter = iter;
|
||||
while (remove_iter != btc_config_section_end()) {
|
||||
const char *remove_section = btc_config_section_name(remove_iter);
|
||||
string_to_bdaddr(remove_section, &bd_addr);
|
||||
if (!string_is_bdaddr(remove_section)) {
|
||||
remove_iter = btc_config_section_next(remove_iter);
|
||||
continue;
|
||||
@@ -164,7 +167,8 @@ static bt_status_t btc_in_fetch_bonded_devices(int add)
|
||||
remove_iter = btc_config_section_next(remove_iter);
|
||||
/* delete config info */
|
||||
if (btc_config_remove_section(remove_section)) {
|
||||
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the exceed device info : %s", remove_section);
|
||||
BTC_TRACE_WARNING("exceeded the maximum number of bonded devices, delete the exceed device info : %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bd_addr.address[0], bd_addr.address[1], bd_addr.address[2], bd_addr.address[3], bd_addr.address[4], bd_addr.address[5]);
|
||||
}
|
||||
}
|
||||
/* write into nvs */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -28,6 +28,18 @@ typedef enum {
|
||||
BTC_MAIN_FUTURE_NUM,
|
||||
} btc_main_future_type_t;
|
||||
|
||||
#define BTC_BLE_STATUS_IDLE 0
|
||||
typedef enum {
|
||||
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
||||
BTC_BLE_STATUS_SCAN, // Scanning exist
|
||||
BTC_BLE_STATUS_CONN, // Connection exist
|
||||
BTC_BLE_STATUS_DEV, // Device record exist
|
||||
BTC_BLE_STATUS_BOND, // Bond info exist
|
||||
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
|
||||
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist
|
||||
BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist
|
||||
} tBTC_BLE_STATUS;
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -1086,6 +1086,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
|
||||
case BTC_GAP_BT_CONFIG_EIR_DATA_EVT:
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
case BTC_GAP_BT_ENC_CHG_EVT:
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:
|
||||
case BTC_GAP_BT_SET_AFH_CHANNELS_EVT:
|
||||
case BTC_GAP_BT_READ_REMOTE_NAME_EVT:
|
||||
@@ -1134,6 +1135,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ENC_CHG_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_ENC_CHG_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_PIN_REQ_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
|
||||
@@ -20,6 +20,7 @@ typedef enum {
|
||||
BTC_GAP_BT_SEARCH_SERVICES_EVT,
|
||||
BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT,
|
||||
BTC_GAP_BT_AUTH_CMPL_EVT,
|
||||
BTC_GAP_BT_ENC_CHG_EVT,
|
||||
BTC_GAP_BT_PIN_REQ_EVT,
|
||||
BTC_GAP_BT_CFM_REQ_EVT,
|
||||
BTC_GAP_BT_KEY_NOTIF_EVT,
|
||||
|
||||
@@ -424,19 +424,6 @@ static void *btc_spp_rfcomm_inter_cb(tBTA_JV_EVT event, tBTA_JV *p_data, void *u
|
||||
slot->rfc_port_handle = BTA_JvRfcommGetPortHdl(p_data->rfc_open.handle);
|
||||
BTA_JvSetPmProfile(p_data->rfc_open.handle, BTA_JV_PM_ID_1, BTA_JV_CONN_OPEN);
|
||||
break;
|
||||
case BTA_JV_RFCOMM_CLOSE_EVT:
|
||||
slot = spp_find_slot_by_id(id);
|
||||
if (!slot) {
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot, event:%d!", __func__, event);
|
||||
p_data->rfc_close.status = ESP_SPP_NO_CONNECTION;
|
||||
break;
|
||||
}
|
||||
if (slot->rfc_handle && p_data->rfc_close.port_status != PORT_LOCAL_CLOSED) {
|
||||
BTA_JvRfcommClose(slot->rfc_handle, NULL, (void *)slot->id);
|
||||
}
|
||||
p_data->rfc_close.status = BTA_JV_SUCCESS;
|
||||
p_data->rfc_close.user_data = (void *)(uintptr_t)slot->id;
|
||||
break;
|
||||
case BTA_JV_RFCOMM_DATA_IND_EVT:
|
||||
break;
|
||||
case BTA_JV_FREE_SCN_EVT:
|
||||
@@ -608,8 +595,7 @@ static void btc_spp_uninit(void)
|
||||
// first, remove all connection
|
||||
for (size_t i = 1; i <= MAX_RFC_PORTS; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->is_server) {
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb,
|
||||
(void *)spp_local_param.spp_slots[i]->id);
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle, (void *)spp_local_param.spp_slots[i]->id);
|
||||
}
|
||||
}
|
||||
// second, remove all server
|
||||
@@ -727,7 +713,7 @@ static void btc_spp_disconnect(btc_spp_args_t *arg)
|
||||
ret = ESP_SPP_NO_CONNECTION;
|
||||
break;
|
||||
}
|
||||
BTA_JvRfcommClose(arg->disconnect.handle, (tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb, (void *)slot->id);
|
||||
BTA_JvRfcommClose(arg->disconnect.handle, (void *)slot->id);
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
} while(0);
|
||||
|
||||
@@ -835,9 +821,7 @@ static void btc_spp_stop_srv(btc_spp_args_t *arg)
|
||||
if (spp_local_param.spp_slots[i] != NULL && !spp_local_param.spp_slots[i]->is_server &&
|
||||
spp_local_param.spp_slots[i]->sdp_handle > 0 &&
|
||||
spp_local_param.spp_slots[i]->scn == srv_scn_arr[j]) {
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle,
|
||||
(tBTA_JV_RFCOMM_CBACK *)btc_spp_rfcomm_inter_cb,
|
||||
(void *)spp_local_param.spp_slots[i]->id);
|
||||
BTA_JvRfcommClose(spp_local_param.spp_slots[i]->rfc_handle, (void *)spp_local_param.spp_slots[i]->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1175,28 +1159,27 @@ void btc_spp_cb_handler(btc_msg_t *msg)
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
break;
|
||||
case BTA_JV_RFCOMM_CLOSE_EVT:
|
||||
param.close.status = p_data->rfc_close.status;
|
||||
param.close.status = BTA_JV_SUCCESS;
|
||||
param.close.port_status = p_data->rfc_close.port_status;
|
||||
param.close.handle = p_data->rfc_close.handle;
|
||||
param.close.async = p_data->rfc_close.async;
|
||||
if (spp_local_param.spp_mode == ESP_SPP_MODE_CB) {
|
||||
btc_spp_cb_to_app(ESP_SPP_CLOSE_EVT, ¶m);
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
uint32_t id = (uintptr_t)p_data->rfc_close.user_data;
|
||||
slot = spp_find_slot_by_id(id);
|
||||
slot = spp_find_slot_by_handle(p_data->rfc_close.handle);
|
||||
if (!slot) {
|
||||
param.close.status = ESP_SPP_NO_CONNECTION;
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
BTC_TRACE_ERROR("%s unable to find RFCOMM slot, event:%d!", __func__, event);
|
||||
break;
|
||||
}
|
||||
spp_free_slot(slot);
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
btc_spp_cb_to_app(ESP_SPP_CLOSE_EVT, ¶m);
|
||||
} else {
|
||||
bool need_call = true;
|
||||
do {
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
uint32_t id = (uintptr_t)p_data->rfc_close.user_data;
|
||||
slot = spp_find_slot_by_id(id);
|
||||
slot = spp_find_slot_by_handle(p_data->rfc_close.handle);
|
||||
if (!slot) {
|
||||
param.close.status = ESP_SPP_NO_CONNECTION;
|
||||
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
|
||||
|
||||
@@ -203,6 +203,12 @@
|
||||
#define UC_BT_SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_SMP_MAX_BONDS
|
||||
#define UC_BT_SMP_MAX_BONDS CONFIG_BT_SMP_MAX_BONDS
|
||||
#else
|
||||
#define UC_BT_SMP_MAX_BONDS 8
|
||||
#endif
|
||||
|
||||
//Device Nane Maximum Length
|
||||
#ifdef CONFIG_BT_MAX_DEVICE_NAME_LEN
|
||||
#define UC_MAX_LOC_BD_NAME_LEN CONFIG_BT_MAX_DEVICE_NAME_LEN
|
||||
|
||||
@@ -894,13 +894,9 @@
|
||||
#define BTM_DEFAULT_SCO_MODE 2
|
||||
#endif
|
||||
|
||||
/* The number of security records for peer devices. 100 AS Default*/
|
||||
/* The number of security records for peer devices. 15 AS Default*/
|
||||
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
|
||||
#if SMP_INCLUDED == TRUE
|
||||
#define BTM_SEC_MAX_DEVICE_RECORDS 15 // 100
|
||||
#else
|
||||
#define BTM_SEC_MAX_DEVICE_RECORDS 8
|
||||
#endif /* SMP_INCLUDED == TRUE */
|
||||
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS
|
||||
#endif
|
||||
|
||||
/* The number of security records for services. 32 AS Default*/
|
||||
|
||||
@@ -142,15 +142,20 @@ static bool hci_hal_env_init(const hci_hal_callbacks_t *upper_callbacks, osi_thr
|
||||
|
||||
static void hci_hal_env_deinit(void)
|
||||
{
|
||||
fixed_queue_free(hci_hal_env.rx_q, osi_free_func);
|
||||
fixed_queue_t *rx_q = hci_hal_env.rx_q;
|
||||
struct pkt_queue *adv_rpt_q = hci_hal_env.adv_rpt_q;
|
||||
struct osi_event *upstream_data_ready = hci_hal_env.upstream_data_ready;
|
||||
|
||||
hci_hal_env.rx_q = NULL;
|
||||
|
||||
pkt_queue_destroy(hci_hal_env.adv_rpt_q, NULL);
|
||||
hci_hal_env.adv_rpt_q = NULL;
|
||||
|
||||
osi_event_delete(hci_hal_env.upstream_data_ready);
|
||||
hci_hal_env.upstream_data_ready = NULL;
|
||||
|
||||
fixed_queue_free(rx_q, osi_free_func);
|
||||
|
||||
pkt_queue_destroy(adv_rpt_q, NULL);
|
||||
|
||||
osi_event_delete(upstream_data_ready);
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_hal_env.cmd_buf_in_use = true;
|
||||
osi_alarm_cancel(hci_hal_env.adv_flow_monitor);
|
||||
|
||||
@@ -2907,5 +2907,28 @@ BOOLEAN btm_get_current_conn_params(BD_ADDR bda, UINT16 *interval, UINT16 *laten
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
uint8_t btm_ble_adv_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
|
||||
if (p_cb->state & BTM_BLE_ADVERTISING) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t btm_ble_scan_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
|
||||
|
||||
if (p_cb->state & BTM_BLE_SCANNING) {
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
@@ -82,6 +82,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_name,
|
||||
memcpy (p_dev_rec->bd_addr, bd_addr, BD_ADDR_LEN);
|
||||
p_dev_rec->hci_handle = BTM_GetHCIConnHandle (bd_addr, BT_TRANSPORT_BR_EDR);
|
||||
p_dev_rec->ble_hci_handle = BTM_GetHCIConnHandle (bd_addr, BT_TRANSPORT_LE);
|
||||
p_dev_rec->enc_mode = BTM_ENC_MODE_UNKNOWN;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* use default value for background connection params */
|
||||
|
||||
@@ -117,3 +117,36 @@ void btm_free(void)
|
||||
btm_ble_sem_free();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t btm_acl_active_count(void)
|
||||
{
|
||||
list_node_t *p_node = NULL;
|
||||
tACL_CONN *p_acl_conn = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
for (p_node = list_begin(btm_cb.p_acl_db_list); p_node; p_node = list_next(p_node)) {
|
||||
p_acl_conn = list_node(p_node);
|
||||
if (p_acl_conn && p_acl_conn->in_use) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t btdm_sec_dev_active_count(void)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
/* First look for the non-paired devices for the oldest entry */
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -4092,6 +4092,13 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
|
||||
p_dev_rec->link_key_type == BTM_LKEY_TYPE_AUTH_COMB_P_256) {
|
||||
p_dev_rec->sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED;
|
||||
}
|
||||
if (p_dev_rec->enc_mode != encr_enable) {
|
||||
p_dev_rec->enc_mode = encr_enable;
|
||||
/* Report the encryption change state of BR/EDR to upper layer */
|
||||
if (btm_cb.api.p_enc_change_callback) {
|
||||
(*btm_cb.api.p_enc_change_callback) (p_dev_rec->bd_addr, encr_enable);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LE_ENCRYPTED;
|
||||
}
|
||||
@@ -4102,6 +4109,13 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
|
||||
if ((status == HCI_SUCCESS) && !encr_enable) {
|
||||
if (p_dev_rec->hci_handle == handle) {
|
||||
p_dev_rec->sec_flags &= ~BTM_SEC_ENCRYPTED;
|
||||
if (p_dev_rec->enc_mode != encr_enable) {
|
||||
p_dev_rec->enc_mode = encr_enable;
|
||||
/* Report the encryption change state of BR/EDR to upper layer */
|
||||
if (btm_cb.api.p_enc_change_callback) {
|
||||
(*btm_cb.api.p_enc_change_callback) (p_dev_rec->bd_addr, encr_enable);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p_dev_rec->sec_flags &= ~BTM_SEC_LE_ENCRYPTED;
|
||||
}
|
||||
|
||||
@@ -668,6 +668,9 @@ struct tBTM_SEC_DEV_REC{
|
||||
secure connection. This will be helpful to know when peer device downgrades it's security. */
|
||||
|
||||
UINT16 ble_hci_handle; /* use in DUMO connection */
|
||||
|
||||
#define BTM_ENC_MODE_UNKNOWN 0xff
|
||||
UINT8 enc_mode; /* encryption mode of current link */
|
||||
UINT8 enc_key_size; /* current link encryption key size */
|
||||
tBT_DEVICE_TYPE device_type;
|
||||
BOOLEAN new_encryption_key_is_p256; /* Set to TRUE when the newly generated LK
|
||||
|
||||
@@ -1231,4 +1231,20 @@ void gatt_set_local_mtu(uint16_t mtu)
|
||||
gatt_default.local_mtu = mtu;
|
||||
}
|
||||
|
||||
uint8_t gatt_tcb_active_count(void)
|
||||
{
|
||||
tGATT_TCB *p_tcb = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
for(p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
|
||||
p_tcb = list_node(p_node);
|
||||
if (p_tcb && p_tcb->in_use && (p_tcb->ch_state != GATT_CH_CLOSE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
@@ -1492,6 +1492,12 @@ typedef void (tBTM_RMT_NAME_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dc,
|
||||
typedef UINT8 (tBTM_AUTH_COMPLETE_CALLBACK) (BD_ADDR bd_addr, DEV_CLASS dev_class,
|
||||
tBTM_BD_NAME bd_name, int result);
|
||||
|
||||
/* Encryption changed for the connection. Parameters are
|
||||
** BD Address of remote
|
||||
** Encryption mode
|
||||
*/
|
||||
typedef void (tBTM_ENC_CHANGE_CALLBACK) (BD_ADDR bd_addr, UINT8 enc_mode);
|
||||
|
||||
enum {
|
||||
BTM_SP_IO_REQ_EVT, /* received IO_CAPABILITY_REQUEST event */
|
||||
BTM_SP_IO_RSP_EVT, /* received IO_CAPABILITY_RESPONSE event */
|
||||
@@ -1869,6 +1875,7 @@ typedef struct {
|
||||
tBTM_LINK_KEY_CALLBACK *p_link_key_callback;
|
||||
tBTM_AUTH_COMPLETE_CALLBACK *p_auth_complete_callback;
|
||||
tBTM_BOND_CANCEL_CMPL_CALLBACK *p_bond_cancel_cmpl_callback;
|
||||
tBTM_ENC_CHANGE_CALLBACK *p_enc_change_callback;
|
||||
tBTM_SP_CALLBACK *p_sp_callback;
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#if SMP_INCLUDED == TRUE
|
||||
|
||||
@@ -201,6 +201,17 @@ config BT_NIMBLE_LL_CFG_FEAT_LE_ENCRYPTION
|
||||
help
|
||||
Enable encryption connection
|
||||
|
||||
config BT_NIMBLE_SM_SC_LVL
|
||||
int "Security level"
|
||||
depends on BT_NIMBLE_SECURITY_ENABLE
|
||||
default 0
|
||||
help
|
||||
LE Security Mode 1 Levels:
|
||||
1. No Security
|
||||
2. Unauthenticated pairing with encryption
|
||||
3. Authenticated pairing with encryption
|
||||
4. Authenticated LE Secure Connections pairing with encryption using a 128-bit strength encryption key.
|
||||
|
||||
config BT_NIMBLE_DEBUG
|
||||
bool "Enable extra runtime asserts and host debugging"
|
||||
default n
|
||||
@@ -620,6 +631,36 @@ config BT_NIMBLE_PERIODIC_ADV_ENH
|
||||
help
|
||||
Enable the periodic advertising enhancements
|
||||
|
||||
menuconfig BT_NIMBLE_GATT_CACHING
|
||||
bool "Enable GATT caching"
|
||||
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
help
|
||||
Enable GATT caching
|
||||
config BT_NIMBLE_GATT_CACHING_MAX_CONNS
|
||||
int "Maximum connections to be cached"
|
||||
depends on BT_NIMBLE_GATT_CACHING
|
||||
default 1
|
||||
help
|
||||
Set this option to set the upper limit on number of connections to be cached.
|
||||
config BT_NIMBLE_GATT_CACHING_MAX_SVCS
|
||||
int "Maximum number of services per connection"
|
||||
depends on BT_NIMBLE_GATT_CACHING
|
||||
default 64
|
||||
help
|
||||
Set this option to set the upper limit on number of services per connection to be cached.
|
||||
config BT_NIMBLE_GATT_CACHING_MAX_CHRS
|
||||
int "Maximum number of characteristics per connection"
|
||||
depends on BT_NIMBLE_GATT_CACHING
|
||||
default 64
|
||||
help
|
||||
Set this option to set the upper limit on number of characteristics per connection to be cached.
|
||||
config BT_NIMBLE_GATT_CACHING_MAX_DSCS
|
||||
int "Maximum number of descriptors per connection"
|
||||
depends on BT_NIMBLE_GATT_CACHING
|
||||
default 64
|
||||
help
|
||||
Set this option to set the upper limit on number of discriptors per connection to be cached.
|
||||
|
||||
config BT_NIMBLE_WHITELIST_SIZE
|
||||
int "BLE white list size"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
@@ -885,3 +926,91 @@ config BT_NIMBLE_HOST_QUEUE_CONG_CHECK
|
||||
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.
|
||||
|
||||
menu "Host-controller Transport"
|
||||
config BT_NIMBLE_TRANSPORT_UART
|
||||
bool "Enable Uart Transport"
|
||||
default y
|
||||
depends on BT_CONTROLLER_DISABLED
|
||||
help
|
||||
Use UART transport
|
||||
|
||||
config BT_NIMBLE_TRANSPORT_UART_PORT
|
||||
int "Uart port"
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
default 1
|
||||
help
|
||||
Uart port
|
||||
|
||||
choice BT_NIMBLE_USE_HCI_UART_PARITY
|
||||
prompt "Uart PARITY"
|
||||
default UART_PARITY_NONE
|
||||
help
|
||||
Uart Parity
|
||||
|
||||
config UART_PARITY_NONE
|
||||
bool "None"
|
||||
config UART_PARITY_ODD
|
||||
bool "Odd"
|
||||
config UART_PARITY_EVEN
|
||||
bool "Even"
|
||||
endchoice
|
||||
|
||||
config BT_NIMBLE_TRANSPORT_UART_PARITY_NONE
|
||||
int
|
||||
default 0 if !UART_PARITY_NONE
|
||||
default 1 if UART_PARITY_NONE
|
||||
|
||||
config BT_NIMBLE_TRANSPORT_UART_PARITY_ODD
|
||||
int
|
||||
default 0 if !UART_PARITY_ODD
|
||||
default 1 if UART_PARITY_ODD
|
||||
|
||||
config BT_NIMBLE_TRANSPORT_UART_PARITY_EVEN
|
||||
int
|
||||
default 0 if !UART_PARITY_EVEN
|
||||
default 1 if UART_PARITY_EVEN
|
||||
|
||||
config BT_NIMBLE_UART_RX_PIN
|
||||
int "UART Rx pin"
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
default 5
|
||||
help
|
||||
Rx pin for Nimble Transport
|
||||
|
||||
config BT_NIMBLE_UART_TX_PIN
|
||||
int "UART Tx pin"
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
default 4
|
||||
help
|
||||
Tx pin for Nimble Transport
|
||||
|
||||
choice BT_NIMBLE_USE_HCI_UART_FLOW_CTRL
|
||||
prompt "Uart Flow Control"
|
||||
default UART_HW_FLOWCTRL_DISABLE
|
||||
help
|
||||
Uart Flow Control
|
||||
|
||||
config UART_HW_FLOWCTRL_DISABLE
|
||||
bool "Disable"
|
||||
config UART_HW_FLOWCTRL_CTS_RTS
|
||||
bool "Enable hardware flow control"
|
||||
endchoice
|
||||
|
||||
config BT_NIMBLE_HCI_UART_FLOW_CTRL
|
||||
int
|
||||
default 0 if UART_HW_FLOWCTRL_DISABLE
|
||||
default 1 if UART_HW_FLOWCTRL_CTS_RTS
|
||||
|
||||
config BT_NIMBLE_HCI_UART_RTS_PIN
|
||||
int "UART Rts Pin"
|
||||
default 19
|
||||
help
|
||||
UART HCI RTS pin
|
||||
|
||||
config BT_NIMBLE_HCI_UART_CTS_PIN
|
||||
int "UART Cts Pin"
|
||||
default 23
|
||||
help
|
||||
UART HCI CTS pin
|
||||
endmenu
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#include "esp_nimble_hci.h"
|
||||
#include "esp_nimble_mem.h"
|
||||
#include "bt_osi_mem.h"
|
||||
#if CONFIG_BT_CONTROLLER_ENABLED
|
||||
#include "esp_bt.h"
|
||||
#endif
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
Submodule components/bt/host/nimble/nimble updated: f29df73af6...7997c0067c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -129,6 +129,16 @@
|
||||
#define MYNEWT_VAL_BLE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_NIMBLE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_GATT_CACHING
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING (CONFIG_BT_NIMBLE_GATT_CACHING)
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_CONNS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_CONNS)
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_SVCS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_SVCS)
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_CHRS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_CHRS)
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_DSCS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_DSCS)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES
|
||||
#define MYNEWT_VAL_BLE_MULTI_ADV_INSTANCES (1)
|
||||
#else
|
||||
@@ -834,7 +844,7 @@
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_LVL
|
||||
#define MYNEWT_VAL_BLE_SM_SC_LVL (0)
|
||||
#define MYNEWT_VAL_BLE_SM_SC_LVL CONFIG_BT_NIMBLE_SM_SC_LVL
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_ONLY
|
||||
@@ -1782,4 +1792,38 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_CONTROLLER_DISABLED
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PORT
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PORT CONFIG_BT_NIMBLE_TRANSPORT_UART_PORT
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__none
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__none CONFIG_BT_NIMBLE_TRANSPORT_UART_PARITY_NONE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__odd
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__odd CONFIG_BT_NIMBLE_TRANSPORT_UART_PARITY_ODD
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__even
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PARITY__even CONFIG_BT_NIMBLE_TRANSPORT_UART_PARITY_EVEN
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_FLOW_CONTROL__rtscts
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_FLOW_CONTROL__rtscts CONFIG_BT_NIMBLE_HCI_UART_FLOW_CTRL
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE (921600)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_DATA_BITS
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_DATA_BITS (3)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_STOP_BITS
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_STOP_BITS (1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
40
components/bt/host/nimble/port/src/nvs_port.c
Normal file
40
components/bt/host/nimble/port/src/nvs_port.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _NVS_H
|
||||
#define _NVS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nvs.h"
|
||||
#include "nimble/storage_port.h"
|
||||
|
||||
static int
|
||||
nvs_open_custom(const char* namespace_name, open_mode_t open_mode, cache_handle_t *out_handle)
|
||||
{
|
||||
switch (open_mode) {
|
||||
case READONLY:
|
||||
return nvs_open(namespace_name, NVS_READONLY, out_handle);
|
||||
|
||||
case READWRITE:
|
||||
return nvs_open(namespace_name, NVS_READWRITE, out_handle);
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
struct cache_fn_mapping
|
||||
link_storage_fn(void *storage_cb)
|
||||
{
|
||||
struct cache_fn_mapping cache_fn;
|
||||
cache_fn.open = nvs_open_custom;
|
||||
cache_fn.close = nvs_close;
|
||||
cache_fn.erase_all = nvs_erase_all;
|
||||
cache_fn.write = nvs_set_blob;
|
||||
cache_fn.read = nvs_get_blob;
|
||||
return cache_fn;
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02307120
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02401120
|
||||
|
||||
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
|
||||
#define ESP_BT_HCI_TL_VERSION 0x00010000
|
||||
@@ -188,6 +188,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
#define BT_BLE_CCA_MODE (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_BLE_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#define BT_BLE_ADV_DATA_LENGTH_ZERO_AUX (CONFIG_BT_BLE_ADV_DATA_LENGTH_ZERO_AUX)
|
||||
#else
|
||||
#define BT_BLE_ADV_DATA_LENGTH_ZERO_AUX (0)
|
||||
#endif
|
||||
|
||||
#define AGC_RECORRECT_EN ((BT_CTRL_AGC_RECORRECT_EN << 0) | (BT_CTRL_CODED_AGC_RECORRECT <<1) | (BT_CTRL_AGC_RECORRECT_NEW << 2))
|
||||
|
||||
#define CFG_MASK_BIT_SCAN_DUPLICATE_OPTION (1<<0)
|
||||
@@ -234,6 +240,7 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
.dup_list_refresh_period = DUPL_SCAN_CACHE_REFRESH_PERIOD, \
|
||||
.ble_50_feat_supp = BT_CTRL_50_FEATURE_SUPPORT, \
|
||||
.ble_cca_mode = BT_BLE_CCA_MODE, \
|
||||
.ble_data_lenth_zero_aux = BT_BLE_ADV_DATA_LENGTH_ZERO_AUX, \
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -305,6 +312,7 @@ typedef struct {
|
||||
uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */
|
||||
bool ble_50_feat_supp; /*!< BLE 5.0 feature support */
|
||||
uint8_t ble_cca_mode; /*!< BLE CCA mode */
|
||||
uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option*/
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
|
||||
struct os_mempool;
|
||||
struct os_mbuf_pool;
|
||||
|
||||
@@ -63,7 +63,7 @@ extern "C" {
|
||||
typedef int ble_hci_trans_rx_cmd_fn(uint8_t *cmd, void *arg);
|
||||
typedef int ble_hci_trans_rx_acl_fn(struct os_mbuf *om, void *arg);
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
#define ble_transport_alloc_cmd() ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD)
|
||||
#define ble_transport_alloc_event(X) ble_hci_trans_buf_alloc(X ? BLE_HCI_TRANS_BUF_EVT_LO : BLE_HCI_TRANS_BUF_EVT_HI)
|
||||
#define ble_transport_free ble_hci_trans_buf_free
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -92,6 +92,10 @@ extern "C" {
|
||||
#define NIMBLE_BLE_ATT_CLT_WRITE \
|
||||
(MYNEWT_VAL(BLE_GATT_WRITE))
|
||||
|
||||
#undef NIMBLE_BLE_ATT_CLT_SIGNED_WRITE
|
||||
#define NIMBLE_BLE_ATT_CLT_SIGNED_WRITE \
|
||||
(MYNEWT_VAL(BLE_GATT_SIGNED_WRITE))
|
||||
|
||||
#undef NIMBLE_BLE_ATT_CLT_WRITE_NO_RSP
|
||||
#define NIMBLE_BLE_ATT_CLT_WRITE_NO_RSP \
|
||||
(MYNEWT_VAL(BLE_GATT_WRITE_NO_RSP))
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#define NIMBLE_HS_STACK_SIZE CONFIG_BT_NIMBLE_HOST_TASK_STACK_SIZE
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
#define NIMBLE_LL_STACK_SIZE CONFIG_BT_LE_CONTROLLER_TASK_STACK_SIZE
|
||||
#endif
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ extern "C" {
|
||||
|
||||
#endif
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
void r_put_le16(void *buf, uint16_t x);
|
||||
#define put_le16 r_put_le16
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ _os_mbuf_trailingspace(struct os_mbuf *om)
|
||||
#define OS_MBUF_TRAILINGSPACE(__om) _os_mbuf_trailingspace(__om)
|
||||
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
/**
|
||||
* Initializes an mqueue. An mqueue is a queue of mbufs that ties to a
|
||||
* particular task's event queue. Mqueues form a helper API around a common
|
||||
|
||||
@@ -163,7 +163,7 @@ typedef __uint128_t os_membuf_t;
|
||||
#define OS_MEMPOOL_BYTES(n,blksize) \
|
||||
(sizeof (os_membuf_t) * OS_MEMPOOL_SIZE((n), (blksize)))
|
||||
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER
|
||||
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
|
||||
/**
|
||||
* Initialize a memory pool.
|
||||
*
|
||||
|
||||
@@ -804,6 +804,23 @@ uint32_t getMillis(void) {
|
||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||
}
|
||||
|
||||
static inline size_t prompt_len_ignore_escape_seq(const char *prompt) {
|
||||
size_t plen = 0;
|
||||
bool in_escape_sequence = false;
|
||||
|
||||
for (; *prompt != '\0'; ++prompt) {
|
||||
if (*prompt == '\033') {
|
||||
in_escape_sequence = true;
|
||||
} else if (in_escape_sequence && *prompt == 'm') {
|
||||
in_escape_sequence = false;
|
||||
} else if (!in_escape_sequence) {
|
||||
++plen;
|
||||
}
|
||||
}
|
||||
|
||||
return plen;
|
||||
}
|
||||
|
||||
/* This function is the core of the line editing capability of linenoise.
|
||||
* It expects 'fd' to be already in "raw mode" so that every key pressed
|
||||
* will be returned ASAP to read().
|
||||
@@ -839,15 +856,16 @@ static int linenoiseEdit(char *buf, size_t buflen, const char *prompt)
|
||||
* initially is just an empty string. */
|
||||
linenoiseHistoryAdd("");
|
||||
|
||||
int pos1 = getCursorPosition();
|
||||
if (write(out_fd, prompt,l.plen) == -1) {
|
||||
return -1;
|
||||
}
|
||||
flushWrite();
|
||||
int pos2 = getCursorPosition();
|
||||
if (pos1 >= 0 && pos2 >= 0) {
|
||||
l.plen = pos2 - pos1;
|
||||
}
|
||||
|
||||
/* If the prompt has been registered with ANSI escape sequences
|
||||
* for terminal colors then we remove them from the prompt length
|
||||
* calculation. */
|
||||
l.plen = prompt_len_ignore_escape_seq(prompt);
|
||||
|
||||
while(1) {
|
||||
char c;
|
||||
int nread;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_private/spi_common_internal.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/adc_share_hw_ctrl.h"
|
||||
#include "hal/spi_ll.h"
|
||||
#include "hal/dac_ll.h"
|
||||
#include "hal/adc_ll.h"
|
||||
@@ -128,7 +129,7 @@ esp_err_t dac_dma_periph_init(uint32_t freq_hz, bool is_alternate, bool is_apll)
|
||||
esp_err_t ret = ESP_OK;
|
||||
/* Acquire DMA peripheral */
|
||||
ESP_RETURN_ON_FALSE(spicommon_periph_claim(DAC_DMA_PERIPH_SPI_HOST, "dac_dma"), ESP_ERR_NOT_FOUND, TAG, "Failed to acquire DAC DMA peripheral");
|
||||
periph_module_enable(PERIPH_SARADC_MODULE);
|
||||
adc_apb_periph_claim();
|
||||
/* Allocate DAC DMA peripheral object */
|
||||
s_ddp = (dac_dma_periph_spi_t *)heap_caps_calloc(1, sizeof(dac_dma_periph_spi_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||
ESP_GOTO_ON_FALSE(s_ddp, ESP_ERR_NO_MEM, err, TAG, "No memory for DAC DMA object");
|
||||
@@ -160,7 +161,7 @@ esp_err_t dac_dma_periph_deinit(void)
|
||||
}
|
||||
ESP_RETURN_ON_FALSE(spicommon_periph_free(DAC_DMA_PERIPH_SPI_HOST), ESP_FAIL, TAG, "Failed to release DAC DMA peripheral");
|
||||
spi_ll_disable_intr(s_ddp->periph_dev, SPI_LL_INTR_OUT_EOF | SPI_LL_INTR_OUT_TOTAL_EOF);
|
||||
periph_module_disable(PERIPH_SARADC_MODULE);
|
||||
adc_apb_periph_free();
|
||||
if (s_ddp) {
|
||||
if (s_ddp->use_apll) {
|
||||
periph_rtc_apll_release();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -176,7 +176,7 @@ esp_err_t adc_digi_deinitialize(void)
|
||||
free(s_adc_digi_ctx);
|
||||
s_adc_digi_ctx = NULL;
|
||||
|
||||
periph_module_disable(PERIPH_SARADC_MODULE);
|
||||
adc_apb_periph_free();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -319,10 +319,7 @@ esp_err_t adc_digi_initialize(const adc_digi_init_config_t *init_config)
|
||||
};
|
||||
adc_hal_dma_ctx_config(&s_adc_digi_ctx->hal, &config);
|
||||
|
||||
//enable ADC digital part
|
||||
periph_module_enable(PERIPH_SARADC_MODULE);
|
||||
//reset ADC digital part
|
||||
periph_module_reset(PERIPH_SARADC_MODULE);
|
||||
adc_apb_periph_claim();
|
||||
|
||||
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
|
||||
adc_hal_calibration_init(ADC_UNIT_1);
|
||||
@@ -396,6 +393,8 @@ esp_err_t adc_digi_start(void)
|
||||
ESP_LOGE(ADC_TAG, "The driver is already started");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
//reset ADC digital part to reset ADC sampling EOF counter
|
||||
periph_module_reset(PERIPH_SARADC_MODULE);
|
||||
sar_periph_ctrl_adc_continuous_power_acquire();
|
||||
//reset flags
|
||||
s_adc_digi_ctx->ringbuf_overflow_flag = 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user