mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
Compare commits
716 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
559a9def5b | ||
|
d9b5d7744c | ||
|
b575737c0c | ||
|
1d04e5f7f8 | ||
|
9adf8a7aa9 | ||
|
91262682c1 | ||
|
c4e72db390 | ||
|
df4df2f493 | ||
|
4764977c3c | ||
|
7f081efbc6 | ||
|
3b2d5e5a4f | ||
|
df12d488fb | ||
|
63013e1060 | ||
|
42426a986c | ||
|
b526cb5372 | ||
|
6a29794a65 | ||
|
85d00d8daa | ||
|
8dd3bb07f8 | ||
|
ceafbca0a2 | ||
|
f53f40396b | ||
|
e263c1add8 | ||
|
4ec321d1b9 | ||
|
c5dcb7e662 | ||
|
6600250f30 | ||
|
cb5c0d3a12 | ||
|
14abc49237 | ||
|
dfe06c6dfb | ||
|
a74775d5f0 | ||
|
378a13ba18 | ||
|
f30c415cdd | ||
|
95c0b90cc1 | ||
|
e7322c8472 | ||
|
357364ab25 | ||
|
d09ccd4b31 | ||
|
1d58ccdf42 | ||
|
3a8fbb7be4 | ||
|
c9694d4004 | ||
|
a19c901e99 | ||
|
4a6d2da209 | ||
|
613558774b | ||
|
34f18da855 | ||
|
d95911ec38 | ||
|
ea48d2802c | ||
|
3e666077f0 | ||
|
23cd758ddb | ||
|
5e0d95c4ec | ||
|
2cd1cdcb7d | ||
|
5760e37dcc | ||
|
f45612fb2f | ||
|
3706b3863a | ||
|
1ffa3be4a7 | ||
|
2ec62e3a98 | ||
|
86c913dbe9 | ||
|
4a82ad3937 | ||
|
7307bf1b87 | ||
|
eae386d0db | ||
|
36620e1c5b | ||
|
e86d1ac95d | ||
|
9a7b82d61f | ||
|
4c3bd860f4 | ||
|
e83bdf62ca | ||
|
ce52121050 | ||
|
4f17f383ec | ||
|
84c96bf5bf | ||
|
56766719df | ||
|
3004d86dc1 | ||
|
98c7d289ee | ||
|
37b47b8e47 | ||
|
10a7eacc98 | ||
|
15adb64dd7 | ||
|
3f7cc13ed7 | ||
|
6aacb06c73 | ||
|
c41f10f4b8 | ||
|
692f86bbd0 | ||
|
02138399ce | ||
|
42986bf1e5 | ||
|
9d80953a63 | ||
|
f11250cd36 | ||
|
857bdf65e5 | ||
|
8ca1efd91a | ||
|
b8d1ff5e95 | ||
|
db3dcc9a79 | ||
|
774a3c1446 | ||
|
1bca6d0ffe | ||
|
9c60abcaca | ||
|
4b11e8cb54 | ||
|
401c940434 | ||
|
1cbdfcc493 | ||
|
a48e682e38 | ||
|
6250918dfa | ||
|
072d5233ca | ||
|
29f5ad6638 | ||
|
5abf384c96 | ||
|
d39c0cc281 | ||
|
8af15bf448 | ||
|
c2986c0a1f | ||
|
e8fc27da7d | ||
|
361d28e19e | ||
|
bfc3931d3f | ||
|
18ff22aa09 | ||
|
ff94a5202c | ||
|
c7d8cc928f | ||
|
c607d8ff68 | ||
|
e1ff84516f | ||
|
654d6ee594 | ||
|
a46c30eda4 | ||
|
73298a6c3d | ||
|
b10767a122 | ||
|
42773d22fd | ||
|
9f2ed0f58d | ||
|
c90831775f | ||
|
f664eb04d1 | ||
|
8fe62b75ca | ||
|
64169e7d12 | ||
|
12a29f1a43 | ||
|
02ee80201b | ||
|
1ee0f9455f | ||
|
df86f46efe | ||
|
30ed610950 | ||
|
18b5d7e5ab | ||
|
89afc96bf0 | ||
|
6dde1b7b80 | ||
|
c3bf2a0685 | ||
|
f6015c29d5 | ||
|
c278dcb707 | ||
|
abb114475f | ||
|
533d90b4c2 | ||
|
83bf77e2f4 | ||
|
c27d9d9d4e | ||
|
a64139690b | ||
|
9122ec43e1 | ||
|
4d80587594 | ||
|
cf1b95cc00 | ||
|
a05b99e0dc | ||
|
8b6b623b64 | ||
|
4f4b4fa9d5 | ||
|
6349f6835d | ||
|
05c1463691 | ||
|
00c3f795a2 | ||
|
8db70b4aa8 | ||
|
439bdc0b77 | ||
|
82bdc66e34 | ||
|
7313da42b5 | ||
|
570cb25d26 | ||
|
db91841915 | ||
|
50664c43b2 | ||
|
c1e5f01d2e | ||
|
f28e3cbc07 | ||
|
4f6b6d3391 | ||
|
d6fb966ea4 | ||
|
df5c9c8804 | ||
|
3c443ae9d7 | ||
|
96b77c11ec | ||
|
f0462244ec | ||
|
2f73a62737 | ||
|
042c0109a9 | ||
|
4bb656c36d | ||
|
471013f7e0 | ||
|
51e29d6d95 | ||
|
3f0c737969 | ||
|
8599f73019 | ||
|
6fbf2675e6 | ||
|
f97748d46f | ||
|
8890627f6d | ||
|
867a237c27 | ||
|
044cadbad3 | ||
|
dda1af6e55 | ||
|
cea8c51527 | ||
|
5fb9aaa377 | ||
|
75724791fa | ||
|
d5938abf79 | ||
|
58ed22461f | ||
|
ed84e5aef3 | ||
|
f8310c4a67 | ||
|
03006a109b | ||
|
3d542b2530 | ||
|
9f3bde6096 | ||
|
7d4bb5de1f | ||
|
a26408bf24 | ||
|
e4d61154f2 | ||
|
cea310d5c5 | ||
|
f2f9d92131 | ||
|
4c248f40aa | ||
|
b92def7b01 | ||
|
0ddcbfa751 | ||
|
94defe35cc | ||
|
0b48653ed0 | ||
|
1ce0434373 | ||
|
bc58f4b9ba | ||
|
2c3af8a18e | ||
|
39c6b2f904 | ||
|
e5b4d2e01a | ||
|
3fc09372f1 | ||
|
6685ca4771 | ||
|
1b5a77eba9 | ||
|
398a428e08 | ||
|
8fffb9d172 | ||
|
d323962e14 | ||
|
d6c52407fc | ||
|
62444346c1 | ||
|
4c4acd8d2f | ||
|
7e5ac34be7 | ||
|
887ff7d685 | ||
|
43dc03659e | ||
|
863da69c5b | ||
|
fb4b035105 | ||
|
04ed861eb8 | ||
|
4e55490602 | ||
|
7ee102a9f6 | ||
|
70a9e72e06 | ||
|
9cfd94a9d6 | ||
|
48416c38c8 | ||
|
beb8347faa | ||
|
450118fdf8 | ||
|
1e1450bf5d | ||
|
3567b1d0ce | ||
|
2f14aeee00 | ||
|
42383518b8 | ||
|
fb15403515 | ||
|
8a20519222 | ||
|
4e33313a9b | ||
|
98ed70cd91 | ||
|
c6ee38eb69 | ||
|
ed1771c7cc | ||
|
1bd674dc64 | ||
|
285a0aa13c | ||
|
a019517d07 | ||
|
f57d5db86d | ||
|
57118e2f10 | ||
|
03527e840c | ||
|
ba0974b101 | ||
|
191cad0398 | ||
|
454268da00 | ||
|
5e048a9ebb | ||
|
ce83031571 | ||
|
298aafd112 | ||
|
f8f96c368b | ||
|
83bd616b6f | ||
|
6743820bce | ||
|
3e06ad6af9 | ||
|
1c6b0bf925 | ||
|
ef2bf23862 | ||
|
cf5dbadf4f | ||
|
72c88db3a8 | ||
|
cfe10825cf | ||
|
be115ec3ab | ||
|
dbfe5b5886 | ||
|
e94b130ede | ||
|
5412ccbcb1 | ||
|
fa9e6713ae | ||
|
2ccfa6bd44 | ||
|
188f86e946 | ||
|
6220de03da | ||
|
31716a4960 | ||
|
10cac76d79 | ||
|
778566042b | ||
|
0e2eccfad0 | ||
|
b26ded717f | ||
|
85825377c8 | ||
|
10419b48bf | ||
|
fa8c79e0fe | ||
|
38edc33bb8 | ||
|
c6750d271e | ||
|
63a9054e5b | ||
|
9699ec9277 | ||
|
15ac1d40fa | ||
|
8f4ec72a0f | ||
|
02668b62e8 | ||
|
36b65c8498 | ||
|
91bc4ebb6c | ||
|
205c484c49 | ||
|
60f4ccf303 | ||
|
1d0df04579 | ||
|
50d4ffd22e | ||
|
9845219a5f | ||
|
b4939b1121 | ||
|
8c1d9e70b5 | ||
|
e444a31e79 | ||
|
c3bd2a7539 | ||
|
3a9c713748 | ||
|
6a63d0eeaf | ||
|
570e32915a | ||
|
8ad6ba2436 | ||
|
7fe18ef334 | ||
|
126ade78d4 | ||
|
608986cd4f | ||
|
fe05db83f1 | ||
|
d1936acf43 | ||
|
7ce22b11bf | ||
|
b917fbe914 | ||
|
beb80ffeeb | ||
|
fc6235c190 | ||
|
92a27d642b | ||
|
9bc10d9eda | ||
|
357239a20c | ||
|
014b3c639f | ||
|
505663cd6b | ||
|
2dc384198d | ||
|
e1dcd81c18 | ||
|
9f653a9d9f | ||
|
b0c389c450 | ||
|
faeb15e1ec | ||
|
cbd1e9fa35 | ||
|
e105d23b51 | ||
|
6cc626ab99 | ||
|
e70fc19384 | ||
|
935501896d | ||
|
e690cfcbd7 | ||
|
6f582fe71d | ||
|
7116547ebf | ||
|
df53422cad | ||
|
014b6ba44a | ||
|
a663c61427 | ||
|
ed1304146b | ||
|
1937bc2bd7 | ||
|
1255be4e3e | ||
|
3e7a5b144a | ||
|
763c2cc188 | ||
|
7ca260554f | ||
|
4e9b4cb9cc | ||
|
efe9100306 | ||
|
ac62b8437d | ||
|
9969b4218d | ||
|
02c3097191 | ||
|
db256ed1e1 | ||
|
270f105823 | ||
|
44811c6896 | ||
|
d8c9530d3c | ||
|
152a4f46d6 | ||
|
b4552c02d4 | ||
|
3c87f47ba2 | ||
|
a0eedf112f | ||
|
a9dae85d03 | ||
|
a18f92b09b | ||
|
6a418013a3 | ||
|
bd9eb5255d | ||
|
29da5b2e17 | ||
|
1c4bbaa567 | ||
|
ad9bce3203 | ||
|
129f1df461 | ||
|
2b58be5a6c | ||
|
ee99795f3d | ||
|
f4b64a491b | ||
|
b5371b38c9 | ||
|
07e8b35ead | ||
|
76f98a4b36 | ||
|
0b3fdf420f | ||
|
a7d37b303d | ||
|
a7b5496770 | ||
|
ce5b2709ab | ||
|
a617116479 | ||
|
4070d095d0 | ||
|
3387d751d9 | ||
|
155e48bbde | ||
|
13155223f3 | ||
|
61ecee012e | ||
|
ab8e4069b5 | ||
|
34064b4302 | ||
|
93fcc418fe | ||
|
6393ef0f52 | ||
|
f00c6d1e84 | ||
|
2aea6e5e9c | ||
|
47a9e032d8 | ||
|
a27e0357b8 | ||
|
c229de0564 | ||
|
f298897fb5 | ||
|
ab2062aa45 | ||
|
3892fd2c09 | ||
|
87f810dca1 | ||
|
868da0741c | ||
|
09b2cd7d26 | ||
|
f3cf5711bf | ||
|
ddbb535080 | ||
|
195f7274c4 | ||
|
cdd3131f8a | ||
|
37c9b4056a | ||
|
dfd46965ae | ||
|
e885ff235f | ||
|
845bbc293a | ||
|
50f8b7b783 | ||
|
c4193d5ec1 | ||
|
8e0bb3ec81 | ||
|
41caedd0da | ||
|
13d4e43888 | ||
|
b837e64640 | ||
|
26e7d01d42 | ||
|
bbd0696992 | ||
|
d4eab2602f | ||
|
dbd225c673 | ||
|
da8835aa0b | ||
|
8e703b14ee | ||
|
79da87def9 | ||
|
0ffe9f0c4e | ||
|
46fd333167 | ||
|
8b50419f55 | ||
|
65691de9bc | ||
|
3514effcd0 | ||
|
f7b9ea8cb5 | ||
|
ac124ee89c | ||
|
01cfb0d6bd | ||
|
69b6eabef0 | ||
|
8c16be1edc | ||
|
a015072a7e | ||
|
7cc2445b9a | ||
|
cfef8291bb | ||
|
725978b817 | ||
|
1e598fc6db | ||
|
08c14389f6 | ||
|
35769b6c50 | ||
|
2aa9a21180 | ||
|
acdc7b0511 | ||
|
3b92e85b30 | ||
|
7d6b82673f | ||
|
12e5f25a1c | ||
|
539064b93c | ||
|
82e69475ca | ||
|
d09342957d | ||
|
7a05ef2002 | ||
|
6a6fccc191 | ||
|
9c41962e68 | ||
|
a7372d5828 | ||
|
3850f82259 | ||
|
3f64b39ad5 | ||
|
536549253d | ||
|
d1d2ce8c28 | ||
|
7ad26f30f0 | ||
|
97610cfccf | ||
|
143c0bdaf9 | ||
|
9ec43e1721 | ||
|
e5f2f1ba78 | ||
|
89ee65e1c6 | ||
|
4eb20f4d99 | ||
|
55d7900079 | ||
|
4b5cf90a95 | ||
|
9edde5e8af | ||
|
67ad5852f6 | ||
|
5641ff1b42 | ||
|
7778b9d83a | ||
|
afeaf64624 | ||
|
6159788b97 | ||
|
695b25775e | ||
|
ccddd3bc01 | ||
|
e982c25b40 | ||
|
7707b9fc91 | ||
|
f97e2d3bde | ||
|
93f04b87b2 | ||
|
d444469cae | ||
|
64b41b5602 | ||
|
b26b1389de | ||
|
3cf2f09469 | ||
|
fb30315d01 | ||
|
027e081622 | ||
|
84b4916fb8 | ||
|
27023a77e7 | ||
|
1a3db605c2 | ||
|
712b9374af | ||
|
06321a5241 | ||
|
b9f10a71ea | ||
|
97219eeb31 | ||
|
a2f2cd3b41 | ||
|
bbad487deb | ||
|
7930cfdba9 | ||
|
68a9d1168f | ||
|
1755fba8dc | ||
|
d7615df616 | ||
|
541e02a7e3 | ||
|
d899bf029d | ||
|
f11ac037c4 | ||
|
0846615e98 | ||
|
f16b3754fb | ||
|
862b7b22b5 | ||
|
e353d09630 | ||
|
5205b31186 | ||
|
de0a323bef | ||
|
39f97ee0d0 | ||
|
ebdc82d3d2 | ||
|
773d282d71 | ||
|
fc7ff2a59c | ||
|
c4ce84bba5 | ||
|
315f18766c | ||
|
9ad19e8122 | ||
|
75fcd062e8 | ||
|
b7fde00aed | ||
|
d6547595d7 | ||
|
5bb12070d9 | ||
|
83b8f38484 | ||
|
bdb65ed066 | ||
|
cbb5b6f50b | ||
|
cc0a73c156 | ||
|
1d4ae1e9ad | ||
|
e14b836fcc | ||
|
fbcfc869e2 | ||
|
4107361a3a | ||
|
e8aa442305 | ||
|
82ee078d9a | ||
|
f90512ba39 | ||
|
bb48077a81 | ||
|
72f9d15a57 | ||
|
78dca32a28 | ||
|
52a70b3418 | ||
|
889c80ec1c | ||
|
922bae0be3 | ||
|
982a7fa499 | ||
|
52413e9925 | ||
|
cfb96e67f9 | ||
|
a7c67c1681 | ||
|
53d75901a9 | ||
|
8f665c3393 | ||
|
b5365c19f7 | ||
|
738afe2de3 | ||
|
ea3b2716fd | ||
|
bfcb673c8e | ||
|
e5d8a68d96 | ||
|
760772ec4b | ||
|
1a9d40ca3d | ||
|
9773c019d8 | ||
|
67ef1865a6 | ||
|
3db38f8281 | ||
|
c6d2fc6807 | ||
|
9237110c5c | ||
|
4c240064ab | ||
|
da4108dd1e | ||
|
01994059e2 | ||
|
763fa9b0fa | ||
|
a55c7a62ad | ||
|
0e1f561a32 | ||
|
cea4d31325 | ||
|
af86b9cbce | ||
|
f16e78f72c | ||
|
bc8540fec1 | ||
|
533c5e98e8 | ||
|
d04718bbe3 | ||
|
7edf2bf66c | ||
|
a05868f0a8 | ||
|
5b1d8d64f2 | ||
|
031ec7af93 | ||
|
2a5802241f | ||
|
f6f4d7b410 | ||
|
8e20c13348 | ||
|
f617a33b8d | ||
|
782ab8d872 | ||
|
b3697e7741 | ||
|
da3c1be049 | ||
|
35785d08fd | ||
|
05fbfe21b9 | ||
|
4fc1587f6c | ||
|
297945c32e | ||
|
d193895ec6 | ||
|
f1bf446410 | ||
|
e6a0eb74c8 | ||
|
b3189bae38 | ||
|
c27c381ba2 | ||
|
95c5805088 | ||
|
196793dccb | ||
|
7c6d447938 | ||
|
7d847e60ec | ||
|
b069b31a2c | ||
|
969161183a | ||
|
45e29a817c | ||
|
dabebbf639 | ||
|
cd78dc632a | ||
|
33b3418b4e | ||
|
6a2f492832 | ||
|
24a03a8d3f | ||
|
27ffeacf07 | ||
|
b1da63d645 | ||
|
ec3a1318dc | ||
|
22da5f6de9 | ||
|
0ec9d3ec7d | ||
|
70764a4cf9 | ||
|
2ad5686937 | ||
|
84d10d8dad | ||
|
7f8de47631 | ||
|
16add00668 | ||
|
a83c918946 | ||
|
9f791e06f6 | ||
|
c3ba237846 | ||
|
17c4a76395 | ||
|
114b16f0d5 | ||
|
e1fc259600 | ||
|
1d537d29d5 | ||
|
09f5854c9a | ||
|
200d8d235b | ||
|
84a32f3288 | ||
|
bfc8142c99 | ||
|
bcebf3e6f1 | ||
|
4577270fc3 | ||
|
2d22fbd4ff | ||
|
9f6af0ad4b | ||
|
c060853f70 | ||
|
501d81ce32 | ||
|
f9a770134b | ||
|
b4fc5b0e8f | ||
|
a821805ddc | ||
|
cb9fa1f295 | ||
|
7ffd68cac2 | ||
|
dd77a4c65d | ||
|
a47cc3dd46 | ||
|
7cd75f30f2 | ||
|
3d2cd911f0 | ||
|
da94560ec5 | ||
|
21ef7ed82c | ||
|
125da7a1c2 | ||
|
ceca7b741c | ||
|
ab95d5cdd7 | ||
|
bc6a193130 | ||
|
7cc5888583 | ||
|
0743361da3 | ||
|
c16fbbf614 | ||
|
b64815be4c | ||
|
885df4c90f | ||
|
d376105e8e | ||
|
7f50bb7e7f | ||
|
810aa5427c | ||
|
48bd67524d | ||
|
70288f864e | ||
|
04238fa5e5 | ||
|
191557db02 | ||
|
dbb82a413f | ||
|
fdfe38a779 | ||
|
e7faa1d851 | ||
|
bf10447b82 | ||
|
be829afe6e | ||
|
950dd8e3e5 | ||
|
330c6a50e1 | ||
|
6065d2fd08 | ||
|
754cd7bd56 | ||
|
46b723e5ed | ||
|
4667fb2495 | ||
|
8c5f1c866b | ||
|
8bb4c694ce | ||
|
fdccc19485 | ||
|
6b9784cc45 | ||
|
f5f966d91a | ||
|
cfa8ed15c0 | ||
|
c70f9db369 | ||
|
2909fc182b | ||
|
e100acbb73 | ||
|
2f433e4342 | ||
|
580cfeaaae | ||
|
955e84a3bc | ||
|
f6cd55d2ac | ||
|
11980a9ad4 | ||
|
6cc5971516 | ||
|
61aff5162c | ||
|
8cf82be917 | ||
|
ed1f4e50df | ||
|
be4956fe7c | ||
|
a1fac97f1a | ||
|
979568fa0b | ||
|
f07c1ca94f | ||
|
cc104eb05b | ||
|
2f4079ebb2 | ||
|
829e6c44f1 | ||
|
81e48ca31f | ||
|
526496ba20 | ||
|
6f31674b28 | ||
|
b7ddb0c3d3 | ||
|
c7f19e76d7 | ||
|
8453806a8c | ||
|
48c3ad37f1 | ||
|
9ec14decce | ||
|
68282cf80b | ||
|
2fadf8a000 | ||
|
c7307de63e | ||
|
c42b791aaa | ||
|
f6db61e4f4 | ||
|
918c4b4c48 | ||
|
d5a5897140 | ||
|
99e02d4e42 | ||
|
381be65472 | ||
|
858b95a924 | ||
|
1cb5712463 | ||
|
4a2f1f0354 | ||
|
56902f0054 | ||
|
f1d3bfc0c7 | ||
|
2a3e2b8eed | ||
|
b44c8b125f | ||
|
2ea359ad0c | ||
|
6bdc49b6e4 | ||
|
800bffb8b0 | ||
|
9d88d13f77 | ||
|
2816cf1d67 | ||
|
b57843b66a | ||
|
12be399762 | ||
|
bc1693aae3 | ||
|
88df8fd293 | ||
|
15d5e88618 | ||
|
9f8cdd3572 | ||
|
95e17d6d92 | ||
|
7d9ba66f83 | ||
|
4d7bc8e8ba | ||
|
abef220b13 | ||
|
04a944598f | ||
|
e94db98e73 | ||
|
efb5928934 | ||
|
7eaf2f4bdb | ||
|
cb99531d15 | ||
|
0bdc12256e | ||
|
1f8e07fd8f | ||
|
be962a9444 | ||
|
4f1a856dbf | ||
|
3fac2b2ddc | ||
|
674d398c93 | ||
|
3ae4822115 | ||
|
97e01a4c4d | ||
|
ce6748873d | ||
|
134f2238bd | ||
|
7f29593a7d | ||
|
067a19ad88 | ||
|
f04525095f | ||
|
68e75dd0df | ||
|
35f521afb6 | ||
|
99a2359c5c | ||
|
c671a0c3eb | ||
|
a538644560 |
@@ -32,3 +32,8 @@ insert_final_newline = false
|
||||
|
||||
[*.py]
|
||||
max_line_length = 119
|
||||
|
||||
[{*.cmake,CMakeLists.txt}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
max_line_length = 120
|
||||
|
7
.gitignore
vendored
7
.gitignore
vendored
@@ -52,4 +52,11 @@ examples/protocols/aws_iot/*/main/certs/*.pem.*
|
||||
coverage.info
|
||||
coverage_report/
|
||||
|
||||
# Windows tools installer build
|
||||
tools/windows/tool_setup/.*
|
||||
tools/windows/tool_setup/input
|
||||
tools/windows/tool_setup/dl
|
||||
tools/windows/tool_setup/Output
|
||||
|
||||
test_multi_heap_host
|
||||
|
||||
|
598
.gitlab-ci.yml
598
.gitlab-ci.yml
@@ -2,9 +2,9 @@ stages:
|
||||
- build
|
||||
- assign_test
|
||||
- host_test
|
||||
- unit_test
|
||||
- integration_test
|
||||
- target_test
|
||||
- deploy
|
||||
- post_check
|
||||
|
||||
variables:
|
||||
# System environment
|
||||
@@ -18,7 +18,7 @@ variables:
|
||||
GET_SOURCES_ATTEMPTS: "10"
|
||||
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
|
||||
|
||||
# We use get_sources.sh script to fetch the submodules and/or re-fetch the repo
|
||||
# We use get-full-sources.sh script to fetch the submodules and/or re-fetch the repo
|
||||
# if it was corrupted (if submodule update fails this can happen)
|
||||
GIT_STRATEGY: fetch
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
@@ -49,6 +49,7 @@ variables:
|
||||
python $APPLY_BOT_FILTER_SCRIPT || exit 0
|
||||
|
||||
before_script:
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
@@ -70,6 +71,7 @@ before_script:
|
||||
|
||||
.do_nothing_before:
|
||||
before_script: &do_nothing_before
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
@@ -78,6 +80,7 @@ before_script:
|
||||
|
||||
.add_gitlab_key_before:
|
||||
before_script: &add_gitlab_key_before
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
@@ -99,13 +102,21 @@ build_template_app:
|
||||
variables:
|
||||
BATCH_BUILD: "1"
|
||||
IDF_CI_BUILD: "1"
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
script:
|
||||
- git clone https://github.com/espressif/esp-idf-template.git
|
||||
# Set the variable for 'esp-idf-template' testing
|
||||
- ESP_IDF_TEMPLATE_GIT=${ESP_IDF_TEMPLATE_GIT:-"https://github.com/espressif/esp-idf-template.git"}
|
||||
- git clone ${ESP_IDF_TEMPLATE_GIT}
|
||||
- cd esp-idf-template
|
||||
# Try to use the same branch name for esp-idf-template that we're
|
||||
# using on esp-idf. If it doesn't exist then just stick to the default
|
||||
# branch
|
||||
- python $CHECKOUT_REF_SCRIPT esp-idf-template
|
||||
- make defconfig
|
||||
# Test debug build (default)
|
||||
- make all V=1
|
||||
# Now test release build
|
||||
@@ -135,6 +146,12 @@ build_template_app:
|
||||
expire_in: 1 mos
|
||||
variables:
|
||||
SSC_CONFIG_FOLDER: "$CI_PROJECT_DIR/SSC/configs/ESP32_IDF"
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_INTEGRATION_TEST
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
script:
|
||||
- git clone $SSC_REPOSITORY
|
||||
- cd SSC
|
||||
@@ -161,6 +178,12 @@ build_esp_idf_tests:
|
||||
- components/idf_test/unit_test/TestCaseAll.yml
|
||||
- components/idf_test/unit_test/CIConfigs/*.yml
|
||||
expire_in: 1 mos
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_UNIT_TEST
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
script:
|
||||
- cd tools/unit-test-app
|
||||
- MAKEFLAGS= make help # make sure kconfig tools are built in single process
|
||||
@@ -170,7 +193,7 @@ build_esp_idf_tests:
|
||||
- make ut-build-all-configs
|
||||
- python tools/UnitTestParser.py
|
||||
|
||||
.build_examples_template: &build_examples_template
|
||||
.build_examples_make_template: &build_examples_make_template
|
||||
<<: *build_template
|
||||
retry: 1
|
||||
artifacts:
|
||||
@@ -185,7 +208,13 @@ build_esp_idf_tests:
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
IDF_CI_BUILD: "1"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/log_examples"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/log_examples_make"
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_EXAMPLE_TEST
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
script:
|
||||
# it's not possible to build 100% out-of-tree and have the "artifacts"
|
||||
# mechanism work, but this is the next best thing
|
||||
@@ -196,29 +225,80 @@ build_esp_idf_tests:
|
||||
- mkdir -p ${LOG_PATH}
|
||||
- ${IDF_PATH}/tools/ci/build_examples.sh "${CI_JOB_NAME}"
|
||||
|
||||
build_examples_00:
|
||||
<<: *build_examples_template
|
||||
# same as above, but for CMake
|
||||
.build_examples_cmake_template: &build_examples_cmake_template
|
||||
<<: *build_template
|
||||
retry: 1
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- build_examples_cmake/*/*/*/build/*.bin
|
||||
- build_examples_cmake/*/*/*/build/*.elf
|
||||
- build_examples_cmake/*/*/*/build/*.map
|
||||
- build_examples_cmake/*/*/*/build/download.config
|
||||
- build_examples_cmake/*/*/*/build/bootloader/*.bin
|
||||
- $LOG_PATH
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
IDF_CI_BUILD: "1"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/log_examples_cmake"
|
||||
script:
|
||||
# it's not possible to build 100% out-of-tree and have the "artifacts"
|
||||
# mechanism work, but this is the next best thing
|
||||
- rm -rf build_examples_cmake
|
||||
- mkdir build_examples_cmake
|
||||
- cd build_examples_cmake
|
||||
# build some of examples
|
||||
- mkdir -p ${LOG_PATH}
|
||||
- ${IDF_PATH}/tools/ci/build_examples_cmake.sh "${CI_JOB_NAME}"
|
||||
|
||||
build_examples_01:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_00:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_02:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_01:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_03:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_02:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_04:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_03:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_05:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_04:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_06:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_05:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_07:
|
||||
<<: *build_examples_template
|
||||
build_examples_make_06:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_make_07:
|
||||
<<: *build_examples_make_template
|
||||
|
||||
build_examples_cmake_00:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_01:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_02:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_03:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_04:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_05:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_06:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
build_examples_cmake_07:
|
||||
<<: *build_examples_cmake_template
|
||||
|
||||
# If you want to add new build example jobs, please add it into dependencies of `.example_test_template`
|
||||
|
||||
@@ -241,6 +321,12 @@ build_docs:
|
||||
- docs/zh_CN/sphinx-warning-log-sanitized.txt
|
||||
- docs/zh_CN/_build/html
|
||||
expire_in: 1 mos
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_BUILD_DOCS
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
script:
|
||||
- cd docs
|
||||
- ./check_lang_folder_sync.sh
|
||||
@@ -253,13 +339,31 @@ build_docs:
|
||||
- make html
|
||||
- ../check_doc_warnings.sh
|
||||
|
||||
verify_cmake_style:
|
||||
stage: build
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
script:
|
||||
tools/cmake/run_cmake_lint.sh
|
||||
|
||||
.host_test_template: &host_test_template
|
||||
stage: host_test
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_HOST_TEST
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
|
||||
test_nvs_on_host:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
@@ -272,10 +376,10 @@ test_nvs_coverage:
|
||||
paths:
|
||||
- components/nvs_flash/test_nvs_host/coverage_report
|
||||
only:
|
||||
- triggers
|
||||
# This job takes a few hours to finish, so only run it on demand
|
||||
variables:
|
||||
BOT_NEEDS_TRIGGER_BY_NAME: 1
|
||||
refs:
|
||||
- triggers
|
||||
variables:
|
||||
- $BOT_LABEL_NVS_COVERAGE
|
||||
script:
|
||||
- cd components/nvs_flash/test_nvs_host
|
||||
- make coverage_report
|
||||
@@ -319,6 +423,12 @@ test_multi_heap_on_host:
|
||||
- cd components/heap/test_multi_heap_host
|
||||
- ./test_all_configs.sh
|
||||
|
||||
test_confserver:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- cd tools/kconfig_new/test
|
||||
- ./test_confserver.py
|
||||
|
||||
test_build_system:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
@@ -328,6 +438,15 @@ test_build_system:
|
||||
- cd test_build_system
|
||||
- ${IDF_PATH}/tools/ci/test_build_system.sh
|
||||
|
||||
test_build_system_cmake:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
- ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh
|
||||
- rm -rf test_build_system
|
||||
- mkdir test_build_system
|
||||
- cd test_build_system
|
||||
- ${IDF_PATH}/tools/ci/test_build_system_cmake.sh
|
||||
|
||||
test_esp_err_to_name_on_host:
|
||||
<<: *host_test_template
|
||||
script:
|
||||
@@ -356,20 +475,22 @@ push_to_github:
|
||||
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- git remote remove github &>/dev/null || true
|
||||
- git remote add github git@github.com:espressif/esp-idf.git
|
||||
# Need separate push commands for tag builds and for branch builds
|
||||
- "[ -n \"${CI_COMMIT_TAG}\" ] && git push github ${CI_COMMIT_TAG}"
|
||||
- "[ -z \"${CI_COMMIT_TAG}\" ] && git push github ${CI_COMMIT_SHA}:refs/heads/${CI_COMMIT_REF_NAME}"
|
||||
- tools/ci/push_to_github.sh
|
||||
|
||||
deploy_docs:
|
||||
stage: host_test
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- deploy
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
refs:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD_DOCS
|
||||
dependencies:
|
||||
- build_docs
|
||||
before_script: *do_nothing_before
|
||||
@@ -401,8 +522,12 @@ check_doc_links:
|
||||
tags:
|
||||
- check_doc_links
|
||||
only:
|
||||
# can only be triggered
|
||||
- triggers
|
||||
refs:
|
||||
# can only be triggered
|
||||
- triggers
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD_DOCS
|
||||
artifacts:
|
||||
paths:
|
||||
- docs/_build/linkcheck
|
||||
@@ -446,6 +571,20 @@ check_permissions:
|
||||
script:
|
||||
- tools/ci/check-executable.sh
|
||||
|
||||
check_examples_cmake_make:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
tags:
|
||||
- build
|
||||
except:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before
|
||||
script:
|
||||
- tools/ci/check_examples_cmake_make.sh
|
||||
|
||||
check_submodule_sync:
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
@@ -456,13 +595,31 @@ check_submodule_sync:
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
tags:
|
||||
- github_sync
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
before_script: *do_nothing_before
|
||||
retry: 2
|
||||
script:
|
||||
# check if all submodules are correctly synced to public repostory
|
||||
- git submodule update --init --recursive
|
||||
|
||||
check_pipeline_triggered_by_label:
|
||||
stage: post_check
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before
|
||||
tags:
|
||||
- build
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL
|
||||
script:
|
||||
# If the pipeline is triggered with label, the pipeline will only succeeded if "regular_test" label is added.
|
||||
# We want to make sure some jobs are always executed to detect regression.
|
||||
- test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1
|
||||
|
||||
assign_test:
|
||||
tags:
|
||||
- assign_test
|
||||
@@ -484,6 +641,12 @@ assign_test:
|
||||
- components/idf_test/*/TC.sqlite
|
||||
- $EXAMPLE_CONFIG_OUTPUT_PATH
|
||||
expire_in: 1 mos
|
||||
only:
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_UNIT_TEST
|
||||
- $BOT_LABEL_INTEGRATION_TEST
|
||||
- $BOT_LABEL_EXAMPLE_TEST
|
||||
before_script: *add_gitlab_key_before
|
||||
script:
|
||||
# assign example tests
|
||||
@@ -498,29 +661,43 @@ assign_test:
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
|
||||
|
||||
.example_test_template: &example_test_template
|
||||
stage: integration_test
|
||||
stage: target_test
|
||||
when: on_success
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
refs:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_EXAMPLE_TEST
|
||||
dependencies:
|
||||
- assign_test
|
||||
- build_examples_00
|
||||
- build_examples_01
|
||||
- build_examples_02
|
||||
- build_examples_03
|
||||
- build_examples_04
|
||||
- build_examples_05
|
||||
- build_examples_06
|
||||
- build_examples_07
|
||||
- build_examples_make_00
|
||||
- build_examples_make_01
|
||||
- build_examples_make_02
|
||||
- build_examples_make_03
|
||||
- build_examples_make_04
|
||||
- build_examples_make_05
|
||||
- build_examples_make_06
|
||||
- build_examples_make_07
|
||||
- build_examples_cmake_00
|
||||
- build_examples_cmake_01
|
||||
- build_examples_cmake_02
|
||||
- build_examples_cmake_03
|
||||
- build_examples_cmake_04
|
||||
- build_examples_cmake_05
|
||||
- build_examples_cmake_06
|
||||
- build_examples_cmake_07
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- $LOG_PATH
|
||||
expire_in: 1 mos
|
||||
expire_in: 1 week
|
||||
reports:
|
||||
junit: $LOG_PATH/*/XUNIT_RESULT.xml
|
||||
variables:
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/examples"
|
||||
@@ -540,10 +717,20 @@ assign_test:
|
||||
|
||||
.unit_test_template: &unit_test_template
|
||||
<<: *example_test_template
|
||||
stage: unit_test
|
||||
stage: target_test
|
||||
dependencies:
|
||||
- assign_test
|
||||
- build_esp_idf_tests
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_UNIT_TEST
|
||||
variables:
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/tools/unit-test-app"
|
||||
@@ -552,14 +739,18 @@ assign_test:
|
||||
ENV_FILE: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
|
||||
|
||||
.test_template: &test_template
|
||||
stage: integration_test
|
||||
stage: target_test
|
||||
when: on_success
|
||||
only:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
refs:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
- schedules
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_INTEGRATION_TEST
|
||||
dependencies:
|
||||
- assign_test
|
||||
- build_ssc_00
|
||||
@@ -624,6 +815,16 @@ example_test_001_01:
|
||||
|
||||
example_test_002_01:
|
||||
<<: *example_test_template
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_ShieldBox_Basic
|
||||
|
||||
example_test_006_01:
|
||||
<<: *example_test_template
|
||||
image: $CI_DOCKER_REGISTRY/ubuntu-test-env$BOT_DOCKER_IMAGE_TAG
|
||||
only:
|
||||
variables:
|
||||
- $BOT_LABEL_IPERF_STRESS_TEST
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_ShieldBox
|
||||
@@ -777,7 +978,7 @@ UT_001_25:
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
|
||||
UT_001_26:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
@@ -814,6 +1015,18 @@ UT_001_31:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_32:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_001_32:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_002_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
@@ -919,7 +1132,14 @@ UT_004_10:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- psram
|
||||
|
||||
|
||||
UT_004_11:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
- psram
|
||||
|
||||
UT_005_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
@@ -1009,65 +1229,73 @@ UT_010_04:
|
||||
- UT_T1_RMT
|
||||
- psram
|
||||
|
||||
UT_017_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T2_1
|
||||
|
||||
UT_017_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T2_1
|
||||
|
||||
UT_017_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T2_1
|
||||
|
||||
UT_017_04:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T2_1
|
||||
- psram
|
||||
|
||||
UT_017_05:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T2_1
|
||||
- 8Mpsram
|
||||
|
||||
UT_601_01:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_601_02:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_601_03:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
IT_001_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T1_4
|
||||
|
||||
IT_001_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T1_4
|
||||
|
||||
IT_001_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
|
||||
IT_001_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
|
||||
IT_001_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
|
||||
IT_001_06:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
|
||||
IT_001_07:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
|
||||
IT_001_08:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
|
||||
IT_001_09:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T1_4
|
||||
|
||||
IT_002_01:
|
||||
<<: *test_template
|
||||
@@ -1079,85 +1307,79 @@ IT_003_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_06:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_07:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_08:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_09:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_10:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_11:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_12:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_003_13:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
|
||||
IT_003_14:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- SSC_T2_5
|
||||
|
||||
IT_004_01:
|
||||
<<: *test_template
|
||||
@@ -1169,7 +1391,79 @@ IT_005_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WEP
|
||||
- SSC_T1_5
|
||||
|
||||
IT_005_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_5
|
||||
|
||||
IT_006_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_006_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_006_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_006_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_006_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_006_06:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_006_07:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
|
||||
IT_007_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_7
|
||||
|
||||
IT_007_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_7
|
||||
|
||||
IT_007_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_7
|
||||
|
||||
IT_008_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_8
|
||||
|
||||
IT_009_01:
|
||||
<<: *test_template
|
||||
@@ -1183,64 +1477,62 @@ IT_010_01:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_010_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_010_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_010_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_011_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T50_1
|
||||
- SSC_T12_MESH1
|
||||
|
||||
IT_501_01:
|
||||
IT_012_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- stress_test
|
||||
- SSC_T1_9
|
||||
|
||||
IT_501_02:
|
||||
IT_012_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- stress_test
|
||||
- SSC_T1_9
|
||||
|
||||
IT_501_03:
|
||||
IT_013_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- stress_test
|
||||
- SSC_T2_2
|
||||
|
||||
IT_502_01:
|
||||
IT_013_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- stress_test
|
||||
- SSC_T2_2
|
||||
|
||||
IT_502_02:
|
||||
IT_014_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_1
|
||||
- stress_test
|
||||
- SSC_T2_3
|
||||
|
||||
IT_503_01:
|
||||
IT_015_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
- stress_test
|
||||
|
||||
IT_503_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
- stress_test
|
||||
|
||||
IT_503_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
- stress_test
|
||||
- SSC_T2_4
|
||||
|
17
.readthedocs.yml
Normal file
17
.readthedocs.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
# .readthedocs.yml
|
||||
# Read the Docs configuration file
|
||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
||||
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
formats:
|
||||
- htmlzip
|
||||
- pdf
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
version: 2.7
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
143
Kconfig
143
Kconfig
@@ -4,6 +4,9 @@
|
||||
#
|
||||
mainmenu "Espressif IoT Development Framework Configuration"
|
||||
|
||||
config IDF_CMAKE
|
||||
bool
|
||||
option env="IDF_CMAKE"
|
||||
|
||||
menu "SDK tool configuration"
|
||||
config TOOLPREFIX
|
||||
@@ -15,11 +18,15 @@ config TOOLPREFIX
|
||||
|
||||
config PYTHON
|
||||
string "Python 2 interpreter"
|
||||
depends on !IDF_CMAKE
|
||||
default "python"
|
||||
help
|
||||
The executable name/path that is used to run python. On some systems Python 2.x
|
||||
may need to be invoked as python2.
|
||||
|
||||
(Note: This option is used with the GNU Make build system only, not idf.py
|
||||
or CMake-based builds.)
|
||||
|
||||
config MAKE_WARN_UNDEFINED_VARIABLES
|
||||
bool "'make' warns on undefined variables"
|
||||
default "y"
|
||||
@@ -35,7 +42,141 @@ endmenu # SDK tool configuration
|
||||
|
||||
source "$COMPONENT_KCONFIGS_PROJBUILD"
|
||||
|
||||
source "$IDF_PATH/Kconfig.compiler"
|
||||
menu "Compiler options"
|
||||
|
||||
choice OPTIMIZATION_COMPILER
|
||||
prompt "Optimization Level"
|
||||
default OPTIMIZATION_LEVEL_DEBUG
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
|
||||
config OPTIMIZATION_LEVEL_DEBUG
|
||||
bool "Debug (-Og)"
|
||||
config OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Assertions can be:
|
||||
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
menuconfig CXX_EXCEPTIONS
|
||||
bool "Enable C++ exceptions"
|
||||
default n
|
||||
help
|
||||
Enabling this option compiles all IDF C++ files with exception support enabled.
|
||||
|
||||
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
|
||||
an exception will abort instead.
|
||||
|
||||
Enabling this option currently adds an additional ~500 bytes of heap overhead
|
||||
when an exception is thrown in user code for the first time.
|
||||
|
||||
config CXX_EXCEPTIONS_EMG_POOL_SIZE
|
||||
int "Emergency Pool Size"
|
||||
default 0
|
||||
depends on CXX_EXCEPTIONS
|
||||
help
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
choice STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
|
||||
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
|
||||
The guards are initialized when a function is entered and then checked when the function exits.
|
||||
If a guard check fails, program is halted. Protection has the following modes:
|
||||
|
||||
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca,
|
||||
and functions with buffers larger than 8 bytes are protected.
|
||||
|
||||
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes
|
||||
additional functions to be protected -- those that have local array definitions,
|
||||
or have references to local frame addresses.
|
||||
|
||||
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
|
||||
|
||||
Modes have the following impact on code performance and coverage:
|
||||
|
||||
- performance: NORMAL > STRONG > OVERALL
|
||||
|
||||
- coverage: NORMAL < STRONG < OVERALL
|
||||
|
||||
|
||||
config STACK_CHECK_NONE
|
||||
bool "None"
|
||||
config STACK_CHECK_NORM
|
||||
bool "Normal"
|
||||
config STACK_CHECK_STRONG
|
||||
bool "Strong"
|
||||
config STACK_CHECK_ALL
|
||||
bool "Overall"
|
||||
endchoice
|
||||
|
||||
config STACK_CHECK
|
||||
bool
|
||||
default !STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection.
|
||||
|
||||
config WARN_WRITE_STRINGS
|
||||
bool "Enable -Wwrite-strings warning flag"
|
||||
default "n"
|
||||
help
|
||||
Adds -Wwrite-strings flag for the C/C++ compilers.
|
||||
|
||||
For C, this gives string constants the type ``const char[]`` so that
|
||||
copying the address of one into a non-const ``char *`` pointer
|
||||
produces a warning. This warning helps to find at compile time code
|
||||
that tries to write into a string constant.
|
||||
|
||||
For C++, this warns about the deprecated conversion from string
|
||||
literals to ``char *``.
|
||||
|
||||
endmenu # Compiler Options
|
||||
|
||||
menu "Component config"
|
||||
source "$COMPONENT_KCONFIGS"
|
||||
|
135
Kconfig.compiler
135
Kconfig.compiler
@@ -1,135 +0,0 @@
|
||||
menu "Compiler options"
|
||||
|
||||
choice OPTIMIZATION_COMPILER
|
||||
prompt "Optimization Level"
|
||||
default OPTIMIZATION_LEVEL_DEBUG
|
||||
help
|
||||
This option sets compiler optimization level (gcc -O argument).
|
||||
|
||||
- for "Release" setting, -Os flag is added to CFLAGS.
|
||||
- for "Debug" setting, -Og flag is added to CFLAGS.
|
||||
|
||||
"Release" with -Os produces smaller & faster compiled code but it
|
||||
may be harder to correlated code addresses to source files when debugging.
|
||||
|
||||
To add custom optimization settings, set CFLAGS and/or CPPFLAGS
|
||||
in project makefile, before including $(IDF_PATH)/make/project.mk. Note that
|
||||
custom optimization levels may be unsupported.
|
||||
|
||||
config OPTIMIZATION_LEVEL_DEBUG
|
||||
bool "Debug (-Og)"
|
||||
config OPTIMIZATION_LEVEL_RELEASE
|
||||
bool "Release (-Os)"
|
||||
endchoice
|
||||
|
||||
choice OPTIMIZATION_ASSERTION_LEVEL
|
||||
prompt "Assertion level"
|
||||
default OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
help
|
||||
Assertions can be:
|
||||
|
||||
- Enabled. Failure will print verbose assertion details. This is the default.
|
||||
|
||||
- Set to "silent" to save code size (failed assertions will abort() but user
|
||||
needs to use the aborting address to find the line number with the failed assertion.)
|
||||
|
||||
- Disabled entirely (not recommended for most configurations.) -DNDEBUG is added
|
||||
to CPPFLAGS in this case.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_ENABLED
|
||||
prompt "Enabled"
|
||||
bool
|
||||
help
|
||||
Enable assertions. Assertion content and line number will be printed on failure.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_SILENT
|
||||
prompt "Silent (saves code size)"
|
||||
bool
|
||||
help
|
||||
Enable silent assertions. Failed assertions will abort(), user needs to
|
||||
use the aborting address to find the line number with the failed assertion.
|
||||
|
||||
config OPTIMIZATION_ASSERTIONS_DISABLED
|
||||
prompt "Disabled (sets -DNDEBUG)"
|
||||
bool
|
||||
help
|
||||
If assertions are disabled, -DNDEBUG is added to CPPFLAGS.
|
||||
|
||||
endchoice # assertions
|
||||
|
||||
menuconfig CXX_EXCEPTIONS
|
||||
bool "Enable C++ exceptions"
|
||||
default n
|
||||
help
|
||||
Enabling this option compiles all IDF C++ files with exception support enabled.
|
||||
|
||||
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
|
||||
an exception will abort instead.
|
||||
|
||||
Enabling this option currently adds an additional ~500 bytes of heap overhead
|
||||
when an exception is thrown in user code for the first time.
|
||||
|
||||
config CXX_EXCEPTIONS_EMG_POOL_SIZE
|
||||
int "Emergency Pool Size"
|
||||
default 0
|
||||
depends on CXX_EXCEPTIONS
|
||||
help
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
choice STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
|
||||
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
|
||||
The guards are initialized when a function is entered and then checked when the function exits.
|
||||
If a guard check fails, program is halted. Protection has the following modes:
|
||||
|
||||
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca,
|
||||
and functions with buffers larger than 8 bytes are protected.
|
||||
|
||||
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes
|
||||
additional functions to be protected -- those that have local array definitions,
|
||||
or have references to local frame addresses.
|
||||
|
||||
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
|
||||
|
||||
Modes have the following impact on code performance and coverage:
|
||||
|
||||
- performance: NORMAL > STRONG > OVERALL
|
||||
|
||||
- coverage: NORMAL < STRONG < OVERALL
|
||||
|
||||
|
||||
config STACK_CHECK_NONE
|
||||
bool "None"
|
||||
config STACK_CHECK_NORM
|
||||
bool "Normal"
|
||||
config STACK_CHECK_STRONG
|
||||
bool "Strong"
|
||||
config STACK_CHECK_ALL
|
||||
bool "Overall"
|
||||
endchoice
|
||||
|
||||
config STACK_CHECK
|
||||
bool
|
||||
default !STACK_CHECK_NONE
|
||||
help
|
||||
Stack smashing protection.
|
||||
|
||||
config WARN_WRITE_STRINGS
|
||||
bool "Enable -Wwrite-strings warning flag"
|
||||
default "n"
|
||||
help
|
||||
Adds -Wwrite-strings flag for the C/C++ compilers.
|
||||
|
||||
For C, this gives string constants the type ``const char[]`` so that
|
||||
copying the address of one into a non-const ``char *`` pointer
|
||||
produces a warning. This warning helps to find at compile time code
|
||||
that tries to write into a string constant.
|
||||
|
||||
For C++, this warns about the deprecated conversion from string
|
||||
literals to ``char *``.
|
||||
|
||||
endmenu # Compiler Options
|
@@ -49,7 +49,7 @@ NOTE: The `-j4` option causes `make` to run 4 parallel jobs. This is much faster
|
||||
|
||||
## Flashing the Project
|
||||
|
||||
When `make all` finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this from make by running:
|
||||
When the build finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this automatically by running:
|
||||
|
||||
`make -j4 flash`
|
||||
|
||||
@@ -88,6 +88,7 @@ Multiple make functions can be combined into one. For example: to build the app
|
||||
make -j5 flash monitor
|
||||
```
|
||||
|
||||
|
||||
## The Partition Table
|
||||
|
||||
Once you've compiled your project, the "build" directory will contain a binary file with a name like "my_app.bin". This is an ESP32 image binary that can be loaded by the bootloader.
|
||||
|
28
components/app_trace/CMakeLists.txt
Normal file
28
components/app_trace/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
set(COMPONENT_SRCS "app_trace.c"
|
||||
"app_trace_util.c"
|
||||
"host_file_io.c"
|
||||
"gcov/gcov_rtio.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
if(CONFIG_SYSVIEW_ENABLE)
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS
|
||||
sys_view/Config
|
||||
sys_view/SEGGER
|
||||
sys_view/Sample/OS)
|
||||
|
||||
list(APPEND COMPONENT_SRCS "sys_view/SEGGER/SEGGER_SYSVIEW.c"
|
||||
"sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c"
|
||||
"sys_view/Sample/OS/SEGGER_SYSVIEW_FreeRTOS.c"
|
||||
"sys_view/esp32/SEGGER_RTT_esp32.c")
|
||||
endif()
|
||||
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_PRIV_REQUIRES xtensa-debug-module)
|
||||
|
||||
register_component()
|
||||
|
||||
# disable --coverage for this component, as it is used as transport
|
||||
# for gcov
|
||||
component_compile_options("-fno-profile-arcs" "-fno-test-coverage")
|
||||
|
||||
target_link_libraries(app_trace gcov)
|
7
components/app_update/CMakeLists.txt
Normal file
7
components/app_update/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
set(COMPONENT_SRCS "esp_ota_ops.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
|
||||
set(COMPONENT_REQUIRES spi_flash)
|
||||
set(COMPONENT_PRIV_REQUIRES bootloader_support)
|
||||
|
||||
register_component()
|
@@ -28,6 +28,7 @@
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_secure_boot.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "esp_ota_ops.h"
|
||||
@@ -144,8 +145,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
if (it->handle == handle) {
|
||||
// must erase the partition before writing to it
|
||||
assert(it->erased_size > 0 && "must erase the partition before writing to it");
|
||||
|
||||
if(it->wrote_size == 0 && size > 0 && data_bytes[0] != 0xE9) {
|
||||
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
}
|
||||
@@ -291,7 +291,7 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
|
||||
uint16_t ota_app_count = 0;
|
||||
uint32_t i = 0;
|
||||
uint32_t seq;
|
||||
static spi_flash_mmap_memory_t ota_data_map;
|
||||
spi_flash_mmap_handle_t ota_data_map;
|
||||
const void *result = NULL;
|
||||
|
||||
find_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
|
||||
@@ -376,7 +376,7 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition)
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
#ifdef CONFIG_SECURE_SIGNED_ON_UPDATE
|
||||
esp_err_t ret = esp_secure_boot_verify_signature(partition->address, data.image_len);
|
||||
if (ret != ESP_OK) {
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
@@ -437,7 +437,7 @@ const esp_partition_t *esp_ota_get_boot_partition(void)
|
||||
{
|
||||
esp_err_t ret;
|
||||
const esp_partition_t *find_partition = NULL;
|
||||
static spi_flash_mmap_memory_t ota_data_map;
|
||||
spi_flash_mmap_handle_t ota_data_map;
|
||||
const void *result = NULL;
|
||||
uint16_t ota_app_count = 0;
|
||||
find_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
|
||||
@@ -493,9 +493,18 @@ const esp_partition_t *esp_ota_get_boot_partition(void)
|
||||
|
||||
const esp_partition_t* esp_ota_get_running_partition(void)
|
||||
{
|
||||
static const esp_partition_t *curr_partition = NULL;
|
||||
|
||||
/*
|
||||
* Currently running partition is unlikely to change across reset cycle,
|
||||
* so it can be cached here, and avoid lookup on every flash write operation.
|
||||
*/
|
||||
if (curr_partition != NULL) {
|
||||
return curr_partition;
|
||||
}
|
||||
|
||||
/* Find the flash address of this exact function. By definition that is part
|
||||
of the currently running firmware. Then find the enclosing partition. */
|
||||
|
||||
size_t phys_offs = spi_flash_cache2phys(esp_ota_get_running_partition);
|
||||
|
||||
assert (phys_offs != SPI_FLASH_CACHE2PHYS_FAIL); /* indicates cache2phys lookup is buggy */
|
||||
@@ -509,6 +518,7 @@ const esp_partition_t* esp_ota_get_running_partition(void)
|
||||
const esp_partition_t *p = esp_partition_get(it);
|
||||
if (p->address <= phys_offs && p->address + p->size > phys_offs) {
|
||||
esp_partition_iterator_release(it);
|
||||
curr_partition = p;
|
||||
return p;
|
||||
}
|
||||
it = esp_partition_next(it);
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <stddef.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
26
components/aws_iot/CMakeLists.txt
Normal file
26
components/aws_iot/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
if(CONFIG_AWS_IOT_SDK)
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
|
||||
set(aws_sdk_src aws-iot-device-sdk-embedded-C/src)
|
||||
set(COMPONENT_SRCS "${aws_sdk_src}/aws_iot_json_utils.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client_common_internal.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client_connect.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client_publish.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client_subscribe.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client_unsubscribe.c"
|
||||
"${aws_sdk_src}/aws_iot_mqtt_client_yield.c"
|
||||
"${aws_sdk_src}/aws_iot_shadow.c"
|
||||
"${aws_sdk_src}/aws_iot_shadow_actions.c"
|
||||
"${aws_sdk_src}/aws_iot_shadow_json.c"
|
||||
"${aws_sdk_src}/aws_iot_shadow_records.c"
|
||||
"port/network_mbedtls_wrapper.c"
|
||||
"port/threads_freertos.c"
|
||||
"port/timer.c")
|
||||
else()
|
||||
message(STATUS "Building empty aws_iot component due to configuration")
|
||||
endif()
|
||||
|
||||
set(COMPONENT_REQUIRES "mbedtls")
|
||||
set(COMPONENT_PRIV_REQUIRES "jsmn")
|
||||
|
||||
register_component()
|
7
components/bootloader/CMakeLists.txt
Normal file
7
components/bootloader/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
# bootloader component logic is all in project_include.cmake,
|
||||
# and subproject/CMakeLists.txt.
|
||||
#
|
||||
# This file is only included so the build system finds the
|
||||
# component
|
||||
|
||||
|
@@ -132,9 +132,59 @@ endmenu # Bootloader
|
||||
|
||||
menu "Security features"
|
||||
|
||||
# These three are the actual options to check in code,
|
||||
# selected by the displayed options
|
||||
config SECURE_SIGNED_ON_BOOT
|
||||
bool
|
||||
default y
|
||||
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
|
||||
|
||||
config SECURE_SIGNED_ON_UPDATE
|
||||
bool
|
||||
default y
|
||||
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
|
||||
config SECURE_SIGNED_APPS
|
||||
bool
|
||||
default y
|
||||
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
|
||||
|
||||
|
||||
config SECURE_SIGNED_APPS_NO_SECURE_BOOT
|
||||
bool "Require signed app images"
|
||||
default n
|
||||
depends on !SECURE_BOOT_ENABLED
|
||||
help
|
||||
Require apps to be signed to verify their integrity.
|
||||
|
||||
This option uses the same app signature scheme as hardware secure boot, but unlike hardware secure boot it does not prevent the bootloader from being physically updated. This means that the device can be secured against remote network access, but not physical access. Compared to using hardware Secure Boot this option is much simpler to implement.
|
||||
|
||||
config SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
|
||||
bool "Bootloader verifies app signatures"
|
||||
default n
|
||||
depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
|
||||
help
|
||||
If this option is set, the bootloader will be compiled with code to verify that an app is signed before booting it.
|
||||
|
||||
If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
|
||||
If hardware secure boot is not enabled, this option doesn't add significant security by itself so most users will want to leave it disabled.
|
||||
|
||||
config SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
bool "Verify app signature on update"
|
||||
default y
|
||||
depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
|
||||
help
|
||||
If this option is set, any OTA updated apps will have the signature verified before being considered valid.
|
||||
|
||||
When enabled, the signature is automatically checked whenever the esp_ota_ops.h APIs are used for OTA updates,
|
||||
or esp_image_format.h APIs are used to verify apps.
|
||||
|
||||
If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
|
||||
If hardware secure boot is not enabled, this option still adds significant security against network-based attackers by preventing spoofing of OTA updates.
|
||||
|
||||
config SECURE_BOOT_ENABLED
|
||||
bool "Enable secure boot in bootloader (READ DOCS FIRST)"
|
||||
default N
|
||||
bool "Enable hardware secure boot in bootloader (READ DOCS FIRST)"
|
||||
default n
|
||||
help
|
||||
Build a bootloader which enables secure boot on first boot.
|
||||
|
||||
@@ -169,12 +219,12 @@ endchoice
|
||||
|
||||
config SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
bool "Sign binaries during build"
|
||||
depends on SECURE_BOOT_ENABLED
|
||||
depends on SECURE_SIGNED_APPS
|
||||
default y
|
||||
help
|
||||
Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
|
||||
Once secure boot or signed app requirement is enabled, app images are required to be signed.
|
||||
|
||||
If enabled, these binary files are signed as part of the build process. The file named in "Secure boot private signing key" will be used to sign the image.
|
||||
If enabled (default), these binary files are signed as part of the build process. The file named in "Secure boot private signing key" will be used to sign the image.
|
||||
|
||||
If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py (for example, on a remote signing server.)
|
||||
|
||||
@@ -183,7 +233,7 @@ config SECURE_BOOT_SIGNING_KEY
|
||||
depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
default secure_boot_signing_key.pem
|
||||
help
|
||||
Path to the key file used to sign partition tables and app images for secure boot. Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
|
||||
Path to the key file used to sign app images.
|
||||
|
||||
Key file is an ECDSA private key (NIST256p curve) in PEM format.
|
||||
|
||||
@@ -196,11 +246,11 @@ config SECURE_BOOT_SIGNING_KEY
|
||||
|
||||
config SECURE_BOOT_VERIFICATION_KEY
|
||||
string "Secure boot public signature verification key"
|
||||
depends on SECURE_BOOT_ENABLED && !SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
default signature_verification_key.bin
|
||||
help
|
||||
Path to a public key file used to verify signed images. This key is compiled into the bootloader,
|
||||
and may also be used to verify signatures on OTA images after download.
|
||||
Path to a public key file used to verify signed images. This key is compiled into the bootloader and/or app,
|
||||
to verify app images.
|
||||
|
||||
Key file is in raw binary format, and can be extracted from a
|
||||
PEM formatted private key using the espsecure.py
|
||||
@@ -208,6 +258,27 @@ config SECURE_BOOT_VERIFICATION_KEY
|
||||
|
||||
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
|
||||
|
||||
choice SECURE_BOOTLOADER_KEY_ENCODING
|
||||
bool "Hardware Key Encoding"
|
||||
depends on SECURE_BOOTLOADER_REFLASHABLE
|
||||
default SECURE_BOOTLOADER_NO_ENCODING
|
||||
help
|
||||
|
||||
In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and can be written to efuse
|
||||
with espefuse.py.
|
||||
|
||||
Normally this is a 256-bit key, but if 3/4 Coding Scheme is used on the device then the efuse key is truncated to 192 bits.
|
||||
|
||||
This configuration item doesn't change any firmware code, it only changes the size of key binary which is generated at build time.
|
||||
|
||||
config SECURE_BOOTLOADER_KEY_ENCODING_256BIT
|
||||
bool "No encoding (256 bit key)"
|
||||
|
||||
config SECURE_BOOTLOADER_KEY_ENCODING_192BIT
|
||||
bool "3/4 encoding (192 bit key)"
|
||||
|
||||
endchoice
|
||||
|
||||
config SECURE_BOOT_INSECURE
|
||||
bool "Allow potentially insecure options"
|
||||
depends on SECURE_BOOT_ENABLED
|
||||
|
@@ -78,12 +78,18 @@ else ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
|
||||
# Reflashable secure bootloader
|
||||
# generates a digest binary (bootloader + digest)
|
||||
|
||||
ifdef CONFIG_SECURE_BOOTLOADER_KEY_ENCODING_192BIT
|
||||
KEY_DIGEST_LEN=192
|
||||
else
|
||||
KEY_DIGEST_LEN=256
|
||||
endif
|
||||
|
||||
BOOTLOADER_DIGEST_BIN := $(BOOTLOADER_BUILD_DIR)/bootloader-reflash-digest.bin
|
||||
SECURE_BOOTLOADER_KEY := $(BOOTLOADER_BUILD_DIR)/secure-bootloader-key.bin
|
||||
SECURE_BOOTLOADER_KEY := $(BOOTLOADER_BUILD_DIR)/secure-bootloader-key-$(KEY_DIGEST_LEN).bin
|
||||
|
||||
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
$(SECURE_BOOTLOADER_KEY): $(SECURE_BOOT_SIGNING_KEY)
|
||||
$(ESPSECUREPY) digest_private_key -k $< $@
|
||||
$(ESPSECUREPY) digest_private_key --keylen $(KEY_DIGEST_LEN) -k $< $@
|
||||
else
|
||||
$(SECURE_BOOTLOADER_KEY):
|
||||
@echo "No pre-generated key for a reflashable secure bootloader is available, due to signing configuration."
|
||||
|
34
components/bootloader/project_include.cmake
Normal file
34
components/bootloader/project_include.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
if(BOOTLOADER_BUILD)
|
||||
return() # don't keep recursing!
|
||||
endif()
|
||||
|
||||
# Glue to build the bootloader subproject binary as an external
|
||||
# cmake project under this one
|
||||
#
|
||||
#
|
||||
set(bootloader_build_dir "${CMAKE_BINARY_DIR}/bootloader")
|
||||
set(bootloader_binary_files
|
||||
"${bootloader_build_dir}/bootloader.elf"
|
||||
"${bootloader_build_dir}/bootloader.bin"
|
||||
"${bootloader_build_dir}/bootloader.map"
|
||||
)
|
||||
|
||||
externalproject_add(bootloader
|
||||
# TODO: support overriding the bootloader in COMPONENT_PATHS
|
||||
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
|
||||
BINARY_DIR "${bootloader_build_dir}"
|
||||
CMAKE_ARGS -DSDKCONFIG=${SDKCONFIG} -DIDF_PATH=${IDF_PATH}
|
||||
-DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR}
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_ALWAYS 1 # no easy way around this...
|
||||
BUILD_BYPRODUCTS ${bootloader_binary_files}
|
||||
)
|
||||
|
||||
# this is a hack due to an (annoying) shortcoming in cmake, it can't
|
||||
# extend the 'clean' target to the external project
|
||||
# see thread: https://cmake.org/pipermail/cmake/2016-December/064660.html
|
||||
#
|
||||
# So for now we just have the top-level build remove the final build products...
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
|
||||
ADDITIONAL_MAKE_CLEAN_FILES
|
||||
${bootloader_binary_files})
|
28
components/bootloader/subproject/CMakeLists.txt
Normal file
28
components/bootloader/subproject/CMakeLists.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
if(NOT SDKCONFIG)
|
||||
message(FATAL_ERROR "Bootloader subproject expects the SDKCONFIG variable to be passed "
|
||||
"in by the parent build process.")
|
||||
endif()
|
||||
|
||||
if(NOT IDF_PATH)
|
||||
message(FATAL_ERROR "Bootloader subproject expects the IDF_PATH variable to be passed "
|
||||
"in by the parent build process.")
|
||||
endif()
|
||||
|
||||
set(COMPONENTS bootloader esptool_py esp32 partition_table soc bootloader_support log spi_flash micro-ecc soc main)
|
||||
set(BOOTLOADER_BUILD 1)
|
||||
add_definitions(-DBOOTLOADER_BUILD=1)
|
||||
|
||||
set(COMPONENT_REQUIRES_COMMON log esp32 soc)
|
||||
|
||||
include("${IDF_PATH}/tools/cmake/project.cmake")
|
||||
project(bootloader)
|
||||
|
||||
target_linker_script(bootloader.elf
|
||||
"main/esp32.bootloader.ld"
|
||||
"main/esp32.bootloader.rom.ld")
|
||||
# Imported from esp32 component
|
||||
target_linker_script(bootloader.elf ${ESP32_BOOTLOADER_LINKER_SCRIPTS})
|
||||
|
||||
target_link_libraries(bootloader.elf gcc)
|
4
components/bootloader/subproject/main/CMakeLists.txt
Normal file
4
components/bootloader/subproject/main/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
set(COMPONENT_SRCS "bootloader_start.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "")
|
||||
set(COMPONENT_REQUIRES "bootloader bootloader_support")
|
||||
register_component()
|
@@ -30,29 +30,29 @@ SECTIONS
|
||||
.iram_loader.text :
|
||||
{
|
||||
. = ALIGN (16);
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
|
||||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*liblog.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_utility.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_sha.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:efuse.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:esp_image_format.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_encrypt.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_partitions.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot_signatures.o(.literal .text .literal.* .text.*)
|
||||
*libmicro-ecc.a:*.o(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:*.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_common.o(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:efuse.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:secure_boot_signatures.*(.literal .text .literal.* .text.*)
|
||||
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
_loader_text_end = ABSOLUTE(.);
|
||||
} > iram_loader_seg
|
||||
|
||||
.iram.text :
|
||||
@@ -119,13 +119,13 @@ SECTIONS
|
||||
. = (. + 3) & ~ 3;
|
||||
/* C++ constructor and destructor tables, properly ordered: */
|
||||
__init_array_start = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*crtbegin.*(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*(.ctors))
|
||||
__init_array_end = ABSOLUTE(.);
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*crtbegin.*(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
/* C++ exception handlers table: */
|
||||
|
@@ -1 +1,4 @@
|
||||
PROVIDE ( ets_update_cpu_frequency = 0x40008550 ); /* Updates g_ticks_per_us on the current CPU only; not on the other core */
|
||||
PROVIDE ( MD5Final = 0x4005db1c );
|
||||
PROVIDE ( MD5Init = 0x4005da7c );
|
||||
PROVIDE ( MD5Update = 0x4005da9c );
|
||||
|
27
components/bootloader_support/CMakeLists.txt
Normal file
27
components/bootloader_support/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
set(COMPONENT_SRCS "src/bootloader_clock.c"
|
||||
"src/bootloader_common.c"
|
||||
"src/bootloader_flash.c"
|
||||
"src/bootloader_random.c"
|
||||
"src/bootloader_sha.c"
|
||||
"src/bootloader_utility.c"
|
||||
"src/efuse.c"
|
||||
"src/esp_image_format.c"
|
||||
"src/flash_encrypt.c"
|
||||
"src/flash_partitions.c"
|
||||
"src/flash_qio_mode.c"
|
||||
"src/secure_boot.c"
|
||||
"src/secure_boot_signatures.c")
|
||||
|
||||
if(${BOOTLOADER_BUILD})
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include include_priv")
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_PRIV_REQUIRES spi_flash micro-ecc)
|
||||
list(APPEND COMPONENT_SRCS "src/bootloader_init.c")
|
||||
else()
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "include")
|
||||
set(COMPONENT_PRIV_INCLUDEDIRS "include_priv")
|
||||
set(COMPONENT_REQUIRES)
|
||||
set(COMPONENT_PRIV_REQUIRES spi_flash mbedtls micro-ecc)
|
||||
endif()
|
||||
|
||||
register_component()
|
@@ -9,10 +9,14 @@ endif
|
||||
|
||||
COMPONENT_SRCDIRS := src
|
||||
|
||||
ifndef IS_BOOTLOADER_BUILD
|
||||
COMPONENT_OBJEXCLUDE := src/bootloader_init.o
|
||||
endif
|
||||
|
||||
#
|
||||
# Secure boot signing key support
|
||||
#
|
||||
ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
ifdef CONFIG_SECURE_SIGNED_APPS
|
||||
|
||||
# this path is created relative to the component build directory
|
||||
SECURE_BOOT_VERIFICATION_KEY := $(abspath signature_verification_key.bin)
|
||||
|
34
components/bootloader_support/include/bootloader_util.h
Normal file
34
components/bootloader_support/include/bootloader_util.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @brief Check if half-open intervals overlap
|
||||
*
|
||||
* @param start1 interval 1 start
|
||||
* @param end1 interval 1 end
|
||||
* @param start2 interval 2 start
|
||||
* @param end2 interval 2 end
|
||||
* @return true iff [start1; end1) overlaps [start2; end2)
|
||||
*/
|
||||
static inline bool bootloader_util_regions_overlap(
|
||||
const intptr_t start1, const intptr_t end1,
|
||||
const intptr_t start2, const intptr_t end2)
|
||||
{
|
||||
return (end1 > start2 && end2 > start1) ||
|
||||
!(end1 <= start2 || end2 <= start1);
|
||||
}
|
@@ -15,6 +15,7 @@
|
||||
#define _ESP_EFUSE_H
|
||||
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -58,6 +59,38 @@ void esp_efuse_reset(void);
|
||||
*/
|
||||
void esp_efuse_disable_basic_rom_console(void);
|
||||
|
||||
/* @brief Encode one or more sets of 6 byte sequences into
|
||||
* 8 bytes suitable for 3/4 Coding Scheme.
|
||||
*
|
||||
* This function is only useful if the CODING_SCHEME efuse
|
||||
* is set to value 1 for 3/4 Coding Scheme.
|
||||
*
|
||||
* @param[in] in_bytes Pointer to a sequence of bytes to encode for 3/4 Coding Scheme. Must have length in_bytes_len. After being written to hardware, these bytes will read back as little-endian words.
|
||||
* @param[out] out_words Pointer to array of words suitable for writing to efuse write registers. Array must contain 2 words (8 bytes) for every 6 bytes in in_bytes_len. Can be a pointer to efuse write registers.
|
||||
* @param in_bytes_len. Length of array pointed to by in_bytes, in bytes. Must be a multiple of 6.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if either pointer is null or in_bytes_len is not a multiple of 6. ESP_OK otherwise.
|
||||
*/
|
||||
esp_err_t esp_efuse_apply_34_encoding(const uint8_t *in_bytes, uint32_t *out_words, size_t in_bytes_len);
|
||||
|
||||
/* @brief Write random data to efuse key block write registers
|
||||
*
|
||||
* @note Caller is responsible for ensuring efuse
|
||||
* block is empty and not write protected, before calling.
|
||||
*
|
||||
* @note Behaviour depends on coding scheme: a 256-bit key is
|
||||
* generated and written for Coding Scheme "None", a 192-bit key
|
||||
* is generated, extended to 256-bits by the Coding Scheme,
|
||||
* and then writtten for 3/4 Coding Scheme.
|
||||
*
|
||||
* @note This function does not burn the new values, caller should
|
||||
* call esp_efuse_burn_new_values() when ready to do this.
|
||||
*
|
||||
* @param blk_wdata0_reg Address of the first data write register
|
||||
* in the block
|
||||
*/
|
||||
void esp_efuse_write_random_key(uint32_t blk_wdata0_reg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -17,7 +17,9 @@
|
||||
#include <stdbool.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
#include "esp_spi_flash.h"
|
||||
#endif
|
||||
#include "soc/efuse_reg.h"
|
||||
|
||||
/**
|
||||
|
@@ -81,6 +81,8 @@ typedef struct {
|
||||
|
||||
_Static_assert(sizeof(esp_image_header_t) == 24, "binary image header should be 24 bytes");
|
||||
|
||||
#define ESP_IMAGE_HASH_LEN 32 /* Length of the appended SHA-256 digest */
|
||||
|
||||
/* Header of binary image segment */
|
||||
typedef struct {
|
||||
uint32_t load_addr;
|
||||
@@ -142,6 +144,16 @@ esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *
|
||||
*/
|
||||
esp_err_t esp_image_verify_bootloader(uint32_t *length);
|
||||
|
||||
/**
|
||||
* @brief Verify the bootloader image.
|
||||
*
|
||||
* @param[out] Metadata for the image. Only valid if result is ESP_OK.
|
||||
*
|
||||
* @return As per esp_image_load_metadata().
|
||||
*/
|
||||
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data);
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t drom_addr;
|
||||
uint32_t drom_load_addr;
|
||||
|
@@ -17,6 +17,14 @@
|
||||
#include <esp_err.h>
|
||||
#include "soc/efuse_reg.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
#if !defined(CONFIG_SECURE_SIGNED_ON_BOOT) || !defined(CONFIG_SECURE_SIGNED_ON_UPDATE) || !defined(CONFIG_SECURE_SIGNED_APPS)
|
||||
#error "internal sdkconfig error, secure boot should always enable all signature options"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "esp_spi_flash.h"
|
||||
|
||||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
#define FLASH_BLOCK_SIZE 0x10000
|
||||
|
||||
/* Provide a Flash API for bootloader_support code,
|
||||
that can be used from bootloader or app code.
|
||||
@@ -100,4 +101,31 @@ esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool
|
||||
*/
|
||||
esp_err_t bootloader_flash_erase_sector(size_t sector);
|
||||
|
||||
/**
|
||||
* @brief Erase the Flash range.
|
||||
*
|
||||
* @param start_addr start address of flash offset
|
||||
* @param size sector aligned size to be erased
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size);
|
||||
|
||||
/* Cache MMU block size */
|
||||
#define MMU_BLOCK_SIZE 0x00010000
|
||||
|
||||
/* Cache MMU address mask (MMU tables ignore bits which are zero) */
|
||||
#define MMU_FLASH_MASK (~(MMU_BLOCK_SIZE - 1))
|
||||
|
||||
/**
|
||||
* @brief Calculate the number of cache pages to map
|
||||
* @param size size of data to map
|
||||
* @param vaddr virtual address where data will be mapped
|
||||
* @return number of cache MMU pages required to do the mapping
|
||||
*/
|
||||
static inline uint32_t bootloader_cache_pages_to_map(uint32_t size, uint32_t vaddr)
|
||||
{
|
||||
return (size + (vaddr - (vaddr & MMU_FLASH_MASK)) + MMU_BLOCK_SIZE - 1) / MMU_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -31,14 +31,14 @@ void bootloader_clock_configure()
|
||||
/* Set CPU to 80MHz. Keep other clocks unmodified. */
|
||||
rtc_cpu_freq_t cpu_freq = RTC_CPU_FREQ_80M;
|
||||
|
||||
/* On ESP32 rev 0, switching to 80MHz if clock was previously set to
|
||||
/* On ESP32 rev 0, switching to 80/160 MHz if clock was previously set to
|
||||
* 240 MHz may cause the chip to lock up (see section 3.5 of the errata
|
||||
* document). For rev. 0, switch to 240 instead if it was chosen in
|
||||
* menuconfig.
|
||||
* document). For rev. 0, switch to 240 instead if it has been enabled
|
||||
* previously.
|
||||
*/
|
||||
uint32_t chip_ver_reg = REG_READ(EFUSE_BLK0_RDATA3_REG);
|
||||
if ((chip_ver_reg & EFUSE_RD_CHIP_VER_REV1_M) == 0 &&
|
||||
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240) {
|
||||
DPORT_REG_GET_FIELD(DPORT_CPU_PER_CONF_REG, DPORT_CPUPERIOD_SEL) == DPORT_CPUPERIOD_SEL_240) {
|
||||
cpu_freq = RTC_CPU_FREQ_240M;
|
||||
}
|
||||
|
||||
|
@@ -102,8 +102,8 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat
|
||||
|
||||
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
if (!partitions) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
return false;
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
|
||||
return false;
|
||||
}
|
||||
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
|
||||
|
||||
@@ -124,7 +124,7 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat
|
||||
// partition->label is not null-terminated string.
|
||||
strncpy(label, (char *)&partition->label, sizeof(partition->label));
|
||||
if (fl_ota_data_erase == true || (bootloader_common_label_search(list_erase, label) == true)) {
|
||||
err = esp_rom_spiflash_erase_area(partition->pos.offset, partition->pos.size);
|
||||
err = bootloader_flash_erase_range(partition->pos.offset, partition->pos.size);
|
||||
if (err != ESP_OK) {
|
||||
ret = false;
|
||||
marker = "err";
|
||||
|
@@ -73,6 +73,11 @@ esp_err_t bootloader_flash_erase_sector(size_t sector)
|
||||
return spi_flash_erase_sector(sector);
|
||||
}
|
||||
|
||||
esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
{
|
||||
return spi_flash_erase_range(start_addr, size);
|
||||
}
|
||||
|
||||
#else
|
||||
/* Bootloader version, uses ROM functions only */
|
||||
#include <soc/dport_reg.h>
|
||||
@@ -86,8 +91,6 @@ static const char *TAG = "bootloader_flash";
|
||||
*/
|
||||
#define MMU_BLOCK0_VADDR 0x3f400000
|
||||
#define MMU_BLOCK50_VADDR 0x3f720000
|
||||
#define MMU_FLASH_MASK 0xffff0000
|
||||
#define MMU_BLOCK_SIZE 0x00010000
|
||||
|
||||
static bool mapped;
|
||||
|
||||
@@ -107,10 +110,11 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
}
|
||||
|
||||
uint32_t src_addr_aligned = src_addr & MMU_FLASH_MASK;
|
||||
uint32_t count = (size + (src_addr - src_addr_aligned) + 0xffff) / MMU_BLOCK_SIZE;
|
||||
uint32_t count = bootloader_cache_pages_to_map(size, src_addr);
|
||||
Cache_Read_Disable(0);
|
||||
Cache_Flush(0);
|
||||
ESP_LOGD(TAG, "mmu set paddr=%08x count=%d", src_addr_aligned, count );
|
||||
ESP_LOGD(TAG, "mmu set paddr=%08x count=%d size=%x src_addr=%x src_addr_aligned=%x",
|
||||
src_addr & MMU_FLASH_MASK, count, size, src_addr, src_addr_aligned );
|
||||
int e = cache_flash_mmu_set(0, 0, MMU_BLOCK0_VADDR, src_addr_aligned, 64, count);
|
||||
if (e != 0) {
|
||||
ESP_LOGE(TAG, "cache_flash_mmu_set failed: %d\n", e);
|
||||
@@ -247,4 +251,28 @@ esp_err_t bootloader_flash_erase_sector(size_t sector)
|
||||
return spi_to_esp_err(esp_rom_spiflash_erase_sector(sector));
|
||||
}
|
||||
|
||||
esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
{
|
||||
if (start_addr % FLASH_SECTOR_SIZE != 0) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (size % FLASH_SECTOR_SIZE != 0) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
size_t start = start_addr / FLASH_SECTOR_SIZE;
|
||||
size_t end = start + size / FLASH_SECTOR_SIZE;
|
||||
const size_t sectors_per_block = FLASH_BLOCK_SIZE / FLASH_SECTOR_SIZE;
|
||||
|
||||
esp_rom_spiflash_result_t rc = ESP_ROM_SPIFLASH_RESULT_OK;
|
||||
for (size_t sector = start; sector != end && rc == ESP_ROM_SPIFLASH_RESULT_OK; ) {
|
||||
if (sector % sectors_per_block == 0 && end - sector >= sectors_per_block) {
|
||||
rc = esp_rom_spiflash_erase_block(sector / sectors_per_block);
|
||||
sector += sectors_per_block;
|
||||
} else {
|
||||
rc = esp_rom_spiflash_erase_sector(sector);
|
||||
++sector;
|
||||
}
|
||||
}
|
||||
return spi_to_esp_err(rc);
|
||||
}
|
||||
#endif
|
||||
|
@@ -33,12 +33,10 @@
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/timer_group_reg.h"
|
||||
#include "soc/gpio_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_image_format.h"
|
||||
@@ -71,6 +69,7 @@ static void wdt_reset_check(void);
|
||||
esp_err_t bootloader_init()
|
||||
{
|
||||
cpu_configure_region_protection();
|
||||
cpu_init_memctl();
|
||||
|
||||
/* Sanity check that static RAM is after the stack */
|
||||
#ifndef NDEBUG
|
||||
@@ -307,10 +306,11 @@ static void IRAM_ATTR flash_gpio_configure(const esp_image_header_t* pfhdr)
|
||||
int drv = 2;
|
||||
switch (pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN; //qio 3
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_ADDR_BITLEN_V, SPI0_R_DIO_ADDR_BITSLEN, SPI_USR_ADDR_BITLEN_S);
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
case ESP_IMAGE_SPI_MODE_DOUT:
|
||||
@@ -427,10 +427,18 @@ static void uart_console_configure(void)
|
||||
// (arrays should be optimized away by the compiler)
|
||||
const uint32_t tx_idx_list[3] = { U0TXD_OUT_IDX, U1TXD_OUT_IDX, U2TXD_OUT_IDX };
|
||||
const uint32_t rx_idx_list[3] = { U0RXD_IN_IDX, U1RXD_IN_IDX, U2RXD_IN_IDX };
|
||||
const uint32_t uart_reset[3] = { DPORT_UART_RST, DPORT_UART1_RST, DPORT_UART2_RST };
|
||||
const uint32_t tx_idx = tx_idx_list[uart_num];
|
||||
const uint32_t rx_idx = rx_idx_list[uart_num];
|
||||
|
||||
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[uart_rx_gpio]);
|
||||
gpio_pad_pullup(uart_rx_gpio);
|
||||
|
||||
gpio_matrix_out(uart_tx_gpio, tx_idx, 0, 0);
|
||||
gpio_matrix_in(uart_rx_gpio, rx_idx, 0);
|
||||
|
||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, uart_reset[uart_num]);
|
||||
}
|
||||
#endif // CONFIG_CONSOLE_UART_CUSTOM
|
||||
|
||||
|
@@ -131,6 +131,9 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
|
||||
case PART_SUBTYPE_DATA_WIFI:
|
||||
partition_usage = "WiFi data";
|
||||
break;
|
||||
case PART_SUBTYPE_DATA_NVS_KEYS:
|
||||
partition_usage = "NVS keys";
|
||||
break;
|
||||
default:
|
||||
partition_usage = "Unknown data";
|
||||
break;
|
||||
@@ -384,7 +387,7 @@ static void unpack_load_app(const esp_image_metadata_t* data)
|
||||
// Find DROM & IROM addresses, to configure cache mappings
|
||||
for (int i = 0; i < data->image.segment_count; i++) {
|
||||
const esp_image_segment_header_t *header = &data->segments[i];
|
||||
if (header->load_addr >= SOC_IROM_LOW && header->load_addr < SOC_IROM_HIGH) {
|
||||
if (header->load_addr >= SOC_DROM_LOW && header->load_addr < SOC_DROM_HIGH) {
|
||||
if (drom_addr != 0) {
|
||||
ESP_LOGE(TAG, MAP_ERR_MSG, "DROM");
|
||||
} else {
|
||||
@@ -394,7 +397,7 @@ static void unpack_load_app(const esp_image_metadata_t* data)
|
||||
drom_load_addr = header->load_addr;
|
||||
drom_size = header->data_len;
|
||||
}
|
||||
if (header->load_addr >= SOC_DROM_LOW && header->load_addr < SOC_DROM_HIGH) {
|
||||
if (header->load_addr >= SOC_IROM_LOW && header->load_addr < SOC_IROM_HIGH) {
|
||||
if (irom_addr != 0) {
|
||||
ESP_LOGE(TAG, MAP_ERR_MSG, "IROM");
|
||||
} else {
|
||||
@@ -425,6 +428,7 @@ static void set_cache_and_start_app(
|
||||
uint32_t irom_size,
|
||||
uint32_t entry_addr)
|
||||
{
|
||||
int rc;
|
||||
ESP_LOGD(TAG, "configure drom and irom and start");
|
||||
Cache_Read_Disable( 0 );
|
||||
Cache_Flush( 0 );
|
||||
@@ -436,20 +440,34 @@ static void set_cache_and_start_app(
|
||||
DPORT_PRO_FLASH_MMU_TABLE[i] = DPORT_FLASH_MMU_TABLE_INVALID_VAL;
|
||||
}
|
||||
|
||||
uint32_t drom_page_count = (drom_size + 64*1024 - 1) / (64*1024); // round up to 64k
|
||||
ESP_LOGV(TAG, "d mmu set paddr=%08x vaddr=%08x size=%d n=%d", drom_addr & 0xffff0000, drom_load_addr & 0xffff0000, drom_size, drom_page_count );
|
||||
int rc = cache_flash_mmu_set( 0, 0, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
rc = cache_flash_mmu_set( 1, 0, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
uint32_t irom_page_count = (irom_size + 64*1024 - 1) / (64*1024); // round up to 64k
|
||||
ESP_LOGV(TAG, "i mmu set paddr=%08x vaddr=%08x size=%d n=%d", irom_addr & 0xffff0000, irom_load_addr & 0xffff0000, irom_size, irom_page_count );
|
||||
rc = cache_flash_mmu_set( 0, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
rc = cache_flash_mmu_set( 1, 0, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count );
|
||||
ESP_LOGV(TAG, "rc=%d", rc );
|
||||
DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG, (DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) | (DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 | DPORT_PRO_CACHE_MASK_DRAM1 );
|
||||
DPORT_REG_CLR_BIT( DPORT_APP_CACHE_CTRL1_REG, (DPORT_APP_CACHE_MASK_IRAM0) | (DPORT_APP_CACHE_MASK_IRAM1 & 0) | (DPORT_APP_CACHE_MASK_IROM0 & 0) | DPORT_APP_CACHE_MASK_DROM0 | DPORT_APP_CACHE_MASK_DRAM1 );
|
||||
uint32_t drom_load_addr_aligned = drom_load_addr & MMU_FLASH_MASK;
|
||||
uint32_t drom_page_count = bootloader_cache_pages_to_map(drom_size, drom_load_addr);
|
||||
ESP_LOGV(TAG, "d mmu set paddr=%08x vaddr=%08x size=%d n=%d",
|
||||
drom_addr & MMU_FLASH_MASK, drom_load_addr_aligned, drom_size, drom_page_count);
|
||||
rc = cache_flash_mmu_set(0, 0, drom_load_addr_aligned, drom_addr & MMU_FLASH_MASK, 64, drom_page_count);
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
rc = cache_flash_mmu_set(1, 0, drom_load_addr_aligned, drom_addr & MMU_FLASH_MASK, 64, drom_page_count);
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
|
||||
uint32_t irom_load_addr_aligned = irom_load_addr & MMU_FLASH_MASK;
|
||||
uint32_t irom_page_count = bootloader_cache_pages_to_map(irom_size, irom_load_addr);
|
||||
ESP_LOGV(TAG, "i mmu set paddr=%08x vaddr=%08x size=%d n=%d",
|
||||
irom_addr & MMU_FLASH_MASK, irom_load_addr_aligned, irom_size, irom_page_count);
|
||||
rc = cache_flash_mmu_set(0, 0, irom_load_addr_aligned, irom_addr & MMU_FLASH_MASK, 64, irom_page_count);
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
rc = cache_flash_mmu_set(1, 0, irom_load_addr_aligned, irom_addr & MMU_FLASH_MASK, 64, irom_page_count);
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
|
||||
DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG,
|
||||
(DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) |
|
||||
(DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 |
|
||||
DPORT_PRO_CACHE_MASK_DRAM1 );
|
||||
|
||||
DPORT_REG_CLR_BIT( DPORT_APP_CACHE_CTRL1_REG,
|
||||
(DPORT_APP_CACHE_MASK_IRAM0) | (DPORT_APP_CACHE_MASK_IRAM1 & 0) |
|
||||
(DPORT_APP_CACHE_MASK_IROM0 & 0) | DPORT_APP_CACHE_MASK_DROM0 |
|
||||
DPORT_APP_CACHE_MASK_DRAM1 );
|
||||
|
||||
Cache_Read_Enable( 0 );
|
||||
|
||||
// Application will need to do Cache_Flush(1) and Cache_Read_Enable(1)
|
||||
|
@@ -13,6 +13,8 @@
|
||||
// limitations under the License.
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_log.h"
|
||||
#include <string.h>
|
||||
#include "bootloader_random.h"
|
||||
|
||||
#define EFUSE_CONF_WRITE 0x5A5A /* efuse_pgm_op_ena, force no rd/wr disable */
|
||||
#define EFUSE_CONF_READ 0x5AA5 /* efuse_read_op_ena, release force */
|
||||
@@ -58,3 +60,55 @@ void esp_efuse_disable_basic_rom_console(void)
|
||||
esp_efuse_burn_new_values();
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_apply_34_encoding(const uint8_t *in_bytes, uint32_t *out_words, size_t in_bytes_len)
|
||||
{
|
||||
if (in_bytes == NULL || out_words == NULL || in_bytes_len % 6 != 0) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
while (in_bytes_len > 0) {
|
||||
uint8_t out[8];
|
||||
uint8_t xor = 0;
|
||||
uint8_t mul = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
xor ^= in_bytes[i];
|
||||
mul += (i + 1) * __builtin_popcount(in_bytes[i]);
|
||||
}
|
||||
|
||||
memcpy(out, in_bytes, 6); // Data bytes
|
||||
out[6] = xor;
|
||||
out[7] = mul;
|
||||
|
||||
memcpy(out_words, out, 8);
|
||||
|
||||
in_bytes_len -= 6;
|
||||
in_bytes += 6;
|
||||
out_words += 2;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void esp_efuse_write_random_key(uint32_t blk_wdata0_reg)
|
||||
{
|
||||
uint32_t buf[8];
|
||||
uint8_t raw[24];
|
||||
uint32_t coding_scheme = REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_CODING_SCHEME_M;
|
||||
|
||||
if (coding_scheme == EFUSE_CODING_SCHEME_VAL_NONE) {
|
||||
bootloader_fill_random(buf, sizeof(buf));
|
||||
} else { // 3/4 Coding Scheme
|
||||
bootloader_fill_random(raw, sizeof(raw));
|
||||
esp_err_t r = esp_efuse_apply_34_encoding(raw, buf, sizeof(raw));
|
||||
assert(r == ESP_OK);
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, "Writing random values to address 0x%08x", blk_wdata0_reg);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ESP_LOGV(TAG, "EFUSE_BLKx_WDATA%d_REG = 0x%08x", i, buf[i]);
|
||||
REG_WRITE(blk_wdata0_reg + 4*i, buf[i]);
|
||||
}
|
||||
bzero(buf, sizeof(buf));
|
||||
bzero(raw, sizeof(raw));
|
||||
}
|
||||
|
@@ -23,10 +23,25 @@
|
||||
#include <bootloader_flash.h>
|
||||
#include <bootloader_random.h>
|
||||
#include <bootloader_sha.h>
|
||||
#include "bootloader_util.h"
|
||||
|
||||
/* Checking signatures as part of verifying images is necessary:
|
||||
- Always if secure boot is enabled
|
||||
- Differently in bootloader and/or app, depending on kconfig
|
||||
*/
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
#ifdef CONFIG_SECURE_SIGNED_ON_BOOT
|
||||
#define SECURE_BOOT_CHECK_SIGNATURE
|
||||
#endif
|
||||
#else /* !BOOTLOADER_BUILD */
|
||||
#ifdef CONFIG_SECURE_SIGNED_ON_UPDATE
|
||||
#define SECURE_BOOT_CHECK_SIGNATURE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const char *TAG = "esp_image";
|
||||
|
||||
#define HASH_LEN 32 /* SHA-256 digest length */
|
||||
#define HASH_LEN ESP_IMAGE_HASH_LEN
|
||||
|
||||
#define SIXTEEN_MB 0x1000000
|
||||
#define ESP_ROM_CHECKSUM_INITIAL 0xEF
|
||||
@@ -42,6 +57,10 @@ static const char *TAG = "esp_image";
|
||||
(Means loaded code isn't executable until after the secure boot check.)
|
||||
*/
|
||||
static uint32_t ram_obfs_value[2];
|
||||
|
||||
/* Range of IRAM used by the loader, defined in ld script */
|
||||
extern int _loader_text_start;
|
||||
extern int _loader_text_end;
|
||||
#endif
|
||||
|
||||
/* Return true if load_addr is an address the bootloader should load into */
|
||||
@@ -107,7 +126,7 @@ esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *
|
||||
}
|
||||
|
||||
// Calculate SHA-256 of image if secure boot is on, or if image has a hash appended
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
#ifdef SECURE_BOOT_CHECK_SIGNATURE
|
||||
if (1) {
|
||||
#else
|
||||
if (data->image.hash_appended) {
|
||||
@@ -174,7 +193,7 @@ goto err;
|
||||
rewritten the header - rely on esptool.py having verified the bootloader at flashing time, instead.
|
||||
*/
|
||||
if (!is_bootloader) {
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
#ifdef SECURE_BOOT_CHECK_SIGNATURE
|
||||
// secure boot images have a signature appended
|
||||
err = verify_secure_boot_signature(sha_handle, data);
|
||||
#else
|
||||
@@ -182,7 +201,7 @@ goto err;
|
||||
if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) {
|
||||
err = verify_simple_hash(sha_handle, data);
|
||||
}
|
||||
#endif // CONFIG_SECURE_BOOT_ENABLED
|
||||
#endif // SECURE_BOOT_CHECK_SIGNATURE
|
||||
} else { // is_bootloader
|
||||
// bootloader may still have a sha256 digest handle open
|
||||
if (sha_handle != NULL) {
|
||||
@@ -287,18 +306,41 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
||||
(do_load)?"load":(is_mapping)?"map":"");
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
/* Before loading segment, check it doesn't clobber bootloader RAM. */
|
||||
if (do_load) {
|
||||
/* Before loading segment, check it doesn't clobber bootloader RAM... */
|
||||
uint32_t end_addr = load_addr + data_len;
|
||||
if (end_addr < 0x40000000) {
|
||||
const intptr_t load_end = load_addr + data_len;
|
||||
if (load_end <= (intptr_t) SOC_DIRAM_DRAM_HIGH) {
|
||||
/* Writing to DRAM */
|
||||
intptr_t sp = (intptr_t)get_sp();
|
||||
if (end_addr > sp - STACK_LOAD_HEADROOM) {
|
||||
ESP_LOGE(TAG, "Segment %d end address 0x%08x too high (bootloader stack 0x%08x liimit 0x%08x)",
|
||||
index, end_addr, sp, sp - STACK_LOAD_HEADROOM);
|
||||
if (load_end > sp - STACK_LOAD_HEADROOM) {
|
||||
/* Bootloader .data/.rodata/.bss is above the stack, so this
|
||||
* also checks that we aren't overwriting these segments.
|
||||
*
|
||||
* TODO: This assumes specific arrangement of sections we have
|
||||
* in the ESP32. Rewrite this in a generic way to support other
|
||||
* layouts.
|
||||
*/
|
||||
ESP_LOGE(TAG, "Segment %d end address 0x%08x too high (bootloader stack 0x%08x limit 0x%08x)",
|
||||
index, load_end, sp, sp - STACK_LOAD_HEADROOM);
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
} else {
|
||||
/* Writing to IRAM */
|
||||
const intptr_t loader_iram_start = (intptr_t) &_loader_text_start;
|
||||
const intptr_t loader_iram_end = (intptr_t) &_loader_text_end;
|
||||
|
||||
if (bootloader_util_regions_overlap(loader_iram_start, loader_iram_end,
|
||||
load_addr, load_end)) {
|
||||
ESP_LOGE(TAG, "Segment %d (0x%08x-0x%08x) overlaps bootloader IRAM (0x%08x-0x%08x)",
|
||||
index, load_addr, load_end, loader_iram_start, loader_iram_end);
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
uint32_t free_page_count = spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
|
||||
ESP_LOGD(TAG, "free data page_count 0x%08x",free_page_count);
|
||||
@@ -442,19 +484,28 @@ static bool should_load(uint32_t load_addr)
|
||||
esp_err_t esp_image_verify_bootloader(uint32_t *length)
|
||||
{
|
||||
esp_image_metadata_t data;
|
||||
const esp_partition_pos_t bootloader_part = {
|
||||
.offset = ESP_BOOTLOADER_OFFSET,
|
||||
.size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET,
|
||||
};
|
||||
esp_err_t err = esp_image_load(ESP_IMAGE_VERIFY,
|
||||
&bootloader_part,
|
||||
&data);
|
||||
esp_err_t err = esp_image_verify_bootloader_data(&data);
|
||||
if (length != NULL) {
|
||||
*length = (err == ESP_OK) ? data.image_len : 0;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data)
|
||||
{
|
||||
if (data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
const esp_partition_pos_t bootloader_part = {
|
||||
.offset = ESP_BOOTLOADER_OFFSET,
|
||||
.size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET,
|
||||
};
|
||||
return esp_image_load(ESP_IMAGE_VERIFY,
|
||||
&bootloader_part,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data)
|
||||
{
|
||||
uint32_t unpadded_length = data->image_len;
|
||||
@@ -492,6 +543,8 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
|
||||
{
|
||||
uint8_t image_hash[HASH_LEN] = { 0 };
|
||||
|
||||
ESP_LOGI(TAG, "Verifying image signature...");
|
||||
|
||||
// For secure boot, we calculate the signature hash over the whole file, which includes any "simple" hash
|
||||
// appended to the image for corruption detection
|
||||
if (data->image.hash_appended) {
|
||||
|
@@ -15,7 +15,6 @@
|
||||
#include <strings.h>
|
||||
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_flash_partitions.h"
|
||||
@@ -62,6 +61,12 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
|
||||
|
||||
static esp_err_t initialise_flash_encryption(void)
|
||||
{
|
||||
uint32_t coding_scheme = REG_GET_FIELD(EFUSE_BLK0_RDATA6_REG, EFUSE_CODING_SCHEME);
|
||||
if (coding_scheme != EFUSE_CODING_SCHEME_VAL_NONE && coding_scheme != EFUSE_CODING_SCHEME_VAL_34) {
|
||||
ESP_LOGE(TAG, "Unknown/unsupported CODING_SCHEME value 0x%x", coding_scheme);
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* Before first flash encryption pass, need to initialise key & crypto config */
|
||||
|
||||
/* Generate key */
|
||||
@@ -79,13 +84,7 @@ static esp_err_t initialise_flash_encryption(void)
|
||||
&& REG_READ(EFUSE_BLK1_RDATA6_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK1_RDATA7_REG) == 0) {
|
||||
ESP_LOGI(TAG, "Generating new flash encryption key...");
|
||||
uint32_t buf[8];
|
||||
bootloader_fill_random(buf, sizeof(buf));
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ESP_LOGV(TAG, "EFUSE_BLK1_WDATA%d_REG = 0x%08x", i, buf[i]);
|
||||
REG_WRITE(EFUSE_BLK1_WDATA0_REG + 4*i, buf[i]);
|
||||
}
|
||||
bzero(buf, sizeof(buf));
|
||||
esp_efuse_write_random_key(EFUSE_BLK1_WDATA0_REG);
|
||||
esp_efuse_burn_new_values();
|
||||
|
||||
ESP_LOGI(TAG, "Read & write protecting new key...");
|
||||
@@ -163,7 +162,7 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
|
||||
/* If the last flash_crypt_cnt bit is burned or write-disabled, the
|
||||
device can't re-encrypt itself. */
|
||||
if (flash_crypt_wr_dis || flash_crypt_cnt == 0xFF) {
|
||||
if (flash_crypt_wr_dis) {
|
||||
ESP_LOGE(TAG, "Cannot re-encrypt data (FLASH_CRYPT_CNT 0x%02x write disabled %d", flash_crypt_cnt, flash_crypt_wr_dis);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -200,8 +199,8 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
ESP_LOGD(TAG, "All flash regions checked for encryption pass");
|
||||
|
||||
/* Set least significant 0-bit in flash_crypt_cnt */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & 0xFF);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == 0xFF */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == EFUSE_RD_FLASH_CRYPT_CNT (0x7F) */
|
||||
uint32_t new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
|
||||
ESP_LOGD(TAG, "FLASH_CRYPT_CNT 0x%x -> 0x%x", flash_crypt_cnt, new_flash_crypt_cnt);
|
||||
REG_SET_FIELD(EFUSE_BLK0_WDATA0_REG, EFUSE_FLASH_CRYPT_CNT, new_flash_crypt_cnt);
|
||||
@@ -285,7 +284,8 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
|
||||
&partition->pos,
|
||||
&data_ignored);
|
||||
should_encrypt = (err == ESP_OK);
|
||||
} else if (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA) {
|
||||
} else if ((partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA)
|
||||
|| (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_NVS_KEYS)) {
|
||||
/* check if we have ota data partition and the partition should be encrypted unconditionally */
|
||||
should_encrypt = true;
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ static bool secure_boot_generate(uint32_t image_len){
|
||||
const uint32_t *image;
|
||||
|
||||
/* hardware secure boot engine only takes full blocks, so round up the
|
||||
image length. The additional data should all be 0xFF.
|
||||
image length. The additional data should all be 0xFF (or the appended SHA, if it falls in the same block).
|
||||
*/
|
||||
if (image_len % sizeof(digest.iv) != 0) {
|
||||
image_len = (image_len / sizeof(digest.iv) + 1) * sizeof(digest.iv);
|
||||
@@ -104,14 +104,21 @@ static inline void burn_efuses()
|
||||
|
||||
esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
esp_err_t err;
|
||||
uint32_t image_len = 0;
|
||||
if (esp_secure_boot_enabled())
|
||||
{
|
||||
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
err = esp_image_verify_bootloader(&image_len);
|
||||
uint32_t coding_scheme = REG_GET_FIELD(EFUSE_BLK0_RDATA6_REG, EFUSE_CODING_SCHEME);
|
||||
if (coding_scheme != EFUSE_CODING_SCHEME_VAL_NONE && coding_scheme != EFUSE_CODING_SCHEME_VAL_34) {
|
||||
ESP_LOGE(TAG, "Unknown/unsupported CODING_SCHEME value 0x%x", coding_scheme);
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/* Verify the bootloader */
|
||||
esp_image_metadata_t bootloader_data = { 0 };
|
||||
err = esp_image_verify_bootloader_data(&bootloader_data);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "bootloader image appears invalid! error %d", err);
|
||||
return err;
|
||||
@@ -131,13 +138,7 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
&& REG_READ(EFUSE_BLK2_RDATA6_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA7_REG) == 0) {
|
||||
ESP_LOGI(TAG, "Generating new secure boot key...");
|
||||
uint32_t buf[8];
|
||||
bootloader_fill_random(buf, sizeof(buf));
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ESP_LOGV(TAG, "EFUSE_BLK2_WDATA%d_REG = 0x%08x", i, buf[i]);
|
||||
REG_WRITE(EFUSE_BLK2_WDATA0_REG + 4*i, buf[i]);
|
||||
}
|
||||
bzero(buf, sizeof(buf));
|
||||
esp_efuse_write_random_key(EFUSE_BLK2_WDATA0_REG);
|
||||
burn_efuses();
|
||||
ESP_LOGI(TAG, "Read & write protecting new key...");
|
||||
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
|
||||
@@ -150,6 +151,11 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Generating secure boot digest...");
|
||||
uint32_t image_len = bootloader_data.image_len;
|
||||
if(bootloader_data.image.hash_appended) {
|
||||
/* Secure boot digest doesn't cover the hash */
|
||||
image_len -= ESP_IMAGE_HASH_LEN;
|
||||
}
|
||||
if (false == secure_boot_generate(image_len)){
|
||||
ESP_LOGE(TAG, "secure boot generation failed");
|
||||
return ESP_FAIL;
|
||||
|
@@ -0,0 +1,94 @@
|
||||
#include <stdint.h>
|
||||
#include <strings.h>
|
||||
#include "esp_efuse.h"
|
||||
#include "unity.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t unencoded[24];
|
||||
uint32_t encoded[8];
|
||||
} coding_scheme_test_t;
|
||||
|
||||
/* Randomly generated byte strings, encoded and written to ESP32
|
||||
using espefuse algorithm, then verified to have no encoding errors
|
||||
and correct readback.
|
||||
*/
|
||||
static const coding_scheme_test_t coding_scheme_data[] = {
|
||||
{
|
||||
.unencoded = { 0x96, 0xa9, 0xab, 0xb2, 0xda, 0xdd, 0x21, 0xd2, 0x35, 0x22, 0xd3, 0x30, 0x3b, 0xf8, 0xcb, 0x77, 0x8d, 0x8d, 0xf4, 0x96, 0x25, 0xc4, 0xb9, 0x94 },
|
||||
.encoded = { 0xb2aba996, 0x6821ddda, 0x2235d221, 0x430730d3, 0x77cbf83b, 0x627f8d8d, 0xc42596f4, 0x4dae94b9 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x0e, 0x6b, 0x1a, 0x1d, 0xa5, 0x9f, 0x24, 0xcf, 0x91, 0x5b, 0xe7, 0xe1, 0x7c, 0x0a, 0x6e, 0xdc, 0x5e, 0x8e, 0xb1, 0xec, 0xd1, 0xf3, 0x75, 0x48 },
|
||||
.encoded = { 0x1d1a6b0e, 0x5e589fa5, 0x5b91cf24, 0x6127e1e7, 0xdc6e0a7c, 0x5d148e5e, 0xf3d1ecb1, 0x57424875 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x0a, 0x79, 0x5a, 0x1c, 0xb1, 0x45, 0x71, 0x2c, 0xb3, 0xda, 0x9e, 0xdc, 0x76, 0x27, 0xf5, 0xca, 0xe7, 0x00, 0x39, 0x95, 0x6c, 0x53, 0xc2, 0x07 },
|
||||
.encoded = { 0x1c5a790a, 0x4ac145b1, 0xdab32c71, 0x6476dc9e, 0xcaf52776, 0x4d8900e7, 0x536c9539, 0x495607c2 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x76, 0x46, 0x88, 0x2d, 0x4c, 0xe1, 0x50, 0x5d, 0xd6, 0x7c, 0x41, 0x15, 0xc6, 0x1f, 0xd4, 0x60, 0x10, 0x15, 0x2a, 0x72, 0x2d, 0x89, 0x93, 0x13 },
|
||||
.encoded = { 0x2d884676, 0x4838e14c, 0x7cd65d50, 0x4bf31541, 0x60d41fc6, 0x39681510, 0x892d722a, 0x497c1393 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x32, 0xbc, 0x40, 0x92, 0x13, 0x37, 0x1a, 0xae, 0xb6, 0x00, 0xed, 0x30, 0xb8, 0x82, 0xee, 0xfc, 0xcf, 0x6d, 0x7f, 0xc5, 0xfa, 0x0e, 0xdd, 0x84 },
|
||||
.encoded = { 0x9240bc32, 0x49783713, 0x00b6ae1a, 0x46df30ed, 0xfcee82b8, 0x6e8a6dcf, 0x0efac57f, 0x571784dd },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x29, 0xb3, 0x04, 0x95, 0xf2, 0x3c, 0x81, 0xe6, 0x5a, 0xf3, 0x42, 0x82, 0xd1, 0x79, 0xe2, 0x12, 0xbe, 0xc3, 0xd4, 0x10, 0x63, 0x66, 0x9f, 0xe3 },
|
||||
.encoded = { 0x9504b329, 0x51c53cf2, 0xf35ae681, 0x460e8242, 0x12e279d1, 0x5825c3be, 0x666310d4, 0x5ebde39f },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0xda, 0xda, 0x71, 0x4a, 0x62, 0x33, 0xdd, 0x31, 0x87, 0xf3, 0x70, 0x12, 0x33, 0x3b, 0x3b, 0xe9, 0xed, 0xc4, 0x6e, 0x6a, 0xc7, 0xd5, 0x85, 0xfc },
|
||||
.encoded = { 0x4a71dada, 0x4e6a3362, 0xf38731dd, 0x4bfa1270, 0xe93b3b33, 0x61f3c4ed, 0xd5c76a6e, 0x636ffc85 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x45, 0x64, 0x51, 0x34, 0x1c, 0x82, 0x81, 0x77, 0xf8, 0x89, 0xb1, 0x15, 0x82, 0x94, 0xdd, 0x64, 0xa2, 0x46, 0x0e, 0xfb, 0x1a, 0x70, 0x4b, 0x9f },
|
||||
.encoded = { 0x34516445, 0x39da821c, 0x89f87781, 0x4f2315b1, 0x64dd9482, 0x474b46a2, 0x701afb0e, 0x5e4b9f4b },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x89, 0x87, 0x15, 0xb6, 0x66, 0x34, 0x49, 0x18, 0x8b, 0x7b, 0xb2, 0xf6, 0x96, 0x1e, 0x2e, 0xf1, 0x03, 0x9d, 0x4e, 0x16, 0x32, 0xd6, 0x23, 0x22 },
|
||||
.encoded = { 0xb6158789, 0x4eff3466, 0x7b8b1849, 0x63e5f6b2, 0xf12e1e96, 0x54c99d03, 0xd632164e, 0x42bd2223 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0xa7, 0xa0, 0xb5, 0x21, 0xd2, 0xa3, 0x9f, 0x65, 0xa9, 0xeb, 0x72, 0xa2, 0x2e, 0xa6, 0xfb, 0x9c, 0x48, 0x7e, 0x68, 0x08, 0x7a, 0xb1, 0x4f, 0xbc },
|
||||
.encoded = { 0x21b5a0a7, 0x4ce2a3d2, 0xeba9659f, 0x5868a272, 0x9cfba62e, 0x5fd97e48, 0xb17a0868, 0x5b58bc4f },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0xf7, 0x05, 0xe3, 0x6c, 0xb1, 0x55, 0xcb, 0x2f, 0x8d, 0x3e, 0x0b, 0x2e, 0x3e, 0xb7, 0x02, 0xf5, 0x91, 0xb1, 0xfe, 0x8b, 0x58, 0x50, 0xb2, 0x40 },
|
||||
.encoded = { 0x6ce305f7, 0x569955b1, 0x3e8d2fcb, 0x56722e0b, 0xf502b73e, 0x535eb191, 0x50588bfe, 0x3a8f40b2 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x0f, 0x93, 0xb0, 0xd5, 0x60, 0xba, 0x40, 0x2a, 0x62, 0xa6, 0x92, 0x82, 0xb8, 0x91, 0x2c, 0xd7, 0x23, 0xdc, 0x6f, 0x7f, 0x2f, 0xbe, 0x41, 0xf5 },
|
||||
.encoded = { 0xd5b0930f, 0x5123ba60, 0xa6622a40, 0x3bbe8292, 0xd72c91b8, 0x582ddc23, 0xbe2f7f6f, 0x6935f541 },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x7f, 0x0c, 0x99, 0xde, 0xff, 0x2e, 0xd2, 0x1c, 0x48, 0x98, 0x70, 0x85, 0x15, 0x01, 0x2a, 0xfb, 0xcd, 0xf2, 0xa0, 0xf9, 0x0e, 0xbc, 0x9f, 0x0c },
|
||||
.encoded = { 0xde990c7f, 0x6fe52eff, 0x98481cd2, 0x3deb8570, 0xfb2a0115, 0x61faf2cd, 0xbc0ef9a0, 0x55780c9f },
|
||||
},
|
||||
{
|
||||
.unencoded = { 0x9a, 0x10, 0x92, 0x03, 0x81, 0xfe, 0x41, 0x57, 0x77, 0x02, 0xcb, 0x20, 0x67, 0xa4, 0x97, 0xf3, 0xf8, 0xc7, 0x0d, 0x65, 0xcd, 0xfc, 0x15, 0xef },
|
||||
.encoded = { 0x0392109a, 0x4b64fe81, 0x02775741, 0x418820cb, 0xf397a467, 0x6998c7f8, 0xfccd650d, 0x6ba3ef15 },
|
||||
},
|
||||
};
|
||||
|
||||
TEST_CASE("Test 3/4 Coding Scheme Algorithm", "[bootloader_support]")
|
||||
{
|
||||
const int num_tests = sizeof(coding_scheme_data)/sizeof(coding_scheme_test_t);
|
||||
for (int i = 0; i < num_tests; i++) {
|
||||
uint32_t result[8];
|
||||
const coding_scheme_test_t *t = &coding_scheme_data[i];
|
||||
|
||||
printf("Test case %d...\n", i);
|
||||
esp_err_t r = esp_efuse_apply_34_encoding(t->unencoded, result, sizeof(t->unencoded));
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_OK, r);
|
||||
TEST_ASSERT_EQUAL_HEX32_ARRAY(t->encoded, result, 8);
|
||||
|
||||
// Do the same, 6 bytes at a time
|
||||
for (int offs = 0; offs < sizeof(t->unencoded); offs += 6) {
|
||||
bzero(result, sizeof(result));
|
||||
r = esp_efuse_apply_34_encoding(t->unencoded + offs, result, 6);
|
||||
TEST_ASSERT_EQUAL_HEX(ESP_OK, r);
|
||||
TEST_ASSERT_EQUAL_HEX32_ARRAY(t->encoded + (offs / 6 * 2), result, 2);
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,6 +14,7 @@
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_util.h"
|
||||
#include "esp_partition.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_image_format.h"
|
||||
@@ -92,3 +93,23 @@ TEST_CASE("Test label_search", "[bootloader_support]")
|
||||
check_label_search(25, "phy, 1234567890123456, nvs1", "12345678901234567", true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Test regions_overlap", "[bootloader_support]")
|
||||
{
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 1, 2) );
|
||||
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 0, 2) );
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 1, 3) );
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 0, 3) );
|
||||
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(0, 2, 1, 2) );
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(1, 3, 1, 2) );
|
||||
TEST_ASSERT( bootloader_util_regions_overlap(0, 3, 1, 2) );
|
||||
|
||||
TEST_ASSERT( !bootloader_util_regions_overlap(2, 3, 1, 2) );
|
||||
TEST_ASSERT( !bootloader_util_regions_overlap(1, 2, 2, 3) );
|
||||
|
||||
TEST_ASSERT( !bootloader_util_regions_overlap(3, 4, 1, 2) );
|
||||
TEST_ASSERT( !bootloader_util_regions_overlap(1, 2, 3, 4) );
|
||||
}
|
||||
|
294
components/bt/CMakeLists.txt
Normal file
294
components/bt/CMakeLists.txt
Normal file
@@ -0,0 +1,294 @@
|
||||
if(CONFIG_BT_ENABLED)
|
||||
|
||||
set(COMPONENT_SRCS "bt.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS include)
|
||||
|
||||
if(CONFIG_BLUEDROID_ENABLED)
|
||||
|
||||
list(APPEND COMPONENT_PRIV_INCLUDEDIRS
|
||||
bluedroid/bta/include
|
||||
bluedroid/bta/ar/include
|
||||
bluedroid/bta/av/include
|
||||
bluedroid/bta/dm/include
|
||||
bluedroid/bta/gatt/include
|
||||
bluedroid/bta/hf_client/include
|
||||
bluedroid/bta/hh/include
|
||||
bluedroid/bta/jv/include
|
||||
bluedroid/bta/sdp/include
|
||||
bluedroid/bta/sys/include
|
||||
bluedroid/device/include
|
||||
bluedroid/hci/include
|
||||
bluedroid/osi/include
|
||||
bluedroid/external/sbc/decoder/include
|
||||
bluedroid/external/sbc/encoder/include
|
||||
bluedroid/btc/profile/esp/blufi/include
|
||||
bluedroid/btc/profile/esp/include
|
||||
bluedroid/btc/profile/std/a2dp/include
|
||||
bluedroid/btc/profile/std/include
|
||||
bluedroid/btc/include
|
||||
bluedroid/stack/btm/include
|
||||
bluedroid/stack/gap/include
|
||||
bluedroid/stack/gatt/include
|
||||
bluedroid/stack/l2cap/include
|
||||
bluedroid/stack/sdp/include
|
||||
bluedroid/stack/smp/include
|
||||
bluedroid/stack/avct/include
|
||||
bluedroid/stack/avrc/include
|
||||
bluedroid/stack/avdt/include
|
||||
bluedroid/stack/a2dp/include
|
||||
bluedroid/stack/rfcomm/include
|
||||
bluedroid/stack/include
|
||||
bluedroid/common/include)
|
||||
|
||||
list(APPEND COMPONENT_ADD_INCLUDEDIRS bluedroid/api/include/api)
|
||||
|
||||
list(APPEND COMPONENT_SRCS "bluedroid/api/esp_a2dp_api.c"
|
||||
"bluedroid/api/esp_avrc_api.c"
|
||||
"bluedroid/api/esp_blufi_api.c"
|
||||
"bluedroid/api/esp_bt_device.c"
|
||||
"bluedroid/api/esp_bt_main.c"
|
||||
"bluedroid/api/esp_gap_ble_api.c"
|
||||
"bluedroid/api/esp_gap_bt_api.c"
|
||||
"bluedroid/api/esp_gatt_common_api.c"
|
||||
"bluedroid/api/esp_gattc_api.c"
|
||||
"bluedroid/api/esp_gatts_api.c"
|
||||
"bluedroid/api/esp_hf_client_api.c"
|
||||
"bluedroid/api/esp_spp_api.c"
|
||||
"bluedroid/bta/ar/bta_ar.c"
|
||||
"bluedroid/bta/av/bta_av_aact.c"
|
||||
"bluedroid/bta/av/bta_av_act.c"
|
||||
"bluedroid/bta/av/bta_av_api.c"
|
||||
"bluedroid/bta/av/bta_av_cfg.c"
|
||||
"bluedroid/bta/av/bta_av_ci.c"
|
||||
"bluedroid/bta/av/bta_av_main.c"
|
||||
"bluedroid/bta/av/bta_av_sbc.c"
|
||||
"bluedroid/bta/av/bta_av_ssm.c"
|
||||
"bluedroid/bta/dm/bta_dm_act.c"
|
||||
"bluedroid/bta/dm/bta_dm_api.c"
|
||||
"bluedroid/bta/dm/bta_dm_cfg.c"
|
||||
"bluedroid/bta/dm/bta_dm_ci.c"
|
||||
"bluedroid/bta/dm/bta_dm_co.c"
|
||||
"bluedroid/bta/dm/bta_dm_main.c"
|
||||
"bluedroid/bta/dm/bta_dm_pm.c"
|
||||
"bluedroid/bta/dm/bta_dm_sco.c"
|
||||
"bluedroid/bta/gatt/bta_gatt_common.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_act.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_api.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_cache.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_ci.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_co.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_main.c"
|
||||
"bluedroid/bta/gatt/bta_gattc_utils.c"
|
||||
"bluedroid/bta/gatt/bta_gatts_act.c"
|
||||
"bluedroid/bta/gatt/bta_gatts_api.c"
|
||||
"bluedroid/bta/gatt/bta_gatts_co.c"
|
||||
"bluedroid/bta/gatt/bta_gatts_main.c"
|
||||
"bluedroid/bta/gatt/bta_gatts_utils.c"
|
||||
"bluedroid/bta/hh/bta_hh_act.c"
|
||||
"bluedroid/bta/hh/bta_hh_api.c"
|
||||
"bluedroid/bta/hh/bta_hh_cfg.c"
|
||||
"bluedroid/bta/hh/bta_hh_le.c"
|
||||
"bluedroid/bta/hh/bta_hh_main.c"
|
||||
"bluedroid/bta/hh/bta_hh_utils.c"
|
||||
"bluedroid/bta/jv/bta_jv_act.c"
|
||||
"bluedroid/bta/jv/bta_jv_api.c"
|
||||
"bluedroid/bta/jv/bta_jv_cfg.c"
|
||||
"bluedroid/bta/jv/bta_jv_main.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_act.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_api.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_at.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_cmd.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_main.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_rfc.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_sco.c"
|
||||
"bluedroid/bta/hf_client/bta_hf_client_sdp.c"
|
||||
"bluedroid/bta/sdp/bta_sdp.c"
|
||||
"bluedroid/bta/sdp/bta_sdp_act.c"
|
||||
"bluedroid/bta/sdp/bta_sdp_api.c"
|
||||
"bluedroid/bta/sdp/bta_sdp_cfg.c"
|
||||
"bluedroid/bta/sys/bta_sys_conn.c"
|
||||
"bluedroid/bta/sys/bta_sys_main.c"
|
||||
"bluedroid/bta/sys/utl.c"
|
||||
"bluedroid/btc/core/btc_alarm.c"
|
||||
"bluedroid/btc/core/btc_ble_storage.c"
|
||||
"bluedroid/btc/core/btc_config.c"
|
||||
"bluedroid/btc/core/btc_dev.c"
|
||||
"bluedroid/btc/core/btc_dm.c"
|
||||
"bluedroid/btc/core/btc_main.c"
|
||||
"bluedroid/btc/core/btc_manage.c"
|
||||
"bluedroid/btc/core/btc_profile_queue.c"
|
||||
"bluedroid/btc/core/btc_sec.c"
|
||||
"bluedroid/btc/core/btc_sm.c"
|
||||
"bluedroid/btc/core/btc_storage.c"
|
||||
"bluedroid/btc/core/btc_task.c"
|
||||
"bluedroid/btc/core/btc_util.c"
|
||||
"bluedroid/btc/profile/esp/blufi/blufi_prf.c"
|
||||
"bluedroid/btc/profile/esp/blufi/blufi_protocol.c"
|
||||
"bluedroid/btc/profile/std/a2dp/bta_av_co.c"
|
||||
"bluedroid/btc/profile/std/a2dp/btc_a2dp.c"
|
||||
"bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c"
|
||||
"bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c"
|
||||
"bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c"
|
||||
"bluedroid/btc/profile/std/a2dp/btc_av.c"
|
||||
"bluedroid/btc/profile/std/avrc/btc_avrc.c"
|
||||
"bluedroid/btc/profile/std/hf_client/btc_hf_client.c"
|
||||
"bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c"
|
||||
"bluedroid/btc/profile/std/gap/btc_gap_ble.c"
|
||||
"bluedroid/btc/profile/std/gap/btc_gap_bt.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gatt_common.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gatt_util.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gattc.c"
|
||||
"bluedroid/btc/profile/std/gatt/btc_gatts.c"
|
||||
"bluedroid/btc/profile/std/spp/btc_spp.c"
|
||||
"bluedroid/device/bdaddr.c"
|
||||
"bluedroid/device/controller.c"
|
||||
"bluedroid/device/interop.c"
|
||||
"bluedroid/external/sbc/decoder/srce/alloc.c"
|
||||
"bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c"
|
||||
"bluedroid/external/sbc/decoder/srce/bitalloc.c"
|
||||
"bluedroid/external/sbc/decoder/srce/bitstream-decode.c"
|
||||
"bluedroid/external/sbc/decoder/srce/decoder-oina.c"
|
||||
"bluedroid/external/sbc/decoder/srce/decoder-private.c"
|
||||
"bluedroid/external/sbc/decoder/srce/decoder-sbc.c"
|
||||
"bluedroid/external/sbc/decoder/srce/dequant.c"
|
||||
"bluedroid/external/sbc/decoder/srce/framing-sbc.c"
|
||||
"bluedroid/external/sbc/decoder/srce/framing.c"
|
||||
"bluedroid/external/sbc/decoder/srce/oi_codec_version.c"
|
||||
"bluedroid/external/sbc/decoder/srce/synthesis-8-generated.c"
|
||||
"bluedroid/external/sbc/decoder/srce/synthesis-dct8.c"
|
||||
"bluedroid/external/sbc/decoder/srce/synthesis-sbc.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_analysis.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_dct.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_dct_coeffs.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_enc_coeffs.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_encoder.c"
|
||||
"bluedroid/external/sbc/encoder/srce/sbc_packing.c"
|
||||
"bluedroid/hci/buffer_allocator.c"
|
||||
"bluedroid/hci/hci_audio.c"
|
||||
"bluedroid/hci/hci_hal_h4.c"
|
||||
"bluedroid/hci/hci_layer.c"
|
||||
"bluedroid/hci/hci_packet_factory.c"
|
||||
"bluedroid/hci/hci_packet_parser.c"
|
||||
"bluedroid/hci/packet_fragmenter.c"
|
||||
"bluedroid/main/bte_init.c"
|
||||
"bluedroid/main/bte_main.c"
|
||||
"bluedroid/osi/alarm.c"
|
||||
"bluedroid/osi/allocator.c"
|
||||
"bluedroid/osi/buffer.c"
|
||||
"bluedroid/osi/config.c"
|
||||
"bluedroid/osi/fixed_queue.c"
|
||||
"bluedroid/osi/future.c"
|
||||
"bluedroid/osi/hash_functions.c"
|
||||
"bluedroid/osi/hash_map.c"
|
||||
"bluedroid/osi/list.c"
|
||||
"bluedroid/osi/mutex.c"
|
||||
"bluedroid/osi/osi.c"
|
||||
"bluedroid/osi/semaphore.c"
|
||||
"bluedroid/stack/a2dp/a2d_api.c"
|
||||
"bluedroid/stack/a2dp/a2d_sbc.c"
|
||||
"bluedroid/stack/avct/avct_api.c"
|
||||
"bluedroid/stack/avct/avct_ccb.c"
|
||||
"bluedroid/stack/avct/avct_l2c.c"
|
||||
"bluedroid/stack/avct/avct_lcb.c"
|
||||
"bluedroid/stack/avct/avct_lcb_act.c"
|
||||
"bluedroid/stack/avdt/avdt_ad.c"
|
||||
"bluedroid/stack/avdt/avdt_api.c"
|
||||
"bluedroid/stack/avdt/avdt_ccb.c"
|
||||
"bluedroid/stack/avdt/avdt_ccb_act.c"
|
||||
"bluedroid/stack/avdt/avdt_l2c.c"
|
||||
"bluedroid/stack/avdt/avdt_msg.c"
|
||||
"bluedroid/stack/avdt/avdt_scb.c"
|
||||
"bluedroid/stack/avdt/avdt_scb_act.c"
|
||||
"bluedroid/stack/avrc/avrc_api.c"
|
||||
"bluedroid/stack/avrc/avrc_bld_ct.c"
|
||||
"bluedroid/stack/avrc/avrc_bld_tg.c"
|
||||
"bluedroid/stack/avrc/avrc_opt.c"
|
||||
"bluedroid/stack/avrc/avrc_pars_ct.c"
|
||||
"bluedroid/stack/avrc/avrc_pars_tg.c"
|
||||
"bluedroid/stack/avrc/avrc_sdp.c"
|
||||
"bluedroid/stack/avrc/avrc_utils.c"
|
||||
"bluedroid/stack/btm/btm_acl.c"
|
||||
"bluedroid/stack/btm/btm_ble.c"
|
||||
"bluedroid/stack/btm/btm_ble_addr.c"
|
||||
"bluedroid/stack/btm/btm_ble_adv_filter.c"
|
||||
"bluedroid/stack/btm/btm_ble_batchscan.c"
|
||||
"bluedroid/stack/btm/btm_ble_bgconn.c"
|
||||
"bluedroid/stack/btm/btm_ble_cont_energy.c"
|
||||
"bluedroid/stack/btm/btm_ble_gap.c"
|
||||
"bluedroid/stack/btm/btm_ble_multi_adv.c"
|
||||
"bluedroid/stack/btm/btm_ble_privacy.c"
|
||||
"bluedroid/stack/btm/btm_dev.c"
|
||||
"bluedroid/stack/btm/btm_devctl.c"
|
||||
"bluedroid/stack/btm/btm_inq.c"
|
||||
"bluedroid/stack/btm/btm_main.c"
|
||||
"bluedroid/stack/btm/btm_pm.c"
|
||||
"bluedroid/stack/btm/btm_sco.c"
|
||||
"bluedroid/stack/btm/btm_sec.c"
|
||||
"bluedroid/stack/btu/btu_hcif.c"
|
||||
"bluedroid/stack/btu/btu_init.c"
|
||||
"bluedroid/stack/btu/btu_task.c"
|
||||
"bluedroid/stack/gap/gap_api.c"
|
||||
"bluedroid/stack/gap/gap_ble.c"
|
||||
"bluedroid/stack/gap/gap_conn.c"
|
||||
"bluedroid/stack/gap/gap_utils.c"
|
||||
"bluedroid/stack/gatt/att_protocol.c"
|
||||
"bluedroid/stack/gatt/gatt_api.c"
|
||||
"bluedroid/stack/gatt/gatt_attr.c"
|
||||
"bluedroid/stack/gatt/gatt_auth.c"
|
||||
"bluedroid/stack/gatt/gatt_cl.c"
|
||||
"bluedroid/stack/gatt/gatt_db.c"
|
||||
"bluedroid/stack/gatt/gatt_main.c"
|
||||
"bluedroid/stack/gatt/gatt_sr.c"
|
||||
"bluedroid/stack/gatt/gatt_utils.c"
|
||||
"bluedroid/stack/hcic/hciblecmds.c"
|
||||
"bluedroid/stack/hcic/hcicmds.c"
|
||||
"bluedroid/stack/l2cap/l2c_api.c"
|
||||
"bluedroid/stack/l2cap/l2c_ble.c"
|
||||
"bluedroid/stack/l2cap/l2c_csm.c"
|
||||
"bluedroid/stack/l2cap/l2c_fcr.c"
|
||||
"bluedroid/stack/l2cap/l2c_link.c"
|
||||
"bluedroid/stack/l2cap/l2c_main.c"
|
||||
"bluedroid/stack/l2cap/l2c_ucd.c"
|
||||
"bluedroid/stack/l2cap/l2c_utils.c"
|
||||
"bluedroid/stack/l2cap/l2cap_client.c"
|
||||
"bluedroid/stack/rfcomm/port_api.c"
|
||||
"bluedroid/stack/rfcomm/port_rfc.c"
|
||||
"bluedroid/stack/rfcomm/port_utils.c"
|
||||
"bluedroid/stack/rfcomm/rfc_l2cap_if.c"
|
||||
"bluedroid/stack/rfcomm/rfc_mx_fsm.c"
|
||||
"bluedroid/stack/rfcomm/rfc_port_fsm.c"
|
||||
"bluedroid/stack/rfcomm/rfc_port_if.c"
|
||||
"bluedroid/stack/rfcomm/rfc_ts_frames.c"
|
||||
"bluedroid/stack/rfcomm/rfc_utils.c"
|
||||
"bluedroid/stack/sdp/sdp_api.c"
|
||||
"bluedroid/stack/sdp/sdp_db.c"
|
||||
"bluedroid/stack/sdp/sdp_discovery.c"
|
||||
"bluedroid/stack/sdp/sdp_main.c"
|
||||
"bluedroid/stack/sdp/sdp_server.c"
|
||||
"bluedroid/stack/sdp/sdp_utils.c"
|
||||
"bluedroid/stack/smp/aes.c"
|
||||
"bluedroid/stack/smp/p_256_curvepara.c"
|
||||
"bluedroid/stack/smp/p_256_ecc_pp.c"
|
||||
"bluedroid/stack/smp/p_256_multprecision.c"
|
||||
"bluedroid/stack/smp/smp_act.c"
|
||||
"bluedroid/stack/smp/smp_api.c"
|
||||
"bluedroid/stack/smp/smp_br_main.c"
|
||||
"bluedroid/stack/smp/smp_cmac.c"
|
||||
"bluedroid/stack/smp/smp_keys.c"
|
||||
"bluedroid/stack/smp/smp_l2c.c"
|
||||
"bluedroid/stack/smp/smp_main.c"
|
||||
"bluedroid/stack/smp/smp_utils.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# requirements can't depend on config
|
||||
set(COMPONENT_PRIV_REQUIRES nvs_flash)
|
||||
|
||||
register_component()
|
||||
|
||||
if(CONFIG_BT_ENABLED)
|
||||
target_link_libraries(bt "-L${CMAKE_CURRENT_LIST_DIR}/lib")
|
||||
target_link_libraries(bt btdm_app)
|
||||
endif()
|
@@ -6,6 +6,29 @@ config BT_ENABLED
|
||||
help
|
||||
Select this option to enable Bluetooth and show the submenu with Bluetooth configuration choices.
|
||||
|
||||
choice BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH
|
||||
prompt "BR/EDR Sync(SCO/eSCO) default data path"
|
||||
depends on BT_ENABLED
|
||||
default BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_PCM
|
||||
help
|
||||
SCO data path, i.e. HCI or PCM.
|
||||
SCO data can be sent/received through HCI synchronous packets, or the data
|
||||
can be routed to on-chip PCM module on ESP32. PCM input/output signals can
|
||||
be "matrixed" to GPIOs. The default data path can also be set using API
|
||||
"esp_bredr_sco_datapath_set"
|
||||
|
||||
config BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_HCI
|
||||
bool "HCI"
|
||||
config BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_PCM
|
||||
bool "PCM"
|
||||
endchoice
|
||||
|
||||
config BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_EFF
|
||||
int
|
||||
default 0 if BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_HCI
|
||||
default 1 if BTDM_CONTROLLER_BR_EDR_SCO_DATA_PATH_PCM
|
||||
default 0
|
||||
|
||||
choice BTDM_CONTROLLER_PINNED_TO_CORE_CHOICE
|
||||
prompt "The cpu core which bluetooth controller run"
|
||||
depends on BT_ENABLED && !FREERTOS_UNICORE
|
||||
@@ -70,10 +93,9 @@ menu "MODEM SLEEP Options"
|
||||
config BTDM_CONTROLLER_MODEM_SLEEP
|
||||
bool "Bluetooth modem sleep"
|
||||
depends on BT_ENABLED
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Enable/disable bluetooth controller low power mode.
|
||||
Note that currently there is problem in the combination use of bluetooth modem sleep and Dynamic Frequency Scaling(DFS). So do not enable DFS if bluetooth modem sleep is in use.
|
||||
|
||||
choice BTDM_MODEM_SLEEP_MODE
|
||||
prompt "Bluetooth Modem sleep mode"
|
||||
@@ -84,11 +106,14 @@ choice BTDM_MODEM_SLEEP_MODE
|
||||
config BTDM_MODEM_SLEEP_MODE_ORIG
|
||||
bool "ORIG Mode(sleep with low power clock)"
|
||||
help
|
||||
ORIG mode is a deep sleep mode that can be used for dual mode controller. In this mode, bluetooth controller sleeps between BR/EDR frames and BLE events. A low power clock is used to maintain bluetooth reference clock.
|
||||
ORIG mode is a bluetooth sleep mode that can be used for dual mode controller. In this mode,
|
||||
bluetooth controller sleeps between BR/EDR frames and BLE events. A low power clock is used to
|
||||
maintain bluetooth reference clock.
|
||||
config BTDM_MODEM_SLEEP_MODE_EVED
|
||||
bool "EVED Mode "
|
||||
bool "EVED Mode(For internal test only)"
|
||||
help
|
||||
This mode is for BLE only.
|
||||
EVED mode is for BLE only and is only for internal test. Do not use it for production. this
|
||||
mode is not compatible with DFS nor light sleep
|
||||
endchoice
|
||||
|
||||
choice BTDM_LOW_POWER_CLOCK
|
||||
@@ -99,11 +124,14 @@ choice BTDM_LOW_POWER_CLOCK
|
||||
|
||||
config BTDM_LPCLK_SEL_MAIN_XTAL
|
||||
bool "Main crystal"
|
||||
help
|
||||
Main crystal can be used as low power clock for bluetooth modem sleep. If this option is selected, bluetooth
|
||||
modem sleep can work under Dynamic Frequency Scaling(DFS) enabled, but cannot work when light sleep is enabled.
|
||||
Main crystal has a relatively better performance than other bluetooth low power clock sources.
|
||||
config BTDM_LPCLK_SEL_EXT_32K_XTAL
|
||||
bool "External 32kHz crystal"
|
||||
depends on ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
@@ -195,15 +223,15 @@ endchoice
|
||||
choice HFP_AUDIO_DATA_PATH
|
||||
prompt "audio(SCO) data path"
|
||||
depends on HFP_ENABLE
|
||||
help
|
||||
SCO data path, i.e. HCI or PCM. This option is set using API
|
||||
"esp_bredr_sco_datapath_set" in Bluetooth host. Default SCO data
|
||||
path can also be set in Bluetooth Controller.
|
||||
|
||||
config HFP_AUDIO_DATA_PATH_PCM
|
||||
bool "PCM"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
config HFP_AUDIO_DATA_PATH_HCI
|
||||
bool "HCI"
|
||||
help
|
||||
This enables the Serial Port Profile
|
||||
endchoice
|
||||
|
||||
config GATTS_ENABLE
|
||||
@@ -234,6 +262,13 @@ config BLE_SMP_ENABLE
|
||||
help
|
||||
This option can be close when the app not used the ble security connect.
|
||||
|
||||
config SMP_SLAVE_CON_PARAMS_UPD_ENABLE
|
||||
bool "Slave enable connection parameters update during pairing"
|
||||
depends on BLE_SMP_ENABLE
|
||||
default n
|
||||
help
|
||||
In order to reduce the pairing time, slave actively initiates connection parameters update during pairing.
|
||||
|
||||
config BT_STACK_NO_LOG
|
||||
bool "Disable BT debug logs (minimize bin size)"
|
||||
depends on BLUEDROID_ENABLED
|
||||
@@ -1009,12 +1044,12 @@ config BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around or application layer
|
||||
handling adv packets is slow, it will cause the controller memory to run out. if enabled, adv packets will be
|
||||
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around or application layer
|
||||
handling adv packets is slow, it will cause the controller memory to run out. if enabled, adv packets will be
|
||||
lost when host queue is congested.
|
||||
|
||||
config BLE_SCAN_DUPLICATE
|
||||
bool "BLE Scan Duplicate Options "
|
||||
bool "BLE Scan Duplicate Options"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
@@ -1045,12 +1080,65 @@ config MESH_DUPLICATE_SCAN_CACHE_SIZE
|
||||
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
|
||||
When the maximum amount of device in the filter is reached, the cache will be refreshed.
|
||||
|
||||
config BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
bool "BLE adv report flow control supported"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default y
|
||||
help
|
||||
The function is mainly used to enable flow control for advertising reports. When it is enabled,
|
||||
advertising reports will be discarded by the controller if the number of unprocessed advertising
|
||||
reports exceeds the size of BLE adv report flow control.
|
||||
|
||||
config BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
int "BLE adv report flow control number"
|
||||
depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
range 50 1000
|
||||
default 100
|
||||
help
|
||||
The number of unprocessed advertising report that Bluedroid can save.If you set
|
||||
`BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a small value, this may cause adv packets lost.
|
||||
If you set `BLE_ADV_REPORT_FLOW_CONTROL_NUM` to a large value, Bluedroid may cache a
|
||||
lot of adv packets and this may cause system memory run out. For example, if you set
|
||||
it to 50, the maximum memory consumed by host is 35 * 50 bytes. Please set
|
||||
`BLE_ADV_REPORT_FLOW_CONTROL_NUM` according to your system free memory and handle adv
|
||||
packets as fast as possible, otherwise it will cause adv packets lost.
|
||||
|
||||
config BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
int "BLE adv lost event threshold value"
|
||||
depends on BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
range 1 1000
|
||||
default 20
|
||||
help
|
||||
When adv report flow control is enabled, The ADV lost event will be generated when the number
|
||||
of ADV packets lost in the controller reaches this threshold. It is better to set a larger value.
|
||||
If you set `BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
config SMP_ENABLE
|
||||
bool
|
||||
depends on BLUEDROID_ENABLED
|
||||
default CLASSIC_BT_ENABLED || BLE_SMP_ENABLE
|
||||
|
||||
config BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY
|
||||
bool "Report adv data and scan response individually when BLE active scan"
|
||||
depends on BLUEDROID_ENABLED
|
||||
default n
|
||||
help
|
||||
Originally, when doing BLE active scan, Bluedroid will not report adv to application layer
|
||||
until receive scan response. This option is used to disable the behavior. When enable this option,
|
||||
Bluedroid will report adv data or scan response to application layer immediately.
|
||||
|
||||
# Memory reserved at start of DRAM for Bluetooth stack
|
||||
|
||||
config BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT
|
||||
int "Timeout of BLE connection establishment"
|
||||
depends on BLUEDROID_ENABLED
|
||||
range 1 60
|
||||
default 30
|
||||
help
|
||||
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
|
||||
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
|
||||
|
||||
config BT_RESERVE_DRAM
|
||||
hex
|
||||
default 0x10000 if BT_ENABLED
|
||||
|
@@ -441,6 +441,23 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
|
||||
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
|
||||
void *value, uint8_t len)
|
||||
{
|
||||
if(param_type >= ESP_BLE_SM_MAX_PARAM) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if((param_type != ESP_BLE_SM_CLEAR_STATIC_PASSKEY) && ( value == NULL || len < sizeof(uint8_t) || len > sizeof(uint32_t))) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if((param_type == ESP_BLE_SM_SET_STATIC_PASSKEY)) {
|
||||
uint32_t passkey = 0;
|
||||
for(uint8_t i = 0; i < len; i++)
|
||||
{
|
||||
passkey += (((uint8_t *)value)[i]<<(8*i));
|
||||
}
|
||||
if(passkey > 999999) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
|
@@ -240,4 +240,50 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_set_pin(esp_bt_pin_type_t pin_type, uint8_t pin_code_len, esp_bt_pin_code_t pin_code)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_SET_PIN_TYPE;
|
||||
arg.set_pin_type.pin_type = pin_type;
|
||||
if (pin_type == ESP_BT_PIN_TYPE_FIXED){
|
||||
arg.set_pin_type.pin_code_len = pin_code_len;
|
||||
memcpy(arg.set_pin_type.pin_code, pin_code, pin_code_len);
|
||||
} else {
|
||||
arg.set_pin_type.pin_code_len = 0;
|
||||
memset(arg.set_pin_type.pin_code, 0, ESP_BT_PIN_CODE_LEN);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_code_len, esp_bt_pin_code_t pin_code)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_gap_bt_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_ACT_PIN_REPLY;
|
||||
arg.pin_reply.accept = accept;
|
||||
arg.pin_reply.pin_code_len = pin_code_len;
|
||||
memcpy(arg.pin_reply.bda.address, bd_addr, sizeof(esp_bd_addr_t));
|
||||
memcpy(arg.pin_reply.pin_code, pin_code, pin_code_len);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */
|
||||
|
@@ -321,6 +321,7 @@ esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *l
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (attr_handle == ESP_GATT_ILLEGAL_HANDLE) {
|
||||
*length = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
@@ -54,12 +54,16 @@ typedef uint8_t esp_ble_key_type_t;
|
||||
#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/ /* relate to BTM_LE_AUTH_NO_BOND in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */ /* relate to BTM_LE_AUTH_BOND in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */ /* relate to BTM_LE_AUTH_REQ_MITM in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_BOND_MITM (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_MITM)/*!< 0101*/
|
||||
#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */ /* relate to BTM_LE_AUTH_REQ_SC_ONLY in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */ /* relate to BTM_LE_AUTH_REQ_SC_BOND in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM in stack/btm_api.h */
|
||||
#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM_BOND in stack/btm_api.h */
|
||||
typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */
|
||||
|
||||
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_DISABLE 0
|
||||
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE 1
|
||||
|
||||
/* relate to BTM_IO_CAP_xxx in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ /* relate to BTM_IO_CAP_OUT in stack/btm_api.h */
|
||||
#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ /* relate to BTM_IO_CAP_IO in stack/btm_api.h */
|
||||
@@ -264,6 +268,10 @@ typedef enum {
|
||||
ESP_BLE_SM_SET_INIT_KEY,
|
||||
ESP_BLE_SM_SET_RSP_KEY,
|
||||
ESP_BLE_SM_MAX_KEY_SIZE,
|
||||
ESP_BLE_SM_SET_STATIC_PASSKEY,
|
||||
ESP_BLE_SM_CLEAR_STATIC_PASSKEY,
|
||||
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
|
||||
ESP_BLE_SM_MAX_PARAM,
|
||||
} esp_ble_sm_param_t;
|
||||
|
||||
/// Advertising parameters
|
||||
@@ -279,7 +287,7 @@ typedef struct {
|
||||
esp_ble_adv_type_t adv_type; /*!< Advertising type */
|
||||
esp_ble_addr_type_t own_addr_type; /*!< Owner bluetooth device address type */
|
||||
esp_bd_addr_t peer_addr; /*!< Peer device bluetooth device address */
|
||||
esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type */
|
||||
esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type, only support public address type and random address type */
|
||||
esp_ble_adv_channel_t channel_map; /*!< Advertising channel map */
|
||||
esp_ble_adv_filter_t adv_filter_policy; /*!< Advertising filter policy */
|
||||
} esp_ble_adv_params_t;
|
||||
@@ -346,8 +354,8 @@ typedef struct {
|
||||
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
|
||||
Time = N * 0.625 msec
|
||||
Time Range: 2.5 msec to 10240 msec */
|
||||
esp_ble_scan_duplicate_t scan_duplicate; /*!< The Scan_Duplicates parameter controls whether the Link Layer should filter out
|
||||
duplicate advertising reports (BLE_SCAN_DUPLICATE_ENABLE) to the Host, or if the Link Layer should generate
|
||||
esp_ble_scan_duplicate_t scan_duplicate; /*!< The Scan_Duplicates parameter controls whether the Link Layer should filter out
|
||||
duplicate advertising reports (BLE_SCAN_DUPLICATE_ENABLE) to the Host, or if the Link Layer should generate
|
||||
advertising reports for each packet received */
|
||||
} esp_ble_scan_params_t;
|
||||
|
||||
@@ -508,7 +516,8 @@ typedef struct
|
||||
uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */
|
||||
esp_ble_addr_type_t addr_type; /*!< Peer device address type */
|
||||
esp_bt_dev_type_t dev_type; /*!< Device type */
|
||||
} esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */
|
||||
esp_ble_auth_req_t auth_mode; /*!< authentication mode */
|
||||
} esp_ble_auth_cmpl_t; /*!< The ble authentication complete cb type */
|
||||
|
||||
/**
|
||||
* @brief union associated with ble security
|
||||
@@ -531,6 +540,7 @@ typedef enum {
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /*!< Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /*!< Search cancelled */
|
||||
ESP_GAP_SEARCH_INQ_DISCARD_NUM_EVT = 7, /*!< The number of pkt discarded by flow control */
|
||||
} esp_gap_search_evt_t;
|
||||
|
||||
/**
|
||||
@@ -586,6 +596,7 @@ typedef union {
|
||||
int num_resps; /*!< Scan result number */
|
||||
uint8_t adv_data_len; /*!< Adv data length */
|
||||
uint8_t scan_rsp_len; /*!< Scan response length */
|
||||
uint32_t num_dis; /*!< The number of discard packets */
|
||||
} scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
|
||||
@@ -933,8 +944,7 @@ esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t
|
||||
* @param[in] type - finding ADV data type
|
||||
* @param[out] length - return the length of ADV data not including type
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
* @return pointer of ADV data
|
||||
*
|
||||
*/
|
||||
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);
|
||||
|
@@ -102,6 +102,14 @@ typedef enum {
|
||||
ESP_BT_COD_SRVC_INFORMATION = 0x400, /*!< Information, e.g., WEB-server, WAP-server */
|
||||
} esp_bt_cod_srvc_t;
|
||||
|
||||
typedef enum{
|
||||
ESP_BT_PIN_TYPE_VARIABLE = 0, /*!< Refer to BTM_PIN_TYPE_VARIABLE */
|
||||
ESP_BT_PIN_TYPE_FIXED = 1, /*!< Refer to BTM_PIN_TYPE_FIXED */
|
||||
} esp_bt_pin_type_t;
|
||||
|
||||
#define ESP_BT_PIN_CODE_LEN 16 /*!< Max pin code length */
|
||||
typedef uint8_t esp_bt_pin_code_t[ESP_BT_PIN_CODE_LEN]; /*!< Pin Code (upto 128 bits) MSB is 0 */
|
||||
|
||||
/// Bits of major service class field
|
||||
#define ESP_BT_COD_SRVC_BIT_MASK (0xffe000) /*!< Major service bit mask */
|
||||
#define ESP_BT_COD_SRVC_BIT_OFFSET (13) /*!< Major service bit offset */
|
||||
@@ -149,6 +157,7 @@ typedef enum {
|
||||
ESP_BT_GAP_RMT_SRVCS_EVT, /*!< get remote services event */
|
||||
ESP_BT_GAP_RMT_SRVC_REC_EVT, /*!< get remote service record event */
|
||||
ESP_BT_GAP_AUTH_CMPL_EVT, /*!< AUTH complete event */
|
||||
ESP_BT_GAP_PIN_REQ_EVT, /*!< Legacy Pairing Pin code request */
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
@@ -216,6 +225,15 @@ typedef union {
|
||||
esp_bt_status_t stat; /*!< authentication complete status */
|
||||
uint8_t device_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< device name */
|
||||
} auth_cmpl; /*!< authentication complete parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_PIN_REQ_EVT
|
||||
*/
|
||||
struct pin_req_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
bool min_16_digit; /*!< TRUE if the pin returned must be at least 16 digits */
|
||||
} pin_req; /*!< pin request parameter struct */
|
||||
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -447,6 +465,38 @@ int esp_bt_gap_get_bond_device_num(void);
|
||||
*/
|
||||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list);
|
||||
|
||||
/**
|
||||
* @brief Set pin type and default pin code for legacy pairing.
|
||||
*
|
||||
* @param[in] pin_type: Use variable or fixed pin.
|
||||
* If pin_type is ESP_BT_PIN_TYPE_VARIABLE, pin_code and pin_code_len
|
||||
* will be ignored, and ESP_BT_GAP_PIN_REQ_EVT will come when control
|
||||
* requests for pin code.
|
||||
* Else, will use fixed pin code and not callback to users.
|
||||
* @param[in] pin_code_len: Length of pin_code
|
||||
* @param[in] pin_code: Pin_code
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_set_pin(esp_bt_pin_type_t pin_type, uint8_t pin_code_len, esp_bt_pin_code_t pin_code);
|
||||
|
||||
/**
|
||||
* @brief Reply the pin_code to the peer device for legacy pairing
|
||||
* when ESP_BT_GAP_PIN_REQ_EVT is coming.
|
||||
*
|
||||
* @param[in] bd_addr: BD address of the peer
|
||||
* @param[in] accept: Pin_code reply successful or declined.
|
||||
* @param[in] pin_code_len: Length of pin_code
|
||||
* @param[in] pin_code: Pin_code
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
|
||||
* - other : failed
|
||||
*/
|
||||
esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_code_len, esp_bt_pin_code_t pin_code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -251,9 +251,9 @@ typedef union {
|
||||
} esp_hf_client_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief HFP client incoming data callback function, the callback is useful in case of
|
||||
* @brief HFP client incoming data callback function, the callback is useful in case of
|
||||
* Voice Over HCI.
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
@@ -261,13 +261,13 @@ typedef union {
|
||||
typedef void (* esp_hf_client_incoming_data_cb_t)(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief HFP client outgoing data callback function, the callback is useful in case of
|
||||
* Voice Over HCI. Once audio connection is set up and the application layer has
|
||||
* prepared data to send, the lower layer will call this function to read data
|
||||
* @brief HFP client outgoing data callback function, the callback is useful in case of
|
||||
* Voice Over HCI. Once audio connection is set up and the application layer has
|
||||
* prepared data to send, the lower layer will call this function to read data
|
||||
* and then send. This callback is supposed to be implemented as non-blocking,
|
||||
* and if data is not enough, return value 0 is supposed.
|
||||
*
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
*
|
||||
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
@@ -326,7 +326,7 @@ esp_err_t esp_hf_client_deinit(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Connect to remote bluetooth HFP audio gateway(AG) device, must after esp_a2d_hf_client_init()
|
||||
* @brief Connect to remote bluetooth HFP audio gateway(AG) device, must after esp_hf_client_init()
|
||||
*
|
||||
* @param[in] remote_bda: remote bluetooth device address
|
||||
*
|
||||
@@ -606,7 +606,7 @@ void esp_hf_client_outgoing_data_ready(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize the down sampling converter. This is a utility function that can
|
||||
* only be used in the case that Voice Over HCI is enabled.
|
||||
* only be used in the case that Voice Over HCI is enabled.
|
||||
*
|
||||
* @param[in] src_sps: original samples per second(source audio data, i.e. 48000, 32000,
|
||||
* 16000, 44100, 22050, 11025)
|
||||
|
@@ -190,8 +190,7 @@ esp_err_t esp_spp_register_callback(esp_spp_cb_t callback);
|
||||
/**
|
||||
* @brief This function is called to init SPP.
|
||||
*
|
||||
* @param[in] mode: Choose the mode of SPP, ESP_SPP_MODE_CB or ESP_SPP_MODE_CB.
|
||||
* Now only supports ESP_SPP_MODE_CB mode, we will continue to update.
|
||||
* @param[in] mode: Choose the mode of SPP, ESP_SPP_MODE_CB or ESP_SPP_MODE_VFS.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
|
@@ -143,6 +143,7 @@ const tBTA_AV_SACT bta_av_a2d_action[] = {
|
||||
bta_av_role_res, /* BTA_AV_ROLE_RES */
|
||||
bta_av_delay_co, /* BTA_AV_DELAY_CO */
|
||||
bta_av_open_at_inc, /* BTA_AV_OPEN_AT_INC */
|
||||
bta_av_open_fail_sdp, /* BTA_AV_OPEN_FAIL_SDP */
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1060,6 +1061,35 @@ void bta_av_free_sdb(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
utl_freebuf((void **) &p_scb->p_disc_db);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_open_fail_sdp
|
||||
**
|
||||
** Description report BTA_AV_OPEN_EVT with service discovery failed status
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_av_open_fail_sdp(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
{
|
||||
tBTA_AV_OPEN open;
|
||||
|
||||
bdcpy(open.bd_addr, p_scb->peer_addr);
|
||||
open.chnl = p_scb->chnl;
|
||||
open.hndl = p_scb->hndl;
|
||||
open.status = BTA_AV_FAIL_SDP;
|
||||
|
||||
if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC ) {
|
||||
open.sep = AVDT_TSEP_SNK;
|
||||
} else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK ) {
|
||||
open.sep = AVDT_TSEP_SRC;
|
||||
}
|
||||
|
||||
(*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);
|
||||
|
||||
UNUSED(p_data);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_av_config_ind
|
||||
@@ -1263,9 +1293,10 @@ void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
/* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind.
|
||||
* call disc_res now */
|
||||
/* this is called in A2DP SRC path only, In case of SINK we don't need it */
|
||||
if (local_sep == AVDT_TSEP_SRC)
|
||||
if (local_sep == AVDT_TSEP_SRC) {
|
||||
p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr,
|
||||
UUID_SERVCLASS_AUDIO_SOURCE);
|
||||
}
|
||||
} else {
|
||||
/* we do not know the peer device and it is using non-SBC codec
|
||||
* we need to know all the SEPs on SNK */
|
||||
@@ -1544,6 +1575,17 @@ void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
/* store number of stream endpoints returned */
|
||||
p_scb->num_seps = p_data->str_msg.msg.discover_cfm.num_seps;
|
||||
|
||||
UINT8 num_seps = (p_scb->num_seps < BTA_AV_NUM_SEPS) ? p_scb->num_seps : BTA_AV_NUM_SEPS;
|
||||
memcpy(p_scb->sep_info, p_data->str_msg.msg.discover_cfm.p_sep_info, sizeof(tAVDT_SEP_INFO) * num_seps);
|
||||
for (i = 0; i < p_data->str_msg.msg.discover_cfm.num_seps; i++) {
|
||||
APPL_TRACE_DEBUG("peer sep %d, in use %d, seid %d, media type %d, tsep %d",
|
||||
i,
|
||||
p_data->str_msg.msg.discover_cfm.p_sep_info[i].in_use,
|
||||
p_data->str_msg.msg.discover_cfm.p_sep_info[i].seid,
|
||||
p_data->str_msg.msg.discover_cfm.p_sep_info[i].media_type,
|
||||
p_data->str_msg.msg.discover_cfm.p_sep_info[i].tsep
|
||||
);
|
||||
}
|
||||
for (i = 0; i < p_scb->num_seps; i++) {
|
||||
/* steam not in use, is a sink, and is audio */
|
||||
if ((p_scb->sep_info[i].in_use == FALSE) &&
|
||||
@@ -1557,7 +1599,7 @@ void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
|
||||
(uuid_int == UUID_SERVCLASS_AUDIO_SINK)) {
|
||||
num_srcs++;
|
||||
}
|
||||
|
||||
APPL_TRACE_DEBUG("num srcs: %d, num_snks: %d\n", num_snks, num_srcs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -829,10 +829,11 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) {
|
||||
p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL;
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
if (p_cb->features & BTA_AV_FEAT_METADATA)
|
||||
if (p_cb->features & BTA_AV_FEAT_METADATA) {
|
||||
p_data->rc_msg.msg.hdr.ctype =
|
||||
bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len,
|
||||
p_data->rc_msg.msg.pass.p_pass_data, is_inquiry);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry);
|
||||
@@ -890,7 +891,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
evt = BTA_AV_VENDOR_CMD_EVT;
|
||||
}
|
||||
}
|
||||
/* else if configured to support vendor specific and it's a response */
|
||||
else if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
|
||||
@@ -902,7 +905,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
|
||||
evt = BTA_AV_META_MSG_EVT;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
evt = BTA_AV_VENDOR_RSP_EVT;
|
||||
}
|
||||
|
||||
}
|
||||
/* else if not configured to support vendor specific and it's a command */
|
||||
|
@@ -105,7 +105,7 @@ void BTA_AvDisable(void)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos)
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos, UINT8 tsep)
|
||||
{
|
||||
tBTA_AV_API_REG *p_buf;
|
||||
|
||||
@@ -122,6 +122,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
|
||||
p_buf->app_id = app_id;
|
||||
p_buf->p_app_data_cback = p_data_cback;
|
||||
p_buf->bta_av_cos = bta_av_cos;
|
||||
p_buf->tsep = tsep;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
@@ -578,18 +578,20 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
|
||||
}
|
||||
|
||||
/* Set the Capturing service class bit */
|
||||
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
|
||||
cod.service = BTM_COD_SERVICE_CAPTURING;
|
||||
} else {
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
cod.service = BTM_COD_SERVICE_CAPTURING | BTM_COD_SERVICE_RENDERING;
|
||||
#else
|
||||
cod.service = BTM_COD_SERVICE_CAPTURING;
|
||||
cod.service = BTM_COD_SERVICE_RENDERING;
|
||||
#endif
|
||||
}
|
||||
utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
|
||||
} /* if 1st channel */
|
||||
|
||||
/* get stream configuration and create stream */
|
||||
/* memset(&cs.cfg,0,sizeof(tAVDT_CFG)); */
|
||||
cs.cfg.num_codec = 1;
|
||||
cs.tsep = AVDT_TSEP_SRC;
|
||||
cs.tsep = p_data->api_reg.tsep;
|
||||
|
||||
/*
|
||||
* memset of cs takes care setting call back pointers to null.
|
||||
@@ -637,11 +639,10 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
|
||||
memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG));
|
||||
while (index < BTA_AV_MAX_SEPS &&
|
||||
(p_scb->p_cos->init)(&codec_type, cs.cfg.codec_info,
|
||||
&cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE) {
|
||||
&cs.cfg.num_protect, cs.cfg.protect_info, p_data->api_reg.tsep) == TRUE) {
|
||||
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
if (index == 1) {
|
||||
cs.tsep = AVDT_TSEP_SNK;
|
||||
if (p_data->api_reg.tsep == AVDT_TSEP_SNK) {
|
||||
cs.p_data_cback = bta_av_stream_data_cback;
|
||||
}
|
||||
APPL_TRACE_DEBUG(" SEP Type = %d\n", cs.tsep);
|
||||
@@ -667,18 +668,20 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
|
||||
}
|
||||
|
||||
if (!bta_av_cb.reg_audio) {
|
||||
/* create the SDP records on the 1st audio channel */
|
||||
bta_av_cb.sdp_a2d_handle = SDP_CreateRecord();
|
||||
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
|
||||
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_handle);
|
||||
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
|
||||
|
||||
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
|
||||
/* create the SDP records on the 1st audio channel */
|
||||
bta_av_cb.sdp_a2d_handle = SDP_CreateRecord();
|
||||
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
|
||||
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_handle);
|
||||
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
|
||||
} else {
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
|
||||
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_avk_service_name, NULL,
|
||||
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
|
||||
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
|
||||
bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
|
||||
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_avk_service_name, NULL,
|
||||
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
|
||||
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
|
||||
#endif
|
||||
}
|
||||
/* start listening when A2DP is registered */
|
||||
if (bta_av_cb.features & BTA_AV_FEAT_RCTG) {
|
||||
bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1);
|
||||
@@ -1261,7 +1264,7 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_st_code(UINT8 state)
|
||||
UNUSED_ATTR static char *bta_av_st_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_ST: return "INIT";
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include "bta/bta_av_co.h"
|
||||
#include "bta_av_int.h"
|
||||
#include "osi/osi.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
@@ -94,6 +95,7 @@ enum {
|
||||
BTA_AV_ROLE_RES,
|
||||
BTA_AV_DELAY_CO,
|
||||
BTA_AV_OPEN_AT_INC,
|
||||
BTA_AV_OPEN_FAIL_SDP,
|
||||
BTA_AV_NUM_SACTIONS
|
||||
};
|
||||
|
||||
@@ -199,7 +201,7 @@ static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
|
||||
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_OK_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_OPEN_FAIL_SDP, BTA_AV_INIT_SST },
|
||||
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
/* STR_DISC_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
|
||||
/* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
|
||||
@@ -563,7 +565,7 @@ void bta_av_set_scb_sst_incoming (tBTA_AV_SCB *p_scb)
|
||||
** Returns char *
|
||||
**
|
||||
*******************************************************************************/
|
||||
static char *bta_av_sst_code(UINT8 state)
|
||||
UNUSED_ATTR static char *bta_av_sst_code(UINT8 state)
|
||||
{
|
||||
switch (state) {
|
||||
case BTA_AV_INIT_SST: return "INIT";
|
||||
|
@@ -158,44 +158,6 @@ enum {
|
||||
/*****************************************************************************
|
||||
** Data types
|
||||
*****************************************************************************/
|
||||
#if 0
|
||||
/* function types for call-out functions */
|
||||
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
|
||||
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
|
||||
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
|
||||
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info);
|
||||
typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
|
||||
UINT8 num_protect, UINT8 *p_protect_info,
|
||||
UINT8 t_local_sep, UINT8 avdt_handle);
|
||||
typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl,
|
||||
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
|
||||
UINT16 mtu);
|
||||
typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu);
|
||||
typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
|
||||
typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
|
||||
typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
|
||||
UINT32 *p_len, UINT32 *p_timestamp);
|
||||
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
|
||||
|
||||
/* the call-out functions for one stream */
|
||||
typedef struct {
|
||||
tBTA_AV_CO_INIT init;
|
||||
tBTA_AV_CO_DISC_RES disc_res;
|
||||
tBTA_AV_CO_GETCFG getcfg;
|
||||
tBTA_AV_CO_SETCFG setcfg;
|
||||
tBTA_AV_CO_OPEN open;
|
||||
tBTA_AV_CO_CLOSE close;
|
||||
tBTA_AV_CO_START start;
|
||||
tBTA_AV_CO_STOP stop;
|
||||
tBTA_AV_CO_DATAPATH data;
|
||||
tBTA_AV_CO_DELAY delay;
|
||||
} tBTA_AV_CO_FUNCTS;
|
||||
#endif
|
||||
|
||||
/* data type for BTA_AV_API_ENABLE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -209,7 +171,8 @@ typedef struct {
|
||||
BT_HDR hdr;
|
||||
char p_service_name[BTA_SERVICE_NAME_LEN + 1];
|
||||
UINT8 app_id;
|
||||
tBTA_AV_DATA_CBACK *p_app_data_cback;
|
||||
UINT8 tsep; // local SEP type
|
||||
tBTA_AV_DATA_CBACK *p_app_data_cback;
|
||||
tBTA_AV_CO_FUNCTS *bta_av_cos;
|
||||
} tBTA_AV_API_REG;
|
||||
|
||||
@@ -698,6 +661,7 @@ extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
extern void bta_av_open_fail_sdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
|
||||
/* ssm action functions - vdp specific */
|
||||
extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
|
||||
|
@@ -127,6 +127,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
|
||||
static void bta_dm_observe_cmpl_cb(void *p_result);
|
||||
static void bta_dm_observe_discard_cb (uint32_t num_dis);
|
||||
static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
|
||||
extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8 *p_uuid128);
|
||||
static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle);
|
||||
@@ -635,13 +636,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
|
||||
/* set modes for Discoverability and connectability if not ignore */
|
||||
if (p_data->set_visibility.disc_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE)
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
|
||||
p_data->set_visibility.disc_mode =
|
||||
((p_data->set_visibility.disc_mode & ~BTA_DM_LE_IGNORE) | le_disc_mode);
|
||||
}
|
||||
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE)
|
||||
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
|
||||
p_data->set_visibility.disc_mode =
|
||||
((p_data->set_visibility.disc_mode & ~BTA_DM_IGNORE) | disc_mode);
|
||||
}
|
||||
|
||||
BTM_SetDiscoverability(p_data->set_visibility.disc_mode,
|
||||
bta_dm_cb.inquiry_scan_window,
|
||||
@@ -649,13 +652,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
if (p_data->set_visibility.conn_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE)
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
|
||||
p_data->set_visibility.conn_mode =
|
||||
((p_data->set_visibility.conn_mode & ~BTA_DM_LE_IGNORE) | le_conn_mode);
|
||||
}
|
||||
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE)
|
||||
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
|
||||
p_data->set_visibility.conn_mode =
|
||||
((p_data->set_visibility.conn_mode & ~BTA_DM_IGNORE) | conn_mode);
|
||||
}
|
||||
|
||||
BTM_SetConnectability(p_data->set_visibility.conn_mode,
|
||||
bta_dm_cb.page_scan_window,
|
||||
@@ -705,7 +710,7 @@ static void bta_dm_process_remove_device(BD_ADDR bd_addr, tBT_TRANSPORT transpor
|
||||
BTA_GATTC_CancelOpen(0, bd_addr, FALSE);
|
||||
#endif
|
||||
|
||||
BTM_SecDeleteDevice(bd_addr);
|
||||
BTM_SecDeleteDevice(bd_addr, transport);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
/* remove all cached GATT information */
|
||||
@@ -748,7 +753,8 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
|
||||
|
||||
/* Take the link down first, and mark the device for removal when disconnected */
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)) {
|
||||
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport) {
|
||||
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
|
||||
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
|
||||
@@ -853,7 +859,7 @@ void bta_dm_close_acl(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
/* if to remove the device from security database ? do it now */
|
||||
else if (p_remove_acl->remove_dev) {
|
||||
if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr)) {
|
||||
if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr, p_remove_acl->transport)) {
|
||||
APPL_TRACE_ERROR("delete device from security database failed.");
|
||||
}
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
@@ -973,6 +979,21 @@ void bta_dm_bond_cancel (tBTA_DM_MSG *p_data)
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_set_pin_type
|
||||
**
|
||||
** Description Set the pin type and fixed pin
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_set_pin_type (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_SetPinType (p_data->set_pin_type.pin_type, p_data->set_pin_type.p_pin, p_data->set_pin_type.pin_len);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pin_reply
|
||||
@@ -1845,10 +1866,12 @@ void bta_dm_disc_result (tBTA_DM_MSG *p_data)
|
||||
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
/* if any BR/EDR service discovery has been done, report the event */
|
||||
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK)))
|
||||
#endif
|
||||
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK))) {
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
|
||||
|
||||
}
|
||||
#else
|
||||
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
|
||||
#endif
|
||||
tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG));
|
||||
|
||||
/* send a message to change state */
|
||||
@@ -2114,9 +2137,10 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
|
||||
}
|
||||
|
||||
/* last one? clear the BLE service bit if all discovery has been done */
|
||||
if (bta_dm_search_cb.uuid_to_search == 0)
|
||||
if (bta_dm_search_cb.uuid_to_search == 0) {
|
||||
bta_dm_search_cb.services_to_search &=
|
||||
(tBTA_SERVICE_MASK)(~(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index)));
|
||||
}
|
||||
|
||||
} else
|
||||
#endif
|
||||
@@ -2626,9 +2650,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_pinname_cback
|
||||
@@ -2685,6 +2707,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
|
||||
bta_dm_cb.p_sec_cback(event, &sec_event);
|
||||
}
|
||||
}
|
||||
#endif //(BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2704,18 +2727,6 @@ static UINT8 bta_dm_pin_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NAME bd_
|
||||
return BTM_NOT_AUTHORIZED;
|
||||
}
|
||||
|
||||
/* If the device name is not known, save bdaddr and devclass and initiate a name request */
|
||||
if (bd_name[0] == 0) {
|
||||
bta_dm_cb.pin_evt = BTA_DM_PIN_REQ_EVT;
|
||||
bdcpy(bta_dm_cb.pin_bd_addr, bd_addr);
|
||||
BTA_COPY_DEVICE_CLASS(bta_dm_cb.pin_dev_class, dev_class);
|
||||
if ((BTM_ReadRemoteDeviceName(bd_addr, bta_dm_pinname_cback, BT_TRANSPORT_BR_EDR)) == BTM_CMD_STARTED) {
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
|
||||
APPL_TRACE_WARNING(" bta_dm_pin_cback() -> Failed to start Remote Name Request ");
|
||||
}
|
||||
|
||||
bdcpy(sec_event.pin_req.bd_addr, bd_addr);
|
||||
BTA_COPY_DEVICE_CLASS(sec_event.pin_req.dev_class, dev_class);
|
||||
BCM_STRNCPY_S((char *)sec_event.pin_req.bd_name, sizeof(BD_NAME), (char *)bd_name, (BD_NAME_LEN - 1));
|
||||
@@ -3256,7 +3267,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
|
||||
if ( bta_dm_cb.device_list.peer_device[i].conn_state == BTA_DM_UNPAIRING ) {
|
||||
if (BTM_SecDeleteDevice(bta_dm_cb.device_list.peer_device[i].peer_bdaddr)) {
|
||||
if (BTM_SecDeleteDevice(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, bta_dm_cb.device_list.peer_device[i].transport)) {
|
||||
issue_unpair_cb = TRUE;
|
||||
}
|
||||
|
||||
@@ -3304,7 +3315,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
if (conn.link_down.is_removed) {
|
||||
BTM_SecDeleteDevice(p_bda);
|
||||
BTM_SecDeleteDevice(p_bda, p_data->acl_change.transport);
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection */
|
||||
BTA_GATTC_CancelOpen(0, p_bda, FALSE);
|
||||
@@ -3482,7 +3493,7 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
|
||||
APPL_TRACE_ERROR(" %s Device does not exist in DB", __FUNCTION__);
|
||||
}
|
||||
} else {
|
||||
BTM_SecDeleteDevice (remote_bd_addr);
|
||||
BTM_SecDeleteDevice (remote_bd_addr, bta_dm_cb.device_list.peer_device[index].transport);
|
||||
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
|
||||
/* need to remove all pending background connection */
|
||||
BTA_GATTC_CancelOpen(0, remote_bd_addr, FALSE);
|
||||
@@ -3591,11 +3602,11 @@ static char *bta_dm_get_remname(void)
|
||||
char *p_temp;
|
||||
|
||||
/* If the name isn't already stored, try retrieving from BTM */
|
||||
if (*p_name == '\0')
|
||||
if (*p_name == '\0') {
|
||||
if ((p_temp = BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr)) != NULL) {
|
||||
p_name = p_temp;
|
||||
}
|
||||
|
||||
}
|
||||
return p_name;
|
||||
}
|
||||
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
|
||||
@@ -4210,6 +4221,28 @@ static void bta_dm_observe_cmpl_cb (void *p_result)
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_observe_discard_cb
|
||||
**
|
||||
** Description Callback for BLE Observe lost
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_dm_observe_discard_cb (uint32_t num_dis)
|
||||
{
|
||||
tBTA_DM_SEARCH data;
|
||||
|
||||
APPL_TRACE_DEBUG("bta_dm_observe_discard_cb");
|
||||
|
||||
data.inq_dis.num_dis = num_dis;
|
||||
if (bta_dm_search_cb.p_scan_cback) {
|
||||
bta_dm_search_cb.p_scan_cback(BTA_DM_INQ_DISCARD_NUM_EVT, &data);
|
||||
}
|
||||
}
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -4233,9 +4266,8 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
|
||||
memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
|
||||
switch (event) {
|
||||
case BTM_LE_IO_REQ_EVT:
|
||||
// #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
|
||||
|
||||
case BTM_LE_IO_REQ_EVT: {
|
||||
// #if (BT_SSP_INCLUDED == TRUE)
|
||||
bta_dm_co_ble_io_req(bda,
|
||||
&p_data->io_req.io_cap,
|
||||
&p_data->io_req.oob_data,
|
||||
@@ -4250,6 +4282,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
APPL_TRACE_EVENT("io mitm: %d oob_data:%d\n", p_data->io_req.auth_req, p_data->io_req.oob_data);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case BTM_LE_SEC_REQUEST_EVT:
|
||||
bdcpy(sec_event.ble_req.bd_addr, bda);
|
||||
@@ -4325,7 +4358,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sec_event.auth_cmpl.auth_mode = p_data->complt.auth_mode;
|
||||
if (bta_dm_cb.p_sec_cback) {
|
||||
//bta_dm_cb.p_sec_cback(BTA_DM_AUTH_CMPL_EVT, &sec_event);
|
||||
bta_dm_cb.p_sec_cback(BTA_DM_BLE_AUTH_CMPL_EVT, &sec_event);
|
||||
@@ -4414,7 +4447,8 @@ void bta_dm_add_ble_device (tBTA_DM_MSG *p_data)
|
||||
{
|
||||
if (!BTM_SecAddBleDevice (p_data->add_ble_device.bd_addr, NULL,
|
||||
p_data->add_ble_device.dev_type ,
|
||||
p_data->add_ble_device.addr_type)) {
|
||||
p_data->add_ble_device.addr_type,
|
||||
p_data->add_ble_device.auth_mode)) {
|
||||
APPL_TRACE_ERROR ("BTA_DM: Error adding BLE Device for device %08x%04x",
|
||||
(p_data->add_ble_device.bd_addr[0] << 24) + (p_data->add_ble_device.bd_addr[1] << 16) + \
|
||||
(p_data->add_ble_device.bd_addr[2] << 8) + p_data->add_ble_device.bd_addr[3],
|
||||
@@ -4443,6 +4477,10 @@ void bta_dm_ble_passkey_reply (tBTA_DM_MSG *p_data)
|
||||
|
||||
}
|
||||
|
||||
void bta_dm_ble_set_static_passkey(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
BTM_BleSetStaticPasskey(p_data->ble_set_static_passkey.add, p_data->ble_set_static_passkey.static_passkey);
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ble_confirm_reply
|
||||
@@ -4730,7 +4768,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
|
||||
bta_dm_search_cb.p_scan_cback = p_data->ble_scan.p_cback;
|
||||
|
||||
if ((status = BTM_BleScan(TRUE, p_data->ble_scan.duration,
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) {
|
||||
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb, bta_dm_observe_discard_cb)) != BTM_CMD_STARTED) {
|
||||
APPL_TRACE_WARNING(" %s start scan failed. status=0x%x\n", __FUNCTION__, status);
|
||||
}
|
||||
|
||||
@@ -4740,7 +4778,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
} else {
|
||||
bta_dm_search_cb.p_scan_cback = NULL;
|
||||
status = BTM_BleScan(FALSE, 0, NULL, NULL);
|
||||
status = BTM_BleScan(FALSE, 0, NULL, NULL, NULL);
|
||||
|
||||
if (status != BTM_CMD_STARTED){
|
||||
APPL_TRACE_WARNING(" %s stop scan failed, status=0x%x\n", __FUNCTION__, status);
|
||||
@@ -5083,9 +5121,10 @@ void bta_dm_ble_setup_storage (tBTA_DM_MSG *p_data)
|
||||
p_data->ble_set_storage.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_CFG_STRG_EVT, p_data->ble_set_storage.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5113,9 +5152,10 @@ void bta_dm_ble_enable_batch_scan (tBTA_DM_MSG *p_data)
|
||||
p_data->ble_enable_scan.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_ENABLE_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5139,9 +5179,10 @@ void bta_dm_ble_disable_batch_scan (tBTA_DM_MSG *p_data)
|
||||
btm_status = BTM_BleDisableBatchScan(p_data->ble_disable_scan.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_DISABLE_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5165,9 +5206,10 @@ void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data)
|
||||
p_data->ble_read_reports.ref_value);
|
||||
}
|
||||
|
||||
if (BTM_CMD_STARTED != btm_status)
|
||||
if (BTM_CMD_STARTED != btm_status) {
|
||||
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_READ_REPTS_EVT, p_data->ble_enable_scan.ref_value,
|
||||
btm_status);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -5297,10 +5339,11 @@ void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback)
|
||||
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback) {
|
||||
p_data->ble_cfg_filter_cond.p_filt_cfg_cback(BTA_DM_BLE_PF_CONFIG_EVT,
|
||||
p_data->ble_cfg_filter_cond.cond_type, 0, status,
|
||||
p_data->ble_cfg_filter_cond.ref_value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5331,9 +5374,10 @@ void bta_dm_enable_scan_filter(tBTA_DM_MSG *p_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_data->ble_enable_scan_filt.p_filt_status_cback)
|
||||
if (p_data->ble_enable_scan_filt.p_filt_status_cback) {
|
||||
p_data->ble_enable_scan_filt.p_filt_status_cback (BTA_DM_BLE_PF_ENABLE_EVT,
|
||||
p_data->ble_enable_scan_filt.ref_value, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5367,9 +5411,10 @@ void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback)
|
||||
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback) {
|
||||
p_data->ble_scan_filt_param_setup.p_filt_param_cback (BTA_DM_BLE_PF_ENABLE_EVT, 0,
|
||||
p_data->ble_scan_filt_param_setup.ref_value, status);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -5679,6 +5724,8 @@ void bta_dm_proc_open_evt(tBTA_GATTC_OPEN *p_data)
|
||||
((p2[0]) << 24) + ((p2[1]) << 16) + ((p2[2]) << 8) + (p2[3]),
|
||||
((p2[4]) << 8) + p2[5]);
|
||||
|
||||
UNUSED(p1);
|
||||
UNUSED(p2);
|
||||
APPL_TRACE_DEBUG("BTA_GATTC_OPEN_EVT conn_id = %d client_if=%d status = %d" ,
|
||||
p_data->conn_id,
|
||||
p_data->client_if,
|
||||
|
@@ -436,6 +436,29 @@ void BTA_DmBondCancel(BD_ADDR bd_addr)
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DMSetPinType
|
||||
**
|
||||
** Description This function set pin type as BTM_PIN_TYPE_FIXED or BTM_PIN_TYPE_VARIABLE
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DMSetPinType (UINT8 pin_type, UINT8 *pin_code, UINT8 pin_code_len)
|
||||
{
|
||||
tBTA_DM_API_SET_PIN_TYPE *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_PIN_TYPE *) osi_malloc(sizeof(tBTA_DM_API_SET_PIN_TYPE))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_SET_PIN_TYPE_EVT;
|
||||
p_msg->pin_type = pin_type;
|
||||
p_msg->pin_len = pin_code_len;
|
||||
memcpy(p_msg->p_pin, pin_code, pin_code_len);
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmPinReply
|
||||
@@ -448,7 +471,6 @@ void BTA_DmBondCancel(BD_ADDR bd_addr)
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin)
|
||||
|
||||
{
|
||||
tBTA_DM_API_PIN_REPLY *p_msg;
|
||||
|
||||
@@ -752,12 +774,13 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
|
||||
**
|
||||
** Parameters: bd_addr - BD address of the peer
|
||||
** dev_type - Remote device's device type.
|
||||
** auth_mode - auth mode
|
||||
** addr_type - LE device address type.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type)
|
||||
void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, int auth_mode, tBT_DEVICE_TYPE dev_type)
|
||||
{
|
||||
tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
|
||||
|
||||
@@ -767,6 +790,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
|
||||
p_msg->hdr.event = BTA_DM_API_ADD_BLEDEVICE_EVT;
|
||||
bdcpy(p_msg->bd_addr, bd_addr);
|
||||
p_msg->addr_type = addr_type;
|
||||
p_msg->auth_mode = auth_mode;
|
||||
p_msg->dev_type = dev_type;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
@@ -803,6 +827,21 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void BTA_DmBleSetStaticPasskey(bool add, uint32_t passkey)
|
||||
{
|
||||
tBTA_DM_API_SET_DEFAULT_PASSKEY *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_SET_DEFAULT_PASSKEY *) osi_malloc(sizeof(tBTA_DM_API_SET_DEFAULT_PASSKEY))) != NULL) {
|
||||
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_DEFAULT_PASSKEY));
|
||||
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT;
|
||||
p_msg->add = add;
|
||||
p_msg->static_passkey = passkey;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleConfirmReply
|
||||
|
@@ -31,6 +31,10 @@
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
#include "common/bte_appl.h"
|
||||
|
||||
#define BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE 0
|
||||
#define BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE 1
|
||||
|
||||
tBTE_APPL_CFG bte_appl_cfg = {
|
||||
#if SMP_INCLUDED == TRUE
|
||||
BTA_LE_AUTH_REQ_SC_MITM_BOND, // Authentication requirements
|
||||
@@ -40,7 +44,8 @@ tBTE_APPL_CFG bte_appl_cfg = {
|
||||
BTM_LOCAL_IO_CAPS_BLE,
|
||||
BTM_BLE_INITIATOR_KEY_SIZE,
|
||||
BTM_BLE_RESPONDER_KEY_SIZE,
|
||||
BTM_BLE_MAX_KEY_SIZE
|
||||
BTM_BLE_MAX_KEY_SIZE,
|
||||
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -319,7 +324,7 @@ void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
|
||||
void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_io_cap < BTM_IO_CAP_MAX ) {
|
||||
@@ -330,7 +335,7 @@ void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req)
|
||||
void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bte_appl_cfg.ble_auth_req = ble_auth_req;
|
||||
@@ -363,5 +368,32 @@ void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if (enable) {
|
||||
enable = BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE;
|
||||
}
|
||||
bte_appl_cfg.ble_accept_auth_enable = enable;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
UINT8 bta_dm_co_ble_get_accept_auth_enable(void)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
return bte_appl_cfg.ble_accept_auth_enable;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 bta_dm_co_ble_get_auth_req(void)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
return bte_appl_cfg.ble_auth_req;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@@ -53,33 +53,34 @@ typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
|
||||
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
|
||||
/* device manager local device API events */
|
||||
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
|
||||
bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
|
||||
bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_close_acl, /* 10 BTA_DM_API_REMOVE_ACL_EVT */
|
||||
bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */
|
||||
bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */
|
||||
bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_set_visibility, /* BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_close_acl, /* BTA_DM_API_REMOVE_ACL_EVT */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/* security API events */
|
||||
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
|
||||
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
|
||||
bta_dm_bond, /* BTA_DM_API_BOND_EVT */
|
||||
bta_dm_bond_cancel, /* BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_set_pin_type, /* BTA_DM_API_SET_PIN_TYPE_EVT */
|
||||
bta_dm_pin_reply, /* BTA_DM_API_PIN_REPLY_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
|
||||
bta_dm_pm_btm_status, /* BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* BTA_DM_PM_TIMER_EVT */
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
/* simple pairing events */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
|
||||
bta_dm_confirm, /* BTA_DM_API_CONFIRM_EVT */
|
||||
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
|
||||
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
|
||||
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
|
||||
bta_dm_loc_oob, /* BTA_DM_API_LOC_OOB_EVT */
|
||||
bta_dm_ci_io_req_act, /* BTA_DM_CI_IO_REQ_EVT */
|
||||
bta_dm_ci_rmt_oob_act, /* BTA_DM_CI_RMT_OOB_EVT */
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
|
||||
@@ -88,6 +89,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
|
||||
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
|
||||
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
|
||||
bta_dm_ble_set_static_passkey, /* BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT */
|
||||
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
|
||||
bta_dm_security_grant,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
@@ -96,18 +98,18 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
|
||||
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
|
||||
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT */
|
||||
bta_dm_ble_scan, /* BTA_DM_API_BLE_SCAN_EVT */
|
||||
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
|
||||
/* This handler function added by
|
||||
Yulong at 2016/9/9 to support the
|
||||
random address setting for the APP */
|
||||
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/
|
||||
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT */
|
||||
/* This handler function added by
|
||||
Yulong at 2016/10/19 to support
|
||||
stop the ble advertising setting
|
||||
by the APP */
|
||||
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT*/
|
||||
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT */
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||
#endif
|
||||
@@ -119,7 +121,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
data to HCI */
|
||||
bta_dm_ble_set_adv_config_raw, /* BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT */
|
||||
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
|
||||
/* New function to allow set raw scan
|
||||
/* New function to allow set raw scan
|
||||
response data to HCI */
|
||||
bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */
|
||||
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
|
||||
@@ -129,10 +131,10 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
|
||||
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
|
||||
#endif
|
||||
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
|
||||
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
|
||||
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
|
||||
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
|
||||
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT */
|
||||
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
|
||||
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
|
||||
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
|
||||
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
|
||||
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
|
||||
@@ -142,9 +144,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_ble_disconnect, /* BTA_DM_API_BLE_DISCONNECT_EVT */
|
||||
#endif
|
||||
|
||||
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
|
||||
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
|
||||
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
|
||||
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
|
||||
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
|
||||
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
|
||||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
|
@@ -1038,9 +1038,10 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive)
|
||||
bta_dm_pm_set_sniff_policy( bta_dm_find_peer_device(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr), bScoActive);
|
||||
|
||||
/* if we had disabled link policy, seems like the hid device stop retrying SNIFF after a few tries. force sniff if needed */
|
||||
if (!bScoActive)
|
||||
if (!bScoActive) {
|
||||
bta_dm_pm_set_mode(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, BTA_DM_PM_NO_ACTION,
|
||||
BTA_DM_PM_RESTART);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -61,6 +61,7 @@ enum {
|
||||
/* security API events */
|
||||
BTA_DM_API_BOND_EVT,
|
||||
BTA_DM_API_BOND_CANCEL_EVT,
|
||||
BTA_DM_API_SET_PIN_TYPE_EVT,
|
||||
BTA_DM_API_PIN_REPLY_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
@@ -86,6 +87,7 @@ enum {
|
||||
BTA_DM_API_ADD_BLEKEY_EVT,
|
||||
BTA_DM_API_ADD_BLEDEVICE_EVT,
|
||||
BTA_DM_API_BLE_PASSKEY_REPLY_EVT,
|
||||
BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT,
|
||||
BTA_DM_API_BLE_CONFIRM_REPLY_EVT,
|
||||
BTA_DM_API_BLE_SEC_GRANT_EVT,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
@@ -271,6 +273,14 @@ typedef struct {
|
||||
tBTA_TRANSPORT transport;
|
||||
} tBTA_DM_API_BOND_CANCEL;
|
||||
|
||||
/* data type for BTA_DM_API_SET_PIN_TYPE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 pin_type;
|
||||
UINT8 pin_len;
|
||||
UINT8 p_pin[PIN_CODE_LEN];
|
||||
} tBTA_DM_API_SET_PIN_TYPE;
|
||||
|
||||
/* data type for BTA_DM_API_PIN_REPLY_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -424,6 +434,7 @@ typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBT_DEVICE_TYPE dev_type ;
|
||||
UINT32 auth_mode;
|
||||
tBLE_ADDR_TYPE addr_type;
|
||||
|
||||
} tBTA_DM_API_ADD_BLE_DEVICE;
|
||||
@@ -435,6 +446,12 @@ typedef struct {
|
||||
UINT32 passkey;
|
||||
} tBTA_DM_API_PASSKEY_REPLY;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN add;
|
||||
UINT32 static_passkey;
|
||||
} tBTA_DM_API_SET_DEFAULT_PASSKEY;
|
||||
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
@@ -744,6 +761,7 @@ typedef union {
|
||||
|
||||
tBTA_DM_API_BOND_CANCEL bond_cancel;
|
||||
|
||||
tBTA_DM_API_SET_PIN_TYPE set_pin_type;
|
||||
tBTA_DM_API_PIN_REPLY pin_reply;
|
||||
|
||||
tBTA_DM_API_LOC_OOB loc_oob;
|
||||
@@ -777,6 +795,7 @@ typedef union {
|
||||
tBTA_DM_API_ADD_BLEKEY add_ble_key;
|
||||
tBTA_DM_API_ADD_BLE_DEVICE add_ble_device;
|
||||
tBTA_DM_API_PASSKEY_REPLY ble_passkey_reply;
|
||||
tBTA_DM_API_SET_DEFAULT_PASSKEY ble_set_static_passkey;
|
||||
tBTA_DM_API_BLE_SEC_GRANT ble_sec_grant;
|
||||
tBTA_DM_API_BLE_SET_BG_CONN_TYPE ble_set_bd_conn_type;
|
||||
tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params;
|
||||
@@ -1166,6 +1185,7 @@ extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_vendor_spec_command(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_bond (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_bond_cancel (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_pin_type (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_pin_reply (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_acl_change(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_add_device (tBTA_DM_MSG *p_data);
|
||||
@@ -1178,6 +1198,7 @@ extern void bta_dm_add_ampkey (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_add_blekey (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_add_ble_device (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_passkey_reply (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_static_passkey(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_confirm_reply (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_security_grant (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data);
|
||||
|
@@ -531,7 +531,9 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
|
||||
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) {
|
||||
/* always call open to hold a connection */
|
||||
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, p_data->transport)) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
uint8_t *bda = (uint8_t *)p_data->remote_bda;
|
||||
#endif
|
||||
status = BTA_GATT_ERROR;
|
||||
APPL_TRACE_ERROR("%s unable to connect to remote bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
@@ -674,7 +676,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
|
||||
//register service change
|
||||
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
|
||||
} else
|
||||
} else
|
||||
#endif
|
||||
{ /* cache is building */
|
||||
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
|
||||
@@ -1070,8 +1072,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data))
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tGATT_READ_PARAM read_param;
|
||||
memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));
|
||||
@@ -1139,8 +1142,9 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data))
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
tGATT_VALUE attr;
|
||||
@@ -1740,7 +1744,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
|
||||
tBTA_GATTC gattc_cb = {0};
|
||||
gattc_cb.set_assoc.client_if = p_msg->api_assoc.client_if;
|
||||
BOOLEAN state = FALSE;
|
||||
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
|
||||
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
|
||||
p_msg->api_assoc.assoc_addr, BTA_TRANSPORT_LE);
|
||||
tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_assoc.client_if);
|
||||
if (p_assoc_clcb != NULL) {
|
||||
@@ -1781,7 +1785,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
|
@@ -93,7 +93,7 @@ static char *bta_gattc_attr_type[] = {
|
||||
};
|
||||
/* utility functions */
|
||||
|
||||
bool display_cache_attribute(void *data, void *context)
|
||||
bool display_cache_attribute(void *data, void *context)
|
||||
{
|
||||
//tBTA_GATTC_CACHE_ATTR *p_attr = data;
|
||||
//APPL_TRACE_ERROR("\t Attr handle[%d] uuid[0x%04x] type[%s] prop[0x%1x]",
|
||||
@@ -102,7 +102,7 @@ bool display_cache_attribute(void *data, void *context)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool display_cache_service(void *data, void *context)
|
||||
bool display_cache_service(void *data, void *context)
|
||||
{
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = data;
|
||||
APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
|
||||
@@ -213,9 +213,9 @@ static void bta_gattc_free(void *ptr)
|
||||
osi_free(ptr);
|
||||
}
|
||||
|
||||
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
|
||||
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
|
||||
{
|
||||
// services/p_new_srvc is NULL
|
||||
// services/p_new_srvc is NULL
|
||||
if (!services || !p_new_srvc) {
|
||||
APPL_TRACE_ERROR("%s services/p_new_srvc is NULL", __func__);
|
||||
return;
|
||||
@@ -243,7 +243,7 @@ void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,8 +314,9 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
/* TODO(jpawlowski): We should use attribute handle, not value handle to refer to characteristic.
|
||||
This is just a temporary workaround.
|
||||
*/
|
||||
if (service->e_handle < value_handle)
|
||||
if (service->e_handle < value_handle) {
|
||||
service->e_handle = value_handle;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC *characteristic = osi_malloc(sizeof(tBTA_GATTC_CHARACTERISTIC));
|
||||
if (!characteristic) {
|
||||
@@ -554,10 +555,10 @@ void bta_gattc_update_include_service(const list_t *services) {
|
||||
if(include_service && !include_service->included_service) {
|
||||
//update
|
||||
include_service->included_service = bta_gattc_find_matching_service(services, include_service->incl_srvc_s_handle);
|
||||
if(!include_service->included_service) {
|
||||
if(!include_service->included_service) {
|
||||
//not match, free it
|
||||
list_remove(service->included_svc, include_service);
|
||||
osi_free(include_service);
|
||||
osi_free(include_service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -980,12 +981,13 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
p_data->value.incl_service.e_handle,
|
||||
p_data->value.incl_service.service_type);
|
||||
|
||||
if (!pri_srvc)
|
||||
if (!pri_srvc) {
|
||||
bta_gattc_add_srvc_to_list(p_srvc_cb,
|
||||
p_data->value.incl_service.s_handle,
|
||||
p_data->value.incl_service.e_handle,
|
||||
p_data->value.incl_service.service_type,
|
||||
FALSE);
|
||||
}
|
||||
/* add into database */
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
@@ -1007,8 +1009,8 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
|
||||
|
||||
case GATT_DISC_CHAR_DSCPT:
|
||||
bta_gattc_add_attr_to_cache(p_srvc_cb,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
p_data->handle,
|
||||
&p_data->type,
|
||||
0,
|
||||
0 /* incl_srvc_s_handle */,
|
||||
0 /* incl_srvc_e_handle */,
|
||||
@@ -1023,8 +1025,9 @@ void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if ( p_clcb && (status != GATT_SUCCESS || p_clcb->status != GATT_SUCCESS) ) {
|
||||
if (status == GATT_SUCCESS)
|
||||
if (status == GATT_SUCCESS) {
|
||||
p_clcb->status = status;
|
||||
}
|
||||
bta_gattc_sm_execute(p_clcb, BTA_GATTC_DISCOVER_CMPL_EVT, NULL);
|
||||
return;
|
||||
}
|
||||
@@ -1071,15 +1074,17 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache))
|
||||
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (list_node_t *sn = list_begin(p_clcb->p_srcb->p_srvc_cache);
|
||||
sn != list_end(p_clcb->p_srcb->p_srvc_cache); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *p_cache = list_node(sn);
|
||||
|
||||
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE))
|
||||
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
|
||||
APPL_TRACE_DEBUG("found service [0x%04x], inst[%d] handle [%d]",
|
||||
@@ -1087,8 +1092,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
p_cache->handle,
|
||||
p_cache->s_handle);
|
||||
#endif
|
||||
if (!p_clcb->p_rcb->p_cback)
|
||||
if (!p_clcb->p_rcb->p_cback) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
@@ -1103,8 +1109,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
|
||||
}
|
||||
|
||||
list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
|
||||
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache))
|
||||
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return p_srcb->p_srvc_cache;
|
||||
}
|
||||
@@ -1112,8 +1119,9 @@ list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
|
||||
const list_t* bta_gattc_get_services(UINT16 conn_id) {
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
|
||||
@@ -1121,63 +1129,68 @@ const list_t* bta_gattc_get_services(UINT16 conn_id) {
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERVICE* bta_gattc_find_matching_service(const list_t *services, UINT16 handle) {
|
||||
if (!services || list_is_empty(services))
|
||||
if (!services || list_is_empty(services)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list_node_t *sn = list_begin(services);
|
||||
sn != list_end(services); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *service = list_node(sn);
|
||||
|
||||
if (handle >= service->s_handle && handle <= service->e_handle)
|
||||
if (handle >= service->s_handle && handle <= service->e_handle) {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const list_t *services = bta_gattc_get_services_srcb(p_srcb);
|
||||
|
||||
return bta_gattc_find_matching_service(services, handle);
|
||||
}
|
||||
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
|
||||
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
const list_t *services = bta_gattc_get_services(conn_id);
|
||||
|
||||
return bta_gattc_find_matching_service(services, handle);
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
|
||||
|
||||
if (!service)
|
||||
if (!service) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(service->characteristics);
|
||||
cn != list_end(service->characteristics); cn = list_next(cn)) {
|
||||
tBTA_GATTC_CHARACTERISTIC *p_char = list_node(cn);
|
||||
if (handle == p_char->handle)
|
||||
if (handle == p_char->handle) {
|
||||
return p_char;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
|
||||
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
return bta_gattc_get_characteristic_srcb(p_srcb, handle);
|
||||
}
|
||||
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
|
||||
{
|
||||
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
|
||||
|
||||
@@ -1191,20 +1204,22 @@ tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, U
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
tBTA_GATTC_DESCRIPTOR *p_desc = list_node(dn);
|
||||
if (handle == p_desc->handle)
|
||||
if (handle == p_desc->handle) {
|
||||
return p_desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
|
||||
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb == NULL )
|
||||
if (p_clcb == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
return bta_gattc_get_descriptor_srcb(p_srcb, handle);
|
||||
@@ -1441,7 +1456,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1474,7 +1489,7 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
}
|
||||
|
||||
if (type == BTGATT_DB_PRIMARY_SERVICE || type == BTGATT_DB_SECONDARY_SERVICE) {
|
||||
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
|
||||
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
|
||||
(type == BTGATT_DB_SECONDARY_SERVICE && !p_cur_srvc->is_primary)) {
|
||||
// if the current service is the last service in the db, need to ensure the current service start handle is not less than the start_handle.
|
||||
if (!svc_length) {
|
||||
@@ -1570,10 +1585,11 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
|
||||
** Returns number of elements inside db from start_handle to end_handle
|
||||
*******************************************************************************/
|
||||
static size_t bta_gattc_get_db_size(list_t *services,
|
||||
UINT16 start_handle, UINT16 end_handle)
|
||||
UINT16 start_handle, UINT16 end_handle)
|
||||
{
|
||||
if (!services || list_is_empty(services))
|
||||
if (!services || list_is_empty(services)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t db_size = 0;
|
||||
UINT16 svc_length = list_length(services) - 1;
|
||||
@@ -1596,9 +1612,10 @@ static size_t bta_gattc_get_db_size(list_t *services,
|
||||
} else {
|
||||
db_size++;
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics))
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
@@ -1655,7 +1672,7 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
|
||||
*count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
*count = 0;
|
||||
@@ -1673,7 +1690,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
|
||||
if (p_clcb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
|
||||
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
|
||||
*count = 0;
|
||||
@@ -1691,7 +1708,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
|
||||
}
|
||||
}
|
||||
*count = bta_gattc_get_db_size_with_type(p_srcb->p_srvc_cache, type, NULL, start_handle, end_handle);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1783,8 +1800,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
p_char->properties);
|
||||
curr_db_attr++;
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
@@ -1812,8 +1830,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc))
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *isn = list_begin(p_cur_srvc->included_svc);
|
||||
isn != list_end(p_cur_srvc->included_svc); isn = list_next(isn)) {
|
||||
@@ -1980,8 +1999,9 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han
|
||||
*******************************************************************************/
|
||||
void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
{
|
||||
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache))
|
||||
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
size_t db_size = bta_gattc_get_db_size(p_srvc_cb->p_srvc_cache, 0x0000, 0xFFFF);
|
||||
@@ -2014,8 +2034,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
sn != list_end(p_srvc_cb->p_srvc_cache); sn = list_next(sn)) {
|
||||
tBTA_GATTC_SERVICE *p_cur_srvc = list_node(sn);
|
||||
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics))
|
||||
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
|
||||
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
|
||||
@@ -2031,8 +2052,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
0 /* incl_srvc_e_handle */,
|
||||
FALSE);
|
||||
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
|
||||
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *dn = list_begin(p_char->descriptors);
|
||||
dn != list_end(p_char->descriptors); dn = list_next(dn)) {
|
||||
@@ -2050,8 +2072,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc))
|
||||
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (list_node_t *an = list_begin(p_cur_srvc->included_svc);
|
||||
an != list_end(p_cur_srvc->included_svc); an = list_next(an)) {
|
||||
|
@@ -261,14 +261,18 @@ tBTA_GATT_STATUS bta_gattc_co_cache_open(BD_ADDR server_bda, BOOLEAN to_save, UI
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS bta_gattc_co_cache_load(tBTA_GATTC_NV_ATTR *attr, UINT8 index)
|
||||
{
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT16 num_attr = 0;
|
||||
#endif
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
size_t length = 0;
|
||||
// Read the size of memory space required for blob
|
||||
nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, NULL, &length);
|
||||
// Read previously saved blob if available
|
||||
esp_err_t err_code = nvs_get_blob(cache_env.cache_addr[index].cache_fp, cache_key, attr, &length);
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
num_attr = length / sizeof(tBTA_GATTC_NV_ATTR);
|
||||
#endif
|
||||
status = (err_code == ESP_OK && length != 0) ? BTA_GATT_OK : BTA_GATT_ERROR;
|
||||
APPL_TRACE_DEBUG("%s() - read=%d, status=%d, err_code = %d",
|
||||
__func__, num_attr, status, err_code);
|
||||
@@ -323,6 +327,9 @@ void bta_gattc_co_cache_save (BD_ADDR server_bda, UINT16 num_attr,
|
||||
status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
#if CONFIG_BT_STACK_NO_LOG
|
||||
(void) status;
|
||||
#endif
|
||||
APPL_TRACE_DEBUG("%s() wrote hash_key = %x%x%x%x, num_attr = %d, status = %d.", __func__, hash_key[0], hash_key[1], hash_key[2], hash_key[3], num_attr, status);
|
||||
}
|
||||
|
||||
|
@@ -416,8 +416,9 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
|
||||
|
||||
if (p_tcb != NULL)
|
||||
{
|
||||
if (p_tcb->p_srvc_cache != NULL)
|
||||
if (p_tcb->p_srvc_cache != NULL) {
|
||||
list_free(p_tcb->p_srvc_cache);
|
||||
}
|
||||
osi_free(p_tcb->p_srvc_list);
|
||||
p_tcb->p_srvc_list = NULL;
|
||||
//osi_free_and_reset((void **)&p_tcb->p_srvc_list);
|
||||
@@ -577,14 +578,16 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id,
|
||||
if ((p_clrcb = bta_gattc_cl_get_regcb(gatt_if)) != NULL) {
|
||||
for (i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
|
||||
if (p_clrcb->notif_reg[i].in_use &&
|
||||
!bdcmp(p_clrcb->notif_reg[i].remote_bda, remote_bda))
|
||||
!bdcmp(p_clrcb->notif_reg[i].remote_bda, remote_bda)) {
|
||||
|
||||
/* It's enough to get service or characteristic handle, as
|
||||
* clear boundaries are always around service.
|
||||
*/
|
||||
handle = p_clrcb->notif_reg[i].handle;
|
||||
if (handle >= start_handle && handle <= end_handle)
|
||||
if (handle >= start_handle && handle <= end_handle) {
|
||||
memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -636,8 +639,9 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda
|
||||
}
|
||||
if (!add) {
|
||||
if (remote_bda_ptr) {
|
||||
// bdstr_t bdstr = {0};
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bdstr[18] = {0};
|
||||
#endif
|
||||
APPL_TRACE_ERROR("%s unable to find the bg connection mask for: %s", __func__,
|
||||
bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
|
||||
}
|
||||
@@ -935,8 +939,9 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
|
||||
if (p_src->len == LEN_UUID_16 || p_src->len == LEN_UUID_32)
|
||||
{
|
||||
for(i=0; i != 16; ++i)
|
||||
for(i=0; i != 16; ++i) {
|
||||
p_dest->uu[i] = base_uuid[i];
|
||||
}
|
||||
}
|
||||
|
||||
switch (p_src->len)
|
||||
|
@@ -403,7 +403,7 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
UINT16 attr_id = 0;
|
||||
tBTA_GATTS cb_data;
|
||||
|
||||
tGATT_ATTR_VAL *p_attr_val = NULL;
|
||||
tGATT_ATTR_VAL *p_attr_val = NULL;
|
||||
tGATTS_ATTR_CONTROL *p_control = NULL;
|
||||
|
||||
if(p_msg->api_add_char.attr_val.attr_max_len != 0){
|
||||
@@ -665,17 +665,18 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
&gatt_if, remote_bda, &transport)) {
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_msg->api_indicate.need_confirm)
|
||||
if (p_msg->api_indicate.need_confirm) {
|
||||
|
||||
status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
else
|
||||
} else {
|
||||
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
}
|
||||
|
||||
/* if over BR_EDR, inform PM for mode change */
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
@@ -702,6 +703,10 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
APPL_TRACE_ERROR("%s, malloc failed", __func__);
|
||||
}
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
|
||||
if (cb_data.req_data.value != NULL) {
|
||||
osi_free(cb_data.req_data.value);
|
||||
cb_data.req_data.value = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x",
|
||||
@@ -825,6 +830,7 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gatts_listen
|
||||
|
@@ -1159,6 +1159,7 @@ static char *bta_hf_client_skip_unknown(char *buffer)
|
||||
buffer = tmp + 2;
|
||||
|
||||
APPL_TRACE_DEBUG("%s %.*s", __FUNCTION__, buffer - start - 2, start);
|
||||
UNUSED(start);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@@ -308,6 +308,7 @@ static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
tBTM_STATUS status = BTM_ConfigScoPath(BTM_SCO_ROUTE_PCM, NULL, NULL, TRUE);
|
||||
APPL_TRACE_DEBUG("%s close config status = %d", __FUNCTION__, status);
|
||||
UNUSED(status);
|
||||
/* SCO clean up here */
|
||||
bta_hf_client_sco_co_close();
|
||||
#endif
|
||||
@@ -429,7 +430,6 @@ static void bta_hf_client_sco_event(UINT8 event)
|
||||
if (event == BTA_HF_CLIENT_SCO_CI_DATA_E) {
|
||||
uint16_t pkt_offset = 1 + HCI_SCO_PREAMBLE_SIZE;
|
||||
uint16_t len_to_send = 0;
|
||||
uint8_t *p;
|
||||
while (true)
|
||||
{
|
||||
p_buf = osi_malloc(sizeof(BT_HDR) + pkt_offset + BTM_SCO_DATA_SIZE_MAX);
|
||||
@@ -439,13 +439,13 @@ static void bta_hf_client_sco_event(UINT8 event)
|
||||
}
|
||||
|
||||
p_buf->offset = pkt_offset;
|
||||
p_buf->len = BTM_SCO_DATA_SIZE_MAX;
|
||||
len_to_send = bta_hf_client_sco_co_out_data(p_buf->data + pkt_offset, BTM_SCO_DATA_SIZE_MAX);
|
||||
if (len_to_send) {
|
||||
if (len_to_send == BTM_SCO_DATA_SIZE_MAX) {
|
||||
// expect to get the exact size of data from upper layer
|
||||
if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_OPEN_ST) {
|
||||
p = (UINT8 *)(p_buf->data + pkt_offset -1);
|
||||
*p = len_to_send; // set SCO packet length;
|
||||
tBTM_STATUS write_stat = BTM_WriteScoData(p_scb->sco_idx, p_buf);
|
||||
if (write_stat != BTM_SUCCESS && write_stat != BTM_SCO_BAD_LENGTH) {
|
||||
if (write_stat != BTM_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@@ -101,8 +101,10 @@ void bta_hh_api_enable(tBTA_HH_DATA *p_data)
|
||||
bta_hh_le_enable();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* signal BTA call back event */
|
||||
(* bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, (tBTA_HH *)&status);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -901,7 +903,9 @@ void bta_hh_get_dscp_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
bta_hh_le_get_dscp_act(p_cb);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
(*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -934,11 +938,10 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
dev_info.status = BTA_HH_OK;
|
||||
} else
|
||||
#endif
|
||||
|
||||
{
|
||||
if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask, &dev_handle)\
|
||||
== HID_SUCCESS) {
|
||||
dev_info.handle = dev_handle;
|
||||
dev_info.status = BTA_HH_OK;
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* update DI information */
|
||||
@@ -966,6 +969,7 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
|
||||
/* update cb_index[] map */
|
||||
bta_hh_cb.cb_index[dev_handle] = p_cb->index;
|
||||
}
|
||||
}
|
||||
} else { /* device already been added */
|
||||
dev_info.handle = p_cb->hid_handle;
|
||||
dev_info.status = BTA_HH_OK;
|
||||
|
@@ -2183,9 +2183,10 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b
|
||||
case GATT_UUID_HID_BT_KB_INPUT:
|
||||
case GATT_UUID_HID_BT_MOUSE_INPUT:
|
||||
case GATT_UUID_HID_REPORT:
|
||||
if (p_data->status == BTA_GATT_OK)
|
||||
if (p_data->status == BTA_GATT_OK) {
|
||||
p_dev_cb->hid_srvc[hid_inst_id].report[p_dev_cb->clt_cfg_idx].client_cfg_value =
|
||||
BTA_GATT_CLT_CONFIG_NOTIFICATION;
|
||||
}
|
||||
p_dev_cb->clt_cfg_idx ++;
|
||||
bta_hh_le_write_rpt_clt_cfg(p_dev_cb, hid_inst_id);
|
||||
|
||||
|
@@ -75,11 +75,12 @@ UINT8 bta_hh_find_cb(BD_ADDR bda)
|
||||
return xx;
|
||||
}
|
||||
#if BTA_HH_DEBUG
|
||||
else
|
||||
else {
|
||||
APPL_TRACE_DEBUG("in_use ? [%d] kdev[%d].hid_handle = %d state = [%d]",
|
||||
bta_hh_cb.kdev[xx].in_use, xx,
|
||||
bta_hh_cb.kdev[xx].hid_handle,
|
||||
bta_hh_cb.kdev[xx].state);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -123,7 +124,9 @@ void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb)
|
||||
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = BTA_HH_IDX_INVALID;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
/* reset device control block */
|
||||
@@ -486,11 +489,12 @@ UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle)
|
||||
#endif
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* regular HID device checking */
|
||||
if (dev_handle < BTA_HH_MAX_KNOWN ) {
|
||||
index = bta_hh_cb.cb_index[dev_handle];
|
||||
}
|
||||
|
||||
}
|
||||
return index;
|
||||
|
||||
}
|
||||
|
@@ -763,6 +763,7 @@ typedef struct {
|
||||
UINT8 fail_reason; /* The HCI reason/error code for when success=FALSE */
|
||||
tBLE_ADDR_TYPE addr_type; /* Peer device address type */
|
||||
tBT_DEVICE_TYPE dev_type;
|
||||
UINT8 auth_mode;
|
||||
} tBTA_DM_AUTH_CMPL;
|
||||
|
||||
|
||||
@@ -1010,6 +1011,7 @@ typedef struct {
|
||||
#define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */
|
||||
#define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */
|
||||
#define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */
|
||||
#define BTA_DM_INQ_DISCARD_NUM_EVT 7 /* The number of inquiry discarded packets */
|
||||
|
||||
typedef UINT8 tBTA_DM_SEARCH_EVT;
|
||||
|
||||
@@ -1041,6 +1043,11 @@ typedef struct {
|
||||
UINT8 num_resps; /* Number of inquiry responses. */
|
||||
} tBTA_DM_INQ_CMPL;
|
||||
|
||||
/* Structure associated with BTA_DM_INQ_DISCARD_NUM_EVT */
|
||||
typedef struct {
|
||||
UINT32 num_dis; /* The number of inquiry discarded packets. */
|
||||
} tBTA_DM_INQ_DISCARD;
|
||||
|
||||
/* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
@@ -1078,6 +1085,7 @@ typedef union {
|
||||
tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
|
||||
tBTA_DM_DISC_BLE_RES disc_ble_res; /* Discovery result for GATT based service */
|
||||
tBTA_DM_DI_DISC_CMPL di_disc; /* DI discovery result for a peer device */
|
||||
tBTA_DM_INQ_DISCARD inq_dis; /* the discarded packets information of inquiry */
|
||||
} tBTA_DM_SEARCH;
|
||||
|
||||
/* Structure of search callback event and structures */
|
||||
@@ -1560,6 +1568,18 @@ extern void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport);
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBondCancel(BD_ADDR bd_addr);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DMSetPinType
|
||||
**
|
||||
** Description This function sets pin type as BTM_PIN_TYPE_FIXED or BTM_PIN_TYPE_VARIABLE
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DMSetPinType (UINT8 pin_type, UINT8 *pin_code, UINT8 pin_code_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmPinReply
|
||||
@@ -1790,6 +1810,22 @@ extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_B
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleSetStaticPasskey
|
||||
**
|
||||
** Description Set BLE SMP static passkey.
|
||||
**
|
||||
** Parameters: add - add static passkey when add is true
|
||||
** clear static passkey when add is false
|
||||
** passkey - static passkey value
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleSetStaticPasskey(bool add, uint32_t passkey);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmBleConfirmReply
|
||||
@@ -1814,12 +1850,13 @@ extern void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept);
|
||||
**
|
||||
** Parameters: bd_addr - BD address of the peer
|
||||
** dev_type - Remote device's device type.
|
||||
** auth_mode - auth mode
|
||||
** addr_type - LE device address type.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type,
|
||||
extern void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, int auth_mode,
|
||||
tBT_DEVICE_TYPE dev_type);
|
||||
|
||||
|
||||
|
@@ -98,7 +98,7 @@ typedef UINT8 tBTA_AV_HNDL;
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_MAX_SEPS
|
||||
#define BTA_AV_MAX_SEPS 2
|
||||
#define BTA_AV_MAX_SEPS 1
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_MAX_A2DP_MTU
|
||||
@@ -259,7 +259,7 @@ typedef UINT8 tBTA_AV_ERR;
|
||||
|
||||
/* function types for call-out functions */
|
||||
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep);
|
||||
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
|
||||
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
|
||||
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
|
||||
@@ -580,7 +580,7 @@ void BTA_AvDisable(void);
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
|
||||
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos);
|
||||
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos, UINT8 tsep);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@@ -85,7 +85,7 @@ typedef struct {
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info,
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
|
||||
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@@ -190,4 +190,10 @@ extern void bta_dm_co_ble_set_init_key_req(UINT8 init_key);
|
||||
extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
|
||||
|
||||
extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
|
||||
|
||||
extern void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable);
|
||||
|
||||
extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);
|
||||
|
||||
extern UINT8 bta_dm_co_ble_get_auth_req(void);
|
||||
#endif
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include "osi/osi.h"
|
||||
#include "stack/bt_types.h"
|
||||
#include "bta/utl.h"
|
||||
#include "bta/bta_sys.h"
|
||||
@@ -137,7 +138,7 @@ UINT8 bta_jv_alloc_sec_id(void)
|
||||
return ret;
|
||||
|
||||
}
|
||||
static int get_sec_id_used(void)
|
||||
UNUSED_ATTR static int get_sec_id_used(void)
|
||||
{
|
||||
int i;
|
||||
int used = 0;
|
||||
@@ -146,12 +147,13 @@ static int get_sec_id_used(void)
|
||||
used++;
|
||||
}
|
||||
}
|
||||
if (used == BTA_JV_NUM_SERVICE_ID)
|
||||
if (used == BTA_JV_NUM_SERVICE_ID) {
|
||||
APPL_TRACE_ERROR("get_sec_id_used, sec id exceeds the limit:%d",
|
||||
BTA_JV_NUM_SERVICE_ID);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
static int get_rfc_cb_used(void)
|
||||
UNUSED_ATTR static int get_rfc_cb_used(void)
|
||||
{
|
||||
int i;
|
||||
int used = 0;
|
||||
@@ -160,9 +162,10 @@ static int get_rfc_cb_used(void)
|
||||
used++;
|
||||
}
|
||||
}
|
||||
if (used == BTA_JV_MAX_RFC_CONN)
|
||||
if (used == BTA_JV_MAX_RFC_CONN) {
|
||||
APPL_TRACE_ERROR("get_sec_id_used, rfc ctrl block exceeds the limit:%d",
|
||||
BTA_JV_MAX_RFC_CONN);
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@@ -474,19 +477,21 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
||||
< BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si]) {
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]);
|
||||
if (p_pcb) {
|
||||
if (NULL == p_pcb->p_pm_cb)
|
||||
if (NULL == p_pcb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle:"
|
||||
" 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to "
|
||||
"pm_cb?", __func__, jv_handle, p_pcb->port_handle, i);
|
||||
}
|
||||
p_cb = &p_pcb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (jv_handle < BTA_JV_MAX_L2C_CONN) {
|
||||
tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle];
|
||||
if (NULL == p_l2c_cb->p_pm_cb)
|
||||
if (NULL == p_l2c_cb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle: "
|
||||
"0x%x): p_pm_cb: %d: no link to pm_cb?", __func__, jv_handle, i);
|
||||
}
|
||||
p_cb = &p_l2c_cb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
@@ -737,9 +742,10 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
|
||||
bta_jv_cb.scn[channel - 1] = TRUE;
|
||||
scn = (UINT8) channel;
|
||||
}
|
||||
if (bta_jv_cb.p_dm_cback)
|
||||
if (bta_jv_cb.p_dm_cback) {
|
||||
bta_jv_cb.p_dm_cback(BTA_JV_GET_SCN_EVT, (tBTA_JV *)&scn,
|
||||
p_data->alloc_channel.user_data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case BTA_JV_CONN_TYPE_L2CAP:
|
||||
@@ -958,6 +964,14 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
stage = "profile_descriptor_list";
|
||||
if (!SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_SERIAL_PORT, SPP_VERSION)){
|
||||
APPL_TRACE_ERROR("create_base_record: failed to create base service "
|
||||
"record, stage: %s, scn: %d, name: %s, with_obex: %d",
|
||||
stage, channel, name, with_obex);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Add the name to the SDP record.
|
||||
if (name[0] != '\0') {
|
||||
stage = "service_name";
|
||||
@@ -985,6 +999,9 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
|
||||
APPL_TRACE_DEBUG("create_base_record: successfully created base service "
|
||||
"record, handle: 0x%08x, scn: %d, name: %s, with_obex: %d",
|
||||
sdp_handle, channel, name, with_obex);
|
||||
|
||||
UNUSED(stage);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1018,6 +1035,8 @@ static int add_spp_sdp(const char *name, const int channel) {
|
||||
|
||||
APPL_TRACE_DEBUG("add_spp_sdp: service registered successfully, "
|
||||
"service_name: %s, handle 0x%08x)", name, handle);
|
||||
UNUSED(stage);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -1510,6 +1529,7 @@ static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len,
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(port_handle);
|
||||
int ret = 0;
|
||||
APPL_TRACE_DEBUG("%s, p_cb:%p, p_pcb:%p, len:%d, type:%d", __func__, p_cb, p_pcb, len, type);
|
||||
UNUSED(p_cb);
|
||||
if (p_pcb != NULL) {
|
||||
switch (type) {
|
||||
case DATA_CO_CALLBACK_TYPE_INCOMING:
|
||||
|
@@ -37,6 +37,8 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
#define SPP_VERSION 0x0102
|
||||
|
||||
enum {
|
||||
/* these events are handled by the state machine */
|
||||
BTA_JV_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_JV),
|
||||
|
@@ -29,6 +29,8 @@
|
||||
static void _btc_storage_save(void)
|
||||
{
|
||||
uint16_t addr_section_count = 0;
|
||||
bt_bdaddr_t bd_addr;
|
||||
uint32_t device_type = 0;
|
||||
const btc_config_section_iter_t *need_remove_iter = NULL;
|
||||
const btc_config_section_iter_t *iter = btc_config_section_begin();
|
||||
|
||||
@@ -36,12 +38,9 @@ static void _btc_storage_save(void)
|
||||
//store the next iter, if remove section, then will not loss the point
|
||||
|
||||
const char *section = btc_config_section_name(iter);
|
||||
if (!string_is_bdaddr(section)) {
|
||||
iter = btc_config_section_next(iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!btc_config_exist(section, BTC_BLE_STORAGE_DEV_TYPE_STR) &&
|
||||
if (string_is_bdaddr(section) &&
|
||||
!btc_config_exist(section, BTC_BLE_STORAGE_DEV_TYPE_STR) &&
|
||||
!btc_config_exist(section, BTC_BLE_STORAGE_ADDR_TYPE_STR) &&
|
||||
!btc_config_exist(section, BTC_BLE_STORAGE_LINK_KEY_STR) &&
|
||||
!btc_config_exist(section, BTC_BLE_STORAGE_LE_KEY_PENC_STR) &&
|
||||
@@ -53,6 +52,14 @@ static void _btc_storage_save(void)
|
||||
btc_config_remove_section(section);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!string_is_bdaddr(section) ||
|
||||
!btc_config_get_int(section, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type) ||
|
||||
((device_type & BT_DEVICE_TYPE_BLE) != BT_DEVICE_TYPE_BLE)) {
|
||||
iter = btc_config_section_next(iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(addr_section_count == BONED_DEVICES_MAX_COUNT) {
|
||||
need_remove_iter = iter;
|
||||
}
|
||||
@@ -63,13 +70,20 @@ static void _btc_storage_save(void)
|
||||
if (need_remove_iter) {
|
||||
while(need_remove_iter != btc_config_section_end()) {
|
||||
const char *need_remove_section = btc_config_section_name(need_remove_iter);
|
||||
if (!string_is_bdaddr(need_remove_section)) {
|
||||
if (!string_is_bdaddr(need_remove_section) ||
|
||||
!btc_config_get_int(need_remove_section, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type) ||
|
||||
((device_type & BT_DEVICE_TYPE_BLE) != BT_DEVICE_TYPE_BLE)) {
|
||||
need_remove_iter = btc_config_section_next(need_remove_iter);
|
||||
continue;
|
||||
}
|
||||
need_remove_iter = btc_config_section_next(need_remove_iter);
|
||||
BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section);
|
||||
btc_config_remove_section(need_remove_section);
|
||||
//delete device info
|
||||
string_to_bdaddr(need_remove_section, &bd_addr);
|
||||
BTM_SecDeleteDevice(bd_addr.address, BT_TRANSPORT_LE);
|
||||
//delet config info
|
||||
if(btc_config_remove_section(need_remove_section)) {
|
||||
BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section);
|
||||
}
|
||||
}
|
||||
}
|
||||
btc_config_flush();
|
||||
@@ -228,6 +242,9 @@ static bt_status_t _btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_a
|
||||
if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_LCSRK_STR)) {
|
||||
ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_LCSRK_STR);
|
||||
}
|
||||
if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_LID_STR)) {
|
||||
ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_LID_STR);
|
||||
}
|
||||
//here don't remove section, because config_save will check it
|
||||
_btc_storage_save();
|
||||
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
|
||||
@@ -536,6 +553,91 @@ bt_status_t btc_storage_remove_ble_dev_type(bt_bdaddr_t *remote_bd_addr, bool fl
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bt_status_t _btc_storage_set_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, uint8_t auth_mode, bool flush)
|
||||
{
|
||||
int ret;
|
||||
bdstr_t bdstr;
|
||||
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr_t));
|
||||
ret = btc_config_set_int(bdstr, BTC_BLE_STORAGE_LE_AUTH_MODE_STR, (int)auth_mode);
|
||||
if (ret == false) {
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
_btc_storage_save();
|
||||
}
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bt_status_t btc_storage_set_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, uint8_t auth_mode, bool flush)
|
||||
{
|
||||
bt_status_t ret;
|
||||
|
||||
btc_config_lock();
|
||||
ret = _btc_storage_set_ble_dev_auth_mode(remote_bd_addr, auth_mode, flush);
|
||||
btc_config_unlock();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bt_status_t _btc_storage_get_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, int* auth_mode)
|
||||
{
|
||||
bdstr_t bdstr;
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||
int ret = btc_config_get_int(bdstr, BTC_BLE_STORAGE_LE_AUTH_MODE_STR, auth_mode);
|
||||
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
bt_status_t btc_storage_get_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, int* auth_mode)
|
||||
{
|
||||
bt_status_t ret;
|
||||
|
||||
btc_config_lock();
|
||||
ret = _btc_storage_get_ble_dev_auth_mode(remote_bd_addr, auth_mode);
|
||||
btc_config_unlock();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bt_status_t _btc_storage_remove_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, bool flush)
|
||||
{
|
||||
bool ret = true;
|
||||
bdstr_t bdstr;
|
||||
uint32_t auth_mode = 0;
|
||||
|
||||
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
|
||||
|
||||
ret = btc_config_get_int(bdstr, BTC_BLE_STORAGE_LE_AUTH_MODE_STR, (int *)&auth_mode);
|
||||
if (ret == false) {
|
||||
//cannot find the key, just return SUCCESS, indicate already removed
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
ret = btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_AUTH_MODE_STR);
|
||||
if (ret == false) {
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
_btc_storage_save();
|
||||
}
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bt_status_t btc_storage_remove_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, bool flush)
|
||||
{
|
||||
bt_status_t ret;
|
||||
|
||||
btc_config_lock();
|
||||
ret = _btc_storage_remove_ble_dev_auth_mode(remote_bd_addr, flush);
|
||||
btc_config_unlock();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bt_status_t _btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, uint8_t addr_type, bool flush)
|
||||
{
|
||||
int ret;
|
||||
@@ -640,11 +742,17 @@ static void _btc_read_le_key(const uint8_t key_type, const size_t key_len, bt_bd
|
||||
bdcpy(bta_bd_addr, bd_addr.address);
|
||||
|
||||
if (!*device_added) {
|
||||
BTA_DmAddBleDevice(bta_bd_addr, addr_type, BT_DEVICE_TYPE_BLE);
|
||||
int auth_mode = 0;
|
||||
if(_btc_storage_get_ble_dev_auth_mode(&bd_addr, &auth_mode) != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_WARNING("%s Failed to get auth mode from flash, please erase flash and download the firmware again", __func__);
|
||||
}
|
||||
BTA_DmAddBleDevice(bta_bd_addr, addr_type, auth_mode, BT_DEVICE_TYPE_BLE);
|
||||
*device_added = true;
|
||||
}
|
||||
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bd_str[20] = {0};
|
||||
#endif
|
||||
BTC_TRACE_DEBUG("%s() Adding key type %d for %s", __func__,
|
||||
key_type, bdaddr_to_string(&bd_addr, bd_str, sizeof(bd_str)));
|
||||
BTA_DmAddBleKey(bta_bd_addr, (tBTA_LE_KEY_VALUE *)buffer, key_type);
|
||||
@@ -750,7 +858,6 @@ bt_status_t btc_storage_load_bonded_ble_devices(void)
|
||||
bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev, int dev_num)
|
||||
{
|
||||
bt_bdaddr_t bd_addr;
|
||||
uint32_t device_type = 0;
|
||||
char buffer[sizeof(tBTM_LE_KEY_VALUE)] = {0};
|
||||
|
||||
btc_config_lock();
|
||||
@@ -760,12 +867,13 @@ bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev
|
||||
if (dev_num-- <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint32_t device_type = 0;
|
||||
const char *name = btc_config_section_name(iter);
|
||||
|
||||
if (!string_is_bdaddr(name) ||
|
||||
!btc_config_get_int(name, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type) ||
|
||||
!(device_type & BT_DEVICE_TYPE_BLE)) {
|
||||
dev_num ++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ static btc_dm_local_key_cb_t ble_local_key_cb;
|
||||
** Externs
|
||||
******************************************************************************/
|
||||
#if BTC_AV_INCLUDED
|
||||
extern bt_status_t btc_av_execute_service(BOOLEAN b_enable);
|
||||
extern bt_status_t btc_av_source_execute_service(BOOLEAN b_enable);
|
||||
extern bt_status_t btc_av_sink_execute_service(BOOLEAN b_enable);
|
||||
#endif
|
||||
#if BTC_HF_CLIENT_INCLUDED
|
||||
@@ -176,13 +176,14 @@ static void btc_dm_remove_ble_bonding_keys(void)
|
||||
bdcpy(bd_addr.address, pairing_cb.bd_addr);
|
||||
|
||||
btc_storage_remove_remote_addr_type(&bd_addr, false);
|
||||
btc_storage_remove_ble_dev_auth_mode(&bd_addr, false);
|
||||
btc_storage_remove_ble_dev_type(&bd_addr, false);
|
||||
btc_storage_remove_ble_bonding_keys(&bd_addr);
|
||||
}
|
||||
|
||||
static void btc_dm_save_ble_bonding_keys(void)
|
||||
{
|
||||
if(!(pairing_cb.ble.is_penc_key_rcvd || pairing_cb.ble.is_pid_key_rcvd || pairing_cb.ble.is_pcsrk_key_rcvd ||
|
||||
if (!(pairing_cb.ble.is_penc_key_rcvd || pairing_cb.ble.is_pid_key_rcvd || pairing_cb.ble.is_pcsrk_key_rcvd ||
|
||||
pairing_cb.ble.is_lenc_key_rcvd || pairing_cb.ble.is_lcsrk_key_rcvd || pairing_cb.ble.is_lidk_key_rcvd)) {
|
||||
return ;
|
||||
}
|
||||
@@ -197,6 +198,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
(char *) &pairing_cb.ble.penc_key,
|
||||
BTM_LE_KEY_PENC,
|
||||
sizeof(tBTM_LE_PENC_KEYS));
|
||||
pairing_cb.ble.is_penc_key_rcvd = false;
|
||||
}
|
||||
|
||||
if (pairing_cb.ble.is_pid_key_rcvd) {
|
||||
@@ -204,6 +206,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
(char *) &pairing_cb.ble.pid_key,
|
||||
BTM_LE_KEY_PID,
|
||||
sizeof(tBTM_LE_PID_KEYS));
|
||||
pairing_cb.ble.is_pid_key_rcvd = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,6 +215,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
(char *) &pairing_cb.ble.pcsrk_key,
|
||||
BTM_LE_KEY_PCSRK,
|
||||
sizeof(tBTM_LE_PCSRK_KEYS));
|
||||
pairing_cb.ble.is_pcsrk_key_rcvd = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,6 +224,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
(char *) &pairing_cb.ble.lenc_key,
|
||||
BTM_LE_KEY_LENC,
|
||||
sizeof(tBTM_LE_LENC_KEYS));
|
||||
pairing_cb.ble.is_lenc_key_rcvd = false;
|
||||
}
|
||||
|
||||
if (pairing_cb.ble.is_lcsrk_key_rcvd) {
|
||||
@@ -227,6 +232,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
(char *) &pairing_cb.ble.lcsrk_key,
|
||||
BTM_LE_KEY_LCSRK,
|
||||
sizeof(tBTM_LE_LCSRK_KEYS));
|
||||
pairing_cb.ble.is_lcsrk_key_rcvd = false;
|
||||
}
|
||||
|
||||
if (pairing_cb.ble.is_lidk_key_rcvd) {
|
||||
@@ -234,6 +240,7 @@ static void btc_dm_save_ble_bonding_keys(void)
|
||||
NULL,
|
||||
BTM_LE_KEY_LID,
|
||||
0);
|
||||
pairing_cb.ble.is_lidk_key_rcvd = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,9 +262,14 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
BTC_TRACE_DEBUG ("%s, - pairing_cb.bd_addr: %08x%04x", __func__,
|
||||
(pairing_cb.bd_addr[0] << 24) + (pairing_cb.bd_addr[1] << 16) + (pairing_cb.bd_addr[2] << 8) + pairing_cb.bd_addr[3],
|
||||
(pairing_cb.bd_addr[4] << 8) + pairing_cb.bd_addr[5]);
|
||||
// Check if need to save BLE keys
|
||||
if((p_auth_cmpl->auth_mode & SMP_AUTH_GEN_BOND) == 0) {
|
||||
return;
|
||||
}
|
||||
if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) {
|
||||
btc_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type, true);
|
||||
}
|
||||
btc_storage_set_ble_dev_auth_mode(&bdaddr, p_auth_cmpl->auth_mode, true);
|
||||
btc_dm_save_ble_bonding_keys();
|
||||
} else {
|
||||
/*Map the HCI fail reason to bt status */
|
||||
@@ -278,6 +290,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
|
||||
}
|
||||
|
||||
#if (CONFIG_BT_STACK_NO_LOG)
|
||||
(void) status;
|
||||
#endif
|
||||
BTC_TRACE_DEBUG("%s, authentication status = %x", __func__, status);
|
||||
return;
|
||||
|
||||
@@ -379,6 +394,27 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
(void) status;
|
||||
}
|
||||
|
||||
static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
|
||||
{
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
esp_bt_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_PIN_REQ_EVT;
|
||||
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
|
||||
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
|
||||
{
|
||||
return btc_enabled_services;
|
||||
@@ -397,7 +433,7 @@ static bt_status_t btc_in_execute_service_request(tBTA_SERVICE_ID service_id,
|
||||
switch (service_id) {
|
||||
#if BTC_AV_INCLUDED
|
||||
case BTA_A2DP_SOURCE_SERVICE_ID:
|
||||
btc_av_execute_service(b_enable);
|
||||
btc_av_source_execute_service(b_enable);
|
||||
break;
|
||||
case BTA_A2DP_SINK_SERVICE_ID:
|
||||
btc_av_sink_execute_service(b_enable);
|
||||
@@ -488,6 +524,8 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
case BTA_DM_PIN_REQ_EVT:
|
||||
BTC_TRACE_DEBUG("BTA_DM_PIN_REQ_EVT");
|
||||
btc_dm_pin_req_evt(&p_data->pin_req);
|
||||
break;
|
||||
case BTA_DM_AUTH_CMPL_EVT:
|
||||
btc_dm_auth_cmpl_evt(&p_data->auth_cmpl);
|
||||
@@ -522,6 +560,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
//remove the bonded key in the config and nvs flash.
|
||||
btc_storage_remove_ble_dev_type(&bd_addr, false);
|
||||
btc_storage_remove_remote_addr_type(&bd_addr, false);
|
||||
btc_storage_remove_ble_dev_auth_mode(&bd_addr, false);
|
||||
param.remove_bond_dev_cmpl.status = btc_storage_remove_ble_bonding_keys(&bd_addr);
|
||||
}
|
||||
ble_msg.act = ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT;
|
||||
@@ -555,6 +594,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
param.ble_security.auth_cmpl.key_present = p_data->auth_cmpl.key_present;
|
||||
memcpy(param.ble_security.auth_cmpl.bd_addr, p_data->auth_cmpl.bd_addr, sizeof(BD_ADDR));
|
||||
memcpy(param.ble_security.auth_cmpl.key, p_data->auth_cmpl.key, sizeof(LINK_KEY));
|
||||
param.ble_security.auth_cmpl.auth_mode = p_data->auth_cmpl.auth_mode;
|
||||
btc_dm_ble_auth_cmpl_evt(&p_data->auth_cmpl);
|
||||
break;
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ static void btc_init_bluetooth(void)
|
||||
bte_main_boot_entry(btc_init_callback);
|
||||
#if (SMP_INCLUDED)
|
||||
btc_config_init();
|
||||
//load the ble local key whitch has been store in the flash
|
||||
//load the ble local key which has been stored in the flash
|
||||
btc_dm_load_ble_local_keys();
|
||||
#endif /* #if (SMP_INCLUDED) */
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#define BTC_BLE_STORAGE_LE_KEY_LENC_STR "LE_KEY_LENC"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_LID_STR "LE_KEY_LID"
|
||||
#define BTC_BLE_STORAGE_LE_KEY_LCSRK_STR "LE_KEY_LCSRK"
|
||||
#define BTC_BLE_STORAGE_LE_AUTH_MODE_STR "AuthMode"
|
||||
|
||||
#define BTC_BLE_STORAGE_LOCAL_ADAPTER_STR "Adapter"
|
||||
#define BTC_BLE_STORAGE_LE_LOCAL_KEY_IR_STR "LE_LOCAL_KEY_IR"
|
||||
@@ -66,6 +67,12 @@ bt_status_t btc_storage_remove_ble_local_keys(void);
|
||||
|
||||
bt_status_t btc_storage_get_ble_local_key(uint8_t key_type, char *key_value, int key_len);
|
||||
|
||||
bt_status_t btc_storage_set_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, uint8_t auth_mode, bool flush);
|
||||
|
||||
bt_status_t btc_storage_get_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, int* auth_mode);
|
||||
|
||||
bt_status_t btc_storage_remove_ble_dev_auth_mode(bt_bdaddr_t *remote_bd_addr, bool flush);
|
||||
|
||||
bt_status_t btc_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr, int *addr_type);
|
||||
|
||||
bt_status_t btc_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, uint8_t addr_type, bool flush);
|
||||
|
@@ -170,6 +170,14 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
status, &rsp);
|
||||
|
||||
if(status != GATT_SUCCESS) {
|
||||
if (blufi_env.prepare_buf) {
|
||||
osi_free(blufi_env.prepare_buf);
|
||||
blufi_env.prepare_buf = NULL;
|
||||
}
|
||||
BLUFI_TRACE_ERROR("write data error , error code 0x%x\n", status);
|
||||
return;
|
||||
}
|
||||
memcpy(blufi_env.prepare_buf + p_data->req_data.p_data->write_req.offset,
|
||||
p_data->req_data.p_data->write_req.value,
|
||||
p_data->req_data.p_data->write_req.len);
|
||||
@@ -194,7 +202,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
GATT_SUCCESS, NULL);
|
||||
|
||||
if (p_data->req_data.p_data->exec_write == GATT_PREP_WRITE_EXEC) {
|
||||
if (blufi_env.prepare_buf && p_data->req_data.p_data->exec_write == GATT_PREP_WRITE_EXEC) {
|
||||
btc_blufi_recv_handler(blufi_env.prepare_buf, blufi_env.prepare_len);
|
||||
}
|
||||
|
||||
@@ -206,13 +214,10 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
break;
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
BLUFI_TRACE_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu);
|
||||
blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE;
|
||||
blufi_env.frag_size = (p_data->req_data.p_data->mtu < BLUFI_MAX_DATA_LEN ? p_data->req_data.p_data->mtu : BLUFI_MAX_DATA_LEN) - BLUFI_MTU_RESERVED_SIZE;
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
BLUFI_TRACE_DEBUG("CONIRM EVT\n");
|
||||
if (p_data && p_data->req_data.value){
|
||||
osi_free(p_data->req_data.value);
|
||||
}
|
||||
BLUFI_TRACE_DEBUG("CONFIRM EVT\n");
|
||||
/* Nothing */
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
|
@@ -72,6 +72,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
|
||||
#define BLUFI_DATA_SEC_MODE_ENC_MASK 0x02
|
||||
#define BLUFI_CTRL_SEC_MODE_CHECK_MASK 0x10
|
||||
#define BLUFI_CTRL_SEC_MODE_ENC_MASK 0x20
|
||||
#define BLUFI_MAX_DATA_LEN 255
|
||||
|
||||
// packet type
|
||||
#define BLUFI_TYPE_MASK 0x03
|
||||
|
@@ -267,11 +267,11 @@ static tBTA_AV_CO_PEER *bta_av_co_get_peer(tBTA_AV_HNDL hndl)
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_num_protect,
|
||||
UINT8 *p_protect_info, UINT8 index)
|
||||
UINT8 *p_protect_info, UINT8 tsep)
|
||||
{
|
||||
FUNC_TRACE();
|
||||
|
||||
APPL_TRACE_DEBUG("bta_av_co_audio_init: %d", index);
|
||||
APPL_TRACE_DEBUG("bta_av_co_audio_init: %d", tsep);
|
||||
|
||||
/* By default - no content protection info */
|
||||
*p_num_protect = 0;
|
||||
@@ -280,29 +280,24 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_
|
||||
/* reset remote preference through setconfig */
|
||||
bta_av_co_cb.codec_cfg_setconfig.id = BTC_AV_CODEC_NONE;
|
||||
|
||||
switch (index) {
|
||||
case BTC_SV_AV_AA_SBC_INDEX:
|
||||
if (tsep == AVDT_TSEP_SRC) {
|
||||
#if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE)
|
||||
{
|
||||
UINT8 *p = p_protect_info;
|
||||
do {
|
||||
UINT8 *p = p_protect_info;
|
||||
|
||||
/* Content protection info - support SCMS-T */
|
||||
*p_num_protect = 1;
|
||||
*p++ = BTA_AV_CP_LOSC;
|
||||
UINT16_TO_STREAM(p, BTA_AV_CP_SCMS_T_ID);
|
||||
|
||||
}
|
||||
/* Content protection info - support SCMS-T */
|
||||
*p_num_protect = 1;
|
||||
*p++ = BTA_AV_CP_LOSC;
|
||||
UINT16_TO_STREAM(p, BTA_AV_CP_SCMS_T_ID);
|
||||
} while (0);
|
||||
#endif
|
||||
/* Set up for SBC codec for SRC*/
|
||||
*p_codec_type = BTA_AV_CODEC_SBC;
|
||||
*p_codec_type = BTA_AV_CODEC_SBC;
|
||||
|
||||
/* This should not fail because we are using constants for parameters */
|
||||
A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &bta_av_co_sbc_caps, p_codec_info);
|
||||
|
||||
/* Codec is valid */
|
||||
return TRUE;
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
case BTC_SV_AV_AA_SBC_SINK_INDEX:
|
||||
A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &bta_av_co_sbc_caps, p_codec_info);
|
||||
return TRUE;
|
||||
} else if (tsep == AVDT_TSEP_SNK) {
|
||||
*p_codec_type = BTA_AV_CODEC_SBC;
|
||||
|
||||
/* This should not fail because we are using constants for parameters */
|
||||
@@ -310,9 +305,8 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_
|
||||
|
||||
/* Codec is valid */
|
||||
return TRUE;
|
||||
#endif
|
||||
default:
|
||||
/* Not valid */
|
||||
} else {
|
||||
APPL_TRACE_WARNING("invalid SEP type %d", tsep);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@@ -143,9 +143,21 @@ static inline void btc_a2d_data_cb_to_app(const uint8_t *data, uint32_t len)
|
||||
}
|
||||
}
|
||||
|
||||
OI_CODEC_SBC_DECODER_CONTEXT context;
|
||||
OI_UINT32 contextData[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
|
||||
OI_INT16 pcmData[15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS];
|
||||
#define BTC_SBC_DEC_CONTEXT_DATA_LEN (CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS))
|
||||
#define BTC_SBC_DEC_PCM_DATA_LEN (15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS)
|
||||
|
||||
#if BTC_SBC_DEC_DYNAMIC_MEMORY == FALSE
|
||||
static OI_CODEC_SBC_DECODER_CONTEXT btc_sbc_decoder_context;
|
||||
static OI_UINT32 btc_sbc_decoder_context_data[BTC_SBC_DEC_CONTEXT_DATA_LEN];
|
||||
static OI_INT16 btc_sbc_pcm_data[BTC_SBC_DEC_PCM_DATA_LEN];
|
||||
#else
|
||||
static OI_CODEC_SBC_DECODER_CONTEXT *btc_sbc_decoder_context_ptr;
|
||||
static OI_UINT32 *btc_sbc_decoder_context_data;
|
||||
static OI_INT16 *btc_sbc_pcm_data;
|
||||
#define btc_sbc_decoder_context (*btc_sbc_decoder_context_ptr)
|
||||
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == FALSE */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Misc helper functions
|
||||
@@ -235,6 +247,16 @@ bool btc_a2dp_sink_startup(void)
|
||||
|
||||
APPL_TRACE_EVENT("## A2DP SINK START MEDIA THREAD ##");
|
||||
|
||||
#if (BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE)
|
||||
btc_sbc_decoder_context_ptr = osi_calloc(sizeof(OI_CODEC_SBC_DECODER_CONTEXT));
|
||||
btc_sbc_decoder_context_data = osi_calloc(BTC_SBC_DEC_CONTEXT_DATA_LEN * sizeof(OI_UINT32));
|
||||
btc_sbc_pcm_data = osi_calloc(BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16));
|
||||
if (!btc_sbc_decoder_context_ptr || !btc_sbc_decoder_context_data || !btc_sbc_pcm_data) {
|
||||
APPL_TRACE_ERROR("failed to allocate SBC decoder");
|
||||
goto error_exit;
|
||||
}
|
||||
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE */
|
||||
|
||||
btc_aa_snk_queue_set = xQueueCreateSet(BTC_A2DP_SINK_TASK_QUEUE_SET_LEN);
|
||||
configASSERT(btc_aa_snk_queue_set);
|
||||
btc_aa_snk_data_queue = xQueueCreate(BTC_A2DP_SINK_DATA_QUEUE_LEN, sizeof(int32_t));
|
||||
@@ -280,6 +302,21 @@ error_exit:;
|
||||
vQueueDelete(btc_aa_snk_queue_set);
|
||||
btc_aa_snk_queue_set = NULL;
|
||||
}
|
||||
#if (BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE)
|
||||
if (btc_sbc_decoder_context_ptr) {
|
||||
osi_free(btc_sbc_decoder_context_ptr);
|
||||
btc_sbc_decoder_context_ptr = NULL;
|
||||
}
|
||||
if (btc_sbc_decoder_context_data) {
|
||||
osi_free(btc_sbc_decoder_context_data);
|
||||
btc_sbc_decoder_context_data = NULL;
|
||||
}
|
||||
if (btc_sbc_pcm_data) {
|
||||
osi_free(btc_sbc_pcm_data);
|
||||
btc_sbc_pcm_data = NULL;
|
||||
}
|
||||
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE */
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -306,6 +343,17 @@ void btc_a2dp_sink_shutdown(void)
|
||||
|
||||
vQueueDelete(btc_aa_snk_queue_set);
|
||||
btc_aa_snk_queue_set = NULL;
|
||||
|
||||
#if (BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE)
|
||||
osi_free(btc_sbc_decoder_context_ptr);
|
||||
btc_sbc_decoder_context_ptr = NULL;
|
||||
|
||||
osi_free(btc_sbc_decoder_context_data);
|
||||
btc_sbc_decoder_context_data = NULL;
|
||||
|
||||
osi_free(btc_sbc_pcm_data);
|
||||
btc_sbc_pcm_data = NULL;
|
||||
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE */
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -467,7 +515,8 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
|
||||
|
||||
btc_aa_snk_cb.rx_flush = FALSE;
|
||||
APPL_TRACE_EVENT("Reset to sink role");
|
||||
status = OI_CODEC_SBC_DecoderReset(&context, contextData, sizeof(contextData), 2, 2, FALSE);
|
||||
status = OI_CODEC_SBC_DecoderReset(&btc_sbc_decoder_context, btc_sbc_decoder_context_data,
|
||||
BTC_SBC_DEC_CONTEXT_DATA_LEN * sizeof(OI_UINT32), 2, 2, FALSE);
|
||||
if (!OI_SUCCESS(status)) {
|
||||
APPL_TRACE_ERROR("OI_CODEC_SBC_DecoderReset failed with error code %d\n", status);
|
||||
}
|
||||
@@ -566,6 +615,7 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
|
||||
|
||||
int frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
|
||||
APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", frames_to_process);
|
||||
UNUSED(frames_to_process);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -582,11 +632,11 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
|
||||
UINT8 *sbc_start_frame = ((UINT8 *)(p_msg + 1) + p_msg->offset + 1);
|
||||
int count;
|
||||
UINT32 pcmBytes, availPcmBytes;
|
||||
OI_INT16 *pcmDataPointer = pcmData; /*Will be overwritten on next packet receipt*/
|
||||
OI_INT16 *pcmDataPointer = btc_sbc_pcm_data; /*Will be overwritten on next packet receipt*/
|
||||
OI_STATUS status;
|
||||
int num_sbc_frames = p_msg->num_frames_to_be_processed;
|
||||
UINT32 sbc_frame_len = p_msg->len - 1;
|
||||
availPcmBytes = 2 * sizeof(pcmData);
|
||||
availPcmBytes = BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16);
|
||||
|
||||
/* XXX: Check if the below check is correct, we are checking for peer to be sink when we are sink */
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK || (btc_aa_snk_cb.rx_flush)) {
|
||||
@@ -603,7 +653,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
|
||||
|
||||
for (count = 0; count < num_sbc_frames && sbc_frame_len != 0; count ++) {
|
||||
pcmBytes = availPcmBytes;
|
||||
status = OI_CODEC_SBC_DecodeFrame(&context, (const OI_BYTE **)&sbc_start_frame,
|
||||
status = OI_CODEC_SBC_DecodeFrame(&btc_sbc_decoder_context, (const OI_BYTE **)&sbc_start_frame,
|
||||
(OI_UINT32 *)&sbc_frame_len,
|
||||
(OI_INT16 *)pcmDataPointer,
|
||||
(OI_UINT32 *)&pcmBytes);
|
||||
@@ -617,7 +667,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
|
||||
p_msg->len = sbc_frame_len + 1;
|
||||
}
|
||||
|
||||
btc_a2d_data_cb_to_app((uint8_t *)pcmData, (2 * sizeof(pcmData) - availPcmBytes));
|
||||
btc_a2d_data_cb_to_app((uint8_t *)btc_sbc_pcm_data, (BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16) - availPcmBytes));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@@ -156,7 +156,6 @@ typedef struct {
|
||||
tBTC_AV_FEEDING_MODE feeding_mode;
|
||||
tBTC_AV_MEDIA_FEEDINGS_STATE media_feeding_state;
|
||||
tBTC_AV_MEDIA_FEEDINGS media_feeding;
|
||||
SBC_ENC_PARAMS encoder;
|
||||
osi_alarm_t *media_alarm;
|
||||
} tBTC_A2DP_SOURCE_CB;
|
||||
|
||||
@@ -187,6 +186,13 @@ static QueueSetHandle_t btc_aa_src_queue_set;
|
||||
static esp_a2d_source_data_cb_t btc_aa_src_data_cb = NULL;
|
||||
static UINT64 last_frame_us = 0;
|
||||
|
||||
#if BTC_SBC_ENC_DYNAMIC_MEMORY == FALSE
|
||||
static SBC_ENC_PARAMS btc_sbc_encoder;
|
||||
#else
|
||||
static SBC_ENC_PARAMS *btc_sbc_encoder_ptr;
|
||||
#define btc_sbc_encoder (*btc_sbc_encoder_ptr)
|
||||
#endif /* BTC_SBC_ENC_DYNAMIC_MEMORY == FALSE */
|
||||
|
||||
void btc_a2dp_src_reg_data_cb(esp_a2d_source_data_cb_t callback)
|
||||
{
|
||||
// todo: critical section protection
|
||||
@@ -310,6 +316,14 @@ bool btc_a2dp_source_startup(void)
|
||||
|
||||
APPL_TRACE_EVENT("## A2DP SOURCE START MEDIA THREAD ##");
|
||||
|
||||
#if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE
|
||||
btc_sbc_encoder_ptr = osi_calloc(sizeof(SBC_ENC_PARAMS));
|
||||
if (!btc_sbc_encoder_ptr) {
|
||||
APPL_TRACE_ERROR("failed to allocate SBC encoder");
|
||||
goto error_exit;
|
||||
}
|
||||
#endif /* #if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE */
|
||||
|
||||
btc_aa_src_queue_set = xQueueCreateSet(BTC_A2DP_SOURCE_TASK_QUEUE_SET_LEN);
|
||||
configASSERT(btc_aa_src_queue_set);
|
||||
btc_aa_src_data_queue = xQueueCreate(BTC_A2DP_SOURCE_DATA_QUEUE_LEN, sizeof(void *));
|
||||
@@ -355,6 +369,12 @@ error_exit:;
|
||||
vQueueDelete(btc_aa_src_queue_set);
|
||||
btc_aa_src_queue_set = NULL;
|
||||
}
|
||||
#if (BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE)
|
||||
if (btc_sbc_encoder_ptr) {
|
||||
osi_free(btc_sbc_encoder_ptr);
|
||||
btc_sbc_encoder_ptr = NULL;
|
||||
}
|
||||
#endif /* #if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -381,6 +401,11 @@ void btc_a2dp_source_shutdown(void)
|
||||
|
||||
vQueueDelete(btc_aa_src_queue_set);
|
||||
btc_aa_src_queue_set = NULL;
|
||||
|
||||
#if (BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE)
|
||||
osi_free(btc_sbc_encoder_ptr);
|
||||
btc_sbc_encoder_ptr = NULL;
|
||||
#endif /* #if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE */
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@@ -470,10 +495,11 @@ static UINT64 time_now_us()
|
||||
static void log_tstamps_us(char *comment)
|
||||
{
|
||||
static UINT64 prev_us = 0;
|
||||
const UINT64 now_us = time_now_us();
|
||||
UINT64 now_us = time_now_us();
|
||||
APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, now_us - prev_us,
|
||||
fixed_queue_length(btc_aa_src_cb.TxAaQ));
|
||||
prev_us = now_us;
|
||||
UNUSED(prev_us);
|
||||
}
|
||||
|
||||
/* when true media task discards any tx frames */
|
||||
@@ -794,13 +820,14 @@ static void btc_a2dp_source_enc_init(BT_HDR *p_msg)
|
||||
btc_aa_src_cb.timestamp = 0;
|
||||
|
||||
/* SBC encoder config (enforced even if not used) */
|
||||
btc_aa_src_cb.encoder.s16ChannelMode = pInitAudio->ChannelMode;
|
||||
btc_aa_src_cb.encoder.s16NumOfSubBands = pInitAudio->NumOfSubBands;
|
||||
btc_aa_src_cb.encoder.s16NumOfBlocks = pInitAudio->NumOfBlocks;
|
||||
btc_aa_src_cb.encoder.s16AllocationMethod = pInitAudio->AllocationMethod;
|
||||
btc_aa_src_cb.encoder.s16SamplingFreq = pInitAudio->SamplingFreq;
|
||||
|
||||
btc_aa_src_cb.encoder.u16BitRate = btc_a2dp_source_get_sbc_rate();
|
||||
btc_sbc_encoder.s16ChannelMode = pInitAudio->ChannelMode;
|
||||
btc_sbc_encoder.s16NumOfSubBands = pInitAudio->NumOfSubBands;
|
||||
btc_sbc_encoder.s16NumOfBlocks = pInitAudio->NumOfBlocks;
|
||||
btc_sbc_encoder.s16AllocationMethod = pInitAudio->AllocationMethod;
|
||||
btc_sbc_encoder.s16SamplingFreq = pInitAudio->SamplingFreq;
|
||||
|
||||
btc_sbc_encoder.u16BitRate = btc_a2dp_source_get_sbc_rate();
|
||||
|
||||
/* Default transcoding is PCM to SBC, modified by feeding configuration */
|
||||
btc_aa_src_cb.TxTranscoding = BTC_MEDIA_TRSCD_PCM_2_SBC;
|
||||
@@ -811,14 +838,14 @@ static void btc_a2dp_source_enc_init(BT_HDR *p_msg)
|
||||
APPL_TRACE_EVENT("btc_a2dp_source_enc_init mtu %d, peer mtu %d",
|
||||
btc_aa_src_cb.TxAaMtuSize, pInitAudio->MtuSize);
|
||||
APPL_TRACE_EVENT(" ch mode %d, subnd %d, nb blk %d, alloc %d, rate %d, freq %d",
|
||||
btc_aa_src_cb.encoder.s16ChannelMode, btc_aa_src_cb.encoder.s16NumOfSubBands,
|
||||
btc_aa_src_cb.encoder.s16NumOfBlocks,
|
||||
btc_aa_src_cb.encoder.s16AllocationMethod, btc_aa_src_cb.encoder.u16BitRate,
|
||||
btc_aa_src_cb.encoder.s16SamplingFreq);
|
||||
btc_sbc_encoder.s16ChannelMode, btc_sbc_encoder.s16NumOfSubBands,
|
||||
btc_sbc_encoder.s16NumOfBlocks,
|
||||
btc_sbc_encoder.s16AllocationMethod, btc_sbc_encoder.u16BitRate,
|
||||
btc_sbc_encoder.s16SamplingFreq);
|
||||
|
||||
/* Reset entirely the SBC encoder */
|
||||
SBC_Encoder_Init(&(btc_aa_src_cb.encoder));
|
||||
APPL_TRACE_DEBUG("btc_a2dp_source_enc_init bit pool %d", btc_aa_src_cb.encoder.s16BitPool);
|
||||
SBC_Encoder_Init(&(btc_sbc_encoder));
|
||||
APPL_TRACE_DEBUG("btc_a2dp_source_enc_init bit pool %d", btc_sbc_encoder.s16BitPool);
|
||||
}
|
||||
|
||||
|
||||
@@ -835,7 +862,7 @@ static void btc_a2dp_source_enc_init(BT_HDR *p_msg)
|
||||
static void btc_a2dp_source_enc_update(BT_HDR *p_msg)
|
||||
{
|
||||
tBTC_MEDIA_UPDATE_AUDIO *pUpdateAudio = (tBTC_MEDIA_UPDATE_AUDIO *) p_msg;
|
||||
SBC_ENC_PARAMS *pstrEncParams = &btc_aa_src_cb.encoder;
|
||||
SBC_ENC_PARAMS *pstrEncParams = &btc_sbc_encoder;
|
||||
UINT16 s16SamplingFreq;
|
||||
SINT16 s16BitPool = 0;
|
||||
SINT16 s16BitRate;
|
||||
@@ -928,19 +955,19 @@ static void btc_a2dp_source_enc_update(BT_HDR *p_msg)
|
||||
if (s16BitPool > pUpdateAudio->MaxBitPool) {
|
||||
APPL_TRACE_DEBUG("%s computed bitpool too large (%d)", __FUNCTION__, s16BitPool);
|
||||
/* Decrease bitrate */
|
||||
btc_aa_src_cb.encoder.u16BitRate -= BTC_MEDIA_BITRATE_STEP;
|
||||
btc_sbc_encoder.u16BitRate -= BTC_MEDIA_BITRATE_STEP;
|
||||
/* Record that we have decreased the bitrate */
|
||||
protect |= 1;
|
||||
} else if (s16BitPool < pUpdateAudio->MinBitPool) {
|
||||
APPL_TRACE_WARNING("%s computed bitpool too small (%d)", __FUNCTION__, s16BitPool);
|
||||
|
||||
/* Increase bitrate */
|
||||
UINT16 previous_u16BitRate = btc_aa_src_cb.encoder.u16BitRate;
|
||||
btc_aa_src_cb.encoder.u16BitRate += BTC_MEDIA_BITRATE_STEP;
|
||||
UINT16 previous_u16BitRate = btc_sbc_encoder.u16BitRate;
|
||||
btc_sbc_encoder.u16BitRate += BTC_MEDIA_BITRATE_STEP;
|
||||
/* Record that we have increased the bitrate */
|
||||
protect |= 2;
|
||||
/* Check over-flow */
|
||||
if (btc_aa_src_cb.encoder.u16BitRate < previous_u16BitRate) {
|
||||
if (btc_sbc_encoder.u16BitRate < previous_u16BitRate) {
|
||||
protect |= 3;
|
||||
}
|
||||
} else {
|
||||
@@ -957,10 +984,10 @@ static void btc_a2dp_source_enc_update(BT_HDR *p_msg)
|
||||
pstrEncParams->s16BitPool = s16BitPool;
|
||||
|
||||
APPL_TRACE_DEBUG("%s final bit rate %d, final bit pool %d", __FUNCTION__,
|
||||
btc_aa_src_cb.encoder.u16BitRate, btc_aa_src_cb.encoder.s16BitPool);
|
||||
btc_sbc_encoder.u16BitRate, btc_sbc_encoder.s16BitPool);
|
||||
|
||||
/* make sure we reinitialize encoder with new settings */
|
||||
SBC_Encoder_Init(&(btc_aa_src_cb.encoder));
|
||||
SBC_Encoder_Init(&(btc_sbc_encoder));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -991,10 +1018,10 @@ static void btc_a2dp_source_pcm2sbc_init(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_feedin
|
||||
case 32000:
|
||||
case 48000:
|
||||
/* For these sampling_freq the AV connection must be 48000 */
|
||||
if (btc_aa_src_cb.encoder.s16SamplingFreq != SBC_sf48000) {
|
||||
if (btc_sbc_encoder.s16SamplingFreq != SBC_sf48000) {
|
||||
/* Reconfiguration needed at 48000 */
|
||||
APPL_TRACE_DEBUG("SBC Reconfiguration needed at 48000");
|
||||
btc_aa_src_cb.encoder.s16SamplingFreq = SBC_sf48000;
|
||||
btc_sbc_encoder.s16SamplingFreq = SBC_sf48000;
|
||||
reconfig_needed = TRUE;
|
||||
}
|
||||
break;
|
||||
@@ -1003,10 +1030,10 @@ static void btc_a2dp_source_pcm2sbc_init(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_feedin
|
||||
case 22050:
|
||||
case 44100:
|
||||
/* For these sampling_freq the AV connection must be 44100 */
|
||||
if (btc_aa_src_cb.encoder.s16SamplingFreq != SBC_sf44100) {
|
||||
if (btc_sbc_encoder.s16SamplingFreq != SBC_sf44100) {
|
||||
/* Reconfiguration needed at 44100 */
|
||||
APPL_TRACE_DEBUG("SBC Reconfiguration needed at 44100");
|
||||
btc_aa_src_cb.encoder.s16SamplingFreq = SBC_sf44100;
|
||||
btc_sbc_encoder.s16SamplingFreq = SBC_sf44100;
|
||||
reconfig_needed = TRUE;
|
||||
}
|
||||
break;
|
||||
@@ -1016,21 +1043,21 @@ static void btc_a2dp_source_pcm2sbc_init(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_feedin
|
||||
}
|
||||
|
||||
/* Some AV Headsets do not support Mono => always ask for Stereo */
|
||||
if (btc_aa_src_cb.encoder.s16ChannelMode == SBC_MONO) {
|
||||
if (btc_sbc_encoder.s16ChannelMode == SBC_MONO) {
|
||||
APPL_TRACE_DEBUG("SBC Reconfiguration needed in Stereo");
|
||||
btc_aa_src_cb.encoder.s16ChannelMode = SBC_JOINT_STEREO;
|
||||
btc_sbc_encoder.s16ChannelMode = SBC_JOINT_STEREO;
|
||||
reconfig_needed = TRUE;
|
||||
}
|
||||
|
||||
if (reconfig_needed != FALSE) {
|
||||
APPL_TRACE_DEBUG("%s :: mtu %d", __FUNCTION__, btc_aa_src_cb.TxAaMtuSize);
|
||||
APPL_TRACE_DEBUG("ch mode %d, nbsubd %d, nb %d, alloc %d, rate %d, freq %d",
|
||||
btc_aa_src_cb.encoder.s16ChannelMode,
|
||||
btc_aa_src_cb.encoder.s16NumOfSubBands, btc_aa_src_cb.encoder.s16NumOfBlocks,
|
||||
btc_aa_src_cb.encoder.s16AllocationMethod, btc_aa_src_cb.encoder.u16BitRate,
|
||||
btc_aa_src_cb.encoder.s16SamplingFreq);
|
||||
btc_sbc_encoder.s16ChannelMode,
|
||||
btc_sbc_encoder.s16NumOfSubBands, btc_sbc_encoder.s16NumOfBlocks,
|
||||
btc_sbc_encoder.s16AllocationMethod, btc_sbc_encoder.u16BitRate,
|
||||
btc_sbc_encoder.s16SamplingFreq);
|
||||
|
||||
SBC_Encoder_Init(&(btc_aa_src_cb.encoder));
|
||||
SBC_Encoder_Init(&(btc_sbc_encoder));
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("%s no SBC reconfig needed", __FUNCTION__);
|
||||
}
|
||||
@@ -1105,8 +1132,8 @@ static UINT8 btc_get_num_aa_frame(void)
|
||||
|
||||
switch (btc_aa_src_cb.TxTranscoding) {
|
||||
case BTC_MEDIA_TRSCD_PCM_2_SBC: {
|
||||
UINT32 pcm_bytes_per_frame = btc_aa_src_cb.encoder.s16NumOfSubBands *
|
||||
btc_aa_src_cb.encoder.s16NumOfBlocks *
|
||||
UINT32 pcm_bytes_per_frame = btc_sbc_encoder.s16NumOfSubBands *
|
||||
btc_sbc_encoder.s16NumOfBlocks *
|
||||
btc_aa_src_cb.media_feeding.cfg.pcm.num_channel *
|
||||
btc_aa_src_cb.media_feeding.cfg.pcm.bit_per_sample / 8;
|
||||
|
||||
@@ -1129,10 +1156,16 @@ static UINT8 btc_get_num_aa_frame(void)
|
||||
|
||||
/* calculate nbr of frames pending for this media tick */
|
||||
result = btc_aa_src_cb.media_feeding_state.pcm.counter / pcm_bytes_per_frame;
|
||||
if (result > MAX_PCM_FRAME_NUM_PER_TICK) {
|
||||
APPL_TRACE_WARNING("%s() - Limiting frames to be sent from %d to %d"
|
||||
, __FUNCTION__, result, MAX_PCM_FRAME_NUM_PER_TICK);
|
||||
result = MAX_PCM_FRAME_NUM_PER_TICK;
|
||||
|
||||
/* limit the frames to be sent */
|
||||
UINT32 frm_nb_threshold = MAX_OUTPUT_A2DP_SRC_FRAME_QUEUE_SZ - fixed_queue_length(btc_aa_src_cb.TxAaQ);
|
||||
if (frm_nb_threshold > MAX_PCM_FRAME_NUM_PER_TICK) {
|
||||
frm_nb_threshold = MAX_PCM_FRAME_NUM_PER_TICK;
|
||||
}
|
||||
|
||||
if (result > frm_nb_threshold) {
|
||||
APPL_TRACE_EVENT("Limit frms to send from %d to %d", result, frm_nb_threshold);
|
||||
result = frm_nb_threshold;
|
||||
}
|
||||
btc_aa_src_cb.media_feeding_state.pcm.counter -= result * pcm_bytes_per_frame;
|
||||
|
||||
@@ -1162,12 +1195,12 @@ static UINT8 btc_get_num_aa_frame(void)
|
||||
|
||||
BOOLEAN btc_media_aa_read_feeding(void)
|
||||
{
|
||||
UINT16 blocm_x_subband = btc_aa_src_cb.encoder.s16NumOfSubBands * \
|
||||
btc_aa_src_cb.encoder.s16NumOfBlocks;
|
||||
UINT16 blocm_x_subband = btc_sbc_encoder.s16NumOfSubBands * \
|
||||
btc_sbc_encoder.s16NumOfBlocks;
|
||||
UINT32 read_size;
|
||||
UINT16 sbc_sampling = 48000;
|
||||
UINT32 src_samples;
|
||||
UINT16 bytes_needed = blocm_x_subband * btc_aa_src_cb.encoder.s16NumOfChannels * \
|
||||
UINT16 bytes_needed = blocm_x_subband * btc_sbc_encoder.s16NumOfChannels * \
|
||||
btc_aa_src_cb.media_feeding.cfg.pcm.bit_per_sample / 8;
|
||||
static UINT16 up_sampled_buffer[SBC_MAX_NUM_FRAME * SBC_MAX_NUM_OF_BLOCKS
|
||||
* SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * 2];
|
||||
@@ -1181,7 +1214,7 @@ BOOLEAN btc_media_aa_read_feeding(void)
|
||||
UINT32 nb_byte_read = 0;
|
||||
|
||||
/* Get the SBC sampling rate */
|
||||
switch (btc_aa_src_cb.encoder.s16SamplingFreq) {
|
||||
switch (btc_sbc_encoder.s16SamplingFreq) {
|
||||
case SBC_sf48000:
|
||||
sbc_sampling = 48000;
|
||||
break;
|
||||
@@ -1199,7 +1232,7 @@ BOOLEAN btc_media_aa_read_feeding(void)
|
||||
if (sbc_sampling == btc_aa_src_cb.media_feeding.cfg.pcm.sampling_freq) {
|
||||
read_size = bytes_needed - btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue;
|
||||
nb_byte_read = btc_aa_src_data_read(
|
||||
((uint8_t *)btc_aa_src_cb.encoder.as16PcmBuffer) +
|
||||
((uint8_t *)btc_sbc_encoder.as16PcmBuffer) +
|
||||
btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue,
|
||||
read_size);
|
||||
if (nb_byte_read == read_size) {
|
||||
@@ -1293,7 +1326,7 @@ BOOLEAN btc_media_aa_read_feeding(void)
|
||||
/* only copy the pcm sample when we have up-sampled enough PCM */
|
||||
if (btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue >= bytes_needed) {
|
||||
/* Copy the output pcm samples in SBC encoding buffer */
|
||||
memcpy((UINT8 *)btc_aa_src_cb.encoder.as16PcmBuffer,
|
||||
memcpy((UINT8 *)btc_sbc_encoder.as16PcmBuffer,
|
||||
(UINT8 *)up_sampled_buffer,
|
||||
bytes_needed);
|
||||
/* update the residue */
|
||||
@@ -1322,8 +1355,8 @@ BOOLEAN btc_media_aa_read_feeding(void)
|
||||
static void btc_media_aa_prep_sbc_2_send(UINT8 nb_frame)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
UINT16 blocm_x_subband = btc_aa_src_cb.encoder.s16NumOfSubBands *
|
||||
btc_aa_src_cb.encoder.s16NumOfBlocks;
|
||||
UINT16 blocm_x_subband = btc_sbc_encoder.s16NumOfSubBands *
|
||||
btc_sbc_encoder.s16NumOfBlocks;
|
||||
|
||||
while (nb_frame) {
|
||||
if (NULL == (p_buf = osi_malloc(BTC_MEDIA_AA_BUF_SIZE))) {
|
||||
@@ -1339,27 +1372,27 @@ static void btc_media_aa_prep_sbc_2_send(UINT8 nb_frame)
|
||||
|
||||
do {
|
||||
/* Write @ of allocated buffer in encoder.pu8Packet */
|
||||
btc_aa_src_cb.encoder.pu8Packet = (UINT8 *) (p_buf + 1) + p_buf->offset + p_buf->len;
|
||||
btc_sbc_encoder.pu8Packet = (UINT8 *) (p_buf + 1) + p_buf->offset + p_buf->len;
|
||||
/* Fill allocated buffer with 0 */
|
||||
memset(btc_aa_src_cb.encoder.as16PcmBuffer, 0, blocm_x_subband
|
||||
* btc_aa_src_cb.encoder.s16NumOfChannels);
|
||||
memset(btc_sbc_encoder.as16PcmBuffer, 0, blocm_x_subband
|
||||
* btc_sbc_encoder.s16NumOfChannels);
|
||||
|
||||
/* Read PCM data and upsample them if needed */
|
||||
if (btc_media_aa_read_feeding()) {
|
||||
/* SBC encode and descramble frame */
|
||||
SBC_Encoder(&(btc_aa_src_cb.encoder));
|
||||
A2D_SbcChkFrInit(btc_aa_src_cb.encoder.pu8Packet);
|
||||
A2D_SbcDescramble(btc_aa_src_cb.encoder.pu8Packet, btc_aa_src_cb.encoder.u16PacketLength);
|
||||
SBC_Encoder(&(btc_sbc_encoder));
|
||||
A2D_SbcChkFrInit(btc_sbc_encoder.pu8Packet);
|
||||
A2D_SbcDescramble(btc_sbc_encoder.pu8Packet, btc_sbc_encoder.u16PacketLength);
|
||||
/* Update SBC frame length */
|
||||
p_buf->len += btc_aa_src_cb.encoder.u16PacketLength;
|
||||
p_buf->len += btc_sbc_encoder.u16PacketLength;
|
||||
nb_frame--;
|
||||
p_buf->layer_specific++;
|
||||
} else {
|
||||
APPL_TRACE_WARNING("btc_media_aa_prep_sbc_2_send underflow %d, %d",
|
||||
nb_frame, btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue);
|
||||
btc_aa_src_cb.media_feeding_state.pcm.counter += nb_frame *
|
||||
btc_aa_src_cb.encoder.s16NumOfSubBands *
|
||||
btc_aa_src_cb.encoder.s16NumOfBlocks *
|
||||
btc_sbc_encoder.s16NumOfSubBands *
|
||||
btc_sbc_encoder.s16NumOfBlocks *
|
||||
btc_aa_src_cb.media_feeding.cfg.pcm.num_channel *
|
||||
btc_aa_src_cb.media_feeding.cfg.pcm.bit_per_sample / 8;
|
||||
/* no more pcm to read */
|
||||
@@ -1372,7 +1405,7 @@ static void btc_media_aa_prep_sbc_2_send(UINT8 nb_frame)
|
||||
}
|
||||
}
|
||||
|
||||
} while (((p_buf->len + btc_aa_src_cb.encoder.u16PacketLength) < btc_aa_src_cb.TxAaMtuSize)
|
||||
} while (((p_buf->len + btc_sbc_encoder.u16PacketLength) < btc_aa_src_cb.TxAaMtuSize)
|
||||
&& (p_buf->layer_specific < 0x0F) && nb_frame);
|
||||
|
||||
if (p_buf->len) {
|
||||
|
@@ -315,8 +315,10 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
||||
} else if (event == BTA_AV_PENDING_EVT) {
|
||||
bdcpy(btc_av_cb.peer_bda.address, ((tBTA_AV *)p_data)->pend.bd_addr);
|
||||
UINT16 uuid = (btc_av_cb.service_id == BTA_A2DP_SOURCE_SERVICE_ID) ? UUID_SERVCLASS_AUDIO_SOURCE :
|
||||
UUID_SERVCLASS_AUDIO_SINK;
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
TRUE, BTA_SEC_AUTHENTICATE, UUID_SERVCLASS_AUDIO_SOURCE);
|
||||
TRUE, BTA_SEC_AUTHENTICATE, uuid);
|
||||
}
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_OPENING);
|
||||
} break;
|
||||
@@ -402,8 +404,8 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
tBTA_AV *p_bta_data = (tBTA_AV *)p_data;
|
||||
esp_a2d_connection_state_t state;
|
||||
btc_sm_state_t av_state;
|
||||
BTC_TRACE_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status,
|
||||
p_bta_data->open.edr);
|
||||
BTC_TRACE_DEBUG("status:%d, edr 0x%x, peer sep %d\n", p_bta_data->open.status,
|
||||
p_bta_data->open.edr, p_bta_data->open.sep);
|
||||
|
||||
if (p_bta_data->open.status == BTA_AV_SUCCESS) {
|
||||
state = ESP_A2D_CONNECTION_STATE_CONNECTED;
|
||||
@@ -428,7 +430,8 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
btc_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
|
||||
(p_bta_data->open.status == BTA_AV_SUCCESS));
|
||||
*/
|
||||
} else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
||||
} else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC &&
|
||||
(p_bta_data->open.status == BTA_AV_SUCCESS)) {
|
||||
/* Bring up AVRCP connection too */
|
||||
BTA_AvOpenRc(btc_av_cb.bta_handle);
|
||||
}
|
||||
@@ -978,10 +981,10 @@ static bt_status_t btc_av_init(int service_id)
|
||||
btc_av_cb.sm_handle =
|
||||
btc_sm_init((const btc_sm_handler_t *)btc_av_state_handlers, BTC_AV_STATE_IDLE);
|
||||
|
||||
btc_dm_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
|
||||
if (service_id == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
btc_dm_enable_service(BTA_A2DP_SINK_SERVICE_ID);
|
||||
} else {
|
||||
btc_dm_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
}
|
||||
|
||||
btc_a2dp_on_init();
|
||||
@@ -1196,10 +1199,13 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
BTC_TRACE_ERROR("ERROR dump_codec_info A2D_ParsSbcInfo fail:%d\n", a2d_status);
|
||||
}
|
||||
}
|
||||
UNUSED(que_len);
|
||||
}
|
||||
#else
|
||||
static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
{
|
||||
UNUSED(event);
|
||||
UNUSED(p_data);
|
||||
BTC_TRACE_WARNING("%s : event %u\n", __func__, event);
|
||||
}
|
||||
#endif
|
||||
@@ -1213,7 +1219,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
|
||||
** Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_av_execute_service(BOOLEAN b_enable)
|
||||
bt_status_t btc_av_execute_service(BOOLEAN b_enable, UINT8 tsep)
|
||||
{
|
||||
if (b_enable) {
|
||||
/* TODO: Removed BTA_SEC_AUTHORIZE since the Java/App does not
|
||||
@@ -1227,7 +1233,7 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
|
||||
| BTA_AV_FEAT_RCTG | BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR
|
||||
| BTA_AV_FEAT_RCCT | BTA_AV_FEAT_ADV_CTRL,
|
||||
bte_av_callback);
|
||||
BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTC_AV_SERVICE_NAME, 0, bte_av_media_callback, &bta_av_a2d_cos);
|
||||
BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTC_AV_SERVICE_NAME, 0, bte_av_media_callback, &bta_av_a2d_cos, tsep);
|
||||
} else {
|
||||
BTA_AvDeregister(btc_av_cb.bta_handle);
|
||||
BTA_AvDisable();
|
||||
@@ -1235,6 +1241,20 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_source_execute_service
|
||||
**
|
||||
** Description Initializes/Shuts down the A2DP source service
|
||||
**
|
||||
** Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_av_source_execute_service(BOOLEAN b_enable)
|
||||
{
|
||||
return btc_av_execute_service(b_enable, AVDT_TSEP_SRC);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btc_av_sink_execute_service
|
||||
@@ -1246,6 +1266,10 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_av_sink_execute_service(BOOLEAN b_enable)
|
||||
{
|
||||
bt_status_t ret = btc_av_execute_service(b_enable, AVDT_TSEP_SNK);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
#if (BTA_AV_SINK_INCLUDED == TRUE)
|
||||
BTA_AvEnable_Sink(b_enable);
|
||||
#endif
|
||||
|
@@ -335,6 +335,8 @@ static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp)
|
||||
} else {
|
||||
BTC_TRACE_ERROR("%s DUT does not support AVRCP controller role", __FUNCTION__);
|
||||
}
|
||||
|
||||
UNUSED(status);
|
||||
#else
|
||||
BTC_TRACE_ERROR("%s AVRCP controller role is not enabled", __FUNCTION__);
|
||||
#endif
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_util.h"
|
||||
#include "osi/mutex.h"
|
||||
#include "esp_bt.h"
|
||||
|
||||
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
|
||||
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
|
||||
@@ -142,6 +143,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
|
||||
|
||||
if (p_adv_data->include_txpower) {
|
||||
mask |= BTM_BLE_AD_BIT_TX_PWR;
|
||||
bta_adv_data->tx_power = esp_ble_tx_power_get(ESP_BLE_PWR_TYPE_ADV);
|
||||
}
|
||||
|
||||
if (p_adv_data->min_interval > 0 && p_adv_data->max_interval > 0 &&
|
||||
@@ -450,6 +452,10 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT
|
||||
status = ESP_BT_STATUS_PARM_INVALID;
|
||||
BTC_TRACE_ERROR("Invalid advertisting channel map parameters.\n");
|
||||
}
|
||||
if (!BLE_ISVALID_PARAM(ble_adv_params->peer_addr_type, BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_RANDOM)) {
|
||||
status = ESP_BT_STATUS_PARM_INVALID;
|
||||
BTC_TRACE_ERROR("Invalid advertisting peer address type parameters.\n");
|
||||
}
|
||||
if(status != ESP_BT_STATUS_SUCCESS) {
|
||||
if(start_adv_cback) {
|
||||
start_adv_cback(status);
|
||||
@@ -569,6 +575,9 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
|
||||
case BTA_DM_SEARCH_CANCEL_CMPL_EVT:
|
||||
BTC_TRACE_DEBUG("BTA_DM_SEARCH_CANCEL_CMPL_EVT\n");
|
||||
break;
|
||||
case BTA_DM_INQ_DISCARD_NUM_EVT:
|
||||
param.scan_rst.num_dis = p_data->inq_dis.num_dis;
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s : Unknown event 0x%x\n", __FUNCTION__, event);
|
||||
return;
|
||||
@@ -829,7 +838,7 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *
|
||||
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0");
|
||||
BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, bits of the random part shall not be all 1 or 0");
|
||||
}
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
@@ -1114,6 +1123,25 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
bta_dm_co_ble_set_max_key_size(key_size);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_SET_STATIC_PASSKEY: {
|
||||
uint32_t passkey = 0;
|
||||
for(uint8_t i = 0; i < arg->set_security_param.len; i++)
|
||||
{
|
||||
passkey += (((uint8_t *)value)[i]<<(8*i));
|
||||
}
|
||||
BTA_DmBleSetStaticPasskey(true, passkey);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_CLEAR_STATIC_PASSKEY: {
|
||||
BTA_DmBleSetStaticPasskey(false, 0);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH: {
|
||||
uint8_t enable = 0;
|
||||
STREAM_TO_UINT8(enable, value);
|
||||
bta_dm_co_ble_set_accept_auth_enable(enable);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -645,6 +645,14 @@ esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
|
||||
return ESP_BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
static void btc_gap_bt_set_pin_type(btc_gap_bt_args_t *arg){
|
||||
BTA_DMSetPinType (arg->set_pin_type.pin_type, arg->set_pin_type.pin_code, arg->set_pin_type.pin_code_len);
|
||||
}
|
||||
|
||||
static void btc_gap_bt_pin_reply(btc_gap_bt_args_t *arg){
|
||||
BTA_DmPinReply(arg->pin_reply.bda.address, arg->pin_reply.accept, arg->pin_reply.pin_code_len, arg->pin_reply.pin_code);
|
||||
}
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_gap_bt_args_t *arg = (btc_gap_bt_args_t *)msg->arg;
|
||||
@@ -682,6 +690,14 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_remove_bond_device(msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_SET_PIN_TYPE:{
|
||||
btc_gap_bt_set_pin_type(arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_ACT_PIN_REPLY: {
|
||||
btc_gap_bt_pin_reply(arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -715,6 +731,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
break;
|
||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:
|
||||
break;
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
@@ -745,6 +762,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_PIN_REQ_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
@@ -530,9 +530,6 @@ static void btc_gatts_cb_param_copy_free(btc_msg_t *msg, tBTA_GATTS *p_data)
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
if (p_data && p_data->req_data.value){
|
||||
osi_free(p_data->req_data.value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -693,10 +690,13 @@ void btc_gatts_call_handler(btc_msg_t *msg)
|
||||
#else
|
||||
//BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
#endif
|
||||
/*
|
||||
not support background connection
|
||||
// Mark background connections
|
||||
if (!arg->open.is_direct) {
|
||||
BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
transport = BTA_GATT_TRANSPORT_LE;
|
||||
|
||||
|
@@ -195,8 +195,9 @@ bt_status_t btc_hf_client_init(void)
|
||||
*******************************************************************************/
|
||||
static bt_status_t connect_int( bt_bdaddr_t *bd_addr, uint16_t uuid )
|
||||
{
|
||||
if (is_connected(bd_addr))
|
||||
if (is_connected(bd_addr)) {
|
||||
return BT_STATUS_BUSY;
|
||||
}
|
||||
|
||||
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING;
|
||||
bdcpy(btc_hf_client_cb.connected_bda.address, bd_addr->address);
|
||||
@@ -713,14 +714,14 @@ static void process_ind_evt(tBTA_HF_CLIENT_IND *ind)
|
||||
{
|
||||
esp_hf_client_cb_param_t param;
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
|
||||
|
||||
switch (ind->type)
|
||||
{
|
||||
case BTA_HF_CLIENT_IND_CALL:
|
||||
param.call.status = ind->value;
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_EVT, ¶m);
|
||||
break;
|
||||
|
||||
|
||||
case BTA_HF_CLIENT_IND_CALLSETUP:
|
||||
param.call_setup.status = ind->value;
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CIND_CALL_SETUP_EVT, ¶m);
|
||||
@@ -787,6 +788,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
BTC_TRACE_WARNING("%s: HF CLient open failed, but another device connected. status=%d state=%d connected device=%s",
|
||||
__FUNCTION__, p_data->open.status, btc_hf_client_cb.state, bdaddr_to_string(&btc_hf_client_cb.connected_bda, bdstr, sizeof(bdstr)));
|
||||
UNUSED(bdstr);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -795,18 +797,20 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = btc_hf_client_cb.state;
|
||||
param.conn_stat.peer_feat = 0;
|
||||
param.conn_stat.chld_feat = 0;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
|
||||
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED)
|
||||
bdsetany(btc_hf_client_cb.connected_bda.address);
|
||||
|
||||
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS)
|
||||
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED) {
|
||||
bdsetany(btc_hf_client_cb.connected_bda.address);
|
||||
}
|
||||
|
||||
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS) {
|
||||
btc_queue_advance();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -820,13 +824,13 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = btc_hf_client_cb.state;
|
||||
param.conn_stat.peer_feat = btc_hf_client_cb.peer_feat;
|
||||
param.conn_stat.chld_feat = btc_hf_client_cb.chld_feat;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
|
||||
|
||||
/* Inform the application about in-band ringtone */
|
||||
if (btc_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_INBAND)
|
||||
{
|
||||
@@ -839,7 +843,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
|
||||
btc_queue_advance();
|
||||
break;
|
||||
|
||||
|
||||
case BTA_HF_CLIENT_CLOSE_EVT:
|
||||
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
|
||||
do {
|
||||
@@ -847,7 +851,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
param.conn_stat.state = ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED;
|
||||
param.conn_stat.peer_feat = 0;
|
||||
param.conn_stat.chld_feat = 0;
|
||||
|
||||
|
||||
memcpy(param.conn_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
|
||||
@@ -980,7 +984,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED;
|
||||
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
sizeof(esp_bd_addr_t));
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
@@ -989,7 +993,7 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
|
||||
memset(¶m, 0, sizeof(esp_hf_client_cb_param_t));
|
||||
param.audio_stat.state = ESP_HF_CLIENT_AUDIO_STATE_CONNECTED_MSBC;
|
||||
memcpy(param.audio_stat.remote_bda, &btc_hf_client_cb.connected_bda,
|
||||
sizeof(esp_bd_addr_t));
|
||||
sizeof(esp_bd_addr_t));
|
||||
btc_hf_client_cb_to_app(ESP_HF_CLIENT_AUDIO_STATE_EVT, ¶m);
|
||||
} while (0);
|
||||
break;
|
||||
|
@@ -28,6 +28,7 @@ typedef enum {
|
||||
BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT,
|
||||
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
|
||||
BTC_GAP_BT_AUTH_CMPL_EVT,
|
||||
BTC_GAP_BT_PIN_REQ_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -39,6 +40,8 @@ typedef enum {
|
||||
BTC_GAP_BT_ACT_SET_COD,
|
||||
BTC_GAP_BT_ACT_READ_RSSI_DELTA,
|
||||
BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE,
|
||||
BTC_GAP_BT_ACT_SET_PIN_TYPE,
|
||||
BTC_GAP_BT_ACT_PIN_REPLY,
|
||||
} btc_gap_bt_act_t;
|
||||
|
||||
/* btc_bt_gap_args_t */
|
||||
@@ -79,6 +82,22 @@ typedef union {
|
||||
struct rm_bond_device_args {
|
||||
bt_bdaddr_t bda;
|
||||
} rm_bond_device;
|
||||
|
||||
// BTC_GAP_BT_ACT_SET_PIN_TYPE
|
||||
struct set_pin_type_args {
|
||||
esp_bt_pin_type_t pin_type;
|
||||
uint8_t pin_code_len;
|
||||
esp_bt_pin_code_t pin_code;
|
||||
} set_pin_type;
|
||||
|
||||
// BTC_GAP_BT_ACT_PIN_REPLY
|
||||
struct pin_reply_args {
|
||||
bt_bdaddr_t bda;
|
||||
bool accept;
|
||||
uint8_t pin_code_len;
|
||||
esp_bt_pin_code_t pin_code;
|
||||
} pin_reply;
|
||||
|
||||
} btc_gap_bt_args_t;
|
||||
|
||||
void btc_gap_bt_call_handler(btc_msg_t *msg);
|
||||
|
@@ -52,7 +52,7 @@ typedef struct {
|
||||
list_t *list;
|
||||
list_t *incoming_list;
|
||||
uint8_t service_uuid[16];
|
||||
char service_name[ESP_SPP_SERVER_NAME_MAX];
|
||||
char service_name[ESP_SPP_SERVER_NAME_MAX + 1];
|
||||
} spp_slot_t;
|
||||
|
||||
static struct spp_local_param_t {
|
||||
@@ -313,6 +313,7 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
||||
{
|
||||
if (osi_mutex_new(&spp_local_param.spp_slot_mutex) != 0) {
|
||||
BTC_TRACE_ERROR("%s osi_mutex_new failed\n", __func__);
|
||||
return;
|
||||
}
|
||||
spp_local_param.spp_mode = arg->init.mode;
|
||||
spp_local_param.spp_slot_id = 0;
|
||||
@@ -321,6 +322,10 @@ static void btc_spp_init(btc_spp_args_t *arg)
|
||||
|
||||
static void btc_spp_uninit(void)
|
||||
{
|
||||
if (!spp_local_param.spp_slot_mutex) {
|
||||
BTC_TRACE_ERROR("%s SPP have not been init\n", __func__);
|
||||
return;
|
||||
}
|
||||
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
|
||||
for (size_t i = 1; i <= BTA_JV_MAX_RFC_SR_SESSION; i++) {
|
||||
if (spp_local_param.spp_slots[i] != NULL && spp_local_param.spp_slots[i]->connected) {
|
||||
|
@@ -127,13 +127,47 @@
|
||||
#else
|
||||
#define SMP_INCLUDED FALSE
|
||||
#define BLE_PRIVACY_SPT FALSE
|
||||
#endif /* CONFIG_GATTC_ENABLE */
|
||||
#endif /* CONFIG_SMP_ENABLE */
|
||||
|
||||
#ifdef CONFIG_SMP_SLAVE_CON_PARAMS_UPD_ENABLE
|
||||
#if(CONFIG_SMP_SLAVE_CON_PARAMS_UPD_ENABLE)
|
||||
#define SMP_SLAVE_CON_PARAMS_UPD_ENABLE TRUE
|
||||
#else
|
||||
#define SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
||||
#endif
|
||||
#else
|
||||
#define SMP_SLAVE_CON_PARAMS_UPD_ENABLE FALSE
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL FALSE
|
||||
#else
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_SUPPORTED */
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM 100
|
||||
#else
|
||||
#define BLE_ADV_REPORT_FLOW_CONTROL_NUM CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_FLOW_CONTROL_NUM */
|
||||
|
||||
#ifndef CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
#define BLE_ADV_REPORT_DISCARD_THRSHOLD 20
|
||||
#else
|
||||
#define BLE_ADV_REPORT_DISCARD_THRSHOLD CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD
|
||||
#endif /* CONFIG_BLE_ADV_REPORT_DISCARD_THRSHOLD */
|
||||
|
||||
#if (CONFIG_BT_ACL_CONNECTIONS)
|
||||
#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS
|
||||
#define GATT_MAX_PHY_CHANNEL CONFIG_BT_ACL_CONNECTIONS
|
||||
#endif /* CONFIG_BT_ACL_CONNECTIONS */
|
||||
|
||||
#if(CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT)
|
||||
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT CONFIG_BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT
|
||||
#else
|
||||
#define BLE_ESTABLISH_LINK_CONNECTION_TIMEOUT 30
|
||||
#endif
|
||||
|
||||
//------------------Added from bdroid_buildcfg.h---------------------
|
||||
#ifndef L2CAP_EXTFEA_SUPPORTED_MASK
|
||||
#define L2CAP_EXTFEA_SUPPORTED_MASK (L2CAP_EXTFEA_ENH_RETRANS | L2CAP_EXTFEA_STREAM_MODE | L2CAP_EXTFEA_NO_CRC | L2CAP_EXTFEA_FIXED_CHNLS)
|
||||
@@ -317,6 +351,12 @@
|
||||
#define SCAN_QUEUE_CONGEST_CHECK CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY
|
||||
#define BTM_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY FALSE
|
||||
#else
|
||||
#define BTM_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY CONFIG_BLE_ACTIVE_SCAN_REPORT_ADV_SCAN_RSP_INDIVIDUALLY
|
||||
#endif
|
||||
|
||||
/* This feature is used to eanble interleaved scan*/
|
||||
#ifndef BTA_HOST_INTERLEAVE_SEARCH
|
||||
#define BTA_HOST_INTERLEAVE_SEARCH FALSE//FALSE
|
||||
@@ -991,7 +1031,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef BTM_BLE_ADV_TX_POWER
|
||||
#define BTM_BLE_ADV_TX_POWER {-21, -15, -7, 1, 9}
|
||||
#define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -31,6 +31,7 @@ typedef struct {
|
||||
UINT8 ble_init_key;
|
||||
UINT8 ble_resp_key;
|
||||
UINT8 ble_max_key_size;
|
||||
UINT8 ble_accept_auth_enable;
|
||||
#endif
|
||||
} tBTE_APPL_CFG;
|
||||
|
||||
|
@@ -100,7 +100,11 @@ static void start_up(void)
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
// Enable adv flow control
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_adv_report_flow_control(HCI_HOST_FLOW_CTRL_ADV_REPORT_ON, (uint16_t)BLE_ADV_REPORT_FLOW_CONTROL_NUM, (uint16_t)BLE_ADV_REPORT_DISCARD_THRSHOLD));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
#endif
|
||||
// Tell the controller about our buffer sizes and buffer counts next
|
||||
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
|
||||
response = AWAIT_COMMAND(
|
||||
@@ -250,10 +254,10 @@ static void start_up(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (simple_pairing_supported) {
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
}
|
||||
|
||||
response = AWAIT_COMMAND(packet_factory->make_set_event_mask(&CLASSIC_EVENT_MASK));
|
||||
packet_parser->parse_generic_command_complete(response);
|
||||
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
response = AWAIT_COMMAND(packet_factory->make_write_sync_flow_control_enable(1));
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#define CASE_RETURN_STR(const) case const: return #const;
|
||||
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
static const char *interop_feature_string(const interop_feature_t feature)
|
||||
{
|
||||
switch (feature) {
|
||||
@@ -36,7 +37,7 @@ static const char *interop_feature_string(const interop_feature_t feature)
|
||||
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
#endif // (!CONFIG_BT_STACK_NO_LOG)
|
||||
// Interface functions
|
||||
bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr)
|
||||
{
|
||||
@@ -47,7 +48,9 @@ bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr)
|
||||
for (size_t i = 0; i != db_size; ++i) {
|
||||
if (feature == interop_database[i].feature &&
|
||||
memcmp(addr, &interop_database[i].addr, interop_database[i].len) == 0) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
char bdstr[20] = {0};
|
||||
#endif
|
||||
LOG_WARN("%s() Device %s is a match for interop workaround %s", __func__,
|
||||
bdaddr_to_string(addr, bdstr, sizeof(bdstr)), interop_feature_string(feature));
|
||||
return true;
|
||||
|
@@ -145,9 +145,10 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
|
||||
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
|
||||
if (*(ps16GenBufPtr) < s32BitSlice + 2) {
|
||||
*(ps16GenArrPtr) = 0;
|
||||
} else
|
||||
} else {
|
||||
*(ps16GenArrPtr) = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
|
||||
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
|
||||
}
|
||||
|
||||
ps16GenBufPtr++;
|
||||
ps16GenArrPtr++;
|
||||
|
@@ -132,9 +132,10 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
|
||||
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
|
||||
if (*ps16GenBufPtr < s32BitSlice + 2) {
|
||||
*ps16GenArrPtr = 0;
|
||||
} else
|
||||
} else {
|
||||
*ps16GenArrPtr = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
|
||||
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
|
||||
}
|
||||
ps16GenBufPtr++;
|
||||
ps16GenArrPtr++;
|
||||
}
|
||||
|
@@ -26,10 +26,10 @@
|
||||
#include "hci/hci_layer.h"
|
||||
#include "osi/thread.h"
|
||||
#include "esp_bt.h"
|
||||
#include "stack/hcimsgs.h"
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
#include "l2c_int.h"
|
||||
#include "stack/hcimsgs.h"
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
|
||||
#define HCI_HAL_SERIAL_BUFFER_SIZE 1026
|
||||
@@ -57,6 +57,7 @@ typedef struct {
|
||||
const allocator_t *allocator;
|
||||
size_t buffer_size;
|
||||
fixed_queue_t *rx_q;
|
||||
uint16_t adv_free_num;
|
||||
} hci_hal_env_t;
|
||||
|
||||
|
||||
@@ -84,6 +85,7 @@ static void hci_hal_env_init(
|
||||
|
||||
hci_hal_env.allocator = buffer_allocator_get_interface();
|
||||
hci_hal_env.buffer_size = buffer_size;
|
||||
hci_hal_env.adv_free_num = 0;
|
||||
|
||||
hci_hal_env.rx_q = fixed_queue_new(max_buffer_count);
|
||||
if (hci_hal_env.rx_q) {
|
||||
@@ -105,8 +107,11 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
|
||||
{
|
||||
assert(upper_callbacks != NULL);
|
||||
callbacks = upper_callbacks;
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, BLE_ADV_REPORT_FLOW_CONTROL_NUM + L2CAP_HOST_FC_ACL_BUFS + QUEUE_SIZE_MAX); // adv flow control num + ACL flow control num + hci cmd numeber
|
||||
#else
|
||||
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
|
||||
#endif
|
||||
|
||||
xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
|
||||
xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
|
||||
@@ -225,12 +230,37 @@ static void hci_packet_complete(BT_HDR *packet){
|
||||
bool host_recv_adv_packet(BT_HDR *packet)
|
||||
{
|
||||
assert(packet);
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT) {
|
||||
return true;
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT) {
|
||||
if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| packet->data[3] == HCI_BLE_ADV_DISCARD_REPORT_EVT
|
||||
#endif
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
static void hci_update_adv_report_flow_control(BT_HDR *packet)
|
||||
{
|
||||
// this is adv packet
|
||||
if(host_recv_adv_packet(packet)) {
|
||||
// update adv free number
|
||||
hci_hal_env.adv_free_num ++;
|
||||
if (esp_vhci_host_check_send_available()){
|
||||
// send hci cmd
|
||||
btsnd_hcic_ble_update_adv_report_flow_control(hci_hal_env.adv_free_num);
|
||||
hci_hal_env.adv_free_num = 0;
|
||||
} else {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
{
|
||||
uint8_t type, hdr_size;
|
||||
@@ -249,8 +279,10 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
packet->offset++;
|
||||
packet->len--;
|
||||
if (type == HCI_BLE_EVENT) {
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
uint8_t len = 0;
|
||||
STREAM_TO_UINT8(len, stream);
|
||||
#endif
|
||||
HCI_TRACE_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
|
||||
packet->len, len);
|
||||
hci_hal_env.allocator->free(packet);
|
||||
@@ -284,6 +316,11 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
hci_hal_env.allocator->free(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
hci_update_adv_report_flow_control(packet);
|
||||
#endif
|
||||
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
|
||||
HCI_TRACE_ERROR("BtuQueue is congested");
|
||||
@@ -291,7 +328,6 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
|
||||
callbacks->packet_ready(packet);
|
||||
}
|
||||
@@ -333,7 +369,7 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
|
||||
pkt->layer_specific = 0;
|
||||
memcpy(pkt->data, data, len);
|
||||
fixed_queue_enqueue(hci_hal_env.rx_q, pkt);
|
||||
hci_hal_h4_task_post(100 / portTICK_PERIOD_MS);
|
||||
hci_hal_h4_task_post(0);
|
||||
|
||||
BTTRC_DUMP_BUFFER("Recv Pkt", pkt->data, len);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user