forked from espressif/esp-idf
Compare commits
455 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6313ea0088 | ||
|
|
735f02c4b7 | ||
|
|
d6df10edaf | ||
|
|
d02d2d5170 | ||
|
|
80c013ee5a | ||
|
|
f2347e5729 | ||
|
|
8cfb0b207a | ||
|
|
6d253b4394 | ||
|
|
50dc31103f | ||
|
|
3af5384a24 | ||
|
|
283c47cbba | ||
|
|
4ae01aed27 | ||
|
|
a5a692ef8c | ||
|
|
3c532e4532 | ||
|
|
2e8d7fa36d | ||
|
|
674cf7520e | ||
|
|
c990ca4e20 | ||
|
|
5b061a0530 | ||
|
|
43d2f940b2 | ||
|
|
a5533a0b5d | ||
|
|
5f56d65405 | ||
|
|
fcf9c3d882 | ||
|
|
a7ad8bc873 | ||
|
|
438c9bcb35 | ||
|
|
328e689cf1 | ||
|
|
13732c5753 | ||
|
|
2544d737c5 | ||
|
|
8bd10b4808 | ||
|
|
a975ba6cef | ||
|
|
9189e1006d | ||
|
|
bc8a84e9e4 | ||
|
|
efe499113c | ||
|
|
7331ee2af2 | ||
|
|
f323fe5fee | ||
|
|
291c4a4fd3 | ||
|
|
9b1bd0a09f | ||
|
|
0ba566e0c6 | ||
|
|
405b1986c2 | ||
|
|
7d2baa3c3d | ||
|
|
530dedbc2d | ||
|
|
7c42b55e45 | ||
|
|
f4022111c8 | ||
|
|
53dcd1202d | ||
|
|
ef2c0e8b3e | ||
|
|
7515dc97b6 | ||
|
|
a9c1820385 | ||
|
|
8fdf200932 | ||
|
|
4cde212817 | ||
|
|
6751373411 | ||
|
|
27fd353752 | ||
|
|
97603b1d59 | ||
|
|
32fd3a3215 | ||
|
|
d1c6eb9574 | ||
|
|
5ee2d3b90d | ||
|
|
8618b452f7 | ||
|
|
39fb5d7150 | ||
|
|
5dafcf9363 | ||
|
|
3f72a12d97 | ||
|
|
af4f2ace84 | ||
|
|
e8ad0415cc | ||
|
|
ac253274a0 | ||
|
|
972107fbc9 | ||
|
|
5e9267f846 | ||
|
|
cfed7c84ce | ||
|
|
3870836a90 | ||
|
|
19f319a55d | ||
|
|
0806617971 | ||
|
|
4f346169ff | ||
|
|
00b895680e | ||
|
|
997d291d85 | ||
|
|
5f2660e1f5 | ||
|
|
451e4cf3b0 | ||
|
|
132b439359 | ||
|
|
04ce9050b6 | ||
|
|
27f8ee6b97 | ||
|
|
1c001ecd7a | ||
|
|
a961984f73 | ||
|
|
2d53799372 | ||
|
|
7275490322 | ||
|
|
f6a7cda7b6 | ||
|
|
d88b74064d | ||
|
|
b9f6b579f1 | ||
|
|
72ad5a142b | ||
|
|
d07f9dfbb2 | ||
|
|
33250ea678 | ||
|
|
300657162b | ||
|
|
7fcc76fa06 | ||
|
|
85fbaaf37a | ||
|
|
da97846483 | ||
|
|
7aa29a0dbb | ||
|
|
516d9f0eae | ||
|
|
bb5789b6ee | ||
|
|
f206bc51ff | ||
|
|
ecc82a3c27 | ||
|
|
6746be5a09 | ||
|
|
007d884a85 | ||
|
|
998416c54b | ||
|
|
873c515ee3 | ||
|
|
ee295c175b | ||
|
|
25ed0aa9bb | ||
|
|
4b4614ffb1 | ||
|
|
21adda8777 | ||
|
|
8ff0f4a616 | ||
|
|
08946da2db | ||
|
|
90b8a42349 | ||
|
|
3c92cd607b | ||
|
|
4f3008bfd8 | ||
|
|
dd1fa7c502 | ||
|
|
50556b8acb | ||
|
|
9da0541020 | ||
|
|
ab74be7abe | ||
|
|
b5c45a4d46 | ||
|
|
225e98dcee | ||
|
|
d66b227e07 | ||
|
|
ce67428c56 | ||
|
|
054e82b4b3 | ||
|
|
7d4a9db191 | ||
|
|
39f97bb4e8 | ||
|
|
8f81157432 | ||
|
|
5141570f24 | ||
|
|
f86d512672 | ||
|
|
ab341359f5 | ||
|
|
f98da26b38 | ||
|
|
d0cd624d2b | ||
|
|
c8c4bd099e | ||
|
|
36c14cf214 | ||
|
|
a7c9cf3a6b | ||
|
|
9aee394dc6 | ||
|
|
05eb9d155f | ||
|
|
0669fe8f02 | ||
|
|
cabb97f9a9 | ||
|
|
41b1db4dc6 | ||
|
|
8bc76b3684 | ||
|
|
245b753904 | ||
|
|
86a6c21e79 | ||
|
|
8cc0379da1 | ||
|
|
e56bfadc58 | ||
|
|
583e80708b | ||
|
|
5cf4d8a1ec | ||
|
|
ef3c6ac276 | ||
|
|
4129436f7e | ||
|
|
0808a04ee8 | ||
|
|
c99977b67c | ||
|
|
8d3d3fdd4a | ||
|
|
c4973908e4 | ||
|
|
3bb43d5f03 | ||
|
|
209d454b5f | ||
|
|
b385fe0586 | ||
|
|
487c4b6725 | ||
|
|
667846cba1 | ||
|
|
ccbb261c35 | ||
|
|
f35fd2a6b0 | ||
|
|
5682a5ef36 | ||
|
|
b66af09b75 | ||
|
|
9b5841f17c | ||
|
|
103de7acdc | ||
|
|
c2b39f4a5f | ||
|
|
2bd198d180 | ||
|
|
5b2fee13cd | ||
|
|
6ceedabb27 | ||
|
|
dac71d688a | ||
|
|
dc304fb3af | ||
|
|
6ae56b61cf | ||
|
|
6698be57c8 | ||
|
|
ef9dbff112 | ||
|
|
561f8ff513 | ||
|
|
945d2e697c | ||
|
|
94c4f32df0 | ||
|
|
ab62202eb9 | ||
|
|
063c23deff | ||
|
|
3868307efd | ||
|
|
e0c834285f | ||
|
|
e99b4e85b9 | ||
|
|
20ab122f80 | ||
|
|
98dd235819 | ||
|
|
94ec3c8e53 | ||
|
|
7535dbc454 | ||
|
|
aeb4d8e3c2 | ||
|
|
ba13d282dd | ||
|
|
806d23b17b | ||
|
|
e410f4268e | ||
|
|
8de29499ce | ||
|
|
ffab6084f0 | ||
|
|
f58c664e2b | ||
|
|
b42ba1b0a5 | ||
|
|
67ba85650d | ||
|
|
0a97cb62ef | ||
|
|
594e1b5e44 | ||
|
|
10a5cfc900 | ||
|
|
e4a840d8cf | ||
|
|
7a32ae363e | ||
|
|
fddc905fa3 | ||
|
|
574dd08085 | ||
|
|
7705126287 | ||
|
|
bf4184a049 | ||
|
|
212222a9e0 | ||
|
|
6d3f81aa77 | ||
|
|
489e98cfb7 | ||
|
|
8d0d7972f3 | ||
|
|
e6acfedd3c | ||
|
|
0f5cae0218 | ||
|
|
712bd1d773 | ||
|
|
4e36ede3bf | ||
|
|
2f2aa41ea7 | ||
|
|
089438139d | ||
|
|
e468a105d8 | ||
|
|
894ddea353 | ||
|
|
fed3c3ebf0 | ||
|
|
f8515688cb | ||
|
|
b9dab23437 | ||
|
|
5632385d5f | ||
|
|
cfcb22fe16 | ||
|
|
d6e3943233 | ||
|
|
b563219f93 | ||
|
|
d881fcd380 | ||
|
|
058a38a141 | ||
|
|
ffe6af44c1 | ||
|
|
1fca253a65 | ||
|
|
486ff50eac | ||
|
|
cf69dfa458 | ||
|
|
501640514a | ||
|
|
a80e687f8c | ||
|
|
bc90b89e2b | ||
|
|
a1cc202b70 | ||
|
|
062ba57d0f | ||
|
|
14baac302f | ||
|
|
af211fcf0c | ||
|
|
5ee7233b5b | ||
|
|
48c7afde27 | ||
|
|
d3bab0d7f0 | ||
|
|
c9ed467e26 | ||
|
|
f0eb023f17 | ||
|
|
8944b90a06 | ||
|
|
9e4ec90a1e | ||
|
|
e4357d9cf3 | ||
|
|
db17ffef00 | ||
|
|
7f2a9f0359 | ||
|
|
ecdeea9a85 | ||
|
|
cfce9e1c72 | ||
|
|
dfce994b54 | ||
|
|
1b78dc2deb | ||
|
|
37a4b0e933 | ||
|
|
8fab9ffb95 | ||
|
|
354137a313 | ||
|
|
0399c8ecaf | ||
|
|
a12e7fa638 | ||
|
|
3278f755d2 | ||
|
|
30281166b1 | ||
|
|
9bd227f8c5 | ||
|
|
80423d638d | ||
|
|
998e18ed69 | ||
|
|
d0e553358a | ||
|
|
0cdb8b4888 | ||
|
|
c1e4ebf2bc | ||
|
|
71ca4c50b0 | ||
|
|
56d82dd5ce | ||
|
|
c4a6eef841 | ||
|
|
05b5671fc4 | ||
|
|
d3646ca59f | ||
|
|
0cb7b27f8b | ||
|
|
2319e8a0eb | ||
|
|
bc12970dde | ||
|
|
7a863cca7c | ||
|
|
9c42b6194e | ||
|
|
3511109b6e | ||
|
|
acff7e58d2 | ||
|
|
0f45323879 | ||
|
|
48ea4bc7f4 | ||
|
|
69686ae8a9 | ||
|
|
28cb5624ef | ||
|
|
c82adcae1b | ||
|
|
c574ad90df | ||
|
|
1d03398a64 | ||
|
|
daf1d05576 | ||
|
|
816a98c3ad | ||
|
|
ebfc47c34b | ||
|
|
681805b6c7 | ||
|
|
392b0b89e3 | ||
|
|
229be8c025 | ||
|
|
e4fb19000a | ||
|
|
0e640c61bd | ||
|
|
ce64bcb81f | ||
|
|
5e48c2bfef | ||
|
|
55c179a599 | ||
|
|
1181b65f7d | ||
|
|
3b116ae0cb | ||
|
|
54b595ed51 | ||
|
|
cf2600adef | ||
|
|
f7eecfcc67 | ||
|
|
eac9eb36d1 | ||
|
|
ec05f3af8f | ||
|
|
9bfb2f0cab | ||
|
|
963fa0fd3a | ||
|
|
8856cc055a | ||
|
|
fab14106c8 | ||
|
|
154294e79f | ||
|
|
e1d965e4b9 | ||
|
|
673d4679ce | ||
|
|
95f6f88aa7 | ||
|
|
621794abb5 | ||
|
|
f918cb185d | ||
|
|
ab22836859 | ||
|
|
9539d44158 | ||
|
|
b6b8af498c | ||
|
|
194b1324d2 | ||
|
|
7a030ff8d6 | ||
|
|
d9a0f9d443 | ||
|
|
3a6be05945 | ||
|
|
d1c536258c | ||
|
|
5a1247246c | ||
|
|
45758b6be0 | ||
|
|
6183de959a | ||
|
|
e9a4eb57b9 | ||
|
|
5894e15f6b | ||
|
|
891c1f4a2b | ||
|
|
f5c962d8b2 | ||
|
|
6aff7125cb | ||
|
|
c68fd9d545 | ||
|
|
d6c06ed0b5 | ||
|
|
8baa6b9d8b | ||
|
|
3923a2be85 | ||
|
|
e7dc749e2f | ||
|
|
df93f672e3 | ||
|
|
4a55009f3e | ||
|
|
dfcff0a5bf | ||
|
|
ff3566e40b | ||
|
|
63eb620d99 | ||
|
|
93c18bb2b4 | ||
|
|
3c6bce1d81 | ||
|
|
90b9c42dc0 | ||
|
|
c5f63bf701 | ||
|
|
ced95c7fb0 | ||
|
|
309fb23ffc | ||
|
|
e9a230c20c | ||
|
|
b0c7f28aed | ||
|
|
7bc1e7608c | ||
|
|
449ce1bad9 | ||
|
|
424a5e2705 | ||
|
|
d8f311c980 | ||
|
|
9b0c252e67 | ||
|
|
2a55629556 | ||
|
|
b523660199 | ||
|
|
150be549eb | ||
|
|
10898a33ed | ||
|
|
dddfc61411 | ||
|
|
404a6b3782 | ||
|
|
29f999361e | ||
|
|
32eeac0b12 | ||
|
|
7d3e8998d8 | ||
|
|
e276b98fe4 | ||
|
|
de7381b77e | ||
|
|
645d9b9590 | ||
|
|
2ad618e068 | ||
|
|
eb408e50c4 | ||
|
|
60da98ee0b | ||
|
|
314f6f371c | ||
|
|
6c69d5e6fd | ||
|
|
90ea0bb7e8 | ||
|
|
6ba817038c | ||
|
|
e54f8a96a0 | ||
|
|
2f9edfebac | ||
|
|
27c28eb1e6 | ||
|
|
6f339ff7a5 | ||
|
|
2cc07d0c4c | ||
|
|
da81b97e17 | ||
|
|
15e65aad1b | ||
|
|
281874d380 | ||
|
|
3f3d8746fc | ||
|
|
b278deabdb | ||
|
|
9065498a5a | ||
|
|
012f5c608d | ||
|
|
c695a4e468 | ||
|
|
755b163d4e | ||
|
|
b19b8702fd | ||
|
|
bd2ff0613d | ||
|
|
b6ebbb5662 | ||
|
|
38d58f1c2e | ||
|
|
ecc6080117 | ||
|
|
e589cad07e | ||
|
|
44764222a5 | ||
|
|
b6ee7f699c | ||
|
|
9b57d4aa0d | ||
|
|
60a642b31c | ||
|
|
48fda0f27b | ||
|
|
33ca8874d4 | ||
|
|
c884931b0b | ||
|
|
41baf59287 | ||
|
|
87f7d1875d | ||
|
|
545c7e5cdd | ||
|
|
ef6fe211b8 | ||
|
|
50637f638f | ||
|
|
c4b861ad65 | ||
|
|
492b926d50 | ||
|
|
b5f8cf0f03 | ||
|
|
c4bb528c61 | ||
|
|
a0bdee0c9c | ||
|
|
c015dd6c41 | ||
|
|
5afafb0050 | ||
|
|
ff008d2be3 | ||
|
|
84bfc96f08 | ||
|
|
0448ee9685 | ||
|
|
42e411dafc | ||
|
|
fbff8eb95b | ||
|
|
c778951547 | ||
|
|
a0776b2f21 | ||
|
|
ae30d1bc7b | ||
|
|
28e4162dd2 | ||
|
|
242f8ea743 | ||
|
|
5c1506f796 | ||
|
|
103559153f | ||
|
|
d340088993 | ||
|
|
e8fbd6e288 | ||
|
|
50b710d267 | ||
|
|
f4554c81fc | ||
|
|
96be8f2efa | ||
|
|
033124be14 | ||
|
|
b4c1bdb11b | ||
|
|
acc9b871d1 | ||
|
|
cb9be8c0c4 | ||
|
|
8388e1be54 | ||
|
|
5960e7419d | ||
|
|
21912b95f4 | ||
|
|
3085eb7ec6 | ||
|
|
8ed44ace4b | ||
|
|
58accf05cf | ||
|
|
6f90393f22 | ||
|
|
66fe94f816 | ||
|
|
df6adbd5bf | ||
|
|
ce3ccc18fa | ||
|
|
36d6e4e2c7 | ||
|
|
a4d45a0a4d | ||
|
|
38170d465c | ||
|
|
ccea4a0f8f | ||
|
|
954c0981d8 | ||
|
|
de79de1c26 | ||
|
|
194e1835c2 | ||
|
|
17ac80867b | ||
|
|
05605920ae | ||
|
|
121e5a7847 | ||
|
|
031ab556a9 | ||
|
|
4837f93968 | ||
|
|
717b1697df | ||
|
|
b5942dc400 | ||
|
|
72d4de442a | ||
|
|
485e254719 | ||
|
|
0ebae99ab0 | ||
|
|
7e488b0c6b | ||
|
|
3a4cf72f30 | ||
|
|
6e0f905761 | ||
|
|
489f5efbd1 | ||
|
|
3a70e61477 | ||
|
|
043ef32651 | ||
|
|
eae3b45170 | ||
|
|
a1c79bbc7b | ||
|
|
cc46b5054a |
21
.gitignore
vendored
21
.gitignore
vendored
@@ -18,23 +18,18 @@ GPATH
|
||||
# eclipse setting
|
||||
.settings
|
||||
|
||||
# MacOS directory files
|
||||
.DS_Store
|
||||
|
||||
# Example project files
|
||||
examples/**/sdkconfig
|
||||
examples/**/sdkconfig.old
|
||||
examples/**/build
|
||||
|
||||
# Doc build artifacts
|
||||
docs/*/_build/
|
||||
docs/*/doxygen-warning-log.txt
|
||||
docs/*/sphinx-warning-log.txt
|
||||
docs/*/sphinx-warning-log-sanitized.txt
|
||||
docs/*/xml/
|
||||
docs/*/xml_in/
|
||||
docs/*/man/
|
||||
docs/doxygen_sqlite3.db
|
||||
#Doc build artifacts
|
||||
docs/_build/
|
||||
docs/doxygen-warning-log.txt
|
||||
docs/sphinx-warning-log.txt
|
||||
docs/sphinx-warning-log-sanitized.txt
|
||||
docs/xml/
|
||||
docs/man/
|
||||
|
||||
# Unit test app files
|
||||
tools/unit-test-app/sdkconfig
|
||||
@@ -51,5 +46,3 @@ examples/protocols/aws_iot/*/main/certs/*.pem.*
|
||||
*.gcno
|
||||
coverage.info
|
||||
coverage_report/
|
||||
|
||||
test_multi_heap_host
|
||||
|
||||
756
.gitlab-ci.yml
756
.gitlab-ci.yml
File diff suppressed because it is too large
Load Diff
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -37,7 +37,3 @@
|
||||
[submodule "components/json/cJSON"]
|
||||
path = components/json/cJSON
|
||||
url = https://github.com/DaveGamble/cJSON.git
|
||||
|
||||
[submodule "components/mbedtls/mbedtls"]
|
||||
path = components/mbedtls/mbedtls
|
||||
url = https://github.com/espressif/mbedtls.git
|
||||
|
||||
115
Kconfig
115
Kconfig
@@ -35,7 +35,120 @@ endmenu # SDK tool configuration
|
||||
|
||||
source "$COMPONENT_KCONFIGS_PROJBUILD"
|
||||
|
||||
source "$IDF_PATH/Kconfig.compiler"
|
||||
menu "Compiler options"
|
||||
|
||||
choice OPTIMIZATION_COMPILER
|
||||
prompt "Optimization Level"
|
||||
default OPTIMIZATION_LEVEL_DEBUG
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
|
||||
config OPTIMIZATION_LEVEL_DEBUG
|
||||
bool "Debug (-Og)"
|
||||
config OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Assertions can be:
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
menuconfig CXX_EXCEPTIONS
|
||||
bool "Enable C++ exceptions"
|
||||
default n
|
||||
help
|
||||
Enabling this option compiles all IDF C++ files with exception support enabled.
|
||||
|
||||
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
|
||||
an exception will abort instead.
|
||||
|
||||
Enabling this option currently adds an additional ~500 bytes of heap overhead
|
||||
when an exception is thrown in user code for the first time.
|
||||
|
||||
config CXX_EXCEPTIONS_EMG_POOL_SIZE
|
||||
int "Emergency Pool Size"
|
||||
default 0
|
||||
depends on CXX_EXCEPTIONS
|
||||
help
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
choice STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
|
||||
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
|
||||
The guards are initialized when a function is entered and then checked when the function exits.
|
||||
If a guard check fails, program is halted. Protection has the following modes:
|
||||
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca, and functions with buffers larger than
|
||||
8 bytes are protected.
|
||||
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes additional functions to be protected -- those that
|
||||
have local array definitions, or have references to local frame addresses.
|
||||
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
|
||||
|
||||
Modes have the following impact on code performance and coverage:
|
||||
- performance: NORMAL > STRONG > OVERALL
|
||||
- coverage: NORMAL < STRONG < OVERALL
|
||||
|
||||
|
||||
config STACK_CHECK_NONE
|
||||
bool "None"
|
||||
config STACK_CHECK_NORM
|
||||
bool "Normal"
|
||||
config STACK_CHECK_STRONG
|
||||
bool "Strong"
|
||||
config STACK_CHECK_ALL
|
||||
bool "Overall"
|
||||
endchoice
|
||||
|
||||
config STACK_CHECK
|
||||
bool
|
||||
default !STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection.
|
||||
|
||||
endmenu # Compiler Options
|
||||
|
||||
menu "Component config"
|
||||
source "$COMPONENT_KCONFIGS"
|
||||
|
||||
135
Kconfig.compiler
135
Kconfig.compiler
@@ -1,135 +0,0 @@
|
||||
menu "Compiler options"
|
||||
|
||||
choice OPTIMIZATION_COMPILER
|
||||
prompt "Optimization Level"
|
||||
default OPTIMIZATION_LEVEL_DEBUG
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
|
||||
config OPTIMIZATION_LEVEL_DEBUG
|
||||
bool "Debug (-Og)"
|
||||
config OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Assertions can be:
|
||||
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
menuconfig CXX_EXCEPTIONS
|
||||
bool "Enable C++ exceptions"
|
||||
default n
|
||||
help
|
||||
Enabling this option compiles all IDF C++ files with exception support enabled.
|
||||
|
||||
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
|
||||
an exception will abort instead.
|
||||
|
||||
Enabling this option currently adds an additional ~500 bytes of heap overhead
|
||||
when an exception is thrown in user code for the first time.
|
||||
|
||||
config CXX_EXCEPTIONS_EMG_POOL_SIZE
|
||||
int "Emergency Pool Size"
|
||||
default 0
|
||||
depends on CXX_EXCEPTIONS
|
||||
help
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
choice STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
|
||||
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
|
||||
The guards are initialized when a function is entered and then checked when the function exits.
|
||||
If a guard check fails, program is halted. Protection has the following modes:
|
||||
|
||||
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca,
|
||||
and functions with buffers larger than 8 bytes are protected.
|
||||
|
||||
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes
|
||||
additional functions to be protected -- those that have local array definitions,
|
||||
or have references to local frame addresses.
|
||||
|
||||
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
|
||||
|
||||
Modes have the following impact on code performance and coverage:
|
||||
|
||||
- performance: NORMAL > STRONG > OVERALL
|
||||
|
||||
- coverage: NORMAL < STRONG < OVERALL
|
||||
|
||||
|
||||
config STACK_CHECK_NONE
|
||||
bool "None"
|
||||
config STACK_CHECK_NORM
|
||||
bool "Normal"
|
||||
config STACK_CHECK_STRONG
|
||||
bool "Strong"
|
||||
config STACK_CHECK_ALL
|
||||
bool "Overall"
|
||||
endchoice
|
||||
|
||||
config STACK_CHECK
|
||||
bool
|
||||
default !STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection.
|
||||
|
||||
config WARN_WRITE_STRINGS
|
||||
bool "Enable -Wwrite-strings warning flag"
|
||||
default "n"
|
||||
help
|
||||
Adds -Wwrite-strings flag for the C/C++ compilers.
|
||||
|
||||
For C, this gives string constants the type ``const char[]`` so that
|
||||
copying the address of one into a non-const ``char *`` pointer
|
||||
produces a warning. This warning helps to find at compile time code
|
||||
that tries to write into a string constant.
|
||||
|
||||
For C++, this warns about the deprecated conversion from string
|
||||
literals to ``char *``.
|
||||
|
||||
endmenu # Compiler Options
|
||||
41
README.md
41
README.md
@@ -1,25 +1,30 @@
|
||||
# Espressif IoT Development Framework
|
||||
|
||||
[](https://docs.espressif.com/projects/esp-idf/en/latest/?badge=latest)
|
||||
[](https://esp-idf.readthedocs.io/en/latest/?badge=latest)
|
||||
|
||||
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
|
||||
|
||||
# Developing With the ESP-IDF
|
||||
# Developing With ESP-IDF
|
||||
|
||||
## Setting Up ESP-IDF
|
||||
|
||||
See setup guides for detailed instructions to set up the ESP-IDF:
|
||||
|
||||
* [Windows Setup Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/windows-setup.html)
|
||||
* [Mac OS Setup Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/macos-setup.html)
|
||||
* [Linux Setup Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/linux-setup.html)
|
||||
* [Getting Started Guide for the stable ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/)
|
||||
* [Getting Started Guide for the latest (master branch) ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/)
|
||||
|
||||
## Finding a Project
|
||||
|
||||
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in the setup guide, ESP-IDF comes with some example projects in the [examples](examples) directory.
|
||||
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in Getting Started, ESP-IDF comes with some example projects in the [examples](examples) directory.
|
||||
|
||||
Once you've found the project you want to work with, change to its directory and you can configure and build it.
|
||||
|
||||
To start your own project based on an example, copy the example project directory outside of the ESP-IDF directory.
|
||||
|
||||
# Quick Reference
|
||||
|
||||
See the Getting Started guide links above for a detailed setup guide. This is a quick reference for common commands when working with ESP-IDF projects:
|
||||
|
||||
## Configuring the Project
|
||||
|
||||
`make menuconfig`
|
||||
@@ -36,15 +41,17 @@ Once done configuring, press Escape multiple times to exit and say "Yes" to save
|
||||
|
||||
## Compiling the Project
|
||||
|
||||
`make all`
|
||||
`make -j4 all`
|
||||
|
||||
... will compile app, bootloader and generate a partition table based on the config.
|
||||
|
||||
NOTE: The `-j4` option causes `make` to run 4 parallel jobs. This is much faster than the default single job. The recommended number to pass to this option is `-j(number of CPUs + 1)`.
|
||||
|
||||
## Flashing the Project
|
||||
|
||||
When `make all` finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this from make by running:
|
||||
|
||||
`make flash`
|
||||
`make -j4 flash`
|
||||
|
||||
This will flash the entire project (app, bootloader and partition table) to a new chip. The settings for serial port flashing can be configured with `make menuconfig`.
|
||||
|
||||
@@ -52,28 +59,28 @@ You don't need to run `make all` before running `make flash`, `make flash` will
|
||||
|
||||
## Viewing Serial Output
|
||||
|
||||
The `make monitor` target uses the [idf_monitor tool](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/idf-monitor.html) to display serial output from the ESP32. idf_monitor also has a range of features to decode crash output and interact with the device. [Check the documentation page for details](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/idf-monitor.html).
|
||||
The `make monitor` target uses the [idf_monitor tool](https://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html) to display serial output from the ESP32. idf_monitor also has a range of features to decode crash output and interact with the device. [Check the documentation page for details](https://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html).
|
||||
|
||||
Exit the monitor by typing Ctrl-].
|
||||
|
||||
To flash and monitor output in one pass, you can run:
|
||||
To build, flash and monitor output in one pass, you can run:
|
||||
|
||||
`make flash monitor`
|
||||
`make -j4 flash monitor`
|
||||
|
||||
## Compiling & Flashing Just the App
|
||||
## Compiling & Flashing Only the App
|
||||
|
||||
After the initial flash, you may just want to build and flash just your app, not the bootloader and partition table:
|
||||
|
||||
* `make app` - build just the app.
|
||||
* `make app-flash` - flash just the app.
|
||||
|
||||
`make app-flash` will automatically rebuild the app if it needs it.
|
||||
`make app-flash` will automatically rebuild the app if any source files have changed.
|
||||
|
||||
(In normal development there's no downside to reflashing the bootloader and partition table each time, if they haven't changed.)
|
||||
|
||||
## Parallel Builds
|
||||
|
||||
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to or one more than the number of CPU cores in your system.)
|
||||
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to the number of CPU cores in your system, plus one.)
|
||||
|
||||
Multiple make functions can be combined into one. For example: to build the app & bootloader using 5 jobs in parallel, then flash everything, and then display serial output from the ESP32 run:
|
||||
|
||||
@@ -96,7 +103,7 @@ The simplest way to use the partition table is to `make menuconfig` and choose o
|
||||
|
||||
In both cases the factory app is flashed at offset 0x10000. If you `make partition_table` then it will print a summary of the partition table.
|
||||
|
||||
For more details about partition tables and how to create custom variations, view the [`docs/en/api-guides/partition-tables.rst`](docs/en/api-guides/partition-tables.rst) file.
|
||||
For more details about partition tables and how to create custom variations, view the [`docs/api-guides/partition-tables.rst`](docs/api-guides/partition-tables.rst) file.
|
||||
|
||||
## Erasing Flash
|
||||
|
||||
@@ -106,12 +113,12 @@ This can be combined with other targets, ie `make erase_flash flash` will erase
|
||||
|
||||
# Resources
|
||||
|
||||
* Documentation for the latest version: https://docs.espressif.com/projects/esp-idf/. This documentation is built from the [docs directory](docs) of this repository.
|
||||
* Documentation for the latest version: https://esp-idf.readthedocs.io/. This documentation is built from the [docs directory](docs) of this repository.
|
||||
|
||||
* The [esp32.com forum](https://esp32.com/) is a place to ask questions and find community resources.
|
||||
|
||||
* [Check the Issues section on github](https://github.com/espressif/esp-idf/issues) if you find a bug or have a feature request. Please check existing Issues before opening a new one.
|
||||
|
||||
* If you're interested in contributing to ESP-IDF, please check the [Contributions Guide](https://docs.espressif.com/projects/esp-idf/en/latest/contribute/index.html).
|
||||
* If you're interested in contributing to ESP-IDF, please check the [Contributions Guide](https://esp-idf.readthedocs.io/en/latest/contribute/index.html).
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ config ESP32_APPTRACE_PENDING_DATA_SIZE_MAX
|
||||
events will be discarded when main HW buffer is full.
|
||||
|
||||
menu "FreeRTOS SystemView Tracing"
|
||||
depends on ESP32_APPTRACE_ENABLE
|
||||
config SYSVIEW_ENABLE
|
||||
bool "SystemView Tracing Enable"
|
||||
depends on ESP32_APPTRACE_ENABLE
|
||||
@@ -191,12 +190,4 @@ config SYSVIEW_EVT_TIMER_EXIT_ENABLE
|
||||
Enables "Timer Exit" event.
|
||||
|
||||
endmenu
|
||||
|
||||
config ESP32_GCOV_ENABLE
|
||||
bool "GCOV to Host Enable"
|
||||
depends on ESP32_DEBUG_STUBS_ENABLE && ESP32_APPTRACE_ENABLE && !SYSVIEW_ENABLE
|
||||
default y
|
||||
help
|
||||
Enables support for GCOV data transfer to host.
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -156,7 +156,6 @@
|
||||
// ALSO SEE example usage of application tracing module in 'components/app_trace/README.rst'
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "eri.h"
|
||||
@@ -336,8 +335,6 @@ typedef struct {
|
||||
uint8_t *(*get_down_buffer)(uint32_t *, esp_apptrace_tmo_t *);
|
||||
esp_err_t (*put_down_buffer)(uint8_t *, esp_apptrace_tmo_t *);
|
||||
bool (*host_is_connected)(void);
|
||||
esp_err_t (*status_reg_set)(uint32_t val);
|
||||
esp_err_t (*status_reg_get)(uint32_t *val);
|
||||
} esp_apptrace_hw_t;
|
||||
|
||||
static uint32_t esp_apptrace_trax_down_buffer_write_nolock(uint8_t *data, uint32_t size);
|
||||
@@ -347,8 +344,6 @@ static esp_err_t esp_apptrace_trax_put_buffer(uint8_t *ptr, esp_apptrace_tmo_t *
|
||||
static bool esp_apptrace_trax_host_is_connected(void);
|
||||
static uint8_t *esp_apptrace_trax_down_buffer_get(uint32_t *size, esp_apptrace_tmo_t *tmo);
|
||||
static esp_err_t esp_apptrace_trax_down_buffer_put(uint8_t *ptr, esp_apptrace_tmo_t *tmo);
|
||||
static esp_err_t esp_apptrace_trax_status_reg_set(uint32_t val);
|
||||
static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val);
|
||||
|
||||
static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = {
|
||||
{
|
||||
@@ -357,9 +352,7 @@ static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = {
|
||||
.flush_up_buffer = esp_apptrace_trax_flush,
|
||||
.get_down_buffer = esp_apptrace_trax_down_buffer_get,
|
||||
.put_down_buffer = esp_apptrace_trax_down_buffer_put,
|
||||
.host_is_connected = esp_apptrace_trax_host_is_connected,
|
||||
.status_reg_set = esp_apptrace_trax_status_reg_set,
|
||||
.status_reg_get = esp_apptrace_trax_status_reg_get
|
||||
.host_is_connected = esp_apptrace_trax_host_is_connected
|
||||
}
|
||||
};
|
||||
|
||||
@@ -422,8 +415,6 @@ static void esp_apptrace_trax_init()
|
||||
eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TRSTP);
|
||||
eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TMEN);
|
||||
eri_write(ESP_APPTRACE_TRAX_CTRL_REG, ESP_APPTRACE_TRAX_BLOCK_ID(ESP_APPTRACE_TRAX_INBLOCK_START));
|
||||
// this is for OpenOCD to let him know where stub entries vector is resided
|
||||
// must be read by host before any transfer using TRAX
|
||||
eri_write(ESP_APPTRACE_TRAX_STAT_REG, 0);
|
||||
|
||||
ESP_APPTRACE_LOGI("Initialized TRAX on CPU%d", xPortGetCoreID());
|
||||
@@ -592,11 +583,11 @@ static uint8_t *esp_apptrace_trax_down_buffer_get(uint32_t *size, esp_apptrace_t
|
||||
while (1) {
|
||||
uint32_t sz = esp_apptrace_rb_read_size_get(&s_trace_buf.rb_down);
|
||||
if (sz != 0) {
|
||||
*size = MIN(*size, sz);
|
||||
ptr = esp_apptrace_rb_consume(&s_trace_buf.rb_down, *size);
|
||||
ptr = esp_apptrace_rb_consume(&s_trace_buf.rb_down, sz > *size ? *size : sz);
|
||||
if (!ptr) {
|
||||
assert(false && "Failed to consume bytes from down buffer!");
|
||||
}
|
||||
*size = sz;
|
||||
break;
|
||||
}
|
||||
// may need to flush
|
||||
@@ -836,18 +827,6 @@ static bool esp_apptrace_trax_host_is_connected(void)
|
||||
return eri_read(ESP_APPTRACE_TRAX_CTRL_REG) & ESP_APPTRACE_TRAX_HOST_CONNECT ? true : false;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_status_reg_set(uint32_t val)
|
||||
{
|
||||
eri_write(ESP_APPTRACE_TRAX_STAT_REG, val);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val)
|
||||
{
|
||||
*val = eri_read(ESP_APPTRACE_TRAX_STAT_REG);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_dest_init()
|
||||
{
|
||||
for (int i = 0; i < ESP_APPTRACE_TRAX_BLOCKS_NUM; i++) {
|
||||
@@ -1184,49 +1163,13 @@ bool esp_apptrace_host_is_connected(esp_apptrace_dest_t dest)
|
||||
hw = ESP_APPTRACE_HW(ESP_APPTRACE_HW_TRAX);
|
||||
#else
|
||||
ESP_APPTRACE_LOGE("Application tracing via TRAX is disabled in menuconfig!");
|
||||
return false;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
} else {
|
||||
ESP_APPTRACE_LOGE("Trace destinations other then TRAX are not supported yet!");
|
||||
return false;
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return hw->host_is_connected();
|
||||
}
|
||||
|
||||
esp_err_t esp_apptrace_status_reg_set(esp_apptrace_dest_t dest, uint32_t val)
|
||||
{
|
||||
esp_apptrace_hw_t *hw = NULL;
|
||||
|
||||
if (dest == ESP_APPTRACE_DEST_TRAX) {
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
hw = ESP_APPTRACE_HW(ESP_APPTRACE_HW_TRAX);
|
||||
#else
|
||||
ESP_APPTRACE_LOGE("Application tracing via TRAX is disabled in menuconfig!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
} else {
|
||||
ESP_APPTRACE_LOGE("Trace destinations other then TRAX are not supported yet!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return hw->status_reg_set(val);
|
||||
}
|
||||
|
||||
esp_err_t esp_apptrace_status_reg_get(esp_apptrace_dest_t dest, uint32_t *val)
|
||||
{
|
||||
esp_apptrace_hw_t *hw = NULL;
|
||||
|
||||
if (dest == ESP_APPTRACE_DEST_TRAX) {
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
hw = ESP_APPTRACE_HW(ESP_APPTRACE_HW_TRAX);
|
||||
#else
|
||||
ESP_APPTRACE_LOGE("Application tracing via TRAX is disabled in menuconfig!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
} else {
|
||||
ESP_APPTRACE_LOGE("Trace destinations other then TRAX are not supported yet!");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return hw->status_reg_get(val);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,92 +21,20 @@
|
||||
#include "soc/timer_group_struct.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_dbg_stubs.h"
|
||||
|
||||
#if CONFIG_ESP32_GCOV_ENABLE
|
||||
|
||||
#define ESP_GCOV_DOWN_BUF_SIZE 4200
|
||||
#if CONFIG_ESP32_APPTRACE_ENABLE
|
||||
|
||||
#define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
|
||||
#include "esp_log.h"
|
||||
const static char *TAG = "esp_gcov_rtio";
|
||||
|
||||
static void (*s_gcov_exit)(void);
|
||||
|
||||
/* TODO: remove code extracted from GCC when IDF toolchain will be updated */
|
||||
/*=============== GCC CODE START ====================*/
|
||||
/* Root of a program/shared-object state */
|
||||
struct gcov_root
|
||||
{
|
||||
void *list;
|
||||
unsigned dumped : 1; /* counts have been dumped. */
|
||||
unsigned run_counted : 1; /* run has been accounted for. */
|
||||
struct gcov_root *next;
|
||||
struct gcov_root *prev;
|
||||
};
|
||||
|
||||
/* Per-dynamic-object gcov state. */
|
||||
extern struct gcov_root __gcov_root;
|
||||
|
||||
static void esp_gcov_reset_status(void)
|
||||
{
|
||||
__gcov_root.dumped = 0;
|
||||
__gcov_root.run_counted = 0;
|
||||
}
|
||||
/*=============== GCC CODE END ====================*/
|
||||
|
||||
static int esp_dbg_stub_gcov_dump_do(void)
|
||||
{
|
||||
int ret = ESP_OK;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "Check for dump handler %p", s_gcov_exit);
|
||||
if (s_gcov_exit) {
|
||||
ESP_EARLY_LOGV(TAG, "Alloc apptrace down buf %d bytes", ESP_GCOV_DOWN_BUF_SIZE);
|
||||
void *down_buf = malloc(ESP_GCOV_DOWN_BUF_SIZE);
|
||||
if (down_buf == NULL) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
ESP_EARLY_LOGV(TAG, "Config apptrace down buf");
|
||||
esp_apptrace_down_buffer_config(down_buf, ESP_GCOV_DOWN_BUF_SIZE);
|
||||
ESP_EARLY_LOGV(TAG, "Dump data... %p", s_gcov_exit);
|
||||
s_gcov_exit();
|
||||
ESP_EARLY_LOGV(TAG, "Free apptrace down buf");
|
||||
free(down_buf);
|
||||
}
|
||||
ESP_EARLY_LOGV(TAG, "Finish file transfer session");
|
||||
ret = esp_apptrace_fstop(ESP_APPTRACE_DEST_TRAX);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Triggers gcov info dump.
|
||||
* This function is to be called by OpenOCD, not by normal user code.
|
||||
* TODO: what about interrupted flash access (when cache disabled)???
|
||||
*
|
||||
* @return ESP_OK on success, otherwise see esp_err_t
|
||||
*/
|
||||
static int esp_dbg_stub_gcov_entry(void)
|
||||
{
|
||||
int ret = ESP_OK;
|
||||
|
||||
// disable IRQs on this CPU, other CPU is halted by OpenOCD
|
||||
unsigned irq_state = portENTER_CRITICAL_NESTED();
|
||||
ret = esp_dbg_stub_gcov_dump_do();
|
||||
// reset dump status to allow incremental data accumulation
|
||||
esp_gcov_reset_status();
|
||||
portEXIT_CRITICAL_NESTED(irq_state);
|
||||
return ret;
|
||||
}
|
||||
static uint8_t s_gcov_down_buf[256];
|
||||
|
||||
void esp_gcov_dump()
|
||||
{
|
||||
#if CONFIG_FREERTOS_UNICORE == 0
|
||||
int other_core = xPortGetCoreID() ? 0 : 1;
|
||||
esp_cpu_stall(other_core);
|
||||
esp_cpu_stall(!xPortGetCoreID());
|
||||
#endif
|
||||
|
||||
while (!esp_apptrace_host_is_connected(ESP_APPTRACE_DEST_TRAX)) {
|
||||
@@ -120,59 +48,46 @@ void esp_gcov_dump()
|
||||
TIMERG1.wdt_wprotect=0;
|
||||
}
|
||||
|
||||
esp_dbg_stub_gcov_dump_do();
|
||||
// reset dump status to allow incremental data accumulation
|
||||
esp_gcov_reset_status();
|
||||
#if CONFIG_FREERTOS_UNICORE == 0
|
||||
esp_cpu_unstall(other_core);
|
||||
#endif
|
||||
if (s_gcov_exit) {
|
||||
esp_apptrace_down_buffer_config(s_gcov_down_buf, sizeof(s_gcov_down_buf));
|
||||
s_gcov_exit();
|
||||
}
|
||||
|
||||
int ret = esp_apptrace_fstop(ESP_APPTRACE_DEST_TRAX);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
int gcov_rtio_atexit(void (*function)(void))
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s %p", __FUNCTION__, function);
|
||||
s_gcov_exit = function;
|
||||
esp_dbg_stub_entry_set(ESP_DBG_STUB_ENTRY_GCOV, (uint32_t)&esp_dbg_stub_gcov_entry);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *gcov_rtio_fopen(const char *path, const char *mode)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fopen(ESP_APPTRACE_DEST_TRAX, path, mode);
|
||||
}
|
||||
|
||||
int gcov_rtio_fclose(void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fclose(ESP_APPTRACE_DEST_TRAX, stream);
|
||||
}
|
||||
|
||||
size_t gcov_rtio_fread(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fread(ESP_APPTRACE_DEST_TRAX, ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
size_t gcov_rtio_fwrite(const void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return esp_apptrace_fwrite(ESP_APPTRACE_DEST_TRAX, ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
int gcov_rtio_fseek(void *stream, long offset, int whence)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
int ret = esp_apptrace_fseek(ESP_APPTRACE_DEST_TRAX, stream, offset, whence);
|
||||
ESP_EARLY_LOGV(TAG, "%s EXIT", __FUNCTION__);
|
||||
return ret;
|
||||
return esp_apptrace_fseek(ESP_APPTRACE_DEST_TRAX, stream, offset, whence);
|
||||
}
|
||||
|
||||
long gcov_rtio_ftell(void *stream)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
long ret = esp_apptrace_ftell(ESP_APPTRACE_DEST_TRAX, stream);
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
return ret;
|
||||
return esp_apptrace_ftell(ESP_APPTRACE_DEST_TRAX, stream);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -87,7 +87,6 @@ static esp_err_t esp_apptrace_file_cmd_send(esp_apptrace_dest_t dest, uint8_t cm
|
||||
esp_err_t ret;
|
||||
esp_apptrace_fcmd_hdr_t *hdr;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "%s %d", __func__, cmd);
|
||||
uint8_t *ptr = esp_apptrace_buffer_get(dest, sizeof(*hdr) + args_len, ESP_APPTRACE_TMO_INFINITE); //TODO: finite tmo
|
||||
if (ptr == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
@@ -102,13 +101,13 @@ static esp_err_t esp_apptrace_file_cmd_send(esp_apptrace_dest_t dest, uint8_t cm
|
||||
// now indicate that this buffer is ready to be sent off to host
|
||||
ret = esp_apptrace_buffer_put(dest, ptr, ESP_APPTRACE_TMO_INFINITE);//TODO: finite tmo
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to put apptrace buffer (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to put apptrace buffer (%d)!", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = esp_apptrace_flush(dest, ESP_APPTRACE_TMO_INFINITE);//TODO: finite tmo
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to flush apptrace buffer (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to flush apptrace buffer (%d)!", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -120,12 +119,11 @@ static esp_err_t esp_apptrace_file_rsp_recv(esp_apptrace_dest_t dest, uint8_t *b
|
||||
uint32_t tot_rd = 0;
|
||||
while (tot_rd < buf_len) {
|
||||
uint32_t rd_size = buf_len - tot_rd;
|
||||
esp_err_t ret = esp_apptrace_read(dest, buf + tot_rd, &rd_size, ESP_APPTRACE_TMO_INFINITE); //TODO: finite tmo
|
||||
esp_err_t ret = esp_apptrace_read(dest, buf, &rd_size, ESP_APPTRACE_TMO_INFINITE); //TODO: finite tmo
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return ret;
|
||||
}
|
||||
ESP_EARLY_LOGV(TAG, "%s read %d bytes", __FUNCTION__, rd_size);
|
||||
tot_rd += rd_size;
|
||||
}
|
||||
|
||||
@@ -144,8 +142,6 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
||||
{
|
||||
esp_apptrace_fopen_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fopen '%s' '%s'", path, mode);
|
||||
|
||||
cmd_args.path = path;
|
||||
cmd_args.path_len = strlen(path) + 1;
|
||||
cmd_args.mode = mode;
|
||||
@@ -154,7 +150,7 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FOPEN, esp_apptrace_fopen_args_prepare,
|
||||
&cmd_args, cmd_args.path_len+cmd_args.mode_len);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -162,7 +158,7 @@ void *esp_apptrace_fopen(esp_apptrace_dest_t dest, const char *path, const char
|
||||
void *resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -184,7 +180,7 @@ int esp_apptrace_fclose(esp_apptrace_dest_t dest, void *stream)
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FCLOSE, esp_apptrace_fclose_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
@@ -192,7 +188,7 @@ int esp_apptrace_fclose(esp_apptrace_dest_t dest, void *stream)
|
||||
int resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
@@ -211,15 +207,13 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
||||
{
|
||||
esp_apptrace_fwrite_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fwrite f %p l %d", stream, size*nmemb);
|
||||
|
||||
cmd_args.buf = (void *)ptr;
|
||||
cmd_args.size = size * nmemb;
|
||||
cmd_args.file = stream;
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FWRITE, esp_apptrace_fwrite_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args.file)+cmd_args.size);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -227,7 +221,7 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
|
||||
size_t resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -246,14 +240,12 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
||||
{
|
||||
esp_apptrace_fread_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fread f %p l %d", stream, size*nmemb);
|
||||
|
||||
cmd_args.size = size * nmemb;
|
||||
cmd_args.file = stream;
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FREAD, esp_apptrace_fread_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -261,13 +253,13 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
|
||||
size_t resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
if (resp > 0) {
|
||||
ret = esp_apptrace_file_rsp_recv(dest, ptr, resp);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read file data (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read file data (%d)!", ret);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -285,15 +277,13 @@ int esp_apptrace_fseek(esp_apptrace_dest_t dest, void *stream, long offset, int
|
||||
{
|
||||
esp_apptrace_fseek_args_t cmd_args;
|
||||
|
||||
ESP_EARLY_LOGV(TAG, "esp_apptrace_fseek f %p o 0x%lx w %d", stream, offset, whence);
|
||||
|
||||
cmd_args.file = stream;
|
||||
cmd_args.offset = offset;
|
||||
cmd_args.whence = whence;
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FSEEK, esp_apptrace_fseek_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -301,7 +291,7 @@ int esp_apptrace_fseek(esp_apptrace_dest_t dest, void *stream, long offset, int
|
||||
int resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -323,7 +313,7 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_FTELL, esp_apptrace_ftell_args_prepare,
|
||||
&cmd_args, sizeof(cmd_args));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send file cmd (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -331,7 +321,7 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
||||
int resp;
|
||||
ret = esp_apptrace_file_rsp_recv(dest, (uint8_t *)&resp, sizeof(resp));
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to read response (%d)!", ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -340,10 +330,9 @@ int esp_apptrace_ftell(esp_apptrace_dest_t dest, void *stream)
|
||||
|
||||
int esp_apptrace_fstop(esp_apptrace_dest_t dest)
|
||||
{
|
||||
ESP_EARLY_LOGV(TAG, "%s", __func__);
|
||||
esp_err_t ret = esp_apptrace_file_cmd_send(dest, ESP_APPTRACE_FILE_CMD_STOP, NULL, NULL, 0);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
ESP_LOGE(TAG, "Failed to send files transfer stop cmd (%d)!", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
0
components/app_update/component.mk
Normal file → Executable file
0
components/app_update/component.mk
Normal file → Executable file
@@ -191,7 +191,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
}
|
||||
|
||||
//if go to here ,means don't find the handle
|
||||
ESP_LOGE(TAG,"not found the handle");
|
||||
ESP_LOGE(TAG,"not found the handle")
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
||||
0
components/app_update/include/esp_ota_ops.h
Normal file → Executable file
0
components/app_update/include/esp_ota_ops.h
Normal file → Executable file
@@ -83,77 +83,3 @@ config AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL
|
||||
Maximum delay between reconnection attempts. If the exponentially increased delay
|
||||
interval reaches this value, the client will stop automatically attempting to reconnect.
|
||||
|
||||
menu "Thing Shadow"
|
||||
depends on AWS_IOT_SDK
|
||||
|
||||
config AWS_IOT_OVERRIDE_THING_SHADOW_RX_BUFFER
|
||||
bool "Override Shadow RX buffer size"
|
||||
depends on AWS_IOT_SDK
|
||||
default n
|
||||
help
|
||||
Allows setting a different Thing Shadow RX buffer
|
||||
size. This is the maximum size of a Thing Shadow
|
||||
message in bytes, plus one.
|
||||
|
||||
If not overridden, the default value is the MQTT RX Buffer length plus one. If overriden, do not set higher than the default value.
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_SIZE_OF_RX_BUFFER
|
||||
int "Maximum RX Buffer (bytes)"
|
||||
depends on AWS_IOT_OVERRIDE_THING_SHADOW_RX_BUFFER
|
||||
default 513
|
||||
range 32 65536
|
||||
help
|
||||
Allows setting a different Thing Shadow RX buffer size.
|
||||
This is the maximum size of a Thing Shadow message in bytes,
|
||||
plus one.
|
||||
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES
|
||||
int "Maximum unique client ID size (bytes)"
|
||||
depends on AWS_IOT_SDK
|
||||
default 80
|
||||
range 4 1000
|
||||
help
|
||||
Maximum size of the Unique Client Id.
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_SIMULTANEOUS_ACKS
|
||||
int "Maximum simultaneous responses"
|
||||
depends on AWS_IOT_SDK
|
||||
default 10
|
||||
range 1 100
|
||||
help
|
||||
At any given time we will wait for this many responses. This will correlate to the rate at which the shadow actions are requested
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_SIMULTANEOUS_THINGNAMES
|
||||
int "Maximum simultaneous Thing Name operations"
|
||||
depends on AWS_IOT_SDK
|
||||
default 10
|
||||
range 1 100
|
||||
help
|
||||
We could perform shadow action on any thing Name and this is maximum Thing Names we can act on at any given time
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_JSON_TOKEN_EXPECTED
|
||||
int "Maximum expected JSON tokens"
|
||||
depends on AWS_IOT_SDK
|
||||
default 120
|
||||
help
|
||||
These are the max tokens that is expected to be in the Shadow JSON document. Includes the metadata which is published
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME
|
||||
int "Maximum topic length (not including Thing Name)"
|
||||
depends on AWS_IOT_SDK
|
||||
default 60
|
||||
range 10 1000
|
||||
help
|
||||
All shadow actions have to be published or subscribed to a topic which is of the format $aws/things/{thingName}/shadow/update/accepted. This refers to the size of the topic without the Thing Name
|
||||
|
||||
config AWS_IOT_SHADOW_MAX_SIZE_OF_THING_NAME
|
||||
int "Maximum Thing Name length"
|
||||
depends on AWS_IOT_SDK
|
||||
default 20
|
||||
range 4 1000
|
||||
help
|
||||
Maximum length of a Thing Name.
|
||||
|
||||
endmenu # Thing Shadow
|
||||
|
||||
|
||||
Submodule components/aws_iot/aws-iot-device-sdk-embedded-C updated: 8bf852db77...7132505b00
@@ -42,20 +42,15 @@
|
||||
#define AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS CONFIG_AWS_IOT_MQTT_NUM_SUBSCRIBE_HANDLERS ///< Maximum number of topic filters the MQTT client can handle at any given time. This should be increased appropriately when using Thing Shadow
|
||||
|
||||
// Thing Shadow specific configs
|
||||
#ifdef CONFIG_AWS_IOT_OVERRIDE_THING_SHADOW_RX_BUFFER
|
||||
#define SHADOW_MAX_SIZE_OF_RX_BUFFER CONFIG_AWS_IOT_SHADOW_MAX_SIZE_OF_RX_BUFFER ///< Maximum size of the SHADOW buffer to store the received Shadow message, including NULL terminating byte
|
||||
#else
|
||||
#define SHADOW_MAX_SIZE_OF_RX_BUFFER (AWS_IOT_MQTT_RX_BUF_LEN + 1)
|
||||
#endif
|
||||
|
||||
#define SHADOW_MAX_SIZE_OF_RX_BUFFER (AWS_IOT_MQTT_RX_BUF_LEN + 1) ///< Maximum size of the SHADOW buffer to store the received Shadow message
|
||||
#define MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES 80 ///< Maximum size of the Unique Client Id. For More info on the Client Id refer \ref response "Acknowledgments"
|
||||
#define MAX_SIZE_CLIENT_ID_WITH_SEQUENCE (MAX_SIZE_OF_UNIQUE_CLIENT_ID_BYTES + 10) ///< This is size of the extra sequence number that will be appended to the Unique client Id
|
||||
#define MAX_SIZE_CLIENT_TOKEN_CLIENT_SEQUENCE (MAX_SIZE_CLIENT_ID_WITH_SEQUENCE + 20) ///< This is size of the the total clientToken key and value pair in the JSON
|
||||
#define MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME CONFIG_AWS_IOT_SHADOW_MAX_SIMULTANEOUS_ACKS ///< At Any given time we will wait for this many responses. This will correlate to the rate at which the shadow actions are requested
|
||||
#define MAX_THINGNAME_HANDLED_AT_ANY_GIVEN_TIME CONFIG_AWS_IOT_SHADOW_MAX_SIMULTANEOUS_THINGNAMES ///< We could perform shadow action on any thing Name and this is maximum Thing Names we can act on at any given time
|
||||
#define MAX_JSON_TOKEN_EXPECTED CONFIG_AWS_IOT_SHADOW_MAX_JSON_TOKEN_EXPECTED ///< These are the max tokens that is expected to be in the Shadow JSON document. Include the metadata that gets published
|
||||
#define MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME CONFIG_AWS_IOT_SHADOW_MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME ///< All shadow actions have to be published or subscribed to a topic which is of the formablogt $aws/things/{thingName}/shadow/update/accepted. This refers to the size of the topic without the Thing Name
|
||||
#define MAX_SIZE_OF_THING_NAME CONFIG_AWS_IOT_SHADOW_MAX_SIZE_OF_THING_NAME ///< The Thing Name should not be bigger than this value. Modify this if the Thing Name needs to be bigger
|
||||
#define MAX_ACKS_TO_COMEIN_AT_ANY_GIVEN_TIME 10 ///< At Any given time we will wait for this many responses. This will correlate to the rate at which the shadow actions are requested
|
||||
#define MAX_THINGNAME_HANDLED_AT_ANY_GIVEN_TIME 10 ///< We could perform shadow action on any thing Name and this is maximum Thing Names we can act on at any given time
|
||||
#define MAX_JSON_TOKEN_EXPECTED 120 ///< These are the max tokens that is expected to be in the Shadow JSON document. Include the metadata that gets published
|
||||
#define MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME 60 ///< All shadow actions have to be published or subscribed to a topic which is of the formablogt $aws/things/{thingName}/shadow/update/accepted. This refers to the size of the topic without the Thing Name
|
||||
#define MAX_SIZE_OF_THING_NAME 20 ///< The Thing Name should not be bigger than this value. Modify this if the Thing Name needs to be bigger
|
||||
#define MAX_SHADOW_TOPIC_LENGTH_BYTES (MAX_SHADOW_TOPIC_LENGTH_WITHOUT_THINGNAME + MAX_SIZE_OF_THING_NAME) ///< This size includes the length of topic with Thing Name
|
||||
|
||||
// Auto Reconnect specific config
|
||||
|
||||
@@ -236,15 +236,6 @@ IoT_Error_t iot_tls_connect(Network *pNetwork, TLSConnectParams *params) {
|
||||
|
||||
mbedtls_ssl_conf_read_timeout(&(tlsDataParams->conf), pNetwork->tlsConnectParams.timeout_ms);
|
||||
|
||||
/* Use the AWS IoT ALPN extension for MQTT, if port 443 is requested */
|
||||
if (pNetwork->tlsConnectParams.DestinationPort == 443) {
|
||||
const char *alpnProtocols[] = { "x-amzn-mqtt-ca", NULL };
|
||||
if ((ret = mbedtls_ssl_conf_alpn_protocols(&(tlsDataParams->conf), alpnProtocols)) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_conf_alpn_protocols returned -0x%x", -ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if((ret = mbedtls_ssl_setup(&(tlsDataParams->ssl), &(tlsDataParams->conf))) != 0) {
|
||||
ESP_LOGE(TAG, "failed! mbedtls_ssl_setup returned -0x%x", -ret);
|
||||
return SSL_CONNECTION_ERROR;
|
||||
|
||||
@@ -62,71 +62,6 @@ config BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
bool "1.9V"
|
||||
endchoice
|
||||
|
||||
config BOOTLOADER_FACTORY_RESET
|
||||
bool "GPIO triggers factory reset"
|
||||
default N
|
||||
help
|
||||
Allows to reset the device to factory settings:
|
||||
- clear one or more data partitions;
|
||||
- boot from "factory" partition.
|
||||
The factory reset will occur if there is a GPIO input pulled low while device starts up.
|
||||
See settings below.
|
||||
|
||||
config BOOTLOADER_NUM_PIN_FACTORY_RESET
|
||||
int "Number of the GPIO input for factory reset"
|
||||
depends on BOOTLOADER_FACTORY_RESET
|
||||
range 0 39
|
||||
default 4
|
||||
help
|
||||
The selected GPIO will be configured as an input with internal pull-up enabled.
|
||||
To trigger a factory reset, this GPIO must be pulled low on reset.
|
||||
Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
|
||||
|
||||
config BOOTLOADER_OTA_DATA_ERASE
|
||||
bool "Clear OTA data on factory reset (select factory partition)"
|
||||
depends on BOOTLOADER_FACTORY_RESET
|
||||
help
|
||||
The device will boot from "factory" partition (or OTA slot 0 if no factory partition is present) after a factory reset.
|
||||
|
||||
config BOOTLOADER_DATA_FACTORY_RESET
|
||||
string "Comma-separated names of partitions to clear on factory reset"
|
||||
depends on BOOTLOADER_FACTORY_RESET
|
||||
default "nvs"
|
||||
help
|
||||
Allows customers to select which data partitions will be erased while factory reset.
|
||||
|
||||
Specify the names of partitions as a comma-delimited with optional spaces for readability. (Like this: "nvs, phy_init, ...")
|
||||
Make sure that the name specified in the partition table and here are the same.
|
||||
Partitions of type "app" cannot be specified here.
|
||||
|
||||
config BOOTLOADER_APP_TEST
|
||||
bool "GPIO triggers boot from test app partition"
|
||||
default N
|
||||
help
|
||||
Allows to run the test app from "TEST" partition.
|
||||
A boot from "test" partition will occur if there is a GPIO input pulled low while device starts up.
|
||||
See settings below.
|
||||
|
||||
config BOOTLOADER_NUM_PIN_APP_TEST
|
||||
int "Number of the GPIO input to boot TEST partition"
|
||||
depends on BOOTLOADER_APP_TEST
|
||||
range 0 39
|
||||
default 18
|
||||
help
|
||||
The selected GPIO will be configured as an input with internal pull-up enabled.
|
||||
To trigger a test app, this GPIO must be pulled low on reset.
|
||||
After the GPIO input is deactivated and the device reboots, the old application will boot.
|
||||
(factory or OTA[x]).
|
||||
Note that GPIO34-39 do not have an internal pullup and an external one must be provided.
|
||||
|
||||
config BOOTLOADER_HOLD_TIME_GPIO
|
||||
int "Hold time of GPIO for reset/test mode (seconds)"
|
||||
depends on BOOTLOADER_FACTORY_RESET || BOOTLOADER_APP_TEST
|
||||
default 5
|
||||
help
|
||||
The GPIO must be held low continuously for this period of time after reset
|
||||
before a factory reset or test partition boot (as applicable) is performed.
|
||||
|
||||
endmenu # Bootloader
|
||||
|
||||
|
||||
@@ -142,7 +77,7 @@ config SECURE_BOOT_ENABLED
|
||||
|
||||
When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
|
||||
|
||||
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
|
||||
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
|
||||
|
||||
choice SECURE_BOOTLOADER_MODE
|
||||
bool "Secure bootloader mode"
|
||||
@@ -206,7 +141,7 @@ config SECURE_BOOT_VERIFICATION_KEY
|
||||
PEM formatted private key using the espsecure.py
|
||||
extract_public_key command.
|
||||
|
||||
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
|
||||
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
|
||||
|
||||
config SECURE_BOOT_INSECURE
|
||||
bool "Allow potentially insecure options"
|
||||
@@ -217,7 +152,7 @@ config SECURE_BOOT_INSECURE
|
||||
|
||||
Only enable these options if you are very sure.
|
||||
|
||||
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
|
||||
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
|
||||
|
||||
config FLASH_ENCRYPTION_ENABLED
|
||||
bool "Enable flash encryption on boot (READ DOCS FIRST)"
|
||||
@@ -228,7 +163,7 @@ config FLASH_ENCRYPTION_ENABLED
|
||||
Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
|
||||
system is complicated and not always possible.
|
||||
|
||||
Read https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html before enabling.
|
||||
Read https://esp-idf.readthedocs.io/en/latest/security/flash-encryption.html before enabling.
|
||||
|
||||
config FLASH_ENCRYPTION_INSECURE
|
||||
bool "Allow potentially insecure options"
|
||||
|
||||
@@ -32,8 +32,7 @@ BOOTLOADER_MAKE= +\
|
||||
V=$(V) \
|
||||
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
|
||||
TEST_COMPONENTS= \
|
||||
TESTS_ALL= \
|
||||
EXCLUDE_COMPONENTS=
|
||||
TESTS_ALL=
|
||||
|
||||
.PHONY: bootloader-clean bootloader-flash bootloader-list-components bootloader $(BOOTLOADER_BIN)
|
||||
|
||||
|
||||
@@ -41,12 +41,6 @@ typedef struct {
|
||||
|
||||
bool flash_encrypt(bootloader_state_t *bs);
|
||||
|
||||
/* Indices used by index_to_partition are the OTA index
|
||||
number, or these special constants */
|
||||
#define FACTORY_INDEX (-1)
|
||||
#define TEST_APP_INDEX (-2)
|
||||
#define INVALID_INDEX (-99)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,14 +8,12 @@ Linker file used to link the bootloader.
|
||||
The main purpose is to make sure the bootloader can load into main memory
|
||||
without overwriting itself.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* I/O */
|
||||
dport0_seg (RW) : org = 0x3FF00000, len = 0x10
|
||||
/* IRAM POOL1, used for APP CPU cache. Bootloader runs from here during the final stage of loading the app because APP CPU is still held in reset, the main app enables APP CPU cache */
|
||||
iram_loader_seg (RWX) : org = 0x40078000, len = 0x8000 /* 32KB, APP CPU cache */
|
||||
iram_seg (RWX) : org = 0x40080000, len = 0x10000 /* 64KB, IRAM */
|
||||
/* IRAM POOL1, used for APP CPU cache. We can abuse it in bootloader because APP CPU is still held in reset, the main app enables APP CPU cache */
|
||||
iram_seg (RWX) : org = 0x40078000, len = 0x8000
|
||||
/* 64k at the end of DRAM, after ROM bootloader stack */
|
||||
dram_seg (RW) : org = 0x3FFF0000, len = 0x10000
|
||||
}
|
||||
@@ -26,30 +24,7 @@ ENTRY(call_start_cpu0);
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
.iram_loader.text :
|
||||
{
|
||||
. = ALIGN (16);
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
*(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*liblog.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_utility.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:esp_image_format.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_partitions.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_sha.o(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
} > iram_loader_seg
|
||||
|
||||
.iram.text :
|
||||
.iram1.text :
|
||||
{
|
||||
. = ALIGN (16);
|
||||
*(.entry.text)
|
||||
@@ -146,7 +121,7 @@ SECTIONS
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.iram .iram.*) /* catch stray IRAM_ATTR */
|
||||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#define CMD_WRDI 0x04
|
||||
#define CMD_RDSR 0x05
|
||||
#define CMD_RDSR2 0x35 /* Not all SPI flash uses this command */
|
||||
#define CMD_OTPEN 0x3A /* Enable OTP mode, not all SPI flash uses this command */
|
||||
|
||||
static const char *TAG = "qio_mode";
|
||||
|
||||
@@ -65,6 +66,11 @@ static void write_status_8b_wrsr2(unsigned new_status);
|
||||
/* Write 16 bit status using WRSR */
|
||||
static void write_status_16b_wrsr(unsigned new_status);
|
||||
|
||||
/* Read 8 bit status of XM25QU64A */
|
||||
static unsigned read_status_8b_xmc25qu64a();
|
||||
/* Write 8 bit status of XM25QU64A */
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status);
|
||||
|
||||
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
|
||||
|
||||
#ifndef CONFIG_BOOTLOADER_SPI_WP_PIN // Set in menuconfig if SPI flasher config is set to a quad mode
|
||||
@@ -84,11 +90,12 @@ static void write_status_16b_wrsr(unsigned new_status);
|
||||
Searching of this table stops when the first match is found.
|
||||
*/
|
||||
const static qio_info_t chip_data[] = {
|
||||
/* Manufacturer, mfg_id, flash_id, id mask, Read Status, Write Status, QIE Bit */
|
||||
{ "MXIC", 0xC2, 0x2000, 0xFF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 },
|
||||
{ "ISSI", 0x9D, 0x4000, 0xCF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 }, /* IDs 0x40xx, 0x70xx */
|
||||
{ "WinBond", 0xEF, 0x4000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
/* Manufacturer, mfg_id, flash_id, id mask, Read Status, Write Status, QIE Bit */
|
||||
{ "MXIC", 0xC2, 0x2000, 0xFF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 },
|
||||
{ "ISSI", 0x9D, 0x4000, 0xCF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 }, /* IDs 0x40xx, 0x70xx */
|
||||
{ "WinBond", 0xEF, 0x4000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
|
||||
{ "XM25QU64A", 0x20, 0x3817, 0xFFFF, read_status_8b_xmc25qu64a, write_status_8b_xmc25qu64a, 6 },
|
||||
|
||||
/* Final entry is default entry, if no other IDs have matched.
|
||||
|
||||
@@ -96,7 +103,7 @@ const static qio_info_t chip_data[] = {
|
||||
GigaDevice (mfg ID 0xC8, flash IDs including 4016),
|
||||
FM25Q32 (QOUT mode only, mfg ID 0xA1, flash IDs including 4016)
|
||||
*/
|
||||
{ NULL, 0xFF, 0xFFFF, 0xFFFF, read_status_8b_rdsr2, write_status_8b_wrsr2, 1 },
|
||||
{ NULL, 0xFF, 0xFFFF, 0xFFFF, read_status_8b_rdsr2, write_status_8b_wrsr2, 1 },
|
||||
};
|
||||
|
||||
#define NUM_CHIPS (sizeof(chip_data) / sizeof(qio_info_t))
|
||||
@@ -114,15 +121,10 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
uint32_t bootloader_read_flash_id()
|
||||
{
|
||||
uint32_t id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00);
|
||||
return id;
|
||||
}
|
||||
|
||||
void bootloader_enable_qio_mode(void)
|
||||
{
|
||||
uint32_t old_ctrl_reg;
|
||||
uint32_t raw_flash_id;
|
||||
uint8_t mfg_id;
|
||||
uint16_t flash_id;
|
||||
@@ -131,11 +133,20 @@ void bootloader_enable_qio_mode(void)
|
||||
ESP_LOGD(TAG, "Probing for QIO mode enable...");
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
||||
raw_flash_id = g_rom_flashchip.device_id;
|
||||
/* Set up some of the SPIFLASH user/ctrl variables which don't change
|
||||
while we're probing using execute_flash_command() */
|
||||
old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
SPIFLASH.ctrl.val = SPI_WP_REG; // keep WP high while idle, otherwise leave DIO mode
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user.usr_addr = 0;
|
||||
SPIFLASH.user.usr_command = 1;
|
||||
SPIFLASH.user2.usr_command_bitlen = 7;
|
||||
|
||||
raw_flash_id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
ESP_LOGD(TAG, "Raw SPI flash chip id 0x%x", raw_flash_id);
|
||||
|
||||
mfg_id = (raw_flash_id >> 16) & 0xFF;
|
||||
flash_id = raw_flash_id & 0xFFFF;
|
||||
mfg_id = raw_flash_id & 0xFF;
|
||||
flash_id = (raw_flash_id >> 16) | (raw_flash_id & 0xFF00);
|
||||
ESP_LOGD(TAG, "Manufacturer ID 0x%02x chip ID 0x%04x", mfg_id, flash_id);
|
||||
|
||||
for (i = 0; i < NUM_CHIPS-1; i++) {
|
||||
@@ -150,9 +161,13 @@ void bootloader_enable_qio_mode(void)
|
||||
ESP_LOGI(TAG, "Enabling default flash chip QIO");
|
||||
}
|
||||
|
||||
enable_qio_mode(chip_data[i].read_status_fn,
|
||||
chip_data[i].write_status_fn,
|
||||
chip_data[i].status_qio_bit);
|
||||
esp_err_t res = enable_qio_mode(chip_data[i].read_status_fn,
|
||||
chip_data[i].write_status_fn,
|
||||
chip_data[i].status_qio_bit);
|
||||
if (res != ESP_OK) {
|
||||
// Restore SPI flash CTRL setting, to keep us in DIO/DOUT mode
|
||||
SPIFLASH.ctrl.val = old_ctrl_reg;
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
@@ -166,15 +181,13 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
// spiconfig specifies a custom efuse pin configuration. This config defines all pins -except- WP,
|
||||
// which is compiled into the bootloader instead.
|
||||
//
|
||||
// Most commonly an overriden pin mapping means ESP32-D2WD or ESP32-PICOD4.
|
||||
//Warn if chip is ESP32-D2WD/ESP32-PICOD4 but someone has changed the WP pin
|
||||
//assignment from that chip's WP pin.
|
||||
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
if (CONFIG_BOOTLOADER_SPI_WP_PIN != ESP32_D2WD_WP_GPIO &&
|
||||
(pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)) {
|
||||
ESP_LOGW(TAG, "Chip is ESP32-D2WD/ESP32-PICOD4 but flash WP pin is different value to internal flash");
|
||||
// Most commonly an overriden pin mapping means ESP32-D2WD. Warn if chip is ESP32-D2WD
|
||||
// but someone has changed the WP pin assignment from that chip's WP pin.
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_RESERVE);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
const int PKG_VER_ESP32_D2WD = 2; // TODO: use chip detection API once available
|
||||
if (pkg_ver == PKG_VER_ESP32_D2WD && CONFIG_BOOTLOADER_SPI_WP_PIN != ESP32_D2WD_WP_GPIO) {
|
||||
ESP_LOGW(TAG, "Chip is ESP32-D2WD but flash WP pin is different value to internal flash");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,15 +259,26 @@ static void write_status_16b_wrsr(unsigned new_status)
|
||||
execute_flash_command(CMD_WRSR, new_status, 16, 0);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_xmc25qu64a()
|
||||
{
|
||||
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
uint32_t read_status = execute_flash_command(CMD_RDSR, 0, 0, 8);
|
||||
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
|
||||
return read_status;
|
||||
}
|
||||
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status)
|
||||
{
|
||||
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
execute_flash_command(CMD_WRSR, new_status, 8, 0);
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
|
||||
}
|
||||
|
||||
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
|
||||
{
|
||||
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user.usr_addr = 0;
|
||||
SPIFLASH.user.usr_command = 1;
|
||||
SPIFLASH.user2.usr_command_bitlen = 7;
|
||||
|
||||
SPIFLASH.user2.usr_command_value = command;
|
||||
SPIFLASH.user.usr_miso = miso_len > 0;
|
||||
SPIFLASH.miso_dlen.usr_miso_dbitlen = miso_len ? (miso_len - 1) : 0;
|
||||
@@ -277,6 +301,5 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
while(SPIFLASH.cmd.usr != 0)
|
||||
{ }
|
||||
|
||||
SPIFLASH.ctrl.val = old_ctrl_reg;
|
||||
return SPIFLASH.data_buf[0];
|
||||
}
|
||||
@@ -24,14 +24,6 @@ extern "C" {
|
||||
*/
|
||||
void bootloader_enable_qio_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Read flash ID by sending 0x9F command
|
||||
* @return flash raw ID
|
||||
* mfg_id = (ID >> 16) & 0xFF;
|
||||
flash_id = ID & 0xffff;
|
||||
*/
|
||||
uint32_t bootloader_read_flash_id();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
0
components/bootloader_support/component.mk
Normal file → Executable file
0
components/bootloader_support/component.mk
Normal file → Executable file
@@ -1,70 +0,0 @@
|
||||
// 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_flash_data_types.h"
|
||||
|
||||
/// Type of hold a GPIO in low state
|
||||
typedef enum {
|
||||
GPIO_LONG_HOLD = 1, /*!< The long hold GPIO */
|
||||
GPIO_SHORT_HOLD = -1, /*!< The short hold GPIO */
|
||||
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
|
||||
} esp_comm_gpio_hold_t;
|
||||
|
||||
/**
|
||||
* @brief Calculate crc for the OTA data partition.
|
||||
*
|
||||
* @param[in] ota_data The OTA data partition.
|
||||
* @return Returns crc value.
|
||||
*/
|
||||
uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s);
|
||||
|
||||
/**
|
||||
* @brief Verifies the validity of the OTA data partition
|
||||
*
|
||||
* @param[in] ota_data The OTA data partition.
|
||||
* @return Returns true on valid, false otherwise.
|
||||
*/
|
||||
bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s);
|
||||
|
||||
/**
|
||||
* @brief Check if the GPIO input is a long hold or a short hold.
|
||||
*
|
||||
* Number of the GPIO input will be configured as an input with internal pull-up enabled.
|
||||
* If the GPIO input is held low continuously for delay_sec period then it is a long hold.
|
||||
* If the GPIO input is held low for less period then it is a short hold.
|
||||
*
|
||||
* @param[in] num_pin Number of the GPIO input.
|
||||
* @param[in] delay_sec Input must be driven low for at least this long, continuously.
|
||||
* @return esp_comm_gpio_hold_t Defines type of hold a GPIO in low state.
|
||||
*/
|
||||
esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec);
|
||||
|
||||
/**
|
||||
* @brief Erase the partition data that is specified in the transferred list.
|
||||
*
|
||||
* @param[in] list_erase String containing a list of cleared partitions. Like this "nvs, phy". The string must be null-terminal.
|
||||
* @param[in] ota_data_erase If true then the OTA data partition will be cleared (if there is it in partition table).
|
||||
* @return Returns true on success, false otherwise.
|
||||
*/
|
||||
bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_data_erase);
|
||||
|
||||
/**
|
||||
* @brief Determines if the list contains the label
|
||||
*
|
||||
* @param[in] list A string of names delimited by commas or spaces. Like this "nvs, phy, data". The string must be null-terminated.
|
||||
* @param[in] label The substring that will be searched in the list.
|
||||
* @return Returns true if the list contains the label, false otherwise.
|
||||
*/
|
||||
bool bootloader_common_label_search(const char *list, char *label);
|
||||
@@ -17,12 +17,12 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_flash_data_types.h"
|
||||
#include <stdbool.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
/* Pre-partition table fixed flash offsets */
|
||||
#define ESP_BOOTLOADER_DIGEST_OFFSET 0x0
|
||||
#define ESP_BOOTLOADER_OFFSET 0x1000 /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */
|
||||
#define ESP_PARTITION_TABLE_OFFSET CONFIG_PARTITION_TABLE_OFFSET /* Offset of partition table. Backwards-compatible name.*/
|
||||
#define ESP_BOOTLOADER_SIZE (ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET)
|
||||
#define ESP_PARTITION_TABLE_OFFSET 0x8000 /* Offset of partition table. Has matching value in partition_table Kconfig.projbuild file. */
|
||||
|
||||
#define ESP_PARTITION_TABLE_MAX_LEN 0xC00 /* Maximum length of partition table data */
|
||||
#define ESP_PARTITION_TABLE_MAX_ENTRIES (ESP_PARTITION_TABLE_MAX_LEN / sizeof(esp_partition_info_t)) /* Maximum length of partition table data, including terminating entry */
|
||||
|
||||
@@ -81,6 +81,8 @@ typedef struct {
|
||||
|
||||
_Static_assert(sizeof(esp_image_header_t) == 24, "binary image header should be 24 bytes");
|
||||
|
||||
#define ESP_IMAGE_HASH_LEN 32 /* Length of the appended SHA-256 digest */
|
||||
|
||||
/* Header of binary image segment */
|
||||
typedef struct {
|
||||
uint32_t load_addr;
|
||||
@@ -142,6 +144,16 @@ esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *
|
||||
*/
|
||||
esp_err_t esp_image_verify_bootloader(uint32_t *length);
|
||||
|
||||
/**
|
||||
* @brief Verify the bootloader image.
|
||||
*
|
||||
* @param[out] Metadata for the image. Only valid if result is ESP_OK.
|
||||
*
|
||||
* @return As per esp_image_load_metadata().
|
||||
*/
|
||||
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data);
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t drom_addr;
|
||||
uint32_t drom_load_addr;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// 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_err.h"
|
||||
|
||||
/* @brief Prepares hardware for work.
|
||||
*
|
||||
* Setting up:
|
||||
* - Disable Cache access for both CPUs;
|
||||
* - Initialise cache mmu;
|
||||
* - Setting up pins and mode for SD, SPI, UART, Clocking.
|
||||
|
||||
* @return ESP_OK - If the setting is successful.
|
||||
* ESP_FAIL - If the setting is not successful.
|
||||
*/
|
||||
esp_err_t bootloader_init();
|
||||
@@ -1,54 +0,0 @@
|
||||
// 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"
|
||||
|
||||
/**
|
||||
* @brief Load partition table.
|
||||
*
|
||||
* Parse partition table, get useful data such as location of
|
||||
* OTA data partition, factory app partition, and test app partition.
|
||||
*
|
||||
* @param[out] bs Bootloader state structure used to save read data.
|
||||
* @return Return true if the partition table was succesfully loaded and MD5 checksum is valid.
|
||||
*/
|
||||
bool bootloader_utility_load_partition_table(bootloader_state_t* bs);
|
||||
|
||||
/**
|
||||
* @brief Return the index of the selected boot partition.
|
||||
*
|
||||
* This is the preferred boot partition, as determined by the partition table &
|
||||
* any OTA sequence number found in OTA data.
|
||||
* This partition will only be booted if it contains a valid app image, otherwise load_boot_image() will search
|
||||
* for a valid partition using this selection as the starting point.
|
||||
*
|
||||
* @param[in] bs Bootloader state structure.
|
||||
* @return Returns the index on success, INVALID_INDEX otherwise.
|
||||
*/
|
||||
int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs);
|
||||
|
||||
/**
|
||||
* @brief Load the selected partition and start application.
|
||||
*
|
||||
* Start from partition 'start_index', if not bootable then work backwards to FACTORY_INDEX
|
||||
* (ie try any OTA slots in descending order and then the factory partition).
|
||||
* If still nothing, start from 'start_index + 1' and work up to highest numbered OTA partition.
|
||||
* If still nothing, try TEST_APP_INDEX.
|
||||
* Everything this function calls must be located in the iram_loader_seg segment.
|
||||
*
|
||||
* @param[in] bs Bootloader state structure.
|
||||
* @param[in] start_index The index from which the search for images begins.
|
||||
*/
|
||||
__attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index);
|
||||
@@ -55,7 +55,7 @@ void bootloader_clock_configure()
|
||||
*/
|
||||
#ifdef CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||
if (!rtc_clk_32k_enabled()) {
|
||||
rtc_clk_32k_bootstrap(CONFIG_ESP32_RTC_XTAL_BOOTSTRAP_CYCLES);
|
||||
rtc_clk_32k_bootstrap();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
// 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/spi_flash.h"
|
||||
#include "rom/crc.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "esp_flash_data_types.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
static const char* TAG = "boot_comm";
|
||||
|
||||
uint32_t bootloader_common_ota_select_crc(const esp_ota_select_entry_t *s)
|
||||
{
|
||||
return crc32_le(UINT32_MAX, (uint8_t*)&s->ota_seq, 4);
|
||||
}
|
||||
|
||||
bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s)
|
||||
{
|
||||
return s->ota_seq != UINT32_MAX && s->crc == bootloader_common_ota_select_crc(s);
|
||||
}
|
||||
|
||||
esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec)
|
||||
{
|
||||
gpio_pad_select_gpio(num_pin);
|
||||
gpio_pad_pullup(num_pin);
|
||||
uint32_t tm_start = esp_log_early_timestamp();
|
||||
if (GPIO_INPUT_GET(num_pin) == 1) {
|
||||
return GPIO_NOT_HOLD;
|
||||
}
|
||||
do {
|
||||
if (GPIO_INPUT_GET(num_pin) != 0) {
|
||||
return GPIO_SHORT_HOLD;
|
||||
}
|
||||
} while (delay_sec > ((esp_log_early_timestamp() - tm_start) / 1000L));
|
||||
return GPIO_LONG_HOLD;
|
||||
}
|
||||
|
||||
// Search for a label in the list. list = "nvs1, nvs2, otadata, nvs"; label = "nvs".
|
||||
bool bootloader_common_label_search(const char *list, char *label)
|
||||
{
|
||||
if (list == NULL || label == NULL) {
|
||||
return false;
|
||||
}
|
||||
const char *sub_list_start_like_label = strstr(list, label);
|
||||
while (sub_list_start_like_label != NULL) {
|
||||
|
||||
// ["," or " "] + label + ["," or " " or "\0"]
|
||||
// first character before the label found there must be a delimiter ["," or " "].
|
||||
int idx_first = sub_list_start_like_label - list;
|
||||
if (idx_first == 0 || (idx_first != 0 && (list[idx_first - 1] == ',' || list[idx_first - 1] == ' '))) {
|
||||
// next character after the label found there must be a delimiter ["," or " " or "\0"].
|
||||
int len_label = strlen(label);
|
||||
if (sub_list_start_like_label[len_label] == 0 ||
|
||||
sub_list_start_like_label[len_label] == ',' ||
|
||||
sub_list_start_like_label[len_label] == ' ') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// [start_delim] + label + [end_delim] was not found.
|
||||
// Position is moving to next delimiter if it is not the end of list.
|
||||
int pos_delim = strcspn(sub_list_start_like_label, ", ");
|
||||
if (pos_delim == strlen(sub_list_start_like_label)) {
|
||||
break;
|
||||
}
|
||||
sub_list_start_like_label = strstr(&sub_list_start_like_label[pos_delim], label);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_data_erase)
|
||||
{
|
||||
const esp_partition_info_t *partitions;
|
||||
const char *marker;
|
||||
esp_err_t err;
|
||||
int num_partitions;
|
||||
bool ret = true;
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if (esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "Verifying partition table signature...");
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table signature.");
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "Partition table signature verified");
|
||||
}
|
||||
#endif
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
|
||||
|
||||
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table");
|
||||
ret = false;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "## Label Usage Offset Length Cleaned");
|
||||
for (int i = 0; i < num_partitions; i++) {
|
||||
const esp_partition_info_t *partition = &partitions[i];
|
||||
char label[sizeof(partition->label) + 1] = {0};
|
||||
if (partition->type == PART_TYPE_DATA) {
|
||||
bool fl_ota_data_erase = false;
|
||||
if (ota_data_erase == true && partition->subtype == PART_SUBTYPE_DATA_OTA) {
|
||||
fl_ota_data_erase = true;
|
||||
}
|
||||
// partition->label is not null-terminated string.
|
||||
strncpy(label, (char *)&partition->label, sizeof(partition->label));
|
||||
if (fl_ota_data_erase == true || (bootloader_common_label_search(list_erase, label) == true)) {
|
||||
err = esp_rom_spiflash_erase_area(partition->pos.offset, partition->pos.size);
|
||||
if (err != ESP_OK) {
|
||||
ret = false;
|
||||
marker = "err";
|
||||
} else {
|
||||
marker = "yes";
|
||||
}
|
||||
} else {
|
||||
marker = "no";
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "%2d %-16s data %08x %08x [%s]", i, partition->label,
|
||||
partition->pos.offset, partition->pos.size, marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bootloader_munmap(partitions);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1,525 +0,0 @@
|
||||
// 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 <string.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "rom/cache.h"
|
||||
#include "rom/efuse.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/crc.h"
|
||||
#include "rom/rtc.h"
|
||||
#include "rom/uart.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "rom/secure_boot.h"
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "soc/gpio_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_clock.h"
|
||||
|
||||
#include "flash_qio_mode.h"
|
||||
|
||||
extern int _bss_start;
|
||||
extern int _bss_end;
|
||||
extern int _data_start;
|
||||
extern int _data_end;
|
||||
|
||||
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 uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
|
||||
|
||||
esp_err_t bootloader_init()
|
||||
{
|
||||
cpu_configure_region_protection();
|
||||
|
||||
/* Sanity check that static RAM is after the stack */
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
int *sp = get_sp();
|
||||
assert(&_bss_start <= &_bss_end);
|
||||
assert(&_data_start <= &_data_end);
|
||||
assert(sp < &_bss_start);
|
||||
assert(sp < &_data_start);
|
||||
}
|
||||
#endif
|
||||
|
||||
//Clear bss
|
||||
memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start));
|
||||
|
||||
/* completely reset MMU for both CPUs
|
||||
(in case serial bootloader was running) */
|
||||
Cache_Read_Disable(0);
|
||||
Cache_Read_Disable(1);
|
||||
Cache_Flush(0);
|
||||
Cache_Flush(1);
|
||||
mmu_init(0);
|
||||
DPORT_REG_SET_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
mmu_init(1);
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
/* (above steps probably unnecessary for most serial bootloader
|
||||
usage, all that's absolutely needed is that we unmask DROM0
|
||||
cache on the following two lines - normal ROM boot exits with
|
||||
DROM0 cache unmasked, but serial bootloader exits with it
|
||||
masked. However can't hurt to be thorough and reset
|
||||
everything.)
|
||||
|
||||
The lines which manipulate DPORT_APP_CACHE_MMU_IA_CLR bit are
|
||||
necessary to work around a hardware bug.
|
||||
*/
|
||||
DPORT_REG_CLR_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MASK_DROM0);
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MASK_DROM0);
|
||||
|
||||
if(bootloader_main() != ESP_OK){
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t bootloader_main()
|
||||
{
|
||||
vddsdio_configure();
|
||||
/* Read and keep flash ID, for further use. */
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
esp_image_header_t fhdr;
|
||||
if (bootloader_flash_read(ESP_BOOTLOADER_OFFSET, &fhdr, sizeof(esp_image_header_t), true) != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
flash_gpio_configure(&fhdr);
|
||||
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
|
||||
//Check if ESP32 is rated for a CPU frequency of 160MHz only
|
||||
if (REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_RATED) &&
|
||||
REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_LOW)) {
|
||||
ESP_LOGE(TAG, "Chip CPU frequency rated for 160MHz. Modify CPU frequency in menuconfig");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
bootloader_clock_configure();
|
||||
uart_console_configure();
|
||||
wdt_reset_check();
|
||||
ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER);
|
||||
|
||||
ESP_LOGI(TAG, "compile time " __TIME__ );
|
||||
ets_set_appcpu_boot_addr(0);
|
||||
|
||||
/* disable watch dog here */
|
||||
REG_CLR_BIT( RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN );
|
||||
REG_CLR_BIT( TIMG_WDTCONFIG0_REG(0), TIMG_WDT_FLASHBOOT_MOD_EN );
|
||||
|
||||
#ifndef CONFIG_SPI_FLASH_ROM_DRIVER_PATCH
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
if(spiconfig != EFUSE_SPICONFIG_SPI_DEFAULTS && spiconfig != EFUSE_SPICONFIG_HSPI_DEFAULTS) {
|
||||
ESP_LOGE(TAG, "SPI flash pins are overridden. \"Enable SPI flash ROM driver patched functions\" must be enabled in menuconfig");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_rom_spiflash_unlock();
|
||||
|
||||
ESP_LOGI(TAG, "Enabling RNG early entropy source...");
|
||||
bootloader_random_enable();
|
||||
|
||||
#if CONFIG_FLASHMODE_QIO || CONFIG_FLASHMODE_QOUT
|
||||
bootloader_enable_qio_mode();
|
||||
#endif
|
||||
|
||||
print_flash_info(&fhdr);
|
||||
|
||||
update_flash_config(&fhdr);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void update_flash_config(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
uint32_t size;
|
||||
switch(pfhdr->spi_size) {
|
||||
case ESP_IMAGE_FLASH_SIZE_1MB:
|
||||
size = 1;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_2MB:
|
||||
size = 2;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_4MB:
|
||||
size = 4;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_8MB:
|
||||
size = 8;
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_16MB:
|
||||
size = 16;
|
||||
break;
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
Cache_Read_Disable( 0 );
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(g_rom_flashchip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
// TODO: set mode
|
||||
// TODO: set frequency
|
||||
Cache_Flush(0);
|
||||
Cache_Read_Enable( 0 );
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t* phdr)
|
||||
{
|
||||
#if (BOOT_LOG_LEVEL >= BOOT_LOG_LEVEL_NOTICE)
|
||||
|
||||
ESP_LOGD(TAG, "magic %02x", phdr->magic );
|
||||
ESP_LOGD(TAG, "segments %02x", phdr->segment_count );
|
||||
ESP_LOGD(TAG, "spi_mode %02x", phdr->spi_mode );
|
||||
ESP_LOGD(TAG, "spi_speed %02x", phdr->spi_speed );
|
||||
ESP_LOGD(TAG, "spi_size %02x", phdr->spi_size );
|
||||
|
||||
const char* str;
|
||||
switch ( phdr->spi_speed ) {
|
||||
case ESP_IMAGE_SPI_SPEED_40M:
|
||||
str = "40MHz";
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_26M:
|
||||
str = "26.7MHz";
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_20M:
|
||||
str = "20MHz";
|
||||
break;
|
||||
case ESP_IMAGE_SPI_SPEED_80M:
|
||||
str = "80MHz";
|
||||
break;
|
||||
default:
|
||||
str = "20MHz";
|
||||
break;
|
||||
}
|
||||
ESP_LOGI(TAG, "SPI Speed : %s", str );
|
||||
|
||||
/* SPI mode could have been set to QIO during boot already,
|
||||
so test the SPI registers not the flash header */
|
||||
uint32_t spi_ctrl = REG_READ(SPI_CTRL_REG(0));
|
||||
if (spi_ctrl & SPI_FREAD_QIO) {
|
||||
str = "QIO";
|
||||
} else if (spi_ctrl & SPI_FREAD_QUAD) {
|
||||
str = "QOUT";
|
||||
} else if (spi_ctrl & SPI_FREAD_DIO) {
|
||||
str = "DIO";
|
||||
} else if (spi_ctrl & SPI_FREAD_DUAL) {
|
||||
str = "DOUT";
|
||||
} else if (spi_ctrl & SPI_FASTRD_MODE) {
|
||||
str = "FAST READ";
|
||||
} else {
|
||||
str = "SLOW READ";
|
||||
}
|
||||
ESP_LOGI(TAG, "SPI Mode : %s", str );
|
||||
|
||||
switch ( phdr->spi_size ) {
|
||||
case ESP_IMAGE_FLASH_SIZE_1MB:
|
||||
str = "1MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_2MB:
|
||||
str = "2MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_4MB:
|
||||
str = "4MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_8MB:
|
||||
str = "8MB";
|
||||
break;
|
||||
case ESP_IMAGE_FLASH_SIZE_16MB:
|
||||
str = "16MB";
|
||||
break;
|
||||
default:
|
||||
str = "2MB";
|
||||
break;
|
||||
}
|
||||
ESP_LOGI(TAG, "SPI Flash Size : %s", str );
|
||||
#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)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void uart_console_configure(void)
|
||||
{
|
||||
#if CONFIG_CONSOLE_UART_NONE
|
||||
ets_install_putc1(NULL);
|
||||
ets_install_putc2(NULL);
|
||||
#else // CONFIG_CONSOLE_UART_NONE
|
||||
const int uart_num = CONFIG_CONSOLE_UART_NUM;
|
||||
|
||||
uartAttach();
|
||||
ets_install_uart_printf();
|
||||
|
||||
// Wait for UART FIFO to be empty.
|
||||
uart_tx_wait_idle(0);
|
||||
|
||||
#if CONFIG_CONSOLE_UART_CUSTOM
|
||||
// Some constants to make the following code less upper-case
|
||||
const int uart_tx_gpio = CONFIG_CONSOLE_UART_TX_GPIO;
|
||||
const int uart_rx_gpio = CONFIG_CONSOLE_UART_RX_GPIO;
|
||||
// Switch to the new UART (this just changes UART number used for
|
||||
// ets_printf in ROM code).
|
||||
uart_tx_switch(uart_num);
|
||||
// If console is attached to UART1 or if non-default pins are used,
|
||||
// need to reconfigure pins using GPIO matrix
|
||||
if (uart_num != 0 || uart_tx_gpio != 1 || uart_rx_gpio != 3) {
|
||||
// Change pin mode for GPIO1/3 from UART to GPIO
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_GPIO3);
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_GPIO1);
|
||||
// Route GPIO signals to/from pins
|
||||
// (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 tx_idx = tx_idx_list[uart_num];
|
||||
const uint32_t rx_idx = rx_idx_list[uart_num];
|
||||
gpio_matrix_out(uart_tx_gpio, tx_idx, 0, 0);
|
||||
gpio_matrix_in(uart_rx_gpio, rx_idx, 0);
|
||||
}
|
||||
#endif // CONFIG_CONSOLE_UART_CUSTOM
|
||||
|
||||
// Set configured UART console baud rate
|
||||
const int uart_baud = CONFIG_CONSOLE_UART_BAUDRATE;
|
||||
uart_div_modify(uart_num, (rtc_clk_apb_freq_get() << 4) / uart_baud);
|
||||
|
||||
#endif // CONFIG_CONSOLE_UART_NONE
|
||||
}
|
||||
|
||||
static void wdt_reset_cpu0_info_enable(void)
|
||||
{
|
||||
//We do not reset core1 info here because it didn't work before cpu1 was up. So we put it into call_start_cpu1.
|
||||
DPORT_REG_SET_BIT(DPORT_PRO_CPU_RECORD_CTRL_REG, DPORT_PRO_CPU_PDEBUG_ENABLE | DPORT_PRO_CPU_RECORD_ENABLE);
|
||||
DPORT_REG_CLR_BIT(DPORT_PRO_CPU_RECORD_CTRL_REG, DPORT_PRO_CPU_RECORD_ENABLE);
|
||||
}
|
||||
|
||||
static void wdt_reset_info_dump(int cpu)
|
||||
{
|
||||
uint32_t inst = 0, pid = 0, stat = 0, data = 0, pc = 0,
|
||||
lsstat = 0, lsaddr = 0, lsdata = 0, dstat = 0;
|
||||
const char *cpu_name = cpu ? "APP" : "PRO";
|
||||
|
||||
if (cpu == 0) {
|
||||
stat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_STATUS_REG);
|
||||
pid = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PID_REG);
|
||||
inst = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGINST_REG);
|
||||
dstat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGSTATUS_REG);
|
||||
data = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGDATA_REG);
|
||||
pc = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGPC_REG);
|
||||
lsstat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGLS0STAT_REG);
|
||||
lsaddr = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGLS0ADDR_REG);
|
||||
lsdata = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_PDEBUGLS0DATA_REG);
|
||||
|
||||
} else {
|
||||
stat = DPORT_REG_READ(DPORT_APP_CPU_RECORD_STATUS_REG);
|
||||
pid = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PID_REG);
|
||||
inst = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGINST_REG);
|
||||
dstat = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGSTATUS_REG);
|
||||
data = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGDATA_REG);
|
||||
pc = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGPC_REG);
|
||||
lsstat = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGLS0STAT_REG);
|
||||
lsaddr = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGLS0ADDR_REG);
|
||||
lsdata = DPORT_REG_READ(DPORT_APP_CPU_RECORD_PDEBUGLS0DATA_REG);
|
||||
}
|
||||
if (DPORT_RECORD_PDEBUGINST_SZ(inst) == 0 &&
|
||||
DPORT_RECORD_PDEBUGSTATUS_BBCAUSE(dstat) == DPORT_RECORD_PDEBUGSTATUS_BBCAUSE_WAITI) {
|
||||
ESP_LOGW(TAG, "WDT reset info: %s CPU PC=0x%x (waiti mode)", cpu_name, pc);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "WDT reset info: %s CPU PC=0x%x", cpu_name, pc);
|
||||
}
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU STATUS 0x%08x", cpu_name, stat);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PID 0x%08x", cpu_name, pid);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGINST 0x%08x", cpu_name, inst);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGSTATUS 0x%08x", cpu_name, dstat);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGDATA 0x%08x", cpu_name, data);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGPC 0x%08x", cpu_name, pc);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0STAT 0x%08x", cpu_name, lsstat);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0ADDR 0x%08x", cpu_name, lsaddr);
|
||||
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0DATA 0x%08x", cpu_name, lsdata);
|
||||
}
|
||||
|
||||
static void wdt_reset_check(void)
|
||||
{
|
||||
int wdt_rst = 0;
|
||||
RESET_REASON rst_reas[2];
|
||||
|
||||
rst_reas[0] = rtc_get_reset_reason(0);
|
||||
rst_reas[1] = rtc_get_reset_reason(1);
|
||||
if (rst_reas[0] == RTCWDT_SYS_RESET || rst_reas[0] == TG0WDT_SYS_RESET || rst_reas[0] == TG1WDT_SYS_RESET ||
|
||||
rst_reas[0] == TGWDT_CPU_RESET || rst_reas[0] == RTCWDT_CPU_RESET) {
|
||||
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
|
||||
wdt_rst = 1;
|
||||
}
|
||||
if (rst_reas[1] == RTCWDT_SYS_RESET || rst_reas[1] == TG0WDT_SYS_RESET || rst_reas[1] == TG1WDT_SYS_RESET ||
|
||||
rst_reas[1] == TGWDT_CPU_RESET || rst_reas[1] == RTCWDT_CPU_RESET) {
|
||||
ESP_LOGW(TAG, "APP CPU has been reset by WDT.");
|
||||
wdt_rst = 1;
|
||||
}
|
||||
if (wdt_rst) {
|
||||
// if reset by WDT dump info from trace port
|
||||
wdt_reset_info_dump(0);
|
||||
wdt_reset_info_dump(1);
|
||||
}
|
||||
wdt_reset_cpu0_info_enable();
|
||||
}
|
||||
|
||||
void __assert_func(const char *file, int line, const char *func, const char *expr)
|
||||
{
|
||||
ESP_LOGE(TAG, "Assert failed in %s, %s:%d (%s)", func, file, line, expr);
|
||||
while(1) {}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
return NULL;
|
||||
}
|
||||
mbedtls_sha256_init(ctx);
|
||||
assert(mbedtls_sha256_starts_ret(ctx, false) == 0);
|
||||
mbedtls_sha256_starts(ctx, false);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
|
||||
{
|
||||
assert(handle != NULL);
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
|
||||
assert(mbedtls_sha256_update_ret(ctx, data, data_len) == 0);
|
||||
mbedtls_sha256_update(ctx, data, data_len);
|
||||
}
|
||||
|
||||
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
|
||||
@@ -44,7 +44,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
|
||||
assert(handle != NULL);
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
|
||||
if (digest != NULL) {
|
||||
assert(mbedtls_sha256_finish_ret(ctx, digest) == 0);
|
||||
mbedtls_sha256_finish(ctx, digest);
|
||||
}
|
||||
mbedtls_sha256_free(ctx);
|
||||
free(handle);
|
||||
|
||||
@@ -1,476 +0,0 @@
|
||||
// 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 <string.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "rom/cache.h"
|
||||
#include "rom/efuse.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/crc.h"
|
||||
#include "rom/rtc.h"
|
||||
#include "rom/uart.h"
|
||||
#include "rom/gpio.h"
|
||||
#include "rom/secure_boot.h"
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "soc/gpio_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
static const char* TAG = "boot";
|
||||
|
||||
/* Reduce literal size for some generic string literals */
|
||||
#define MAP_ERR_MSG "Image contains multiple %s segments. Only the last one will be mapped."
|
||||
|
||||
static void load_image(const esp_image_metadata_t* image_data);
|
||||
static void unpack_load_app(const esp_image_metadata_t *data);
|
||||
static void set_cache_and_start_app(uint32_t drom_addr,
|
||||
uint32_t drom_load_addr,
|
||||
uint32_t drom_size,
|
||||
uint32_t irom_addr,
|
||||
uint32_t irom_load_addr,
|
||||
uint32_t irom_size,
|
||||
uint32_t entry_addr);
|
||||
|
||||
bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
{
|
||||
const esp_partition_info_t *partitions;
|
||||
const char *partition_usage;
|
||||
esp_err_t err;
|
||||
int num_partitions;
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if(esp_secure_boot_enabled()) {
|
||||
ESP_LOGI(TAG, "Verifying partition table signature...");
|
||||
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table signature.");
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "Partition table signature verified");
|
||||
}
|
||||
#endif
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
|
||||
|
||||
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to verify partition table");
|
||||
return false;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Partition Table:");
|
||||
ESP_LOGI(TAG, "## Label Usage Type ST Offset Length");
|
||||
|
||||
for(int i = 0; i < num_partitions; i++) {
|
||||
const esp_partition_info_t *partition = &partitions[i];
|
||||
ESP_LOGD(TAG, "load partition table entry 0x%x", (intptr_t)partition);
|
||||
ESP_LOGD(TAG, "type=%x subtype=%x", partition->type, partition->subtype);
|
||||
partition_usage = "unknown";
|
||||
|
||||
/* valid partition table */
|
||||
switch(partition->type) {
|
||||
case PART_TYPE_APP: /* app partition */
|
||||
switch(partition->subtype) {
|
||||
case PART_SUBTYPE_FACTORY: /* factory binary */
|
||||
bs->factory = partition->pos;
|
||||
partition_usage = "factory app";
|
||||
break;
|
||||
case PART_SUBTYPE_TEST: /* test binary */
|
||||
bs->test = partition->pos;
|
||||
partition_usage = "test app";
|
||||
break;
|
||||
default:
|
||||
/* OTA binary */
|
||||
if ((partition->subtype & ~PART_SUBTYPE_OTA_MASK) == PART_SUBTYPE_OTA_FLAG) {
|
||||
bs->ota[partition->subtype & PART_SUBTYPE_OTA_MASK] = partition->pos;
|
||||
++bs->app_count;
|
||||
partition_usage = "OTA app";
|
||||
}
|
||||
else {
|
||||
partition_usage = "Unknown app";
|
||||
}
|
||||
break;
|
||||
}
|
||||
break; /* PART_TYPE_APP */
|
||||
case PART_TYPE_DATA: /* data partition */
|
||||
switch(partition->subtype) {
|
||||
case PART_SUBTYPE_DATA_OTA: /* ota data */
|
||||
bs->ota_info = partition->pos;
|
||||
partition_usage = "OTA data";
|
||||
break;
|
||||
case PART_SUBTYPE_DATA_RF:
|
||||
partition_usage = "RF data";
|
||||
break;
|
||||
case PART_SUBTYPE_DATA_WIFI:
|
||||
partition_usage = "WiFi data";
|
||||
break;
|
||||
default:
|
||||
partition_usage = "Unknown data";
|
||||
break;
|
||||
}
|
||||
break; /* PARTITION_USAGE_DATA */
|
||||
default: /* other partition type */
|
||||
break;
|
||||
}
|
||||
|
||||
/* print partition type info */
|
||||
ESP_LOGI(TAG, "%2d %-16s %-16s %02x %02x %08x %08x", i, partition->label, partition_usage,
|
||||
partition->type, partition->subtype,
|
||||
partition->pos.offset, partition->pos.size);
|
||||
}
|
||||
|
||||
bootloader_munmap(partitions);
|
||||
|
||||
ESP_LOGI(TAG,"End of partition table");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Given a partition index, return the partition position data from the bootloader_state_t structure */
|
||||
static esp_partition_pos_t index_to_partition(const bootloader_state_t *bs, int index)
|
||||
{
|
||||
if (index == FACTORY_INDEX) {
|
||||
return bs->factory;
|
||||
}
|
||||
|
||||
if (index == TEST_APP_INDEX) {
|
||||
return bs->test;
|
||||
}
|
||||
|
||||
if (index >= 0 && index < MAX_OTA_SLOTS && index < bs->app_count) {
|
||||
return bs->ota[index];
|
||||
}
|
||||
|
||||
esp_partition_pos_t invalid = { 0 };
|
||||
return invalid;
|
||||
}
|
||||
|
||||
static void log_invalid_app_partition(int index)
|
||||
{
|
||||
const char *not_bootable = " is not bootable"; /* save a few string literal bytes */
|
||||
switch(index) {
|
||||
case FACTORY_INDEX:
|
||||
ESP_LOGE(TAG, "Factory app partition%s", not_bootable);
|
||||
break;
|
||||
case TEST_APP_INDEX:
|
||||
ESP_LOGE(TAG, "Factory test app partition%s", not_bootable);
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "OTA app partition slot %d%s", index, not_bootable);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs)
|
||||
{
|
||||
esp_ota_select_entry_t sa,sb;
|
||||
const esp_ota_select_entry_t *ota_select_map;
|
||||
|
||||
if (bs->ota_info.offset != 0) {
|
||||
// partition table has OTA data partition
|
||||
if (bs->ota_info.size < 2 * SPI_SEC_SIZE) {
|
||||
ESP_LOGE(TAG, "ota_info partition size %d is too small (minimum %d bytes)", bs->ota_info.size, sizeof(esp_ota_select_entry_t));
|
||||
return INVALID_INDEX; // can't proceed
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "OTA data offset 0x%x", bs->ota_info.offset);
|
||||
ota_select_map = bootloader_mmap(bs->ota_info.offset, bs->ota_info.size);
|
||||
if (!ota_select_map) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", bs->ota_info.offset, bs->ota_info.size);
|
||||
return INVALID_INDEX; // can't proceed
|
||||
}
|
||||
memcpy(&sa, ota_select_map, sizeof(esp_ota_select_entry_t));
|
||||
memcpy(&sb, (uint8_t *)ota_select_map + SPI_SEC_SIZE, sizeof(esp_ota_select_entry_t));
|
||||
bootloader_munmap(ota_select_map);
|
||||
|
||||
ESP_LOGD(TAG, "OTA sequence values A 0x%08x B 0x%08x", sa.ota_seq, sb.ota_seq);
|
||||
if(sa.ota_seq == UINT32_MAX && sb.ota_seq == UINT32_MAX) {
|
||||
ESP_LOGD(TAG, "OTA sequence numbers both empty (all-0xFF)");
|
||||
if (bs->factory.offset != 0) {
|
||||
ESP_LOGI(TAG, "Defaulting to factory image");
|
||||
return FACTORY_INDEX;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "No factory image, trying OTA 0");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
bool ota_valid = false;
|
||||
const char *ota_msg;
|
||||
int ota_seq; // Raw OTA sequence number. May be more than # of OTA slots
|
||||
if(bootloader_common_ota_select_valid(&sa) && bootloader_common_ota_select_valid(&sb)) {
|
||||
ota_valid = true;
|
||||
ota_msg = "Both OTA values";
|
||||
ota_seq = MAX(sa.ota_seq, sb.ota_seq) - 1;
|
||||
} else if(bootloader_common_ota_select_valid(&sa)) {
|
||||
ota_valid = true;
|
||||
ota_msg = "Only OTA sequence A is";
|
||||
ota_seq = sa.ota_seq - 1;
|
||||
} else if(bootloader_common_ota_select_valid(&sb)) {
|
||||
ota_valid = true;
|
||||
ota_msg = "Only OTA sequence B is";
|
||||
ota_seq = sb.ota_seq - 1;
|
||||
}
|
||||
|
||||
if (ota_valid) {
|
||||
int ota_slot = ota_seq % bs->app_count; // Actual OTA partition selection
|
||||
ESP_LOGD(TAG, "%s valid. Mapping seq %d -> OTA slot %d", ota_msg, ota_seq, ota_slot);
|
||||
return ota_slot;
|
||||
} else if (bs->factory.offset != 0) {
|
||||
ESP_LOGE(TAG, "ota data partition invalid, falling back to factory");
|
||||
return FACTORY_INDEX;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "ota data partition invalid and no factory, will try all partitions");
|
||||
return FACTORY_INDEX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise, start from factory app partition and let the search logic
|
||||
// proceed from there
|
||||
return FACTORY_INDEX;
|
||||
}
|
||||
|
||||
/* Return true if a partition has a valid app image that was successfully loaded */
|
||||
static bool try_load_partition(const esp_partition_pos_t *partition, esp_image_metadata_t *data)
|
||||
{
|
||||
if (partition->size == 0) {
|
||||
ESP_LOGD(TAG, "Can't boot from zero-length partition");
|
||||
return false;
|
||||
}
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
if (esp_image_load(ESP_IMAGE_LOAD, partition, data) == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Loaded app from partition at offset 0x%x",
|
||||
partition->offset);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#define TRY_LOG_FORMAT "Trying partition index %d offs 0x%x size 0x%x"
|
||||
|
||||
void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index)
|
||||
{
|
||||
int index = start_index;
|
||||
esp_partition_pos_t part;
|
||||
esp_image_metadata_t image_data;
|
||||
|
||||
if(start_index == TEST_APP_INDEX) {
|
||||
if (try_load_partition(&bs->test, &image_data)) {
|
||||
load_image(&image_data);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "No bootable test partition in the partition table");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* work backwards from start_index, down to the factory app */
|
||||
for(index = start_index; index >= FACTORY_INDEX; index--) {
|
||||
part = index_to_partition(bs, index);
|
||||
if (part.size == 0) {
|
||||
continue;
|
||||
}
|
||||
ESP_LOGD(TAG, TRY_LOG_FORMAT, index, part.offset, part.size);
|
||||
if (try_load_partition(&part, &image_data)) {
|
||||
load_image(&image_data);
|
||||
}
|
||||
log_invalid_app_partition(index);
|
||||
}
|
||||
|
||||
/* failing that work forwards from start_index, try valid OTA slots */
|
||||
for(index = start_index + 1; index < bs->app_count; index++) {
|
||||
part = index_to_partition(bs, index);
|
||||
if (part.size == 0) {
|
||||
continue;
|
||||
}
|
||||
ESP_LOGD(TAG, TRY_LOG_FORMAT, index, part.offset, part.size);
|
||||
if (try_load_partition(&part, &image_data)) {
|
||||
load_image(&image_data);
|
||||
}
|
||||
log_invalid_app_partition(index);
|
||||
}
|
||||
|
||||
if (try_load_partition(&bs->test, &image_data)) {
|
||||
ESP_LOGW(TAG, "Falling back to test app as only bootable partition");
|
||||
load_image(&image_data);
|
||||
}
|
||||
|
||||
ESP_LOGE(TAG, "No bootable app partitions in the partition table");
|
||||
bzero(&image_data, sizeof(esp_image_metadata_t));
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
#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();
|
||||
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...
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_ENABLED
|
||||
/* encrypt flash */
|
||||
ESP_LOGI(TAG, "Checking flash encryption...");
|
||||
bool flash_encryption_enabled = esp_flash_encryption_enabled();
|
||||
err = esp_flash_encrypt_check_and_update();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Flash encryption check failed (%d).", err);
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
cache resets properly */
|
||||
ESP_LOGI(TAG, "Resetting with flash encryption enabled...");
|
||||
REG_WRITE(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Disabling RNG early entropy source...");
|
||||
bootloader_random_disable();
|
||||
|
||||
// copy loaded segments to RAM, set up caches for mapped segments, and start application
|
||||
unpack_load_app(image_data);
|
||||
}
|
||||
|
||||
static void unpack_load_app(const esp_image_metadata_t* data)
|
||||
{
|
||||
uint32_t drom_addr = 0;
|
||||
uint32_t drom_load_addr = 0;
|
||||
uint32_t drom_size = 0;
|
||||
uint32_t irom_addr = 0;
|
||||
uint32_t irom_load_addr = 0;
|
||||
uint32_t irom_size = 0;
|
||||
|
||||
// Find DROM & IROM addresses, to configure cache mappings
|
||||
for (int i = 0; i < data->image.segment_count; i++) {
|
||||
const esp_image_segment_header_t *header = &data->segments[i];
|
||||
if (header->load_addr >= SOC_IROM_LOW && header->load_addr < SOC_IROM_HIGH) {
|
||||
if (drom_addr != 0) {
|
||||
ESP_LOGE(TAG, MAP_ERR_MSG, "DROM");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Mapping segment %d as %s", i, "DROM");
|
||||
}
|
||||
drom_addr = data->segment_data[i];
|
||||
drom_load_addr = header->load_addr;
|
||||
drom_size = header->data_len;
|
||||
}
|
||||
if (header->load_addr >= SOC_DROM_LOW && header->load_addr < SOC_DROM_HIGH) {
|
||||
if (irom_addr != 0) {
|
||||
ESP_LOGE(TAG, MAP_ERR_MSG, "IROM");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Mapping segment %d as %s", i, "IROM");
|
||||
}
|
||||
irom_addr = data->segment_data[i];
|
||||
irom_load_addr = header->load_addr;
|
||||
irom_size = header->data_len;
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "calling set_cache_and_start_app");
|
||||
set_cache_and_start_app(drom_addr,
|
||||
drom_load_addr,
|
||||
drom_size,
|
||||
irom_addr,
|
||||
irom_load_addr,
|
||||
irom_size,
|
||||
data->image.entry_addr);
|
||||
}
|
||||
|
||||
static void set_cache_and_start_app(
|
||||
uint32_t drom_addr,
|
||||
uint32_t drom_load_addr,
|
||||
uint32_t drom_size,
|
||||
uint32_t irom_addr,
|
||||
uint32_t irom_load_addr,
|
||||
uint32_t irom_size,
|
||||
uint32_t entry_addr)
|
||||
{
|
||||
ESP_LOGD(TAG, "configure drom and irom and start");
|
||||
Cache_Read_Disable( 0 );
|
||||
Cache_Flush( 0 );
|
||||
|
||||
/* Clear the MMU entries that are already set up,
|
||||
so the new app only has the mappings it creates.
|
||||
*/
|
||||
for (int i = 0; i < DPORT_FLASH_MMU_TABLE_SIZE; i++) {
|
||||
DPORT_PRO_FLASH_MMU_TABLE[i] = DPORT_FLASH_MMU_TABLE_INVALID_VAL;
|
||||
}
|
||||
|
||||
uint32_t drom_page_count = (drom_size + 64*1024 - 1) / (64*1024); // round up to 64k
|
||||
ESP_LOGV(TAG, "d mmu set paddr=%08x vaddr=%08x size=%d n=%d", drom_addr & 0xffff0000, drom_load_addr & 0xffff0000, drom_size, drom_page_count );
|
||||
int rc = cache_flash_mmu_set( 0, 0, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
rc = cache_flash_mmu_set( 1, 0, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
uint32_t irom_page_count = (irom_size + 64*1024 - 1) / (64*1024); // round up to 64k
|
||||
ESP_LOGV(TAG, "i mmu set paddr=%08x vaddr=%08x size=%d n=%d", irom_addr & 0xffff0000, irom_load_addr & 0xffff0000, irom_size, irom_page_count );
|
||||
rc = cache_flash_mmu_set( 0, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
rc = cache_flash_mmu_set( 1, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG, (DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) | (DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 | DPORT_PRO_CACHE_MASK_DRAM1 );
|
||||
DPORT_REG_CLR_BIT( DPORT_APP_CACHE_CTRL1_REG, (DPORT_APP_CACHE_MASK_IRAM0) | (DPORT_APP_CACHE_MASK_IRAM1 & 0) | (DPORT_APP_CACHE_MASK_IROM0 & 0) | DPORT_APP_CACHE_MASK_DROM0 | DPORT_APP_CACHE_MASK_DRAM1 );
|
||||
Cache_Read_Enable( 0 );
|
||||
|
||||
// Application will need to do Cache_Flush(1) and Cache_Read_Enable(1)
|
||||
|
||||
ESP_LOGD(TAG, "start: 0x%08x", entry_addr);
|
||||
typedef void (*entry_t)(void) __attribute__((noreturn));
|
||||
entry_t entry = ((entry_t) entry_addr);
|
||||
|
||||
// TODO: we have used quite a bit of stack at this point.
|
||||
// use "movsp" instruction to reset stack back to where ROM stack starts.
|
||||
(*entry)();
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
static const char *TAG = "esp_image";
|
||||
|
||||
#define HASH_LEN 32 /* SHA-256 digest length */
|
||||
#define HASH_LEN ESP_IMAGE_HASH_LEN
|
||||
|
||||
#define SIXTEEN_MB 0x1000000
|
||||
#define ESP_ROM_CHECKSUM_INITIAL 0xEF
|
||||
@@ -157,12 +157,11 @@ goto err;
|
||||
|
||||
data->image_len = end_addr - data->start_addr;
|
||||
ESP_LOGV(TAG, "image start 0x%08x end of last section 0x%08x", data->start_addr, end_addr);
|
||||
if (!esp_cpu_in_ocd_debug_mode()) {
|
||||
err = verify_checksum(sha_handle, checksum_word, data);
|
||||
if (err != ESP_OK) {
|
||||
goto err;
|
||||
}
|
||||
err = verify_checksum(sha_handle, checksum_word, data);
|
||||
if (err != ESP_OK) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (data->image_len > part->size) {
|
||||
FAIL_LOAD("Image length %d doesn't fit in partition length %d", data->image_len, part->size);
|
||||
}
|
||||
@@ -179,7 +178,7 @@ goto err;
|
||||
err = verify_secure_boot_signature(sha_handle, data);
|
||||
#else
|
||||
// No secure boot, but SHA-256 can be appended for basic corruption detection
|
||||
if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) {
|
||||
if (sha_handle != NULL) {
|
||||
err = verify_simple_hash(sha_handle, data);
|
||||
}
|
||||
#endif // CONFIG_SECURE_BOOT_ENABLED
|
||||
@@ -442,19 +441,28 @@ static bool should_load(uint32_t load_addr)
|
||||
esp_err_t esp_image_verify_bootloader(uint32_t *length)
|
||||
{
|
||||
esp_image_metadata_t data;
|
||||
const esp_partition_pos_t bootloader_part = {
|
||||
.offset = ESP_BOOTLOADER_OFFSET,
|
||||
.size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET,
|
||||
};
|
||||
esp_err_t err = esp_image_load(ESP_IMAGE_VERIFY,
|
||||
&bootloader_part,
|
||||
&data);
|
||||
esp_err_t err = esp_image_verify_bootloader_data(&data);
|
||||
if (length != NULL) {
|
||||
*length = (err == ESP_OK) ? data.image_len : 0;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data)
|
||||
{
|
||||
if (data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
const esp_partition_pos_t bootloader_part = {
|
||||
.offset = ESP_BOOTLOADER_OFFSET,
|
||||
.size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET,
|
||||
};
|
||||
return esp_image_load(ESP_IMAGE_VERIFY,
|
||||
&bootloader_part,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data)
|
||||
{
|
||||
uint32_t unpadded_length = data->image_len;
|
||||
|
||||
@@ -62,6 +62,11 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
|
||||
|
||||
static esp_err_t initialise_flash_encryption(void)
|
||||
{
|
||||
if (REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_CODING_SCHEME_M) {
|
||||
ESP_LOGE(TAG, "Flash Encryption is currently not supported on hardware with 3/4 Coding Scheme (CODING_SCHEME efuse set)");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* Before first flash encryption pass, need to initialise key & crypto config */
|
||||
|
||||
/* Generate key */
|
||||
|
||||
@@ -11,76 +11,50 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <string.h>
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp_log.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/md5_hash.h"
|
||||
#include "esp_flash_data_types.h"
|
||||
|
||||
static const char *TAG = "flash_parts";
|
||||
|
||||
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||
{
|
||||
int md5_found = 0;
|
||||
int num_parts;
|
||||
uint32_t chip_size = g_rom_flashchip.chip_size;
|
||||
*num_partitions = 0;
|
||||
int num_parts;
|
||||
uint32_t chip_size = g_rom_flashchip.chip_size;
|
||||
*num_partitions = 0;
|
||||
|
||||
for (num_parts = 0; num_parts < ESP_PARTITION_TABLE_MAX_ENTRIES; num_parts++) {
|
||||
const esp_partition_info_t *part = &partition_table[num_parts];
|
||||
for(num_parts = 0; num_parts < ESP_PARTITION_TABLE_MAX_ENTRIES; num_parts++) {
|
||||
const esp_partition_info_t *part = &partition_table[num_parts];
|
||||
|
||||
if (part->magic == ESP_PARTITION_MAGIC) {
|
||||
const esp_partition_pos_t *pos = &part->pos;
|
||||
if (pos->offset > chip_size || pos->offset + pos->size > chip_size) {
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "partition %d invalid - offset 0x%x size 0x%x exceeds flash chip size 0x%x",
|
||||
num_parts, pos->offset, pos->size, chip_size);
|
||||
}
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
} else if (part->magic == ESP_PARTITION_MAGIC_MD5) {
|
||||
if (md5_found) {
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "Only one MD5 checksum is allowed");
|
||||
}
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (part->magic == 0xFFFF
|
||||
&& part->type == PART_TYPE_END
|
||||
&& part->subtype == PART_SUBTYPE_END) {
|
||||
/* TODO: check md5 */
|
||||
ESP_LOGD(TAG, "partition table verified, %d entries", num_parts);
|
||||
*num_partitions = num_parts;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
struct MD5Context context;
|
||||
unsigned char digest[16];
|
||||
MD5Init(&context);
|
||||
MD5Update(&context, (unsigned char *) partition_table, num_parts * sizeof(esp_partition_info_t));
|
||||
MD5Final(digest, &context);
|
||||
|
||||
unsigned char *md5sum = ((unsigned char *) part) + 16; // skip the 2B magic number and the 14B fillup bytes
|
||||
|
||||
if (memcmp(md5sum, digest, sizeof(digest)) != 0) {
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "Incorrect MD5 checksum");
|
||||
}
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
//MD5 checksum matches and we continue with the next interation in
|
||||
//order to detect the end of the partition table
|
||||
md5_found = 1;
|
||||
} else if (part->magic == 0xFFFF
|
||||
&& part->type == PART_TYPE_END
|
||||
&& part->subtype == PART_SUBTYPE_END) {
|
||||
ESP_LOGD(TAG, "partition table verified, %d entries", num_parts);
|
||||
*num_partitions = num_parts - md5_found; //do not count the partition where the MD5 checksum is held
|
||||
return ESP_OK;
|
||||
} else {
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "partition %d invalid magic number 0x%x", num_parts, part->magic);
|
||||
}
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
if (part->magic != ESP_PARTITION_MAGIC) {
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "partition %d invalid magic number 0x%x", num_parts, part->magic);
|
||||
}
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "partition table has no terminating entry, not valid");
|
||||
const esp_partition_pos_t *pos = &part->pos;
|
||||
if (pos->offset > chip_size || pos->offset + pos->size > chip_size) {
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "partition %d invalid - offset 0x%x size 0x%x exceeds flash chip size 0x%x",
|
||||
num_parts, pos->offset, pos->size, chip_size);
|
||||
}
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (log_errors) {
|
||||
ESP_LOGE(TAG, "partition table has no terminating entry, not valid");
|
||||
}
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ static bool secure_boot_generate(uint32_t image_len){
|
||||
const uint32_t *image;
|
||||
|
||||
/* hardware secure boot engine only takes full blocks, so round up the
|
||||
image length. The additional data should all be 0xFF.
|
||||
image length. The additional data should all be 0xFF (or the appended SHA, if it falls in the same block).
|
||||
*/
|
||||
if (image_len % sizeof(digest.iv) != 0) {
|
||||
image_len = (image_len / sizeof(digest.iv) + 1) * sizeof(digest.iv);
|
||||
@@ -104,14 +104,20 @@ static inline void burn_efuses()
|
||||
|
||||
esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
esp_err_t err;
|
||||
uint32_t image_len = 0;
|
||||
if (esp_secure_boot_enabled())
|
||||
{
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
err = esp_image_verify_bootloader(&image_len);
|
||||
if (REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_CODING_SCHEME_M) {
|
||||
ESP_LOGE(TAG, "Secure Boot is currently not supported on hardware with 3/4 Coding Scheme (CODING_SCHEME efuse set)");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* Verify the bootloader */
|
||||
esp_image_metadata_t bootloader_data = { 0 };
|
||||
err = esp_image_verify_bootloader_data(&bootloader_data);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "bootloader image appears invalid! error %d", err);
|
||||
return err;
|
||||
@@ -150,6 +156,11 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Generating secure boot digest...");
|
||||
uint32_t image_len = bootloader_data.image_len;
|
||||
if(bootloader_data.image.hash_appended) {
|
||||
/* Secure boot digest doesn't cover the hash */
|
||||
image_len -= ESP_IMAGE_HASH_LEN;
|
||||
}
|
||||
if (false == secure_boot_generate(image_len)){
|
||||
ESP_LOGE(TAG, "secure boot generation failed");
|
||||
return ESP_FAIL;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <esp_types.h>
|
||||
#include <stdio.h>
|
||||
#include "string.h"
|
||||
#include "rom/ets_sys.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -13,7 +12,7 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
#include "esp_partition.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_image_format.h"
|
||||
@@ -48,47 +47,3 @@ TEST_CASE("Verify unit test app image", "[bootloader_support]")
|
||||
TEST_ASSERT_TRUE(data.image_len <= running->size);
|
||||
}
|
||||
|
||||
void check_label_search (int num_test, const char *list, const char *t_label, bool result)
|
||||
{
|
||||
// gen_esp32part.py trims up to 16 characters
|
||||
// and the string may not have a null terminal symbol.
|
||||
// below is cutting as it does the generator.
|
||||
char label[16 + 1] = {0};
|
||||
strncpy(label, t_label, sizeof(label) - 1);
|
||||
|
||||
bool ret = bootloader_common_label_search(list, label);
|
||||
if (ret != result) {
|
||||
printf("%d) %s | %s \n", num_test, list, label);
|
||||
}
|
||||
TEST_ASSERT_MESSAGE(ret == result, "Test failed");
|
||||
}
|
||||
|
||||
TEST_CASE("Test label_search", "[bootloader_support]")
|
||||
{
|
||||
TEST_ASSERT_FALSE(bootloader_common_label_search(NULL, NULL));
|
||||
TEST_ASSERT_FALSE(bootloader_common_label_search("nvs", NULL));
|
||||
|
||||
check_label_search(1, "nvs", "nvs", true);
|
||||
check_label_search(2, "nvs, ", "nvs", true);
|
||||
check_label_search(3, "nvs1", "nvs", false);
|
||||
check_label_search(3, "nvs1, ", "nvs", false);
|
||||
check_label_search(4, "nvs1nvs1, phy", "nvs1", false);
|
||||
check_label_search(5, "nvs1, nvs1, phy", "nvs1", true);
|
||||
check_label_search(6, "nvs12, nvs12, phy", "nvs1", false);
|
||||
check_label_search(7, "nvs12, nvs1, phy", "nvs1", true);
|
||||
check_label_search(8, "nvs12, nvs3, phy, nvs1","nvs1", true);
|
||||
check_label_search(9, "nvs1nvs1, phy, nvs", "nvs", true);
|
||||
check_label_search(10, "nvs1nvs1, phy, nvs1", "nvs", false);
|
||||
check_label_search(11, "nvs1, nvs, phy, nvs1", "nvs", true);
|
||||
check_label_search(12, "nvs1, nvs2, phy, nvs","nvs", true);
|
||||
check_label_search(13, "ota_data, backup_nvs", "nvs", false);
|
||||
check_label_search(14, "nvs1, nvs2, ota, nvs", "vs1", false);
|
||||
|
||||
check_label_search(20, "12345678901234, phy, nvs1", "12345678901234", true);
|
||||
check_label_search(21, "123456789012345, phy, nvs1", "123456789012345", true);
|
||||
check_label_search(22, "1234567890123456, phy, nvs1", "1234567890123456", true);
|
||||
check_label_search(23, "12345678901234567, phy, nvs1", "12345678901234567", false);
|
||||
check_label_search(24, "1234567890123456, phy, nvs1", "12345678901234567", true);
|
||||
check_label_search(25, "phy, 1234567890123456, nvs1", "12345678901234567", true);
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ choice BTDM_CONTROLLER_HCI_MODE_CHOICE
|
||||
|
||||
config BTDM_CONTROLLER_HCI_MODE_VHCI
|
||||
bool "VHCI"
|
||||
help
|
||||
help
|
||||
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32, too.
|
||||
|
||||
config BTDM_CONTROLLER_HCI_MODE_UART_H4
|
||||
@@ -64,48 +64,6 @@ config BT_HCI_UART_BAUDRATE
|
||||
UART Baudrate for HCI. Please use standard baudrate.
|
||||
endmenu
|
||||
|
||||
menu "MODEM SLEEP Options"
|
||||
visible if BT_ENABLED
|
||||
|
||||
config BTDM_CONTROLLER_MODEM_SLEEP
|
||||
bool "Bluetooth modem sleep"
|
||||
depends on BT_ENABLED
|
||||
default n
|
||||
help
|
||||
Enable/disable bluetooth controller low power mode.
|
||||
Note that currently there is problem in the combination use of bluetooth modem sleep and Dynamic Frequency Scaling(DFS). So do not enable DFS if bluetooth modem sleep is in use.
|
||||
|
||||
choice BTDM_MODEM_SLEEP_MODE
|
||||
prompt "Bluetooth Modem sleep mode"
|
||||
depends on BTDM_CONTROLLER_MODEM_SLEEP
|
||||
help
|
||||
To select which strategy to use for modem sleep
|
||||
|
||||
config BTDM_MODEM_SLEEP_MODE_ORIG
|
||||
bool "ORIG Mode(sleep with low power clock)"
|
||||
help
|
||||
ORIG mode is a deep sleep mode that can be used for dual mode controller. In this mode, bluetooth controller sleeps between BR/EDR frames and BLE events. A low power clock is used to maintain bluetooth reference clock.
|
||||
config BTDM_MODEM_SLEEP_MODE_EVED
|
||||
bool "EVED Mode "
|
||||
help
|
||||
This mode is for BLE only.
|
||||
endchoice
|
||||
|
||||
choice BTDM_LOW_POWER_CLOCK
|
||||
prompt "Bluetooth low power clock"
|
||||
depends on BTDM_MODEM_SLEEP_MODE_ORIG
|
||||
help
|
||||
Select the low power clock source for bluetooth controller
|
||||
|
||||
config BTDM_LPCLK_SEL_MAIN_XTAL
|
||||
bool "Main crystal"
|
||||
config BTDM_LPCLK_SEL_EXT_32K_XTAL
|
||||
bool "External 32kHz crystal"
|
||||
depends on ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
bool "Bluedroid Enable"
|
||||
depends on BTDM_CONTROLLER_HCI_MODE_VHCI
|
||||
@@ -155,61 +113,17 @@ config CLASSIC_BT_ENABLED
|
||||
help
|
||||
For now this option needs "SMP_ENABLE" to be set to yes
|
||||
|
||||
config A2DP_ENABLE
|
||||
bool "A2DP"
|
||||
depends on CLASSIC_BT_ENABLED
|
||||
default n
|
||||
help
|
||||
Advanced Audio Distrubution Profile
|
||||
|
||||
config A2DP_SINK_TASK_STACK_SIZE
|
||||
int "A2DP sink (audio stream decoding) task stack size"
|
||||
depends on A2DP_ENABLE
|
||||
default 2048
|
||||
|
||||
config A2DP_SOURCE_TASK_STACK_SIZE
|
||||
int "A2DP source (audio stream encoding) task stack size"
|
||||
depends on A2DP_ENABLE
|
||||
default 2048
|
||||
|
||||
config BT_SPP_ENABLED
|
||||
bool "SPP"
|
||||
depends on CLASSIC_BT_ENABLED
|
||||
default n
|
||||
default 2048
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
|
||||
config HFP_ENABLE
|
||||
bool "Hands Free/Handset Profile"
|
||||
depends on CLASSIC_BT_ENABLED
|
||||
default n
|
||||
|
||||
choice HFP_ROLE
|
||||
prompt "Hands-free Profile Role configuration"
|
||||
depends on HFP_ENABLE
|
||||
|
||||
config HFP_CLIENT_ENABLE
|
||||
bool "Hands Free Unit"
|
||||
endchoice
|
||||
|
||||
choice HFP_AUDIO_DATA_PATH
|
||||
prompt "audio(SCO) data path"
|
||||
depends on HFP_ENABLE
|
||||
|
||||
config HFP_AUDIO_DATA_PATH_PCM
|
||||
bool "PCM"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
config HFP_AUDIO_DATA_PATH_HCI
|
||||
bool "HCI"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
endchoice
|
||||
This affects the stack size of A2DP sink task which invokes the data callback function.
|
||||
|
||||
config GATTS_ENABLE
|
||||
bool "Include GATT server module(GATTS)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
default y
|
||||
help
|
||||
This option can be disabled when the app work only on gatt client mode
|
||||
|
||||
@@ -220,13 +134,6 @@ config GATTC_ENABLE
|
||||
help
|
||||
This option can be close when the app work only on gatt server mode
|
||||
|
||||
config GATTC_CACHE_NVS_FLASH
|
||||
bool "Save gattc cache data to nvs flash"
|
||||
depends on GATTC_ENABLE
|
||||
default n
|
||||
help
|
||||
This select can save gattc cache data to nvs flash
|
||||
|
||||
config BLE_SMP_ENABLE
|
||||
bool "Include BLE security module(SMP)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
@@ -235,775 +142,20 @@ config BLE_SMP_ENABLE
|
||||
This option can be close when the app not used the ble security connect.
|
||||
|
||||
config BT_STACK_NO_LOG
|
||||
bool "Disable BT debug logs (minimize bin size)"
|
||||
bool "Close the bluedroid bt stack log print"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
This select can save the rodata code size
|
||||
|
||||
menu "BT DEBUG LOG LEVEL"
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
|
||||
choice HCI_INITIAL_TRACE_LEVEL
|
||||
prompt "HCI layer"
|
||||
default HCI_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for HCI layer
|
||||
|
||||
config HCI_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config HCI_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config HCI_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config HCI_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config HCI_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config HCI_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config HCI_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config HCI_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if HCI_TRACE_LEVEL_NONE
|
||||
default 1 if HCI_TRACE_LEVEL_ERROR
|
||||
default 2 if HCI_TRACE_LEVEL_WARNING
|
||||
default 3 if HCI_TRACE_LEVEL_API
|
||||
default 4 if HCI_TRACE_LEVEL_EVENT
|
||||
default 5 if HCI_TRACE_LEVEL_DEBUG
|
||||
default 6 if HCI_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BTM_INITIAL_TRACE_LEVEL
|
||||
prompt "BTM layer"
|
||||
default BTM_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BTM layer
|
||||
|
||||
config BTM_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BTM_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BTM_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BTM_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BTM_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BTM_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BTM_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BTM_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BTM_TRACE_LEVEL_NONE
|
||||
default 1 if BTM_TRACE_LEVEL_ERROR
|
||||
default 2 if BTM_TRACE_LEVEL_WARNING
|
||||
default 3 if BTM_TRACE_LEVEL_API
|
||||
default 4 if BTM_TRACE_LEVEL_EVENT
|
||||
default 5 if BTM_TRACE_LEVEL_DEBUG
|
||||
default 6 if BTM_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice L2CAP_INITIAL_TRACE_LEVEL
|
||||
prompt "L2CAP layer"
|
||||
default L2CAP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for L2CAP layer
|
||||
|
||||
config L2CAP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config L2CAP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config L2CAP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config L2CAP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config L2CAP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config L2CAP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config L2CAP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config L2CAP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if L2CAP_TRACE_LEVEL_NONE
|
||||
default 1 if L2CAP_TRACE_LEVEL_ERROR
|
||||
default 2 if L2CAP_TRACE_LEVEL_WARNING
|
||||
default 3 if L2CAP_TRACE_LEVEL_API
|
||||
default 4 if L2CAP_TRACE_LEVEL_EVENT
|
||||
default 5 if L2CAP_TRACE_LEVEL_DEBUG
|
||||
default 6 if L2CAP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice RFCOMM_INITIAL_TRACE_LEVEL
|
||||
prompt "RFCOMM layer"
|
||||
default RFCOMM_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for RFCOMM layer
|
||||
|
||||
config RFCOMM_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config RFCOMM_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config RFCOMM_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config RFCOMM_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config RFCOMM_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config RFCOMM_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config RFCOMM_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config RFCOMM_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if RFCOMM_TRACE_LEVEL_NONE
|
||||
default 1 if RFCOMM_TRACE_LEVEL_ERROR
|
||||
default 2 if RFCOMM_TRACE_LEVEL_WARNING
|
||||
default 3 if RFCOMM_TRACE_LEVEL_API
|
||||
default 4 if RFCOMM_TRACE_LEVEL_EVENT
|
||||
default 5 if RFCOMM_TRACE_LEVEL_DEBUG
|
||||
default 6 if RFCOMM_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice SDP_INITIAL_TRACE_LEVEL
|
||||
prompt "SDP layer"
|
||||
default SDP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for SDP layer
|
||||
|
||||
config SDP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config SDP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config SDP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config SDP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config SDP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config SDP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config SDP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config SDP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if SDP_TRACE_LEVEL_NONE
|
||||
default 1 if SDP_TRACE_LEVEL_ERROR
|
||||
default 2 if SDP_TRACE_LEVEL_WARNING
|
||||
default 3 if SDP_TRACE_LEVEL_API
|
||||
default 4 if SDP_TRACE_LEVEL_EVENT
|
||||
default 5 if SDP_TRACE_LEVEL_DEBUG
|
||||
default 6 if SDP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice GAP_INITIAL_TRACE_LEVEL
|
||||
prompt "GAP layer"
|
||||
default GAP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for GAP layer
|
||||
|
||||
config GAP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config GAP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config GAP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config GAP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config GAP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config GAP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config GAP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config GAP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if GAP_TRACE_LEVEL_NONE
|
||||
default 1 if GAP_TRACE_LEVEL_ERROR
|
||||
default 2 if GAP_TRACE_LEVEL_WARNING
|
||||
default 3 if GAP_TRACE_LEVEL_API
|
||||
default 4 if GAP_TRACE_LEVEL_EVENT
|
||||
default 5 if GAP_TRACE_LEVEL_DEBUG
|
||||
default 6 if GAP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BNEP_INITIAL_TRACE_LEVEL
|
||||
prompt "BNEP layer"
|
||||
default BNEP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BNEP layer
|
||||
|
||||
config BNEP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BNEP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BNEP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BNEP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BNEP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BNEP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BNEP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BNEP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BNEP_TRACE_LEVEL_NONE
|
||||
default 1 if BNEP_TRACE_LEVEL_ERROR
|
||||
default 2 if BNEP_TRACE_LEVEL_WARNING
|
||||
default 3 if BNEP_TRACE_LEVEL_API
|
||||
default 4 if BNEP_TRACE_LEVEL_EVENT
|
||||
default 5 if BNEP_TRACE_LEVEL_DEBUG
|
||||
default 6 if BNEP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice PAN_INITIAL_TRACE_LEVEL
|
||||
prompt "PAN layer"
|
||||
default PAN_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for PAN layer
|
||||
|
||||
config PAN_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config PAN_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config PAN_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config PAN_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config PAN_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config PAN_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config PAN_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config PAN_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if PAN_TRACE_LEVEL_NONE
|
||||
default 1 if PAN_TRACE_LEVEL_ERROR
|
||||
default 2 if PAN_TRACE_LEVEL_WARNING
|
||||
default 3 if PAN_TRACE_LEVEL_API
|
||||
default 4 if PAN_TRACE_LEVEL_EVENT
|
||||
default 5 if PAN_TRACE_LEVEL_DEBUG
|
||||
default 6 if PAN_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice A2D_INITIAL_TRACE_LEVEL
|
||||
prompt "A2D layer"
|
||||
default A2D_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for A2D layer
|
||||
|
||||
config A2D_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config A2D_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config A2D_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config A2D_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config A2D_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config A2D_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config A2D_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config A2D_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if A2D_TRACE_LEVEL_NONE
|
||||
default 1 if A2D_TRACE_LEVEL_ERROR
|
||||
default 2 if A2D_TRACE_LEVEL_WARNING
|
||||
default 3 if A2D_TRACE_LEVEL_API
|
||||
default 4 if A2D_TRACE_LEVEL_EVENT
|
||||
default 5 if A2D_TRACE_LEVEL_DEBUG
|
||||
default 6 if A2D_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice AVDT_INITIAL_TRACE_LEVEL
|
||||
prompt "AVDT layer"
|
||||
default AVDT_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for AVDT layer
|
||||
|
||||
config AVDT_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config AVDT_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config AVDT_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config AVDT_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config AVDT_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config AVDT_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config AVDT_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config AVDT_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if AVDT_TRACE_LEVEL_NONE
|
||||
default 1 if AVDT_TRACE_LEVEL_ERROR
|
||||
default 2 if AVDT_TRACE_LEVEL_WARNING
|
||||
default 3 if AVDT_TRACE_LEVEL_API
|
||||
default 4 if AVDT_TRACE_LEVEL_EVENT
|
||||
default 5 if AVDT_TRACE_LEVEL_DEBUG
|
||||
default 6 if AVDT_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice AVCT_INITIAL_TRACE_LEVEL
|
||||
prompt "AVCT layer"
|
||||
default AVCT_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for AVCT layer
|
||||
|
||||
config AVCT_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config AVCT_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config AVCT_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config AVCT_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config AVCT_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config AVCT_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config AVCT_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config AVCT_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if AVCT_TRACE_LEVEL_NONE
|
||||
default 1 if AVCT_TRACE_LEVEL_ERROR
|
||||
default 2 if AVCT_TRACE_LEVEL_WARNING
|
||||
default 3 if AVCT_TRACE_LEVEL_API
|
||||
default 4 if AVCT_TRACE_LEVEL_EVENT
|
||||
default 5 if AVCT_TRACE_LEVEL_DEBUG
|
||||
default 6 if AVCT_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice AVRC_INITIAL_TRACE_LEVEL
|
||||
prompt "AVRC layer"
|
||||
default AVRC_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for AVRC layer
|
||||
|
||||
config AVRC_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config AVRC_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config AVRC_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config AVRC_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config AVRC_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config AVRC_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config AVRC_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config AVRC_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if AVRC_TRACE_LEVEL_NONE
|
||||
default 1 if AVRC_TRACE_LEVEL_ERROR
|
||||
default 2 if AVRC_TRACE_LEVEL_WARNING
|
||||
default 3 if AVRC_TRACE_LEVEL_API
|
||||
default 4 if AVRC_TRACE_LEVEL_EVENT
|
||||
default 5 if AVRC_TRACE_LEVEL_DEBUG
|
||||
default 6 if AVRC_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice MCA_INITIAL_TRACE_LEVEL
|
||||
prompt "MCA layer"
|
||||
default MCA_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for MCA layer
|
||||
|
||||
config MCA_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config MCA_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config MCA_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config MCA_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config MCA_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config MCA_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config MCA_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config MCA_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if MCA_TRACE_LEVEL_NONE
|
||||
default 1 if MCA_TRACE_LEVEL_ERROR
|
||||
default 2 if MCA_TRACE_LEVEL_WARNING
|
||||
default 3 if MCA_TRACE_LEVEL_API
|
||||
default 4 if MCA_TRACE_LEVEL_EVENT
|
||||
default 5 if MCA_TRACE_LEVEL_DEBUG
|
||||
default 6 if MCA_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice HID_INITIAL_TRACE_LEVEL
|
||||
prompt "HID layer"
|
||||
default HID_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for HID layer
|
||||
|
||||
config HID_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config HID_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config HID_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config HID_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config HID_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config HID_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config HID_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config HID_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if HID_TRACE_LEVEL_NONE
|
||||
default 1 if HID_TRACE_LEVEL_ERROR
|
||||
default 2 if HID_TRACE_LEVEL_WARNING
|
||||
default 3 if HID_TRACE_LEVEL_API
|
||||
default 4 if HID_TRACE_LEVEL_EVENT
|
||||
default 5 if HID_TRACE_LEVEL_DEBUG
|
||||
default 6 if HID_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice APPL_INITIAL_TRACE_LEVEL
|
||||
prompt "APPL layer"
|
||||
default APPL_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for APPL layer
|
||||
|
||||
config APPL_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config APPL_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config APPL_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config APPL_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config APPL_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config APPL_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config APPL_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config APPL_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if APPL_TRACE_LEVEL_NONE
|
||||
default 1 if APPL_TRACE_LEVEL_ERROR
|
||||
default 2 if APPL_TRACE_LEVEL_WARNING
|
||||
default 3 if APPL_TRACE_LEVEL_API
|
||||
default 4 if APPL_TRACE_LEVEL_EVENT
|
||||
default 5 if APPL_TRACE_LEVEL_DEBUG
|
||||
default 6 if APPL_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice GATT_INITIAL_TRACE_LEVEL
|
||||
prompt "GATT layer"
|
||||
default GATT_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for GATT layer
|
||||
|
||||
config GATT_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config GATT_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config GATT_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config GATT_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config GATT_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config GATT_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config GATT_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config GATT_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if GATT_TRACE_LEVEL_NONE
|
||||
default 1 if GATT_TRACE_LEVEL_ERROR
|
||||
default 2 if GATT_TRACE_LEVEL_WARNING
|
||||
default 3 if GATT_TRACE_LEVEL_API
|
||||
default 4 if GATT_TRACE_LEVEL_EVENT
|
||||
default 5 if GATT_TRACE_LEVEL_DEBUG
|
||||
default 6 if GATT_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice SMP_INITIAL_TRACE_LEVEL
|
||||
prompt "SMP layer"
|
||||
default SMP_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for SMP layer
|
||||
|
||||
config SMP_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config SMP_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config SMP_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config SMP_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config SMP_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config SMP_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config SMP_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config SMP_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if SMP_TRACE_LEVEL_NONE
|
||||
default 1 if SMP_TRACE_LEVEL_ERROR
|
||||
default 2 if SMP_TRACE_LEVEL_WARNING
|
||||
default 3 if SMP_TRACE_LEVEL_API
|
||||
default 4 if SMP_TRACE_LEVEL_EVENT
|
||||
default 5 if SMP_TRACE_LEVEL_DEBUG
|
||||
default 6 if SMP_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BTIF_INITIAL_TRACE_LEVEL
|
||||
prompt "BTIF layer"
|
||||
default BTIF_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BTIF layer
|
||||
|
||||
config BTIF_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BTIF_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BTIF_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BTIF_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BTIF_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BTIF_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BTIF_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BTIF_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BTIF_TRACE_LEVEL_NONE
|
||||
default 1 if BTIF_TRACE_LEVEL_ERROR
|
||||
default 2 if BTIF_TRACE_LEVEL_WARNING
|
||||
default 3 if BTIF_TRACE_LEVEL_API
|
||||
default 4 if BTIF_TRACE_LEVEL_EVENT
|
||||
default 5 if BTIF_TRACE_LEVEL_DEBUG
|
||||
default 6 if BTIF_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BTC_INITIAL_TRACE_LEVEL
|
||||
prompt "BTC layer"
|
||||
default BTC_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BTC layer
|
||||
|
||||
config BTC_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BTC_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BTC_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BTC_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BTC_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BTC_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BTC_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BTC_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BTC_TRACE_LEVEL_NONE
|
||||
default 1 if BTC_TRACE_LEVEL_ERROR
|
||||
default 2 if BTC_TRACE_LEVEL_WARNING
|
||||
default 3 if BTC_TRACE_LEVEL_API
|
||||
default 4 if BTC_TRACE_LEVEL_EVENT
|
||||
default 5 if BTC_TRACE_LEVEL_DEBUG
|
||||
default 6 if BTC_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice OSI_INITIAL_TRACE_LEVEL
|
||||
prompt "OSI layer"
|
||||
default OSI_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for OSI layer
|
||||
|
||||
config OSI_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config OSI_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config OSI_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config OSI_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config OSI_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config OSI_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config OSI_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config OSI_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if OSI_TRACE_LEVEL_NONE
|
||||
default 1 if OSI_TRACE_LEVEL_ERROR
|
||||
default 2 if OSI_TRACE_LEVEL_WARNING
|
||||
default 3 if OSI_TRACE_LEVEL_API
|
||||
default 4 if OSI_TRACE_LEVEL_EVENT
|
||||
default 5 if OSI_TRACE_LEVEL_DEBUG
|
||||
default 6 if OSI_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
choice BLUFI_INITIAL_TRACE_LEVEL
|
||||
prompt "BLUFI layer"
|
||||
default BLUFI_TRACE_LEVEL_WARNING
|
||||
depends on BLUEDROID_ENABLED && !BT_STACK_NO_LOG
|
||||
help
|
||||
Define BT trace level for BLUFI layer
|
||||
|
||||
config BLUFI_TRACE_LEVEL_NONE
|
||||
bool "NONE"
|
||||
config BLUFI_TRACE_LEVEL_ERROR
|
||||
bool "ERROR"
|
||||
config BLUFI_TRACE_LEVEL_WARNING
|
||||
bool "WARNING"
|
||||
config BLUFI_TRACE_LEVEL_API
|
||||
bool "API"
|
||||
config BLUFI_TRACE_LEVEL_EVENT
|
||||
bool "EVENT"
|
||||
config BLUFI_TRACE_LEVEL_DEBUG
|
||||
bool "DEBUG"
|
||||
config BLUFI_TRACE_LEVEL_VERBOSE
|
||||
bool "VERBOSE"
|
||||
endchoice
|
||||
|
||||
config BLUFI_INITIAL_TRACE_LEVEL
|
||||
int
|
||||
depends on BLUEDROID_ENABLED
|
||||
default 0 if BLUFI_TRACE_LEVEL_NONE
|
||||
default 1 if BLUFI_TRACE_LEVEL_ERROR
|
||||
default 2 if BLUFI_TRACE_LEVEL_WARNING
|
||||
default 3 if BLUFI_TRACE_LEVEL_API
|
||||
default 4 if BLUFI_TRACE_LEVEL_EVENT
|
||||
default 5 if BLUFI_TRACE_LEVEL_DEBUG
|
||||
default 6 if BLUFI_TRACE_LEVEL_VERBOSE
|
||||
default 2
|
||||
|
||||
endmenu #BT DEBUG LOG LEVEL
|
||||
|
||||
|
||||
config BT_ACL_CONNECTIONS
|
||||
int "BT/BLE MAX ACL CONNECTIONS(1~7)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
range 1 7
|
||||
default 4
|
||||
help
|
||||
help
|
||||
Maximum BT/BLE connection count
|
||||
|
||||
config BT_ALLOCATION_FROM_SPIRAM_FIRST
|
||||
bool "BT/BLE will first malloc the memory from the PSRAM"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
This select can save the internal RAM if there have the PSRAM
|
||||
|
||||
config BT_BLE_DYNAMIC_ENV_MEMORY
|
||||
bool "Use dynamic memory allocation in BT/BLE stack"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
This select can make the allocation of memory will become more flexible
|
||||
|
||||
config BLE_SCAN_DUPLICATE
|
||||
bool "BLE Scan Duplicate Options "
|
||||
depends on BLUEDROID_ENABLED
|
||||
@@ -1014,8 +166,8 @@ config BLE_SCAN_DUPLICATE
|
||||
config DUPLICATE_SCAN_CACHE_SIZE
|
||||
int "Maximum number of devices in scan duplicate filter"
|
||||
depends on BLE_SCAN_DUPLICATE
|
||||
range 10 200
|
||||
default 20
|
||||
range 10 1000
|
||||
default 500
|
||||
help
|
||||
Maximum number of devices which can be recorded in scan duplicate filter.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
@@ -1040,7 +192,7 @@ config SMP_ENABLE
|
||||
bool
|
||||
depends on BLUEDROID_ENABLED
|
||||
default CLASSIC_BT_ENABLED || BLE_SMP_ENABLE
|
||||
|
||||
|
||||
# Memory reserved at start of DRAM for Bluetooth stack
|
||||
config BT_RESERVE_DRAM
|
||||
hex
|
||||
|
||||
@@ -12,17 +12,30 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_a2dp_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_av.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_A2DP, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_sink_init(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -30,7 +43,7 @@ esp_err_t esp_a2d_sink_init(void)
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_INIT_EVT;
|
||||
@@ -45,9 +58,9 @@ esp_err_t esp_a2d_sink_deinit(void)
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_DEINIT_EVT;
|
||||
@@ -57,7 +70,7 @@ esp_err_t esp_a2d_sink_deinit(void)
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback)
|
||||
esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@@ -69,11 +82,11 @@ esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback)
|
||||
msg.act = BTC_AV_SINK_API_REG_DATA_CB_EVT;
|
||||
|
||||
btc_av_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
arg.data_cb = callback;
|
||||
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_msg_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -82,17 +95,17 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda)
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_CONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.connect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
@@ -104,10 +117,10 @@ esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda)
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
bt_status_t stat;
|
||||
btc_msg_t msg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_DISCONNECT_EVT;
|
||||
@@ -117,139 +130,4 @@ esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda)
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
|
||||
esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_A2DP, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_API_MEDIA_CTRL_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
arg.ctrl = ctrl;
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
esp_err_t esp_a2d_source_init(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_INIT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_source_deinit(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_DEINIT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_source_connect(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_CONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.src_connect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_source_disconnect(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_DISCONNECT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_a2d_source_register_data_callback(esp_a2d_source_data_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_REG_DATA_CB_EVT;
|
||||
|
||||
btc_av_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
arg.src_data_cb = callback;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
|
||||
#endif /* #if BTC_AV_INCLUDED */
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_avrc_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_avrc.h"
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
#include "esp_blufi_api.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc_task.h"
|
||||
#include "btc_blufi_prf.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc/btc_main.h"
|
||||
#include "osi/future.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_main.h"
|
||||
#include "future.h"
|
||||
#include "btc_gatts.h"
|
||||
#include "btc_gatt_util.h"
|
||||
|
||||
esp_err_t esp_blufi_register_callbacks(esp_blufi_callbacks_t *callbacks)
|
||||
{
|
||||
@@ -58,23 +57,6 @@ esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), btc_blufi_call_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_blufi_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_SEND_WIFI_LIST;
|
||||
arg.wifi_list.apCount = apCount;
|
||||
arg.wifi_list.list = list;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), btc_blufi_call_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_profile_init(void)
|
||||
{
|
||||
@@ -121,44 +103,7 @@ esp_err_t esp_blufi_close(esp_gatt_if_t gatts_if, uint16_t conn_id)
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CLOSE;
|
||||
arg.close.conn_id = BTC_GATT_CREATE_CONN_ID(gatts_if, conn_id);
|
||||
arg.close.conn_id = conn_id;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_send_error_info(esp_blufi_error_state_t state)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_blufi_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_SEND_ERR_INFO;
|
||||
arg.blufi_err_infor.state = state;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_send_custom_data(uint8_t *data, uint32_t data_len)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_blufi_args_t arg;
|
||||
if(data == NULL || data_len == 0) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_SEND_CUSTOM_DATA;
|
||||
arg.custom_data.data = data;
|
||||
arg.custom_data.data_len = data_len;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), btc_blufi_call_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#include <string.h>
|
||||
#include "esp_bt_device.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "device/controller.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_dev.h"
|
||||
#include "controller.h"
|
||||
#include "btc_task.h"
|
||||
#include "btc_dev.h"
|
||||
|
||||
const uint8_t *esp_bt_dev_get_address(void)
|
||||
{
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_main.h"
|
||||
#include "btc_task.h"
|
||||
#include "btc_main.h"
|
||||
#include "esp_bt.h"
|
||||
#include "osi/future.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "future.h"
|
||||
#include "allocator.h"
|
||||
|
||||
static bool bd_already_enable = false;
|
||||
static bool bd_already_init = false;
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "esp_bt_device.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "bta_api.h"
|
||||
#include "bt_trace.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gap_ble.h"
|
||||
#include "btc/btc_ble_storage.h"
|
||||
#include "btc_ble_storage.h"
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
|
||||
@@ -35,7 +35,7 @@ esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (adv_data == NULL) {
|
||||
@@ -60,7 +60,7 @@ esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (scan_params == NULL) {
|
||||
@@ -195,86 +195,6 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
{
|
||||
esp_err_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
switch (icon) {
|
||||
case ESP_BLE_APPEARANCE_GENERIC_PHONE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_COMPUTER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_REMOTE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_THERMOMETER:
|
||||
case ESP_BLE_APPEARANCE_THERMOMETER_EAR:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_HEART_RATE:
|
||||
case ESP_BLE_APPEARANCE_HEART_RATE_BELT:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE:
|
||||
case ESP_BLE_APPEARANCE_BLOOD_PRESSURE_ARM:
|
||||
case ESP_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER:
|
||||
case ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP:
|
||||
case ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_GLUCOSE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_WEIGHT:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_WALKING:
|
||||
case ESP_BLE_APPEARANCE_WALKING_IN_SHOE:
|
||||
case ESP_BLE_APPEARANCE_WALKING_ON_SHOE:
|
||||
case ESP_BLE_APPEARANCE_WALKING_ON_HIP:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_WATCH:
|
||||
case ESP_BLE_APPEARANCE_SPORTS_WATCH:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_EYEGLASSES:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_DISPLAY:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER:
|
||||
case ESP_BLE_APPEARANCE_HID_BARCODE_SCANNER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_HID:
|
||||
case ESP_BLE_APPEARANCE_HID_KEYBOARD:
|
||||
case ESP_BLE_APPEARANCE_HID_MOUSE:
|
||||
case ESP_BLE_APPEARANCE_HID_JOYSTICK:
|
||||
case ESP_BLE_APPEARANCE_HID_GAMEPAD:
|
||||
case ESP_BLE_APPEARANCE_HID_DIGITIZER_TABLET:
|
||||
case ESP_BLE_APPEARANCE_HID_CARD_READER:
|
||||
case ESP_BLE_APPEARANCE_HID_DIGITAL_PEN:
|
||||
case ESP_BLE_APPEARANCE_UNKNOWN:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_CLOCK:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_TAG:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_KEYRING:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_CYCLING:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_COMPUTER:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_SPEED:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_CADENCE:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_POWER:
|
||||
case ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE:
|
||||
case ESP_BLE_APPEARANCE_POWERED_WHEELCHAIR:
|
||||
case ESP_BLE_APPEARANCE_MOBILITY_SCOOTER:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_INSULIN_PUMP:
|
||||
case ESP_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP:
|
||||
case ESP_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP:
|
||||
case ESP_BLE_APPEARANCE_INSULIN_PEN:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY:
|
||||
case ESP_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD:
|
||||
case ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV:
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
|
||||
arg.cfg_local_icon.icon = icon;
|
||||
ret = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
break;
|
||||
default:
|
||||
ret = ESP_ERR_INVALID_ARG;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
@@ -348,18 +268,6 @@ esp_err_t esp_ble_gap_set_device_name(const char *name)
|
||||
return esp_bt_dev_set_device_name(name);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type)
|
||||
{
|
||||
if(esp_bluedroid_get_status() != (ESP_BLUEDROID_STATUS_ENABLED)) {
|
||||
LOG_ERROR("%s, bluedroid status error", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if(!BTM_BleGetCurrentAddress(local_used_addr, addr_type)) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *length)
|
||||
{
|
||||
if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) &&
|
||||
@@ -542,9 +450,7 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
|
||||
int esp_ble_get_bond_device_num(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
return btc_storage_get_num_ble_bond_devices();
|
||||
}
|
||||
|
||||
@@ -12,30 +12,15 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_gap_bt_api.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "bt_trace.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gap_bt.h"
|
||||
#include "btc/btc_storage.h"
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
|
||||
esp_err_t esp_bt_gap_register_callback(esp_bt_gap_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_GAP_BT, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
#if BTC_GAP_BT_INCLUDED
|
||||
|
||||
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode)
|
||||
{
|
||||
@@ -45,7 +30,7 @@ esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode)
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_SCAN_MODE;
|
||||
@@ -54,190 +39,4 @@ esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_start_discovery(esp_bt_inq_mode_t mode, uint8_t inq_len, uint8_t num_rsps)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (mode != ESP_BT_INQ_MODE_GENERAL_INQUIRY &&
|
||||
mode != ESP_BT_INQ_MODE_LIMITED_INQUIRY) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (inq_len < ESP_BT_GAP_MIN_INQ_LEN ||
|
||||
inq_len > ESP_BT_GAP_MAX_INQ_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_START_DISCOVERY;
|
||||
|
||||
arg.start_disc.mode = mode;
|
||||
arg.start_disc.inq_len = inq_len;
|
||||
arg.start_disc.num_rsps = num_rsps;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_cancel_discovery(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_CANCEL_DISCOVERY;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_remote_services(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_GET_REMOTE_SERVICES;
|
||||
|
||||
memcpy(&arg.bda, remote_bda, sizeof(bt_bdaddr_t));
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_remote_service_record(esp_bd_addr_t remote_bda, esp_bt_uuid_t *uuid)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_GET_REMOTE_SERVICE_RECORD;
|
||||
|
||||
memcpy(&arg.get_rmt_srv_rcd.bda, remote_bda, sizeof(bt_bdaddr_t));
|
||||
memcpy(&arg.get_rmt_srv_rcd.uuid, uuid, sizeof(esp_bt_uuid_t));
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
uint8_t *esp_bt_gap_resolve_eir_data(uint8_t *eir, esp_bt_eir_type_t type, uint8_t *length)
|
||||
{
|
||||
if (!eir) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return BTM_CheckEirData(eir, type, length);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case ESP_BT_SET_COD_MAJOR_MINOR:
|
||||
case ESP_BT_SET_COD_SERVICE_CLASS:
|
||||
case ESP_BT_CLR_COD_SERVICE_CLASS:
|
||||
case ESP_BT_SET_COD_ALL:
|
||||
case ESP_BT_INIT_COD:
|
||||
break;
|
||||
default:
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
break;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_COD;
|
||||
|
||||
arg.set_cod.mode = mode;
|
||||
memcpy(&arg.set_cod.cod, &cod, sizeof(esp_bt_cod_t));
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_bt_gap_get_cod(esp_bt_cod_t *cod)
|
||||
{
|
||||
return btc_gap_bt_get_cod(cod);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_bt_gap_read_rssi_delta(esp_bd_addr_t remote_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_READ_RSSI_DELTA;
|
||||
memcpy(arg.read_rssi_delta.bda.address, remote_addr, sizeof(esp_bd_addr_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE;
|
||||
|
||||
memcpy(arg.rm_bond_device.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
int esp_bt_gap_get_bond_device_num(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return btc_storage_get_num_bt_bond_devices();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
||||
{
|
||||
int ret;
|
||||
int dev_num_total;
|
||||
|
||||
if (dev_num == NULL || dev_list == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
dev_num_total = btc_storage_get_num_bt_bond_devices();
|
||||
if (*dev_num > dev_num_total) {
|
||||
*dev_num = dev_num_total;
|
||||
}
|
||||
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, *dev_num);
|
||||
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "esp_gatt_common_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "btc_gatt_common.h"
|
||||
#include "btc_main.h"
|
||||
|
||||
/**
|
||||
* @brief This function is called to set local MTU,
|
||||
@@ -32,7 +32,7 @@
|
||||
esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatt_com_args_t arg;
|
||||
btc_ble_main_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
@@ -41,9 +41,9 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATT_COMMON;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_GATT_ACT_SET_LOCAL_MTU;
|
||||
arg.set_mtu.mtu = mtu;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatt_com_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_main_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@@ -16,12 +16,9 @@
|
||||
|
||||
#include "esp_gattc_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gattc.h"
|
||||
#include "btc_gatt_util.h"
|
||||
#include "stack/l2cdefs.h"
|
||||
#include "stack/l2c_api.h"
|
||||
|
||||
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
|
||||
@@ -329,11 +326,6 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_READ_CHAR;
|
||||
@@ -353,11 +345,6 @@ esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_READ_MULTIPLE_CHAR;
|
||||
@@ -384,11 +371,6 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_READ_CHAR_DESCR;
|
||||
@@ -411,11 +393,6 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_WRITE_CHAR;
|
||||
@@ -441,11 +418,6 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_WRITE_CHAR_DESCR;
|
||||
@@ -471,11 +443,6 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_PREPARE_WRITE;
|
||||
@@ -501,11 +468,6 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR;
|
||||
@@ -585,37 +547,5 @@ esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr, esp_bd_addr_t assoc_addr, bool is_assoc)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_CACHE_ASSOC;
|
||||
arg.cache_assoc.is_assoc = is_assoc;
|
||||
arg.cache_assoc.gattc_if = gattc_if;
|
||||
memcpy(arg.cache_assoc.src_addr, src_addr, sizeof(esp_bd_addr_t));
|
||||
memcpy(arg.cache_assoc.assoc_addr, assoc_addr, sizeof(esp_bd_addr_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_cache_get_addr_list(esp_gatt_if_t gattc_if)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ATC_CACHE_GET_ADDR_LIST;
|
||||
arg.get_addr_list.gattc_if = gattc_if;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif ///GATTC_INCLUDED == TRUE
|
||||
|
||||
|
||||
@@ -16,13 +16,10 @@
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_gatts_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gatts.h"
|
||||
#include "btc_gatt_util.h"
|
||||
#include "common/bt_target.h"
|
||||
#include "stack/l2cdefs.h"
|
||||
#include "stack/l2c_api.h"
|
||||
|
||||
#include "bt_target.h"
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
#define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type))
|
||||
|
||||
@@ -260,11 +257,6 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_ERROR("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_SEND_INDICATE;
|
||||
|
||||
@@ -1,476 +0,0 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include <string.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_hf_client_api.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc_hf_client.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_hf_client_api.h"
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
esp_err_t esp_hf_client_register_callback(esp_hf_client_cb_t callback)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_HF_CLIENT, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_init(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_INIT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_deinit(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DEINIT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_connect(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_CONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.connect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_disconnect(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DISCONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.disconnect), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_connect_audio(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_CONNECT_AUDIO_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.connect_audio), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_disconnect_audio(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_hf_client_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DISCONNECT_AUDIO_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
memcpy(&(arg.disconnect_audio), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_hf_client_start_voice_recognition(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_START_VOICE_RECOGNITION_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_stop_voice_recognition(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_STOP_VOICE_RECOGNITION_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_volume_update(esp_hf_volume_control_target_t type, int volume)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_VOLUME_UPDATE_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.volume_update.type = type;
|
||||
arg.volume_update.volume = volume;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_dial(const char *number)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
if (number != NULL && strlen(number) > ESP_BT_HF_CLIENT_NUMBER_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DIAL_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
if (number != NULL) {
|
||||
strcpy(arg.dial.number, number);
|
||||
} else {
|
||||
arg.dial.number[0] = '\0';
|
||||
}
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_dial_memory(int location)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_DIAL_MEMORY_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.dial_memory.location = location;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_send_chld_cmd(esp_hf_chld_type_t chld, int idx)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_SEND_CHLD_CMD_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.chld.type = chld;
|
||||
arg.chld.idx = idx;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_send_btrh_cmd(esp_hf_btrh_cmd_t btrh)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_SEND_BTRH_CMD_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.btrh.cmd = btrh;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_answer_call(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_ANSWER_CALL_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_reject_call(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_REJECT_CALL_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_query_current_calls(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_QUERY_CURRENT_CALLS_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_query_current_operator_name(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_QUERY_CURRENT_OPERATOR_NAME_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_retrieve_subscriber_info(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_RETRIEVE_SUBSCRIBER_INFO_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_send_dtmf(char code)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_hf_client_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_SEND_DTMF_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.send_dtmf.code = code;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_request_last_voice_tag_number(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_REQUEST_LAST_VOICE_TAG_NUMBER_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t recv,
|
||||
esp_hf_client_outgoing_data_cb_t send)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HF_CLIENT;
|
||||
msg.act = BTC_HF_CLIENT_REGISTER_DATA_CALLBACK_EVT;
|
||||
|
||||
btc_hf_client_args_t arg;
|
||||
memset(&arg, 0, sizeof(btc_hf_client_args_t));
|
||||
arg.reg_data_cb.recv = recv;
|
||||
arg.reg_data_cb.send = send;
|
||||
|
||||
/* Switch to BTC context */
|
||||
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_hf_client_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
void esp_hf_client_outgoing_data_ready(void)
|
||||
{
|
||||
BTA_HfClientCiData();
|
||||
}
|
||||
|
||||
void esp_hf_client_pcm_resample_init(uint32_t src_sps, uint32_t bits, uint32_t channels)
|
||||
{
|
||||
BTA_DmPcmInitSamples(src_sps, bits, channels);
|
||||
}
|
||||
|
||||
int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst)
|
||||
{
|
||||
return BTA_DmPcmResample(src, in_bytes, dst);
|
||||
}
|
||||
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
|
||||
#endif /* BTC_HF_CLIENT_INCLUDED */
|
||||
@@ -1,174 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_bt_main.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "btc_spp.h"
|
||||
#include "esp_spp_api.h"
|
||||
#include "common/bt_target.h"
|
||||
|
||||
#if (defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE)
|
||||
|
||||
static const uint8_t UUID_SPP[16] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
static tSDP_UUID sdp_uuid;
|
||||
esp_err_t esp_spp_register_callback(esp_spp_cb_t *callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_profile_cb_set(BTC_PID_SPP, callback);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_spp_init(esp_spp_mode_t mode)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_INIT;
|
||||
|
||||
arg.init.mode = mode;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_deinit()
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_UNINIT;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_spp_start_discovery(esp_bd_addr_t bd_addr)
|
||||
{
|
||||
sdp_uuid.len = 16;
|
||||
memcpy(sdp_uuid.uu.uuid128, UUID_SPP, sizeof(sdp_uuid.uu.uuid128));
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_START_DISCOVERY;
|
||||
|
||||
memcpy(arg.start_discovery.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
|
||||
arg.start_discovery.num_uuid = 1;
|
||||
arg.start_discovery.p_uuid_list = &sdp_uuid;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), btc_spp_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_connect(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t remote_scn, esp_bd_addr_t peer_bd_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_CONNECT;
|
||||
|
||||
arg.connect.sec_mask = sec_mask;
|
||||
arg.connect.role = role;
|
||||
arg.connect.remote_scn = remote_scn;
|
||||
memcpy(arg.connect.peer_bd_addr, peer_bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_disconnect(uint32_t handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_DISCONNECT;
|
||||
|
||||
arg.disconnect.handle = handle;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t local_scn, const char *name)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (strlen(name) > ESP_SPP_SERVER_NAME_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_START_SRV;
|
||||
|
||||
arg.start_srv.sec_mask = sec_mask;
|
||||
arg.start_srv.role = role;
|
||||
arg.start_srv.local_scn = local_scn;
|
||||
arg.start_srv.max_session = ESP_SPP_MAX_SESSION;
|
||||
strcpy(arg.start_srv.name, name);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_WRITE;
|
||||
|
||||
arg.write.handle = handle;
|
||||
arg.write.len = len;
|
||||
arg.write.p_data = p_data;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), btc_spp_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_vfs_register()
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
return btc_spp_vfs_register();
|
||||
}
|
||||
|
||||
#endif ///defined BTC_SPP_INCLUDED && BTC_SPP_INCLUDED == TRUE
|
||||
@@ -1,454 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_GAP_BT_API_H__
|
||||
#define __ESP_GAP_BT_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/// RSSI threshold
|
||||
#define ESP_BT_GAP_RSSI_HIGH_THRLD -20 /*!< High RSSI threshold */
|
||||
#define ESP_BT_GAP_RSSI_LOW_THRLD -45 /*!< Low RSSI threshold */
|
||||
|
||||
/// Class of device
|
||||
typedef struct {
|
||||
uint32_t reserved_2: 2; /*!< undefined */
|
||||
uint32_t minor: 6; /*!< minor class */
|
||||
uint32_t major: 5; /*!< major class */
|
||||
uint32_t service: 11; /*!< service class */
|
||||
uint32_t reserved_8: 8; /*!< undefined */
|
||||
} esp_bt_cod_t;
|
||||
|
||||
/// class of device settings
|
||||
typedef enum {
|
||||
ESP_BT_SET_COD_MAJOR_MINOR = 0x01, /*!< overwrite major, minor class */
|
||||
ESP_BT_SET_COD_SERVICE_CLASS = 0x02, /*!< set the bits in the input, the current bit will remain */
|
||||
ESP_BT_CLR_COD_SERVICE_CLASS = 0x04, /*!< clear the bits in the input, others will remain */
|
||||
ESP_BT_SET_COD_ALL = 0x08, /*!< overwrite major, minor, set the bits in service class */
|
||||
ESP_BT_INIT_COD = 0x0a, /*!< overwrite major, minor, and service class */
|
||||
} esp_bt_cod_mode_t;
|
||||
|
||||
/// Discoverability and Connectability mode
|
||||
typedef enum {
|
||||
ESP_BT_SCAN_MODE_NONE = 0, /*!< Neither discoverable nor connectable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE, /*!< Connectable but not discoverable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE /*!< both discoverable and connectable */
|
||||
} esp_bt_scan_mode_t;
|
||||
|
||||
/// Bluetooth Device Property type
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DEV_PROP_BDNAME = 1, /*!< Bluetooth device name, value type is int8_t [] */
|
||||
ESP_BT_GAP_DEV_PROP_COD, /*!< Class of Device, value type is uint32_t */
|
||||
ESP_BT_GAP_DEV_PROP_RSSI, /*!< Received Signal strength Indication, value type is int8_t, ranging from -128 to 127 */
|
||||
ESP_BT_GAP_DEV_PROP_EIR, /*!< Extended Inquiry Response, value type is uint8_t [] */
|
||||
} esp_bt_gap_dev_prop_type_t;
|
||||
|
||||
/// Maximum bytes of Bluetooth device name
|
||||
#define ESP_BT_GAP_MAX_BDNAME_LEN (248)
|
||||
|
||||
/// Maximum size of EIR Significant part
|
||||
#define ESP_BT_GAP_EIR_DATA_LEN (240)
|
||||
|
||||
/// Bluetooth Device Property Descriptor
|
||||
typedef struct {
|
||||
esp_bt_gap_dev_prop_type_t type; /*!< device property type */
|
||||
int len; /*!< device property value length */
|
||||
void *val; /*!< devlice prpoerty value */
|
||||
} esp_bt_gap_dev_prop_t;
|
||||
|
||||
/// Extended Inquiry Response data type
|
||||
typedef enum {
|
||||
ESP_BT_EIR_TYPE_FLAGS = 0x01, /*!< Flag with information such as BR/EDR and LE support */
|
||||
ESP_BT_EIR_TYPE_INCMPL_16BITS_UUID = 0x02, /*!< Incomplete list of 16-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_CMPL_16BITS_UUID = 0x03, /*!< Complete list of 16-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_INCMPL_32BITS_UUID = 0x04, /*!< Incomplete list of 32-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_CMPL_32BITS_UUID = 0x05, /*!< Complete list of 32-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_INCMPL_128BITS_UUID = 0x06, /*!< Incomplete list of 128-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_CMPL_128BITS_UUID = 0x07, /*!< Complete list of 128-bit service UUIDs */
|
||||
ESP_BT_EIR_TYPE_SHORT_LOCAL_NAME = 0x08, /*!< Shortened Local Name */
|
||||
ESP_BT_EIR_TYPE_CMPL_LOCAL_NAME = 0x09, /*!< Complete Local Name */
|
||||
ESP_BT_EIR_TYPE_TX_POWER_LEVEL = 0x0a, /*!< Tx power level, value is 1 octet ranging from -127 to 127, unit is dBm*/
|
||||
ESP_BT_EIR_TYPE_MANU_SPECIFIC = 0xff, /*!< Manufacturer specific data */
|
||||
} esp_bt_eir_type_t;
|
||||
|
||||
/// Major service class field of Class of Device, mutiple bits can be set
|
||||
typedef enum {
|
||||
ESP_BT_COD_SRVC_NONE = 0, /*!< None indicates an invalid value */
|
||||
ESP_BT_COD_SRVC_LMTD_DISCOVER = 0x1, /*!< Limited Discoverable Mode */
|
||||
ESP_BT_COD_SRVC_POSITIONING = 0x8, /*!< Positioning (Location identification) */
|
||||
ESP_BT_COD_SRVC_NETWORKING = 0x10, /*!< Networking, e.g. LAN, Ad hoc */
|
||||
ESP_BT_COD_SRVC_RENDERING = 0x20, /*!< Rendering, e.g. Printing, Speakers */
|
||||
ESP_BT_COD_SRVC_CAPTURING = 0x40, /*!< Capturing, e.g. Scanner, Microphone */
|
||||
ESP_BT_COD_SRVC_OBJ_TRANSFER = 0x80, /*!< Object Transfer, e.g. v-Inbox, v-Folder */
|
||||
ESP_BT_COD_SRVC_AUDIO = 0x100, /*!< Audio, e.g. Speaker, Microphone, Headerset service */
|
||||
ESP_BT_COD_SRVC_TELEPHONY = 0x200, /*!< Telephony, e.g. Cordless telephony, Modem, Headset service */
|
||||
ESP_BT_COD_SRVC_INFORMATION = 0x400, /*!< Information, e.g., WEB-server, WAP-server */
|
||||
} esp_bt_cod_srvc_t;
|
||||
|
||||
/// Bits of major service class field
|
||||
#define ESP_BT_COD_SRVC_BIT_MASK (0xffe000) /*!< Major service bit mask */
|
||||
#define ESP_BT_COD_SRVC_BIT_OFFSET (13) /*!< Major service bit offset */
|
||||
|
||||
/// Major device class field of Class of Device
|
||||
typedef enum {
|
||||
ESP_BT_COD_MAJOR_DEV_MISC = 0, /*!< Miscellaneous */
|
||||
ESP_BT_COD_MAJOR_DEV_COMPUTER = 1, /*!< Computer */
|
||||
ESP_BT_COD_MAJOR_DEV_PHONE = 2, /*!< Phone(cellular, cordless, pay phone, modem */
|
||||
ESP_BT_COD_MAJOR_DEV_LAN_NAP = 3, /*!< LAN, Network Access Point */
|
||||
ESP_BT_COD_MAJOR_DEV_AV = 4, /*!< Audio/Video(headset, speaker, stereo, video display, VCR */
|
||||
ESP_BT_COD_MAJOR_DEV_PERIPHERAL = 5, /*!< Peripheral(mouse, joystick, keyboard) */
|
||||
ESP_BT_COD_MAJOR_DEV_IMAGING = 6, /*!< Imaging(printer, scanner, camera, display */
|
||||
ESP_BT_COD_MAJOR_DEV_WEARABLE = 7, /*!< Wearable */
|
||||
ESP_BT_COD_MAJOR_DEV_TOY = 8, /*!< Toy */
|
||||
ESP_BT_COD_MAJOR_DEV_HEALTH = 9, /*!< Health */
|
||||
ESP_BT_COD_MAJOR_DEV_UNCATEGORIZED = 31, /*!< Uncategorized: device not specified */
|
||||
} esp_bt_cod_major_dev_t;
|
||||
|
||||
/// Bits of major device class field
|
||||
#define ESP_BT_COD_MAJOR_DEV_BIT_MASK (0x1f00) /*!< Major device bit mask */
|
||||
#define ESP_BT_COD_MAJOR_DEV_BIT_OFFSET (8) /*!< Major device bit offset */
|
||||
|
||||
/// Bits of minor device class field
|
||||
#define ESP_BT_COD_MINOR_DEV_BIT_MASK (0xfc) /*!< Minor device bit mask */
|
||||
#define ESP_BT_COD_MINOR_DEV_BIT_OFFSET (2) /*!< Minor device bit offset */
|
||||
|
||||
/// Bits of format type
|
||||
#define ESP_BT_COD_FORMAT_TYPE_BIT_MASK (0x03) /*!< Format type bit mask */
|
||||
#define ESP_BT_COD_FORMAT_TYPE_BIT_OFFSET (0) /*!< Format type bit offset */
|
||||
|
||||
/// Class of device format type 1
|
||||
#define ESP_BT_COD_FORMAT_TYPE_1 (0x00)
|
||||
|
||||
/** Bluetooth Device Discovery state */
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DISCOVERY_STOPPED, /*!< device discovery stopped */
|
||||
ESP_BT_GAP_DISCOVERY_STARTED, /*!< device discovery started */
|
||||
} esp_bt_gap_discovery_state_t;
|
||||
|
||||
/// BT GAP callback events
|
||||
typedef enum {
|
||||
ESP_BT_GAP_DISC_RES_EVT = 0, /*!< device discovery result event */
|
||||
ESP_BT_GAP_DISC_STATE_CHANGED_EVT, /*!< discovery state changed event */
|
||||
ESP_BT_GAP_RMT_SRVCS_EVT, /*!< get remote services event */
|
||||
ESP_BT_GAP_RMT_SRVC_REC_EVT, /*!< get remote service record event */
|
||||
ESP_BT_GAP_AUTH_CMPL_EVT, /*!< AUTH complete event */
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
/** Inquiry Mode */
|
||||
typedef enum {
|
||||
ESP_BT_INQ_MODE_GENERAL_INQUIRY, /*!< General inquiry mode */
|
||||
ESP_BT_INQ_MODE_LIMITED_INQUIRY, /*!< Limited inquiry mode */
|
||||
} esp_bt_inq_mode_t;
|
||||
|
||||
/** Minimum and Maximum inquiry length*/
|
||||
#define ESP_BT_GAP_MIN_INQ_LEN (0x01) /*!< Minimum inquiry duration, unit is 1.28s */
|
||||
#define ESP_BT_GAP_MAX_INQ_LEN (0x30) /*!< Maximum inquiry duration, unit is 1.28s */
|
||||
|
||||
/// A2DP state callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BT_GAP_DISC_RES_EVT
|
||||
*/
|
||||
struct disc_res_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
int num_prop; /*!< number of properties got */
|
||||
esp_bt_gap_dev_prop_t *prop; /*!< properties discovered from the new device */
|
||||
} disc_res; /*!< discovery result paramter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_DISC_STATE_CHANGED_EVT
|
||||
*/
|
||||
struct disc_state_changed_param {
|
||||
esp_bt_gap_discovery_state_t state; /*!< discovery state */
|
||||
} disc_st_chg; /*!< discovery state changed parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_RMT_SRVCS_EVT
|
||||
*/
|
||||
struct rmt_srvcs_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< service search status */
|
||||
int num_uuids; /*!< number of UUID in uuid_list */
|
||||
esp_bt_uuid_t *uuid_list; /*!< list of service UUIDs of remote device */
|
||||
} rmt_srvcs; /*!< services of remote device parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_RMT_SRVC_REC_EVT
|
||||
*/
|
||||
struct rmt_srvc_rec_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< service search status */
|
||||
} rmt_srvc_rec; /*!< specific service record from remote device parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_READ_RSSI_DELTA_EVT *
|
||||
*/
|
||||
struct read_rssi_delta_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< read rssi status */
|
||||
int8_t rssi_delta; /*!< rssi delta value range -128 ~127, The value zero indicates that the RSSI is inside the Golden Receive Power Range, the Golden Receive Power Range is from ESP_BT_GAP_RSSI_LOW_THRLD to ESP_BT_GAP_RSSI_HIGH_THRLD */
|
||||
} read_rssi_delta; /*!< read rssi parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_AUTH_CMPL_EVT
|
||||
*/
|
||||
struct auth_cmpl_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t stat; /*!< authentication complete status */
|
||||
uint8_t device_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< device name */
|
||||
} auth_cmpl; /*!< authentication complete parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief bluetooth GAP callback function type
|
||||
* @param event : Event type
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_bt_gap_cb_t)(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief get major service field of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return major service bits
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_srvc(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_SRVC_BIT_MASK) >> ESP_BT_COD_SRVC_BIT_OFFSET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get major device field of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return major device bits
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_major_dev(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_MAJOR_DEV_BIT_MASK) >> ESP_BT_COD_MAJOR_DEV_BIT_OFFSET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get minor service field of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return minor service bits
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_minor_dev(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_MINOR_DEV_BIT_MASK) >> ESP_BT_COD_MINOR_DEV_BIT_OFFSET;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get format type of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return format type
|
||||
*/
|
||||
inline uint32_t esp_bt_gap_get_cod_format_type(uint32_t cod)
|
||||
{
|
||||
return (cod & ESP_BT_COD_FORMAT_TYPE_BIT_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief decide the integrity of COD
|
||||
* @param[in] cod: Class of Device
|
||||
* @return
|
||||
* - true if cod is valid
|
||||
* - false otherise
|
||||
*/
|
||||
inline bool esp_bt_gap_is_valid_cod(uint32_t cod)
|
||||
{
|
||||
if (esp_bt_gap_get_cod_format_type(cod) == ESP_BT_COD_FORMAT_TYPE_1 &&
|
||||
esp_bt_gap_get_cod_srvc(cod) != ESP_BT_COD_SRVC_NONE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief register callback function. This function should be called after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_register_callback(esp_bt_gap_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief Set discoverability and connectability mode for legacy bluetooth. This function should
|
||||
* be called after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @param[in] mode : one of the enums of bt_scan_mode_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_ARG: if argument invalid
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Start device discovery. This function should be called after esp_bluedroid_enable() completes successfully.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is started or halted.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_RES_EVT if discovery result is got.
|
||||
*
|
||||
* @param[in] mode - inquiry mode
|
||||
* @param[in] inq_len - inquiry duration in 1.28 sec units, ranging from 0x01 to 0x30
|
||||
* @param[in] num_rsps - number of inquiry responses that can be received, value 0 indicates an unlimited number of responses
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_ARG: if invalid parameters are provided
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_start_discovery(esp_bt_inq_mode_t mode, uint8_t inq_len, uint8_t num_rsps);
|
||||
|
||||
/**
|
||||
* @brief Cancel device discovery. This function should be called after esp_bluedroid_enable() completes successfully
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_DISC_STATE_CHANGED_EVT if discovery is stopped.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_cancel_discovery(void);
|
||||
|
||||
/**
|
||||
* @brief Start SDP to get remote services. This function should be called after esp_bluedroid_enable() completes successfully.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_RMT_SRVCS_EVT after service discovery ends
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_remote_services(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
* @brief Start SDP to look up the service matching uuid on the remote device. This function should be called after
|
||||
* esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_RMT_SRVC_REC_EVT after service discovery ends
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_remote_service_record(esp_bd_addr_t remote_bda, esp_bt_uuid_t *uuid);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get EIR data for a specific type.
|
||||
*
|
||||
* @param[in] eir - pointer of raw eir data to be resolved
|
||||
* @param[in] type - specific EIR data type
|
||||
* @param[out] length - return the length of EIR data excluding fields of length and data type
|
||||
*
|
||||
* @return pointer of starting position of eir data excluding eir data type, NULL if not found
|
||||
*
|
||||
*/
|
||||
uint8_t *esp_bt_gap_resolve_eir_data(uint8_t *eir, esp_bt_eir_type_t type, uint8_t *length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set class of device.
|
||||
* esp_bt_gap_cb_t will is called with ESP_BT_GAP_SET_COD_EVT after set COD ends
|
||||
* Some profile have special restrictions on class of device,
|
||||
* changes may cause these profile do not work
|
||||
*
|
||||
* @param[in] cod - class of device
|
||||
* @param[in] mode - setting mode
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_ERR_INVALID_ARG: if param is invalid
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_cod(esp_bt_cod_t cod, esp_bt_cod_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get class of device.
|
||||
*
|
||||
* @param[out] cod - class of device
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_cod(esp_bt_cod_t *cod);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read RSSI delta by address after connected. The RSSI value returned by ESP_BT_GAP_READ_RSSI_DELTA_EVT.
|
||||
*
|
||||
*
|
||||
* @param[in] remote_addr - remote device address, corresponding to a certain connection handle.
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_read_rssi_delta(esp_bd_addr_t remote_addr);
|
||||
|
||||
/**
|
||||
* @brief Removes a device from the security database list of
|
||||
* peer device.
|
||||
*
|
||||
* @param[in] bd_addr : BD address of the peer device
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_FAIL : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the device number from the security database list of peer device.
|
||||
* It will return the device bonded number immediately.
|
||||
*
|
||||
* @return - >= 0 : bonded devices number.
|
||||
* - ESP_FAIL : failed
|
||||
*
|
||||
*/
|
||||
int esp_bt_gap_get_bond_device_num(void);
|
||||
|
||||
/**
|
||||
* @brief Get the device from the security database list of peer device.
|
||||
* It will return the device bonded information immediately.
|
||||
* @param[inout] dev_num: Indicate the dev_list array(buffer) size as input.
|
||||
* If dev_num is large enough, it means the actual number as output.
|
||||
* Suggest that dev_num value equal to esp_ble_get_bond_device_num().
|
||||
*
|
||||
* @param[out] dev_list: an array(buffer) of `esp_bd_addr_t` type. Use for storing the bonded devices address.
|
||||
* The dev_list should be allocated by who call this API.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GAP_BT_API_H__ */
|
||||
@@ -1,635 +0,0 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_HF_CLIENT_API_H__
|
||||
#define __ESP_HF_CLIENT_API_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_hf_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_HF_CLIENT_NUMBER_LEN (32)
|
||||
#define ESP_BT_HF_CLIENT_OPERATOR_NAME_LEN (16)
|
||||
|
||||
/// Bluetooth HFP RFCOMM connection and service level connection status
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0, /*!< RFCOMM data link channel released */
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING, /*!< connecting remote device on the RFCOMM data link*/
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_CONNECTED, /*!< RFCOMM connection established */
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_SLC_CONNECTED, /*!< service level connection established */
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTING, /*!< disconnecting with remote device on the RFCOMM dat link*/
|
||||
} esp_hf_client_connection_state_t;
|
||||
|
||||
/// Bluetooth HFP audio connection status
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED = 0, /*!< audio connection released */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTING, /*!< audio connection has been initiated */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTED, /*!< audio connection is established */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, /*!< mSBC audio connection is estalibshed */
|
||||
} esp_hf_client_audio_state_t;
|
||||
|
||||
/// in-band ring tone state
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0,
|
||||
ESP_HF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
|
||||
} esp_hf_client_in_band_ring_state_t;
|
||||
|
||||
/* features masks of AG */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_3WAY 0x01 /* Three-way calling */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_ECNR 0x02 /* Echo cancellation and/or noise reduction */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_VREC 0x04 /* Voice recognition */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_INBAND 0x08 /* In-band ring tone */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_VTAG 0x10 /* Attach a phone number to a voice tag */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_REJECT 0x20 /* Ability to reject incoming call */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_ECS 0x40 /* Enhanced Call Status */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_ECC 0x80 /* Enhanced Call Control */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_EXTERR 0x100 /* Extended error codes */
|
||||
#define ESP_HF_CLIENT_PEER_FEAT_CODEC 0x200 /* Codec Negotiation */
|
||||
|
||||
/* CHLD feature masks of AG */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_REL 0x01 /* 0 Release waiting call or held calls */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_REL_ACC 0x02 /* 1 Release active calls and accept other waiting or held call */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_REL_X 0x04 /* 1x Release specified active call only */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_HOLD_ACC 0x08 /* 2 Active calls on hold and accept other waiting or held call */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_PRIV_X 0x10 /* 2x Request private mode with specified call(put the rest on hold */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_MERGE 0x20 /* 3 Add held call to multiparty */
|
||||
#define ESP_HF_CLIENT_CHLD_FEAT_MERGE_DETACH 0x40 /* 4 Connect two calls and leave(disconnct from multiparty */
|
||||
|
||||
/// HF CLIENT callback events
|
||||
typedef enum {
|
||||
ESP_HF_CLIENT_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_HF_CLIENT_AUDIO_STATE_EVT, /*!< audio connection state change event */
|
||||
ESP_HF_CLIENT_BVRA_EVT, /*!< voice recognition state change event */
|
||||
ESP_HF_CLIENT_CIND_CALL_EVT, /*!< call indication */
|
||||
ESP_HF_CLIENT_CIND_CALL_SETUP_EVT, /*!< call setup indication */
|
||||
ESP_HF_CLIENT_CIND_CALL_HELD_EVT, /*!< call held indication */
|
||||
ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT, /*!< network service availability indication */
|
||||
ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT, /*!< signal strength indication */
|
||||
ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT, /*!< roaming status indication */
|
||||
ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT, /*!< battery level indication */
|
||||
ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT, /*!< current operator information */
|
||||
ESP_HF_CLIENT_BTRH_EVT, /*!< call response and hold event */
|
||||
ESP_HF_CLIENT_CLIP_EVT, /*!< Calling Line Identification notification */
|
||||
ESP_HF_CLIENT_CCWA_EVT, /*!< call waiting notification */
|
||||
ESP_HF_CLIENT_CLCC_EVT, /*!< list of current calls notification */
|
||||
ESP_HF_CLIENT_VOLUME_CONTROL_EVT, /*!< audio volume control command from AG, provided by +VGM or +VGS message */
|
||||
ESP_HF_CLIENT_AT_RESPONSE_EVT, /*!< AT command response event */
|
||||
ESP_HF_CLIENT_CNUM_EVT, /*!< subscriber information response from AG */
|
||||
ESP_HF_CLIENT_BSIR_EVT, /*!< setting of in-band ring tone */
|
||||
ESP_HF_CLIENT_BINP_EVT, /*!< requested number of last voice tag from AG */
|
||||
ESP_HF_CLIENT_RING_IND_EVT, /*!< ring indication event */
|
||||
} esp_hf_client_cb_event_t;
|
||||
|
||||
/// HFP client callback parameters
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CONNECTION_STATE_EVT
|
||||
*/
|
||||
struct hf_client_conn_stat_param {
|
||||
esp_hf_client_connection_state_t state; /*!< HF connection state */
|
||||
uint32_t peer_feat; /*!< AG supported features */
|
||||
uint32_t chld_feat; /*!< AG supported features on call hold and multiparty services */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} conn_stat; /*!< HF callback param of ESP_HF_CLIENT_CONNECTION_STATE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_AUDIO_STATE_EVT
|
||||
*/
|
||||
struct hf_client_audio_stat_param {
|
||||
esp_hf_client_audio_state_t state; /*!< audio connection state */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} audio_stat; /*!< HF callback param of ESP_HF_CLIENT_AUDIO_STATE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BVRA_EVT
|
||||
*/
|
||||
struct hf_client_bvra_param {
|
||||
esp_hf_vr_state_t value; /*!< voice recognition state */
|
||||
} bvra; /*!< HF callback param of ESP_HF_CLIENT_BVRA_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT
|
||||
*/
|
||||
struct hf_client_service_availability_param {
|
||||
esp_hf_service_availability_status_t status; /*!< service availability status */
|
||||
} service_availability; /*!< HF callback param of ESP_HF_CLIENT_CIND_SERVICE_AVAILABILITY_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT
|
||||
*/
|
||||
struct hf_client_network_roaming_param {
|
||||
esp_hf_roaming_status_t status; /*!< roaming status */
|
||||
} roaming; /*!< HF callback param of ESP_HF_CLIENT_CIND_ROAMING_STATUS_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT
|
||||
*/
|
||||
struct hf_client_signal_strength_ind_param {
|
||||
int value; /*!< singal strength value, ranges from 0 to 5 */
|
||||
} signal_strength; /*!< HF callback param of ESP_HF_CLIENT_CIND_SIGNAL_STRENGTH_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT
|
||||
*/
|
||||
struct hf_client_battery_level_ind_param {
|
||||
int value; /*!< battery charge value, ranges from 0 to 5 */
|
||||
} battery_level; /*!< HF callback param of ESP_HF_CLIENT_CIND_BATTERY_LEVEL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT
|
||||
*/
|
||||
struct hf_client_current_operator_param {
|
||||
const char *name; /*!< name of the network operator */
|
||||
} cops; /*!< HF callback param of ESP_HF_CLIENT_COPS_CURRENT_OPERATOR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_CALL_EVT
|
||||
*/
|
||||
struct hf_client_call_ind_param {
|
||||
esp_hf_call_status_t status; /*!< call status indicator */
|
||||
} call; /*!< HF callback param of ESP_HF_CLIENT_CIND_CALL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_CALL_SETUP_EVT
|
||||
*/
|
||||
struct hf_client_call_setup_ind_param {
|
||||
esp_hf_call_setup_status_t status; /*!< call setup status indicator */
|
||||
} call_setup; /*!< HF callback param of ESP_HF_CLIENT_BVRA_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CIND_CALL_HELD_EVT
|
||||
*/
|
||||
struct hf_client_call_held_ind_param {
|
||||
esp_hf_call_held_status_t status; /*!< bluetooth proprietary call hold status indocator */
|
||||
} call_held; /*!< HF callback param of ESP_HF_CLIENT_CIND_CALL_HELD_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BTRH_EVT
|
||||
*/
|
||||
struct hf_client_btrh_param {
|
||||
esp_hf_btrh_status_t status; /*!< call hold and response status result code */
|
||||
} btrh; /*!< HF callback param of ESP_HF_CLIENT_BRTH_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CLIP_EVT
|
||||
*/
|
||||
struct hf_client_clip_param {
|
||||
const char *number; /*!< phone number string of call */
|
||||
} clip; /*!< HF callback param of ESP_HF_CLIENT_CLIP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CCWA_EVT
|
||||
*/
|
||||
struct hf_client_ccwa_param {
|
||||
const char *number; /*!< phone number string of waiting call */
|
||||
} ccwa; /*!< HF callback param of ESP_HF_CLIENT_BVRA_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CLCC_EVT
|
||||
*/
|
||||
struct hf_client_clcc_param {
|
||||
int idx; /*!< numbering(starting with 1) of the call */
|
||||
esp_hf_current_call_direction_t dir; /*!< direction of the call */
|
||||
esp_hf_current_call_status_t status; /*!< status of the call */
|
||||
esp_hf_current_call_mpty_type_t mpty; /*!< multi-party flag */
|
||||
char *number; /*!< phone number(optional) */
|
||||
} clcc; /*!< HF callback param of ESP_HF_CLIENT_CLCC_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_VOLUME_CONTROL_EVT
|
||||
*/
|
||||
struct hf_client_volume_control_param {
|
||||
esp_hf_volume_control_target_t type; /*!< volume control target, speaker or microphone */
|
||||
int volume; /*!< gain, ranges from 0 to 15 */
|
||||
} volume_control; /*!< HF callback param of ESP_HF_CLIENT_VOLUME_CONTROL_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_AT_RESPONSE_EVT
|
||||
*/
|
||||
struct hf_client_at_response_param {
|
||||
esp_hf_at_response_code_t code; /*!< AT response code */
|
||||
esp_hf_cme_err_t cme; /*!< Extended Audio Gateway Error Result Code */
|
||||
} at_response; /*!< HF callback param of ESP_HF_CLIENT_AT_RESPONSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_CNUM_EVT
|
||||
*/
|
||||
struct hf_client_cnum_param {
|
||||
const char *number; /*!< phone number string */
|
||||
esp_hf_subscriber_service_type_t type; /*!< service type that the phone number relates to */
|
||||
} cnum; /*!< HF callback param of ESP_HF_CLIENT_CNUM_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BSIR_EVT
|
||||
*/
|
||||
struct hf_client_bsirparam {
|
||||
esp_hf_client_in_band_ring_state_t state; /*!< setting state of in-band ring tone */
|
||||
} bsir; /*!< HF callback param of ESP_HF_CLIENT_BSIR_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_HF_CLIENT_BINP_EVT
|
||||
*/
|
||||
struct hf_client_binp_param {
|
||||
const char *number; /*!< phone number corresponding to the last voice tag in the HF */
|
||||
} binp; /*!< HF callback param of ESP_HF_CLIENT_BINP_EVT */
|
||||
|
||||
} esp_hf_client_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief HFP client incoming data callback function, the callback is useful in case of
|
||||
* Voice Over HCI.
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*/
|
||||
typedef void (* esp_hf_client_incoming_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief HFP client outgoing data callback function, the callback is useful in case of
|
||||
* Voice Over HCI. Once audio connection is set up and the application layer has
|
||||
* prepared data to send, the lower layer will call this function to read data
|
||||
* and then send. This callback is supposed to be implemented as non-blocking,
|
||||
* and if data is not enough, return value 0 is supposed.
|
||||
*
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
* @param[out] length of data successfully read
|
||||
*/
|
||||
typedef uint32_t (* esp_hf_client_outgoing_data_cb_t)(uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief HFP client callback function type
|
||||
*
|
||||
* @param event : Event type
|
||||
*
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_hf_client_cb_t)(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to HFP client module. This function should be called
|
||||
* only after esp_bluedroid_enable() completes successfully, used by HFP client
|
||||
*
|
||||
* @param[in] callback: HFP client event callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_register_callback(esp_hf_client_cb_t callback);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth HFP client module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for HFP client module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect to remote bluetooth HFP audio gateway(AG) device, must after esp_a2d_hf_client_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: connect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect from the remote HFP audio gateway
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Create audio connection with remote HFP AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_connect_audio(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Release the established audio connection with remote HFP AG.
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_disconnect_audio(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Enable voice recognition in the AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_start_voice_recognition(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disable voice recognition in the AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_stop_voice_recognition(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Volume synchronization with AG. As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] type: volume control target, speaker or microphone
|
||||
* @param[in] volume: gain of the speaker of microphone, ranges 0 to 15
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_volume_update(esp_hf_volume_control_target_t type, int volume);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Place a call with a specified number, if number is NULL, last called number is
|
||||
* called. As a precondition to use this API, Service Level Connection shall
|
||||
* exist with AG
|
||||
*
|
||||
* @param[in] number: number string of the call. If NULL, the last number is called(aka re-dial)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_dial(const char *number);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Place a call with number specified by location(speed dial). As a precondition,
|
||||
* to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] location: location of the number in the memory
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
|
||||
esp_err_t esp_hf_client_dial_memory(int location);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Send call hold and multiparty commands, or enhanced call control commands(Use AT+CHLD).
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] chld: AT+CHLD call hold and multiparty handling AT command.
|
||||
* @param[in] idx: used in Enhanced Call Control Mechanisms, used if chld is
|
||||
* ESP_HF_CHLD_TYPE_REL_X or ESP_HF_CHLD_TYPE_PRIV_X
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_send_chld_cmd(esp_hf_chld_type_t chld, int idx);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Send response and hold action command(Send AT+BTRH command)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] btrh: response and hold action to send
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_send_btrh_cmd(esp_hf_btrh_cmd_t btrh);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Answer an incoming call(send ATA command). As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_answer_call(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Reject an incoming call(send AT+CHUP command), As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_reject_call(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Query list of current calls in AG(send AT+CLCC command), As a precondition to use this API,
|
||||
* Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_query_current_calls(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Query the name of currently selected network operator in AG(use AT+COPS commands)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_query_current_operator_name(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get subscriber information number from AG(send AT+CNUM command)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_retrieve_subscriber_info(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Transmit DTMF codes during an ongoing call(use AT+VTS commands)
|
||||
* As a precondition to use this API, Service Level Connection shall exist with AG
|
||||
*
|
||||
* @param[in] code: dtmf code, single ascii character in the set 0-9, #, *, A-D
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_send_dtmf(char code);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Request a phone number from AG corresponding to last voice tag recorded
|
||||
* (send AT+BINP command). As a precondition to use this API, Service Level
|
||||
* Connection shall exist with AG
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_request_last_voice_tag_number(void);
|
||||
|
||||
/**
|
||||
* @brief Register HFP client data output function; the callback is only used in
|
||||
* the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] recv: HFP client incoming data callback function
|
||||
* @param[in] send: HFP client outgoing data callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_hf_client_register_data_callback(esp_hf_client_incoming_data_cb_t recv,
|
||||
esp_hf_client_outgoing_data_cb_t send);
|
||||
|
||||
/**
|
||||
* @brief Trigger the lower-layer to fetch and send audio data. This function is only
|
||||
* only used in the case that Voice Over HCI is enabled. Precondition is that
|
||||
* the HFP audio connection is connected. After this function is called, lower
|
||||
* layer will invoke esp_hf_client_outgoing_data_cb_t to fetch data
|
||||
*
|
||||
*/
|
||||
void esp_hf_client_outgoing_data_ready(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the down sampling converter. This is a utility function that can
|
||||
* only be used in the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] src_sps: original samples per second(source audio data, i.e. 48000, 32000,
|
||||
* 16000, 44100, 22050, 11025)
|
||||
* @param[in] bits: number of bits per pcm sample (16)
|
||||
* @param[in] channels: number of channels (i.e. mono(1), stereo(2)...)
|
||||
*/
|
||||
void esp_hf_client_pcm_resample_init(uint32_t src_sps, uint32_t bits, uint32_t channels);
|
||||
|
||||
/**
|
||||
* @brief Down sampling utility to convert high sampling rate into 8K/16bits 1-channel mode PCM
|
||||
* samples. This can only be used in the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] src: pointer to the buffer where the original smapling PCM are stored
|
||||
* @param[in] in_bytes: length of the input PCM sample buffer in byte
|
||||
* @param[in] dst: pointer to the buffer which is to be used to store the converted PCM samples
|
||||
*
|
||||
* @return number of samples converted
|
||||
*/
|
||||
int32_t esp_hf_client_pcm_resample(void *src, uint32_t in_bytes, void *dst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_HF_CLIENT_API_H__ */
|
||||
@@ -1,181 +0,0 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_HF_DEFS_H__
|
||||
#define __ESP_HF_DEFS_H__
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/// Bluetooth HFP audio volume control target
|
||||
typedef enum {
|
||||
ESP_HF_VOLUME_CONTROL_TARGET_SPK = 0, /*!< speaker */
|
||||
ESP_HF_VOLUME_CONTROL_TARGET_MIC, /*!< microphone */
|
||||
} esp_hf_volume_control_target_t;
|
||||
|
||||
/// +CIND roaming status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_ROAMING_STATUS_INACTIVE = 0, /*!< roaming is not active */
|
||||
ESP_HF_ROAMING_STATUS_ACTIVE, /*!< a roaming is active */
|
||||
} esp_hf_roaming_status_t;
|
||||
|
||||
/// +CIND call status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_STATUS_NO_CALLS = 0, /*!< no call in progress */
|
||||
ESP_HF_CALL_STATUS_CALL_IN_PROGRESS = 1, /*!< call is present(active or held) */
|
||||
} esp_hf_call_status_t;
|
||||
|
||||
/// +CIND call setup status indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_SETUP_STATUS_NONE = 0, /*!< no call setup in progress */
|
||||
ESP_HF_CALL_SETUP_STATUS_INCOMING = 1, /*!< incoming call setup in progress */
|
||||
ESP_HF_CALL_SETUP_STATUS_OUTGOING_DIALING = 2, /*!< outgoing call setup in dialing state */
|
||||
ESP_HF_CALL_SETUP_STATUS_OUTGOING_ALERTING = 3, /*!< outgoing call setup in alerting state */
|
||||
} esp_hf_call_setup_status_t;
|
||||
|
||||
/// +CIND call held indicator values
|
||||
typedef enum {
|
||||
ESP_HF_CALL_HELD_STATUS_NONE = 0, /*!< no calls held */
|
||||
ESP_HF_CALL_HELD_STATUS_HELD_AND_ACTIVE = 1, /*!< both active and held call */
|
||||
ESP_HF_CALL_HELD_STATUS_HELD = 2, /*!< call on hold, no active call*/
|
||||
} esp_hf_call_held_status_t;
|
||||
|
||||
/// +CIND network service availability status
|
||||
typedef enum {
|
||||
ESP_HF_SERVICE_AVAILABILITY_STATUS_UNAVAILABLE = 0, /*!< service not available */
|
||||
ESP_HF_SERVICE_AVAILABILITY_STATUS_AVAILABLE, /*!< service available */
|
||||
} esp_hf_service_availability_status_t;
|
||||
|
||||
/// +CLCC status of the call
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_STATUS_ACTIVE = 0, /*!< active */
|
||||
ESP_HF_CURRENT_CALL_STATUS_HELD = 1, /*!< held */
|
||||
ESP_HF_CURRENT_CALL_STATUS_DIALING = 2, /*!< dialing (outgoing calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_ALERTING = 3, /*!< alerting (outgoing calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_INCOMING = 4, /*!< incoming (incoming calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_WAITING = 5, /*!< waiting (incoming calls only) */
|
||||
ESP_HF_CURRENT_CALL_STATUS_HELD_BY_RESP_HOLD = 6, /*!< call held by response and hold */
|
||||
} esp_hf_current_call_status_t;
|
||||
|
||||
/// +CLCC direction of the call
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_DIRECTION_OUTGOING = 0, /*!< outgoing */
|
||||
ESP_HF_CURRENT_CALL_DIRECTION_INCOMING = 1, /*!< incoming */
|
||||
} esp_hf_current_call_direction_t;
|
||||
|
||||
/// +CLCC multi-party call flag
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_MPTY_TYPE_SINGLE = 0, /*!< not a member of a multi-party call */
|
||||
ESP_HF_CURRENT_CALL_MPTY_TYPE_MULTI = 1, /*!< member of a multi-party call */
|
||||
} esp_hf_current_call_mpty_type_t;
|
||||
|
||||
/// +CLCC call mode
|
||||
typedef enum {
|
||||
ESP_HF_CURRENT_CALL_MODE_VOICE = 0,
|
||||
ESP_HF_CURRENT_CALL_MODE_DATA = 1,
|
||||
ESP_HF_CURRENT_CALL_MODE_FAX = 2,
|
||||
} esp_hf_current_call_mode_t;
|
||||
|
||||
/// +CLCC address type
|
||||
typedef enum {
|
||||
ESP_HF_CALL_ADDR_TYPE_UNKNOWN = 0x81, /*!< unkown address type */
|
||||
ESP_HF_CALL_ADDR_TYPE_INTERNATIONAL = 0x91, /*!< international address */
|
||||
} esp_hf_call_addr_type_t;
|
||||
|
||||
/// +CNUM service type of the phone number
|
||||
typedef enum {
|
||||
ESP_HF_SUBSCRIBER_SERVICE_TYPE_UNKNOWN = 0, /*!< unknown */
|
||||
ESP_HF_SUBSCRIBER_SERVICE_TYPE_VOICE, /*!< voice service */
|
||||
ESP_HF_SUBSCRIBER_SERVICE_TYPE_FAX, /*!< fax service */
|
||||
} esp_hf_subscriber_service_type_t;
|
||||
|
||||
/// +BTRH response and hold result code
|
||||
typedef enum {
|
||||
ESP_HF_BTRH_STATUS_HELD = 0, /*!< incoming call is put on held in AG */
|
||||
ESP_HF_BTRH_STATUS_ACCEPTED, /*!< held incoming call is accepted in AG */
|
||||
ESP_HF_BTRH_STATUS_REJECTED, /*!< held incoming call is rejected in AG */
|
||||
} esp_hf_btrh_status_t;
|
||||
|
||||
/// AT+BTRH response and hold action code
|
||||
typedef enum {
|
||||
ESP_HF_BTRH_CMD_HOLD = 0, /*!< put the incoming call on hold */
|
||||
ESP_HF_BTRH_CMD_ACCEPT = 1, /*!< accept a held incoming call */
|
||||
ESP_HF_BTRH_CMD_REJECT = 2, /*!< reject a held incoming call */
|
||||
} esp_hf_btrh_cmd_t;
|
||||
|
||||
/// response indication codes for AT commands
|
||||
typedef enum {
|
||||
ESP_HF_AT_RESPONSE_CODE_OK = 0, /*!< acknoweledges execution of a command line */
|
||||
ESP_HF_AT_RESPONSE_CODE_ERR, /*!< command not accepted */
|
||||
ESP_HF_AT_RESPONSE_CODE_NO_CARRIER, /*!< connection terminated */
|
||||
ESP_HF_AT_RESPONSE_CODE_BUSY, /*!< busy signal detected */
|
||||
ESP_HF_AT_RESPONSE_CODE_NO_ANSWER, /*!< connection completion timeout */
|
||||
ESP_HF_AT_RESPONSE_CODE_DELAYED, /*!< delayed */
|
||||
ESP_HF_AT_RESPONSE_CODE_BLACKLISTED, /*!< blacklisted */
|
||||
ESP_HF_AT_RESPONSE_CODE_CME, /*!< CME error */
|
||||
} esp_hf_at_response_code_t;
|
||||
|
||||
/// voice recognition state
|
||||
typedef enum {
|
||||
ESP_HF_VR_STATE_DISABLED = 0, /*!< voice recognition disabled */
|
||||
ESP_HF_VR_STATE_ENABLED, /*!< voice recognition enabled */
|
||||
} esp_hf_vr_state_t;
|
||||
|
||||
/// AT+CHLD command values
|
||||
typedef enum {
|
||||
ESP_HF_CHLD_TYPE_REL = 0, /*!< <0>, Terminate all held or set UDUB("busy") to a waiting call */
|
||||
ESP_HF_CHLD_TYPE_REL_ACC, /*!< <1>, Terminate all active calls and accepts a waiting/held call */
|
||||
ESP_HF_CHLD_TYPE_HOLD_ACC, /*!< <2>, Hold all active calls and accepts a waiting/held call */
|
||||
ESP_HF_CHLD_TYPE_MERGE, /*!< <3>, Add all held calls to a conference */
|
||||
ESP_HF_CHLD_TYPE_MERGE_DETACH, /*!< <4>, connect the two calls and disconnects the subscriber from both calls */
|
||||
ESP_HF_CHLD_TYPE_REL_X, /*!< <1x>, releases specified calls only */
|
||||
ESP_HF_CHLD_TYPE_PRIV_X, /*!< <2x>, request private consultation mode with specified call */
|
||||
} esp_hf_chld_type_t;
|
||||
|
||||
/// Extended Audio Gateway Error Result Code Response
|
||||
typedef enum {
|
||||
ESP_HF_CME_AG_FAILURE = 0, /*!< ag failure */
|
||||
ESP_HF_CME_NO_CONNECTION_TO_PHONE = 1, /*!< no connection to phone */
|
||||
ESP_HF_CME_OPERATION_NOT_ALLOWED = 3, /*!< operation not allowed */
|
||||
ESP_HF_CME_OPERATION_NOT_SUPPORTED = 4, /*!< operation not supported */
|
||||
ESP_HF_CME_PH_SIM_PIN_REQUIRED = 5, /*!< PH-SIM PIN Required */
|
||||
ESP_HF_CME_SIM_NOT_INSERTED = 10, /*!< SIM not inserted */
|
||||
ESP_HF_CME_SIM_PIN_REQUIRED = 11, /*!< SIM PIN required */
|
||||
ESP_HF_CME_SIM_PUK_REQUIRED = 12, /*!< SIM PUK required */
|
||||
ESP_HF_CME_SIM_FAILURE = 13, /*!< SIM failure */
|
||||
ESP_HF_CME_SIM_BUSY = 14, /*!< SIM busy */
|
||||
ESP_HF_CME_INCORRECT_PASSWORD = 16, /*!< incorrect password */
|
||||
ESP_HF_CME_SIM_PIN2_REQUIRED = 17, /*!< SIM PIN2 required */
|
||||
ESP_HF_CME_SIM_PUK2_REQUIRED = 18, /*!< SIM PUK2 required */
|
||||
ESP_HF_CME_MEMEORY_FULL = 20, /*!< memory full */
|
||||
ESP_HF_CME_INVALID_INDEX = 21, /*!< invalid index */
|
||||
ESP_HF_CME_MEMEORY_FAILURE = 23, /*!< memory failure */
|
||||
ESP_HF_CME_TEXT_STRING_TOO_LONG = 24, /*!< test string too long */
|
||||
ESP_HF_CME_INVALID_CHARACTERS_IN_TEXT_STRING = 25, /*!< invalid characters in text string */
|
||||
ESP_HF_CME_DIAL_STRING_TOO_LONG = 26, /*!< dial string too long*/
|
||||
ESP_HF_CME_INVALID_CHARACTERS_IN_DIAL_STRING = 27, /*!< invalid characters in dial string */
|
||||
ESP_HF_CME_NO_NETWORK_SERVICE = 30, /*!< no network service */
|
||||
ESP_HF_CME_NETWORK_TIMEOUT = 31, /*!< network timeout */
|
||||
ESP_HF_CME_NETWORK_NOT_ALLOWED = 32, /*!< network not allowed --emergency calls only */
|
||||
} esp_hf_cme_err_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_HF_DEFS_H__ */
|
||||
@@ -1,305 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_SPP_API_H__
|
||||
#define __ESP_SPP_API_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_SPP_SUCCESS = 0, /*!< Successful operation. */
|
||||
ESP_SPP_FAILURE, /*!< Generic failure. */
|
||||
ESP_SPP_BUSY, /*!< Temporarily can not handle this request. */
|
||||
ESP_SPP_NO_DATA, /*!< no data. */
|
||||
ESP_SPP_NO_RESOURCE /*!< No more set pm control block */
|
||||
} esp_spp_status_t;
|
||||
|
||||
/* Security Setting Mask */
|
||||
#define ESP_SPP_SEC_NONE 0x0000 /*!< No security. relate to BTA_SEC_NONE in bta/bta_api.h */
|
||||
#define ESP_SPP_SEC_AUTHORIZE 0x0001 /*!< Authorization required (only needed for out going connection ) relate to BTA_SEC_AUTHORIZE in bta/bta_api.h*/
|
||||
#define ESP_SPP_SEC_AUTHENTICATE 0x0012 /*!< Authentication required. relate to BTA_SEC_AUTHENTICATE in bta/bta_api.h*/
|
||||
#define ESP_SPP_SEC_ENCRYPT 0x0024 /*!< Encryption required. relate to BTA_SEC_ENCRYPT in bta/bta_api.h*/
|
||||
#define ESP_SPP_SEC_MODE4_LEVEL4 0x0040 /*!< Mode 4 level 4 service, i.e. incoming/outgoing MITM and P-256 encryption relate to BTA_SEC_MODE4_LEVEL4 in bta/bta_api.h*/
|
||||
#define ESP_SPP_SEC_MITM 0x3000 /*!< Man-In-The_Middle protection relate to BTA_SEC_MITM in bta/bta_api.h*/
|
||||
#define ESP_SPP_SEC_IN_16_DIGITS 0x4000 /*!< Min 16 digit for pin code relate to BTA_SEC_IN_16_DIGITS in bta/bta_api.h*/
|
||||
typedef uint16_t esp_spp_sec_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_SPP_ROLE_MASTER = 0, /*!< Role: master */
|
||||
ESP_SPP_ROLE_SLAVE = 1, /*!< Role: slave */
|
||||
} esp_spp_role_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_SPP_MODE_CB = 0, /*!< When data is coming, a callback will come with data */
|
||||
ESP_SPP_MODE_VFS = 1, /*!< Use VFS to write/read data */
|
||||
} esp_spp_mode_t;
|
||||
|
||||
#define ESP_SPP_MAX_MTU (3*330) /*!< SPP max MTU */
|
||||
#define ESP_SPP_MAX_SCN 31 /*!< SPP max SCN */
|
||||
/**
|
||||
* @brief SPP callback function events
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_SPP_INIT_EVT = 0, /*!< When SPP is inited, the event comes */
|
||||
ESP_SPP_DISCOVERY_COMP_EVT = 8, /*!< When SDP discovery complete, the event comes */
|
||||
ESP_SPP_OPEN_EVT = 26, /*!< When SPP Client connection open, the event comes */
|
||||
ESP_SPP_CLOSE_EVT = 27, /*!< When SPP connection closed, the event comes */
|
||||
ESP_SPP_START_EVT = 28, /*!< When SPP server started, the event comes */
|
||||
ESP_SPP_CL_INIT_EVT = 29, /*!< When SPP client initiated a connection, the event comes */
|
||||
ESP_SPP_DATA_IND_EVT = 30, /*!< When SPP connection received data, the event comes, olny for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_CONG_EVT = 31, /*!< When SPP connection congestion status changed, the event comes, olny for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes, olny for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */
|
||||
} esp_spp_cb_event_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief SPP callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* @brief SPP_INIT_EVT
|
||||
*/
|
||||
struct spp_init_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
} init; /*!< SPP callback param of SPP_INIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief SPP_DISCOVERY_COMP_EVT
|
||||
*/
|
||||
struct spp_discovery_comp_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint8_t scn_num; /*!< The num of scn_num */
|
||||
uint8_t scn[ESP_SPP_MAX_SCN]; /*!< channel # */
|
||||
} disc_comp; /*!< SPP callback param of SPP_DISCOVERY_COMP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_OPEN_EVT
|
||||
*/
|
||||
struct spp_open_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
int fd; /*!< The file descriptor olny for ESP_SPP_MODE_VFS*/
|
||||
esp_bd_addr_t rem_bda; /*!< The peer address */
|
||||
} open; /*!< SPP callback param of ESP_SPP_OPEN_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_SRV_OPEN_EVT
|
||||
*/
|
||||
struct spp_srv_open_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint32_t new_listen_handle; /*!< The new listen handle */
|
||||
int fd; /*!< The file descriptor olny for ESP_SPP_MODE_VFS*/
|
||||
esp_bd_addr_t rem_bda; /*!< The peer address */
|
||||
} srv_open; /*!< SPP callback param of ESP_SPP_SRV_OPEN_EVT */
|
||||
/**
|
||||
* @brief ESP_SPP_CLOSE_EVT
|
||||
*/
|
||||
struct spp_close_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t port_status; /*!< PORT status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
bool async; /*!< FALSE, if local initiates disconnect */
|
||||
} close; /*!< SPP callback param of ESP_SPP_CLOSE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_START_EVT
|
||||
*/
|
||||
struct spp_start_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint8_t sec_id; /*!< security ID used by this server */
|
||||
bool use_co; /*!< TRUE to use co_rfc_data */
|
||||
} start; /*!< SPP callback param of ESP_SPP_START_EVT */
|
||||
/**
|
||||
* @brief ESP_SPP_CL_INIT_EVT
|
||||
*/
|
||||
struct spp_cl_init_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint8_t sec_id; /*!< security ID used by this server */
|
||||
bool use_co; /*!< TRUE to use co_rfc_data */
|
||||
} cl_init; /*!< SPP callback param of ESP_SPP_CL_INIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_WRITE_EVT
|
||||
*/
|
||||
struct spp_write_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
int len; /*!< The length of the data written. */
|
||||
bool cong; /*!< congestion status */
|
||||
} write; /*!< SPP callback param of ESP_SPP_WRITE_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_DATA_IND_EVT
|
||||
*/
|
||||
struct spp_data_ind_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint16_t len; /*!< The length of data */
|
||||
uint8_t *data; /*!< The data recived */
|
||||
} data_ind; /*!< SPP callback param of ESP_SPP_DATA_IND_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_CONG_EVT
|
||||
*/
|
||||
struct spp_cong_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
bool cong; /*!< TRUE, congested. FALSE, uncongested */
|
||||
} cong; /*!< SPP callback param of ESP_SPP_CONG_EVT */
|
||||
} esp_spp_cb_param_t; /*!< SPP callback parameter union type */
|
||||
|
||||
/**
|
||||
* @brief SPP callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Point to callback parameter, currently is union type
|
||||
*/
|
||||
typedef void (esp_spp_cb_t)(esp_spp_cb_event_t event, esp_spp_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to init callbacks
|
||||
* with SPP module.
|
||||
*
|
||||
* @param[in] callback: pointer to the init callback function.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_register_callback(esp_spp_cb_t callback);
|
||||
|
||||
/**
|
||||
* @brief This function is called to init SPP.
|
||||
*
|
||||
* @param[in] mode: Choose the mode of SPP, ESP_SPP_MODE_CB or ESP_SPP_MODE_CB.
|
||||
* Now only supports ESP_SPP_MODE_CB mode, we will continue to update.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_init(esp_spp_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief This function is called to uninit SPP.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_deinit();
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to performs service discovery for
|
||||
* the services provided by the given peer device. When the
|
||||
* operation is complete the callback function will be called
|
||||
* with a ESP_SPP_DISCOVERY_COMP_EVT.
|
||||
*
|
||||
* @param[in] bd_addr: Remote device bluetooth device address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_start_discovery(esp_bd_addr_t bd_addr);
|
||||
|
||||
/**
|
||||
* @brief This function makes an SPP conection to a remote BD Address.
|
||||
* When the connection is initiated or failed to initiate,
|
||||
* the callback is called with ESP_SPP_CL_INIT_EVT.
|
||||
* When the connection is established or failed,
|
||||
* the callback is called with ESP_SPP_OPEN_EVT.
|
||||
*
|
||||
* @param[in] sec_mask: Security Setting Mask .
|
||||
* @param[in] role: Msater or slave.
|
||||
* @param[in] remote_scn: Remote device bluetooth device SCN.
|
||||
* @param[in] peer_bd_addr: Remote device bluetooth device address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_connect(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t remote_scn, esp_bd_addr_t peer_bd_addr);
|
||||
|
||||
/**
|
||||
* @brief This function closes an SPP connection.
|
||||
*
|
||||
* @param[in] handle: The connection handle.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_disconnect(uint32_t handle);
|
||||
|
||||
/**
|
||||
* @brief This function create a SPP server and starts listening for an
|
||||
* SPP connection request from a remote Bluetooth device.
|
||||
* When the server is started successfully, the callback is called
|
||||
* with ESP_SPP_START_EVT.
|
||||
* When the connection is established, the callback is called
|
||||
* with ESP_SPP_SRV_OPEN_EVT.
|
||||
*
|
||||
* @param[in] sec_mask: Security Setting Mask .
|
||||
* @param[in] role: Msater or slave.
|
||||
* @param[in] local_scn: The specific channel you want to get.
|
||||
* If channel is 0, means get any channel.
|
||||
* @param[in] name: Server's name.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t local_scn, const char *name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is used to write data, olny for ESP_SPP_MODE_CB.
|
||||
*
|
||||
* @param[in] handle: The connection handle.
|
||||
* @param[in] len: The length of the data written.
|
||||
* @param[in] p_data: The data written.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is used to register VFS.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_vfs_register(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif ///__ESP_SPP_API_H__
|
||||
@@ -67,28 +67,11 @@ typedef enum {
|
||||
ESP_A2D_AUDIO_STATE_STARTED, /*!< audio stream datapath started */
|
||||
} esp_a2d_audio_state_t;
|
||||
|
||||
/// A2DP media control command acknowledgement code
|
||||
typedef enum {
|
||||
ESP_A2D_MEDIA_CTRL_ACK_SUCCESS = 0, /*!< media control command is acknowledged with success */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_FAILURE, /*!< media control command is acknowledged with failure */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_BUSY, /*!< media control command is rejected, as previous command is not yet acknowledged */
|
||||
} esp_a2d_media_ctrl_ack_t;
|
||||
|
||||
/// A2DP media control commands
|
||||
typedef enum {
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
|
||||
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
|
||||
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
|
||||
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */
|
||||
ESP_A2D_MEDIA_CTRL_SUSPEND, /*!< command to suspend media transmission */
|
||||
} esp_a2d_media_ctrl_t;
|
||||
|
||||
/// A2DP callback events
|
||||
typedef enum {
|
||||
ESP_A2D_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
|
||||
ESP_A2D_AUDIO_STATE_EVT, /*!< audio stream transmission state changed event */
|
||||
ESP_A2D_AUDIO_CFG_EVT, /*!< audio codec is configured, only used for A2DP SINK */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_EVT, /*!< acknowledge event in response to media control commands */
|
||||
ESP_A2D_AUDIO_STATE_EVT = 1, /*!< audio stream transmission state changed event */
|
||||
ESP_A2D_AUDIO_CFG_EVT = 2 /*!< audio codec is configured */
|
||||
} esp_a2d_cb_event_t;
|
||||
|
||||
/// A2DP state callback parameters
|
||||
@@ -101,7 +84,7 @@ typedef union {
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
esp_a2d_disc_rsn_t disc_rsn; /*!< reason of disconnection for "DISCONNECTED" */
|
||||
} conn_stat; /*!< A2DP connection status */
|
||||
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_AUDIO_STATE_EVT
|
||||
*/
|
||||
@@ -109,7 +92,7 @@ typedef union {
|
||||
esp_a2d_audio_state_t state; /*!< one of the values from esp_a2d_audio_state_t */
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
} audio_stat; /*!< audio stream playing state */
|
||||
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_AUDIO_CFG_EVT
|
||||
*/
|
||||
@@ -117,52 +100,32 @@ typedef union {
|
||||
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
|
||||
esp_a2d_mcc_t mcc; /*!< A2DP media codec capability information */
|
||||
} audio_cfg; /*!< media codec configuration infomation */
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_MEDIA_CTRL_ACK_EVT
|
||||
*/
|
||||
struct media_ctrl_stat_param {
|
||||
esp_a2d_media_ctrl_t cmd; /*!< media control commands to acknowledge */
|
||||
esp_a2d_media_ctrl_ack_t status; /*!< acknowledgement to media control commands */
|
||||
} media_ctrl_stat; /*!< status in acknowledgement to media control commands */
|
||||
} esp_a2d_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief A2DP profile callback function type
|
||||
*
|
||||
* @param event : Event type
|
||||
*
|
||||
* @param param : Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_a2d_cb_t)(esp_a2d_cb_event_t event, esp_a2d_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief A2DP profile data callback function
|
||||
*
|
||||
* @param[in] buf : data received from A2DP source device and is PCM format decoder from SBC decoder;
|
||||
* buf references to a static memory block and can be overwritten by upcoming data
|
||||
*
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
*
|
||||
*/
|
||||
typedef void (* esp_a2d_sink_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
typedef void (* esp_a2d_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief A2DP source data read callback function
|
||||
*
|
||||
* @param[in] buf : buffer to be filled with PCM data stream from higer layer
|
||||
*
|
||||
* @param[in] len : size(in bytes) of data block to be copied to buf. -1 is an indication to user
|
||||
* that data buffer shall be flushed
|
||||
*
|
||||
* @return size of bytes read successfully, if the argumetn len is -1, this value is ignored.
|
||||
*
|
||||
*/
|
||||
typedef int32_t (* esp_a2d_source_data_cb_t)(uint8_t *buf, int32_t len);
|
||||
|
||||
/**
|
||||
* @brief Register application callback function to A2DP module. This function should be called
|
||||
* only after esp_bluedroid_enable() completes successfully, used by both A2DP source
|
||||
* and sink.
|
||||
*
|
||||
* @param[in] callback: A2DP event callback function
|
||||
* only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @param[in] callback: A2DP sink event callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
@@ -179,7 +142,7 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
|
||||
* completes successfully, used only by A2DP sink. The callback is invoked in the context
|
||||
* of A2DP sink task whose stack size is configurable through menuconfig
|
||||
*
|
||||
* @param[in] callback: A2DP sink data callback function
|
||||
* @param[in] callback: A2DP data callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
@@ -187,7 +150,7 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback);
|
||||
esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
@@ -195,7 +158,7 @@ esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback);
|
||||
* @brief Initialize the bluetooth A2DP sink module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
@@ -206,10 +169,10 @@ esp_err_t esp_a2d_sink_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for A2DP sink module. This function
|
||||
* @brief De-initialize for A2DP sink module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
@@ -220,11 +183,11 @@ esp_err_t esp_a2d_sink_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect to remote bluetooth A2DP source device, must after esp_a2d_sink_init()
|
||||
* @brief Connect the remote bluetooth device bluetooth, must after esp_a2d_sink_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_OK: connect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
@@ -235,10 +198,10 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect from the remote A2DP source device
|
||||
* @brief Disconnect the remote bluetooth device
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
@@ -246,94 +209,6 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda);
|
||||
*/
|
||||
esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief media control commands; this API can be used for both A2DP sink and source
|
||||
*
|
||||
* @param[in] ctrl: control commands for A2DP data channel
|
||||
* @return
|
||||
* - ESP_OK: control command is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth A2DP source module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_init(void);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for A2DP source module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Register A2DP source data input function; For now the input is PCM data stream.
|
||||
* This function should be called only after esp_bluedroid_enable() completes
|
||||
* successfully. The callback is invoked in the context of A2DP source task whose
|
||||
* stack size is configurable through menuconfig
|
||||
*
|
||||
* @param[in] callback: A2DP source data callback function
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: if callback is a NULL function pointer
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_register_data_callback(esp_a2d_source_data_cb_t callback);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect to remote A2DP sink device, must after esp_a2d_source_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: connect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_connect(esp_bd_addr_t remote_bda);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Disconnect from the remote A2DP sink device
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
* @return
|
||||
* - ESP_OK: disconnect request is sent to lower layer
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_a2d_source_disconnect(esp_bd_addr_t remote_bda);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -50,9 +50,6 @@ typedef enum {
|
||||
ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY, /*<! When Phone send Client Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY, /*<! When Phone send Server Private key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_SLAVE_DISCONNECT_BLE, /*<! When Phone send Disconnect key to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_GET_WIFI_LIST, /*<! When Phone send get wifi list command to ESP32, this event happen */
|
||||
ESP_BLUFI_EVENT_REPORT_ERROR, /*<! When Blufi report error, this event happen */
|
||||
ESP_BLUFI_EVENT_RECV_CUSTOM_DATA, /*<! When Phone send custom data to ESP32, this event happen */
|
||||
} esp_blufi_cb_event_t;
|
||||
|
||||
/// BLUFI config status
|
||||
@@ -64,27 +61,15 @@ typedef enum {
|
||||
/// BLUFI init status
|
||||
typedef enum {
|
||||
ESP_BLUFI_INIT_OK = 0,
|
||||
ESP_BLUFI_INIT_FAILED,
|
||||
ESP_BLUFI_INIT_FAILED = 0,
|
||||
} esp_blufi_init_state_t;
|
||||
|
||||
/// BLUFI deinit status
|
||||
typedef enum {
|
||||
ESP_BLUFI_DEINIT_OK = 0,
|
||||
ESP_BLUFI_DEINIT_FAILED,
|
||||
ESP_BLUFI_DEINIT_FAILED = 0,
|
||||
} esp_blufi_deinit_state_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLUFI_SEQUENCE_ERROR = 0,
|
||||
ESP_BLUFI_CHECKSUM_ERROR,
|
||||
ESP_BLUFI_DECRYPT_ERROR,
|
||||
ESP_BLUFI_ENCRYPT_ERROR,
|
||||
ESP_BLUFI_INIT_SECURITY_ERROR,
|
||||
ESP_BLUFI_DH_MALLOC_ERROR,
|
||||
ESP_BLUFI_DH_PARAM_ERROR,
|
||||
ESP_BLUFI_READ_PARAM_ERROR,
|
||||
ESP_BLUFI_MAKE_PUBLIC_ERROR,
|
||||
} esp_blufi_error_state_t;
|
||||
|
||||
/**
|
||||
* @brief BLUFI extra information structure
|
||||
*/
|
||||
@@ -108,12 +93,6 @@ typedef struct {
|
||||
bool softap_channel_set; /*!< is channel of softap interface set */
|
||||
} esp_blufi_extra_info_t;
|
||||
|
||||
/** @brief Description of an WiFi AP */
|
||||
typedef struct {
|
||||
uint8_t ssid[33]; /**< SSID of AP */
|
||||
int8_t rssi; /**< signal strength of AP */
|
||||
} esp_blufi_ap_record_t;
|
||||
|
||||
/**
|
||||
* @brief BLUFI callback parameters union
|
||||
*/
|
||||
@@ -268,21 +247,7 @@ typedef union {
|
||||
uint8_t *pkey; /*!< Client Private Key point, if Client certificate not contain Key */
|
||||
int pkey_len; /*!< Client Private key length */
|
||||
} server_pkey; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY */
|
||||
/**
|
||||
* @brief
|
||||
* ESP_BLUFI_EVENT_REPORT_ERROR
|
||||
*/
|
||||
struct blufi_get_error_evt_param {
|
||||
esp_blufi_error_state_t state; /*!< Blufi error state */
|
||||
} report_error; /*!< Blufi callback param of ESP_BLUFI_EVENT_REPORT_ERROR */
|
||||
/**
|
||||
* @brief
|
||||
* ESP_BLUFI_EVENT_RECV_CUSTOM_DATA
|
||||
*/
|
||||
struct blufi_recv_custom_data_evt_param {
|
||||
uint8_t *data; /*!< Custom data */
|
||||
uint32_t data_len; /*!< Custom data Length */
|
||||
} custom_data; /*!< Blufi callback param of ESP_BLUFI_EVENT_RECV_CUSTOM_DATA */
|
||||
|
||||
} esp_blufi_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -382,17 +347,6 @@ esp_err_t esp_blufi_profile_deinit(void);
|
||||
*/
|
||||
esp_err_t esp_blufi_send_wifi_conn_report(wifi_mode_t opmode, esp_blufi_sta_conn_state_t sta_conn_state, uint8_t softap_conn_num, esp_blufi_extra_info_t *extra_info);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to send wifi list
|
||||
* @param apCount : wifi list count
|
||||
* @param list : wifi list
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_send_wifi_list(uint16_t apCount, esp_blufi_ap_record_t *list);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Get BLUFI profile version
|
||||
@@ -414,26 +368,6 @@ uint16_t esp_blufi_get_version(void);
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_close(esp_gatt_if_t gatts_if, uint16_t conn_id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to send blufi error information
|
||||
* @param state : error state
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_send_error_info(esp_blufi_error_state_t state);
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to custom data
|
||||
* @param data : custom data value
|
||||
* @param data_len : the length of custom data
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_blufi_send_custom_data(uint8_t *data, uint32_t data_len);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -48,9 +48,9 @@ typedef enum {
|
||||
ESP_BT_STATUS_UNACCEPT_CONN_INTERVAL, /* relate to BT_UNACCEPT_CONN_INTERVAL in bt_def.h */
|
||||
ESP_BT_STATUS_PARAM_OUT_OF_RANGE, /* relate to BT_PARAM_OUT_OF_RANGE in bt_def.h */
|
||||
ESP_BT_STATUS_TIMEOUT, /* relate to BT_STATUS_TIMEOUT in bt_def.h */
|
||||
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in stack/btm_api.h */
|
||||
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in stack/btm_api.h */
|
||||
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in stack/hcidefs.h */
|
||||
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
||||
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
|
||||
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in hcidefs.h */
|
||||
ESP_BT_STATUS_MEMORY_FULL, /* relate to BT_STATUS_MEMORY_FULL in bt_def.h */
|
||||
} esp_bt_status_t;
|
||||
|
||||
@@ -67,13 +67,13 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
|
||||
/// Default GATT interface id
|
||||
#define ESP_DEFAULT_GATT_IF 0xff
|
||||
|
||||
#define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 500 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ /* relate to ESP_BLE_CONN_PARAM_UNDEF in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_SCAN_PARAM_UNDEF 0xffffffff /* relate to ESP_BLE_SCAN_PARAM_UNDEF in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 500 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ /* relate to ESP_BLE_CONN_PARAM_UNDEF in btm_ble_api.h */
|
||||
#define ESP_BLE_SCAN_PARAM_UNDEF 0xffffffff /* relate to ESP_BLE_SCAN_PARAM_UNDEF in btm_ble_api.h */
|
||||
|
||||
/// Check the param is valid or not
|
||||
#define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
@@ -113,13 +113,13 @@ typedef enum {
|
||||
} esp_ble_addr_type_t;
|
||||
|
||||
/// Used to exchange the encrytyption key in the init key & response key
|
||||
#define ESP_BLE_ENC_KEY_MASK (1 << 0) /* relate to BTM_BLE_ENC_KEY_MASK in stack/btm_api.h */
|
||||
#define ESP_BLE_ENC_KEY_MASK (1 << 0) /* relate to BTM_BLE_ENC_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the IRK key in the init key & response key
|
||||
#define ESP_BLE_ID_KEY_MASK (1 << 1) /* relate to BTM_BLE_ID_KEY_MASK in stack/btm_api.h */
|
||||
#define ESP_BLE_ID_KEY_MASK (1 << 1) /* relate to BTM_BLE_ID_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the CSRK key in the init key & response key
|
||||
#define ESP_BLE_CSR_KEY_MASK (1 << 2) /* relate to BTM_BLE_CSR_KEY_MASK in stack/btm_api.h */
|
||||
#define ESP_BLE_CSR_KEY_MASK (1 << 2) /* relate to BTM_BLE_CSR_KEY_MASK in btm_api.h */
|
||||
/// Used to exchange the link key(this key just used in the BLE & BR/EDR coexist mode) in the init key & response key
|
||||
#define ESP_BLE_LINK_KEY_MASK (1 << 3) /* relate to BTM_BLE_LINK_KEY_MASK in stack/btm_api.h */
|
||||
#define ESP_BLE_LINK_KEY_MASK (1 << 3) /* relate to BTM_BLE_LINK_KEY_MASK in btm_api.h */
|
||||
typedef uint8_t esp_ble_key_mask_t; /* the key mask type */
|
||||
|
||||
/// Minimum of the application id
|
||||
@@ -27,24 +27,22 @@ extern "C" {
|
||||
/**
|
||||
*
|
||||
* @brief Get bluetooth device address. Must use after "esp_bluedroid_enable".
|
||||
*
|
||||
*
|
||||
* @return bluetooth device address (six bytes), or NULL if bluetooth stack is not enabled
|
||||
*/
|
||||
const uint8_t *esp_bt_dev_get_address(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set bluetooth device name. This function should be called after esp_bluedroid_enable()
|
||||
* completes successfully.
|
||||
* A BR/EDR/LE device type shall have a single Bluetooth device name which shall be
|
||||
* identical irrespective of the physical channel used to perform the name discovery procedure.
|
||||
* @brief Set bluetooth device name. This function should be called after esp_bluedroid_enable()
|
||||
* completes successfully
|
||||
*
|
||||
* @param[in] name : device name to be set
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_ARG : if name is NULL pointer or empty, or string length out of limit
|
||||
* - ESP_ERR_INVALID_STATE : if bluetooth stack is not yet enabled
|
||||
* - ESP_INVALID_STATE : if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL : others
|
||||
*/
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name);
|
||||
@@ -38,94 +38,34 @@ extern "C" {
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* relate to BTM_LE_KEY_xxx in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_NONE 0 /* relate to BTM_LE_KEY_NONE in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */ /* relate to BTM_LE_KEY_PENC in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */ /* relate to BTM_LE_KEY_PID in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */ /* relate to BTM_LE_KEY_PCSRK in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/ /* relate to BTM_LE_KEY_PLK in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4) /* relate to BTM_LE_KEY_LLK in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */ /* relate to BTM_LE_KEY_LENC in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */ /* relate to BTM_LE_KEY_LID in stack/btm_api.h */
|
||||
#define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */ /* relate to BTM_LE_KEY_LCSRK in stack/btm_api.h */
|
||||
/* relate to BTM_LE_KEY_xxx in btm_api.h */
|
||||
#define ESP_LE_KEY_NONE 0 /* relate to BTM_LE_KEY_NONE in btm_api.h */
|
||||
#define ESP_LE_KEY_PENC (1 << 0) /*!< encryption key, encryption information of peer device */ /* relate to BTM_LE_KEY_PENC in btm_api.h */
|
||||
#define ESP_LE_KEY_PID (1 << 1) /*!< identity key of the peer device */ /* relate to BTM_LE_KEY_PID in btm_api.h */
|
||||
#define ESP_LE_KEY_PCSRK (1 << 2) /*!< peer SRK */ /* relate to BTM_LE_KEY_PCSRK in btm_api.h */
|
||||
#define ESP_LE_KEY_PLK (1 << 3) /*!< Link key*/ /* relate to BTM_LE_KEY_PLK in btm_api.h */
|
||||
#define ESP_LE_KEY_LLK (ESP_LE_KEY_PLK << 4) /* relate to BTM_LE_KEY_LLK in btm_api.h */
|
||||
#define ESP_LE_KEY_LENC (ESP_LE_KEY_PENC << 4) /*!< master role security information:div */ /* relate to BTM_LE_KEY_LENC in btm_api.h */
|
||||
#define ESP_LE_KEY_LID (ESP_LE_KEY_PID << 4) /*!< master device ID key */ /* relate to BTM_LE_KEY_LID in btm_api.h */
|
||||
#define ESP_LE_KEY_LCSRK (ESP_LE_KEY_PCSRK << 4) /*!< local CSRK has been deliver to peer */ /* relate to BTM_LE_KEY_LCSRK in btm_api.h */
|
||||
typedef uint8_t esp_ble_key_type_t;
|
||||
|
||||
/* relate to BTM_LE_AUTH_xxx in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/ /* relate to BTM_LE_AUTH_NO_BOND in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */ /* relate to BTM_LE_AUTH_BOND in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */ /* relate to BTM_LE_AUTH_REQ_MITM in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */ /* relate to BTM_LE_AUTH_REQ_SC_ONLY in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */ /* relate to BTM_LE_AUTH_REQ_SC_BOND in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM_BOND in stack/btm_api.h */
|
||||
/* relate to BTM_LE_AUTH_xxx in btm_api.h */
|
||||
#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/ /* relate to BTM_LE_AUTH_NO_BOND in btm_api.h */
|
||||
#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */ /* relate to BTM_LE_AUTH_BOND in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */ /* relate to BTM_LE_AUTH_REQ_MITM in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */ /* relate to BTM_LE_AUTH_REQ_SC_ONLY in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */ /* relate to BTM_LE_AUTH_REQ_SC_BOND in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM in btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM_BOND in btm_api.h */
|
||||
typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */
|
||||
|
||||
/* relate to BTM_IO_CAP_xxx in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ /* relate to BTM_IO_CAP_OUT in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ /* relate to BTM_IO_CAP_IO in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */ /* relate to BTM_IO_CAP_IN in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */ /* relate to BTM_IO_CAP_NONE in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ /* relate to BTM_IO_CAP_KBDISP in stack/btm_api.h */
|
||||
|
||||
#define ESP_BLE_APPEARANCE_UNKNOWN 0x0000 /* relate to BTM_BLE_APPEARANCE_UNKNOWN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PHONE 0x0040 /* relate to BTM_BLE_APPEARANCE_GENERIC_PHONE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_COMPUTER 0x0080 /* relate to BTM_BLE_APPEARANCE_GENERIC_COMPUTER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_WATCH 0x00C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_WATCH in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_SPORTS_WATCH 0x00C1 /* relate to BTM_BLE_APPEARANCE_SPORTS_WATCH in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_CLOCK 0x0100 /* relate to BTM_BLE_APPEARANCE_GENERIC_CLOCK in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_DISPLAY 0x0140 /* relate to BTM_BLE_APPEARANCE_GENERIC_DISPLAY in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_REMOTE 0x0180 /* relate to BTM_BLE_APPEARANCE_GENERIC_REMOTE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_EYEGLASSES 0x01C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_EYEGLASSES in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_TAG 0x0200 /* relate to BTM_BLE_APPEARANCE_GENERIC_TAG in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_KEYRING 0x0240 /* relate to BTM_BLE_APPEARANCE_GENERIC_KEYRING in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 0x0280 /* relate to BTM_BLE_APPEARANCE_GENERIC_MEDIA_PLAYER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 0x02C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_BARCODE_SCANNER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_THERMOMETER 0x0300 /* relate to BTM_BLE_APPEARANCE_GENERIC_THERMOMETER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_THERMOMETER_EAR 0x0301 /* relate to BTM_BLE_APPEARANCE_THERMOMETER_EAR in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_HEART_RATE 0x0340 /* relate to BTM_BLE_APPEARANCE_GENERIC_HEART_RATE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HEART_RATE_BELT 0x0341 /* relate to BTM_BLE_APPEARANCE_HEART_RATE_BELT in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 0x0380 /* relate to BTM_BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_BLOOD_PRESSURE_ARM 0x0381 /* relate to BTM_BLE_APPEARANCE_BLOOD_PRESSURE_ARM in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 0x0382 /* relate to BTM_BLE_APPEARANCE_BLOOD_PRESSURE_WRIST in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_HID 0x03C0 /* relate to BTM_BLE_APPEARANCE_GENERIC_HID in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_KEYBOARD 0x03C1 /* relate to BTM_BLE_APPEARANCE_HID_KEYBOARD in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_MOUSE 0x03C2 /* relate to BTM_BLE_APPEARANCE_HID_MOUSE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_JOYSTICK 0x03C3 /* relate to BTM_BLE_APPEARANCE_HID_JOYSTICK in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_GAMEPAD 0x03C4 /* relate to BTM_BLE_APPEARANCE_HID_GAMEPAD in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_DIGITIZER_TABLET 0x03C5 /* relate to BTM_BLE_APPEARANCE_HID_DIGITIZER_TABLET in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_CARD_READER 0x03C6 /* relate to BTM_BLE_APPEARANCE_HID_CARD_READER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_DIGITAL_PEN 0x03C7 /* relate to BTM_BLE_APPEARANCE_HID_DIGITAL_PEN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_HID_BARCODE_SCANNER 0x03C8 /* relate to BTM_BLE_APPEARANCE_HID_BARCODE_SCANNER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_GLUCOSE 0x0400 /* relate to BTM_BLE_APPEARANCE_GENERIC_GLUCOSE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_WALKING 0x0440 /* relate to BTM_BLE_APPEARANCE_GENERIC_WALKING in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_WALKING_IN_SHOE 0x0441 /* relate to BTM_BLE_APPEARANCE_WALKING_IN_SHOE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_WALKING_ON_SHOE 0x0442 /* relate to BTM_BLE_APPEARANCE_WALKING_ON_SHOE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_WALKING_ON_HIP 0x0443 /* relate to BTM_BLE_APPEARANCE_WALKING_ON_HIP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_CYCLING 0x0480 /* relate to BTM_BLE_APPEARANCE_GENERIC_CYCLING in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_COMPUTER 0x0481 /* relate to BTM_BLE_APPEARANCE_CYCLING_COMPUTER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_SPEED 0x0482 /* relate to BTM_BLE_APPEARANCE_CYCLING_SPEED in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_CADENCE 0x0483 /* relate to BTM_BLE_APPEARANCE_CYCLING_CADENCE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_POWER 0x0484 /* relate to BTM_BLE_APPEARANCE_CYCLING_POWER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485 /* relate to BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40 /* relate to BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41 /* relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42 /* relate to BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_WEIGHT 0x0C80 /* relate to BTM_BLE_APPEARANCE_GENERIC_WEIGHT in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE 0x0CC0 /* relate to BTM_BLE_APPEARANCE_GENERIC_PERSONAL_MOBILITY_DEVICE in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_POWERED_WHEELCHAIR 0x0CC1 /* relate to BTM_BLE_APPEARANCE_POWERED_WHEELCHAIR in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_MOBILITY_SCOOTER 0x0CC2 /* relate to BTM_BLE_APPEARANCE_MOBILITY_SCOOTER in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR 0x0D00 /* relate to BTM_BLE_APPEARANCE_GENERIC_CONTINUOUS_GLUCOSE_MONITOR in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_INSULIN_PUMP 0x0D40 /* relate to BTM_BLE_APPEARANCE_GENERIC_INSULIN_PUMP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP 0x0D41 /* relate to BTM_BLE_APPEARANCE_INSULIN_PUMP_DURABLE_PUMP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP 0x0D44 /* relate to BTM_BLE_APPEARANCE_INSULIN_PUMP_PATCH_PUMP in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_INSULIN_PEN 0x0D48 /* relate to BTM_BLE_APPEARANCE_INSULIN_PEN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY 0x0D80 /* relate to BTM_BLE_APPEARANCE_GENERIC_MEDICATION_DELIVERY in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS 0x1440 /* relate to BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION 0x1441 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV 0x1442 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD 0x1443 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV 0x1444 /* relate to BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_POD_AND_NAV in stack/btm_ble_api.h */
|
||||
|
||||
/* relate to BTM_IO_CAP_xxx in btm_api.h */
|
||||
#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ /* relate to BTM_IO_CAP_OUT in btm_api.h */
|
||||
#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ /* relate to BTM_IO_CAP_IO in btm_api.h */
|
||||
#define ESP_IO_CAP_IN 2 /*!< KeyboardOnly */ /* relate to BTM_IO_CAP_IN in btm_api.h */
|
||||
#define ESP_IO_CAP_NONE 3 /*!< NoInputNoOutput */ /* relate to BTM_IO_CAP_NONE in btm_api.h */
|
||||
#define ESP_IO_CAP_KBDISP 4 /*!< Keyboard display */ /* relate to BTM_IO_CAP_KBDISP in btm_api.h */
|
||||
typedef uint8_t esp_ble_io_cap_t; /*!< combination of the io capability */
|
||||
|
||||
/// GAP BLE callback event type
|
||||
@@ -168,45 +108,45 @@ typedef enum {
|
||||
/// Scan response data maximum length
|
||||
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
|
||||
|
||||
/* relate to BTM_BLE_AD_TYPE_xxx in stack/btm_ble_api.h */
|
||||
/* relate to BTM_BLE_AD_TYPE_xxx in btm_ble_api.h */
|
||||
/// The type of advertising data(not adv_type)
|
||||
typedef enum {
|
||||
ESP_BLE_AD_TYPE_FLAG = 0x01, /* relate to BTM_BLE_AD_TYPE_FLAG in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_16SRV_PART = 0x02, /* relate to BTM_BLE_AD_TYPE_16SRV_PART in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03, /* relate to BTM_BLE_AD_TYPE_16SRV_CMPL in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SRV_PART = 0x04, /* relate to BTM_BLE_AD_TYPE_32SRV_PART in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05, /* relate to BTM_BLE_AD_TYPE_32SRV_CMPL in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SRV_PART = 0x06, /* relate to BTM_BLE_AD_TYPE_128SRV_PART in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07, /* relate to BTM_BLE_AD_TYPE_128SRV_CMPL in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_NAME_SHORT = 0x08, /* relate to BTM_BLE_AD_TYPE_NAME_SHORT in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_NAME_CMPL = 0x09, /* relate to BTM_BLE_AD_TYPE_NAME_CMPL in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_TX_PWR = 0x0A, /* relate to BTM_BLE_AD_TYPE_TX_PWR in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D, /* relate to BTM_BLE_AD_TYPE_DEV_CLASS in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SM_TK = 0x10, /* relate to BTM_BLE_AD_TYPE_SM_TK in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11, /* relate to BTM_BLE_AD_TYPE_SM_OOB_FLAG in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_INT_RANGE = 0x12, /* relate to BTM_BLE_AD_TYPE_INT_RANGE in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14, /* relate to BTM_BLE_AD_TYPE_SOL_SRV_UUID in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15, /* relate to BTM_BLE_AD_TYPE_128SOL_SRV_UUID in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16, /* relate to BTM_BLE_AD_TYPE_SERVICE_DATA in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17, /* relate to BTM_BLE_AD_TYPE_PUBLIC_TARGET in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18, /* relate to BTM_BLE_AD_TYPE_RANDOM_TARGET in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_APPEARANCE = 0x19, /* relate to BTM_BLE_AD_TYPE_APPEARANCE in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_ADV_INT = 0x1A, /* relate to BTM_BLE_AD_TYPE_ADV_INT in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_DEV_ADDR = 0x1b, /* relate to BTM_BLE_AD_TYPE_LE_DEV_ADDR in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_ROLE = 0x1c, /* relate to BTM_BLE_AD_TYPE_LE_ROLE in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SPAIR_C256 = 0x1d, /* relate to BTM_BLE_AD_TYPE_SPAIR_C256 in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SPAIR_R256 = 0x1e, /* relate to BTM_BLE_AD_TYPE_SPAIR_R256 in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1f, /* relate to BTM_BLE_AD_TYPE_32SOL_SRV_UUID in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x20, /* relate to BTM_BLE_AD_TYPE_32SERVICE_DATA in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x21, /* relate to BTM_BLE_AD_TYPE_128SERVICE_DATA in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SECURE_CONFIRM = 0x22, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SECURE_RANDOM = 0x23, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_RANDOM in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_URI = 0x24, /* relate to BTM_BLE_AD_TYPE_URI in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_INDOOR_POSITION = 0x25, /* relate to BTM_BLE_AD_TYPE_INDOOR_POSITION in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_TRANS_DISC_DATA = 0x26, /* relate to BTM_BLE_AD_TYPE_TRANS_DISC_DATA in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SUPPORT_FEATURE = 0x27, /* relate to BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_CHAN_MAP_UPDATE = 0x28, /* relate to BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF, /* relate to BTM_BLE_AD_MANUFACTURER_SPECIFIC_TYPE in stack/btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_FLAG = 0x01, /* relate to BTM_BLE_AD_TYPE_FLAG in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_16SRV_PART = 0x02, /* relate to BTM_BLE_AD_TYPE_16SRV_PART in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_16SRV_CMPL = 0x03, /* relate to BTM_BLE_AD_TYPE_16SRV_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SRV_PART = 0x04, /* relate to BTM_BLE_AD_TYPE_32SRV_PART in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SRV_CMPL = 0x05, /* relate to BTM_BLE_AD_TYPE_32SRV_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SRV_PART = 0x06, /* relate to BTM_BLE_AD_TYPE_128SRV_PART in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SRV_CMPL = 0x07, /* relate to BTM_BLE_AD_TYPE_128SRV_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_NAME_SHORT = 0x08, /* relate to BTM_BLE_AD_TYPE_NAME_SHORT in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_NAME_CMPL = 0x09, /* relate to BTM_BLE_AD_TYPE_NAME_CMPL in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_TX_PWR = 0x0A, /* relate to BTM_BLE_AD_TYPE_TX_PWR in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_DEV_CLASS = 0x0D, /* relate to BTM_BLE_AD_TYPE_DEV_CLASS in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SM_TK = 0x10, /* relate to BTM_BLE_AD_TYPE_SM_TK in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SM_OOB_FLAG = 0x11, /* relate to BTM_BLE_AD_TYPE_SM_OOB_FLAG in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_INT_RANGE = 0x12, /* relate to BTM_BLE_AD_TYPE_INT_RANGE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SOL_SRV_UUID = 0x14, /* relate to BTM_BLE_AD_TYPE_SOL_SRV_UUID in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SOL_SRV_UUID = 0x15, /* relate to BTM_BLE_AD_TYPE_128SOL_SRV_UUID in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SERVICE_DATA = 0x16, /* relate to BTM_BLE_AD_TYPE_SERVICE_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_PUBLIC_TARGET = 0x17, /* relate to BTM_BLE_AD_TYPE_PUBLIC_TARGET in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_RANDOM_TARGET = 0x18, /* relate to BTM_BLE_AD_TYPE_RANDOM_TARGET in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_APPEARANCE = 0x19, /* relate to BTM_BLE_AD_TYPE_APPEARANCE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_ADV_INT = 0x1A, /* relate to BTM_BLE_AD_TYPE_ADV_INT in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_DEV_ADDR = 0x1b, /* relate to BTM_BLE_AD_TYPE_LE_DEV_ADDR in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_ROLE = 0x1c, /* relate to BTM_BLE_AD_TYPE_LE_ROLE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SPAIR_C256 = 0x1d, /* relate to BTM_BLE_AD_TYPE_SPAIR_C256 in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_SPAIR_R256 = 0x1e, /* relate to BTM_BLE_AD_TYPE_SPAIR_R256 in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SOL_SRV_UUID = 0x1f, /* relate to BTM_BLE_AD_TYPE_32SOL_SRV_UUID in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_32SERVICE_DATA = 0x20, /* relate to BTM_BLE_AD_TYPE_32SERVICE_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_128SERVICE_DATA = 0x21, /* relate to BTM_BLE_AD_TYPE_128SERVICE_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SECURE_CONFIRM = 0x22, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_CONFIRM in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SECURE_RANDOM = 0x23, /* relate to BTM_BLE_AD_TYPE_LE_SECURE_RANDOM in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_URI = 0x24, /* relate to BTM_BLE_AD_TYPE_URI in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_INDOOR_POSITION = 0x25, /* relate to BTM_BLE_AD_TYPE_INDOOR_POSITION in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_TRANS_DISC_DATA = 0x26, /* relate to BTM_BLE_AD_TYPE_TRANS_DISC_DATA in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_LE_SUPPORT_FEATURE = 0x27, /* relate to BTM_BLE_AD_TYPE_LE_SUPPORT_FEATURE in btm_ble_api.h */
|
||||
ESP_BLE_AD_TYPE_CHAN_MAP_UPDATE = 0x28, /* relate to BTM_BLE_AD_TYPE_CHAN_MAP_UPDATE in btm_ble_api.h */
|
||||
ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE = 0xFF, /* relate to BTM_BLE_AD_MANUFACTURER_SPECIFIC_TYPE in btm_ble_api.h */
|
||||
} esp_ble_adv_data_type;
|
||||
|
||||
/// Advertising mode
|
||||
@@ -239,18 +179,18 @@ typedef enum {
|
||||
} esp_ble_adv_filter_t;
|
||||
|
||||
|
||||
/* relate to BTA_DM_BLE_SEC_xxx in bta/bta_api.h */
|
||||
/* relate to BTA_DM_BLE_SEC_xxx in bta_api.h */
|
||||
typedef enum {
|
||||
ESP_BLE_SEC_ENCRYPT = 1, /* relate to BTA_DM_BLE_SEC_ENCRYPT in bta/bta_api.h. If the device has already
|
||||
ESP_BLE_SEC_ENCRYPT = 1, /* relate to BTA_DM_BLE_SEC_ENCRYPT in bta_api.h. If the device has already
|
||||
bonded, the stack will used LTK to encrypt with the remote device directly.
|
||||
Else if the device hasn't bonded, the stack will used the default authentication request
|
||||
used the esp_ble_gap_set_security_param function set by the user. */
|
||||
ESP_BLE_SEC_ENCRYPT_NO_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_NO_MITM in bta/bta_api.h. If the device has already
|
||||
ESP_BLE_SEC_ENCRYPT_NO_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_NO_MITM in bta_api.h. If the device has already
|
||||
bonded, the stack will check the LTK Whether the authentication request has been met, if met, used the LTK
|
||||
to encrypt with the remote device directly, else Re-pair with the remote device.
|
||||
Else if the device hasn't bonded, the stack will used NO MITM authentication request in the current link instead of
|
||||
used the authreq in the esp_ble_gap_set_security_param function set by the user. */
|
||||
ESP_BLE_SEC_ENCRYPT_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_MITM in bta/bta_api.h. If the device has already
|
||||
ESP_BLE_SEC_ENCRYPT_MITM, /* relate to BTA_DM_BLE_SEC_ENCRYPT_MITM in bta_api.h. If the device has already
|
||||
bonded, the stack will check the LTK Whether the authentication request has been met, if met, used the LTK
|
||||
to encrypt with the remote device directly, else Re-pair with the remote device.
|
||||
Else if the device hasn't bonded, the stack will used MITM authentication request in the current link instead of
|
||||
@@ -845,20 +785,6 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
/**
|
||||
* @brief set local gap appearance icon
|
||||
*
|
||||
*
|
||||
* @param[in] icon - External appearance value, these values are defined by the Bluetooth SIG, please refer to
|
||||
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.gap.appearance.xml
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_config_local_icon (uint16_t icon);
|
||||
|
||||
/**
|
||||
* @brief Add or remove device from white list
|
||||
*
|
||||
@@ -914,18 +840,7 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_device_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get local used address and adress type.
|
||||
* uint8_t *esp_bt_dev_get_address(void) get the public address
|
||||
*
|
||||
* @param[in] local_used_addr - current local used ble address (six bytes)
|
||||
* @param[in] addr_type - ble address type
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t * addr_type);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get ADV data for a specific type.
|
||||
*
|
||||
@@ -1066,7 +981,7 @@ esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr);
|
||||
* It will return the device bonded number immediately.
|
||||
*
|
||||
* @return - >= 0 : bonded devices number.
|
||||
* - ESP_FAIL : failed
|
||||
* - < 0 : failed
|
||||
*
|
||||
*/
|
||||
int esp_ble_get_bond_device_num(void);
|
||||
52
components/bt/bluedroid/api/include/esp_gap_bt_api.h
Normal file
52
components/bt/bluedroid/api/include/esp_gap_bt_api.h
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_GAP_BT_API_H__
|
||||
#define __ESP_GAP_BT_API_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/// Discoverability and Connectability mode
|
||||
typedef enum {
|
||||
ESP_BT_SCAN_MODE_NONE = 0, /*!< Neither discoverable nor connectable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE, /*!< Connectable but not discoverable */
|
||||
ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE /*!< both discoverable and connectaable */
|
||||
} esp_bt_scan_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Set discoverability and connectability mode for legacy bluetooth. This function should
|
||||
* be called after esp_bluedroid_enable() completes successfully
|
||||
*
|
||||
* @param[in] mode : one of the enums of bt_scan_mode_t
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : Succeed
|
||||
* - ESP_ERR_INVALID_ARG: if argument invalid
|
||||
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - ESP_FAIL: others
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_scan_mode(esp_bt_scan_mode_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_GAP_BT_API_H__ */
|
||||
@@ -23,10 +23,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Maximum Transmission Unit used in GATT
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23 /* relate to GATT_DEF_BLE_MTU_SIZE in stack/gatt_api.h */
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23 /* relate to GATT_DEF_BLE_MTU_SIZE in gatt_api.h */
|
||||
|
||||
// Maximum Transmission Unit allowed in GATT
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517 /* relate to GATT_MAX_MTU_SIZE in stack/gatt_api.h */
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517 /* relate to GATT_MAX_MTU_SIZE in gatt_api.h */
|
||||
|
||||
/**
|
||||
* @brief This function is called to set local MTU,
|
||||
@@ -154,81 +154,81 @@ extern "C" {
|
||||
* @}
|
||||
*/
|
||||
|
||||
/* relate to BTA_GATT_PREP_WRITE_xxx in bta/bta_gatt_api.h */
|
||||
/* relate to BTA_GATT_PREP_WRITE_xxx in bta_gatt_api.h */
|
||||
/// Attribute write data type from the client
|
||||
typedef enum {
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */ /* relate to BTA_GATT_PREP_WRITE_CANCEL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */ /* relate to BTA_GATT_PREP_WRITE_EXEC in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_CANCEL = 0x00, /*!< Prepare write cancel */ /* relate to BTA_GATT_PREP_WRITE_CANCEL in bta_gatt_api.h */
|
||||
ESP_GATT_PREP_WRITE_EXEC = 0x01, /*!< Prepare write execute */ /* relate to BTA_GATT_PREP_WRITE_EXEC in bta_gatt_api.h */
|
||||
} esp_gatt_prep_write_type;
|
||||
|
||||
/* relate to BTA_GATT_xxx in bta/bta_gatt_api.h */
|
||||
/* relate to BTA_GATT_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief GATT success code and error codes
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_OK = 0x0, /* relate to BTA_GATT_OK in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */ /* relate to BTA_GATT_INVALID_HANDLE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */ /* relate to BTA_GATT_READ_NOT_PERMIT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */ /* relate to BTA_GATT_WRITE_NOT_PERMIT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */ /* relate to BTA_GATT_INVALID_PDU in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */ /* relate to BTA_GATT_INSUF_AUTHENTICATION in bta/bta_gatt_api.h */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */ /* relate to BTA_GATT_REQ_NOT_SUPPORTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */ /* relate to BTA_GATT_INVALID_OFFSET in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */ /* relate to BTA_GATT_INSUF_AUTHORIZATION in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */ /* relate to BTA_GATT_PREPARE_Q_FULL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */ /* relate to BTA_GATT_NOT_FOUND in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */ /* relate to BTA_GATT_NOT_LONG in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */ /* relate to BTA_GATT_INSUF_KEY_SIZE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */ /* relate to BTA_GATT_INVALID_ATTR_LEN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */ /* relate to BTA_GATT_ERR_UNLIKELY in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */ /* relate to BTA_GATT_INSUF_ENCRYPTION in bta/bta_gatt_api.h */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */ /* relate to BTA_GATT_UNSUPPORT_GRP_TYPE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */ /* relate to BTA_GATT_INSUF_RESOURCE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_OK = 0x0, /* relate to BTA_GATT_OK in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */ /* relate to BTA_GATT_INVALID_HANDLE in bta_gatt_api.h */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */ /* relate to BTA_GATT_READ_NOT_PERMIT in bta_gatt_api.h */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */ /* relate to BTA_GATT_WRITE_NOT_PERMIT in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */ /* relate to BTA_GATT_INVALID_PDU in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */ /* relate to BTA_GATT_INSUF_AUTHENTICATION in bta_gatt_api.h */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */ /* relate to BTA_GATT_REQ_NOT_SUPPORTED in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */ /* relate to BTA_GATT_INVALID_OFFSET in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */ /* relate to BTA_GATT_INSUF_AUTHORIZATION in bta_gatt_api.h */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */ /* relate to BTA_GATT_PREPARE_Q_FULL in bta_gatt_api.h */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */ /* relate to BTA_GATT_NOT_FOUND in bta_gatt_api.h */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */ /* relate to BTA_GATT_NOT_LONG in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */ /* relate to BTA_GATT_INSUF_KEY_SIZE in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */ /* relate to BTA_GATT_INVALID_ATTR_LEN in bta_gatt_api.h */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */ /* relate to BTA_GATT_ERR_UNLIKELY in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */ /* relate to BTA_GATT_INSUF_ENCRYPTION in bta_gatt_api.h */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */ /* relate to BTA_GATT_UNSUPPORT_GRP_TYPE in bta_gatt_api.h */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */ /* relate to BTA_GATT_INSUF_RESOURCE in bta_gatt_api.h */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */ /* relate to BTA_GATT_NO_RESOURCES in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */ /* relate to BTA_GATT_INTERNAL_ERROR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */ /* relate to BTA_GATT_WRONG_STATE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */ /* relate to BTA_GATT_DB_FULL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */ /* relate to BTA_GATT_BUSY in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */ /* relate to BTA_GATT_ERROR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */ /* relate to BTA_GATT_CMD_STARTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */ /* relate to BTA_GATT_ILLEGAL_PARAMETER in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */ /* relate to BTA_GATT_PENDING in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */ /* relate to BTA_GATT_AUTH_FAIL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */ /* relate to BTA_GATT_MORE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */ /* relate to BTA_GATT_INVALID_CFG in bta/bta_gatt_api.h */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */ /* relate to BTA_GATT_SERVICE_STARTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK, /* relate to BTA_GATT_ENCRYPED_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */ /* relate to BTA_GATT_ENCRYPED_NO_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */ /* relate to BTA_GATT_NOT_ENCRYPTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */ /* relate to BTA_GATT_CONGESTED in bta/bta_gatt_api.h */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */ /* relate to BTA_GATT_DUP_REG in bta/bta_gatt_api.h */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */ /* relate to BTA_GATT_ALREADY_OPEN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */ /* relate to BTA_GATT_CANCEL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */ /* relate to BTA_GATT_NO_RESOURCES in bta_gatt_api.h */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */ /* relate to BTA_GATT_INTERNAL_ERROR in bta_gatt_api.h */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */ /* relate to BTA_GATT_WRONG_STATE in bta_gatt_api.h */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */ /* relate to BTA_GATT_DB_FULL in bta_gatt_api.h */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */ /* relate to BTA_GATT_BUSY in bta_gatt_api.h */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */ /* relate to BTA_GATT_ERROR in bta_gatt_api.h */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */ /* relate to BTA_GATT_CMD_STARTED in bta_gatt_api.h */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */ /* relate to BTA_GATT_ILLEGAL_PARAMETER in bta_gatt_api.h */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */ /* relate to BTA_GATT_PENDING in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */ /* relate to BTA_GATT_AUTH_FAIL in bta_gatt_api.h */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */ /* relate to BTA_GATT_MORE in bta_gatt_api.h */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */ /* relate to BTA_GATT_INVALID_CFG in bta_gatt_api.h */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */ /* relate to BTA_GATT_SERVICE_STARTED in bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK, /* relate to BTA_GATT_ENCRYPED_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */ /* relate to BTA_GATT_ENCRYPED_NO_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */ /* relate to BTA_GATT_NOT_ENCRYPTED in bta_gatt_api.h */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */ /* relate to BTA_GATT_CONGESTED in bta_gatt_api.h */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */ /* relate to BTA_GATT_DUP_REG in bta_gatt_api.h */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */ /* relate to BTA_GATT_ALREADY_OPEN in bta_gatt_api.h */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */ /* relate to BTA_GATT_CANCEL in bta_gatt_api.h */
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_STACK_RSP = 0xe0, /* 0xe0 */ /* relate to BTA_GATT_STACK_RSP in bta/bta_gatt_api.h */
|
||||
ESP_GATT_APP_RSP = 0xe1, /* 0xe1 */ /* relate to BTA_GATT_APP_RSP in bta/bta_gatt_api.h */
|
||||
ESP_GATT_STACK_RSP = 0xe0, /* 0xe0 */ /* relate to BTA_GATT_STACK_RSP in bta_gatt_api.h */
|
||||
ESP_GATT_APP_RSP = 0xe1, /* 0xe1 */ /* relate to BTA_GATT_APP_RSP in bta_gatt_api.h */
|
||||
//Error caused by customer application or stack bug
|
||||
ESP_GATT_UNKNOWN_ERROR = 0xef, /* 0xef */ /* relate to BTA_GATT_UNKNOWN_ERROR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ /* relate to BTA_GATT_CCC_CFG_ERR in bta/bta_gatt_api.h */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */ /* relate to BTA_GATT_PRC_IN_PROGRESS in bta/bta_gatt_api.h */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */ /* relate to BTA_GATT_OUT_OF_RANGE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_UNKNOWN_ERROR = 0xef, /* 0xef */ /* relate to BTA_GATT_UNKNOWN_ERROR in bta_gatt_api.h */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */ /* relate to BTA_GATT_CCC_CFG_ERR in bta_gatt_api.h */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */ /* relate to BTA_GATT_PRC_IN_PROGRESS in bta_gatt_api.h */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */ /* relate to BTA_GATT_OUT_OF_RANGE in bta_gatt_api.h */
|
||||
} esp_gatt_status_t;
|
||||
|
||||
/* relate to BTA_GATT_CONN_xxx in bta/bta_gatt_api.h */
|
||||
/* relate to BTA_GATT_CONN_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Gatt Connection reason enum
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */ /* relate to BTA_GATT_CONN_UNKNOWN in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */ /* relate to BTA_GATT_CONN_L2C_FAILURE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */ /* relate to BTA_GATT_CONN_TIMEOUT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */ /* relate to BTA_GATT_CONN_TERMINATE_PEER_USER in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */ /* relate to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */ /* relate to BTA_GATT_CONN_FAIL_ESTABLISH in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */ /* relate to BTA_GATT_CONN_LMP_TIMEOUT in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */ /* relate to BTA_GATT_CONN_CONN_CANCEL in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */ /* relate to BTA_GATT_CONN_NONE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_CONN_UNKNOWN = 0, /*!< Gatt connection unknown */ /* relate to BTA_GATT_CONN_UNKNOWN in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_L2C_FAILURE = 1, /*!< General L2cap failure */ /* relate to BTA_GATT_CONN_L2C_FAILURE in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TIMEOUT = 0x08, /*!< Connection timeout */ /* relate to BTA_GATT_CONN_TIMEOUT in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_PEER_USER = 0x13, /*!< Connection terminate by peer user */ /* relate to BTA_GATT_CONN_TERMINATE_PEER_USER in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_TERMINATE_LOCAL_HOST = 0x16, /*!< Connectionterminated by local host */ /* relate to BTA_GATT_CONN_TERMINATE_LOCAL_HOST in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_FAIL_ESTABLISH = 0x3e, /*!< Connection fail to establish */ /* relate to BTA_GATT_CONN_FAIL_ESTABLISH in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_LMP_TIMEOUT = 0x22, /*!< Connection fail for LMP response tout */ /* relate to BTA_GATT_CONN_LMP_TIMEOUT in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_CONN_CANCEL = 0x0100, /*!< L2CAP connection cancelled */ /* relate to BTA_GATT_CONN_CONN_CANCEL in bta_gatt_api.h */
|
||||
ESP_GATT_CONN_NONE = 0x0101 /*!< No connection to cancel */ /* relate to BTA_GATT_CONN_NONE in bta_gatt_api.h */
|
||||
} esp_gatt_conn_reason_t;
|
||||
|
||||
/**
|
||||
@@ -248,42 +248,42 @@ typedef struct {
|
||||
bool is_primary; /*!< This service is primary or not */
|
||||
} __attribute__((packed)) esp_gatt_srvc_id_t;
|
||||
|
||||
/* relate to BTA_GATT_AUTH_REQ_xxx in bta/bta_gatt_api.h */
|
||||
/* relate to BTA_GATT_AUTH_REQ_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Gatt authentication request type
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_AUTH_REQ_NONE = 0, /* relate to BTA_GATT_AUTH_REQ_NONE in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_NO_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /* relate to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /* relate to BTA_GATT_AUTH_REQ_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NONE = 0, /* relate to BTA_GATT_AUTH_REQ_NONE in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_NO_MITM = 1, /* unauthenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_NO_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_MITM = 2, /* authenticated encryption */ /* relate to BTA_GATT_AUTH_REQ_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_NO_MITM = 3, /* relate to BTA_GATT_AUTH_REQ_SIGNED_NO_MITM in bta_gatt_api.h */
|
||||
ESP_GATT_AUTH_REQ_SIGNED_MITM = 4, /* relate to BTA_GATT_AUTH_REQ_SIGNED_MITM in bta_gatt_api.h */
|
||||
} esp_gatt_auth_req_t;
|
||||
|
||||
/* relate to BTA_GATT_PERM_xxx in bta/bta_gatt_api.h */
|
||||
/* relate to BTA_GATT_PERM_xxx in bta_gatt_api.h */
|
||||
/**
|
||||
* @brief Attribute permissions
|
||||
*/
|
||||
#define ESP_GATT_PERM_READ (1 << 0) /* bit 0 - 0x0001 */ /* relate to BTA_GATT_PERM_READ in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 - 0x0002 */ /* relate to BTA_GATT_PERM_READ_ENCRYPTED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 - 0x0004 */ /* relate to BTA_GATT_PERM_READ_ENC_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE (1 << 4) /* bit 4 - 0x0010 */ /* relate to BTA_GATT_PERM_WRITE in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 - 0x0020 */ /* relate to BTA_GATT_PERM_WRITE_ENCRYPTED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ (1 << 0) /* bit 0 - 0x0001 */ /* relate to BTA_GATT_PERM_READ in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENCRYPTED (1 << 1) /* bit 1 - 0x0002 */ /* relate to BTA_GATT_PERM_READ_ENCRYPTED in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_ENC_MITM (1 << 2) /* bit 2 - 0x0004 */ /* relate to BTA_GATT_PERM_READ_ENC_MITM in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE (1 << 4) /* bit 4 - 0x0010 */ /* relate to BTA_GATT_PERM_WRITE in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENCRYPTED (1 << 5) /* bit 5 - 0x0020 */ /* relate to BTA_GATT_PERM_WRITE_ENCRYPTED in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta_gatt_api.h */
|
||||
typedef uint16_t esp_gatt_perm_t;
|
||||
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta_gatt_api.h */
|
||||
/* definition of characteristic properties */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0) /* 0x01 */ /* relate to BTA_GATT_CHAR_PROP_BIT_BROADCAST in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1) /* 0x02 */ /* relate to BTA_GATT_CHAR_PROP_BIT_READ in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2) /* 0x04 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE_NR in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3) /* 0x08 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4) /* 0x10 */ /* relate to BTA_GATT_CHAR_PROP_BIT_NOTIFY in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5) /* 0x20 */ /* relate to BTA_GATT_CHAR_PROP_BIT_INDICATE in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6) /* 0x40 */ /* relate to BTA_GATT_CHAR_PROP_BIT_AUTH in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) /* 0x80 */ /* relate to BTA_GATT_CHAR_PROP_BIT_EXT_PROP in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_BROADCAST (1 << 0) /* 0x01 */ /* relate to BTA_GATT_CHAR_PROP_BIT_BROADCAST in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_READ (1 << 1) /* 0x02 */ /* relate to BTA_GATT_CHAR_PROP_BIT_READ in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE_NR (1 << 2) /* 0x04 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE_NR in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_WRITE (1 << 3) /* 0x08 */ /* relate to BTA_GATT_CHAR_PROP_BIT_WRITE in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_NOTIFY (1 << 4) /* 0x10 */ /* relate to BTA_GATT_CHAR_PROP_BIT_NOTIFY in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_INDICATE (1 << 5) /* 0x20 */ /* relate to BTA_GATT_CHAR_PROP_BIT_INDICATE in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_AUTH (1 << 6) /* 0x40 */ /* relate to BTA_GATT_CHAR_PROP_BIT_AUTH in bta_gatt_api.h */
|
||||
#define ESP_GATT_CHAR_PROP_BIT_EXT_PROP (1 << 7) /* 0x80 */ /* relate to BTA_GATT_CHAR_PROP_BIT_EXT_PROP in bta_gatt_api.h */
|
||||
typedef uint8_t esp_gatt_char_prop_t;
|
||||
|
||||
/// GATT maximum attribute length
|
||||
@@ -450,8 +450,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t handle; /*!< The include service current attribute handle */
|
||||
uint16_t incl_srvc_s_handle; /*!< The start handle of the service which has been included */
|
||||
uint16_t incl_srvc_e_handle; /*!< The end handle of the service which has been included */
|
||||
uint16_t incl_srvc_s_handle; /*!< The start hanlde of the service which has been included */
|
||||
esp_bt_uuid_t uuid; /*!< The include service uuid */
|
||||
} esp_gattc_incl_svc_elem_t; /*!< The gattc inclue service element */
|
||||
|
||||
@@ -63,10 +63,8 @@ typedef enum {
|
||||
ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
|
||||
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
|
||||
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
|
||||
ESP_GATTC_READ_MULTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor multiple complete, the event comes */
|
||||
ESP_GATTC_READ_MUTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor mutiple complete, the event comes */
|
||||
ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */
|
||||
ESP_GATTC_SET_ASSOC_EVT = 44, /*!< When the ble gattc set the associated address complete, the event comes */
|
||||
ESP_GATTC_GET_ADDR_LIST_EVT = 45, /*!< When the ble get gattc address list in cache finish, the event comes */
|
||||
} esp_gattc_cb_event_t;
|
||||
|
||||
|
||||
@@ -127,7 +125,6 @@ typedef union {
|
||||
uint16_t start_handle; /*!< Service start handle */
|
||||
uint16_t end_handle; /*!< Service end handle */
|
||||
esp_gatt_id_t srvc_id; /*!< Service id, include service uuid and other information */
|
||||
bool is_primary; /*!< True if this is the primary service */
|
||||
} search_res; /*!< Gatt client callback param of ESP_GATTC_SEARCH_RES_EVT */
|
||||
|
||||
/**
|
||||
@@ -218,20 +215,6 @@ typedef union {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
} disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
|
||||
/**
|
||||
* @brief ESP_GATTC_SET_ASSOC_EVT
|
||||
*/
|
||||
struct gattc_set_assoc_addr_cmp_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
} set_assoc_cmp; /*!< Gatt client callback param of ESP_GATTC_SET_ASSOC_EVT */
|
||||
/**
|
||||
* @brief ESP_GATTC_GET_ADDR_LIST_EVT
|
||||
*/
|
||||
struct gattc_get_addr_list_evt_param {
|
||||
esp_gatt_status_t status; /*!< Operation status */
|
||||
uint8_t num_addr; /*!< The number of address in the gattc cache address list */
|
||||
esp_bd_addr_t *addr_list; /*!< The pointer to the address list which has been get from the gattc cache */
|
||||
} get_addr_list; /*!< Gatt client callback param of ESP_GATTC_GET_ADDR_LIST_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_GATTC_QUEUE_FULL_EVT
|
||||
@@ -801,41 +784,6 @@ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda);
|
||||
|
||||
/**
|
||||
* @brief Add or delete the associated address with the source address.
|
||||
* Note: The role of this API is mainly when the client side has stored a server-side database,
|
||||
* when it needs to connect another device, but the device's attribute database is the same
|
||||
* as the server database stored on the client-side, calling this API can use the database
|
||||
* that the device has stored used as the peer server database to reduce the attribute
|
||||
* database search and discovery process and speed up the connection time.
|
||||
* The associated address mains that device want to used the database has stored in the local cache.
|
||||
* The source address mains that device want to share the database to the associated address device.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] src_addr: the source address which provide the attribute table.
|
||||
* @param[in] assoc_addr: the associated device address which went to share the attribute table with the source address.
|
||||
* @param[in] is_assoc: true add the associated device address, false remove the associated device address.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr,
|
||||
esp_bd_addr_t assoc_addr, bool is_assoc);
|
||||
/**
|
||||
* @brief Get the address list which has store the attribute table in the gattc cache. There will
|
||||
* callback ESP_GATTC_GET_ADDR_LIST_EVT event when get address list complete.
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_cache_get_addr_list(esp_gatt_if_t gattc_if);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -22,9 +22,9 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#include <string.h>
|
||||
#include "bta/bta_ar_api.h"
|
||||
#include "bta_ar_api.h"
|
||||
#include "bta_ar_int.h"
|
||||
|
||||
#if BTA_AR_INCLUDED
|
||||
@@ -32,8 +32,6 @@
|
||||
/* AV control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_AR_CB bta_ar_cb;
|
||||
#else
|
||||
tBTA_AR_CB *bta_ar_cb_ptr;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#ifndef BTA_AR_INT_H
|
||||
#define BTA_AR_INT_H
|
||||
|
||||
#include "bta/bta_av_api.h"
|
||||
#include "bta_av_api.h"
|
||||
|
||||
#if (BTA_AR_INCLUDED == TRUE)
|
||||
|
||||
@@ -24,22 +24,22 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
// #include <assert.h>
|
||||
#include "common/bt_trace.h"
|
||||
#include "bt_trace.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#include "bta_av_int.h"
|
||||
#include "stack/avdt_api.h"
|
||||
#include "bta/utl.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "stack/l2cdefs.h"
|
||||
#include "avdt_api.h"
|
||||
#include "utl.h"
|
||||
#include "l2c_api.h"
|
||||
#include "l2cdefs.h"
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
#include "bta/bta_ar_api.h"
|
||||
#include "bta_ar_api.h"
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -549,7 +549,7 @@ static void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, t
|
||||
if (p_data) {
|
||||
bta_av_conn_cback(handle, bd_addr, event, p_data);
|
||||
} else {
|
||||
APPL_TRACE_EVENT("%s: p_data is null", __func__);
|
||||
APPL_TRACE_ERROR("%s: p_data is null", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,7 +815,7 @@ void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS;
|
||||
if (p_data->role_res.hci_status != HCI_SUCCESS) {
|
||||
p_scb->role &= ~BTA_AV_ROLE_START_INT;
|
||||
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
/* start failed because of role switch. */
|
||||
start.chnl = p_scb->chnl;
|
||||
start.status = BTA_AV_FAIL_ROLE;
|
||||
@@ -956,7 +956,7 @@ void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
p_scb->sec_mask = p_data->api_open.sec_mask;
|
||||
p_scb->use_rc = p_data->api_open.use_rc;
|
||||
|
||||
bta_sys_app_open(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
|
||||
bta_sys_app_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
|
||||
|
||||
/* allocate discovery database */
|
||||
if (p_scb->p_disc_db == NULL) {
|
||||
@@ -1330,7 +1330,7 @@ void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
L2CA_SetTxPriority(p_scb->l2c_cid, L2CAP_CHNL_PRIORITY_MEDIUM);
|
||||
L2CA_SetChnlFlushability (p_scb->l2c_cid, TRUE);
|
||||
|
||||
bta_sys_conn_open(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
|
||||
bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
|
||||
memset(&p_scb->q_info, 0, sizeof(tBTA_AV_Q_INFO));
|
||||
|
||||
p_scb->l2c_bufs = 0;
|
||||
@@ -1933,7 +1933,8 @@ void bta_av_do_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
|
||||
if ((p_scb->started == FALSE) && ((p_scb->role & BTA_AV_ROLE_START_INT) == 0)) {
|
||||
p_scb->role |= BTA_AV_ROLE_START_INT;
|
||||
bta_sys_busy(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_busy(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
|
||||
AVDT_StartReq(&p_scb->avdt_handle, 1);
|
||||
} else if (p_scb->started) {
|
||||
p_scb->role |= BTA_AV_ROLE_START_INT;
|
||||
@@ -1968,7 +1969,7 @@ void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
APPL_TRACE_ERROR("bta_av_str_stopped:audio_open_cnt=%d, p_data %p",
|
||||
bta_av_cb.audio_open_cnt, p_data);
|
||||
|
||||
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
if ((bta_av_cb.features & BTA_AV_FEAT_MASTER) == 0 || bta_av_cb.audio_open_cnt == 1) {
|
||||
policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH;
|
||||
}
|
||||
@@ -2238,7 +2239,7 @@ void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
if (p_data && (p_data->hdr.offset != BTA_AV_RS_NONE)) {
|
||||
p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS;
|
||||
if (p_data->hdr.offset == BTA_AV_RS_FAIL) {
|
||||
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
start.chnl = p_scb->chnl;
|
||||
start.status = BTA_AV_FAIL_ROLE;
|
||||
start.hndl = p_scb->hndl;
|
||||
@@ -2274,9 +2275,9 @@ void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
}
|
||||
|
||||
/* tell role manager to check M/S role */
|
||||
bta_sys_conn_open(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
|
||||
bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
|
||||
|
||||
bta_sys_busy(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_busy(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
|
||||
if (p_scb->media_type == AVDT_MEDIA_AUDIO) {
|
||||
/* in normal logic, conns should be bta_av_cb.audio_count - 1,
|
||||
@@ -2363,7 +2364,7 @@ void bta_av_start_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
UNUSED(p_data);
|
||||
|
||||
if (p_scb->started == FALSE && p_scb->co_started == FALSE) {
|
||||
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
notify_start_failed(p_scb);
|
||||
}
|
||||
|
||||
@@ -2412,8 +2413,7 @@ void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
event = BTA_AV_OPEN_EVT;
|
||||
p_scb->open_status = BTA_AV_SUCCESS;
|
||||
|
||||
bta_sys_conn_close(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
|
||||
|
||||
bta_sys_conn_close(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
|
||||
bta_av_cleanup(p_scb, p_data);
|
||||
(*bta_av_cb.p_cback)(event, &data);
|
||||
} else {
|
||||
@@ -2432,8 +2432,7 @@ void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
data.close.disc_rsn = p_scb->disc_rsn;
|
||||
event = BTA_AV_CLOSE_EVT;
|
||||
|
||||
bta_sys_conn_close(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
|
||||
|
||||
bta_sys_conn_close(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
|
||||
bta_av_cleanup(p_scb, p_data);
|
||||
(*bta_av_cb.p_cback)(event, &data);
|
||||
}
|
||||
@@ -2507,7 +2506,7 @@ void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
p_scb->cong = FALSE;
|
||||
}
|
||||
|
||||
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
|
||||
if ((bta_av_cb.features & BTA_AV_FEAT_MASTER) == 0 || bta_av_cb.audio_open_cnt == 1) {
|
||||
policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH;
|
||||
}
|
||||
|
||||
@@ -23,24 +23,24 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_av_api.h"
|
||||
#include "bta_av_api.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "stack/avdt_api.h"
|
||||
#include "bta/utl.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/list.h"
|
||||
#include "avdt_api.h"
|
||||
#include "utl.h"
|
||||
#include "l2c_api.h"
|
||||
#include "allocator.h"
|
||||
#include "list.h"
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
#include "bta/bta_ar_api.h"
|
||||
#include "bta_ar_api.h"
|
||||
#endif
|
||||
|
||||
#define LOG_TAG "bt_bta_av"
|
||||
// #include "osi/include/log.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "bt_trace.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
@@ -474,7 +474,7 @@ void bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
p_scb->rc_handle = p_data->rc_conn_chg.handle;
|
||||
APPL_TRACE_DEBUG("bta_av_rc_opened shdl:%d, srch %d", i + 1, p_scb->rc_handle);
|
||||
shdl = i + 1;
|
||||
APPL_TRACE_EVENT("%s allow incoming AVRCP connections:%d", __func__, p_scb->use_rc);
|
||||
LOG_INFO("%s allow incoming AVRCP connections:%d", __func__, p_scb->use_rc);
|
||||
bta_sys_stop_timer(&p_scb->timer);
|
||||
disc = p_scb->hndl;
|
||||
break;
|
||||
@@ -506,7 +506,7 @@ void bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
|
||||
p_cb->rcb[i].shdl = shdl;
|
||||
rc_open.rc_handle = i;
|
||||
APPL_TRACE_EVENT("bta_av_rc_opened rcb[%d] shdl:%d lidx:%d/%d",
|
||||
APPL_TRACE_ERROR("bta_av_rc_opened rcb[%d] shdl:%d lidx:%d/%d",
|
||||
i, shdl, p_cb->rcb[i].lidx, p_cb->lcb[BTA_AV_NUM_LINKS].lidx);
|
||||
p_cb->rcb[i].status |= BTA_AV_RC_CONN_MASK;
|
||||
|
||||
@@ -1063,7 +1063,7 @@ void bta_av_stream_chg(tBTA_AV_SCB *p_scb, BOOLEAN started)
|
||||
**
|
||||
** Function bta_av_conn_chg
|
||||
**
|
||||
** Description connection status changed.
|
||||
** Description connetion status changed.
|
||||
** Open an AVRCP acceptor channel, if new conn.
|
||||
**
|
||||
** Returns void
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_av_api.h"
|
||||
#include "allocator.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_av_api.h"
|
||||
#include "bta_av_int.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_av_int.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bt_target.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "bta/bta_av_ci.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "bta_av_ci.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
#ifndef BTA_AV_INT_H
|
||||
#define BTA_AV_INT_H
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_av_api.h"
|
||||
#include "stack/avdt_api.h"
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "osi/list.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_av_api.h"
|
||||
#include "avdt_api.h"
|
||||
#include "bta_av_co.h"
|
||||
#include "list.h"
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
@@ -153,7 +153,6 @@ enum {
|
||||
#define BTA_AV_MULTI_AV_SUPPORTED 0x01
|
||||
#define BTA_AV_MULTI_AV_IN_USE 0x02
|
||||
|
||||
#define TSEP_TO_SYS_ID(x) ((x) == AVDT_TSEP_SRC ? BTA_ID_AV : BTA_ID_AVK)
|
||||
|
||||
/*****************************************************************************
|
||||
** Data types
|
||||
@@ -25,20 +25,20 @@
|
||||
// #include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "bt_target.h"
|
||||
#include "bt_trace.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
#include "bta_av_int.h"
|
||||
#include "bta/utl.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "stack/l2cdefs.h"
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "utl.h"
|
||||
#include "l2c_api.h"
|
||||
#include "l2cdefs.h"
|
||||
#include "bta_av_co.h"
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
#include "bta/bta_ar_api.h"
|
||||
#include "bta_ar_api.h"
|
||||
#endif
|
||||
#include "osi/osi.h"
|
||||
#include "osi.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
@@ -194,8 +194,6 @@ const tBTA_AV_NSM_ACT bta_av_nsm_act[] = {
|
||||
/* AV control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_AV_CB bta_av_cb;
|
||||
#else
|
||||
tBTA_AV_CB *bta_av_cb_ptr;
|
||||
#endif
|
||||
|
||||
#if (defined(BTA_AV_DEBUG) && BTA_AV_DEBUG == TRUE)
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "stack/a2d_api.h"
|
||||
#include "stack/a2d_sbc.h"
|
||||
#include "bta/bta_av_sbc.h"
|
||||
#include "bta/utl.h"
|
||||
#include "common/bt_defs.h"
|
||||
#include "bt_target.h"
|
||||
#include "a2d_api.h"
|
||||
#include "a2d_sbc.h"
|
||||
#include "bta_av_sbc.h"
|
||||
#include "utl.h"
|
||||
#include "bt_utils.h"
|
||||
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "bta_av_co.h"
|
||||
#include "bta_av_int.h"
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
@@ -23,28 +23,27 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bt_target.h"
|
||||
#include "bt_types.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "bta/bta_dm_co.h"
|
||||
#include "bta/bta_gattc_co.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "bta_dm_co.h"
|
||||
#include "btm_api.h"
|
||||
#include "btm_int.h"
|
||||
#include "stack/btu.h"
|
||||
#include "stack/sdp_api.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "bta/utl.h"
|
||||
#include "stack/gap_api.h" /* For GAP_BleReadPeerPrefConnParams */
|
||||
#include "btu.h"
|
||||
#include "sdp_api.h"
|
||||
#include "l2c_api.h"
|
||||
#include "utl.h"
|
||||
#include "gap_api.h" /* For GAP_BleReadPeerPrefConnParams */
|
||||
#include <string.h>
|
||||
#include "device/controller.h"
|
||||
#include "controller.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_dm"
|
||||
// #include "osi/include/log.h"
|
||||
|
||||
#if (GAP_INCLUDED == TRUE)
|
||||
#include "stack/gap_api.h"
|
||||
#include "gap_api.h"
|
||||
#endif
|
||||
|
||||
static void bta_dm_inq_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
|
||||
@@ -169,10 +168,10 @@ const UINT16 bta_service_id_to_uuid_lkup_tbl [BTA_MAX_SERVICE_ID] = {
|
||||
|
||||
/*
|
||||
* NOTE : The number of element in bta_service_id_to_btm_srv_id_lkup_tbl should be matching with
|
||||
* the value BTA_MAX_SERVICE_ID in bta/bta_api.h
|
||||
* the value BTA_MAX_SERVICE_ID in bta_api.h
|
||||
*
|
||||
* i.e., If you add new Service ID for BTA, the correct security ID of the new service
|
||||
* from Security service definitions (stack/btm_api.h) should be added to this lookup table.
|
||||
* from Security service definitions (btm_api.h) should be added to this lookup table.
|
||||
*/
|
||||
const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl [BTA_MAX_SERVICE_ID] = {
|
||||
0, /* Reserved */
|
||||
@@ -374,12 +373,6 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
bta_sys_hw_unregister( BTA_SYS_HW_BLUETOOTH );
|
||||
/* notify BTA DM is now unactive */
|
||||
bta_dm_cb.is_bta_dm_active = FALSE;
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
|
||||
#if (GATTC_INCLUDED == TRUE && GATTC_CACHE_NVS == TRUE)
|
||||
/* clear the gattc cache address list */
|
||||
bta_gattc_co_cache_addr_deinit();
|
||||
#endif
|
||||
#endif
|
||||
} else if ( status == BTA_SYS_HW_ON_EVT ) {
|
||||
/* FIXME: We should not unregister as the SYS shall invoke this callback on a H/W error.
|
||||
* We need to revisit when this platform has more than one BLuetooth H/W chip */
|
||||
@@ -402,17 +395,15 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
#endif
|
||||
/* hw is ready, go on with BTA DM initialization */
|
||||
memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb));
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs));
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
|
||||
|
||||
memcpy(dev_class, p_bta_dm_cfg->dev_class, sizeof(dev_class));
|
||||
BTM_SetDeviceClass (dev_class);
|
||||
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
|
||||
#if (GATTC_INCLUDED == TRUE && GATTC_CACHE_NVS == TRUE)
|
||||
// load the gattc cache address list
|
||||
bta_gattc_co_cache_addr_init();
|
||||
#endif /* #if (GATTC_INCLUDED = TRUE) */
|
||||
/* load BLE local information: ID keys, ER if available */
|
||||
bta_dm_co_ble_load_local_keys(&key_mask, er, &id_key);
|
||||
|
||||
@@ -447,12 +438,10 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
|
||||
BTM_ReadLocalDeviceNameFromController((tBTM_CMPL_CB *)bta_dm_local_name_cback);
|
||||
|
||||
bta_sys_rm_register((tBTA_SYS_CONN_CBACK *)bta_dm_rm_cback);
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/* initialize bluetooth low power manager */
|
||||
bta_dm_init_pm();
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
bta_sys_policy_register((tBTA_SYS_CONN_CBACK *)bta_dm_policy_cback);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && SDP_INCLUDED == TRUE) && (GATTC_INCLUDED == TRUE)
|
||||
@@ -489,11 +478,9 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
|
||||
|
||||
BTM_SetDiscoverability(BTM_NON_DISCOVERABLE, 0, 0);
|
||||
BTM_SetConnectability(BTM_NON_CONNECTABLE, 0, 0);
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_disable_pm();
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
bta_dm_disable_search_and_disc();
|
||||
bta_dm_cb.disabling = TRUE;
|
||||
|
||||
@@ -709,7 +696,7 @@ void bta_dm_process_remove_device(BD_ADDR bd_addr)
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
/* remove all cached GATT information */
|
||||
BTA_GATTC_Refresh(bd_addr, false);
|
||||
BTA_GATTC_Refresh(bd_addr);
|
||||
#endif
|
||||
|
||||
if (bta_dm_cb.p_sec_cback) {
|
||||
@@ -893,7 +880,7 @@ void bta_dm_close_acl(tBTA_DM_MSG *p_data)
|
||||
/* need to remove all pending background connection if any */
|
||||
BTA_GATTC_CancelOpen(0, p_remove_acl->bd_addr, FALSE);
|
||||
/* remove all cached GATT information */
|
||||
BTA_GATTC_Refresh(p_remove_acl->bd_addr, false);
|
||||
BTA_GATTC_Refresh(p_remove_acl->bd_addr);
|
||||
#endif
|
||||
}
|
||||
/* otherwise, no action needed */
|
||||
@@ -1078,12 +1065,12 @@ static void bta_dm_policy_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app
|
||||
p_dev->link_policy &= (~policy);
|
||||
BTM_SetLinkPolicy(p_dev->peer_bdaddr, &(p_dev->link_policy));
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
if (policy & (HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)) {
|
||||
/* if clearing sniff/park, wake the link */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_pm_active(p_dev->peer_bdaddr);
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
}
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
break;
|
||||
|
||||
case BTA_SYS_PLCY_DEF_SET:
|
||||
@@ -1629,9 +1616,11 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
|
||||
|| (p_data->sdp_event.sdp_result == SDP_DB_FULL)) {
|
||||
APPL_TRACE_DEBUG("sdp_result::0x%x", p_data->sdp_event.sdp_result);
|
||||
do {
|
||||
|
||||
p_sdp_rec = NULL;
|
||||
if ( bta_dm_search_cb.service_index == (BTA_USER_SERVICE_ID + 1) ) {
|
||||
p_sdp_rec = SDP_FindServiceUUIDInDb(bta_dm_search_cb.p_sdp_db, &bta_dm_search_cb.uuid, p_sdp_rec);
|
||||
|
||||
if (p_sdp_rec && SDP_FindProtocolListElemInRec(p_sdp_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
bta_dm_search_cb.peer_scn = (UINT8) pe.params[0];
|
||||
scn_found = TRUE;
|
||||
@@ -1647,6 +1636,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
|
||||
p_uuid += (bta_dm_search_cb.num_uuid - bta_dm_search_cb.uuid_to_search);
|
||||
/* only support 16 bits UUID for now */
|
||||
service = p_uuid->uu.uuid16;
|
||||
|
||||
}
|
||||
/* all GATT based services */
|
||||
do {
|
||||
@@ -1679,7 +1669,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
|
||||
if (((p_data->sdp_event.sdp_result == SDP_DB_FULL) &&
|
||||
bta_dm_search_cb.services != BTA_ALL_SERVICE_MASK) ||
|
||||
(p_sdp_rec != NULL)) {
|
||||
if (service != UUID_SERVCLASS_PNP_INFORMATION && service != 0) {
|
||||
if (service != UUID_SERVCLASS_PNP_INFORMATION) {
|
||||
UINT16 tmp_svc = 0xFFFF;
|
||||
bta_dm_search_cb.services_found |=
|
||||
(tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index - 1));
|
||||
@@ -1706,8 +1696,11 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
|
||||
} else { /* regular one service per search or PNP search */
|
||||
break;
|
||||
}
|
||||
|
||||
} while (bta_dm_search_cb.service_index <= BTA_MAX_SERVICE_ID);
|
||||
|
||||
// osi_free(bta_dm_search_cb.p_sdp_db);
|
||||
// bta_dm_search_cb.p_sdp_db = NULL;
|
||||
APPL_TRACE_DEBUG("%s services_found = %04x", __FUNCTION__,
|
||||
bta_dm_search_cb.services_found);
|
||||
|
||||
@@ -2117,13 +2110,13 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
memset (&uuid, 0, sizeof(tSDP_UUID));
|
||||
|
||||
while (bta_dm_search_cb.service_index < BTA_MAX_SERVICE_ID) {
|
||||
tBTA_SERVICE_MASK this_service_mask = (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index));
|
||||
if ( bta_dm_search_cb.services_to_search & this_service_mask) {
|
||||
if ( bta_dm_search_cb.services_to_search
|
||||
& (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index))) {
|
||||
if ((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(BTA_DM_SDP_DB_SIZE)) != NULL) {
|
||||
APPL_TRACE_DEBUG("bta_dm_search_cb.services = %04x***********", bta_dm_search_cb.services);
|
||||
/* try to search all services by search based on L2CAP UUID */
|
||||
if (bta_dm_search_cb.services == BTA_ALL_SERVICE_MASK ) {
|
||||
APPL_TRACE_DEBUG("%s services_to_search=%08x", __func__, bta_dm_search_cb.services_to_search);
|
||||
LOG_INFO("%s services_to_search=%08x", __func__, bta_dm_search_cb.services_to_search);
|
||||
if (bta_dm_search_cb.services_to_search & BTA_RES_SERVICE_MASK) {
|
||||
uuid.uu.uuid16 = bta_service_id_to_uuid_lkup_tbl[0];
|
||||
bta_dm_search_cb.services_to_search &= ~BTA_RES_SERVICE_MASK;
|
||||
@@ -2134,7 +2127,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
} else {
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
/* for LE only profile */
|
||||
if (this_service_mask == BTA_BLE_SERVICE_MASK) {
|
||||
if (bta_dm_search_cb.service_index == BTA_BLE_SERVICE_ID) {
|
||||
if (bta_dm_search_cb.uuid_to_search > 0 && bta_dm_search_cb.p_srvc_uuid) {
|
||||
memcpy(&uuid,
|
||||
(const void *)(bta_dm_search_cb.p_srvc_uuid + \
|
||||
@@ -2165,11 +2158,11 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
uuid.len = LEN_UUID_16;
|
||||
}
|
||||
|
||||
if (this_service_mask == BTA_USER_SERVICE_MASK) {
|
||||
if (bta_dm_search_cb.service_index == BTA_USER_SERVICE_ID) {
|
||||
memcpy(&uuid, &bta_dm_search_cb.uuid, sizeof(tSDP_UUID));
|
||||
}
|
||||
|
||||
APPL_TRACE_DEBUG("%s search UUID = %04x", __func__, uuid.uu.uuid16);
|
||||
LOG_INFO("%s search UUID = %04x", __func__, uuid.uu.uuid16);
|
||||
SDP_InitDiscoveryDb (bta_dm_search_cb.p_sdp_db, BTA_DM_SDP_DB_SIZE, 1, &uuid, 0, NULL);
|
||||
|
||||
memset(g_disc_raw_data_buf, 0, sizeof(g_disc_raw_data_buf));
|
||||
@@ -2186,9 +2179,9 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
|
||||
} else {
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
if ((this_service_mask == BTA_BLE_SERVICE_MASK &&
|
||||
if ((bta_dm_search_cb.service_index == BTA_BLE_SERVICE_ID &&
|
||||
bta_dm_search_cb.uuid_to_search == 0) ||
|
||||
this_service_mask != BTA_BLE_SERVICE_MASK)
|
||||
bta_dm_search_cb.service_index != BTA_BLE_SERVICE_ID)
|
||||
#endif
|
||||
bta_dm_search_cb.service_index++;
|
||||
return;
|
||||
@@ -3131,7 +3124,7 @@ static BOOLEAN bta_dm_check_av(UINT16 event)
|
||||
}
|
||||
#endif
|
||||
|
||||
APPL_TRACE_EVENT("bta_dm_check_av:%d", bta_dm_cb.cur_av_count);
|
||||
APPL_TRACE_WARNING("bta_dm_check_av:%d", bta_dm_cb.cur_av_count);
|
||||
if (bta_dm_cb.cur_av_count) {
|
||||
for (i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
p_dev = &bta_dm_cb.device_list.peer_device[i];
|
||||
@@ -3342,7 +3335,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
|
||||
/* need to remove all pending background connection */
|
||||
BTA_GATTC_CancelOpen(0, p_bda, FALSE);
|
||||
/* remove all cached GATT information */
|
||||
BTA_GATTC_Refresh(p_bda, false);
|
||||
BTA_GATTC_Refresh(p_bda);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3373,12 +3366,10 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
UNUSED(p_tle);
|
||||
tBTA_SYS_HW_MSG *sys_enable_event;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/* disable the power managment module */
|
||||
bta_dm_disable_pm();
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
/* register our callback to SYS HW manager */
|
||||
bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
|
||||
|
||||
@@ -3441,7 +3432,9 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
}
|
||||
/* AV calls bta_sys_conn_open with the A2DP stream count as app_id */
|
||||
if (BTA_ID_AV == id) {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_cb.cur_av_count = bta_dm_get_av_count();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
}
|
||||
} else if ( status == BTA_SYS_CONN_IDLE) {
|
||||
if (p_dev) {
|
||||
@@ -3450,10 +3443,12 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
|
||||
/* get cur_av_count from connected services */
|
||||
if (BTA_ID_AV == id) {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
bta_dm_cb.cur_av_count = bta_dm_get_av_count();
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
}
|
||||
}
|
||||
APPL_TRACE_EVENT("bta_dm_rm_cback:%d, status:%d", bta_dm_cb.cur_av_count, status);
|
||||
APPL_TRACE_WARNING("bta_dm_rm_cback:%d, status:%d", bta_dm_cb.cur_av_count, status);
|
||||
}
|
||||
|
||||
/* Don't adjust roles for each busy/idle state transition to avoid
|
||||
@@ -3516,7 +3511,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
|
||||
/* need to remove all pending background connection */
|
||||
BTA_GATTC_CancelOpen(0, remote_bd_addr, FALSE);
|
||||
/* remove all cached GATT information */
|
||||
BTA_GATTC_Refresh(remote_bd_addr, false);
|
||||
BTA_GATTC_Refresh(remote_bd_addr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -4689,19 +4684,6 @@ void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_config_local_icon
|
||||
**
|
||||
** Description This function sets the local icon value.
|
||||
**
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_BleConfigLocalIcon (p_data->ble_local_icon.icon);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_observe
|
||||
@@ -5536,7 +5518,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id)
|
||||
APPL_TRACE_ERROR("%s out of room to accomodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used );
|
||||
}
|
||||
|
||||
APPL_TRACE_API("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len);
|
||||
LOG_INFO("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len);
|
||||
if ( bta_dm_search_cb.state != BTA_DM_SEARCH_IDLE) {
|
||||
|
||||
/* send result back to app now, one by one */
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "bta_sys_int.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "btm_int.h"
|
||||
#include <string.h>
|
||||
#include "bta/utl.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "utl.h"
|
||||
#include "allocator.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
@@ -166,7 +166,7 @@ void BTA_DisableTestMode(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetDeviceName(const char *p_name)
|
||||
void BTA_DmSetDeviceName(char *p_name)
|
||||
{
|
||||
|
||||
tBTA_DM_API_SET_NAME *p_msg;
|
||||
@@ -1631,30 +1631,6 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleConfigLocalIcon
|
||||
**
|
||||
** Description set gap local icon
|
||||
**
|
||||
** Parameters: icon - appearance value.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmBleConfigLocalIcon(uint16_t icon)
|
||||
{
|
||||
tBTA_DM_API_LOCAL_ICON *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_LOCAL_ICON *) osi_malloc(sizeof(tBTA_DM_API_LOCAL_ICON))) != NULL) {
|
||||
memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_ICON));
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_LOCAL_ICON_EVT;
|
||||
p_msg->icon = icon;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_BleEnableAdvInstance
|
||||
|
||||
@@ -24,11 +24,11 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bt_target.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
// #include "bta/bta_jv_api.h"
|
||||
// #include "bta_jv_api.h"
|
||||
|
||||
#ifndef BTA_DM_LINK_POLICY_SETTINGS
|
||||
#define BTA_DM_LINK_POLICY_SETTINGS (HCI_ENABLE_MASTER_SLAVE_SWITCH | HCI_ENABLE_HOLD_MODE | HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)
|
||||
@@ -116,24 +116,39 @@ tBTA_DM_CFG *p_bta_dm_cfg = (tBTA_DM_CFG *) &bta_dm_cfg;
|
||||
tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *) &bta_dm_rm_cfg;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
# define BTA_DM_NUM_PM_ENTRY 6 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 6 /* number of entries in bta_dm_pm_spec */
|
||||
# define BTA_DM_NUM_PM_ENTRY 21 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 15 /* number of entries in bta_dm_pm_spec */
|
||||
#else
|
||||
# define BTA_DM_NUM_PM_ENTRY 4 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 4 /* number of entries in bta_dm_pm_spec */
|
||||
# define BTA_DM_NUM_PM_ENTRY 19 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 13 /* number of entries in bta_dm_pm_spec */
|
||||
#endif
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1] = {
|
||||
{BTA_ID_SYS, BTA_DM_NUM_PM_ENTRY, 0}, /* reserved: specifies length of this table. */
|
||||
{BTA_ID_AG, BTA_ALL_APP_ID, 0}, /* ag uses first spec table for app id 0 */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 1}, /* av spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 2}, /* HS spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 3} /* avk spec table */
|
||||
{BTA_ID_CT, 1, 1}, /* ct (BTA_ID_CT,APP ID=1) spec table */
|
||||
{BTA_ID_CG, BTA_ALL_APP_ID, 1}, /* cg resue ct spec table */
|
||||
{BTA_ID_DG, BTA_ALL_APP_ID, 2}, /* dg spec table */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 4}, /* av spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 12}, /* avk spec table */
|
||||
{BTA_ID_FTC, BTA_ALL_APP_ID, 6}, /* ftc spec table */
|
||||
{BTA_ID_FTS, BTA_ALL_APP_ID, 7}, /* fts spec table */
|
||||
{BTA_ID_HD, BTA_ALL_APP_ID, 3}, /* hd spec table */
|
||||
{BTA_ID_HH, BTA_ALL_APP_ID, 5}, /* hh spec table */
|
||||
{BTA_ID_PBC, BTA_ALL_APP_ID, 2}, /* reuse dg spec table */
|
||||
{BTA_ID_PBS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_OPC, BTA_ALL_APP_ID, 6}, /* reuse ftc spec table */
|
||||
{BTA_ID_OPS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
// {BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
|
||||
// {BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_HL, BTA_ALL_APP_ID, 8}, /* reuse fts spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_PANU, 9}, /* PANU spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_NAP, 10}, /* NAP spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 11} /* HS spec table */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
, {BTA_ID_GATTC, BTA_ALL_APP_ID, 4} /* gattc spec table */
|
||||
, {BTA_ID_GATTS, BTA_ALL_APP_ID, 5} /* gatts spec table */
|
||||
, {BTA_ID_GATTC, BTA_ALL_APP_ID, 13} /* gattc spec table */
|
||||
, {BTA_ID_GATTS, BTA_ALL_APP_ID, 14} /* gatts spec table */
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -158,7 +173,64 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* AV : 1 */
|
||||
/* CT, CG : 1 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_PARK, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open park */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
|
||||
{{BTA_DM_PM_PARK, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close park */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* DG, PBC : 2 */
|
||||
{
|
||||
(BTA_DM_PM_ACTIVE), /* no power saving mode allowed */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF, 1000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HD : 3 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR3), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_HD_IDLE_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* AV : 4 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@@ -177,7 +249,122 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* HS : 2 */
|
||||
/* HH : 5 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR1), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close, used for HH suspend */
|
||||
{{BTA_DM_PM_SNIFF_HH_IDLE_IDX, BTA_DM_PM_HH_IDLE_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* FTC, OPC, JV : 6 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* FTS, PBS, OPS, MSE, BTA_JV_PM_ID_1 : 7 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HL : 8 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* PANU : 9 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* NAP : 10 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HS : 11 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@@ -196,7 +383,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
},
|
||||
|
||||
/* AVK : 3 */
|
||||
/* AVK : 12 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@@ -216,7 +403,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* GATTC : 4 */
|
||||
/* GATTC : 13 */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@@ -237,7 +424,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
/* GATTS : 5 */
|
||||
/* GATTS : 14 */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@@ -272,13 +459,13 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
#endif /* BTE_SIM_APP */
|
||||
};
|
||||
|
||||
/* Please refer to the SNIFF table definitions in bta/bta_api.h.
|
||||
/* Please refer to the SNIFF table definitions in bta_api.h.
|
||||
*
|
||||
* Adding to or Modifying the Table
|
||||
* Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF5 - BTA_DM_PM_SNIFF7.
|
||||
* Overrides of additional table entries can be specified in bdroid_buildcfg.h. If additional
|
||||
* sniff parameter entries are added or an override of an existing entry is specified in
|
||||
* bdroid_buildcfg.h then the BTA_DM_PM_*_IDX defines in bta/bta_api.h will need to be match the new
|
||||
* bdroid_buildcfg.h then the BTA_DM_PM_*_IDX defines in bta_api.h will need to be match the new
|
||||
* ordering.
|
||||
*
|
||||
* Table Ordering
|
||||
@@ -291,7 +478,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] = {
|
||||
* More sniff parameter entries can be added for
|
||||
* BTA_DM_PM_SNIFF3 - BTA_DM_PM_SNIFF7, if needed. When entries are added or
|
||||
* removed, BTA_DM_PM_PARK_IDX needs to be updated to reflect the actual index
|
||||
* BTA_DM_PM_PARK_IDX is defined in bta/bta_api.h and can be override by the
|
||||
* BTA_DM_PM_PARK_IDX is defined in bta_api.h and can be override by the
|
||||
* bdroid_buildcfg.h settings.
|
||||
* The SNIFF table entries must be in the order from highest latency (biggest
|
||||
* interval) to lowest latency. If there's a conflict among the connected
|
||||
@@ -341,8 +528,6 @@ tBTA_DM_PM_CFG *p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG *) &bta_dm_pm_cfg;
|
||||
tBTA_DM_PM_SPEC *p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC *) &bta_dm_pm_spec;
|
||||
tBTM_PM_PWR_MD *p_bta_dm_pm_md = (tBTM_PM_PWR_MD *) &bta_dm_pm_md;
|
||||
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* The performance impact of EIR packet size
|
||||
**
|
||||
** When BTM_EIR_DEFAULT_FEC_REQUIRED is TRUE,
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include <string.h>
|
||||
#include "bta/bta_dm_ci.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "bta_dm_ci.h"
|
||||
#include "allocator.h"
|
||||
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
@@ -83,3 +83,32 @@ void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16
|
||||
}
|
||||
}
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sco_ci_data_ready
|
||||
**
|
||||
** Description This function sends an event to indicating that the phone
|
||||
** has SCO data ready.
|
||||
**
|
||||
** Parameters event: is obtained from bta_dm_sco_co_open() function, which
|
||||
** is the BTA event we want to send back to BTA module
|
||||
** when there is encoded data ready.
|
||||
** sco_handle: is the BTA sco handle which indicate a specific
|
||||
** SCO connection.
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = event;
|
||||
p_buf->layer_specific = sco_handle;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
#ifndef BTA_DM_INT_H
|
||||
#define BTA_DM_INT_H
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -63,11 +63,11 @@ enum {
|
||||
BTA_DM_API_BOND_CANCEL_EVT,
|
||||
BTA_DM_API_PIN_REPLY_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
BTA_DM_PM_BTM_STATUS_EVT,
|
||||
BTA_DM_PM_TIMER_EVT,
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/* simple pairing events */
|
||||
BTA_DM_API_CONFIRM_EVT,
|
||||
@@ -108,7 +108,6 @@ enum {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
BTA_DM_API_LOCAL_PRIVACY_EVT,
|
||||
#endif
|
||||
BTA_DM_API_LOCAL_ICON_EVT,
|
||||
BTA_DM_API_BLE_ADV_PARAM_EVT,
|
||||
|
||||
/*******This event added by Yulong at 2016/10/20 to
|
||||
@@ -350,7 +349,6 @@ typedef struct {
|
||||
#endif
|
||||
} tBTA_DM_ACL_CHANGE;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* data type for BTA_DM_PM_BTM_STATUS_EVT */
|
||||
typedef struct {
|
||||
|
||||
@@ -368,7 +366,7 @@ typedef struct {
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_DM_PM_ACTION pm_request;
|
||||
} tBTA_DM_PM_TIMER;
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
|
||||
/* data type for BTA_DM_API_ADD_DEVICE_EVT */
|
||||
typedef struct {
|
||||
@@ -470,11 +468,6 @@ typedef struct {
|
||||
tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||
} tBTA_DM_API_LOCAL_PRIVACY;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
uint16_t icon;
|
||||
} tBTA_DM_API_LOCAL_ICON;
|
||||
|
||||
/* set scan parameter for BLE connections */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -759,11 +752,9 @@ typedef union {
|
||||
|
||||
tBTA_DM_ACL_CHANGE acl_change;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
tBTA_DM_PM_BTM_STATUS pm_status;
|
||||
|
||||
tBTA_DM_PM_TIMER pm_timer;
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
tBTA_DM_API_DI_DISC di_disc;
|
||||
|
||||
@@ -785,7 +776,6 @@ typedef union {
|
||||
tBTA_DM_API_BLE_SCAN ble_scan;
|
||||
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
|
||||
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
|
||||
tBTA_DM_API_LOCAL_ICON ble_local_icon;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
|
||||
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
|
||||
@@ -893,10 +883,6 @@ typedef struct {
|
||||
|
||||
} tBTA_DM_CONNECTED_SRVCS;
|
||||
|
||||
extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
|
||||
typedef struct {
|
||||
#define BTA_DM_PM_SNIFF_TIMER_IDX 0
|
||||
#define BTA_DM_PM_PARK_TIMER_IDX 1
|
||||
@@ -916,8 +902,9 @@ typedef struct {
|
||||
BOOLEAN in_use;
|
||||
} tBTA_PM_TIMER;
|
||||
|
||||
extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
#define BTA_DM_NUM_PM_TIMER 7
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* DM control block */
|
||||
typedef struct {
|
||||
@@ -938,10 +925,10 @@ typedef struct {
|
||||
UINT32 wbt_sdp_handle; /* WIDCOMM Extensions SDP record handle */
|
||||
UINT8 wbt_scn; /* WIDCOMM Extensions SCN */
|
||||
UINT8 num_master_only;
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
#if BTM_SSR_INCLUDED == TRUE
|
||||
UINT8 pm_id;
|
||||
tBTA_PM_TIMER pm_timer[BTA_DM_NUM_PM_TIMER];
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */
|
||||
UINT16 cur_policy; /* current default link policy */
|
||||
UINT16 rs_event; /* the event waiting for role switch */
|
||||
@@ -1108,14 +1095,12 @@ typedef struct {
|
||||
UINT8 lmp_version;
|
||||
} tBTA_DM_LMP_VER_INFO;
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
extern tBTA_DM_PM_CFG *p_bta_dm_pm_cfg;
|
||||
extern tBTA_DM_PM_SPEC *p_bta_dm_pm_spec;
|
||||
extern tBTM_PM_PWR_MD *p_bta_dm_pm_md;
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
extern tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec;
|
||||
#endif
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* update dynamic BRCM Aware EIR data */
|
||||
extern const tBTA_DM_EIR_CONF bta_dm_eir_cfg;
|
||||
@@ -1147,7 +1132,6 @@ extern tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
|
||||
|
||||
extern BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg);
|
||||
extern void bta_dm_sm_disable( void );
|
||||
extern void bta_dm_sm_deinit(void);
|
||||
extern BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg);
|
||||
extern void bta_dm_search_sm_disable( void );
|
||||
|
||||
@@ -1170,6 +1154,9 @@ extern void bta_dm_add_device (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_remove_device (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_close_acl(tBTA_DM_MSG *p_data);
|
||||
|
||||
|
||||
extern void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_pm_timer(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_add_ampkey (tBTA_DM_MSG *p_data);
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
@@ -1193,7 +1180,6 @@ extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params_all(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
|
||||
@@ -1229,13 +1215,8 @@ extern void bta_dm_ci_io_req_act(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ci_rmt_oob_act(tBTA_DM_MSG *p_data);
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
extern void bta_dm_init_pm(void);
|
||||
extern void bta_dm_disable_pm(void);
|
||||
extern void bta_dm_pm_active(BD_ADDR peer_addr);
|
||||
extern void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_pm_timer(tBTA_DM_MSG *p_data);
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
extern UINT8 bta_dm_get_av_count(void);
|
||||
extern void bta_dm_search_start (tBTA_DM_MSG *p_data);
|
||||
@@ -1262,6 +1243,9 @@ extern void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data);
|
||||
extern tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr);
|
||||
|
||||
extern void bta_dm_pm_active(BD_ADDR peer_addr);
|
||||
|
||||
void bta_dm_eir_update_uuid(UINT16 uuid16, BOOLEAN adding);
|
||||
|
||||
extern void bta_dm_enable_test_mode(tBTA_DM_MSG *p_data);
|
||||
@@ -22,11 +22,9 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "osi/allocator.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -37,10 +35,6 @@
|
||||
tBTA_DM_CB bta_dm_cb;
|
||||
tBTA_DM_SEARCH_CB bta_dm_search_cb;
|
||||
tBTA_DM_DI_CB bta_dm_di_cb;
|
||||
#else
|
||||
tBTA_DM_CB *bta_dm_cb_ptr;
|
||||
tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr;
|
||||
tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -66,11 +60,11 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
/* simple pairing events */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
|
||||
@@ -111,7 +105,6 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||
#endif
|
||||
bta_dm_ble_config_local_icon, /* BTA_DM_API_LOCAL_ICON_EVT */
|
||||
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
||||
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
|
||||
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
||||
@@ -353,18 +346,6 @@ void bta_dm_sm_disable( )
|
||||
bta_sys_deregister( BTA_ID_DM );
|
||||
}
|
||||
|
||||
void bta_dm_sm_deinit(void)
|
||||
{
|
||||
memset(&bta_dm_cb, 0, sizeof(tBTA_DM_CB));
|
||||
memset(&bta_dm_search_cb, 0, sizeof(tBTA_DM_SEARCH_CB));
|
||||
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
|
||||
#if BTA_DYNAMIC_MEMORY
|
||||
FREE_AND_RESET(bta_dm_cb_ptr);
|
||||
FREE_AND_RESET(bta_dm_search_cb_ptr);
|
||||
FREE_AND_RESET(bta_dm_di_cb_ptr);
|
||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -26,15 +26,13 @@
|
||||
// #include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "btm_api.h"
|
||||
|
||||
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_mode,
|
||||
tBTA_DM_PM_REQ pm_req);
|
||||
@@ -47,15 +45,18 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive);
|
||||
static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable);
|
||||
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
UINT8 timer_idx);
|
||||
#endif///BTM_SSR_INCLUDED == TRUE
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
#if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE)
|
||||
#include "../hh/bta_hh_int.h"
|
||||
/* BTA_DM_PM_SSR1 will be dedicated for HH SSR setting entry, no other profile can use it */
|
||||
#define BTA_DM_PM_SSR_HH BTA_DM_PM_SSR1
|
||||
#endif /* (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE) */
|
||||
#endif
|
||||
static void bta_dm_pm_ssr(BD_ADDR peer_addr);
|
||||
#endif /* (BTM_SSR_INCLUDED == TRUE) */
|
||||
|
||||
tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -117,6 +118,27 @@ void bta_dm_disable_pm(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_get_av_count
|
||||
**
|
||||
** Description Get the number of connected AV
|
||||
**
|
||||
**
|
||||
** Returns number of av connections
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_dm_get_av_count(void)
|
||||
{
|
||||
UINT8 count = 0;
|
||||
for (int i = 0; i < bta_dm_conn_srvcs.count; i++) {
|
||||
if (bta_dm_conn_srvcs.conn_srvc[i].id == BTA_ID_AV) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_stop_timer
|
||||
@@ -315,10 +337,10 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
{
|
||||
|
||||
UINT8 i, j;
|
||||
UINT8 *p = NULL;
|
||||
tBTA_DM_PEER_DEVICE *p_dev;
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
UINT8 *p = NULL;
|
||||
int index = BTA_DM_PM_SSR0;
|
||||
#endif
|
||||
|
||||
@@ -470,6 +492,7 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
tBTA_DM_PM_REQ pm_req )
|
||||
{
|
||||
@@ -572,7 +595,7 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
remaining_ticks = bta_dm_pm_get_remaining_ticks(&bta_dm_cb.pm_timer[i].timer[timer_idx]);
|
||||
if (remaining_ticks < timeout) {
|
||||
APPL_TRACE_DEBUG("%s remain 0\n", __func__);
|
||||
LOG_DEBUG("%s remain 0\n", __func__);
|
||||
/* Cancel and restart the timer */
|
||||
/*
|
||||
* TODO: The value of pm_action[timer_idx] is
|
||||
@@ -679,6 +702,8 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
BTM_ReadPowerMode(p_peer_dev->peer_bdaddr, &mode);
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
p_rem_feat = BTM_ReadRemoteFeatures (p_peer_dev->peer_bdaddr);
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_sniff cur:%d, idx:%d, info:x%x", mode, index, p_peer_dev->info);
|
||||
if (mode != BTM_PM_MD_SNIFF ||
|
||||
(HCI_SNIFF_SUB_RATE_SUPPORTED(BTM_ReadLocalFeatures ()) && p_rem_feat &&
|
||||
@@ -780,7 +805,6 @@ static void bta_dm_pm_ssr(BD_ADDR peer_addr)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_active
|
||||
@@ -800,8 +824,11 @@ void bta_dm_pm_active(BD_ADDR peer_addr)
|
||||
/* switch to active mode */
|
||||
pm.mode = BTM_PM_MD_ACTIVE;
|
||||
BTM_SetPowerMode (bta_dm_cb.pm_id, peer_addr, &pm);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_btm_cback
|
||||
@@ -874,7 +901,6 @@ static void bta_dm_pm_timer_cback(void *p_tle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_btm_status
|
||||
@@ -969,9 +995,11 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pm_timer
|
||||
@@ -987,7 +1015,33 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data)
|
||||
APPL_TRACE_EVENT("%s", __func__);
|
||||
bta_dm_pm_set_mode(p_data->pm_timer.bd_addr, p_data->pm_timer.pm_request, BTA_DM_PM_EXECUTE);
|
||||
}
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_find_peer_device
|
||||
**
|
||||
** Description Given an address, find the associated control block.
|
||||
**
|
||||
** Returns tBTA_DM_PEER_DEVICE
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTA_DM_PEER_DEVICE *p_dev = NULL;
|
||||
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, peer_addr)) {
|
||||
p_dev = &bta_dm_cb.device_list.peer_device[i];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return p_dev;
|
||||
}
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_is_sco_active
|
||||
@@ -1084,52 +1138,7 @@ static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisa
|
||||
BTM_SetLinkPolicy(p_dev->peer_bdaddr, &policy_setting);
|
||||
|
||||
}
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_get_av_count
|
||||
**
|
||||
** Description Get the number of connected AV
|
||||
**
|
||||
**
|
||||
** Returns number of av connections
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 bta_dm_get_av_count(void)
|
||||
{
|
||||
UINT8 count = 0;
|
||||
for (int i = 0; i < bta_dm_conn_srvcs.count; i++) {
|
||||
if (bta_dm_conn_srvcs.conn_srvc[i].id == BTA_ID_AV) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_find_peer_device
|
||||
**
|
||||
** Description Given an address, find the associated control block.
|
||||
**
|
||||
** Returns tBTA_DM_PEER_DEVICE
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTA_DM_PEER_DEVICE *p_dev = NULL;
|
||||
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, peer_addr)) {
|
||||
p_dev = &bta_dm_cb.device_list.peer_device[i];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return p_dev;
|
||||
}
|
||||
|
||||
#endif ///BTM_SSR_INCLUDED == TRUE
|
||||
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
@@ -1152,6 +1161,5 @@ tBTA_DM_CONTRL_STATE bta_dm_pm_obtain_controller_state(void)
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_obtain_controller_state: %d", cur_state);
|
||||
return cur_state;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
#include <string.h>
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
|
||||
@@ -650,6 +650,6 @@ INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst)
|
||||
APPL_TRACE_DEBUG("bta_pcm_resample : outsamples %d", out_sample);
|
||||
#endif
|
||||
|
||||
return (out_sample);
|
||||
return (out_sample * bta_dm_pcm_cb.sample_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_gatt_common.h"
|
||||
#include "bta_gatt_common.h"
|
||||
#include "gatt_int.h"
|
||||
|
||||
void BTA_GATT_SetLocalMTU(uint16_t mtu)
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
******************************************************************************/
|
||||
#define LOG_TAG "bt_bta_gattc"
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "utl.h"
|
||||
#include "bta_sys.h"
|
||||
|
||||
#include "bta_gattc_int.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "l2c_api.h"
|
||||
#include "l2c_int.h"
|
||||
#include "gatt_int.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "allocator.h"
|
||||
#include "mutex.h"
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
#include "bta_hh_int.h"
|
||||
@@ -65,15 +65,17 @@ static void bta_gattc_pop_command_to_send(tBTA_GATTC_CLCB *p_clcb);
|
||||
static void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB *p_clreg);
|
||||
static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda);
|
||||
static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested);
|
||||
static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data);
|
||||
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda);
|
||||
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda, BOOLEAN *need_timer);
|
||||
static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle);
|
||||
static void bta_gattc_start_service_change_ccc_timer(UINT16 conn_id, BD_ADDR bda,UINT32 timeout_ms,
|
||||
UINT8 timer_cnt, UINT8 last_status, TIMER_LIST_ENT *ccc_timer);
|
||||
|
||||
static tGATT_CBACK bta_gattc_cl_cback = {
|
||||
bta_gattc_conn_cback,
|
||||
bta_gattc_cmpl_cback,
|
||||
bta_gattc_disc_res_cback,
|
||||
bta_gattc_disc_cmpl_cback,
|
||||
bta_gattc_req_cback,
|
||||
NULL,
|
||||
bta_gattc_enc_cmpl_cback,
|
||||
bta_gattc_cong_cback
|
||||
};
|
||||
@@ -124,6 +126,8 @@ static void bta_gattc_enable(tBTA_GATTC_CB *p_cb)
|
||||
/* initialize control block */
|
||||
memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
|
||||
p_cb->state = BTA_GATTC_STATE_ENABLED;
|
||||
// Create a write ccc mutex when the gatt client enable
|
||||
osi_mutex_new(&bta_gattc_cb.write_ccc_mutex);
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("GATTC is already enabled");
|
||||
}
|
||||
@@ -150,6 +154,8 @@ void bta_gattc_disable(tBTA_GATTC_CB *p_cb)
|
||||
APPL_TRACE_ERROR("not enabled or disable in pogress");
|
||||
return;
|
||||
}
|
||||
// Free the write ccc mutex when the gatt client disable
|
||||
osi_mutex_free(&bta_gattc_cb.write_ccc_mutex);
|
||||
|
||||
for (i = 0; i < BTA_GATTC_CL_MAX; i ++) {
|
||||
if (p_cb->cl_rcb[i].in_use) {
|
||||
@@ -667,14 +673,11 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
if (p_clcb->p_srcb->p_srvc_cache == NULL ||
|
||||
p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE) {
|
||||
if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) {
|
||||
#if (GATTC_CACHE_NVS == TRUE)
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD;
|
||||
if (bta_gattc_cache_load(p_clcb)) {
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
|
||||
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
|
||||
} else
|
||||
#endif
|
||||
{ /* cache is building */
|
||||
} else { /* cache is building */
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
|
||||
/* cache load failure, start discovery */
|
||||
bta_gattc_start_discover(p_clcb, NULL);
|
||||
@@ -1020,10 +1023,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
list_free(p_clcb->p_srcb->p_srvc_cache);
|
||||
p_clcb->p_srcb->p_srvc_cache = NULL;
|
||||
}
|
||||
#if(GATTC_CACHE_NVS == TRUE)
|
||||
|
||||
/* used to reset cache in application */
|
||||
bta_gattc_cache_reset(p_clcb->p_srcb->server_bda);
|
||||
#endif
|
||||
}
|
||||
if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_list) {
|
||||
/* release pending attribute list buffer */
|
||||
@@ -1052,10 +1054,6 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
p_q_cmd = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//register service change
|
||||
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1245,7 +1243,7 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
|
||||
} else {
|
||||
cb_data.read.handle = p_clcb->p_q_cmd->api_read.handle;
|
||||
}
|
||||
|
||||
|
||||
if (p_clcb->p_q_cmd->hdr.event != BTA_GATTC_API_READ_MULTI_EVT) {
|
||||
event = p_clcb->p_q_cmd->api_read.cmpl_evt;
|
||||
} else {
|
||||
@@ -1272,34 +1270,23 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
|
||||
{
|
||||
tBTA_GATTC cb_data = {0};
|
||||
UINT8 event;
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_clcb->bda);
|
||||
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
cb_data.write.status = p_data->status;
|
||||
cb_data.write.handle = p_data->p_cmpl->att_value.handle;
|
||||
|
||||
if (p_clcb->p_q_cmd->api_write.hdr.event == BTA_GATTC_API_WRITE_EVT &&
|
||||
p_clcb->p_q_cmd->api_write.write_type == BTA_GATTC_WRITE_PREPARE) {
|
||||
// Should check the value received from the peer device is correct or not.
|
||||
if (memcmp(p_clcb->p_q_cmd->api_write.p_value, p_data->p_cmpl->att_value.value,
|
||||
p_data->p_cmpl->att_value.len) != 0) {
|
||||
cb_data.write.status = BTA_GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
event = BTA_GATTC_PREP_WRITE_EVT;
|
||||
} else {
|
||||
} else {
|
||||
event = p_clcb->p_q_cmd->api_write.cmpl_evt;
|
||||
}
|
||||
}
|
||||
//free the command data store in the queue.
|
||||
bta_gattc_free_command_data(p_clcb);
|
||||
bta_gattc_pop_command_to_send(p_clcb);
|
||||
cb_data.write.conn_id = p_clcb->bta_conn_id;
|
||||
if (p_conn && p_conn->svc_change_descr_handle == cb_data.write.handle) {
|
||||
if(cb_data.write.status != BTA_GATT_OK) {
|
||||
APPL_TRACE_ERROR("service change write ccc failed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* write complete, callback */
|
||||
( *p_clcb->p_rcb->p_cback)(event, (tBTA_GATTC *)&cb_data);
|
||||
|
||||
@@ -1626,12 +1613,58 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
|
||||
tBT_TRANSPORT transport)
|
||||
{
|
||||
tBTA_GATTC_DATA *p_buf;
|
||||
BOOLEAN start_ccc_timer = FALSE;
|
||||
tBTA_GATTC_CONN *p_conn = NULL;
|
||||
tBTA_GATTC_FIND_SERVICE_CB result;
|
||||
|
||||
if (reason != 0) {
|
||||
APPL_TRACE_WARNING("%s() - cif=%d connected=%d conn_id=%d reason=0x%04x",
|
||||
__FUNCTION__, gattc_if, connected, conn_id, reason);
|
||||
}
|
||||
|
||||
if (connected == TRUE){
|
||||
p_conn = bta_gattc_conn_find_alloc(bda);
|
||||
}
|
||||
else if (connected == FALSE){
|
||||
p_conn = bta_gattc_conn_find(bda);
|
||||
}
|
||||
|
||||
if (p_conn == NULL){
|
||||
APPL_TRACE_ERROR("p_conn is NULL in %s\n", __func__);
|
||||
}
|
||||
|
||||
if ((transport == BT_TRANSPORT_LE) && (connected == TRUE) && (p_conn != NULL) \
|
||||
&& (p_conn->service_change_ccc_written == FALSE) && (p_conn->ccc_timer_used == FALSE)) {
|
||||
result = bta_gattc_register_service_change_notify(conn_id, bda, &start_ccc_timer);
|
||||
if (start_ccc_timer == TRUE) {
|
||||
TIMER_LIST_ENT *ccc_timer = &(p_conn->service_change_ccc_timer);
|
||||
/* start a 1000ms timer to wait for service discovery finished */
|
||||
bta_gattc_start_service_change_ccc_timer(conn_id, bda, 1000, 0, result, ccc_timer);
|
||||
p_conn->ccc_timer_used = TRUE;
|
||||
}
|
||||
else {
|
||||
/* Has written service change ccc; or service change ccc doesn't exist in remote device's gatt database */
|
||||
p_conn->service_change_ccc_written = TRUE;
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((transport == BT_TRANSPORT_LE) && (connected == FALSE) && (p_conn != NULL)){
|
||||
p_conn->service_change_ccc_written = FALSE;
|
||||
if (p_conn->ccc_timer_used == TRUE){
|
||||
assert(bta_gattc_cb.write_ccc_mutex != NULL);
|
||||
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
if (p_conn->service_change_ccc_timer.param != 0) {
|
||||
osi_free((void *)p_conn->service_change_ccc_timer.param);
|
||||
p_conn->service_change_ccc_timer.param = (TIMER_PARAM_TYPE)0;
|
||||
}
|
||||
bta_sys_stop_timer(&(p_conn->service_change_ccc_timer));
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
bt_bdaddr_t bdaddr;
|
||||
bdcpy(bdaddr.address, bda);
|
||||
|
||||
@@ -1730,84 +1763,8 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
p_srvc_cb->p_srvc_cache = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
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,
|
||||
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) {
|
||||
if (p_assoc_clcb->state == BTA_GATTC_CONN_ST || p_assoc_clcb->state == BTA_GATTC_DISCOVER_ST) {
|
||||
gattc_cb.set_assoc.status = BTA_GATT_BUSY;
|
||||
if (p_clrcb != NULL) {
|
||||
(*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_msg->api_assoc.is_assoc) {
|
||||
if ((state = bta_gattc_co_cache_append_assoc_addr(p_msg->api_assoc.src_addr, p_msg->api_assoc.assoc_addr)) == TRUE) {
|
||||
gattc_cb.set_assoc.status = BTA_GATT_OK;
|
||||
|
||||
} else {
|
||||
gattc_cb.set_assoc.status = BTA_GATT_ERROR;
|
||||
if (p_clrcb != NULL) {
|
||||
(*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (( state = bta_gattc_co_cache_remove_assoc_addr(p_msg->api_assoc.src_addr, p_msg->api_assoc.assoc_addr)) == TRUE) {
|
||||
gattc_cb.set_assoc.status = BTA_GATT_OK;
|
||||
} else {
|
||||
gattc_cb.set_assoc.status = BTA_GATT_ERROR;
|
||||
if (p_clrcb != NULL) {
|
||||
(*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_clrcb != NULL) {
|
||||
(*p_clrcb->p_cback)(BTA_GATTC_ASSOC_EVT, &gattc_cb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTC gattc_cb = {0};
|
||||
tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_get_addr.client_if);
|
||||
UINT8 num_addr = bta_gattc_co_get_addr_num();
|
||||
gattc_cb.get_addr_list.client_if = p_msg->api_get_addr.client_if;
|
||||
|
||||
if (num_addr != 0) {
|
||||
gattc_cb.get_addr_list.num_addr = num_addr;
|
||||
gattc_cb.get_addr_list.bda_list = (BD_ADDR *)osi_malloc(sizeof(BD_ADDR)*num_addr);
|
||||
if (gattc_cb.get_addr_list.bda_list != NULL) {
|
||||
bta_gattc_co_get_addr_list(gattc_cb.get_addr_list.bda_list);
|
||||
gattc_cb.get_addr_list.status = BTA_GATT_OK;
|
||||
} else {
|
||||
gattc_cb.get_addr_list.status = BTA_GATT_ERROR;
|
||||
}
|
||||
} else {
|
||||
gattc_cb.get_addr_list.status = BTA_GATT_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (p_clrcb != NULL) {
|
||||
(* p_clrcb->p_cback)(BTA_GATTC_GET_ADDR_LIST_EVT, &gattc_cb);
|
||||
}
|
||||
|
||||
//release the address list buffer after used.
|
||||
if (gattc_cb.get_addr_list.bda_list != NULL) {
|
||||
osi_free((void *)gattc_cb.get_addr_list.bda_list);
|
||||
}
|
||||
/* used to reset cache in application */
|
||||
bta_gattc_cache_reset(p_msg->api_conn.remote_bda);
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@@ -1848,7 +1805,7 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
|
||||
UINT16 s_handle = ((UINT16)(*(p )) + (((UINT16)(*(p + 1))) << 8));
|
||||
UINT16 e_handle = ((UINT16)(*(p + 2)) + (((UINT16)(*(p + 3))) << 8));
|
||||
|
||||
APPL_TRACE_DEBUG("%s: service changed s_handle:0x%04x e_handle:0x%04x",
|
||||
APPL_TRACE_ERROR("%s: service changed s_handle:0x%04x e_handle:0x%04x",
|
||||
__func__, s_handle, e_handle);
|
||||
|
||||
processed = TRUE;
|
||||
@@ -2087,27 +2044,6 @@ static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_req_cback
|
||||
**
|
||||
** Description GATT request command callback for BTA GATT client.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
********************************************************************************/
|
||||
static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data)
|
||||
{
|
||||
/* GATTC doesn't need to process the GATT request commands.
|
||||
* Add this callback here to avoid the warning "Call back not found for application"
|
||||
* printed in the function gatt_sr_send_req_callback
|
||||
* */
|
||||
UNUSED (conn_id);
|
||||
UNUSED (trans_id) ;
|
||||
UNUSED (type);
|
||||
UNUSED (p_data);
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2221,7 +2157,7 @@ void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
}
|
||||
/* if listen to all */
|
||||
else {
|
||||
APPL_TRACE_DEBUG("Listen For All now");
|
||||
LOG_DEBUG("Listen For All now");
|
||||
/* go through all connected device and send
|
||||
callback for all connected slave connection */
|
||||
bta_gattc_process_listen_all(p_msg->api_listen.client_if);
|
||||
@@ -2254,28 +2190,58 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_start_service_change_ccc_timer
|
||||
**
|
||||
** Description start a timer to wait for service change ccc discovered
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_start_service_change_ccc_timer(UINT16 conn_id, BD_ADDR bda,UINT32 timeout_ms,
|
||||
UINT8 timer_cnt, UINT8 last_status, TIMER_LIST_ENT *ccc_timer)
|
||||
{
|
||||
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) osi_malloc(sizeof(tBTA_GATTC_WAIT_CCC_TIMER));
|
||||
if (p_timer_param != NULL) {
|
||||
p_timer_param->conn_id = conn_id;
|
||||
memcpy(p_timer_param->remote_bda, bda, sizeof(BD_ADDR));
|
||||
p_timer_param->count = timer_cnt;
|
||||
p_timer_param->last_status = last_status;
|
||||
ccc_timer->param = (UINT32)p_timer_param;
|
||||
ccc_timer->p_cback = (TIMER_CBACK *)&bta_gattc_wait4_service_change_ccc_cback;
|
||||
bta_sys_start_timer(ccc_timer, 0, timeout_ms);
|
||||
}
|
||||
else {
|
||||
APPL_TRACE_ERROR("%s, allocate p_timer_param failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_register_service_change_notify
|
||||
**
|
||||
** Description Find remote device's gatt service change characteristic ccc's handle and write 2 to this
|
||||
** this ccc.
|
||||
** this ccc. If not found, start a timer to wait for service discovery finished.
|
||||
**
|
||||
** Returns Return result of service change ccc service discovery result
|
||||
** Returns Return result of service change ccc service discovery result result and written operate result
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda)
|
||||
tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda, BOOLEAN *need_timer)
|
||||
{
|
||||
tBTA_GATTC_SERV *p_srcb = NULL;
|
||||
list_t *p_cache = NULL;
|
||||
tBTA_GATTC_SERVICE *p_service = NULL;
|
||||
tBTA_GATTC_CHARACTERISTIC *p_char = NULL;
|
||||
tBTA_GATTC_DESCRIPTOR *p_desc = NULL;
|
||||
tGATT_STATUS write_status;
|
||||
tGATT_VALUE ccc_value;
|
||||
tBTA_GATTC_FIND_SERVICE_CB result;
|
||||
BOOLEAN gatt_cache_found = FALSE;
|
||||
BOOLEAN gatt_service_found = FALSE;
|
||||
BOOLEAN gatt_service_change_found = FALSE;
|
||||
BOOLEAN gatt_ccc_found = FALSE;
|
||||
BOOLEAN start_find_ccc_timer = FALSE;
|
||||
|
||||
tBT_UUID gatt_service_uuid = {LEN_UUID_16, {UUID_SERVCLASS_GATT_SERVER}};
|
||||
tBT_UUID gatt_service_change_uuid = {LEN_UUID_16, {GATT_UUID_GATT_SRV_CHGD}};
|
||||
@@ -2287,6 +2253,7 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
gatt_cache_found = TRUE;
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CACHE_NOT_FOUND;
|
||||
}
|
||||
/* start to find gatt service */
|
||||
@@ -2301,6 +2268,7 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
}
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CACHE_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -2319,6 +2287,7 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
}
|
||||
else if (gatt_cache_found == TRUE) {
|
||||
/* Gatt service not found, start a timer to wait for service discovery */
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_SERVICE_NOT_FOUND;
|
||||
}
|
||||
/* start to find gatt service change characteristic ccc */
|
||||
@@ -2340,21 +2309,29 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
* wait for service discovery
|
||||
* Case2: remote device exist service change char, we have found gatt service, but have not found
|
||||
* service change char, we need to start a timer here*/
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CHAR_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (gatt_ccc_found == TRUE){
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find_alloc(remote_bda);
|
||||
if (p_conn) {
|
||||
p_conn->svc_change_descr_handle = p_desc->handle;
|
||||
ccc_value.handle = p_desc->handle;
|
||||
ccc_value.len = 2;
|
||||
ccc_value.value[0] = GATT_CLT_CONFIG_INDICATION;
|
||||
ccc_value.auth_req = GATT_AUTH_REQ_NONE;
|
||||
if (gatt_is_clcb_allocated(conn_id)) {
|
||||
APPL_TRACE_DEBUG("%s, GATTC_Write GATT_BUSY conn_id = %d", __func__, conn_id);
|
||||
write_status = GATT_BUSY;
|
||||
} else {
|
||||
write_status = GATTC_Write (conn_id, GATT_WRITE, &ccc_value);
|
||||
}
|
||||
if (write_status != GATT_SUCCESS) {
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_WRITE_CCC_FAILED;
|
||||
}
|
||||
else {
|
||||
start_find_ccc_timer = FALSE;
|
||||
result = SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
|
||||
}
|
||||
result = SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
|
||||
uint16_t indicate_value = GATT_CLT_CONFIG_INDICATION;
|
||||
tBTA_GATT_UNFMT indicate_v;
|
||||
indicate_v.len = 2;
|
||||
indicate_v.p_value = (uint8_t *)&indicate_value;
|
||||
BTA_GATTC_WriteCharDescr (conn_id, p_desc->handle, BTA_GATTC_TYPE_WRITE, &indicate_v, BTA_GATT_AUTH_REQ_NONE);
|
||||
|
||||
}
|
||||
else if (gatt_service_change_found == TRUE) {
|
||||
/* Gatt service char found, but service change char ccc not found,
|
||||
@@ -2362,11 +2339,81 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
|
||||
* wait for service discovery
|
||||
* Case2: remote device exist service change char ccc, we have found gatt service change char, but have not found
|
||||
* service change char ccc, we need to start a timer here */
|
||||
start_find_ccc_timer = TRUE;
|
||||
result = SERVICE_CHANGE_CCC_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (need_timer != NULL) {
|
||||
*need_timer = start_find_ccc_timer;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_wait4_service_change_ccc_cback
|
||||
**
|
||||
** Description callback function of service_change_ccc_timer
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
tBTA_GATTC_FIND_SERVICE_CB result;
|
||||
BOOLEAN start_ccc_timer = FALSE;
|
||||
UINT32 new_timeout;
|
||||
|
||||
assert(bta_gattc_cb.write_ccc_mutex != NULL);
|
||||
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) p_tle->param;
|
||||
p_tle->param = (TIMER_PARAM_TYPE)0;
|
||||
if (p_timer_param == NULL){
|
||||
APPL_TRACE_ERROR("p_timer_param is NULL in %s\n", __func__);
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_timer_param->remote_bda);
|
||||
if (p_conn == NULL){
|
||||
APPL_TRACE_ERROR("p_conn is NULL in %s\n", __func__);
|
||||
osi_free(p_timer_param);
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
result = bta_gattc_register_service_change_notify(p_timer_param->conn_id, p_timer_param->remote_bda, &start_ccc_timer);
|
||||
/* If return SERVICE_CHANGE_CHAR_NOT_FOUND or SERVICE_CHANGE_CCC_NOT_FOUND twice, means remote device doesn't have
|
||||
* service change char or ccc, stop timer */
|
||||
if ((result == p_timer_param->last_status) \
|
||||
&& ((result == SERVICE_CHANGE_CHAR_NOT_FOUND) || (result == SERVICE_CHANGE_CCC_NOT_FOUND))){
|
||||
start_ccc_timer = FALSE;
|
||||
}
|
||||
|
||||
if ((start_ccc_timer == TRUE) && (p_timer_param->count < 10)){
|
||||
TIMER_LIST_ENT *ccc_timer = &(p_conn->service_change_ccc_timer);
|
||||
if (result == SERVICE_CHANGE_WRITE_CCC_FAILED){
|
||||
/* retry to write service change ccc, needn't to add counter */
|
||||
new_timeout = 200;
|
||||
}
|
||||
else {
|
||||
/* retry to find service change ccc */
|
||||
new_timeout = 1000;
|
||||
p_timer_param->count ++;
|
||||
}
|
||||
bta_gattc_start_service_change_ccc_timer(p_timer_param->conn_id, p_timer_param->remote_bda, \
|
||||
new_timeout, p_timer_param->count, result, ccc_timer);
|
||||
}
|
||||
else {
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
p_conn->service_change_ccc_written = TRUE;
|
||||
}
|
||||
|
||||
osi_free(p_timer_param);
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif ///GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "bt_target.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gattc_int.h"
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -547,7 +547,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
|
||||
p_buf->hdr.layer_specific = conn_id;
|
||||
p_buf->auth_req = auth_req;
|
||||
p_buf->num_attr = p_read_multi->num_attr;
|
||||
p_buf->cmpl_evt = BTA_GATTC_READ_MULTIPLE_EVT;
|
||||
p_buf->cmpl_evt = BTA_GATTC_READ_MUTIPLE_EVT;
|
||||
if (p_buf->num_attr > 0) {
|
||||
memcpy(p_buf->handles, p_read_multi->handles, sizeof(UINT16) * p_read_multi->num_attr);
|
||||
}
|
||||
@@ -912,20 +912,12 @@ tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
** Description Refresh the server cache of the remote device
|
||||
**
|
||||
** Parameters remote_bda: remote device BD address.
|
||||
** erase_flash: delete cache from nvs flash
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash)
|
||||
void BTA_GATTC_Refresh(BD_ADDR remote_bda)
|
||||
{
|
||||
#if(GATTC_CACHE_NVS == TRUE)
|
||||
if(erase_flash) {
|
||||
/* used to reset cache in application */
|
||||
bta_gattc_cache_reset(remote_bda);
|
||||
}
|
||||
#endif
|
||||
|
||||
tBTA_GATTC_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
|
||||
@@ -937,35 +929,6 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash)
|
||||
return;
|
||||
}
|
||||
|
||||
void BTA_GATTC_CacheAssoc(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR assoc_addr, BOOLEAN is_assoc)
|
||||
{
|
||||
tBTA_GATTC_API_CACHE_ASSOC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_CACHE_ASSOC *)osi_malloc(sizeof(tBTA_GATTC_API_CACHE_ASSOC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_CACHE_ASSOC_EVT;
|
||||
p_buf->is_assoc = is_assoc;
|
||||
p_buf->client_if = client_if;
|
||||
memcpy(p_buf->src_addr, src_addr, sizeof(BD_ADDR));
|
||||
memcpy(p_buf->assoc_addr, assoc_addr, sizeof(BD_ADDR));
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void BTA_GATTC_CacheGetAddrList(tBTA_GATTC_IF client_if)
|
||||
{
|
||||
tBTA_GATTC_API_GET_ADDR *p_buf;
|
||||
if ((p_buf = (tBTA_GATTC_API_GET_ADDR *)osi_malloc(sizeof(tBTA_GATTC_API_GET_ADDR))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT;
|
||||
p_buf->client_if = client_if;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_Listen
|
||||
|
||||
@@ -23,23 +23,24 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "stack/sdp_api.h"
|
||||
#include "stack/sdpdefs.h"
|
||||
#include "utl.h"
|
||||
#include "bta_sys.h"
|
||||
#include "sdp_api.h"
|
||||
#include "sdpdefs.h"
|
||||
#include "bta_gattc_int.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "stack/btm_ble_api.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "btm_api.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include "allocator.h"
|
||||
#include "l2c_api.h"
|
||||
#include "btm_int.h"
|
||||
#include "errno.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_gattc"
|
||||
// #include "osi/include/log.h"
|
||||
|
||||
static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb);
|
||||
@@ -48,8 +49,6 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
bt_gatt_db_attribute_type_t type,
|
||||
tBT_UUID *char_uuid,
|
||||
UINT16 start_handle, UINT16 end_handle);
|
||||
static void bta_gattc_cache_write(BD_ADDR server_bda, UINT16 num_attr,
|
||||
tBTA_GATTC_NV_ATTR *attr);
|
||||
tBTA_GATTC_SERVICE* bta_gattc_find_matching_service(const list_t *services, UINT16 handle);
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle);
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle);
|
||||
@@ -105,7 +104,7 @@ bool display_cache_attribute(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]",
|
||||
LOG_INFO("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
|
||||
p_cur_srvc->s_handle, p_cur_srvc->e_handle,
|
||||
((p_cur_srvc->uuid.len == 2) ? "uuid16" : "uuid128"),
|
||||
p_cur_srvc->uuid.uu.uuid16,
|
||||
@@ -213,40 +212,6 @@ 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)
|
||||
{
|
||||
// services/p_new_srvc is NULL
|
||||
if (!services || !p_new_srvc) {
|
||||
APPL_TRACE_ERROR("%s services/p_new_srvc is NULL", __func__);
|
||||
return;
|
||||
}
|
||||
//list is empty
|
||||
if (list_is_empty(services)) {
|
||||
list_append(services, p_new_srvc);
|
||||
} else {
|
||||
//check the first service
|
||||
list_node_t *sn = list_begin(services);
|
||||
tBTA_GATTC_SERVICE *service = list_node(sn);
|
||||
if(service && p_new_srvc->e_handle < service->s_handle) {
|
||||
list_prepend(services, p_new_srvc);
|
||||
} else {
|
||||
for (list_node_t *sn = list_begin(services); sn != list_end(services); sn = list_next(sn)) {
|
||||
list_node_t *next_sn = list_next(sn);
|
||||
if(next_sn == list_end(services)) {
|
||||
list_append(services, p_new_srvc);
|
||||
return;
|
||||
}
|
||||
tBTA_GATTC_SERVICE *service = list_node(sn);
|
||||
tBTA_GATTC_SERVICE *next_service = list_node(next_sn);
|
||||
if (p_new_srvc->s_handle > service->e_handle && p_new_srvc->e_handle < next_service->s_handle) {
|
||||
list_insert_after(services, sn, p_new_srvc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_add_srvc_to_cache
|
||||
@@ -284,12 +249,7 @@ static tBTA_GATT_STATUS bta_gattc_add_srvc_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
p_srvc_cb->p_srvc_cache = list_new(service_free);
|
||||
}
|
||||
|
||||
if(is_primary) {
|
||||
list_append(p_srvc_cb->p_srvc_cache, p_new_srvc);
|
||||
} else {
|
||||
//add secondary service into list
|
||||
bta_gattc_insert_sec_service_to_cache(p_srvc_cb->p_srvc_cache, p_new_srvc);
|
||||
}
|
||||
list_append(p_srvc_cb->p_srvc_cache, p_new_srvc);
|
||||
return BTA_GATT_OK;
|
||||
}
|
||||
|
||||
@@ -346,7 +306,6 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
tBT_UUID *p_uuid,
|
||||
UINT8 property,
|
||||
UINT16 incl_srvc_s_handle,
|
||||
UINT16 incl_srvc_e_handle,
|
||||
tBTA_GATTC_ATTR_TYPE type)
|
||||
{
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
@@ -371,19 +330,13 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
isvc->handle = handle;
|
||||
memcpy(&isvc->uuid, p_uuid, sizeof(tBT_UUID));
|
||||
isvc->incl_srvc_s_handle = incl_srvc_s_handle;
|
||||
isvc->incl_srvc_e_handle = incl_srvc_e_handle;
|
||||
isvc->owning_service = service;
|
||||
isvc->included_service = bta_gattc_find_matching_service(
|
||||
p_srvc_cb->p_srvc_cache, incl_srvc_s_handle);
|
||||
if (!isvc->included_service) {
|
||||
// if it is a secondary service, wait to update later
|
||||
if(property == 0){
|
||||
p_srvc_cb->update_sec_sev = true;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s: Illegal action to add non-existing included service!", __func__);
|
||||
osi_free(isvc);
|
||||
return GATT_WRONG_STATE;
|
||||
}
|
||||
APPL_TRACE_ERROR("%s: Illegal action to add non-existing included service!", __func__);
|
||||
osi_free(isvc);
|
||||
return GATT_WRONG_STATE;
|
||||
}
|
||||
|
||||
list_append(service->included_svc, isvc);
|
||||
@@ -547,30 +500,6 @@ void bta_gattc_start_disc_char_dscp(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void bta_gattc_update_include_service(const list_t *services) {
|
||||
if (!services || list_is_empty(services)) {
|
||||
return;
|
||||
}
|
||||
for (list_node_t *sn = list_begin(services); sn != list_end(services); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *service = list_node(sn);
|
||||
if(!service && list_is_empty(service->included_svc)) break;
|
||||
for (list_node_t *sn = list_begin(service->included_svc); sn != list_end(service->included_svc); sn = list_next(sn)) {
|
||||
tBTA_GATTC_INCLUDED_SVC *include_service = list_node(sn);
|
||||
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) {
|
||||
//not match, free it
|
||||
list_remove(service->included_svc, include_service);
|
||||
osi_free(include_service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_explore_srvc
|
||||
@@ -606,13 +535,8 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
||||
return;
|
||||
}
|
||||
}
|
||||
//update include service when have secondary service
|
||||
if(p_srvc_cb->update_sec_sev) {
|
||||
bta_gattc_update_include_service(p_srvc_cb->p_srvc_cache);
|
||||
p_srvc_cb->update_sec_sev = false;
|
||||
}
|
||||
/* no service found at all, the end of server discovery*/
|
||||
APPL_TRACE_DEBUG("%s no more services found", __func__);
|
||||
LOG_DEBUG("%s no more services found", __func__);
|
||||
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
bta_gattc_display_cache_server(p_srvc_cb->p_srvc_cache);
|
||||
@@ -624,11 +548,13 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
|
||||
L2CA_EnableUpdateBleConnParams(p_clcb->p_srcb->server_bda, TRUE);
|
||||
}
|
||||
#endif
|
||||
#if(GATTC_CACHE_NVS == TRUE)
|
||||
/* save cache to NV */
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_SAVE;
|
||||
bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id);
|
||||
#endif
|
||||
|
||||
if (btm_sec_is_a_bonded_dev(p_srvc_cb->server_bda)) {
|
||||
bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id);
|
||||
}
|
||||
|
||||
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
|
||||
}
|
||||
/*******************************************************************************
|
||||
@@ -998,7 +924,6 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
&p_data->value.incl_service.service_type,
|
||||
pri_srvc,
|
||||
p_data->value.incl_service.s_handle,
|
||||
p_data->value.incl_service.e_handle,
|
||||
BTA_GATTC_ATTR_TYPE_INCL_SRVC);
|
||||
break;
|
||||
|
||||
@@ -1012,14 +937,10 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
break;
|
||||
|
||||
case GATT_DISC_CHAR_DSCPT:
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
0,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb, p_data->handle, &p_data->type, 0,
|
||||
0 /* incl_srvc_handle */,
|
||||
BTA_GATTC_ATTR_TYPE_CHAR_DESCR);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1102,8 +1023,8 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
cb_data.srvc_res.service_uuid.inst_id = p_cache->handle;
|
||||
cb_data.srvc_res.start_handle = p_cache->s_handle;
|
||||
cb_data.srvc_res.end_handle = p_cache->e_handle;
|
||||
cb_data.srvc_res.is_primary = p_cache->is_primary;
|
||||
memcpy(&cb_data.srvc_res.service_uuid.uuid, &p_cache->uuid, sizeof(tBT_UUID));
|
||||
memcpy(&cb_data.srvc_res.service_uuid.uuid, &p_cache->uuid, sizeof(tBTA_GATT_ID));
|
||||
|
||||
(* p_clcb->p_rcb->p_cback)(BTA_GATTC_SEARCH_RES_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
@@ -1221,12 +1142,6 @@ void bta_gattc_get_service_with_uuid(UINT16 conn_id, tBT_UUID *svc_uuid,
|
||||
int *count)
|
||||
{
|
||||
const list_t* svc = bta_gattc_get_services(conn_id);
|
||||
if(!svc) {
|
||||
APPL_TRACE_WARNING("%s(), no service.", __func__);
|
||||
*svc_db = NULL;
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
size_t db_size = list_length(svc);
|
||||
void *buffer = osi_malloc(db_size*sizeof(btgatt_db_element_t));
|
||||
if (!buffer) {
|
||||
@@ -1302,15 +1217,14 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
APPL_TRACE_DEBUG("the service cache is empty.");
|
||||
*count = 0;
|
||||
*char_db = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
size_t db_size = ((end_handle - start_handle + 1) < p_srcb->total_attr) ? (end_handle - start_handle + 1) : p_srcb->total_attr;
|
||||
size_t db_size = ((end_handle - start_handle) < p_srcb->total_attr) ? (end_handle - start_handle) : p_srcb->total_attr;
|
||||
|
||||
if (!db_size) {
|
||||
APPL_TRACE_DEBUG("the db size is 0.");
|
||||
*count = 0;
|
||||
*char_db = NULL;
|
||||
return;
|
||||
@@ -1319,7 +1233,6 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
void *buffer = osi_malloc(db_size*sizeof(btgatt_db_element_t));
|
||||
|
||||
if (!buffer) {
|
||||
APPL_TRACE_DEBUG("the buffer is NULL.");
|
||||
*count = 0;
|
||||
*char_db = NULL;
|
||||
return;
|
||||
@@ -1360,7 +1273,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
BTGATT_DB_INCLUDED_SERVICE,
|
||||
p_isvc->handle,
|
||||
p_isvc->incl_srvc_s_handle /* s_handle */,
|
||||
p_isvc->incl_srvc_e_handle /* e_handle */,
|
||||
0 /* e_handle */,
|
||||
p_isvc->handle,
|
||||
p_isvc->uuid,
|
||||
0 /* property */);
|
||||
@@ -1378,10 +1291,9 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
tBTA_GATTC_CHARACTERISTIC *p_char = list_node(cn);
|
||||
if(op == GATT_OP_GET_ALL_CHAR || op == GATT_OP_GET_CHAR_BY_UUID) {
|
||||
if (p_char->handle < start_handle) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_char->handle < start_handle) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_char->handle > end_handle) {
|
||||
@@ -1391,7 +1303,6 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
}
|
||||
if ((op == GATT_OP_GET_ALL_CHAR || op == GATT_OP_GET_CHAR_BY_UUID) &&
|
||||
(char_uuid == NULL || bta_gattc_uuid_compare(&p_char->uuid, char_uuid, TRUE))) {
|
||||
APPL_TRACE_DEBUG("%s(), uuid match.", __func__);
|
||||
bta_gattc_fill_gatt_db_el(curr_db_attr,
|
||||
BTGATT_DB_CHARACTERISTIC,
|
||||
p_char->handle,
|
||||
@@ -1902,7 +1813,7 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
|
||||
tBTA_GATTC_NV_ATTR *p_attr)
|
||||
{
|
||||
/* first attribute loading, initialize buffer */
|
||||
APPL_TRACE_DEBUG("%s: bta_gattc_rebuild_cache, num_attr = %d", __func__, num_attr);
|
||||
APPL_TRACE_ERROR("%s: bta_gattc_rebuild_cache", __func__);
|
||||
|
||||
list_free(p_srvc_cb->p_srvc_cache);
|
||||
p_srvc_cb->p_srvc_cache = NULL;
|
||||
@@ -1927,21 +1838,12 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
|
||||
break;
|
||||
|
||||
case BTA_GATTC_ATTR_TYPE_CHAR_DESCR:
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_attr->s_handle,
|
||||
&p_attr->uuid,
|
||||
p_attr->prop,
|
||||
p_attr->incl_srvc_s_handle,
|
||||
p_attr->incl_srvc_e_handle,
|
||||
p_attr->attr_type);
|
||||
break;
|
||||
case BTA_GATTC_ATTR_TYPE_INCL_SRVC:
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_attr->s_handle,
|
||||
&p_attr->uuid,
|
||||
p_attr->prop,
|
||||
p_attr->incl_srvc_s_handle,
|
||||
p_attr->incl_srvc_e_handle,
|
||||
p_attr->incl_srvc_handle,
|
||||
p_attr->attr_type);
|
||||
break;
|
||||
}
|
||||
@@ -1960,8 +1862,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_handle,
|
||||
UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_s_handle,
|
||||
UINT16 incl_srvc_e_handle, BOOLEAN is_primary)
|
||||
UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_handle,
|
||||
BOOLEAN is_primary)
|
||||
{
|
||||
p_attr->s_handle = s_handle;
|
||||
p_attr->e_handle = e_handle;
|
||||
@@ -1969,8 +1871,7 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han
|
||||
p_attr->is_primary = is_primary;
|
||||
p_attr->id = 0;
|
||||
p_attr->prop = prop;
|
||||
p_attr->incl_srvc_s_handle = incl_srvc_s_handle;
|
||||
p_attr->incl_srvc_e_handle = incl_srvc_e_handle;
|
||||
p_attr->incl_srvc_handle = incl_srvc_handle;
|
||||
|
||||
memcpy(&p_attr->uuid, &uuid, sizeof(tBT_UUID));
|
||||
}
|
||||
@@ -1991,11 +1892,6 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
int i = 0;
|
||||
size_t db_size = bta_gattc_get_db_size(p_srvc_cb->p_srvc_cache, 0x0000, 0xFFFF);
|
||||
tBTA_GATTC_NV_ATTR *nv_attr = osi_malloc(db_size * sizeof(tBTA_GATTC_NV_ATTR));
|
||||
// This step is very importent, if not clear the memory, the hasy key base on the attribute case will be not corret.
|
||||
if (nv_attr != NULL) {
|
||||
memset(nv_attr, 0, db_size * sizeof(tBTA_GATTC_NV_ATTR));
|
||||
}
|
||||
|
||||
if (!nv_attr) {
|
||||
APPL_TRACE_WARNING("%s(), no resource.", __func__);
|
||||
return;
|
||||
@@ -2010,8 +1906,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
p_cur_srvc->e_handle,
|
||||
p_cur_srvc->uuid,
|
||||
0 /* properties */,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
0 /* incl_srvc_handle */,
|
||||
p_cur_srvc->is_primary);
|
||||
}
|
||||
|
||||
@@ -2032,8 +1927,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
0,
|
||||
p_char->uuid,
|
||||
p_char->properties,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
0 /* incl_srvc_handle */,
|
||||
FALSE);
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
@@ -2049,8 +1943,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
0,
|
||||
p_desc->uuid,
|
||||
0 /* properties */,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
0 /* incl_srvc_handle */,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
@@ -2069,13 +1962,11 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
p_isvc->uuid,
|
||||
0 /* properties */,
|
||||
p_isvc->included_service->s_handle,
|
||||
p_isvc->included_service->e_handle,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Gattc cache write/read need to be added in IDF 3.1*/
|
||||
bta_gattc_cache_write(p_srvc_cb->server_bda, db_size, nv_attr);
|
||||
osi_free(nv_attr);
|
||||
}
|
||||
|
||||
@@ -2092,56 +1983,56 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
*******************************************************************************/
|
||||
bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb)
|
||||
{
|
||||
/* open NV cache and send call in */
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
UINT8 index = 0;
|
||||
#if 0
|
||||
char fname[255] = {0};
|
||||
bta_gattc_generate_cache_file_name(fname, p_clcb->p_srcb->server_bda);
|
||||
|
||||
FILE *fd = fopen(fname, "rb");
|
||||
if (!fd) {
|
||||
APPL_TRACE_ERROR("%s: can't open GATT cache file %s for reading, error: %s",
|
||||
__func__, fname, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
UINT16 cache_ver = 0;
|
||||
tBTA_GATTC_NV_ATTR *attr = NULL;
|
||||
bool success = false;
|
||||
|
||||
if ((status = bta_gattc_co_cache_open(p_clcb->p_srcb->server_bda, true, &index)) != BTA_GATT_OK) {
|
||||
APPL_TRACE_DEBUG("%s(), gattc cache open fail, index = %x", __func__, index);
|
||||
return false;
|
||||
if (fread(&cache_ver, sizeof(UINT16), 1, fd) != 1) {
|
||||
APPL_TRACE_ERROR("%s: can't read GATT cache version from: %s", __func__, fname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
size_t num_attr = bta_gattc_get_cache_attr_length(index) / sizeof(tBTA_GATTC_NV_ATTR);
|
||||
if (cache_ver != GATT_CACHE_VERSION) {
|
||||
APPL_TRACE_ERROR("%s: wrong GATT cache version: %s", __func__, fname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!num_attr) {
|
||||
return false;
|
||||
UINT16 num_attr = 0;
|
||||
|
||||
if (fread(&num_attr, sizeof(UINT16), 1, fd) != 1) {
|
||||
APPL_TRACE_ERROR("%s: can't read number of GATT attributes: %s", __func__, fname);
|
||||
goto done;
|
||||
}
|
||||
//don't forget to set the total attribute number.
|
||||
p_clcb->p_srcb->total_attr = num_attr;
|
||||
APPL_TRACE_DEBUG("%s(), index = %x, num_attr = %d", __func__, index, num_attr);
|
||||
if ((attr = osi_malloc(sizeof(tBTA_GATTC_NV_ATTR) * num_attr)) == NULL) {
|
||||
APPL_TRACE_ERROR("%s, No Memory.", __func__);
|
||||
return false;
|
||||
}
|
||||
if ((status = bta_gattc_co_cache_load(attr, index)) != BTA_GATT_OK) {
|
||||
APPL_TRACE_DEBUG("%s(), gattc cache load fail, status = %x", __func__, status);
|
||||
return false;
|
||||
|
||||
attr = osi_malloc(sizeof(tBTA_GATTC_NV_ATTR) * num_attr);
|
||||
|
||||
if (fread(attr, sizeof(tBTA_GATTC_NV_ATTR), 0xFF, fd) != num_attr) {
|
||||
APPL_TRACE_ERROR("%s: can't read GATT attributes: %s", __func__, fname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
bta_gattc_rebuild_cache(p_clcb->p_srcb, num_attr, attr);
|
||||
//free the attr buffer after used.
|
||||
osi_free(attr);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_cache_write
|
||||
**
|
||||
** Description This callout function is executed by GATT when a server cache
|
||||
** is available to save.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** num_attr: number of attribute to be save.
|
||||
** attr: pointer to the list of attributes to save.
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_gattc_cache_write(BD_ADDR server_bda, UINT16 num_attr,
|
||||
tBTA_GATTC_NV_ATTR *attr)
|
||||
{
|
||||
bta_gattc_co_cache_save(server_bda, num_attr, attr);
|
||||
success = true;
|
||||
|
||||
done:
|
||||
osi_free(attr);
|
||||
fclose(fd);
|
||||
return success;
|
||||
#endif
|
||||
bool success = false;
|
||||
return success;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2161,7 +2052,6 @@ void bta_gattc_cache_reset(BD_ADDR server_bda)
|
||||
BTIF_TRACE_DEBUG("%s", __func__);
|
||||
char fname[255] = {0};
|
||||
bta_gattc_generate_cache_file_name(fname, server_bda);
|
||||
bta_gattc_co_cache_reset(server_bda);
|
||||
//unlink(fname);
|
||||
}
|
||||
#endif /* BTA_GATT_INCLUDED */
|
||||
|
||||
@@ -22,17 +22,17 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_gattc_ci.h"
|
||||
#include "bta/utl.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gattc_ci.h"
|
||||
#include "utl.h"
|
||||
#include "allocator.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -1,645 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2013 Broadcom Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifdef BT_SUPPORT_NVM
|
||||
#include <unistd.h>
|
||||
#endif /* BT_SUPPORT_NVM */
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "bta/bta_gattc_co.h"
|
||||
#include "bta/bta_gattc_ci.h"
|
||||
|
||||
// #include "btif_util.h"
|
||||
#include "btm_int.h"
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "osi/list.h"
|
||||
#include "esp_err.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if( defined BLE_INCLUDED ) && (BLE_INCLUDED == TRUE)
|
||||
#if( defined BTA_GATT_INCLUDED ) && (GATTC_INCLUDED == TRUE)
|
||||
|
||||
#define GATT_CACHE_PREFIX "gatt_"
|
||||
#define INVALID_ADDR_NUM 0xff
|
||||
#define MAX_DEVICE_IN_CACHE 50
|
||||
#define MAX_ADDR_LIST_CACHE_BUF 2048
|
||||
|
||||
#ifdef BT_SUPPORT_NVM
|
||||
static FILE *sCacheFD = 0;
|
||||
static void getFilename(char *buffer, BD_ADDR bda)
|
||||
{
|
||||
sprintf(buffer, "%s%02x%02x%02x%02x%02x%02x", GATT_CACHE_PREFIX
|
||||
, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
}
|
||||
|
||||
static void cacheClose()
|
||||
{
|
||||
if (sCacheFD != 0) {
|
||||
fclose(sCacheFD);
|
||||
sCacheFD = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static bool cacheOpen(BD_ADDR bda, bool to_save)
|
||||
{
|
||||
char fname[255] = {0};
|
||||
getFilename(fname, bda);
|
||||
|
||||
cacheClose();
|
||||
sCacheFD = fopen(fname, to_save ? "w" : "r");
|
||||
|
||||
return (sCacheFD != 0);
|
||||
}
|
||||
|
||||
static void cacheReset(BD_ADDR bda)
|
||||
{
|
||||
char fname[255] = {0};
|
||||
getFilename(fname, bda);
|
||||
unlink(fname);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static const char *cache_key = "gattc_cache_key";
|
||||
static const char *cache_addr = "cache_addr_tab";
|
||||
nvs_handle nvs_fp;
|
||||
|
||||
typedef struct {
|
||||
//save the service data in the list according to the address
|
||||
nvs_handle cache_fp;
|
||||
BOOLEAN is_open;
|
||||
BD_ADDR addr;
|
||||
hash_key_t hash_key;
|
||||
list_t *assoc_addr;
|
||||
}cache_addr_info_t;
|
||||
|
||||
typedef struct {
|
||||
//save the address list in the cache
|
||||
nvs_handle addr_fp;
|
||||
BOOLEAN is_open;
|
||||
UINT8 num_addr;
|
||||
cache_addr_info_t cache_addr[MAX_DEVICE_IN_CACHE];
|
||||
}cache_env_t;
|
||||
|
||||
cache_env_t cache_env;
|
||||
|
||||
static void getFilename(char *buffer, hash_key_t hash)
|
||||
{
|
||||
sprintf(buffer, "%s%02x%02x%02x%02x", GATT_CACHE_PREFIX,
|
||||
hash[0], hash[1], hash[2], hash[3]);
|
||||
}
|
||||
|
||||
static void cacheClose(BD_ADDR bda)
|
||||
{
|
||||
UINT8 index = 0;
|
||||
if ((index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) {
|
||||
if (cache_env.cache_addr[index].is_open) {
|
||||
nvs_close(cache_env.cache_addr[index].cache_fp);
|
||||
cache_env.cache_addr[index].is_open = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool cacheOpen(BD_ADDR bda, bool to_save, UINT8 *index)
|
||||
{
|
||||
UNUSED(to_save);
|
||||
char fname[255] = {0};
|
||||
UINT8 *assoc_addr = NULL;
|
||||
esp_err_t status = ESP_FAIL;
|
||||
hash_key_t hash_key = {0};
|
||||
if (((*index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) ||
|
||||
((assoc_addr = bta_gattc_co_cache_find_src_addr(bda, index)) != NULL)) {
|
||||
if (cache_env.cache_addr[*index].is_open) {
|
||||
return TRUE;
|
||||
} else {
|
||||
memcpy(hash_key, cache_env.cache_addr[*index].hash_key, sizeof(hash_key_t));
|
||||
getFilename(fname, hash_key);
|
||||
if ((status = nvs_open(fname, NVS_READWRITE, &cache_env.cache_addr[*index].cache_fp)) == ESP_OK) {
|
||||
// Set the open flag to TRUE when success to open the hash file.
|
||||
cache_env.cache_addr[*index].is_open = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ((status == ESP_OK) ? true : false);
|
||||
}
|
||||
|
||||
static void cacheReset(BD_ADDR bda)
|
||||
{
|
||||
char fname[255] = {0};
|
||||
getFilename(fname, bda);
|
||||
UINT8 index = 0;
|
||||
//cache_env.cache_addr
|
||||
if ((index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) {
|
||||
//clear the association address pending in the source address.
|
||||
bta_gattc_co_cache_clear_assoc_addr(bda);
|
||||
if (cache_env.cache_addr[index].is_open) {
|
||||
nvs_erase_all(cache_env.cache_addr[index].cache_fp);
|
||||
nvs_close(cache_env.cache_addr[index].cache_fp);
|
||||
cache_env.cache_addr[index].is_open = FALSE;
|
||||
} else {
|
||||
cacheOpen(bda, false, &index);
|
||||
if (cache_env.cache_addr[index].is_open) {
|
||||
nvs_erase_all(cache_env.cache_addr[index].cache_fp);
|
||||
nvs_close(cache_env.cache_addr[index].cache_fp);
|
||||
cache_env.cache_addr[index].is_open = FALSE;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s cacheOpen failed", __func__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(cache_env.num_addr == 0) {
|
||||
APPL_TRACE_ERROR("%s cache addr list error", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
UINT8 num = cache_env.num_addr;
|
||||
//delete the server_bda in the addr_info list.
|
||||
for(UINT8 i = index; i < (num - 1); i++) {
|
||||
memcpy(&cache_env.cache_addr[i], &cache_env.cache_addr[i+1], sizeof(cache_addr_info_t));
|
||||
}
|
||||
//reduced the number address counter also
|
||||
cache_env.num_addr--;
|
||||
|
||||
//update addr list to nvs flash
|
||||
if(cache_env.num_addr > 0) {
|
||||
//update
|
||||
UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF);
|
||||
if(!p_buf) {
|
||||
APPL_TRACE_ERROR("%s malloc error", __func__);
|
||||
return;
|
||||
}
|
||||
UINT16 length = cache_env.num_addr*(sizeof(BD_ADDR) + sizeof(hash_key_t));
|
||||
for (UINT8 i = 0; i < cache_env.num_addr; i++) {
|
||||
//copy the address to the buffer.
|
||||
memcpy(p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)), cache_env.cache_addr[i].addr, sizeof(BD_ADDR));
|
||||
//copy the hash key to the buffer.
|
||||
memcpy(p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)) + sizeof(BD_ADDR),
|
||||
cache_env.cache_addr[i].hash_key, sizeof(hash_key_t));
|
||||
}
|
||||
if (cache_env.is_open) {
|
||||
if (nvs_set_blob(cache_env.addr_fp, cache_key, p_buf, length) != ESP_OK) {
|
||||
APPL_TRACE_WARNING("%s, nvs set blob failed", __func__);
|
||||
}
|
||||
}
|
||||
osi_free(p_buf);
|
||||
|
||||
} else {
|
||||
//erase
|
||||
if (cache_env.is_open) {
|
||||
nvs_erase_all(cache_env.addr_fp);
|
||||
nvs_close(cache_env.addr_fp);
|
||||
cache_env.is_open = FALSE;
|
||||
} else {
|
||||
APPL_TRACE_WARNING("cache_env status is error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BT_SUPPORT_NVM */
|
||||
/*****************************************************************************
|
||||
** Function Declarations
|
||||
*****************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_open
|
||||
**
|
||||
** Description This callout function is executed by GATTC when a GATT server
|
||||
** cache is ready to be sent.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** evt: call in event to be passed in when cache open is done.
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
** to_save: open cache to save or to load.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS bta_gattc_co_cache_open(BD_ADDR server_bda, BOOLEAN to_save, UINT8 *index)
|
||||
{
|
||||
/* open NV cache and send call in */
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
if (!cacheOpen(server_bda, to_save, index)) {
|
||||
status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
APPL_TRACE_DEBUG("%s() - status=%d", __func__, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_load
|
||||
**
|
||||
** Description This callout function is executed by GATT when server cache
|
||||
** is required to load.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** evt: call in event to be passed in when cache save is done.
|
||||
** num_attr: number of attribute to be save.
|
||||
** attr_index: starting attribute index of the save operation.
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS bta_gattc_co_cache_load(tBTA_GATTC_NV_ATTR *attr, UINT8 index)
|
||||
{
|
||||
UINT16 num_attr = 0;
|
||||
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);
|
||||
num_attr = length / sizeof(tBTA_GATTC_NV_ATTR);
|
||||
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);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
size_t bta_gattc_get_cache_attr_length(UINT8 index)
|
||||
{
|
||||
size_t length = 0;
|
||||
if (index == INVALID_ADDR_NUM) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the size of memory space required for blob
|
||||
nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, NULL, &length);
|
||||
return length;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_save
|
||||
**
|
||||
** Description This callout function is executed by GATT when a server cache
|
||||
** is available to save.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** evt: call in event to be passed in when cache save is done.
|
||||
** num_attr: number of attribute to be save.
|
||||
** p_attr: pointer to the list of attributes to save.
|
||||
** attr_index: starting attribute index of the save operation.
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_co_cache_save (BD_ADDR server_bda, UINT16 num_attr,
|
||||
tBTA_GATTC_NV_ATTR *p_attr_list)
|
||||
{
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
hash_key_t hash_key = {0};
|
||||
UINT8 index = INVALID_ADDR_NUM;
|
||||
//calculate the hash value of the attribute table which should be added to the nvs flash.
|
||||
hash_function_blob((unsigned char *)p_attr_list, sizeof(tBTA_GATTC_NV_ATTR)*num_attr, hash_key);
|
||||
//save the address list to the nvs flash
|
||||
bta_gattc_co_cache_addr_save(server_bda, hash_key);
|
||||
|
||||
if (cacheOpen(server_bda, TRUE, &index)) {
|
||||
esp_err_t err_code = nvs_set_blob(cache_env.cache_addr[index].cache_fp, cache_key,
|
||||
p_attr_list, sizeof(tBTA_GATTC_NV_ATTR)*num_attr);
|
||||
status = (err_code == ESP_OK) ? BTA_GATT_OK : BTA_GATT_ERROR;
|
||||
} else {
|
||||
status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_close
|
||||
**
|
||||
** Description This callout function is executed by GATTC when a GATT server
|
||||
** cache is written completely.
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
** conn_id: connection ID of this cache operation attach to.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_co_cache_close(BD_ADDR server_bda, UINT16 conn_id)
|
||||
{
|
||||
UNUSED(conn_id);
|
||||
//#ifdef BT_SUPPORT_NVM
|
||||
cacheClose(server_bda);
|
||||
//#endif /* BT_SUPPORT_NVM */
|
||||
/* close NV when server cache is done saving or loading,
|
||||
does not need to do anything for now on Insight */
|
||||
|
||||
BTIF_TRACE_DEBUG("%s()", __FUNCTION__);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_co_cache_reset
|
||||
**
|
||||
** Description This callout function is executed by GATTC to reset cache in
|
||||
** application
|
||||
**
|
||||
** Parameter server_bda: server bd address of this cache belongs to
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_co_cache_reset(BD_ADDR server_bda)
|
||||
{
|
||||
cacheReset(server_bda);
|
||||
}
|
||||
|
||||
void bta_gattc_co_cache_addr_init(void)
|
||||
{
|
||||
nvs_handle fp;
|
||||
esp_err_t err_code;
|
||||
UINT8 num_addr;
|
||||
UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF);
|
||||
size_t length = MAX_ADDR_LIST_CACHE_BUF;
|
||||
|
||||
if ((err_code = nvs_open(cache_addr, NVS_READWRITE, &fp)) == ESP_OK) {
|
||||
cache_env.addr_fp = fp;
|
||||
cache_env.is_open = TRUE;
|
||||
// Read previously saved blob if available
|
||||
if ((err_code = nvs_get_blob(fp, cache_key, p_buf, &length)) != ESP_OK) {
|
||||
if(err_code != ESP_ERR_NVS_NOT_FOUND) {
|
||||
APPL_TRACE_ERROR("%s, Line = %d, nvs flash get blob data fail, err_code = 0x%x", __func__, __LINE__, err_code);
|
||||
}
|
||||
osi_free(p_buf);
|
||||
return;
|
||||
}
|
||||
num_addr = length / (sizeof(BD_ADDR) + sizeof(hash_key_t));
|
||||
cache_env.num_addr = num_addr;
|
||||
//read the address from nvs flash to cache address list.
|
||||
for (UINT8 i = 0; i < num_addr; i++) {
|
||||
memcpy(cache_env.cache_addr[i].addr, p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)), sizeof(BD_ADDR));
|
||||
memcpy(cache_env.cache_addr[i].hash_key,
|
||||
p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)) + sizeof(BD_ADDR), sizeof(hash_key_t));
|
||||
|
||||
APPL_TRACE_DEBUG("cache_addr[%x] = %x:%x:%x:%x:%x:%x", i, cache_env.cache_addr[i].addr[0], cache_env.cache_addr[i].addr[1], cache_env.cache_addr[i].addr[2],
|
||||
cache_env.cache_addr[i].addr[3], cache_env.cache_addr[i].addr[4], cache_env.cache_addr[i].addr[5]);
|
||||
APPL_TRACE_DEBUG("hash_key[%x] = %x%x%x%x", i, cache_env.cache_addr[i].hash_key[0], cache_env.cache_addr[i].hash_key[1],
|
||||
cache_env.cache_addr[i].hash_key[2], cache_env.cache_addr[i].hash_key[3]);
|
||||
bta_gattc_co_cache_new_assoc_list(cache_env.cache_addr[i].addr, i);
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s, Line = %d, nvs flash open fail, err_code = %x", __func__, __LINE__, err_code);
|
||||
osi_free(p_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
osi_free(p_buf);
|
||||
return;
|
||||
}
|
||||
|
||||
void bta_gattc_co_cache_addr_deinit(void)
|
||||
{
|
||||
if(!cache_env.is_open) {
|
||||
return;
|
||||
}
|
||||
nvs_close(cache_env.addr_fp);
|
||||
cache_env.is_open = false;
|
||||
|
||||
for(UINT8 i = 0; i< cache_env.num_addr; i++) {
|
||||
cache_addr_info_t *addr_info = &cache_env.cache_addr[i];
|
||||
if(addr_info) {
|
||||
nvs_close(addr_info->cache_fp);
|
||||
addr_info->is_open = false;
|
||||
if(addr_info->assoc_addr) {
|
||||
list_free(addr_info->assoc_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN bta_gattc_co_addr_in_cache(BD_ADDR bda)
|
||||
{
|
||||
UINT8 addr_index = 0;
|
||||
UINT8 num = cache_env.num_addr;
|
||||
cache_addr_info_t *addr_info = &cache_env.cache_addr[0];
|
||||
for (addr_index = 0; addr_index < num; addr_index++) {
|
||||
if (!memcmp(addr_info->addr, bda, sizeof(BD_ADDR))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT8 bta_gattc_co_find_addr_in_cache(BD_ADDR bda)
|
||||
{
|
||||
UINT8 addr_index = 0;
|
||||
UINT8 num = cache_env.num_addr;
|
||||
cache_addr_info_t *addr_info = &cache_env.cache_addr[0];
|
||||
|
||||
for (addr_index = 0; addr_index < num; addr_index++, addr_info++) {
|
||||
if (!memcmp(addr_info->addr, bda, sizeof(BD_ADDR))) {
|
||||
return addr_index;
|
||||
}
|
||||
}
|
||||
|
||||
return INVALID_ADDR_NUM;
|
||||
}
|
||||
|
||||
UINT8 bta_gattc_co_find_hash_in_cache(hash_key_t hash_key)
|
||||
{
|
||||
UINT8 index = 0;
|
||||
UINT8 num = cache_env.num_addr;
|
||||
cache_addr_info_t *addr_info = &cache_env.cache_addr[0];
|
||||
for (index = 0; index < num; index++) {
|
||||
if (!memcmp(addr_info->hash_key, hash_key, sizeof(hash_key_t))) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return INVALID_ADDR_NUM;
|
||||
}
|
||||
|
||||
UINT8 bta_gattc_co_get_addr_num(void)
|
||||
{
|
||||
return cache_env.num_addr;
|
||||
}
|
||||
|
||||
void bta_gattc_co_get_addr_list(BD_ADDR *addr_list)
|
||||
{
|
||||
UINT8 num = cache_env.num_addr;
|
||||
for (UINT8 i = 0; i < num; i++) {
|
||||
memcpy(addr_list[i], cache_env.cache_addr[i].addr, sizeof(BD_ADDR));
|
||||
}
|
||||
}
|
||||
|
||||
void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, hash_key_t hash_key)
|
||||
{
|
||||
esp_err_t err_code;
|
||||
UINT8 num = ++cache_env.num_addr;
|
||||
UINT8 index = 0;
|
||||
UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF);
|
||||
// check the address list has the same hash key or not
|
||||
if (bta_gattc_co_find_hash_in_cache(hash_key) != INVALID_ADDR_NUM) {
|
||||
APPL_TRACE_DEBUG("%s(), the hash key already in the cache list.", __func__);
|
||||
if ((index = bta_gattc_co_find_addr_in_cache(bd_addr)) != INVALID_ADDR_NUM) {
|
||||
APPL_TRACE_DEBUG("%s(), the hash bd_addr already in the cache list, index = %x", __func__, index);
|
||||
//if the bd_addr already in the address list, update the hash key in it.
|
||||
memcpy(cache_env.cache_addr[index].addr, bd_addr, sizeof(BD_ADDR));
|
||||
memcpy(cache_env.cache_addr[index].hash_key, hash_key, sizeof(hash_key_t));
|
||||
} else {
|
||||
//if the bd_addr didn't in the address list, added the bd_addr to the last of the address list.
|
||||
memcpy(cache_env.cache_addr[num - 1].hash_key, hash_key, sizeof(hash_key_t));
|
||||
memcpy(cache_env.cache_addr[num - 1].addr, bd_addr, sizeof(BD_ADDR));
|
||||
}
|
||||
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("%s(), num = %d", __func__, num);
|
||||
memcpy(cache_env.cache_addr[num - 1].addr, bd_addr, sizeof(BD_ADDR));
|
||||
memcpy(cache_env.cache_addr[num - 1].hash_key, hash_key, sizeof(hash_key_t));
|
||||
}
|
||||
|
||||
nvs_handle *fp = &cache_env.addr_fp;
|
||||
UINT16 length = num*(sizeof(BD_ADDR) + sizeof(hash_key_t));
|
||||
|
||||
for (UINT8 i = 0; i < num; i++) {
|
||||
//copy the address to the buffer.
|
||||
memcpy(p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)), cache_env.cache_addr[i].addr, sizeof(BD_ADDR));
|
||||
//copy the hash key to the buffer.
|
||||
memcpy(p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)) + sizeof(BD_ADDR),
|
||||
cache_env.cache_addr[i].hash_key, sizeof(hash_key_t));
|
||||
}
|
||||
|
||||
if (cache_env.is_open) {
|
||||
if ((err_code = nvs_set_blob(cache_env.addr_fp, cache_key, p_buf, length)) != ESP_OK) {
|
||||
APPL_TRACE_WARNING("%s(), nvs set blob fail, err %d", __func__, err_code);
|
||||
}
|
||||
} else {
|
||||
if ((err_code = nvs_open(cache_addr, NVS_READWRITE , fp)) == ESP_OK) {
|
||||
cache_env.is_open = true;
|
||||
if (( err_code = nvs_set_blob(cache_env.addr_fp, cache_key, p_buf, length)) != ESP_OK) {
|
||||
APPL_TRACE_WARNING("%s(), nvs set blob fail, err %d", __func__, err_code);
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s, Line = %d, nvs flash open fail, err_code = %x", __func__, __LINE__, err_code);
|
||||
}
|
||||
}
|
||||
//free the buffer after used.
|
||||
osi_free(p_buf);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN bta_gattc_co_cache_new_assoc_list(BD_ADDR src_addr, UINT8 index)
|
||||
{
|
||||
cache_addr_info_t *addr_info = &cache_env.cache_addr[index];
|
||||
addr_info->assoc_addr = list_new(osi_free_func);
|
||||
return (addr_info->assoc_addr != NULL ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
BOOLEAN bta_gattc_co_cache_append_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr)
|
||||
{
|
||||
UINT8 addr_index = 0;
|
||||
cache_addr_info_t *addr_info;
|
||||
UINT8 *p_assoc_buf = osi_malloc(sizeof(BD_ADDR));
|
||||
memcpy(p_assoc_buf, assoc_addr, sizeof(BD_ADDR));
|
||||
if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) {
|
||||
addr_info = &cache_env.cache_addr[addr_index];
|
||||
if (addr_info->assoc_addr == NULL) {
|
||||
addr_info->assoc_addr =list_new(NULL);
|
||||
}
|
||||
return list_append(addr_info->assoc_addr, p_assoc_buf);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN bta_gattc_co_cache_remove_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr)
|
||||
{
|
||||
UINT8 addr_index = 0;
|
||||
cache_addr_info_t *addr_info;
|
||||
if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) {
|
||||
addr_info = &cache_env.cache_addr[addr_index];
|
||||
if (addr_info->assoc_addr != NULL) {
|
||||
for (list_node_t *sn = list_begin(addr_info->assoc_addr);
|
||||
sn != list_end(addr_info->assoc_addr); sn = list_next(sn)) {
|
||||
void *addr = list_node(sn);
|
||||
if (!memcmp(addr, assoc_addr, sizeof(BD_ADDR))) {
|
||||
return list_remove(addr_info->assoc_addr, addr);
|
||||
}
|
||||
}
|
||||
//return list_remove(addr_info->assoc_addr, assoc_addr);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT8* bta_gattc_co_cache_find_src_addr(BD_ADDR assoc_addr, UINT8 *index)
|
||||
{
|
||||
UINT8 num = cache_env.num_addr;
|
||||
cache_addr_info_t *addr_info = &cache_env.cache_addr[0];
|
||||
UINT8 *addr_data;
|
||||
//Check the assoc_addr list is NULL or not
|
||||
if (addr_info->assoc_addr == NULL) {
|
||||
*index = INVALID_ADDR_NUM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
for (const list_node_t *node = list_begin(addr_info->assoc_addr); node != list_end(addr_info->assoc_addr);
|
||||
node = list_next(node)) {
|
||||
addr_data = (UINT8 *)list_node(node);
|
||||
if (!memcmp(addr_data, assoc_addr, sizeof(BD_ADDR))) {
|
||||
*index = i;
|
||||
return (UINT8 *)addr_info->addr;
|
||||
}
|
||||
}
|
||||
addr_info++;
|
||||
|
||||
if (addr_info->assoc_addr == NULL) {
|
||||
*index = INVALID_ADDR_NUM;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
*index = INVALID_ADDR_NUM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOLEAN bta_gattc_co_cache_clear_assoc_addr(BD_ADDR src_addr)
|
||||
{
|
||||
UINT8 addr_index = 0;
|
||||
cache_addr_info_t *addr_info;
|
||||
if ((addr_index = bta_gattc_co_find_addr_in_cache(src_addr)) != INVALID_ADDR_NUM) {
|
||||
addr_info = &cache_env.cache_addr[addr_index];
|
||||
if (addr_info->assoc_addr != NULL) {
|
||||
list_clear(addr_info->assoc_addr);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* #if( defined BLE_INCLUDED ) && (BLE_INCLUDED == TRUE) */
|
||||
#endif /* #if( defined BTA_GATT_INCLUDED ) && (BTA_GATT_INCLUDED == TRUE) */
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if (GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "bta_gattc_int.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -238,8 +237,6 @@ const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] = {
|
||||
/* GATTC control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_GATTC_CB bta_gattc_cb;
|
||||
#else
|
||||
tBTA_GATTC_CB *bta_gattc_cb_ptr;
|
||||
#endif
|
||||
|
||||
#if BTA_GATT_DEBUG == TRUE
|
||||
@@ -356,12 +353,7 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
|
||||
case BTA_GATTC_API_REFRESH_EVT:
|
||||
bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_CACHE_ASSOC_EVT:
|
||||
bta_gattc_process_api_cache_assoc(p_cb, (tBTA_GATTC_DATA *)p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT:
|
||||
bta_gattc_process_api_cache_get_addr_list(p_cb, (tBTA_GATTC_DATA *)p_msg);
|
||||
break;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
case BTA_GATTC_API_LISTEN_EVT:
|
||||
bta_gattc_listen(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
@@ -501,12 +493,4 @@ static char *gattc_state_code(tBTA_GATTC_STATE state_code)
|
||||
}
|
||||
|
||||
#endif /* Debug Functions */
|
||||
|
||||
void bta_gattc_deinit(void)
|
||||
{
|
||||
#if BTA_DYNAMIC_MEMORY
|
||||
memset(bta_gattc_cb_ptr, 0, sizeof(tBTA_GATTC_CB));
|
||||
FREE_AND_RESET(bta_gattc_cb_ptr);
|
||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||
}
|
||||
#endif /* GATTC_INCLUDED == TRUE && BLE_INCLUDED == TRUE */
|
||||
|
||||
@@ -22,20 +22,21 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "device/bdaddr.h"
|
||||
#include "bdaddr.h"
|
||||
// #include "btif/include/btif_util.h"
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "utl.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gattc_int.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "l2c_api.h"
|
||||
#include "allocator.h"
|
||||
|
||||
#define LOG_TAG "bt_bta_gattc"
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
@@ -862,6 +863,10 @@ BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda)
|
||||
if (p_conn != NULL) {
|
||||
p_conn->in_use = FALSE;
|
||||
memset(p_conn->remote_bda, 0, BD_ADDR_LEN);
|
||||
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
bta_sys_free_timer(&p_conn->service_change_ccc_timer);
|
||||
p_conn->ccc_timer_used = FALSE;
|
||||
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -962,7 +967,7 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
break;
|
||||
|
||||
default:
|
||||
APPL_TRACE_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_src->len);
|
||||
LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_src->len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "utl.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gatts_int.h"
|
||||
#include "bta/bta_gatts_co.h"
|
||||
#include "stack/btm_ble_api.h"
|
||||
#include "bta_gatts_co.h"
|
||||
#include "btm_ble_api.h"
|
||||
#include <string.h>
|
||||
#include "osi/allocator.h"
|
||||
#include "allocator.h"
|
||||
|
||||
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
|
||||
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
|
||||
@@ -335,19 +335,19 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
|
||||
cb_data.create.status = BTA_GATT_OK;
|
||||
cb_data.create.service_id = service_id;
|
||||
|
||||
// btla-specific ++
|
||||
cb_data.create.is_primary = p_msg->api_create_svc.is_pri;
|
||||
|
||||
// btla-specific --
|
||||
cb_data.create.server_if = p_cb->rcb[rcb_idx].gatt_if;
|
||||
} else {
|
||||
cb_data.status = BTA_GATT_ERROR;
|
||||
memset(&p_cb->srvc_cb[srvc_idx], 0, sizeof(tBTA_GATTS_SRVC_CB));
|
||||
APPL_TRACE_ERROR("service creation failed.");
|
||||
}
|
||||
|
||||
// btla-specific ++
|
||||
memcpy(&cb_data.create.uuid, &p_msg->api_create_svc.service_uuid, sizeof(tBT_UUID));
|
||||
cb_data.create.svc_instance = p_msg->api_create_svc.inst;
|
||||
|
||||
// btla-specific --
|
||||
}
|
||||
if (p_cb->rcb[rcb_idx].p_cback) {
|
||||
(* p_cb->rcb[rcb_idx].p_cback)(BTA_GATTS_CREATE_EVT, &cb_data);
|
||||
@@ -692,7 +692,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
cb_data.req_data.status = status;
|
||||
cb_data.req_data.conn_id = p_msg->api_indicate.hdr.layer_specific;
|
||||
|
||||
cb_data.req_data.value = (uint8_t *)osi_malloc(p_msg->api_indicate.len);
|
||||
cb_data.req_data.value =(uint8_t *)osi_malloc(p_msg->api_indicate.len);
|
||||
if (cb_data.req_data.value != NULL){
|
||||
memset(cb_data.req_data.value, 0, p_msg->api_indicate.len);
|
||||
cb_data.req_data.data_len = p_msg->api_indicate.len;
|
||||
@@ -702,6 +702,10 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
APPL_TRACE_ERROR("%s, malloc failed", __func__);
|
||||
}
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
|
||||
if (cb_data.req_data.value != NULL) {
|
||||
osi_free(cb_data.req_data.value);
|
||||
cb_data.req_data.value = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x",
|
||||
|
||||
@@ -22,15 +22,15 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gatts_int.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "allocator.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "bta_gatts_int.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
/* type for service building action functions */
|
||||
typedef void (*tBTA_GATTS_SRVC_ACT)(tBTA_GATTS_SRVC_CB *p_rcb, tBTA_GATTS_DATA *p_data);
|
||||
@@ -47,8 +46,6 @@ const tBTA_GATTS_SRVC_ACT bta_gatts_srvc_build_act[] = {
|
||||
/* GATTS control block */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_GATTS_CB bta_gatts_cb;
|
||||
#else
|
||||
tBTA_GATTS_CB *bta_gatts_cb_ptr;
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -138,12 +135,4 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
void bta_gatts_deinit(void)
|
||||
{
|
||||
memset(&bta_gatts_cb, 0, sizeof(tBTA_GATTS_CB));
|
||||
#if BTA_DYNAMIC_MEMORY
|
||||
FREE_AND_RESET(bta_gatts_cb_ptr);
|
||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||
}
|
||||
|
||||
#endif /* GATTS_INCLUDED */
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "common/bt_target.h"
|
||||
#include "bt_target.h"
|
||||
|
||||
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
|
||||
|
||||
#include <string.h>
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "utl.h"
|
||||
#include "bta_sys.h"
|
||||
#include "bta_gatts_int.h"
|
||||
|
||||
static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user