Compare commits
733 Commits
dev
...
copilot/pr
| Author | SHA1 | Date |
|---|---|---|
|
|
587160a019 | |
|
|
7eb62f4e7e | |
|
|
0f0f42875e | |
|
|
3071f321df | |
|
|
4b24310592 | |
|
|
23f6535cef | |
|
|
1ef939c9c7 | |
|
|
43c69af388 | |
|
|
784bb0fd16 | |
|
|
924643514c | |
|
|
e694c837bf | |
|
|
6d2a8219d2 | |
|
|
09d4d46be8 | |
|
|
f168377115 | |
|
|
d167cc2478 | |
|
|
0d1d12fc66 | |
|
|
994a8c18f5 | |
|
|
e13928b015 | |
|
|
8c21590bdf | |
|
|
c3190cf47c | |
|
|
70d8bd4720 | |
|
|
4714c37b7f | |
|
|
0ccfab8279 | |
|
|
5294ad21bd | |
|
|
00271cfaae | |
|
|
fac056bc7d | |
|
|
3b306ae982 | |
|
|
8a9ab0c65a | |
|
|
a91f2a311c | |
|
|
c7f1c0675f | |
|
|
8c3f60e878 | |
|
|
8456ee94d7 | |
|
|
1a1526791b | |
|
|
57ebf5d7f9 | |
|
|
e1032e6693 | |
|
|
2c35a23f62 | |
|
|
459c1fc3e3 | |
|
|
6fb9902889 | |
|
|
1b6e6215fe | |
|
|
3bfade5f48 | |
|
|
c5b8a64347 | |
|
|
b95024eee5 | |
|
|
765755dbb2 | |
|
|
02745b9a3f | |
|
|
a83dced527 | |
|
|
6e4d1c3380 | |
|
|
1f4cd62f5e | |
|
|
f9754a49b5 | |
|
|
9ca633b9bd | |
|
|
ae93faf1b4 | |
|
|
6730ed14a8 | |
|
|
098029d3e3 | |
|
|
483df41283 | |
|
|
79d3290d96 | |
|
|
6d50d86c54 | |
|
|
7720b13e29 | |
|
|
24b6482b8e | |
|
|
5526ca9f76 | |
|
|
4d4f15eeb1 | |
|
|
ff16970d67 | |
|
|
a74b84a6f9 | |
|
|
6dd955a9ef | |
|
|
d70c16ccf7 | |
|
|
0cf595fdbf | |
|
|
dd6e58afe6 | |
|
|
54e536407f | |
|
|
49a0c0ffce | |
|
|
8db9b23dca | |
|
|
ca8142629f | |
|
|
13dae0fee7 | |
|
|
abd1eaf88f | |
|
|
e829611cbc | |
|
|
0d0fddd4d1 | |
|
|
77f6bff7a4 | |
|
|
4835b315d8 | |
|
|
9cf4c8e9de | |
|
|
04870f29b7 | |
|
|
58d2179d91 | |
|
|
02c5e94088 | |
|
|
71f0c43ff1 | |
|
|
42e243c03c | |
|
|
fe34376458 | |
|
|
9902692ca3 | |
|
|
a5bb09a566 | |
|
|
f3ba3987b7 | |
|
|
94d4fa1c2a | |
|
|
f53d2576a8 | |
|
|
2709e30e08 | |
|
|
8aaad71be6 | |
|
|
c36eb5d4db | |
|
|
b04a2fab3a | |
|
|
a6f9d1cea4 | |
|
|
7a45da74ca | |
|
|
744a902e29 | |
|
|
b6d1040bb9 | |
|
|
e7001f10d6 | |
|
|
ee89f146e6 | |
|
|
99def1db98 | |
|
|
0b0934b93e | |
|
|
63076eac76 | |
|
|
ce8374972d | |
|
|
40baac46b6 | |
|
|
647d483d41 | |
|
|
7464dd39ff | |
|
|
21e6488814 | |
|
|
8039443ac9 | |
|
|
fba96936bf | |
|
|
82f3d007ed | |
|
|
dfe890ea6c | |
|
|
1d4e47a9ec | |
|
|
34f599b1be | |
|
|
00e65e4dae | |
|
|
6c492b47aa | |
|
|
cf5f1df054 | |
|
|
876dc70179 | |
|
|
a03b00b116 | |
|
|
abc873e5b7 | |
|
|
32b4aac49d | |
|
|
0c4353c644 | |
|
|
c4ab84ddb3 | |
|
|
de4875d2df | |
|
|
3602dac941 | |
|
|
1ef3d009af | |
|
|
3281ce6841 | |
|
|
7bbb16b160 | |
|
|
6c9dc5503b | |
|
|
cbea408ece | |
|
|
373a30ccc0 | |
|
|
d7c85ed056 | |
|
|
3187ead586 | |
|
|
080d24168b | |
|
|
2468a9a090 | |
|
|
2aa93386fd | |
|
|
def4c56f8f | |
|
|
1974e4be0e | |
|
|
6426035e6f | |
|
|
c3237bd37f | |
|
|
54b81bb936 | |
|
|
f8626513d0 | |
|
|
231cca859e | |
|
|
02425b18dc | |
|
|
665a1768d7 | |
|
|
b25151d2dd | |
|
|
77c516ccec | |
|
|
208eef2765 | |
|
|
e76f082bdb | |
|
|
9e5c9ecb2f | |
|
|
b422587be5 | |
|
|
1b99dbd833 | |
|
|
f8c2561c83 | |
|
|
125cd50688 | |
|
|
f688ab0987 | |
|
|
977bb0838d | |
|
|
78b6dc609d | |
|
|
3eb5bb4697 | |
|
|
50f6ee3817 | |
|
|
8982a80624 | |
|
|
5495c21435 | |
|
|
554d99be98 | |
|
|
c97efa56c1 | |
|
|
b6bcfdfc12 | |
|
|
635db1a6a5 | |
|
|
26cdd597f0 | |
|
|
6af982c3fb | |
|
|
7ac84381f7 | |
|
|
48361b8611 | |
|
|
9166bbb3f6 | |
|
|
c4109efec5 | |
|
|
1279dc71aa | |
|
|
13dba37e5f | |
|
|
cbd8486e0c | |
|
|
58fd5d5bd9 | |
|
|
2d7665563f | |
|
|
6c1b11cfed | |
|
|
a39f1ad0e2 | |
|
|
b18438ec89 | |
|
|
1903a03ff2 | |
|
|
55a3787b27 | |
|
|
1c6809b88c | |
|
|
1bd69b1d62 | |
|
|
db042f72d4 | |
|
|
73e28f7fd9 | |
|
|
fb7b326081 | |
|
|
dffc5d9bed | |
|
|
ce6724811c | |
|
|
ef7c892b27 | |
|
|
033c0487de | |
|
|
28a2de9356 | |
|
|
a52ae77f97 | |
|
|
fea1edd625 | |
|
|
67b309f087 | |
|
|
6a76432632 | |
|
|
a9c98b6d3d | |
|
|
ca49e1e291 | |
|
|
3102f5af68 | |
|
|
6d0913d78a | |
|
|
6976814da4 | |
|
|
f7a22f985a | |
|
|
199e1ae9bf | |
|
|
0565f7e313 | |
|
|
fa04c40172 | |
|
|
0a93bc305e | |
|
|
c33cd7ae1d | |
|
|
ca4130187a | |
|
|
c5b098cdc7 | |
|
|
7624b23453 | |
|
|
34149e5b9e | |
|
|
4f88e893dc | |
|
|
243240e3ab | |
|
|
8595a5c088 | |
|
|
a2706334f8 | |
|
|
5827ad0aef | |
|
|
03e521ee13 | |
|
|
6647769e81 | |
|
|
a316e2185b | |
|
|
31e94dd8c9 | |
|
|
0f7aba71c8 | |
|
|
086fa564b8 | |
|
|
8dd48f0430 | |
|
|
0f68596808 | |
|
|
e1986c51b1 | |
|
|
fa97c92438 | |
|
|
191be9d2ec | |
|
|
6b9f1c7361 | |
|
|
699e7a382b | |
|
|
2614fcde85 | |
|
|
e221f5facb | |
|
|
f821eff90c | |
|
|
dc57b9ac6e | |
|
|
5a35671379 | |
|
|
48c01df5b3 | |
|
|
f446c71611 | |
|
|
e0730d4d64 | |
|
|
3f76d3a763 | |
|
|
c4b59ecfb6 | |
|
|
cc3669acd9 | |
|
|
a2a7026bca | |
|
|
8b8bdf8518 | |
|
|
d90ac58a8b | |
|
|
080b681c38 | |
|
|
73b5a6d862 | |
|
|
8d8dc017e6 | |
|
|
10ec9d0ff6 | |
|
|
3a88f890a9 | |
|
|
35551deab8 | |
|
|
6426ecc981 | |
|
|
a54b568616 | |
|
|
d18babcbcc | |
|
|
c4cec4f868 | |
|
|
34bfb85fcc | |
|
|
efe2486d8d | |
|
|
5d3d0ee6e3 | |
|
|
32e1c81391 | |
|
|
132453c0d7 | |
|
|
9128199bb7 | |
|
|
74663d6cf7 | |
|
|
1d6a2cc803 | |
|
|
fe229135f8 | |
|
|
4659711387 | |
|
|
bee2b50a6d | |
|
|
a04b919dae | |
|
|
6c0f5fffce | |
|
|
10ef8e9b0f | |
|
|
61962200bf | |
|
|
da9b273239 | |
|
|
f08c82b2e3 | |
|
|
1aa2545d51 | |
|
|
2c1e50516a | |
|
|
513a6b1063 | |
|
|
06fc0eefe8 | |
|
|
d800bf1f8e | |
|
|
7ebe4b65b6 | |
|
|
013be33246 | |
|
|
5f3c369a71 | |
|
|
af3f4e8e9f | |
|
|
4ca53866fe | |
|
|
bcc830ea10 | |
|
|
2a10e69528 | |
|
|
82b06b1468 | |
|
|
45138d77a1 | |
|
|
a8307e10b6 | |
|
|
f3654daa06 | |
|
|
bcbf5f9c55 | |
|
|
d47164b2b0 | |
|
|
026db6dfa4 | |
|
|
4cb36ccf47 | |
|
|
6cb50db5bd | |
|
|
65fbc3c6b6 | |
|
|
35c3d85823 | |
|
|
dc9897fb67 | |
|
|
4baa9477e4 | |
|
|
95cd2488e8 | |
|
|
91aa677c78 | |
|
|
01cc4da180 | |
|
|
12f20c8d34 | |
|
|
e81000ad6e | |
|
|
085770f5a3 | |
|
|
eeaf6ff389 | |
|
|
64d4df2bca | |
|
|
7ac5a15b96 | |
|
|
d543c05d87 | |
|
|
df6bc0fa3c | |
|
|
c91905096a | |
|
|
c5c31b4e9d | |
|
|
f680a26f87 | |
|
|
68ef63520d | |
|
|
6a8860b384 | |
|
|
02fa7ce1ef | |
|
|
7f01e2630d | |
|
|
2a71b51066 | |
|
|
fb8676e715 | |
|
|
b3d4132dfc | |
|
|
fe8e66ab8b | |
|
|
9cb39dc0db | |
|
|
824e6d0fca | |
|
|
772495f561 | |
|
|
236b16d55f | |
|
|
450da945b1 | |
|
|
59c0cba029 | |
|
|
3c131992d2 | |
|
|
e739721b93 | |
|
|
429d25a953 | |
|
|
5fc0f5b754 | |
|
|
84fc3cefee | |
|
|
4e966c8997 | |
|
|
355d7f6b36 | |
|
|
73f0f0bf5c | |
|
|
f71477ec12 | |
|
|
e361130272 | |
|
|
6defd04a82 | |
|
|
f9ac81dbc5 | |
|
|
7bc1dc468d | |
|
|
cd36c0d88b | |
|
|
a1039206f9 | |
|
|
a71b5614c0 | |
|
|
ca3e8d9dbc | |
|
|
59146f40ed | |
|
|
14eff59179 | |
|
|
541f21384a | |
|
|
06abe5ece2 | |
|
|
2ea19a820a | |
|
|
d35f3f99b2 | |
|
|
3f861153ba | |
|
|
6e195fa9d1 | |
|
|
0e7628a6fe | |
|
|
07669fe207 | |
|
|
ac288113c5 | |
|
|
48a9a6066f | |
|
|
8b659f13db | |
|
|
9b72792378 | |
|
|
5d1cd7287d | |
|
|
3e2247c9cf | |
|
|
ad524e3705 | |
|
|
afd9853b99 | |
|
|
4c2e407954 | |
|
|
b55d78a905 | |
|
|
a80eabc810 | |
|
|
d33cd6eeff | |
|
|
576781a69c | |
|
|
92e9a77eb2 | |
|
|
f3aa95cb4b | |
|
|
7d68d3fe06 | |
|
|
4cb3f47aac | |
|
|
d1cc10ef68 | |
|
|
474067591a | |
|
|
1b53740d2a | |
|
|
4318f050cf | |
|
|
0215688d0e | |
|
|
04ec6b20de | |
|
|
9a57a90ba0 | |
|
|
a18a42e98a | |
|
|
39007dc02d | |
|
|
32d1b33221 | |
|
|
5101ff90ef | |
|
|
fb4c45a360 | |
|
|
a9efc84189 | |
|
|
2bbdc67958 | |
|
|
eacc6cfc9a | |
|
|
24937cdb38 | |
|
|
9a0a9b8e29 | |
|
|
df5904a41b | |
|
|
1d0b558090 | |
|
|
9e14193b3c | |
|
|
3f7b0c707c | |
|
|
e482b92d11 | |
|
|
6302f4e2c3 | |
|
|
c0d54593a9 | |
|
|
42aeb49c23 | |
|
|
f5b26f71cb | |
|
|
85db3a228b | |
|
|
8b3a1a0f57 | |
|
|
33368edc2a | |
|
|
9890f09e3f | |
|
|
b69a099c4a | |
|
|
d967ffe918 | |
|
|
95bededfaf | |
|
|
140f414f65 | |
|
|
abb204078c | |
|
|
35ed1ce372 | |
|
|
e5d182aa9d | |
|
|
0535700f63 | |
|
|
7b3c6fa5ec | |
|
|
f5d6efd185 | |
|
|
fb6d1b8cbc | |
|
|
13a289fc79 | |
|
|
2763b29d55 | |
|
|
f63df58228 | |
|
|
7e23f12812 | |
|
|
72a9f431c0 | |
|
|
0ac0044e05 | |
|
|
1ab07c7d83 | |
|
|
b368f97316 | |
|
|
6c388b677b | |
|
|
4690eba325 | |
|
|
72d85f9bc5 | |
|
|
92fa9fbe63 | |
|
|
789f134a1f | |
|
|
ad452fd077 | |
|
|
014124af81 | |
|
|
6e4815ed97 | |
|
|
92b05a9cd1 | |
|
|
1e0cde373b | |
|
|
718d712aa3 | |
|
|
1f4cfaba27 | |
|
|
79ab44208f | |
|
|
c39d471958 | |
|
|
ace9f8f530 | |
|
|
69776d00c2 | |
|
|
94cef6a956 | |
|
|
88fa9ddde8 | |
|
|
b2ade67903 | |
|
|
d494e289e7 | |
|
|
ec2b64173d | |
|
|
8608698fb3 | |
|
|
add354a647 | |
|
|
cd2dfdae83 | |
|
|
56da446e29 | |
|
|
62b6c92dc1 | |
|
|
e724d91aca | |
|
|
586e7ffc7d | |
|
|
ac9cffc528 | |
|
|
a2d23015b0 | |
|
|
4e23ad3edd | |
|
|
a785db9cf8 | |
|
|
a234906bb0 | |
|
|
6cafa60b13 | |
|
|
472d428534 | |
|
|
243acecda5 | |
|
|
182cc4016a | |
|
|
e3d7e82cc2 | |
|
|
2f7d2053ac | |
|
|
4b3f987d31 | |
|
|
47fe1432e4 | |
|
|
87fd88b9f2 | |
|
|
780ab736d2 | |
|
|
703e8fff17 | |
|
|
979b66f3bf | |
|
|
4700a26a6e | |
|
|
57d9d81a2d | |
|
|
3fb6d3affb | |
|
|
a63ae64dc5 | |
|
|
0adf299235 | |
|
|
7e9b8a9efb | |
|
|
7f826f188f | |
|
|
cd3208b767 | |
|
|
32ad49291f | |
|
|
045702fd61 | |
|
|
7febb53baf | |
|
|
b6a6bda7bf | |
|
|
4c4e720aec | |
|
|
c09dcd2266 | |
|
|
6fb4b08cf1 | |
|
|
7f80aee687 | |
|
|
983819c21d | |
|
|
80e172b56c | |
|
|
d793ddf6df | |
|
|
e6d21b1ff7 | |
|
|
d03e02610a | |
|
|
2c95b3db74 | |
|
|
e0181c9f95 | |
|
|
1d6f4ae504 | |
|
|
0eef976b0c | |
|
|
b299900972 | |
|
|
eb2a2c4c86 | |
|
|
58c0ed2c8b | |
|
|
cc7fc545c7 | |
|
|
11af0c8d1c | |
|
|
64938efdd8 | |
|
|
669fbe371f | |
|
|
f15a286ee5 | |
|
|
a125dd37d2 | |
|
|
9dc6be64e4 | |
|
|
5c5301a1f8 | |
|
|
63376f1c9b | |
|
|
fdc346edaa | |
|
|
abfbbfa4e9 | |
|
|
b7d946ff1d | |
|
|
201a62a6a1 | |
|
|
4b05991160 | |
|
|
99913e9f83 | |
|
|
4e05072afa | |
|
|
1655e1832e | |
|
|
80083a6c6e | |
|
|
55f2b71865 | |
|
|
f582b08c10 | |
|
|
43018e3c48 | |
|
|
98a50be547 | |
|
|
794e8ab6e2 | |
|
|
b78c45b51e | |
|
|
676764447c | |
|
|
9ff81d7dd9 | |
|
|
219d6c1547 | |
|
|
64768a4d6a | |
|
|
1316e86843 | |
|
|
408af3e872 | |
|
|
1a68e3e697 | |
|
|
f0dafbb834 | |
|
|
c932ccd18e | |
|
|
c726342078 | |
|
|
e52900eb16 | |
|
|
ad343e7331 | |
|
|
114f7d188c | |
|
|
8c3353e282 | |
|
|
91fba2c49d | |
|
|
f782c2da0d | |
|
|
72518eb7cd | |
|
|
4a65c71d2f | |
|
|
5ee3452176 | |
|
|
22a56f142e | |
|
|
684d6932da | |
|
|
af88ad07e8 | |
|
|
1921f5a056 | |
|
|
2f66660084 | |
|
|
1fad1f6b36 | |
|
|
65beb47901 | |
|
|
72dd24a7fb | |
|
|
de5f442be9 | |
|
|
7a47f711bc | |
|
|
97342ef5d9 | |
|
|
3d0422ff26 | |
|
|
27c2138205 | |
|
|
e5c9d6ce0b | |
|
|
96ebb6b886 | |
|
|
4f18cfa087 | |
|
|
56b10ab0b5 | |
|
|
4970ea3f54 | |
|
|
c177eccf90 | |
|
|
51b2361e0e | |
|
|
b3f8703c6d | |
|
|
f82c4786ed | |
|
|
2353c89ad7 | |
|
|
ea67d12ace | |
|
|
a555fb1198 | |
|
|
a34d9a71fa | |
|
|
c87b7142bc | |
|
|
72143ef6bd | |
|
|
9341d0e028 | |
|
|
771d59fdbb | |
|
|
23dbf0c246 | |
|
|
8d34cbb7f2 | |
|
|
bfc7554b42 | |
|
|
74eae9b1a7 | |
|
|
fba1d12530 | |
|
|
285532f922 | |
|
|
6b28b88fdf | |
|
|
a3bc392737 | |
|
|
5fcee896a0 | |
|
|
a055c287f5 | |
|
|
752ca9d372 | |
|
|
1d39d82188 | |
|
|
cb559fec01 | |
|
|
91fde75c9d | |
|
|
5c05c4cd6c | |
|
|
0ec062c156 | |
|
|
86c303c964 | |
|
|
c74e543123 | |
|
|
8320a53a5a | |
|
|
7c2f1803f5 | |
|
|
86d940940e | |
|
|
aa49836aba | |
|
|
579dac6b73 | |
|
|
491c2f1b60 | |
|
|
271630faff | |
|
|
52df36641d | |
|
|
6044eb74d2 | |
|
|
f0821e7bef | |
|
|
0e7a35ff72 | |
|
|
cf7f09a7cc | |
|
|
092c0b6c09 | |
|
|
8f70665715 | |
|
|
f8c2b0e210 | |
|
|
b5e7cfe53a | |
|
|
2274c91efe | |
|
|
cee7569f30 | |
|
|
04d1e7d974 | |
|
|
d90ff374fc | |
|
|
f2a34393cf | |
|
|
8084aa14fc | |
|
|
d7a1ee939f | |
|
|
97e17530fb | |
|
|
189519c95c | |
|
|
a936a45d4b | |
|
|
bfed81c014 | |
|
|
2575f85332 | |
|
|
956f6864a7 | |
|
|
20270e05f6 | |
|
|
768f262d18 | |
|
|
15819261f9 | |
|
|
6be4791c4f | |
|
|
0d728445fe | |
|
|
e112fa753a | |
|
|
be87c6a634 | |
|
|
902b19394c | |
|
|
6f4f52ecf7 | |
|
|
9f81e8fa18 | |
|
|
97982aedca | |
|
|
f5dac27fdd | |
|
|
9565ad4c38 | |
|
|
255019b202 | |
|
|
e1c6555f89 | |
|
|
5b1900f1ef | |
|
|
fd36cb8242 | |
|
|
3343f40412 | |
|
|
c2df26241e | |
|
|
07593fac23 | |
|
|
a9e15be513 | |
|
|
8a88ef679a | |
|
|
4ac6a35970 | |
|
|
12a4df19ac | |
|
|
e9d4f928ca | |
|
|
3d1589f15a | |
|
|
cb9703c7f9 | |
|
|
76e7ec3fe8 | |
|
|
b5cf97d741 | |
|
|
11272ce67a | |
|
|
af2adab4ef | |
|
|
2fcf8b131b | |
|
|
b787bd00dc | |
|
|
d12c6023d9 | |
|
|
d19f0b2009 | |
|
|
5f87453562 | |
|
|
d4fdcf87f4 | |
|
|
bb358f5ef0 | |
|
|
3a670aaecb | |
|
|
bb8fae4cd1 | |
|
|
e6ae25e935 | |
|
|
155a501a1e | |
|
|
2f1c434288 | |
|
|
d214aed78f | |
|
|
9735bb6cba | |
|
|
fb175719dd | |
|
|
510764ce62 | |
|
|
940a011664 | |
|
|
2f9ed21f73 | |
|
|
d7fe4826cf | |
|
|
b999116e63 | |
|
|
c30ed5e991 | |
|
|
741a829251 | |
|
|
789ce69bb5 | |
|
|
b0f21a417d | |
|
|
5194f75a88 | |
|
|
6bf0867a11 | |
|
|
5b610ed733 | |
|
|
bc64b0a366 | |
|
|
d3562fcfce | |
|
|
a92b9c7d61 | |
|
|
3358946297 | |
|
|
8f1fd61775 | |
|
|
aea63ec2e4 | |
|
|
dd06f6ec56 | |
|
|
952b7651af | |
|
|
7ca0b725aa | |
|
|
090d7d3034 | |
|
|
ee90fdddf0 | |
|
|
a47e504046 | |
|
|
a08d3053d9 | |
|
|
dbde6f0ed4 | |
|
|
620861c24f | |
|
|
da5cb009e0 | |
|
|
28d441b9c8 | |
|
|
a2e37ef189 | |
|
|
3ab1f9e8bd | |
|
|
f5c7c0a9ff | |
|
|
5558d6bcf7 | |
|
|
aa90d14c0a | |
|
|
d1d133e78c | |
|
|
d920be649b | |
|
|
ee6adc9e8d | |
|
|
754aa99c39 | |
|
|
56f0be77a1 | |
|
|
ca5e623a85 | |
|
|
4e5b6aa830 | |
|
|
a6b7ccc2fd | |
|
|
c7a5d181aa | |
|
|
82a9a94f01 | |
|
|
a4da7f4162 | |
|
|
efd2771ffc | |
|
|
e506ee2f86 | |
|
|
80ae7e89e9 | |
|
|
79b78e9629 | |
|
|
667bd4abba | |
|
|
1e182085a6 | |
|
|
d6f87b8550 | |
|
|
269303eea6 | |
|
|
000d78ac06 | |
|
|
ebb8787391 | |
|
|
b99da67e94 | |
|
|
b7d9776e45 | |
|
|
d9706d87f4 | |
|
|
6bcf91c339 | |
|
|
8952e6ddb7 | |
|
|
18cd71b81d | |
|
|
4e888cbbe4 | |
|
|
58ffd85d61 | |
|
|
f919c9c490 | |
|
|
0df7598fde | |
|
|
97841e32c5 | |
|
|
dec5c58daf | |
|
|
ec305935f9 | |
|
|
dac351422b | |
|
|
de6f8f5b1c | |
|
|
b6a3d495e2 | |
|
|
d6204bc1bf | |
|
|
77d785f814 | |
|
|
6d5025dc55 | |
|
|
f6ff415e55 | |
|
|
c3c60105fa | |
|
|
339de05938 | |
|
|
cc84ed0b6f | |
|
|
a3d9b24322 | |
|
|
675dc80db6 | |
|
|
5805376c2b | |
|
|
cf07bea530 |
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: WebKit
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
name: 缺陷反馈 | Bug
|
||||
description: 当您发现了一个缺陷,需要向社区反馈时,请使用此模板。
|
||||
title: "[BUG] <标题>"
|
||||
labels: [👀 needs triage, "Type: Bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢您对 openvela 社区的支持与关注,欢迎反馈缺陷。
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "重现问题的步骤"
|
||||
description: "简洁地描述错误是什么,为什么您认为它是一个错误,以及如何重现它的步骤"
|
||||
placeholder: |
|
||||
重现问题的步骤,可能包括日志和截图。
|
||||
1. 步骤 1
|
||||
2. 步骤 2
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: architecture
|
||||
attributes:
|
||||
label: Issue Architecture
|
||||
multiple: true
|
||||
options:
|
||||
- "Arch: arm"
|
||||
- "Arch: arm64"
|
||||
- "Arch: x86_64"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
提交前请确认您已遵循以下步骤:
|
||||
- 确认问题在 [**dev**](../) 上可重现。
|
||||
- 遇到构建问题时运行 `make distclean`。
|
||||
- 搜索 [现有问题](./)
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
name: 新需求 | Feature
|
||||
description: 当您需要反馈或实现一个新需求时,使用此模板。
|
||||
title: "[FEATURE] <标题>"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢您对 openvela 社区的支持与关注。
|
||||
|
||||
- type: textarea
|
||||
id: question-description
|
||||
attributes:
|
||||
label: 您的需求是否和问题相关?
|
||||
description: 请简单描述问题,并提供issue链接。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: 请描述您想要的解决方案
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: 替代方案
|
||||
attributes:
|
||||
label: 请描述您考虑过的替代解决方案
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
提交前请搜索 [现有功能需求](./)
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
name: 问题咨询
|
||||
title: "[问题咨询]"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
感谢您对 openvela 社区的支持与关注。
|
||||
|
||||
- type: textarea
|
||||
id: question-description
|
||||
attributes:
|
||||
label: 描述
|
||||
description: 请解释您的问题的背景或上下文,这有助于其他人更好地理解您的问题或疑问。
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
提交前请确认您已遵循以下步骤:
|
||||
- 我已搜索 [openvela 文档](../),但未找到问题的答案。
|
||||
- 已搜索 [现有问题](./)
|
||||
|
|
@ -0,0 +1 @@
|
|||
blank_issues_enabled: false
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
## 概要
|
||||
|
||||
*在此部分更新信息,说明更改的必要性、具体做了什么以及如何实现的,如果有新功能出现,请提供参考资料(依赖关系、类似问题和解决方案等)。*
|
||||
|
||||
## 影响
|
||||
|
||||
*在此部分更新信息(如适用),说明更改如何影响用户、构建过程、硬件、文档、安全性、兼容性等。*
|
||||
|
||||
## 测试
|
||||
|
||||
*在此部分更新信息,详细说明如何验证更改,使用什么主机进行构建(操作系统、CPU、编译器等),使用什么目标进行验证(架构、板子:配置等)。提供更改前后的构建和运行日志将非常有帮助。*
|
||||
|
|
@ -0,0 +1 @@
|
|||
* @hyson710 @gzh-terry @chengkai15 @huangyulong3 @zhongzhijie1 @zhangyuan376
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
# 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.
|
||||
#
|
||||
name: Bug report
|
||||
description: Report a bug to improve openvela stability
|
||||
title: "[BUG] <title>"
|
||||
labels: [👀 needs triage, "Type: Bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Hello openvela Community member! Please keep things tidy by putting your post in the proper place:
|
||||
|
||||
Reporting a bug: use this form.
|
||||
Asking a question or getting help: use the [General Help](./new?assignees=&labels=Community%3A+Question&projects=&template=003_help.yml&title=%5BHELP%5D+%3Ctitle%3E) form.
|
||||
Requesting a new feature: use the [Feature request](./new?assignees=&labels=Type%3A+Enhancement&projects=&template=002_feature_request.yml&title=%5BFEATURE%5D+%3Ctitle%3E) form.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description / Steps to reproduce the issue"
|
||||
description: "A clear and concise description of what the bug is, and why you consider it to be a bug, and steps for how to reproduce it"
|
||||
placeholder: |
|
||||
A description with steps to reproduce the issue.
|
||||
May include logs, images, or videos.
|
||||
1. Step 1
|
||||
2. Step 2
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: architecture
|
||||
attributes:
|
||||
label: Issue Architecture
|
||||
description: What architecture(s) are you seeing the problem on?
|
||||
multiple: true
|
||||
options:
|
||||
- "[Arch: arm]"
|
||||
- "[Arch: arm64]"
|
||||
- "[Arch: x86_64]"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Before You Submit
|
||||
|
||||
Please verify that you've followed these steps:
|
||||
- Confirm the problem is reproducible on [**dev**](../).
|
||||
- Run `make distclean` when encountering build issues.
|
||||
- Search [existing issues](./) (including [closed](./?q=is%3Aissue+is%3Aclosed))
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
# 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.
|
||||
#
|
||||
name: Feature request
|
||||
description: Request an enhancement for openvela
|
||||
title: "[FEATURE] <title>"
|
||||
labels: ["Type: Enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Hello openvela Community member! Please keep things tidy by putting your post in the proper place:
|
||||
|
||||
Requesting a new feature: use this form.
|
||||
Asking a question or getting help: use the [General Help](./new?assignees=&labels=Community%3A+Question&projects=&template=003_help.yml&title=%5BHELP%5D+%3Ctitle%3E) form.
|
||||
Reporting a bug: use the [Bug report](./new?assignees=&labels=%F0%9F%91%80+needs+triage%2CType%3A+Bug&projects=&template=001_bug_report.yml&title=%5BBUG%5D+%3Ctitle%3E) form.
|
||||
|
||||
- type: textarea
|
||||
id: question-description
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe.
|
||||
description: Please provide a clear and concise description of what the problem is. Add relevant issue link.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: Please provide a clear and concise description of what you want to happen.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description: Please provide a clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Before You Submit
|
||||
|
||||
Please verify that you've followed these steps:
|
||||
- Search [existing feature requests](./) (including [closed](./?q=is%3Aissue+is%3Aclosed))
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# 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.
|
||||
#
|
||||
name: General Help
|
||||
description: Get general support regarding openvela
|
||||
title: "[HELP] <title>"
|
||||
labels: ["Community: Question"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Hello openvela Community member! Please keep things tidy by putting your post in the proper place:
|
||||
|
||||
Asking a question or getting help: use this form.
|
||||
Reporting a bug: use the [Bug report](./new?assignees=&labels=%F0%9F%91%80+needs+triage%2CType%3A+Bug&projects=&template=001_bug_report.yml&title=%5BBUG%5D+%3Ctitle%3E) form.
|
||||
Requesting a new feature: use the [Feature request](./new?assignees=&labels=Type%3A+Enhancement&projects=&template=002_feature_request.yml&title=%5BFEATURE%5D+%3Ctitle%3E) form
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Whether you're a beginner or an experienced developer, openvela Help is here to assist you with all your openvela questions and concerns.
|
||||
|
||||
- type: textarea
|
||||
id: question-description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Explain the background or context of your question. This helps others understand your problem or inquiry better.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Before You Submit
|
||||
|
||||
Please verify that you've followed these steps:
|
||||
- I have searched [openvela Documentation](../) and didn't find an answer to my question.
|
||||
- Search [existing issues](./) (including [closed](./?q=is%3Aissue+is%3Aclosed))
|
||||
|
|
@ -0,0 +1 @@
|
|||
blank_issues_enabled: false
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
*Note: Please adhere to [Contributing Guidelines](https://github.com/open-vela/docs/blob/dev/CONTRIBUTING.md).*
|
||||
|
||||
## Summary
|
||||
|
||||
*Update this section with information on why change is necessary,
|
||||
what it exactly does and how, if new feature shows up, provide
|
||||
references (dependencies, similar problems and solutions), etc.*
|
||||
|
||||
## Impact
|
||||
|
||||
*Update this section, where applicable, on how change affects users,
|
||||
build process, hardware, documentation, security, compatibility, etc.*
|
||||
|
||||
## Testing
|
||||
|
||||
*Update this section with details on how did you verify the change,
|
||||
what Host was used for build (OS, CPU, compiler, ..), what Target was
|
||||
used for verification (arch, board:config, ..), etc. Providing build
|
||||
and runtime logs from before and after change is highly appreciated.*
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: checkpatch
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
checkpatch:
|
||||
uses: open-vela/public-actions/.github/workflows/checkpatch.yml@dev
|
||||
secrets: inherit
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: CI
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
ci:
|
||||
uses: open-vela/public-actions/.github/workflows/ci.yml@dev
|
||||
secrets: inherit
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: clang-format
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
clang-format:
|
||||
uses: open-vela/public-actions/.github/workflows/clang-format.yml@dev
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
name: 'Close stale issues and PR'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
workflow_dispatch: # 允许手动触发
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
uses: open-vela/public-actions/.github/workflows/stale.yml@dev
|
||||
secrets: inherit
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
*.o
|
||||
*.built
|
||||
*.depend
|
||||
*.dep
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
bootstrap_go_package {
|
||||
name: "soong-frameworkBluetooth",
|
||||
pkgPath: "android/soong/frameworkBluetooth",
|
||||
deps: [
|
||||
"soong-android",
|
||||
"soong-cc",
|
||||
],
|
||||
srcs: [
|
||||
"frameworkBluetooth.go",
|
||||
"frameworkBluetoothBin.go",
|
||||
],
|
||||
pluginFor: ["soong_build"],
|
||||
}
|
||||
|
||||
frameworkBluetooth_cc_library {
|
||||
name : "libbt-framework-client",
|
||||
min_sdk_version: "33",
|
||||
|
||||
srcs : [
|
||||
"framework/common/*.c",
|
||||
"framework/socket/*.c",
|
||||
"service/common/index_allocator.c",
|
||||
"service/ipc/socket/src/bt_socket_client.c",
|
||||
"service/ipc/socket/src/bt_socket_adapter.c",
|
||||
"service/ipc/socket/src/bt_socket_advertiser.c",
|
||||
"service/ipc/socket/src/bt_socket_avrcp_control.c",
|
||||
"service/ipc/socket/src/bt_socket_scan.c",
|
||||
"service/ipc/socket/src/bt_socket_gattc.c",
|
||||
"service/ipc/socket/src/bt_socket_gatts.c",
|
||||
"service/ipc/socket/src/bt_socket_a2dp_sink.c",
|
||||
"service/ipc/socket/src/bt_socket_a2dp_source.c",
|
||||
"service/ipc/socket/src/bt_socket_avrcp_target.c",
|
||||
"service/ipc/socket/src/bt_socket_hfp_ag.c",
|
||||
"service/ipc/socket/src/bt_socket_hfp_hf.c",
|
||||
"service/ipc/socket/src/bt_socket_hid_device.c",
|
||||
"service/ipc/socket/src/bt_socket_l2cap.c",
|
||||
"service/ipc/socket/src/bt_socket_spp.c",
|
||||
"service/src/manager_service.c",
|
||||
],
|
||||
|
||||
include_dirs : [
|
||||
"vendor/vela/apps/system/libuv/libuv/include",
|
||||
"vendor/vela/apps/system/libuv/libuv/src",
|
||||
],
|
||||
|
||||
local_include_dirs : [
|
||||
"framework/include",
|
||||
"service",
|
||||
"service/common",
|
||||
"service/ipc",
|
||||
"service/ipc/socket/include",
|
||||
"service/profiles",
|
||||
"service/profiles/include",
|
||||
"service/src",
|
||||
"dfx",
|
||||
],
|
||||
|
||||
static_libs : [
|
||||
"libuv",
|
||||
],
|
||||
|
||||
shared_libs : [
|
||||
"liblog",
|
||||
],
|
||||
|
||||
cflags : [
|
||||
//"-DANDROID",
|
||||
"-Werror",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-typedef-redefinition",
|
||||
],
|
||||
|
||||
apex_available : [
|
||||
"//apex_available:platform",
|
||||
"com.android.btservices",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"kernel_modules_headers",
|
||||
],
|
||||
}
|
||||
|
||||
frameworkBluetooth_cc_binary {
|
||||
name : "bttool",
|
||||
|
||||
srcs : [
|
||||
"tools/bt_tools.c",
|
||||
"tools/adv.c",
|
||||
"tools/scan.c",
|
||||
"tools/gatt_client.c",
|
||||
"tools/gatt_server.c",
|
||||
"tools/a2dp_sink.c",
|
||||
"tools/a2dp_source.c",
|
||||
"tools/hfp_ag.c",
|
||||
"tools/hfp_hf.c",
|
||||
"tools/hid_device.c",
|
||||
"tools/l2cap.c",
|
||||
"tools/spp.c",
|
||||
"tools/log.c",
|
||||
"tools/utils.c",
|
||||
],
|
||||
|
||||
include_dirs : [
|
||||
"vendor/vela/apps/system/libuv/libuv/include",
|
||||
"vendor/vela/apps/system/libuv/libuv/src",
|
||||
],
|
||||
|
||||
local_include_dirs : [
|
||||
"framework/include",
|
||||
"service",
|
||||
"service/common",
|
||||
"service/utils",
|
||||
],
|
||||
|
||||
static_libs : [
|
||||
"libuv",
|
||||
],
|
||||
|
||||
shared_libs : [
|
||||
"liblog",
|
||||
"libbt-framework-client",
|
||||
],
|
||||
|
||||
cflags : [
|
||||
//"-DANDROID",
|
||||
"-Werror",
|
||||
"-Wno-unused-parameter",
|
||||
"-Wno-unused-function",
|
||||
"-Wno-unused-variable",
|
||||
],
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,878 @@
|
|||
#
|
||||
# Copyright (C) 2020 Xiaomi Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
|
||||
menuconfig BLUETOOTH
|
||||
bool "Bluetooth"
|
||||
default n
|
||||
depends on LIBUV
|
||||
depends on LIBUV_EXTENSION
|
||||
|
||||
if BLUETOOTH
|
||||
menuconfig BLUETOOTH_FRAMEWORK
|
||||
bool "Framework API"
|
||||
default n
|
||||
help
|
||||
Enable Bluetooth Framework API
|
||||
|
||||
if BLUETOOTH_FRAMEWORK
|
||||
choice
|
||||
prompt "Select Bluetooth framework type"
|
||||
default BLUETOOTH_FRAMEWORK_LOCAL
|
||||
config BLUETOOTH_FRAMEWORK_LOCAL
|
||||
bool "Use local API without IPC"
|
||||
config BLUETOOTH_FRAMEWORK_SOCKET_IPC
|
||||
bool "Use socket IPC API"
|
||||
endchoice
|
||||
|
||||
if BLUETOOTH_FRAMEWORK_SOCKET_IPC
|
||||
config BLUETOOTH_RPMSG_CPUNAME
|
||||
string "Bluetooth RPMsg CPU name"
|
||||
default "cp"
|
||||
help
|
||||
Bluetooth default server name
|
||||
|
||||
config BLUETOOTH_SOCKET_BUF_SIZE
|
||||
int "Bluetooth socket buffer size"
|
||||
default 1024
|
||||
help
|
||||
Bluetooth socket buffer size
|
||||
|
||||
config BLUETOOTH_SOCKET_PORT
|
||||
int "Bluetooth socket port num"
|
||||
default 140704
|
||||
help
|
||||
Socket port of inet
|
||||
|
||||
endif #BLUETOOTH_FRAMEWORK_SOCKET_IPC
|
||||
|
||||
config BLUETOOTH_FRAMEWORK_ASYNC
|
||||
bool "Enable Bluetooth Framework async API"
|
||||
default n
|
||||
help
|
||||
Enable Bluetooth Framework async API
|
||||
|
||||
choice
|
||||
prompt "Select feature API"
|
||||
default BLUETOOTH_FEATURE_NONE
|
||||
config BLUETOOTH_FEATURE_NONE
|
||||
bool "Not supporting Bluetooth feature API."
|
||||
config BLUETOOTH_FEATURE
|
||||
bool "Support Bluetooth synchronization API."
|
||||
depends on FEATURE_FRAMEWORK
|
||||
config BLUETOOTH_FEATURE_ASYNC
|
||||
bool "Support Bluetooth asynchronous API."
|
||||
depends on FEATURE_FRAMEWORK
|
||||
depends on BLUETOOTH_FRAMEWORK_ASYNC
|
||||
endchoice
|
||||
|
||||
endif #BLUETOOTH_FRAMEWORK
|
||||
|
||||
menu "Core"
|
||||
config BLUETOOTH_BREDR_SUPPORT
|
||||
bool "Bluetooth BREDR"
|
||||
default y
|
||||
|
||||
config BLUETOOTH_BLE_SUPPORT
|
||||
bool "Bluetooth LE"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_BLE_ADV
|
||||
bool "LE Advertising support"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_BLE_SCAN
|
||||
bool "LE Scan support"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_BLE_SCAN_FILTER
|
||||
bool "LE Scan Filter support"
|
||||
default n
|
||||
depends on BLUETOOTH_BLE_SCAN
|
||||
|
||||
config BLUETOOTH_HCI_FILTER
|
||||
bool "Enable Bluetooth HCI filter"
|
||||
default y
|
||||
help
|
||||
Enable Bluetooth HCI filter
|
||||
|
||||
config BLUETOOTH_L2CAP
|
||||
bool "L2CAP dynamic channel support"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_L2CAP
|
||||
config BLUETOOTH_L2CAP_OUTGOING_MTU
|
||||
int "Outgoing MTU"
|
||||
default 2048
|
||||
help
|
||||
config L2CAP Outgoing MTU
|
||||
|
||||
endif #BLUETOOTH_L2CAP
|
||||
|
||||
choice
|
||||
prompt "Select BT vendor"
|
||||
default BLUETOOTH_VENDOR_NONE
|
||||
config BLUETOOTH_VENDOR_BES
|
||||
bool "Bluetooth vendor BES"
|
||||
config BLUETOOTH_VENDOR_ACTIONS
|
||||
bool "Bluetooth vendor ACTIONS"
|
||||
config BLUETOOTH_VENDOR_NONE
|
||||
bool "Bluetooth vendor NONE"
|
||||
endchoice
|
||||
|
||||
config BLUETOOTH_PM_MAX_TIMER_NUMBER
|
||||
int "Bluetooth PM maximum number of timers"
|
||||
default 16
|
||||
|
||||
config BLUETOOTH_UPGRADE
|
||||
bool "Enable Bluetooth Storage transformation tool for upgrading OS"
|
||||
default n
|
||||
depends on KVDB
|
||||
depends on UNQLITE
|
||||
|
||||
config BLUETOOTH_TASK_STACK_SIZE
|
||||
int "Bluetooth task stack size"
|
||||
default 8192
|
||||
help
|
||||
This cofiguration is used to set the stack size of bluetooth task.
|
||||
|
||||
config BLUETOOTH_SERVICE_LOOP_THREAD_STACK_SIZE
|
||||
int "Bluetooth Service loop thread stack size"
|
||||
default 8192
|
||||
|
||||
config BLUETOOTH_SERVICE_LOOP_THREAD_PRIORITY
|
||||
int "Bluetooth Service loop thread priority"
|
||||
default 103
|
||||
|
||||
config BLUETOOTH_MAX_SAVED_REMOTE_UUIDS_LEN
|
||||
int "Bluetooth saved remote uuids length"
|
||||
default 80
|
||||
|
||||
config BLUETOOTH_MAX_REGISTER_NUM
|
||||
int "Max register callback nums"
|
||||
default 4
|
||||
|
||||
endmenu #Core
|
||||
|
||||
menuconfig BLUETOOTH_SERVICE
|
||||
bool "Service"
|
||||
default n
|
||||
help
|
||||
Enable Bluetooth Service
|
||||
|
||||
if BLUETOOTH_SERVICE
|
||||
menuconfig BLUETOOTH_SERVER
|
||||
bool "Bluetooth Server"
|
||||
default n
|
||||
help
|
||||
Enable Bluetooth server
|
||||
|
||||
if BLUETOOTH_SERVER
|
||||
config BLUETOOTH_SERVER_NAME
|
||||
string "Blutooth Server name"
|
||||
default "bluetoothd"
|
||||
help
|
||||
Bluetooth default server name
|
||||
|
||||
config BLUETOOTH_IPC_JOIN_LOOP
|
||||
bool "Let IPC join service loop"
|
||||
default n
|
||||
help
|
||||
Bluetooth IPC join service loop
|
||||
|
||||
config BLUETOOTH_NET_IPv4
|
||||
bool "Let Bluetooth Server listen message from network"
|
||||
default n
|
||||
depends on NET_IPv4
|
||||
help
|
||||
Bluetooth server listen message
|
||||
|
||||
endif #BLUETOOTH_SERVER
|
||||
|
||||
if BLUETOOTH_BREDR_SUPPORT
|
||||
menu "Bluetooth BREDR Config"
|
||||
choice
|
||||
prompt "Select BR stack"
|
||||
default BLUETOOTH_STACK_BREDR_BLUELET
|
||||
config BLUETOOTH_STACK_BREDR_BLUELET
|
||||
bool "Classic BT stack use bluelet"
|
||||
select LIB_BLUELET
|
||||
config BLUETOOTH_STACK_BREDR_ZBLUE
|
||||
bool "Classic BT stack use zblue"
|
||||
config BLUETOOTH_STACK_NOT_SUPPORT_CLASSIC_BT
|
||||
bool "Not support classic BT stack"
|
||||
endchoice
|
||||
|
||||
endmenu #Bluetooth BREDR Config
|
||||
endif #BLUETOOTH_BREDR_SUPPORT
|
||||
|
||||
if BLUETOOTH_BLE_SUPPORT
|
||||
menu "Bluetooth LE Config"
|
||||
choice
|
||||
prompt "Select LE stack"
|
||||
default BLUETOOTH_STACK_LE_BLUELET
|
||||
config BLUETOOTH_STACK_LE_BLUELET
|
||||
bool "BLE Stack use Bluelet"
|
||||
select LIB_BLUELET
|
||||
config BLUETOOTH_STACK_LE_ZBLUE
|
||||
bool "BLE Stack use Zblue"
|
||||
config BLUETOOTH_STACK_NOT_SUPPORT_LE
|
||||
bool "Not support BLE Stack"
|
||||
endchoice
|
||||
|
||||
config BLUETOOTH_LE_SCANNER_MAX_NUM
|
||||
int "LE Scanner max register number"
|
||||
default 2
|
||||
help
|
||||
LE Scanner max register number
|
||||
|
||||
config BLUETOOTH_LE_ADVERTISER_MAX_NUM
|
||||
int "LE Advertiser max register number"
|
||||
default 2
|
||||
help
|
||||
LE Advertiser max register number
|
||||
|
||||
config BLUETOOTH_CONNECTION_MANAGER
|
||||
bool "Bluetooth connection manager support"
|
||||
default y
|
||||
|
||||
config LE_DLF_SUPPORT
|
||||
bool "Enable LE DLF support"
|
||||
depends on BLUETOOTH_CONNECTION_MANAGER
|
||||
default n
|
||||
|
||||
endmenu #Bluetooth LE Config
|
||||
endif #BLUETOOTH_BLE_SUPPORT
|
||||
|
||||
choice
|
||||
prompt "Select Bluetooth Storage Method(Unqlite, KVDB)"
|
||||
default BLUETOOTH_STORAGE_PROPERTY_SUPPORT
|
||||
config BLUETOOTH_STORAGE_PROPERTY_SUPPORT
|
||||
bool "Bluetooth Storage KVDB Property support"
|
||||
depends on KVDB
|
||||
config BLUETOOTH_STORAGE_UNQLITE_SUPPORT
|
||||
bool "Bluetooth Storage uv_db support"
|
||||
depends on UNQLITE
|
||||
endchoice
|
||||
|
||||
config BLUETOOTH_STORAGE_UPDATE
|
||||
bool "Bluetooth Storage update"
|
||||
default y
|
||||
depends on BLUETOOTH_STORAGE_PROPERTY_SUPPORT
|
||||
|
||||
config BLUETOOTH_SERVICE_HCI_UART_NAME
|
||||
string "HCI uart driver name"
|
||||
default "/dev/ttyHCI0"
|
||||
|
||||
config BLUETOOTH_HCI_BRIDGE_MODE
|
||||
bool "HCI bridge mode"
|
||||
default n
|
||||
|
||||
config CONFIG_BLUETOOTH_DEFAULT_COD
|
||||
hex "Default class of device"
|
||||
default 0x00280704
|
||||
help
|
||||
Set default class of device
|
||||
|
||||
endif #BLUETOOTH_SERVICE
|
||||
|
||||
menu "Profiles"
|
||||
menuconfig BLUETOOTH_A2DP
|
||||
bool "Advanced Audio Distribution Profile (A2DP)"
|
||||
default n
|
||||
depends on MEDIA
|
||||
|
||||
if BLUETOOTH_A2DP
|
||||
config BLUETOOTH_A2DP_SOURCE
|
||||
bool "A2DP source role support"
|
||||
default n
|
||||
select BLUETOOTH_AVRCP_TARGET
|
||||
|
||||
config ZBLUE_A2DP_SBC_MAX_BIT_POOL
|
||||
int "A2DP sbc codec max bit pool"
|
||||
default 32
|
||||
depends on BLUETOOTH_STACK_BREDR_ZBLUE
|
||||
help
|
||||
A2DP sbc codec max bit pool 1~53
|
||||
|
||||
if BLUETOOTH_A2DP_SOURCE
|
||||
config BLUETOOTH_A2DP_PEER_PARTIAL_RECONN
|
||||
bool "Bluetooth A2DP peer partial reconnect support"
|
||||
default y
|
||||
help
|
||||
Bluetooth A2DP peer partial reconnect support
|
||||
|
||||
config ZBLUE_A2DP_SOURCE_BUF_SIZE
|
||||
int "A2DP source buffer size"
|
||||
default 660
|
||||
depends on BLUETOOTH_STACK_BREDR_ZBLUE
|
||||
help
|
||||
Buffer size is related to L2CAP TX MTU
|
||||
|
||||
endif #BLUETOOTH_A2DP_SOURCE
|
||||
|
||||
config BLUETOOTH_A2DP_SINK
|
||||
bool "A2DP sink role support"
|
||||
default n
|
||||
select BLUETOOTH_AVRCP_CONTROL
|
||||
|
||||
config BLUETOOTH_A2DP_AAC_CODEC
|
||||
bool "Bluetooth A2DP AAC codec support"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_A2DP_MAX_CONNECTIONS
|
||||
int "Maximum A2DP connections"
|
||||
default 1
|
||||
help
|
||||
Maximum A2DP connections
|
||||
|
||||
endif #BLUETOOTH_A2DP
|
||||
|
||||
menu "Audio/Video Remote Control Profile (AVRCP)"
|
||||
config BLUETOOTH_AVRCP_TARGET
|
||||
bool "Audio/Video Remote Control Profile (Target) support"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_AVRCP_CONTROL
|
||||
bool "Audio/Video Remote Control Profile (Control) support"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_AVRCP_ABSOLUTE_VOLUME
|
||||
bool "Audio/Video Remote Control Profile support absolute volume"
|
||||
default n
|
||||
depends on (BLUETOOTH_AVRCP_CONTROL || BLUETOOTH_AVRCP_TARGET) && ((BLUETOOTH_STACK_BREDR_BLUELET && BLUELET_AVRCP_TG_ABSVOL_SUPPORT) || (BLUETOOTH_STACK_BREDR_ZBLUE))
|
||||
endmenu #Audio/Video Remote Control Profile
|
||||
|
||||
menu "Hands-Free Profile (HFP)"
|
||||
config BLUETOOTH_HFP_HF
|
||||
bool "HFP hands-free profile support"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_HFP_HF
|
||||
config HFP_HF_MAX_CONNECTIONS
|
||||
int "HFP hands-free max connections"
|
||||
default 1
|
||||
|
||||
config HFP_HF_WEBCHAT_BLOCKER
|
||||
bool "Block webchat automatically"
|
||||
default y
|
||||
|
||||
endif #BLUETOOTH_HFP_HF
|
||||
|
||||
config BLUETOOTH_HFP_AG
|
||||
bool "HFP audio-gateway profile support"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_HFP_AG
|
||||
config HFP_AG_MAX_CONNECTIONS
|
||||
int "HFP audio-gateway max connections"
|
||||
default 1
|
||||
|
||||
config BLUETOOTH_HFP_AG_PRIMARY_SLOT
|
||||
int "HFP select primary modem slot"
|
||||
default 0
|
||||
|
||||
endif # BLUETOOTH_HFP_AG
|
||||
|
||||
config BLUETOOTH_SCO_CTRL_PATH
|
||||
string "Bluetooth SCO Transport Ctrl Path"
|
||||
default "sco_ctrl"
|
||||
|
||||
endmenu #Hands-Free Profile
|
||||
|
||||
menu "LE Audio"
|
||||
comment "There should be two \"LE Audio support\" options, if you only see one, please enable \"Bluetooth BLE support\" in Framework"
|
||||
|
||||
config BLUETOOTH_BLE_AUDIO
|
||||
bool "LE Audio support"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_BLE_SUPPORT
|
||||
config BLUETOOTH_LE_AUDIO_SUPPORT
|
||||
bool "LE Audio support"
|
||||
default n
|
||||
|
||||
endif #BLUETOOTH_BLE_SUPPORT
|
||||
|
||||
menuconfig BLUETOOTH_LEAUDIO_CLIENT
|
||||
bool "Bluetooth LE Audio Client"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_LEAUDIO_CLIENT
|
||||
config BLUETOOTH_LEAUDIO_TBS
|
||||
bool "Enable Bluetooth LE Audio TBS feature"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_LEAUDIO_TBS
|
||||
config BLUETOOTH_LEAUDIO_TBS_PRIMARY_SLOT
|
||||
int "LE Audio TBS select primary modem slot"
|
||||
default 0
|
||||
|
||||
config BLUETOOTH_LEAUDIO_TBS_CALL_NAME
|
||||
string "LE Audio call name"
|
||||
default "/ril_0/voicecall0"
|
||||
|
||||
endif # BLUETOOTH_LEAUDIO_TBS
|
||||
|
||||
config BLUETOOTH_LEAUDIO_MCS
|
||||
bool "Enable Bluetooth LE Audio MCS feature"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_LEAUDIO_VMICP
|
||||
bool "Enable Bluetooth LE Audio VMICP feature"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_MAX_CONNECTIONS
|
||||
int "LE Audio Client max connections"
|
||||
default 4
|
||||
help
|
||||
LE Audio Client max connections
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_MAX_GROUP
|
||||
int "LE Audio Client max group"
|
||||
default 4
|
||||
help
|
||||
LE Audio Client max HFP_AG_MAX_CONNECTIONS
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_MAX_DEVICES
|
||||
int "LE Audio Client max devices"
|
||||
default 8
|
||||
help
|
||||
LE Audio Client max devices
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_MAX_ALLOC_NUMBER
|
||||
int "LE Audio Client max alloc number"
|
||||
default 64
|
||||
help
|
||||
LE Audio Client max group
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_ASE_MAX_NUMBER
|
||||
int "LE Audio Client max ase number"
|
||||
default 2
|
||||
help
|
||||
LE Audio Client max ase number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_PAC_MAX_NUMBER
|
||||
int "LE Audio Client max pac number"
|
||||
default 3
|
||||
help
|
||||
LE Audio Client max pac number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_CIS_MAX_NUMBER
|
||||
int "LE Audio Client max cis number"
|
||||
default 2
|
||||
help
|
||||
LE Audio Client max cis number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_CLIENT_METADATA_MAX_NUMBER
|
||||
int "LE Audio Client max metadata number"
|
||||
default 4
|
||||
help
|
||||
LE Audio Client max metadata number
|
||||
|
||||
endif # BLUETOOTH_LEAUDIO_CLIENT
|
||||
|
||||
|
||||
menuconfig BLUETOOTH_LEAUDIO_SERVER
|
||||
bool "Bluetooth LE Audio Server"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_LEAUDIO_SERVER
|
||||
config BLUETOOTH_LEAUDIO_CCP
|
||||
bool "Enable Bluetooth LE Audio CCP feature"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_LEAUDIO_CCP
|
||||
config BLUETOOTH_LEAUDIO_SERVER_CALL_CONTROL_NUMBER
|
||||
int "LE Audio TBS server number"
|
||||
default 1
|
||||
help
|
||||
LE Audio TBS server number
|
||||
|
||||
endif # BLUETOOTH_LEAUDIO_CCP
|
||||
|
||||
config BLUETOOTH_LEAUDIO_MCP
|
||||
bool "Enable Bluetooth LE Audio MCP feature"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_LEAUDIO_MCP
|
||||
config BLUETOOTH_LEAUDIO_SERVER_MEDIA_CONTROL_NUMBER
|
||||
int "LE Audio MCS server number"
|
||||
default 1
|
||||
help
|
||||
LE Audio MCS server number
|
||||
|
||||
endif # BLUETOOTH_LEAUDIO_MCP
|
||||
|
||||
menuconfig BLUETOOTH_LEAUDIO_VMICS
|
||||
bool "Enable Bluetooth LE Audio VMICS feature"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_LEAUDIO_VMICS
|
||||
config BLUETOOTH_LEAUDIO_VCS_VOLUME_STEP
|
||||
int "LE Audio Server VCS volume step size"
|
||||
default 2
|
||||
help
|
||||
LE Audio Server VCS volume step size
|
||||
|
||||
config BLUETOOTH_LEAUDIO_VOCS_NUMBER
|
||||
int "LE Audio Server VOCS numnber"
|
||||
default 0
|
||||
help
|
||||
LE Audio Server VOCS number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_AICS_NUMBER
|
||||
int "LE Audio Server AICS numnber"
|
||||
default 0
|
||||
help
|
||||
LE Audio Server AICS numnber
|
||||
|
||||
config BLUETOOTH_LEAUDIO_VCS_VOLUME_INITIAL
|
||||
int "LE Audio Server VCS initial volume value"
|
||||
default 125
|
||||
help
|
||||
LE Audio Server VCS volume initial value
|
||||
|
||||
config BLUETOOTH_LEAUDIO_VCS_UNMUTED
|
||||
int "LE Audio Server VCS unmute"
|
||||
default 0
|
||||
help
|
||||
LE Audio Server VCS unmute
|
||||
|
||||
config BLUETOOTH_LEAUDIO_VCS_VOLUME_DEFAULT_SETTING
|
||||
int "LE Audio Server VCS vol settings"
|
||||
default 0
|
||||
help
|
||||
LE Audio Server VCS vol settings
|
||||
|
||||
config BLUETOOTH_LEAUDIO_MICS_NUMBER
|
||||
int "LE Audio Server MICS numnber"
|
||||
default 0
|
||||
help
|
||||
LE Audio Server MICS number
|
||||
|
||||
endif # BLUETOOTH_LEAUDIO_VMICS
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_SINK_ASE_NUMBER
|
||||
int "LE Audio Server Sink number"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server Sink ase number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_SOURCE_ASE_NUMBER
|
||||
int "LE Audio Server Source number"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server Source ase number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_BASS_STATE_NUMBER
|
||||
int "LE Audio Server Bass state number"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server Bass state number
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_SOURCE
|
||||
bool "Enable LE Audio Server source"
|
||||
default y
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_SOURCE_LOCATION
|
||||
int "LE Audio Server source location"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server source location
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_SINK_LOCATION
|
||||
int "LE Audio Server sink location"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server sink location
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_CSIS_SIZE
|
||||
int "LE Audio Server CSIS set size"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server CSIS set size
|
||||
|
||||
config BLUETOOTH_LEAUDIO_SERVER_CSIS_RANK
|
||||
int "LE Audio Server CSIS rank"
|
||||
default 1
|
||||
help
|
||||
LE Audio Server CSIS rank
|
||||
|
||||
endif # BLUETOOTH_LEAUDIO_SERVER
|
||||
|
||||
endmenu #Bluetooth LE Audio
|
||||
|
||||
menu "Bluetooth Audio Transport"
|
||||
config BLUETOOTH_AUDIO_TRANS_RPSMG_SERVER
|
||||
bool "RPMsg audio transport server"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_AUDIO_TRANS_ID_SOURCE_CTRL
|
||||
int "Bluetooth Audio Transport Source Ctrl Channel ID"
|
||||
default 0
|
||||
|
||||
config BLUETOOTH_AUDIO_TRANS_ID_SOURCE_AUDIO
|
||||
int "Bluetooth Audio Transport Source Audio Channel ID"
|
||||
default 1
|
||||
|
||||
config BLUETOOTH_AUDIO_TRANS_ID_SINK_CTRL
|
||||
int "Bluetooth Audio Transport Sink Ctrl Channel ID"
|
||||
default 2
|
||||
|
||||
config BLUETOOTH_AUDIO_TRANS_ID_SINK_AUDIO
|
||||
int "Bluetooth Audio Transport Sink Audio Channel ID"
|
||||
default 3
|
||||
|
||||
config BLUETOOTH_AUDIO_TRANS_ID_HFP_CTRL
|
||||
int "Bluetooth Audio Transport SCO Ctrl Channel ID"
|
||||
default 4
|
||||
|
||||
config BLUETOOTH_LEA_SINK_CTRL_PATH
|
||||
string "Bluetooth LE Audio Transport Sink Ctrl Path"
|
||||
default "lea_sink_ctrl"
|
||||
|
||||
config BLUETOOTH_LEA_SINK_DATA_PATH
|
||||
string "Bluetooth LE Audio Transport Sink Data Path"
|
||||
default "lea_sink_data"
|
||||
|
||||
config BLUETOOTH_LEA_SOURCE_CTRL_PATH
|
||||
string "Bluetooth LE Audio Transport Source Ctrl Path"
|
||||
default "lea_source_ctrl"
|
||||
|
||||
config BLUETOOTH_LEA_SOURCE_DATA_PATH
|
||||
string "Bluetooth LE Audio Transport Source Data Path"
|
||||
default "lea_source_data"
|
||||
|
||||
config BLUETOOTH_A2DP_SINK_CTRL_PATH
|
||||
string "Bluetooth A2DP Audio Transport Sink Ctrl Path"
|
||||
default "a2dp_sink_ctrl"
|
||||
|
||||
config BLUETOOTH_A2DP_SINK_DATA_PATH
|
||||
string "Bluetooth A2DP Audio Transport Sink Data Path"
|
||||
default "a2dp_sink_data"
|
||||
|
||||
config BLUETOOTH_A2DP_SOURCE_CTRL_PATH
|
||||
string "Bluetooth A2DP Audio Transport Source Ctrl Path"
|
||||
default "a2dp_source_ctrl"
|
||||
|
||||
config BLUETOOTH_A2DP_SOURCE_DATA_PATH
|
||||
string "Bluetooth A2DP Audio Transport Source Data Path"
|
||||
default "a2dp_source_data"
|
||||
|
||||
endmenu #Bluetooth Audio Transport config
|
||||
|
||||
config BLUETOOTH_GATT
|
||||
bool "Generic ATT Profile Support(deprecated)"
|
||||
default y
|
||||
|
||||
menuconfig BLUETOOTH_GATT_CLIENT
|
||||
bool "Generic Attribute Profile (GATT) Client"
|
||||
default n if !BLUETOOTH_GATT
|
||||
default y if BLUETOOTH_GATT
|
||||
|
||||
if BLUETOOTH_GATT_CLIENT
|
||||
config BLUETOOTH_GATTC_MAX_CONNECTIONS
|
||||
int "GATT Client max connections"
|
||||
default 8
|
||||
|
||||
config GATT_CLIENT_SERVICE_MAX
|
||||
int "Maximum number of discovered services per connection"
|
||||
default 20
|
||||
depends on BLUETOOTH_GATT_CLIENT && BLUETOOTH_STACK_LE_ZBLUE && BT_GATT_CLIENT
|
||||
help
|
||||
The maximum number of GATT services that can be stored per BLE connection
|
||||
when using the ZBLUE stack.
|
||||
|
||||
config GATT_CLIENT_ELEMENT_MAX
|
||||
int "Maximum number of discovered GATT attributes per connection"
|
||||
default 200
|
||||
depends on BLUETOOTH_GATT_CLIENT && BLUETOOTH_STACK_LE_ZBLUE && BT_GATT_CLIENT
|
||||
help
|
||||
The maximum number of GATT attribute elements (e.g., characteristics
|
||||
and descriptors) that can be stored per BLE connection
|
||||
when using the ZBLUE stack.
|
||||
|
||||
config GATT_CLIENT_CHAR_PER_SERVICE_MAX
|
||||
int "Maximum number of characteristics per service"
|
||||
default 100
|
||||
depends on BLUETOOTH_GATT_CLIENT && BLUETOOTH_STACK_LE_ZBLUE && BT_GATT_CLIENT
|
||||
help
|
||||
The maximum number of characteristics that can be discovered and stored
|
||||
under a single GATT service when using the ZBLUE stack.
|
||||
endif # BLUETOOTH_GATT_CLIENT
|
||||
|
||||
menuconfig BLUETOOTH_GATT_SERVER
|
||||
bool "Generic Attribute Profile (GATT) Server"
|
||||
default n if !BLUETOOTH_GATT
|
||||
default y if BLUETOOTH_GATT
|
||||
|
||||
if BLUETOOTH_GATT_SERVER
|
||||
config BLUETOOTH_GATTS_MAX_CONNECTIONS
|
||||
int "GATT Server max connections"
|
||||
default 4
|
||||
|
||||
config BLUETOOTH_GATTS_MAX_ATTRIBUTE_NUM
|
||||
int "GATT Server max number of attributes contained in a table"
|
||||
default 10
|
||||
|
||||
config BLUETOOTH_GATTS_CACHE_SUPPORT
|
||||
bool "Enable GATT Server Cache Support"
|
||||
default y
|
||||
depends on BLUETOOTH_BLE_SUPPORT
|
||||
help
|
||||
Enable internal GATT attribute table hash comparison.
|
||||
On reconnect, trusted devices may receive Service Changed indications
|
||||
if attribute changes are detected.
|
||||
endif # BLUETOOTH_GATT_SERVER
|
||||
|
||||
menuconfig BLUETOOTH_SPP
|
||||
bool "Serial Port Profile (SPP)"
|
||||
default n
|
||||
|
||||
if BLUETOOTH_SPP
|
||||
config BLUETOOTH_SPP_MAX_CONNECTIONS
|
||||
int "SPP max connections"
|
||||
default 1
|
||||
|
||||
config BLUETOOTH_SPP_SERVER_MAX_CONNECTIONS
|
||||
int "SPP Server max connections"
|
||||
default 8
|
||||
|
||||
config BLUETOOTH_SPP_RPMSG_NET
|
||||
bool "SPP RPMsg net support"
|
||||
default n
|
||||
depends on NET_RPMSG
|
||||
|
||||
endif #BLUETOOTH_SPP
|
||||
|
||||
config BLUETOOTH_HID_DEVICE
|
||||
bool "Human Interface Device Profile (HID)"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_PAN
|
||||
bool "Personal Area Network Profile (PAN)"
|
||||
default n
|
||||
depends on ALLOW_BSD_COMPONENTS
|
||||
help
|
||||
config NET_TUN_PKTSIZE should set 1518
|
||||
|
||||
endmenu #Profiles
|
||||
|
||||
menu "Debug"
|
||||
config BLUETOOTH_DEBUG_TIMEVAL
|
||||
bool "Enable Bluetooth debug time"
|
||||
default n
|
||||
help
|
||||
Enable this option to include Bluetooth debug time functionality.
|
||||
|
||||
config BLUETOOTH_DEBUG_TIME_UNIT_US
|
||||
bool "Use microseconds for Bluetooth debug time"
|
||||
default n
|
||||
depends on BLUETOOTH_DEBUG_TIMEVAL
|
||||
help
|
||||
Enable this option to use microseconds (us) for Bluetooth debug time.
|
||||
If disabled, milliseconds (ms) will be used by default.
|
||||
|
||||
config BLUETOOTH_DEBUG_MEMORY
|
||||
bool "Enable Bluetooth debug memory"
|
||||
default n
|
||||
help
|
||||
Enable this option to override standard memory allocation functions
|
||||
(malloc, calloc, free) with Bluetooth-specific versions (bt_malloc, etc).
|
||||
Useful for tracking memory usage and debugging in Bluetooth modules.
|
||||
|
||||
config BLUETOOTH_DEBUG_TRACE
|
||||
bool "Enable Bluetooth debug trace"
|
||||
default n
|
||||
help
|
||||
Enable Bluetooth debug trace tools.
|
||||
|
||||
if BLUETOOTH_DEBUG_TRACE
|
||||
config BLUETOOTH_TRACE_BUFFER_SIZE
|
||||
int "Bluetooth trace buffer size"
|
||||
default 512
|
||||
|
||||
endif #BLUETOOTH_DEBUG_TRACE
|
||||
|
||||
config MAX_SNOOP_FILE_SIZE
|
||||
int "Maximum size of the snoop log file"
|
||||
default 1048576
|
||||
help
|
||||
Maximum size of the snoop log file
|
||||
|
||||
config BLUETOOTH_DUMPBUFFER
|
||||
bool "Bluetooth dumpbuffer"
|
||||
default n
|
||||
|
||||
config BLUETOOTH_DFX
|
||||
bool "Enable Bluetooth DFX"
|
||||
default y
|
||||
depends on DFX_EVENT
|
||||
help
|
||||
Enable Bluetooth DFX
|
||||
|
||||
config BLUETOOTH_LOG
|
||||
bool "Enable Bluetooth log"
|
||||
default y
|
||||
help
|
||||
Enable Bluetooth log
|
||||
|
||||
if BLUETOOTH_LOG
|
||||
config BLUETOOTH_SERVICE_LOG_LEVEL
|
||||
int "Bluetooth Service log level"
|
||||
default 7
|
||||
depends on BLUETOOTH_SERVICE
|
||||
help
|
||||
Set BT Service log level <0~7>
|
||||
endif #BLUETOOTH_LOG
|
||||
|
||||
endmenu #Debug
|
||||
|
||||
config BLUETOOTH_TOOLS
|
||||
bool "Bluetooth profile test tools (BT_TOOLS)"
|
||||
default n
|
||||
select BLUETOOTH_FRAMEWORK
|
||||
|
||||
menuconfig APP_BT_SAMPLE_CODE
|
||||
bool "Sample Code"
|
||||
default n
|
||||
select BLUETOOTH_FRAMEWORK
|
||||
|
||||
if APP_BT_SAMPLE_CODE
|
||||
config APP_BT_SAMPLE_CODE_BASIC
|
||||
bool "Bluetooth basic sample code"
|
||||
default n
|
||||
|
||||
config APP_BT_SAMPLE_CODE_ENABLE
|
||||
bool "Bluetooth enable sample code"
|
||||
default n
|
||||
|
||||
config APP_BT_SAMPLE_CODE_DISCOVERY
|
||||
bool "Bluetooth discovery sample code"
|
||||
default n
|
||||
|
||||
config APP_BT_SAMPLE_CODE_CREATEBOND
|
||||
bool "Bluetooth createbond sample code"
|
||||
default n
|
||||
|
||||
config APP_BT_SAMPLE_CODE_ACCEPTBOND
|
||||
bool "Bluetooth acceptbond sample code"
|
||||
default n
|
||||
|
||||
endif #APP_BT_SAMPLE_CODE
|
||||
|
||||
endif #BLUETOOTH
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
Copyright (C) 2024 Xiaomi Corporation
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#
|
||||
# Copyright (C) 2020 Xiaomi Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH), y)
|
||||
CONFIGURED_APPS += $(APPDIR)/frameworks/connectivity/bluetooth
|
||||
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/framework/include
|
||||
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/framework/include
|
||||
|
||||
endif
|
||||
|
|
@ -0,0 +1,711 @@
|
|||
#
|
||||
# Copyright (C) 2020 Xiaomi Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH), y)
|
||||
|
||||
CSRCS += framework/common/*.c
|
||||
CSRCS += framework/api/bluetooth.c
|
||||
CSRCS += framework/api/bt_adapter.c
|
||||
CSRCS += framework/api/bt_device.c
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
CSRCS += framework/api/bt_a2dp_sink.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SINK
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SOURCE), y)
|
||||
CSRCS += framework/api/bt_a2dp_source.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_TARGET), y)
|
||||
CSRCS += framework/api/bt_avrcp_target.c
|
||||
endif #CONFIG_BLUETOOTH_AVRCP_TARGET
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL), y)
|
||||
CSRCS += framework/api/bt_avrcp_control.c
|
||||
endif #CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_HF), y)
|
||||
CSRCS += framework/api/bt_hfp_hf.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_HF
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_AG), y)
|
||||
CSRCS += framework/api/bt_hfp_ag.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_AG
|
||||
ifeq ($(CONFIG_BLUETOOTH_SPP), y)
|
||||
CSRCS += framework/api/bt_spp.c
|
||||
endif #CONFIG_BLUETOOTH_SPP
|
||||
ifeq ($(CONFIG_BLUETOOTH_HID_DEVICE), y)
|
||||
CSRCS += framework/api/bt_hid_device.c
|
||||
endif #CONFIG_BLUETOOTH_HID_DEVICE
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_CLIENT), y)
|
||||
CSRCS += framework/api/bt_gattc.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_CLIENT
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_SERVER), y)
|
||||
CSRCS += framework/api/bt_gatts.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_SERVER
|
||||
ifeq ($(CONFIG_BLUETOOTH_L2CAP), y)
|
||||
CSRCS += framework/api/bt_l2cap.c
|
||||
endif #CONFIG_BLUETOOTH_L2CAP
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_ADV), y)
|
||||
CSRCS += framework/api/bt_le_advertiser.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_ADV
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_SCAN), y)
|
||||
CSRCS += framework/api/bt_le_scan.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_SCAN
|
||||
ifeq ($(CONFIG_BLUETOOTH_LOG), y)
|
||||
CSRCS += framework/api/bt_trace.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_PAN), y)
|
||||
CSRCS += framework/api/bt_pan.c
|
||||
endif #CONFIG_BLUETOOTH_PAN
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_AUDIO), y)
|
||||
CSRCS := framework/api/bt_lea*.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_AUDIO
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC), y)
|
||||
CSRCS += service/ipc/bluetooth_ipc.c
|
||||
CSRCS += framework/socket/bt_device.c
|
||||
CSRCS += framework/socket/bt_adapter.c
|
||||
CSRCS += framework/socket/bluetooth.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_manager.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_client.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_server.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_device.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_adapter.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_bluetooth.c
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
CSRCS += framework/socket/bt_a2dp_sink.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_a2dp_sink.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SINK
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SOURCE), y)
|
||||
CSRCS += framework/socket/bt_a2dp_source.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_a2dp_source.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_TARGET), y)
|
||||
CSRCS += framework/socket/bt_avrcp_target.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_avrcp_target.c
|
||||
endif #CONFIG_BLUETOOTH_AVRCP_TARGET
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL), y)
|
||||
CSRCS += framework/socket/bt_avrcp_control.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_avrcp_control.c
|
||||
endif #CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_HF), y)
|
||||
CSRCS += framework/socket/bt_hfp_hf.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_hfp_hf.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_HF
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_AG), y)
|
||||
CSRCS += framework/socket/bt_hfp_ag.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_hfp_ag.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_AG
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_SPP), y)
|
||||
CSRCS += framework/socket/bt_spp.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_spp.c
|
||||
endif #CONFIG_BLUETOOTH_SPP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HID_DEVICE), y)
|
||||
CSRCS += framework/socket/bt_hid_device.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_hid_device.c
|
||||
endif #CONFIG_BLUETOOTH_HID_DEVICE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_CLIENT), y)
|
||||
CSRCS += framework/socket/bt_gattc.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_gattc.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_CLIENT
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_SERVER), y)
|
||||
CSRCS += framework/socket/bt_gatts.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_gatts.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_SERVER
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_L2CAP), y)
|
||||
CSRCS += framework/socket/bt_l2cap.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_l2cap.c
|
||||
endif #CONFIG_BLUETOOTH_L2CAP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_ADV), y)
|
||||
CSRCS += framework/socket/bt_le_advertiser.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_advertiser.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_ADV
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_SCAN), y)
|
||||
CSRCS += framework/socket/bt_le_scan.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_scan.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_SCAN
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_PAN), y)
|
||||
CSRCS += framework/socket/bt_pan.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_pan.c
|
||||
endif #CONFIG_BLUETOOTH_PAN
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LOG), y)
|
||||
CSRCS += framework/socket/bt_trace.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_log.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_AUDIO
|
||||
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/ipc/socket/include
|
||||
ifeq ($(CONFIG_BLUETOOTH_FRAMEWORK_ASYNC), y)
|
||||
CSRCS += framework/socket/async/*.c
|
||||
CSRCS += framework/btwrap/async/*.c
|
||||
endif #CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
endif #CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC
|
||||
|
||||
CSRCS += service/src/manager_service.c
|
||||
CSRCS += service/common/index_allocator.c
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_CONNECTION_MANAGER), y)
|
||||
CSRCS += service/src/connection_manager.c
|
||||
endif #CONFIG_BLUETOOTH_CONNECTION_MANAGER
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_PROPERTY_SUPPORT), y)
|
||||
CSRCS += service/common/storage_property.c
|
||||
else
|
||||
CSRCS += service/common/storage.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_UPDATE), y)
|
||||
CSRCS += tools/storage_update/storage_version_4.c
|
||||
CSRCS += tools/storage_update/storage_version_5.c
|
||||
endif #CONFIG_BLUETOOTH_STORAGE_UPDATE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_DEBUG_MEMORY),y)
|
||||
CSRCS += debug/bt_memory.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_DEBUG_TRACE), y)
|
||||
CSRCS += service/debug/bt_trace.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_SERVICE), y)
|
||||
CSRCS += service/common/service_loop.c
|
||||
CSRCS += service/src/adapter_service.c
|
||||
CSRCS += service/src/adapter_state.c
|
||||
CSRCS += service/src/btservice.c
|
||||
CSRCS += service/src/device.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_BREDR_SUPPORT), y)
|
||||
CSRCS += service/src/power_manager.c
|
||||
endif #CONFIG_BLUETOOTH_BREDR_SUPPORT
|
||||
CSRCS += service/vendor/bt_vendor.c
|
||||
CSRCS += service/src/hci_parser.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_ADV), y)
|
||||
CSRCS += service/src/advertising.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_ADV
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_SCAN), y)
|
||||
CSRCS += service/src/scan_manager.c
|
||||
CSRCS += service/src/scan_record.c
|
||||
CSRCS += service/src/scan_filter.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_SCAN
|
||||
ifeq ($(CONFIG_BLUETOOTH_L2CAP), y)
|
||||
CSRCS += service/src/l2cap_service.c
|
||||
endif #CONFIG_BLUETOOTH_L2CAP
|
||||
ifeq ($(CONFIG_LE_DLF_SUPPORT), y)
|
||||
CSRCS += service/src/connection_manager_dlf.c
|
||||
endif #CONFIG_LE_DLF_SUPPORT
|
||||
CSRCS += service/stacks/*.c
|
||||
ifneq ($(CONFIG_BLUETOOTH_STACK_BREDR_BLUELET)$(CONFIG_BLUETOOTH_STACK_LE_BLUELET),)
|
||||
CSRCS += service/stacks/bluelet/*.c
|
||||
endif
|
||||
ifneq ($(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE)$(CONFIG_BLUETOOTH_STACK_LE_ZBLUE),)
|
||||
CSRCS += service/stacks/zephyr/hci_h4.c
|
||||
CSRCS += service/stacks/zephyr/sal_debug_interface.c
|
||||
CSRCS += service/stacks/zephyr/sal_zblue.c
|
||||
CSRCS += service/stacks/zephyr/sal_adapter_interface.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_CONNECTION_MANAGER), y)
|
||||
CSRCS += service/stacks/zephyr/sal_connection_manager.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_SPP), y)
|
||||
CSRCS += service/stacks/zephyr/sal_spp_interface.c
|
||||
endif #CONFIG_BLUETOOTH_SPP
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP), y)
|
||||
CSRCS += service/stacks/zephyr/sal_a2dp_interface.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP
|
||||
ifneq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL)$(CONFIG_BLUETOOTH_AVRCP_TARGET),)
|
||||
CSRCS += service/stacks/zephyr/sal_avrcp_interface.c
|
||||
endif #CONFIG_BLUETOOTH_AVRCP_CONTROL/CONFIG_BLUETOOTH_AVRCP_TARGET
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_HF), y)
|
||||
CSRCS += service/stacks/zephyr/sal_hfp_hf_interface.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_HF
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_AG), y)
|
||||
CSRCS += service/stacks/zephyr/sal_hfp_ag_interface.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_AG
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HID_DEVICE), y)
|
||||
CSRCS += service/stacks/zephyr/sal_hid_device_interface.c
|
||||
endif #CONFIG_BLUETOOTH_HID_DEVICE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STACK_LE_ZBLUE), y)
|
||||
CSRCS += service/stacks/zephyr/sal_adapter_le_interface.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_ADV), y)
|
||||
CSRCS += service/stacks/zephyr/sal_le_advertise_interface.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_ADV
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_SCAN), y)
|
||||
CSRCS += service/stacks/zephyr/sal_le_scan_interface.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_SCAN
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_CLIENT), y)
|
||||
CSRCS += service/stacks/zephyr/sal_gatt_client_interface.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_CLIENT
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_SERVER), y)
|
||||
CSRCS += service/stacks/zephyr/sal_gatt_server_interface.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_SERVER
|
||||
endif #CONFIG_BLUETOOTH_STACK_LE_ZBLUE
|
||||
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_AUDIO),)
|
||||
CSRCS := $(filter-out $(wildcard service/stacks/bluelet/sal_lea_*),$(wildcard $(CSRCS)))
|
||||
endif #CONFIG_BLUETOOTH_BLE_AUDIO
|
||||
CSRCS += service/profiles/*.c
|
||||
CSRCS += service/profiles/system/*.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP),)
|
||||
CSRCS := $(filter-out $(wildcard service/profiles/system/bt_player.c),$(wildcard $(CSRCS)))
|
||||
endif #CONFIG_BLUETOOTH_A2DP
|
||||
ifeq ($(findstring y, $(CONFIG_BLUETOOTH_A2DP)_$(CONFIG_BLUETOOTH_HFP_AG)_$(CONFIG_BLUETOOTH_HFP_HF)_$(CONFIG_BLUETOOTH_BLE_AUDIO)), )
|
||||
CSRCS := $(filter-out $(wildcard service/profiles/system/media_system.c),$(wildcard $(CSRCS)))
|
||||
else
|
||||
CSRCS += service/profiles/audio_interface/*.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP/CONFIG_BLUETOOTH_HFP_AG/CONFIG_BLUETOOTH_HFP_HF
|
||||
ifeq ($(CONFIG_MICO_MEDIA_MAIN_PLAYER),y)
|
||||
CFLAGS += ${INCDIR_PREFIX}${TOPDIR}/../vendor/xiaomi/miai/mediaplayer/include
|
||||
endif #CONFIG_MICO_MEDIA_MAIN_PLAYER
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_CLIENT), y)
|
||||
CSRCS += service/profiles/gatt/gattc_event.c
|
||||
CSRCS += service/profiles/gatt/gattc_service.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_CLIENT
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_SERVER), y)
|
||||
CSRCS += service/profiles/gatt/gatts_event.c
|
||||
CSRCS += service/profiles/gatt/gatts_service.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_SERVER
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP), y)
|
||||
CSRCS += service/profiles/a2dp/*.c
|
||||
CSRCS += service/profiles/a2dp/codec/*.c
|
||||
CSRCS += service/profiles/avrcp/*.c
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles/a2dp
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles/a2dp/codec
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles/avrcp
|
||||
endif #CONFIG_BLUETOOTH_A2DP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SOURCE), y)
|
||||
CSRCS += service/profiles/a2dp/source/*.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
CSRCS += service/profiles/a2dp/sink/*.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SINK
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_TARGET), y)
|
||||
CSRCS += service/profiles/avrcp/target/*.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL), y)
|
||||
CSRCS += service/profiles/avrcp/control/*.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SINK
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_HF), y)
|
||||
CSRCS += service/profiles/hfp_hf/*.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_HF
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_AG), y)
|
||||
CSRCS += service/profiles/hfp_ag/*.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_AG
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_SPP), y)
|
||||
CSRCS += service/profiles/spp/*.c
|
||||
endif #CONFIG_BLUETOOTH_SPP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HID_DEVICE), y)
|
||||
CSRCS += service/profiles/hid/*.c
|
||||
endif #CONFIG_BLUETOOTH_HID_DEVICE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_PAN), y)
|
||||
CSRCS += service/profiles/pan/*.c
|
||||
endif #CONFIG_BLUETOOTH_PAN
|
||||
|
||||
ifneq ($(findstring y, $(CONFIG_BLUETOOTH_LEAUDIO_CLIENT)_$(CONFIG_BLUETOOTH_LEAUDIO_SERVER)), )
|
||||
CSRCS += service/profiles/leaudio/audio_ipc/*.c
|
||||
CSRCS += service/profiles/leaudio/*.c
|
||||
CSRCS += service/profiles/leaudio/codec/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_CLIENT/CONFIG_BLUETOOTH_LEAUDIO_SERVER
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_SERVER), y)
|
||||
CSRCS += service/profiles/leaudio/server/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_SERVER
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_CCP), y)
|
||||
CSRCS += service/profiles/leaudio/ccp/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_CCP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_MCP), y)
|
||||
CSRCS += service/profiles/leaudio/mcp/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_MCP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_VMICS), y)
|
||||
CSRCS += service/profiles/leaudio/vmics/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_VMICS
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_CLIENT), y)
|
||||
CSRCS += service/profiles/leaudio/client/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_CLIENT
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_MCS), y)
|
||||
CSRCS += service/profiles/leaudio/mcs/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_MCS
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_TBS), y)
|
||||
CSRCS += service/profiles/leaudio/tbs/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_TBS
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_VMICP), y)
|
||||
CSRCS += service/profiles/leaudio/vmicp/*.c
|
||||
endif #CONFIG_BLUETOOTH_LEAUDIO_VMICP
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LOG), y)
|
||||
CSRCS += service/utils/log_server.c
|
||||
CSRCS += service/utils/btsnoop_log.c
|
||||
CSRCS += service/utils/btsnoop_writer.c
|
||||
CSRCS += service/utils/btsnoop_filter.c
|
||||
endif #CONFIG_BLUETOOTH_LOG
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HCI_FILTER), y)
|
||||
CSRCS += service/vhal/bt_hci_filter.c
|
||||
endif
|
||||
|
||||
CSRCS += service/vhal/bt_vhal.c
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/vhal
|
||||
endif #CONFIG_BLUETOOTH_SERVICE
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE), y)
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_BASIC), y)
|
||||
CSRCS += sample_code/basic/*.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_ENABLE), y)
|
||||
CSRCS += sample_code/enable/*.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY), y)
|
||||
CSRCS += sample_code/discovery/*.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND), y)
|
||||
CSRCS += sample_code/createbond/*.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND), y)
|
||||
CSRCS += sample_code/acceptbond/*.c
|
||||
endif
|
||||
endif #CONFIG_APP_BT_SAMPLE_CODE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_TOOLS), y)
|
||||
CSRCS += tools/utils.c
|
||||
CSRCS += tools/uv_thread_loop.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_FRAMEWORK_ASYNC), y)
|
||||
CSRCS += tools/async/gap.c
|
||||
CSRCS += tools/async/log.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_ADV), y)
|
||||
CSRCS += tools/async/adv.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_ADV
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_SCAN), y)
|
||||
CSRCS += tools/async/scan.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT), y)
|
||||
CSRCS += tools/async/gatt_client.c
|
||||
endif #CONFIG_BLUETOOTH_GATT
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_ADV), y)
|
||||
CSRCS += tools/adv.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_BLE_SCAN), y)
|
||||
CSRCS += tools/scan.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_L2CAP), y)
|
||||
CSRCS += tools/l2cap.c
|
||||
endif #CONFIG_BLUETOOTH_L2CAP
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
CSRCS += tools/a2dp_sink.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SINK
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SOURCE), y)
|
||||
CSRCS += tools/a2dp_source.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL), y)
|
||||
CSRCS += tools/avrcp_control.c
|
||||
endif #CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_CLIENT), y)
|
||||
CSRCS += tools/gatt_client.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_CLIENT
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_SERVER), y)
|
||||
CSRCS += tools/gatt_server.c
|
||||
endif #CONFIG_BLUETOOTH_GATT_SERVER
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_HF), y)
|
||||
CSRCS += tools/hfp_hf.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_HF
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_AG), y)
|
||||
CSRCS += tools/hfp_ag.c
|
||||
endif #CONFIG_BLUETOOTH_HFP_AG
|
||||
ifeq ($(CONFIG_BLUETOOTH_LOG), y)
|
||||
CSRCS += tools/log.c
|
||||
endif #CONFIG_BLUETOOTH_LOG
|
||||
ifeq ($(CONFIG_BLUETOOTH_SPP), y)
|
||||
CSRCS += tools/spp.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_HID_DEVICE), y)
|
||||
CSRCS += tools/hid_device.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_PAN), y)
|
||||
CSRCS += tools/panu.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_SERVER), y)
|
||||
CSRCS += tools/lea_server.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_MCP), y)
|
||||
CSRCS += tools/lea_mcp.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_CCP), y)
|
||||
CSRCS += tools/lea_ccp.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_VMICS), y)
|
||||
CSRCS += tools/lea_vmics.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_CLIENT), y)
|
||||
CSRCS += tools/lea_client.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_VMICP), y)
|
||||
CSRCS += tools/lea_vmicp.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_MCS), y)
|
||||
CSRCS += tools/lea_mcs.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LEAUDIO_TBS), y)
|
||||
CSRCS += tools/lea_tbs.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_UPDATE), y)
|
||||
CSRCS += tools/storage_update/storage_tool.c
|
||||
endif #CONFIG_BLUETOOTH_STORAGE_UPDATE
|
||||
|
||||
endif
|
||||
|
||||
# framework/service/stack/tools dependence
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/framework/include
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/framework/common
|
||||
|
||||
ifneq ($(CONFIG_LIB_DBUS_RPMSG_SERVER_CPUNAME)$(CONFIG_OFONO),)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/dbus/dbus
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/glib/glib/glib
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/glib/glib
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/glib
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/system/utils/gdbus
|
||||
endif
|
||||
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/src
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/common
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles/include
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles/system
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/stacks
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/stacks/include
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/vendor
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/dfx
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_SERVICE), y)
|
||||
ifneq ($(CONFIG_BLUETOOTH_STACK_BREDR_BLUELET)$(CONFIG_BLUETOOTH_STACK_LE_BLUELET),)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/stacks/bluelet/include
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/bluelet/bluelet/src/samples/stack_adapter/inc
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/vendor/xiaomi/vela/bluelet/inc
|
||||
endif
|
||||
ifneq ($(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE)$(CONFIG_BLUETOOTH_STACK_LE_ZBLUE),)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/stacks/zephyr/include
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/zblue/zblue/port/include/
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/zblue/zblue/subsys/bluetooth/host
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/zblue/zblue/subsys/settings/include/settings
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/zblue/zblue/port/include/kernel/include
|
||||
endif
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/ipc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE), y)
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_BASIC), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/sample_code/basic
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_ENABLE), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/sample_code/enable
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/sample_code/discovery
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/sample_code/createbond
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/sample_code/acceptbond
|
||||
endif
|
||||
endif #CONFIG_APP_BT_SAMPLE_CODE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_TOOLS), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/tools
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_UPDATE), y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/tools/storage_update
|
||||
endif #CONFIG_BLUETOOTH_STORAGE_UPDATE
|
||||
|
||||
ifeq ($(CONFIG_ARCH_SIM),y)
|
||||
CFLAGS += -O0
|
||||
endif
|
||||
CFLAGS += -Wno-strict-prototypes #-fno-short-enums -Wl,-no-enum-size-warning #-Werror
|
||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||
STACKSIZE = $(CONFIG_BLUETOOTH_TASK_STACK_SIZE)
|
||||
MODULE = $(CONFIG_BLUETOOTH)
|
||||
|
||||
# if enabled bluetoothd
|
||||
ifeq ($(CONFIG_BLUETOOTH_SERVER), y)
|
||||
PROGNAME += $(CONFIG_BLUETOOTH_SERVER_NAME)
|
||||
MAINSRC += service/src/main.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE), y)
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_BASIC), y)
|
||||
PROGNAME += bt_basic
|
||||
MAINSRC += sample_code/basic/basic.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_ENABLE), y)
|
||||
PROGNAME += bt_enable
|
||||
MAINSRC += sample_code/enable/enable.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY), y)
|
||||
PROGNAME += bt_discovery
|
||||
MAINSRC += sample_code/discovery/discovery.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND), y)
|
||||
PROGNAME += bt_createbond
|
||||
MAINSRC += sample_code/createbond/createbond.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND), y)
|
||||
PROGNAME += bt_acceptbond
|
||||
MAINSRC += sample_code/acceptbond/acceptbond.c
|
||||
endif
|
||||
endif #CONFIG_APP_BT_SAMPLE_CODE
|
||||
|
||||
# if enabled bttool
|
||||
ifeq ($(CONFIG_BLUETOOTH_TOOLS), y)
|
||||
PROGNAME += bttool
|
||||
MAINSRC += tools/bt_tools.c
|
||||
PROGNAME += adapter_test
|
||||
MAINSRC += tests/adapter_test.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_UPGRADE), y)
|
||||
PROGNAME += bt_upgrade
|
||||
MAINSRC += tools/storage_transform.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_UPDATE), y)
|
||||
PROGNAME += bt_storage_update
|
||||
MAINSRC += tools/storage_update/storage_update.c
|
||||
endif #CONFIG_BLUETOOTH_STORAGE_UPDATE
|
||||
endif
|
||||
|
||||
ASRCS := $(wildcard $(ASRCS))
|
||||
CSRCS := $(wildcard $(CSRCS))
|
||||
CXXSRCS := $(wildcard $(CXXSRCS))
|
||||
MAINSRC := $(wildcard $(MAINSRC))
|
||||
|
||||
NOEXPORTSRCS = $(ASRCS)$(CSRCS)$(CXXSRCS)$(MAINSRC)
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_FEATURE),y)
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/feature/include
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/runtimes/feature/include
|
||||
|
||||
CSRCS += feature/src/system_bluetooth.c
|
||||
CSRCS += feature/src/system_bluetooth_impl.c
|
||||
CSRCS += feature/src/feature_bluetooth_util.c
|
||||
CSRCS += feature/src/system_bluetooth_bt.c
|
||||
CSRCS += feature/src/system_bluetooth_bt_impl.c
|
||||
CSRCS += feature/src/feature_bluetooth_callback.c
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
CSRCS += feature/src/system_bluetooth_bt_a2dpsink.c
|
||||
CSRCS += feature/src/system_bluetooth_bt_a2dpsink_impl.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL), y)
|
||||
CSRCS += feature/src/system_bluetooth_bt_avrcpcontrol.c
|
||||
CSRCS += feature/src/system_bluetooth_bt_avrcpcontrol_impl.c
|
||||
endif
|
||||
|
||||
depend::
|
||||
$(APPDIR)/../prebuilts/tools/rust/bin/jidl/jidl_gen_cpp \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/jidl/bluetooth.jidl --out-dir \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/src --header system_bluetooth.h --source system_bluetooth.c
|
||||
$(APPDIR)/../prebuilts/tools/rust/bin/jidl/jidl_gen_cpp \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/jidl/bluetooth_bt.jidl --out-dir \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/src --header system_bluetooth_bt.h --source system_bluetooth_bt.c
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
$(APPDIR)/../prebuilts/tools/rust/bin/jidl/jidl_gen_cpp \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/jidl/bluetooth_bt_a2dpsink.jidl --out-dir \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/src --header system_bluetooth_bt_a2dpsink.h --source system_bluetooth_bt_a2dpsink.c
|
||||
endif
|
||||
ifeq ($(CONFIG_BLUETOOTH_AVRCP_CONTROL), y)
|
||||
@python3 $(APPDIR)/frameworks/runtimes/feature/tools/jidl/jsongensource.py \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/jidl/bluetooth_bt_avrcpcontrol.jidl -out-dir \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/src -header system_bluetooth_bt_avrcpcontrol.h -source system_bluetooth_bt_avrcpcontrol.c
|
||||
endif
|
||||
else ifeq ($(CONFIG_BLUETOOTH_FEATURE_ASYNC), y)
|
||||
include $(APPDIR)/frameworks/runtimes/feature/Make.defs
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/feature/feature_async/include
|
||||
|
||||
CSRCS += feature/feature_async/src/bluetooth.c
|
||||
CSRCS += feature/feature_async/src/bluetooth_impl.c
|
||||
CSRCS += feature/feature_async/src/feature_bluetooth_util.c
|
||||
CSRCS += feature/feature_async/src/bluetooth_ble.c
|
||||
CSRCS += feature/feature_async/src/bluetooth_ble_impl.c
|
||||
|
||||
depend::
|
||||
@python3 $(APPDIR)/frameworks/runtimes/feature/tools/jidl/jsongensource.py \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/feature_async/jidl/bluetooth.jidl -out-dir \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/feature_async/src -header bluetooth.h -source bluetooth.c
|
||||
@python3 $(APPDIR)/frameworks/runtimes/feature/tools/jidl/jsongensource.py \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/feature_async/jidl/bluetooth_ble.jidl -out-dir \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/feature_async/src -header bluetooth_ble.h -source bluetooth_ble.c
|
||||
else
|
||||
endif
|
||||
|
||||
ifneq ($(NOEXPORTSRCS),)
|
||||
BIN := $(APPDIR)/staging/libbluetooth.a
|
||||
endif
|
||||
|
||||
include $(APPDIR)/Application.mk
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
############################################################################
|
||||
# apps/system/lzf/Makefile.host
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
############################################################################
|
||||
# USAGE:
|
||||
#
|
||||
# 1. TOPDIR and APPDIR must be defined on the make command line: TOPDIR
|
||||
# is the full path to the nuttx/ directory; APPDIR is the full path to
|
||||
# the apps/ directory. For example:
|
||||
#
|
||||
# make -f Makefile.host TOPDIR=/home/me/projects/nuttx
|
||||
# APPDIR=/home/me/projects/apps
|
||||
#
|
||||
# 2. Add CONFIG_DEBUG_FEATURES=y to the make command line to enable debug output
|
||||
# 3. Make sure to clean old target .o files before making new host .o
|
||||
# files.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
BIN = bttool$(HOSTEXEEXT)
|
||||
CFLAGS := -I.
|
||||
CFLAGS += -I service/src
|
||||
CFLAGS += -I framework/include
|
||||
CFLAGS += -I tools
|
||||
CFLAGS += -I service
|
||||
CFLAGS += -I service/common
|
||||
CFLAGS += -I service/ipc/socket/include
|
||||
CFLAGS += -I service/stacks
|
||||
CFLAGS += -I service/stacks/include
|
||||
CFLAGS += -I service/profiles
|
||||
CFLAGS += -I service/profiles/include
|
||||
CFLAGS += -DFAR= -DOK=0 -m32
|
||||
|
||||
LDLIBS += -lpthread -lreadline -luv
|
||||
|
||||
BTDIR = $(APPDIR)/frameworks/bluetooth
|
||||
|
||||
CSRCS := $(wildcard framework/common/*.c)
|
||||
CSRCS += $(wildcard framework/socket/*.c)
|
||||
CSRCS += $(wildcard tools/*.c)
|
||||
CSRCS := $(filter-out $(wildcard tools/lea*) tools/log.c,$(wildcard $(CSRCS)))
|
||||
CSRCS += service/ipc/socket/src/bt_socket_client.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_adapter.c
|
||||
CSRCS += service/common/service_loop.c
|
||||
CSRCS += service/src/manager_service.c
|
||||
CSRCS += service/common/callbacks_list.c
|
||||
CSRCS += service/common/index_allocator.c
|
||||
CSRCS += service/utils/log.c
|
||||
|
||||
CINC := nuttx/config.h
|
||||
CINC += nuttx/list.h
|
||||
CINC += nuttx/nuttx.h
|
||||
|
||||
all: $(BIN)
|
||||
.PHONY: clean
|
||||
|
||||
nuttx/config.h:
|
||||
$(Q) mkdir -p nuttx
|
||||
$(Q) ln -sf $(TOPDIR)/include/nuttx/config.h nuttx/
|
||||
|
||||
nuttx/list.h:
|
||||
$(Q) mkdir -p nuttx
|
||||
$(Q) ln -sf $(TOPDIR)/include/nuttx/list.h nuttx/
|
||||
|
||||
nuttx/nuttx.h:
|
||||
$(Q) mkdir -p nuttx
|
||||
$(Q) ln -sf $(TOPDIR)/include/nuttx/nuttx.h nuttx/
|
||||
|
||||
$(BIN): $(CINC) $(CSRCS)
|
||||
$(Q) $(HOSTCC) $(CFLAGS) -o $@ $(filter-out $(CINC), $^) $(LDLIBS)
|
||||
|
||||
clean:
|
||||
rm -rf $(BIN) nuttx
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
# Overview of openvela Bluetooth
|
||||
|
||||
\[ English | [简体中文](README_zh-cn.md) \]
|
||||
|
||||
## 1. Introduction to openvela Bluetooth
|
||||
|
||||
openvela Bluetooth has been certified for Bluetooth 5.4. It currently supports Bluetooth profiles listed as below:
|
||||
|
||||
- Core
|
||||
|
||||
- BR/EDR/BLE
|
||||
- GAP
|
||||
- L2CAP
|
||||
- GATT Client/Server
|
||||
- A2DP SRC/SNK
|
||||
- AVRCP CT/TG
|
||||
- HFP AG/HF
|
||||
- PAN
|
||||
- SPP
|
||||
- HID
|
||||
- HOGP
|
||||
- LEA
|
||||
|
||||
- TMAP
|
||||
- CAP
|
||||
- BAP/ASCS/PACS/BASS
|
||||
- CSIP/CSIS
|
||||
- MCP/MCS
|
||||
- CCP/TBS
|
||||
- VCP/VCS
|
||||
- Mesh
|
||||
|
||||
openvela Bluetooth currently also supports a variety of open source and proprietary stacks such as Zephyr, Bluez, Bluedroid, Barrot, etc.
|
||||
|
||||
## 2. openvela Bluetooth Application Development
|
||||
|
||||
Third-party application developers may utilize the openvela QuickApp Feature to acquire system access capabilities.
|
||||
|
||||
Additionally, NDK interfaces are also provided to utilize all Bluetooth system-level capabilities. Please refer to header files in folder framework/include for more details.
|
||||
|
||||
## 3. openvela Bluetooth Driver Development
|
||||
|
||||
openvela Bluetooth supports multiple driver architectures. Taking the widely used BTH4 driver architecture as an example, chip manufacturers can implement a variable of the **struct bt_driver_s** structure type, and initialize the following member functions for it.
|
||||
|
||||
- CODE int (*open)(FAR struct bt_driver_s *btdev);
|
||||
- CODE int (*send)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
|
||||
- CODE int (*ioctl)(FAR struct bt_driver_s *btdev, int cmd, unsigned long arg);
|
||||
- CODE void (*close)(FAR struct bt_driver_s *btdev);
|
||||
|
||||
The implementation of the above member functions depends on the specific type of HCI utilized, which refers to the physical bus linking the Host and the Controller.
|
||||
|
||||
Then, register the driver instance by passing the variable of the above structure type via the API bt_driver_register().
|
||||
|
||||
- int **bt_driver_register**(FAR struct bt_driver_s *drv);
|
||||
|
||||
Please refer to the type definition in header file nuttx/include/nuttx/wireless/bluetooth/bt_driver.h. The figure below helps to provide a comprehensive understanding of its functioning within the openvela OS.
|
||||
|
||||

|
||||
|
||||
Note: chip manufacturers are not required to implement the receive() member function, for it will be initialized by the BTH4 driver.
|
||||
|
||||
- CODE int (*receive)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
|
||||
|
||||
Upon receipt of HCI data from the chip, the vendor drivers should invoke the **bt_netdev_receive**() function, which in turn will trigger the receive() function to store the received HCI data.
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
# 蓝牙概述
|
||||
|
||||
\[ [English](README.md) | 简体中文 \]
|
||||
|
||||
## 一、 openvela 蓝牙能力介绍
|
||||
|
||||
openvela 蓝牙已经通过 Bluetooth 5.4 认证。目前支持的蓝牙能力包括:
|
||||
|
||||
- Core
|
||||
|
||||
- BR/EDR/BLE
|
||||
- GAP
|
||||
- L2CAP
|
||||
- GATT Client/Server
|
||||
- A2DP SRC/SNK
|
||||
- AVRCP CT/TG
|
||||
- HFP AG/HF
|
||||
- PAN
|
||||
- SPP
|
||||
- HID
|
||||
- HOGP
|
||||
- LEA
|
||||
|
||||
- TMAP
|
||||
- CAP
|
||||
- BAP/ASCS/PACS/BASS
|
||||
- CSIP/CSIS
|
||||
- MCP/MCS
|
||||
- CCP/TBS
|
||||
- VCP/VCS
|
||||
- Mesh
|
||||
|
||||
openvela 蓝牙目前还能够支持多种开源、闭源协议栈,如Zephyr、Bluez、Bluedroid、Barrot等。
|
||||
|
||||
## 二、 openvela 蓝牙应用开发
|
||||
|
||||
对于第三方应用开发者,可以使用 openvela 快应用 QuickApp Feature ,它是基于 QuickJS 引擎使用 C++ 实现的一系列 API 接口,为三方应用提供系统访问能力。
|
||||
|
||||
另外,还提供了 NDK 接口来使用蓝牙系统的所有能力。可以参阅目录 framework/include 中的头文件获取更多信息。
|
||||
|
||||
## 三、 openvela 蓝牙驱动开发
|
||||
|
||||
openvela 蓝牙支持多种驱动架构。以目前常用的 BTH4 驱动架构为例,芯片厂商可以实现一个 **struct bt_driver_s** 结构体类型的变量,并为其初始化以下成员函数:
|
||||
|
||||
- CODE int (*open)(FAR struct bt_driver_s *btdev);
|
||||
- CODE int (*send)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
|
||||
- CODE int (*ioctl)(FAR struct bt_driver_s *btdev, int cmd, unsigned long arg);
|
||||
- CODE void (*close)(FAR struct bt_driver_s *btdev);
|
||||
|
||||
上面成员函数的实现依赖于 HCI 的实际工作方式,也就是 Host 和 Controller 之间的物理总线。
|
||||
|
||||
然后,将上述结构体类型的变量通过 API **bt_driver_register**()注册该驱动实例。
|
||||
|
||||
- int **bt_driver_register**(FAR struct bt_driver_s *drv);
|
||||
|
||||
类型定义可参考头文件 nuttx/include/nuttx/wireless/bluetooth/bt_driver.h。调用关系如下图所示:
|
||||
|
||||

|
||||
|
||||
备注:对于 receive() 成员函数,芯片厂商无需定义,BTH4 驱动会为其初始化。
|
||||
|
||||
- CODE int (*receive)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
|
||||
|
||||
当收到来自芯片的 HCI 数据时,只要调用 **bt_netdev_receive**()即可,它会调用这个 receive()函数来保存收到 HCI 数据。
|
||||
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_memory.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#define GUARD_SIZE 16
|
||||
#define GUARD_HEAD 0xAA
|
||||
#define GUARD_TAIL 0xBB
|
||||
|
||||
typedef struct bt_mem_node {
|
||||
void* addr;
|
||||
size_t size;
|
||||
const char* file;
|
||||
int line;
|
||||
unsigned char guard[GUARD_SIZE];
|
||||
struct bt_mem_node* next;
|
||||
} bt_mem_node_t;
|
||||
|
||||
typedef struct bt_mem_manager {
|
||||
bt_mem_node_t* mem_list;
|
||||
pthread_mutex_t list_lock;
|
||||
size_t current_mem;
|
||||
size_t peak_mem;
|
||||
} bt_mem_manager_t;
|
||||
|
||||
static bt_mem_manager_t g_mem_manager = {
|
||||
.mem_list = NULL,
|
||||
.list_lock = PTHREAD_MUTEX_INITIALIZER,
|
||||
.current_mem = 0,
|
||||
.peak_mem = 0,
|
||||
};
|
||||
|
||||
void* bt_malloc_hook(size_t size, const char* file, int line)
|
||||
{
|
||||
bt_mem_manager_t* mem_manager = &g_mem_manager;
|
||||
void* raw;
|
||||
bt_mem_node_t* head;
|
||||
|
||||
raw = malloc(size + sizeof(bt_mem_node_t) + GUARD_SIZE);
|
||||
if (!raw) {
|
||||
syslog(LOG_ALERT, "[bt_memory] malloc failed, size: %zu, file: %s, line: %d", size, file, line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
head = (bt_mem_node_t*)raw;
|
||||
*head = (bt_mem_node_t) {
|
||||
.addr = (char*)raw + sizeof(bt_mem_node_t),
|
||||
.size = size,
|
||||
.file = file,
|
||||
.line = line,
|
||||
.next = NULL
|
||||
};
|
||||
|
||||
memset(head->guard, GUARD_HEAD, sizeof(head->guard));
|
||||
memset((char*)head->addr + size, GUARD_TAIL, GUARD_SIZE);
|
||||
|
||||
pthread_mutex_lock(&mem_manager->list_lock);
|
||||
mem_manager->current_mem += size;
|
||||
if (mem_manager->current_mem > mem_manager->peak_mem) {
|
||||
mem_manager->peak_mem = mem_manager->current_mem;
|
||||
}
|
||||
|
||||
head->next = mem_manager->mem_list;
|
||||
mem_manager->mem_list = head;
|
||||
pthread_mutex_unlock(&mem_manager->list_lock);
|
||||
|
||||
return head->addr;
|
||||
}
|
||||
|
||||
void* bt_calloc_hook(size_t num, size_t size, const char* file, int line)
|
||||
{
|
||||
size_t total;
|
||||
void* ptr;
|
||||
|
||||
total = num * size;
|
||||
ptr = bt_malloc_hook(total, file, line);
|
||||
if (!ptr) {
|
||||
syslog(LOG_ALERT, "[bt_memory] calloc failed, num: %zu, size: %zu, file: %s, line: %d", num, size, file, line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(ptr, 0, total);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void bt_free_hook(void* ptr)
|
||||
{
|
||||
bt_mem_manager_t* mem_manager = &g_mem_manager;
|
||||
bt_mem_node_t** pp;
|
||||
bool found = false;
|
||||
|
||||
if (!ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&mem_manager->list_lock);
|
||||
|
||||
pp = &mem_manager->mem_list;
|
||||
while (*pp) {
|
||||
if ((*pp)->addr == ptr) {
|
||||
bt_mem_node_t* node = *pp;
|
||||
|
||||
for (int i = 0; i < GUARD_SIZE; i++) {
|
||||
if (((uint8_t)node->guard[i] != GUARD_HEAD) || ((uint8_t)((char*)ptr + node->size)[i] != GUARD_TAIL)) {
|
||||
syslog(LOG_ALERT, "[bt_memory] Buffer overflow at %s:%d", node->file, node->line);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
mem_manager->current_mem -= node->size;
|
||||
*pp = node->next;
|
||||
found = true;
|
||||
free(node);
|
||||
break;
|
||||
}
|
||||
pp = &(*pp)->next;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mem_manager->list_lock);
|
||||
|
||||
if (!found) {
|
||||
syslog(LOG_ALERT, "[bt_memory] Freeing unallocated memory %p", ptr);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_report_leak(void)
|
||||
{
|
||||
bt_mem_manager_t* mem_manager = &g_mem_manager;
|
||||
bt_mem_node_t* node;
|
||||
|
||||
pthread_mutex_lock(&mem_manager->list_lock);
|
||||
|
||||
syslog(LOG_ALERT, "[bt_memory] ===== Memory Leak Report =====");
|
||||
syslog(LOG_ALERT, "[bt_memory] Peak memory: %zu bytes", mem_manager->peak_mem);
|
||||
|
||||
node = mem_manager->mem_list;
|
||||
while (node) {
|
||||
syslog(LOG_ALERT, "[bt_memory] Leak %p (%zu bytes) at %s:%d",
|
||||
node->addr, node->size, node->file, node->line);
|
||||
node = node->next;
|
||||
}
|
||||
syslog(LOG_ALERT, "[bt_memory] ===== End of Report =====");
|
||||
|
||||
pthread_mutex_unlock(&mem_manager->list_lock);
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bt_memory.h"
|
||||
|
||||
void test_leak()
|
||||
{
|
||||
void* p1 = bt_malloc(128);
|
||||
void* p2 = bt_malloc(256);
|
||||
}
|
||||
|
||||
void test_overflow()
|
||||
{
|
||||
char* buf = (char*)bt_malloc(16);
|
||||
memset(buf, 0, 20);
|
||||
bt_free(buf);
|
||||
}
|
||||
|
||||
void test_double_free()
|
||||
{
|
||||
void* p = bt_malloc(64);
|
||||
bt_free(p);
|
||||
bt_free(p);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_leak();
|
||||
|
||||
test_overflow();
|
||||
|
||||
test_double_free();
|
||||
|
||||
void* p2 = bt_malloc(500);
|
||||
|
||||
bt_report_leak();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_sched_trace.h"
|
||||
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
#define DUMP_THRESHOLD 256
|
||||
|
||||
typedef struct {
|
||||
char tag[MAX_TAG_LEN];
|
||||
uint64_t timestamp;
|
||||
uint32_t latency_us;
|
||||
} bt_latency_record_t;
|
||||
|
||||
typedef struct {
|
||||
bt_latency_record_t buffer[CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE];
|
||||
atomic_uint head;
|
||||
atomic_uint tail;
|
||||
} bt_trace_manager_t;
|
||||
|
||||
static bt_trace_manager_t g_trace_manager = { 0 };
|
||||
|
||||
static inline uint64_t get_monotonic_ns()
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (uint64_t)ts.tv_sec * 1000000000UL + ts.tv_nsec;
|
||||
}
|
||||
|
||||
void bt_note_start(void)
|
||||
{
|
||||
bt_trace_manager_t* trace_manager = &g_trace_manager;
|
||||
|
||||
atomic_store(&trace_manager->head, 0);
|
||||
atomic_store(&trace_manager->tail, 0);
|
||||
}
|
||||
|
||||
void bt_note_stop(void)
|
||||
{
|
||||
bt_trace_manager_t* trace_manager = &g_trace_manager;
|
||||
char log_buf[DUMP_THRESHOLD];
|
||||
int written = 0;
|
||||
|
||||
while (trace_manager->tail != trace_manager->head) {
|
||||
bt_latency_record_t* p = &trace_manager->buffer[trace_manager->tail % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE];
|
||||
|
||||
written += snprintf(log_buf + written, sizeof(log_buf) - written,
|
||||
"[TAG=%s][TS=%lu][LAT=%uus]\n",
|
||||
p->tag, p->timestamp, p->latency_us);
|
||||
trace_manager->tail = (trace_manager->tail + 1) % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE;
|
||||
written = written % DUMP_THRESHOLD;
|
||||
|
||||
if (written > DUMP_THRESHOLD) {
|
||||
BT_LOGD("%s", log_buf);
|
||||
written = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (written > 0) {
|
||||
BT_LOGD("%s", log_buf);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_note_begin(const char* tag, bt_timepoint_t* point)
|
||||
{
|
||||
if (strlen(tag) > MAX_TAG_LEN) {
|
||||
BT_LOGD("tag is too long, max length is %d\n", MAX_TAG_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
strlcpy(point->tag, tag, MAX_TAG_LEN);
|
||||
point->start_ns = get_monotonic_ns();
|
||||
}
|
||||
|
||||
void bt_note_end(const char* tag, bt_timepoint_t* point)
|
||||
{
|
||||
bt_trace_manager_t* trace_manager = &g_trace_manager;
|
||||
uint64_t end;
|
||||
uint32_t idx;
|
||||
|
||||
if (strlen(tag) > MAX_TAG_LEN) {
|
||||
BT_LOGD("tag is too long, max length is %d\n", MAX_TAG_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
end = get_monotonic_ns();
|
||||
idx = atomic_fetch_add(&trace_manager->head, 1) % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE;
|
||||
strlcpy(trace_manager->buffer[idx].tag, point->tag, MAX_TAG_LEN);
|
||||
|
||||
trace_manager->buffer[idx].timestamp = end;
|
||||
trace_manager->buffer[idx].latency_us = (end - point->start_ns) / 1000;
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
############################################################################
|
||||
# Copyright (C) 2025 Xiaomi Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
############################################################################
|
||||
import re
|
||||
import argparse
|
||||
import pandas as pd
|
||||
import matplotlib.pyplot as plt
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='Latency log analyzer with tag support')
|
||||
parser.add_argument('--log', required=True,
|
||||
help='Input log file path')
|
||||
parser.add_argument('--output-img', default='latency_by_tag.png',
|
||||
help='Output image path (default: latency_by_tag.png)')
|
||||
parser.add_argument('--output-report',
|
||||
help='Output report file path (optional)')
|
||||
return parser.parse_args()
|
||||
|
||||
def parse_log_line(line):
|
||||
pattern = r"\[TAG=([^$$]+)\]\[TS=(\d+)\]\[LAT=(\d+)us\]"
|
||||
|
||||
if match := re.search(pattern, line):
|
||||
return {
|
||||
"tag": match.group(1),
|
||||
"timestamp": datetime.fromtimestamp(int(match.group(2))/1e9),
|
||||
"latency": int(match.group(3))
|
||||
}
|
||||
return None
|
||||
|
||||
def load_log_data(log_path):
|
||||
try:
|
||||
with open(log_path, 'r') as f:
|
||||
records = []
|
||||
for line in f:
|
||||
if record := parse_log_line(line.strip()):
|
||||
records.append(record)
|
||||
return pd.DataFrame(records)
|
||||
except FileNotFoundError:
|
||||
raise SystemExit(f"Error: Log file {log_path} not found")
|
||||
|
||||
|
||||
def generate_latency_plot(df, output_path):
|
||||
plt.figure(figsize=(15, 8))
|
||||
colors = plt.cm.tab10.colors
|
||||
|
||||
for idx, (tag, group) in enumerate(df.groupby('tag')):
|
||||
group = group.sort_values('timestamp')
|
||||
plt.plot(group['timestamp'], group['latency'],
|
||||
color=colors[idx % 10],
|
||||
marker='o', markersize=3,
|
||||
linestyle='-', linewidth=1,
|
||||
label=tag)
|
||||
|
||||
plt.title('Latency Timeline by Tag')
|
||||
plt.xlabel('Timestamp')
|
||||
plt.ylabel('Latency (μs)')
|
||||
plt.legend(loc='upper left', bbox_to_anchor=(1, 1))
|
||||
plt.grid(True, alpha=0.3)
|
||||
plt.xticks(rotation=45)
|
||||
plt.tight_layout()
|
||||
|
||||
Path(output_path).parent.mkdir(parents=True, exist_ok=True)
|
||||
plt.savefig(output_path, dpi=300, bbox_inches='tight')
|
||||
plt.close()
|
||||
|
||||
def generate_stat_report(df, output_path=None):
|
||||
stats = []
|
||||
for tag, group in df.groupby('tag'):
|
||||
desc = group['latency'].describe(percentiles=[.5, .95, .99])
|
||||
stats.append({
|
||||
'Tag': tag,
|
||||
'Count': desc['count'],
|
||||
'Mean': desc['mean'],
|
||||
'Min': desc['min'],
|
||||
'50%': desc['50%'],
|
||||
'95%': desc['95%'],
|
||||
'99%': desc['max'],
|
||||
'Max': desc['max']
|
||||
})
|
||||
|
||||
report_df = pd.DataFrame(stats)
|
||||
report_str = report_df.to_string(index=False, float_format='%.2f')
|
||||
|
||||
if output_path:
|
||||
Path(output_path).parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(output_path, 'w') as f:
|
||||
f.write("=== Latency Statistics Report ===\n")
|
||||
f.write(report_str)
|
||||
print(f"Report saved to {output_path}")
|
||||
else:
|
||||
print("\n" + report_str)
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
df = load_log_data(args.log)
|
||||
if df.empty:
|
||||
raise SystemExit("Error: No valid records found in log file")
|
||||
|
||||
generate_latency_plot(df, args.output_img)
|
||||
print(f"Visualization saved to {args.output_img}")
|
||||
|
||||
if args.output_report:
|
||||
generate_stat_report(df, args.output_report)
|
||||
else:
|
||||
generate_stat_report(df)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_sched_trace.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void test_func1()
|
||||
{
|
||||
bt_timepoint_t tp1;
|
||||
|
||||
bt_trace_begin("test_func1", &tp1);
|
||||
usleep(rand() % 1000);
|
||||
bt_trace_end("test_func1", &tp1);
|
||||
}
|
||||
|
||||
void test_func2()
|
||||
{
|
||||
bt_timepoint_t tp1;
|
||||
|
||||
bt_trace_begin("test_func2", &tp1);
|
||||
usleep(rand() % 1000);
|
||||
bt_trace_end("test_func2", &tp1);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
bt_trace_start();
|
||||
|
||||
test_func1();
|
||||
test_func2();
|
||||
|
||||
test_func1();
|
||||
test_func2();
|
||||
|
||||
test_func1();
|
||||
test_func2();
|
||||
|
||||
bt_trace_stop();
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 220 KiB |
|
|
@ -0,0 +1,276 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _BT_DFX_H_
|
||||
#define _BT_DFX_H_
|
||||
|
||||
#ifdef CONFIG_DFX
|
||||
#include <dfx.h>
|
||||
#endif
|
||||
|
||||
#include "bt_dfx_event.h"
|
||||
#include "bt_dfx_reason.h"
|
||||
|
||||
// br
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_BREDR_SUPPORT)
|
||||
#define BT_DFX_SEND_BR_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_BR_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_BR_GAP_INQUIRY_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: brInquiryError: %s", reason); \
|
||||
BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_INQUIRY), \
|
||||
"%s:%s", "brInquiryError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_BR_GAP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: brConnectError: %s", reason); \
|
||||
BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_CONN), \
|
||||
"%s:%s", "brConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_BR_GAP_DISCONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: brDisconnectError: %s", reason); \
|
||||
BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_DISCONN), \
|
||||
"%s:%s", "brDisconnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_BR_GAP_PAIR_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: brPairError: %s", reason); \
|
||||
BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_PAIR), \
|
||||
"%s:%s", "brPairError", reason); \
|
||||
} while (0)
|
||||
|
||||
// ble
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_BLE_SUPPORT)
|
||||
#define BT_DFX_SEND_LE_GAP_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_LE_GAP_EVENT(...)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_BLE_SCAN
|
||||
#define BT_DFX_LE_GAP_SCAN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: bleScanError: %s", reason); \
|
||||
BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_SCAN), \
|
||||
"%s:%s", "bleScanError", reason); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_LE_GAP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: bleConnectError: %s", reason); \
|
||||
BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_CONN), \
|
||||
"%s:%s", "bleConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_LE_GAP_DISCONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: bleDisconnectError: %s", reason); \
|
||||
BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_DISCONN), \
|
||||
"%s:%s", "bleDisconnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_LE_GAP_PAIR_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: blePairError: %s", reason); \
|
||||
BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_PAIR), \
|
||||
"%s:%s", "blePairError", reason); \
|
||||
} while (0)
|
||||
|
||||
// spp
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_SPP)
|
||||
#define BT_DFX_SEND_SPP_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_SPP_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_SPP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btSppConnectError: %s", reason); \
|
||||
BT_DFX_SEND_SPP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_RFCOMM, BT_DFXC_SPP_CONN), \
|
||||
"%s:%s", "btSppConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_SPP_DISCONN_ERROR(reason, scn, port, role) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btSppDisconnected: %s, scn: %d, port: %d, role: %d", \
|
||||
reason, scn, port, role); \
|
||||
BT_DFX_SEND_SPP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_RFCOMM, BT_DFXC_SPP_DISCONN), \
|
||||
"%s:%s,%s:%d,%s:%d,%s:%s", "btSppDisconnected", reason, "scn", scn, \
|
||||
"port", port, "role", role); \
|
||||
} while (0)
|
||||
|
||||
// a2dp
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_A2DP)
|
||||
#define BT_DFX_SEND_A2DP_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_A2DP_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_A2DP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btA2dpConnectError: %s", reason); \
|
||||
BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_CONN), \
|
||||
"%s:%s", "btA2dpConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_A2DP_MEDIA_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btA2dpMediaError: %s", reason); \
|
||||
BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_MEDIA), \
|
||||
"%s:%s", "btA2dpMediaError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_A2DP_OFFLOAD_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btA2dpOffloadError: %s", reason); \
|
||||
BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_OFFLOAD), \
|
||||
"%s:%s", "btA2dpOffloadError", reason); \
|
||||
} while (0)
|
||||
|
||||
// avrcp
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && (defined(CONFIG_BLUETOOTH_AVRCP_CONTROL) || defined(CONFIG_BLUETOOTH_AVRCP_TARGET))
|
||||
#define BT_DFX_SEND_AVRCP_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_AVRCP_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_AVRCP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btAvrcpConnectError: %s", reason); \
|
||||
BT_DFX_SEND_AVRCP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_AVRCP, BT_DFXC_AVRCP_CONN), \
|
||||
"%s:%s", "btAvrcpConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_AVRCP_CTRL_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btAvrcpCtrlError: %s", reason); \
|
||||
BT_DFX_SEND_AVRCP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_AVRCP, BT_DFXC_AVRCP_CTRL), \
|
||||
"%s:%s", "btAvrcpCtrlError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_AVRCP_VOL_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btAvrcpVolError: %s", reason); \
|
||||
BT_DFX_SEND_AVRCP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_AVRCP, BT_DFXC_AVRCP_VOL), \
|
||||
"%s:%s", "btAvrcpVolError", reason); \
|
||||
} while (0)
|
||||
|
||||
// hfp
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && (defined(CONFIG_BLUETOOTH_HFP_HF) || defined(CONFIG_BLUETOOTH_HFP_AG))
|
||||
#define BT_DFX_SEND_HFP_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_HFP_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_HFP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btHfpConnectError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_CONN), \
|
||||
"%s:%s", "btHfpConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_HFP_SCO_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btHfpScoConnectError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_SCO_CONN), \
|
||||
"%s:%s", "btHfpScoConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_HFP_VOL_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btHfpVolError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_VOL), \
|
||||
"%s:%s", "btHfpVolError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_HFP_MEDIA_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btHfpMediaError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_MEDIA), \
|
||||
"%s:%s", "btHfpMediaError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_HFP_OFFLOAD_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btHfpOffloadError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_OFFLOAD), \
|
||||
"%s:%s", "btHfpOffloadError", reason); \
|
||||
} while (0)
|
||||
|
||||
// hid
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_HID_DEVICE)
|
||||
#define BT_DFX_SEND_HID_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_HID_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_HID_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btHidConnectError: %s", reason); \
|
||||
BT_DFX_SEND_HID_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HID, BT_DFXC_HID_CONN), \
|
||||
"%s:%s", "btHidConnectError", reason); \
|
||||
} while (0)
|
||||
|
||||
// others
|
||||
#if defined(CONFIG_BLUETOOTH_DFX)
|
||||
#define BT_DFX_SEND_OTHERS_EVENT(...) sendEventMisightF(__VA_ARGS__)
|
||||
#else
|
||||
#define BT_DFX_SEND_OTHERS_EVENT(...)
|
||||
#endif
|
||||
|
||||
#define BT_DFX_SOCKET_ERROR(reason, port) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btSocketError: %s, port: %d", reason, port); \
|
||||
BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_SOCKET), \
|
||||
"%s:%s,%s:%d", "btSocketError", reason, "port", port); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_IPC_CONN_ERROR(type, reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btIpcConnectError: %s, reason: %s", type, reason); \
|
||||
BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_IPC_CONN), \
|
||||
"%s:%s,%s:%s", "btIpcConnectError", type, "reason", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_IPC_ALLOC_ERROR(reason, packet_code) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btIpcAllocError: %s, packetCode: %" PRIu32, reason, packet_code); \
|
||||
BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_IPC_ALLOC), \
|
||||
"%s:%s,%s:%" PRIu32 "", "btIpcAllocError", reason, "packetCode", packet_code); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_DRIVER_ERROR(type, name, reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btDriverError: %s, name: %s, reason: %s", type, name, reason); \
|
||||
BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_DRIVER), \
|
||||
"%s:%s,%s:%s,%s:%s", "btDriverError", type, "name", name, "reason", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_OPEN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: btOpenError: %s", reason); \
|
||||
BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_OPEN), \
|
||||
"%s:%s", "btOpenError", reason); \
|
||||
} while (0)
|
||||
|
||||
#endif /* _BT_DFX_H_ */
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#ifndef _BT_DFX_EVENT_H_
|
||||
#define _BT_DFX_EVENT_H_
|
||||
|
||||
// vela bluetooth event id
|
||||
#define BT_DFX_BASE_VELA_BLUETOOTH (923020000)
|
||||
|
||||
// event group
|
||||
#define BT_DFXG_BR_GAP (0)
|
||||
#define BT_DFXG_LE_GAP (500)
|
||||
#define BT_DFXG_RFCOMM (1000)
|
||||
#define BT_DFXG_L2CAP (1100)
|
||||
#define BT_DFXG_GATT (1200)
|
||||
#define BT_DFXG_A2DP (3000)
|
||||
#define BT_DFXG_AVRCP (3200)
|
||||
#define BT_DFXG_HFP (3400)
|
||||
#define BT_DFXG_LE_AUDIO (4000)
|
||||
#define BT_DFXG_HID (6000)
|
||||
#define BT_DFXG_MESH (6100)
|
||||
#define BT_DFXG_CHANNEL_SOUNDING (7000)
|
||||
#define BT_DFXG_OTHERS (9000)
|
||||
|
||||
// event subcode
|
||||
// group: BT_DFXG_BR_GAP
|
||||
#define BT_DFXC_BR_GAP_INQUIRY (0)
|
||||
#define BT_DFXC_BR_GAP_CONN (100)
|
||||
#define BT_DFXC_BR_GAP_DISCONN (110)
|
||||
#define BT_DFXC_BR_GAP_PAIR (200)
|
||||
|
||||
// group: BT_DFXG_LE_GAP
|
||||
#define BT_DFXC_LE_GAP_SCAN (0)
|
||||
#define BT_DFXC_LE_GAP_CONN (100)
|
||||
#define BT_DFXC_LE_GAP_DISCONN (110)
|
||||
#define BT_DFXC_LE_GAP_PAIR (200)
|
||||
|
||||
// group: BT_DFXG_RFCOMM
|
||||
#define BT_DFXC_SPP_CONN (0)
|
||||
#define BT_DFXC_SPP_DISCONN (10)
|
||||
|
||||
// group: BT_DFXG_A2DP
|
||||
#define BT_DFXC_A2DP_CONN (0)
|
||||
#define BT_DFXC_A2DP_MEDIA (10)
|
||||
#define BT_DFXC_A2DP_OFFLOAD (20)
|
||||
|
||||
// group: BT_DFXG_AVRCP
|
||||
#define BT_DFXC_AVRCP_CONN (0)
|
||||
#define BT_DFXC_AVRCP_CTRL (10)
|
||||
#define BT_DFXC_AVRCP_VOL (20)
|
||||
|
||||
// group: BT_DFXG_HFP
|
||||
#define BT_DFXC_HFP_CONN (0)
|
||||
#define BT_DFXC_HFP_SCO_CONN (10)
|
||||
#define BT_DFXC_HFP_VOL (20)
|
||||
#define BT_DFXC_HFP_MEDIA (30)
|
||||
#define BT_DFXC_HFP_OFFLOAD (40)
|
||||
|
||||
// group: BT_DFXG_HID
|
||||
#define BT_DFXC_HID_CONN (0)
|
||||
|
||||
// group: BT_DFXG_MESH
|
||||
|
||||
// group: BT_DFXG_CHANNEL_SOUNDING
|
||||
|
||||
// group: BT_DFXG_OTHERS
|
||||
#define BT_DFXC_SOCKET (0)
|
||||
#define BT_DFXC_IPC_CONN (10)
|
||||
#define BT_DFXC_IPC_ALLOC (20)
|
||||
#define BT_DFXC_DRIVER (100)
|
||||
#define BT_DFXC_OPEN (200)
|
||||
|
||||
#define BT_DFX_BUILD_CODE(group, subcode) ((BT_DFX_BASE_VELA_BLUETOOTH) + (group) + (subcode))
|
||||
|
||||
#endif /* _BT_DFX_EVENT_H_ */
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2025 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#ifndef _BT_DFX_REASON_H_
|
||||
#define _BT_DFX_REASON_H_
|
||||
|
||||
// error reason
|
||||
#define BT_DFXE_REPEATED_ATTEMPT "btRepeatedAttempt"
|
||||
#define BT_DFXE_ADAPTER_STATE_NOT_ON "btAdapterStateNotOn"
|
||||
#define BT_DFXE_PAGE_TIMEOUT "btPageTimeout"
|
||||
#define BT_DFXE_CONN_TIMEOUT "btConnTimeout"
|
||||
#define BT_DFXE_CONN_FAILED_TO_BE_ESTABLISHED "btConnFailedToBeEstablished"
|
||||
|
||||
#define BT_DFXE_SCANNER_EXCEED_MAX_NUM "btScannerExceedMaxNum"
|
||||
|
||||
#define BT_DFXE_SPP_NOT_STARTUP "btSppNotStartup"
|
||||
#define BT_DFXE_SPP_SCN_ALLOC_FAIL "btSppScnAllocFail"
|
||||
#define BT_DFXE_SPP_NO_RESOURCES "btSppNoResources"
|
||||
|
||||
#define BT_DFXE_A2DP_CONN_TIMEOUT "btA2dpConnTimeout"
|
||||
#define BT_DFXE_SET_A2DP_AVAILABLE_FAIL "btSetA2dpAvailableFail"
|
||||
#define BT_DFXE_GET_A2DP_AVAILABLE_FAIL "btGetA2dpAvailableFail"
|
||||
|
||||
#define BT_DFXE_OFFLOAD_START_TIMEOUT "btOffloadStartTimeout"
|
||||
#define BT_DFXE_OFFLOAD_HCI_UNSPECIFIED_ERROR "btOffloadHciUnspecifiedError"
|
||||
|
||||
#define BT_DFXE_GET_MEDIA_VOLUME_RANGE_FAIL "btGetMediaVolumeRangeFail"
|
||||
#define BT_DFXE_SET_MEDIA_VOLUME_FAIL "btSetMediaVolumeFail"
|
||||
#define BT_DFXE_SET_UI_VOLUME_FAIL "btSetUiVolumeFail"
|
||||
#define BT_DFXE_MEDIA_PLAYER_CREATE_FAIL "btMediaPlayerCreateFail"
|
||||
#define BT_DFXE_GET_STREAM_VOLUME_FAIL "btGetStreamVolumeFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_OPEN_FAIL "btMediaSessionOpenFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_SET_EVENT_CB_FAIL "btMediaSessionSetEventCbFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_START_FAIL "btMediaSessionStartFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_STOP_FAIL "btMediaSessionStopFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_PAUSE_FAIL "btMediaSessionPauseFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_NEXT_SONG_FAIL "btMediaSessionNextSongFail"
|
||||
#define BT_DFXE_MEDIA_SESSION_PREV_SONG_FAIL "btMediaSessionPrevSongFail"
|
||||
|
||||
#define BT_DFXE_HFP_AG_CONN_TIMEOUT "btHfpAgConnTimeout"
|
||||
#define BT_DFXE_HFP_AG_CONN_RETRY_FAIL "btHfpAgConnRetryFail"
|
||||
#define BT_DFXE_HFP_HF_CONN_TIMEOUT "btHfpHfConnTimeout"
|
||||
#define BT_DFXE_HFP_HF_CONN_RETRY_FAIL "btHfpHfConnRetryFail"
|
||||
#define BT_DFXE_SET_VOICE_CALL_VOLUME_FAIL "btSetVoiceCallVolumeFail"
|
||||
#define BT_DFXE_GET_VOICE_CALL_VOLUME_FAIL "btGetVoiceCallVolumeFail"
|
||||
#define BT_DFXE_MEDIA_POLICY_SUBSCRIBE_FAIL "btMediaPolicySubscribeFail"
|
||||
#define BT_DFXE_SET_HFP_SAMPLERATE_FAIL "btSetHfpSamplerateFail"
|
||||
#define BT_DFXE_SET_SCO_AVAILABLE_FAIL "btSetScoAvailableFail"
|
||||
#define BT_DFXE_SET_SCO_UNAVAILABLE_FAIL "btSetScoUnavailableFail"
|
||||
#define BT_DFXE_SET_ANC_ENABLE_FAIL "btSetAncEnableFail"
|
||||
|
||||
#define BT_DFXE_HID_CONNECT_BUSY "btHidConnectBusy"
|
||||
|
||||
#define BT_DFXE_CLIENT_CONNECT_FAIL "btClientConnectFail"
|
||||
#define BT_DFXE_ASYNC_CLIENT_CONN_FAIL "btAsyncClientConnectFail"
|
||||
#define BT_DFXE_FILE_DESCRIPTOR_ERROR "btFileDescriptorError"
|
||||
#define BT_DFXE_SPP_CONN_FAIL "btSppConnFail"
|
||||
#define BT_DFXE_CLIENT_MSG_ALLOC_FAIL "btClientMsgAllocFail"
|
||||
#define BT_DFXE_SERVER_CACHE_ALLOC_FAIL "btServerCacheAllocFail"
|
||||
#define BT_DFXE_OPEN_HCI_UART_FAIL "btOpenHciUartFail"
|
||||
#define BT_DFXE_LE_ENABLE_FAIL "btLeEnableFail"
|
||||
#define BT_DFXE_BR_ENABLE_FAIL "btBrEnableFail"
|
||||
|
||||
#endif /* _BT_DFX_REASON_H_ */
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FEATURE_BLUETOOTH_H_
|
||||
#define _FEATURE_BLUETOOTH_H_
|
||||
#include "bluetooth.h"
|
||||
#include "bt_device.h"
|
||||
#include "bt_list.h"
|
||||
#include "bt_message_gattc.h"
|
||||
#include "feature_exports.h"
|
||||
|
||||
#define FEATURE_MANAGER_BLUETOOTH_DATA "bluetooth"
|
||||
|
||||
#define FEATURE_BT_NO_RESOURCES 10013
|
||||
#define FEATURE_BT_IPC_ERROR 10012
|
||||
#define FEATURE_BT_UNKNOWN_ERROR 10008
|
||||
#define FEATURE_BT_NOT_ENABLED 10001
|
||||
#define FEATURE_BT_NOT_FOUND 10014
|
||||
|
||||
typedef enum {
|
||||
STATE_NON_SCAN = 0,
|
||||
STATE_SCANING = 1,
|
||||
} ScanState;
|
||||
|
||||
typedef struct {
|
||||
FtCallbackId feature_callback_id;
|
||||
void* feature;
|
||||
void* data;
|
||||
} callback_info_t;
|
||||
|
||||
typedef struct {
|
||||
FeatureInstanceHandle* feature_ins;
|
||||
|
||||
// There will be additional events related to subscribing to features in the future.
|
||||
} feature_bluetooth_ins_t;
|
||||
|
||||
typedef struct {
|
||||
FeatureInstanceHandle* feature_ins;
|
||||
|
||||
// There will be additional events related to subscribing to features in the future.
|
||||
} feature_bluetooth_ble_ins_t;
|
||||
|
||||
typedef struct {
|
||||
FtPromiseId pid;
|
||||
union {
|
||||
FeatureInstanceHandle feature_ins;
|
||||
FeatureInterfaceHandle interface;
|
||||
};
|
||||
} feature_data_t;
|
||||
|
||||
typedef struct {
|
||||
bt_instance_t* ins;
|
||||
FeatureInterfaceHandle interface;
|
||||
void* adv;
|
||||
void* start_userdata;
|
||||
bool busy;
|
||||
} feature_bluetooth_adv_info_t;
|
||||
|
||||
typedef struct {
|
||||
FtInt id;
|
||||
FtCallbackId callback;
|
||||
FtCallbackId fail;
|
||||
} scan_subscribe_info_t;
|
||||
|
||||
typedef struct {
|
||||
bt_instance_t* ins;
|
||||
FeatureInterfaceHandle interface;
|
||||
void* scan;
|
||||
void* start_userdata;
|
||||
bool busy;
|
||||
bt_list_t* subscribe_info;
|
||||
FtInt subscribe_id;
|
||||
} feature_bluetooth_scan_info_t;
|
||||
|
||||
typedef struct {
|
||||
gattc_handle_t handle;
|
||||
bt_address_t remote_address;
|
||||
ble_addr_type_t addr_type;
|
||||
connection_state_t conn_state;
|
||||
uint16_t gatt_mtu;
|
||||
} gattc_t;
|
||||
|
||||
typedef enum {
|
||||
FEATURE_GATTC_CONN,
|
||||
FEATURE_GATTC_DISCONN,
|
||||
FEATURE_GATTC_DISCOVERY,
|
||||
FEATURE_GATTC_READ_CHAR,
|
||||
FEATURE_GATTC_READ_DESC,
|
||||
FEATURE_GATTC_WRITE_CHAR,
|
||||
FEATURE_GATTC_WRITE_DESC,
|
||||
FEATURE_GATTC_SET_MTU,
|
||||
FEATURE_GATTC_SET_NOTIFY,
|
||||
} gattc_userdata_type_t;
|
||||
|
||||
typedef struct {
|
||||
FtPromiseId pid;
|
||||
gattc_userdata_type_t userdata_type;
|
||||
FeatureInterfaceHandle interface;
|
||||
} gattc_data_t;
|
||||
|
||||
typedef struct {
|
||||
bool created;
|
||||
bt_instance_t* ins;
|
||||
FeatureInterfaceHandle interface;
|
||||
gattc_t* gattc;
|
||||
bt_list_t* userdata_list;
|
||||
} feature_bluetooth_gattc_info_t;
|
||||
|
||||
typedef struct {
|
||||
bt_list_t* feature_ble_adv;
|
||||
bt_list_t* feature_ble_scan;
|
||||
bt_list_t* feature_ble_gattc;
|
||||
} feature_bluetooth_features_info_t;
|
||||
|
||||
char* StringToFtString(const char* str);
|
||||
bool js_event_cb_added();
|
||||
void feature_bluetooth_post_task(FeatureInstanceHandle handle, FtCallbackId callback_id, void* data);
|
||||
FeatureErrorCode bt_status_to_feature_error(uint8_t status);
|
||||
void feature_bluetooth_init_bt_ins_async(FeatureProtoHandle handle);
|
||||
void feature_bluetooth_uninit_bt_ins_async(void* data);
|
||||
bt_instance_t* feature_bluetooth_get_bt_ins(FeatureInstanceHandle feature);
|
||||
void feature_ble_list_free(void* data);
|
||||
#endif // _FEATURE_BLUETOOTH_H_
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module system.bluetooth@2.0
|
||||
|
||||
promise<object> getAddressAsync()
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
module system.bluetooth.ble@2.0
|
||||
|
||||
struct AdvertiseSetting {
|
||||
int interval
|
||||
int txPower
|
||||
boolean connectable
|
||||
}
|
||||
|
||||
struct ManufactureData {
|
||||
string manufactureId
|
||||
object manufactureValue
|
||||
}
|
||||
|
||||
struct ServiceData {
|
||||
string serviceUuid
|
||||
object serviceValue
|
||||
}
|
||||
|
||||
struct AdvertiseData {
|
||||
string[] serviceUuids
|
||||
ManufactureData[] manufactureData
|
||||
ServiceData[] serviceData
|
||||
}
|
||||
|
||||
struct StartAdvertisingParams {
|
||||
AdvertiseSetting setting
|
||||
AdvertiseData advData
|
||||
AdvertiseData advResponse = null
|
||||
}
|
||||
|
||||
interface Advertiser {
|
||||
promise<void> startAdvertising(StartAdvertisingParams params)
|
||||
void stopAdvertising()
|
||||
void close()
|
||||
}
|
||||
[ctor="true", target="adv"] Advertiser createAdvertiser()
|
||||
|
||||
struct ScanFilter {
|
||||
string deviceId
|
||||
string name
|
||||
string serviceUuid
|
||||
}
|
||||
|
||||
const ScanDuty = {
|
||||
SCAN_MODE_LOW_POWER = 0,
|
||||
SCAN_MODE_BALANCED = 1,
|
||||
SCAN_MODE_LOW_LATENCY = 2
|
||||
}
|
||||
|
||||
struct ScanOptions {
|
||||
int interval
|
||||
int dutyMode
|
||||
}
|
||||
|
||||
struct StartScanParams {
|
||||
ScanFilter[] filters
|
||||
ScanOptions options = null
|
||||
}
|
||||
|
||||
const ScanState = {
|
||||
STATE_NON_SCAN = 0,
|
||||
STATE_SCANING = 1
|
||||
}
|
||||
|
||||
struct ScanResult {
|
||||
string deviceId
|
||||
int rssi
|
||||
object data
|
||||
string addressType
|
||||
}
|
||||
|
||||
callback deviceFoundResult(ScanResult[] result)
|
||||
callback deviceFindFail()
|
||||
struct DeviceFindParams {
|
||||
callback deviceFoundResult callback
|
||||
callback deviceFindFail fail
|
||||
}
|
||||
|
||||
struct ScanStateParams {
|
||||
int scanState
|
||||
}
|
||||
|
||||
interface Scanner {
|
||||
promise<void> startBLEScan(StartScanParams params)
|
||||
void stopBLEScan()
|
||||
promise<ScanStateParams> getScanState()
|
||||
int subscribeBLEDeviceFind(DeviceFindParams params)
|
||||
void unsubscribeBLEDeviceFind(int SubscribeId)
|
||||
void close()
|
||||
}
|
||||
[ctor="true", target="scan"] Scanner createScanner()
|
||||
|
||||
struct BLEDescriptor {
|
||||
string serviceUuid
|
||||
string characteristicUuid
|
||||
string descriptorUuid
|
||||
object descriptorValue
|
||||
}
|
||||
|
||||
struct GattProperties {
|
||||
boolean read
|
||||
boolean write
|
||||
boolean writeNoResponse
|
||||
boolean notify
|
||||
boolean indicate
|
||||
}
|
||||
|
||||
struct BLECharacteristic {
|
||||
string serviceUuid
|
||||
string characteristicUuid
|
||||
object characteristicValue
|
||||
BLEDescriptor[] descriptors
|
||||
GattProperties properties
|
||||
}
|
||||
|
||||
struct GattService {
|
||||
string serviceUuid
|
||||
boolean isPrimary
|
||||
BLECharacteristic[] characteristics
|
||||
GattService[] includeServices
|
||||
}
|
||||
|
||||
struct SetNotifyCharChangedParams {
|
||||
BLECharacteristic characteristic
|
||||
boolean enable
|
||||
}
|
||||
|
||||
const ProfileConnectionState = {
|
||||
STATE_DISCONNECTED = 0,
|
||||
STATE_CONNECTING = 1,
|
||||
STATE_CONNECTED = 2,
|
||||
STATE_DISCONNECTING = 3
|
||||
}
|
||||
|
||||
struct ReadCharacteristicValue {
|
||||
BLECharacteristic characteristic
|
||||
}
|
||||
|
||||
struct ReadDescriptorValue {
|
||||
BLEDescriptor descriptor
|
||||
}
|
||||
|
||||
struct WriteCharacteristicValue {
|
||||
BLECharacteristic characteristic
|
||||
}
|
||||
|
||||
struct WriteDescriptorValue {
|
||||
BLEDescriptor descriptor
|
||||
}
|
||||
|
||||
struct SetBLEMtuSize {
|
||||
int mtu
|
||||
}
|
||||
|
||||
interface GattClient {
|
||||
promise<void> connect()
|
||||
promise<void> disconnect()
|
||||
promise<GattService[]> getServices()
|
||||
promise<BLECharacteristic> readCharacteristicValue(ReadCharacteristicValue params)
|
||||
promise<BLEDescriptor> readDescriptorValue(ReadDescriptorValue params)
|
||||
promise<void> writeCharacteristicValue(WriteCharacteristicValue params)
|
||||
promise<void> writeDescriptorValue(WriteDescriptorValue params)
|
||||
promise<void> setBLEMtuSize(SetBLEMtuSize params)
|
||||
promise<void> setNotifyCharacteristicChanged(SetNotifyCharChangedParams params)
|
||||
boolean close()
|
||||
event onBLECharacteristicChange(BLECharacteristic params)
|
||||
event onBLEConnectionStateChange(int state)
|
||||
}
|
||||
[ctor="true", target="gattc"] GattClient createGattClientDevice(string deviceId, string addressType = "UNKNOWN")
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "bluetooth.h"
|
||||
#include "bt_adapter.h"
|
||||
#include "feature_bluetooth.h"
|
||||
#include "feature_exports.h"
|
||||
#include "feature_log.h"
|
||||
|
||||
#define file_tag "bluetooth"
|
||||
|
||||
void system_bluetooth_onRegister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_INFO("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onCreate(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_init_bt_ins_async(handle);
|
||||
FEATURE_LOG_INFO("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onRequired(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
FEATURE_LOG_INFO("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onDetached(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
FEATURE_LOG_INFO("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onDestroy(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
FEATURE_LOG_INFO("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onUnregister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_INFO("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
static void get_addr_cb(bt_instance_t* ins, bt_status_t status, bt_address_t* addr, void* userdata)
|
||||
{
|
||||
feature_data_t* data = (feature_data_t*)userdata;
|
||||
|
||||
if (FeatureInstanceIsDetached(data->feature_ins)) {
|
||||
FeatureFreeInstanceHandle(data->feature_ins);
|
||||
free(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (addr != NULL) {
|
||||
ft_context_ref ft_ctx = FeatureGetContext(data->feature_ins);
|
||||
ft_value_t ret_obj = ft_new_object(ft_ctx);
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
bt_addr_ba2str(addr, addr_str);
|
||||
ft_value_t ret_data = ft_from_string(ft_ctx, addr_str);
|
||||
ft_obj_set_property(ft_ctx, ret_obj, "address", ret_data);
|
||||
|
||||
FeaturePromiseResolve(data->feature_ins, data->pid, &ret_obj);
|
||||
ft_free_value(ft_ctx, ret_obj);
|
||||
} else {
|
||||
FeaturePromiseReject(data->feature_ins, data->pid, bt_status_to_feature_error(status), "get address failed!");
|
||||
}
|
||||
|
||||
FeatureFreeInstanceHandle(data->feature_ins);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void system_bluetooth_wrap_getAddressAsync(FeatureInstanceHandle feature, AppendData append_data, FtPromiseId pid)
|
||||
{
|
||||
feature_data_t* data;
|
||||
bt_status_t status;
|
||||
|
||||
data = (feature_data_t*)malloc(sizeof(feature_data_t));
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
data->feature_ins = FeatureDupInstanceHandle(feature);
|
||||
data->pid = pid;
|
||||
|
||||
status = bt_adapter_get_address_async(feature_bluetooth_get_bt_ins(feature), get_addr_cb, (void*)data);
|
||||
|
||||
if (status == BT_STATUS_SUCCESS)
|
||||
return;
|
||||
|
||||
FeaturePromiseReject(feature, pid, bt_status_to_feature_error(status), "get address failed!");
|
||||
FeatureFreeInstanceHandle(data->feature_ins);
|
||||
free(data);
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* Copyright (C) 2025 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "feature_bluetooth.h"
|
||||
#include "feature_log.h"
|
||||
#include <kvdb.h>
|
||||
|
||||
#define KVDB_USE_FEATURE "persist.using_bluetooth_feature"
|
||||
|
||||
char* StringToFtString(const char* str)
|
||||
{
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
int len = strlen(str);
|
||||
char* ftStr = (char*)FeatureMalloc(len + 1, FT_CHAR);
|
||||
strcpy(ftStr, str);
|
||||
return ftStr;
|
||||
}
|
||||
|
||||
static bool feature_bluetooth_using_feature()
|
||||
{
|
||||
static int using_bluetoothd_feature = -1;
|
||||
|
||||
if (using_bluetoothd_feature == -1) {
|
||||
using_bluetoothd_feature = property_get_bool(KVDB_USE_FEATURE, 1);
|
||||
}
|
||||
|
||||
return using_bluetoothd_feature;
|
||||
}
|
||||
|
||||
void feature_ble_list_free(void* data)
|
||||
{
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void feature_bluetooth_list_init(bt_instance_t* bt_ins)
|
||||
{
|
||||
feature_bluetooth_features_info_t* features_info;
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_info = (feature_bluetooth_features_info_t*)calloc(1, sizeof(feature_bluetooth_features_info_t));
|
||||
|
||||
assert(features_info);
|
||||
|
||||
features_info->feature_ble_adv = bt_list_new(feature_ble_list_free);
|
||||
features_info->feature_ble_scan = bt_list_new(feature_ble_list_free);
|
||||
features_info->feature_ble_gattc = bt_list_new(feature_ble_list_free);
|
||||
bt_ins->context = features_info;
|
||||
}
|
||||
|
||||
static void feature_bluetooth_list_uninit(bt_instance_t* bt_ins)
|
||||
{
|
||||
feature_bluetooth_features_info_t* features_info;
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_info = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
bt_list_free(features_info->feature_ble_adv);
|
||||
bt_list_free(features_info->feature_ble_scan);
|
||||
bt_list_free(features_info->feature_ble_gattc);
|
||||
free(bt_ins->context);
|
||||
bt_ins->context = NULL;
|
||||
}
|
||||
|
||||
static void ipc_connected(bt_instance_t* ins, void* userdata)
|
||||
{
|
||||
FEATURE_LOG_ERROR("ipc connected");
|
||||
}
|
||||
|
||||
static void ipc_disconnected(bt_instance_t* ins, void* userdata, int status)
|
||||
{
|
||||
FEATURE_LOG_ERROR("ipc disconnected");
|
||||
}
|
||||
|
||||
void feature_bluetooth_init_bt_ins_async(FeatureProtoHandle handle)
|
||||
{
|
||||
uv_loop_t* loop;
|
||||
FeatureManagerHandle manager = FeatureGetManagerHandleFromProto(handle);
|
||||
void* data = FeatureGetManagerUserData(manager, FEATURE_MANAGER_BLUETOOTH_DATA);
|
||||
bt_instance_t* bluetooth_ins = (bt_instance_t*)data;
|
||||
|
||||
if (!feature_bluetooth_using_feature()) {
|
||||
FeatureSetProtoData(handle, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bluetooth_ins) {
|
||||
FeatureSetProtoData(handle, bluetooth_ins);
|
||||
return;
|
||||
}
|
||||
|
||||
loop = FeatureGetUVLoop(manager);
|
||||
bluetooth_ins = bluetooth_create_async_instance(loop, ipc_connected, ipc_disconnected, NULL);
|
||||
if (bluetooth_ins == NULL) {
|
||||
FEATURE_LOG_ERROR("Failed to get Bluetooth instance.");
|
||||
return;
|
||||
}
|
||||
|
||||
FeatureSetManagerUserDataWithFreeCallback(manager, FEATURE_MANAGER_BLUETOOTH_DATA, bluetooth_ins, feature_bluetooth_uninit_bt_ins_async);
|
||||
feature_bluetooth_list_init(bluetooth_ins);
|
||||
|
||||
FeatureSetProtoData(handle, bluetooth_ins);
|
||||
}
|
||||
|
||||
void feature_bluetooth_uninit_bt_ins_async(void* data)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = (bt_instance_t*)data;
|
||||
feature_bluetooth_features_info_t* features_info;
|
||||
|
||||
if (!feature_bluetooth_using_feature()) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_info = (feature_bluetooth_features_info_t*)bluetooth_ins->context;
|
||||
|
||||
if (!features_info) {
|
||||
FEATURE_LOG_ERROR("Feature context not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
feature_bluetooth_list_uninit(bluetooth_ins);
|
||||
bluetooth_delete_async_instance(bluetooth_ins);
|
||||
}
|
||||
|
||||
bt_instance_t* feature_bluetooth_get_bt_ins(FeatureInstanceHandle feature)
|
||||
{
|
||||
FeatureProtoHandle protoHandle = FeatureGetProtoHandle(feature);
|
||||
return FeatureGetProtoData(protoHandle);
|
||||
}
|
||||
|
||||
FeatureErrorCode bt_status_to_feature_error(uint8_t status)
|
||||
{
|
||||
switch (status) {
|
||||
case BT_STATUS_FAIL:
|
||||
return FT_ERR_GENERAL;
|
||||
case BT_STATUS_NOMEM:
|
||||
return FT_ERR_GENERAL;
|
||||
case BT_STATUS_NOT_ENABLED:
|
||||
return FEATURE_BT_NOT_ENABLED;
|
||||
case BT_STATUS_DONE:
|
||||
return FT_ERR_DUPLICATE_SUBMISSION;
|
||||
case BT_STATUS_NOT_SUPPORTED:
|
||||
return FT_ERR_NOT_SUPPORTED;
|
||||
case BT_STATUS_NO_RESOURCES:
|
||||
return FEATURE_BT_NO_RESOURCES;
|
||||
case BT_STATUS_IPC_ERROR:
|
||||
return FEATURE_BT_IPC_ERROR;
|
||||
case BT_STATUS_DEVICE_NOT_FOUND:
|
||||
return FEATURE_BT_NOT_FOUND;
|
||||
case BT_STATUS_PARM_INVALID:
|
||||
return FT_ERR_ARGS;
|
||||
case BT_STATUS_NOT_FOUND:
|
||||
return FEATURE_BT_NOT_FOUND;
|
||||
case BT_STATUS_ERROR_BUT_UNKNOWN:
|
||||
return FEATURE_BT_UNKNOWN_ERROR;
|
||||
default:
|
||||
return FT_ERR_GENERAL;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* This file is auto-generated by jsongensource.py, Do not modify it directly!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FEATURE_BLUETOOTH_CONSTANT_H_
|
||||
#define FEATURE_BLUETOOTH_CONSTANT_H_
|
||||
#include "bluetooth.h"
|
||||
#include "bt_list.h"
|
||||
#include "feature_exports.h"
|
||||
|
||||
typedef enum {
|
||||
A2DP_SINK,
|
||||
A2DP_SOURCE,
|
||||
HFP_AG,
|
||||
HFP_HF,
|
||||
HID_DEVICE,
|
||||
PAN_USE,
|
||||
MAX_FEATURE_ID,
|
||||
} feature_bluetooth_profile_t;
|
||||
|
||||
typedef enum {
|
||||
ON_ADAPTER_STATE_CHANGE,
|
||||
ON_DISCOVERY_RESULT,
|
||||
ON_BOND_STATE_CHANGE,
|
||||
A2DPSINK_ON_CONNECT_STATE_CHANGE,
|
||||
AVRCPCONTROL_ELEMENT_ATTRIBUTE_CALLBACK,
|
||||
} feature_bluetooth_callback_t;
|
||||
|
||||
typedef enum {
|
||||
FEATURE_BLUETOOTH,
|
||||
FEATURE_BLUETOOTH_BT,
|
||||
FEATURE_BLUETOOTH_A2DPSINK,
|
||||
FEATURE_BLUETOOTH_AVRCPCONTROL,
|
||||
} feature_bluetooth_feature_type_t;
|
||||
|
||||
typedef struct {
|
||||
FeatureInstanceHandle* feature_ins;
|
||||
FtCallbackId on_adapter_state_changed_cb_id;
|
||||
} feature_bluetooth_bluetooth_callbacks_t;
|
||||
|
||||
typedef struct {
|
||||
FeatureInstanceHandle* feature_ins;
|
||||
FtCallbackId on_discovery_result_cb_id;
|
||||
FtCallbackId on_bond_state_changed_cb_id;
|
||||
} feature_bluetooth_bluetooth_bt_callbacks_t;
|
||||
|
||||
typedef struct {
|
||||
FeatureInstanceHandle* feature_ins;
|
||||
FtCallbackId a2dp_sink_connection_state_cb_id;
|
||||
} feature_bluetooth_a2dp_sink_callbacks_t;
|
||||
|
||||
typedef struct {
|
||||
FeatureInstanceHandle* feature_ins;
|
||||
FtCallbackId avrcp_control_element_attribute_cb_id;
|
||||
} feature_bluetooth_avrcp_control_callbacks_t;
|
||||
|
||||
typedef struct {
|
||||
FtCallbackId feature_callback_id;
|
||||
void* feature;
|
||||
void* data;
|
||||
} callback_info_t;
|
||||
|
||||
typedef struct {
|
||||
uv_mutex_t mutex;
|
||||
bt_list_t* feature_bluetooth_callbacks;
|
||||
bt_list_t* feature_bluetooth_bt_callbacks;
|
||||
bt_list_t* feature_a2dp_sink_callbacks;
|
||||
bt_list_t* feature_avrcp_control_callbacks;
|
||||
uint32_t created_features;
|
||||
} feature_bluetooth_features_info_t;
|
||||
|
||||
void feature_bluetooth_deal_callback(int status, void* data);
|
||||
void feature_bluetooth_remove_callback(int status, void* data);
|
||||
void feature_bluetooth_post_task(FeatureInstanceHandle handle, FtCallbackId callback_id, void* data);
|
||||
char* StringToFtString(const char* str);
|
||||
void feature_bluetooth_init_bt_ins(feature_bluetooth_feature_type_t feature, FeatureProtoHandle handle);
|
||||
void feature_bluetooth_uninit_bt_ins(feature_bluetooth_feature_type_t feature, FeatureProtoHandle handle);
|
||||
bt_instance_t* feature_bluetooth_get_bt_ins(FeatureInstanceHandle feature);
|
||||
|
||||
void feature_bluetooth_add_feature_callback(FeatureInstanceHandle handle, feature_bluetooth_feature_type_t feature_type);
|
||||
void feature_bluetooth_free_feature_callback(FeatureInstanceHandle handle, feature_bluetooth_feature_type_t feature_type);
|
||||
void feature_bluetooth_set_feature_callback(FeatureInstanceHandle handle, FtCallbackId callback_id, feature_bluetooth_callback_t callback_type);
|
||||
FtCallbackId feature_bluetooth_get_feature_callback(FeatureInstanceHandle handle, feature_bluetooth_callback_t callback_type);
|
||||
void feature_bluetooth_callback_init(bt_instance_t* bt_ins);
|
||||
void feature_bluetooth_callback_uninit(bt_instance_t* bt_ins);
|
||||
#endif // FEATURE_BLUETOOTH_CONSTANT_H_
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
module system.bluetooth@1.0
|
||||
|
||||
callback openAdapterSuccess()
|
||||
callback openAdapterFail(string data, int code)
|
||||
callback openAdapterComplete()
|
||||
struct OpenAdapterParams {
|
||||
boolean operateAdapter = false
|
||||
callback openAdapterSuccess success
|
||||
callback openAdapterFail fail
|
||||
callback openAdapterComplete complete
|
||||
}
|
||||
void openAdapter(OpenAdapterParams params)
|
||||
|
||||
callback closeAdapterSuccess()
|
||||
callback closeAdapterFail(string data, int code)
|
||||
callback closeAdapterComplete()
|
||||
struct CloseAdapterParams {
|
||||
boolean operateAdapter = false
|
||||
callback closeAdapterSuccess success
|
||||
callback closeAdapterFail fail
|
||||
callback closeAdapterComplete complete
|
||||
}
|
||||
void closeAdapter(CloseAdapterParams params)
|
||||
|
||||
struct GetAdapterSuccessResult {
|
||||
boolean available
|
||||
boolean discovering
|
||||
}
|
||||
callback getAdapterStateSuccess(GetAdapterSuccessResult data)
|
||||
callback getAdapterStateFail(string data, int code)
|
||||
callback getAdapterStateComplete()
|
||||
struct GetAdapterStateParams {
|
||||
callback getAdapterStateSuccess success
|
||||
callback getAdapterStateFail fail
|
||||
callback getAdapterStateComplete complete
|
||||
}
|
||||
void getAdapterState(GetAdapterStateParams params)
|
||||
|
||||
|
||||
struct adapterStateCallbackData {
|
||||
boolean available
|
||||
boolean discovering
|
||||
}
|
||||
callback adapterStateChange(adapterStateCallbackData data)
|
||||
property adapterStateChange onadapterstatechange
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
module system.bluetooth.bt@1.0
|
||||
|
||||
callback startDiscoverySuccess()
|
||||
callback startDiscoveryFail(string data, int code)
|
||||
callback startDiscoveryComplete()
|
||||
struct StartDiscoveryParams {
|
||||
callback startDiscoverySuccess success
|
||||
callback startDiscoveryFail fail
|
||||
callback startDiscoveryComplete complete
|
||||
}
|
||||
void startDiscovery(StartDiscoveryParams params)
|
||||
|
||||
callback stopDiscoverySuccess()
|
||||
callback stopDiscoveryFail(string data, int code)
|
||||
callback stopDiscoveryComplete()
|
||||
struct StopDiscoveryParams {
|
||||
callback stopDiscoverySuccess success
|
||||
callback stopDiscoveryFail fail
|
||||
callback stopDiscoveryComplete complete
|
||||
}
|
||||
void stopDiscovery(StopDiscoveryParams params)
|
||||
|
||||
|
||||
struct DiscoveryResultCallbackData {
|
||||
string deviceId
|
||||
string name
|
||||
uint cod
|
||||
uint rssi
|
||||
}
|
||||
callback discoveryResultChange(DiscoveryResultCallbackData data)
|
||||
property discoveryResultChange ondiscoveryresult
|
||||
|
||||
|
||||
callback connectProfilesSuccess()
|
||||
callback connectProfilesFail(string data, int code)
|
||||
callback connectProfilesComplete()
|
||||
struct ConnectProfilesParams {
|
||||
string deviceId
|
||||
int[] profiles
|
||||
callback connectProfilesSuccess success
|
||||
callback connectProfilesFail fail
|
||||
callback connectProfilesComplete complete
|
||||
}
|
||||
void connectProfiles(ConnectProfilesParams params)
|
||||
|
||||
callback disconnectProfilesSuccess()
|
||||
callback disconnectProfilesFail(string data, int code)
|
||||
callback disconnectProfilesComplete()
|
||||
struct DisconnectProfilesParams{
|
||||
string deviceId
|
||||
int[] profiles
|
||||
callback disconnectProfilesSuccess success
|
||||
callback disconnectProfilesFail fail
|
||||
callback disconnectProfilesComplete complete
|
||||
}
|
||||
void disconnectProfiles(DisconnectProfilesParams params)
|
||||
|
||||
callback disconnectSuccess()
|
||||
callback disconnectFail(string data, int code)
|
||||
callback disconnectComplete()
|
||||
struct DisconnectParams{
|
||||
string deviceId
|
||||
callback disconnectSuccess success
|
||||
callback disconnectFail fail
|
||||
callback disconnectComplete complete
|
||||
}
|
||||
void disconnect(DisconnectParams params)
|
||||
|
||||
boolean getConnectState(string deviceId)
|
||||
|
||||
struct connectedDevice {
|
||||
string deviceId
|
||||
string name
|
||||
int cod
|
||||
}
|
||||
string[] getConnectedDevices()
|
||||
|
||||
string[] getBondedDevices()
|
||||
|
||||
struct onBondStateChangeData {
|
||||
string deviceId
|
||||
int bondState
|
||||
}
|
||||
callback onBondStateChangeCallback(onBondStateChangeData data)
|
||||
property onBondStateChangeCallback onbondstatechange
|
||||
|
||||
callback removeBondedSuccess()
|
||||
callback removeBondedFail(string data, int code)
|
||||
callback removeBondedComplete()
|
||||
struct RemoveBondedParams{
|
||||
string deviceId
|
||||
callback removeBondedSuccess success
|
||||
callback removeBondedFail fail
|
||||
callback removeBondedComplete complete
|
||||
}
|
||||
void removeBondedDevice(RemoveBondedParams params)
|
||||
|
||||
|
||||
boolean setScanMode(int scanMode)
|
||||
|
||||
int getScanMode()
|
||||
|
||||
string getDeviceName(string deviceId)
|
||||
|
||||
uint getDeviceClass(string deviceId)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
module system.bluetooth.bt.a2dpsink@1.0
|
||||
|
||||
|
||||
struct OnConnectStateChangeData {
|
||||
string deviceId
|
||||
int connectState
|
||||
}
|
||||
callback onConnectStateChangeCallback(OnConnectStateChangeData data)
|
||||
property onConnectStateChangeCallback onconnectstatechange
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
module system.bluetooth.bt.avrcpcontrol@1.0
|
||||
|
||||
callback startGetElementAttributeSuccess()
|
||||
callback startGetElementAttributeFail(string data, int code)
|
||||
callback startGetElementAttributeComplete()
|
||||
struct StartGetElementAttributeParams {
|
||||
string deviceId
|
||||
callback startGetElementAttributeSuccess success
|
||||
callback startGetElementAttributeFail fail
|
||||
callback startGetElementAttributeComplete complete
|
||||
}
|
||||
void startGetElementAttribute(StartGetElementAttributeParams params)
|
||||
|
||||
struct attr_info_t {
|
||||
int attrId
|
||||
int chrSet
|
||||
string text
|
||||
}
|
||||
|
||||
struct OnElementAttributeData {
|
||||
string deviceId
|
||||
int attrsCount
|
||||
attr_info_t[] attrs;
|
||||
}
|
||||
|
||||
callback ElementAttributeCallback(OnElementAttributeData data)
|
||||
property ElementAttributeCallback onElementattribute
|
||||
|
|
@ -0,0 +1,784 @@
|
|||
/*
|
||||
* Copyright (C) 2024 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "bt_a2dp_sink.h"
|
||||
#include "bt_adapter.h"
|
||||
#include "bt_avrcp_control.h"
|
||||
#include "bt_list.h"
|
||||
#include "feature_bluetooth.h"
|
||||
#include "feature_exports.h"
|
||||
#include "feature_log.h"
|
||||
#include "system_bluetooth.h"
|
||||
#include "system_bluetooth_bt.h"
|
||||
#include "system_bluetooth_bt_a2dpsink.h"
|
||||
#include "system_bluetooth_bt_avrcpcontrol.h"
|
||||
#include "uv.h"
|
||||
|
||||
#define REMOVE_CALLBACK(feature_callback, callback_type) \
|
||||
do { \
|
||||
if (feature_callback->callback_type != -1) { \
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->callback_type, NULL); \
|
||||
} \
|
||||
feature_callback->callback_type = -1; \
|
||||
} while (0);
|
||||
|
||||
#define add_feature_callback(feature_callbacks, new_callbacks_type, handle) \
|
||||
{ \
|
||||
new_callbacks_type* new_callback = (new_callbacks_type*)malloc(sizeof(new_callbacks_type)); \
|
||||
/* The hexadecimal representation of -1 is 0xFF */ \
|
||||
memset(new_callback, -1, sizeof(new_callbacks_type)); \
|
||||
new_callback->feature_ins = handle; \
|
||||
bt_list_add_tail(feature_callbacks, new_callback); \
|
||||
}
|
||||
|
||||
#define set_feature_callback(feature_callbacks, callbacks_type, find_func, handle, callback_id, callback_type) \
|
||||
{ \
|
||||
callbacks_type* callbacks = (callbacks_type*)bt_list_find(feature_callbacks, find_func, handle); \
|
||||
REMOVE_CALLBACK(callbacks, callback_type) \
|
||||
callbacks->callback_type = callback_id; \
|
||||
};
|
||||
|
||||
#define get_feature_callback(feature_callbacks, callbacks_type, find_func, handle, callback_id, callback_type) \
|
||||
{ \
|
||||
callbacks_type* callbacks = (callbacks_type*)bt_list_find(feature_callbacks, find_func, handle); \
|
||||
callback_id = callbacks->callback_type; \
|
||||
};
|
||||
|
||||
static bool get_callback_bluetooth(void* data, void* feature_ins)
|
||||
{
|
||||
feature_bluetooth_bluetooth_callbacks_t* callbacks = (feature_bluetooth_bluetooth_callbacks_t*)data;
|
||||
if (!callbacks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return callbacks->feature_ins == feature_ins;
|
||||
}
|
||||
|
||||
static bool get_callback_bluetooth_bt(void* data, void* feature_ins)
|
||||
{
|
||||
feature_bluetooth_bluetooth_bt_callbacks_t* callbacks = (feature_bluetooth_bluetooth_bt_callbacks_t*)data;
|
||||
if (!callbacks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return callbacks->feature_ins == feature_ins;
|
||||
}
|
||||
|
||||
static bool get_callback_a2dp_sink(void* data, void* feature_ins)
|
||||
{
|
||||
feature_bluetooth_a2dp_sink_callbacks_t* callbacks = (feature_bluetooth_a2dp_sink_callbacks_t*)data;
|
||||
if (!callbacks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return callbacks->feature_ins == feature_ins;
|
||||
}
|
||||
|
||||
static bool get_callback_avrcp_control(void* data, void* feature_ins)
|
||||
{
|
||||
feature_bluetooth_avrcp_control_callbacks_t* callbacks = (feature_bluetooth_avrcp_control_callbacks_t*)data;
|
||||
if (!callbacks) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return callbacks->feature_ins == feature_ins;
|
||||
}
|
||||
|
||||
static void free_feature_callback(bt_list_t* callbacks, FeatureInstanceHandle handle, bt_list_find_cb find_func)
|
||||
{
|
||||
void* data;
|
||||
|
||||
if (!callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
data = bt_list_find(callbacks, find_func, handle);
|
||||
if (data) {
|
||||
bt_list_remove(callbacks, data);
|
||||
}
|
||||
}
|
||||
|
||||
static void free_feature_bluetooth_node(void* node)
|
||||
{
|
||||
feature_bluetooth_bluetooth_callbacks_t* feature_callback = (feature_bluetooth_bluetooth_callbacks_t*)node;
|
||||
|
||||
if (!feature_callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
REMOVE_CALLBACK(feature_callback, on_adapter_state_changed_cb_id);
|
||||
free(feature_callback);
|
||||
}
|
||||
|
||||
static void free_feature_bluetooth_bt_node(void* node)
|
||||
{
|
||||
feature_bluetooth_bluetooth_bt_callbacks_t* feature_callback = (feature_bluetooth_bluetooth_bt_callbacks_t*)node;
|
||||
|
||||
if (!feature_callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
REMOVE_CALLBACK(feature_callback, on_bond_state_changed_cb_id);
|
||||
REMOVE_CALLBACK(feature_callback, on_discovery_result_cb_id);
|
||||
free(feature_callback);
|
||||
}
|
||||
|
||||
static void free_feature_bluetooth_a2dp_sink_node(void* node)
|
||||
{
|
||||
feature_bluetooth_a2dp_sink_callbacks_t* feature_callback = (feature_bluetooth_a2dp_sink_callbacks_t*)node;
|
||||
|
||||
if (!feature_callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
REMOVE_CALLBACK(feature_callback, a2dp_sink_connection_state_cb_id);
|
||||
free(feature_callback);
|
||||
}
|
||||
|
||||
static void free_feature_bluetooth_avrcp_control_node(void* node)
|
||||
{
|
||||
feature_bluetooth_avrcp_control_callbacks_t* feature_callback = (feature_bluetooth_avrcp_control_callbacks_t*)node;
|
||||
|
||||
if (!feature_callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
REMOVE_CALLBACK(feature_callback, avrcp_control_element_attribute_cb_id);
|
||||
free(feature_callback);
|
||||
}
|
||||
|
||||
static void on_adapter_state_changed_cb(void* cookie, bt_adapter_state_t state)
|
||||
{
|
||||
bt_instance_t* bt_ins = (bt_instance_t*)cookie;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
bt_list_t* callbacks;
|
||||
bt_list_node_t* node;
|
||||
|
||||
FEATURE_LOG_DEBUG("adapter state change callback, state: %d", state);
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
callbacks = features_callbacks->feature_bluetooth_callbacks;
|
||||
if (!callbacks) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
node = bt_list_head(callbacks);
|
||||
if (!node) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (node) {
|
||||
feature_bluetooth_bluetooth_callbacks_t* feature_callback;
|
||||
system_bluetooth_adapterStateCallbackData* data;
|
||||
|
||||
feature_callback = (feature_bluetooth_bluetooth_callbacks_t*)bt_list_node(node);
|
||||
if (!feature_callback) {
|
||||
break;
|
||||
}
|
||||
|
||||
FEATURE_LOG_DEBUG("feature:%p, callbackId:%d", feature_callback->feature_ins, feature_callback->on_adapter_state_changed_cb_id);
|
||||
if (state != BT_ADAPTER_STATE_ON && state != BT_ADAPTER_STATE_OFF) {
|
||||
break;
|
||||
}
|
||||
|
||||
data = system_bluetoothMallocadapterStateCallbackData();
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->available = state == BT_ADAPTER_STATE_ON;
|
||||
data->discovering = bt_adapter_is_discovering(bt_ins);
|
||||
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->on_adapter_state_changed_cb_id, data);
|
||||
node = bt_list_next(callbacks, node);
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
static void on_discovery_state_changed_cb(void* cookie, bt_discovery_state_t state)
|
||||
{
|
||||
bt_instance_t* bt_ins = (bt_instance_t*)cookie;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
bt_list_t* callbacks;
|
||||
bt_list_node_t* node;
|
||||
|
||||
FEATURE_LOG_DEBUG("discovery state change callback, state: %d", state);
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
callbacks = features_callbacks->feature_bluetooth_callbacks;
|
||||
if (!callbacks) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
node = bt_list_head(callbacks);
|
||||
if (!node) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (node) {
|
||||
feature_bluetooth_bluetooth_callbacks_t* feature_callback;
|
||||
system_bluetooth_adapterStateCallbackData* data;
|
||||
|
||||
feature_callback = (feature_bluetooth_bluetooth_callbacks_t*)bt_list_node(node);
|
||||
if (!feature_callback) {
|
||||
break;
|
||||
}
|
||||
|
||||
FEATURE_LOG_DEBUG("feature:%p, callbackId:%d", feature_callback->feature_ins, feature_callback->on_adapter_state_changed_cb_id);
|
||||
data = system_bluetoothMallocadapterStateCallbackData();
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->available = bt_adapter_get_state(bt_ins) == BT_ADAPTER_STATE_ON;
|
||||
data->discovering = state == BT_DISCOVERY_STATE_STARTED;
|
||||
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->on_adapter_state_changed_cb_id, data);
|
||||
node = bt_list_next(callbacks, node);
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
static void on_discovery_result_cb(void* cookie, bt_discovery_result_t* result)
|
||||
{
|
||||
bt_instance_t* bt_ins = (bt_instance_t*)cookie;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
bt_list_t* callbacks;
|
||||
bt_list_node_t* node;
|
||||
|
||||
FEATURE_LOG_DEBUG("discovery result callback");
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
callbacks = features_callbacks->feature_bluetooth_bt_callbacks;
|
||||
if (!callbacks) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
node = bt_list_head(callbacks);
|
||||
if (!node) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (node) {
|
||||
feature_bluetooth_bluetooth_bt_callbacks_t* feature_callback;
|
||||
system_bluetooth_bt_DiscoveryResultCallbackData* data;
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
|
||||
feature_callback = (feature_bluetooth_bluetooth_bt_callbacks_t*)bt_list_node(node);
|
||||
if (!feature_callback) {
|
||||
break;
|
||||
}
|
||||
|
||||
FEATURE_LOG_DEBUG("feature:%p, callbackId:%d", feature_callback->feature_ins, feature_callback->on_discovery_result_cb_id);
|
||||
data = system_bluetooth_btMallocDiscoveryResultCallbackData();
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->name = StringToFtString(result->name);
|
||||
bt_addr_ba2str(&result->addr, addr_str);
|
||||
data->deviceId = StringToFtString(addr_str);
|
||||
data->cod = result->cod;
|
||||
data->rssi = -result->rssi;
|
||||
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->on_discovery_result_cb_id, data);
|
||||
node = bt_list_next(callbacks, node);
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
static void on_bond_state_changed_cb(void* cookie, bt_address_t* addr, bt_transport_t transport, bond_state_t state, bool is_ctkd)
|
||||
{
|
||||
bt_instance_t* bt_ins = (bt_instance_t*)cookie;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
bt_list_t* callbacks;
|
||||
bt_list_node_t* node;
|
||||
|
||||
FEATURE_LOG_DEBUG("bond state callback");
|
||||
if (transport != BT_TRANSPORT_BREDR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
callbacks = features_callbacks->feature_bluetooth_bt_callbacks;
|
||||
if (!callbacks) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
node = bt_list_head(callbacks);
|
||||
if (!node) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (node) {
|
||||
feature_bluetooth_bluetooth_bt_callbacks_t* feature_callback;
|
||||
system_bluetooth_bt_onBondStateChangeData* data;
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
|
||||
feature_callback = (feature_bluetooth_bluetooth_bt_callbacks_t*)bt_list_node(node);
|
||||
if (!feature_callback) {
|
||||
break;
|
||||
}
|
||||
|
||||
FEATURE_LOG_DEBUG("feature:%p, callbackId:%d", feature_callback->feature_ins, feature_callback->on_bond_state_changed_cb_id);
|
||||
data = system_bluetooth_btMalloconBondStateChangeData();
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bt_addr_ba2str(addr, addr_str);
|
||||
data->deviceId = StringToFtString(addr_str);
|
||||
data->bondState = state;
|
||||
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->on_bond_state_changed_cb_id, data);
|
||||
node = bt_list_next(callbacks, node);
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
const static adapter_callbacks_t g_adapter_cbs = {
|
||||
.on_adapter_state_changed = on_adapter_state_changed_cb,
|
||||
.on_discovery_state_changed = on_discovery_state_changed_cb,
|
||||
.on_discovery_result = on_discovery_result_cb,
|
||||
.on_bond_state_changed = on_bond_state_changed_cb,
|
||||
};
|
||||
|
||||
static void a2dp_sink_connection_state_cb(void* cookie, bt_address_t* addr, profile_connection_state_t state)
|
||||
{
|
||||
bt_instance_t* bt_ins = (bt_instance_t*)cookie;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
bt_list_t* callbacks;
|
||||
bt_list_node_t* node;
|
||||
|
||||
FEATURE_LOG_DEBUG("a2dp sink connection state cb");
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
callbacks = features_callbacks->feature_a2dp_sink_callbacks;
|
||||
if (!callbacks) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
node = bt_list_head(callbacks);
|
||||
if (!node) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (node) {
|
||||
feature_bluetooth_a2dp_sink_callbacks_t* feature_callback;
|
||||
system_bluetooth_bt_a2dpsink_OnConnectStateChangeData* data;
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
|
||||
feature_callback = (feature_bluetooth_a2dp_sink_callbacks_t*)bt_list_node(node);
|
||||
if (!feature_callback) {
|
||||
break;
|
||||
}
|
||||
|
||||
FEATURE_LOG_DEBUG("feature:%p, callbackId:%d", feature_callback->feature_ins, feature_callback->a2dp_sink_connection_state_cb_id);
|
||||
bt_addr_ba2str(addr, addr_str);
|
||||
data = system_bluetooth_bt_a2dpsinkMallocOnConnectStateChangeData();
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->deviceId = StringToFtString(addr_str);
|
||||
data->connectState = state;
|
||||
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->a2dp_sink_connection_state_cb_id, data);
|
||||
node = bt_list_next(callbacks, node);
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
static const a2dp_sink_callbacks_t a2dp_sink_cbs = {
|
||||
sizeof(a2dp_sink_cbs),
|
||||
a2dp_sink_connection_state_cb,
|
||||
};
|
||||
|
||||
system_bluetooth_bt_avrcpcontrol_attr_info_t* get_attr_info(avrcp_element_attr_val_t* attr)
|
||||
{
|
||||
system_bluetooth_bt_avrcpcontrol_attr_info_t* attr_info = system_bluetooth_bt_avrcpcontrolMallocattr_info_t();
|
||||
attr_info->attrId = attr->attr_id;
|
||||
attr_info->chrSet = attr->chr_set;
|
||||
attr_info->text = StringToFtString((char*)attr->text);
|
||||
return attr_info;
|
||||
}
|
||||
|
||||
static void avrcp_control_get_element_attribute_cb(void* cookie, bt_address_t* addr, uint8_t attrs_count, avrcp_element_attr_val_t* attrs)
|
||||
{
|
||||
int attr_index;
|
||||
bt_instance_t* bt_ins = (bt_instance_t*)cookie;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
bt_list_t* callbacks;
|
||||
bt_list_node_t* node;
|
||||
|
||||
FEATURE_LOG_DEBUG("avrcp control element attribute cb");
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
callbacks = features_callbacks->feature_avrcp_control_callbacks;
|
||||
if (!callbacks) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
node = bt_list_head(callbacks);
|
||||
if (!node) {
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
while (node) {
|
||||
feature_bluetooth_avrcp_control_callbacks_t* feature_callback;
|
||||
system_bluetooth_bt_avrcpcontrol_OnElementAttributeData* data;
|
||||
FtArray* attributes;
|
||||
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
|
||||
feature_callback = (feature_bluetooth_avrcp_control_callbacks_t*)bt_list_node(node);
|
||||
if (!feature_callback) {
|
||||
break;
|
||||
}
|
||||
|
||||
FEATURE_LOG_DEBUG("feature:%p, callbackId:%d", feature_callback->feature_ins, feature_callback->avrcp_control_element_attribute_cb_id);
|
||||
bt_addr_ba2str(addr, addr_str);
|
||||
data = system_bluetooth_bt_avrcpcontrolMallocOnElementAttributeData();
|
||||
attributes = system_bluetooth_bt_avrcpcontrol_malloc_attr_info_t_struct_type_array();
|
||||
|
||||
if (!data || !attributes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data->deviceId = StringToFtString(addr_str);
|
||||
data->attrsCount = attrs_count;
|
||||
attributes->_size = attrs_count;
|
||||
attributes->_element = malloc(attributes->_size * sizeof(struct Attribute*));
|
||||
if (!attributes->_element) {
|
||||
continue;
|
||||
}
|
||||
for (attr_index = 0; attr_index < attributes->_size; attr_index++) {
|
||||
system_bluetooth_bt_avrcpcontrol_attr_info_t* attr_info = get_attr_info(&attrs[attr_index]);
|
||||
((system_bluetooth_bt_avrcpcontrol_attr_info_t**)attributes->_element)[attr_index] = attr_info;
|
||||
}
|
||||
|
||||
data->attrs = attributes;
|
||||
|
||||
feature_bluetooth_post_task(feature_callback->feature_ins, feature_callback->avrcp_control_element_attribute_cb_id, data);
|
||||
node = bt_list_next(callbacks, node);
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
static const avrcp_control_callbacks_t avrcp_control_cbs = {
|
||||
.size = sizeof(avrcp_control_cbs),
|
||||
.get_element_attribute_cb = avrcp_control_get_element_attribute_cb,
|
||||
};
|
||||
|
||||
void feature_bluetooth_add_feature_callback(FeatureInstanceHandle handle, feature_bluetooth_feature_type_t feature_type)
|
||||
{
|
||||
bt_instance_t* bt_ins;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
|
||||
bt_ins = feature_bluetooth_get_bt_ins(handle);
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
switch (feature_type) {
|
||||
case FEATURE_BLUETOOTH:
|
||||
add_feature_callback(features_callbacks->feature_bluetooth_callbacks, feature_bluetooth_bluetooth_callbacks_t, handle);
|
||||
break;
|
||||
case FEATURE_BLUETOOTH_BT:
|
||||
add_feature_callback(features_callbacks->feature_bluetooth_bt_callbacks, feature_bluetooth_bluetooth_bt_callbacks_t, handle);
|
||||
break;
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
case FEATURE_BLUETOOTH_A2DPSINK:
|
||||
add_feature_callback(features_callbacks->feature_a2dp_sink_callbacks, feature_bluetooth_a2dp_sink_callbacks_t, handle);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
case FEATURE_BLUETOOTH_AVRCPCONTROL:
|
||||
add_feature_callback(features_callbacks->feature_avrcp_control_callbacks, feature_bluetooth_avrcp_control_callbacks_t, handle);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
void feature_bluetooth_free_feature_callback(FeatureInstanceHandle handle, feature_bluetooth_feature_type_t feature_type)
|
||||
{
|
||||
bt_instance_t* bt_ins;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
|
||||
bt_ins = feature_bluetooth_get_bt_ins(handle);
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
switch (feature_type) {
|
||||
case FEATURE_BLUETOOTH:
|
||||
free_feature_callback(features_callbacks->feature_bluetooth_callbacks, handle, get_callback_bluetooth);
|
||||
break;
|
||||
case FEATURE_BLUETOOTH_BT:
|
||||
free_feature_callback(features_callbacks->feature_bluetooth_bt_callbacks, handle, get_callback_bluetooth_bt);
|
||||
break;
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
case FEATURE_BLUETOOTH_A2DPSINK:
|
||||
free_feature_callback(features_callbacks->feature_a2dp_sink_callbacks, handle, get_callback_a2dp_sink);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
case FEATURE_BLUETOOTH_AVRCPCONTROL:
|
||||
free_feature_callback(features_callbacks->feature_avrcp_control_callbacks, handle, get_callback_avrcp_control);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
void feature_bluetooth_set_feature_callback(FeatureInstanceHandle handle, FtCallbackId callback_id, feature_bluetooth_callback_t callback_type)
|
||||
{
|
||||
bt_instance_t* bt_ins;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
|
||||
bt_ins = feature_bluetooth_get_bt_ins(handle);
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
switch (callback_type) {
|
||||
case ON_ADAPTER_STATE_CHANGE:
|
||||
set_feature_callback(features_callbacks->feature_bluetooth_callbacks, feature_bluetooth_bluetooth_callbacks_t, get_callback_bluetooth, handle, callback_id, on_adapter_state_changed_cb_id);
|
||||
break;
|
||||
case ON_DISCOVERY_RESULT:
|
||||
set_feature_callback(features_callbacks->feature_bluetooth_bt_callbacks, feature_bluetooth_bluetooth_bt_callbacks_t, get_callback_bluetooth_bt, handle, callback_id, on_discovery_result_cb_id);
|
||||
break;
|
||||
case ON_BOND_STATE_CHANGE:
|
||||
set_feature_callback(features_callbacks->feature_bluetooth_bt_callbacks, feature_bluetooth_bluetooth_bt_callbacks_t, get_callback_bluetooth_bt, handle, callback_id, on_bond_state_changed_cb_id);
|
||||
break;
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
case A2DPSINK_ON_CONNECT_STATE_CHANGE:
|
||||
set_feature_callback(features_callbacks->feature_a2dp_sink_callbacks, feature_bluetooth_a2dp_sink_callbacks_t, get_callback_a2dp_sink, handle, callback_id, a2dp_sink_connection_state_cb_id);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
case AVRCPCONTROL_ELEMENT_ATTRIBUTE_CALLBACK:
|
||||
set_feature_callback(features_callbacks->feature_avrcp_control_callbacks, feature_bluetooth_avrcp_control_callbacks_t, get_callback_avrcp_control, handle, callback_id, avrcp_control_element_attribute_cb_id);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
}
|
||||
|
||||
FtCallbackId feature_bluetooth_get_feature_callback(FeatureInstanceHandle handle, feature_bluetooth_callback_t callback_type)
|
||||
{
|
||||
bt_instance_t* bt_ins;
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
FtCallbackId callback_id = -1;
|
||||
|
||||
bt_ins = feature_bluetooth_get_bt_ins(handle);
|
||||
if (!bt_ins) {
|
||||
return callback_id;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)bt_ins->context;
|
||||
|
||||
if (!features_callbacks) {
|
||||
return callback_id;
|
||||
}
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
switch (callback_type) {
|
||||
case ON_ADAPTER_STATE_CHANGE:
|
||||
set_feature_callback(features_callbacks->feature_bluetooth_callbacks, feature_bluetooth_bluetooth_callbacks_t, get_callback_bluetooth, handle, callback_id, on_adapter_state_changed_cb_id);
|
||||
break;
|
||||
case ON_DISCOVERY_RESULT:
|
||||
set_feature_callback(features_callbacks->feature_bluetooth_bt_callbacks, feature_bluetooth_bluetooth_bt_callbacks_t, get_callback_bluetooth_bt, handle, callback_id, on_discovery_result_cb_id);
|
||||
break;
|
||||
case ON_BOND_STATE_CHANGE:
|
||||
set_feature_callback(features_callbacks->feature_bluetooth_bt_callbacks, feature_bluetooth_bluetooth_bt_callbacks_t, get_callback_bluetooth_bt, handle, callback_id, on_bond_state_changed_cb_id);
|
||||
break;
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
case A2DPSINK_ON_CONNECT_STATE_CHANGE:
|
||||
get_feature_callback(features_callbacks->feature_a2dp_sink_callbacks, feature_bluetooth_a2dp_sink_callbacks_t, get_callback_a2dp_sink, handle, callback_id, a2dp_sink_connection_state_cb_id);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
case AVRCPCONTROL_ELEMENT_ATTRIBUTE_CALLBACK:
|
||||
get_feature_callback(features_callbacks->feature_avrcp_control_callbacks, feature_bluetooth_avrcp_control_callbacks_t, get_callback_avrcp_control, handle, callback_id, avrcp_control_element_attribute_cb_id);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
return callback_id;
|
||||
}
|
||||
|
||||
void feature_bluetooth_callback_init(bt_instance_t* bt_ins)
|
||||
{
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = (feature_bluetooth_features_info_t*)calloc(1, sizeof(feature_bluetooth_features_info_t));
|
||||
|
||||
assert(features_callbacks);
|
||||
|
||||
uv_mutex_init(&features_callbacks->mutex);
|
||||
|
||||
features_callbacks->feature_bluetooth_callbacks = bt_list_new(free_feature_bluetooth_node);
|
||||
features_callbacks->feature_bluetooth_bt_callbacks = bt_list_new(free_feature_bluetooth_bt_node);
|
||||
|
||||
bt_ins->adapter_cookie = bt_adapter_register_callback(bt_ins, &g_adapter_cbs);
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
features_callbacks->feature_a2dp_sink_callbacks = bt_list_new(free_feature_bluetooth_a2dp_sink_node);
|
||||
bt_ins->a2dp_sink_cookie = bt_a2dp_sink_register_callbacks(bt_ins, &a2dp_sink_cbs);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
features_callbacks->feature_avrcp_control_callbacks = bt_list_new(free_feature_bluetooth_avrcp_control_node);
|
||||
bt_ins->avrcp_control_cookie = bt_avrcp_control_register_callbacks(bt_ins, &avrcp_control_cbs);
|
||||
#endif
|
||||
|
||||
bt_ins->context = features_callbacks;
|
||||
}
|
||||
|
||||
void feature_bluetooth_callback_uninit(bt_instance_t* bt_ins)
|
||||
{
|
||||
feature_bluetooth_features_info_t* features_callbacks;
|
||||
|
||||
if (!bt_ins) {
|
||||
return;
|
||||
}
|
||||
|
||||
features_callbacks = bt_ins->context;
|
||||
bt_ins->context = NULL;
|
||||
if (!features_callbacks) {
|
||||
return;
|
||||
}
|
||||
|
||||
bt_adapter_unregister_callback(bt_ins, bt_ins->adapter_cookie);
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
bt_a2dp_sink_unregister_callbacks(bt_ins, bt_ins->a2dp_sink_cookie);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
bt_avrcp_control_unregister_callbacks(bt_ins, bt_ins->avrcp_control_cookie);
|
||||
#endif
|
||||
|
||||
uv_mutex_lock(&features_callbacks->mutex);
|
||||
bt_list_free(features_callbacks->feature_bluetooth_callbacks);
|
||||
bt_list_free(features_callbacks->feature_bluetooth_bt_callbacks);
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
bt_list_free(features_callbacks->feature_a2dp_sink_callbacks);
|
||||
#endif
|
||||
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
|
||||
bt_list_free(features_callbacks->feature_avrcp_control_callbacks);
|
||||
#endif
|
||||
uv_mutex_unlock(&features_callbacks->mutex);
|
||||
|
||||
uv_mutex_destroy(&features_callbacks->mutex);
|
||||
free(features_callbacks);
|
||||
}
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
/*
|
||||
* Copyright (C) 2024 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "feature_bluetooth.h"
|
||||
#include "feature_log.h"
|
||||
#include <kvdb.h>
|
||||
|
||||
#define KVDB_USE_FEATURE "persist.using_bluetooth_feature"
|
||||
|
||||
static void free_callback_info(callback_info_t* info)
|
||||
{
|
||||
if (info->data)
|
||||
FeatureFreeValue(info->data);
|
||||
|
||||
free(info);
|
||||
}
|
||||
|
||||
void feature_bluetooth_deal_callback(int status, void* data)
|
||||
{
|
||||
callback_info_t* info = (callback_info_t*)data;
|
||||
FEATURE_LOG_DEBUG("callback type:%d, feature:%p, callback id: %d", info->callback_id, info->feature, info->feature_callback_id);
|
||||
if (!FeatureCheckCallbackId(info->feature, info->feature_callback_id)) {
|
||||
goto freeData;
|
||||
}
|
||||
|
||||
if (!FeatureInvokeCallback(info->feature, info->feature_callback_id, info->data)) {
|
||||
FEATURE_LOG_ERROR("feature:%p, callback id: %d, invoke discoveryresult callback failed!",
|
||||
info->feature, info->feature_callback_id);
|
||||
}
|
||||
|
||||
freeData:
|
||||
free_callback_info(info);
|
||||
}
|
||||
|
||||
void feature_bluetooth_remove_callback(int status, void* data)
|
||||
{
|
||||
callback_info_t* info = (callback_info_t*)data;
|
||||
FEATURE_LOG_DEBUG("remove callback, feature:%p, callback id: %d", info->feature, info->feature_callback_id);
|
||||
FeatureRemoveCallback(info->feature, info->feature_callback_id);
|
||||
|
||||
free_callback_info(info);
|
||||
}
|
||||
|
||||
void feature_bluetooth_post_task(FeatureInstanceHandle handle, FtCallbackId callback_id, void* data)
|
||||
{
|
||||
callback_info_t* callback_info;
|
||||
|
||||
callback_info = (callback_info_t*)calloc(1, sizeof(callback_info_t));
|
||||
if (!callback_info) {
|
||||
if (data)
|
||||
FeatureFreeValue(data);
|
||||
return;
|
||||
}
|
||||
|
||||
callback_info->feature_callback_id = callback_id;
|
||||
callback_info->feature = handle;
|
||||
callback_info->data = data;
|
||||
if (!FeaturePost(handle, feature_bluetooth_deal_callback, callback_info)) {
|
||||
FEATURE_LOG_WARN("feature:%p, callback id: %d, post callback failed!", handle, callback_id);
|
||||
free_callback_info(callback_info);
|
||||
}
|
||||
}
|
||||
|
||||
char* StringToFtString(const char* str)
|
||||
{
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
int len = strlen(str);
|
||||
char* ftStr = (char*)FeatureMalloc(len + 1, FT_CHAR);
|
||||
strcpy(ftStr, str);
|
||||
return ftStr;
|
||||
}
|
||||
|
||||
static bool feature_bluetooth_using_feature()
|
||||
{
|
||||
static int using_bluetoothd_feature = -1;
|
||||
|
||||
if (using_bluetoothd_feature == -1) {
|
||||
using_bluetoothd_feature = property_get_bool(KVDB_USE_FEATURE, 1);
|
||||
}
|
||||
|
||||
return using_bluetoothd_feature;
|
||||
}
|
||||
|
||||
void feature_bluetooth_init_bt_ins(feature_bluetooth_feature_type_t feature, FeatureProtoHandle handle)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins;
|
||||
|
||||
if (!feature_bluetooth_using_feature()) {
|
||||
FeatureSetProtoData(handle, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
bluetooth_ins = bluetooth_get_instance();
|
||||
|
||||
if (bluetooth_ins == NULL) {
|
||||
FEATURE_LOG_ERROR("Failed to get Bluetooth instance.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (bluetooth_ins->context == NULL) {
|
||||
feature_bluetooth_callback_init(bluetooth_ins);
|
||||
}
|
||||
|
||||
((feature_bluetooth_features_info_t*)bluetooth_ins->context)->created_features |= (1UL << feature);
|
||||
|
||||
FeatureSetProtoData(handle, bluetooth_ins);
|
||||
}
|
||||
|
||||
void feature_bluetooth_uninit_bt_ins(feature_bluetooth_feature_type_t feature, FeatureProtoHandle handle)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins;
|
||||
feature_bluetooth_features_info_t* features_info;
|
||||
|
||||
if (!feature_bluetooth_using_feature()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FeatureSetProtoData(handle, NULL);
|
||||
|
||||
bluetooth_ins = bluetooth_find_instance(getpid());
|
||||
|
||||
if (bluetooth_ins == NULL) {
|
||||
FEATURE_LOG_ERROR("Bluetooth instance not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
features_info = (feature_bluetooth_features_info_t*)bluetooth_ins->context;
|
||||
|
||||
if (!features_info) {
|
||||
FEATURE_LOG_ERROR("Feature context not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
features_info->created_features &= ~(1UL << feature);
|
||||
|
||||
if (features_info->created_features) {
|
||||
return;
|
||||
}
|
||||
|
||||
feature_bluetooth_callback_uninit(bluetooth_ins);
|
||||
bluetooth_delete_instance(bluetooth_ins);
|
||||
}
|
||||
|
||||
void feature_bluetooth_set_bt_ins(FeatureProtoHandle protoHandle)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = bluetooth_get_instance();
|
||||
FeatureSetProtoData(protoHandle, bluetooth_ins);
|
||||
}
|
||||
|
||||
bt_instance_t* feature_bluetooth_get_bt_ins(FeatureInstanceHandle feature)
|
||||
{
|
||||
FeatureProtoHandle protoHandle = FeatureGetProtoHandle(feature);
|
||||
return FeatureGetProtoData(protoHandle);
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file is auto-generated by jsongensource.py, Do not modify it directly!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "bt_a2dp_sink.h"
|
||||
#include "feature_bluetooth.h"
|
||||
#include "system_bluetooth_bt_a2dpsink.h"
|
||||
|
||||
#define file_tag "system_bluetooth_bt_a2dpsnk"
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_onRegister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_onCreate(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_init_bt_ins(FEATURE_BLUETOOTH_A2DPSINK, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_onRequired(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_add_feature_callback(handle, FEATURE_BLUETOOTH_A2DPSINK);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_onDetached(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_free_feature_callback(handle, FEATURE_BLUETOOTH_A2DPSINK);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_onDestroy(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_uninit_bt_ins(FEATURE_BLUETOOTH_A2DPSINK, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_onUnregister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
FtCallbackId system_bluetooth_bt_a2dpsink_get_onconnectstatechange(void* feature, AppendData append_data)
|
||||
{
|
||||
return feature_bluetooth_get_feature_callback(feature, A2DPSINK_ON_CONNECT_STATE_CHANGE);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_a2dpsink_set_onconnectstatechange(void* feature, AppendData append_data, FtCallbackId onconnectstatechange)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("set on a2dpsink set on connect state change callback: %p, callbackId: %d", feature, onconnectstatechange);
|
||||
feature_bluetooth_set_feature_callback(feature, onconnectstatechange, A2DPSINK_ON_CONNECT_STATE_CHANGE);
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* This file is auto-generated by jsongensource.py, Do not modify it directly!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2024 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "bt_avrcp_control.h"
|
||||
#include "feature_bluetooth.h"
|
||||
#include "system_bluetooth_bt_avrcpcontrol.h"
|
||||
|
||||
#define file_tag "system_bluetooth_bt_avrcpcontrol"
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_onRegister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_onCreate(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_init_bt_ins(FEATURE_BLUETOOTH_AVRCPCONTROL, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_onRequired(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_add_feature_callback(handle, FEATURE_BLUETOOTH_AVRCPCONTROL);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_onDetached(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_free_feature_callback(handle, FEATURE_BLUETOOTH_AVRCPCONTROL);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_onDestroy(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_uninit_bt_ins(FEATURE_BLUETOOTH_AVRCPCONTROL, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_onUnregister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
FtCallbackId system_bluetooth_bt_avrcpcontrol_get_onElementattribute(void* feature, union AppendData append_data)
|
||||
{
|
||||
return feature_bluetooth_get_feature_callback(feature, AVRCPCONTROL_ELEMENT_ATTRIBUTE_CALLBACK);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_set_onElementattribute(void* feature, union AppendData append_data, FtCallbackId onElementattribute)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("set on avrcpcontrol set element attribute callback: %p, callbackId: %d", feature, onElementattribute);
|
||||
feature_bluetooth_set_feature_callback(feature, onElementattribute, AVRCPCONTROL_ELEMENT_ATTRIBUTE_CALLBACK);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_avrcpcontrol_wrap_startGetElementAttribute(FeatureInstanceHandle feature, union AppendData append_data, system_bluetooth_bt_avrcpcontrol_StartGetElementAttributeParams* params)
|
||||
{
|
||||
bt_address_t addr;
|
||||
bt_status_t status;
|
||||
|
||||
if (bt_addr_str2ba(params->deviceId, &addr) < 0) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "invalid addr!", BT_STATUS_PARM_INVALID)) {
|
||||
FEATURE_LOG_ERROR("invoke get element attribute fail callback failed!");
|
||||
}
|
||||
goto COMPLETE_CALLBACK;
|
||||
}
|
||||
|
||||
status = bt_avrcp_control_get_element_attributes(feature_bluetooth_get_bt_ins(feature), &addr);
|
||||
|
||||
if (status == BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke get element attribute success failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "get element attribute failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke get element attribute fail callback failed!");
|
||||
}
|
||||
}
|
||||
COMPLETE_CALLBACK:
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
|
@ -0,0 +1,457 @@
|
|||
/*
|
||||
* This file is auto-generated by jsongensource.py, Do not modify it directly!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "bluetooth.h"
|
||||
#include "bt_a2dp_sink.h"
|
||||
#include "bt_a2dp_source.h"
|
||||
#include "bt_adapter.h"
|
||||
#include "bt_hfp_ag.h"
|
||||
#include "bt_hfp_hf.h"
|
||||
#include "bt_hid_device.h"
|
||||
#include "bt_pan.h"
|
||||
#include "feature_bluetooth.h"
|
||||
#include "system_bluetooth_bt.h"
|
||||
|
||||
#define file_tag "system_bluetooth_bt"
|
||||
|
||||
static bool bt_feature_allocator(void** data, uint32_t size)
|
||||
{
|
||||
*data = malloc(size);
|
||||
if (!(*data))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bt_status_t bluetooth_connect_profiles(FeatureInstanceHandle feature, bt_address_t* addr, feature_bluetooth_profile_t profile_id)
|
||||
{
|
||||
bt_status_t status = BT_STATUS_SUCCESS;
|
||||
bt_instance_t* bt_ins = feature_bluetooth_get_bt_ins(feature);
|
||||
if (!bt_ins) {
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
switch (profile_id) {
|
||||
case A2DP_SINK:
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
status = bt_a2dp_sink_connect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case A2DP_SOURCE:
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
status = bt_a2dp_source_connect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case HFP_AG:
|
||||
#ifdef CONFIG_BLUETOOTH_HFP_AG
|
||||
status = bt_hfp_ag_connect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case HFP_HF:
|
||||
#ifdef CONFIG_BLUETOOTH_HFP_HF
|
||||
status = bt_hfp_hf_connect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case HID_DEVICE:
|
||||
#ifdef CONFIG_BLUETOOTH_HID_DEVICE
|
||||
status = bt_hid_device_connect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case PAN_USE:
|
||||
#ifdef CONFIG_BLUETOOTH_PAN
|
||||
status = bt_pan_connect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
status = BT_STATUS_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static bt_status_t bluetooth_disconnect_profiles(FeatureInstanceHandle feature, bt_address_t* addr, feature_bluetooth_profile_t profile_id)
|
||||
{
|
||||
bt_status_t status = BT_STATUS_SUCCESS;
|
||||
bt_instance_t* bt_ins = feature_bluetooth_get_bt_ins(feature);
|
||||
if (!bt_ins) {
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
switch (profile_id) {
|
||||
case A2DP_SINK:
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
status = bt_a2dp_sink_disconnect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case A2DP_SOURCE:
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SOURCE
|
||||
status = bt_a2dp_source_disconnect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case HFP_AG:
|
||||
#ifdef CONFIG_BLUETOOTH_HFP_AG
|
||||
status = bt_hfp_ag_disconnect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case HFP_HF:
|
||||
#ifdef CONFIG_BLUETOOTH_HFP_HF
|
||||
status = bt_hfp_hf_disconnect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case HID_DEVICE:
|
||||
#ifdef CONFIG_BLUETOOTH_HID_DEVICE
|
||||
status = bt_hid_device_disconnect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
case PAN_USE:
|
||||
#ifdef CONFIG_BLUETOOTH_PAN
|
||||
status = bt_pan_disconnect(bt_ins, addr);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
status = BT_STATUS_NOT_SUPPORTED;
|
||||
break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_onRegister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_onCreate(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_init_bt_ins(FEATURE_BLUETOOTH_BT, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_onRequired(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_add_feature_callback(handle, FEATURE_BLUETOOTH_BT);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_onDetached(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_free_feature_callback(handle, FEATURE_BLUETOOTH_BT);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_onDestroy(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_uninit_bt_ins(FEATURE_BLUETOOTH_BT, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_onUnregister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_wrap_startDiscovery(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_bt_StartDiscoveryParams* params)
|
||||
{
|
||||
int timeout = 8;
|
||||
bt_status_t status = bt_adapter_start_discovery(feature_bluetooth_get_bt_ins(feature), timeout);
|
||||
if (status == BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke start discovery success failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "start discovery failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke start discovery fail callback failed!");
|
||||
}
|
||||
}
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke start discovery complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
void system_bluetooth_bt_wrap_stopDiscovery(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_bt_StopDiscoveryParams* params)
|
||||
{
|
||||
bt_status_t status = bt_adapter_cancel_discovery(feature_bluetooth_get_bt_ins(feature));
|
||||
if (status == BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke stop discovery success callback failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "stop discovery failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke stop discovery fail callback failed!");
|
||||
}
|
||||
}
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke stop discovery complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_wrap_connectProfiles(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_bt_ConnectProfilesParams* params)
|
||||
{
|
||||
int profiles_num = params->profiles->_size;
|
||||
int* profiles = (int*)(params->profiles->_element);
|
||||
bt_address_t addr;
|
||||
int status = BT_STATUS_SUCCESS;
|
||||
if (bt_addr_str2ba(params->deviceId, &addr) < 0) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "invalid addr!", BT_STATUS_PARM_INVALID)) {
|
||||
FEATURE_LOG_ERROR("invoke connect profiles fail callback failed!");
|
||||
}
|
||||
goto COMPLETE_CALLBACK;
|
||||
}
|
||||
|
||||
for (int i = 0; i < profiles_num; ++i) {
|
||||
status |= bluetooth_connect_profiles(feature, &addr, (feature_bluetooth_profile_t)(profiles[i]));
|
||||
}
|
||||
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "connect all passing profiles failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke connect profiles fail callback failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke connect profiles success callback failed!");
|
||||
}
|
||||
}
|
||||
COMPLETE_CALLBACK:
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke connect profiles complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_wrap_disconnectProfiles(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_bt_DisconnectProfilesParams* params)
|
||||
{
|
||||
int profiles_num = params->profiles->_size;
|
||||
int* profiles = (int*)params->profiles->_element;
|
||||
bt_address_t addr;
|
||||
int status = BT_STATUS_SUCCESS;
|
||||
if (bt_addr_str2ba(params->deviceId, &addr) < 0) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "invalid addr!", BT_STATUS_PARM_INVALID)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect profiles fail callback failed!");
|
||||
}
|
||||
goto COMPLETE_CALLBACK;
|
||||
}
|
||||
for (int i = 0; i < profiles_num; ++i) {
|
||||
status |= bluetooth_disconnect_profiles(feature, &addr, (feature_bluetooth_profile_t)profiles[i]);
|
||||
}
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "disconnect all passing profiles failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect profiles fail callback failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect profiles success callback failed!");
|
||||
}
|
||||
}
|
||||
COMPLETE_CALLBACK:
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect profiles complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_wrap_disconnect(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_bt_DisconnectParams* params)
|
||||
{
|
||||
bt_address_t addr;
|
||||
bt_status_t status = BT_STATUS_SUCCESS;
|
||||
if (bt_addr_str2ba(params->deviceId, &addr) < 0) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "invalid addr!", BT_STATUS_PARM_INVALID)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect fail callback failed!");
|
||||
}
|
||||
goto COMPLETE_CALLBACK;
|
||||
}
|
||||
|
||||
status = bt_device_disconnect(feature_bluetooth_get_bt_ins(feature), &addr);
|
||||
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "disconnect failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect fail callback failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect success callback failed!");
|
||||
}
|
||||
}
|
||||
COMPLETE_CALLBACK:
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke disconnect complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
FtBool system_bluetooth_bt_wrap_getConnectState(FeatureInstanceHandle feature, AppendData append_data, FtString deviceId)
|
||||
{
|
||||
FtBool connected = false;
|
||||
bt_address_t addr;
|
||||
if (bt_addr_str2ba(deviceId, &addr) < 0) {
|
||||
return false;
|
||||
}
|
||||
#ifdef CONFIG_BLUETOOTH_A2DP_SINK
|
||||
connected |= bt_a2dp_sink_get_connection_state(feature_bluetooth_get_bt_ins(feature), &addr);
|
||||
#endif
|
||||
return connected;
|
||||
}
|
||||
|
||||
FtArray* system_bluetooth_bt_wrap_getConnectedDevices(FeatureInstanceHandle feature, AppendData append_data)
|
||||
{
|
||||
bt_address_t* addrs = NULL;
|
||||
int num = 0;
|
||||
bt_adapter_get_connected_devices(feature_bluetooth_get_bt_ins(feature), BT_TRANSPORT_BREDR, &addrs, &num, bt_feature_allocator);
|
||||
FtArray* devices = system_bluetooth_bt_malloc_string_array();
|
||||
devices->_size = num;
|
||||
devices->_element = malloc(devices->_size * sizeof(char*));
|
||||
for (int i = 0; i < devices->_size; ++i) {
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
bt_addr_ba2str(addrs + i, addr_str);
|
||||
((char**)devices->_element)[i] = StringToFtString(addr_str);
|
||||
}
|
||||
free(addrs);
|
||||
return devices;
|
||||
}
|
||||
|
||||
FtArray* system_bluetooth_bt_wrap_getBondedDevices(FeatureInstanceHandle feature, AppendData append_data)
|
||||
{
|
||||
bt_address_t* addrs = NULL;
|
||||
int num = 0;
|
||||
bt_adapter_get_bonded_devices(feature_bluetooth_get_bt_ins(feature), BT_TRANSPORT_BREDR, &addrs, &num, bt_feature_allocator);
|
||||
FtArray* devices = system_bluetooth_bt_malloc_string_array();
|
||||
devices->_size = num;
|
||||
devices->_element = malloc(devices->_size * sizeof(char*));
|
||||
for (int i = 0; i < devices->_size; ++i) {
|
||||
char addr_str[BT_ADDR_STR_LENGTH] = { 0 };
|
||||
bt_addr_ba2str(addrs + i, addr_str);
|
||||
((char**)devices->_element)[i] = StringToFtString(addr_str);
|
||||
}
|
||||
free(addrs);
|
||||
return devices;
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_wrap_removeBondedDevice(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_bt_RemoveBondedParams* params)
|
||||
{
|
||||
bt_address_t addr;
|
||||
bt_status_t status;
|
||||
if (bt_addr_str2ba(params->deviceId, &addr) < 0) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "invalid addr!", BT_STATUS_PARM_INVALID)) {
|
||||
FEATURE_LOG_ERROR("invoke remove bonded fail callback failed!");
|
||||
}
|
||||
goto COMPLETE_CALLBACK;
|
||||
}
|
||||
|
||||
if (!bt_device_is_bonded(feature_bluetooth_get_bt_ins(feature), &addr, BT_TRANSPORT_BREDR)) {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke remove bonded success callback failed!");
|
||||
}
|
||||
goto COMPLETE_CALLBACK;
|
||||
}
|
||||
|
||||
status = bt_device_remove_bond(feature_bluetooth_get_bt_ins(feature), &addr, BT_TRANSPORT_BREDR);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "remove bonded failed!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke remove bonded fail callback failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke remove bonded success callback failed!");
|
||||
}
|
||||
}
|
||||
COMPLETE_CALLBACK:
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke remove bonded complete callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
FtBool system_bluetooth_bt_wrap_setScanMode(FeatureInstanceHandle feature, AppendData append_data, FtInt scanMode)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("set scanmode: %d!", scanMode);
|
||||
if (scanMode < 0 || scanMode > 2) {
|
||||
return false;
|
||||
}
|
||||
if (bt_adapter_set_scan_mode(feature_bluetooth_get_bt_ins(feature), (bt_scan_mode_t)scanMode, 1) == BT_STATUS_SUCCESS) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FtInt system_bluetooth_bt_wrap_getScanMode(FeatureInstanceHandle feature, AppendData append_data)
|
||||
{
|
||||
return bt_adapter_get_scan_mode(feature_bluetooth_get_bt_ins(feature));
|
||||
}
|
||||
|
||||
FtString system_bluetooth_bt_wrap_getDeviceName(FeatureInstanceHandle feature, AppendData append_data, FtString deviceId)
|
||||
{
|
||||
bt_address_t addr;
|
||||
char name[64] = { 0 };
|
||||
if (bt_addr_str2ba(deviceId, &addr) < 0) {
|
||||
return StringToFtString("");
|
||||
}
|
||||
bt_device_get_name(feature_bluetooth_get_bt_ins(feature), &addr, name, 64);
|
||||
return StringToFtString(name);
|
||||
}
|
||||
|
||||
FtUint32 system_bluetooth_bt_wrap_getDeviceClass(FeatureInstanceHandle feature, AppendData append_data, FtString deviceId)
|
||||
{
|
||||
bt_address_t addr;
|
||||
if (bt_addr_str2ba(deviceId, &addr) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return bt_device_get_device_class(feature_bluetooth_get_bt_ins(feature), &addr);
|
||||
}
|
||||
|
||||
FtCallbackId system_bluetooth_bt_get_ondiscoveryresult(void* feature, AppendData append_data)
|
||||
{
|
||||
return feature_bluetooth_get_feature_callback(feature, ON_DISCOVERY_RESULT);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_set_ondiscoveryresult(void* feature, AppendData append_data, FtCallbackId ondiscoveryresult)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("set ondiscoveryresult feature: %p, callbackId: %d", feature, ondiscoveryresult);
|
||||
feature_bluetooth_set_feature_callback(feature, ondiscoveryresult, ON_DISCOVERY_RESULT);
|
||||
}
|
||||
|
||||
FtCallbackId system_bluetooth_bt_get_onbondstatechange(void* feature, AppendData append_data)
|
||||
{
|
||||
return feature_bluetooth_get_feature_callback(feature, ON_BOND_STATE_CHANGE);
|
||||
}
|
||||
|
||||
void system_bluetooth_bt_set_onbondstatechange(void* feature, AppendData append_data, FtCallbackId onbondstatechange)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("set onbondstatechange feature: %p, callbackId: %d", feature, onbondstatechange);
|
||||
feature_bluetooth_set_feature_callback(feature, onbondstatechange, ON_BOND_STATE_CHANGE);
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* This file is auto-generated by jsongensource.py, Do not modify it directly!
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Xiaomi Corporation. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "bluetooth.h"
|
||||
#include "bt_adapter.h"
|
||||
#include "feature_bluetooth.h"
|
||||
#include "feature_exports.h"
|
||||
#include "feature_log.h"
|
||||
#include "system_bluetooth.h"
|
||||
#include "system_bluetooth_bt.h"
|
||||
|
||||
#define file_tag "system_bluetooth"
|
||||
|
||||
void system_bluetooth_onRegister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onCreate(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_init_bt_ins(FEATURE_BLUETOOTH, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onRequired(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_add_feature_callback(handle, FEATURE_BLUETOOTH);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onDetached(FeatureRuntimeContext ctx, FeatureInstanceHandle handle)
|
||||
{
|
||||
feature_bluetooth_free_feature_callback(handle, FEATURE_BLUETOOTH);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onDestroy(FeatureRuntimeContext ctx, FeatureProtoHandle handle)
|
||||
{
|
||||
feature_bluetooth_uninit_bt_ins(FEATURE_BLUETOOTH, handle);
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_onUnregister(const char* feature_name)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("%s::%s()", file_tag, __FUNCTION__);
|
||||
}
|
||||
|
||||
void system_bluetooth_wrap_openAdapter(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_OpenAdapterParams* params)
|
||||
{
|
||||
bt_status_t status = bt_adapter_enable(feature_bluetooth_get_bt_ins(feature));
|
||||
if (status == BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke success openAdapter callback failed, feature is %p, params->success is %d!", feature, params->success);
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "enable fail!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke fail openAdapter callback failed!");
|
||||
}
|
||||
}
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke complete openAdapter callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
void system_bluetooth_wrap_closeAdapter(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_CloseAdapterParams* params)
|
||||
{
|
||||
bt_status_t status = bt_adapter_disable(feature_bluetooth_get_bt_ins(feature));
|
||||
if (status == BT_STATUS_SUCCESS) {
|
||||
if (!FeatureInvokeCallback(feature, params->success)) {
|
||||
FEATURE_LOG_ERROR("invoke success closeAdapter callback failed!");
|
||||
}
|
||||
} else {
|
||||
if (!FeatureInvokeCallback(feature, params->fail, "enable fail!", status)) {
|
||||
FEATURE_LOG_ERROR("invoke fail closeAdapter callback failed!");
|
||||
}
|
||||
}
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke complete closeAdapter callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
void system_bluetooth_wrap_getAdapterState(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_GetAdapterStateParams* params)
|
||||
{
|
||||
bt_instance_t* ins = feature_bluetooth_get_bt_ins(feature);
|
||||
bt_adapter_state_t state = bt_adapter_get_state(ins);
|
||||
bool is_discovering = bt_adapter_is_discovering(ins);
|
||||
system_bluetooth_GetAdapterSuccessResult* success_result = system_bluetoothMallocGetAdapterSuccessResult();
|
||||
success_result->available = state == BT_ADAPTER_STATE_ON;
|
||||
success_result->discovering = is_discovering;
|
||||
|
||||
if (!FeatureInvokeCallback(feature, params->success, success_result)) {
|
||||
FEATURE_LOG_ERROR("invoke success getAdapterState callback failed!");
|
||||
}
|
||||
|
||||
FeatureFreeValue(success_result);
|
||||
|
||||
if (!FeatureInvokeCallback(feature, params->complete)) {
|
||||
FEATURE_LOG_ERROR("invoke complete getAdapterState callback failed!");
|
||||
}
|
||||
|
||||
FeatureRemoveCallback(feature, params->success);
|
||||
FeatureRemoveCallback(feature, params->fail);
|
||||
FeatureRemoveCallback(feature, params->complete);
|
||||
}
|
||||
|
||||
FtCallbackId system_bluetooth_get_onadapterstatechange(void* feature, AppendData append_data)
|
||||
{
|
||||
return feature_bluetooth_get_feature_callback(feature, ON_ADAPTER_STATE_CHANGE);
|
||||
}
|
||||
|
||||
void system_bluetooth_set_onadapterstatechange(void* feature, AppendData append_data, FtCallbackId onadapterstatechange)
|
||||
{
|
||||
FEATURE_LOG_DEBUG("set onadapterstatechange feature: %p, callbackId: %d", feature, onadapterstatechange);
|
||||
feature_bluetooth_set_feature_callback(feature, onadapterstatechange, ON_ADAPTER_STATE_CHANGE);
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_LOCAL
|
||||
#include "btservice.h"
|
||||
#include "manager_service.h"
|
||||
#include "service_loop.h"
|
||||
#endif
|
||||
#include "bluetooth.h"
|
||||
#include "bt_internal.h"
|
||||
#include "manager_service.h"
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
bt_instance_t* BTSYMBOLS(bluetooth_create_instance)(void)
|
||||
{
|
||||
uint32_t app_id;
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_LOCAL
|
||||
service_loop_init();
|
||||
bt_service_init();
|
||||
service_loop_run(true, "bt_service");
|
||||
#endif
|
||||
bt_instance_t* ins = zalloc(sizeof(bt_instance_t));
|
||||
if (!ins) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bt_status_t status = manager_create_instance(PTR2INT(uint64_t) ins, BLUETOOTH_SYSTEM, "local", getpid(), 0, &app_id);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
free(ins);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ins->app_id = app_id;
|
||||
|
||||
return ins;
|
||||
}
|
||||
|
||||
bt_instance_t* BTSYMBOLS(bluetooth_get_instance)(void)
|
||||
{
|
||||
bt_status_t status;
|
||||
uint64_t handle;
|
||||
|
||||
status = manager_get_instance("local", getpid(), &handle);
|
||||
if (status == BT_STATUS_SUCCESS && handle)
|
||||
return INT2PTR(bt_instance_t*) handle;
|
||||
else
|
||||
return BTSYMBOLS(bluetooth_create_instance)();
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bluetooth_get_proxy)(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
switch (id) {
|
||||
case PROFILE_HFP_HF:
|
||||
/* for binder ipc*/
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_BINDER_IPC
|
||||
if (!ins->hfp_hf_proxy) {
|
||||
ins->hfp_hf_proxy = NULL;
|
||||
}
|
||||
return ins->hfp_hf_proxy;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bluetooth_delete_instance)(bt_instance_t* ins)
|
||||
{
|
||||
manager_delete_instance(ins->app_id);
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_LOCAL
|
||||
bt_service_cleanup();
|
||||
service_loop_exit();
|
||||
#endif
|
||||
free(ins);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bluetooth_start_service)(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
return manager_start_service(ins->app_id, id);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bluetooth_stop_service)(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
return manager_stop_service(ins->app_id, id);
|
||||
}
|
||||
|
||||
#include "uv.h"
|
||||
bool BTSYMBOLS(bluetooth_set_external_uv)(bt_instance_t* ins, uv_loop_t* ext_loop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "a2dp_sink_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "a2dp_sink_service.h"
|
||||
#include "bt_a2dp_sink.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static a2dp_sink_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (a2dp_sink_interface_t*)service_manager_get_profile(PROFILE_A2DP_SINK);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_a2dp_sink_register_callbacks)(bt_instance_t* ins, const a2dp_sink_callbacks_t* callbacks)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_a2dp_sink_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_a2dp_sink_is_connected)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_connected(addr);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_a2dp_sink_is_playing)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_playing(addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t BTSYMBOLS(bt_a2dp_sink_get_connection_state)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_connection_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_sink_connect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_sink_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_sink_set_active_device)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_sink_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_active_device(addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "a2dp_source_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "a2dp_source_service.h"
|
||||
#include "bt_a2dp_source.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static a2dp_source_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (a2dp_source_interface_t*)service_manager_get_profile(PROFILE_A2DP);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_a2dp_source_register_callbacks)(bt_instance_t* ins, const a2dp_source_callbacks_t* callbacks)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_a2dp_source_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_a2dp_source_is_connected)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_connected(addr);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_a2dp_source_is_playing)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_playing(addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t BTSYMBOLS(bt_a2dp_source_get_connection_state)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_connection_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_connect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_set_silence_device)(bt_instance_t* ins, bt_address_t* addr, bool silence)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_silence_device(addr, silence);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_set_active_device)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
a2dp_source_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_active_device(addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "adapter_internel.h"
|
||||
#include "bt_adapter.h"
|
||||
#include "bt_internal.h"
|
||||
|
||||
void* BTSYMBOLS(bt_adapter_register_callback)(bt_instance_t* ins, const adapter_callbacks_t* adapter_cbs)
|
||||
{
|
||||
return adapter_register_callback(NULL, adapter_cbs);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_adapter_unregister_callback)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
return adapter_unregister_callback(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_enable)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_enable(SYS_SET_BT_ALL);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_disable)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_disable(SYS_SET_BT_ALL);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_disable_safe)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_disable_safe(SYS_SET_BT_ALL);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_enable_le)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_enable(APP_SET_LE_ONLY);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_disable_le)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_disable(APP_SET_LE_ONLY);
|
||||
}
|
||||
|
||||
bt_adapter_state_t BTSYMBOLS(bt_adapter_get_state)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_state();
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_adapter_is_le_enabled)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_is_le_enabled();
|
||||
}
|
||||
|
||||
bt_device_type_t BTSYMBOLS(bt_adapter_get_type)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_type();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_discovery_filter)(bt_instance_t* ins)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_start_limited_discovery)(bt_instance_t* ins, uint32_t timeout)
|
||||
{
|
||||
return adapter_start_discovery(timeout, true);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_debug_mode)(bt_instance_t* ins, bt_debug_mode_t mode, uint8_t operation)
|
||||
{
|
||||
return adapter_set_debug_mode(mode, operation);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_start_discovery)(bt_instance_t* ins, uint32_t timeout)
|
||||
{
|
||||
return adapter_start_discovery(timeout, false);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_cancel_discovery)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_cancel_discovery();
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_adapter_is_discovering)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_is_discovering();
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_adapter_get_address)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_get_address(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_name)(bt_instance_t* ins, const char* name)
|
||||
{
|
||||
return adapter_set_name(name);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_adapter_get_name)(bt_instance_t* ins, char* name, int length)
|
||||
{
|
||||
return adapter_get_name(name, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_get_uuids)(bt_instance_t* ins, bt_uuid_t* uuids, uint16_t* size)
|
||||
{
|
||||
return adapter_get_uuids(uuids, size);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_scan_mode)(bt_instance_t* ins, bt_scan_mode_t mode, bool bondable)
|
||||
{
|
||||
return adapter_set_scan_mode(mode, bondable);
|
||||
}
|
||||
|
||||
bt_scan_mode_t BTSYMBOLS(bt_adapter_get_scan_mode)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_scan_mode();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_device_class)(bt_instance_t* ins, uint32_t cod)
|
||||
{
|
||||
return adapter_set_device_class(cod);
|
||||
}
|
||||
|
||||
uint32_t BTSYMBOLS(bt_adapter_get_device_class)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_device_class();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_io_capability)(bt_instance_t* ins, bt_io_capability_t cap)
|
||||
{
|
||||
return adapter_set_io_capability(cap);
|
||||
}
|
||||
|
||||
bt_io_capability_t BTSYMBOLS(bt_adapter_get_io_capability)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_io_capability();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_inquiry_scan_parameters)(bt_instance_t* ins, bt_scan_type_t type,
|
||||
uint16_t interval, uint16_t window)
|
||||
{
|
||||
return adapter_set_inquiry_scan_parameters(type, interval, window);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_page_scan_parameters)(bt_instance_t* ins, bt_scan_type_t type,
|
||||
uint16_t interval, uint16_t window)
|
||||
{
|
||||
return adapter_set_page_scan_parameters(type, interval, window);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_le_io_capability)(bt_instance_t* ins, uint32_t le_io_cap)
|
||||
{
|
||||
return adapter_set_le_io_capability(le_io_cap);
|
||||
}
|
||||
|
||||
uint32_t BTSYMBOLS(bt_adapter_get_le_io_capability)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_le_io_capability();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_get_le_address)(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t* type)
|
||||
{
|
||||
return adapter_get_le_address(addr, type);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_le_address)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_set_le_address(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_le_identity_address)(bt_instance_t* ins, bt_address_t* addr, bool is_public)
|
||||
{
|
||||
return adapter_set_le_identity_address(addr, is_public);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_le_appearance)(bt_instance_t* ins, uint16_t appearance)
|
||||
{
|
||||
return adapter_set_le_appearance(appearance);
|
||||
}
|
||||
|
||||
uint16_t BTSYMBOLS(bt_adapter_get_le_appearance)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_get_le_appearance();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_enable_key_derivation)(bt_instance_t* ins,
|
||||
bool brkey_to_lekey,
|
||||
bool lekey_to_brkey)
|
||||
{
|
||||
return adapter_le_enable_key_derivation(brkey_to_lekey, lekey_to_brkey);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_add_whitelist)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_le_add_whitelist(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_remove_whitelist)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_le_remove_whitelist(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_get_bonded_devices)(bt_instance_t* ins, bt_transport_t transport, bt_address_t** addr, int* num, bt_allocator_t allocator)
|
||||
{
|
||||
return adapter_get_bonded_devices(transport, addr, num, allocator);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_get_connected_devices)(bt_instance_t* ins, bt_transport_t transport, bt_address_t** addr, int* num, bt_allocator_t allocator)
|
||||
{
|
||||
return adapter_get_connected_devices(transport, addr, num, allocator);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_afh_channel_classification)(bt_instance_t* ins, uint16_t central_frequency,
|
||||
uint16_t band_width, uint16_t number)
|
||||
{
|
||||
return adapter_set_afh_channel_classification(central_frequency, band_width, number);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_adapter_disconnect_all_devices)(bt_instance_t* ins)
|
||||
{
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_adapter_is_support_bredr)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_is_support_bredr();
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_adapter_is_support_le)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_is_support_le();
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_adapter_is_support_leaudio)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_is_support_leaudio();
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "avrcp_control_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avrcp_control_service.h"
|
||||
#include "bt_avrcp_control.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static avrcp_control_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (avrcp_control_interface_t*)service_manager_get_profile(PROFILE_AVRCP_CT);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_avrcp_control_register_callbacks)(bt_instance_t* ins, const avrcp_control_callbacks_t* callbacks)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_avrcp_control_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_element_attributes)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_get_element_attributes(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_send_passthrough_cmd)(bt_instance_t* ins, bt_address_t* addr, uint8_t cmd, uint8_t state)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_send_passthrough_cmd(addr, cmd, state);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_unit_info)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_get_unit_info(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_subunit_info)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_get_subunit_info(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_playback_state)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_get_playback_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_register_notification)(bt_instance_t* ins, bt_address_t* addr, uint8_t event, uint32_t interval)
|
||||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_register_notification(addr, event, interval);
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "avrcp_target_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avrcp_target_service.h"
|
||||
#include "bt_avrcp_target.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static avrcp_target_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (avrcp_target_interface_t*)service_manager_get_profile(PROFILE_AVRCP_TG);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_avrcp_target_register_callbacks)(bt_instance_t* ins, const avrcp_target_callbacks_t* callbacks)
|
||||
{
|
||||
avrcp_target_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_avrcp_target_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
avrcp_target_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_target_get_play_status_response)(bt_instance_t* ins, bt_address_t* addr, avrcp_play_status_t play_status,
|
||||
uint32_t song_len, uint32_t song_pos)
|
||||
{
|
||||
avrcp_target_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_play_status_rsp(addr, play_status, song_len, song_pos);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_target_play_status_notify)(bt_instance_t* ins, bt_address_t* addr, avrcp_play_status_t play_status)
|
||||
{
|
||||
avrcp_target_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->play_status_notify(addr, play_status);
|
||||
}
|
||||
|
|
@ -0,0 +1,240 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "adapter_internel.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
#include "bt_internal.h"
|
||||
#include "connection_manager.h"
|
||||
#include "device.h"
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_get_identity_address)(bt_instance_t* ins, bt_address_t* bd_addr, bt_address_t* id_addr)
|
||||
{
|
||||
return adapter_get_remote_identity_address(bd_addr, id_addr);
|
||||
}
|
||||
|
||||
ble_addr_type_t BTSYMBOLS(bt_device_get_address_type)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bt_device_type_t BTSYMBOLS(bt_device_get_device_type)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_get_remote_device_type(addr);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_device_get_name)(bt_instance_t* ins, bt_address_t* addr, char* name, uint32_t length)
|
||||
{
|
||||
return adapter_get_remote_name(addr, name);
|
||||
}
|
||||
|
||||
uint32_t BTSYMBOLS(bt_device_get_device_class)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_get_remote_device_class(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_get_uuids)(bt_instance_t* ins, bt_address_t* addr, bt_uuid_t** uuids, uint16_t* size, bt_allocator_t allocator)
|
||||
{
|
||||
return adapter_get_remote_uuids(addr, uuids, size, allocator);
|
||||
}
|
||||
|
||||
uint16_t BTSYMBOLS(bt_device_get_appearance)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_get_remote_appearance(addr);
|
||||
}
|
||||
|
||||
int8_t BTSYMBOLS(bt_device_get_rssi)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_get_remote_rssi(addr);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_device_get_alias)(bt_instance_t* ins, bt_address_t* addr, char* alias, uint32_t length)
|
||||
{
|
||||
return adapter_get_remote_alias(addr, alias);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_alias)(bt_instance_t* ins, bt_address_t* addr, const char* alias)
|
||||
{
|
||||
return adapter_set_remote_alias(addr, alias);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_device_is_connected)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return adapter_is_remote_connected(addr, transport);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_device_is_encrypted)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return adapter_is_remote_encrypted(addr, transport);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_device_is_bond_initiate_local)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return adapter_is_bond_initiate_local(addr, transport);
|
||||
}
|
||||
|
||||
bond_state_t BTSYMBOLS(bt_device_get_bond_state)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return adapter_get_remote_bond_state(addr, transport);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_device_is_bonded)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return adapter_is_remote_bonded(addr, transport);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_connect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_background_connect)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
#ifdef CONFIG_BLUETOOTH_CONNECTION_MANAGER
|
||||
return bt_cm_device_connect(addr, transport);
|
||||
#else
|
||||
return BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_background_disconnect)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
#ifdef CONFIG_BLUETOOTH_CONNECTION_MANAGER
|
||||
return bt_cm_device_disconnect(addr, transport);
|
||||
#else
|
||||
return BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_connect_le)(bt_instance_t* ins,
|
||||
bt_address_t* addr,
|
||||
ble_addr_type_t type,
|
||||
ble_connect_params_t* param)
|
||||
{
|
||||
return adapter_le_connect(addr, type, param);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_disconnect_le)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_le_disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_connect_request_reply)(bt_instance_t* ins, bt_address_t* addr, bool accept)
|
||||
{
|
||||
return adapter_connect_request_reply(addr, accept);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_device_connect_all_profile)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_device_disconnect_all_profile)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_le_phy)(bt_instance_t* ins, bt_address_t* addr,
|
||||
ble_phy_type_t tx_phy,
|
||||
ble_phy_type_t rx_phy)
|
||||
{
|
||||
return adapter_le_set_phy(addr, tx_phy, rx_phy);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_create_bond)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return adapter_create_bond(addr, transport);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_security_level)(bt_instance_t* ins, uint8_t level, bt_transport_t transport)
|
||||
{
|
||||
return adapter_set_security_level(level, transport);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_bondable_le)(bt_instance_t* ins, bool bondable)
|
||||
{
|
||||
return adapter_le_set_bondable(bondable);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_remove_bond)(bt_instance_t* ins, bt_address_t* addr, uint8_t transport)
|
||||
{
|
||||
return adapter_remove_bond(addr, transport);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_cancel_bond)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_cancel_bond(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_pair_request_reply)(bt_instance_t* ins, bt_address_t* addr, bool accept)
|
||||
{
|
||||
return adapter_pair_request_reply(addr, accept);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_pairing_confirmation)(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bool accept)
|
||||
{
|
||||
return adapter_set_pairing_confirmation(addr, transport, accept);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_pin_code)(bt_instance_t* ins, bt_address_t* addr, bool accept,
|
||||
char* pincode, int len)
|
||||
{
|
||||
return adapter_set_pin_code(addr, accept, pincode, len);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_pass_key)(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bool accept, uint32_t passkey)
|
||||
{
|
||||
return adapter_set_pass_key(addr, transport, accept, passkey);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_le_legacy_tk)(bt_instance_t* ins, bt_address_t* addr, bt_128key_t tk_val)
|
||||
{
|
||||
return adapter_le_set_legacy_tk(addr, tk_val);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_le_sc_remote_oob_data)(bt_instance_t* ins, bt_address_t* addr, bt_128key_t c_val, bt_128key_t r_val)
|
||||
{
|
||||
return adapter_le_set_remote_oob_data(addr, c_val, r_val);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_get_le_sc_local_oob_data)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_le_get_local_oob_data(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_enable_enhanced_mode)(bt_instance_t* ins, bt_address_t* addr, bt_enhanced_mode_t mode)
|
||||
{
|
||||
#ifdef CONFIG_BLUETOOTH_CONNECTION_MANAGER
|
||||
return bt_cm_enable_enhanced_mode(addr, mode);
|
||||
#else
|
||||
return BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_disable_enhanced_mode)(bt_instance_t* ins, bt_address_t* addr, bt_enhanced_mode_t mode)
|
||||
{
|
||||
#ifdef CONFIG_BLUETOOTH_CONNECTION_MANAGER
|
||||
return bt_cm_disable_enhanced_mode(addr, mode);
|
||||
#else
|
||||
return BT_STATUS_UNSUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "gattc"
|
||||
|
||||
#include "bt_gattc.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "gattc_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static gattc_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (gattc_interface_t*)service_manager_get_profile(PROFILE_GATTC);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_create_connect)(bt_instance_t* ins, gattc_handle_t* phandle, gattc_callbacks_t* callbacks)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->create_connect(NULL, phandle, callbacks);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_delete_connect)(gattc_handle_t conn_handle)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->delete_connect(conn_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_connect)(gattc_handle_t conn_handle, bt_address_t* addr, ble_addr_type_t addr_type)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(conn_handle, addr, addr_type);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_disconnect)(gattc_handle_t conn_handle)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(conn_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_discover_service)(gattc_handle_t conn_handle, bt_uuid_t* filter_uuid)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->discover_service(conn_handle, filter_uuid);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_get_attribute_by_handle)(gattc_handle_t conn_handle, uint16_t attr_handle, gatt_attr_desc_t* attr_desc)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_attribute_by_handle(conn_handle, attr_handle, attr_desc);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_get_attribute_by_uuid)(gattc_handle_t conn_handle, uint16_t start_handle, uint16_t end_handle, bt_uuid_t* attr_uuid, gatt_attr_desc_t* attr_desc)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_attribute_by_uuid(conn_handle, start_handle, end_handle, attr_uuid, attr_desc);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_read)(gattc_handle_t conn_handle, uint16_t attr_handle)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read(conn_handle, attr_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_write)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->write(conn_handle, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_write_without_response)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->write_without_response(conn_handle, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_write_with_signed)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->write_signed(conn_handle, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_subscribe)(gattc_handle_t conn_handle, uint16_t attr_handle, uint16_t ccc_value)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->subscribe(conn_handle, attr_handle, ccc_value);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_unsubscribe)(gattc_handle_t conn_handle, uint16_t attr_handle)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unsubscribe(conn_handle, attr_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_exchange_mtu)(gattc_handle_t conn_handle, uint32_t mtu)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->exchange_mtu(conn_handle, mtu);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_update_connection_parameter)(gattc_handle_t conn_handle, uint32_t min_interval, uint32_t max_interval, uint32_t latency,
|
||||
uint32_t timeout, uint32_t min_connection_event_length, uint32_t max_connection_event_length)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->update_connection_parameter(conn_handle, min_interval, max_interval, latency,
|
||||
timeout, min_connection_event_length, max_connection_event_length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_read_phy)(gattc_handle_t conn_handle)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_phy(conn_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_update_phy)(gattc_handle_t conn_handle, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->update_phy(conn_handle, tx_phy, rx_phy);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gattc_read_rssi)(gattc_handle_t conn_handle)
|
||||
{
|
||||
gattc_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_rssi(conn_handle);
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "gatts"
|
||||
|
||||
#include "bt_gatts.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "gatts_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static gatts_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (gatts_interface_t*)service_manager_get_profile(PROFILE_GATTS);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_register_service)(bt_instance_t* ins, gatts_handle_t* phandle, gatts_callbacks_t* callbacks)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_service(NULL, phandle, callbacks);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_unregister_service)(gatts_handle_t srv_handle)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_service(srv_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_connect)(gatts_handle_t srv_handle, bt_address_t* addr, ble_addr_type_t addr_type)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(srv_handle, addr, addr_type);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_connect_bear)(gatts_handle_t srv_handle, bt_address_t* addr, ble_addr_type_t addr_type, uint8_t bear_type)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect_bear(srv_handle, addr, addr_type, bear_type);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_disconnect)(gatts_handle_t srv_handle, bt_address_t* addr)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(srv_handle, addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_add_attr_table)(gatts_handle_t srv_handle, gatt_srv_db_t* srv_db)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->add_attr_table(srv_handle, srv_db);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_remove_attr_table)(gatts_handle_t srv_handle, uint16_t attr_handle)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->remove_attr_table(srv_handle, attr_handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_set_attr_value)(gatts_handle_t srv_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_attr_value(srv_handle, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_get_attr_value)(gatts_handle_t srv_handle, uint16_t attr_handle, uint8_t* value, uint16_t* length)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_attr_value(srv_handle, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_response)(gatts_handle_t srv_handle, bt_address_t* addr, uint32_t req_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->response(srv_handle, addr, req_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_notify)(gatts_handle_t srv_handle, bt_address_t* addr, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->notify(srv_handle, addr, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_indicate)(gatts_handle_t srv_handle, bt_address_t* addr, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->indicate(srv_handle, addr, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_read_phy)(gatts_handle_t srv_handle, bt_address_t* addr)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_phy(srv_handle, addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_gatts_update_phy)(gatts_handle_t srv_handle, bt_address_t* addr, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy)
|
||||
{
|
||||
gatts_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->update_phy(srv_handle, addr, tx_phy, rx_phy);
|
||||
}
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "hfp_ag_api"
|
||||
|
||||
#include "bt_hfp_ag.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "hfp_ag_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static hfp_ag_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (hfp_ag_interface_t*)service_manager_get_profile(PROFILE_HFP_AG);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_hfp_ag_register_callbacks)(bt_instance_t* ins, const hfp_ag_callbacks_t* callbacks)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hfp_ag_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hfp_ag_is_connected)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_connected(addr);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hfp_ag_is_audio_connected)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_audio_connected(addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t BTSYMBOLS(bt_hfp_ag_get_connection_state)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_connection_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_connect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_connect_audio)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect_audio(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_disconnect_audio)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect_audio(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_start_virtual_call)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->start_virtual_call(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_stop_virtual_call)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->stop_virtual_call(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_start_voice_recognition)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->start_voice_recognition(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_stop_voice_recognition)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->stop_voice_recognition(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_phone_state_change)(bt_instance_t* ins, bt_address_t* addr,
|
||||
uint8_t num_active, uint8_t num_held,
|
||||
hfp_ag_call_state_t call_state, hfp_call_addrtype_t type,
|
||||
const char* number, const char* name)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->phone_state_change(addr, num_active, num_held, call_state, type, number, name);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_notify_device_status)(bt_instance_t* ins, bt_address_t* addr,
|
||||
hfp_network_state_t network, hfp_roaming_state_t roam,
|
||||
uint8_t signal, uint8_t battery)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->device_status_changed(addr, network, roam, signal, battery);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_volume_control)(bt_instance_t* ins, bt_address_t* addr, hfp_volume_type_t type, uint8_t volume)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->volume_control(addr, type, volume);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_send_at_command)(bt_instance_t* ins, bt_address_t* addr, const char* at_command)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->send_at_command(addr, at_command);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_send_vendor_specific_at_command)(bt_instance_t* ins, bt_address_t* addr, const char* command, const char* value)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->send_vendor_specific_at_command(addr, command, value);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_send_clcc_response)(bt_instance_t* ins, bt_address_t* addr,
|
||||
uint32_t index, hfp_call_direction_t dir, hfp_ag_call_state_t call, hfp_call_mode_t mode,
|
||||
hfp_call_mpty_type_t mpty, hfp_call_addrtype_t type, const char* number)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->send_clcc_response(addr, index, dir, call, mode, mpty, type, number);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_send_cind_response)(bt_instance_t* ins, bt_address_t* addr,
|
||||
hfp_network_state_t network, hfp_call_t call, hfp_callheld_t call_held, hfp_callsetup_t call_setup,
|
||||
uint8_t signal, hfp_roaming_state_t roam, uint8_t battery)
|
||||
{
|
||||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->send_cind_response(addr, network, call, call_held, call_setup, signal, roam, battery);
|
||||
}
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "hfp_hf_api"
|
||||
|
||||
#include "bt_hfp_hf.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "hfp_hf_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static hfp_hf_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (hfp_hf_interface_t*)service_manager_get_profile(PROFILE_HFP_HF);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_hfp_hf_register_callbacks)(bt_instance_t* ins, const hfp_hf_callbacks_t* callbacks)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, (hfp_hf_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hfp_hf_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hfp_hf_is_connected)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_connected(addr);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hfp_hf_is_audio_connected)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->is_audio_connected(addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t BTSYMBOLS(bt_hfp_hf_get_connection_state)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_connection_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_connect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_set_connection_policy)(bt_instance_t* ins, bt_address_t* addr, connection_policy_t policy)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_connection_policy(addr, policy);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_connect_audio)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect_audio(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_disconnect_audio)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect_audio(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_start_voice_recognition)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->start_voice_recognition(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_stop_voice_recognition)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->stop_voice_recognition(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_dial)(bt_instance_t* ins, bt_address_t* addr, const char* number)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->dial(addr, number);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_dial_memory)(bt_instance_t* ins, bt_address_t* addr, uint32_t memory)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->dial_memory(addr, memory);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_redial)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->redial(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_accept_call)(bt_instance_t* ins, bt_address_t* addr, hfp_call_accept_t flag)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->accept_call(addr, flag);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_reject_call)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->reject_call(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_hold_call)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->hold_call(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_terminate_call)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->terminate_call(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_control_call)(bt_instance_t* ins, bt_address_t* addr, hfp_call_control_t chld, uint8_t index)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->control_call(addr, chld, index);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_query_current_calls)(bt_instance_t* ins, bt_address_t* addr, hfp_current_call_t** calls, int* num, bt_allocator_t allocator)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->query_current_calls(addr, calls, num, allocator);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_send_at_cmd)(bt_instance_t* ins, bt_address_t* addr, const char* cmd)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
return profile->send_at_cmd(addr, cmd);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_update_battery_level)(bt_instance_t* ins, bt_address_t* addr, uint8_t level)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
return profile->update_battery_level(addr, level);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_volume_control)(bt_instance_t* ins, bt_address_t* addr, hfp_volume_type_t type, uint8_t volume)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
return profile->volume_control(addr, type, volume);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_send_dtmf)(bt_instance_t* ins, bt_address_t* addr, char dtmf)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
return profile->send_dtmf(addr, dtmf);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_get_subscriber_number)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
return profile->get_subscriber_number(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_query_current_calls_with_callback)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hfp_hf_interface_t* profile = get_profile_service();
|
||||
return profile->query_current_calls_with_callback(addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "hid_device_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_hid_device.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "hid_device_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static hid_device_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (hid_device_interface_t*)service_manager_get_profile(PROFILE_HID_DEV);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_hid_device_register_callbacks)(bt_instance_t* ins, const hid_device_callbacks_t* callbacks)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_hid_device_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_register_app)(bt_instance_t* ins, hid_device_sdp_settings_t* sdp, bool le_hid)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_app(sdp, le_hid);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_unregister_app)(bt_instance_t* ins)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_app();
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_connect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_send_report)(bt_instance_t* ins, bt_address_t* addr, uint8_t rpt_id, uint8_t* rpt_data, int rpt_size)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->send_report(addr, rpt_id, rpt_data, rpt_size);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_response_report)(bt_instance_t* ins, bt_address_t* addr, uint8_t rpt_type, uint8_t* rpt_data, int rpt_size)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->response_report(addr, rpt_type, rpt_data, rpt_size);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_report_error)(bt_instance_t* ins, bt_address_t* addr, hid_status_error_t error)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->report_error(addr, error);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_hid_device_virtual_unplug)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
hid_device_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->virtual_unplug(addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2024 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "L2CAP_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_internal.h"
|
||||
#include "bt_l2cap.h"
|
||||
#include "l2cap_service.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
void* BTSYMBOLS(bt_l2cap_register_callbacks)(bt_instance_t* ins, const l2cap_callbacks_t* callbacks)
|
||||
{
|
||||
return l2cap_register_callbacks(ins, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_l2cap_unregister_callbacks)(bt_instance_t* ins, void* handle)
|
||||
{
|
||||
return l2cap_unregister_callbacks(NULL, handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_listen)(bt_instance_t* ins, void* handle, l2cap_config_option_t* option)
|
||||
{
|
||||
return l2cap_listen_channel(handle, option);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_connect)(bt_instance_t* ins, void* handel, bt_address_t* addr, l2cap_config_option_t* option)
|
||||
{
|
||||
return l2cap_connect_channel(handel, addr, option);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_disconnect)(bt_instance_t* ins, void* handle, uint16_t id)
|
||||
{
|
||||
return l2cap_disconnect_channel(handle, id);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_stop_listen)(bt_instance_t* ins, void* handle, uint16_t psm)
|
||||
{
|
||||
return l2cap_stop_listen_channel(handle, BT_TRANSPORT_BLE, psm);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_stop_listen_with_transport)(bt_instance_t* ins, void* handle, bt_transport_t transport, uint16_t psm)
|
||||
{
|
||||
return l2cap_stop_listen_channel(handle, transport, psm);
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "adv"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "advertising.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_le_advertiser.h"
|
||||
#include "bt_list.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
bt_advertiser_t* BTSYMBOLS(bt_le_start_advertising)(bt_instance_t* ins,
|
||||
ble_adv_params_t* params,
|
||||
uint8_t* adv_data,
|
||||
uint16_t adv_len,
|
||||
uint8_t* scan_rsp_data,
|
||||
uint16_t scan_rsp_len,
|
||||
advertiser_callback_t* cbs)
|
||||
{
|
||||
return start_advertising(NULL, params, adv_data, adv_len,
|
||||
scan_rsp_data, scan_rsp_len, cbs);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_le_stop_advertising)(bt_instance_t* ins, bt_advertiser_t* adver)
|
||||
{
|
||||
stop_advertising(adver);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_le_stop_advertising_id)(bt_instance_t* ins, uint8_t adv_id)
|
||||
{
|
||||
stop_advertising_id(adv_id);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_le_advertising_is_supported)(bt_instance_t* ins)
|
||||
{
|
||||
return advertising_is_supported();
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "scan"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_le_scan.h"
|
||||
#include "bt_list.h"
|
||||
#include "scan_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
bt_scanner_t* BTSYMBOLS(bt_le_start_scan)(bt_instance_t* ins, const scanner_callbacks_t* cbs)
|
||||
{
|
||||
return scanner_start_scan(NULL, cbs);
|
||||
}
|
||||
|
||||
bt_scanner_t* BTSYMBOLS(bt_le_start_scan_settings)(bt_instance_t* ins,
|
||||
ble_scan_settings_t* settings,
|
||||
const scanner_callbacks_t* cbs)
|
||||
{
|
||||
return scanner_start_scan_settings(NULL, settings, cbs);
|
||||
}
|
||||
|
||||
bt_scanner_t* BTSYMBOLS(bt_le_start_scan_with_filters)(bt_instance_t* ins,
|
||||
ble_scan_settings_t* settings,
|
||||
ble_scan_filter_t* filter,
|
||||
const scanner_callbacks_t* cbs)
|
||||
{
|
||||
return scanner_start_scan_with_filters(NULL, settings, filter, cbs);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bt_le_stop_scan)(bt_instance_t* ins, bt_scanner_t* scanner)
|
||||
{
|
||||
scanner_stop_scan(scanner);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_le_scan_is_supported)(bt_instance_t* ins)
|
||||
{
|
||||
return scan_is_supported();
|
||||
}
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_lea_ccp.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_ccp_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static lea_ccp_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_ccp_interface_t*)service_manager_get_profile(PROFILE_LEAUDIO_CCP);
|
||||
}
|
||||
|
||||
void* bt_lea_ccp_register_callbacks(bt_instance_t* ins, const lea_ccp_callbacks_t* callbacks)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, (lea_ccp_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_ccp_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_provider_name(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_provider_name(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_uci(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_uci(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_technology(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_technology(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_uri_schemes_supported_list(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_uri_schemes_supported_list(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_signal_strength(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_signal_strength(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_signal_strength_report_interval(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_signal_strength_report_interval(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_content_control_id(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_content_control_id(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_status_flags(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_status_flags(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_call_control_optional_opcodes(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_call_control_optional_opcodes(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_incoming_call(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_incoming_call(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_incoming_call_target_bearer_uri(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_incoming_call_target_bearer_uri(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_call_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_call_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_bearer_list_current_calls(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_bearer_list_current_calls(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_read_call_friendly_name(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_call_friendly_name(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_call_control_by_index(bt_instance_t* ins, bt_address_t* addr, uint8_t opcode)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->call_control_by_index(addr, opcode);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_originate_call(bt_instance_t* ins, bt_address_t* addr, uint8_t* uri)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->originate_call(addr, uri);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_ccp_join_calls(bt_instance_t* ins, bt_address_t* addr, uint8_t number,
|
||||
uint8_t* call_indexes)
|
||||
{
|
||||
lea_ccp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->join_calls(addr, number, call_indexes);
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_lea_server.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_client_service.h"
|
||||
#include "service_manager.h"
|
||||
|
||||
static lea_client_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_client_interface_t*)service_manager_get_profile(
|
||||
PROFILE_LEAUDIO_CLIENT);
|
||||
}
|
||||
|
||||
void* bt_lea_client_register_callbacks(bt_instance_t* ins,
|
||||
const lea_client_callbacks_t* callbacks)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_client_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_connect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_connect_audio(bt_instance_t* ins, bt_address_t* addr, uint8_t context)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect_audio(addr, context);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_disconnect_audio(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect_audio(addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t bt_lea_client_get_connection_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_connection_state(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_get_group_id(bt_instance_t* ins, bt_address_t* addr, uint32_t* group_id)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_group_id(addr, group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_discovery_member_start(bt_instance_t* ins, uint32_t group_id)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->discovery_member_start(group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_discovery_member_stop(bt_instance_t* ins, uint32_t group_id)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->discovery_member_stop(group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_group_add_member(bt_instance_t* ins, uint32_t group_id, bt_address_t* addr)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->group_add_member(group_id, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_group_remove_member(bt_instance_t* ins, uint32_t group_id, bt_address_t* addr)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->group_remove_member(group_id, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_group_connect_audio(bt_instance_t* ins, uint32_t group_id, uint8_t context)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->group_connect_audio(group_id, context);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_group_disconnect_audio(bt_instance_t* ins, uint32_t group_id)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->group_disconnect_audio(group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_group_lock(bt_instance_t* ins, uint32_t group_id)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->group_lock(group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_client_group_unlock(bt_instance_t* ins, uint32_t group_id)
|
||||
{
|
||||
lea_client_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->group_unlock(group_id);
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_lea_mcp.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_mcp_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static lea_mcp_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_mcp_interface_t*)service_manager_get_profile(PROFILE_LEAUDIO_MCP);
|
||||
}
|
||||
|
||||
void* bt_lea_mcp_register_callbacks(bt_instance_t* ins, const lea_mcp_callbacks_t* callbacks)
|
||||
{
|
||||
lea_mcp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_callbacks(NULL, (lea_mcp_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_mcp_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_mcp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->reset_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcp_read_info(bt_instance_t* ins, bt_address_t* addr, uint8_t opcode)
|
||||
{
|
||||
lea_mcp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->read_remote_mcs_info(addr, opcode);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcp_media_control_request(bt_instance_t* ins, bt_address_t* addr, uint32_t opcode, int32_t n)
|
||||
{
|
||||
lea_mcp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->media_control_request(addr, opcode, n);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcp_search_control_request(bt_instance_t* ins, bt_address_t* addr, uint8_t number, uint32_t type, uint8_t* parameter)
|
||||
{
|
||||
lea_mcp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->search_control_request(addr, number, type, parameter);
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_lea_mcs.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_mcs_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static lea_mcs_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_mcs_interface_t*)service_manager_get_profile(PROFILE_LEAUDIO_MCS);
|
||||
}
|
||||
|
||||
void* bt_lea_mcs_register_callbacks(bt_instance_t* ins, const lea_mcs_callbacks_t* callbacks)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_callbacks(NULL, (lea_mcs_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_mcs_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->reset_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_service_add(bt_instance_t* ins)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->mcs_add();
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_service_remove(bt_instance_t* ins)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->mcs_remove();
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_playing_order_changed(bt_instance_t* ins, uint8_t order)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->playing_order_changed(order);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_media_state_changed(bt_instance_t* ins, uint8_t state)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->media_state_changed(state);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_playback_speed_changed(bt_instance_t* ins, int8_t speed)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->playback_speed_changed(speed);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_seeking_speed_changed(bt_instance_t* ins, int8_t speed)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->seeking_speed_changed(speed);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_track_title_changed(void* handl, uint8_t* title)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->track_title_changed(title);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_track_duration_changed(bt_instance_t* ins, int32_t duration)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->track_duration_changed(duration);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_track_position_changed(bt_instance_t* ins, int32_t position)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->track_position_changed(position);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_current_track_change(bt_instance_t* ins, lea_object_id track_id)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->current_track_changed(track_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_next_track_changed(bt_instance_t* ins, lea_object_id track_id)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->next_track_changed(track_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_current_group_changed(bt_instance_t* ins, lea_object_id group_id)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->current_group_changed(group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_parent_group_changed(bt_instance_t* ins, lea_object_id group_id)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->parent_group_changed(group_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_set_media_player_info(bt_instance_t* ins)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_media_player_info();
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mcs_media_control_point_response(bt_instance_t* ins, lea_adpt_mcs_media_control_result_t result)
|
||||
{
|
||||
lea_mcs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->media_control_response(result);
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_lea_server.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_server_service.h"
|
||||
#include "service_manager.h"
|
||||
|
||||
static lea_server_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_server_interface_t*)service_manager_get_profile(
|
||||
PROFILE_LEAUDIO_SERVER);
|
||||
}
|
||||
|
||||
void* bt_lea_server_register_callbacks(bt_instance_t* ins,
|
||||
const lea_server_callbacks_t* callbacks)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_server_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_server_start_announce(bt_instance_t* ins, uint8_t adv_id,
|
||||
uint8_t announce_type, uint8_t* adv_data, uint16_t adv_size,
|
||||
uint8_t* md_data, uint16_t md_size)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->start_announce(adv_id, announce_type, adv_data,
|
||||
adv_size, md_data, md_size);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_server_stop_announce(bt_instance_t* ins, uint8_t adv_id)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->stop_announce(adv_id);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_server_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_server_disconnect_audio(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect_audio(addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t bt_lea_server_get_connection_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_server_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->get_connection_state(addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_lea_tbs.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_tbs_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static lea_tbs_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_tbs_interface_t*)service_manager_get_profile(PROFILE_LEAUDIO_TBS);
|
||||
}
|
||||
|
||||
void* bt_lea_tbs_register_callbacks(bt_instance_t* ins, const lea_tbs_callbacks_t* callbacks)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, (lea_tbs_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_tbs_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_service_add(bt_instance_t* ins)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->tbs_add();
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_service_remove(bt_instance_t* ins)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->tbs_remove();
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_set_telephone_bearer_info(bt_instance_t* ins,
|
||||
lea_tbs_telephone_bearer_t* bearer)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_telephone_bearer(bearer);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_add_call(bt_instance_t* ins, lea_tbs_calls_t* call_s)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->add_call(call_s);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_remove_call(bt_instance_t* ins, uint8_t call_index)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->remove_call(call_index);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_provider_name_changed(bt_instance_t* ins, uint8_t* name)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->provider_name_changed(name);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_bearer_technology_changed(bt_instance_t* ins,
|
||||
lea_adpt_bearer_technology_t technology)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->bearer_technology_changed(technology);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_uri_schemes_supported_list_changed(bt_instance_t* ins,
|
||||
uint8_t* uri_schemes)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->uri_schemes_supported_list_changed(uri_schemes);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_rssi_value_changed(bt_instance_t* ins, uint8_t strength)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->rssi_value_changed(strength);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_rssi_interval_changed(bt_instance_t* ins,
|
||||
uint8_t interval)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->rssi_interval_changed(interval);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_status_flags_changed(bt_instance_t* ins, uint16_t status_flags)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->status_flags_changed(status_flags);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_call_state_changed(bt_instance_t* ins, uint8_t number,
|
||||
lea_tbs_call_state_t* state_s)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->call_state_changed(number, state_s);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_notify_termination_reason(bt_instance_t* ins, uint8_t call_index,
|
||||
lea_adpt_termination_reason_t reason)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->notify_termination_reason(call_index, reason);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_tbs_call_control_response(bt_instance_t* ins, uint8_t call_index,
|
||||
lea_adpt_call_control_result_t result)
|
||||
{
|
||||
lea_tbs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->call_control_response(call_index, result);
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include "bt_lea_vmicp.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_vmicp_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
static lea_vmicp_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_vmicp_interface_t*)service_manager_get_profile(PROFILE_LEAUDIO_VMICP);
|
||||
}
|
||||
|
||||
void* bt_lea_vmicp_register_callbacks(bt_instance_t* ins, const lea_vmicp_callbacks_t* callbacks)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, (lea_vmicp_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_vmicp_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_get_volume_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->vol_get(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_get_volume_flags(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->flags_get(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_change_volume(bt_instance_t* ins, bt_address_t* addr, int dir)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->vol_change(addr, dir);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_change_unmute_volume(bt_instance_t* ins, bt_address_t* addr, int dir)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->vol_unmute_change(addr, dir);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_set_volume(bt_instance_t* ins, bt_address_t* addr, int vol)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->vol_set(addr, vol);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_set_volume_mute(bt_instance_t* ins, bt_address_t* addr, int mute)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->mute_state_set(addr, mute);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_get_mic_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->mic_mute_get(addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vmicp_set_mic_mute(bt_instance_t* ins, bt_address_t* addr, int mute)
|
||||
{
|
||||
lea_vmicp_interface_t* profile = get_profile_service();
|
||||
return profile->mic_mute_set(addr, mute);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_lea_vmics.h"
|
||||
#include "bt_profile.h"
|
||||
#include "lea_vmics_service.h"
|
||||
#include "service_manager.h"
|
||||
|
||||
static lea_vmics_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (lea_vmics_interface_t*)service_manager_get_profile(PROFILE_LEAUDIO_VMICS);
|
||||
}
|
||||
|
||||
void* bt_lea_vmics_register_callbacks(bt_instance_t* ins, const lea_vmics_callbacks_t* callbacks)
|
||||
{
|
||||
lea_vmics_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, (lea_vmics_callbacks_t*)callbacks);
|
||||
}
|
||||
|
||||
bool bt_lea_vmics_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
lea_vmics_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vcs_volume_set(bt_instance_t* ins, int vol)
|
||||
{
|
||||
lea_vmics_interface_t* profile = get_profile_service();
|
||||
return profile->vcs_volume_notify(ins, vol);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vcs_mute_set(bt_instance_t* ins, int mute)
|
||||
{
|
||||
lea_vmics_interface_t* profile = get_profile_service();
|
||||
return profile->vcs_mute_notify(ins, mute);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_vcs_volume_flags_set(bt_instance_t* ins, int flags)
|
||||
{
|
||||
lea_vmics_interface_t* profile = get_profile_service();
|
||||
return profile->vcs_volume_flags_notify(ins, flags);
|
||||
}
|
||||
|
||||
bt_status_t bt_lea_mics_mute_set(bt_instance_t* ins, int mute)
|
||||
{
|
||||
lea_vmics_interface_t* profile = get_profile_service();
|
||||
return profile->mics_mute_notify(ins, mute);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "pan_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_internal.h"
|
||||
#include "bt_pan.h"
|
||||
#include "bt_profile.h"
|
||||
#include "pan_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static pan_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (pan_interface_t*)service_manager_get_profile(PROFILE_PANU);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_pan_register_callbacks)(bt_instance_t* ins, const pan_callbacks_t* callbacks)
|
||||
{
|
||||
pan_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_pan_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
pan_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_pan_connect)(bt_instance_t* ins, bt_address_t* addr, uint8_t dst_role, uint8_t src_role)
|
||||
{
|
||||
pan_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(addr, dst_role, src_role);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_pan_disconnect)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
pan_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "spp_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "bt_spp.h"
|
||||
#include "service_manager.h"
|
||||
#include "spp_service.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
static spp_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (spp_interface_t*)service_manager_get_profile(PROFILE_SPP);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_spp_register_app_with_name)(bt_instance_t* ins, const char* name, const spp_callbacks_t* callbacks)
|
||||
{
|
||||
spp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_app(NULL, name, callbacks);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_spp_register_app)(bt_instance_t* ins, const spp_callbacks_t* callbacks)
|
||||
{
|
||||
return BTSYMBOLS(bt_spp_register_app_with_name)(ins, NULL, callbacks);
|
||||
}
|
||||
|
||||
void* BTSYMBOLS(bt_spp_register_app_ext)(bt_instance_t* ins, const char* name, int port_type, const spp_callbacks_t* callbacks)
|
||||
{
|
||||
return BTSYMBOLS(bt_spp_register_app_with_name)(ins, name, callbacks);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_spp_unregister_app)(bt_instance_t* ins, void* handle)
|
||||
{
|
||||
spp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_app(NULL, handle);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_spp_server_start)(bt_instance_t* ins, void* handle, uint16_t scn, bt_uuid_t* uuid, uint8_t max_connection)
|
||||
{
|
||||
spp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->server_start(handle, scn, uuid, max_connection);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_spp_server_stop)(bt_instance_t* ins, void* handle, uint16_t scn)
|
||||
{
|
||||
spp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->server_stop(handle, scn);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_spp_connect)(bt_instance_t* ins, void* handle, bt_address_t* addr, int16_t scn, bt_uuid_t* uuid, uint16_t* port)
|
||||
{
|
||||
spp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->connect(handle, addr, scn, uuid, port);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_spp_disconnect)(bt_instance_t* ins, void* handle, bt_address_t* addr, uint16_t port)
|
||||
{
|
||||
spp_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->disconnect(handle, addr, port);
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2024 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_trace.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bt_internal.h"
|
||||
#include "utils/btsnoop_log.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
void BTSYMBOLS(bluetooth_enable_btsnoop_log)(bt_instance_t* ins)
|
||||
{
|
||||
bt_log_module_enable(LOG_ID_SNOOP, false);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bluetooth_disable_btsnoop_log)(bt_instance_t* ins)
|
||||
{
|
||||
bt_log_module_disable(LOG_ID_SNOOP, false);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bluetooth_set_btsnoop_filter)(bt_instance_t* ins, btsnoop_filter_flag_t filter_flag)
|
||||
{
|
||||
btsnoop_set_filter(filter_flag);
|
||||
}
|
||||
|
||||
void BTSYMBOLS(bluetooth_remove_btsnoop_filter)(bt_instance_t* ins, btsnoop_filter_flag_t filter_flag)
|
||||
{
|
||||
btsnoop_remove_filter(filter_flag);
|
||||
}
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_BINDER_IPC
|
||||
#include "adapter_proxy.h"
|
||||
#include "adapter_stub.h"
|
||||
#include "bluetooth_proxy.h"
|
||||
#include "gattc_proxy.h"
|
||||
#include "gatts_proxy.h"
|
||||
#include "hfp_ag_proxy.h"
|
||||
#include "hfp_hf_proxy.h"
|
||||
#include "hid_device_proxy.h"
|
||||
#include "pan_proxy.h"
|
||||
#include "spp_proxy.h"
|
||||
#endif
|
||||
#include "bluetooth.h"
|
||||
|
||||
bt_instance_t* bluetooth_create_instance(void)
|
||||
{
|
||||
AIBinder* binder;
|
||||
char name[64] = { 0 };
|
||||
|
||||
bt_instance_t* ins = zalloc(sizeof(bt_instance_t));
|
||||
if (!ins) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
binder = BtManager_getService((BpBtManager**)&ins->manager_proxy, MANAGER_BINDER_INSTANCE);
|
||||
if (!binder)
|
||||
goto bail;
|
||||
|
||||
gethostname(name, 64);
|
||||
bt_status_t status = BpBtManager_createInstance(binder, (uint32_t)ins, BLUETOOTH_SYSTEM, name, &ins->app_id);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
goto bail;
|
||||
|
||||
BtAdapter_getService((BpBtAdapter**)&ins->adapter_proxy, ADAPTER_BINDER_INSTANCE);
|
||||
Bluetooth_startThreadPool();
|
||||
|
||||
return ins;
|
||||
|
||||
bail:
|
||||
free(ins);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bt_instance_t* bluetooth_get_instance(void)
|
||||
{
|
||||
uint32_t handle;
|
||||
char name[64] = { 0 };
|
||||
AIBinder* binder;
|
||||
BpBtManager* proxy = NULL;
|
||||
|
||||
/* find instance from bluetooth manager by hostname,
|
||||
if not found, create new instance for this hostname
|
||||
*/
|
||||
|
||||
binder = BtManager_getService(&proxy, MANAGER_BINDER_INSTANCE);
|
||||
if (!binder)
|
||||
return NULL;
|
||||
|
||||
gethostname(name, 64);
|
||||
bt_status_t status = BpBtManager_getInstance(binder, name, &handle);
|
||||
BpBtManager_delete(proxy);
|
||||
if (status == BT_STATUS_SUCCESS && handle)
|
||||
return (bt_instance_t*)handle;
|
||||
else
|
||||
return bluetooth_create_instance();
|
||||
}
|
||||
|
||||
void* bluetooth_get_proxy(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
switch (id) {
|
||||
case PROFILE_HFP_HF:
|
||||
/* for binder ipc*/
|
||||
if (!ins->hfp_hf_proxy) {
|
||||
ins->hfp_hf_proxy = BpBtHfpHf_new(HFP_HF_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->hfp_hf_proxy;
|
||||
case PROFILE_HFP_AG: {
|
||||
if (!ins->hfp_ag_proxy) {
|
||||
ins->hfp_ag_proxy = BpBtHfpAg_new(HFP_AG_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->hfp_ag_proxy;
|
||||
}
|
||||
case PROFILE_SPP: {
|
||||
if (!ins->spp_proxy) {
|
||||
ins->spp_proxy = BpBtSpp_new(SPP_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->spp_proxy;
|
||||
}
|
||||
case PROFILE_HID_DEV: {
|
||||
if (!ins->hidd_proxy) {
|
||||
ins->hidd_proxy = BpBtHidd_new(HID_DEVICE_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->hidd_proxy;
|
||||
}
|
||||
case PROFILE_PANU: {
|
||||
if (!ins->pan_proxy) {
|
||||
ins->pan_proxy = BpBtPan_new(PAN_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->pan_proxy;
|
||||
}
|
||||
case PROFILE_GATTC: {
|
||||
if (!ins->gattc_proxy) {
|
||||
ins->gattc_proxy = BpBtGattClient_new(GATT_CLIENT_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->gattc_proxy;
|
||||
}
|
||||
case PROFILE_GATTS: {
|
||||
if (!ins->gatts_proxy) {
|
||||
ins->gatts_proxy = BpBtGattServer_new(GATT_SERVER_BINDER_INSTANCE);
|
||||
}
|
||||
return ins->gatts_proxy;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void bluetooth_delete_instance(bt_instance_t* ins)
|
||||
{
|
||||
if (ins->hfp_hf_proxy)
|
||||
BpBtHfpHf_delete(ins->hfp_hf_proxy);
|
||||
|
||||
if (ins->hfp_ag_proxy)
|
||||
BpBtHfpAg_delete(ins->hfp_ag_proxy);
|
||||
|
||||
if (ins->spp_proxy)
|
||||
BpBtSpp_delete(ins->spp_proxy);
|
||||
|
||||
if (ins->pan_proxy)
|
||||
BpBtPan_delete(ins->pan_proxy);
|
||||
|
||||
if (ins->gattc_proxy)
|
||||
BpBtGattClient_delete(ins->gattc_proxy);
|
||||
|
||||
if (ins->gatts_proxy)
|
||||
BpBtGattServer_delete(ins->gatts_proxy);
|
||||
|
||||
BpBtAdapter_delete(ins->adapter_proxy);
|
||||
BpBtManager_deleteInstance(ins->manager_proxy, ins->app_id);
|
||||
BpBtManager_delete(ins->manager_proxy);
|
||||
free(ins);
|
||||
}
|
||||
|
||||
bt_status_t bluetooth_start_service(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
return BpBtManager_startService(ins->manager_proxy, ins->app_id, id);
|
||||
}
|
||||
|
||||
bt_status_t bluetooth_stop_service(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
return BpBtManager_stopService(ins->manager_proxy, ins->app_id, id);
|
||||
}
|
||||
|
||||
#include "uv.h"
|
||||
bool bluetooth_set_external_uv(bt_instance_t* ins, uv_loop_t* ext_loop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "adapter_callbacks_stub.h"
|
||||
#include "adapter_proxy.h"
|
||||
#include "adapter_stub.h"
|
||||
#include "bt_adapter.h"
|
||||
|
||||
void* bt_adapter_register_callback(bt_instance_t* ins, const adapter_callbacks_t* adapter_cbs)
|
||||
{
|
||||
BpBtAdapter* bpAdapter = ins->adapter_proxy;
|
||||
|
||||
if (!BtAdapter_getService(&bpAdapter, ADAPTER_BINDER_INSTANCE))
|
||||
return NULL;
|
||||
|
||||
IBtAdapterCallbacks* cbks = BtAdapterCallbacks_new(adapter_cbs);
|
||||
AIBinder* binder = BtAdapterCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtAdapterCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* rmt_cookie = BpBtAdapter_registerCallback(bpAdapter, binder);
|
||||
AIBinder_decStrong(binder);
|
||||
if (!rmt_cookie) {
|
||||
BtAdapterCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cbks->cookie = rmt_cookie;
|
||||
return (void*)cbks;
|
||||
}
|
||||
|
||||
bool bt_adapter_unregister_callback(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
IBtAdapterCallbacks* cbks = cookie;
|
||||
|
||||
bool ret = BpBtAdapter_unRegisterCallback((BpBtAdapter*)ins->adapter_proxy, cbks->cookie);
|
||||
if (ret)
|
||||
BtAdapterCallbacks_delete(cbks);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_enable(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_enable((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_disable(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_disable((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_enable_le(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_enableLe((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_disable_le(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_disableLe((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_adapter_state_t bt_adapter_get_state(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getState((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bool bt_adapter_is_le_enabled(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_isLeEnabled((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_device_type_t bt_adapter_get_type(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getType((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_discovery_filter(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_setDiscoveryFilter((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_start_discovery(bt_instance_t* ins, uint32_t timeout)
|
||||
{
|
||||
return BpBtAdapter_startDiscovery((BpBtAdapter*)ins->adapter_proxy, timeout);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_cancel_discovery(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_cancelDiscovery((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bool bt_adapter_is_discovering(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_isDiscovering((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
void bt_adapter_get_address(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtAdapter_getAddress((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_name(bt_instance_t* ins, const char* name)
|
||||
{
|
||||
assert(strlen(name) <= 64);
|
||||
|
||||
return BpBtAdapter_setName((BpBtAdapter*)ins->adapter_proxy, name);
|
||||
}
|
||||
|
||||
void bt_adapter_get_name(bt_instance_t* ins, char* name, int length)
|
||||
{
|
||||
BpBtAdapter_getName((BpBtAdapter*)ins->adapter_proxy, name, length);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_get_uuids(bt_instance_t* ins, bt_uuid_t* uuids, uint16_t* size)
|
||||
{
|
||||
return BpBtAdapter_getUuids((BpBtAdapter*)ins->adapter_proxy, uuids, size);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_scan_mode(bt_instance_t* ins, bt_scan_mode_t mode, bool bondable)
|
||||
{
|
||||
return BpBtAdapter_setScanMode((BpBtAdapter*)ins->adapter_proxy, mode, bondable);
|
||||
}
|
||||
|
||||
bt_scan_mode_t bt_adapter_get_scan_mode(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getScanMode((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_device_class(bt_instance_t* ins, uint32_t cod)
|
||||
{
|
||||
return BpBtAdapter_setDeviceClass((BpBtAdapter*)ins->adapter_proxy, cod);
|
||||
}
|
||||
|
||||
uint32_t bt_adapter_get_device_class(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getDeviceClass((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_io_capability(bt_instance_t* ins, bt_io_capability_t cap)
|
||||
{
|
||||
return BpBtAdapter_setIOCapability((BpBtAdapter*)ins->adapter_proxy, cap);
|
||||
}
|
||||
|
||||
bt_io_capability_t bt_adapter_get_io_capability(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getIOCapability((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_le_io_capability(bt_instance_t* ins, uint32_t le_io_cap)
|
||||
{
|
||||
return BpBtAdapter_SetLeIOCapability((BpBtAdapter*)ins->adapter_proxy, le_io_cap);
|
||||
}
|
||||
|
||||
uint32_t bt_adapter_get_le_io_capability(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getLeIOCapability((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_get_le_address(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t* type)
|
||||
{
|
||||
return BpBtAdapter_getLeAddress((BpBtAdapter*)ins->adapter_proxy, addr, type);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_le_address(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_setLeAddress((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_le_identity_address(bt_instance_t* ins, bt_address_t* addr, bool is_public)
|
||||
{
|
||||
return BpBtAdapter_setLeIdentityAddress((BpBtAdapter*)ins->adapter_proxy, addr, is_public);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_le_appearance(bt_instance_t* ins, uint16_t appearance)
|
||||
{
|
||||
return BpBtAdapter_setLeAppearance((BpBtAdapter*)ins->adapter_proxy, appearance);
|
||||
}
|
||||
|
||||
uint16_t bt_adapter_get_le_appearance(bt_instance_t* ins)
|
||||
{
|
||||
return BpBtAdapter_getLeAppearance((BpBtAdapter*)ins->adapter_proxy);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_get_bonded_devices(bt_instance_t* ins, bt_transport_t transport, bt_address_t** addr, int* num, bt_allocator_t allocator)
|
||||
{
|
||||
return BpBtAdapter_getBondedDevices((BpBtAdapter*)ins->adapter_proxy, addr, num, allocator);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_get_connected_devices(bt_instance_t* ins, bt_transport_t transport, bt_address_t** addr, int* num, bt_allocator_t allocator)
|
||||
{
|
||||
return BpBtAdapter_getConnectedDevices((BpBtAdapter*)ins->adapter_proxy, addr, num, allocator);
|
||||
}
|
||||
|
||||
void bt_adapter_disconnect_all_devices(bt_instance_t* ins)
|
||||
{
|
||||
}
|
||||
|
||||
bool bt_adapter_is_support_bredr(bt_instance_t* ins)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bt_adapter_is_support_le(bt_instance_t* ins)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bt_adapter_is_support_leaudio(bt_instance_t* ins)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "adapter_internel.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
#include "device.h"
|
||||
|
||||
#include "adapter_proxy.h"
|
||||
#include "adapter_stub.h"
|
||||
|
||||
bt_address_t* bt_device_get_identity_address(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ble_addr_type_t bt_device_get_address_type(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bt_device_type_t bt_device_get_device_type(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_getRemoteDeviceType((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bool bt_device_get_name(bt_instance_t* ins, bt_address_t* addr, char* name, uint32_t length)
|
||||
{
|
||||
return BpBtAdapter_getRemoteName((BpBtAdapter*)ins->adapter_proxy, addr, name, length);
|
||||
}
|
||||
|
||||
uint32_t bt_device_get_device_class(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_getRemoteDeviceClass((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_get_uuids(bt_instance_t* ins, bt_address_t* addr, bt_uuid_t** uuids, uint16_t* size, bt_allocator_t allocator)
|
||||
{
|
||||
return BpBtAdapter_getRemoteUuids((BpBtAdapter*)ins->adapter_proxy, addr, uuids, size, allocator);
|
||||
}
|
||||
|
||||
uint16_t bt_device_get_appearance(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_getRemoteAppearance((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
int8_t bt_device_get_rssi(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_getRemoteRssi((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bool bt_device_get_alias(bt_instance_t* ins, bt_address_t* addr, char* alias, uint32_t length)
|
||||
{
|
||||
return BpBtAdapter_getRemoteAlias((BpBtAdapter*)ins->adapter_proxy, addr, alias, length);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_set_alias(bt_instance_t* ins, bt_address_t* addr, const char* alias)
|
||||
{
|
||||
return BpBtAdapter_setRemoteAlias((BpBtAdapter*)ins->adapter_proxy, addr, alias);
|
||||
}
|
||||
|
||||
bool bt_device_is_connected(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_isRemoteConnected((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bool bt_device_is_encrypted(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_isRemoteEncrypted((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bool bt_device_is_bond_initiate_local(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_isBondInitiateLocal((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bond_state_t bt_device_get_bond_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_getRemoteBondState((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bool bt_device_is_bonded(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_isRemoteBonded((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_connect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_connect((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_disconnect((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_connect_le(bt_instance_t* ins,
|
||||
bt_address_t* addr,
|
||||
ble_addr_type_t type,
|
||||
ble_connect_params_t* param)
|
||||
{
|
||||
return BpBtAdapter_leConnect((BpBtAdapter*)ins->adapter_proxy, addr, type, param);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_disconnect_le(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_leDisconnect((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
void bt_device_connect_all_profile(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
}
|
||||
|
||||
void bt_device_disconnect_all_profile(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
}
|
||||
|
||||
bt_status_t bt_device_set_le_phy(bt_instance_t* ins,
|
||||
bt_address_t* addr,
|
||||
ble_phy_type_t tx_phy,
|
||||
ble_phy_type_t rx_phy)
|
||||
{
|
||||
return BpBtAdapter_leSetPhy((BpBtAdapter*)ins->adapter_proxy, addr, tx_phy, rx_phy);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_create_bond(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
return BpBtAdapter_createBond((BpBtAdapter*)ins->adapter_proxy, addr, transport);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_remove_bond(bt_instance_t* ins, bt_address_t* addr, uint8_t transport)
|
||||
{
|
||||
return BpBtAdapter_removeBond((BpBtAdapter*)ins->adapter_proxy, addr, transport);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_cancel_bond(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return BpBtAdapter_cancelBond((BpBtAdapter*)ins->adapter_proxy, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_pair_request_reply(bt_instance_t* ins, bt_address_t* addr, bool accept)
|
||||
{
|
||||
return BpBtAdapter_pairRequestReply((BpBtAdapter*)ins->adapter_proxy, addr, accept);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_set_pairing_confirmation(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bool accept)
|
||||
{
|
||||
return BpBtAdapter_setPairingConfirmation((BpBtAdapter*)ins->adapter_proxy, addr, transport, accept);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_set_pin_code(bt_instance_t* ins, bt_address_t* addr, bool accept,
|
||||
char* pincode, int len)
|
||||
{
|
||||
return BpBtAdapter_setPinCode((BpBtAdapter*)ins->adapter_proxy, addr, accept, pincode, len);
|
||||
}
|
||||
|
||||
bt_status_t bt_device_set_pass_key(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bool accept, uint32_t passkey)
|
||||
{
|
||||
return BpBtAdapter_setPassKey((BpBtAdapter*)ins->adapter_proxy, addr, transport, accept, passkey);
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "gattc"
|
||||
|
||||
#include "bt_gattc.h"
|
||||
#include "bt_profile.h"
|
||||
|
||||
#include "gattc_callbacks_stub.h"
|
||||
#include "gattc_proxy.h"
|
||||
#include "gattc_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
bt_status_t bt_gattc_create_connect(bt_instance_t* ins, gattc_handle_t* phandle, gattc_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtGattClient* gattc = (BpBtGattClient*)bluetooth_get_proxy(ins, PROFILE_GATTC);
|
||||
|
||||
IBtGattClientCallbacks* cbks = BtGattClientCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtGattClientCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtGattClientCallbacks_delete(cbks);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
void* handle = BpBtGattClient_createConnect(gattc, binder);
|
||||
if (!handle) {
|
||||
BtGattClientCallbacks_delete(cbks);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
cbks->proxy = gattc;
|
||||
cbks->cookie = handle;
|
||||
*phandle = cbks;
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_delete_connect(gattc_handle_t conn_handle)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
bt_status_t status = BpBtGattClient_deleteConnect(cbks->proxy, cbks->cookie);
|
||||
if (status == BT_STATUS_SUCCESS)
|
||||
BtGattClientCallbacks_delete(cbks);
|
||||
return status;
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_connect(gattc_handle_t conn_handle, bt_address_t* addr, ble_addr_type_t addr_type)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_connect(cbks->proxy, cbks->cookie, addr, addr_type);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_disconnect(gattc_handle_t conn_handle)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_disconnect(cbks->proxy, cbks->cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_discover_service(gattc_handle_t conn_handle, bt_uuid_t* filter_uuid)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_discoverService(cbks->proxy, cbks->cookie, filter_uuid);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_get_attribute_by_handle(gattc_handle_t conn_handle, uint16_t attr_handle, gatt_attr_desc_t* attr_desc)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_getAttributeByHandle(cbks->proxy, cbks->cookie, attr_handle, attr_desc);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_get_attribute_by_uuid(gattc_handle_t conn_handle, bt_uuid_t* attr_uuid, gatt_attr_desc_t* attr_desc)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_getAttributeByUUID(cbks->proxy, cbks->cookie, attr_uuid, attr_desc);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_read(gattc_handle_t conn_handle, uint16_t attr_handle)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_read(cbks->proxy, cbks->cookie, attr_handle);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_write(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_write(cbks->proxy, cbks->cookie, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_write_without_response(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_writeWithoutResponse(cbks->proxy, cbks->cookie, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_subscribe(gattc_handle_t conn_handle, uint16_t value_handle, uint16_t cccd_handle)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_subscribe(cbks->proxy, cbks->cookie, value_handle, cccd_handle);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_unsubscribe(gattc_handle_t conn_handle, uint16_t value_handle, uint16_t cccd_handle)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_unsubscribe(cbks->proxy, cbks->cookie, value_handle, cccd_handle);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_exchange_mtu(gattc_handle_t conn_handle, uint32_t mtu)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_exchangeMtu(cbks->proxy, cbks->cookie, mtu);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_update_connection_parameter(gattc_handle_t conn_handle, uint32_t min_interval, uint32_t max_interval, uint32_t latency,
|
||||
uint32_t timeout, uint32_t min_connection_event_length, uint32_t max_connection_event_length)
|
||||
{
|
||||
IBtGattClientCallbacks* cbks = conn_handle;
|
||||
return BpBtGattClient_updateConnectionParameter(cbks->proxy, cbks->cookie, min_interval, max_interval, latency,
|
||||
timeout, min_connection_event_length, max_connection_event_length);
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "gatts"
|
||||
|
||||
#include "bt_gatts.h"
|
||||
#include "bt_profile.h"
|
||||
|
||||
#include "gatts_callbacks_stub.h"
|
||||
#include "gatts_proxy.h"
|
||||
#include "gatts_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
bt_status_t bt_gatts_register_service(bt_instance_t* ins, gatts_handle_t* phandle, gatts_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtGattServer* gatts = (BpBtGattServer*)bluetooth_get_proxy(ins, PROFILE_GATTS);
|
||||
|
||||
IBtGattServerCallbacks* cbks = BtGattServerCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtGattServerCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtGattServerCallbacks_delete(cbks);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
void* handle = BpBtGattServer_registerService(gatts, binder);
|
||||
if (!handle) {
|
||||
BtGattServerCallbacks_delete(cbks);
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
cbks->proxy = gatts;
|
||||
cbks->cookie = handle;
|
||||
*phandle = cbks;
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_unregister_service(gatts_handle_t srv_handle)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
bt_status_t status = BpBtGattServer_unregisterService(cbks->proxy, cbks->cookie);
|
||||
if (status == BT_STATUS_SUCCESS)
|
||||
BtGattServerCallbacks_delete(cbks);
|
||||
return status;
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_connect(gatts_handle_t srv_handle, bt_address_t* addr, ble_addr_type_t addr_type)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_connect(cbks->proxy, cbks->cookie, addr, addr_type);
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_disconnect(gatts_handle_t srv_handle)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_disconnect(cbks->proxy, cbks->cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_create_service_table(gatts_handle_t srv_handle, gatt_srv_db_t* srv_db)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
bt_status_t status = BpBtGattServer_createServiceTable(cbks->proxy, cbks->cookie, srv_db);
|
||||
if (status == BT_STATUS_SUCCESS)
|
||||
cbks->srv_db = srv_db;
|
||||
return status;
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_start(gatts_handle_t srv_handle)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_start(cbks->proxy, cbks->cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_stop(gatts_handle_t srv_handle)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_stop(cbks->proxy, cbks->cookie);
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_response(gatts_handle_t srv_handle, uint32_t req_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_response(cbks->proxy, cbks->cookie, req_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_notify(gatts_handle_t srv_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_notify(cbks->proxy, cbks->cookie, attr_handle, value, length);
|
||||
}
|
||||
|
||||
bt_status_t bt_gatts_indicate(gatts_handle_t srv_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
IBtGattServerCallbacks* cbks = srv_handle;
|
||||
return BpBtGattServer_indicate(cbks->proxy, cbks->cookie, attr_handle, value, length);
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "hfp_ag_api"
|
||||
|
||||
#include "bt_hfp_ag.h"
|
||||
#include "bt_profile.h"
|
||||
|
||||
#include "hfp_ag_callbacks_stub.h"
|
||||
#include "hfp_ag_proxy.h"
|
||||
#include "hfp_ag_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void* bt_hfp_ag_register_callbacks(bt_instance_t* ins, const hfp_ag_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
IBtHfpAgCallbacks* cbks = BtHfpAgCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtHfpAgCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtHfpAgCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* remote_cbks = BpBtHfpAg_registerCallback(ag, binder);
|
||||
if (!remote_cbks) {
|
||||
BtHfpAgCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
cbks->cookie = remote_cbks;
|
||||
|
||||
return cbks;
|
||||
}
|
||||
|
||||
bool bt_hfp_ag_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
IBtHfpAgCallbacks* cbks = cookie;
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
bool ret = BpBtHfpAg_unRegisterCallback(ag, cbks->cookie);
|
||||
if (ret)
|
||||
BtHfpAgCallbacks_delete(cbks);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool bt_hfp_ag_is_connected(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_isConnected(ag, addr);
|
||||
}
|
||||
|
||||
bool bt_hfp_ag_is_audio_connected(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_isAudioConnected(ag, addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t bt_hfp_ag_get_connection_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_getConnectionState(ag, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_connect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_connect(ag, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_disconnect(ag, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_connect_audio(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_connectAudio(ag, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_disconnect_audio(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_disconnectAudio(ag, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_start_voice_recognition(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_startVoiceRecognition(ag, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_stop_voice_recognition(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpAg* ag = (BpBtHfpAg*)bluetooth_get_proxy(ins, PROFILE_HFP_AG);
|
||||
|
||||
return BpBtHfpAg_stopVoiceRecognition(ag, addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_THF "hfp_hf_api"
|
||||
|
||||
#include "bt_hfp_hf.h"
|
||||
#include "bt_profile.h"
|
||||
|
||||
#include "hfp_hf_callbacks_stub.h"
|
||||
#include "hfp_hf_proxy.h"
|
||||
#include "hfp_hf_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void* bt_hfp_hf_register_callbacks(bt_instance_t* ins, const hfp_hf_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
IBtHfpHfCallbacks* cbks = BtHfpHfCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtHfpHfCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtHfpHfCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* remote_cbks = BpBtHfpHf_registerCallback(hf, binder);
|
||||
if (!remote_cbks) {
|
||||
BtHfpHfCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
cbks->cookie = remote_cbks;
|
||||
|
||||
return cbks;
|
||||
}
|
||||
|
||||
bool bt_hfp_hf_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
IBtHfpHfCallbacks* cbks = cookie;
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
bool ret = BpBtHfpHf_unRegisterCallback(hf, cbks->cookie);
|
||||
if (ret)
|
||||
BtHfpHfCallbacks_delete(cbks);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool bt_hfp_hf_is_connected(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_isConnected(hf, addr);
|
||||
}
|
||||
|
||||
bool bt_hfp_hf_is_audio_connected(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_isAudioConnected(hf, addr);
|
||||
}
|
||||
|
||||
profile_connection_state_t bt_hfp_hf_get_connection_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_getConnectionState(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_connect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_connect(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_disconnect(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_connect_audio(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_connectAudio(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_disconnect_audio(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_disconnectAudio(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_start_voice_recognition(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_startVoiceRecognition(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_stop_voice_recognition(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_stopVoiceRecognition(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_dial(bt_instance_t* ins, bt_address_t* addr, const char* number)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_dial(hf, addr, number);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_dial_memory(bt_instance_t* ins, bt_address_t* addr, uint32_t memory)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_dialMemory(hf, addr, memory);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_redial(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_redial(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_accept_call(bt_instance_t* ins, bt_address_t* addr, hfp_call_accept_t flag)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_acceptCall(hf, addr, flag);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_reject_call(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_rejectCall(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_hold_call(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_holdCall(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_terminate_call(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_terminateCall(hf, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_control_call(bt_instance_t* ins, bt_address_t* addr, hfp_call_control_t chld, uint8_t index)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_controlCall(hf, addr, chld, index);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_query_current_calls(bt_instance_t* ins, bt_address_t* addr, hfp_current_call_t** calls, int* num, bt_allocator_t allocator)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_queryCurrentCalls(hf, addr, calls, num, allocator);
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_send_at_cmd(bt_instance_t* ins, bt_address_t* addr, const char* cmd)
|
||||
{
|
||||
BpBtHfpHf* hf = (BpBtHfpHf*)bluetooth_get_proxy(ins, PROFILE_HFP_HF);
|
||||
|
||||
return BpBtHfpHf_sendAtCmd(hf, addr, cmd);
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "hid_device_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "bt_hid_device.h"
|
||||
#include "bt_profile.h"
|
||||
|
||||
#include "hid_device_callbacks_stub.h"
|
||||
#include "hid_device_proxy.h"
|
||||
#include "hid_device_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
void* bt_hid_device_register_callbacks(bt_instance_t* ins, const hid_device_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
IBtHiddCallbacks* cbks = BtHiddCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtHiddCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtHiddCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* remote_cbks = BpBtHidd_registerCallback(hidd, binder);
|
||||
if (!remote_cbks) {
|
||||
BtHiddCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
cbks->cookie = remote_cbks;
|
||||
|
||||
return cbks;
|
||||
}
|
||||
|
||||
bool bt_hid_device_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
IBtHiddCallbacks* cbks = cookie;
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
bool ret = BpBtHidd_unRegisterCallback(hidd, cbks->cookie);
|
||||
if (ret)
|
||||
BtHiddCallbacks_delete(cbks);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_register_app(bt_instance_t* ins, hid_device_sdp_settings_t* sdp, bool le_hid)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_registerApp(hidd, sdp, le_hid);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_unregister_app(bt_instance_t* ins)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_unregisterApp(hidd);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_connect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_connect(hidd, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_disconnect(hidd, addr);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_send_report(bt_instance_t* ins, bt_address_t* addr, uint8_t rpt_id, uint8_t* rpt_data, int rpt_size)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_sendReport(hidd, addr, rpt_id, rpt_data, rpt_size);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_response_report(bt_instance_t* ins, bt_address_t* addr, uint8_t rpt_type, uint8_t* rpt_data, int rpt_size)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_responseReport(hidd, addr, rpt_type, rpt_data, rpt_size);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_report_error(bt_instance_t* ins, bt_address_t* addr, hid_status_error_t error)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_reportError(hidd, addr, error);
|
||||
}
|
||||
|
||||
bt_status_t bt_hid_device_virtual_unplug(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtHidd* hidd = (BpBtHidd*)bluetooth_get_proxy(ins, PROFILE_HID_DEV);
|
||||
|
||||
return BpBtHidd_virtualUnplug(hidd, addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "adv"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "adapter_proxy.h"
|
||||
#include "adapter_stub.h"
|
||||
#include "advertiser_callbacks_stub.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bt_le_advertiser.h"
|
||||
#include "bt_list.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
bt_advertiser_t* bt_le_start_advertising(bt_instance_t* ins,
|
||||
ble_adv_params_t* params,
|
||||
uint8_t* adv_data,
|
||||
uint16_t adv_len,
|
||||
uint8_t* scan_rsp_data,
|
||||
uint16_t scan_rsp_len,
|
||||
advertiser_callback_t* cbs)
|
||||
{
|
||||
BpBtAdapter* bpAdapter = ins->adapter_proxy;
|
||||
|
||||
IBtAdvertiserCallbacks* cbks = BtAdvertiserCallbacks_new(cbs);
|
||||
AIBinder* binder = BtAdvertiserCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtAdvertiserCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* rmt_adver = BpBtAdapter_startAdvertising(bpAdapter, params,
|
||||
adv_data, adv_len,
|
||||
scan_rsp_data,
|
||||
scan_rsp_len, binder);
|
||||
AIBinder_decStrong(binder);
|
||||
if (!rmt_adver) {
|
||||
BtAdvertiserCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cbks->cookie = rmt_adver;
|
||||
return (bt_advertiser_t*)cbks;
|
||||
}
|
||||
|
||||
void bt_le_stop_advertising(bt_instance_t* ins, bt_advertiser_t* adver)
|
||||
{
|
||||
BpBtAdapter* bpAdapter = ins->adapter_proxy;
|
||||
IBtAdvertiserCallbacks* cbks = adver;
|
||||
|
||||
BpBtAdapter_stopAdvertising(bpAdapter, cbks->cookie);
|
||||
}
|
||||
|
||||
void bt_le_stop_advertising_id(bt_instance_t* ins, uint8_t adv_id)
|
||||
{
|
||||
BpBtAdapter* bpAdapter = ins->adapter_proxy;
|
||||
|
||||
BpBtAdapter_stopAdvertisingId(bpAdapter, adv_id);
|
||||
}
|
||||
|
||||
bool bt_le_advertising_is_supported(bt_instance_t* ins)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "adv"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "adapter_proxy.h"
|
||||
#include "adapter_stub.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bt_le_scan.h"
|
||||
#include "bt_list.h"
|
||||
#include "scanner_callbacks_stub.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
bt_scanner_t* bt_le_start_scan(bt_instance_t* ins, const scanner_callbacks_t* cbs)
|
||||
{
|
||||
return bt_le_start_scan_settings(ins, NULL, cbs);
|
||||
}
|
||||
|
||||
bt_scanner_t* bt_le_start_scan_settings(bt_instance_t* ins,
|
||||
ble_scan_settings_t* settings,
|
||||
const scanner_callbacks_t* cbs)
|
||||
{
|
||||
BpBtAdapter* bpAdapter = ins->adapter_proxy;
|
||||
void* rmt_scanner = NULL;
|
||||
|
||||
IBtScannerCallbacks* cbks = BtScannerCallbacks_new(cbs);
|
||||
AIBinder* binder = BtScannerCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtScannerCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (settings)
|
||||
rmt_scanner = BpBtAdapter_startScanSettings(bpAdapter, settings, binder);
|
||||
else
|
||||
rmt_scanner = BpBtAdapter_startScan(bpAdapter, binder);
|
||||
|
||||
AIBinder_decStrong(binder);
|
||||
if (!rmt_scanner) {
|
||||
BtScannerCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cbks->cookie = rmt_scanner;
|
||||
return (bt_scanner_t*)cbks;
|
||||
}
|
||||
|
||||
void bt_le_stop_scan(bt_instance_t* ins, bt_scanner_t* scanner)
|
||||
{
|
||||
BpBtAdapter* bpAdapter = ins->adapter_proxy;
|
||||
IBtScannerCallbacks* cbks = scanner;
|
||||
|
||||
BpBtAdapter_stopScan(bpAdapter, cbks->cookie);
|
||||
}
|
||||
|
||||
bool bt_le_scan_is_supported(bt_instance_t* ins)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "pan_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "bt_pan.h"
|
||||
#include "bt_profile.h"
|
||||
|
||||
#include "pan_callbacks_stub.h"
|
||||
#include "pan_proxy.h"
|
||||
#include "pan_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
void* bt_pan_register_callbacks(bt_instance_t* ins, const pan_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtPan* pan = (BpBtPan*)bluetooth_get_proxy(ins, PROFILE_PANU);
|
||||
|
||||
IBtPanCallbacks* cbks = BtPanCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtPanCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtPanCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* remote_cbks = BpBtPan_registerCallback(pan, binder);
|
||||
if (!remote_cbks) {
|
||||
BtPanCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
cbks->cookie = remote_cbks;
|
||||
|
||||
return cbks;
|
||||
}
|
||||
|
||||
bool bt_pan_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
IBtPanCallbacks* cbks = cookie;
|
||||
BpBtPan* pan = (BpBtPan*)bluetooth_get_proxy(ins, PROFILE_PANU);
|
||||
|
||||
bool ret = BpBtPan_unRegisterCallback(pan, cbks->cookie);
|
||||
if (ret)
|
||||
BtPanCallbacks_delete(cbks);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bt_status_t bt_pan_connect(bt_instance_t* ins, bt_address_t* addr, uint8_t dst_role, uint8_t src_role)
|
||||
{
|
||||
BpBtPan* pan = (BpBtPan*)bluetooth_get_proxy(ins, PROFILE_PANU);
|
||||
|
||||
return BpBtPan_connect(pan, addr, dst_role, src_role);
|
||||
}
|
||||
|
||||
bt_status_t bt_pan_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
BpBtPan* pan = (BpBtPan*)bluetooth_get_proxy(ins, PROFILE_PANU);
|
||||
|
||||
return BpBtPan_disconnect(pan, addr);
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "spp_api"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "bt_profile.h"
|
||||
#include "bt_spp.h"
|
||||
|
||||
#include "spp_callbacks_stub.h"
|
||||
#include "spp_proxy.h"
|
||||
#include "spp_stub.h"
|
||||
|
||||
#include "utils/log.h"
|
||||
|
||||
void* bt_spp_register_app(bt_instance_t* ins, const spp_callbacks_t* callbacks)
|
||||
{
|
||||
BpBtSpp* spp = (BpBtSpp*)bluetooth_get_proxy(ins, PROFILE_SPP);
|
||||
|
||||
IBtSppCallbacks* cbks = BtSppCallbacks_new(callbacks);
|
||||
AIBinder* binder = BtSppCallbacks_getBinder(cbks);
|
||||
if (!binder) {
|
||||
BtSppCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* handle = BpBtSpp_registerApp(spp, binder);
|
||||
if (!handle) {
|
||||
BtSppCallbacks_delete(cbks);
|
||||
return NULL;
|
||||
}
|
||||
cbks->cookie = handle;
|
||||
|
||||
return cbks;
|
||||
}
|
||||
|
||||
bt_status_t bt_spp_unregister_app(bt_instance_t* ins, void* handle)
|
||||
{
|
||||
IBtSppCallbacks* cbks = handle;
|
||||
BpBtSpp* spp = (BpBtSpp*)bluetooth_get_proxy(ins, PROFILE_SPP);
|
||||
|
||||
bt_status_t status = BpBtSpp_unRegisterApp(spp, cbks->cookie);
|
||||
if (status == BT_STATUS_SUCCESS)
|
||||
BtSppCallbacks_delete(cbks);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bt_status_t bt_spp_server_start(bt_instance_t* ins, void* handle, uint16_t scn, bt_uuid_t* uuid, uint8_t max_connection)
|
||||
{
|
||||
IBtSppCallbacks* cbks = handle;
|
||||
BpBtSpp* spp = (BpBtSpp*)bluetooth_get_proxy(ins, PROFILE_SPP);
|
||||
|
||||
return BpBtSpp_serverStart(spp, cbks->cookie, scn, uuid, max_connection);
|
||||
}
|
||||
|
||||
bt_status_t bt_spp_server_stop(bt_instance_t* ins, void* handle, uint16_t scn)
|
||||
{
|
||||
IBtSppCallbacks* cbks = handle;
|
||||
BpBtSpp* spp = (BpBtSpp*)bluetooth_get_proxy(ins, PROFILE_SPP);
|
||||
|
||||
return BpBtSpp_serverStop(spp, cbks->cookie, scn);
|
||||
}
|
||||
|
||||
bt_status_t bt_spp_connect(bt_instance_t* ins, void* handle, bt_address_t* addr, int16_t scn, bt_uuid_t* uuid, uint16_t* port)
|
||||
{
|
||||
IBtSppCallbacks* cbks = handle;
|
||||
BpBtSpp* spp = (BpBtSpp*)bluetooth_get_proxy(ins, PROFILE_SPP);
|
||||
|
||||
return BpBtSpp_connect(spp, cbks->cookie, addr, scn, uuid, port);
|
||||
}
|
||||
|
||||
bt_status_t bt_spp_disconnect(bt_instance_t* ins, void* handle, bt_address_t* addr, uint16_t port)
|
||||
{
|
||||
IBtSppCallbacks* cbks = handle;
|
||||
BpBtSpp* spp = (BpBtSpp*)bluetooth_get_proxy(ins, PROFILE_SPP);
|
||||
|
||||
return BpBtSpp_disconnect(spp, cbks->cookie, addr, port);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,230 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bt_addr.h"
|
||||
#include "bt_debug.h"
|
||||
#include "bt_list.h"
|
||||
#include "bt_utils.h"
|
||||
|
||||
#include "advertiser_data.h"
|
||||
|
||||
typedef struct advertiser_data_ {
|
||||
bt_list_t* data;
|
||||
uint8_t* buffer;
|
||||
} advertiser_data_t;
|
||||
|
||||
static void advertiser_data_calc_len(void* data, void* context)
|
||||
{
|
||||
adv_data_t* adata = data;
|
||||
|
||||
*(uint16_t*)context += adata->len + 1;
|
||||
}
|
||||
|
||||
advertiser_data_t* advertiser_data_new(void)
|
||||
{
|
||||
advertiser_data_t* ad = malloc(sizeof(advertiser_data_t));
|
||||
if (!ad)
|
||||
return NULL;
|
||||
|
||||
ad->data = bt_list_new((bt_list_free_cb_t)free);
|
||||
ad->buffer = NULL;
|
||||
|
||||
return ad;
|
||||
}
|
||||
|
||||
void advertiser_data_free(advertiser_data_t* ad)
|
||||
{
|
||||
if (ad->buffer)
|
||||
free(ad->buffer);
|
||||
|
||||
bt_list_free(ad->data);
|
||||
free(ad);
|
||||
}
|
||||
|
||||
uint8_t* advertiser_data_build(advertiser_data_t* ad, uint16_t* len)
|
||||
{
|
||||
uint16_t total_len = 0;
|
||||
bt_list_node_t* node;
|
||||
uint8_t* p;
|
||||
|
||||
if (ad->buffer)
|
||||
free(ad->buffer);
|
||||
|
||||
if (!bt_list_length(ad->data))
|
||||
return NULL;
|
||||
|
||||
bt_list_foreach(ad->data, advertiser_data_calc_len, &total_len);
|
||||
|
||||
*len = total_len;
|
||||
ad->buffer = malloc(total_len);
|
||||
p = ad->buffer;
|
||||
|
||||
for (node = bt_list_head(ad->data); node != NULL;
|
||||
node = bt_list_next(ad->data, node)) {
|
||||
adv_data_t* adata = bt_list_node(node);
|
||||
memcpy(p, adata, adata->len + 1);
|
||||
p += adata->len + 1;
|
||||
}
|
||||
|
||||
return ad->buffer;
|
||||
}
|
||||
|
||||
void advertiser_data_set_name(advertiser_data_t* ad, const char* name)
|
||||
{
|
||||
uint8_t name_len = strlen(name);
|
||||
adv_data_t* data = zalloc(sizeof(adv_data_t) + name_len + 1);
|
||||
|
||||
if (name_len > BT_LE_AD_NAME_LEN) {
|
||||
name_len = BT_LE_AD_NAME_LEN;
|
||||
data->type = BT_AD_NAME_SHORT;
|
||||
} else
|
||||
data->type = BT_AD_NAME_COMPLETE;
|
||||
|
||||
data->len = name_len + 1;
|
||||
memcpy(data->data, name, name_len);
|
||||
|
||||
bt_list_add_tail(ad->data, data);
|
||||
}
|
||||
|
||||
void advertiser_data_set_flags(advertiser_data_t* ad, uint8_t flags)
|
||||
{
|
||||
adv_data_t* data = malloc(sizeof(adv_data_t) + 1);
|
||||
|
||||
data->len = 2;
|
||||
data->type = BT_AD_FLAGS;
|
||||
data->data[0] = flags;
|
||||
|
||||
bt_list_add_tail(ad->data, data);
|
||||
}
|
||||
|
||||
void advertiser_data_set_appearance(advertiser_data_t* ad, uint16_t appearance)
|
||||
{
|
||||
adv_data_t* data = malloc(sizeof(adv_data_t) + 2);
|
||||
uint8_t* p = data->data;
|
||||
|
||||
data->len = 3;
|
||||
data->type = BT_AD_GAP_APPEARANCE;
|
||||
UINT16_TO_STREAM(p, appearance);
|
||||
|
||||
bt_list_add_tail(ad->data, data);
|
||||
}
|
||||
|
||||
void advertiser_data_add_data(advertiser_data_t* ad, uint8_t type, uint8_t* data, uint8_t len)
|
||||
{
|
||||
adv_data_t* adata = malloc(sizeof(adv_data_t) + len);
|
||||
|
||||
adata->type = type;
|
||||
adata->len = len;
|
||||
memcpy(adata->data, data, len);
|
||||
|
||||
bt_list_add_tail(ad->data, adata);
|
||||
}
|
||||
|
||||
void advertiser_data_remove_data(advertiser_data_t* ad, uint8_t type, uint8_t* data, uint8_t len)
|
||||
{
|
||||
}
|
||||
|
||||
void advertiser_data_add_manufacture_data(advertiser_data_t* ad,
|
||||
uint16_t manufacture_id,
|
||||
uint8_t* data, uint8_t length)
|
||||
{
|
||||
adv_data_t* mdata = malloc(sizeof(adv_data_t) + 2 + length);
|
||||
uint8_t* p = mdata->data;
|
||||
|
||||
mdata->len = length + 2 + 1;
|
||||
mdata->type = BT_AD_MANUFACTURER_DATA;
|
||||
UINT16_TO_STREAM(p, manufacture_id);
|
||||
memcpy(p, data, length);
|
||||
|
||||
bt_list_add_tail(ad->data, mdata);
|
||||
}
|
||||
|
||||
bool advertiser_data_add_service_uuid(advertiser_data_t* ad, const bt_uuid_t* uuid)
|
||||
{
|
||||
adv_data_t* data;
|
||||
uint8_t* p;
|
||||
|
||||
switch (uuid->type) {
|
||||
case BT_UUID16_TYPE:
|
||||
data = malloc(sizeof(adv_data_t) + 2);
|
||||
data->len = 2 + 1;
|
||||
data->type = BT_AD_UUID16_ALL;
|
||||
p = data->data;
|
||||
UINT16_TO_STREAM(p, uuid->val.u16);
|
||||
break;
|
||||
case BT_UUID32_TYPE:
|
||||
data = malloc(sizeof(adv_data_t) + 4);
|
||||
data->len = 4 + 1;
|
||||
data->type = BT_AD_UUID32_ALL;
|
||||
p = data->data;
|
||||
UINT32_TO_STREAM(p, uuid->val.u32);
|
||||
case BT_UUID128_TYPE:
|
||||
data = malloc(sizeof(adv_data_t) + 16);
|
||||
data->len = 16 + 1;
|
||||
data->type = BT_AD_UUID128_ALL;
|
||||
memcpy(data->data, uuid->val.u128, 16);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
bt_list_add_tail(ad->data, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool advertiser_data_add_service_data(advertiser_data_t* ad,
|
||||
const bt_uuid_t* uuid,
|
||||
uint8_t* data, uint8_t len)
|
||||
{
|
||||
adv_data_t* sdata;
|
||||
uint8_t* p;
|
||||
|
||||
switch (uuid->type) {
|
||||
case BT_UUID16_TYPE:
|
||||
sdata = malloc(sizeof(adv_data_t) + len + 2);
|
||||
sdata->len = 2 + 1;
|
||||
sdata->type = BT_AD_SERVICE_DATA16;
|
||||
p = sdata->data;
|
||||
UINT16_TO_STREAM(p, uuid->val.u16);
|
||||
break;
|
||||
case BT_UUID32_TYPE:
|
||||
sdata = malloc(sizeof(adv_data_t) + len + 4);
|
||||
sdata->len = 4 + 1;
|
||||
sdata->type = BT_AD_SERVICE_DATA32;
|
||||
p = sdata->data;
|
||||
UINT32_TO_STREAM(p, uuid->val.u32);
|
||||
case BT_UUID128_TYPE:
|
||||
sdata = malloc(sizeof(adv_data_t) + len + 16);
|
||||
sdata->len = 16 + 1;
|
||||
sdata->type = BT_AD_SERVICE_DATA128;
|
||||
memcpy(sdata->data, uuid->val.u128, 16);
|
||||
p = sdata->data + 16;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(p, data, len);
|
||||
sdata->len += len;
|
||||
bt_list_add_tail(ad->data, sdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,215 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2023 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "advertiser_data.h"
|
||||
#include "bt_debug.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t ad_type;
|
||||
const char* desc;
|
||||
} ad_type_desc_t;
|
||||
|
||||
static const ad_type_desc_t ad_type_map[] = {
|
||||
{ BT_AD_FLAGS, "Flags" },
|
||||
{ BT_AD_UUID16_SOME, "Incomplete List of 16bit Service Class UUIDs" },
|
||||
{ BT_AD_UUID16_ALL, "Complete List of 16bit Service Class UUIDs" },
|
||||
{ BT_AD_UUID32_SOME, "Incomplete List of 32bit Service Class UUIDs" },
|
||||
{ BT_AD_UUID32_ALL, "Complete List of 32bit Service Class UUIDs" },
|
||||
{ BT_AD_UUID128_SOME, "Incomplete List of 128bit Service Class UUIDs" },
|
||||
{ BT_AD_UUID128_ALL, "Complete List of 128bit Service Class UUIDs" },
|
||||
{ BT_AD_NAME_SHORT, "Shortened Local Name" },
|
||||
{ BT_AD_NAME_COMPLETE, "Complete Local Name" },
|
||||
{ BT_AD_TX_POWER, "Tx Power Level" },
|
||||
{ BT_AD_CLASS_OF_DEV, "Class of Device" },
|
||||
{ BT_AD_SSP_HASH, "Simple Pairing Hash C192" },
|
||||
{ BT_AD_SSP_RANDOMIZER, "Simple Pairing Randomizer R192" },
|
||||
{ BT_AD_SMP_TK, "Security Manager TK Value" },
|
||||
{ BT_AD_SMP_OOB_FLAGS, "Security Manager Out of Band Flags" },
|
||||
{ BT_AD_PERIPHERAL_CONN_INTERVAL, "Peripheral Connection Interval Range" },
|
||||
{ BT_AD_SOLICIT16, "List of 16bit Service Solicitation UUIDs" },
|
||||
{ BT_AD_SOLICIT128, "List of 128bit Service Solicitation UUIDs" },
|
||||
{ BT_AD_SERVICE_DATA16, "Service Data 16bit UUID" },
|
||||
{ BT_AD_PUBLIC_ADDRESS, "Public Target Address" },
|
||||
{ BT_AD_RANDOM_ADDRESS, "Random Target Address" },
|
||||
{ BT_AD_GAP_APPEARANCE, "Appearance" },
|
||||
{ BT_AD_ADVERTISING_INTERVAL, "Advertising Interval" },
|
||||
{ BT_AD_LE_DEVICE_ADDRESS, "LE Bluetooth Device Address" },
|
||||
{ BT_AD_LE_ROLE, "LE Role" },
|
||||
{ BT_AD_SSP_HASH_P256, "Simple Pairing Hash C256" },
|
||||
{ BT_AD_SSP_RANDOMIZER_P256, "Simple Pairing Randomizer R256" },
|
||||
{ BT_AD_SOLICIT32, "List of 32bit Service Solicitation UUIDs" },
|
||||
{ BT_AD_SERVICE_DATA32, "Service Data 32bit UUID" },
|
||||
{ BT_AD_SERVICE_DATA128, "Service Data 128bit UUID" },
|
||||
{ BT_AD_LE_SC_CONFIRM_VALUE, "LE Secure Connections Confirmation Value" },
|
||||
{ BT_AD_LE_SC_RANDOM_VALUE, "LE Secure Connections Random Value" },
|
||||
{ BT_AD_URI, "URI" },
|
||||
{ BT_AD_INDOOR_POSITIONING, "Indoor Positioning" },
|
||||
{ BT_AD_TRANSPORT_DISCOVERY, "Transport Discovery Data" },
|
||||
{ BT_AD_LE_SUPPORTED_FEATURES, "LE Supported Features" },
|
||||
{ BT_AD_CHANNEL_MAP_UPDATE_IND, "Channel Map Update Indication" },
|
||||
{ BT_AD_MESH_PROV, "PBADV" },
|
||||
{ BT_AD_MESH_DATA, "Mesh Message" },
|
||||
{ BT_AD_MESH_BEACON, "Mesh Beacon" },
|
||||
{ BT_AD_BIG_INFO, "BIGInfo" },
|
||||
{ BT_AD_BROADCAST_CODE, "Broadcast_Code" },
|
||||
{ BT_AD_RESOLVABLE_SET_IDENTIFIER, "Resolvable Set Identifier" },
|
||||
{ BT_AD_ADV_INTERVAL_LONG, "Advertising Interval long" },
|
||||
{ BT_AD_BROADCAST_NAME, "Broadcast_Name" },
|
||||
{ BT_AD_ENCRYPTED_ADV_DATA, "Encrypted Advertising Data" },
|
||||
{ BT_AD_PERIODIC_ADV_RSP_TIMING, "Periodic Advertising Response Timing Information" },
|
||||
{ BT_AD_3D_INFO_DATA, "3D Information Data" },
|
||||
{ BT_AD_MANUFACTURER_DATA, "Manufacturer Specific Data" },
|
||||
};
|
||||
|
||||
static const char* show_ad_type_desc(uint8_t type)
|
||||
{
|
||||
for (int i = 0; i < sizeof(ad_type_map) / sizeof(ad_type_map[0]); i++) {
|
||||
if (ad_type_map[i].ad_type == type)
|
||||
return ad_type_map[i].desc;
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
static void advertiser_data_info(adv_data_t* ad)
|
||||
{
|
||||
if (ad->len < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
syslog(4, "AdvType:(%s)\n", show_ad_type_desc(ad->type));
|
||||
BT_DUMPBUFFER("AdvData:", ad->data, ad->len - 1);
|
||||
|
||||
switch (ad->type) {
|
||||
case BT_AD_FLAGS:
|
||||
break;
|
||||
case BT_AD_UUID16_SOME:
|
||||
break;
|
||||
case BT_AD_UUID16_ALL:
|
||||
break;
|
||||
case BT_AD_UUID32_SOME:
|
||||
break;
|
||||
case BT_AD_UUID32_ALL:
|
||||
break;
|
||||
case BT_AD_UUID128_SOME:
|
||||
break;
|
||||
case BT_AD_UUID128_ALL:
|
||||
break;
|
||||
case BT_AD_NAME_SHORT:
|
||||
break;
|
||||
case BT_AD_NAME_COMPLETE:
|
||||
break;
|
||||
case BT_AD_TX_POWER:
|
||||
break;
|
||||
case BT_AD_CLASS_OF_DEV:
|
||||
break;
|
||||
case BT_AD_SSP_HASH:
|
||||
break;
|
||||
case BT_AD_SSP_RANDOMIZER:
|
||||
break;
|
||||
case BT_AD_SMP_TK:
|
||||
/* if ad->len == 8, ad type is SMP_TK */
|
||||
break;
|
||||
case BT_AD_SMP_OOB_FLAGS:
|
||||
break;
|
||||
case BT_AD_PERIPHERAL_CONN_INTERVAL:
|
||||
break;
|
||||
case BT_AD_SOLICIT16:
|
||||
break;
|
||||
case BT_AD_SOLICIT128:
|
||||
break;
|
||||
case BT_AD_SERVICE_DATA16:
|
||||
break;
|
||||
case BT_AD_PUBLIC_ADDRESS:
|
||||
break;
|
||||
case BT_AD_RANDOM_ADDRESS:
|
||||
break;
|
||||
case BT_AD_GAP_APPEARANCE:
|
||||
break;
|
||||
case BT_AD_ADVERTISING_INTERVAL:
|
||||
break;
|
||||
case BT_AD_LE_DEVICE_ADDRESS:
|
||||
break;
|
||||
case BT_AD_LE_ROLE:
|
||||
break;
|
||||
case BT_AD_SSP_HASH_P256:
|
||||
break;
|
||||
case BT_AD_SSP_RANDOMIZER_P256:
|
||||
break;
|
||||
case BT_AD_SOLICIT32:
|
||||
break;
|
||||
case BT_AD_SERVICE_DATA32:
|
||||
break;
|
||||
case BT_AD_SERVICE_DATA128:
|
||||
break;
|
||||
case BT_AD_LE_SC_CONFIRM_VALUE:
|
||||
break;
|
||||
case BT_AD_LE_SC_RANDOM_VALUE:
|
||||
break;
|
||||
case BT_AD_URI:
|
||||
break;
|
||||
case BT_AD_INDOOR_POSITIONING:
|
||||
break;
|
||||
case BT_AD_TRANSPORT_DISCOVERY:
|
||||
break;
|
||||
case BT_AD_LE_SUPPORTED_FEATURES:
|
||||
break;
|
||||
case BT_AD_CHANNEL_MAP_UPDATE_IND:
|
||||
break;
|
||||
case BT_AD_MESH_PROV:
|
||||
break;
|
||||
case BT_AD_MESH_DATA:
|
||||
break;
|
||||
case BT_AD_MESH_BEACON:
|
||||
break;
|
||||
case BT_AD_BIG_INFO:
|
||||
break;
|
||||
case BT_AD_BROADCAST_CODE:
|
||||
break;
|
||||
case BT_AD_RESOLVABLE_SET_IDENTIFIER:
|
||||
break;
|
||||
case BT_AD_ADV_INTERVAL_LONG:
|
||||
break;
|
||||
case BT_AD_BROADCAST_NAME:
|
||||
break;
|
||||
case BT_AD_ENCRYPTED_ADV_DATA:
|
||||
break;
|
||||
case BT_AD_PERIODIC_ADV_RSP_TIMING:
|
||||
break;
|
||||
case BT_AD_3D_INFO_DATA:
|
||||
break;
|
||||
case BT_AD_MANUFACTURER_DATA:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool advertiser_data_dump(uint8_t* data, uint16_t len, ad_dump_cb_t dump)
|
||||
{
|
||||
uint16_t offset = 0;
|
||||
|
||||
while (offset < len) {
|
||||
adv_data_t* ad = (adv_data_t*)&data[offset];
|
||||
|
||||
advertiser_data_info(ad);
|
||||
offset += ad->len + 1;
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bt_addr.h"
|
||||
|
||||
static const bt_address_t bt_addr_empty = {
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
};
|
||||
|
||||
static char g_bdaddr_str[18];
|
||||
|
||||
static int bachk(const char* str)
|
||||
{
|
||||
if (!str)
|
||||
return -1;
|
||||
|
||||
if (strlen(str) != 17)
|
||||
return -1;
|
||||
|
||||
while (*str) {
|
||||
if (!isxdigit(*str++))
|
||||
return -1;
|
||||
|
||||
if (!isxdigit(*str++))
|
||||
return -1;
|
||||
|
||||
if (*str == 0)
|
||||
break;
|
||||
|
||||
if (*str++ != ':')
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool bt_addr_is_empty(const bt_address_t* addr)
|
||||
{
|
||||
return memcmp(addr->addr, bt_addr_empty.addr, BT_ADDR_LENGTH) == 0;
|
||||
}
|
||||
|
||||
void bt_addr_set_empty(bt_address_t* addr)
|
||||
{
|
||||
assert(addr != NULL);
|
||||
|
||||
memcpy(addr, &bt_addr_empty, sizeof(bt_address_t));
|
||||
}
|
||||
|
||||
int bt_addr_compare(const bt_address_t* a, const bt_address_t* b)
|
||||
{
|
||||
return memcmp(a, b, sizeof(bt_address_t));
|
||||
}
|
||||
|
||||
int bt_addr_ba2str(const bt_address_t* addr, char* str)
|
||||
{
|
||||
return sprintf(str, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
|
||||
addr->addr[5], addr->addr[4], addr->addr[3],
|
||||
addr->addr[2], addr->addr[1], addr->addr[0]);
|
||||
}
|
||||
|
||||
char* bt_addr_bastr(const bt_address_t* addr)
|
||||
{
|
||||
if (!addr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bt_addr_ba2str(addr, g_bdaddr_str);
|
||||
g_bdaddr_str[17] = '\0';
|
||||
|
||||
return g_bdaddr_str;
|
||||
}
|
||||
|
||||
int bt_addr_str2ba(const char* str, bt_address_t* addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (bachk(str) < 0) {
|
||||
memset(addr, 0, sizeof(bt_address_t));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 5; i >= 0; i--, str += 3)
|
||||
addr->addr[i] = strtol(str, NULL, 16);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_addr_set(bt_address_t* addr, const uint8_t* bd)
|
||||
{
|
||||
memcpy(addr->addr, bd, 6);
|
||||
}
|
||||
|
||||
void bt_addr_swap(const bt_address_t* src, bt_address_t* dest)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
dest->addr[5 - i] = src->addr[i];
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2024 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include "bt_hash.h"
|
||||
|
||||
#define HASH4 h = ((h << 5) + h + *key++);
|
||||
|
||||
uint32_t bt_hash4(const void* keyarg, size_t len)
|
||||
{
|
||||
const uint8_t* key = keyarg;
|
||||
uint32_t h = 0;
|
||||
size_t loop;
|
||||
|
||||
if (len > 0) {
|
||||
loop = (len + 8 - 1) >> 3;
|
||||
switch (len & (8 - 1)) {
|
||||
case 0:
|
||||
do {
|
||||
HASH4;
|
||||
case 7:
|
||||
HASH4;
|
||||
case 6:
|
||||
HASH4;
|
||||
case 5:
|
||||
HASH4;
|
||||
case 4:
|
||||
HASH4;
|
||||
case 3:
|
||||
HASH4;
|
||||
case 2:
|
||||
HASH4;
|
||||
case 1:
|
||||
HASH4;
|
||||
} while (--loop);
|
||||
}
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2024 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#ifndef __BT_HASH_H__
|
||||
#define __BT_HASH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
uint32_t bt_hash4(const void* keyarg, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BT_HASH_H__ */
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#ifndef _BT_INTERNAL_H__
|
||||
#define _BT_INTERNAL_H__
|
||||
|
||||
#include "bt_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef BTSYMBOLS
|
||||
#undef BTSYMBOLS
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC
|
||||
#define BTSYMBOLS(s) server_##s
|
||||
#else
|
||||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_CPU_BIT64) // CONFIG_CPU_BIT64
|
||||
#define PTR uint64_t
|
||||
#define PRTx PRIx64
|
||||
#if !defined(INT2PTR)
|
||||
#define INT2PTR(pt) (pt)(uint64_t) // For example, INT2PTR(pt)(int): (int)=>uint64_t=>(pt)/pointer type
|
||||
#endif
|
||||
#if !defined(PTR2INT)
|
||||
#define PTR2INT(it) (it)(uint64_t) // For example, PTR2INT(it)(pointer): (pointer)=>uint64_t=>(it)/int type
|
||||
#endif
|
||||
#else // CONFIG_CPU_BIT32 and others
|
||||
#define PTR uint32_t
|
||||
#define PRTx PRIx32
|
||||
#if !defined(INT2PTR)
|
||||
#define INT2PTR(pt) (pt)(uint32_t) // For example, INT2PTR(pt)(int): (int)=>uint32_t=>(pt)/pointer type
|
||||
#endif
|
||||
#if !defined(PTR2INT)
|
||||
#define PTR2INT(it) (it)(uint32_t) // For example, PTR2INT(it)(pointer): (pointer)=>uint32_t=>(it)/int type
|
||||
#endif
|
||||
#endif // End of else
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BT_INTERNAL_H__ */
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bt_list.h"
|
||||
|
||||
typedef struct _bt_list {
|
||||
struct list_node list;
|
||||
size_t length;
|
||||
bt_list_free_cb_t free_cb;
|
||||
} bt_list_t;
|
||||
|
||||
typedef struct _bt_list_node {
|
||||
struct list_node node;
|
||||
void* data;
|
||||
} bt_list_node_t;
|
||||
|
||||
bt_list_t* bt_list_new(bt_list_free_cb_t cb)
|
||||
{
|
||||
bt_list_t* list = malloc(sizeof(bt_list_t));
|
||||
if (!list)
|
||||
return NULL;
|
||||
|
||||
list->length = 0;
|
||||
list->free_cb = cb;
|
||||
list_initialize(&list->list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void bt_list_free(bt_list_t* list)
|
||||
{
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
bt_list_clear(list);
|
||||
list_delete(&list->list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
void bt_list_clear(bt_list_t* list)
|
||||
{
|
||||
assert(list);
|
||||
struct list_node* node;
|
||||
struct list_node* tmp;
|
||||
|
||||
list_for_every_safe(&list->list, node, tmp)
|
||||
{
|
||||
bt_list_node_t* bt_node = (bt_list_node_t*)node;
|
||||
list_delete(&bt_node->node);
|
||||
if (list->free_cb)
|
||||
list->free_cb(bt_node->data);
|
||||
free(bt_node);
|
||||
list->length--;
|
||||
}
|
||||
}
|
||||
|
||||
bool bt_list_is_empty(bt_list_t* list)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
return list->length == 0;
|
||||
}
|
||||
|
||||
size_t bt_list_length(bt_list_t* list)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
return list->length;
|
||||
}
|
||||
|
||||
bt_list_node_t* bt_list_head(bt_list_t* list)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
return (bt_list_node_t*)list_peek_head(&list->list);
|
||||
}
|
||||
|
||||
bt_list_node_t* bt_list_tail(bt_list_t* list)
|
||||
{
|
||||
assert(list);
|
||||
|
||||
return (bt_list_node_t*)list_peek_tail(&list->list);
|
||||
}
|
||||
|
||||
bt_list_node_t* bt_list_next(bt_list_t* list, bt_list_node_t* bt_node)
|
||||
{
|
||||
assert(list);
|
||||
if (!bt_node)
|
||||
return NULL;
|
||||
|
||||
return (bt_list_node_t*)list_next(&list->list, &bt_node->node);
|
||||
}
|
||||
|
||||
void* bt_list_node(bt_list_node_t* bt_node)
|
||||
{
|
||||
assert(bt_node);
|
||||
if (!bt_node)
|
||||
return NULL;
|
||||
|
||||
return bt_node->data;
|
||||
}
|
||||
|
||||
void bt_list_add_head(bt_list_t* list, void* data)
|
||||
{
|
||||
assert(list);
|
||||
bt_list_node_t* node = malloc(sizeof(bt_list_node_t));
|
||||
assert(node);
|
||||
|
||||
node->data = data;
|
||||
list_add_head(&list->list, &node->node);
|
||||
list->length++;
|
||||
}
|
||||
|
||||
void bt_list_add_tail(bt_list_t* list, void* data)
|
||||
{
|
||||
assert(list);
|
||||
bt_list_node_t* node = malloc(sizeof(bt_list_node_t));
|
||||
assert(node);
|
||||
|
||||
node->data = data;
|
||||
list_add_tail(&list->list, &node->node);
|
||||
list->length++;
|
||||
}
|
||||
|
||||
void bt_list_remove_node(bt_list_t* list, bt_list_node_t* node)
|
||||
{
|
||||
list_delete(&node->node);
|
||||
list->length--;
|
||||
if (list->free_cb)
|
||||
list->free_cb(node->data);
|
||||
free(node);
|
||||
}
|
||||
|
||||
void bt_list_remove(bt_list_t* list, void* data)
|
||||
{
|
||||
assert(list);
|
||||
struct list_node* node;
|
||||
struct list_node* tmp;
|
||||
|
||||
list_for_every_safe(&list->list, node, tmp)
|
||||
{
|
||||
bt_list_node_t* bt_node = (bt_list_node_t*)node;
|
||||
if (bt_node->data == data) {
|
||||
list_delete(&bt_node->node);
|
||||
if (list->free_cb)
|
||||
list->free_cb(bt_node->data);
|
||||
free(bt_node);
|
||||
list->length--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bt_list_move(bt_list_t* src, bt_list_t* dst, void* data, bool move_to_head)
|
||||
{
|
||||
assert(src);
|
||||
assert(dst);
|
||||
struct list_node* node;
|
||||
struct list_node* tmp;
|
||||
|
||||
list_for_every_safe(&src->list, node, tmp)
|
||||
{
|
||||
bt_list_node_t* bt_node = (bt_list_node_t*)node;
|
||||
if (bt_node->data != data)
|
||||
continue;
|
||||
|
||||
list_delete(&bt_node->node);
|
||||
src->length--;
|
||||
|
||||
if (move_to_head) {
|
||||
list_add_head(&dst->list, &bt_node->node);
|
||||
} else {
|
||||
list_add_tail(&dst->list, &bt_node->node);
|
||||
}
|
||||
dst->length++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void bt_list_foreach(bt_list_t* list, bt_list_iter_cb cb, void* context)
|
||||
{
|
||||
assert(list);
|
||||
struct list_node* node;
|
||||
struct list_node* tmp;
|
||||
|
||||
list_for_every_safe(&list->list, node, tmp)
|
||||
{
|
||||
bt_list_node_t* bt_node = (bt_list_node_t*)node;
|
||||
cb(bt_node->data, context);
|
||||
}
|
||||
}
|
||||
|
||||
void* bt_list_find(bt_list_t* list, bt_list_find_cb cb, void* context)
|
||||
{
|
||||
assert(list);
|
||||
struct list_node* node;
|
||||
struct list_node* tmp;
|
||||
|
||||
list_for_every_safe(&list->list, node, tmp)
|
||||
{
|
||||
bt_list_node_t* bt_node = (bt_list_node_t*)node;
|
||||
if (cb(bt_node->data, context))
|
||||
return bt_node->data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2022 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <stdint.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "bt_time.h"
|
||||
|
||||
uint64_t bt_get_os_timestamp_us(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_BOOTTIME, &ts);
|
||||
|
||||
return (uint64_t)(((uint64_t)ts.tv_sec * 1000000L) + ((uint64_t)ts.tv_nsec / 1000));
|
||||
}
|
||||
|
||||
uint32_t bt_get_os_timestamp_ms(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_BOOTTIME, &ts);
|
||||
|
||||
return (uint32_t)((ts.tv_sec * 1000) + (ts.tv_nsec / 1000000UL));
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/****************************************************************************
|
||||
* Copyright (C) 2024 Xiaomi Corporation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __BT_LOG_API_H__
|
||||
#define __BT_LOG_API_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "bluetooth.h"
|
||||
|
||||
#ifndef BTSYMBOLS
|
||||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTSNOOP_FILTER_A2DP_AUDIO,
|
||||
BTSNOOP_FILTER_AVCTP_BROWSING,
|
||||
BTSNOOP_FILTER_ATT,
|
||||
BTSNOOP_FILTER_SPP,
|
||||
BTSNOOP_FILTER_NOCP,
|
||||
BTSNOOP_FILTER_MAX,
|
||||
BTSNOOP_FILTER_UNFILTER,
|
||||
} btsnoop_filter_flag_t;
|
||||
|
||||
/**
|
||||
* @brief Enable bluetooth btsnoop log
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
*/
|
||||
void BTSYMBOLS(bluetooth_enable_btsnoop_log)(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
* @brief Disable bluetooth btsnoop log
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
*/
|
||||
void BTSYMBOLS(bluetooth_disable_btsnoop_log)(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
* @brief Set a filter flag in the btsnoop log
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param filter_flag - the flag bit for filtering specified data in the btsnoop log.
|
||||
*/
|
||||
void BTSYMBOLS(bluetooth_set_btsnoop_filter)(bt_instance_t* ins, btsnoop_filter_flag_t filter_flag);
|
||||
|
||||
/**
|
||||
* @brief Remove a filter flag in the btsnoop log
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param filter_flag - the flag bit for filtering specified data in the btsnoop log.
|
||||
*/
|
||||
void BTSYMBOLS(bluetooth_remove_btsnoop_filter)(bt_instance_t* ins, btsnoop_filter_flag_t filter_flag);
|
||||
|
||||
// async
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
#include "bt_async.h"
|
||||
|
||||
bt_status_t bluetooth_enable_btsnoop_log_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bluetooth_disable_btsnoop_log_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bluetooth_set_btsnoop_filter_async(bt_instance_t* ins, btsnoop_filter_flag_t filter_flag,
|
||||
bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bluetooth_remove_btsnoop_filter_async(bt_instance_t* ins, btsnoop_filter_flag_t filter_flag,
|
||||
bt_status_cb_t cb, void* userdata);
|
||||
#endif // CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* __BT_LOG_API_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue