forked from espressif/esp-idf
Compare commits
538 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b8741b172 | ||
|
|
9cf323d4c6 | ||
|
|
f47a4796e5 | ||
|
|
8cd37950c7 | ||
|
|
ee1c907d21 | ||
|
|
9f4f8e24f2 | ||
|
|
5ff245f7f9 | ||
|
|
541632c555 | ||
|
|
89c22c63e6 | ||
|
|
7c38b262fb | ||
|
|
70fc0e3037 | ||
|
|
3b15317109 | ||
|
|
300aa4d08c | ||
|
|
8742f242eb | ||
|
|
2fc047d61d | ||
|
|
3e81bd22c3 | ||
|
|
62e909183b | ||
|
|
5570cd2a97 | ||
|
|
cc5101f1eb | ||
|
|
408294ab15 | ||
|
|
2374ec54c4 | ||
|
|
84706fe4bb | ||
|
|
2a9108ff1b | ||
|
|
c535addbfa | ||
|
|
f8319f08cc | ||
|
|
83a73e994d | ||
|
|
55ea18dc9d | ||
|
|
7fa676a2d6 | ||
|
|
f92665a637 | ||
|
|
0b633e8516 | ||
|
|
4254e38bb4 | ||
|
|
f1c0fe8614 | ||
|
|
1fa8d232ea | ||
|
|
0cb30ed881 | ||
|
|
29a04ba3d7 | ||
|
|
637fa8abcc | ||
|
|
e460ec8d33 | ||
|
|
af26dc76c8 | ||
|
|
4c7562dd4d | ||
|
|
dcf6b54e94 | ||
|
|
1f3f65b40e | ||
|
|
ee934f7147 | ||
|
|
258bb60c38 | ||
|
|
5d5113c5f9 | ||
|
|
3bc4d11dbb | ||
|
|
771761a576 | ||
|
|
b1dfff4010 | ||
|
|
4dda86b352 | ||
|
|
7e97c5fb16 | ||
|
|
a3c20bde5d | ||
|
|
ffbf04ab2d | ||
|
|
e6414b69f5 | ||
|
|
3213978b45 | ||
|
|
9b3ae86417 | ||
|
|
eb7c381761 | ||
|
|
d82d7039fc | ||
|
|
3d56f1b1b9 | ||
|
|
dc3e9531c0 | ||
|
|
4cf7387e14 | ||
|
|
bc4c826ff1 | ||
|
|
8374791fd4 | ||
|
|
78b6d515bb | ||
|
|
27e8db2ae9 | ||
|
|
70fc931dd2 | ||
|
|
4d7f9c5d88 | ||
|
|
c136089f4e | ||
|
|
bb6cf16177 | ||
|
|
a06844d9b1 | ||
|
|
5ec51688a6 | ||
|
|
64984b7b71 | ||
|
|
15962a953a | ||
|
|
1ed2f223fb | ||
|
|
373e585bb7 | ||
|
|
52702cf886 | ||
|
|
5fa34283c0 | ||
|
|
9897fd9c87 | ||
|
|
8b4177f148 | ||
|
|
275eab4f5d | ||
|
|
05521c918d | ||
|
|
e99f45b4c6 | ||
|
|
a64a528cb8 | ||
|
|
66c164b90b | ||
|
|
d4e32532df | ||
|
|
5aad8507cb | ||
|
|
1c09bc1675 | ||
|
|
89dbe5f6dc | ||
|
|
5ce43f68f3 | ||
|
|
3ba5cb9687 | ||
|
|
280ec09b03 | ||
|
|
d2e5b33e2c | ||
|
|
98b744c85b | ||
|
|
ca79a7d878 | ||
|
|
d4a361bb71 | ||
|
|
d574cea5e5 | ||
|
|
2ba5320112 | ||
|
|
85e5f0e546 | ||
|
|
f0e5c92516 | ||
|
|
28157cf1e2 | ||
|
|
0a13c60466 | ||
|
|
1b9597f961 | ||
|
|
fd36f6fcac | ||
|
|
cea24c7137 | ||
|
|
c3398f3373 | ||
|
|
85315941e3 | ||
|
|
9e9aeb64be | ||
|
|
b89f08a615 | ||
|
|
470d5406ec | ||
|
|
4bc2985aa3 | ||
|
|
b0eef7f889 | ||
|
|
f20186fe02 | ||
|
|
4066844908 | ||
|
|
ea3094a9a6 | ||
|
|
71d37432da | ||
|
|
8f9090b351 | ||
|
|
0e28063291 | ||
|
|
376b2f74ed | ||
|
|
9f52809629 | ||
|
|
9c8b54b886 | ||
|
|
4faf042c21 | ||
|
|
9a51752d4d | ||
|
|
e7d6748aec | ||
|
|
a2cbe3f0a3 | ||
|
|
f66e3f031d | ||
|
|
9efa26a23f | ||
|
|
3b9d5e120e | ||
|
|
aaf3f4a7c3 | ||
|
|
082c713069 | ||
|
|
f5c8cc2bef | ||
|
|
fd47ea34bb | ||
|
|
b19e27dd48 | ||
|
|
22fbaf65fd | ||
|
|
e362358ea3 | ||
|
|
47d542acaa | ||
|
|
ea967cf2fb | ||
|
|
c079772799 | ||
|
|
b6b04bbeff | ||
|
|
568b693493 | ||
|
|
806b14dd22 | ||
|
|
a07bce4fcc | ||
|
|
0e34a993d0 | ||
|
|
458ce7d4cf | ||
|
|
6bcf47386d | ||
|
|
228f92211b | ||
|
|
61210271a8 | ||
|
|
830464eee7 | ||
|
|
83f272ca4f | ||
|
|
01902148da | ||
|
|
dcc7a41ad8 | ||
|
|
73f6ca8ebf | ||
|
|
cc213b7c61 | ||
|
|
42f244ae61 | ||
|
|
f9feb970b9 | ||
|
|
9bd8d5f860 | ||
|
|
b60280e2cf | ||
|
|
8c52152369 | ||
|
|
f3ec76b75b | ||
|
|
5c53238853 | ||
|
|
a255e67a84 | ||
|
|
234ad8cd1e | ||
|
|
3ba9de778e | ||
|
|
40d398199f | ||
|
|
a7d981dc5e | ||
|
|
222a254e49 | ||
|
|
57de44f45b | ||
|
|
41aa38ddf7 | ||
|
|
b69a5fe27c | ||
|
|
ee47bebfad | ||
|
|
1265a44c17 | ||
|
|
51f7ddc223 | ||
|
|
2377b40784 | ||
|
|
01d5030d5e | ||
|
|
a24ebb4538 | ||
|
|
62e9dfe13c | ||
|
|
28a6a0cc33 | ||
|
|
80409743f1 | ||
|
|
063ea6f1ef | ||
|
|
640ce31dae | ||
|
|
1df5f07eee | ||
|
|
c55a07bf57 | ||
|
|
408a16b21a | ||
|
|
8096a16765 | ||
|
|
8352be2027 | ||
|
|
5f1187dc92 | ||
|
|
a43f54ccc0 | ||
|
|
9b72c4ef54 | ||
|
|
0efee1745c | ||
|
|
5be1323c0a | ||
|
|
f9163c6d43 | ||
|
|
3e214bc2f4 | ||
|
|
c5649deaca | ||
|
|
a12a681794 | ||
|
|
26160a217e | ||
|
|
2a985b3c65 | ||
|
|
d23876f3e4 | ||
|
|
709b74c033 | ||
|
|
3e761525c3 | ||
|
|
a34ff0eca3 | ||
|
|
38dd5acc71 | ||
|
|
abd21843e5 | ||
|
|
023cbd60ac | ||
|
|
9b2c0ffe79 | ||
|
|
bd826801ba | ||
|
|
d2fb80529c | ||
|
|
ea6520ee81 | ||
|
|
85186042c3 | ||
|
|
9004c42f29 | ||
|
|
33c631570e | ||
|
|
b359cd85f1 | ||
|
|
0f505ddf8e | ||
|
|
27322a8597 | ||
|
|
7b97a3de61 | ||
|
|
ec06c11a19 | ||
|
|
8f896f07c5 | ||
|
|
8f175bf638 | ||
|
|
724165bd35 | ||
|
|
69359f4dfb | ||
|
|
5753eba7c4 | ||
|
|
c9cb9b7ab1 | ||
|
|
3d0682d49e | ||
|
|
a5662dc290 | ||
|
|
4893ae3c11 | ||
|
|
b6f5573e0f | ||
|
|
29f835d2f1 | ||
|
|
d93f1d55c5 | ||
|
|
4b612be8d9 | ||
|
|
9323c190c2 | ||
|
|
a9ff81a603 | ||
|
|
f2fd239471 | ||
|
|
d56ae4caab | ||
|
|
2c4128b98d | ||
|
|
9582b3cead | ||
|
|
b8855fbd03 | ||
|
|
3ac6c10d11 | ||
|
|
7c233ebc80 | ||
|
|
fe6f4ce916 | ||
|
|
4502621282 | ||
|
|
ae152ca84e | ||
|
|
602573933c | ||
|
|
0440a63cb6 | ||
|
|
9a6b151c41 | ||
|
|
8a151a51cf | ||
|
|
fc7a2a7af7 | ||
|
|
17ffe58051 | ||
|
|
c722d8aab6 | ||
|
|
3bd63654c8 | ||
|
|
8b2b9140ac | ||
|
|
bf15a29e18 | ||
|
|
1158811fbd | ||
|
|
a00717803a | ||
|
|
4c96e523a3 | ||
|
|
83bd62fb7c | ||
|
|
2d0ac9208e | ||
|
|
d34b0242ba | ||
|
|
c3f819289d | ||
|
|
2152112ff8 | ||
|
|
8599ec33d5 | ||
|
|
510ae698e2 | ||
|
|
27d360127d | ||
|
|
2ce39a857f | ||
|
|
b0b6d190ff | ||
|
|
d4327c47a1 | ||
|
|
c08a831f17 | ||
|
|
2c64d8d302 | ||
|
|
06d18ca0d6 | ||
|
|
8d494a8d03 | ||
|
|
a70bb45c48 | ||
|
|
77920038f6 | ||
|
|
c920d2ed64 | ||
|
|
cc13237746 | ||
|
|
016b27c132 | ||
|
|
dfeeaf386e | ||
|
|
2da016575f | ||
|
|
23540fa90d | ||
|
|
ae94c0134b | ||
|
|
0f852fcd5f | ||
|
|
2291ded9a1 | ||
|
|
90afc33cd8 | ||
|
|
8567102be4 | ||
|
|
f93ebedcb6 | ||
|
|
27690e0990 | ||
|
|
31883c9a64 | ||
|
|
8efe72379d | ||
|
|
6020d08074 | ||
|
|
2417ffe69e | ||
|
|
30c6144b2f | ||
|
|
afa39b0d02 | ||
|
|
064df2a1fa | ||
|
|
7646dd575a | ||
|
|
8e694cddcc | ||
|
|
b86dd75df5 | ||
|
|
044ead90ce | ||
|
|
7c15d88e75 | ||
|
|
b531376a62 | ||
|
|
2ffeffddc6 | ||
|
|
ccc8fb8f65 | ||
|
|
9da552c409 | ||
|
|
4e2a52ea85 | ||
|
|
ac44663186 | ||
|
|
413bcd8fcd | ||
|
|
fcb76f0671 | ||
|
|
b85d778374 | ||
|
|
120cb89c56 | ||
|
|
6115e2500a | ||
|
|
1830bc4d29 | ||
|
|
1be59d080a | ||
|
|
93f7ae7f7f | ||
|
|
fc56156013 | ||
|
|
b3a1ec3ac0 | ||
|
|
8c5ccece57 | ||
|
|
5f32741958 | ||
|
|
ed57048579 | ||
|
|
b4a8bd2040 | ||
|
|
50ea662fe0 | ||
|
|
358c9ad946 | ||
|
|
d411856956 | ||
|
|
3139589b7c | ||
|
|
f0e97da81e | ||
|
|
c710a583bb | ||
|
|
54a38a87e2 | ||
|
|
cf7b9bed4c | ||
|
|
7310ab3589 | ||
|
|
4652a99e92 | ||
|
|
3c8b37087b | ||
|
|
a6895cef01 | ||
|
|
c1c41a30ea | ||
|
|
436e3d3345 | ||
|
|
f5777749dc | ||
|
|
4fe7b96e76 | ||
|
|
9607a1121d | ||
|
|
00f2e33008 | ||
|
|
1a5e528c83 | ||
|
|
962d9de65e | ||
|
|
24e0a124a8 | ||
|
|
ec7e307a18 | ||
|
|
b32d47ab98 | ||
|
|
84f4548b98 | ||
|
|
4005c24ce1 | ||
|
|
691997af91 | ||
|
|
47d9b8ca50 | ||
|
|
3b86f974ea | ||
|
|
58dffd9b3c | ||
|
|
7e36e97467 | ||
|
|
d23ef4c6bd | ||
|
|
34a26ed632 | ||
|
|
c51b2fb75f | ||
|
|
dd1265845f | ||
|
|
06733dc407 | ||
|
|
1008091a74 | ||
|
|
e759833c44 | ||
|
|
f2e1c06b0c | ||
|
|
a2e56227cc | ||
|
|
e416552e46 | ||
|
|
bc310e088b | ||
|
|
b761052e6b | ||
|
|
7727b7f693 | ||
|
|
08299f5f9b | ||
|
|
9beb67dedf | ||
|
|
80cfe30b29 | ||
|
|
85ac17e5ba | ||
|
|
fd4b09f283 | ||
|
|
6cdf728ce8 | ||
|
|
698a7705b8 | ||
|
|
298682913c | ||
|
|
2c06ea4039 | ||
|
|
57bd2488af | ||
|
|
22c682b52e | ||
|
|
7771d72d7c | ||
|
|
4200246df3 | ||
|
|
c7660fe26d | ||
|
|
bc26c82f01 | ||
|
|
bd55386769 | ||
|
|
85403d2e5e | ||
|
|
48944645f1 | ||
|
|
1a4234c0e1 | ||
|
|
374a03f210 | ||
|
|
9c49c40daa | ||
|
|
a253028107 | ||
|
|
4e57c2bf6f | ||
|
|
aa2d885139 | ||
|
|
ac2d88912d | ||
|
|
387f48aa9a | ||
|
|
15e9343a20 | ||
|
|
bbd4266328 | ||
|
|
729f45db61 | ||
|
|
c97d3aed45 | ||
|
|
1097ed0fcf | ||
|
|
69dc6f386c | ||
|
|
2456b833b5 | ||
|
|
a72d10a4e2 | ||
|
|
a61d79966b | ||
|
|
a0bb3e8fdf | ||
|
|
a8d3034a3c | ||
|
|
4d4d86be51 | ||
|
|
464a62b516 | ||
|
|
38142889a5 | ||
|
|
f18329b15f | ||
|
|
61a5631b51 | ||
|
|
39854bebd3 | ||
|
|
1d526b4d10 | ||
|
|
daa6a0d5c2 | ||
|
|
8cc9921651 | ||
|
|
c7d2134d7b | ||
|
|
64cbabffd4 | ||
|
|
e9bb0da852 | ||
|
|
74e4fbba06 | ||
|
|
dd9ba05c49 | ||
|
|
8eea1ee804 | ||
|
|
2d818bbfe5 | ||
|
|
20762c4524 | ||
|
|
78d9e6390d | ||
|
|
4024dce2b4 | ||
|
|
54ca68e79f | ||
|
|
3f9d7edd72 | ||
|
|
bd2e42b87d | ||
|
|
a258fa9a59 | ||
|
|
afe0e318c1 | ||
|
|
f2da2e8b77 | ||
|
|
0a83a253ca | ||
|
|
9da4043cba | ||
|
|
8f89b32938 | ||
|
|
2ac4df6e47 | ||
|
|
a15fd9846b | ||
|
|
8def30a57b | ||
|
|
c2b4a872cb | ||
|
|
8bab1037bb | ||
|
|
bf17be96b4 | ||
|
|
259e2ba975 | ||
|
|
909e7fcc3b | ||
|
|
1f8e365608 | ||
|
|
eca7d88db5 | ||
|
|
36092067a0 | ||
|
|
61f8f1905f | ||
|
|
6f46cd332e | ||
|
|
df5d0be767 | ||
|
|
35630f5e52 | ||
|
|
ba28b5a599 | ||
|
|
4544d37078 | ||
|
|
0077c1234f | ||
|
|
2fe12978a0 | ||
|
|
756efd4829 | ||
|
|
e28a335ef6 | ||
|
|
d1ee48208f | ||
|
|
9e5c30baff | ||
|
|
028093efe6 | ||
|
|
e5665a198a | ||
|
|
deacd79736 | ||
|
|
d9be451649 | ||
|
|
bbb549c830 | ||
|
|
8dfbb9e816 | ||
|
|
33271be13b | ||
|
|
6c1542e151 | ||
|
|
9682d3b355 | ||
|
|
2476315a3b | ||
|
|
4ff5528a23 | ||
|
|
d406bf02b5 | ||
|
|
119af9f78f | ||
|
|
cb8a1eb219 | ||
|
|
94c0684fdb | ||
|
|
9cc713cd06 | ||
|
|
e852e0a106 | ||
|
|
15fe8086ee | ||
|
|
391c3a1ce9 | ||
|
|
dd70bf2f0a | ||
|
|
8bf27c103c | ||
|
|
344db9a7e7 | ||
|
|
8b99b2deb0 | ||
|
|
78637971e5 | ||
|
|
6fe8a34ff8 | ||
|
|
c630c0493a | ||
|
|
1cc16ab128 | ||
|
|
335b970868 | ||
|
|
94bec845ea | ||
|
|
a92b18c37e | ||
|
|
c36c0c34a1 | ||
|
|
c0faa8fa94 | ||
|
|
9fe886edcd | ||
|
|
0993dfb880 | ||
|
|
0c4d864823 | ||
|
|
729e5cb126 | ||
|
|
5ba3b99f2b | ||
|
|
57249447a7 | ||
|
|
8c6ce09982 | ||
|
|
c83dc69938 | ||
|
|
00f130621f | ||
|
|
64dcc3cee1 | ||
|
|
93ec3acfce | ||
|
|
eb8e894147 | ||
|
|
53e2f9096d | ||
|
|
c15484ec58 | ||
|
|
e4eaa28b82 | ||
|
|
e3f811b5b8 | ||
|
|
05ff8169f7 | ||
|
|
b98b548f01 | ||
|
|
88867e66d1 | ||
|
|
f8dde8cebf | ||
|
|
516a4ba28d | ||
|
|
206f843e82 | ||
|
|
8582b27f1d | ||
|
|
4a7cda8cb0 | ||
|
|
68442ecaa0 | ||
|
|
a56fc41215 | ||
|
|
355df44822 | ||
|
|
c410322070 | ||
|
|
6bacffff21 | ||
|
|
1f73689c50 | ||
|
|
50282f1e7a | ||
|
|
ed304d5173 | ||
|
|
c4eaf86516 | ||
|
|
e51277fbc7 | ||
|
|
7938bbf3c0 | ||
|
|
2fc1fabcee | ||
|
|
4746554954 | ||
|
|
016575ccda | ||
|
|
1bebd2d8d2 | ||
|
|
2ceb122ee2 | ||
|
|
df6a32f305 | ||
|
|
88e3e64348 | ||
|
|
0f7c9a29a2 | ||
|
|
ca4f560f2b | ||
|
|
c365c5db2a | ||
|
|
a055ee6da6 | ||
|
|
1143fea119 | ||
|
|
3d5852131b | ||
|
|
4521a50db5 | ||
|
|
f04e4f99e6 | ||
|
|
72ba89f191 | ||
|
|
80a1f5e18c | ||
|
|
f0ae83d056 | ||
|
|
2f707291eb | ||
|
|
f10d734f30 | ||
|
|
24615ef848 | ||
|
|
e930ff0b1f | ||
|
|
fde5e93ab5 | ||
|
|
901c5624d3 | ||
|
|
229a974252 | ||
|
|
0cdaf0008d | ||
|
|
0c20e3bda8 | ||
|
|
8c9657063a |
@@ -168,6 +168,8 @@
|
||||
|
||||
- "tools/split_paths_by_spaces.py"
|
||||
|
||||
- "tools/check_python_dependencies.py"
|
||||
|
||||
.patterns-docker: &patterns-docker
|
||||
- "tools/docker/**/*"
|
||||
|
||||
|
||||
@@ -229,6 +229,15 @@ pytest_examples_esp32c6_generic:
|
||||
artifacts: false
|
||||
tags: [ esp32c6, generic ]
|
||||
|
||||
pytest_examples_esp32c6_usj_device:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
- .rules:test:example_test-esp32c6
|
||||
needs:
|
||||
- job: build_pytest_examples_esp32c6
|
||||
artifacts: false
|
||||
tags: [ esp32c6, usj_device ]
|
||||
|
||||
pytest_examples_esp32h2_generic:
|
||||
extends:
|
||||
- .pytest_examples_dir_template
|
||||
|
||||
@@ -5,7 +5,7 @@ default_stages: [commit]
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.0.1
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
# note: whitespace exclusions use multiline regex, see https://pre-commit.com/#regular-expressions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "esp_freertos_hooks.h"
|
||||
#include "esp_private/dbg_stubs.h"
|
||||
#include "esp_ipc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/libc_stubs.h"
|
||||
@@ -80,6 +81,7 @@ void gcov_create_task(void *arg)
|
||||
(void *)&s_gcov_task_running, configMAX_PRIORITIES - 1, NULL, 0);
|
||||
}
|
||||
|
||||
static IRAM_ATTR
|
||||
void gcov_create_task_tick_hook(void)
|
||||
{
|
||||
extern esp_err_t esp_ipc_start_gcov_from_isr(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
@@ -106,12 +108,16 @@ static int esp_dbg_stub_gcov_entry(void)
|
||||
|
||||
void gcov_rtio_init(void)
|
||||
{
|
||||
uint32_t capabilities = 0;
|
||||
uint32_t stub_entry = 0;
|
||||
ESP_EARLY_LOGV(TAG, "%s", __FUNCTION__);
|
||||
esp_dbg_stub_entry_set(ESP_DBG_STUB_ENTRY_GCOV, (uint32_t)&esp_dbg_stub_gcov_entry);
|
||||
if (esp_dbg_stub_entry_get(ESP_DBG_STUB_ENTRY_CAPABILITIES, &capabilities) == ESP_OK) {
|
||||
esp_dbg_stub_entry_set(ESP_DBG_STUB_ENTRY_CAPABILITIES, capabilities | ESP_DBG_STUB_CAP_GCOV_TASK);
|
||||
assert(esp_dbg_stub_entry_get(ESP_DBG_STUB_ENTRY_GCOV, &stub_entry) == ESP_OK);
|
||||
if (stub_entry != 0) {
|
||||
/* "__gcov_init()" can be called several times. We must avoid multiple tick hook registration */
|
||||
return;
|
||||
}
|
||||
esp_dbg_stub_entry_set(ESP_DBG_STUB_ENTRY_GCOV, (uint32_t)&esp_dbg_stub_gcov_entry);
|
||||
assert(esp_dbg_stub_entry_get(ESP_DBG_STUB_ENTRY_CAPABILITIES, &stub_entry) == ESP_OK);
|
||||
esp_dbg_stub_entry_set(ESP_DBG_STUB_ENTRY_CAPABILITIES, stub_entry | ESP_DBG_STUB_CAP_GCOV_TASK);
|
||||
esp_register_freertos_tick_hook(gcov_create_task_tick_hook);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ set(common_include_dirs
|
||||
common/api/include/api
|
||||
common/btc/profile/esp/blufi/include
|
||||
common/btc/profile/esp/include
|
||||
common/hci_log/include
|
||||
)
|
||||
|
||||
set(ble_mesh_include_dirs
|
||||
@@ -66,40 +67,40 @@ if(CONFIG_IDF_DOC_BUILD)
|
||||
${nimble_hci_include_dirs})
|
||||
endif()
|
||||
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
|
||||
set(srcs "")
|
||||
set(include_dirs "")
|
||||
set(ldfragments "linker.lf")
|
||||
set(ldscripts "linker_common.lf")
|
||||
if(CONFIG_BT_CONTROLLER_ENABLED)
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
list(APPEND srcs "controller/esp32/bt.c"
|
||||
"controller/esp32/hli_api.c"
|
||||
"controller/esp32/hli_vectors.S")
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C3)
|
||||
list(APPEND srcs "controller/esp32c3/bt.c")
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32S3)
|
||||
list(APPEND srcs "controller/esp32c3/bt.c")
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
set(ldfragments "linker.lf.esp32c2")
|
||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||
set(ldscripts "linker_esp32c2.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||
list(APPEND srcs "controller/esp32c6/bt.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
list(APPEND srcs "controller/esp32h2/bt.c")
|
||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
||||
endif()
|
||||
|
||||
list(APPEND include_dirs ${target_specific_include_dirs})
|
||||
|
||||
endif()
|
||||
|
||||
# Common
|
||||
@@ -114,6 +115,7 @@ if(CONFIG_BT_ENABLED)
|
||||
|
||||
list(APPEND srcs "common/btc/core/btc_alarm.c"
|
||||
"common/api/esp_blufi_api.c"
|
||||
"common/hci_log/bt_hci_log.c"
|
||||
"common/btc/core/btc_manage.c"
|
||||
"common/btc/core/btc_task.c"
|
||||
"common/btc/profile/esp/blufi/blufi_prf.c"
|
||||
@@ -821,7 +823,7 @@ idf_component_register(SRCS "${srcs}"
|
||||
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
|
||||
REQUIRES esp_timer esp_wifi
|
||||
PRIV_REQUIRES nvs_flash soc esp_pm esp_phy esp_coex mbedtls driver vfs
|
||||
LDFRAGMENTS "${ldfragments}")
|
||||
LDFRAGMENTS "${ldscripts}")
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
|
||||
@@ -838,14 +840,8 @@ if(CONFIG_BT_ENABLED)
|
||||
target_link_directories(${COMPONENT_LIB} INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3")
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32c6/esp32c6-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
elseif(CONFIG_IDF_TARGET_ESP32H2)
|
||||
add_prebuilt_library(libble_app "controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a")
|
||||
elseif(CONFIG_BT_CONTROLLER_ENABLED)
|
||||
add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a")
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -80,6 +80,37 @@ menu "Bluetooth"
|
||||
We cannot split the memory into 3 different regions (IRAM, BLE-IRAM, DRAM).
|
||||
So this option will disable the PMP (ESP_SYSTEM_PMP_IDRAM_SPLIT)
|
||||
|
||||
config BT_HCI_LOG_DEBUG_EN
|
||||
depends on BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED
|
||||
bool "Enable Bluetooth HCI debug mode"
|
||||
default n
|
||||
help
|
||||
This option is used to enable bluetooth debug mode, which saves the hci layer data stream.
|
||||
|
||||
config BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
depends on BT_HCI_LOG_DEBUG_EN
|
||||
int "Size of the cache used for HCI data in Bluetooth HCI debug mode (N*1024 bytes)"
|
||||
range 1 100
|
||||
default 5
|
||||
help
|
||||
This option is to configure the buffer size of the hci data steam cache in hci debug mode.
|
||||
This is a ring buffer, the new data will overwrite the oldest data if the buffer is full.
|
||||
|
||||
config BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
depends on BT_HCI_LOG_DEBUG_EN
|
||||
int "Size of the cache used for adv report in Bluetooth HCI debug mode (N*1024 bytes)"
|
||||
range 1 100
|
||||
default 8
|
||||
help
|
||||
This option is to configure the buffer size of the hci adv report cache in hci debug mode.
|
||||
This is a ring buffer, the new data will overwrite the oldest data if the buffer is full.
|
||||
|
||||
menu "Common Options"
|
||||
visible if (BT_BLUEDROID_ENABLED || BT_NIMBLE_ENABLED)
|
||||
|
||||
source "$IDF_PATH/components/bt/common/Kconfig.in"
|
||||
endmenu
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLE_MESH
|
||||
|
||||
6
components/bt/common/Kconfig.in
Normal file
6
components/bt/common/Kconfig.in
Normal file
@@ -0,0 +1,6 @@
|
||||
config BT_ALARM_MAX_NUM
|
||||
int "Maximum number of Bluetooth alarms"
|
||||
default 50
|
||||
help
|
||||
This option decides the maximum number of alarms which
|
||||
could be used by Bluetooth host.
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -405,6 +405,13 @@ static void btc_deinit_mem(void) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BTC_HF_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_local_param_ptr) {
|
||||
osi_free(hf_local_param_ptr);
|
||||
hf_local_param_ptr = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_client_local_param_ptr) {
|
||||
osi_free(hf_client_local_param_ptr);
|
||||
@@ -460,6 +467,13 @@ static bt_status_t btc_init_mem(void) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BTC_HF_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if ((hf_local_param_ptr = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
memset((void *)hf_local_param_ptr, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t));
|
||||
#endif
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if ((hf_client_local_param_ptr = (hf_client_local_param_t *)osi_malloc(sizeof(hf_client_local_param_t))) == NULL) {
|
||||
goto error_exit;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -9,6 +9,11 @@
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "esp_blufi_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
|
||||
#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion
|
||||
@@ -193,5 +198,10 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_blufi_cb_deep_free(btc_msg_t *msg);
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -20,6 +20,10 @@
|
||||
#include "esp_gap_ble_api.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLUFI_APP_UUID 0xFFFF
|
||||
#define BLUFI_DEVICE_NAME "BLUFI_DEVICE"
|
||||
|
||||
@@ -96,4 +100,7 @@ void esp_blufi_send_encap(void *arg);
|
||||
int esp_blufi_handle_gap_events(struct ble_gap_event *event, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif/* _ESP_BLUFI_ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -21,6 +21,11 @@
|
||||
#define ESP_BLUFI_SUCCESS 0x00
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
||||
|
||||
@@ -100,4 +105,7 @@ void btc_blufi_call_deep_free(btc_msg_t *msg);
|
||||
|
||||
uint16_t btc_blufi_get_version(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __BTC_BLUFI_PRF_H__ */
|
||||
|
||||
334
components/bt/common/hci_log/bt_hci_log.c
Normal file
334
components/bt/common/hci_log/bt_hci_log.c
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
#include "bt_common.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
#define BT_HCI_LOG_PRINT_TAG (1)
|
||||
#define BT_HCI_LOG_DATA_BUF_SIZE (1024 * HCI_LOG_DATA_BUFFER_SIZE)
|
||||
#define BT_HCI_LOG_ADV_BUF_SIZE (1024 * HCI_LOG_ADV_BUFFER_SIZE)
|
||||
|
||||
typedef struct {
|
||||
osi_mutex_t mutex_lock;
|
||||
uint64_t log_record_in;
|
||||
uint64_t log_record_out;
|
||||
uint64_t buf_size;
|
||||
uint8_t *p_hci_log_buffer;
|
||||
uint8_t index;
|
||||
bool overflow;
|
||||
} bt_hci_log_t;
|
||||
|
||||
static const char s_hex_to_char_mapping[16] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
bt_hci_log_t g_bt_hci_log_data_ctl = {0};
|
||||
bt_hci_log_t g_bt_hci_log_adv_ctl = {0};
|
||||
|
||||
esp_err_t bt_hci_log_init(void)
|
||||
{
|
||||
uint8_t *g_bt_hci_log_data_buffer = NULL;
|
||||
uint8_t *g_bt_hci_log_adv_buffer = NULL;
|
||||
|
||||
g_bt_hci_log_data_buffer = malloc(BT_HCI_LOG_DATA_BUF_SIZE);
|
||||
if (!g_bt_hci_log_data_buffer) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
g_bt_hci_log_adv_buffer = malloc(BT_HCI_LOG_ADV_BUF_SIZE);
|
||||
if (!g_bt_hci_log_adv_buffer) {
|
||||
if (g_bt_hci_log_data_buffer) {
|
||||
free(g_bt_hci_log_data_buffer);
|
||||
g_bt_hci_log_data_buffer = NULL;
|
||||
}
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
memset(g_bt_hci_log_data_buffer, 0, BT_HCI_LOG_DATA_BUF_SIZE);
|
||||
memset(g_bt_hci_log_adv_buffer, 0, BT_HCI_LOG_ADV_BUF_SIZE);
|
||||
|
||||
memset(&g_bt_hci_log_data_ctl, 0, sizeof(bt_hci_log_t));
|
||||
g_bt_hci_log_data_ctl.buf_size = BT_HCI_LOG_DATA_BUF_SIZE;
|
||||
g_bt_hci_log_data_ctl.p_hci_log_buffer = g_bt_hci_log_data_buffer;
|
||||
|
||||
memset(&g_bt_hci_log_adv_ctl, 0, sizeof(bt_hci_log_t));
|
||||
g_bt_hci_log_adv_ctl.buf_size = BT_HCI_LOG_ADV_BUF_SIZE;
|
||||
g_bt_hci_log_adv_ctl.p_hci_log_buffer = g_bt_hci_log_adv_buffer;
|
||||
|
||||
osi_mutex_new((osi_mutex_t *)&g_bt_hci_log_data_ctl.mutex_lock);
|
||||
osi_mutex_new((osi_mutex_t *)&g_bt_hci_log_adv_ctl.mutex_lock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bt_hci_log_deinit(void)
|
||||
{
|
||||
if (g_bt_hci_log_data_ctl.p_hci_log_buffer) {
|
||||
free(g_bt_hci_log_data_ctl.p_hci_log_buffer);
|
||||
g_bt_hci_log_data_ctl.p_hci_log_buffer = NULL;
|
||||
}
|
||||
|
||||
if (g_bt_hci_log_adv_ctl.p_hci_log_buffer) {
|
||||
free(g_bt_hci_log_adv_ctl.p_hci_log_buffer);
|
||||
g_bt_hci_log_adv_ctl.p_hci_log_buffer = NULL;
|
||||
}
|
||||
|
||||
osi_mutex_free((osi_mutex_t *)&g_bt_hci_log_data_ctl.mutex_lock);
|
||||
osi_mutex_free((osi_mutex_t *)&g_bt_hci_log_adv_ctl.mutex_lock);
|
||||
|
||||
memset(&g_bt_hci_log_data_ctl, 0, sizeof(bt_hci_log_t));
|
||||
memset(&g_bt_hci_log_adv_ctl, 0, sizeof(bt_hci_log_t));
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if (BT_HCI_LOG_PRINT_TAG)
|
||||
static char IRAM_ATTR *bt_data_type_to_str(uint8_t data_type)
|
||||
{
|
||||
char *tag = NULL;
|
||||
switch (data_type)
|
||||
{
|
||||
case HCI_LOG_DATA_TYPE_COMMAND:
|
||||
// hci cmd data
|
||||
tag = "CMD";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_H2C_ACL:
|
||||
// host to controller hci acl data
|
||||
tag = "HAL";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_SCO:
|
||||
// hci sco data
|
||||
tag = "SCO";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_EVENT:
|
||||
// hci event
|
||||
tag = "EVT";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_ADV:
|
||||
// controller adv report data
|
||||
tag = "ADV";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_C2H_ACL:
|
||||
// controller to host hci acl data
|
||||
tag = "CAL";
|
||||
break;
|
||||
case HCI_LOG_DATA_TYPE_SELF_DEFINE:
|
||||
// self-defining data
|
||||
tag = "ST";
|
||||
break;
|
||||
default:
|
||||
// unknown data type
|
||||
tag = "UK";
|
||||
break;
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
#endif
|
||||
|
||||
void bt_hci_log_record_hex(bt_hci_log_t *p_hci_log_ctl, uint8_t *hex, uint8_t hex_len)
|
||||
{
|
||||
uint8_t hci_log_char;
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
while (hex_len--)
|
||||
{
|
||||
hci_log_char = ((*hex) >> 4);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = s_hex_to_char_mapping [hci_log_char];
|
||||
|
||||
if (++ p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
hci_log_char = ((*hex) & 0x0f);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = s_hex_to_char_mapping [hci_log_char];
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = ' ';
|
||||
|
||||
if (++ p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
++ hex;
|
||||
}
|
||||
}
|
||||
|
||||
void bt_hci_log_record_string(bt_hci_log_t *p_hci_log_ctl, char *string)
|
||||
{
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
while (*string != '\0') {
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = *string;
|
||||
++string;
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_data(bt_hci_log_t *p_hci_log_ctl, char *str, uint8_t data_type, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
osi_mutex_t mutex_lock;
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
if (!p_hci_log_ctl->p_hci_log_buffer) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
if (!g_hci_log_buffer) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
mutex_lock = p_hci_log_ctl->mutex_lock;
|
||||
osi_mutex_lock(&mutex_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
#if (1)
|
||||
// Add hci data index
|
||||
bt_hci_log_record_hex(p_hci_log_ctl, &p_hci_log_ctl->index, 1);
|
||||
#endif
|
||||
|
||||
#if (BT_HCI_LOG_PRINT_TAG)
|
||||
char *tag = NULL;
|
||||
tag = bt_data_type_to_str(data_type);
|
||||
|
||||
if (tag) {
|
||||
bt_hci_log_record_string(p_hci_log_ctl, tag);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = ':';
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (str) {
|
||||
bt_hci_log_record_string(p_hci_log_ctl, str);
|
||||
}
|
||||
|
||||
bt_hci_log_record_hex(p_hci_log_ctl, data, data_len);
|
||||
|
||||
g_hci_log_buffer[p_hci_log_ctl->log_record_in] = '\n';
|
||||
|
||||
if (++p_hci_log_ctl->log_record_in >= p_hci_log_ctl->buf_size) {
|
||||
p_hci_log_ctl->log_record_in = 0;
|
||||
}
|
||||
|
||||
if (p_hci_log_ctl->log_record_in == p_hci_log_ctl->log_record_out) {
|
||||
p_hci_log_ctl->overflow = true;
|
||||
}
|
||||
|
||||
p_hci_log_ctl->index ++;
|
||||
|
||||
osi_mutex_unlock(&mutex_lock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void bt_hci_log_data_show(bt_hci_log_t *p_hci_log_ctl)
|
||||
{
|
||||
volatile uint64_t log_record_in,log_record_out;
|
||||
uint8_t *g_hci_log_buffer;
|
||||
|
||||
if (!p_hci_log_ctl->p_hci_log_buffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
osi_mutex_t mutex_lock = p_hci_log_ctl->mutex_lock;
|
||||
|
||||
osi_mutex_lock(&mutex_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
log_record_in = p_hci_log_ctl->log_record_in;
|
||||
log_record_out = p_hci_log_ctl->log_record_out;
|
||||
|
||||
g_hci_log_buffer = p_hci_log_ctl->p_hci_log_buffer;
|
||||
|
||||
if (p_hci_log_ctl->overflow) {
|
||||
log_record_out = log_record_in;
|
||||
printf("%c",g_hci_log_buffer[log_record_out]);
|
||||
|
||||
if (++log_record_out >= p_hci_log_ctl->buf_size) {
|
||||
log_record_out = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while (log_record_in != log_record_out)
|
||||
{
|
||||
printf("%c",g_hci_log_buffer[log_record_out]);
|
||||
|
||||
if (++log_record_out >= p_hci_log_ctl->buf_size) {
|
||||
log_record_out = 0;
|
||||
}
|
||||
}
|
||||
|
||||
p_hci_log_ctl->log_record_out = log_record_out;
|
||||
p_hci_log_ctl->overflow = false;
|
||||
|
||||
osi_mutex_unlock(&mutex_lock);
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_hci_data(uint8_t data_type, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
return bt_hci_log_record_data(&g_bt_hci_log_data_ctl, NULL, data_type, data, data_len);
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_custom_data(char *string, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
return bt_hci_log_record_data(&g_bt_hci_log_data_ctl, string, HCI_LOG_DATA_TYPE_SELF_DEFINE, data, data_len);
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bt_hci_log_record_hci_adv(uint8_t data_type, uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
return bt_hci_log_record_data(&g_bt_hci_log_adv_ctl, NULL, data_type, data, data_len);
|
||||
}
|
||||
|
||||
void bt_hci_log_hci_data_show(void)
|
||||
{
|
||||
bt_hci_log_data_show(&g_bt_hci_log_data_ctl);
|
||||
}
|
||||
|
||||
void bt_hci_log_hci_adv_show(void)
|
||||
{
|
||||
bt_hci_log_data_show(&g_bt_hci_log_adv_ctl);
|
||||
}
|
||||
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
108
components/bt/common/hci_log/include/hci_log/bt_hci_log.h
Normal file
108
components/bt/common/hci_log/include/hci_log/bt_hci_log.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_BT_HCI_LOG_H__
|
||||
#define __ESP_BT_HCI_LOG_H__
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define HCI_LOG_DATA_TYPE_COMMAND (1)
|
||||
#define HCI_LOG_DATA_TYPE_H2C_ACL (2)
|
||||
#define HCI_LOG_DATA_TYPE_SCO (3)
|
||||
#define HCI_LOG_DATA_TYPE_EVENT (4)
|
||||
#define HCI_LOG_DATA_TYPE_ADV (5)
|
||||
#define HCI_LOG_DATA_TYPE_SELF_DEFINE (6)
|
||||
#define HCI_LOG_DATA_TYPE_C2H_ACL (7)
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to record self-defining data
|
||||
* @param string : data identification
|
||||
* @param data : data
|
||||
* @param data_len : the length of data
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_record_custom_data(char *string, uint8_t *data, uint8_t data_len);
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to print all hci data record
|
||||
*
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void bt_hci_log_hci_data_show(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to print all adv report
|
||||
*
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void bt_hci_log_hci_adv_show(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to init hci log env
|
||||
*
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_init(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to deinit hci debug mode,
|
||||
* and can only be called internally by Bluetooth
|
||||
*
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to record hci data without adv report event,
|
||||
* and can only be called internally by Bluetooth
|
||||
*
|
||||
* @param str : data type, define in bt_data_type_to_str()
|
||||
* @param data : data
|
||||
* @param data_len : the length of data
|
||||
*
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_record_hci_data(uint8_t data_type, uint8_t *data, uint8_t data_len);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief This function is called to record hci adv report event only
|
||||
* and can only be called internally by Bluetooth
|
||||
*
|
||||
* @param str : data type, define in bt_data_type_to_str()
|
||||
* @param data : data
|
||||
* @param data_len : the length of data
|
||||
* @return ESP_OK - success, other - failed
|
||||
*
|
||||
*/
|
||||
esp_err_t bt_hci_log_record_hci_adv(uint8_t data_type, uint8_t *data, uint8_t data_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BT_HCI_LOG_H__ */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -64,6 +64,24 @@
|
||||
#define BT_BLE_DYNAMIC_ENV_MEMORY FALSE
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_LOG_DEBUG_EN
|
||||
#define BT_HCI_LOG_INCLUDED UC_BT_HCI_LOG_DEBUG_EN
|
||||
#else
|
||||
#define BT_HCI_LOG_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define HCI_LOG_DATA_BUFFER_SIZE UC_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
#define HCI_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
#if UC_BT_HCI_ADV_BUFFER_SIZE
|
||||
#define HCI_LOG_ADV_BUFFER_SIZE UC_BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
#else
|
||||
#define HCI_LOG_ADV_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
/* OS Configuration from User config (eg: sdkconfig) */
|
||||
#define TASK_PINNED_TO_CORE UC_TASK_PINNED_TO_CORE
|
||||
#define BT_TASK_MAX_PRIORITIES configMAX_PRIORITIES
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -50,6 +50,15 @@
|
||||
#define UC_BTC_TASK_STACK_SIZE 4096
|
||||
#endif
|
||||
|
||||
/**********************************************************
|
||||
* Alarm reference
|
||||
**********************************************************/
|
||||
#ifdef CONFIG_BT_ALARM_MAX_NUM
|
||||
#define UC_ALARM_MAX_NUM CONFIG_BT_ALARM_MAX_NUM
|
||||
#else
|
||||
#define UC_ALARM_MAX_NUM 50
|
||||
#endif
|
||||
|
||||
/**********************************************************
|
||||
* Trace reference
|
||||
**********************************************************/
|
||||
@@ -98,4 +107,22 @@
|
||||
#define UC_BT_BLUEDROID_MEM_DEBUG FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_DEBUG_EN
|
||||
#define UC_BT_HCI_LOG_DEBUG_EN TRUE
|
||||
#else
|
||||
#define UC_BT_HCI_LOG_DEBUG_EN FALSE
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
|
||||
#else
|
||||
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
#define UC_BT_HCI_LOG_ADV_BUFFER_SIZE CONFIG_BT_HCI_LOG_ADV_BUFFER_SIZE
|
||||
#else
|
||||
#define UC_BT_HCI_LOG_ADV_BUFFER_SIZE (5)
|
||||
#endif
|
||||
|
||||
#endif /* __BT_USER_CONFIG_H__ */
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_timer.h"
|
||||
#include "bt_user_config.h"
|
||||
|
||||
typedef struct alarm_t osi_alarm_t;
|
||||
typedef uint64_t period_ms_t;
|
||||
@@ -33,7 +34,7 @@ typedef enum {
|
||||
OSI_ALARM_ERR_INVALID_STATE = -3,
|
||||
} osi_alarm_err_t;
|
||||
|
||||
#define ALARM_CBS_NUM 50
|
||||
#define ALARM_CBS_NUM UC_ALARM_MAX_NUM
|
||||
#define ALARM_ID_BASE 1000
|
||||
|
||||
int osi_alarm_create_mux(void);
|
||||
|
||||
@@ -172,7 +172,7 @@ config BTDM_CTRL_PINNED_TO_CORE
|
||||
choice BTDM_CTRL_HCI_MODE_CHOICE
|
||||
prompt "HCI mode"
|
||||
help
|
||||
Speicify HCI mode as VHCI or UART(H4)
|
||||
Specify HCI mode as VHCI or UART(H4)
|
||||
|
||||
config BTDM_CTRL_HCI_MODE_VHCI
|
||||
bool "VHCI"
|
||||
@@ -398,6 +398,14 @@ config BTDM_CTRL_FULL_SCAN_SUPPORTED
|
||||
The full scan function is mainly used to provide BLE scan performance.
|
||||
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
|
||||
|
||||
config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
bool "Disable active scan backoff"
|
||||
default n
|
||||
help
|
||||
Disable active scan backoff. The bluetooth spec requires that scanners should run a backoff procedure to
|
||||
minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active
|
||||
scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU.
|
||||
|
||||
config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010004
|
||||
#define OSI_VERSION 0x00010005
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
@@ -176,6 +176,7 @@ struct osi_funcs_t {
|
||||
void (*_interrupt_l3_restore)(void);
|
||||
void *(* _customer_queue_create)(uint32_t queue_len, uint32_t item_size);
|
||||
int (* _coex_version_get)(unsigned int *major, unsigned int *minor, unsigned int *patch);
|
||||
void (* _patch_apply)(void);
|
||||
uint32_t _magic;
|
||||
};
|
||||
|
||||
@@ -232,16 +233,16 @@ extern uint32_t _data_end_btdm_rom;
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _nimble_bss_start;
|
||||
extern uint32_t _nimble_bss_end;
|
||||
extern uint32_t _btdm_bss_start;
|
||||
extern uint32_t _btdm_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
extern uint32_t _bt_controller_bss_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
extern uint32_t _nimble_data_start;
|
||||
extern uint32_t _nimble_data_end;
|
||||
extern uint32_t _btdm_data_start;
|
||||
extern uint32_t _btdm_data_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
extern uint32_t _bt_controller_data_end;
|
||||
|
||||
extern void config_bt_funcs_reset(void);
|
||||
extern void config_ble_funcs_reset(void);
|
||||
extern void config_btdm_funcs_reset(void);
|
||||
|
||||
/* Local Function Declare
|
||||
*********************************************************************
|
||||
@@ -315,6 +316,7 @@ static void *customer_queue_create_hlevel_wrapper(uint32_t queue_len, uint32_t i
|
||||
static void interrupt_l3_disable(void);
|
||||
static void interrupt_l3_restore(void);
|
||||
static void bt_controller_deinit_internal(void);
|
||||
static void patch_apply(void);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@@ -402,6 +404,7 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._customer_queue_create = NULL,
|
||||
#endif /* CONFIG_BTDM_CTRL_HLI */
|
||||
._coex_version_get = coex_version_get_wrapper,
|
||||
._patch_apply = patch_apply,
|
||||
._magic = OSI_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
@@ -753,7 +756,7 @@ static int32_t queue_send_hlevel_wrapper(void *queue, void *item, uint32_t block
|
||||
* @param item The message which will be send
|
||||
* @param hptw need do task yield or not
|
||||
* @return send success or not
|
||||
* There is an issue here: When the queue is full, it may reture true but it send fail to the queue, sometimes.
|
||||
* There is an issue here: When the queue is full, it may return true but it send fail to the queue, sometimes.
|
||||
* But in Bluetooth controller's isr, We don't care about the return value.
|
||||
* It only required tp send success when the queue is empty all the time.
|
||||
* So, this function meets the requirement.
|
||||
@@ -1274,7 +1277,45 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
bool update = true;
|
||||
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
||||
@@ -1325,61 +1366,86 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == ESP_BT_MODE_BTDM) {
|
||||
mem_start = (intptr_t)&_btdm_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BTDM BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_btdm_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BTDM Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (mode == ESP_BT_MODE_BTDM) {
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
ret = esp_bt_mem_release_areas(&cont_data, &cont_bss);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret = esp_bt_controller_mem_release(mode);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode == ESP_BT_MODE_BTDM) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_nimble_bss_start;
|
||||
mem_end = (intptr_t)&_nimble_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
mem_start = (intptr_t)&_nimble_data_start;
|
||||
mem_end = (intptr_t)&_nimble_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BTDM_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
/* free data and BSS section for Bluetooth controller ROM code */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BTDM_CTRL_HLI
|
||||
@@ -1643,6 +1709,18 @@ static void bt_shutdown(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static void patch_apply(void)
|
||||
{
|
||||
config_btdm_funcs_reset();
|
||||
|
||||
#ifndef CONFIG_BTDM_CTRL_MODE_BLE_ONLY
|
||||
config_bt_funcs_reset();
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY
|
||||
config_ble_funcs_reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
@@ -1676,7 +1754,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
|
||||
sdk_config_set_bt_pll_track_enable(true);
|
||||
|
||||
// inititalize bluetooth baseband
|
||||
// initialize bluetooth baseband
|
||||
btdm_check_and_init_bb();
|
||||
|
||||
ret = btdm_controller_enable(mode);
|
||||
@@ -1839,7 +1917,7 @@ esp_err_t esp_ble_scan_dupilcate_list_flush(void)
|
||||
|
||||
/**
|
||||
* This function re-write controller's function,
|
||||
* As coredump can not show paramerters in function which is in a .a file.
|
||||
* As coredump can not show parameters in function which is in a .a file.
|
||||
*
|
||||
* After coredump fixing this issue, just delete this function.
|
||||
*/
|
||||
|
||||
@@ -147,7 +147,7 @@ if BT_LE_EXT_ADV
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
@@ -421,6 +421,26 @@ config BT_LE_SLEEP_ENABLE
|
||||
help
|
||||
Enable BLE sleep
|
||||
|
||||
choice BT_LE_LP_CLK_SRC
|
||||
prompt "BLE low power clock source"
|
||||
default BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
config BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
bool "Use main XTAL as RTC clock source"
|
||||
help
|
||||
User main XTAL as RTC clock source.
|
||||
This option is recommended if external 32.768k XTAL is not available.
|
||||
Using the external 32.768 kHz XTAL will have lower current consumption
|
||||
in light sleep compared to using the main XTAL.
|
||||
|
||||
config BT_LE_LP_CLK_SRC_DEFAULT
|
||||
bool "Use system RTC slow clock source"
|
||||
help
|
||||
Use the same slow clock source as system RTC
|
||||
Using any clock source other than external 32.768 kHz XTAL at pin0 supports only
|
||||
legacy ADV and SCAN due to low clock accuracy.
|
||||
|
||||
endchoice
|
||||
|
||||
config BT_LE_USE_ESP_TIMER
|
||||
bool "Use Esp Timer for callout"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
@@ -430,6 +450,7 @@ config BT_LE_USE_ESP_TIMER
|
||||
|
||||
config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on BT_LE_ROLE_OBSERVER_ENABLE
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
@@ -464,3 +485,45 @@ config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
config BT_LE_RELEASE_IRAM_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
config BT_LE_ROLE_CENTROL_ENABLE
|
||||
bool "Enable BLE Centrol role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable centrol role function.
|
||||
|
||||
config BT_LE_ROLE_PERIPHERAL_ENABLE
|
||||
bool "Enable BLE Peripheral role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable Peripheral role function.
|
||||
|
||||
config BT_LE_ROLE_BROADCASTER_ENABLE
|
||||
bool "Enable BLE Broadcaster role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable broadcaster role function.
|
||||
|
||||
config BT_LE_ROLE_OBSERVER_ENABLE
|
||||
bool "Enable BLE Observer role function"
|
||||
depends on !BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Enable observer role function.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -54,12 +54,14 @@
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#include "soc/syscon_reg.h"
|
||||
#include "soc/dport_access.h"
|
||||
|
||||
#include "hal/efuse_ll.h"
|
||||
#include "soc/rtc.h"
|
||||
/* Macro definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -78,6 +80,11 @@
|
||||
#define ACL_DATA_MBUF_LEADINGSPCAE 4
|
||||
#endif // CONFIG_BT_BLUEDROID_ENABLED
|
||||
|
||||
typedef enum ble_rtc_slow_clk_src {
|
||||
BT_SLOW_CLK_SRC_MAIN_XTAL,
|
||||
BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0,
|
||||
} ble_rtc_slow_clk_src_t;
|
||||
|
||||
/* Types definition
|
||||
************************************************************************
|
||||
*/
|
||||
@@ -156,15 +163,22 @@ extern int ble_txpwr_set(esp_ble_enhanced_power_type_t power_type, uint16_t hand
|
||||
extern int ble_txpwr_get(esp_ble_enhanced_power_type_t power_type, uint16_t handle);
|
||||
extern int ble_get_npl_element_info(esp_bt_controller_config_t *cfg, ble_npl_count_info_t * npl_info);
|
||||
extern void bt_track_pll_cap(void);
|
||||
|
||||
extern char *ble_controller_get_compile_version(void);
|
||||
extern const char *r_ble_controller_get_rom_compile_version(void);
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
extern uint32_t _iram_bt_text_start;
|
||||
extern uint32_t _bss_bt_end;
|
||||
#else
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
#endif
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
extern uint32_t _bt_controller_bss_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
extern uint32_t _bt_controller_data_end;
|
||||
|
||||
/* Local Function Declaration
|
||||
*********************************************************************
|
||||
*/
|
||||
@@ -486,7 +500,7 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
s_ble_active = true;
|
||||
}
|
||||
|
||||
esp_err_t controller_sleep_init(void)
|
||||
esp_err_t controller_sleep_init(ble_rtc_slow_clk_src_t slow_clk_src)
|
||||
{
|
||||
esp_err_t rc = 0;
|
||||
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
|
||||
@@ -494,7 +508,11 @@ esp_err_t controller_sleep_init(void)
|
||||
r_ble_lll_rfmgmt_set_sleep_cb(controller_sleep_cb, controller_wakeup_cb, 0, 0, 500 + BLE_RTC_DELAY_US);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||
if (slow_clk_src == BT_SLOW_CLK_SRC_MAIN_XTAL) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON);
|
||||
} else {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
|
||||
}
|
||||
#endif // CONFIG_PM_ENABLE
|
||||
|
||||
#endif // CONFIG_BT_LE_SLEEP_ENABLE
|
||||
@@ -545,37 +563,74 @@ void controller_sleep_deinit(void)
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
}
|
||||
|
||||
void ble_rtc_clk_init(void)
|
||||
static void esp_bt_rtc_slow_clk_select(ble_rtc_slow_clk_src_t slow_clk_src)
|
||||
{
|
||||
// modem_clkrst_reg
|
||||
// LP_TIMER_SEL_XTAL32K -> 0
|
||||
// LP_TIMER_SEL_XTAL -> 1
|
||||
// LP_TIMER_SEL_8M -> 0
|
||||
// LP_TIMER_SEL_RTC_SLOW -> 0
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
|
||||
/* Select slow clock source for BT momdule */
|
||||
switch (slow_clk_src) {
|
||||
case BT_SLOW_CLK_SRC_MAIN_XTAL:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using main XTAL as clock source");
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
// LP_TIMER_CLK_DIV_NUM -> 130
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 129, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 129, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#else
|
||||
// LP_TIMER_CLK_DIV_NUM -> 250
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 249, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 249, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
|
||||
// MODEM_CLKRST_ETM_CLK_ACTIVE -> 1
|
||||
// MODEM_CLKRST_ETM_CLK_SEL -> 0
|
||||
break;
|
||||
case BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0:
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Using external 32.768 kHz XTAL as clock source");
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 1, MODEM_CLKRST_LP_TIMER_SEL_XTAL32K_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_XTAL_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_8M_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, 1, 0, MODEM_CLKRST_LP_TIMER_SEL_RTC_SLOW_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_MODEM_LP_TIMER_CONF_REG, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM, 0, MODEM_CLKRST_LP_TIMER_CLK_DIV_NUM_S);
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "Unsupported slow clock");
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_ETM_CLK_CONF_REG, 1, 1, MODEM_CLKRST_ETM_CLK_ACTIVE_S);
|
||||
SET_PERI_REG_BITS(MODEM_CLKRST_ETM_CLK_CONF_REG, 1, 0, MODEM_CLKRST_ETM_CLK_SEL_S);
|
||||
}
|
||||
|
||||
static ble_rtc_slow_clk_src_t ble_rtc_clk_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
ble_rtc_slow_clk_src_t slow_clk_src;
|
||||
|
||||
#if CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
cfg->rtc_freq = 40000;
|
||||
#else
|
||||
cfg->rtc_freq = 32000;
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
slow_clk_src = BT_SLOW_CLK_SRC_MAIN_XTAL;
|
||||
#else
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) {
|
||||
cfg->rtc_freq = 32768;
|
||||
slow_clk_src = BT_SLOW_CLK_SRC_32K_XTAL_ON_PIN0;
|
||||
} else {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
#ifdef CONFIG_XTAL_FREQ_26
|
||||
cfg->rtc_freq = 40000;
|
||||
#else
|
||||
cfg->rtc_freq = 32000;
|
||||
#endif // CONFIG_XTAL_FREQ_26
|
||||
slow_clk_src = BT_SLOW_CLK_SRC_MAIN_XTAL;
|
||||
}
|
||||
#endif /* CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL */
|
||||
esp_bt_rtc_slow_clk_select(slow_clk_src);
|
||||
return slow_clk_src;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ble_npl_count_info_t npl_info;
|
||||
ble_rtc_slow_clk_src_t rtc_clk_src;
|
||||
|
||||
memset(&npl_info, 0, sizeof(ble_npl_count_info_t));
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state");
|
||||
@@ -587,7 +642,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ble_rtc_clk_init();
|
||||
rtc_clk_src = ble_rtc_clk_init(cfg);
|
||||
|
||||
ret = esp_register_ext_funcs(&ext_funcs_ro);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -595,6 +650,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
extern int esp_ble_rom_func_ptr_init_all(void);
|
||||
esp_ble_rom_func_ptr_init_all();
|
||||
#else
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Init only legacy adv and slave function");
|
||||
extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void);
|
||||
esp_ble_rom_func_ptr_init_legacy_adv_and_slave();
|
||||
#endif
|
||||
|
||||
/* Initialize the function pointers for OS porting */
|
||||
npl_freertos_funcs_init();
|
||||
struct npl_funcs_t *p_npl_funcs = npl_freertos_funcs_get();
|
||||
@@ -643,13 +707,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
#endif
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble rom commit:[%s]", r_ble_controller_get_rom_compile_version());
|
||||
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -671,7 +737,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
|
||||
ret = controller_sleep_init();
|
||||
ret = controller_sleep_init(rtc_clk_src);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret);
|
||||
goto free_controller;
|
||||
@@ -840,9 +906,48 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_BT_RELEASE_IRAM
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if(area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||
/* Release Bluetooth text section and merge Bluetooth data, bss & text into a large free heap
|
||||
@@ -851,26 +956,58 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
* memory into 3 different regions (IRAM, BLE-IRAM, DRAM). So `ESP_SYSTEM_PMP_IDRAM_SPLIT` needs
|
||||
* to be disabled.
|
||||
*/
|
||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "`ESP_SYSTEM_PMP_IDRAM_SPLIT` should be disabled!");
|
||||
assert(0);
|
||||
#error "ESP_SYSTEM_PMP_IDRAM_SPLIT should be disabled to allow BT to be released"
|
||||
#endif // CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
mem_start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start);
|
||||
mem_end = (intptr_t)&_bss_bt_end;
|
||||
#else
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
#endif // CONFIG_BT_RELEASE_IRAM
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Release BLE [0x%08x] - [0x%08x], len %d", mem_start,
|
||||
mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
if ((mode & ESP_BT_MODE_BLE) == 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_RELEASE_IRAM
|
||||
bt_area_t merged_region = {
|
||||
.start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start),
|
||||
.end = (intptr_t)&_bss_bt_end,
|
||||
.name = "BT Text, BSS and Data"
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_region);
|
||||
#else
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -46,6 +46,10 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER MYNEWT_VAL(BLE_ROLE_OBSERVER)
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL MYNEWT_VAL(BLE_ROLE_CENTRAL)
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL MYNEWT_VAL(BLE_ROLE_PERIPHERAL)
|
||||
#define DEFAULT_BT_LE_ROLE_BROADCASTER MYNEWT_VAL(BLE_ROLE_BROADCASTER)
|
||||
#else
|
||||
|
||||
#if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY
|
||||
@@ -57,13 +61,13 @@ extern "C" {
|
||||
#if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1)
|
||||
#define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_MAX_CONNECTIONS)
|
||||
@@ -125,6 +129,29 @@ extern "C" {
|
||||
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_CENTROL_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_CENTROL (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_PERIPHERAL_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_PERIPHERAL (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_BROADCASTER_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_BROADCASTER (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_BROADCASTER (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_LE_ROLE_OBSERVER_ENABLE)
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER (1)
|
||||
#else
|
||||
#define DEFAULT_BT_LE_ROLE_OBSERVER (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF
|
||||
|
||||
@@ -23,7 +23,7 @@ config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
|
||||
default 0
|
||||
help
|
||||
BLE ACL buffer have two methods to be allocated. One is persistent allocating
|
||||
(alloate when controller initialise, never free until controller de-initialise)
|
||||
(allocate when controller initialise, never free until controller de-initialise)
|
||||
another is dynamically allocating (allocate before TX and free after TX).
|
||||
|
||||
choice BT_CTRL_PINNED_TO_CORE_CHOICE
|
||||
@@ -72,11 +72,11 @@ config BT_CTRL_HCI_TL
|
||||
HCI mode as VHCI or UART(H4)
|
||||
|
||||
config BT_CTRL_ADV_DUP_FILT_MAX
|
||||
int "The maxinum number of 5.0 extend duplicate scan filter"
|
||||
int "The maximum number of 5.0 extend duplicate scan filter"
|
||||
range 1 500
|
||||
default 30
|
||||
help
|
||||
The maxinum number of suplicate scan filter
|
||||
The maximum number of suplicate scan filter
|
||||
|
||||
choice BT_BLE_CCA_MODE
|
||||
prompt "BLE CCA mode"
|
||||
@@ -475,3 +475,17 @@ config BT_BLE_ADV_DATA_LENGTH_ZERO_AUX
|
||||
When this option is enabled, auxiliary packets will be present in the events of
|
||||
'Non-Connectable and Non-Scannable' regardless of whether the advertising length is 0.
|
||||
If this option is not enabled, auxiliary packets will only be present when the advertising length is not 0.
|
||||
|
||||
config BT_CTRL_CHAN_ASS_EN
|
||||
bool "Enable channel assessment"
|
||||
default y
|
||||
help
|
||||
If this option is enabled, The Controller will records the communication quality
|
||||
for each channel and then start a timer to check and update the channel map every 4 seconds.
|
||||
|
||||
config BT_CTRL_LE_PING_EN
|
||||
bool "Enable LE Ping procedure"
|
||||
default y
|
||||
help
|
||||
If this option is disabled, The Controller will not start the LE authenticated payload timer.
|
||||
This option is used for some compatibility problems related to LE ping procedure.
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
// wakeup request sources
|
||||
enum {
|
||||
BTDM_ASYNC_WAKEUP_SRC_VHCI = 0,
|
||||
BTDM_ASYNC_WAKEUP_REQ_COEX,
|
||||
BTDM_ASYNC_WAKEUP_SRC_DISA,
|
||||
BTDM_ASYNC_WAKEUP_SRC_TMR,
|
||||
BTDM_ASYNC_WAKEUP_SRC_MAX,
|
||||
@@ -73,12 +74,12 @@ enum {
|
||||
typedef union {
|
||||
struct {
|
||||
uint32_t enable : 1; // whether low power mode is required
|
||||
uint32_t lpclk_sel : 2; // low power clock source
|
||||
uint32_t lpclk_sel : 3; // low power clock source
|
||||
uint32_t mac_bb_pd : 1; // whether hardware(MAC, BB) force-power-down is required during sleep
|
||||
uint32_t wakeup_timer_required : 1; // whether system timer is needed
|
||||
uint32_t no_light_sleep : 1; // do not allow system to enter light sleep after bluetooth is enabled
|
||||
uint32_t main_xtal_pu : 1; // power up main XTAL
|
||||
uint32_t reserved : 25; // reserved
|
||||
uint32_t reserved : 24; // reserved
|
||||
};
|
||||
uint32_t val;
|
||||
} btdm_lpcntl_t;
|
||||
@@ -110,7 +111,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010007
|
||||
#define OSI_VERSION 0x00010008
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* Types definition
|
||||
@@ -184,8 +185,12 @@ struct osi_funcs_t {
|
||||
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
|
||||
void (* _coex_wifi_sleep_set)(bool sleep);
|
||||
int (* _coex_core_ble_conn_dyn_prio_get)(bool *low, bool *high);
|
||||
int (* _coex_schm_register_btdm_callback)(void *callback);
|
||||
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
|
||||
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
|
||||
uint32_t (* _coex_schm_interval_get)(void);
|
||||
uint8_t (* _coex_schm_curr_period_get)(void);
|
||||
void *(* _coex_schm_curr_phase_get)(void);
|
||||
void (* _interrupt_on)(int intr_num);
|
||||
void (* _interrupt_off)(int intr_num);
|
||||
void (* _esp_hw_power_down)(void);
|
||||
@@ -193,6 +198,8 @@ struct osi_funcs_t {
|
||||
void (* _ets_backup_dma_copy)(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_rem);
|
||||
void (* _ets_delay_us)(uint32_t us);
|
||||
void (* _btdm_rom_table_ready)(void);
|
||||
bool (* _coex_bt_wakeup_request)(void);
|
||||
void (* _coex_bt_wakeup_request_end)(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -256,16 +263,12 @@ extern void btdm_cca_feature_enable(void);
|
||||
|
||||
extern uint32_t _bt_bss_start;
|
||||
extern uint32_t _bt_bss_end;
|
||||
extern uint32_t _btdm_bss_start;
|
||||
extern uint32_t _btdm_bss_end;
|
||||
extern uint32_t _nimble_bss_start;
|
||||
extern uint32_t _nimble_bss_end;
|
||||
extern uint32_t _bt_controller_bss_start;
|
||||
extern uint32_t _bt_controller_bss_end;
|
||||
extern uint32_t _bt_data_start;
|
||||
extern uint32_t _bt_data_end;
|
||||
extern uint32_t _btdm_data_start;
|
||||
extern uint32_t _btdm_data_end;
|
||||
extern uint32_t _nimble_data_start;
|
||||
extern uint32_t _nimble_data_end;
|
||||
extern uint32_t _bt_controller_data_start;
|
||||
extern uint32_t _bt_controller_data_end;
|
||||
|
||||
/* Local Function Declare
|
||||
*********************************************************************
|
||||
@@ -306,14 +309,20 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
|
||||
static void btdm_sleep_enter_phase2_wrapper(void);
|
||||
static void btdm_sleep_exit_phase3_wrapper(void);
|
||||
static void coex_wifi_sleep_set_hook(bool sleep);
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback);
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
|
||||
static uint32_t coex_schm_interval_get_wrapper(void);
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void);
|
||||
static void * coex_schm_curr_phase_get_wrapper(void);
|
||||
static void interrupt_on_wrapper(int intr_num);
|
||||
static void interrupt_off_wrapper(int intr_num);
|
||||
static void btdm_hw_mac_power_up_wrapper(void);
|
||||
static void btdm_hw_mac_power_down_wrapper(void);
|
||||
static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32_t num, bool to_mem);
|
||||
static void btdm_funcs_table_ready_wrapper(void);
|
||||
static bool coex_bt_wakeup_request(void);
|
||||
static void coex_bt_wakeup_request_end(void);
|
||||
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
|
||||
@@ -371,8 +380,12 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
|
||||
._coex_wifi_sleep_set = coex_wifi_sleep_set_hook,
|
||||
._coex_core_ble_conn_dyn_prio_get = NULL,
|
||||
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
|
||||
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
|
||||
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
|
||||
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
|
||||
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
|
||||
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
|
||||
._interrupt_on = interrupt_on_wrapper,
|
||||
._interrupt_off = interrupt_off_wrapper,
|
||||
._esp_hw_power_down = btdm_hw_mac_power_down_wrapper,
|
||||
@@ -380,6 +393,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._ets_backup_dma_copy = btdm_backup_dma_copy_wrapper,
|
||||
._ets_delay_us = esp_rom_delay_us,
|
||||
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
|
||||
._coex_bt_wakeup_request = coex_bt_wakeup_request,
|
||||
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
|
||||
};
|
||||
|
||||
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
|
||||
@@ -400,7 +415,7 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0;
|
||||
// semaphore used for blocking VHCI API to wait for controller to wake up
|
||||
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
|
||||
// wakeup timer
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr = NULL;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
|
||||
@@ -853,6 +868,22 @@ static bool async_wakeup_request(int event)
|
||||
semphr_take_wrapper(s_wakeup_req_sem, OSI_FUNCS_TIME_BLOCKING);
|
||||
}
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
if (!btdm_power_state_active()) {
|
||||
do_wakeup_request = true;
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (s_lp_stat.pm_lock_released) {
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_wakeup_request();
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required && s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -872,6 +903,9 @@ static void async_wakeup_request_end(int event)
|
||||
case BTDM_ASYNC_WAKEUP_SRC_DISA:
|
||||
allow_to_sleep = true;
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
allow_to_sleep = false;
|
||||
break;
|
||||
default:
|
||||
allow_to_sleep = true;
|
||||
break;
|
||||
@@ -891,18 +925,25 @@ static void btdm_funcs_table_ready_wrapper(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
bool bt_async_wakeup_request(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_SRC_VHCI);
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
void bt_wakeup_request_end(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_SRC_VHCI);
|
||||
}
|
||||
|
||||
static bool coex_bt_wakeup_request(void)
|
||||
{
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
}
|
||||
|
||||
static void coex_bt_wakeup_request_end(void)
|
||||
{
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
return;
|
||||
}
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
@@ -939,145 +980,175 @@ static void btdm_controller_mem_init(void)
|
||||
btdm_controller_rom_data_init();
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
/**
|
||||
* Release two memory areas to the heap. If both areas are consecutive, they will be released as
|
||||
* a single area.
|
||||
*/
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* if the addresses of rom btdm .data and .bss are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(ets_rom_layout_p->data_end_btdm == ets_rom_layout_p->bss_start_btdm) {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->bss_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->data_end_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
/* if the addresses of rom interface btdm .data and .bss are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(ets_rom_layout_p->data_end_interface_btdm == ets_rom_layout_p->bss_start_interface_btdm) {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)ets_rom_layout_p->data_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->data_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)ets_rom_layout_p->bss_start_interface_btdm;
|
||||
mem_end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release rom interface btdm BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
bt_area_t rom_btdm_data = {
|
||||
.start = (intptr_t) ets_rom_layout_p->data_start_btdm,
|
||||
.end = (intptr_t) ets_rom_layout_p->data_end_btdm,
|
||||
.name = "ROM btdm data",
|
||||
};
|
||||
bt_area_t rom_btdm_bss = {
|
||||
.start = (intptr_t)ets_rom_layout_p->bss_start_btdm,
|
||||
.end = (intptr_t)ets_rom_layout_p->bss_end_btdm,
|
||||
.name = "ROM btdm BSS",
|
||||
};
|
||||
bt_area_t rom_btdm_inter_data = {
|
||||
.start = (intptr_t) ets_rom_layout_p->data_start_interface_btdm,
|
||||
.end = (intptr_t) ets_rom_layout_p->data_end_interface_btdm,
|
||||
.name = "ROM interface btdm data",
|
||||
};
|
||||
bt_area_t rom_btdm_inter_bss = {
|
||||
.start = (intptr_t)ets_rom_layout_p->bss_start_interface_btdm,
|
||||
.end = (intptr_t)ets_rom_layout_p->bss_end_interface_btdm,
|
||||
.name = "ROM interface btdm BSS",
|
||||
};
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
ret = ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* Free BTDM memory used by the ROM */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&rom_btdm_data, &rom_btdm_bss);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&rom_btdm_inter_data, &rom_btdm_inter_bss);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* free data and BSS section for libbtdm_app.a */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&cont_data, &cont_bss);
|
||||
}
|
||||
/* free data and BSS section for Bluetooth controller ROM code */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
ret = esp_bt_controller_mem_release(mode);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* if the addresses of btdm .bss and bt .bss are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_bss_end == _btdm_bss_start) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_btdm_bss_start;
|
||||
mem_end = (intptr_t)&_btdm_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BTDM BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
}
|
||||
/* if the addresses of btdm .data and bt .data are consecutive,
|
||||
they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_data_end == _btdm_data_start) {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_btdm_data_start;
|
||||
mem_end = (intptr_t)&_btdm_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release BTDM Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_nimble_bss_start;
|
||||
mem_end = (intptr_t)&_nimble_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release NimBLE BSS [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
mem_start = (intptr_t)&_nimble_data_start;
|
||||
mem_end = (intptr_t)&_nimble_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(BT_LOG_TAG, "Release NimBLE Data [0x%08x] - [0x%08x], len %d", mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
|
||||
/* free data and BSS section for Bluetooth controller ROM code */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_controller_rom_mem_release(mode);
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
@@ -1112,6 +1183,147 @@ static void IRAM_ATTR btdm_mac_bb_power_up_cb(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
// init low-power control resources
|
||||
static esp_err_t btdm_low_power_mode_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
do {
|
||||
// set default values for global states or resources
|
||||
s_lp_stat.val = 0;
|
||||
s_lp_cntl.val = 0;
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
s_wakeup_req_sem = NULL;
|
||||
s_btdm_slp_tmr = NULL;
|
||||
|
||||
// configure and initialize resources
|
||||
s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0;
|
||||
s_lp_cntl.lpclk_sel = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? cfg->sleep_clock : ESP_BT_SLEEP_CLOCK_MAIN_XTAL;
|
||||
s_lp_cntl.no_light_sleep = 0;
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (!btdm_deep_sleep_mem_init()) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
break;
|
||||
}
|
||||
s_lp_cntl.mac_bb_pd = 1;
|
||||
#endif
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_lp_cntl.wakeup_timer_required = 1;
|
||||
#endif
|
||||
// async wakeup semaphore for VHCI
|
||||
s_wakeup_req_sem = semphr_create_wrapper(1, 0);
|
||||
if (s_wakeup_req_sem == NULL) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
break;
|
||||
}
|
||||
btdm_vnd_offload_task_register(BTDM_VND_OL_SIG_WAKEUP_TMR, btdm_sleep_exit_phase0);
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp",
|
||||
};
|
||||
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// set default bluetooth sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) { // External 32 kHz XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() != SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
ESP_LOGW(BT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
s_lp_cntl.lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL;
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) { // Internal 136kHz RC oscillator
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) {
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 136kHz RC oscillator. The accuracy of this clock is a lot larger than 500ppm which is "
|
||||
"required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state.");
|
||||
} else {
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 136kHz RC oscillator not detected.");
|
||||
assert(0);
|
||||
}
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
ESP_LOGI(BT_LOG_TAG, "Bluetooth will use main XTAL as Bluetooth sleep clock.");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
}
|
||||
|
||||
bool select_src_ret __attribute__((unused));
|
||||
bool set_div_ret __attribute__((unused));
|
||||
if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON));
|
||||
s_lp_cntl.main_xtal_pu = 1;
|
||||
#endif
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() / MHZ);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 1 << (btdm_lpcycle_us_frac);
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
} else if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_RTC_SLOW) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = esp_clk_slowclk_cal_get();
|
||||
} else {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
break;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
break;
|
||||
}
|
||||
ESP_LOGW(BT_LOG_TAG, "light sleep mode will not be able to apply when bluetooth is enabled.");
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
break;
|
||||
} else {
|
||||
s_lp_stat.pm_lock_released = 1;
|
||||
}
|
||||
#endif
|
||||
} while (0);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void)
|
||||
{
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED &&
|
||||
btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
return ESP_BT_SLEEP_CLOCK_NONE;
|
||||
}
|
||||
|
||||
return s_lp_cntl.lpclk_sel;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
{
|
||||
esp_err_t err = ESP_FAIL;
|
||||
@@ -1147,6 +1359,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
ESP_LOGE(BT_LOG_TAG, "SLEEP_MODE_1 enabled but sleep clock not configured");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (cfg->sleep_clock > ESP_BT_SLEEP_CLOCK_RTC_SLOW) {
|
||||
ESP_LOGE(BT_LOG_TAG, "SLEEP_MODE_1 is enabled but this sleep clock is not supported");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
// overwrite some parameters
|
||||
@@ -1172,133 +1388,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
ESP_LOGI(BT_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version());
|
||||
|
||||
// init low-power control resources
|
||||
do {
|
||||
// set default values for global states or resources
|
||||
s_lp_stat.val = 0;
|
||||
s_lp_cntl.val = 0;
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
s_wakeup_req_sem = NULL;
|
||||
s_btdm_slp_tmr = NULL;
|
||||
|
||||
// configure and initialize resources
|
||||
s_lp_cntl.enable = (cfg->sleep_mode == ESP_BT_SLEEP_MODE_1) ? 1 : 0;
|
||||
s_lp_cntl.no_light_sleep = 0;
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (!btdm_deep_sleep_mem_init()) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
s_lp_cntl.mac_bb_pd = 1;
|
||||
#endif
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_lp_cntl.wakeup_timer_required = 1;
|
||||
#endif
|
||||
// async wakeup semaphore for VHCI
|
||||
s_wakeup_req_sem = semphr_create_wrapper(1, 0);
|
||||
if (s_wakeup_req_sem == NULL) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
btdm_vnd_offload_task_register(BTDM_VND_OL_SIG_WAKEUP_TMR, btdm_sleep_exit_phase0);
|
||||
}
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
esp_timer_create_args_t create_args = {
|
||||
.callback = btdm_slp_tmr_callback,
|
||||
.arg = NULL,
|
||||
.name = "btSlp",
|
||||
};
|
||||
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
// set default bluetooth sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
// set default bluetooth sleep clock source
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#if CONFIG_BT_CTRL_LPCLK_SEL_EXT_32K_XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32 kHz XTAL
|
||||
} else {
|
||||
ESP_LOGW(BT_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
}
|
||||
#elif (CONFIG_BT_CTRL_LPCLK_SEL_MAIN_XTAL)
|
||||
ESP_LOGI(BT_LOG_TAG, "Bluetooth will use main XTAL as Bluetooth sleep clock.");
|
||||
#if !CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
s_lp_cntl.no_light_sleep = 1;
|
||||
#endif
|
||||
#elif (CONFIG_BT_CTRL_LPCLK_SEL_RTC_SLOW)
|
||||
// check whether or not internal 150 kHz RC oscillator is working
|
||||
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_RC_SLOW) {
|
||||
s_lp_cntl.lpclk_sel = BTDM_LPCLK_SEL_RTC_SLOW; // Internal 150 kHz RC oscillator
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC osciallator. The accuracy of this clock is a lot larger than 500ppm which is "
|
||||
"required in Bluetooth communication, so don't select this option in scenarios such as BLE connection state.");
|
||||
} else {
|
||||
ESP_LOGW(BT_LOG_TAG, "Internal 150kHz RC oscillator not detected.");
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool select_src_ret __attribute__((unused));
|
||||
bool set_div_ret __attribute__((unused));
|
||||
if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_ON));
|
||||
s_lp_cntl.main_xtal_pu = 1;
|
||||
#endif
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() / MHZ);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 1 << (btdm_lpcycle_us_frac);
|
||||
} else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL32K) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
} else if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_RTC_SLOW) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = esp_clk_slowclk_cal_get();
|
||||
} else {
|
||||
err = ESP_ERR_INVALID_ARG;
|
||||
goto error;
|
||||
}
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
}
|
||||
ESP_LOGW(BT_LOG_TAG, "light sleep mode will not be able to apply when bluetooth is enabled.");
|
||||
}
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
err = ESP_ERR_NO_MEM;
|
||||
goto error;
|
||||
} else {
|
||||
s_lp_stat.pm_lock_released = 1;
|
||||
}
|
||||
#endif
|
||||
} while (0);
|
||||
if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) {
|
||||
ESP_LOGE(BT_LOG_TAG, "Low power module initialization failed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
@@ -1336,69 +1429,70 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// deinit low power control resources
|
||||
static void btdm_low_power_mode_deinit(void)
|
||||
{
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (s_lp_cntl.mac_bb_pd) {
|
||||
btdm_deep_sleep_mem_deinit();
|
||||
s_lp_cntl.mac_bb_pd = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required && s_btdm_slp_tmr != NULL) {
|
||||
if (s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
}
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR);
|
||||
if (s_wakeup_req_sem != NULL) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_lp_cntl.lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
if (s_lp_cntl.main_xtal_pu) {
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF));
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
}
|
||||
|
||||
static void bt_controller_deinit_internal(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
// deinit low power control resources
|
||||
do {
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
if (s_lp_cntl.mac_bb_pd) {
|
||||
btdm_deep_sleep_mem_deinit();
|
||||
s_lp_cntl.mac_bb_pd = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_lp_cntl.no_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
s_lp_stat.pm_lock_released = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (s_lp_cntl.wakeup_timer_required) {
|
||||
if (s_lp_stat.wakeup_timer_started) {
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
}
|
||||
s_lp_stat.wakeup_timer_started = 0;
|
||||
esp_timer_delete(s_btdm_slp_tmr);
|
||||
s_btdm_slp_tmr = NULL;
|
||||
}
|
||||
|
||||
if (s_lp_cntl.enable) {
|
||||
btdm_vnd_offload_task_deregister(BTDM_VND_OL_SIG_WAKEUP_TMR);
|
||||
if (s_wakeup_req_sem != NULL) {
|
||||
semphr_delete_wrapper(s_wakeup_req_sem);
|
||||
s_wakeup_req_sem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_lp_cntl.lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
#ifdef CONFIG_BT_CTRL_MAIN_XTAL_PU_DURING_LIGHT_SLEEP
|
||||
if (s_lp_cntl.main_xtal_pu) {
|
||||
ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_OFF));
|
||||
s_lp_cntl.main_xtal_pu = 0;
|
||||
}
|
||||
#endif
|
||||
btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW);
|
||||
btdm_lpclk_set_div(0);
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_update_lpclk_interval();
|
||||
#endif
|
||||
}
|
||||
|
||||
btdm_lpcycle_us = 0;
|
||||
} while (0);
|
||||
btdm_low_power_mode_deinit();
|
||||
|
||||
esp_bt_power_domain_off();
|
||||
#if CONFIG_MAC_BB_PD
|
||||
@@ -1677,4 +1771,55 @@ static void coex_wifi_sleep_set_hook(bool sleep)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t coex_schm_interval_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_interval_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_period_get();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void * coex_schm_curr_phase_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_phase_get();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
|
||||
@@ -147,7 +147,7 @@ if BT_LE_EXT_ADV
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
@@ -562,3 +562,17 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool "Msys Mbuf Init in Controller"
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -512,9 +512,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
}
|
||||
|
||||
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
{
|
||||
uint8_t size;
|
||||
int extra = *(int *)arg;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
@@ -523,9 +524,27 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
{
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
@@ -780,13 +799,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
coex_init();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -804,10 +816,16 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto controller_init_err;
|
||||
goto modem_deint;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
@@ -835,13 +853,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
esp_phy_modem_deinit();
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
@@ -872,10 +889,10 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_controller_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* De-initialize default event queue */
|
||||
@@ -986,70 +1003,86 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* If the addresses of btdm .bss and bt .bss are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_bss_end == _bt_controller_bss_start) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
/* If the addresses of btdm .data and bt .data are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_data_end == _bt_controller_data_start) {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ if BT_LE_EXT_ADV
|
||||
Enable this option to start periodic advertisement.
|
||||
|
||||
config BT_LE_PERIODIC_ADV_SYNC_TRANSFER
|
||||
bool "Enable Transer Sync Events"
|
||||
bool "Enable Transfer Sync Events"
|
||||
depends on BT_LE_ENABLE_PERIODIC_ADV
|
||||
default y
|
||||
help
|
||||
@@ -554,3 +554,17 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
|
||||
config BT_LE_MSYS_INIT_IN_CONTROLLER
|
||||
bool
|
||||
default y
|
||||
|
||||
config BT_LE_TX_CCA_ENABLED
|
||||
bool "Enable TX CCA feature"
|
||||
default n
|
||||
help
|
||||
Enable CCA feature to cancel sending the packet if the signal power is stronger than CCA threshold.
|
||||
|
||||
config BT_LE_CCA_RSSI_THRESH
|
||||
int "CCA RSSI threshold value"
|
||||
depends on BT_LE_TX_CCA_ENABLED
|
||||
range 20 100
|
||||
default 20
|
||||
help
|
||||
Power threshold of CCA in unit of -1 dBm.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -501,9 +501,10 @@ IRAM_ATTR void controller_wakeup_cb(void *arg)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
static esp_err_t sleep_modem_ble_mac_retention_init(void *arg)
|
||||
{
|
||||
uint8_t size;
|
||||
int extra = *(int *)arg;
|
||||
const sleep_retention_entries_config_t *ble_mac_modem_config = esp_ble_mac_retention_link_get(&size, extra);
|
||||
esp_err_t err = sleep_retention_entries_create(ble_mac_modem_config, size, REGDMA_LINK_PRI_5, SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
@@ -512,9 +513,27 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
return err;
|
||||
}
|
||||
|
||||
static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
|
||||
{
|
||||
int retention_args = extra;
|
||||
sleep_retention_module_init_param_t init_param = {
|
||||
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
|
||||
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB)
|
||||
};
|
||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void sleep_modem_ble_mac_modem_state_deinit(void)
|
||||
{
|
||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
if (err == ESP_OK) {
|
||||
err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_BLE_MAC);
|
||||
assert(err == ESP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
|
||||
@@ -752,14 +771,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_init();
|
||||
#endif // CONFIG_SW_COEXIST_ENABLE
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
interface_func_t bt_controller_log_interface;
|
||||
bt_controller_log_interface = esp_bt_controller_log_interface;
|
||||
@@ -777,10 +788,18 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_DUMP
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
|
||||
goto controller_init_err;
|
||||
goto modem_deint;
|
||||
}
|
||||
#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED
|
||||
|
||||
ret = ble_controller_init(cfg);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret);
|
||||
goto modem_deint;
|
||||
}
|
||||
|
||||
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble controller commit:[%s]", ble_controller_get_compile_version());
|
||||
|
||||
esp_ble_change_rtc_freq(slow_clk_freq);
|
||||
|
||||
ble_controller_scan_duplicate_config();
|
||||
@@ -809,13 +828,12 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
|
||||
free_controller:
|
||||
controller_sleep_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
controller_init_err:
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
os_msys_deinit();
|
||||
ble_controller_deinit();
|
||||
modem_deint:
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -844,10 +862,10 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
modem_clock_deselect_lp_clock_source(PERIPH_BT_MODULE);
|
||||
modem_clock_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
ble_controller_deinit();
|
||||
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
r_ble_log_deinit_async();
|
||||
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
|
||||
ble_controller_deinit();
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
/* De-initialize default event queue */
|
||||
@@ -958,70 +976,86 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
const char* name;
|
||||
} bt_area_t;
|
||||
|
||||
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
intptr_t mem_start = area->start;
|
||||
intptr_t mem_end = area->end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (area1->end == area2->start) {
|
||||
bt_area_t merged_area = {
|
||||
.start = area1->start,
|
||||
.end = area2->end,
|
||||
.name = area1->name
|
||||
};
|
||||
ret = esp_bt_mem_release_area(&merged_area);
|
||||
} else {
|
||||
esp_bt_mem_release_area(area1);
|
||||
ret = esp_bt_mem_release_area(area2);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
intptr_t mem_start, mem_end;
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_area_t bss = {
|
||||
.start = (intptr_t)&_bt_bss_start,
|
||||
.end = (intptr_t)&_bt_bss_end,
|
||||
.name = "BT BSS",
|
||||
};
|
||||
bt_area_t cont_bss = {
|
||||
.start = (intptr_t)&_bt_controller_bss_start,
|
||||
.end = (intptr_t)&_bt_controller_bss_end,
|
||||
.name = "BT Controller BSS",
|
||||
};
|
||||
bt_area_t data = {
|
||||
.start = (intptr_t)&_bt_data_start,
|
||||
.end = (intptr_t)&_bt_data_end,
|
||||
.name = "BT Data",
|
||||
};
|
||||
bt_area_t cont_data = {
|
||||
.start = (intptr_t)&_bt_controller_data_start,
|
||||
.end = (intptr_t)&_bt_controller_data_end,
|
||||
.name = "BT Controller Data"
|
||||
};
|
||||
|
||||
if (mode & ESP_BT_MODE_BLE) {
|
||||
/* If the addresses of btdm .bss and bt .bss are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_bss_end == _bt_controller_bss_start) {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_bss_start;
|
||||
mem_end = (intptr_t)&_bt_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_bss_start;
|
||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller BSS [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Start by freeing Bluetooth BSS section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||
}
|
||||
/* If the addresses of btdm .data and bt .data are consecutive,
|
||||
* they are registered in the system heap as a piece of memory
|
||||
*/
|
||||
if(_bt_data_end == _bt_controller_data_start) {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
} else {
|
||||
mem_start = (intptr_t)&_bt_data_start;
|
||||
mem_end = (intptr_t)&_bt_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
|
||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
||||
if (mem_start != mem_end) {
|
||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release Controller Data [0x%08x] - [0x%08x], len %d",
|
||||
mem_start, mem_end, mem_end - mem_start);
|
||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
||||
}
|
||||
/* Do the same thing with the Bluetooth data section */
|
||||
if (ret == ESP_OK) {
|
||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||
}
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Submodule components/bt/controller/lib_esp32 updated: e43c9b121f...43ecd22ec6
Submodule components/bt/controller/lib_esp32c2/esp32c2-bt-lib updated: 7f3eb5f556...b9a902c355
Submodule components/bt/controller/lib_esp32c3_family updated: e5c0f7256e...76ed4114ee
Submodule components/bt/controller/lib_esp32c6/esp32c6-bt-lib updated: 19eb534d33...0af472c6f9
Submodule components/bt/controller/lib_esp32h2/esp32h2-bt-lib updated: c97e0d84f0...70612d08d1
@@ -16,6 +16,6 @@ The ESP-BLE-MESH networking enables many-to-many (m:m) device communications and
|
||||
- [API Reference](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/esp-ble-mesh.html)
|
||||
|
||||
|
||||
### [ESP-BLE-MESH Examples](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh)
|
||||
### [ESP-BLE-MESH Examples](../../../examples/bluetooth/esp_ble_mesh)
|
||||
|
||||
- Refer to **ESP-BLE-MESH Examples** of [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp-ble-mesh/ble-mesh-index.html#getting-started-with-esp-ble-mesh) for the tutorials of ESP BLE Mesh examples.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -576,9 +576,9 @@ esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_src) &&
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_dst) &&
|
||||
!ESP_BLE_MESH_ADDR_IS_GROUP(info->hb_dst)) {
|
||||
if (!(ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_src) &&
|
||||
(ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_dst) ||
|
||||
ESP_BLE_MESH_ADDR_IS_GROUP(info->hb_dst)))) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
||||
@@ -1132,7 +1132,7 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
||||
|
||||
int bt_mesh_gatts_set_local_device_name(const char *name)
|
||||
{
|
||||
BTM_SetLocalDeviceName((char *)name);
|
||||
BTM_SetLocalDeviceName((char *)name, BT_DEVICE_TYPE_BLE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1481,7 +1481,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
/* Register Notification fot Mesh Provisioning/Proxy Data Out Characteristic */
|
||||
/* Register Notification for Mesh Provisioning/Proxy Data Out Characteristic */
|
||||
status = BTA_GATTC_RegisterForNotifications(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].data_out_handle);
|
||||
if (status != BTA_GATT_OK) {
|
||||
|
||||
@@ -1751,9 +1751,7 @@ static bool ignore_net_msg(uint16_t src, uint16_t dst)
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) &&
|
||||
bt_mesh_is_provisioner_en() &&
|
||||
BLE_MESH_ADDR_IS_UNICAST(dst) &&
|
||||
bt_mesh_elem_find(dst)) {
|
||||
bt_mesh_is_provisioner_en()) {
|
||||
/* If the destination address of the message is the element
|
||||
* address of Provisioner, but Provisioner fails to find the
|
||||
* node in its provisioning database, then this message will
|
||||
@@ -1810,7 +1808,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi,
|
||||
bt_mesh_elem_find(rx.ctx.recv_dst));
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER) &&
|
||||
bt_mesh_private_gatt_proxy_state_get() == BLE_MESH_PRIVATE_GATT_PROXY_DISABLED &&
|
||||
bt_mesh_private_gatt_proxy_state_get() != BLE_MESH_PRIVATE_GATT_PROXY_ENABLED &&
|
||||
net_if == BLE_MESH_NET_IF_PROXY) {
|
||||
bt_mesh_proxy_server_addr_add(data, rx.ctx.addr);
|
||||
|
||||
|
||||
@@ -368,7 +368,6 @@ static void seg_tx_reset(struct seg_tx *tx)
|
||||
tx->cb_data = NULL;
|
||||
tx->seq_auth = 0U;
|
||||
tx->sub = NULL;
|
||||
tx->seg_n = 0;
|
||||
tx->last_seg_n = 0;
|
||||
tx->lsn_updated = 0;
|
||||
tx->dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
@@ -385,6 +384,7 @@ static void seg_tx_reset(struct seg_tx *tx)
|
||||
}
|
||||
|
||||
tx->nack_count = 0U;
|
||||
tx->seg_n = 0;
|
||||
|
||||
bt_mesh_seg_tx_unlock();
|
||||
|
||||
|
||||
Submodule components/bt/esp_ble_mesh/lib/lib updated: 41bf5fc092...4934ca9038
@@ -273,7 +273,7 @@ config BT_GATTC_CACHE_NVS_FLASH
|
||||
config BT_GATTC_CONNECT_RETRY_COUNT
|
||||
int "The number of attempts to reconnect if the connection establishment failed"
|
||||
depends on BT_GATTC_ENABLE
|
||||
range 0 7
|
||||
range 0 255
|
||||
default 3
|
||||
help
|
||||
The number of attempts to reconnect if the connection establishment failed
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#if (BT_CONTROLLER_INCLUDED == TRUE)
|
||||
#include "esp_bt.h"
|
||||
#endif
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#define LOG_TAG "HCI_API"
|
||||
|
||||
@@ -59,6 +60,9 @@ bool hci_host_check_send_available(void)
|
||||
|
||||
void hci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
{
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(data[0], data, len);
|
||||
#endif
|
||||
#if (BT_CONTROLLER_INCLUDED == TRUE)
|
||||
esp_vhci_host_send_packet(data, len);
|
||||
#else /* BT_CONTROLLER_INCLUDED == TRUE */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "osi/future.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "config/stack_config.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
#include "bt_common.h"
|
||||
|
||||
static bool bd_already_enable = false;
|
||||
static bool bd_already_init = false;
|
||||
@@ -180,6 +182,10 @@ esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
|
||||
|
||||
bd_already_init = true;
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_init();
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -224,6 +230,10 @@ esp_err_t esp_bluedroid_deinit(void)
|
||||
|
||||
bluedriod_config_deinit();
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_deinit();
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
|
||||
bd_already_init = false;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -299,6 +299,7 @@ esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
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:
|
||||
case ESP_BLE_APPEARANCE_STANDALONE_SPEAKER:
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON;
|
||||
@@ -396,9 +397,25 @@ 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)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
return esp_bt_dev_set_device_name(name);
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!name){
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
|
||||
arg.set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_get_device_name(void)
|
||||
@@ -1599,3 +1616,31 @@ esp_err_t esp_ble_gap_set_periodic_adv_sync_trans_params(esp_bd_addr_t addr, con
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (!vendor_cmd_param || !vendor_cmd_param->p_param_buf || !vendor_cmd_param->param_len) {
|
||||
return ESP_ERR_NOT_ALLOWED;
|
||||
}
|
||||
// If command is not a VSC, return error
|
||||
if ((vendor_cmd_param->opcode & VENDOR_HCI_CMD_MASK) != VENDOR_HCI_CMD_MASK) {
|
||||
return ESP_ERR_NOT_ALLOWED;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT;
|
||||
arg.vendor_cmd_send.opcode = vendor_cmd_param->opcode;
|
||||
arg.vendor_cmd_send.param_len = vendor_cmd_param->param_len;
|
||||
arg.vendor_cmd_send.p_param_buf = vendor_cmd_param->p_param_buf;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -494,4 +494,40 @@ esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, uint16_t pkt_ty
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_set_device_name(const char *name)
|
||||
{
|
||||
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 ((!name) || (strlen(name) > BTC_MAX_LOC_BD_NAME_LEN)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_DEV_NAME;
|
||||
arg.bt_set_dev_name.device_name = (char *)name;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), btc_gap_bt_arg_deep_copy,
|
||||
btc_gap_bt_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_get_device_name(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_GET_DEV_NAME;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
||||
@@ -70,7 +70,7 @@ esp_err_t esp_bluedroid_disable(void);
|
||||
* - ESP_OK : Succeed
|
||||
* - Other : Failed
|
||||
*/
|
||||
esp_err_t esp_bluedroid_init(void) __attribute__((deprecated("Please use esp_bluedroid_init_with_cfg")));
|
||||
esp_err_t esp_bluedroid_init(void);
|
||||
|
||||
/**
|
||||
* @brief Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff.
|
||||
|
||||
@@ -104,6 +104,7 @@ typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit
|
||||
#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_STANDALONE_SPEAKER 0x0841 /*!< relate to BTM_BLE_APPEARANCE_STANDALONE_SPEAKER 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 */
|
||||
@@ -224,6 +225,7 @@ typedef enum {
|
||||
ESP_GAP_BLE_DTM_TEST_UPDATE_EVT, /*!< when direct test mode state changes, the event comes */
|
||||
// BLE_INCLUDED
|
||||
ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT, /*!< When clear advertising complete, the event comes */
|
||||
ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
@@ -238,6 +240,8 @@ typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN];
|
||||
/// Scan response data maximum length
|
||||
#define ESP_BLE_SCAN_RSP_DATA_LEN_MAX 31
|
||||
|
||||
#define VENDOR_HCI_CMD_MASK (0x3F << 10) /**!< 0xFC00 */
|
||||
|
||||
/* relate to BTM_BLE_AD_TYPE_xxx in stack/btm_ble_api.h */
|
||||
/// The type of advertising data(not adv_type)
|
||||
typedef enum {
|
||||
@@ -364,6 +368,15 @@ typedef enum {
|
||||
DTM_TEST_STOP_EVT,
|
||||
} esp_ble_dtm_update_evt_t;
|
||||
|
||||
/**
|
||||
* @brief Vendor HCI command parameters
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t opcode; /*!< vendor hci command opcode */
|
||||
uint8_t param_len; /*!< the length of parameter */
|
||||
uint8_t *p_param_buf; /*!< the point of parameter buffer */
|
||||
} esp_ble_vendor_cmd_params_t;
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
/**
|
||||
* @brief DTM TX parameters
|
||||
@@ -945,7 +958,7 @@ typedef struct {
|
||||
esp_ble_gap_ext_adv_data_status_t data_status; /*!< data type */
|
||||
uint8_t adv_data_len; /*!< extend advertising data length */
|
||||
uint8_t adv_data[251]; /*!< extend advertising data */
|
||||
} esp_ble_gap_ext_adv_reprot_t;
|
||||
} esp_ble_gap_ext_adv_report_t;
|
||||
|
||||
/**
|
||||
* @brief periodic adv report parameters
|
||||
@@ -1410,7 +1423,7 @@ typedef union {
|
||||
* @brief ESP_GAP_BLE_EXT_ADV_REPORT_EVT
|
||||
*/
|
||||
struct ble_ext_adv_report_param {
|
||||
esp_ble_gap_ext_adv_reprot_t params; /*!< extend advertising report parameters */
|
||||
esp_ble_gap_ext_adv_report_t params; /*!< extend advertising report parameters */
|
||||
} ext_adv_report; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_REPORT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT
|
||||
@@ -1471,6 +1484,14 @@ typedef union {
|
||||
esp_ble_dtm_update_evt_t update_evt; /*!< DTM state change event, 0x00: DTM TX start, 0x01: DTM RX start, 0x02:DTM end */
|
||||
uint16_t num_of_pkt; /*!< number of packets received, only valid if update_evt is DTM_TEST_STOP_EVT and shall be reported as 0 for a transmitter */
|
||||
} dtm_state_update; /*!< Event parameter of ESP_GAP_BLE_DTM_TEST_UPDATE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT
|
||||
*/
|
||||
struct vendor_cmd_cmpl_evt_param {
|
||||
uint16_t opcode; /*!< vendor hci command opcode */
|
||||
uint16_t param_len; /*!< The length of parameter buffer */
|
||||
uint8_t *p_param_buf; /*!< The point of parameter buffer */
|
||||
} vendor_cmd_cmpl; /*!< Event parameter of ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT */
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -2540,6 +2561,19 @@ esp_err_t esp_ble_dtm_stop(void);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_clear_advertising(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to send vendor hci command.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param[in] vendor_cmd_param: vendor hci command parameters
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cmd_param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -105,7 +105,7 @@ typedef uint8_t esp_bt_eir_type_t;
|
||||
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_2_DH5 0x1000
|
||||
#define ESP_BT_ACL_PKT_TYPES_MASK_NO_3_DH5 0x2000
|
||||
|
||||
// DM1 cann not be disabled. All options are mandatory to include DM1.
|
||||
// DM1 can not be disabled. All options are mandatory to include DM1.
|
||||
#define ESP_BT_ACL_DM1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM1 | 0x330e) /* 0x330e */
|
||||
#define ESP_BT_ACL_DH1_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DH1 | 0x330e) /* 0x331e */
|
||||
#define ESP_BT_ACL_DM3_ONLY (ESP_BT_ACL_PKT_TYPES_MASK_DM3 | 0x330e) /* 0x370e */
|
||||
@@ -142,7 +142,7 @@ typedef struct {
|
||||
uint8_t *p_url; /*!< URL point */
|
||||
} esp_bt_eir_data_t;
|
||||
|
||||
/// Major service class field of Class of Device, mutiple bits can be set
|
||||
/// Major service class field of Class of Device, multiple 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 */
|
||||
@@ -266,6 +266,7 @@ typedef enum {
|
||||
ESP_BT_GAP_GET_PAGE_TO_EVT, /*!< Get page timeout event */
|
||||
ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, /*!< Set ACL packet types event */
|
||||
ESP_BT_GAP_ENC_CHG_EVT, /*!< Encryption change event */
|
||||
ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, /*!< Get device name complete event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
@@ -475,6 +476,14 @@ typedef union {
|
||||
uint16_t handle; /*!< ACL connection handle */
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address */
|
||||
} acl_disconn_cmpl_stat; /*!< ACL disconnection complete status parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_GAP_BT_GET_DEV_NAME_CMPL_EVT
|
||||
*/
|
||||
struct get_dev_name_cmpl_evt_param {
|
||||
esp_bt_status_t status; /*!< Indicate the get device name success status */
|
||||
char *name; /*!< Name of bluetooth device */
|
||||
} get_dev_name_cmpl; /*!< Get device name complete status parameter struct */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -541,7 +550,7 @@ static inline uint32_t esp_bt_gap_get_cod_format_type(uint32_t cod)
|
||||
*
|
||||
* @return
|
||||
* - true if cod is valid
|
||||
* - false otherise
|
||||
* - false otherwise
|
||||
*/
|
||||
static inline bool esp_bt_gap_is_valid_cod(uint32_t cod)
|
||||
{
|
||||
@@ -909,6 +918,26 @@ esp_err_t esp_bt_gap_get_page_timeout(void);
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_acl_pkt_types(esp_bd_addr_t remote_bda, esp_bt_acl_pkt_type_t pkt_types);
|
||||
|
||||
/**
|
||||
* @brief Set device name to the local device
|
||||
*
|
||||
* @param[in] name - device name.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_device_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Get device name of the local device
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_device_name(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -615,6 +615,11 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
|
||||
btm_ble_resolving_list_cleanup (); //by TH, because cmn_ble_vsc_cb.max_filter has something mistake as btm_ble_adv_filter_cleanup
|
||||
#endif
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
// btm_ble_multi_adv_init is called when the host is enabled, so btm_ble_multi_adv_cleanup is called when the host is disabled.
|
||||
btm_ble_multi_adv_cleanup();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -678,9 +683,11 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
|
||||
*******************************************************************************/
|
||||
void bta_dm_set_dev_name (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name);
|
||||
BTM_SetLocalDeviceName((char *)p_data->set_name.name, p_data->set_name.name_type);
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
bta_dm_set_eir ((char *)p_data->set_name.name);
|
||||
if (p_data->set_name.name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
bta_dm_set_eir ((char *)p_data->set_name.name);
|
||||
}
|
||||
#endif /// CLASSIC_BT_INCLUDED
|
||||
}
|
||||
|
||||
@@ -699,7 +706,7 @@ void bta_dm_get_dev_name (tBTA_DM_MSG *p_data)
|
||||
tBTM_STATUS status;
|
||||
char *name = NULL;
|
||||
|
||||
status = BTM_ReadLocalDeviceName(&name);
|
||||
status = BTM_ReadLocalDeviceName(&name, p_data->get_name.name_type);
|
||||
if (p_data->get_name.p_cback) {
|
||||
(*p_data->get_name.p_cback)(status, name);
|
||||
}
|
||||
@@ -724,6 +731,14 @@ void bta_dm_cfg_coex_status (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
#endif
|
||||
|
||||
void bta_dm_send_vendor_hci(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_VendorSpecificCommand(p_data->vendor_hci_cmd.opcode,
|
||||
p_data->vendor_hci_cmd.param_len,
|
||||
p_data->vendor_hci_cmd.p_param_buf,
|
||||
p_data->vendor_hci_cmd.vendor_hci_cb);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_set_afh_channels
|
||||
@@ -4138,7 +4153,7 @@ static void bta_dm_set_eir (char *local_name)
|
||||
if (p_bta_dm_eir_cfg->bta_dm_eir_included_name) {
|
||||
/* if local name is not provided, get it from controller */
|
||||
if ( local_name == NULL ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name ) != BTM_SUCCESS ) {
|
||||
if ( BTM_ReadLocalDeviceName( &local_name, BT_DEVICE_TYPE_BREDR) != BTM_SUCCESS ) {
|
||||
APPL_TRACE_ERROR("Fail to read local device name for EIR");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ void BTA_DisableTestMode(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmSetDeviceName(const char *p_name)
|
||||
void BTA_DmSetDeviceName(const char *p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
|
||||
tBTA_DM_API_SET_NAME *p_msg;
|
||||
@@ -176,6 +176,7 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
/* truncate the name if needed */
|
||||
BCM_STRNCPY_S((char *)p_msg->name, p_name, BD_NAME_LEN);
|
||||
p_msg->name[BD_NAME_LEN] = '\0';
|
||||
p_msg->name_type = name_type;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
@@ -191,13 +192,14 @@ void BTA_DmSetDeviceName(const char *p_name)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback)
|
||||
void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
tBTA_DM_API_GET_NAME *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_GET_NAME *) osi_malloc(sizeof(tBTA_DM_API_GET_NAME))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_GET_NAME_EVT;
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->name_type = name_type;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
@@ -227,6 +229,21 @@ void BTA_DmCfgCoexStatus(UINT8 op, UINT8 type, UINT8 status)
|
||||
}
|
||||
#endif
|
||||
|
||||
void BTA_DmsendVendorHciCmd(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf, tBTA_SEND_VENDOR_HCI_CMPL_CBACK p_vendor_cmd_complete_cback)
|
||||
{
|
||||
tBTA_DM_API_SEND_VENDOR_HCI_CMD *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_SEND_VENDOR_HCI_CMD *)osi_malloc(sizeof(tBTA_DM_API_SEND_VENDOR_HCI_CMD) + param_len)) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT;
|
||||
p_msg->opcode = opcode;
|
||||
p_msg->param_len = param_len;
|
||||
p_msg->p_param_buf = (UINT8 *)(p_msg + 1);
|
||||
memcpy(p_msg->p_param_buf, p_param_buf, param_len);
|
||||
p_msg->vendor_hci_cb = p_vendor_cmd_complete_cback;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
void BTA_DmConfigEir(tBTA_DM_EIR_CONF *eir_config)
|
||||
@@ -2906,7 +2923,6 @@ void BTA_VendorCleanup (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
btm_ble_multi_adv_cleanup();
|
||||
}
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
void BTA_DmBleGapReadPHY(BD_ADDR addr)
|
||||
|
||||
@@ -65,6 +65,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
bta_dm_cfg_coex_status, /* BTA_DM_API_CFG_COEX_ST_EVT */
|
||||
#endif
|
||||
bta_dm_send_vendor_hci, /* BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT */
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
|
||||
bta_dm_set_page_timeout, /* BTA_DM_API_PAGE_TO_SET_EVT */
|
||||
|
||||
@@ -57,6 +57,7 @@ enum {
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
BTA_DM_API_CFG_COEX_ST_EVT,
|
||||
#endif
|
||||
BTA_DM_API_SEND_VENDOR_HCI_CMD_EVT,
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
BTA_DM_API_CONFIG_EIR_EVT,
|
||||
BTA_DM_API_PAGE_TO_SET_EVT,
|
||||
@@ -249,11 +250,13 @@ typedef struct {
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_NAME name; /* max 248 bytes name, plus must be Null terminated */
|
||||
tBT_DEVICE_TYPE name_type; /* name for BLE, name for BT or name for BTDM */
|
||||
} tBTA_DM_API_SET_NAME;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BT_HDR hdr;
|
||||
tBTA_GET_DEV_NAME_CBACK *p_cback;
|
||||
tBT_DEVICE_TYPE name_type;
|
||||
} tBTA_DM_API_GET_NAME;
|
||||
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
@@ -265,6 +268,14 @@ typedef struct {
|
||||
} tBTA_DM_API_CFG_COEX_STATUS;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 opcode;
|
||||
UINT8 param_len;
|
||||
UINT8 *p_param_buf;
|
||||
tBTA_SEND_VENDOR_HCI_CMPL_CBACK *vendor_hci_cb;
|
||||
}tBTA_DM_API_SEND_VENDOR_HCI_CMD;
|
||||
|
||||
/* data type for BTA_DM_API_CONFIG_EIR_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -1162,6 +1173,7 @@ typedef union {
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
tBTA_DM_API_CFG_COEX_STATUS cfg_coex_status;
|
||||
#endif
|
||||
tBTA_DM_API_SEND_VENDOR_HCI_CMD vendor_hci_cmd;
|
||||
tBTA_DM_API_CONFIG_EIR config_eir;
|
||||
|
||||
tBTA_DM_API_SET_AFH_CHANNELS set_afh_channels;
|
||||
@@ -1676,6 +1688,7 @@ extern void bta_dm_get_dev_name (tBTA_DM_MSG *p_data);
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
extern void bta_dm_cfg_coex_status(tBTA_DM_MSG *p_data);
|
||||
#endif
|
||||
extern void bta_dm_send_vendor_hci(tBTA_DM_MSG *p_data);
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
extern void bta_dm_config_eir (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_page_timeout (tBTA_DM_MSG *p_data);
|
||||
|
||||
@@ -276,7 +276,7 @@ static void bta_hh_di_sdp_cback(UINT16 result)
|
||||
bta_hh_update_di_info(p_cb, di_rec.rec.vendor, di_rec.rec.product, di_rec.rec.version, 0);
|
||||
}
|
||||
|
||||
} else { /* no DI recrod available */
|
||||
} else { /* no DI record available */
|
||||
bta_hh_update_di_info(p_cb, BTA_HH_VENDOR_ID_INVALID, 0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
|
||||
return;
|
||||
}
|
||||
/* GetSDPRecord. at one time only one SDP precedure can be active */
|
||||
/* GetSDPRecord. at one time only one SDP procedure can be active */
|
||||
else if (!bta_hh_cb.p_disc_db) {
|
||||
bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_malloc(p_bta_hh_cfg->sdp_db_size);
|
||||
|
||||
@@ -429,6 +429,7 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
APPL_TRACE_DEBUG ("bta_hh_sdp_cmpl: HID_HostOpenDev failed: \
|
||||
Status 0x%2X", ret);
|
||||
#endif
|
||||
conn_dat.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
/* open fail, remove device from management device list */
|
||||
HID_HostRemoveDev( p_cb->hid_handle);
|
||||
status = BTA_HH_ERR;
|
||||
@@ -452,8 +453,6 @@ void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
HID_HostRemoveDev( p_cb->incoming_hid_handle);
|
||||
}
|
||||
conn_dat.status = status;
|
||||
/* check if host initiate the connection*/
|
||||
conn_dat.is_orig = !p_cb->incoming_conn;
|
||||
(* bta_hh_cb.p_cback)(BTA_HH_OPEN_EVT, (tBTA_HH *)&conn_dat);
|
||||
|
||||
/* move state machine W4_CONN ->IDLE */
|
||||
@@ -523,8 +522,7 @@ void bta_hh_open_cmpl_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
|
||||
memset((void *)&conn, 0, sizeof (tBTA_HH_CONN));
|
||||
conn.handle = dev_handle;
|
||||
/* check if host initiate the connection*/
|
||||
conn.is_orig = !p_cb->incoming_conn;
|
||||
conn.is_orig = HID_HostConnectOrig(dev_handle);
|
||||
bdcpy(conn.bda, p_cb->addr);
|
||||
|
||||
/* increase connection number */
|
||||
@@ -596,7 +594,7 @@ void bta_hh_open_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
if (p_cb->app_id != 0) {
|
||||
bta_hh_sm_execute(p_cb, BTA_HH_OPEN_CMPL_EVT, p_data);
|
||||
} else
|
||||
/* app_id == 0 indicates an incoming conenction request arrives without SDP
|
||||
/* app_id == 0 indicates an incoming connection request arrives without SDP
|
||||
performed, do it first */
|
||||
{
|
||||
/* store the handle here in case sdp fails - need to disconnect */
|
||||
@@ -637,7 +635,7 @@ void bta_hh_data_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
**
|
||||
** Function bta_hh_handsk_act
|
||||
**
|
||||
** Description HID Host process a handshake acknoledgement.
|
||||
** Description HID Host process a handshake acknowledgement.
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
@@ -674,7 +672,7 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
p_cb->w4_evt = 0;
|
||||
break;
|
||||
|
||||
/* acknoledgement from HID device for SET_ transaction */
|
||||
/* acknowledgement from HID device for SET_ transaction */
|
||||
case BTA_HH_SET_RPT_EVT:
|
||||
case BTA_HH_SET_PROTO_EVT:
|
||||
case BTA_HH_SET_IDLE_EVT :
|
||||
@@ -693,8 +691,7 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
case BTA_HH_OPEN_EVT:
|
||||
conn.status = p_data->hid_cback.data ? BTA_HH_ERR_PROTO : BTA_HH_OK;
|
||||
conn.handle = p_cb->hid_handle;
|
||||
/* check if host initiate the connection*/
|
||||
conn.is_orig = !p_cb->incoming_conn;
|
||||
conn.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
bdcpy(conn.bda, p_cb->addr);
|
||||
(* bta_hh_cb.p_cback)(p_cb->w4_evt, (tBTA_HH *)&conn);
|
||||
#if BTA_HH_DEBUG
|
||||
@@ -704,12 +701,12 @@ void bta_hh_handsk_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
break;
|
||||
|
||||
default:
|
||||
/* unknow transaction handshake response */
|
||||
/* unknown transaction handshake response */
|
||||
APPL_TRACE_DEBUG("unknown transaction type");
|
||||
break;
|
||||
}
|
||||
|
||||
/* transaction achknoledgement received, inform PM for mode change */
|
||||
/* transaction acknowledgement received, inform PM for mode change */
|
||||
bta_sys_idle(BTA_ID_HH, p_cb->app_id, p_cb->addr);
|
||||
return;
|
||||
}
|
||||
@@ -799,7 +796,7 @@ void bta_hh_open_failure(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
conn_dat.status = (reason == HID_ERR_AUTH_FAILED) ?
|
||||
BTA_HH_ERR_AUTH_FAILED : BTA_HH_ERR;
|
||||
/* check if host initiate the connection*/
|
||||
conn_dat.is_orig = !p_cb->incoming_conn;
|
||||
conn_dat.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
bdcpy(conn_dat.bda, p_cb->addr);
|
||||
HID_HostCloseDev(p_cb->hid_handle);
|
||||
|
||||
@@ -844,13 +841,13 @@ void bta_hh_close_act (tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
|
||||
/* Check reason for closing */
|
||||
if ((reason & (HID_L2CAP_CONN_FAIL | HID_L2CAP_REQ_FAIL)) || /* Failure to initialize connection (page timeout or l2cap error) */
|
||||
(reason == HID_ERR_AUTH_FAILED) || /* Authenication error (while initiating) */
|
||||
(reason == HID_ERR_AUTH_FAILED) || /* Authentication error (while initiating) */
|
||||
(reason == HID_ERR_L2CAP_FAILED)) { /* Failure creating l2cap connection */
|
||||
/* Failure in opening connection */
|
||||
conn_dat.handle = p_cb->hid_handle;
|
||||
conn_dat.status = (reason == HID_ERR_AUTH_FAILED) ? BTA_HH_ERR_AUTH_FAILED : BTA_HH_ERR;
|
||||
/* check if host initiate the connection*/
|
||||
conn_dat.is_orig = !p_cb->incoming_conn;
|
||||
conn_dat.is_orig = HID_HostConnectOrig(p_cb->hid_handle);
|
||||
bdcpy(conn_dat.bda, p_cb->addr);
|
||||
HID_HostCloseDev(p_cb->hid_handle);
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA *p_data)
|
||||
cback_data.conn.status = BTA_HH_ERR_DB_FULL;
|
||||
cback_data.conn.handle = BTA_HH_INVALID_HANDLE;
|
||||
/* check if host initiate the connection*/
|
||||
cback_data.conn.is_orig = !p_cb->incoming_conn;
|
||||
cback_data.conn.is_orig = TRUE;
|
||||
break;
|
||||
/* DB full, BTA_HhAddDev */
|
||||
case BTA_HH_API_MAINT_DEV_EVT:
|
||||
|
||||
@@ -417,6 +417,8 @@ typedef void (tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTA_STATUS st
|
||||
|
||||
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
typedef tBTM_VSC_CMPL_CB tBTA_SEND_VENDOR_HCI_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK;
|
||||
|
||||
typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK;
|
||||
@@ -433,6 +435,8 @@ typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
|
||||
|
||||
typedef tBTM_CMPL_CB tBTA_CMPL_CB;
|
||||
|
||||
typedef tBTM_VSC_CMPL tBTA_VSC_CMPL;
|
||||
|
||||
typedef tBTM_TX_POWER_RESULTS tBTA_TX_POWER_RESULTS;
|
||||
|
||||
typedef tBTM_RSSI_RESULTS tBTA_RSSI_RESULTS;
|
||||
@@ -1716,7 +1720,7 @@ extern void BTA_DisableTestMode(void);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
extern void BTA_DmSetDeviceName(const char *p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1728,7 +1732,7 @@ extern void BTA_DmSetDeviceName(const char *p_name);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback);
|
||||
extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1744,6 +1748,8 @@ extern void BTA_DmGetDeviceName(tBTA_GET_DEV_NAME_CBACK *p_cback);
|
||||
extern void BTA_DmCfgCoexStatus(UINT8 op, UINT8 type, UINT8 status);
|
||||
#endif
|
||||
|
||||
extern void BTA_DmsendVendorHciCmd(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf, tBTA_SEND_VENDOR_HCI_CMPL_CBACK p_vendor_cmd_complete_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmGetRemoteName
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the implementation of the JAVA API for Bluetooth Wireless
|
||||
* Technology (JABWT) as specified by the JSR82 specificiation
|
||||
* Technology (JABWT) as specified by the JSR82 specification
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@@ -118,6 +118,11 @@ void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback)
|
||||
|
||||
APPL_TRACE_API( "BTA_JvDisable");
|
||||
bta_sys_deregister(BTA_ID_JV);
|
||||
memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB));
|
||||
/* set handle to invalid value by default */
|
||||
for (int i = 0; i < BTA_JV_PM_MAX_NUM; i++) {
|
||||
bta_jv_cb.pm_cb[i].handle = BTA_JV_PM_HANDLE_CLEAR;
|
||||
}
|
||||
if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_JV_API_DISABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
@@ -893,7 +898,7 @@ tBTA_JV_STATUS BTA_JvRfcommConfig(BOOLEAN enable_l2cap_ertm)
|
||||
**
|
||||
** Function BTA_JvRfcommConnect
|
||||
**
|
||||
** Description This function makes an RFCOMM conection to a remote BD
|
||||
** Description This function makes an RFCOMM connection to a remote BD
|
||||
** Address.
|
||||
** When the connection is initiated or failed to initiate,
|
||||
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT
|
||||
@@ -1204,7 +1209,7 @@ tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given)
|
||||
** Parameters: handle, JV handle from RFCOMM or L2CAP
|
||||
** app_id: app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details
|
||||
** BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and
|
||||
** BTA_JV_CONN_CLOSE is called implicitely
|
||||
** BTA_JV_CONN_CLOSE is called implicitly
|
||||
** init_st: state after calling this API. typically it should be BTA_JV_CONN_OPEN
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
|
||||
@@ -41,7 +41,7 @@ void btc_dev_call_handler(btc_msg_t *msg)
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_DEV_ACT_SET_DEVICE_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name, BT_DEVICE_TYPE_DUMO);
|
||||
break;
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
case BTC_DEV_ACT_CFG_COEX_STATUS:
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "btc/btc_common.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_main.h"
|
||||
#include "btc/btc_util.h"
|
||||
#include "common/bt_trace.h"
|
||||
#include "common/bt_target.h"
|
||||
#include "btc/btc_storage.h"
|
||||
@@ -717,14 +718,14 @@ static void btc_dm_acl_link_stat(tBTA_DM_ACL_LINK_STAT *p_acl_link_stat)
|
||||
switch (p_acl_link_stat->event) {
|
||||
case BTA_ACL_LINK_STAT_CONN_CMPL: {
|
||||
event = ESP_BT_GAP_ACL_CONN_CMPL_STAT_EVT;
|
||||
param.acl_conn_cmpl_stat.stat = p_acl_link_stat->link_act.conn_cmpl.status | ESP_BT_STATUS_BASE_FOR_HCI_ERR;
|
||||
param.acl_conn_cmpl_stat.stat = btc_hci_to_esp_status(p_acl_link_stat->link_act.conn_cmpl.status);
|
||||
param.acl_conn_cmpl_stat.handle = p_acl_link_stat->link_act.conn_cmpl.handle;
|
||||
memcpy(param.acl_conn_cmpl_stat.bda, p_acl_link_stat->link_act.conn_cmpl.bd_addr, ESP_BD_ADDR_LEN);
|
||||
break;
|
||||
}
|
||||
case BTA_ACL_LINK_STAT_DISCONN_CMPL: {
|
||||
event = ESP_BT_GAP_ACL_DISCONN_CMPL_STAT_EVT;
|
||||
param.acl_disconn_cmpl_stat.reason = p_acl_link_stat->link_act.disconn_cmpl.reason | ESP_BT_STATUS_BASE_FOR_HCI_ERR;
|
||||
param.acl_disconn_cmpl_stat.reason = btc_hci_to_esp_status(p_acl_link_stat->link_act.disconn_cmpl.reason);
|
||||
param.acl_disconn_cmpl_stat.handle = p_acl_link_stat->link_act.disconn_cmpl.handle;
|
||||
memcpy(param.acl_disconn_cmpl_stat.bda, p_acl_link_stat->link_act.disconn_cmpl.bd_addr, ESP_BD_ADDR_LEN);
|
||||
break;
|
||||
@@ -788,7 +789,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
/* Set initial device name, it can be overwritten later */
|
||||
if (p_data->enable.status == BTA_SUCCESS) {
|
||||
const char *initial_device_name = "ESP32";
|
||||
BTA_DmSetDeviceName(initial_device_name);
|
||||
BTA_DmSetDeviceName(initial_device_name, BT_DEVICE_TYPE_DUMO);
|
||||
}
|
||||
btc_enable_bluetooth_evt(p_data->enable.status);
|
||||
break;
|
||||
|
||||
@@ -141,18 +141,34 @@ uint32_t btc_get_ble_status(void)
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
// Number of recorded devices
|
||||
extern uint8_t btm_ble_sec_dev_active_count(void);
|
||||
if (btm_ble_sec_dev_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_KEYS);
|
||||
}
|
||||
|
||||
// Number of saved bonded devices
|
||||
if (btc_storage_get_num_ble_bond_devices()) {
|
||||
status |= BIT(BTC_BLE_STATUS_BOND);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
// Privacy enabled
|
||||
extern uint8_t btm_ble_privacy_is_enabled(void);
|
||||
if (btm_ble_privacy_is_enabled()) {
|
||||
status |= BIT(BTC_BLE_STATUS_PRIVACY);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Number of recorded devices
|
||||
extern uint8_t btdm_sec_dev_active_count(void);
|
||||
if (btdm_sec_dev_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_DEV);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
// Number of active extended advertsing
|
||||
extern uint8_t btm_ble_ext_adv_active_count(void);
|
||||
if (btm_ble_ext_adv_active_count()) {
|
||||
status |= BIT(BTC_BLE_STATUS_EXT_ADV);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Number of active ACL connection
|
||||
extern uint8_t btm_acl_active_count(void);
|
||||
|
||||
@@ -338,8 +338,11 @@ esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
esp_status = ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT;
|
||||
break;
|
||||
case HCI_ERR_UNSUPPORTED_VALUE:
|
||||
esp_status = ESP_BT_STATUS_UNSUPPORTED;
|
||||
break;
|
||||
default:
|
||||
esp_status = ESP_BT_STATUS_FAIL;
|
||||
esp_status = hci_status | ESP_BT_STATUS_BASE_FOR_HCI_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,15 @@ typedef enum {
|
||||
#define BTC_BLE_STATUS_IDLE 0
|
||||
typedef enum {
|
||||
BTC_BLE_STATUS_ADV = 0, // Advertising exist
|
||||
BTC_BLE_STATUS_EXT_ADV, // Extended advertising exist
|
||||
BTC_BLE_STATUS_SCAN, // Scanning exist
|
||||
BTC_BLE_STATUS_CONN, // Connection exist
|
||||
BTC_BLE_STATUS_DEV, // Device record exist
|
||||
BTC_BLE_STATUS_KEYS, // Device keys record exist
|
||||
BTC_BLE_STATUS_BOND, // Bond info exist
|
||||
BTC_BLE_STATUS_GATTC_CACHE, // GATTC cache exist
|
||||
BTC_BLE_STATUS_GATTC_APP, // GATTC application exist
|
||||
BTC_BLE_STATUS_GATTS_SRVC, // GATTS service exist
|
||||
BTC_BLE_STATUS_PRIVACY, // Privacy enabled
|
||||
} tBTC_BLE_STATUS;
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -1067,7 +1067,7 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
|
||||
break;
|
||||
case BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT:
|
||||
msg.act = ESP_GAP_BLE_EXT_ADV_REPORT_EVT;
|
||||
memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_reprot_t));
|
||||
memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_report_t));
|
||||
if (params->ext_adv_report.adv_data) {
|
||||
memcpy(param.ext_adv_report.params.adv_data,
|
||||
params->ext_adv_report.adv_data, params->ext_adv_report.adv_data_len);
|
||||
@@ -1256,6 +1256,42 @@ void btc_dtm_stop_callback(void *p1)
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_vendor_hci_cmd_complete_callback(tBTA_VSC_CMPL *p_param)
|
||||
{
|
||||
bool param_invalid = false;
|
||||
if ((!p_param) || (!p_param->param_len) || (!p_param->p_param_buf)) {
|
||||
BTC_TRACE_ERROR("%s param error\n", __func__);
|
||||
param_invalid = true;
|
||||
}
|
||||
|
||||
esp_ble_gap_cb_param_t param = {0};
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT;
|
||||
if (!param_invalid) {
|
||||
param.vendor_cmd_cmpl.opcode = p_param->opcode;
|
||||
param.vendor_cmd_cmpl.param_len = p_param->param_len;
|
||||
param.vendor_cmd_cmpl.p_param_buf = p_param->p_param_buf;
|
||||
} else {
|
||||
if (p_param) {
|
||||
param.vendor_cmd_cmpl.opcode = p_param->opcode;
|
||||
} else {
|
||||
param.vendor_cmd_cmpl.opcode = 0;
|
||||
}
|
||||
param.vendor_cmd_cmpl.param_len = 0;
|
||||
param.vendor_cmd_cmpl.p_param_buf = NULL;
|
||||
}
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_ble_gap_cb_param_t), btc_gap_ble_cb_deep_copy, btc_gap_ble_cb_deep_free);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_get_whitelist_size(uint16_t *length)
|
||||
{
|
||||
BTM_BleGetWhiteListSize(length);
|
||||
@@ -1598,6 +1634,31 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
break;
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: {
|
||||
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
|
||||
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
|
||||
if (src->vendor_cmd_send.param_len) {
|
||||
dst->vendor_cmd_send.p_param_buf = osi_malloc(src->vendor_cmd_send.param_len);
|
||||
if (dst->vendor_cmd_send.p_param_buf) {
|
||||
memcpy(dst->vendor_cmd_send.p_param_buf, src->vendor_cmd_send.p_param_buf, src->vendor_cmd_send.param_len);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
|
||||
btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src;
|
||||
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *)p_dest;
|
||||
dst->set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->set_dev_name.device_name, src->set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n",__func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@@ -1606,7 +1667,22 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
|
||||
void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
esp_ble_gap_cb_param_t *src = (esp_ble_gap_cb_param_t *)p_src;
|
||||
esp_ble_gap_cb_param_t *dst = (esp_ble_gap_cb_param_t *) p_dest;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT: {
|
||||
if (src->vendor_cmd_cmpl.param_len) {
|
||||
dst->vendor_cmd_cmpl.p_param_buf = osi_malloc(src->vendor_cmd_cmpl.param_len);
|
||||
if (dst->vendor_cmd_cmpl.p_param_buf) {
|
||||
memcpy(dst->vendor_cmd_cmpl.p_param_buf, src->vendor_cmd_cmpl.p_param_buf,
|
||||
src->vendor_cmd_cmpl.param_len);
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s, malloc failed\n", __func__);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
@@ -1704,6 +1780,21 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: {
|
||||
uint8_t *p_param_buf = ((btc_ble_gap_args_t *)msg->arg)->vendor_cmd_send.p_param_buf;
|
||||
if (p_param_buf) {
|
||||
osi_free(p_param_buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:{
|
||||
char *p_name = ((btc_ble_gap_args_t *)msg->arg)->set_dev_name.device_name;
|
||||
if (p_name) {
|
||||
osi_free((uint8_t *)p_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act);
|
||||
break;
|
||||
@@ -1721,6 +1812,13 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT: {
|
||||
uint8_t *value = ((esp_ble_gap_cb_param_t *)msg->arg)->vendor_cmd_cmpl.p_param_buf;
|
||||
if (value) {
|
||||
osi_free(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_DEBUG("Unhandled deep free %d", msg->act);
|
||||
break;
|
||||
@@ -1808,10 +1906,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_SET_DEV_NAME:
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name);
|
||||
BTA_DmSetDeviceName(arg->set_dev_name.device_name, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_GET_DEV_NAME:
|
||||
BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback);
|
||||
BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW:
|
||||
@@ -2192,6 +2290,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
btc_ble_dtm_enhance_rx_start(arg_5->dtm_enh_rx_start.rx_channel, arg_5->dtm_enh_rx_start.phy, arg_5->dtm_enh_rx_start.modulation_index, btc_dtm_rx_start_callback);
|
||||
break;
|
||||
#endif // if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT:
|
||||
BTA_DmsendVendorHciCmd(arg->vendor_cmd_send.opcode,
|
||||
arg->vendor_cmd_send.param_len,
|
||||
arg->vendor_cmd_send.p_param_buf,
|
||||
btc_ble_vendor_hci_cmd_complete_callback);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -853,6 +853,33 @@ static void btc_gap_bt_set_qos(btc_gap_bt_args_t *arg)
|
||||
#endif /// (BTA_DM_QOS_INCLUDED == TRUE)
|
||||
}
|
||||
|
||||
static void btc_gap_bt_get_dev_name_callback(UINT8 status, char *name)
|
||||
{
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
memset(¶m, 0, sizeof(esp_bt_gap_cb_param_t));
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT;
|
||||
|
||||
param.get_dev_name_cmpl.status = btc_btm_status_to_esp_status(status);
|
||||
param.get_dev_name_cmpl.name = (char *)osi_malloc(BTC_MAX_LOC_BD_NAME_LEN + 1);
|
||||
if (param.get_dev_name_cmpl.name) {
|
||||
BCM_STRNCPY_S(param.get_dev_name_cmpl.name, name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
param.get_dev_name_cmpl.name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
param.get_dev_name_cmpl.status = ESP_BT_STATUS_NOMEM;
|
||||
}
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m, sizeof(esp_bt_gap_cb_param_t), NULL, NULL);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
switch (msg->act) {
|
||||
@@ -872,6 +899,7 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME:
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
@@ -913,6 +941,18 @@ void btc_gap_bt_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
btc_gap_bt_args_t *src = (btc_gap_bt_args_t *)p_src;
|
||||
btc_gap_bt_args_t *dst = (btc_gap_bt_args_t *)p_dest;
|
||||
dst->bt_set_dev_name.device_name = (char *)osi_malloc((BTC_MAX_LOC_BD_NAME_LEN + 1) * sizeof(char));
|
||||
if (dst->bt_set_dev_name.device_name) {
|
||||
BCM_STRNCPY_S(dst->bt_set_dev_name.device_name, src->bt_set_dev_name.device_name, BTC_MAX_LOC_BD_NAME_LEN);
|
||||
dst->bt_set_dev_name.device_name[BTC_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act);
|
||||
break;
|
||||
@@ -939,6 +979,7 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT:
|
||||
case BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES:
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME:
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_PASSKEY_REPLY:
|
||||
case BTC_GAP_BT_ACT_CONFIRM_REPLY:
|
||||
@@ -957,6 +998,13 @@ void btc_gap_bt_arg_deep_free(btc_msg_t *msg)
|
||||
osi_free(arg->config_eir.eir_data.p_url);
|
||||
}
|
||||
break;
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
char *p_name = arg->bt_set_dev_name.device_name;
|
||||
if (p_name) {
|
||||
osi_free((uint8_t *)p_name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("Unhandled deep copy %d, arg: %p\n", msg->act, arg);
|
||||
break;
|
||||
@@ -1049,6 +1097,14 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_set_acl_pkt_types(arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_DEV_NAME: {
|
||||
BTA_DmSetDeviceName(arg->bt_set_dev_name.device_name, BT_DEVICE_TYPE_BREDR);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_GET_DEV_NAME: {
|
||||
BTA_DmGetDeviceName(btc_gap_bt_get_dev_name_callback, BT_DEVICE_TYPE_BREDR);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1101,6 +1157,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
#if (BTC_DM_PM_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_MODE_CHG_EVT:
|
||||
#endif /// BTC_DM_PM_INCLUDED == TRUE
|
||||
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT:
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
@@ -1192,6 +1249,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_ACL_PKT_TYPE_CHANGED_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT: {
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_GET_DEV_NAME_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -68,7 +68,7 @@ static UINT16 btc_max_hf_clients = BTC_HF_NUM_CB;
|
||||
#if HFP_DYNAMIC_MEMORY == FALSE
|
||||
static hf_local_param_t hf_local_param[BTC_HF_NUM_CB];
|
||||
#else
|
||||
static hf_local_param_t *hf_local_param = NULL;
|
||||
hf_local_param_t *hf_local_param_ptr = NULL;
|
||||
#endif
|
||||
|
||||
#if (BTM_WBS_INCLUDED == TRUE)
|
||||
@@ -319,20 +319,18 @@ bt_status_t btc_hf_init(void)
|
||||
BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients);
|
||||
|
||||
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_local_param != NULL) {
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
if ((hf_local_param = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
|
||||
APPL_TRACE_ERROR("%s malloc failed!", __func__);
|
||||
return BT_STATUS_NOMEM;
|
||||
if (hf_local_param == NULL) {
|
||||
if ((hf_local_param = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
|
||||
BTC_TRACE_ERROR("%s malloc failed!", __func__);
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
}
|
||||
memset((void *)hf_local_param, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t));
|
||||
#endif
|
||||
|
||||
/* Invoke the enable service API to the core to set the appropriate service_id
|
||||
* Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled (phone)
|
||||
* othwerwise only HSP is enabled (tablet)*/
|
||||
* otherwise only HSP is enabled (tablet)*/
|
||||
#if (defined(BTC_HF_SERVICES) && (BTC_HF_SERVICES & BTA_HFP_SERVICE_MASK))
|
||||
btc_dm_enable_service(BTA_HFP_SERVICE_ID);
|
||||
#else
|
||||
@@ -759,7 +757,7 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
|
||||
}
|
||||
/* CIND response should have been updated. */
|
||||
BTA_AgResult(BTA_AG_HANDLE_ALL, res, &ag_res);
|
||||
/* Just open SCO conenction. */
|
||||
/* Just open SCO connection. */
|
||||
BTA_AgAudioOpen(ag_res.audio_handle);
|
||||
activeCallUpdated = TRUE;
|
||||
}
|
||||
@@ -1572,7 +1570,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
|
||||
CHECK_HF_IDX(idx);
|
||||
BTC_TRACE_DEBUG("AG Bitmap of peer-codecs %d", p_data->val.num);
|
||||
#if (BTM_WBS_INCLUDED == TRUE)
|
||||
/* If the peer supports mSBC and the BTC prefferred codec is also mSBC, then
|
||||
/* If the peer supports mSBC and the BTC preferred codec is also mSBC, then
|
||||
** we should set the BTA AG Codec to mSBC. This would trigger a +BCS to mSBC at the time
|
||||
** of SCO connection establishment */
|
||||
if ((btc_conf_hf_force_wbs == TRUE) && (p_data->val.num & BTA_AG_CODEC_MSBC)) {
|
||||
@@ -1608,7 +1606,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
|
||||
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
|
||||
memcpy(param.bcs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
|
||||
param.bcs_rep.mode = p_data->val.num;
|
||||
/* No ESP_HF_WBS_NONE case, becuase HFP 1.6 supported device can send BCS */
|
||||
/* No ESP_HF_WBS_NONE case, because HFP 1.6 supported device can send BCS */
|
||||
btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
|
||||
@@ -189,7 +189,7 @@ static btc_hh_device_t *btc_hh_find_connected_dev_by_bda(BD_ADDR bd_addr)
|
||||
*
|
||||
* Function btc_hh_stop_vup_timer
|
||||
*
|
||||
* Description stop vitual unplug timer
|
||||
* Description stop virtual unplug timer
|
||||
*
|
||||
* Returns void
|
||||
******************************************************************************/
|
||||
@@ -316,7 +316,7 @@ void btc_hh_remove_device(BD_ADDR bd_addr)
|
||||
|
||||
for (i = 0; i < BTC_HH_MAX_ADDED_DEV; i++) {
|
||||
p_added_dev = &btc_hh_cb.added_devices[i];
|
||||
if (p_added_dev->bd_addr == bd_addr) {
|
||||
if (memcmp(p_added_dev->bd_addr, bd_addr, BD_ADDR_LEN) == 0) {
|
||||
BTA_HhRemoveDev(p_added_dev->dev_handle);
|
||||
btc_storage_remove_hid_info((bt_bdaddr_t *)p_added_dev->bd_addr);
|
||||
memset(p_added_dev->bd_addr, 0, 6);
|
||||
@@ -544,6 +544,11 @@ static void btc_hh_connect(btc_hidh_args_t *arg)
|
||||
BTC_TRACE_ERROR("%s exceeded the maximum supported HID device number %d!", __func__, BTC_HH_MAX_HID);
|
||||
ret = ESP_HIDH_ERR_NO_RES;
|
||||
break;
|
||||
} else if (dev && dev->dev_status == ESP_HIDH_CONN_STATE_CONNECTED) {
|
||||
BTC_TRACE_WARNING("%s Device[%s] already connected", __func__,
|
||||
bdaddr_to_string((const bt_bdaddr_t *)arg->connect.bd_addr, bdstr, sizeof(bdstr)));
|
||||
param.open.conn_status = ESP_HIDH_CONN_STATE_CONNECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < BTC_HH_MAX_ADDED_DEV; i++) {
|
||||
@@ -662,7 +667,7 @@ static void btc_hh_virtual_unplug(btc_hidh_args_t *arg)
|
||||
param.unplug.conn_status = ESP_HIDH_CONN_STATE_DISCONNECTING;
|
||||
param.unplug.handle = p_dev->dev_handle;
|
||||
} else if ((p_dev != NULL) && (p_dev->dev_status == ESP_HIDH_CONN_STATE_CONNECTED)) {
|
||||
BTC_TRACE_WARNING("%s: Virtual unplug not suported, disconnecting device", __func__);
|
||||
BTC_TRACE_WARNING("%s: Virtual unplug not supported, disconnecting device", __func__);
|
||||
/* start the timer */
|
||||
btc_hh_start_vup_timer(arg->unplug.bd_addr);
|
||||
p_dev->local_vup = true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -102,6 +102,7 @@ typedef enum {
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
BTC_GAP_BLE_ACT_CLEAR_ADV,
|
||||
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT,
|
||||
} btc_gap_ble_act_t;
|
||||
|
||||
/* btc_ble_gap_args_t */
|
||||
@@ -172,7 +173,7 @@ typedef union {
|
||||
//BTC_GAP_BLE_ACT_SET_DEV_NAME,
|
||||
struct set_dev_name_args {
|
||||
#define ESP_GAP_DEVICE_NAME_MAX (32)
|
||||
char device_name[ESP_GAP_DEVICE_NAME_MAX + 1];
|
||||
char *device_name;
|
||||
} set_dev_name;
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
//BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW,
|
||||
@@ -248,6 +249,12 @@ typedef union {
|
||||
struct dtm_rx_start_args {
|
||||
uint8_t rx_channel;
|
||||
} dtm_rx_start;
|
||||
//BTC_DEV_VENDOR_HCI_CMD_EVT
|
||||
struct vendor_cmd_send_args {
|
||||
uint16_t opcode;
|
||||
uint8_t param_len;
|
||||
uint8_t *p_param_buf;
|
||||
} vendor_cmd_send;
|
||||
} btc_ble_gap_args_t;
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -35,6 +35,7 @@ typedef enum {
|
||||
BTC_GAP_BT_SET_PAGE_TO_EVT,
|
||||
BTC_GAP_BT_GET_PAGE_TO_EVT,
|
||||
BTC_GAP_BT_SET_ACL_PKT_TYPES_EVT,
|
||||
BTC_GAP_BT_GET_DEV_NAME_CMPL_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -58,6 +59,8 @@ typedef enum {
|
||||
BTC_GAP_BT_ACT_SET_PAGE_TIMEOUT,
|
||||
BTC_GAP_BT_ACT_GET_PAGE_TIMEOUT,
|
||||
BTC_GAP_BT_ACT_SET_ACL_PKT_TYPES,
|
||||
BTC_GAP_BT_ACT_SET_DEV_NAME,
|
||||
BTC_GAP_BT_ACT_GET_DEV_NAME,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
@@ -165,6 +168,10 @@ typedef union {
|
||||
uint16_t pkt_types;
|
||||
} set_acl_pkt_types;
|
||||
|
||||
// BTC_GAP_BT_ACT_SET_DEV_NAME
|
||||
struct bt_set_dev_name_args {
|
||||
char *device_name;
|
||||
} bt_set_dev_name;
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -233,6 +233,11 @@ typedef struct
|
||||
esp_hf_outgoing_data_cb_t btc_hf_outgoing_data_cb;
|
||||
} hf_local_param_t;
|
||||
|
||||
#if HFP_DYNAMIC_MEMORY == TRUE
|
||||
extern hf_local_param_t *hf_local_param_ptr;
|
||||
#define hf_local_param (hf_local_param_ptr)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
** BTC HF AG Handle Hub
|
||||
********************************************************************************/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -285,8 +285,8 @@ static int free_sdp_slot(int id)
|
||||
// Record have already been freed
|
||||
handle = -1;
|
||||
}
|
||||
osi_free(slot);
|
||||
slot = NULL;
|
||||
osi_free(sdp_local_param.sdp_slots[id]);
|
||||
sdp_local_param.sdp_slots[id] = NULL;
|
||||
|
||||
return handle;
|
||||
}
|
||||
@@ -1034,14 +1034,16 @@ static void btc_sdp_remove_record(btc_sdp_args_t *arg)
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s SDP record with handle %d not found",
|
||||
__func__, arg->remove_record.record_handle);
|
||||
return;
|
||||
ret = ESP_SDP_NO_CREATE_RECORD;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the Record handle, and free the slot */
|
||||
/* The application layer record_handle is equivalent to the id of the btc layer */
|
||||
int slot = get_sdp_slot_id_by_handle(arg->remove_record.record_handle);
|
||||
if (slot < 0) {
|
||||
return;
|
||||
ret = ESP_SDP_NO_CREATE_RECORD;
|
||||
break;
|
||||
}
|
||||
|
||||
handle = free_sdp_slot(slot);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "l2c_int.h"
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
#include "stack/hcimsgs.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#define HCI_BLE_EVENT 0x3e
|
||||
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
|
||||
@@ -441,7 +442,7 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
uint8_t len = 0;
|
||||
STREAM_TO_UINT8(len, stream);
|
||||
#endif
|
||||
HCI_TRACE_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
HCI_TRACE_ERROR("Workaround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
packet->len, len);
|
||||
osi_free(packet);
|
||||
return;
|
||||
@@ -554,10 +555,14 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
bool is_adv_rpt = host_recv_adv_packet(data);
|
||||
|
||||
if (!is_adv_rpt) {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
uint8_t data_type = ((data[0] == 2) ? HCI_LOG_DATA_TYPE_C2H_ACL : data[0]);
|
||||
bt_hci_log_record_hci_data(data_type, data, len);
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
pkt_size = BT_HDR_SIZE + len;
|
||||
pkt = (BT_HDR *) osi_calloc(pkt_size);
|
||||
if (!pkt) {
|
||||
HCI_TRACE_ERROR("%s couldn't aquire memory for inbound data buffer.\n", __func__);
|
||||
HCI_TRACE_ERROR("%s couldn't acquire memory for inbound data buffer.\n", __func__);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -567,6 +572,10 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
memcpy(pkt->data, data, len);
|
||||
fixed_queue_enqueue(hci_hal_env.rx_q, pkt, FIXED_QUEUE_MAX_TIMEOUT);
|
||||
} else {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
// data type is adv report
|
||||
bt_hci_log_record_hci_adv(HCI_LOG_DATA_TYPE_ADV, data, len);
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
#if !BLE_ADV_REPORT_FLOW_CONTROL
|
||||
// drop the packets if pkt_queue length goes beyond upper limit
|
||||
if (pkt_queue_length(hci_hal_env.adv_rpt_q) > HCI_HAL_BLE_ADV_RPT_QUEUE_LEN_MAX) {
|
||||
|
||||
@@ -144,6 +144,10 @@ void hci_shut_down(void)
|
||||
|
||||
bool hci_downstream_data_post(uint32_t timeout)
|
||||
{
|
||||
if (hci_host_env.downstream_data_ready == NULL) {
|
||||
HCI_TRACE_WARNING("%s downstream_data_ready event not created", __func__);
|
||||
return false;
|
||||
}
|
||||
return osi_thread_post_event(hci_host_env.downstream_data_ready, timeout);
|
||||
}
|
||||
|
||||
@@ -263,7 +267,7 @@ static void transmit_command(
|
||||
// in case the upper layer didn't already
|
||||
command->event = MSG_STACK_TO_HC_HCI_CMD;
|
||||
|
||||
HCI_TRACE_DEBUG("HCI Enqueue Comamnd opcode=0x%x\n", metadata->opcode);
|
||||
HCI_TRACE_DEBUG("HCI Enqueue Command opcode=0x%x\n", metadata->opcode);
|
||||
BTTRC_DUMP_BUFFER(NULL, command->data + command->offset, command->len);
|
||||
|
||||
fixed_pkt_queue_enqueue(hci_host_env.command_queue, linked_pkt, FIXED_PKT_QUEUE_MAX_TIMEOUT);
|
||||
|
||||
@@ -2931,4 +2931,31 @@ uint8_t btm_ble_scan_active_count(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
uint8_t btm_ble_sec_dev_active_count(void)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
/* First look for the non-paired devices for the oldest entry */
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE) && (p_dev_rec->ble.key_type != BTM_LE_KEY_NONE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (BLE_PRIVACY_SPT == TRUE)
|
||||
uint8_t btm_ble_privacy_is_enabled(void)
|
||||
{
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
return (p_cb->privacy_mode != BTM_PRIVACY_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
@@ -27,6 +27,7 @@ static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len,
|
||||
typedef struct {
|
||||
uint16_t ter_con_handle;
|
||||
bool invalid;
|
||||
bool enabled;
|
||||
UINT8 instance;
|
||||
int duration;
|
||||
int max_events;
|
||||
@@ -331,7 +332,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr)
|
||||
__func__, btm_ble_hci_status_to_str(err), err);
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
} else {
|
||||
// set random address success, update address infor
|
||||
// set random address success, update address info
|
||||
if(extend_adv_cb.inst[instance].configured && extend_adv_cb.inst[instance].connetable) {
|
||||
BTM_BleSetStaticAddr(rand_addr);
|
||||
BTM_UpdateAddrInfor(BLE_ADDR_RANDOM, rand_addr);
|
||||
@@ -415,7 +416,7 @@ end:
|
||||
BTM_TRACE_ERROR("LE EA SetParams: cmd err=0x%x", err);
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
} else {
|
||||
// set addr success, update address infor
|
||||
// set addr success, update address info
|
||||
BTM_UpdateAddrInfor(BLE_ADDR_RANDOM, rand_addr);
|
||||
}
|
||||
}
|
||||
@@ -540,6 +541,7 @@ end:
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++)
|
||||
{
|
||||
adv_record[i].invalid = false;
|
||||
adv_record[i].enabled = false;
|
||||
adv_record[i].instance = INVALID_VALUE;
|
||||
adv_record[i].duration = INVALID_VALUE;
|
||||
adv_record[i].max_events = INVALID_VALUE;
|
||||
@@ -550,6 +552,7 @@ end:
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
adv_record[index].invalid = false;
|
||||
adv_record[index].enabled = false;
|
||||
adv_record[index].instance = INVALID_VALUE;
|
||||
adv_record[index].duration = INVALID_VALUE;
|
||||
adv_record[index].max_events = INVALID_VALUE;
|
||||
@@ -563,6 +566,7 @@ end:
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
adv_record[index].invalid = true;
|
||||
adv_record[index].enabled = true;
|
||||
adv_record[index].instance = ext_adv[i].instance;
|
||||
adv_record[index].duration = ext_adv[i].duration;
|
||||
adv_record[index].max_events = ext_adv[i].max_events;
|
||||
@@ -588,12 +592,12 @@ tBTM_STATUS BTM_BleStartExtAdvRestart(uint8_t con_handle)
|
||||
}
|
||||
}
|
||||
|
||||
if((index >= MAX_BLE_ADV_INSTANCE) || (!adv_record[index].invalid) || (adv_record[index].retry_count > GATTC_CONNECT_RETRY_COUNT)) {
|
||||
if((index >= MAX_BLE_ADV_INSTANCE) || (!adv_record[index].invalid)) {
|
||||
return BTM_WRONG_MODE;
|
||||
}
|
||||
|
||||
adv_record[index].retry_count ++;
|
||||
BTM_TRACE_DEBUG("remote device did not reveive aux connect response, retatrt the extend adv to reconnect, adv handle %d con_handle %d\n", index, con_handle);
|
||||
BTM_TRACE_DEBUG("remote device did not receive aux connect response, retatrt the extend adv to reconnect, adv handle %d con_handle %d\n", index, con_handle);
|
||||
ext_adv.instance = adv_record[index].instance;
|
||||
ext_adv.duration = adv_record[index].duration;
|
||||
ext_adv.max_events = adv_record[index].max_events;
|
||||
@@ -794,8 +798,13 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params)
|
||||
|| (params->reports_disabled > 0x01)
|
||||
|| (params->filter_duplicates > 0x01)
|
||||
#endif
|
||||
|| (params->addr_type > 0x01) ||
|
||||
(params->sid > 0xf) || (params->skip > 0x01F3)) {
|
||||
/*If the Periodic Advertiser List is not used,
|
||||
the Advertising_SID, Advertiser Address_Type, and Advertiser Address
|
||||
parameters specify the periodic advertising device to listen to; otherwise they
|
||||
shall be ignored.*/
|
||||
|| (params->filter_policy == 0 && params->addr_type > 0x01)
|
||||
|| (params->filter_policy == 0 && params->sid > 0xf)
|
||||
|| (params->skip > 0x01F3)) {
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
BTM_TRACE_ERROR("%s, The sync parameters is invalid.", __func__);
|
||||
goto end;
|
||||
@@ -1196,6 +1205,7 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params)
|
||||
adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE;
|
||||
adv_record[params->adv_handle].invalid = false;
|
||||
}
|
||||
adv_record[params->adv_handle].enabled = false;
|
||||
|
||||
memcpy(&cb_params.adv_term, params, sizeof(tBTM_BLE_ADV_TERMINAT));
|
||||
|
||||
@@ -1311,6 +1321,19 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par
|
||||
|
||||
}
|
||||
|
||||
uint8_t btm_ble_ext_adv_active_count(void)
|
||||
{
|
||||
uint8_t count = 0;
|
||||
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++) {
|
||||
if (adv_record[i].enabled == true) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
@@ -2236,16 +2236,16 @@ UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
|
||||
/* device name */
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME) {
|
||||
if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
|
||||
if (strlen(btm_cb.cfg.ble_bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
|
||||
cp_len = (UINT16)(len - MIN_ADV_LENGTH);
|
||||
*p++ = cp_len + 1;
|
||||
*p++ = BTM_BLE_AD_TYPE_NAME_SHORT;
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.ble_bd_name, cp_len);
|
||||
} else {
|
||||
cp_len = (UINT16)strlen(btm_cb.cfg.bd_name);
|
||||
cp_len = (UINT16)strlen(btm_cb.cfg.ble_bd_name);
|
||||
*p++ = cp_len + 1;
|
||||
*p++ = BTM_BLE_AD_TYPE_NAME_CMPL;
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
|
||||
ARRAY_TO_STREAM(p, btm_cb.cfg.ble_bd_name, cp_len);
|
||||
}
|
||||
len -= (cp_len + MIN_ADV_LENGTH);
|
||||
data_mask &= ~BTM_BLE_AD_BIT_DEV_NAME;
|
||||
@@ -3291,6 +3291,7 @@ static void btm_ble_appearance_to_cod(UINT16 appearance, UINT8 *dev_class)
|
||||
case BTM_BLE_APPEARANCE_CYCLING_CADENCE:
|
||||
case BTM_BLE_APPEARANCE_CYCLING_POWER:
|
||||
case BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE:
|
||||
case BTM_BLE_APPEARANCE_STANDALONE_SPEAKER:
|
||||
case BTM_BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS:
|
||||
case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION:
|
||||
case BTM_BLE_APPEARANCE_OUTDOOR_SPORTS_LOCATION_AND_NAV:
|
||||
|
||||
@@ -824,6 +824,13 @@ void btm_ble_multi_adv_init(void)
|
||||
*******************************************************************************/
|
||||
void btm_ble_multi_adv_cleanup(void)
|
||||
{
|
||||
#if BTM_DYNAMIC_MEMORY == TRUE
|
||||
if (btm_multi_adv_cb_ptr == NULL)
|
||||
{
|
||||
BTM_TRACE_WARNING("%s memory has been freed", __func__);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (btm_multi_adv_cb.p_adv_inst) {
|
||||
osi_free(btm_multi_adv_cb.p_adv_inst);
|
||||
btm_multi_adv_cb.p_adv_inst = NULL;
|
||||
|
||||
@@ -81,7 +81,8 @@ void btm_dev_init (void)
|
||||
|
||||
/* Initialize nonzero defaults */
|
||||
#if (BTM_MAX_LOC_BD_NAME_LEN > 0)
|
||||
memset(btm_cb.cfg.bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
memset(btm_cb.cfg.ble_bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
memset(btm_cb.cfg.bredr_bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
|
||||
#endif
|
||||
|
||||
btm_cb.devcb.reset_timer.param = (TIMER_PARAM_TYPE)TT_DEV_RESET;
|
||||
@@ -449,11 +450,11 @@ static void btm_decode_ext_features_page (UINT8 page_number, const BD_FEATURES p
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
UINT8 *p;
|
||||
|
||||
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN)) {
|
||||
if (!p_name || !p_name[0] || (strlen ((char *)p_name) > BD_NAME_LEN) || (name_type > BT_DEVICE_TYPE_DUMO)) {
|
||||
return (BTM_ILLEGAL_VALUE);
|
||||
}
|
||||
|
||||
@@ -463,16 +464,26 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
/* Save the device name if local storage is enabled */
|
||||
p = (UINT8 *)btm_cb.cfg.bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
if (name_type & BT_DEVICE_TYPE_BLE) {
|
||||
p = (UINT8 *)btm_cb.cfg.ble_bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.ble_bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.ble_bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
p = (UINT8 *)btm_cb.cfg.bredr_bd_name;
|
||||
if (p != (UINT8 *)p_name) {
|
||||
BCM_STRNCPY_S(btm_cb.cfg.bredr_bd_name, p_name, BTM_MAX_LOC_BD_NAME_LEN);
|
||||
btm_cb.cfg.bredr_bd_name[BTM_MAX_LOC_BD_NAME_LEN] = '\0';
|
||||
}
|
||||
}
|
||||
#else
|
||||
p = (UINT8 *)p_name;
|
||||
#endif
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
if (btsnd_hcic_change_name(p)) {
|
||||
if ((name_type & BT_DEVICE_TYPE_BREDR) && btsnd_hcic_change_name(p)) {
|
||||
return (BTM_CMD_STARTED);
|
||||
} else
|
||||
#endif
|
||||
@@ -496,10 +507,33 @@ tBTM_STATUS BTM_SetLocalDeviceName (char *p_name)
|
||||
** is returned and p_name is set to NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name)
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name, tBT_DEVICE_TYPE name_type)
|
||||
{
|
||||
/*
|
||||
// name_type should be BT_DEVICE_TYPE_BLE or BT_DEVICE_TYPE_BREDR
|
||||
if (name_type > BT_DEVICE_TYPE_BREDR) {
|
||||
*p_name = NULL;
|
||||
BTM_TRACE_ERROR("name_type unknown %d", name_type);
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
*/
|
||||
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
*p_name = btm_cb.cfg.bd_name;
|
||||
if ((name_type == BT_DEVICE_TYPE_DUMO) &&
|
||||
(BCM_STRNCMP_S(btm_cb.cfg.bredr_bd_name, btm_cb.cfg.ble_bd_name, BTM_MAX_LOC_BD_NAME_LEN) != 0)) {
|
||||
*p_name = NULL;
|
||||
BTM_TRACE_ERROR("Error, BLE and BREDR have different names, return NULL\n");
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BLE) {
|
||||
*p_name = btm_cb.cfg.ble_bd_name;
|
||||
}
|
||||
|
||||
if (name_type & BT_DEVICE_TYPE_BREDR) {
|
||||
*p_name = btm_cb.cfg.bredr_bd_name;
|
||||
}
|
||||
|
||||
return (BTM_SUCCESS);
|
||||
#else
|
||||
*p_name = NULL;
|
||||
@@ -740,19 +774,20 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
#endif // (BLE_INCLUDED == TRUE)
|
||||
tBTM_VSC_CMPL vcs_cplt_params;
|
||||
|
||||
/* If there was a callback address for vcs complete, call it */
|
||||
if (p_vsc_cplt_cback) {
|
||||
/* Pass paramters to the callback function */
|
||||
/* Pass parameters to the callback function */
|
||||
vcs_cplt_params.opcode = opcode; /* Number of bytes in return info */
|
||||
vcs_cplt_params.param_len = evt_len; /* Number of bytes in return info */
|
||||
vcs_cplt_params.p_param_buf = p;
|
||||
(*p_vsc_cplt_cback)(&vcs_cplt_params); /* Call the VSC complete callback function */
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -133,20 +133,3 @@ uint8_t btm_acl_active_count(void)
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8_t btdm_sec_dev_active_count(void)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
uint8_t count = 0;
|
||||
|
||||
/* First look for the non-paired devices for the oldest entry */
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if (p_dev_rec && (p_dev_rec->sec_flags & BTM_SEC_IN_USE)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed autorization will take place */
|
||||
/* Reset the temporary authorized flag so that next time (untrusted) service is accessed authorization will take place */
|
||||
if (p_dev_rec->last_author_service_id != BTM_SEC_NO_LAST_SERVICE_ID && p_dev_rec->p_cur_service) {
|
||||
BTM_TRACE_DEBUG ("btm_sec_clr_auth_service_by_psm [clearing device: %02x:%02x:%02x:%02x:%02x:%02x]\n",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
@@ -1364,7 +1364,7 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
|
||||
|| (transport == BT_TRANSPORT_LE && p_dev_rec->ble_hci_handle == BTM_SEC_INVALID_HANDLE)
|
||||
#endif
|
||||
) {
|
||||
/* Connection should be up and runnning */
|
||||
/* Connection should be up and running */
|
||||
BTM_TRACE_WARNING ("Security Manager: BTM_SetEncryption not connected\n");
|
||||
|
||||
if (p_callback) {
|
||||
@@ -1790,15 +1790,15 @@ UINT16 BTM_BuildOobData(UINT8 *p_data, UINT16 max_len, BT_OCTET16 c,
|
||||
}
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
name_size = name_len;
|
||||
if (name_size > strlen(btm_cb.cfg.bd_name)) {
|
||||
if (name_size > strlen(btm_cb.cfg.bredr_bd_name)) {
|
||||
name_type = BTM_EIR_COMPLETE_LOCAL_NAME_TYPE;
|
||||
name_size = (UINT16)strlen(btm_cb.cfg.bd_name);
|
||||
name_size = (UINT16)strlen(btm_cb.cfg.bredr_bd_name);
|
||||
}
|
||||
delta = name_size + 2;
|
||||
if (max_len >= delta) {
|
||||
*p++ = name_size + 1;
|
||||
*p++ = name_type;
|
||||
ARRAY_TO_STREAM (p, btm_cb.cfg.bd_name, name_size);
|
||||
ARRAY_TO_STREAM (p, btm_cb.cfg.bredr_bd_name, name_size);
|
||||
len += delta;
|
||||
max_len -= delta;
|
||||
}
|
||||
@@ -2118,7 +2118,7 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
|
||||
|
||||
/* If there is no application registered with this PSM do not allow connection */
|
||||
if (!p_serv_rec) {
|
||||
BTM_TRACE_WARNING ("%s() PSM: %d no application registerd\n", __func__, psm);
|
||||
BTM_TRACE_WARNING ("%s() PSM: %d no application registered\n", __func__, psm);
|
||||
(*p_callback) (bd_addr, transport, p_ref_data, BTM_MODE_UNSUPPORTED);
|
||||
return (BTM_MODE_UNSUPPORTED);
|
||||
}
|
||||
@@ -2514,7 +2514,7 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
|
||||
|
||||
if (rc == BTM_SUCCESS) {
|
||||
BTM_TRACE_EVENT("%s: allow to bypass, checking authorization\n", __FUNCTION__);
|
||||
/* the security in BTM_SEC_IN_FLAGS is fullfilled so far, check the requirements in */
|
||||
/* the security in BTM_SEC_IN_FLAGS is fulfilled so far, check the requirements in */
|
||||
/* btm_sec_execute_procedure */
|
||||
if ((is_originator && (p_serv_rec->security_flags & BTM_SEC_OUT_AUTHORIZE)) ||
|
||||
(!is_originator && (p_serv_rec->security_flags & BTM_SEC_IN_AUTHORIZE))) {
|
||||
@@ -3979,7 +3979,7 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
|
||||
/* or BR key is higher security than existing LE keys */
|
||||
(!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) &&
|
||||
(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED)))) {
|
||||
BTM_TRACE_DEBUG ("link encrypted afer dedic bonding can use SMP_BR_CHNL\n");
|
||||
BTM_TRACE_DEBUG ("link encrypted after dedic bonding can use SMP_BR_CHNL\n");
|
||||
|
||||
if (btm_sec_is_master(p_dev_rec)) {
|
||||
// Encryption is required to start SM over BR/EDR
|
||||
@@ -4255,7 +4255,7 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
|
||||
** Function btm_sec_connected
|
||||
**
|
||||
** Description This function is when a connection to the peer device is
|
||||
** establsihed
|
||||
** established
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
@@ -5926,7 +5926,7 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
**
|
||||
** Function btm_sec_auth_payload_tout
|
||||
**
|
||||
** Description Processes the HCI Autheniticated Payload Timeout Event
|
||||
** Description Processes the HCI Authenticated Payload Timeout Event
|
||||
** indicating that a packet containing a valid MIC on the
|
||||
** connection handle was not received within the programmed
|
||||
** timeout value. (Spec Default is 30 secs, but can be
|
||||
@@ -6294,7 +6294,7 @@ static BOOLEAN btm_sec_is_master(tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
** Description This function is called when legacy authentication is used
|
||||
** and only remote device has completed the authentication
|
||||
**
|
||||
** Returns TRUE if aunthentication command sent successfully
|
||||
** Returns TRUE if authentication command sent successfully
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btm_sec_legacy_authentication_mutual (tBTM_SEC_DEV_REC *p_dev_rec)
|
||||
|
||||
@@ -715,7 +715,8 @@ struct tBTM_SEC_DEV_REC{
|
||||
*/
|
||||
typedef struct {
|
||||
#if BTM_MAX_LOC_BD_NAME_LEN > 0
|
||||
tBTM_LOC_BD_NAME bd_name; /* local Bluetooth device name */
|
||||
tBTM_LOC_BD_NAME bredr_bd_name; /* local BREDR device name */
|
||||
tBTM_LOC_BD_NAME ble_bd_name; /* local BLE device name */
|
||||
#endif
|
||||
BOOLEAN pin_type; /* TRUE if PIN type is fixed */
|
||||
UINT8 pin_code_len; /* Bonding information */
|
||||
|
||||
@@ -1241,6 +1241,9 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context)
|
||||
static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_cmd,
|
||||
void *p_vsc_status_cback)
|
||||
{
|
||||
if (status != HCI_SUCCESS){
|
||||
HCI_TRACE_WARNING("%s,opcode:0x%04x,status:0x%02x", __func__, opcode,status);
|
||||
}
|
||||
BD_ADDR bd_addr;
|
||||
UINT16 handle;
|
||||
#if BTM_SCO_INCLUDED == TRUE
|
||||
|
||||
@@ -98,11 +98,11 @@ void btu_init_core(void)
|
||||
#endif
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true)
|
||||
gatt_init();
|
||||
#endif
|
||||
#if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE)
|
||||
SMP_Init();
|
||||
#endif
|
||||
#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true)
|
||||
gatt_init();
|
||||
#endif
|
||||
btm_ble_init();
|
||||
#endif
|
||||
|
||||
@@ -65,7 +65,7 @@ static const tGATT_CBACK gap_cback = {
|
||||
**
|
||||
** Function gap_find_clcb_by_bd_addr
|
||||
**
|
||||
** Description The function searches all LCB with macthing bd address
|
||||
** Description The function searches all LCB with matching bd address
|
||||
**
|
||||
** Returns total number of clcb found.
|
||||
**
|
||||
@@ -88,7 +88,7 @@ tGAP_CLCB *gap_find_clcb_by_bd_addr(BD_ADDR bda)
|
||||
**
|
||||
** Function gap_ble_find_clcb_by_conn_id
|
||||
**
|
||||
** Description The function searches all LCB with macthing connection ID
|
||||
** Description The function searches all LCB with matching connection ID
|
||||
**
|
||||
** Returns total number of clcb found.
|
||||
**
|
||||
@@ -163,7 +163,7 @@ void gap_ble_dealloc_clcb(tGAP_CLCB *p_clcb)
|
||||
**
|
||||
** Description The function enqueue a GAP client request
|
||||
**
|
||||
** Returns TRUE is successul; FALSE otherwise
|
||||
** Returns TRUE is successful; FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_CBACK *p_cback)
|
||||
@@ -185,7 +185,7 @@ BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_C
|
||||
**
|
||||
** Description The function dequeue a GAP client request if any
|
||||
**
|
||||
** Returns TRUE is successul; FALSE otherwise
|
||||
** Returns TRUE is successful; FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN gap_ble_dequeue_request (tGAP_CLCB *p_clcb, UINT16 *p_uuid, tGAP_BLE_CMPL_CBACK **p_cback)
|
||||
@@ -221,7 +221,7 @@ tGATT_STATUS gap_read_attr_value (UINT16 handle, tGATT_VALUE *p_value, BOOLEAN i
|
||||
|
||||
switch (p_db_attr->uuid) {
|
||||
case GATT_UUID_GAP_DEVICE_NAME:
|
||||
BTM_ReadLocalDeviceName((char **)&p_dev_name);
|
||||
BTM_ReadLocalDeviceName((char **)&p_dev_name, BT_DEVICE_TYPE_BLE);
|
||||
if (strlen ((char *)p_dev_name) > GATT_MAX_ATTR_LEN) {
|
||||
p_value->len = GATT_MAX_ATTR_LEN;
|
||||
} else {
|
||||
@@ -304,7 +304,7 @@ UINT8 gap_proc_write_req( tGATTS_REQ_TYPE type, tGATT_WRITE_REQ *p_data)
|
||||
case GATT_UUID_GAP_DEVICE_NAME: {
|
||||
UINT8 *p_val = p_data->value;
|
||||
p_val[p_data->len] = '\0';
|
||||
BTM_SetLocalDeviceName((char *)p_val);
|
||||
BTM_SetLocalDeviceName((char *)p_val, BT_DEVICE_TYPE_BLE);
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
@@ -385,7 +385,7 @@ void gap_ble_s_attr_request_cback (UINT16 conn_id, UINT32 trans_id,
|
||||
**
|
||||
** Function btm_ble_att_db_init
|
||||
**
|
||||
** Description GAP ATT database initalization.
|
||||
** Description GAP ATT database initialization.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
@@ -510,7 +510,7 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
|
||||
break;
|
||||
|
||||
case GATT_UUID_GAP_DEVICE_NAME:
|
||||
BTM_SetLocalDeviceName((char *)p_value->p_dev_name);
|
||||
BTM_SetLocalDeviceName((char *)p_value->p_dev_name, BT_DEVICE_TYPE_BLE);
|
||||
break;
|
||||
|
||||
case GATT_UUID_GAP_CENTRAL_ADDR_RESOL:
|
||||
@@ -529,7 +529,7 @@ void GAP_BleAttrDBUpdate(UINT16 attr_uuid, tGAP_BLE_ATTR_VALUE *p_value)
|
||||
**
|
||||
** Function gap_ble_send_cl_read_request
|
||||
**
|
||||
** Description utility function to send a read request for a GAP charactersitic
|
||||
** Description utility function to send a read request for a GAP characteristic
|
||||
**
|
||||
** Returns TRUE if read started, else FALSE if GAP is busy
|
||||
**
|
||||
|
||||
@@ -379,6 +379,7 @@ tHID_STATUS HID_HostAddDev ( BD_ADDR addr, UINT16 attr_mask, UINT8 *handle )
|
||||
if (!hh_cb.devices[i].in_use) {
|
||||
hh_cb.devices[i].in_use = TRUE;
|
||||
hh_cb.devices[i].delay_remove = FALSE;
|
||||
hh_cb.devices[i].is_orig = FALSE;
|
||||
memcpy( hh_cb.devices[i].addr, addr, sizeof( BD_ADDR ) ) ;
|
||||
hh_cb.devices[i].state = HID_DEV_NO_CONN;
|
||||
hh_cb.devices[i].conn_tries = 0 ;
|
||||
@@ -486,6 +487,7 @@ tHID_STATUS HID_HostOpenDev ( UINT8 dev_handle )
|
||||
}
|
||||
|
||||
hh_cb.devices[dev_handle].conn_tries = 1;
|
||||
hh_cb.devices[dev_handle].is_orig = TRUE;
|
||||
return hidh_conn_initiate( dev_handle );
|
||||
}
|
||||
|
||||
@@ -651,4 +653,23 @@ BOOLEAN hid_known_hid_device (BD_ADDR bd_addr)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN HID_HostConnectOrig(UINT8 dev_handle)
|
||||
{
|
||||
BOOLEAN ret = FALSE;
|
||||
|
||||
do {
|
||||
if (!hh_cb.reg_flag) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((dev_handle >= HID_HOST_MAX_DEVICES) || (!hh_cb.devices[dev_handle].in_use)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ret = hh_cb.devices[dev_handle].is_orig;
|
||||
} while (0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif //HID_HOST_INCLUDED
|
||||
|
||||
@@ -35,11 +35,11 @@ enum { HID_DEV_NO_CONN, HID_DEV_CONNECTED };
|
||||
typedef struct per_device_ctb {
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN delay_remove;
|
||||
BOOLEAN is_orig;
|
||||
BD_ADDR addr; /* BD-Addr of the host device */
|
||||
UINT16 attr_mask; /* 0x01- virtual_cable; 0x02- normally_connectable; 0x03- reconn_initiate;
|
||||
0x04- sdp_disable; */
|
||||
UINT8 state; /* Device state if in HOST-KNOWN mode */
|
||||
UINT8 conn_substate;
|
||||
UINT8 conn_tries; /* Remembers to the number of connection attempts while CONNECTING */
|
||||
|
||||
tHID_CONN conn; /* L2CAP channel info */
|
||||
|
||||
@@ -33,6 +33,8 @@ typedef int32_t INT32;
|
||||
|
||||
#define BCM_STRCPY_S(x1,x2) strcpy((x1),(x2))
|
||||
#define BCM_STRNCPY_S(x1,x2,x3) strncpy((x1),(x2),(x3))
|
||||
#define BCM_STRCMP_S(x1,x2) strcmp((x1),(x2))
|
||||
#define BCM_STRNCMP_S(x1,x2,x3) strncmp((x1),(x2),(x3))
|
||||
|
||||
/* READ WELL !!
|
||||
**
|
||||
|
||||
@@ -470,7 +470,6 @@ typedef enum {
|
||||
#define BTM_COD_SERVICE_CLASS_LO_B 0x00E0
|
||||
#define BTM_COD_SERVICE_CLASS_MASK 0xFFE0
|
||||
|
||||
|
||||
/* BTM service definitions
|
||||
** Used for storing EIR data to bit mask
|
||||
*/
|
||||
@@ -2067,7 +2066,7 @@ BOOLEAN BTM_IsDeviceUp (void);
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name);
|
||||
tBTM_STATUS BTM_SetLocalDeviceName (char *p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2096,7 +2095,7 @@ tBTM_STATUS BTM_SetDeviceClass (DEV_CLASS dev_class);
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name);
|
||||
tBTM_STATUS BTM_ReadLocalDeviceName (char **p_name, tBT_DEVICE_TYPE name_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -254,6 +254,7 @@ typedef UINT8 BLE_SIGNATURE[BTM_BLE_AUTH_SIGN_LEN]; /* Device address */
|
||||
#define BTM_BLE_APPEARANCE_CYCLING_CADENCE 0x0483
|
||||
#define BTM_BLE_APPEARANCE_CYCLING_POWER 0x0484
|
||||
#define BTM_BLE_APPEARANCE_CYCLING_SPEED_CADENCE 0x0485
|
||||
#define BTM_BLE_APPEARANCE_STANDALONE_SPEAKER 0x0841
|
||||
#define BTM_BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 0x0C40
|
||||
#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 0x0C41
|
||||
#define BTM_BLE_APPEARANCE_PULSE_OXIMETER_WRIST 0x0C42
|
||||
|
||||
@@ -249,6 +249,17 @@ BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
|
||||
*******************************************************************************/
|
||||
extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function HID_HostConnectOrig
|
||||
**
|
||||
** Description Check if the HID Host initiates the connection
|
||||
**
|
||||
** Returns TRUE if the HID Host initiates the connection else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN HID_HostConnectOrig(UINT8 dev_handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -367,6 +367,11 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
if (reason != HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT) {
|
||||
BTM_Recovery_Pre_State();
|
||||
}
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
if(btm_ble_inter_get() && reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) {
|
||||
BTM_BleStartExtAdvRestart(handle);
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
status = FALSE;
|
||||
} else {
|
||||
@@ -438,7 +443,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
#endif
|
||||
{
|
||||
#if (L2CAP_NUM_FIXED_CHNLS > 0)
|
||||
/* If we are going to re-use the LCB without dropping it, release all fixed channels
|
||||
/* If we are going to reuse the LCB without dropping it, release all fixed channels
|
||||
here */
|
||||
int xx;
|
||||
for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++) {
|
||||
@@ -463,9 +468,9 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
}
|
||||
|
||||
p_lcb->p_pending_ccb = NULL;
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_CONNECT_RETRY_EN == TRUE)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if(reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT && p_lcb->transport == BT_TRANSPORT_LE) {
|
||||
|
||||
#if (GATTC_CONNECT_RETRY_EN == TRUE)
|
||||
if(p_lcb->link_role == HCI_ROLE_MASTER && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
||||
L2CAP_TRACE_DEBUG("master retry connect, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||
p_lcb->retry_create_con ++;
|
||||
@@ -475,9 +480,10 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
lcb_is_free = FALSE; /* still using this lcb */
|
||||
}
|
||||
}
|
||||
#endif // (GATTC_CONNECT_RETRY_EN == TRUE)
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
||||
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
||||
p_lcb->retry_create_con ++;
|
||||
L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||
BTM_BleStartExtAdvRestart(handle);
|
||||
@@ -485,7 +491,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
||||
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
||||
p_lcb->retry_create_con ++;
|
||||
L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||
btm_ble_start_adv();
|
||||
@@ -909,7 +915,7 @@ UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles)
|
||||
**
|
||||
** Function l2c_link_role_changed
|
||||
**
|
||||
** Description This function is called whan a link's master/slave role change
|
||||
** Description This function is called when a link's master/slave role change
|
||||
** event is received. It simply updates the link control block.
|
||||
**
|
||||
** Returns void
|
||||
@@ -947,7 +953,7 @@ void l2c_link_role_changed (BD_ADDR bd_addr, UINT8 new_role, UINT8 hci_status)
|
||||
**
|
||||
** Function l2c_pin_code_request
|
||||
**
|
||||
** Description This function is called whan a pin-code request is received
|
||||
** Description This function is called when a pin-code request is received
|
||||
** on a connection. If there are no channels active yet on the
|
||||
** link, it extends the link first connection timer. Make sure
|
||||
** that inactivity timer is not extended if PIN code happens
|
||||
|
||||
@@ -388,8 +388,7 @@ config BT_NIMBLE_RPA_TIMEOUT
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default 900
|
||||
help
|
||||
Time interval between RPA address change. This is applicable in case of
|
||||
Host based RPA
|
||||
Time interval between RPA address change.
|
||||
|
||||
menuconfig BT_NIMBLE_MESH
|
||||
bool "Enable BLE mesh functionality"
|
||||
@@ -523,7 +522,7 @@ config BT_NIMBLE_ENABLE_CONN_REATTEMPT
|
||||
|
||||
config BT_NIMBLE_MAX_CONN_REATTEMPT
|
||||
int "Maximum number connection reattempts"
|
||||
range 1 7
|
||||
range 1 255
|
||||
default 3
|
||||
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_ENABLE_CONN_REATTEMPT
|
||||
help
|
||||
@@ -634,8 +633,9 @@ config BT_NIMBLE_PERIODIC_ADV_ENH
|
||||
menuconfig BT_NIMBLE_GATT_CACHING
|
||||
bool "Enable GATT caching"
|
||||
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_50_FEATURE_SUPPORT
|
||||
select BT_NIMBLE_DYNAMIC_SERVICE
|
||||
help
|
||||
Enable GATT caching
|
||||
Enable GATT caching
|
||||
config BT_NIMBLE_GATT_CACHING_MAX_CONNS
|
||||
int "Maximum connections to be cached"
|
||||
depends on BT_NIMBLE_GATT_CACHING
|
||||
@@ -942,9 +942,35 @@ menu "Host-controller Transport"
|
||||
help
|
||||
Uart port
|
||||
|
||||
choice BT_NIMBLE_HCI_USE_UART_BAUDRATE
|
||||
prompt "Uart Hci Baud Rate"
|
||||
default UART_BAUDRATE_921600
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
help
|
||||
Uart Baud Rate
|
||||
|
||||
config UART_BAUDRATE_115200
|
||||
bool "115200"
|
||||
config UART_BAUDRATE_230400
|
||||
bool "230400"
|
||||
config UART_BAUDRATE_460800
|
||||
bool "460800"
|
||||
config UART_BAUDRATE_921600
|
||||
bool "921600"
|
||||
endchoice
|
||||
|
||||
config BT_NIMBLE_HCI_UART_BAUDRATE
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
int
|
||||
default 115200 if UART_BAUDRATE_115200
|
||||
default 230400 if UART_BAUDRATE_230400
|
||||
default 460800 if UART_BAUDRATE_460800
|
||||
default 921600 if UART_BAUDRATE_921600
|
||||
|
||||
choice BT_NIMBLE_USE_HCI_UART_PARITY
|
||||
prompt "Uart PARITY"
|
||||
default UART_PARITY_NONE
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
help
|
||||
Uart Parity
|
||||
|
||||
@@ -960,16 +986,19 @@ menu "Host-controller Transport"
|
||||
int
|
||||
default 0 if !UART_PARITY_NONE
|
||||
default 1 if UART_PARITY_NONE
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
|
||||
config BT_NIMBLE_TRANSPORT_UART_PARITY_ODD
|
||||
int
|
||||
default 0 if !UART_PARITY_ODD
|
||||
default 1 if UART_PARITY_ODD
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
|
||||
config BT_NIMBLE_TRANSPORT_UART_PARITY_EVEN
|
||||
int
|
||||
default 0 if !UART_PARITY_EVEN
|
||||
default 1 if UART_PARITY_EVEN
|
||||
depends on BT_CONTROLLER_DISABLED && BT_NIMBLE_TRANSPORT_UART
|
||||
|
||||
config BT_NIMBLE_UART_RX_PIN
|
||||
int "UART Rx pin"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_compiler.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "bt_common.h"
|
||||
#include "hci_log/bt_hci_log.h"
|
||||
|
||||
#define NIMBLE_VHCI_TIMEOUT_MS 2000
|
||||
#define BLE_HCI_EVENT_HDR_LEN (2)
|
||||
@@ -75,6 +77,9 @@ int ble_hci_trans_hs_cmd_tx(uint8_t *cmd)
|
||||
}
|
||||
|
||||
if (xSemaphoreTake(vhci_send_sem, NIMBLE_VHCI_TIMEOUT_MS / portTICK_PERIOD_MS) == pdTRUE) {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(cmd[0], cmd, len);
|
||||
#endif
|
||||
esp_vhci_host_send_packet(cmd, len);
|
||||
} else {
|
||||
rc = BLE_HS_ETIMEOUT_HCI;
|
||||
@@ -112,6 +117,9 @@ int ble_hci_trans_hs_acl_tx(struct os_mbuf *om)
|
||||
len += OS_MBUF_PKTLEN(om);
|
||||
|
||||
if (xSemaphoreTake(vhci_send_sem, NIMBLE_VHCI_TIMEOUT_MS / portTICK_PERIOD_MS) == pdTRUE) {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(data[0], data, len);
|
||||
#endif
|
||||
esp_vhci_host_send_packet(data, len);
|
||||
} else {
|
||||
rc = BLE_HS_ETIMEOUT_HCI;
|
||||
@@ -215,12 +223,18 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
/* Allocate LE Advertising Report Event from lo pool only */
|
||||
if ((data[1] == BLE_HCI_EVCODE_LE_META) &&
|
||||
(data[3] == BLE_HCI_LE_SUBEV_ADV_RPT || data[3] == BLE_HCI_LE_SUBEV_EXT_ADV_RPT)) {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_adv(HCI_LOG_DATA_TYPE_ADV, data, len);
|
||||
#endif
|
||||
evbuf = ble_transport_alloc_evt(1);
|
||||
/* Skip advertising report if we're out of memory */
|
||||
if (!evbuf) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(data[0], data, len);
|
||||
#endif
|
||||
evbuf = ble_transport_alloc_evt(0);
|
||||
assert(evbuf != NULL);
|
||||
}
|
||||
@@ -231,6 +245,9 @@ static int host_rcv_pkt(uint8_t *data, uint16_t len)
|
||||
rc = ble_hci_trans_ll_evt_tx(evbuf);
|
||||
assert(rc == 0);
|
||||
} else if (data[0] == BLE_HCI_UART_H4_ACL) {
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_record_hci_data(HCI_LOG_DATA_TYPE_C2H_ACL, data, len);
|
||||
#endif
|
||||
ble_hci_rx_acl(data + 1, len - 1);
|
||||
}
|
||||
return 0;
|
||||
@@ -265,6 +282,10 @@ esp_err_t esp_nimble_hci_init(void)
|
||||
goto err;
|
||||
}
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_init();
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
|
||||
xSemaphoreGive(vhci_send_sem);
|
||||
|
||||
#if MYNEWT_VAL(BLE_QUEUE_CONG_CHECK)
|
||||
@@ -292,6 +313,10 @@ esp_err_t esp_nimble_hci_deinit(void)
|
||||
|
||||
ble_buf_free();
|
||||
|
||||
#if (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
bt_hci_log_deinit();
|
||||
#endif // (BT_HCI_LOG_INCLUDED == TRUE)
|
||||
|
||||
#if MYNEWT_VAL(BLE_QUEUE_CONG_CHECK)
|
||||
ble_adv_list_deinit();
|
||||
#endif
|
||||
|
||||
Submodule components/bt/host/nimble/nimble updated: 7997c0067c...a2acac3e14
@@ -133,10 +133,31 @@
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING (CONFIG_BT_NIMBLE_GATT_CACHING)
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_GATT_CACHING_MAX_CONNS
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_CONNS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_CONNS)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_CONNS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_GATT_CACHING_MAX_SVCS
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_SVCS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_SVCS)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_SVCS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_GATT_CACHING_MAX_CHRS
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_CHRS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_CHRS)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_CHRS (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_GATT_CACHING_MAX_DSCS
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_DSCS (CONFIG_BT_NIMBLE_GATT_CACHING_MAX_DSCS)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_GATT_CACHING_MAX_DSCS (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES
|
||||
@@ -487,7 +508,11 @@
|
||||
/*** @apache-mynewt-nimble/nimble/host */
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_DYNAMIC_SERVICE
|
||||
#ifdef CONFIG_BT_NIMBLE_DYNAMIC_SERVICE
|
||||
#define MYNEWT_VAL_BLE_DYNAMIC_SERVICE CONFIG_BT_NIMBLE_DYNAMIC_SERVICE
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_DYNAMIC_SERVICE (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_ATT_PREFERRED_MTU
|
||||
@@ -610,6 +635,10 @@
|
||||
#define MYNEWT_VAL_BLE_GATT_READ_MULT (MYNEWT_VAL_BLE_ROLE_CENTRAL)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_GATT_READ_MULT_VAR
|
||||
#define MYNEWT_VAL_BLE_GATT_READ_MULT_VAR (MYNEWT_VAL_BLE_ROLE_CENTRAL)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_GATT_READ_UUID
|
||||
#define MYNEWT_VAL_BLE_GATT_READ_UUID (MYNEWT_VAL_BLE_ROLE_CENTRAL)
|
||||
#endif
|
||||
@@ -844,7 +873,11 @@
|
||||
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_LVL
|
||||
#ifdef CONFIG_BT_NIMBLE_SM_SC_LVL
|
||||
#define MYNEWT_VAL_BLE_SM_SC_LVL CONFIG_BT_NIMBLE_SM_SC_LVL
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_SM_SC_LVL (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SM_SC_ONLY
|
||||
@@ -1792,7 +1825,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_CONTROLLER_DISABLED
|
||||
#if CONFIG_BT_CONTROLLER_DISABLED && CONFIG_BT_NIMBLE_TRANSPORT_UART
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_PORT
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_PORT CONFIG_BT_NIMBLE_TRANSPORT_UART_PORT
|
||||
#endif
|
||||
@@ -1814,7 +1847,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE (921600)
|
||||
#define MYNEWT_VAL_BLE_TRANSPORT_UART_BAUDRATE CONFIG_BT_NIMBLE_HCI_UART_BAUDRATE
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_TRANSPORT_UART_DATA_BITS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
|
||||
#endif //CONFIG_BT_ENABLED
|
||||
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20221207
|
||||
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240315
|
||||
|
||||
/**
|
||||
* @brief Bluetooth mode for controller enable/disable
|
||||
@@ -167,6 +167,12 @@ the adv packet will be discarded until the memory is restored. */
|
||||
#define BTDM_CONTROLLER_SCO_DATA_PATH_HCI 0 // SCO data is routed to HCI
|
||||
#define BTDM_CONTROLLER_SCO_DATA_PATH_PCM 1 // SCO data path is PCM
|
||||
|
||||
#ifdef CONFIG_BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX CONFIG_BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
|
||||
#else
|
||||
#define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
|
||||
#endif
|
||||
|
||||
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
|
||||
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
|
||||
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
|
||||
@@ -190,6 +196,7 @@ the adv packet will be discarded until the memory is restored. */
|
||||
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
|
||||
.hli = BTDM_CTRL_HLI, \
|
||||
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
|
||||
.ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
|
||||
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
|
||||
}
|
||||
|
||||
@@ -233,6 +240,7 @@ typedef struct {
|
||||
uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge) */
|
||||
bool hli; /*!< Using high level interrupt or not */
|
||||
uint16_t dup_list_refresh_period; /*!< Duplicate scan list refresh period */
|
||||
bool ble_scan_backoff; /*!< BLE scan backoff */
|
||||
uint32_t magic; /*!< Magic number */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02401120
|
||||
#define ESP_BT_CTRL_CONFIG_VERSION 0x02404010
|
||||
|
||||
#define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead
|
||||
#define ESP_BT_HCI_TL_VERSION 0x00010000
|
||||
@@ -194,6 +194,18 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
#define BT_BLE_ADV_DATA_LENGTH_ZERO_AUX (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_CTRL_CHAN_ASS_EN)
|
||||
#define BT_CTRL_CHAN_ASS_EN (CONFIG_BT_CTRL_CHAN_ASS_EN)
|
||||
#else
|
||||
#define BT_CTRL_CHAN_ASS_EN (0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_CTRL_LE_PING_EN)
|
||||
#define BT_CTRL_LE_PING_EN (CONFIG_BT_CTRL_LE_PING_EN)
|
||||
#else
|
||||
#define BT_CTRL_LE_PING_EN (0)
|
||||
#endif
|
||||
|
||||
#define AGC_RECORRECT_EN ((BT_CTRL_AGC_RECORRECT_EN << 0) | (BT_CTRL_CODED_AGC_RECORRECT <<1) | (BT_CTRL_AGC_RECORRECT_NEW << 2))
|
||||
|
||||
#define CFG_MASK_BIT_SCAN_DUPLICATE_OPTION (1<<0)
|
||||
@@ -241,6 +253,8 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);
|
||||
.ble_50_feat_supp = BT_CTRL_50_FEATURE_SUPPORT, \
|
||||
.ble_cca_mode = BT_BLE_CCA_MODE, \
|
||||
.ble_data_lenth_zero_aux = BT_BLE_ADV_DATA_LENGTH_ZERO_AUX, \
|
||||
.ble_chan_ass_en = BT_CTRL_CHAN_ASS_EN, \
|
||||
.ble_ping_en = BT_CTRL_LE_PING_EN, \
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -289,7 +303,7 @@ typedef struct {
|
||||
uint8_t sleep_clock; /*!< controller sleep clock */
|
||||
uint8_t ble_st_acl_tx_buf_nb; /*!< controller static ACL TX BUFFER number */
|
||||
uint8_t ble_hw_cca_check; /*!< controller hardware triggered CCA check */
|
||||
uint16_t ble_adv_dup_filt_max; /*!< maxinum number of duplicate scan filter */
|
||||
uint16_t ble_adv_dup_filt_max; /*!< maximum number of duplicate scan filter */
|
||||
bool coex_param_en; /*!< deprecated */
|
||||
uint8_t ce_len_type; /*!< connection event length computation method */
|
||||
bool coex_use_hooks; /*!< deprecated */
|
||||
@@ -312,7 +326,9 @@ typedef struct {
|
||||
uint16_t dup_list_refresh_period; /*!< duplicate scan list refresh time */
|
||||
bool ble_50_feat_supp; /*!< BLE 5.0 feature support */
|
||||
uint8_t ble_cca_mode; /*!< BLE CCA mode */
|
||||
uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option*/
|
||||
uint8_t ble_data_lenth_zero_aux; /*!< Config ext adv aux option */
|
||||
uint8_t ble_chan_ass_en; /*!< BLE channel assessment enable */
|
||||
uint8_t ble_ping_en; /*!< BLE ping procedure enable */
|
||||
} esp_bt_controller_config_t;
|
||||
|
||||
/**
|
||||
@@ -600,6 +616,15 @@ void esp_wifi_bt_power_domain_on(void);
|
||||
*/
|
||||
void esp_wifi_bt_power_domain_off(void);
|
||||
|
||||
/**
|
||||
* @brief Get the Bluetooth module sleep clock source.
|
||||
*
|
||||
* Note that this function shall not be invoked before esp_bt_controller_init()
|
||||
*
|
||||
* @return clock source used in Bluetooth low power mode
|
||||
*/
|
||||
esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
[sections:bt_bss]
|
||||
entries:
|
||||
.bss+
|
||||
|
||||
[sections:bt_common]
|
||||
entries:
|
||||
COMMON
|
||||
|
||||
[scheme:bt_start_end]
|
||||
entries:
|
||||
bt_bss -> dram0_bss
|
||||
bt_common -> dram0_bss
|
||||
data -> dram0_data
|
||||
|
||||
# For the following fragments, order matters for
|
||||
# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates:
|
||||
#
|
||||
# . = ALIGN(4)
|
||||
# _sym_start
|
||||
# ...
|
||||
# . = ALIGN(4)
|
||||
# _sym_end
|
||||
|
||||
[mapping:bt]
|
||||
archive: libbt.a
|
||||
entries:
|
||||
if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
|
||||
* (extram_bss)
|
||||
else:
|
||||
* (bt_start_end);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||
|
||||
[mapping:btdm]
|
||||
archive: libbtdm_app.a
|
||||
entries:
|
||||
* (bt_start_end);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(btdm_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(btdm_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(btdm_data)
|
||||
|
||||
[mapping:bt_controller]
|
||||
archive: libble_app.a
|
||||
entries:
|
||||
* (bt_start_end);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
||||
|
||||
[mapping:nimble]
|
||||
archive: libnimble.a
|
||||
entries:
|
||||
* (bt_start_end);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(nimble_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(nimble_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(nimble_data)
|
||||
42
components/bt/linker_common.lf
Normal file
42
components/bt/linker_common.lf
Normal file
@@ -0,0 +1,42 @@
|
||||
[sections:bt_bss]
|
||||
entries:
|
||||
.bss+
|
||||
|
||||
[sections:bt_common]
|
||||
entries:
|
||||
COMMON
|
||||
|
||||
[scheme:bt_default]
|
||||
entries:
|
||||
bt_bss -> dram0_bss
|
||||
bt_common -> dram0_bss
|
||||
data -> dram0_data
|
||||
|
||||
[scheme:bt_extram_bss]
|
||||
entries:
|
||||
bt_bss -> extern_ram
|
||||
bt_common -> extern_ram
|
||||
data -> dram0_data
|
||||
|
||||
# For the following fragments, order matters for
|
||||
# 'ALIGN(4) ALIGN(4, post) SURROUND(sym)', which generates:
|
||||
#
|
||||
# . = ALIGN(4)
|
||||
# _sym_start
|
||||
# ...
|
||||
# . = ALIGN(4)
|
||||
# _sym_end
|
||||
|
||||
[mapping:bt]
|
||||
archive: libbt.a
|
||||
entries:
|
||||
if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
|
||||
* (bt_extram_bss);
|
||||
bt_bss -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||
bt_common -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||
else:
|
||||
* (bt_default);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||
@@ -1,4 +1,4 @@
|
||||
[sections:bt_text]
|
||||
[sections:bt_iram_text]
|
||||
entries:
|
||||
.iram1+
|
||||
|
||||
@@ -17,9 +17,9 @@ entries:
|
||||
entries:
|
||||
COMMON
|
||||
|
||||
[scheme:bt_start_end]
|
||||
[scheme:bt_default]
|
||||
entries:
|
||||
bt_text -> iram0_bt_text
|
||||
bt_iram_text -> iram0_bt_text
|
||||
bt_bss -> dram0_bt_bss
|
||||
bt_common -> dram0_bt_bss
|
||||
bt_data -> dram0_bt_data
|
||||
@@ -36,25 +36,15 @@ entries:
|
||||
[mapping:bt]
|
||||
archive: libbt.a
|
||||
entries:
|
||||
* (bt_start_end);
|
||||
* (bt_default);
|
||||
bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||
bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||
bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||
if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
|
||||
* (extram_bss)
|
||||
|
||||
[mapping:btdm]
|
||||
archive: libbtdm_app.a
|
||||
entries:
|
||||
* (bt_start_end);
|
||||
bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(btdm_bss),
|
||||
bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(btdm_common),
|
||||
bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(btdm_data)
|
||||
|
||||
[mapping:bt_controller]
|
||||
[mapping:ble_app]
|
||||
archive: libble_app.a
|
||||
entries:
|
||||
* (bt_start_end);
|
||||
* (bt_default);
|
||||
bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||
bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||
bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
||||
7
components/bt/linker_esp_ble_controller.lf
Normal file
7
components/bt/linker_esp_ble_controller.lf
Normal file
@@ -0,0 +1,7 @@
|
||||
[mapping:ble_app]
|
||||
archive: libble_app.a
|
||||
entries:
|
||||
* (bt_default);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
||||
7
components/bt/linker_rw_bt_controller.lf
Normal file
7
components/bt/linker_rw_bt_controller.lf
Normal file
@@ -0,0 +1,7 @@
|
||||
[mapping:btdm]
|
||||
archive: libbtdm_app.a
|
||||
entries:
|
||||
* (bt_default);
|
||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
||||
@@ -84,6 +84,10 @@ extern "C" {
|
||||
#define NIMBLE_BLE_ATT_CLT_READ_MULT \
|
||||
(MYNEWT_VAL(BLE_GATT_READ_MULT))
|
||||
|
||||
#undef NIMBLE_BLE_ATT_CLT_READ_MULT_VAR
|
||||
#define NIMBLE_BLE_ATT_CLT_READ_MULT_VAR \
|
||||
(MYNEWT_VAL(BLE_GATT_READ_MULT_VAR))
|
||||
|
||||
#undef NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE
|
||||
#define NIMBLE_BLE_ATT_CLT_READ_GROUP_TYPE \
|
||||
(MYNEWT_VAL(BLE_GATT_DISC_ALL_SVCS))
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* SPDX-FileContributor: 2019-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileContributor: 2019-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
@@ -842,15 +842,35 @@ ble_npl_time_t
|
||||
IRAM_ATTR npl_freertos_callout_get_ticks(struct ble_npl_callout *co)
|
||||
{
|
||||
#if BLE_NPL_USE_ESP_TIMER
|
||||
/* Currently, esp_timer does not support an API which gets the expiry time for
|
||||
* current timer.
|
||||
* Returning 0 from here should not cause any effect.
|
||||
|
||||
uint32_t exp = 0;
|
||||
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
uint64_t expiry = 0;
|
||||
esp_err_t err;
|
||||
|
||||
struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co;
|
||||
|
||||
//Fetch expiry time in microseconds
|
||||
err = esp_timer_get_expiry_time((esp_timer_handle_t)(callout->handle), &expiry);
|
||||
if (err != ESP_OK) {
|
||||
//Error. Could not fetch the expiry time
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Convert microseconds to ticks
|
||||
npl_freertos_time_ms_to_ticks((uint32_t)(expiry / 1000), &exp);
|
||||
#else
|
||||
//esp_timer_get_expiry_time() is only available from IDF 5.0 onwards
|
||||
/* Returning 0 from here should not cause any effect.
|
||||
* Drawback of this approach is that existing code to reset timer would be called
|
||||
* more often (since the if condition to invoke reset timer would always succeed if
|
||||
* timer is active).
|
||||
*/
|
||||
exp = 0;
|
||||
#endif //ESP_IDF_VERSION
|
||||
|
||||
return 0;
|
||||
return exp;
|
||||
#else
|
||||
struct ble_npl_callout_freertos *callout = (struct ble_npl_callout_freertos *)co->co;
|
||||
return xTimerGetExpiryTime(callout->handle);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user