forked from espressif/esp-idf
Compare commits
567 Commits
Author | SHA1 | Date | |
---|---|---|---|
143d26aa49 | |||
e1eabe6f6a | |||
0407ab426e | |||
bcbc4a9599 | |||
50737018cc | |||
19913cec43 | |||
bf80d8211e | |||
7d26cf16cc | |||
86c4d8737e | |||
8ffe0ff357 | |||
faf96bd108 | |||
8225cc75df | |||
0d6cae963b | |||
3a94beeb5b | |||
29f6537faf | |||
160f435e4d | |||
51d2d9041c | |||
5a6ac7f32f | |||
0f3f7d984a | |||
efdddbb253 | |||
ce9c7e4f79 | |||
66c0699411 | |||
646c851824 | |||
51a49a861a | |||
9b34085053 | |||
0f7dc2ec02 | |||
2e341f003a | |||
92c8fd24bb | |||
2aa255c875 | |||
5a3af62f44 | |||
bc1d87a846 | |||
71d0d08c4e | |||
0caa96584c | |||
5d4cd1269b | |||
6e1eb21bae | |||
0d1c490a7c | |||
dbd2cd2f7a | |||
34b14ddf5b | |||
9592346090 | |||
696d6867b4 | |||
f52b877199 | |||
a179125fd3 | |||
1dd8411e04 | |||
e6a71fe29c | |||
efe8490623 | |||
a29f30b5d3 | |||
c570e253fe | |||
7b7f597cb4 | |||
3a5249aea9 | |||
28c19e623f | |||
cabe66195c | |||
f0855c85ad | |||
569334267f | |||
9911823658 | |||
b90f32bffb | |||
20db198401 | |||
bf877941c4 | |||
f9a51fc784 | |||
aa09462685 | |||
365c336a98 | |||
95c768165f | |||
12f2ae47c6 | |||
fc6b44f500 | |||
0042aaafa1 | |||
adcf95dc9f | |||
e5ee10e89f | |||
c9f1cb2f4c | |||
a0c8de077b | |||
9e62340897 | |||
f451efd1d0 | |||
f490eda68c | |||
f2dfb0cf70 | |||
03aef3c087 | |||
9a6526554d | |||
8d4e1c0616 | |||
4e27cbb89f | |||
b51f89d827 | |||
e30c7a9b27 | |||
622842a983 | |||
2bcb02795e | |||
fd22441494 | |||
8f048ffddc | |||
3e3ce3da81 | |||
0a0f2caa1d | |||
2441858835 | |||
3545b58986 | |||
9f10f684d3 | |||
5d750fb8ce | |||
6f8f39a2e5 | |||
6c60d3ef29 | |||
ecaf8a7a61 | |||
7ef60d2c2b | |||
e524b4b1fd | |||
40cce58a52 | |||
c50d44e66e | |||
07a3eca372 | |||
626684578a | |||
5ba3b8c587 | |||
c286416762 | |||
fd1c127d34 | |||
b5aa65c136 | |||
61486620c7 | |||
396f477972 | |||
2165154c04 | |||
46e918cfa1 | |||
051d2fbdd5 | |||
41f91d3ef6 | |||
ffce53449b | |||
7314f44b13 | |||
4936110591 | |||
af9472bb7a | |||
d190c53ec8 | |||
26c6583bab | |||
b3720f80c7 | |||
8147d48ec8 | |||
8466b8d6d3 | |||
6e47143dc5 | |||
10c882764e | |||
4559434d5a | |||
25f837a148 | |||
53e295a616 | |||
156ffa412e | |||
7726102bfb | |||
8c74a4a989 | |||
48bd2152d0 | |||
7db01c954e | |||
d90868b42e | |||
7d60a78b31 | |||
23a8cbb247 | |||
f3fd849da1 | |||
7a2bd81870 | |||
2b6f7697b9 | |||
610b5579a7 | |||
15a9d4f4d3 | |||
65e9af5114 | |||
579cbd8229 | |||
2b84f3e6c4 | |||
10732770d3 | |||
f2c10cb443 | |||
c67b02db52 | |||
dc4c16f475 | |||
3f2bf11751 | |||
b1f264be69 | |||
d14f2c5fca | |||
35898c704f | |||
3564d6728c | |||
c5b1b57b09 | |||
fbd38ad19a | |||
2d5ee438fa | |||
46b12a560a | |||
f19bc120f1 | |||
9c87165bc8 | |||
6514820311 | |||
0af56e2815 | |||
a06b88d7f6 | |||
5e292d50ad | |||
321ecc94d3 | |||
f0f30f9d0c | |||
9ea662a4ba | |||
285925a43b | |||
9e51598ee7 | |||
5e321badd5 | |||
e943181f72 | |||
2dc98f3be8 | |||
3badf6ebd9 | |||
9a1b11c813 | |||
b933d851bf | |||
204b58a34c | |||
88c9506469 | |||
202664bac0 | |||
0500fa2344 | |||
fefc65f885 | |||
d7e257d8ba | |||
ca3df7de7f | |||
8849d6acfa | |||
e8e5410cef | |||
cc68a512d2 | |||
3a291da164 | |||
1173b4f51a | |||
f6d0a913de | |||
149171f119 | |||
94091761c4 | |||
262f3774e8 | |||
30f93365b5 | |||
e0748cdaf2 | |||
6cd6423092 | |||
38b1c93764 | |||
9f3f7009c0 | |||
69d8fab619 | |||
cc50d88a89 | |||
4aea2dce15 | |||
54c7379060 | |||
b12c2646fa | |||
39ac9cb44b | |||
64fbce50c2 | |||
d1e8b4473d | |||
38e2d3bec6 | |||
2192de7111 | |||
c7f4fb56d8 | |||
3201333f06 | |||
85a89db863 | |||
21a8a9a170 | |||
0ce9d2662d | |||
d4e13c011e | |||
f380d72825 | |||
6ccb4cf5b7 | |||
f8e24754d1 | |||
86975b7e8f | |||
c2bb7d7cd6 | |||
3451f3526f | |||
cc3ba7186f | |||
7d28c02fd5 | |||
1aa2f36dec | |||
3becdd7850 | |||
cfd7a5b84e | |||
cf2062f1d7 | |||
a742bad8f3 | |||
ef11260310 | |||
7b39d5e5c5 | |||
d5b0b36758 | |||
0a609be968 | |||
8fa409a0b5 | |||
2e9904556f | |||
8e32eb78a4 | |||
a3adc6c202 | |||
148a269808 | |||
7b3bedbc10 | |||
5b11428f00 | |||
4cd7fd89f5 | |||
ceb56a7a72 | |||
ebfa74310c | |||
b482ba117d | |||
07735424a2 | |||
f2f5a237c0 | |||
3be1c70d46 | |||
beb34b5390 | |||
3991084777 | |||
088439c634 | |||
dbd05d8986 | |||
02068cf328 | |||
7c5dd19c83 | |||
a6fb161309 | |||
0929dbbc9b | |||
4c27f9ced8 | |||
b800dfe6f1 | |||
caa1ef0cb6 | |||
97e7c14f4e | |||
c157c696e7 | |||
d900cb5a35 | |||
e8a4e70c42 | |||
4cb729283d | |||
6a3e160aaf | |||
70ecb7ec94 | |||
21e2c417e8 | |||
3ca82d5923 | |||
7af04d857f | |||
e070e1886f | |||
6da2bec1e8 | |||
73345bae44 | |||
b9f2531e8c | |||
b6e6a4f4b2 | |||
9420c5398f | |||
31c8be0738 | |||
cbc438c807 | |||
2d26163019 | |||
ff2624f09c | |||
11d141e87d | |||
91f29bef17 | |||
8ed62223cd | |||
de7a50dca0 | |||
a9eac4a124 | |||
3e27184c38 | |||
5758b739f1 | |||
2d7124e319 | |||
232408981d | |||
9821e533db | |||
6d8990f39b | |||
83a9a4dc70 | |||
630ffde6bb | |||
6af30250a8 | |||
30d2f13358 | |||
d7569b5862 | |||
db9979701a | |||
dca5ed2263 | |||
0ef3af367d | |||
9afe47425b | |||
f5d33fa889 | |||
29cef5a9cc | |||
40171d7307 | |||
e64bae3a0c | |||
a71fad46d4 | |||
2c9acce0ff | |||
8e58b31a69 | |||
bf152907a4 | |||
47ca5d53df | |||
c1fe8ceb83 | |||
db38c37cf7 | |||
71ce87c79e | |||
611c300a92 | |||
b7eb82d191 | |||
933674301f | |||
3b2e231ae3 | |||
881cd4310c | |||
13e6e9f592 | |||
cfc73a6de7 | |||
62e359a4e1 | |||
ab4024c84e | |||
f4ee20165e | |||
e443467f37 | |||
a6f990ffb9 | |||
43561a40d2 | |||
55f5c2e08d | |||
e4418f4f92 | |||
968728bf95 | |||
2073a6e738 | |||
95b72a96f8 | |||
2617dee69f | |||
f94db7bba7 | |||
f7f02c9a43 | |||
52f0b86965 | |||
12bbe0f39b | |||
536b2d8a65 | |||
f5ab51c9b7 | |||
8a5c712730 | |||
2287c28b41 | |||
129ac11c31 | |||
166918e802 | |||
4b028cca86 | |||
a9d266b921 | |||
dc9c2f3b60 | |||
ae1389afd9 | |||
92f1d7ae39 | |||
f73c972280 | |||
378a5b159a | |||
2ef218059b | |||
28a8349fb8 | |||
4acc941c3d | |||
4ae01f0c9d | |||
2c4e0cf878 | |||
4b739249c2 | |||
b3f4755ac2 | |||
0e022b7db9 | |||
9185c370dc | |||
b62182d75a | |||
890a341db4 | |||
04815c2d27 | |||
0af6d8ffe3 | |||
43b2563f5a | |||
16586524e9 | |||
f60acb2196 | |||
1d2a9efa55 | |||
5ab4a9da51 | |||
b63be2e08e | |||
6cf4e14671 | |||
39f7d1ad0b | |||
d3a29c2d08 | |||
31a8a488f0 | |||
b908d4325b | |||
54c148d289 | |||
60b937b5ca | |||
b816edac3c | |||
2ee0f98d05 | |||
f83296e448 | |||
09515bdfde | |||
081b623a34 | |||
871e95087e | |||
a3b3f9ae2d | |||
fb6f343ce5 | |||
e1069de9aa | |||
a219e9f819 | |||
8f8113f5cd | |||
cf3647fe40 | |||
06651c0951 | |||
d54fadef41 | |||
3b4353da5d | |||
261c5bf6a8 | |||
6132d7bce3 | |||
1db04ae574 | |||
6d4adb46f3 | |||
e681f449bc | |||
f3725a7821 | |||
34f6773471 | |||
d0e7fd4369 | |||
13a3edee8a | |||
56866567ae | |||
bc83d470e3 | |||
a298d32d65 | |||
172a216edb | |||
d5923f0e2e | |||
cd9249970f | |||
676a27c7cf | |||
33121c3311 | |||
38509b2b95 | |||
e821c22a8c | |||
8c363321db | |||
ce279988c3 | |||
7200b8bf77 | |||
7e5cd986a9 | |||
fa1e983028 | |||
71e344da20 | |||
620bba3a66 | |||
8f7f32c0a5 | |||
3cbbc3bbac | |||
5c42c831f5 | |||
8c57aa0242 | |||
0d5609ba92 | |||
e209307297 | |||
4ac347b295 | |||
fc3aa765cf | |||
31c94b25c5 | |||
5b8d1c9da3 | |||
7f784c84d2 | |||
532c8847c7 | |||
6dc31101ce | |||
c763b8089c | |||
7d9330d1af | |||
618aa6a3a4 | |||
762bf705bb | |||
5988e77a3a | |||
26e7f3fde6 | |||
ba2ff1876f | |||
0757e019f4 | |||
c68390f922 | |||
8e3a1876cb | |||
cc8652d8d2 | |||
3cd8538f53 | |||
0033b31442 | |||
56afb3bd1c | |||
e622ee0f41 | |||
2d50291b05 | |||
c9b1e1df60 | |||
9a72c11e6e | |||
39dbe7daa8 | |||
554a28e8a1 | |||
7a2885885c | |||
d154723a84 | |||
16918e400e | |||
510f726935 | |||
3295ed0995 | |||
924895f832 | |||
403268a13a | |||
6b3da6b188 | |||
93b4c71595 | |||
d6badc53eb | |||
cb7aaae35e | |||
18533e132a | |||
7a7128c7a3 | |||
208d87742c | |||
dd76df7aee | |||
deba35d2e5 | |||
9fdc36ed57 | |||
184f2f0fd6 | |||
b36f4aa813 | |||
4b6ac69c04 | |||
c7d73901d0 | |||
76cc8c1c0c | |||
38a2be75a9 | |||
c85fc16282 | |||
ab888394c3 | |||
b8a2b77f70 | |||
ef8341b5bc | |||
c31217d193 | |||
16a56e2e7a | |||
1b3c6fb1a1 | |||
f7177095cf | |||
0e89436769 | |||
40067fb50f | |||
167c21b987 | |||
a2f00b0adf | |||
feecafeb0e | |||
7bbbf2d4b3 | |||
21fb5085bd | |||
82a80005b9 | |||
b354c11db7 | |||
e5672e5d7f | |||
3e972a3ffe | |||
8bd09fb0a5 | |||
e90c90d1f6 | |||
2f72645320 | |||
4be28a798f | |||
eed94b87e2 | |||
a218d4b925 | |||
015f523939 | |||
7196573605 | |||
4a698ffb75 | |||
3368783bf0 | |||
7e0e514127 | |||
541c267af3 | |||
bbfe9f4efa | |||
9bd172356e | |||
1b8dd9f173 | |||
dd33cec716 | |||
1cb29ac446 | |||
7b368fc211 | |||
d6ceb4a31a | |||
d5f9eb65e9 | |||
ce3d20dcd2 | |||
1dc461ba80 | |||
f03382b0ff | |||
2ecd007974 | |||
c6e32c1a61 | |||
2f26bb2e65 | |||
3be2b430d1 | |||
ff01bcfd88 | |||
8442255ccc | |||
c92e677da4 | |||
6d2faf4172 | |||
826146e985 | |||
2faf3c9c34 | |||
3fedc3eb28 | |||
4148beca50 | |||
c71b38c467 | |||
8e2b189252 | |||
dca83700f2 | |||
37e131f76b | |||
c76f00373f | |||
24a713b3c4 | |||
88fe438524 | |||
7f1fd0b8d3 | |||
2c91bc7a50 | |||
3cec8d0122 | |||
6381817006 | |||
14a6b33d5e | |||
6505f82a80 | |||
c05a0ae6c3 | |||
2a9555f5dd | |||
f72df315f7 | |||
e7a263938b | |||
3ed0f8e113 | |||
7e1ccb56a7 | |||
50a0b00afa | |||
be8f34065d | |||
d0eab0f3ee | |||
7a530be302 | |||
b692bda09b | |||
e4a83f856e | |||
e25152a031 | |||
885aec7aba | |||
0c2419d798 | |||
a3a58546bc | |||
2f2f0fbcbd | |||
ec4c75b692 | |||
90ddbaac16 | |||
0176f912b6 | |||
615376d14a | |||
fe516fb7c2 | |||
f5c805160b | |||
00e3f7f6b6 | |||
d6b316c375 | |||
bc04b1f53b | |||
50ceb45e6f | |||
646c7a7515 | |||
cc7e91e1a3 | |||
725f0a7545 | |||
bd0984226e | |||
f330bb50b2 | |||
4f1e27fa76 | |||
16755a2c51 | |||
936b99d756 | |||
c88cc4950e | |||
54e5e440b1 | |||
e8bcda3512 | |||
35a30072f4 | |||
edb0374b9d | |||
78539acdd1 | |||
a1546e0714 | |||
8ff6afd29f |
2
.flake8
2
.flake8
@ -156,10 +156,10 @@ exclude =
|
||||
components/protocomm/python/sec0_pb2.py,
|
||||
components/protocomm/python/sec1_pb2.py,
|
||||
components/protocomm/python/session_pb2.py,
|
||||
components/wifi_provisioning/python/wifi_scan_pb2.py,
|
||||
components/wifi_provisioning/python/wifi_config_pb2.py,
|
||||
components/wifi_provisioning/python/wifi_constants_pb2.py,
|
||||
examples/provisioning/custom_config/components/custom_provisioning/python/custom_config_pb2.py,
|
||||
# temporary list (should be empty)
|
||||
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py,
|
||||
tools/esp_app_trace/pylibelf,
|
||||
tools/mass_mfg/mfg_gen.py,
|
||||
|
1136
.gitlab-ci.yml
1136
.gitlab-ci.yml
File diff suppressed because it is too large
Load Diff
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -69,3 +69,7 @@
|
||||
[submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"]
|
||||
path = examples/build_system/cmake/import_lib/main/lib/tinyxml2
|
||||
url = https://github.com/leethomason/tinyxml2
|
||||
|
||||
[submodule "components/nimble/nimble"]
|
||||
path = components/nimble/nimble
|
||||
url = https://github.com/espressif/esp-nimble.git
|
||||
|
21
.readthedocs.yml
Normal file
21
.readthedocs.yml
Normal file
@ -0,0 +1,21 @@
|
||||
# .readthedocs.yml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
formats:
|
||||
- pdf
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
version: 2.7
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
|
||||
# We need to list all the submodules included in documentation build by Doxygen
|
||||
submodules:
|
||||
include:
|
||||
- components/mqtt/esp-mqtt
|
118
CMakeLists.txt
118
CMakeLists.txt
@ -1,108 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(esp-idf C CXX ASM)
|
||||
|
||||
if(NOT IDF_PATH)
|
||||
set(IDF_PATH ${CMAKE_CURRENT_LIST_DIR})
|
||||
endif()
|
||||
|
||||
include(tools/cmake/idf_functions.cmake)
|
||||
|
||||
#
|
||||
# Set variables that control the build configuration and the build itself
|
||||
#
|
||||
idf_set_variables()
|
||||
|
||||
kconfig_set_variables()
|
||||
|
||||
#
|
||||
# Generate a component dependencies file, enumerating components to be included in the build
|
||||
# as well as their dependencies.
|
||||
#
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||
-D "COMPONENTS=${IDF_COMPONENTS}"
|
||||
-D "COMPONENT_REQUIRES_COMMON=${IDF_COMPONENT_REQUIRES_COMMON}"
|
||||
-D "EXCLUDE_COMPONENTS=${IDF_EXCLUDE_COMPONENTS}"
|
||||
-D "TEST_COMPONENTS=${IDF_TEST_COMPONENTS}"
|
||||
-D "TEST_EXCLUDE_COMPONENTS=${IDF_TEST_EXCLUDE_COMPONENTS}"
|
||||
-D "BUILD_TESTS=${IDF_BUILD_TESTS}"
|
||||
-D "DEPENDENCIES_FILE=${CMAKE_BINARY_DIR}/component_depends.cmake"
|
||||
-D "COMPONENT_DIRS=${IDF_COMPONENT_DIRS}"
|
||||
-D "BOOTLOADER_BUILD=${BOOTLOADER_BUILD}"
|
||||
-D "IDF_TARGET=${IDF_TARGET}"
|
||||
-D "IDF_PATH=${IDF_PATH}"
|
||||
-D "DEBUG=${DEBUG}"
|
||||
-P "${IDF_PATH}/tools/cmake/scripts/expand_requirements.cmake"
|
||||
WORKING_DIRECTORY "${PROJECT_PATH}"
|
||||
RESULT_VARIABLE expand_requirements_result)
|
||||
|
||||
if(expand_requirements_result)
|
||||
message(FATAL_ERROR "Failed to expand component requirements")
|
||||
endif()
|
||||
|
||||
include("${CMAKE_BINARY_DIR}/component_depends.cmake")
|
||||
|
||||
#
|
||||
# We now have the following component-related variables:
|
||||
#
|
||||
# IDF_COMPONENTS is the list of initial components set by the user
|
||||
# (or empty to include all components in the build).
|
||||
# BUILD_COMPONENTS is the list of components to include in the build.
|
||||
# BUILD_COMPONENT_PATHS is the paths to all of these components, obtained from the component dependencies file.
|
||||
#
|
||||
# Print the list of found components and test components
|
||||
#
|
||||
string(REPLACE ";" " " BUILD_COMPONENTS_SPACES "${BUILD_COMPONENTS}")
|
||||
message(STATUS "Component names: ${BUILD_COMPONENTS_SPACES}")
|
||||
unset(BUILD_COMPONENTS_SPACES)
|
||||
message(STATUS "Component paths: ${BUILD_COMPONENT_PATHS}")
|
||||
|
||||
# Print list of test components
|
||||
if(TESTS_ALL EQUAL 1 OR TEST_COMPONENTS)
|
||||
string(REPLACE ";" " " BUILD_TEST_COMPONENTS_SPACES "${BUILD_TEST_COMPONENTS}")
|
||||
message(STATUS "Test component names: ${BUILD_TEST_COMPONENTS_SPACES}")
|
||||
unset(BUILD_TEST_COMPONENTS_SPACES)
|
||||
message(STATUS "Test component paths: ${BUILD_TEST_COMPONENT_PATHS}")
|
||||
endif()
|
||||
|
||||
# Generate project configuration
|
||||
kconfig_process_config()
|
||||
|
||||
# Include sdkconfig.cmake so rest of the build knows the configuration
|
||||
include(${SDKCONFIG_CMAKE})
|
||||
|
||||
# Verify the environment is configured correctly
|
||||
idf_verify_environment()
|
||||
|
||||
# Check git revision (may trigger reruns of cmake)
|
||||
## sets IDF_VER to IDF git revision
|
||||
idf_get_git_revision()
|
||||
|
||||
# Check that the targets set in cache, sdkconfig, and in environment all match
|
||||
idf_check_config_target()
|
||||
|
||||
## get PROJECT_VER
|
||||
if(NOT BOOTLOADER_BUILD)
|
||||
app_get_revision("${CMAKE_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# Add some idf-wide definitions
|
||||
idf_set_global_compile_options()
|
||||
|
||||
# generate compile_commands.json (needs to come after project)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||
|
||||
#
|
||||
# Setup variables for linker script generation
|
||||
#
|
||||
ldgen_set_variables()
|
||||
|
||||
# Include any top-level project_include.cmake files from components
|
||||
foreach(component ${BUILD_COMPONENT_PATHS})
|
||||
set(COMPONENT_PATH "${component}")
|
||||
include_if_exists("${component}/project_include.cmake")
|
||||
unset(COMPONENT_PATH)
|
||||
endforeach()
|
||||
|
||||
#
|
||||
# Add each component to the build as a library
|
||||
#
|
||||
@ -144,18 +42,4 @@ foreach(component ${BUILD_COMPONENTS})
|
||||
add_component_dependencies(${component_target} ${dep_target} PRIVATE)
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(IDF_BUILD_ARTIFACTS)
|
||||
# Write project description JSON file
|
||||
make_json_list("${BUILD_COMPONENTS}" build_components_json)
|
||||
make_json_list("${BUILD_COMPONENT_PATHS}" build_component_paths_json)
|
||||
configure_file("${IDF_PATH}/tools/cmake/project_description.json.in"
|
||||
"${IDF_BUILD_ARTIFACTS_DIR}/project_description.json")
|
||||
unset(build_components_json)
|
||||
unset(build_component_paths_json)
|
||||
endif()
|
||||
|
||||
set(BUILD_COMPONENTS ${BUILD_COMPONENTS} PARENT_SCOPE)
|
||||
|
||||
ldgen_add_dependencies()
|
||||
endforeach()
|
4
Kconfig
4
Kconfig
@ -23,6 +23,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
default "IDF_TARGET_NOT_SET" if IDF_TARGET_ENV=""
|
||||
default IDF_TARGET_ENV
|
||||
|
||||
config IDF_FIRMWARE_CHIP_ID
|
||||
hex
|
||||
default 0x0000 if IDF_TARGET="esp32"
|
||||
default 0xFFFF
|
||||
|
||||
menu "SDK tool configuration"
|
||||
config TOOLPREFIX
|
||||
|
66
SUPPORT_POLICY.md
Normal file
66
SUPPORT_POLICY.md
Normal file
@ -0,0 +1,66 @@
|
||||
The latest support policy for ESP-IDF can be found at [https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md](https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md)
|
||||
|
||||
Support Period Policy
|
||||
=====================
|
||||
|
||||
Each ESP-IDF major and minor release (V4.0, V4.1, etc) is supported for
|
||||
18 months after the initial stable release date.
|
||||
|
||||
Supported means that the ESP-IDF team will continue to apply bug fixes,
|
||||
security fixes, etc to the release branch on GitHub, and periodically
|
||||
make new bugfix releases as needed.
|
||||
|
||||
Users are encouraged to upgrade to a newer ESP-IDF release before the
|
||||
support period finishes and the release becomes End of Life (EOL). It is
|
||||
our policy to not continue fixing bugs in End of Life releases.
|
||||
|
||||
Pre-release versions (betas, previews, `-rc` and `-dev` versions, etc)
|
||||
are not covered by any support period. Sometimes a particular feature is
|
||||
marked as \"Preview\" in a release, which means it is also not covered
|
||||
by the support period.
|
||||
|
||||
The ESP-IDF Programming Guide has information about the
|
||||
[different versions of ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/versions.html)
|
||||
(major, minor, bugfix, etc).
|
||||
|
||||
Long Term Support releases
|
||||
--------------------------
|
||||
|
||||
Some releases (starting with ESP-IDF V3.3) are designated Long Term
|
||||
Support (LTS). LTS releases are supported for 30 months (2.5 years)
|
||||
after the initial stable release date.
|
||||
|
||||
A new LTS release will be made at least every 18 months. This means
|
||||
there will always be a period of at least 12 months to upgrade from the
|
||||
previous LTS release to the following LTS release.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
ESP-IDF V3.3 was released in September 2019 and is a Long Term Support
|
||||
(LTS) release, meaning it will be supported for 30 months until February
|
||||
2022.
|
||||
|
||||
- The first V3.3 release was `v3.3` in September 2019.
|
||||
- The ESP-IDF team continues to backport bug fixes, security fixes,
|
||||
etc to the release branch `release/v3.3`.
|
||||
- Periodically stable bugfix releases are created from the release
|
||||
branch. For example `v3.3.1`, `v3.3.2`, etc. Users are encouraged to
|
||||
always update to the latest bugfix release.
|
||||
- V3.3 bugfix releases continue until February 2022, when all V3.3.x
|
||||
releases become End of Life.
|
||||
|
||||
Existing Releases
|
||||
-----------------
|
||||
|
||||
ESP-IDF release V3.3 and all newer releases will follow this support
|
||||
period policy. The support period for each release will be announced
|
||||
when the release is made.
|
||||
|
||||
For releases made before the support period policy was announced,
|
||||
the following support periods apply:
|
||||
|
||||
- ESP-IDF V3.1.x and V3.2.x will both be supported until October 2020.
|
||||
- ESP-IDF V3.0.9 (planned for October 2019) will be the last V3.0
|
||||
bugfix release. ESP-IDF V3.0.x is End of Life from October 2019.
|
||||
- ESP-IDF versions before V3.0 are already End of Life.
|
@ -8,9 +8,16 @@ PARTTOOL_PY := $(PYTHON) $(IDF_PATH)/components/partition_table/parttool.py
|
||||
# Generate blank partition file
|
||||
BLANK_OTA_DATA_FILE = $(BUILD_DIR_BASE)/ota_data_initial.bin
|
||||
|
||||
$(BLANK_OTA_DATA_FILE): partition_table_get_info $(PARTITION_TABLE_BIN) | check_python_dependencies
|
||||
# Copy PARTITION_TABLE_CSV_PATH definition here from $IDF_PATH/components/partition_table/Makefile.projbuild
|
||||
# to avoid undefined variables warning for PARTITION_TABLE_CSV_PATH
|
||||
ifndef PARTITION_TABLE_CSV_PATH
|
||||
PARTITION_TABLE_ROOT := $(call dequote,$(if $(CONFIG_PARTITION_TABLE_CUSTOM),$(PROJECT_PATH),$(IDF_PATH)/components/partition_table))
|
||||
PARTITION_TABLE_CSV_PATH := $(call dequote,$(abspath $(PARTITION_TABLE_ROOT)/$(call dequote,$(CONFIG_PARTITION_TABLE_FILENAME))))
|
||||
endif
|
||||
|
||||
$(BLANK_OTA_DATA_FILE): partition_table_get_info $(PARTITION_TABLE_CSV_PATH) | check_python_dependencies
|
||||
$(shell if [ "$(OTA_DATA_OFFSET)" != "" ] && [ "$(OTA_DATA_SIZE)" != "" ]; then \
|
||||
$(PARTTOOL_PY) --partition-type data --partition-subtype ota --partition-table-file $(PARTITION_TABLE_BIN) \
|
||||
$(PARTTOOL_PY) --partition-type data --partition-subtype ota --partition-table-file $(PARTITION_TABLE_CSV_PATH) \
|
||||
-q generate_blank_partition_file --output $(BLANK_OTA_DATA_FILE); \
|
||||
fi; )
|
||||
$(eval BLANK_OTA_DATA_FILE = $(shell if [ "$(OTA_DATA_OFFSET)" != "" ] && [ "$(OTA_DATA_SIZE)" != "" ]; then \
|
||||
@ -22,11 +29,11 @@ blank_ota_data: $(BLANK_OTA_DATA_FILE)
|
||||
# expand to empty values.
|
||||
ESPTOOL_ALL_FLASH_ARGS += $(OTA_DATA_OFFSET) $(BLANK_OTA_DATA_FILE)
|
||||
|
||||
erase_otadata: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_BIN) erase_otadata
|
||||
erase_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_CSV_PATH) erase_otadata
|
||||
|
||||
read_otadata: $(PARTITION_TABLE_BIN) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_BIN) read_otadata
|
||||
read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_python_dependencies
|
||||
$(OTATOOL_PY) --partition-table-file $(PARTITION_TABLE_CSV_PATH) read_otadata
|
||||
|
||||
erase_ota: erase_otadata
|
||||
@echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "esp_efuse.h"
|
||||
|
||||
|
||||
#define SUB_TYPE_ID(i) (i & 0x0F)
|
||||
#define SUB_TYPE_ID(i) (i & 0x0F)
|
||||
|
||||
typedef struct ota_ops_entry_ {
|
||||
uint32_t handle;
|
||||
@ -208,7 +208,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
// must erase the partition before writing to it
|
||||
assert(it->erased_size > 0 && "must erase the partition before writing to it");
|
||||
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x)", data_bytes[0]);
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ static void test_flow1(void)
|
||||
// 3 Stage: run OTA0 -> check it -> copy OTA0 to OTA1 -> reboot --//--
|
||||
// 4 Stage: run OTA1 -> check it -> copy OTA1 to OTA0 -> reboot --//--
|
||||
// 5 Stage: run OTA0 -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, OTA0", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow1, test_flow1, test_flow1, test_flow1);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, OTA0", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow1, test_flow1, test_flow1, test_flow1);
|
||||
|
||||
static void test_flow2(void)
|
||||
{
|
||||
@ -332,7 +332,7 @@ static void test_flow2(void)
|
||||
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
|
||||
// 3 Stage: run OTA0 -> check it -> corrupt ota data -> reboot --//--
|
||||
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, corrupt ota_sec1, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow2, test_flow2, test_flow2);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, corrupt ota_sec1, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow2, test_flow2, test_flow2);
|
||||
|
||||
static void test_flow3(void)
|
||||
{
|
||||
@ -376,7 +376,7 @@ static void test_flow3(void)
|
||||
// 3 Stage: run OTA0 -> check it -> copy OTA0 to OTA1 -> reboot --//--
|
||||
// 3 Stage: run OTA1 -> check it -> corrupt ota sector2 -> reboot --//--
|
||||
// 4 Stage: run OTA0 -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, currupt ota_sec2, OTA0", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow3, test_flow3, test_flow3, test_flow3);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, OTA1, currupt ota_sec2, OTA0", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow3, test_flow3, test_flow3, test_flow3);
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
|
||||
#define STORAGE_NAMESPACE "update_ota"
|
||||
@ -443,7 +443,7 @@ static void test_flow4(void)
|
||||
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
|
||||
// 3 Stage: run OTA0 -> check it -> set_pin_factory_reset -> reboot --//--
|
||||
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_APP_TEST
|
||||
@ -486,7 +486,7 @@ static void test_flow5(void)
|
||||
// 2 Stage: run factory -> check it -> copy factory to Test and set pin_test_app -> reboot --//--
|
||||
// 3 Stage: run test -> check it -> reset pin_test_app -> reboot --//--
|
||||
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
|
||||
#endif
|
||||
|
||||
static const esp_partition_t* app_update(void)
|
||||
@ -580,7 +580,7 @@ static void test_rollback1_1(void)
|
||||
// 3 Stage: run OTA0 -> check it -> esp_ota_mark_app_valid_cancel_rollback() -> reboot --//--
|
||||
// 4 Stage: run OTA0 -> check it -> esp_ota_mark_app_invalid_rollback_and_reboot() -> reboot
|
||||
// 5 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA0, rollback -> factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback1, test_rollback1, test_rollback1, test_rollback1_1);
|
||||
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA0, rollback -> factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback1, test_rollback1, test_rollback1, test_rollback1_1);
|
||||
|
||||
static void test_rollback2(void)
|
||||
{
|
||||
@ -678,7 +678,7 @@ static void test_rollback2_1(void)
|
||||
// 3 Stage: run OTA0 -> check it -> esp_ota_mark_app_valid_cancel_rollback(), copy to next app slot -> reboot --//--
|
||||
// 4 Stage: run OTA1 -> check it -> PENDING_VERIFY/esp_ota_mark_app_invalid_rollback_and_reboot() -> reboot
|
||||
// 5 Stage: run OTA0(rollback) -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA1, rollback -> OTA0", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback2, test_rollback2, test_rollback2, test_rollback2_1);
|
||||
TEST_CASE_MULTIPLE_STAGES("Test rollback. factory, OTA0, OTA1, rollback -> OTA0", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback2, test_rollback2, test_rollback2, test_rollback2_1);
|
||||
|
||||
static void test_erase_last_app_flow(void)
|
||||
{
|
||||
@ -729,4 +729,4 @@ static void test_erase_last_app_rollback(void)
|
||||
// 3 Stage: run OTA0 -> check it -> copy factory to OTA1 -> reboot --//--
|
||||
// 4 Stage: run OTA1 -> check it -> erase OTA0 and rollback -> reboot
|
||||
// 5 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Test erase_last_boot_app_partition. factory, OTA1, OTA0, factory", "[app_update][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_rollback);
|
||||
TEST_CASE_MULTIPLE_STAGES("Test erase_last_boot_app_partition. factory, OTA1, OTA0, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_flow, test_erase_last_app_rollback);
|
||||
|
@ -504,16 +504,23 @@ menu "Security features"
|
||||
|
||||
Only set this option in testing environments.
|
||||
|
||||
config SECURE_BOOT_TEST_MODE
|
||||
bool "Secure boot test mode: don't permanently set any eFuses"
|
||||
depends on SECURE_BOOT_INSECURE
|
||||
default N
|
||||
help
|
||||
If this option is set, all permanent secure boot changes (via eFuse) are disabled.
|
||||
|
||||
Log output will state changes which would be applied, but they will not be.
|
||||
|
||||
This option is for testing purposes only - it completely disables secure boot protection.
|
||||
|
||||
endmenu # Potentially Insecure
|
||||
|
||||
config FLASH_ENCRYPTION_DISABLE_PLAINTEXT
|
||||
bool "Disable serial reflashing of plaintext firmware"
|
||||
depends on FLASH_ENCRYPTION_ENABLED
|
||||
default y if SECURE_BOOT_ENABLED
|
||||
default n if !SECURE_BOOT_ENABLED
|
||||
help
|
||||
If this option is enabled, flash encryption is permanently enabled after first boot by write-protecting
|
||||
the FLASH_CRYPT_CNT efuse. This is the recommended configuration for a secure production system.
|
||||
|
||||
If this option is disabled, FLASH_CRYPT_CNT is left writeable and up to 4 plaintext re-flashes are allowed.
|
||||
An attacker with physical access will be able to read out encrypted flash contents until all plaintext
|
||||
re-flashes have been used up.
|
||||
|
||||
If this option is disabled and hardware Secure Boot is enabled, Secure Boot must be configured in
|
||||
Reflashable mode so that a new Secure Boot digest can be flashed at the same time as plaintext firmware.
|
||||
This combination is not secure and should not be used for a production system.
|
||||
|
||||
endmenu # Security features
|
||||
|
@ -49,10 +49,11 @@ if((NOT CONFIG_SECURE_BOOT_ENABLED) OR
|
||||
CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH)
|
||||
externalproject_add(bootloader
|
||||
# TODO: support overriding the bootloader in COMPONENT_PATHS
|
||||
SOURCE_DIR "${IDF_PATH}/components/bootloader/subproject"
|
||||
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
|
||||
BINARY_DIR "${bootloader_build_dir}"
|
||||
CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH}
|
||||
-DSECURE_BOOT_SIGNING_KEY=${secure_boot_signing_key}
|
||||
-DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR}
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_ALWAYS 1 # no easy way around this...
|
||||
BUILD_BYPRODUCTS ${bootloader_binary_files}
|
||||
|
@ -27,9 +27,9 @@ target_linker_script(bootloader.elf
|
||||
# as cmake won't attach linker args to a header-only library, attach
|
||||
# linker args directly to the bootloader.elf
|
||||
set(ESP32_BOOTLOADER_LINKER_SCRIPTS
|
||||
"../../esp32/ld/esp32.rom.ld"
|
||||
"../../esp32/ld/esp32.rom.spiram_incompatible_fns.ld"
|
||||
"../../esp32/ld/esp32.peripherals.ld")
|
||||
"${IDF_PATH}/components/esp32/ld/esp32.rom.ld"
|
||||
"${IDF_PATH}/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld"
|
||||
"${IDF_PATH}/components/esp32/ld/esp32.peripherals.ld")
|
||||
|
||||
target_linker_script(bootloader.elf ${ESP32_BOOTLOADER_LINKER_SCRIPTS})
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "bootloader_common.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "rom/rtc.h"
|
||||
|
||||
static const char* TAG = "boot";
|
||||
|
||||
@ -74,7 +75,8 @@ static int selected_boot_partition(const bootloader_state_t *bs)
|
||||
int boot_index = bootloader_utility_get_selected_boot_partition(bs);
|
||||
if (boot_index == INVALID_INDEX) {
|
||||
return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
|
||||
} else {
|
||||
}
|
||||
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
|
||||
// Factory firmware.
|
||||
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
|
||||
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
set(COMPONENT_SRCS "src/bootloader_clock.c"
|
||||
"src/bootloader_common.c"
|
||||
"src/bootloader_flash.c"
|
||||
"src/bootloader_flash_config.c"
|
||||
"src/bootloader_random.c"
|
||||
"src/bootloader_sha.c"
|
||||
"src/bootloader_utility.c"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
#include "esp_flash_data_types.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_image_format.h"
|
||||
|
||||
/// Type of hold a GPIO in low state
|
||||
typedef enum {
|
||||
@ -23,6 +24,11 @@ typedef enum {
|
||||
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
|
||||
} esp_comm_gpio_hold_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_IMAGE_BOOTLOADER,
|
||||
ESP_IMAGE_APPLICATION
|
||||
} esp_image_type;
|
||||
|
||||
/**
|
||||
* @brief Calculate crc for the OTA data select.
|
||||
*
|
||||
@ -125,7 +131,7 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
|
||||
/**
|
||||
* @brief Returns esp_app_desc structure for app partition. This structure includes app version.
|
||||
*
|
||||
*
|
||||
* Returns a description for the requested app partition.
|
||||
* @param[in] partition App partition description.
|
||||
* @param[out] app_desc Structure of info about app.
|
||||
@ -136,3 +142,26 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
* - ESP_FAIL: mapping is fail.
|
||||
*/
|
||||
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
|
||||
|
||||
/**
|
||||
* @brief Get chip revision
|
||||
*
|
||||
* @return Chip revision number
|
||||
*/
|
||||
uint8_t bootloader_common_get_chip_revision(void);
|
||||
|
||||
/**
|
||||
* @brief Check if the image (bootloader and application) has valid chip ID and revision
|
||||
*
|
||||
* @param[in] img_hdr: image header
|
||||
* @param[in] type: image type, bootloader or application
|
||||
* @return
|
||||
* - ESP_OK: image and chip are matched well
|
||||
* - ESP_FAIL: image doesn't match to the chip
|
||||
*/
|
||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type);
|
||||
|
||||
/**
|
||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||
*/
|
||||
void bootloader_common_vddsdio_configure();
|
||||
|
@ -0,0 +1,71 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_image_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Update the flash id in g_rom_flashchip(global esp_rom_spiflash_chip_t structure).
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_update_id();
|
||||
|
||||
/**
|
||||
* @brief Set the flash CS setup and hold time.
|
||||
*
|
||||
* @note CS setup time is recomemded to be 1.5T, and CS hold time is recommended to be 2.5T.
|
||||
* cs_setup = 1, cs_setup_time = 0; cs_hold = 1, cs_hold_time = 1.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_cs_timing_config();
|
||||
|
||||
/**
|
||||
* @brief Configure SPI flash clock.
|
||||
*
|
||||
* @note This function only set clock frequency for SPI0.
|
||||
*
|
||||
* @param pfhdr Pointer to App image header, from where to fetch flash settings.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_clock_config(const esp_image_header_t* pfhdr);
|
||||
|
||||
/**
|
||||
* @brief Configure SPI flash gpio, include the IO matrix and drive strength configuration.
|
||||
*
|
||||
* @param pfhdr Pointer to App image header, from where to fetch flash settings.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
|
||||
|
||||
/**
|
||||
* @brief Configure SPI flash read dummy based on different mode and frequency.
|
||||
*
|
||||
* @param pfhdr Pointer to App image header, from where to fetch flash settings.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -55,6 +55,19 @@ typedef enum {
|
||||
|
||||
#define ESP_IMAGE_HEADER_MAGIC 0xE9
|
||||
|
||||
/**
|
||||
* @brief ESP chip ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
|
||||
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
|
||||
} __attribute__((packed)) esp_chip_id_t;
|
||||
|
||||
/** @cond */
|
||||
_Static_assert(sizeof(esp_chip_id_t) == 2, "esp_chip_id_t should be 16 bit");
|
||||
/** @endcond */
|
||||
|
||||
/* Main header of binary image */
|
||||
typedef struct {
|
||||
uint8_t magic;
|
||||
@ -71,8 +84,9 @@ typedef struct {
|
||||
uint8_t wp_pin;
|
||||
/* Drive settings for the SPI flash pins (read by ROM bootloader) */
|
||||
uint8_t spi_pin_drv[3];
|
||||
/* Reserved bytes in ESP32 additional header space, currently unused */
|
||||
uint8_t reserved[11];
|
||||
esp_chip_id_t chip_id; /*!< Chip identification number */
|
||||
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
|
||||
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
|
||||
/* If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum. Included in image length. This digest
|
||||
* is separate to secure boot and only used for detecting corruption. For secure boot signed images, the signature
|
||||
* is appended after this (and the simple hash is included in the signed data). */
|
||||
|
@ -46,6 +46,25 @@ static inline bool esp_secure_boot_enabled(void) {
|
||||
return REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_RD_ABS_DONE_0;
|
||||
}
|
||||
|
||||
/** @brief Generate secure digest from bootloader image
|
||||
*
|
||||
* @important This function is intended to be called from bootloader code only.
|
||||
*
|
||||
* If secure boot is not yet enabled for bootloader, this will:
|
||||
* 1) generate the secure boot key and burn it on EFUSE
|
||||
* (without enabling R/W protection)
|
||||
* 2) generate the digest from bootloader and save it
|
||||
* to flash address 0x0
|
||||
*
|
||||
* If first boot gets interrupted after calling this function
|
||||
* but before esp_secure_boot_permanently_enable() is called, then
|
||||
* the key burned on EFUSE will not be regenerated, unless manually
|
||||
* done using espefuse.py tool
|
||||
*
|
||||
* @return ESP_OK if secure boot digest is generated
|
||||
* successfully or found to be already present
|
||||
*/
|
||||
esp_err_t esp_secure_boot_generate_digest(void);
|
||||
|
||||
/** @brief Enable secure boot if it is not already enabled.
|
||||
*
|
||||
@ -54,9 +73,13 @@ static inline bool esp_secure_boot_enabled(void) {
|
||||
*
|
||||
* @important This function is intended to be called from bootloader code only.
|
||||
*
|
||||
* @important This will enable r/w protection of secure boot key on EFUSE,
|
||||
* therefore it is to be ensured that esp_secure_boot_generate_digest()
|
||||
* is called before this
|
||||
*
|
||||
* If secure boot is not yet enabled for bootloader, this will
|
||||
* generate the secure boot digest and enable secure boot by blowing
|
||||
* the EFUSE_RD_ABS_DONE_0 efuse.
|
||||
* 1) enable R/W protection of secure boot key on EFUSE
|
||||
* 2) enable secure boot by blowing the EFUSE_RD_ABS_DONE_0 efuse.
|
||||
*
|
||||
* This function does not verify secure boot of the bootloader (the
|
||||
* ROM bootloader does this.)
|
||||
@ -64,7 +87,6 @@ static inline bool esp_secure_boot_enabled(void) {
|
||||
* Will fail if efuses have been part-burned in a way that indicates
|
||||
* secure boot should not or could not be correctly enabled.
|
||||
*
|
||||
*
|
||||
* @return ESP_ERR_INVALID_STATE if efuse state doesn't allow
|
||||
* secure boot to be enabled cleanly. ESP_OK if secure boot
|
||||
* is enabled on this chip from now on.
|
||||
|
@ -30,6 +30,13 @@
|
||||
bootloader_support components only.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get number of free pages
|
||||
*
|
||||
* @return Number of free pages
|
||||
*/
|
||||
uint32_t bootloader_mmap_get_free_pages();
|
||||
|
||||
/**
|
||||
* @brief Map a region of flash to data memory
|
||||
*
|
||||
|
@ -27,6 +27,11 @@
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/apb_ctrl_reg.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "bootloader_sha.h"
|
||||
#include "sys/param.h"
|
||||
@ -257,3 +262,66 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void bootloader_common_vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) { // VDDSDIO regulator is enabled @ 1.8V
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
ets_delay_us(10); // wait for regulator to become stable
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
uint8_t bootloader_common_get_chip_revision(void)
|
||||
{
|
||||
uint8_t eco_bit0, eco_bit1, eco_bit2;
|
||||
eco_bit0 = (REG_READ(EFUSE_BLK0_RDATA3_REG) & 0xF000) >> 15;
|
||||
eco_bit1 = (REG_READ(EFUSE_BLK0_RDATA5_REG) & 0x100000) >> 20;
|
||||
eco_bit2 = (REG_READ(APB_CTRL_DATE_REG) & 0x80000000) >> 31;
|
||||
uint32_t combine_value = (eco_bit2 << 2) | (eco_bit1 << 1) | eco_bit0;
|
||||
uint8_t chip_ver = 0;
|
||||
switch (combine_value) {
|
||||
case 0:
|
||||
chip_ver = 0;
|
||||
break;
|
||||
case 1:
|
||||
chip_ver = 1;
|
||||
break;
|
||||
case 3:
|
||||
chip_ver = 2;
|
||||
break;
|
||||
case 7:
|
||||
chip_ver = 3;
|
||||
break;
|
||||
default:
|
||||
chip_ver = 0;
|
||||
break;
|
||||
}
|
||||
return chip_ver;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
|
||||
if (chip_id != img_hdr->chip_id) {
|
||||
ESP_LOGE(TAG, "mismatch chip ID, expected %d, found %d", chip_id, img_hdr->chip_id);
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
uint8_t revision = bootloader_common_get_chip_revision();
|
||||
if (revision < img_hdr->min_chip_rev) {
|
||||
ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev);
|
||||
err = ESP_FAIL;
|
||||
} else if (revision != img_hdr->min_chip_rev) {
|
||||
ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ static const char *TAG = "bootloader_mmap";
|
||||
|
||||
static spi_flash_mmap_handle_t map;
|
||||
|
||||
uint32_t bootloader_mmap_get_free_pages()
|
||||
{
|
||||
return spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
|
||||
}
|
||||
|
||||
const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
{
|
||||
if (map) {
|
||||
@ -91,12 +96,22 @@ static const char *TAG = "bootloader_flash";
|
||||
*/
|
||||
#define MMU_BLOCK0_VADDR 0x3f400000
|
||||
#define MMU_BLOCK50_VADDR 0x3f720000
|
||||
#define MMU_FREE_PAGES ((MMU_BLOCK50_VADDR - MMU_BLOCK0_VADDR) / FLASH_BLOCK_SIZE)
|
||||
|
||||
static bool mapped;
|
||||
|
||||
// Current bootloader mapping (ab)used for bootloader_read()
|
||||
static uint32_t current_read_mapping = UINT32_MAX;
|
||||
|
||||
uint32_t bootloader_mmap_get_free_pages()
|
||||
{
|
||||
/**
|
||||
* Allow mapping up to 50 of the 51 available MMU blocks (last one used for reads)
|
||||
* Since, bootloader_mmap function below assumes it to be 0x320000 (50 pages), we can safely do this.
|
||||
*/
|
||||
return MMU_FREE_PAGES;
|
||||
}
|
||||
|
||||
const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
{
|
||||
if (mapped) {
|
||||
|
165
components/bootloader_support/src/bootloader_flash_config.c
Normal file
165
components/bootloader_support/src/bootloader_flash_config.c
Normal file
@ -0,0 +1,165 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include "string.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/efuse.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_pins.h"
|
||||
#include "flash_qio_mode.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
|
||||
void bootloader_flash_update_id()
|
||||
{
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config()
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(1), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
uint32_t spi_clk_div = 0;
|
||||
switch (pfhdr->spi_speed) {
|
||||
case ESP_IMAGE_SPI_SPEED_80M:
|
||||
spi_clk_div = 1;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_40M:
|
||||
spi_clk_div = 2;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_26M:
|
||||
spi_clk_div = 3;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_20M:
|
||||
spi_clk_div = 4;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
esp_rom_spiflash_config_clk(spi_clk_div, 0);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
uint32_t drv = 2;
|
||||
if (pfhdr->spi_speed == ESP_IMAGE_SPI_SPEED_80M) {
|
||||
drv = 3;
|
||||
}
|
||||
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
|
||||
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
|
||||
// For ESP32D2WD the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
|
||||
// For ESP32PICOD2 the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
|
||||
// For ESP32PICOD4 the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else {
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
|
||||
gpio_matrix_out(SPI_IOMUX_PIN_NUM_CS, SPICS0_OUT_IDX, 0, 0);
|
||||
gpio_matrix_out(SPI_IOMUX_PIN_NUM_MISO, SPIQ_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(SPI_IOMUX_PIN_NUM_MISO, SPIQ_IN_IDX, 0);
|
||||
gpio_matrix_out(SPI_IOMUX_PIN_NUM_MOSI, SPID_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(SPI_IOMUX_PIN_NUM_MOSI, SPID_IN_IDX, 0);
|
||||
gpio_matrix_out(SPI_IOMUX_PIN_NUM_WP, SPIWP_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(SPI_IOMUX_PIN_NUM_WP, SPIWP_IN_IDX, 0);
|
||||
gpio_matrix_out(SPI_IOMUX_PIN_NUM_HD, SPIHD_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(SPI_IOMUX_PIN_NUM_HD, SPIHD_IN_IDX, 0);
|
||||
//select pin function gpio
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, PIN_FUNC_GPIO);
|
||||
// flash clock signal should come from IO MUX.
|
||||
// set drive ability for clock
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
|
||||
uint32_t flash_id = g_rom_flashchip.device_id;
|
||||
if (flash_id == FLASH_ID_GD25LQ32C) {
|
||||
// Set drive ability for 1.8v flash in 80Mhz.
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA0_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA1_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA2_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA3_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CMD_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
int spi_cache_dummy = 0;
|
||||
uint32_t modebit = READ_PERI_REG(SPI_CTRL_REG(0));
|
||||
if (modebit & SPI_FASTRD_MODE) {
|
||||
if (modebit & SPI_FREAD_QIO) { //SPI mode is QIO
|
||||
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN;
|
||||
} else if (modebit & SPI_FREAD_DIO) { //SPI mode is DIO
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_ADDR_BITLEN_V, SPI0_R_DIO_ADDR_BITSLEN, SPI_USR_ADDR_BITLEN_S);
|
||||
} else if(modebit & (SPI_FREAD_QUAD | SPI_FREAD_DUAL)) { //SPI mode is QOUT or DIO
|
||||
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN;
|
||||
}
|
||||
}
|
||||
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
switch (pfhdr->spi_speed) {
|
||||
case ESP_IMAGE_SPI_SPEED_80M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_80M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_80M;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_40M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_40M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_40M;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_26M:
|
||||
case ESP_IMAGE_SPI_SPEED_20M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_20M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = ESP_ROM_SPIFLASH_DUMMY_LEN_PLUS_20M;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + g_rom_spiflash_dummy_len_plus[0],
|
||||
SPI_USR_DUMMY_CYCLELEN_S);
|
||||
}
|
@ -33,12 +33,10 @@
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "soc/gpio_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/rtc_wdt.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
@ -50,6 +48,8 @@
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_clock.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
|
||||
#include "flash_qio_mode.h"
|
||||
|
||||
@ -63,8 +63,7 @@ static const char* TAG = "boot";
|
||||
static esp_err_t bootloader_main();
|
||||
static void print_flash_info(const esp_image_header_t* pfhdr);
|
||||
static void update_flash_config(const esp_image_header_t* pfhdr);
|
||||
static void vddsdio_configure();
|
||||
static void flash_gpio_configure(const esp_image_header_t* pfhdr);
|
||||
static void bootloader_init_flash_configure(const esp_image_header_t* pfhdr);
|
||||
static void uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
|
||||
@ -119,7 +118,7 @@ esp_err_t bootloader_init()
|
||||
|
||||
static esp_err_t bootloader_main()
|
||||
{
|
||||
vddsdio_configure();
|
||||
bootloader_common_vddsdio_configure();
|
||||
/* Read and keep flash ID, for further use. */
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
esp_image_header_t fhdr;
|
||||
@ -127,7 +126,15 @@ static esp_err_t bootloader_main()
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
flash_gpio_configure(&fhdr);
|
||||
|
||||
/* Check chip ID and minimum chip revision that supported by this image */
|
||||
uint8_t revision = bootloader_common_get_chip_revision();
|
||||
ESP_LOGI(TAG, "Chip Revision: %d", revision);
|
||||
if (bootloader_common_check_chip_validity(&fhdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
bootloader_init_flash_configure(&fhdr);
|
||||
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
|
||||
//Check if ESP32 is rated for a CPU frequency of 160MHz only
|
||||
if (REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_RATED) &&
|
||||
@ -287,128 +294,15 @@ static void print_flash_info(const esp_image_header_t* phdr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) { // VDDSDIO regulator is enabled @ 1.8V
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
ets_delay_us(10); // wait for regulator to become stable
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
#define FLASH_CLK_IO 6
|
||||
#define FLASH_CS_IO 11
|
||||
#define FLASH_SPIQ_IO 7
|
||||
#define FLASH_SPID_IO 8
|
||||
#define FLASH_SPIWP_IO 10
|
||||
#define FLASH_SPIHD_IO 9
|
||||
#define FLASH_IO_MATRIX_DUMMY_40M 1
|
||||
#define FLASH_IO_MATRIX_DUMMY_80M 2
|
||||
#define FLASH_IO_DRIVE_GD_WITH_1V8PSRAM 3
|
||||
|
||||
/*
|
||||
* Bootloader reads SPI configuration from bin header, so that
|
||||
* the burning configuration can be different with compiling configuration.
|
||||
*/
|
||||
static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
int spi_cache_dummy = 0;
|
||||
int drv = 2;
|
||||
switch (pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN; //qio 3
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
case ESP_IMAGE_SPI_MODE_DOUT:
|
||||
default:
|
||||
spi_cache_dummy = SPI0_R_FAST_DUMMY_CYCLELEN;
|
||||
break;
|
||||
}
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
switch (pfhdr->spi_speed) {
|
||||
case ESP_IMAGE_SPI_SPEED_80M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_80M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_80M;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M,
|
||||
SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
drv = 3;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_40M:
|
||||
g_rom_spiflash_dummy_len_plus[0] = FLASH_IO_MATRIX_DUMMY_40M;
|
||||
g_rom_spiflash_dummy_len_plus[1] = FLASH_IO_MATRIX_DUMMY_40M;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_40M,
|
||||
SPI_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
|
||||
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
|
||||
// For ESP32D2WD the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
|
||||
// For ESP32PICOD2 the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
|
||||
// For ESP32PICOD4 the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else {
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
|
||||
gpio_matrix_out(FLASH_CS_IO, SPICS0_OUT_IDX, 0, 0);
|
||||
gpio_matrix_out(FLASH_SPIQ_IO, SPIQ_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPIQ_IO, SPIQ_IN_IDX, 0);
|
||||
gpio_matrix_out(FLASH_SPID_IO, SPID_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPID_IO, SPID_IN_IDX, 0);
|
||||
gpio_matrix_out(FLASH_SPIWP_IO, SPIWP_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPIWP_IO, SPIWP_IN_IDX, 0);
|
||||
gpio_matrix_out(FLASH_SPIHD_IO, SPIHD_OUT_IDX, 0, 0);
|
||||
gpio_matrix_in(FLASH_SPIHD_IO, SPIHD_IN_IDX, 0);
|
||||
//select pin function gpio
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA2_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA3_U, PIN_FUNC_GPIO);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, PIN_FUNC_GPIO);
|
||||
// flash clock signal should come from IO MUX.
|
||||
// set drive ability for clock
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
|
||||
#if CONFIG_SPIRAM_TYPE_ESPPSRAM32
|
||||
uint32_t flash_id = g_rom_flashchip.device_id;
|
||||
if (flash_id == FLASH_ID_GD25LQ32C) {
|
||||
// Set drive ability for 1.8v flash in 80Mhz.
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA0_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA1_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA2_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_DATA3_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CMD_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, 3, FUN_DRV_S);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
bootloader_flash_gpio_config(pfhdr);
|
||||
bootloader_flash_dummy_config(pfhdr);
|
||||
bootloader_flash_cs_timing_config();
|
||||
}
|
||||
|
||||
static void uart_console_configure(void)
|
||||
@ -442,10 +336,18 @@ static void uart_console_configure(void)
|
||||
// (arrays should be optimized away by the compiler)
|
||||
const uint32_t tx_idx_list[3] = { U0TXD_OUT_IDX, U1TXD_OUT_IDX, U2TXD_OUT_IDX };
|
||||
const uint32_t rx_idx_list[3] = { U0RXD_IN_IDX, U1RXD_IN_IDX, U2RXD_IN_IDX };
|
||||
const uint32_t uart_reset[3] = { DPORT_UART_RST, DPORT_UART1_RST, DPORT_UART2_RST };
|
||||
const uint32_t tx_idx = tx_idx_list[uart_num];
|
||||
const uint32_t rx_idx = rx_idx_list[uart_num];
|
||||
|
||||
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[uart_rx_gpio]);
|
||||
gpio_pad_pullup(uart_rx_gpio);
|
||||
|
||||
gpio_matrix_out(uart_tx_gpio, tx_idx, 0, 0);
|
||||
gpio_matrix_in(uart_rx_gpio, rx_idx, 0);
|
||||
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
|
||||
}
|
||||
#endif // CONFIG_CONSOLE_UART_CUSTOM
|
||||
|
||||
|
@ -114,17 +114,18 @@ void bootloader_random_enable(void)
|
||||
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
/* Disable i2s clock */
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
|
||||
|
||||
/* Reset some i2s configuration (possibly redundant as we reset entire
|
||||
I2S peripheral further down). */
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
|
||||
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
|
||||
|
||||
/* Disable i2s clock */
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
|
||||
/* Restore SYSCON mode registers */
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
|
||||
|
@ -478,24 +478,71 @@ void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_
|
||||
// Copy loaded segments to RAM, set up caches for mapped segments, and start application.
|
||||
static void load_image(const esp_image_metadata_t* image_data)
|
||||
{
|
||||
/**
|
||||
* Rough steps for a first boot, when encryption and secure boot are both disabled:
|
||||
* 1) Generate secure boot key and write to EFUSE.
|
||||
* 2) Write plaintext digest based on plaintext bootloader
|
||||
* 3) Generate flash encryption key and write to EFUSE.
|
||||
* 4) Encrypt flash in-place including bootloader, then digest,
|
||||
* then app partitions and other encrypted partitions
|
||||
* 5) Burn EFUSE to enable flash encryption (FLASH_CRYPT_CNT)
|
||||
* 6) Burn EFUSE to enable secure boot (ABS_DONE_0)
|
||||
*
|
||||
* If power failure happens during Step 1, probably the next boot will continue from Step 2.
|
||||
* There is some small chance that EFUSEs will be part-way through being written so will be
|
||||
* somehow corrupted here. Thankfully this window of time is very small, but if that's the
|
||||
* case, one has to use the espefuse tool to manually set the remaining bits and enable R/W
|
||||
* protection. Once the relevant EFUSE bits are set and R/W protected, Step 1 will be skipped
|
||||
* successfully on further reboots.
|
||||
*
|
||||
* If power failure happens during Step 2, Step 1 will be skipped and Step 2 repeated:
|
||||
* the digest will get re-written on the next boot.
|
||||
*
|
||||
* If power failure happens during Step 3, it's possible that EFUSE was partially written
|
||||
* with the generated flash encryption key, though the time window for that would again
|
||||
* be very small. On reboot, Step 1 will be skipped and Step 2 repeated, though, Step 3
|
||||
* may fail due to the above mentioned reason, in which case, one has to use the espefuse
|
||||
* tool to manually set the remaining bits and enable R/W protection. Once the relevant EFUSE
|
||||
* bits are set and R/W protected, Step 3 will be skipped successfully on further reboots.
|
||||
*
|
||||
* If power failure happens after start of 4 and before end of 5, the next boot will fail
|
||||
* (bootloader header is encrypted and flash encryption isn't enabled yet, so it looks like
|
||||
* noise to the ROM bootloader). The check in the ROM is pretty basic so if the first byte of
|
||||
* ciphertext happens to be the magic byte E9 then it may try to boot, but it will definitely
|
||||
* crash (no chance that the remaining ciphertext will look like a valid bootloader image).
|
||||
* Only solution is to reflash with all plaintext and the whole process starts again: skips
|
||||
* Step 1, repeats Step 2, skips Step 3, etc.
|
||||
*
|
||||
* If power failure happens after 5 but before 6, the device will reboot with flash
|
||||
* encryption on and will regenerate an encrypted digest in Step 2. This should still
|
||||
* be valid as the input data for the digest is read via flash cache (so will be decrypted)
|
||||
* and the code in secure_boot_generate() tells bootloader_flash_write() to encrypt the data
|
||||
* on write if flash encryption is enabled. Steps 3 - 5 are skipped (encryption already on),
|
||||
* then Step 6 enables secure boot.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_FLASH_ENCRYPTION_ENABLED)
|
||||
esp_err_t err;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
/* Generate secure digest from this bootloader to protect future
|
||||
modifications */
|
||||
ESP_LOGI(TAG, "Checking secure boot...");
|
||||
err = esp_secure_boot_permanently_enable();
|
||||
/* Steps 1 & 2 (see above for full description):
|
||||
* 1) Generate secure boot EFUSE key
|
||||
* 2) Compute digest of plaintext bootloader
|
||||
*/
|
||||
err = esp_secure_boot_generate_digest();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Bootloader digest generation failed (%d). SECURE BOOT IS NOT ENABLED.", err);
|
||||
/* Allow booting to continue, as the failure is probably
|
||||
due to user-configured EFUSEs for testing...
|
||||
*/
|
||||
ESP_LOGE(TAG, "Bootloader digest generation for secure boot failed (%d).", err);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
/* encrypt flash */
|
||||
/* Steps 3, 4 & 5 (see above for full description):
|
||||
* 3) Generate flash encryption EFUSE key
|
||||
* 4) Encrypt flash contents
|
||||
* 5) Burn EFUSE to enable flash encryption
|
||||
*/
|
||||
ESP_LOGI(TAG, "Checking flash encryption...");
|
||||
bool flash_encryption_enabled = esp_flash_encryption_enabled();
|
||||
err = esp_flash_encrypt_check_and_update();
|
||||
@ -503,7 +550,24 @@ static void load_image(const esp_image_metadata_t* image_data)
|
||||
ESP_LOGE(TAG, "Flash encryption check failed (%d).", err);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
/* Step 6 (see above for full description):
|
||||
* 6) Burn EFUSE to enable secure boot
|
||||
*/
|
||||
ESP_LOGI(TAG, "Checking secure boot...");
|
||||
err = esp_secure_boot_permanently_enable();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "FAILED TO ENABLE SECURE BOOT (%d).", err);
|
||||
/* Panic here as secure boot is not properly enabled
|
||||
due to one of the reasons in above function
|
||||
*/
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
if (!flash_encryption_enabled && esp_flash_encryption_enabled()) {
|
||||
/* Flash encryption was just enabled for the first time,
|
||||
so issue a system reset to ensure flash encryption
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <bootloader_random.h>
|
||||
#include <bootloader_sha.h>
|
||||
#include "bootloader_util.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
/* Checking signatures as part of verifying images is necessary:
|
||||
- Always if secure boot is enabled
|
||||
@ -280,6 +281,9 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
|
||||
}
|
||||
err = ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) {
|
||||
err = ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (!silent) {
|
||||
if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) {
|
||||
ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode);
|
||||
@ -368,24 +372,22 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
||||
}
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
uint32_t free_page_count = spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
|
||||
ESP_LOGD(TAG, "free data page_count 0x%08x",free_page_count);
|
||||
uint32_t offset_page = 0;
|
||||
while (data_len >= free_page_count * SPI_FLASH_MMU_PAGE_SIZE) {
|
||||
offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0)?1:0;
|
||||
err = process_segment_data(load_addr, data_addr, (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE, do_load, sha_handle, checksum);
|
||||
uint32_t free_page_count = bootloader_mmap_get_free_pages();
|
||||
ESP_LOGD(TAG, "free data page_count 0x%08x", free_page_count);
|
||||
|
||||
int32_t data_len_remain = data_len;
|
||||
while (data_len_remain > 0) {
|
||||
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));
|
||||
err = process_segment_data(load_addr, data_addr, data_len, do_load, sha_handle, checksum);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
data_addr += (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE;
|
||||
data_len -= (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE;
|
||||
}
|
||||
#endif
|
||||
err = process_segment_data(load_addr, data_addr, data_len, do_load, sha_handle, checksum);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
data_addr += data_len;
|
||||
data_len_remain -= data_len;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
err:
|
||||
|
@ -163,7 +163,7 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
|
||||
/* If the last flash_crypt_cnt bit is burned or write-disabled, the
|
||||
device can't re-encrypt itself. */
|
||||
if (flash_crypt_wr_dis || flash_crypt_cnt == 0xFF) {
|
||||
if (flash_crypt_wr_dis) {
|
||||
ESP_LOGE(TAG, "Cannot re-encrypt data (FLASH_CRYPT_CNT 0x%02x write disabled %d", flash_crypt_cnt, flash_crypt_wr_dis);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@ -200,11 +200,19 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
ESP_LOGD(TAG, "All flash regions checked for encryption pass");
|
||||
|
||||
/* Set least significant 0-bit in flash_crypt_cnt */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & 0xFF);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == 0xFF */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == EFUSE_RD_FLASH_CRYPT_CNT (0x7F) */
|
||||
uint32_t new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
|
||||
ESP_LOGD(TAG, "FLASH_CRYPT_CNT 0x%x -> 0x%x", flash_crypt_cnt, new_flash_crypt_cnt);
|
||||
REG_SET_FIELD(EFUSE_BLK0_WDATA0_REG, EFUSE_FLASH_CRYPT_CNT, new_flash_crypt_cnt);
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_DISABLE_PLAINTEXT
|
||||
ESP_LOGI(TAG, "Write protecting FLASH_CRYPT_CNT efuse...");
|
||||
REG_SET_BIT(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_FLASH_CRYPT_CNT);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling FLASH_CRYPT_CNT - plaintext flashing is still possible");
|
||||
#endif
|
||||
|
||||
esp_efuse_burn_new_values();
|
||||
|
||||
ESP_LOGI(TAG, "Flash encryption completed");
|
||||
@ -225,18 +233,18 @@ static esp_err_t encrypt_bootloader()
|
||||
return err;
|
||||
}
|
||||
|
||||
if (esp_secure_boot_enabled()) {
|
||||
/* If secure boot is enabled and bootloader was plaintext, also
|
||||
need to encrypt secure boot IV+digest.
|
||||
*/
|
||||
ESP_LOGD(TAG, "Encrypting secure bootloader IV & digest...");
|
||||
err = esp_flash_encrypt_region(FLASH_OFFS_SECURE_BOOT_IV_DIGEST,
|
||||
FLASH_SECTOR_SIZE);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to encrypt bootloader IV & digest in place: 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
/* If secure boot is enabled and bootloader was plaintext, also
|
||||
* need to encrypt secure boot IV+digest.
|
||||
*/
|
||||
ESP_LOGD(TAG, "Encrypting secure bootloader IV & digest...");
|
||||
err = esp_flash_encrypt_region(FLASH_OFFS_SECURE_BOOT_IV_DIGEST,
|
||||
FLASH_SECTOR_SIZE);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to encrypt bootloader IV & digest in place: 0x%x", err);
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
ESP_LOGW(TAG, "no valid bootloader was found");
|
||||
|
@ -36,6 +36,12 @@
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_efuse.h"
|
||||
|
||||
/* The following API implementations are used only when called
|
||||
* from the bootloader code.
|
||||
*/
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
|
||||
static const char* TAG = "secure_boot";
|
||||
|
||||
/**
|
||||
@ -95,18 +101,15 @@ static bool secure_boot_generate(uint32_t image_len){
|
||||
/* Burn values written to the efuse write registers */
|
||||
static inline void burn_efuses()
|
||||
{
|
||||
#ifdef CONFIG_SECURE_BOOT_TEST_MODE
|
||||
ESP_LOGE(TAG, "SECURE BOOT TEST MODE. Not really burning any efuses! NOT SECURE");
|
||||
#else
|
||||
esp_efuse_burn_new_values();
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
esp_err_t esp_secure_boot_generate_digest(void)
|
||||
{
|
||||
esp_err_t err;
|
||||
if (esp_secure_boot_enabled())
|
||||
{
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled."
|
||||
" No need to generate digest. continuing..");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -124,6 +127,7 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Generate secure boot key and keep in EFUSE */
|
||||
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
|
||||
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
|
||||
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
|
||||
@ -140,16 +144,11 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
ESP_LOGI(TAG, "Generating new secure boot key...");
|
||||
esp_efuse_write_random_key(EFUSE_BLK2_WDATA0_REG);
|
||||
burn_efuses();
|
||||
ESP_LOGI(TAG, "Read & write protecting new key...");
|
||||
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
|
||||
burn_efuses();
|
||||
efuse_key_read_protected = true;
|
||||
efuse_key_write_protected = true;
|
||||
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Using pre-loaded secure boot key in EFUSE block 2");
|
||||
}
|
||||
|
||||
/* Generate secure boot digest using programmed key in EFUSE */
|
||||
ESP_LOGI(TAG, "Generating secure boot digest...");
|
||||
uint32_t image_len = bootloader_data.image_len;
|
||||
if(bootloader_data.image.hash_appended) {
|
||||
@ -162,7 +161,28 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
}
|
||||
ESP_LOGI(TAG, "Digest generation complete.");
|
||||
|
||||
#ifndef CONFIG_SECURE_BOOT_TEST_MODE
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_secure_boot_permanently_enable(void)
|
||||
{
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
|
||||
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
|
||||
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
|
||||
if (efuse_key_read_protected == false
|
||||
&& efuse_key_write_protected == false) {
|
||||
ESP_LOGI(TAG, "Read & write protecting new key...");
|
||||
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
|
||||
burn_efuses();
|
||||
efuse_key_read_protected = true;
|
||||
efuse_key_write_protected = true;
|
||||
}
|
||||
|
||||
if (!efuse_key_read_protected) {
|
||||
ESP_LOGE(TAG, "Pre-loaded key is not read protected. Refusing to blow secure boot efuse.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@ -171,7 +191,6 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
ESP_LOGE(TAG, "Pre-loaded key is not write protected. Refusing to blow secure boot efuse.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "blowing secure boot efuse...");
|
||||
ESP_LOGD(TAG, "before updating, EFUSE_BLK0_RDATA6 %x", REG_READ(EFUSE_BLK0_RDATA6_REG));
|
||||
@ -200,11 +219,9 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
ESP_LOGI(TAG, "secure boot is now enabled for bootloader image");
|
||||
return ESP_OK;
|
||||
} else {
|
||||
#ifdef CONFIG_SECURE_BOOT_TEST_MODE
|
||||
ESP_LOGE(TAG, "secure boot not enabled due to test mode");
|
||||
#else
|
||||
ESP_LOGE(TAG, "secure boot not enabled for bootloader image, EFUSE_RD_ABS_DONE_0 is probably write protected!");
|
||||
#endif
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #ifdef BOOTLOADER_BUILD
|
||||
|
@ -21,12 +21,7 @@
|
||||
|
||||
#include "uECC.h"
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
#include "rom/sha.h"
|
||||
typedef SHA_CTX sha_context;
|
||||
#else
|
||||
#include "hwcrypto/sha.h"
|
||||
#endif
|
||||
#include <sys/param.h>
|
||||
|
||||
static const char* TAG = "secure_boot";
|
||||
|
||||
@ -37,6 +32,9 @@ extern const uint8_t signature_verification_key_end[] asm("_binary_signature_ver
|
||||
|
||||
#define DIGEST_LEN 32
|
||||
|
||||
/* Mmap source address mask */
|
||||
#define MMAP_ALIGNED_MASK 0x0000FFFF
|
||||
|
||||
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
|
||||
{
|
||||
uint8_t digest[DIGEST_LEN];
|
||||
@ -45,26 +43,44 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
|
||||
|
||||
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
|
||||
|
||||
data = bootloader_mmap(src_addr, length + sizeof(esp_secure_boot_sig_block_t));
|
||||
if(data == NULL) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr, length+sizeof(esp_secure_boot_sig_block_t));
|
||||
return ESP_FAIL;
|
||||
bootloader_sha256_handle_t handle = bootloader_sha256_start();
|
||||
|
||||
uint32_t free_page_count = bootloader_mmap_get_free_pages();
|
||||
ESP_LOGD(TAG, "free data page_count 0x%08x", free_page_count);
|
||||
|
||||
int32_t data_len_remain = length;
|
||||
uint32_t data_addr = src_addr;
|
||||
while (data_len_remain > 0) {
|
||||
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. */
|
||||
uint32_t data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
|
||||
data = (const uint8_t *) bootloader_mmap(data_addr, data_len);
|
||||
if(!data) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", data_addr, data_len);
|
||||
bootloader_sha256_finish(handle, NULL);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bootloader_sha256_data(handle, data, data_len);
|
||||
bootloader_munmap(data);
|
||||
|
||||
data_addr += data_len;
|
||||
data_len_remain -= data_len;
|
||||
}
|
||||
|
||||
// Calculate digest of main image
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
bootloader_sha256_handle_t handle = bootloader_sha256_start();
|
||||
bootloader_sha256_data(handle, data, length);
|
||||
/* Done! Get the digest */
|
||||
bootloader_sha256_finish(handle, digest);
|
||||
#else
|
||||
/* Use thread-safe esp-idf SHA function */
|
||||
esp_sha(SHA2_256, data, length, digest);
|
||||
#endif
|
||||
|
||||
// Map the signature block and verify the signature
|
||||
sigblock = (const esp_secure_boot_sig_block_t *)(data + length);
|
||||
// Map the signature block
|
||||
sigblock = (const esp_secure_boot_sig_block_t *) bootloader_mmap(src_addr + length, sizeof(esp_secure_boot_sig_block_t));
|
||||
if(!sigblock) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", src_addr + length, sizeof(esp_secure_boot_sig_block_t));
|
||||
return ESP_FAIL;
|
||||
}
|
||||
// Verify the signature
|
||||
esp_err_t err = esp_secure_boot_verify_signature_block(sigblock, digest);
|
||||
bootloader_munmap(data);
|
||||
// Unmap
|
||||
bootloader_munmap(sigblock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,14 @@ if(CONFIG_BT_ENABLED)
|
||||
"bluedroid/bta/jv/bta_jv_api.c"
|
||||
"bluedroid/bta/jv/bta_jv_cfg.c"
|
||||
"bluedroid/bta/jv/bta_jv_main.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_act.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_api.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_at.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_cmd.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_main.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_rfc.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_sco.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_sdp.c"
|
||||
"bluedroid/bta/sdp/bta_sdp.c"
|
||||
"bluedroid/bta/sdp/bta_sdp_act.c"
|
||||
"bluedroid/bta/sdp/bta_sdp_api.c"
|
||||
@ -123,6 +131,8 @@ if(CONFIG_BT_ENABLED)
|
||||
"bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c"
|
||||
"bluedroid/btc/profile/std/a2dp/btc_av.c"
|
||||
"bluedroid/btc/profile/std/avrc/btc_avrc.c"
|
||||
"bluedroid/btc/profile/std/hf_client/btc_hf_client.c"
|
||||
"bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c"
|
||||
"bluedroid/btc/profile/std/gap/btc_gap_ble.c"
|
||||
"bluedroid/btc/profile/std/gap/btc_gap_bt.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gatt_common.c"
|
||||
@ -273,7 +283,7 @@ if(CONFIG_BT_ENABLED)
|
||||
endif()
|
||||
|
||||
# requirements can't depend on config
|
||||
set(COMPONENT_PRIV_REQUIRES nvs_flash)
|
||||
set(COMPONENT_PRIV_REQUIRES nvs_flash nimble)
|
||||
|
||||
register_component()
|
||||
|
||||
|
@ -53,6 +53,29 @@ menu Bluetooth
|
||||
BR/EDR Synchronize maximum connections of bluetooth controller.
|
||||
Each connection uses 2KB static DRAM whenever the BT controller is enabled.
|
||||
|
||||
choice BTDM_CTRL_BR_EDR_SCO_DATA_PATH
|
||||
prompt "BR/EDR Sync(SCO/eSCO) default data path"
|
||||
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
|
||||
help
|
||||
SCO data path, i.e. HCI or PCM.
|
||||
SCO data can be sent/received through HCI synchronous packets, or the data
|
||||
can be routed to on-chip PCM module on ESP32. PCM input/output signals can
|
||||
be "matrixed" to GPIOs. The default data path can also be set using API
|
||||
"esp_bredr_sco_datapath_set"
|
||||
|
||||
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
|
||||
bool "HCI"
|
||||
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
|
||||
bool "PCM"
|
||||
endchoice
|
||||
|
||||
config BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF
|
||||
int
|
||||
default 0 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_HCI
|
||||
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
|
||||
default 0
|
||||
|
||||
config BTDM_CONTROLLER_BLE_MAX_CONN_EFF
|
||||
int
|
||||
default BTDM_CONTROLLER_BLE_MAX_CONN if BTDM_CONTROLLER_MODE_BLE_ONLY || BTDM_CONTROLLER_MODE_BTDM
|
||||
@ -258,6 +281,55 @@ menu Bluetooth
|
||||
The full scan function is mainly used to provide BLE scan performance.
|
||||
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
|
||||
|
||||
config BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on (BTDM_CONTROLLER_MODE_BTDM || BTDM_CONTROLLER_MODE_BLE_ONLY)
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that Bluedroid can save.If you set
|
||||
`BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a large value, Bluedroid may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BLE_ADV_REPORT_FLOW_CONTROL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
menuconfig BTDM_COEX_BT_OPTIONS
|
||||
bool "Coexistence Bluetooth Side Options"
|
||||
depends on SW_COEXIST_ENABLE
|
||||
default n
|
||||
help
|
||||
Options of Bluetooth Side of WiFi and bluetooth coexistence.
|
||||
|
||||
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
|
||||
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
|
||||
depends on BTDM_COEX_BT_OPTIONS
|
||||
default n
|
||||
help
|
||||
Improve BLE ADV coexistence priority to make it better performance.
|
||||
For example, BLE mesh need to enable this option to improve BLE adv performance.
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
@ -356,15 +428,15 @@ menu Bluetooth
|
||||
choice HFP_AUDIO_DATA_PATH
|
||||
prompt "audio(SCO) data path"
|
||||
depends on HFP_ENABLE
|
||||
help
|
||||
SCO data path, i.e. HCI or PCM. This option is set using API
|
||||
"esp_bredr_sco_datapath_set" in Bluetooth host. Default SCO data
|
||||
path can also be set in Bluetooth Controller.
|
||||
|
||||
config HFP_AUDIO_DATA_PATH_PCM
|
||||
bool "PCM"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
config HFP_AUDIO_DATA_PATH_HCI
|
||||
bool "HCI"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
endchoice
|
||||
|
||||
config BT_SSP_ENABLED
|
||||
@ -1229,9 +1301,304 @@ menu Bluetooth
|
||||
Bluedroid will report adv data or scan response to application layer immediately.
|
||||
|
||||
# Memory reserved at start of DRAM for Bluetooth stack
|
||||
|
||||
config BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT
|
||||
int "Timeout of BLE connection establishment"
|
||||
depends on BLUEDROID_ENABLED
|
||||
range 1 60
|
||||
default 30
|
||||
help
|
||||
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
|
||||
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
|
||||
|
||||
config BT_RESERVE_DRAM
|
||||
hex
|
||||
default 0xdb5c if BT_ENABLED
|
||||
default 0
|
||||
|
||||
|
||||
menuconfig NIMBLE_ENABLED
|
||||
bool "Enable NimBLE host stack"
|
||||
depends on BTDM_CONTROLLER_HCI_MODE_VHCI && !BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
This enables NimBLE host stack
|
||||
|
||||
config NIMBLE_MAX_CONNECTIONS
|
||||
int "Maximum number of concurrent connections"
|
||||
range 1 9
|
||||
default 1
|
||||
depends on NIMBLE_ENABLED
|
||||
help
|
||||
Defines maximum number of concurrent BLE connections
|
||||
|
||||
config NIMBLE_MAX_BONDS
|
||||
int "Maximum number of bonds to save across reboots"
|
||||
default 3
|
||||
depends on NIMBLE_ENABLED
|
||||
help
|
||||
Defines maximum number of bonds to save for peer security and our security
|
||||
|
||||
config NIMBLE_MAX_CCCDS
|
||||
int "Maximum number of CCC descriptors to save across reboots"
|
||||
default 8
|
||||
depends on NIMBLE_ENABLED
|
||||
help
|
||||
Defines maximum number of CCC descriptors to save
|
||||
|
||||
config NIMBLE_L2CAP_COC_MAX_NUM
|
||||
int "Maximum number of connection oriented channels"
|
||||
range 0 9
|
||||
depends on NIMBLE_ENABLED
|
||||
default 0
|
||||
help
|
||||
Defines maximum number of BLE Connection Oriented Channels. When set to (0), BLE COC is not compiled in
|
||||
|
||||
choice NIMBLE_PINNED_TO_CORE_CHOICE
|
||||
prompt "The CPU core on which NimBLE host will run"
|
||||
depends on NIMBLE_ENABLED && !FREERTOS_UNICORE
|
||||
help
|
||||
The CPU core on which NimBLE host will run. You can choose Core 0 or Core 1.
|
||||
Cannot specify no-affinity
|
||||
|
||||
config NIMBLE_PINNED_TO_CORE_0
|
||||
bool "Core 0 (PRO CPU)"
|
||||
config NIMBLE_PINNED_TO_CORE_1
|
||||
bool "Core 1 (APP CPU)"
|
||||
depends on !FREERTOS_UNICORE
|
||||
endchoice
|
||||
|
||||
config NIMBLE_PINNED_TO_CORE
|
||||
int
|
||||
depends on NIMBLE_ENABLED
|
||||
default 0 if NIMBLE_PINNED_TO_CORE_0
|
||||
default 1 if NIMBLE_PINNED_TO_CORE_1
|
||||
default 0
|
||||
|
||||
config NIMBLE_TASK_STACK_SIZE
|
||||
int "NimBLE Host task stack size"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 4096
|
||||
help
|
||||
This configures stack size of NimBLE host task
|
||||
|
||||
config NIMBLE_ROLE_CENTRAL
|
||||
bool "Enable BLE Central role"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
|
||||
config NIMBLE_ROLE_PERIPHERAL
|
||||
bool "Enable BLE Peripheral role"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
|
||||
config NIMBLE_ROLE_BROADCASTER
|
||||
bool "Enable BLE Broadcaster role"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
|
||||
config NIMBLE_ROLE_OBSERVER
|
||||
bool "Enable BLE Observer role"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
|
||||
config NIMBLE_NVS_PERSIST
|
||||
bool "Persist the BLE Bonding keys in NVS"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable this flag to make bonding persistent across device reboots
|
||||
|
||||
config NIMBLE_SM_LEGACY
|
||||
bool "Security manager legacy pairing"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable security manager legacy pairing
|
||||
|
||||
config NIMBLE_SM_SC
|
||||
bool "Security manager secure connections (4.2)"
|
||||
depends on NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable security manager secure connections
|
||||
|
||||
config NIMBLE_DEBUG
|
||||
bool "Enable extra runtime asserts and host debugging"
|
||||
default n
|
||||
depends on NIMBLE_ENABLED
|
||||
help
|
||||
This enables extra runtime asserts and host debugging
|
||||
|
||||
config NIMBLE_SM_SC_DEBUG_KEYS
|
||||
bool "Use predefined public-private key pair"
|
||||
default n
|
||||
depends on NIMBLE_ENABLED && NIMBLE_SM_SC
|
||||
help
|
||||
If this option is enabled, SM uses predefined DH key pair as described
|
||||
in Core Specification, Vol. 3, Part H, 2.3.5.6.1. This allows to
|
||||
decrypt air traffic easily and thus should only be used for debugging.
|
||||
|
||||
config NIMBLE_SVC_GAP_DEVICE_NAME
|
||||
string "BLE GAP default device name"
|
||||
depends on NIMBLE_ENABLED
|
||||
default "nimble"
|
||||
help
|
||||
The Device Name characteristic shall contain the name of the device as an UTF-8 string.
|
||||
This name can be changed by using API ble_svc_gap_device_name_set()
|
||||
|
||||
config NIMBLE_GAP_DEVICE_NAME_MAX_LEN
|
||||
int "Maximum length of BLE device name in octets"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 31
|
||||
help
|
||||
Device Name characteristic value shall be 0 to 248 octets in length
|
||||
|
||||
config NIMBLE_ATT_PREFERRED_MTU
|
||||
int "Preferred MTU size in octets"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 256
|
||||
help
|
||||
This is the default value of ATT MTU indicated by the device during an ATT MTU exchange.
|
||||
This value can be changed using API ble_att_set_preferred_mtu()
|
||||
|
||||
config NIMBLE_SVC_GAP_APPEARANCE
|
||||
hex "External appearance of the device"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 0
|
||||
help
|
||||
Standard BLE GAP Appearance value in HEX format e.g. 0x02C0
|
||||
|
||||
config NIMBLE_ACL_BUF_COUNT
|
||||
int "ACL Buffer count"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 12
|
||||
help
|
||||
The number of ACL data buffers.
|
||||
|
||||
config NIMBLE_ACL_BUF_SIZE
|
||||
int "ACL Buffer size"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 255
|
||||
help
|
||||
This is the maximum size of the data portion of HCI ACL data packets.
|
||||
It does not include the HCI data header (of 4 bytes)
|
||||
|
||||
config NIMBLE_HCI_EVT_BUF_SIZE
|
||||
int "HCI Event Buffer size"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 70
|
||||
help
|
||||
This is the size of each HCI event buffer in bytes
|
||||
|
||||
config NIMBLE_HCI_EVT_HI_BUF_COUNT
|
||||
int "High Priority HCI Event Buffer count"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 30
|
||||
help
|
||||
This is the high priority HCI events' buffer size. High-priority
|
||||
event buffers are for everything except advertising reports. If there
|
||||
are no free high-priority event buffers then host will try to allocate a
|
||||
low-priority buffer instead
|
||||
|
||||
config NIMBLE_HCI_EVT_LO_BUF_COUNT
|
||||
int "Low Priority HCI Event Buffer count"
|
||||
depends on NIMBLE_ENABLED
|
||||
default 8
|
||||
help
|
||||
This is the low priority HCI events' buffer size. Low-priority event
|
||||
buffers are only used for advertising reports. If there are no free
|
||||
low-priority event buffers, then an incoming advertising report will
|
||||
get dropped
|
||||
|
||||
menuconfig NIMBLE_MESH
|
||||
bool "Enable BLE mesh functionality"
|
||||
select NIMBLE_SM_SC
|
||||
depends on NIMBLE_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable BLE Mesh functionality
|
||||
|
||||
config NIMBLE_MESH_PROXY
|
||||
bool "Enable mesh proxy functionality"
|
||||
default n
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
Enable proxy. This is automatically set whenever NIMBLE_MESH_PB_GATT or
|
||||
NIMBLE_MESH_GATT_PROXY is set
|
||||
|
||||
|
||||
config NIMBLE_MESH_PROV
|
||||
bool "Enable BLE mesh provisioning"
|
||||
default y
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
Enable mesh provisioning
|
||||
|
||||
config NIMBLE_MESH_PB_ADV
|
||||
bool "Enable mesh provisioning over advertising bearer"
|
||||
default y
|
||||
depends on NIMBLE_MESH_PROV
|
||||
help
|
||||
Enable this option to allow the device to be provisioned over
|
||||
the advertising bearer
|
||||
|
||||
|
||||
config NIMBLE_MESH_PB_GATT
|
||||
bool "Enable mesh provisioning over GATT bearer"
|
||||
default y
|
||||
select NIMBLE_MESH_PROXY
|
||||
depends on NIMBLE_MESH_PROV
|
||||
help
|
||||
Enable this option to allow the device to be provisioned over the GATT
|
||||
bearer
|
||||
|
||||
config NIMBLE_MESH_GATT_PROXY
|
||||
bool "Enable GATT Proxy functionality"
|
||||
default y
|
||||
select NIMBLE_MESH_PROXY
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
This option enables support for the Mesh GATT Proxy Service,
|
||||
i.e. the ability to act as a proxy between a Mesh GATT Client
|
||||
and a Mesh network
|
||||
|
||||
config NIMBLE_MESH_RELAY
|
||||
bool "Enable mesh relay functionality"
|
||||
default n
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
Support for acting as a Mesh Relay Node
|
||||
|
||||
config NIMBLE_MESH_LOW_POWER
|
||||
bool "Enable mesh low power mode"
|
||||
default n
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
Enable this option to be able to act as a Low Power Node
|
||||
|
||||
config NIMBLE_MESH_FRIEND
|
||||
bool "Enable mesh friend functionality"
|
||||
default n
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
Enable this option to be able to act as a Friend Node
|
||||
|
||||
config NIMBLE_MESH_DEVICE_NAME
|
||||
string "Set mesh device name"
|
||||
default "nimble-mesh-node"
|
||||
depends on NIMBLE_MESH
|
||||
help
|
||||
This value defines Bluetooth Mesh device/node name
|
||||
|
||||
config NIMBLE_CRYPTO_STACK_MBEDTLS
|
||||
bool "Override TinyCrypt with mbedTLS for crypto computations"
|
||||
default y
|
||||
depends on NIMBLE_ENABLED
|
||||
select MBEDTLS_ECP_RESTARTABLE
|
||||
select MBEDTLS_CMAC_C
|
||||
help
|
||||
Enable this option to choose mbedTLS instead of TinyCrypt for crypto
|
||||
computations.
|
||||
|
||||
endmenu
|
||||
|
@ -457,7 +457,7 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!device_info){
|
||||
if (!device_info && type <= ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@ -465,7 +465,9 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST;
|
||||
arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_ADD;
|
||||
arg.update_duplicate_exceptional_list.info_type = type;
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
if (device_info) {
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
@ -479,7 +481,7 @@ esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!device_info){
|
||||
if (!device_info && type <= ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@ -487,7 +489,9 @@ esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate
|
||||
msg.act = BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST;
|
||||
arg.update_duplicate_exceptional_list.subcode = ESP_BLE_DUPLICATE_EXCEPTIONAL_LIST_REMOVE;
|
||||
arg.update_duplicate_exceptional_list.info_type = type;
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
if (device_info) {
|
||||
memcpy(arg.update_duplicate_exceptional_list.device_info, device_info, sizeof(esp_bd_addr_t));
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
@ -267,14 +267,25 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
ESP_BLE_SM_PASSKEY = 0,
|
||||
/* Authentication requirements of local device */
|
||||
ESP_BLE_SM_AUTHEN_REQ_MODE,
|
||||
/* The IO capability of local device */
|
||||
ESP_BLE_SM_IOCAP_MODE,
|
||||
/* Initiator Key Distribution/Generation */
|
||||
ESP_BLE_SM_SET_INIT_KEY,
|
||||
/* Responder Key Distribution/Generation */
|
||||
ESP_BLE_SM_SET_RSP_KEY,
|
||||
/* Maximum Encryption key size to support */
|
||||
ESP_BLE_SM_MAX_KEY_SIZE,
|
||||
/* Minimum Encryption key size requirement from Peer */
|
||||
ESP_BLE_SM_MIN_KEY_SIZE,
|
||||
/* Set static Passkey */
|
||||
ESP_BLE_SM_SET_STATIC_PASSKEY,
|
||||
/* Reset static Passkey */
|
||||
ESP_BLE_SM_CLEAR_STATIC_PASSKEY,
|
||||
/* Accept only specified SMP Authentication requirement */
|
||||
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
|
||||
/* Enable/Disable OOB support */
|
||||
ESP_BLE_SM_OOB_SUPPORT,
|
||||
ESP_BLE_SM_MAX_PARAM,
|
||||
} esp_ble_sm_param_t;
|
||||
@ -558,6 +569,7 @@ typedef enum {
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /*!< Search cancelled */
|
||||
ESP_GAP_SEARCH_INQ_DISCARD_NUM_EVT = 7, /*!< The number of pkt discarded by flow control */
|
||||
} esp_gap_search_evt_t;
|
||||
|
||||
/**
|
||||
@ -588,12 +600,18 @@ typedef enum {
|
||||
typedef enum {
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR = 0, /*!< BLE advertising address , device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID, /*!< BLE mesh link ID, it is for BLE mesh, device info will be added into ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE, /*!< BLE mesh beacon AD type, the format is | Len | 0x2B | Beacon Type | Beacon Data | */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV, /*!< BLE mesh provisioning service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1827 | .... |` */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV, /*!< BLE mesh adv with proxy service uuid, the format is | 0x02 | 0x01 | flags | 0x03 | 0x03 | 0x1828 | .... |` */
|
||||
} esp_ble_duplicate_exceptional_info_type_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = (BLE_BIT(0) | BLE_BIT(1)), /*!< duplicate scan exceptional all list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ADDR_LIST = BLE_BIT(0), /*!< duplicate scan exceptional addr list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_LINK_ID_LIST = BLE_BIT(1), /*!< duplicate scan exceptional mesh link ID list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_BEACON_TYPE_LIST = BLE_BIT(2), /*!< duplicate scan exceptional mesh beacon type list */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROV_SRV_ADV_LIST = BLE_BIT(3), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_MESH_PROXY_SRV_ADV_LIST = BLE_BIT(4), /*!< duplicate scan exceptional mesh adv with provisioning service uuid */
|
||||
ESP_BLE_DUPLICATE_SCAN_EXCEPTIONAL_ALL_LIST = 0xFFFF, /*!< duplicate scan exceptional all list */
|
||||
} esp_duplicate_scan_exceptional_list_type_t;
|
||||
|
||||
typedef uint8_t esp_duplicate_info_t[ESP_BD_ADDR_LEN];
|
||||
@ -635,6 +653,7 @@ typedef union {
|
||||
int num_resps; /*!< Scan result number */
|
||||
uint8_t adv_data_len; /*!< Adv data length */
|
||||
uint8_t scan_rsp_len; /*!< Scan response length */
|
||||
uint32_t num_dis; /*!< The number of discard packets */
|
||||
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
|
||||
@ -1049,6 +1068,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr);
|
||||
*
|
||||
*
|
||||
* @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t
|
||||
* when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid.
|
||||
* @param[in] device_info: the device information.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
@ -1061,6 +1081,7 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
*
|
||||
*
|
||||
* @param[in] type: device info type, it is defined in esp_ble_duplicate_exceptional_info_type_t
|
||||
* when type is MESH_BEACON_TYPE, MESH_PROV_SRV_ADV or MESH_PROXY_SRV_ADV , device_info is invalid.
|
||||
* @param[in] device_info: the device information.
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
|
@ -1293,9 +1293,10 @@ void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
/* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind.
|
||||
* call disc_res now */
|
||||
/* this is called in A2DP SRC path only, In case of SINK we don't need it */
|
||||
if (local_sep == AVDT_TSEP_SRC)
|
||||
if (local_sep == AVDT_TSEP_SRC) {
|
||||
p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr,
|
||||
UUID_SERVCLASS_AUDIO_SOURCE);
|
||||
}
|
||||
} else {
|
||||
/* we do not know the peer device and it is using non-SBC codec
|
||||
* we need to know all the SEPs on SNK */
|
||||
|
@ -829,10 +829,11 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) {
|
||||
p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL;
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
if (p_cb->features & BTA_AV_FEAT_METADATA)
|
||||
if (p_cb->features & BTA_AV_FEAT_METADATA) {
|
||||
p_data->rc_msg.msg.hdr.ctype =
|
||||
bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len,
|
||||
p_data->rc_msg.msg.pass.p_pass_data, is_inquiry);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry);
|
||||
@ -890,7 +891,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
evt = BTA_AV_VENDOR_CMD_EVT;
|
||||
}
|
||||
}
|
||||
/* else if configured to support vendor specific and it's a response */
|
||||
else if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
|
||||
@ -902,7 +905,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
evt = BTA_AV_META_MSG_EVT;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
evt = BTA_AV_VENDOR_RSP_EVT;
|
||||
}
|
||||
|
||||
}
|
||||
/* else if not configured to support vendor specific and it's a command */
|
||||
|
@ -1268,7 +1268,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_st_code(UINT8 state)
|
||||
UNUSED_ATTR static char *bta_av_st_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_ST: return "INIT";
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "osi/osi.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
@ -564,7 +565,7 @@ void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_sst_code(UINT8 state)
|
||||
UNUSED_ATTR static char *bta_av_sst_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_SST: return "INIT";
|
||||
|
@ -127,6 +127,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
|
||||
static void bta_dm_observe_cmpl_cb(void *p_result);
|
||||
static void bta_dm_observe_discard_cb (uint32_t num_dis);
|
||||
static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
|
||||
extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128);
|
||||
static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle);
|
||||
@ -635,13 +636,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
|
||||
/* set modes for Discoverability and connectability if not ignore */
|
||||
if (p_data->set_visibility.disc_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE)
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
|
||||
p_data->set_visibility.disc_mode =
|
||||
((p_data->set_visibility.disc_mode & ~BTA_DM_LE_IGNORE) | le_disc_mode);
|
||||
}
|
||||
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE)
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
|
||||
p_data->set_visibility.disc_mode =
|
||||
((p_data->set_visibility.disc_mode & ~BTA_DM_IGNORE) | disc_mode);
|
||||
}
|
||||
|
||||
BTM_SetDiscoverability(p_data->set_visibility.disc_mode,
|
||||
bta_dm_cb.inquiry_scan_window,
|
||||
@ -649,13 +652,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
if (p_data->set_visibility.conn_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE)
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
|
||||
p_data->set_visibility.conn_mode =
|
||||
((p_data->set_visibility.conn_mode & ~BTA_DM_LE_IGNORE) | le_conn_mode);
|
||||
}
|
||||
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE)
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
|
||||
p_data->set_visibility.conn_mode =
|
||||
((p_data->set_visibility.conn_mode & ~BTA_DM_IGNORE) | conn_mode);
|
||||
}
|
||||
|
||||
BTM_SetConnectability(p_data->set_visibility.conn_mode,
|
||||
bta_dm_cb.page_scan_window,
|
||||
@ -1900,10 +1905,12 @@ void bta_dm_disc_result (tBTA_DM_MSG *p_data)
|
||||
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
/* if any BR/EDR service discovery has been done, report the event */
|
||||
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK)))
|
||||
#endif
|
||||
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK))) {
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
|
||||
|
||||
}
|
||||
#else
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
|
||||
#endif
|
||||
tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG));
|
||||
|
||||
/* send a message to change state */
|
||||
@ -2169,9 +2176,10 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
}
|
||||
|
||||
/* last one? clear the BLE service bit if all discovery has been done */
|
||||
if (bta_dm_search_cb.uuid_to_search == 0)
|
||||
if (bta_dm_search_cb.uuid_to_search == 0) {
|
||||
bta_dm_search_cb.services_to_search &=
|
||||
(tBTA_SERVICE_MASK)(~(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index)));
|
||||
}
|
||||
|
||||
} else
|
||||
#endif
|
||||
@ -3654,11 +3662,11 @@ static char *bta_dm_get_remname(void)
|
||||
char *p_temp;
|
||||
|
||||
/* If the name isn't already stored, try retrieving from BTM */
|
||||
if (*p_name == '\0')
|
||||
if (*p_name == '\0') {
|
||||
if ((p_temp = BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr)) != NULL) {
|
||||
p_name = p_temp;
|
||||
}
|
||||
|
||||
}
|
||||
return p_name;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
|
||||
@ -4273,6 +4281,28 @@ static void bta_dm_observe_cmpl_cb (void *p_result)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_observe_discard_cb
|
||||
**
|
||||
** Description Callback for BLE Observe lost
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_dm_observe_discard_cb (uint32_t num_dis)
|
||||
{
|
||||
tBTA_DM_SEARCH data;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_dm_observe_discard_cb");
|
||||
|
||||
data.inq_dis.num_dis = num_dis;
|
||||
if (bta_dm_search_cb.p_scan_cback) {
|
||||
bta_dm_search_cb.p_scan_cback(BTA_DM_INQ_DISCARD_NUM_EVT, &data);
|
||||
}
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -4815,7 +4845,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
|
||||
bta_dm_search_cb.p_scan_cback = p_data->ble_scan.p_cback;
|
||||
|
||||
if ((status = BTM_BleScan(TRUE, p_data->ble_scan.duration,
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) {
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb, bta_dm_observe_discard_cb)) != BTM_CMD_STARTED) {
|
||||
APPL_TRACE_WARNING(" %s start scan failed. status=0x%x\n", __FUNCTION__, status);
|
||||
}
|
||||
|
||||
@ -4825,7 +4855,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
} else {
|
||||
bta_dm_search_cb.p_scan_cback = NULL;
|
||||
status = BTM_BleScan(FALSE, 0, NULL, NULL);
|
||||
status = BTM_BleScan(FALSE, 0, NULL, NULL, NULL);
|
||||
|
||||
if (status != BTM_CMD_STARTED){
|
||||
APPL_TRACE_WARNING(" %s stop scan failed, status=0x%x\n", __FUNCTION__, status);
|
||||
@ -5219,9 +5249,10 @@ void bta_dm_ble_setup_storage (tBTA_DM_MSG *p_data)
|
||||
p_data->ble_set_storage.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_CFG_STRG_EVT, p_data->ble_set_storage.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -5249,9 +5280,10 @@ void bta_dm_ble_enable_batch_scan (tBTA_DM_MSG *p_data)
|
||||
p_data->ble_enable_scan.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_ENABLE_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -5275,9 +5307,10 @@ void bta_dm_ble_disable_batch_scan (tBTA_DM_MSG *p_data)
|
||||
btm_status = BTM_BleDisableBatchScan(p_data->ble_disable_scan.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_DISABLE_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -5301,9 +5334,10 @@ void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data)
|
||||
p_data->ble_read_reports.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_READ_REPTS_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -5433,10 +5467,11 @@ void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback)
|
||||
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback) {
|
||||
p_data->ble_cfg_filter_cond.p_filt_cfg_cback(BTA_DM_BLE_PF_CONFIG_EVT,
|
||||
p_data->ble_cfg_filter_cond.cond_type, 0, status,
|
||||
p_data->ble_cfg_filter_cond.ref_value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5467,9 +5502,10 @@ void bta_dm_enable_scan_filter(tBTA_DM_MSG *p_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_data->ble_enable_scan_filt.p_filt_status_cback)
|
||||
if (p_data->ble_enable_scan_filt.p_filt_status_cback) {
|
||||
p_data->ble_enable_scan_filt.p_filt_status_cback (BTA_DM_BLE_PF_ENABLE_EVT,
|
||||
p_data->ble_enable_scan_filt.ref_value, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5503,9 +5539,10 @@ void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback)
|
||||
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback) {
|
||||
p_data->ble_scan_filt_param_setup.p_filt_param_cback (BTA_DM_BLE_PF_ENABLE_EVT, 0,
|
||||
p_data->ble_scan_filt_param_setup.ref_value, status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -5815,6 +5852,8 @@ void bta_dm_proc_open_evt(tBTA_GATTC_OPEN *p_data)
|
||||
((p2[0]) << 24) + ((p2[1]) << 16) + ((p2[2]) << 8) + (p2[3]),
|
||||
((p2[4]) << 8) + p2[5]);
|
||||
|
||||
UNUSED(p1);
|
||||
UNUSED(p2);
|
||||
APPL_TRACE_DEBUG("BTA_GATTC_OPEN_EVT conn_id = %d client_if=%d status = %d" ,
|
||||
p_data->conn_id,
|
||||
p_data->client_if,
|
||||
|
@ -48,6 +48,7 @@ tBTE_APPL_CFG bte_appl_cfg = {
|
||||
BTM_BLE_INITIATOR_KEY_SIZE,
|
||||
BTM_BLE_RESPONDER_KEY_SIZE,
|
||||
BTM_BLE_MAX_KEY_SIZE,
|
||||
BTM_BLE_MIN_KEY_SIZE,
|
||||
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE,
|
||||
BTM_BLE_OOB_DISABLE,
|
||||
};
|
||||
@ -407,7 +408,7 @@ void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key)
|
||||
void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_key_size >= BTM_BLE_MIN_KEY_SIZE && ble_key_size <= BTM_BLE_MAX_KEY_SIZE) {
|
||||
if(ble_key_size >= bte_appl_cfg.ble_min_key_size && ble_key_size <= BTM_BLE_MAX_KEY_SIZE) {
|
||||
bte_appl_cfg.ble_max_key_size = ble_key_size;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
|
||||
@ -415,6 +416,17 @@ void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_key_size >= BTM_BLE_MIN_KEY_SIZE && ble_key_size <= bte_appl_cfg.ble_max_key_size) {
|
||||
bte_appl_cfg.ble_min_key_size = ble_key_size;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
@ -1038,9 +1038,10 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive)
|
||||
bta_dm_pm_set_sniff_policy( bta_dm_find_peer_device(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr), bScoActive);
|
||||
|
||||
/* if we had disabled link policy, seems like the hid device stop retrying SNIFF after a few tries. force sniff if needed */
|
||||
if (!bScoActive)
|
||||
if (!bScoActive) {
|
||||
bta_dm_pm_set_mode(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, BTA_DM_PM_NO_ACTION,
|
||||
BTA_DM_PM_RESTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,7 +531,9 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
|
||||
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) {
|
||||
/* always call open to hold a connection */
|
||||
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, p_data->transport)) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
uint8_t *bda = (uint8_t *)p_data->remote_bda;
|
||||
#endif
|
||||
status = BTA_GATT_ERROR;
|
||||
APPL_TRACE_ERROR("%s unable to connect to remote bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
@ -674,7 +676,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
|
||||
//register service change
|
||||
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
|
||||
} else
|
||||
} else
|
||||
#endif
|
||||
{ /* cache is building */
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
|
||||
@ -1071,8 +1073,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data))
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tGATT_READ_PARAM read_param;
|
||||
memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));
|
||||
@ -1140,8 +1143,9 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data))
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
tGATT_VALUE attr;
|
||||
@ -1742,7 +1746,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
|
||||
tBTA_GATTC gattc_cb = {0};
|
||||
gattc_cb.set_assoc.client_if = p_msg->api_assoc.client_if;
|
||||
BOOLEAN state = FALSE;
|
||||
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
|
||||
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
|
||||
p_msg->api_assoc.assoc_addr, BTA_TRANSPORT_LE);
|
||||
tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_assoc.client_if);
|
||||
if (p_assoc_clcb != NULL) {
|
||||
@ -1783,7 +1787,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ static char *bta_gattc_attr_type[] = {
|
||||
};
|
||||
/* utility functions */
|
||||
|
||||
bool display_cache_attribute(void *data, void *context)
|
||||
bool display_cache_attribute(void *data, void *context)
|
||||
{
|
||||
//tBTA_GATTC_CACHE_ATTR *p_attr = data;
|
||||
//APPL_TRACE_ERROR("\t Attr handle[%d] uuid[0x%04x] type[%s] prop[0x%1x]",
|
||||
@ -102,7 +102,7 @@ bool display_cache_attribute(void *data, void *context)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool display_cache_service(void *data, void *context)
|
||||
bool display_cache_service(void *data, void *context)
|
||||
{
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = data;
|
||||
APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
|
||||
@ -213,9 +213,9 @@ static void bta_gattc_free(void *ptr)
|
||||
osi_free(ptr);
|
||||
}
|
||||
|
||||
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
|
||||
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
|
||||
{
|
||||
// services/p_new_srvc is NULL
|
||||
// services/p_new_srvc is NULL
|
||||
if (!services || !p_new_srvc) {
|
||||
APPL_TRACE_ERROR("%s services/p_new_srvc is NULL", __func__);
|
||||
return;
|
||||
@ -243,7 +243,7 @@ void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,8 +314,9 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
/* TODO(jpawlowski): We should use attribute handle, not value handle to refer to characteristic.
|
||||
This is just a temporary workaround.
|
||||
*/
|
||||
if (service->e_handle < value_handle)
|
||||
if (service->e_handle < value_handle) {
|
||||
service->e_handle = value_handle;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC *characteristic = osi_malloc(sizeof(tBTA_GATTC_CHARACTERISTIC));
|
||||
if (!characteristic) {
|
||||
@ -554,10 +555,10 @@ void bta_gattc_update_include_service(const list_t *services) {
|
||||
if(include_service && !include_service->included_service) {
|
||||
//update
|
||||
include_service->included_service = bta_gattc_find_matching_service(services, include_service->incl_srvc_s_handle);
|
||||
if(!include_service->included_service) {
|
||||
if(!include_service->included_service) {
|
||||
//not match, free it
|
||||
list_remove(service->included_svc, include_service);
|
||||
osi_free(include_service);
|
||||
osi_free(include_service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -980,12 +981,13 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
p_data->value.incl_service.e_handle,
|
||||
p_data->value.incl_service.service_type);
|
||||
|
||||
if (!pri_srvc)
|
||||
if (!pri_srvc) {
|
||||
bta_gattc_add_srvc_to_list(p_srvc_cb,
|
||||
p_data->value.incl_service.s_handle,
|
||||
p_data->value.incl_service.e_handle,
|
||||
p_data->value.incl_service.service_type,
|
||||
FALSE);
|
||||
}
|
||||
/* add into database */
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
@ -1007,8 +1009,8 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
|
||||
case GATT_DISC_CHAR_DSCPT:
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
0,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
@ -1023,8 +1025,9 @@ void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if ( p_clcb && (status != GATT_SUCCESS || p_clcb->status != GATT_SUCCESS) ) {
|
||||
if (status == GATT_SUCCESS)
|
||||
if (status == GATT_SUCCESS) {
|
||||
p_clcb->status = status;
|
||||
}
|
||||
bta_gattc_sm_execute(p_clcb, BTA_GATTC_DISCOVER_CMPL_EVT, NULL);
|
||||
return;
|
||||
}
|
||||
@ -1071,15 +1074,17 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache))
|
||||
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (list_node_t *sn = list_begin(p_clcb->p_srcb->p_srvc_cache);
|
||||
sn != list_end(p_clcb->p_srcb->p_srvc_cache); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *p_cache = list_node(sn);
|
||||
|
||||
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE))
|
||||
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
APPL_TRACE_DEBUG("found service [0x%04x], inst[%d] handle [%d]",
|
||||
@ -1087,8 +1092,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
p_cache->handle,
|
||||
p_cache->s_handle);
|
||||
#endif
|
||||
if (!p_clcb->p_rcb->p_cback)
|
||||
if (!p_clcb->p_rcb->p_cback) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
@ -1103,8 +1109,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
}
|
||||
|
||||
list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
|
||||
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache))
|
||||
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p_srcb->p_srvc_cache;
|
||||
}
|
||||
@ -1112,8 +1119,9 @@ list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
|
||||
const list_t* bta_gattc_get_services(UINT16 conn_id) {
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
|
||||
@ -1121,63 +1129,68 @@ const list_t* bta_gattc_get_services(UINT16 conn_id) {
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERVICE* bta_gattc_find_matching_service(const list_t *services, UINT16 handle) {
|
||||
if (!services || list_is_empty(services))
|
||||
if (!services || list_is_empty(services)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list_node_t *sn = list_begin(services);
|
||||
sn != list_end(services); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *service = list_node(sn);
|
||||
|
||||
if (handle >= service->s_handle && handle <= service->e_handle)
|
||||
if (handle >= service->s_handle && handle <= service->e_handle) {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const list_t *services = bta_gattc_get_services_srcb(p_srcb);
|
||||
|
||||
return bta_gattc_find_matching_service(services, handle);
|
||||
}
|
||||
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
const list_t *services = bta_gattc_get_services(conn_id);
|
||||
|
||||
return bta_gattc_find_matching_service(services, handle);
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
|
||||
|
||||
if (!service)
|
||||
if (!service) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(service->characteristics);
|
||||
cn != list_end(service->characteristics); cn = list_next(cn)) {
|
||||
tBTA_GATTC_CHARACTERISTIC *p_char = list_node(cn);
|
||||
if (handle == p_char->handle)
|
||||
if (handle == p_char->handle) {
|
||||
return p_char;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
return bta_gattc_get_characteristic_srcb(p_srcb, handle);
|
||||
}
|
||||
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
|
||||
|
||||
@ -1191,20 +1204,22 @@ tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, U
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
tBTA_GATTC_DESCRIPTOR *p_desc = list_node(dn);
|
||||
if (handle == p_desc->handle)
|
||||
if (handle == p_desc->handle) {
|
||||
return p_desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
return bta_gattc_get_descriptor_srcb(p_srcb, handle);
|
||||
@ -1443,7 +1458,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1476,7 +1491,7 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
}
|
||||
|
||||
if (type == BTGATT_DB_PRIMARY_SERVICE || type == BTGATT_DB_SECONDARY_SERVICE) {
|
||||
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
|
||||
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
|
||||
(type == BTGATT_DB_SECONDARY_SERVICE && !p_cur_srvc->is_primary)) {
|
||||
// if the current service is the last service in the db, need to ensure the current service start handle is not less than the start_handle.
|
||||
if (!svc_length) {
|
||||
@ -1572,10 +1587,11 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
** Returns number of elements inside db from start_handle to end_handle
|
||||
*******************************************************************************/
|
||||
static size_t bta_gattc_get_db_size(list_t *services,
|
||||
UINT16 start_handle, UINT16 end_handle)
|
||||
UINT16 start_handle, UINT16 end_handle)
|
||||
{
|
||||
if (!services || list_is_empty(services))
|
||||
if (!services || list_is_empty(services)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t db_size = 0;
|
||||
UINT16 svc_length = list_length(services) - 1;
|
||||
@ -1598,9 +1614,10 @@ static size_t bta_gattc_get_db_size(list_t *services,
|
||||
} else {
|
||||
db_size++;
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics))
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
@ -1657,7 +1674,7 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
*count = 0;
|
||||
@ -1676,7 +1693,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
*count = 0;
|
||||
@ -1694,7 +1711,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
|
||||
}
|
||||
}
|
||||
*count = bta_gattc_get_db_size_with_type(p_srcb->p_srvc_cache, type, NULL, start_handle, end_handle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1786,8 +1803,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
p_char->properties);
|
||||
curr_db_attr++;
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
@ -1815,8 +1833,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc))
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *isn = list_begin(p_cur_srvc->included_svc);
|
||||
isn != list_end(p_cur_srvc->included_svc); isn = list_next(isn)) {
|
||||
@ -1983,8 +2002,9 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han
|
||||
*******************************************************************************/
|
||||
void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
{
|
||||
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache))
|
||||
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
size_t db_size = bta_gattc_get_db_size(p_srvc_cb->p_srvc_cache, 0x0000, 0xFFFF);
|
||||
@ -2017,8 +2037,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
sn != list_end(p_srvc_cb->p_srvc_cache); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = list_node(sn);
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics))
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
@ -2034,8 +2055,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
0 /* incl_srvc_e_handle */,
|
||||
FALSE);
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
@ -2053,8 +2075,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc))
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *an = list_begin(p_cur_srvc->included_svc);
|
||||
an != list_end(p_cur_srvc->included_svc); an = list_next(an)) {
|
||||
|
@ -261,14 +261,18 @@ tBTA_GATT_STATUS bta_gattc_co_cache_open(BD_ADDR server_bda, BOOLEAN to_save, UI
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS bta_gattc_co_cache_load(tBTA_GATTC_NV_ATTR *attr, UINT8 index)
|
||||
{
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT16 num_attr = 0;
|
||||
#endif
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
size_t length = 0;
|
||||
// Read the size of memory space required for blob
|
||||
nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, NULL, &length);
|
||||
// Read previously saved blob if available
|
||||
esp_err_t err_code = nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, attr, &length);
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
num_attr = length / sizeof(tBTA_GATTC_NV_ATTR);
|
||||
#endif
|
||||
status = (err_code == ESP_OK && length != 0) ? BTA_GATT_OK : BTA_GATT_ERROR;
|
||||
APPL_TRACE_DEBUG("%s() - read=%d, status=%d, err_code = %d",
|
||||
__func__, num_attr, status, err_code);
|
||||
@ -323,6 +327,9 @@ void bta_gattc_co_cache_save (BD_ADDR server_bda, UINT16 num_attr,
|
||||
status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_STACK_NO_LOG
|
||||
(void) status;
|
||||
#endif
|
||||
APPL_TRACE_DEBUG("%s() wrote hash_key = %x%x%x%x, num_attr = %d, status = %d.", __func__, hash_key[0], hash_key[1], hash_key[2], hash_key[3], num_attr, status);
|
||||
}
|
||||
|
||||
|
@ -416,8 +416,9 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
|
||||
|
||||
if (p_tcb != NULL)
|
||||
{
|
||||
if (p_tcb->p_srvc_cache != NULL)
|
||||
if (p_tcb->p_srvc_cache != NULL) {
|
||||
list_free(p_tcb->p_srvc_cache);
|
||||
}
|
||||
osi_free(p_tcb->p_srvc_list);
|
||||
p_tcb->p_srvc_list = NULL;
|
||||
//osi_free_and_reset((void **)&p_tcb->p_srvc_list);
|
||||
@ -583,8 +584,9 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id,
|
||||
* clear boundaries are always around service.
|
||||
*/
|
||||
handle = p_clrcb->notif_reg[i].handle;
|
||||
if (handle >= start_handle && handle <= end_handle)
|
||||
if (handle >= start_handle && handle <= end_handle) {
|
||||
memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -637,8 +639,9 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda
|
||||
}
|
||||
if (!add) {
|
||||
if (remote_bda_ptr) {
|
||||
// bdstr_t bdstr = {0};
|
||||
#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__,
|
||||
bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
|
||||
}
|
||||
@ -936,8 +939,9 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
|
||||
if (p_src->len == LEN_UUID_16 || p_src->len == LEN_UUID_32)
|
||||
{
|
||||
for(i=0; i != 16; ++i)
|
||||
for(i=0; i != 16; ++i) {
|
||||
p_dest->uu[i] = base_uuid[i];
|
||||
}
|
||||
}
|
||||
|
||||
switch (p_src->len)
|
||||
|
@ -403,7 +403,7 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
UINT16 attr_id = 0;
|
||||
tBTA_GATTS cb_data;
|
||||
|
||||
tGATT_ATTR_VAL *p_attr_val = NULL;
|
||||
tGATT_ATTR_VAL *p_attr_val = NULL;
|
||||
tGATTS_ATTR_CONTROL *p_control = NULL;
|
||||
|
||||
if(p_msg->api_add_char.attr_val.attr_max_len != 0){
|
||||
@ -665,17 +665,18 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
&gatt_if, remote_bda, &transport)) {
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_msg->api_indicate.need_confirm)
|
||||
if (p_msg->api_indicate.need_confirm) {
|
||||
|
||||
status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
else
|
||||
} else {
|
||||
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
}
|
||||
|
||||
/* if over BR_EDR, inform PM for mode change */
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
@ -858,13 +859,13 @@ void bta_gatts_send_service_change_indication (tBTA_GATTS_DATA *p_msg)
|
||||
memcpy(bd_addr, p_msg->api_send_service_change.remote_bda, BD_ADDR_LEN);
|
||||
status = GATT_SendServiceChangeIndication(bd_addr);
|
||||
} else {
|
||||
status = GATT_SendServiceChangeIndication(NULL);
|
||||
status = GATT_SendServiceChangeIndication(NULL);
|
||||
}
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
service_change.status = status;
|
||||
service_change.server_if = p_msg->api_send_service_change.server_if;
|
||||
(*p_rcb->p_cback)(BTA_GATTS_SEND_SERVICE_CHANGE_EVT, (tBTA_GATTS *)&service_change);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -940,7 +941,7 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
|
||||
cb_data.req_data.p_data = (tBTA_GATTS_REQ_DATA *)p_data;
|
||||
|
||||
if(req_type == BTA_GATTS_CONF_EVT) {
|
||||
cb_data.req_data.handle = p_data->handle;
|
||||
cb_data.req_data.handle = p_data->handle;
|
||||
}
|
||||
(*p_rcb->p_cback)(req_type, &cb_data);
|
||||
} else {
|
||||
|
@ -1159,6 +1159,7 @@ static char *bta_hf_client_skip_unknown(char *buffer)
|
||||
buffer = tmp + 2;
|
||||
|
||||
APPL_TRACE_DEBUG("%s %.*s", __FUNCTION__, buffer - start - 2, start);
|
||||
UNUSED(start);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -308,6 +308,7 @@ static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTM_STATUS status = BTM_ConfigScoPath(BTM_SCO_ROUTE_PCM, NULL, NULL, TRUE);
|
||||
APPL_TRACE_DEBUG("%s close config status = %d", __FUNCTION__, status);
|
||||
UNUSED(status);
|
||||
/* SCO clean up here */
|
||||
bta_hf_client_sco_co_close();
|
||||
#endif
|
||||
|
@ -101,8 +101,10 @@ void bta_hh_api_enable(tBTA_HH_DATA *p_data)
|
||||
bta_hh_le_enable();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* signal BTA call back event */
|
||||
(* bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, (tBTA_HH *)&status);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -901,7 +903,9 @@ void bta_hh_get_dscp_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
bta_hh_le_get_dscp_act(p_cb);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -934,11 +938,10 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
dev_info.status = BTA_HH_OK;
|
||||
} else
|
||||
#endif
|
||||
|
||||
{
|
||||
if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask, &dev_handle)\
|
||||
== HID_SUCCESS) {
|
||||
dev_info.handle = dev_handle;
|
||||
dev_info.status = BTA_HH_OK;
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* update DI information */
|
||||
@ -966,6 +969,7 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
/* update cb_index[] map */
|
||||
bta_hh_cb.cb_index[dev_handle] = p_cb->index;
|
||||
}
|
||||
}
|
||||
} else { /* device already been added */
|
||||
dev_info.handle = p_cb->hid_handle;
|
||||
dev_info.status = BTA_HH_OK;
|
||||
|
@ -2183,9 +2183,10 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b
|
||||
case GATT_UUID_HID_BT_KB_INPUT:
|
||||
case GATT_UUID_HID_BT_MOUSE_INPUT:
|
||||
case GATT_UUID_HID_REPORT:
|
||||
if (p_data->status == BTA_GATT_OK)
|
||||
if (p_data->status == BTA_GATT_OK) {
|
||||
p_dev_cb->hid_srvc[hid_inst_id].report[p_dev_cb->clt_cfg_idx].client_cfg_value =
|
||||
BTA_GATT_CLT_CONFIG_NOTIFICATION;
|
||||
}
|
||||
p_dev_cb->clt_cfg_idx ++;
|
||||
bta_hh_le_write_rpt_clt_cfg(p_dev_cb, hid_inst_id);
|
||||
|
||||
|
@ -75,11 +75,12 @@ UINT8 bta_hh_find_cb(BD_ADDR bda)
|
||||
return xx;
|
||||
}
|
||||
#if BTA_HH_DEBUG
|
||||
else
|
||||
else {
|
||||
APPL_TRACE_DEBUG("in_use ? [%d] kdev[%d].hid_handle = %d state = [%d]",
|
||||
bta_hh_cb.kdev[xx].in_use, xx,
|
||||
bta_hh_cb.kdev[xx].hid_handle,
|
||||
bta_hh_cb.kdev[xx].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -123,7 +124,9 @@ void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb)
|
||||
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = BTA_HH_IDX_INVALID;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset device control block */
|
||||
@ -486,11 +489,12 @@ UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle)
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* regular HID device checking */
|
||||
if (dev_handle < BTA_HH_MAX_KNOWN ) {
|
||||
index = bta_hh_cb.cb_index[dev_handle];
|
||||
}
|
||||
|
||||
}
|
||||
return index;
|
||||
|
||||
}
|
||||
|
@ -1024,6 +1024,7 @@ typedef struct {
|
||||
#define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */
|
||||
#define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */
|
||||
#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
|
||||
#define BTA_DM_INQ_DISCARD_NUM_EVT 7 /* The number of inquiry discarded packets */
|
||||
|
||||
typedef UINT8 tBTA_DM_SEARCH_EVT;
|
||||
|
||||
@ -1055,6 +1056,11 @@ typedef struct {
|
||||
UINT8 num_resps; /* Number of inquiry responses. */
|
||||
} tBTA_DM_INQ_CMPL;
|
||||
|
||||
/* Structure associated with BTA_DM_INQ_DISCARD_NUM_EVT */
|
||||
typedef struct {
|
||||
UINT32 num_dis; /* The number of inquiry discarded packets. */
|
||||
} tBTA_DM_INQ_DISCARD;
|
||||
|
||||
/* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
@ -1092,6 +1098,7 @@ typedef union {
|
||||
tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
|
||||
tBTA_DM_DISC_BLE_RES disc_ble_res; /* Discovery result for GATT based service */
|
||||
tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
|
||||
tBTA_DM_INQ_DISCARD inq_dis; /* the discarded packets information of inquiry */
|
||||
} tBTA_DM_SEARCH;
|
||||
|
||||
/* Structure of search callback event and structures */
|
||||
|
@ -205,6 +205,8 @@ extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
|
||||
|
||||
extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
|
||||
|
||||
extern void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size);
|
||||
|
||||
extern void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable);
|
||||
|
||||
extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/osi.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
@ -137,7 +138,7 @@ UINT8 bta_jv_alloc_sec_id(void)
|
||||
return ret;
|
||||
|
||||
}
|
||||
static int get_sec_id_used(void)
|
||||
UNUSED_ATTR static int get_sec_id_used(void)
|
||||
{
|
||||
int i;
|
||||
int used = 0;
|
||||
@ -146,12 +147,13 @@ static int get_sec_id_used(void)
|
||||
used++;
|
||||
}
|
||||
}
|
||||
if (used == BTA_JV_NUM_SERVICE_ID)
|
||||
if (used == BTA_JV_NUM_SERVICE_ID) {
|
||||
APPL_TRACE_ERROR("get_sec_id_used, sec id exceeds the limit:%d",
|
||||
BTA_JV_NUM_SERVICE_ID);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
static int get_rfc_cb_used(void)
|
||||
UNUSED_ATTR static int get_rfc_cb_used(void)
|
||||
{
|
||||
int i;
|
||||
int used = 0;
|
||||
@ -160,9 +162,10 @@ static int get_rfc_cb_used(void)
|
||||
used++;
|
||||
}
|
||||
}
|
||||
if (used == BTA_JV_MAX_RFC_CONN)
|
||||
if (used == BTA_JV_MAX_RFC_CONN) {
|
||||
APPL_TRACE_ERROR("get_sec_id_used, rfc ctrl block exceeds the limit:%d",
|
||||
BTA_JV_MAX_RFC_CONN);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@ -474,19 +477,21 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
||||
< BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) {
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]);
|
||||
if (p_pcb) {
|
||||
if (NULL == p_pcb->p_pm_cb)
|
||||
if (NULL == p_pcb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle:"
|
||||
" 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to "
|
||||
"pm_cb?", __func__, jv_handle, p_pcb->port_handle, i);
|
||||
}
|
||||
p_cb = &p_pcb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (jv_handle < BTA_JV_MAX_L2C_CONN) {
|
||||
tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle];
|
||||
if (NULL == p_l2c_cb->p_pm_cb)
|
||||
if (NULL == p_l2c_cb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle: "
|
||||
"0x%x): p_pm_cb: %d: no link to pm_cb?", __func__, jv_handle, i);
|
||||
}
|
||||
p_cb = &p_l2c_cb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
@ -742,9 +747,10 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
|
||||
bta_jv_cb.scn[channel - 1] = TRUE;
|
||||
scn = (UINT8) channel;
|
||||
}
|
||||
if (bta_jv_cb.p_dm_cback)
|
||||
if (bta_jv_cb.p_dm_cback) {
|
||||
bta_jv_cb.p_dm_cback(BTA_JV_GET_SCN_EVT, (tBTA_JV *)&scn,
|
||||
p_data->alloc_channel.user_data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case BTA_JV_CONN_TYPE_L2CAP:
|
||||
@ -998,6 +1004,9 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
|
||||
APPL_TRACE_DEBUG("create_base_record: successfully created base service "
|
||||
"record, handle: 0x%08x, scn: %d, name: %s, with_obex: %d",
|
||||
sdp_handle, channel, name, with_obex);
|
||||
|
||||
UNUSED(stage);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1031,6 +1040,8 @@ static int add_spp_sdp(const char *name, const int channel) {
|
||||
|
||||
APPL_TRACE_DEBUG("add_spp_sdp: service registered successfully, "
|
||||
"service_name: %s, handle 0x%08x)", name, handle);
|
||||
UNUSED(stage);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -1523,6 +1534,7 @@ static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len,
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(port_handle);
|
||||
int ret = 0;
|
||||
APPL_TRACE_DEBUG("%s, p_cb:%p, p_pcb:%p, len:%d, type:%d", __func__, p_cb, p_pcb, len, type);
|
||||
UNUSED(p_cb);
|
||||
if (p_pcb != NULL) {
|
||||
switch (type) {
|
||||
case DATA_CO_CALLBACK_TYPE_INCOMING:
|
||||
|
@ -750,7 +750,9 @@ static void _btc_read_le_key(const uint8_t key_type, const size_t key_len, bt_bd
|
||||
*device_added = true;
|
||||
}
|
||||
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bd_str[20] = {0};
|
||||
#endif
|
||||
BTC_TRACE_DEBUG("%s() Adding key type %d for %s", __func__,
|
||||
key_type, bdaddr_to_string(&bd_addr, bd_str, sizeof(bd_str)));
|
||||
BTA_DmAddBleKey(bta_bd_addr, (tBTA_LE_KEY_VALUE *)buffer, key_type);
|
||||
|
@ -290,6 +290,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
BTC_TRACE_DEBUG("%s, authentication status = %x", __func__, status);
|
||||
return;
|
||||
|
||||
|
@ -170,6 +170,14 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
status, &rsp);
|
||||
|
||||
if(status != GATT_SUCCESS) {
|
||||
if (blufi_env.prepare_buf) {
|
||||
osi_free(blufi_env.prepare_buf);
|
||||
blufi_env.prepare_buf = NULL;
|
||||
}
|
||||
BLUFI_TRACE_ERROR("write data error , error code 0x%x\n", status);
|
||||
return;
|
||||
}
|
||||
memcpy(blufi_env.prepare_buf + p_data->req_data.p_data->write_req.offset,
|
||||
p_data->req_data.p_data->write_req.value,
|
||||
p_data->req_data.p_data->write_req.len);
|
||||
@ -194,7 +202,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
GATT_SUCCESS, NULL);
|
||||
|
||||
if (p_data->req_data.p_data->exec_write == GATT_PREP_WRITE_EXEC) {
|
||||
if (blufi_env.prepare_buf && p_data->req_data.p_data->exec_write == GATT_PREP_WRITE_EXEC) {
|
||||
btc_blufi_recv_handler(blufi_env.prepare_buf, blufi_env.prepare_len);
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
APPL_TRACE_DEBUG("BTC MEDIA (A2DP-DATA) EVENT %u", ctrl);
|
||||
|
||||
if (btc_aa_ctrl_cb.a2dp_cmd_pending != ESP_A2D_MEDIA_CTRL_NONE) {
|
||||
APPL_TRACE_DEBUG("un-acked a2dp cmd: %u", btc_aa_ctrl_cb.a2dp_cmd_pending);
|
||||
APPL_TRACE_WARNING("un-acked a2dp cmd: %u", btc_aa_ctrl_cb.a2dp_cmd_pending);
|
||||
a2dp_cmd_acknowledge(ctrl, ESP_A2D_MEDIA_CTRL_ACK_BUSY);
|
||||
return;
|
||||
}
|
||||
@ -179,6 +179,11 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
/* local suspend */
|
||||
if (btc_av_stream_started_ready()) {
|
||||
btc_dispatch_sm_event(BTC_AV_SUSPEND_STREAM_REQ_EVT, NULL, 0);
|
||||
#if (BTC_AV_SINK_INCLUDED == TRUE)
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SRC && btc_av_get_service_id() == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
/* we are not in started state; just ack back ok. This can happen if we are
|
||||
remotely suspended; clear REMOTE SUSPEND Flag */
|
||||
|
@ -615,6 +615,7 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
|
||||
|
||||
int frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
|
||||
APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", frames_to_process);
|
||||
UNUSED(frames_to_process);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -827,6 +828,8 @@ static void btc_a2dp_sink_thread_cleanup(UNUSED_ATTR void *context)
|
||||
|
||||
fixed_queue_free(btc_aa_snk_cb.RxSbcQ, osi_free_func);
|
||||
|
||||
btc_aa_snk_cb.RxSbcQ = NULL;
|
||||
|
||||
future_ready(btc_a2dp_sink_future, NULL);
|
||||
}
|
||||
|
||||
|
@ -495,10 +495,11 @@ static UINT64 time_now_us()
|
||||
static void log_tstamps_us(char *comment)
|
||||
{
|
||||
static UINT64 prev_us = 0;
|
||||
const UINT64 now_us = time_now_us();
|
||||
UINT64 now_us = time_now_us();
|
||||
APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, now_us - prev_us,
|
||||
fixed_queue_length(btc_aa_src_cb.TxAaQ));
|
||||
prev_us = now_us;
|
||||
UNUSED(prev_us);
|
||||
}
|
||||
|
||||
/* when true media task discards any tx frames */
|
||||
@ -1155,10 +1156,16 @@ static UINT8 btc_get_num_aa_frame(void)
|
||||
|
||||
/* calculate nbr of frames pending for this media tick */
|
||||
result = btc_aa_src_cb.media_feeding_state.pcm.counter / pcm_bytes_per_frame;
|
||||
if (result > MAX_PCM_FRAME_NUM_PER_TICK) {
|
||||
APPL_TRACE_WARNING("%s() - Limiting frames to be sent from %d to %d"
|
||||
, __FUNCTION__, result, MAX_PCM_FRAME_NUM_PER_TICK);
|
||||
result = MAX_PCM_FRAME_NUM_PER_TICK;
|
||||
|
||||
/* limit the frames to be sent */
|
||||
UINT32 frm_nb_threshold = MAX_OUTPUT_A2DP_SRC_FRAME_QUEUE_SZ - fixed_queue_length(btc_aa_src_cb.TxAaQ);
|
||||
if (frm_nb_threshold > MAX_PCM_FRAME_NUM_PER_TICK) {
|
||||
frm_nb_threshold = MAX_PCM_FRAME_NUM_PER_TICK;
|
||||
}
|
||||
|
||||
if (result > frm_nb_threshold) {
|
||||
APPL_TRACE_EVENT("Limit frms to send from %d to %d", result, frm_nb_threshold);
|
||||
result = frm_nb_threshold;
|
||||
}
|
||||
btc_aa_src_cb.media_feeding_state.pcm.counter -= result * pcm_bytes_per_frame;
|
||||
|
||||
@ -1657,6 +1664,8 @@ static void btc_a2dp_source_thread_cleanup(UNUSED_ATTR void *context)
|
||||
|
||||
fixed_queue_free(btc_aa_src_cb.TxAaQ, osi_free_func);
|
||||
|
||||
btc_aa_src_cb.TxAaQ = NULL;
|
||||
|
||||
future_ready(btc_a2dp_source_future, NULL);
|
||||
}
|
||||
|
||||
|
@ -1199,10 +1199,13 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
BTC_TRACE_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status);
|
||||
}
|
||||
}
|
||||
UNUSED(que_len);
|
||||
}
|
||||
#else
|
||||
static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
{
|
||||
UNUSED(event);
|
||||
UNUSED(p_data);
|
||||
BTC_TRACE_WARNING("%s : event %u\n", __func__, event);
|
||||
}
|
||||
#endif
|
||||
|
@ -335,6 +335,8 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__);
|
||||
}
|
||||
|
||||
UNUSED(status);
|
||||
#else
|
||||
BTC_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
@ -604,6 +604,9 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
|
||||
case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
|
||||
BTC_TRACE_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n");
|
||||
break;
|
||||
case BTA_DM_INQ_DISCARD_NUM_EVT:
|
||||
param.scan_rst.num_dis = p_data->inq_dis.num_dis;
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event);
|
||||
return;
|
||||
@ -1186,6 +1189,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
bta_dm_co_ble_set_max_key_size(key_size);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_MIN_KEY_SIZE: {
|
||||
uint8_t key_size = 0;
|
||||
STREAM_TO_UINT8(key_size, value);
|
||||
bta_dm_co_ble_set_min_key_size(key_size);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_SET_STATIC_PASSKEY: {
|
||||
uint32_t passkey = 0;
|
||||
for(uint8_t i = 0; i < arg->set_security_param.len; i++)
|
||||
|
@ -715,10 +715,13 @@ void btc_gatts_call_handler(btc_msg_t *msg)
|
||||
#else
|
||||
//BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
#endif
|
||||
/*
|
||||
not support background connection
|
||||
// Mark background connections
|
||||
if (!arg->open.is_direct) {
|
||||
BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
transport = BTA_GATT_TRANSPORT_LE;
|
||||
|
||||
|
@ -195,8 +195,9 @@ bt_status_t btc_hf_client_init(void)
|
||||
*******************************************************************************/
|
||||
static bt_status_t connect_int( bt_bdaddr_t *bd_addr, uint16_t uuid )
|
||||
{
|
||||
if (is_connected(bd_addr))
|
||||
if (is_connected(bd_addr)) {
|
||||
return BT_STATUS_BUSY;
|
||||
}
|
||||
|
||||
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING;
|
||||
bdcpy(btc_hf_client_cb.connected_bda.address, bd_addr->address);
|
||||
@ -713,14 +714,14 @@ static void process_ind_evt(tBTA_HF_CLIENT_IND *ind)
|
||||
{
|
||||
esp_hf_client_cb_param_t param;
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
|
||||
|
||||
switch (ind->type)
|
||||
{
|
||||
case BTA_HF_CLIENT_IND_CALL:
|
||||
param.call.status = ind->value;
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_EVT, ¶m);
|
||||
break;
|
||||
|
||||
|
||||
case BTA_HF_CLIENT_IND_CALLSETUP:
|
||||
param.call_setup.status = ind->value;
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_SETUP_EVT, ¶m);
|
||||
@ -787,6 +788,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
BTC_TRACE_WARNING("%s: HF CLient open failed, but another device connected. status=%d state=%d connected device=%s",
|
||||
__FUNCTION__, p_data->open.status, btc_hf_client_cb.state, bdaddr_to_string(&btc_hf_client_cb.connected_bda, bdstr, sizeof(bdstr)));
|
||||
UNUSED(bdstr);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -795,18 +797,20 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = btc_hf_client_cb.state;
|
||||
param.conn_stat.peer_feat = 0;
|
||||
param.conn_stat.chld_feat = 0;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
|
||||
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED)
|
||||
bdsetany(btc_hf_client_cb.connected_bda.address);
|
||||
|
||||
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS)
|
||||
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED) {
|
||||
bdsetany(btc_hf_client_cb.connected_bda.address);
|
||||
}
|
||||
|
||||
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS) {
|
||||
btc_queue_advance();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -820,13 +824,13 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = btc_hf_client_cb.state;
|
||||
param.conn_stat.peer_feat = btc_hf_client_cb.peer_feat;
|
||||
param.conn_stat.chld_feat = btc_hf_client_cb.chld_feat;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
|
||||
|
||||
/* Inform the application about in-band ringtone */
|
||||
if (btc_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND)
|
||||
{
|
||||
@ -839,7 +843,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
|
||||
btc_queue_advance();
|
||||
break;
|
||||
|
||||
|
||||
case BTA_HF_CLIENT_CLOSE_EVT:
|
||||
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
|
||||
do {
|
||||
@ -847,7 +851,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
|
||||
param.conn_stat.peer_feat = 0;
|
||||
param.conn_stat.chld_feat = 0;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
@ -980,7 +984,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED;
|
||||
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
sizeof(esp_bd_addr_t));
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
@ -989,7 +993,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC;
|
||||
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
sizeof(esp_bd_addr_t));
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
|
@ -315,6 +315,7 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
||||
{
|
||||
if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) {
|
||||
BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
spp_local_param.spp_mode = arg->init.mode;
|
||||
spp_local_param.spp_slot_id = 0;
|
||||
@ -323,6 +324,10 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
||||
|
||||
static void btc_spp_uninit(void)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
|
||||
|
@ -98,6 +98,10 @@
|
||||
#define CLASSIC_BT_INCLUDED FALSE
|
||||
#endif /* CLASSIC_BT_INCLUDED */
|
||||
|
||||
#ifndef CLASSIC_BT_GATT_INCLUDED
|
||||
#define CLASSIC_BT_GATT_INCLUDED FALSE
|
||||
#endif /* CLASSIC_BT_GATT_INCLUDED */
|
||||
|
||||
#ifndef CONFIG_GATTC_CACHE_NVS_FLASH
|
||||
#define CONFIG_GATTC_CACHE_NVS_FLASH FALSE
|
||||
#endif /* CONFIG_GATTC_CACHE_NVS_FLASH */
|
||||
@ -143,11 +147,35 @@
|
||||
#define SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL FALSE
|
||||
#else
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED */
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM 100
|
||||
#else
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM */
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
#define BLE_ADV_REPORT_DISCARD_THRSHOLD 20
|
||||
#else
|
||||
#define BLE_ADV_REPORT_DISCARD_THRSHOLD CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD */
|
||||
|
||||
#if (CONFIG_BT_ACL_CONNECTIONS)
|
||||
#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS
|
||||
#define GATT_MAX_PHY_CHANNEL CONFIG_BT_ACL_CONNECTIONS
|
||||
#endif /* CONFIG_BT_ACL_CONNECTIONS */
|
||||
|
||||
#if(CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT)
|
||||
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT
|
||||
#else
|
||||
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT 30
|
||||
#endif
|
||||
|
||||
//------------------Added from bdroid_buildcfg.h---------------------
|
||||
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
|
||||
#define L2CAP_EXTFEA_SUPPORTED_MASK (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
|
||||
|
@ -31,6 +31,7 @@ typedef struct {
|
||||
UINT8 ble_init_key;
|
||||
UINT8 ble_resp_key;
|
||||
UINT8 ble_max_key_size;
|
||||
UINT8 ble_min_key_size;
|
||||
UINT8 ble_accept_auth_enable;
|
||||
UINT8 oob_support;
|
||||
#endif
|
||||
@ -48,4 +49,4 @@ typedef struct {
|
||||
#endif
|
||||
} tBTE_BT_APPL_CFG;
|
||||
|
||||
extern tBTE_BT_APPL_CFG bte_bt_appl_cfg;
|
||||
extern tBTE_BT_APPL_CFG bte_bt_appl_cfg;
|
||||
|
@ -100,7 +100,11 @@ static void start_up(void)
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
// Enable adv flow control
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_adv_report_flow_control(HCI_HOST_FLOW_CTRL_ADV_REPORT_ON, (uint16_t)BLE_ADV_REPORT_FLOW_CONTROL_NUM, (uint16_t)BLE_ADV_REPORT_DISCARD_THRSHOLD));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif
|
||||
// Tell the controller about our buffer sizes and buffer counts next
|
||||
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
|
||||
response = AWAIT_COMMAND(
|
||||
|
@ -27,6 +27,7 @@
|
||||
#define CASE_RETURN_STR(const) case const: return #const;
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *interop_feature_string(const interop_feature_t feature)
|
||||
{
|
||||
switch (feature) {
|
||||
@ -36,7 +37,7 @@ static const char *interop_feature_string(const interop_feature_t feature)
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
#endif // (!CONFIG_BT_STACK_NO_LOG)
|
||||
// Interface functions
|
||||
bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr)
|
||||
{
|
||||
@ -47,7 +48,9 @@ bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr)
|
||||
for (size_t i = 0; i != db_size; ++i) {
|
||||
if (feature == interop_database[i].feature &&
|
||||
memcmp(addr, &interop_database[i].addr, interop_database[i].len) == 0) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bdstr[20] = {0};
|
||||
#endif
|
||||
LOG_WARN("%s() Device %s is a match for interop workaround %s", __func__,
|
||||
bdaddr_to_string(addr, bdstr, sizeof(bdstr)), interop_feature_string(feature));
|
||||
return true;
|
||||
|
@ -145,9 +145,10 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
|
||||
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
|
||||
if (*(ps16GenBufPtr) < s32BitSlice + 2) {
|
||||
*(ps16GenArrPtr) = 0;
|
||||
} else
|
||||
} else {
|
||||
*(ps16GenArrPtr) = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
|
||||
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
|
||||
}
|
||||
|
||||
ps16GenBufPtr++;
|
||||
ps16GenArrPtr++;
|
||||
|
@ -132,9 +132,10 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
|
||||
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
|
||||
if (*ps16GenBufPtr < s32BitSlice + 2) {
|
||||
*ps16GenArrPtr = 0;
|
||||
} else
|
||||
} else {
|
||||
*ps16GenArrPtr = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
|
||||
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
|
||||
}
|
||||
ps16GenBufPtr++;
|
||||
ps16GenArrPtr++;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ static const uint16_t outbound_event_types[] = {
|
||||
typedef struct {
|
||||
size_t buffer_size;
|
||||
fixed_queue_t *rx_q;
|
||||
uint16_t adv_free_num;
|
||||
} hci_hal_env_t;
|
||||
|
||||
|
||||
@ -81,6 +82,7 @@ static void hci_hal_env_init(
|
||||
assert(max_buffer_count > 0);
|
||||
|
||||
hci_hal_env.buffer_size = buffer_size;
|
||||
hci_hal_env.adv_free_num = 0;
|
||||
|
||||
hci_hal_env.rx_q = fixed_queue_new(max_buffer_count);
|
||||
if (hci_hal_env.rx_q) {
|
||||
@ -102,8 +104,11 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
|
||||
{
|
||||
assert(upper_callbacks != NULL);
|
||||
callbacks = upper_callbacks;
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, BLE_ADV_REPORT_FLOW_CONTROL_NUM + L2CAP_HOST_FC_ACL_BUFS + QUEUE_SIZE_MAX); // adv flow control num + ACL flow control num + hci cmd numeber
|
||||
#else
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
|
||||
#endif
|
||||
|
||||
xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
|
||||
xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
|
||||
@ -184,10 +189,10 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout)
|
||||
evt.par = 0;
|
||||
|
||||
if (xQueueSend(xHciH4Queue, &evt, timeout) != pdTRUE) {
|
||||
return TASK_POST_SUCCESS;
|
||||
return TASK_POST_FAIL;
|
||||
}
|
||||
|
||||
return TASK_POST_FAIL;
|
||||
return TASK_POST_SUCCESS;
|
||||
}
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
@ -223,12 +228,37 @@ static void hci_packet_complete(BT_HDR *packet){
|
||||
bool host_recv_adv_packet(BT_HDR *packet)
|
||||
{
|
||||
assert(packet);
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT) {
|
||||
return true;
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT) {
|
||||
if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| packet->data[3] == HCI_BLE_ADV_DISCARD_REPORT_EVT
|
||||
#endif
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
static void hci_update_adv_report_flow_control(BT_HDR *packet)
|
||||
{
|
||||
// this is adv packet
|
||||
if(host_recv_adv_packet(packet)) {
|
||||
// update adv free number
|
||||
hci_hal_env.adv_free_num ++;
|
||||
if (esp_vhci_host_check_send_available()){
|
||||
// send hci cmd
|
||||
btsnd_hcic_ble_update_adv_report_flow_control(hci_hal_env.adv_free_num);
|
||||
hci_hal_env.adv_free_num = 0;
|
||||
} else {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
{
|
||||
uint8_t type, hdr_size;
|
||||
@ -247,8 +277,10 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
packet->offset++;
|
||||
packet->len--;
|
||||
if (type == HCI_BLE_EVENT) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
uint8_t len = 0;
|
||||
STREAM_TO_UINT8(len, stream);
|
||||
#endif
|
||||
HCI_TRACE_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
packet->len, len);
|
||||
osi_free(packet);
|
||||
@ -282,6 +314,11 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
osi_free(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_update_adv_report_flow_control(packet);
|
||||
#endif
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
|
||||
HCI_TRACE_ERROR("BtuQueue is congested");
|
||||
@ -289,7 +326,6 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
|
||||
callbacks->packet_ready(packet);
|
||||
}
|
||||
|
@ -317,7 +317,11 @@ static void event_command_ready(fixed_queue_t *queue)
|
||||
|
||||
wait_entry = fixed_queue_dequeue(queue);
|
||||
|
||||
if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE){
|
||||
if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| wait_entry->opcode == HCI_VENDOR_BLE_ADV_REPORT_FLOW_CONTROL
|
||||
#endif
|
||||
){
|
||||
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
|
||||
osi_free(wait_entry->command);
|
||||
osi_free(wait_entry);
|
||||
|
@ -53,6 +53,18 @@ static BT_HDR *make_set_c2h_flow_control(uint8_t enable)
|
||||
return packet;
|
||||
}
|
||||
|
||||
static BT_HDR *make_set_adv_report_flow_control(uint8_t enable, uint16_t num, uint16_t lost_threshold)
|
||||
{
|
||||
uint8_t *stream;
|
||||
const uint8_t parameter_size = 1 + 2 + 2;
|
||||
BT_HDR *packet = make_command(HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL, parameter_size, &stream);
|
||||
|
||||
UINT8_TO_STREAM(stream, enable);
|
||||
UINT16_TO_STREAM(stream, num);
|
||||
UINT16_TO_STREAM(stream, lost_threshold);
|
||||
return packet;
|
||||
}
|
||||
|
||||
static BT_HDR *make_host_buffer_size(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count)
|
||||
{
|
||||
uint8_t *stream;
|
||||
@ -239,6 +251,7 @@ static const hci_packet_factory_t interface = {
|
||||
make_reset,
|
||||
make_read_buffer_size,
|
||||
make_set_c2h_flow_control,
|
||||
make_set_adv_report_flow_control,
|
||||
make_host_buffer_size,
|
||||
make_read_local_version_info,
|
||||
make_read_bd_addr,
|
||||
|
@ -26,6 +26,7 @@ typedef struct {
|
||||
BT_HDR *(*make_reset)(void);
|
||||
BT_HDR *(*make_read_buffer_size)(void);
|
||||
BT_HDR *(*make_set_c2h_flow_control)(uint8_t enable);
|
||||
BT_HDR *(*make_set_adv_report_flow_control)(uint8_t enable, uint16_t num, uint16_t lost_threshold);
|
||||
BT_HDR *(*make_host_buffer_size)(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count);
|
||||
BT_HDR *(*make_read_local_version_info)(void);
|
||||
BT_HDR *(*make_read_bd_addr)(void);
|
||||
|
@ -366,4 +366,9 @@ void BTE_DeinitStack(void)
|
||||
#if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
|
||||
A2D_Deinit();
|
||||
#endif
|
||||
|
||||
#if (defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE)
|
||||
RFCOMM_Deinit();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ typedef enum {
|
||||
#define BTC_A2DP_SOURCE_TASK_STACK_SIZE (CONFIG_A2DP_SOURCE_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) // by menuconfig
|
||||
#define BTC_A2DP_SOURCE_TASK_NAME "BtA2dSourceT"
|
||||
#define BTC_A2DP_SOURCE_TASK_PRIO (configMAX_PRIORITIES - 3)
|
||||
#define BTC_A2DP_SOURCE_DATA_QUEUE_LEN (3)
|
||||
#define BTC_A2DP_SOURCE_DATA_QUEUE_LEN (1)
|
||||
#define BTC_A2DP_SOURCE_CTRL_QUEUE_LEN (5)
|
||||
#define BTC_A2DP_SOURCE_TASK_QUEUE_SET_LEN (BTC_A2DP_SOURCE_DATA_QUEUE_LEN + BTC_A2DP_SOURCE_CTRL_QUEUE_LEN)
|
||||
|
||||
|
@ -61,8 +61,9 @@ bool list_contains(const list_t *list, const void *data)
|
||||
assert(data != NULL);
|
||||
|
||||
for (const list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) {
|
||||
if (list_node(node) == data)
|
||||
if (list_node(node) == data) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -201,8 +202,9 @@ list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *conte
|
||||
|
||||
for (list_node_t *node = list->head; node; ) {
|
||||
list_node_t *next = node->next;
|
||||
if (!callback(node->data, context))
|
||||
if (!callback(node->data, context)) {
|
||||
return node;
|
||||
}
|
||||
node = next;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -605,8 +605,9 @@ void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
|
||||
{
|
||||
UNUSED(p_lcb);
|
||||
|
||||
if (p_data == NULL)
|
||||
if (p_data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
osi_free(p_data->p_buf);
|
||||
p_data->p_buf = NULL;
|
||||
|
@ -345,8 +345,10 @@ UINT8 *avdt_scb_hdl_report(tAVDT_SCB *p_scb, UINT8 *p, UINT16 len)
|
||||
p += 2;
|
||||
BE_STREAM_TO_UINT32(ssrc, p);
|
||||
|
||||
UNUSED(ssrc);
|
||||
UNUSED(o_p);
|
||||
UNUSED(o_v);
|
||||
UNUSED(o_cc);
|
||||
|
||||
switch (pt) {
|
||||
case AVDT_RTCP_PT_SR: /* the packet type - SR (Sender Report) */
|
||||
@ -627,15 +629,19 @@ void avdt_scb_hdl_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
|
||||
avdt_scb_hdl_pkt_frag(p_scb, p_data);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if AVDT_REPORTING == TRUE
|
||||
if (p_data->p_pkt->layer_specific == AVDT_CHAN_REPORT) {
|
||||
p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
|
||||
avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len);
|
||||
osi_free(p_data->p_pkt);
|
||||
p_data->p_pkt = NULL;
|
||||
osi_free(p_data->p_pkt);
|
||||
p_data->p_pkt = NULL;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
avdt_scb_hdl_pkt_no_frag(p_scb, p_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1303,7 +1309,9 @@ void avdt_scb_hdl_write_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
if (fixed_queue_is_empty(p_scb->frag_q))
|
||||
#endif
|
||||
{
|
||||
avdt_scb_hdl_write_req_no_frag(p_scb, p_data);
|
||||
}
|
||||
#if AVDT_MULTIPLEXING == TRUE
|
||||
else {
|
||||
avdt_scb_hdl_write_req_frag(p_scb, p_data);
|
||||
|
@ -120,10 +120,11 @@ BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
if (!result) {
|
||||
AVRC_TRACE_ERROR(
|
||||
"avrc_is_valid_player_attrib_value() found not matching attrib(x%x)-value(x%x) pair!",
|
||||
attrib, value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -261,9 +261,10 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
|
||||
#if BLE_INCLUDED == TRUE
|
||||
p->transport = transport;
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if (transport == BT_TRANSPORT_LE)
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
btm_ble_refresh_local_resolvable_private_addr(bda,
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
|
||||
}
|
||||
#else
|
||||
p->conn_addr_type = BLE_ADDR_PUBLIC;
|
||||
memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
|
||||
@ -2495,15 +2496,17 @@ void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type)
|
||||
}
|
||||
|
||||
/* 2 and 3 MPS support? */
|
||||
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
|
||||
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) {
|
||||
/* Not supported. Add 'not_supported' mask for all 2MPS packet types */
|
||||
*p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
|
||||
}
|
||||
|
||||
if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]))
|
||||
if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) {
|
||||
/* Not supported. Add 'not_supported' mask for all 3MPS packet types */
|
||||
*p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
|
||||
}
|
||||
|
||||
/* EDR 3 and 5 slot support? */
|
||||
if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])
|
||||
|
@ -66,7 +66,7 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
|
||||
** bd_name - Name of the peer device. NULL if unknown.
|
||||
** dev_type - Remote device's device type.
|
||||
** addr_type - LE device address type.
|
||||
** auth_mode - auth mode
|
||||
** auth_mode - auth mode
|
||||
**
|
||||
** Returns TRUE if added OK, else FALSE
|
||||
**
|
||||
@ -887,8 +887,9 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
return BTM_SEC_OK;
|
||||
}
|
||||
|
||||
if (security_required & BTM_SEC_OUT_MITM)
|
||||
if (security_required & BTM_SEC_OUT_MITM) {
|
||||
auth_req |= BTM_LE_AUTH_REQ_MITM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -898,8 +899,9 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
return BTM_SEC_OK;
|
||||
}
|
||||
|
||||
if (security_required & BTM_SEC_IN_MITM)
|
||||
if (security_required & BTM_SEC_IN_MITM) {
|
||||
auth_req |= BTM_LE_AUTH_REQ_MITM;
|
||||
}
|
||||
}
|
||||
|
||||
tBTM_BLE_SEC_REQ_ACT ble_sec_act = BTM_BLE_SEC_REQ_ACT_NONE;
|
||||
@ -907,11 +909,13 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
|
||||
BTM_TRACE_DEBUG ("%s ble_sec_act %d", __func__ , ble_sec_act);
|
||||
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD)
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD) {
|
||||
return BTM_SEC_ENC_PENDING;
|
||||
}
|
||||
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_NONE)
|
||||
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_NONE) {
|
||||
return BTM_SEC_OK;
|
||||
}
|
||||
|
||||
UINT8 sec_flag = 0;
|
||||
BTM_GetSecurityFlagsByTransport(bdaddr, &sec_flag, BT_TRANSPORT_LE);
|
||||
@ -920,11 +924,13 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
BOOLEAN is_key_mitm = FALSE;
|
||||
if (sec_flag & (BTM_SEC_FLAG_ENCRYPTED| BTM_SEC_FLAG_LKEY_KNOWN))
|
||||
{
|
||||
if (sec_flag & BTM_SEC_FLAG_ENCRYPTED)
|
||||
if (sec_flag & BTM_SEC_FLAG_ENCRYPTED) {
|
||||
is_link_encrypted = TRUE;
|
||||
}
|
||||
|
||||
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED)
|
||||
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) {
|
||||
is_key_mitm = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_req & BTM_LE_AUTH_REQ_MITM)
|
||||
@ -933,16 +939,18 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
|
||||
{
|
||||
return BTM_SEC_ENCRYPT_MITM;
|
||||
} else {
|
||||
if (is_link_encrypted)
|
||||
if (is_link_encrypted) {
|
||||
return BTM_SEC_OK;
|
||||
else
|
||||
} else {
|
||||
return BTM_SEC_ENCRYPT;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (is_link_encrypted)
|
||||
if (is_link_encrypted) {
|
||||
return BTM_SEC_OK;
|
||||
else
|
||||
} else {
|
||||
return BTM_SEC_ENCRYPT_NO_MITM;
|
||||
}
|
||||
}
|
||||
|
||||
return BTM_SEC_OK;
|
||||
@ -1012,8 +1020,9 @@ BOOLEAN btm_ble_start_sec_check(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originat
|
||||
break;
|
||||
}
|
||||
|
||||
if (ble_sec_act == BTM_BLE_SEC_NONE)
|
||||
if (ble_sec_act == BTM_BLE_SEC_NONE) {
|
||||
return status;
|
||||
}
|
||||
|
||||
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
|
||||
p_lcb->sec_act = sec_act;
|
||||
@ -1922,9 +1931,7 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
UINT8 role, status, bda_type;
|
||||
UINT16 handle;
|
||||
BD_ADDR bda;
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
BD_ADDR local_rpa, peer_rpa;
|
||||
#endif ///BLE_PRIVACY_SPT == TRUE
|
||||
UINT16 conn_interval, conn_latency, conn_timeout;
|
||||
BOOLEAN match = FALSE;
|
||||
UNUSED(evt_len);
|
||||
@ -1935,14 +1942,13 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
STREAM_TO_BDADDR (bda, p);
|
||||
BTM_TRACE_DEBUG("status = %d, handle = %d, role = %d, bda_type = %d",status,handle,role,bda_type);
|
||||
if (status == 0) {
|
||||
#if (BLE_PRIVACY_SPT == TRUE )
|
||||
peer_addr_type = bda_type;
|
||||
match = btm_identity_addr_to_random_pseudo (bda, &bda_type, TRUE);
|
||||
|
||||
if (enhanced) {
|
||||
STREAM_TO_BDADDR (local_rpa, p);
|
||||
STREAM_TO_BDADDR (peer_rpa, p);
|
||||
}
|
||||
#if (BLE_PRIVACY_SPT == TRUE )
|
||||
peer_addr_type = bda_type;
|
||||
match = btm_identity_addr_to_random_pseudo (bda, &bda_type, TRUE);
|
||||
|
||||
/* possiblly receive connection complete with resolvable random on
|
||||
slave role while the device has been paired */
|
||||
@ -1997,9 +2003,18 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
|
||||
btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
btm_ble_update_mode_operation(role, bda, status);
|
||||
BOOLEAN bg_con = btm_ble_update_mode_operation(role, bda, status);
|
||||
if (status != HCI_SUCCESS && !bg_con) {
|
||||
// notify connection failed
|
||||
l2c_link_hci_disc_comp (handle, status);
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/* Notify security manager */
|
||||
btm_sec_disconnected (handle, status);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -312,9 +312,10 @@ void btm_ble_scan_pf_cmpl_cback(tBTM_VSC_CMPL *p_params)
|
||||
if (HCI_SUCCESS == status) {
|
||||
if (memcmp(&btm_ble_adv_filt_cb.cur_filter_target.bda, &na_bda, BD_ADDR_LEN) == 0) {
|
||||
btm_ble_cs_update_pf_counter(action, cond_type, NULL, num_avail);
|
||||
} else
|
||||
} else {
|
||||
btm_ble_cs_update_pf_counter(action, cond_type,
|
||||
&btm_ble_adv_filt_cb.cur_filter_target, num_avail);
|
||||
}
|
||||
}
|
||||
|
||||
/* send ADV PF operation complete */
|
||||
@ -855,9 +856,10 @@ tBTM_STATUS btm_ble_update_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
|
||||
len,
|
||||
param,
|
||||
btm_ble_scan_pf_cmpl_cback)) != BTM_NO_RESOURCES) {
|
||||
if (p_uuid_cond && p_uuid_cond->p_target_addr)
|
||||
if (p_uuid_cond && p_uuid_cond->p_target_addr) {
|
||||
memcpy(&btm_ble_adv_filt_cb.cur_filter_target, p_uuid_cond->p_target_addr,
|
||||
sizeof(tBLE_BD_ADDR));
|
||||
}
|
||||
else {
|
||||
memset(&btm_ble_adv_filt_cb.cur_filter_target, 0, sizeof(tBLE_BD_ADDR));
|
||||
}
|
||||
@ -914,15 +916,17 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
|
||||
/* clear manufactuer data filter */
|
||||
st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL,
|
||||
BTM_BLE_PF_MANU_DATA, cb_evt, ref_value);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_MANU_DATA, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
|
||||
/* clear local name filter */
|
||||
st = btm_ble_update_pf_local_name(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_LOCAL_NAME, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
|
||||
/* update the counter for service data */
|
||||
st = btm_ble_update_srvc_data_change(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL);
|
||||
@ -936,16 +940,18 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
|
||||
|
||||
st = btm_ble_update_uuid_filter(BTM_BLE_SCAN_COND_CLEAR, filt_index,
|
||||
BTM_BLE_PF_SRVC_SOL_UUID, NULL, cb_evt, ref_value);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SOL_UUID, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
|
||||
/* clear service data filter */
|
||||
st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL,
|
||||
BTM_BLE_PF_SRVC_DATA_PATTERN, cb_evt, ref_value);
|
||||
if (BTM_CMD_STARTED == st)
|
||||
if (BTM_CMD_STARTED == st) {
|
||||
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SRVC_DATA, cb_evt,
|
||||
ref_value, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* select feature based on control block settings */
|
||||
@ -1053,9 +1059,10 @@ tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, tBTM_BLE_PF_FILT_INDEX filt_i
|
||||
|
||||
if (cmn_ble_vsc_cb.version_supported == BTM_VSC_CHIP_CAPABILITY_L_VERSION) {
|
||||
len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN;
|
||||
} else
|
||||
} else {
|
||||
len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN +
|
||||
BTM_BLE_ADV_FILT_TRACK_NUM;
|
||||
}
|
||||
|
||||
if ((st = BTM_VendorSpecificCommand (HCI_BLE_ADV_FILTER_OCF,
|
||||
(UINT8)len,
|
||||
|
@ -427,9 +427,10 @@ void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
|
||||
if (0 == num_records) {
|
||||
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
|
||||
&p_data, &data_len);
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback)
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback) {
|
||||
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format, num_records,
|
||||
data_len, p_data, status);
|
||||
}
|
||||
} else {
|
||||
if ((len - 4) > 0) {
|
||||
btm_ble_batchscan_enq_rep_data(report_format, num_records, p, len - 4);
|
||||
@ -439,9 +440,10 @@ void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
|
||||
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
|
||||
&p_data, &data_len);
|
||||
/* Send whatever is available, in case of a command failure */
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data)
|
||||
if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data) {
|
||||
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format,
|
||||
num_records, data_len, p_data, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,9 +62,10 @@ void btm_ble_cont_energy_cmpl_cback (tBTM_VSC_CMPL *p_params)
|
||||
BTM_TRACE_DEBUG("energy_info status=%d,tx_t=%u, rx_t=%u, ener_used=%u, idle_t=%u",
|
||||
status, total_tx_time, total_rx_time, total_energy_used, total_idle_time);
|
||||
|
||||
if (NULL != ble_energy_info_cb.p_ener_cback)
|
||||
if (NULL != ble_energy_info_cb.p_ener_cback) {
|
||||
ble_energy_info_cb.p_ener_cback(total_tx_time, total_rx_time, total_idle_time,
|
||||
total_energy_used, status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ void btm_sem_init(void)
|
||||
osi_sem_new(&adv_data_sem, 1, 0);
|
||||
osi_sem_new(&adv_param_sem, 1, 0);
|
||||
osi_sem_new(&scan_enable_sem, 1, 0);
|
||||
osi_sem_new(&scan_param_sem, 1, 0);
|
||||
osi_sem_new(&scan_param_sem, 1, 0);
|
||||
}
|
||||
|
||||
void btm_sem_free(void)
|
||||
@ -334,9 +334,10 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy)
|
||||
/* if adv active, stop and restart */
|
||||
btm_ble_stop_adv ();
|
||||
|
||||
if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE)
|
||||
if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE) {
|
||||
p_cb->evt_type = btm_set_conn_mode_adv_init_addr(p_cb, p_addr_ptr, &init_addr_type,
|
||||
&p_cb->adv_addr_type);
|
||||
}
|
||||
|
||||
btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min :
|
||||
BTM_BLE_GAP_ADV_SLOW_INT),
|
||||
@ -493,7 +494,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb)
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb, tBTM_INQ_DIS_CB *p_discard_cb)
|
||||
{
|
||||
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
|
||||
tBTM_STATUS status = BTM_WRONG_MODE;
|
||||
@ -511,6 +512,7 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
|
||||
|
||||
btm_cb.ble_ctr_cb.p_scan_results_cb = p_results_cb;
|
||||
btm_cb.ble_ctr_cb.p_scan_cmpl_cb = p_cmpl_cb;
|
||||
btm_cb.ble_ctr_cb.p_obs_discard_cb = p_discard_cb;
|
||||
status = BTM_CMD_STARTED;
|
||||
|
||||
/* scan is not started */
|
||||
@ -755,6 +757,7 @@ extern void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK *p_vsc_c
|
||||
|
||||
void BTM_VendorHciEchoCmdCallback(tBTM_VSC_CMPL *p1)
|
||||
{
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
if (!p1) {
|
||||
return;
|
||||
}
|
||||
@ -762,6 +765,7 @@ void BTM_VendorHciEchoCmdCallback(tBTM_VSC_CMPL *p1)
|
||||
uint8_t status, echo;
|
||||
STREAM_TO_UINT8 (status, p);
|
||||
STREAM_TO_UINT8 (echo, p);
|
||||
#endif
|
||||
BTM_TRACE_DEBUG("%s status 0x%x echo 0x%x", __func__, status, echo);
|
||||
}
|
||||
|
||||
@ -780,7 +784,7 @@ void BTM_VendorHciEchoCmdTest(uint8_t echo)
|
||||
{
|
||||
BTM_VendorSpecificCommand (HCI_VENDOR_COMMON_ECHO_CMD_OPCODE,
|
||||
1,
|
||||
&echo,
|
||||
&echo,
|
||||
BTM_VendorHciEchoCmdCallback);
|
||||
}
|
||||
|
||||
@ -1296,7 +1300,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
}
|
||||
|
||||
if(own_bda_type == BLE_ADDR_RANDOM) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
|
||||
//close privacy
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
|
||||
@ -1305,9 +1309,9 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
#endif
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN);
|
||||
// set address to controller
|
||||
// set address to controller
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
|
||||
|
||||
|
||||
} else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
|
||||
@ -1317,7 +1321,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
} else if(own_bda_type == BLE_ADDR_PUBLIC_ID || own_bda_type == BLE_ADDR_RANDOM_ID) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
@ -1332,7 +1336,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
#endif
|
||||
if(own_bda_type == BLE_ADDR_PUBLIC_ID) {
|
||||
@ -1349,17 +1353,17 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
}
|
||||
|
||||
if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
|
||||
!BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
|
||||
BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n");
|
||||
BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n");
|
||||
if(adv_cb) {
|
||||
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
|
||||
}
|
||||
@ -1390,7 +1394,7 @@ tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8
|
||||
}
|
||||
|
||||
BTM_TRACE_EVENT ("update params for an active adv\n");
|
||||
|
||||
|
||||
tBTM_STATUS status = BTM_SUCCESS;
|
||||
/* update adv params */
|
||||
if (btsnd_hcic_ble_write_adv_params (adv_int_min,
|
||||
@ -1418,7 +1422,7 @@ tBTM_STATUS BTM_BleStartAdv(void)
|
||||
}
|
||||
|
||||
btm_ble_stop_adv();
|
||||
|
||||
|
||||
status = btm_ble_start_adv();
|
||||
|
||||
return status;
|
||||
@ -1537,35 +1541,35 @@ tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
BTM_BleConfigPrivacy(FALSE, NULL);
|
||||
}
|
||||
#endif
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN);
|
||||
// set address to controller
|
||||
// set address to controller
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
|
||||
|
||||
|
||||
} else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr);
|
||||
}else {
|
||||
BTM_TRACE_ERROR ("No random address yet, please set random address and try\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
} else if(addr_type_own == BLE_ADDR_PUBLIC_ID || addr_type_own == BLE_ADDR_RANDOM_ID) {
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
|
||||
addr_type_own = BLE_ADDR_RANDOM;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
|
||||
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr);
|
||||
} else {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if(btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
|
||||
BTM_TRACE_ERROR ("Error state\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
#endif
|
||||
if(addr_type_own == BLE_ADDR_PUBLIC_ID) {
|
||||
addr_type_own = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
} else {
|
||||
//own_bda_type == BLE_ADDR_RANDOM_ID
|
||||
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
|
||||
@ -1575,12 +1579,12 @@ tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
|
||||
} else {
|
||||
BTM_TRACE_ERROR ("No RPA and no random address yet, please set RPA or random address and try\n");
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
|
||||
}
|
||||
|
||||
/* If not supporting extended scan support, use the older range for checking */
|
||||
@ -1709,7 +1713,7 @@ tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_le
|
||||
** Returns status
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info,
|
||||
tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info,
|
||||
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb)
|
||||
{
|
||||
tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb;
|
||||
@ -1728,11 +1732,31 @@ tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type
|
||||
device_info_array[2] = (type >> 8) & 0xff;
|
||||
device_info_array[3] = (type >> 16) & 0xff;
|
||||
device_info_array[4] = (type >> 24) & 0xff;
|
||||
if(type == BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR) {
|
||||
bt_rcopy(&device_info_array[5], device_info, BD_ADDR_LEN);
|
||||
} else {
|
||||
memcpy(&device_info_array[5], device_info, 4);
|
||||
switch (type)
|
||||
{
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR:
|
||||
bt_rcopy(&device_info_array[5], device_info, BD_ADDR_LEN);
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID:
|
||||
memcpy(&device_info_array[5], device_info, 4);
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE:
|
||||
//do nothing
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV:
|
||||
//do nothing
|
||||
break;
|
||||
case BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV:
|
||||
//do nothing
|
||||
break;
|
||||
default:
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
if(status == BTM_ILLEGAL_VALUE) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = BTM_VendorSpecificCommand(HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST, 1 + 4 + BD_ADDR_LEN, device_info_array, NULL);
|
||||
if(status == BTM_CMD_STARTED) {
|
||||
status = BTM_SUCCESS;
|
||||
@ -1862,8 +1886,9 @@ tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len)
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr)
|
||||
{
|
||||
if (rand_addr == NULL)
|
||||
if (rand_addr == NULL) {
|
||||
return BTM_SET_STATIC_RAND_ADDR_FAIL;
|
||||
}
|
||||
|
||||
if (!(btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_SCAN || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_ADV || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_IDLE)) {
|
||||
BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state);
|
||||
@ -1930,7 +1955,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type)
|
||||
memset(addr, 0, BD_ADDR_LEN);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -2913,7 +2938,7 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
|
||||
memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX);
|
||||
p_cur->adv_data_len = 0;
|
||||
p_cur->scan_rsp_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Clear the adv cache if the addresses are not equal
|
||||
if(memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) != 0) {
|
||||
@ -3367,7 +3392,7 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
temp_addr_type = addr_type;
|
||||
memcpy(temp_bda, bda, BD_ADDR_LEN);
|
||||
|
||||
|
||||
/* map address to security record */
|
||||
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
|
||||
|
||||
@ -3490,13 +3515,13 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
0x02 Scannable undirected advertising (ADV_SCAN_IND)
|
||||
0x03 Non connectable undirected advertising (ADV_NONCONN_IND)
|
||||
0x04 Scan Response (SCAN_RSP)
|
||||
0x05-0xFF Reserved for future use
|
||||
0x05-0xFF Reserved for future use
|
||||
*/
|
||||
//if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer
|
||||
if(p_le_inq_cb->scan_duplicate_filter == BTM_BLE_SCAN_DUPLICATE_ENABLE) {
|
||||
/*
|
||||
Bluedroid will put the advertising packet and scan response into a packet and send it to the higher layer.
|
||||
If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising
|
||||
If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising
|
||||
packet will be discarded. So we added the following judgment:
|
||||
1. For different addresses, send the last advertising packet to higher layer
|
||||
2. For same address and same advertising type (not scan response), send the last advertising packet to higher layer
|
||||
@ -3602,6 +3627,17 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
|
||||
}
|
||||
}
|
||||
|
||||
void btm_ble_process_adv_discard_evt(UINT8 *p)
|
||||
{
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
uint32_t num_dis = 0;
|
||||
STREAM_TO_UINT32 (num_dis, p);
|
||||
tBTM_INQ_DIS_CB *p_obs_discard_cb = btm_cb.ble_ctr_cb.p_obs_discard_cb;
|
||||
if(p_obs_discard_cb) {
|
||||
(p_obs_discard_cb)(num_dis);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_ble_start_scan
|
||||
@ -3845,7 +3881,7 @@ tBTM_STATUS btm_ble_start_adv(void)
|
||||
btm_execute_wl_dev_operation();
|
||||
btm_cb.ble_ctr_cb.wl_state |= BTM_BLE_WL_ADV;
|
||||
}
|
||||
/* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core,
|
||||
/* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core,
|
||||
this causes the 'adv_mode' and 'state' not be set yet, so we set the state first */
|
||||
tBTM_BLE_GAP_STATE temp_state = p_cb->state;
|
||||
UINT8 adv_mode = p_cb->adv_mode;
|
||||
@ -4139,7 +4175,7 @@ BOOLEAN btm_ble_clear_topology_mask (tBTM_BLE_STATE_MASK request_state_mask)
|
||||
**
|
||||
** Description Get BLE topology bit mask
|
||||
**
|
||||
** Returns state mask.
|
||||
** Returns state mask.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_BLE_STATE_MASK btm_ble_get_topology_mask (void)
|
||||
@ -4193,8 +4229,9 @@ void btm_ble_update_link_topology_mask(UINT8 link_role, BOOLEAN increase)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 status)
|
||||
BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 status)
|
||||
{
|
||||
BOOLEAN bg_con = FALSE;
|
||||
if (status == HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT) {
|
||||
btm_cb.ble_ctr_cb.inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
|
||||
/* make device fall back into undirected adv mode by default */
|
||||
@ -4213,8 +4250,10 @@ void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 statu
|
||||
now in order */
|
||||
if (btm_ble_get_conn_st() == BLE_CONN_IDLE && status != HCI_ERR_HOST_REJECT_RESOURCES &&
|
||||
!btm_send_pending_direct_conn()) {
|
||||
btm_ble_resume_bg_conn();
|
||||
bg_con = btm_ble_resume_bg_conn();
|
||||
}
|
||||
|
||||
return bg_con;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -521,9 +521,10 @@ tBTM_STATUS btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
btm_ble_resolving_list_vsc_op_cmpl);
|
||||
}
|
||||
|
||||
if (st == BTM_CMD_STARTED)
|
||||
if (st == BTM_CMD_STARTED) {
|
||||
btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
|
||||
BTM_BLE_META_READ_IRK_ENTRY);
|
||||
}
|
||||
|
||||
return st;
|
||||
}
|
||||
@ -799,9 +800,10 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
}
|
||||
}
|
||||
|
||||
if (rt)
|
||||
if (rt) {
|
||||
btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
|
||||
BTM_BLE_META_ADD_IRK_ENTRY);
|
||||
}
|
||||
|
||||
/* if resolving list has been turned on, re-enable it */
|
||||
if (rl_mask) {
|
||||
|
@ -207,8 +207,9 @@ BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport)
|
||||
extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
|
||||
if (p_dev_rec == NULL)
|
||||
if (p_dev_rec == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_dev_rec->sec_flags = 0;
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
|
||||
|
@ -273,13 +273,15 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat
|
||||
btm_cb.btm_acl_pkt_types_supported = (BTM_ACL_PKT_TYPES_MASK_DH1 +
|
||||
BTM_ACL_PKT_TYPES_MASK_DM1);
|
||||
|
||||
if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features))
|
||||
if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_DM3);
|
||||
}
|
||||
|
||||
if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features))
|
||||
if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 +
|
||||
BTM_ACL_PKT_TYPES_MASK_DM5);
|
||||
}
|
||||
|
||||
/* Add in EDR related ACL types */
|
||||
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features)) {
|
||||
@ -297,13 +299,15 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat
|
||||
/* Check to see if 3 and 5 slot packets are available */
|
||||
if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) ||
|
||||
HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) {
|
||||
if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features))
|
||||
if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
|
||||
}
|
||||
|
||||
if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features))
|
||||
if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features)) {
|
||||
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 +
|
||||
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
|
||||
}
|
||||
}
|
||||
|
||||
BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x",
|
||||
|
@ -1042,9 +1042,10 @@ tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb
|
||||
return btm_ble_read_remote_name(remote_bda, p_cur, p_cb);
|
||||
} else
|
||||
#endif
|
||||
|
||||
{
|
||||
return (btm_initiate_rem_name (remote_bda, p_cur, BTM_RMT_NAME_EXT,
|
||||
BTM_EXT_RMT_NAME_TIMEOUT, p_cb));
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1080,11 +1081,13 @@ tBTM_STATUS BTM_CancelRemoteDeviceName (void)
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (btsnd_hcic_rmt_name_req_cancel (p_inq->remname_bda)) {
|
||||
return (BTM_CMD_STARTED);
|
||||
} else {
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return (BTM_WRONG_MODE);
|
||||
}
|
||||
|
@ -78,7 +78,9 @@ const UINT8 btm_pm_md_comp_matrix[BTM_PM_NUM_SET_MODES * BTM_PM_NUM_SET_MODES] =
|
||||
/* function prototype */
|
||||
static int btm_pm_find_acl_ind(BD_ADDR remote_bda);
|
||||
static tBTM_STATUS btm_pm_snd_md_req( UINT8 pm_id, int link_ind, tBTM_PM_PWR_MD *p_mode );
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *mode_to_string(tBTM_PM_MODE mode);
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef BTM_PM_DEBUG
|
||||
@ -950,6 +952,7 @@ tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *mode_to_string(tBTM_PM_MODE mode)
|
||||
{
|
||||
switch (mode) {
|
||||
@ -960,3 +963,4 @@ static const char *mode_to_string(tBTM_PM_MODE mode)
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -887,7 +887,9 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
|
||||
#ifdef APPL_AUTH_WRITE_EXCEPTION
|
||||
if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr))
|
||||
#endif
|
||||
{
|
||||
btsnd_hcic_write_auth_enable (TRUE);
|
||||
}
|
||||
|
||||
btm_cb.acl_disc_reason = 0xff ;
|
||||
|
||||
@ -907,9 +909,10 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED;
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_AUTH_FAILURE);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -949,7 +952,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec;
|
||||
tBTM_STATUS status;
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT8 *p_features;
|
||||
#endif
|
||||
UINT8 ii;
|
||||
tACL_CONN *p = btm_bda_to_acl(bd_addr, transport);
|
||||
BTM_TRACE_API ("btm_sec_bond_by_transport BDA: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
@ -1042,7 +1047,9 @@ tBTM_STATUS btm_sec_bond_by_transport (BD_ADDR bd_addr, tBT_TRANSPORT transport,
|
||||
}
|
||||
|
||||
for (ii = 0; ii <= HCI_EXT_FEATURES_PAGE_MAX; ii++) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
p_features = p_dev_rec->features[ii];
|
||||
#endif
|
||||
BTM_TRACE_EVENT(" remote_features page[%1d] = %02x-%02x-%02x-%02x\n",
|
||||
ii, p_features[0], p_features[1], p_features[2], p_features[3]);
|
||||
BTM_TRACE_EVENT(" %02x-%02x-%02x-%02x\n",
|
||||
@ -1396,7 +1403,9 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
rc = btm_sec_execute_procedure (p_dev_rec);
|
||||
}
|
||||
|
||||
if (rc != BTM_CMD_STARTED && rc != BTM_BUSY) {
|
||||
if (p_callback) {
|
||||
@ -2163,9 +2172,10 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
|
||||
"rmt_support_for_sc : %d -> fail pairing\n", __FUNCTION__,
|
||||
local_supports_sc,
|
||||
p_dev_rec->remote_supports_secure_connections);
|
||||
if (p_callback)
|
||||
if (p_callback) {
|
||||
(*p_callback) (bd_addr, transport, (void *)p_ref_data,
|
||||
BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
return (BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
@ -2525,9 +2535,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
|
||||
"remote_support_for_sc %d: fail pairing\n", __FUNCTION__,
|
||||
local_supports_sc, p_dev_rec->remote_supports_secure_connections);
|
||||
|
||||
if (p_callback)
|
||||
if (p_callback) {
|
||||
(*p_callback) (bd_addr, transport, (void *)p_ref_data,
|
||||
BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
return (BTM_MODE4_LEVEL4_NOT_SUPPORTED);
|
||||
}
|
||||
@ -3013,9 +3024,10 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
|
||||
|
||||
/* Notify all clients waiting for name to be resolved */
|
||||
for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
|
||||
if (btm_cb.p_rmt_name_callback[i] && p_bd_addr)
|
||||
if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) {
|
||||
(*btm_cb.p_rmt_name_callback[i])(p_bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dev_class[0] = 0;
|
||||
@ -3100,9 +3112,10 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
|
||||
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -3128,10 +3141,11 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
|
||||
/* that some authentication has been completed */
|
||||
/* This is required when different entities receive link notification and auth complete */
|
||||
if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) {
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -3907,10 +3921,11 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
||||
/* User probably Disabled the keyboard while it was asleap. Let her try */
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
/* report the suthentication status */
|
||||
if (old_state != BTM_PAIR_STATE_IDLE)
|
||||
if (old_state != BTM_PAIR_STATE_IDLE) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, status);
|
||||
}
|
||||
}
|
||||
|
||||
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
|
||||
@ -4181,9 +4196,10 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
|
||||
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
@ -4408,10 +4424,11 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
|
||||
res = FALSE;
|
||||
}
|
||||
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_SUCCESS);
|
||||
}
|
||||
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
|
||||
|
||||
@ -4717,9 +4734,10 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
||||
if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)
|
||||
/* for derived key, always send authentication callback for BR channel */
|
||||
|| ltk_derived_lk) {
|
||||
if (btm_cb.api.p_auth_complete_callback)
|
||||
if (btm_cb.api.p_auth_complete_callback) {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
/* We will save link key only if the user authorized it - BTE report link key in all cases */
|
||||
@ -4829,10 +4847,11 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda,
|
||||
NULL,
|
||||
name, HCI_ERR_CONNECTION_TOUT);
|
||||
} else
|
||||
} else {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4888,10 +4907,11 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda,
|
||||
NULL,
|
||||
name, HCI_ERR_CONNECTION_TOUT);
|
||||
} else
|
||||
} else {
|
||||
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
|
||||
p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -5520,10 +5540,11 @@ static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle)
|
||||
*******************************************************************************/
|
||||
static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
{
|
||||
if (btm_cb.api.p_link_key_callback)
|
||||
if (btm_cb.api.p_link_key_callback) {
|
||||
(*btm_cb.api.p_link_key_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
|
||||
p_dev_rec->sec_bd_name, p_dev_rec->link_key,
|
||||
p_dev_rec->link_key_type);
|
||||
}
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
|
||||
@ -5703,7 +5724,9 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA
|
||||
(*p_callback) (p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE, p_dev_rec->p_ref_data, res);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res);
|
||||
}
|
||||
}
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btm_sec_check_pending_reqs();
|
||||
@ -5761,7 +5784,9 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
#ifdef APPL_AUTH_WRITE_EXCEPTION
|
||||
if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr))
|
||||
#endif
|
||||
{
|
||||
btsnd_hcic_write_auth_enable (TRUE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN);
|
||||
@ -5913,8 +5938,9 @@ static BOOLEAN btm_sec_is_serv_level0(UINT16 psm)
|
||||
static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport,
|
||||
UINT8 encr_enable)
|
||||
{
|
||||
if (fixed_queue_is_empty(btm_cb.sec_pending_q))
|
||||
if (fixed_queue_is_empty(btm_cb.sec_pending_q)) {
|
||||
return;
|
||||
}
|
||||
|
||||
UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING;
|
||||
list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q);
|
||||
|
@ -279,8 +279,11 @@ typedef UINT16 tBTM_BLE_STATE_MASK;
|
||||
#define BTM_LE_RESOLVING_LIST_MAX 0x20
|
||||
#endif
|
||||
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR 0
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID 1
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_ADV_ADDR 0
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_LINK_ID 1
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_BEACON_TYPE 2
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROV_SRV_ADV 3
|
||||
#define BTM_DUPLICATE_SCAN_EXCEPTIONAL_INFO_MESH_PROXY_SRV_ADV 4
|
||||
|
||||
typedef struct {
|
||||
BD_ADDR *resolve_q_random_pseudo;
|
||||
@ -319,6 +322,7 @@ typedef struct {
|
||||
/* observer callback and timer */
|
||||
tBTM_INQ_RESULTS_CB *p_obs_results_cb;
|
||||
tBTM_CMPL_CB *p_obs_cmpl_cb;
|
||||
tBTM_INQ_DIS_CB *p_obs_discard_cb;
|
||||
TIMER_LIST_ENT obs_timer_ent;
|
||||
|
||||
/* scan callback and timer */
|
||||
@ -368,6 +372,7 @@ extern "C" {
|
||||
|
||||
void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
|
||||
void btm_ble_process_adv_pkt (UINT8 *p);
|
||||
void btm_ble_process_adv_discard_evt(UINT8 *p);
|
||||
void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
|
||||
tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
|
||||
BOOLEAN btm_ble_cancel_remote_name(BD_ADDR remote_bda);
|
||||
@ -443,7 +448,7 @@ BOOLEAN btm_ble_start_auto_conn(BOOLEAN start);
|
||||
BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cback);
|
||||
BOOLEAN btm_ble_renew_bg_conn_params(BOOLEAN add, BD_ADDR bd_addr);
|
||||
void btm_write_dir_conn_wl(BD_ADDR target_addr);
|
||||
void btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
|
||||
BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bda, UINT8 status);
|
||||
BOOLEAN btm_execute_wl_dev_operation(void);
|
||||
void btm_ble_update_link_topology_mask(UINT8 role, BOOLEAN increase);
|
||||
|
||||
|
@ -122,6 +122,7 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len);
|
||||
#if BLE_INCLUDED == TRUE
|
||||
static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len);
|
||||
static void btu_ble_process_adv_pkt (UINT8 *p);
|
||||
static void btu_ble_process_adv_dis(UINT8 *p);
|
||||
static void btu_ble_read_remote_feat_evt (UINT8 *p);
|
||||
static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len);
|
||||
static void btu_ble_ll_get_conn_param_format_err_from_contoller (UINT8 status, UINT16 handle);
|
||||
@ -342,6 +343,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
case HCI_BLE_ADV_PKT_RPT_EVT: /* result of inquiry */
|
||||
btu_ble_process_adv_pkt(p);
|
||||
break;
|
||||
case HCI_BLE_ADV_DISCARD_REPORT_EVT:
|
||||
btu_ble_process_adv_dis(p);
|
||||
break;
|
||||
case HCI_BLE_CONN_COMPLETE_EVT:
|
||||
btu_ble_ll_conn_complete_evt(p, hci_evt_len);
|
||||
break;
|
||||
@ -1809,6 +1813,11 @@ static void btu_ble_process_adv_pkt (UINT8 *p)
|
||||
btm_ble_process_adv_pkt(p);
|
||||
}
|
||||
|
||||
static void btu_ble_process_adv_dis(UINT8 *p)
|
||||
{
|
||||
btm_ble_process_adv_discard_evt(p);
|
||||
}
|
||||
|
||||
static void btu_ble_ll_conn_complete_evt ( UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
btm_ble_conn_complete(p, evt_len, FALSE);
|
||||
|
@ -437,6 +437,9 @@ void gap_attr_db_init(void)
|
||||
memset (&app_uuid.uu.uuid128, 0x81, LEN_UUID_128);
|
||||
|
||||
status = GATTS_StartService(gap_cb.gatt_if, service_handle, GAP_TRANSPORT_SUPPORTED );
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
|
||||
GAP_TRACE_EVENT ("GAP App gatt_if: %d s_hdl = %d start_status=%d",
|
||||
gap_cb.gatt_if, service_handle, status);
|
||||
|
@ -292,7 +292,7 @@ UINT16 GATTS_AddIncludeService (UINT16 service_handle, UINT16 include_svc_handle
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
|
||||
tGATT_PERM perm, tGATT_CHAR_PROP property,
|
||||
tGATT_PERM perm, tGATT_CHAR_PROP property,
|
||||
tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control)
|
||||
{
|
||||
tGATT_HDL_LIST_ELEM *p_decl;
|
||||
@ -311,7 +311,7 @@ UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
|
||||
return gatts_add_characteristic(&p_decl->svc_db,
|
||||
perm,
|
||||
property,
|
||||
p_char_uuid,
|
||||
p_char_uuid,
|
||||
attr_val, control);
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -443,9 +443,9 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
|
||||
tGATT_SR_REG *p_sreg;
|
||||
tGATT_HDL_LIST_ELEM *p_list = NULL;
|
||||
UINT8 i_sreg;
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
#if (SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
tBT_UUID *p_uuid;
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#endif ///SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
tGATT_REG *p_reg = gatt_get_regcb(gatt_if);
|
||||
|
||||
tGATTS_PENDING_NEW_SRV_START *p_buf;
|
||||
@ -484,10 +484,10 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
|
||||
case GATT_TRANSPORT_BR_EDR:
|
||||
case GATT_TRANSPORT_LE_BR_EDR:
|
||||
if (p_sreg->type == GATT_UUID_PRI_SERVICE) {
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
#if (SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
p_uuid = gatts_get_service_uuid (p_sreg->p_db);
|
||||
p_sreg->sdp_handle = gatt_add_sdp_record(p_uuid, p_sreg->s_hdl, p_sreg->e_hdl);
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#endif ///SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -539,11 +539,11 @@ void GATTS_StopService (UINT16 service_handle)
|
||||
|
||||
/* Index 0 is reserved for GATT, and is never stopped */
|
||||
if ( (ii > 0) && (ii < GATT_MAX_SR_PROFILES) && (gatt_cb.sr_reg[ii].in_use) ) {
|
||||
#if(SDP_INCLUDED == TRUE)
|
||||
#if(SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
if (gatt_cb.sr_reg[ii].sdp_handle) {
|
||||
SDP_DeleteRecord(gatt_cb.sr_reg[ii].sdp_handle);
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#endif ///SDP_INCLUDED == TRUE && CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
gatt_remove_a_srv_from_list(&gatt_cb.srv_list_info, &gatt_cb.srv_list[ii]);
|
||||
gatt_cb.srv_list[ii].in_use = FALSE;
|
||||
memset (&gatt_cb.sr_reg[ii], 0, sizeof(tGATT_SR_REG));
|
||||
@ -734,7 +734,7 @@ tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *v
|
||||
return GATT_INVALID_ATTR_LEN;
|
||||
}
|
||||
if ((p_decl = gatt_find_hdl_buffer_by_attr_handle(attr_handle)) == NULL) {
|
||||
GATT_TRACE_DEBUG("Service not created\n");
|
||||
GATT_TRACE_DEBUG("Service not created\n");
|
||||
return GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
@ -1161,14 +1161,19 @@ void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout, tBT_TRANSPORT trans
|
||||
if (p_tcb->att_lcid == L2CAP_ATT_CID) {
|
||||
status = L2CA_SetFixedChannelTout (bd_addr, L2CAP_ATT_CID, idle_tout);
|
||||
|
||||
if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP)
|
||||
if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP) {
|
||||
L2CA_SetIdleTimeoutByBdAddr(p_tcb->peer_bda,
|
||||
GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP, BT_TRANSPORT_LE);
|
||||
}
|
||||
} else {
|
||||
status = L2CA_SetIdleTimeout (p_tcb->att_lcid, idle_tout, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
|
||||
GATT_TRACE_API ("GATT_SetIdleTimeout idle_tout=%d status=%d(1-OK 0-not performed)",
|
||||
idle_tout, status);
|
||||
}
|
||||
@ -1507,7 +1512,7 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
|
||||
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
|
||||
|
||||
if (!srv_chg_ind_pending) {
|
||||
status = gatt_send_srv_chg_ind(addr);
|
||||
status = gatt_send_srv_chg_ind(addr);
|
||||
} else {
|
||||
status = GATT_BUSY;
|
||||
GATT_TRACE_DEBUG("discard srv chg - already has one in the queue");
|
||||
|
@ -374,6 +374,10 @@ void gatt_profile_db_init (void)
|
||||
*/
|
||||
status = GATTS_StartService (gatt_cb.gatt_if, service_handle, GATTP_TRANSPORT_SUPPORTED );
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
|
||||
GATT_TRACE_DEBUG ("gatt_profile_db_init: gatt_if=%d start status%d\n",
|
||||
gatt_cb.gatt_if, status);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ static void gatt_le_connect_cback (UINT16 chan, BD_ADDR bd_addr, BOOLEAN connect
|
||||
UINT16 reason, tBT_TRANSPORT transport);
|
||||
static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf);
|
||||
static void gatt_le_cong_cback(BD_ADDR remote_bda, BOOLEAN congest);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 l2cap_cid,
|
||||
UINT16 psm, UINT8 l2cap_id);
|
||||
static void gatt_l2cif_connect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
|
||||
@ -56,9 +56,9 @@ static void gatt_l2cif_config_cfm_cback (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cf
|
||||
static void gatt_l2cif_disconnect_ind_cback (UINT16 l2cap_cid, BOOLEAN ack_needed);
|
||||
static void gatt_l2cif_disconnect_cfm_cback (UINT16 l2cap_cid, UINT16 result);
|
||||
static void gatt_l2cif_data_ind_cback (UINT16 l2cap_cid, BT_HDR *p_msg);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
static void gatt_send_conn_cback (tGATT_TCB *p_tcb);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
static void gatt_l2cif_congest_cback (UINT16 cid, BOOLEAN congested);
|
||||
static const tL2CAP_APPL_INFO dyn_info = {
|
||||
gatt_l2cif_connect_ind_cback,
|
||||
@ -73,7 +73,7 @@ static const tL2CAP_APPL_INFO dyn_info = {
|
||||
gatt_l2cif_congest_cback,
|
||||
NULL
|
||||
} ;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
|
||||
#if GATT_DYNAMIC_MEMORY == FALSE
|
||||
tGATT_CB gatt_cb;
|
||||
@ -125,12 +125,13 @@ void gatt_init (void)
|
||||
fixed_reg.default_idle_tout = 0xffff; /* 0xffff default idle timeout */
|
||||
|
||||
L2CA_RegisterFixedChannel (L2CAP_ATT_CID, &fixed_reg);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
/* Now, register with L2CAP for ATT PSM over BR/EDR */
|
||||
if (!L2CA_Register (BT_PSM_ATT, (tL2CAP_APPL_INFO *) &dyn_info)) {
|
||||
GATT_TRACE_ERROR ("ATT Dynamic Registration failed");
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
BTM_SetSecurityLevel(TRUE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
|
||||
BTM_SetSecurityLevel(FALSE, "", BTM_SEC_SERVICE_ATT, BTM_SEC_NONE, BT_PSM_ATT, 0, 0);
|
||||
|
||||
@ -221,12 +222,12 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
p_tcb->att_lcid = L2CAP_ATT_CID;
|
||||
gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
} else {
|
||||
if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) {
|
||||
gatt_ret = TRUE;
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
|
||||
}
|
||||
|
||||
@ -262,10 +263,10 @@ BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb)
|
||||
gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
|
||||
ret = L2CA_CancelBleConnectReq (p_tcb->peer_bda);
|
||||
}
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
} else {
|
||||
ret = L2CA_DisconnectReq(p_tcb->att_lcid);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
}
|
||||
} else {
|
||||
GATT_TRACE_DEBUG ("gatt_disconnect already in closing state");
|
||||
@ -581,7 +582,7 @@ static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_GATT_INCLUDED == TRUE)
|
||||
static void gatt_l2cif_connect_ind_cback (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
|
||||
{
|
||||
/* do we already have a control channel for this peer? */
|
||||
@ -887,7 +888,7 @@ static void gatt_l2cif_congest_cback (UINT16 lcid, BOOLEAN congested)
|
||||
}
|
||||
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#endif ///CLASSIC_BT_GATT_INCLUDED == TRUE
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user