Compare commits
393 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
6425e8be56 | |
|
|
676d098658 | |
|
|
0cf1898d83 | |
|
|
eeadab36e1 | |
|
|
9e14509c31 | |
|
|
f3f6b7f8f9 | |
|
|
c7750b15d5 | |
|
|
bad412afbc | |
|
|
e832f79c93 | |
|
|
e6cb78e55a | |
|
|
50c45b2fa0 | |
|
|
166492cf4c | |
|
|
c7f1136d36 | |
|
|
ba33b35581 | |
|
|
ad8d3c3e1c | |
|
|
7a7bec624e | |
|
|
5c129c4322 | |
|
|
559d730ee2 | |
|
|
f35a3353d8 | |
|
|
fa468a7dfd | |
|
|
53af42b246 | |
|
|
b785295a2d | |
|
|
2f97944915 | |
|
|
1bf95d3005 | |
|
|
6c4dc95334 | |
|
|
fb03f0bbc5 | |
|
|
bf3e459d0b | |
|
|
5845d97591 | |
|
|
6757503ea8 | |
|
|
1a471d24a0 | |
|
|
b378e460b7 | |
|
|
435a4f37b6 | |
|
|
055fbbb9ea | |
|
|
88cab691fd | |
|
|
406593e3ac | |
|
|
554f74f7b3 | |
|
|
ea27e37547 | |
|
|
8769dc695a | |
|
|
e321fa7f5c | |
|
|
f1c0794060 | |
|
|
83d3c9933c | |
|
|
df46a78b4e | |
|
|
c052138352 | |
|
|
24f3458801 | |
|
|
a757639402 | |
|
|
54aca2b7d4 | |
|
|
caf260a82f | |
|
|
738422724c | |
|
|
7450ea80b6 | |
|
|
962f40c78c | |
|
|
b2356d6bda | |
|
|
71d247e024 | |
|
|
ebefa1d6d4 | |
|
|
c612690595 | |
|
|
e12d033afb | |
|
|
a559753d1d | |
|
|
9e3c953bcf | |
|
|
ca9dec36f2 | |
|
|
0c4d32d4d4 | |
|
|
832a9608be | |
|
|
bc366f3585 | |
|
|
eb2f3910fd | |
|
|
5eb5c62f05 | |
|
|
1dfea5724b | |
|
|
d44b35611f | |
|
|
9ec5776fd1 | |
|
|
d6690aeb93 | |
|
|
a913c6a857 | |
|
|
5ee890cc21 | |
|
|
215e4f1e11 | |
|
|
d39fc0f95e | |
|
|
2fc72d34b7 | |
|
|
3222cb0948 | |
|
|
7d5503bc92 | |
|
|
24f2be16ee | |
|
|
a1ed5e657f | |
|
|
e27c2a1cd5 | |
|
|
f02f33bafa | |
|
|
d12f79ab8c | |
|
|
d9e407836e | |
|
|
90020e899a | |
|
|
a8fa3ba64d | |
|
|
c0eb262b37 | |
|
|
1787ea002f | |
|
|
2c19cbfb56 | |
|
|
388154f714 | |
|
|
ac8d14a313 | |
|
|
9d9ab69e5d | |
|
|
8eac5afb0f | |
|
|
48293bb53b | |
|
|
9c75d61ad0 | |
|
|
ee66b60638 | |
|
|
9ae7450c1f | |
|
|
25897a5b40 | |
|
|
a3eac431b9 | |
|
|
f43a1bf044 | |
|
|
fa7f730f7e | |
|
|
b39cadca8e | |
|
|
5c526deff8 | |
|
|
7133dbf0f4 | |
|
|
a50d87978f | |
|
|
a510c37783 | |
|
|
9ac5a39952 | |
|
|
2cad6e44d1 | |
|
|
0e72579851 | |
|
|
4ddf4c0ef8 | |
|
|
2f7c5b8421 | |
|
|
a446d6ecd0 | |
|
|
21d4eadaaa | |
|
|
7ecb00b734 | |
|
|
17f572ca9a | |
|
|
84b7960406 | |
|
|
95dd38bafb | |
|
|
8aa53e32d4 | |
|
|
30f781f87f | |
|
|
55d8088676 | |
|
|
9c4b086364 | |
|
|
a504715438 | |
|
|
daf31822d8 | |
|
|
3adeaad48a | |
|
|
e1d922be22 | |
|
|
d34e8575aa | |
|
|
4762d1271d | |
|
|
c92cb9a9ee | |
|
|
e1caf81f4a | |
|
|
10190d8dcb | |
|
|
e2927efd8d | |
|
|
8b92f2d7c7 | |
|
|
82c0b955c1 | |
|
|
ab4b02cdb8 | |
|
|
e044c99d57 | |
|
|
3cca36d333 | |
|
|
d0c5c186c5 | |
|
|
4417269939 | |
|
|
11d442c427 | |
|
|
172157bb6f | |
|
|
9131229035 | |
|
|
1309b694c3 | |
|
|
983df76378 | |
|
|
301df447c1 | |
|
|
8e1229fcc7 | |
|
|
87d95cab3f | |
|
|
00b3834856 | |
|
|
e7c3ecd6f8 | |
|
|
dd23ac80a0 | |
|
|
73ae55888b | |
|
|
14a279fffb | |
|
|
a73a956ad7 | |
|
|
4bb23325a9 | |
|
|
35cfc2567f | |
|
|
0531683e09 | |
|
|
3f3c1b4508 | |
|
|
ac4a0d5539 | |
|
|
870b84e37a | |
|
|
1dda88727b | |
|
|
ad6a003495 | |
|
|
97d8fb5725 | |
|
|
b6a731a7a9 | |
|
|
164d3217db | |
|
|
28b761df29 | |
|
|
36ec7b30dd | |
|
|
6bba45387b | |
|
|
cb5b0435cd | |
|
|
a61eb2c3d9 | |
|
|
cdd6946ebe | |
|
|
5a3c6dfbfe | |
|
|
2bf1af3792 | |
|
|
d2c8360dbf | |
|
|
a31abe3104 | |
|
|
b7326a8755 | |
|
|
6c35b08788 | |
|
|
b5d58b7ea2 | |
|
|
599dae9ef7 | |
|
|
6ca0e6c7ca | |
|
|
fe10ebb341 | |
|
|
5e83175f35 | |
|
|
3e90658fc9 | |
|
|
ffd449d59e | |
|
|
a79cd61c07 | |
|
|
498bbed959 | |
|
|
3c0bad6980 | |
|
|
73db978918 | |
|
|
ed0d7cb859 | |
|
|
2244e388f7 | |
|
|
ca68358f90 | |
|
|
257b1d3593 | |
|
|
9f1317ecb0 | |
|
|
4d524866b1 | |
|
|
a8e63f3c35 | |
|
|
304d0656c3 | |
|
|
d7a276c5a7 | |
|
|
aaa760ea87 | |
|
|
04c18ed137 | |
|
|
ff6ce1b422 | |
|
|
c9ec25e045 | |
|
|
123ade9b66 | |
|
|
04d1af18ce | |
|
|
fea685e8d6 | |
|
|
2e7c5c3fda | |
|
|
e3da0a99f5 | |
|
|
5d4b187141 | |
|
|
303c98578c | |
|
|
e2a23e44c7 | |
|
|
b4222022ac | |
|
|
f42d03e00f | |
|
|
c6f31b57a0 | |
|
|
2dd9ac98b6 | |
|
|
ffe9428e8f | |
|
|
7ace20ddc8 | |
|
|
ba5b1c1352 | |
|
|
159eff88a4 | |
|
|
3b3ba992a1 | |
|
|
c50da340d1 | |
|
|
52b2cb501e | |
|
|
e081bbe098 | |
|
|
de09e4746d | |
|
|
e6f54d41ff | |
|
|
6af7d7d3d9 | |
|
|
eefd90a60e | |
|
|
dade9fde52 | |
|
|
a477d6fded | |
|
|
ad2a07f91a | |
|
|
28330f9382 | |
|
|
95ff44b12e | |
|
|
47c1ca9843 | |
|
|
1621b8217c | |
|
|
b27697c417 | |
|
|
095d21ddab | |
|
|
056ab86475 | |
|
|
c53c14c11f | |
|
|
cc07bcc9c3 | |
|
|
ccff2e2c35 | |
|
|
cbe2678d88 | |
|
|
108f885a0a | |
|
|
5b6e5033b7 | |
|
|
86754d17f1 | |
|
|
02afee005d | |
|
|
93c50cc7a5 | |
|
|
0b006b78d9 | |
|
|
3a7363adc6 | |
|
|
81de22d52d | |
|
|
edd9d7e1fb | |
|
|
fd0296b569 | |
|
|
c41b6e15b1 | |
|
|
fa39a980aa | |
|
|
581948c330 | |
|
|
f43330c59e | |
|
|
57140e2137 | |
|
|
eecfd090fe | |
|
|
4c5e7c5760 | |
|
|
524df6bb31 | |
|
|
438c0032b7 | |
|
|
c56f5b4f4b | |
|
|
27cc4374e5 | |
|
|
842e267a37 | |
|
|
781c999c91 | |
|
|
8018850f6e | |
|
|
7baa3e9add | |
|
|
f7d0f931c4 | |
|
|
5a97fc75c1 | |
|
|
c6ba6fab4f | |
|
|
699fcfa34e | |
|
|
bd50fdb0ae | |
|
|
3b18b7cb8a | |
|
|
43b6f0e791 | |
|
|
c7d042e371 | |
|
|
7684233bf1 | |
|
|
76e949e897 | |
|
|
415be99036 | |
|
|
2d71371901 | |
|
|
0aa1d74548 | |
|
|
e0699b4797 | |
|
|
de8ef06fc8 | |
|
|
158d5f8e10 | |
|
|
199fdff9d6 | |
|
|
d6bd202002 | |
|
|
3e328ff2f5 | |
|
|
616c09ec15 | |
|
|
7414987dde | |
|
|
e18cc309fd | |
|
|
5ee1c6944a | |
|
|
1aa0a59c97 | |
|
|
e52b434172 | |
|
|
6ab8107575 | |
|
|
8a49db6e78 | |
|
|
b8c7fb4e23 | |
|
|
e499823b31 | |
|
|
ded2d655b1 | |
|
|
a737850e1f | |
|
|
54f9f99502 | |
|
|
7d2627e6f6 | |
|
|
35619721a7 | |
|
|
9d7ddc49be | |
|
|
89d1a7df7a | |
|
|
cb99b4546c | |
|
|
adc08df0a4 | |
|
|
cd756e4cee | |
|
|
16abe9046b | |
|
|
a3cc0bd160 | |
|
|
dd8a0ef9f1 | |
|
|
21458c91ca | |
|
|
a99ae73163 | |
|
|
e1f34acea6 | |
|
|
43429d82f2 | |
|
|
ac28491a2d | |
|
|
bb96c36bb5 | |
|
|
79655b85f6 | |
|
|
2bec299b07 | |
|
|
c94519872b | |
|
|
66ec689200 | |
|
|
05e1bfef50 | |
|
|
8d456a5218 | |
|
|
ace0535474 | |
|
|
748ea54904 | |
|
|
578e895451 | |
|
|
26a70f7af7 | |
|
|
d79629bfa4 | |
|
|
9d6193def5 | |
|
|
fba5f48fab | |
|
|
6cbbcb8ad1 | |
|
|
12124f78a0 | |
|
|
7bfcb74aa8 | |
|
|
914526bf60 | |
|
|
e781787517 | |
|
|
7fcbecc5cd | |
|
|
beebf57a97 | |
|
|
c4b13fe7b2 | |
|
|
b6d9041078 | |
|
|
9dd20370bb | |
|
|
4aa506e324 | |
|
|
ae12a3458a | |
|
|
d78e6be873 | |
|
|
860e6357d9 | |
|
|
5b807f088c | |
|
|
540d46499d | |
|
|
92594c2d26 | |
|
|
d91362fd92 | |
|
|
da1fa9aea1 | |
|
|
af0bdfa8ac | |
|
|
d9cecb6987 | |
|
|
981570db50 | |
|
|
11c269d7d0 | |
|
|
d61b5cf1be | |
|
|
f376350309 | |
|
|
62216a72f8 | |
|
|
3401f08950 | |
|
|
aea5f40624 | |
|
|
76014539ec | |
|
|
8e80c727a1 | |
|
|
d3b95f21f1 | |
|
|
75f0368648 | |
|
|
0d5604befa | |
|
|
0f09cd64e9 | |
|
|
3345c269cc | |
|
|
29e21f884e | |
|
|
8fbb699c66 | |
|
|
eb4d0a3ce3 | |
|
|
1838bc72e8 | |
|
|
3d0232691d | |
|
|
44a24c0a70 | |
|
|
a04c9f1196 | |
|
|
3b5e43eee4 | |
|
|
60072ab342 | |
|
|
5c99058bde | |
|
|
762c46bf83 | |
|
|
b235c0ca05 | |
|
|
34cd324193 | |
|
|
81057dee1c | |
|
|
4e284fe9d2 | |
|
|
3b0e6f4ac7 | |
|
|
ff11a44813 | |
|
|
b89fa88010 | |
|
|
b05d6fe309 | |
|
|
f49afa51e0 | |
|
|
9e5bffd7b3 | |
|
|
8f6491a581 | |
|
|
f7c8884982 | |
|
|
fe21f0767d | |
|
|
fa87d5daf5 | |
|
|
5f6acaf3f5 | |
|
|
805e59c285 | |
|
|
699424e0f6 | |
|
|
9a1a00a441 | |
|
|
636900a3ae | |
|
|
4a10c15312 | |
|
|
314c68e58c | |
|
|
56dcc1df6d | |
|
|
4f9a03d009 | |
|
|
c22ed32a0a | |
|
|
dc040bcd2b | |
|
|
e5ef25c8d5 | |
|
|
a6ab66c905 | |
|
|
9d0c825cbb |
|
|
@ -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,16 @@
|
|||
# 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]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
# 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
|
||||
|
||||
11
Android.bp
11
Android.bp
|
|
@ -7,7 +7,6 @@ bootstrap_go_package {
|
|||
],
|
||||
srcs: [
|
||||
"frameworkBluetooth.go",
|
||||
"frameworkBluetoothBin.go",
|
||||
],
|
||||
pluginFor: ["soong_build"],
|
||||
}
|
||||
|
|
@ -23,7 +22,6 @@ frameworkBluetooth_cc_library {
|
|||
"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",
|
||||
|
|
@ -33,7 +31,6 @@ frameworkBluetooth_cc_library {
|
|||
"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",
|
||||
],
|
||||
|
|
@ -76,13 +73,9 @@ frameworkBluetooth_cc_library {
|
|||
"//apex_available:platform",
|
||||
"com.android.btservices",
|
||||
],
|
||||
|
||||
header_libs: [
|
||||
"kernel_modules_headers_apex",
|
||||
],
|
||||
}
|
||||
|
||||
frameworkBluetooth_cc_binary {
|
||||
cc_binary {
|
||||
name : "bttool",
|
||||
|
||||
srcs : [
|
||||
|
|
@ -96,7 +89,6 @@ frameworkBluetooth_cc_binary {
|
|||
"tools/hfp_ag.c",
|
||||
"tools/hfp_hf.c",
|
||||
"tools/hid_device.c",
|
||||
"tools/l2cap.c",
|
||||
"tools/spp.c",
|
||||
"tools/log.c",
|
||||
"tools/utils.c",
|
||||
|
|
@ -110,7 +102,6 @@ frameworkBluetooth_cc_binary {
|
|||
local_include_dirs : [
|
||||
"framework/include",
|
||||
"service",
|
||||
"service/common",
|
||||
"service/utils",
|
||||
],
|
||||
|
||||
|
|
|
|||
160
CMakeLists.txt
160
CMakeLists.txt
|
|
@ -35,6 +35,10 @@ if(CONFIG_BLUETOOTH)
|
|||
${BLUETOOTH_DIR}/framework/api/bt_adapter.c
|
||||
${BLUETOOTH_DIR}/framework/api/bt_device.c)
|
||||
|
||||
if(CONFIG_BLUETOOTH_LE_CS)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_cs.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_A2DP_SINK)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_a2dp_sink.c)
|
||||
endif()
|
||||
|
|
@ -190,6 +194,11 @@ if(CONFIG_BLUETOOTH)
|
|||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_log.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_LE_CS)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_cs.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_cs.c)
|
||||
endif()
|
||||
|
||||
list(APPEND INCDIR ${BLUETOOTH_DIR}/service/ipc/socket/include)
|
||||
|
||||
if (CONFIG_BLUETOOTH_FRAMEWORK_ASYNC)
|
||||
|
|
@ -211,7 +220,7 @@ if(CONFIG_BLUETOOTH)
|
|||
if(CONFIG_BLUETOOTH_STORAGE_PROPERTY_SUPPORT)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/common/storage_property.c)
|
||||
else()
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/common/bt_storage.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/common/storage.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_STORAGE_UPDATE)
|
||||
|
|
@ -281,10 +290,6 @@ if(CONFIG_BLUETOOTH)
|
|||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_adapter_interface.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_connection_manager.c)
|
||||
|
||||
if(CONFIG_BLUETOOTH_SPP)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_spp_interface.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_A2DP)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_a2dp_interface.c)
|
||||
endif()
|
||||
|
|
@ -293,10 +298,6 @@ if(CONFIG_BLUETOOTH)
|
|||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_avrcp_interface.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_HID_DEVICE)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_hid_device_interface.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_HFP_HF)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_hfp_hf_interface.c)
|
||||
endif()
|
||||
|
|
@ -305,6 +306,14 @@ if(CONFIG_BLUETOOTH)
|
|||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_hfp_ag_interface.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_SPP)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_spp_interface.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_HID_DEVICE)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_hid_device_stub.c)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_STACK_LE_ZBLUE)
|
||||
|
|
@ -325,6 +334,10 @@ if(CONFIG_BLUETOOTH)
|
|||
if(CONFIG_BLUETOOTH_GATT_SERVER)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_gatt_server_interface.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_LE_CS)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_le_cs_interface.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_BLUETOOTH_BLE_AUDIO)
|
||||
|
|
@ -351,16 +364,17 @@ if(CONFIG_BLUETOOTH)
|
|||
list(REMOVE_ITEM CSRCS
|
||||
${BLUETOOTH_DIR}/service/profiles/system/media_system.c)
|
||||
else()
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/audio_interface/audio_control.c)
|
||||
if(CONFIG_AUDIOUTILS_TINYCOMPRESS)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/audio_interface/audio_transport.c)
|
||||
list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/audio_interface/include)
|
||||
endif()
|
||||
file(GLOB APPEND_FILES
|
||||
${BLUETOOTH_DIR}/service/profiles/audio_interface/*.c)
|
||||
list(APPEND CSRCS ${APPEND_FILES})
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_GATT_CLIENT)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/gatt/gattc_event.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/gatt/gattc_service.c)
|
||||
if(CONFIG_BLUETOOTH_GATT_CLIENT_DEBUG)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/gatt/gattc_debug.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_GATT_SERVER)
|
||||
|
|
@ -415,12 +429,6 @@ if(CONFIG_BLUETOOTH)
|
|||
|
||||
if(CONFIG_BLUETOOTH_HFP_AG)
|
||||
file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/hfp_ag/*.c)
|
||||
if(CONFIG_PHONE_SERVICE)
|
||||
list(REMOVE_ITEM APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/system/telephony_interface.c)
|
||||
list(REMOVE_ITEM APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/hfp_ag/hfp_ag_tele_service.c)
|
||||
else()
|
||||
list(REMOVE_ITEM APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/hfp_ag/hfp_ag_tele_phone_service.c)
|
||||
endif()
|
||||
list(APPEND CSRCS ${APPEND_FILES})
|
||||
endif()
|
||||
|
||||
|
|
@ -503,6 +511,12 @@ if(CONFIG_BLUETOOTH)
|
|||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/utils/btsnoop_filter.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_LE_CS)
|
||||
file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/cs/*.c)
|
||||
list(APPEND CSRCS ${APPEND_FILES})
|
||||
list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/cs)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_HCI_FILTER)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/service/vhal/bt_hci_filter.c)
|
||||
endif()
|
||||
|
|
@ -519,23 +533,23 @@ if(CONFIG_BLUETOOTH)
|
|||
|
||||
if(CONFIG_APP_BT_SAMPLE_CODE)
|
||||
if(CONFIG_APP_BT_SAMPLE_CODE_BASIC)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/basic/app_bt_gap.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/basic/*.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BT_SAMPLE_CODE_ENABLE)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/enable/app_bt_gap.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/enable/*.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/discovery/app_bt_gap.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/discovery/*.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/createbond/app_bt_gap.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/createbond/*.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/acceptbond/app_bt_gap.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/acceptbond/*.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
@ -567,10 +581,6 @@ if(CONFIG_BLUETOOTH)
|
|||
list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/scan.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_L2CAP)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/l2cap.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_A2DP_SINK)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/a2dp_sink.c)
|
||||
endif()
|
||||
|
|
@ -601,10 +611,7 @@ if(CONFIG_BLUETOOTH)
|
|||
|
||||
if(CONFIG_BLUETOOTH_LOG)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/log.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_DEBUG_TRACE)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/debug/bt_trace.c)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/debug/bt_trace.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_SPP)
|
||||
|
|
@ -654,9 +661,14 @@ if(CONFIG_BLUETOOTH)
|
|||
if(CONFIG_BLUETOOTH_STORAGE_UPDATE)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/storage_update/storage_tool.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_LE_CS)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/le_cs.c)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND INCDIR ${BLUETOOTH_DIR}/framework/include)
|
||||
list(APPEND INCDIR ${BLUETOOTH_DIR}/framework/common)
|
||||
|
||||
if(CONFIG_LIB_DBUS_RPMSG_SERVER_CPUNAME OR CONFIG_OFONO)
|
||||
list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/dbus/dbus)
|
||||
|
|
@ -703,10 +715,7 @@ if(CONFIG_BLUETOOTH)
|
|||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE OR CONFIG_BLUETOOTH_STACK_LE_ZBLUE)
|
||||
list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/zblue/zblue/port/include/)
|
||||
list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/zblue/zblue/subsys/settings/include/settings)
|
||||
list(APPEND INCDIR
|
||||
${NUTTX_APPS_DIR}/external/zblue/zblue/port/include/kernel/include)
|
||||
nuttx_add_dependencies(TARGET libbluetooth DEPENDS zblue)
|
||||
endif()
|
||||
|
||||
list(APPEND INCDIR ${BLUETOOTH_DIR}/service/ipc)
|
||||
|
|
@ -798,7 +807,7 @@ if(CONFIG_BLUETOOTH)
|
|||
INCLUDE_DIRECTORIES
|
||||
${INCDIR}
|
||||
STACKSIZE
|
||||
4096
|
||||
8192
|
||||
PRIORITY
|
||||
${SCHED_PRIORITY_DEFAULT}
|
||||
COMPILE_FLAGS
|
||||
|
|
@ -896,6 +905,24 @@ if(CONFIG_BLUETOOTH)
|
|||
libbluetooth)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_UPGRADE)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
bt_upgrade
|
||||
SRCS
|
||||
${BLUETOOTH_DIR}/tools/storage_transform.c
|
||||
INCLUDE_DIRECTORIES
|
||||
${INCDIR}
|
||||
STACKSIZE
|
||||
8192
|
||||
PRIORITY
|
||||
${SCHED_PRIORITY_DEFAULT}
|
||||
COMPILE_FLAGS
|
||||
${CFLAGS}
|
||||
DEPENDS
|
||||
libbluetooth)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_STORAGE_UPDATE)
|
||||
nuttx_add_application(
|
||||
NAME
|
||||
|
|
@ -922,23 +949,21 @@ if(CONFIG_BLUETOOTH)
|
|||
|
||||
target_include_directories(libbluetooth PRIVATE ${CMAKE_CURRENT_LIST_DIR}/feature/include)
|
||||
|
||||
set(JIDL_PATHS ${BLUETOOTH_DIR}/feature/jidl/bluetooth.jidl
|
||||
${BLUETOOTH_DIR}/feature/jidl/bluetooth_bt.jidl)
|
||||
set(JIDL_OUT_NAMES system_bluetooth system_bluetooth_bt)
|
||||
set(JIDL_PATHS ${BLUETOOTH_DIR}/feature/jdil/bluetooth.jidl
|
||||
${BLUETOOTH_DIR}/feature/jdil/bluetooth_bt.jidl)
|
||||
|
||||
set(FEATURE_NAMES system_bluetooth system_bluetooth_bt)
|
||||
|
||||
if(CONFIG_BLUETOOTH_A2DP_SINK)
|
||||
list(APPEND FEATURE_SRCS ${BLUETOOTH_DIR}/feature/src/system_bluetooth_bt_a2dpsink_impl.c)
|
||||
list(APPEND JIDL_PATHS ${BLUETOOTH_DIR}/feature/jidl/bluetooth_bt_a2dpsink.jidl)
|
||||
list(APPEND FEATURE_NAMES system_bluetooth_bt_a2dpsink)
|
||||
list(APPEND JIDL_OUT_NAMES system_bluetooth_bt_a2dpsink)
|
||||
list(APPEND FEATURE_SRCS ${BLUETOOTH_DIR}/feature/src/system_bluetooth_a2dpsink_impl.c)
|
||||
list(APPEND JIDL_PATHS ${BLUETOOTH_DIR}/feature/jdil/bluetooth_a2dpsink.jidl)
|
||||
list(APPEND FEATURE_NAMES system_bluetooth_a2dpsink)
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_AVRCP_CONTROL)
|
||||
list(APPEND FEATURE_SRCS ${BLUETOOTH_DIR}/feature/src/system_bluetooth_bt_avrcpcontrol_impl.c)
|
||||
list(APPEND JIDL_PATHS ${BLUETOOTH_DIR}/feature/jidl/bluetooth_bt_avrcpcontrol.jidl)
|
||||
list(APPEND FEATURE_NAMES system_bluetooth_bt_avrcpcontrol)
|
||||
list(APPEND JIDL_OUT_NAMES system_bluetooth_bt_avrcpcontrol)
|
||||
list(APPEND FEATURE_SRCS ${BLUETOOTH_DIR}/feature/src/system_bluetooth_avrcpcontrol_impl.c)
|
||||
list(APPEND JIDL_PATHS ${BLUETOOTH_DIR}/feature/jdil/bluetooth_avrcpcontrol.jidl)
|
||||
list(APPEND FEATURE_NAMES system_bluetooth_avrcpcontrol)
|
||||
endif()
|
||||
|
||||
nuttx_add_jidl(
|
||||
|
|
@ -950,51 +975,31 @@ if(CONFIG_BLUETOOTH)
|
|||
${JIDL_PATHS}
|
||||
FEATURE_NAMES
|
||||
${FEATURE_NAMES}
|
||||
JIDL_OUT_NAMES
|
||||
${JIDL_OUT_NAMES}
|
||||
OUT_SRC_EXT
|
||||
c)
|
||||
elseif(CONFIG_BLUETOOTH_FEATURE_ASYNC)
|
||||
set(ASYNC_FEATURE_SRCS ${BLUETOOTH_DIR}/feature/feature_async/src/bluetooth_impl.c
|
||||
${BLUETOOTH_DIR}/feature/feature_async/src/feature_bluetooth_util.c
|
||||
${BLUETOOTH_DIR}/feature/feature_async/src/bluetooth_ble_impl.c)
|
||||
|
||||
target_include_directories(libbluetooth PRIVATE ${CMAKE_CURRENT_LIST_DIR}/feature/feature_async/include)
|
||||
|
||||
set(ASYNC_FEATURE_NAMES system_bluetooth system_bluetooth_ble)
|
||||
|
||||
include(nuttx_add_jidl)
|
||||
set(PY_SCRIPT ${FEATURE_TOP}/tools/jidl/jsongensource.py)
|
||||
set(BINARY_EXT_MODULES_DIR ${CMAKE_BINARY_DIR}/feature/modules/)
|
||||
set(JIDL_PATHS ${BLUETOOTH_DIR}/feature/feature_async/jidl/bluetooth.jidl)
|
||||
|
||||
list(APPEND JIDL_PATHS
|
||||
${BLUETOOTH_DIR}/feature/feature_async/jidl/bluetooth_ble.jidl)
|
||||
|
||||
if(CONFIG_BLUETOOTH_GATT)
|
||||
list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/btwrap/async/bt_gatt_feature.c)
|
||||
endif()
|
||||
|
||||
nuttx_add_jidl(
|
||||
TARGET
|
||||
libbluetooth
|
||||
FEATURE_SRCS
|
||||
${ASYNC_FEATURE_SRCS}
|
||||
JIDL_SCRIPT
|
||||
${PY_SCRIPT}
|
||||
JIDL_OUT_DIR
|
||||
${BINARY_EXT_MODULES_DIR}
|
||||
JIDLS
|
||||
${JIDL_PATHS}
|
||||
FEATURE_NAMES
|
||||
${ASYNC_FEATURE_NAMES}
|
||||
OUT_SRC_EXT
|
||||
c)
|
||||
else()
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLUETOOTH_DFX)
|
||||
set(XML_PATHS ${BLUETOOTH_DIR}/dfx/event_bt.xml)
|
||||
nuttx_add_dfx_event(
|
||||
TARGET
|
||||
dfx_bt
|
||||
XML_PATHS
|
||||
${XML_PATHS})
|
||||
endif()
|
||||
|
||||
# Add Dependson
|
||||
nuttx_add_dependencies(TARGET libbluetooth DEPENDS libuv)
|
||||
|
||||
|
|
@ -1006,9 +1011,6 @@ if(CONFIG_BLUETOOTH)
|
|||
${BLUETOOTH_DIR}/framework/include)
|
||||
|
||||
# Library Configuration
|
||||
if(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE OR CONFIG_BLUETOOTH_STACK_LE_ZBLUE)
|
||||
target_link_libraries(libbluetooth PRIVATE zblue_headers)
|
||||
endif()
|
||||
target_compile_options(libbluetooth PRIVATE ${CFLAGS})
|
||||
target_sources(libbluetooth PRIVATE ${CSRCS})
|
||||
target_include_directories(libbluetooth PRIVATE ${INCDIR})
|
||||
|
|
|
|||
107
Kconfig
107
Kconfig
|
|
@ -66,15 +66,15 @@ config BLUETOOTH_FRAMEWORK_ASYNC
|
|||
Enable Bluetooth Framework async API
|
||||
|
||||
choice
|
||||
prompt "select feature api"
|
||||
prompt "Select feature API"
|
||||
default BLUETOOTH_FEATURE_NONE
|
||||
config BLUETOOTH_FEATURE_NONE
|
||||
bool "not supporting Bluetooth feature API."
|
||||
bool "Not supporting Bluetooth feature API."
|
||||
config BLUETOOTH_FEATURE
|
||||
bool "support Bluetooth synchronization API."
|
||||
bool "Support Bluetooth synchronization API."
|
||||
depends on FEATURE_FRAMEWORK
|
||||
config BLUETOOTH_FEATURE_ASYNC
|
||||
bool "support Bluetooth asynchronous API."
|
||||
bool "Support Bluetooth asynchronous API."
|
||||
depends on FEATURE_FRAMEWORK
|
||||
depends on BLUETOOTH_FRAMEWORK_ASYNC
|
||||
endchoice
|
||||
|
|
@ -103,12 +103,6 @@ config BLUETOOTH_BLE_SCAN_FILTER
|
|||
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
|
||||
|
|
@ -163,7 +157,7 @@ config BLUETOOTH_MAX_SAVED_REMOTE_UUIDS_LEN
|
|||
|
||||
config BLUETOOTH_MAX_REGISTER_NUM
|
||||
int "Max register callback nums"
|
||||
default 6
|
||||
default 4
|
||||
|
||||
endmenu #Core
|
||||
|
||||
|
|
@ -233,6 +227,11 @@ choice
|
|||
bool "Not support BLE Stack"
|
||||
endchoice
|
||||
|
||||
config BLUETOOTH_LE_CS
|
||||
bool "Bluetooth LE Channel Sounding supported"
|
||||
depends on BLUETOOTH_STACK_LE_ZBLUE
|
||||
default n
|
||||
|
||||
config BLUETOOTH_LE_SCANNER_MAX_NUM
|
||||
int "LE Scanner max register number"
|
||||
default 2
|
||||
|
|
@ -245,20 +244,15 @@ config BLUETOOTH_LE_ADVERTISER_MAX_NUM
|
|||
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)"
|
||||
prompt "Select Bluetooth Storage Method(Unqlite, KVDB)"
|
||||
default BLUETOOTH_STORAGE_PROPERTY_SUPPORT
|
||||
config BLUETOOTH_STORAGE_PROPERTY_SUPPORT
|
||||
bool "Bluetooth Storage KVDB Property support"
|
||||
|
|
@ -301,13 +295,6 @@ config BLUETOOTH_A2DP_SOURCE
|
|||
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"
|
||||
|
|
@ -315,13 +302,6 @@ config BLUETOOTH_A2DP_PEER_PARTIAL_RECONN
|
|||
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
|
||||
|
|
@ -385,15 +365,6 @@ config BLUETOOTH_HFP_AG_PRIMARY_SLOT
|
|||
int "HFP select primary modem slot"
|
||||
default 0
|
||||
|
||||
config BLUETOOTH_HFP_AG_LOCAL_TELEPHONY
|
||||
bool "Handle telephony AT commands locally instead of notifying upper layer"
|
||||
default y
|
||||
help
|
||||
If enabled, the HFP AG service handles telephony-related AT commands
|
||||
(AT+CIND, AT+CLCC, AT+COPS, ATA, AT+CHUP, ATD, AT+CHLD) locally by
|
||||
calling telephony service directly. If disabled, these requests are
|
||||
forwarded to the upper layer (e.g. AP core) via callback.
|
||||
|
||||
endif # BLUETOOTH_HFP_AG
|
||||
|
||||
config BLUETOOTH_SCO_CTRL_PATH
|
||||
|
|
@ -650,16 +621,6 @@ config BLUETOOTH_AUDIO_TRANS_ID_HFP_CTRL
|
|||
int "Bluetooth Audio Transport SCO Ctrl Channel ID"
|
||||
default 4
|
||||
|
||||
config BLUETOOTH_A2DP_SINK_DEVICE
|
||||
string "Bluetooth A2DP Audio Transport Sink Device"
|
||||
default "/dev/audio/a2dpsnkp" if MEDIA_SERVER
|
||||
default "/dev/audio/a2dpsnk"
|
||||
|
||||
config BLUETOOTH_A2DP_SOURCE_DEVICE
|
||||
string "Bluetooth A2DP Audio Transport Source Device"
|
||||
default "/dev/audio/a2dpsrcc" if MEDIA_SERVER
|
||||
default "/dev/audio/a2dpsrc"
|
||||
|
||||
config BLUETOOTH_LEA_SINK_CTRL_PATH
|
||||
string "Bluetooth LE Audio Transport Sink Ctrl Path"
|
||||
default "lea_sink_ctrl"
|
||||
|
|
@ -676,9 +637,25 @@ 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
|
||||
|
||||
menuconfig BLUETOOTH_GATT
|
||||
config BLUETOOTH_GATT
|
||||
bool "Generic ATT Profile Support(deprecated)"
|
||||
default y
|
||||
|
||||
|
|
@ -716,6 +693,14 @@ config GATT_CLIENT_CHAR_PER_SERVICE_MAX
|
|||
help
|
||||
The maximum number of characteristics that can be discovered and stored
|
||||
under a single GATT service when using the ZBLUE stack.
|
||||
|
||||
config BLUETOOTH_GATT_CLIENT_DEBUG
|
||||
bool "Enable GATT Client debug"
|
||||
default y
|
||||
help
|
||||
Enable debug logging for GATT Client service discovery and dump.
|
||||
Disabling this option reduces code size by removing log strings.
|
||||
|
||||
endif # BLUETOOTH_GATT_CLIENT
|
||||
|
||||
menuconfig BLUETOOTH_GATT_SERVER
|
||||
|
|
@ -731,32 +716,26 @@ config BLUETOOTH_GATTS_MAX_CONNECTIONS
|
|||
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
|
||||
depends on SERIAL_TERMIOS
|
||||
depends on PSEUDOTERM
|
||||
|
||||
if BLUETOOTH_SPP
|
||||
config BLUETOOTH_SPP_MAX_CONNECTIONS
|
||||
int "SPP max connections"
|
||||
default 1
|
||||
default 8
|
||||
|
||||
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
|
||||
|
|
@ -821,7 +800,7 @@ config BLUETOOTH_DUMPBUFFER
|
|||
config BLUETOOTH_DFX
|
||||
bool "Enable Bluetooth DFX"
|
||||
default y
|
||||
depends on DFX
|
||||
depends on DFX_EVENT
|
||||
help
|
||||
Enable Bluetooth DFX
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
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
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/include
|
||||
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/include
|
||||
|
||||
endif
|
||||
|
|
|
|||
72
Makefile
72
Makefile
|
|
@ -22,7 +22,9 @@ CSRCS += framework/common/*.c
|
|||
CSRCS += framework/api/bluetooth.c
|
||||
CSRCS += framework/api/bt_adapter.c
|
||||
CSRCS += framework/api/bt_device.c
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LE_CS), y)
|
||||
CSRCS += framework/api/bt_cs.c
|
||||
endif #CONFIG_BLUETOOTH_LE_CS
|
||||
ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
||||
CSRCS += framework/api/bt_a2dp_sink.c
|
||||
endif #CONFIG_BLUETOOTH_A2DP_SINK
|
||||
|
|
@ -160,6 +162,11 @@ CSRCS += framework/socket/bt_trace.c
|
|||
CSRCS += service/ipc/socket/src/bt_socket_log.c
|
||||
endif #CONFIG_BLUETOOTH_BLE_AUDIO
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LE_CS), y)
|
||||
CSRCS += framework/socket/bt_cs.c
|
||||
CSRCS += service/ipc/socket/src/bt_socket_cs.c
|
||||
endif #CONFIG_BLUETOOTH_LE_CS
|
||||
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/ipc/socket/include
|
||||
ifeq ($(CONFIG_BLUETOOTH_FRAMEWORK_ASYNC), y)
|
||||
CSRCS += framework/socket/async/*.c
|
||||
|
|
@ -177,7 +184,7 @@ endif #CONFIG_BLUETOOTH_CONNECTION_MANAGER
|
|||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_PROPERTY_SUPPORT), y)
|
||||
CSRCS += service/common/storage_property.c
|
||||
else
|
||||
CSRCS += service/common/bt_storage.c
|
||||
CSRCS += service/common/storage.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_STORAGE_UPDATE), y)
|
||||
|
|
@ -189,7 +196,7 @@ ifeq ($(CONFIG_BLUETOOTH_DEBUG_MEMORY),y)
|
|||
CSRCS += debug/bt_memory.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_DEBUG_TRACE), y)
|
||||
ifeq ($(CONFIG_BLUETOOTH_LOG), y)
|
||||
CSRCS += service/debug/bt_trace.c
|
||||
endif
|
||||
|
||||
|
|
@ -230,9 +237,6 @@ ifneq ($(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE)$(CONFIG_BLUETOOTH_STACK_LE_ZBLUE),)
|
|||
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
|
||||
|
|
@ -240,17 +244,6 @@ 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)
|
||||
|
|
@ -265,6 +258,9 @@ 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
|
||||
ifeq ($(CONFIG_BLUETOOTH_LE_CS), y)
|
||||
CSRCS += service/stacks/zephyr/sal_le_cs_interface.c
|
||||
endif #CONFIG_BLUETOOTH_LE_CS
|
||||
endif #CONFIG_BLUETOOTH_STACK_LE_ZBLUE
|
||||
|
||||
endif
|
||||
|
|
@ -279,11 +275,7 @@ 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/audio_control.c
|
||||
ifeq ($(CONFIG_AUDIOUTILS_TINYCOMPRESS), y)
|
||||
CSRCS += service/profiles/audio_interface/audio_transport.c
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/service/profiles/audio_interface/include
|
||||
endif #CONFIG_AUDIOUTILS_TINYCOMPRESS
|
||||
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
|
||||
|
|
@ -291,6 +283,9 @@ 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
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_CLIENT_DEBUG), y)
|
||||
CSRCS += service/profiles/gatt/gattc_debug.c
|
||||
endif
|
||||
endif #CONFIG_BLUETOOTH_GATT_CLIENT
|
||||
ifeq ($(CONFIG_BLUETOOTH_GATT_SERVER), y)
|
||||
CSRCS += service/profiles/gatt/gatts_event.c
|
||||
|
|
@ -328,11 +323,6 @@ endif #CONFIG_BLUETOOTH_HFP_HF
|
|||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HFP_AG), y)
|
||||
CSRCS += service/profiles/hfp_ag/*.c
|
||||
ifeq ($(CONFIG_PHONE_SERVICE), y)
|
||||
CSRCS := $(filter-out $(wildcard service/profiles/system/telephony_interface.c) $(wildcard service/profiles/hfp_ag/hfp_ag_tele_service.c), $(wildcard $(CSRCS)))
|
||||
else
|
||||
CSRCS := $(filter-out $(wildcard service/profiles/hfp_ag/hfp_ag_tele_phone_service.c),$(wildcard $(CSRCS)))
|
||||
endif
|
||||
endif #CONFIG_BLUETOOTH_HFP_AG
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_SPP), y)
|
||||
|
|
@ -392,6 +382,11 @@ CSRCS += service/utils/btsnoop_writer.c
|
|||
CSRCS += service/utils/btsnoop_filter.c
|
||||
endif #CONFIG_BLUETOOTH_LOG
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LE_CS), y)
|
||||
CSRCS += service/profiles/cs/*.c
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/profiles/cs
|
||||
endif #CONFIG_BLUETOOTH_LE_CS
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_HCI_FILTER), y)
|
||||
CSRCS += service/vhal/bt_hci_filter.c
|
||||
endif
|
||||
|
|
@ -444,9 +439,6 @@ 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
|
||||
|
|
@ -517,10 +509,15 @@ ifeq ($(CONFIG_BLUETOOTH_STORAGE_UPDATE), y)
|
|||
CSRCS += tools/storage_update/storage_tool.c
|
||||
endif #CONFIG_BLUETOOTH_STORAGE_UPDATE
|
||||
|
||||
ifeq ($(CONFIG_BLUETOOTH_LE_CS), y)
|
||||
CSRCS += tools/le_cs.c
|
||||
endif
|
||||
|
||||
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
|
||||
|
|
@ -552,6 +549,7 @@ ifneq ($(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE)$(CONFIG_BLUETOOTH_STACK_LE_ZBLUE),)
|
|||
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/subsys/bluetooth
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/external/zblue/zblue/port/include/kernel/include
|
||||
endif
|
||||
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/service/ipc
|
||||
|
|
@ -656,7 +654,6 @@ 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
|
||||
|
|
@ -674,13 +671,6 @@ CSRCS += feature/src/system_bluetooth_bt_avrcpcontrol.c
|
|||
CSRCS += feature/src/system_bluetooth_bt_avrcpcontrol_impl.c
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_BLUETOOTH_DFX),)
|
||||
DFX_XML=$(APPDIR)/frameworks/system/dfx/src/onetrack/xml
|
||||
BLUETOOTH_XML=$(APPDIR)/frameworks/connectivity/bluetooth/dfx/event_bt.xml
|
||||
context::
|
||||
@cp $(BLUETOOTH_XML) $(DFX_XML)
|
||||
endif
|
||||
|
||||
depend::
|
||||
$(APPDIR)/../prebuilts/tools/rust/bin/jidl/jidl_gen_cpp \
|
||||
$(APPDIR)/frameworks/connectivity/bluetooth/feature/jidl/bluetooth.jidl --out-dir \
|
||||
|
|
@ -694,9 +684,9 @@ ifeq ($(CONFIG_BLUETOOTH_A2DP_SINK), y)
|
|||
$(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)
|
||||
$(APPDIR)/../prebuilts/tools/rust/bin/jidl/jidl_gen_cpp \
|
||||
$(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
|
||||
@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
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
***************************************************************************/
|
||||
#include "bt_sched_trace.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -23,6 +24,9 @@
|
|||
|
||||
#include "utils/log.h"
|
||||
|
||||
#ifndef CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE
|
||||
#define CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE 64
|
||||
#endif
|
||||
#define DUMP_THRESHOLD 256
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -64,7 +68,7 @@ void bt_note_stop(void)
|
|||
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",
|
||||
"[TAG=%s][TS=%" PRIu64 "][LAT=%" PRIu32 "us]\n",
|
||||
p->tag, p->timestamp, p->latency_us);
|
||||
trace_manager->tail = (trace_manager->tail + 1) % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE;
|
||||
written = written % DUMP_THRESHOLD;
|
||||
|
|
|
|||
186
dfx/bt_dfx.h
186
dfx/bt_dfx.h
|
|
@ -96,181 +96,75 @@
|
|||
"%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)
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_BREDR_SUPPORT)
|
||||
#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) \
|
||||
#define BT_DFX_A2DP_CONN_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); \
|
||||
BT_LOGE("BT_DFX: a2dpConnError: %s", reason); \
|
||||
BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_CONN), \
|
||||
"%s:%s", "a2dpConnError", reason); \
|
||||
} while (0)
|
||||
|
||||
#define BT_DFX_A2DP_OFFLOAD_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: a2dpOffloadError: %s", reason); \
|
||||
BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_OFFLOAD), \
|
||||
"%s:%s", "a2dpOffloadError", reason); \
|
||||
} while (0)
|
||||
|
||||
// hfp
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && (defined(CONFIG_BLUETOOTH_HFP_HF) || defined(CONFIG_BLUETOOTH_HFP_AG))
|
||||
#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_BREDR_SUPPORT)
|
||||
#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) \
|
||||
#define BT_DFX_HFP_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); \
|
||||
BT_LOGE("BT_DFX: hfpConnError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_CONN), \
|
||||
"%s:%s", "hfpConnError", 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); \
|
||||
#define BT_DFX_HFP_OFFLOAD_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: hfpOffloadError: %s", reason); \
|
||||
BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_OFFLOAD), \
|
||||
"%s:%s", "hfpOffloadError", 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
|
||||
// open (enable)
|
||||
#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); \
|
||||
#define BT_DFX_OPEN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: openError: %s", reason); \
|
||||
BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_OPEN), \
|
||||
"%s:%s", "openError", reason); \
|
||||
} 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); \
|
||||
// spp / ipc
|
||||
#define BT_DFX_SPP_CONN_ERROR(reason) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: sppConnError: %s", reason); \
|
||||
BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_RFCOMM, 0), \
|
||||
"%s:%s", "sppConnError", 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); \
|
||||
#define BT_DFX_IPC_CONN_ERROR(reason, extra) \
|
||||
do { \
|
||||
BT_LOGE("BT_DFX: ipcConnError: %s %s", reason, extra); \
|
||||
BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_RFCOMM, 0), \
|
||||
"%s:%s:%s", "ipcConnError", reason, extra); \
|
||||
} 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_ */
|
||||
#endif /* _BT_DFX_H_ */
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
#define _BT_DFX_EVENT_H_
|
||||
|
||||
// vela bluetooth event id
|
||||
#define BT_DFX_BASE_VELA_BLUETOOTH (961020000)
|
||||
#define BT_DFX_BASE_VELA_BLUETOOTH (923020000)
|
||||
|
||||
// event group
|
||||
#define BT_DFXG_BR_GAP (0)
|
||||
|
|
@ -47,40 +47,16 @@
|
|||
#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)
|
||||
#define BT_DFXC_A2DP_OFFLOAD (100)
|
||||
|
||||
// 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
|
||||
#define BT_DFXC_HFP_OFFLOAD (100)
|
||||
|
||||
// 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_DFXC_OPEN (0)
|
||||
|
||||
#define BT_DFX_BUILD_CODE(group, subcode) ((BT_DFX_BASE_VELA_BLUETOOTH) + (group) + (subcode))
|
||||
|
||||
|
|
|
|||
|
|
@ -24,53 +24,16 @@
|
|||
#define BT_DFXE_CONN_FAILED_TO_BE_ESTABLISHED "btConnFailedToBeEstablished"
|
||||
|
||||
#define BT_DFXE_SCANNER_EXCEED_MAX_NUM "btScannerExceedMaxNum"
|
||||
|
||||
#define BT_DFXE_LE_ENABLE_FAIL "btLeEnableFail"
|
||||
#define BT_DFXE_BR_ENABLE_FAIL "btBrEnableFail"
|
||||
#define BT_DFXE_A2DP_CONN_TIMEOUT "btA2dpConnTimeout"
|
||||
#define BT_DFXE_OFFLOAD_START_TIMEOUT "btOffloadStartTimeout"
|
||||
#define BT_DFXE_OFFLOAD_HCI_UNSPECIFIED_ERROR "btOffloadHciUnspecifiedError"
|
||||
#define BT_DFXE_HFP_HF_CONN_TIMEOUT "btHfpHfConnTimeout"
|
||||
#define BT_DFXE_HFP_HF_CONN_RETRY_FAIL "btHfpHfConnRetryFail"
|
||||
#define BT_DFXE_SPP_CONN_FAIL "btSppConnFail"
|
||||
#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_ */
|
||||
|
|
@ -191,8 +191,8 @@ bt_status_t get_valid_uuid128(uint8_t uuid128[16], const char* in)
|
|||
|
||||
char* bt_uuid_to_feature_string(const bt_uuid_t* bt_uuid)
|
||||
{
|
||||
char uuid[40] = { 0 };
|
||||
bt_uuid_to_string(bt_uuid, uuid, 40);
|
||||
char uuid[BT_UUID_STR_LENGTH] = { 0 };
|
||||
bt_uuid_to_string(bt_uuid, uuid, BT_UUID_STR_LENGTH);
|
||||
return StringToFtString(uuid);
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ FtString system_bluetooth_bt_wrap_getDeviceName(FeatureInstanceHandle feature, A
|
|||
return StringToFtString(name);
|
||||
}
|
||||
|
||||
FtUint32 system_bluetooth_bt_wrap_getDeviceClass(FeatureInstanceHandle feature, AppendData append_data, FtString deviceId)
|
||||
unsigned int system_bluetooth_bt_wrap_getDeviceClass(FeatureInstanceHandle feature, AppendData append_data, FtString deviceId)
|
||||
{
|
||||
bt_address_t addr;
|
||||
if (bt_addr_str2ba(deviceId, &addr) < 0) {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void system_bluetooth_wrap_openAdapter(FeatureInstanceHandle feature, AppendData
|
|||
|
||||
void system_bluetooth_wrap_closeAdapter(FeatureInstanceHandle feature, AppendData append_data, system_bluetooth_CloseAdapterParams* params)
|
||||
{
|
||||
bt_status_t status = bt_adapter_disable_safe(feature_bluetooth_get_bt_ins(feature));
|
||||
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!");
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ bt_status_t BTSYMBOLS(bt_adapter_disable)(bt_instance_t* ins)
|
|||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_disable_safe)(bt_instance_t* ins)
|
||||
{
|
||||
return adapter_disable_safe(SYS_SET_BT_ALL);
|
||||
return adapter_disable(SYS_SET_BT_ALL);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_enable_le)(bt_instance_t* ins)
|
||||
|
|
@ -82,7 +82,7 @@ bt_status_t BTSYMBOLS(bt_adapter_start_limited_discovery)(bt_instance_t* ins, ui
|
|||
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)
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_debug_mode)(bt_instance_t* ins, uint8_t mode, uint8_t operation)
|
||||
{
|
||||
return adapter_set_debug_mode(mode, operation);
|
||||
}
|
||||
|
|
@ -208,12 +208,7 @@ bt_status_t BTSYMBOLS(bt_adapter_le_enable_key_derivation)(bt_instance_t* ins,
|
|||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_add_whitelist)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return adapter_le_add_whitelist_with_type(addr, BT_LE_ADDR_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_add_whitelist_with_type)(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t type)
|
||||
{
|
||||
return adapter_le_add_whitelist_with_type(addr, type);
|
||||
return adapter_le_add_whitelist(addr);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_remove_whitelist)(bt_instance_t* ins, bt_address_t* addr)
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ bt_status_t BTSYMBOLS(bt_avrcp_control_get_playback_state)(bt_instance_t* ins, b
|
|||
{
|
||||
avrcp_control_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->avrcp_control_get_playback_state(addr);
|
||||
return profile->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)
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_register_notification)(bt_instance_t* ins, bt_address_t* addr, avrcp_notification_event_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,75 @@
|
|||
/****************************************************************************
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "bt_cs.h"
|
||||
#include "bt_internal.h"
|
||||
#include "bt_profile.h"
|
||||
#include "cs_service.h"
|
||||
#include "service_manager.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_LE_CS
|
||||
|
||||
static bt_cs_interface_t* get_profile_service(void)
|
||||
{
|
||||
return (bt_cs_interface_t*)service_manager_get_profile(PROFILE_CS);
|
||||
}
|
||||
void* BTSYMBOLS(bt_cs_register_callbacks)(bt_instance_t* ins, const cs_callbacks_t* callbacks)
|
||||
{
|
||||
bt_cs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_cs_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
bt_cs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_cs_start_distance_measurement)(bt_instance_t* ins, bt_distance_measurement_params_t* params)
|
||||
{
|
||||
bt_cs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->start_distance_measurement(params);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_cs_stop_distance_measurement)(bt_instance_t* ins, bt_address_t* addr, uint8_t method, bool timeout)
|
||||
{
|
||||
bt_cs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->stop_distance_measurement(addr, method, timeout);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_cs_set_config)(bt_instance_t* ins, bt_address_t* addr, const bt_cs_set_params_t* params)
|
||||
{
|
||||
bt_cs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->set_config(addr, params);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_CS_RAS_TEST
|
||||
bt_status_t BTSYMBOLS(bt_cs_test)(bt_instance_t* ins, void* data, uint16_t len)
|
||||
{
|
||||
bt_cs_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->cs_test(data, len);
|
||||
}
|
||||
#endif /* CONFIG_BT_CS_RAS_TEST */
|
||||
|
||||
#endif /* CONFIG_BLUETOOTH_LE_CS */
|
||||
|
|
@ -21,7 +21,6 @@
|
|||
#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)
|
||||
|
|
@ -31,7 +30,11 @@ bt_status_t BTSYMBOLS(bt_device_get_identity_address)(bt_instance_t* ins, bt_add
|
|||
|
||||
ble_addr_type_t BTSYMBOLS(bt_device_get_address_type)(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
#ifdef CONFIG_BLUETOOTH_BLE_SUPPORT
|
||||
return adapter_get_le_remote_address_type(addr);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bt_device_type_t BTSYMBOLS(bt_device_get_device_type)(bt_instance_t* ins, bt_address_t* addr)
|
||||
|
|
@ -109,24 +112,6 @@ bt_status_t BTSYMBOLS(bt_device_disconnect)(bt_instance_t* ins, bt_address_t* ad
|
|||
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,
|
||||
|
|
@ -219,22 +204,4 @@ bt_status_t BTSYMBOLS(bt_device_set_le_sc_remote_oob_data)(bt_instance_t* ins, b
|
|||
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
|
||||
}
|
||||
|
|
@ -98,13 +98,6 @@ bt_status_t BTSYMBOLS(bt_gattc_write_without_response)(gattc_handle_t conn_handl
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -152,6 +152,13 @@ bt_status_t BTSYMBOLS(bt_hfp_ag_send_at_command)(bt_instance_t* ins, bt_address_
|
|||
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)
|
||||
|
|
@ -161,13 +168,6 @@ bt_status_t BTSYMBOLS(bt_hfp_ag_send_clcc_response)(bt_instance_t* ins, bt_addre
|
|||
return profile->send_clcc_response(addr, index, dir, call, mode, mpty, type, number);
|
||||
}
|
||||
|
||||
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_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)
|
||||
|
|
@ -175,4 +175,4 @@ bt_status_t BTSYMBOLS(bt_hfp_ag_send_cind_response)(bt_instance_t* ins, bt_addre
|
|||
hfp_ag_interface_t* profile = get_profile_service();
|
||||
|
||||
return profile->send_cind_response(addr, network, call, call_held, call_setup, signal, roam, battery);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,35 +24,25 @@
|
|||
|
||||
void* BTSYMBOLS(bt_l2cap_register_callbacks)(bt_instance_t* ins, const l2cap_callbacks_t* callbacks)
|
||||
{
|
||||
return l2cap_register_callbacks(ins, callbacks);
|
||||
return l2cap_register_callbacks(NULL, callbacks);
|
||||
}
|
||||
|
||||
bool BTSYMBOLS(bt_l2cap_unregister_callbacks)(bt_instance_t* ins, void* handle)
|
||||
bool BTSYMBOLS(bt_l2cap_unregister_callbacks)(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
return l2cap_unregister_callbacks(NULL, handle);
|
||||
return l2cap_unregister_callbacks(NULL, cookie);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_listen)(bt_instance_t* ins, void* handle, l2cap_config_option_t* option)
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_listen)(bt_instance_t* ins, l2cap_config_option_t* option)
|
||||
{
|
||||
return l2cap_listen_channel(handle, option);
|
||||
return l2cap_listen_channel(option);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_connect)(bt_instance_t* ins, void* handel, bt_address_t* addr, l2cap_config_option_t* option)
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_connect)(bt_instance_t* ins, bt_address_t* addr, l2cap_config_option_t* option)
|
||||
{
|
||||
return l2cap_connect_channel(handel, addr, option);
|
||||
return l2cap_connect_channel(addr, option);
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_disconnect)(bt_instance_t* ins, void* handle, uint16_t id)
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_disconnect)(bt_instance_t* ins, uint16_t cid)
|
||||
{
|
||||
return l2cap_disconnect_channel(handle, id);
|
||||
return l2cap_disconnect_channel(cid);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "scan"
|
||||
#define LOG_TAG "adv"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -186,9 +186,9 @@ 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)
|
||||
bt_status_t bt_adapter_set_le_identity_address(bt_instance_t* ins, bt_address_t* addr, bool public)
|
||||
{
|
||||
return BpBtAdapter_setLeIdentityAddress((BpBtAdapter*)ins->adapter_proxy, addr, is_public);
|
||||
return BpBtAdapter_setLeIdentityAddress((BpBtAdapter*)ins->adapter_proxy, addr, public);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_le_appearance(bt_instance_t* ins, uint16_t appearance)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -54,6 +53,7 @@ typedef struct {
|
|||
|
||||
struct gatt_client {
|
||||
gattc_handle_t conn;
|
||||
bt_address_t addr;
|
||||
bt_gattc_feature_callbacks_t callbacks;
|
||||
bool connected;
|
||||
bool services_discovering;
|
||||
|
|
@ -158,6 +158,25 @@ void discovery_database_destroy(gatt_client_t* client)
|
|||
}
|
||||
}
|
||||
|
||||
static bool match_client_by_addr(void* element, void* context)
|
||||
{
|
||||
bt_address_t* target_addr;
|
||||
gatt_client_t* client;
|
||||
|
||||
target_addr = (bt_address_t*)context;
|
||||
client = (gatt_client_t*)element;
|
||||
|
||||
return memcmp(&client->addr, target_addr, sizeof(bt_address_t)) == 0;
|
||||
}
|
||||
|
||||
static gatt_client_t* find_client_by_addr(bt_address_t* addr)
|
||||
{
|
||||
if (!g_gatt_client_list || !addr)
|
||||
return NULL;
|
||||
|
||||
return (gatt_client_t*)bt_list_find(g_gatt_client_list, match_client_by_addr, (void*)addr);
|
||||
}
|
||||
|
||||
static gatt_client_t* find_client_by_conn(gattc_handle_t conn)
|
||||
{
|
||||
bt_list_node_t* node;
|
||||
|
|
@ -308,18 +327,6 @@ static gatt_descriptor_t* find_desc_by_attr_handle(gatt_client_t* client, uint16
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void gatt_service_list_to_array(bt_list_t* list,
|
||||
const gatt_service_t* out_array[])
|
||||
{
|
||||
bt_list_node_t* node;
|
||||
size_t i = 0;
|
||||
|
||||
for (node = bt_list_head(list); node != NULL;
|
||||
node = bt_list_next(list, node)) {
|
||||
out_array[i++] = (gatt_service_t*)bt_list_node(node);
|
||||
}
|
||||
}
|
||||
|
||||
static gatt_service_t* build_service_from_attr_list(bt_list_t* attr_list)
|
||||
{
|
||||
gatt_service_t* service;
|
||||
|
|
@ -432,10 +439,11 @@ static void feature_on_connected(void* conn_handle, bt_address_t* addr)
|
|||
return;
|
||||
|
||||
client->connected = true;
|
||||
memcpy(&client->addr, addr, sizeof(bt_address_t));
|
||||
|
||||
BT_FEATURE_LOG("connected: conn=%p", conn_handle);
|
||||
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_connected, client->ins, GATT_STATUS_SUCCESS, client->conn);
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_connected, client->ins, BT_STATUS_SUCCESS, client->conn);
|
||||
}
|
||||
|
||||
static void feature_on_disconnected(void* conn_handle, bt_address_t* addr)
|
||||
|
|
@ -455,7 +463,7 @@ static void feature_on_disconnected(void* conn_handle, bt_address_t* addr)
|
|||
client->services_discovering = false;
|
||||
discovery_database_clear(client);
|
||||
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_disconnected, client->ins, GATT_STATUS_SUCCESS,
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_disconnected, client->ins, BT_STATUS_SUCCESS,
|
||||
client->conn);
|
||||
}
|
||||
|
||||
|
|
@ -466,8 +474,6 @@ static void feature_get_attribute_cb(bt_instance_t* ins, bt_status_t status,
|
|||
gatt_client_t* client;
|
||||
gatt_attr_desc_t* attr_node;
|
||||
gatt_service_t* service;
|
||||
size_t service_count;
|
||||
const gatt_service_t** service_array;
|
||||
|
||||
(void)ins;
|
||||
|
||||
|
|
@ -498,23 +504,10 @@ static void feature_get_attribute_cb(bt_instance_t* ins, bt_status_t status,
|
|||
free(user_data);
|
||||
|
||||
client->services_discovering = false;
|
||||
|
||||
service_count = bt_list_length(client->services_db);
|
||||
service_array = calloc(service_count, sizeof(gatt_service_t*));
|
||||
|
||||
if (!service_array) {
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_discovered,
|
||||
client->ins, GATT_STATUS_FAILURE,
|
||||
client->conn, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
gatt_service_list_to_array(client->services_db, service_array);
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_discovered,
|
||||
client->ins, GATT_STATUS_SUCCESS,
|
||||
client->conn, service_array, service_count);
|
||||
client->conn, NULL);
|
||||
|
||||
free(service_array);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -537,6 +530,9 @@ static void feature_get_attribute_cb(bt_instance_t* ins, bt_status_t status,
|
|||
if (service) {
|
||||
bt_list_add_tail(client->services_db, service);
|
||||
}
|
||||
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_discovered, client->ins, BT_STATUS_SUCCESS,
|
||||
client->conn, service);
|
||||
}
|
||||
|
||||
free(user_data);
|
||||
|
|
@ -557,7 +553,7 @@ static void feature_on_discovered(void* conn_handle, gatt_status_t status,
|
|||
if (status != GATT_STATUS_SUCCESS) {
|
||||
client->services_discovering = false;
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_discovered, client->ins, status,
|
||||
client->conn, NULL, 0);
|
||||
client->conn, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -588,7 +584,7 @@ static void feature_on_discovered(void* conn_handle, gatt_status_t status,
|
|||
client->services_discovering = false;
|
||||
BT_GATTC_FEATURE_INVOKE_CB(client, on_discovered,
|
||||
client->ins, GATT_STATUS_FAILURE,
|
||||
client->conn, NULL, 0);
|
||||
client->conn, NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -791,6 +787,7 @@ bt_status_t bt_gattc_feature_create_client_async(bt_instance_t* ins, bt_address_
|
|||
goto fail;
|
||||
}
|
||||
|
||||
memcpy(&client->addr, addr, sizeof(bt_address_t));
|
||||
client->ins = ins;
|
||||
|
||||
memcpy(&client->callbacks, callbacks, callbacks->size);
|
||||
|
|
@ -841,7 +838,7 @@ static void delete_client_cb(bt_instance_t* ins, bt_status_t status, void* userd
|
|||
user_ud = client->delete_client_ctx.delete_userdata;
|
||||
conn_handle = client->conn;
|
||||
|
||||
if (g_gatt_client_list) {
|
||||
if (status == BT_STATUS_SUCCESS && g_gatt_client_list) {
|
||||
bt_list_remove(g_gatt_client_list, client);
|
||||
|
||||
if (!bt_list_length(g_gatt_client_list)) {
|
||||
|
|
@ -854,15 +851,15 @@ static void delete_client_cb(bt_instance_t* ins, bt_status_t status, void* userd
|
|||
user_cb(ins, status, conn_handle, user_ud);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_feature_delete_client_async(bt_instance_t* ins, gattc_handle_t conn_handle,
|
||||
bt_status_t bt_gattc_feature_delete_client_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_gattc_feature_delete_client_cb_t cb, void* userdata)
|
||||
{
|
||||
gatt_client_t* client;
|
||||
|
||||
if (!ins || !conn_handle)
|
||||
if (!ins || !addr || !cb)
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
|
||||
client = find_client_by_conn(conn_handle);
|
||||
client = find_client_by_addr(addr);
|
||||
if (!client)
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,6 @@ bool advertiser_data_add_service_data(advertiser_data_t* ad,
|
|||
}
|
||||
|
||||
memcpy(p, data, len);
|
||||
sdata->len += len;
|
||||
bt_list_add_tail(ad->data, sdata);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -88,13 +88,12 @@ static const char* show_ad_type_desc(uint8_t type)
|
|||
|
||||
static void advertiser_data_info(adv_data_t* ad)
|
||||
{
|
||||
if (!ad || ad->len < 1) {
|
||||
syslog(LOG_ERR, "Invalid params, ad(%p)", 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);
|
||||
lib_dumpbuffer("AdvData:", ad->data, ad->len - 1);
|
||||
|
||||
switch (ad->type) {
|
||||
case BT_AD_FLAGS:
|
||||
|
|
|
|||
|
|
@ -138,6 +138,10 @@ static void euv_close_callback(uv_handle_t* hdl)
|
|||
#endif
|
||||
|
||||
if (handle->status == EUV_ALL_PIPE_CLOSED) {
|
||||
if (handle->close_cb) {
|
||||
handle->close_cb(handle);
|
||||
}
|
||||
|
||||
// all pipe closed, free handle
|
||||
BT_LOGD("%s, free handle 0x%p", __func__, handle);
|
||||
free(handle);
|
||||
|
|
@ -199,6 +203,16 @@ int euv_pipe_read_start(euv_pipe_t* handle, uint16_t read_size, euv_read_cb read
|
|||
euv_read_t* reader;
|
||||
int ret;
|
||||
|
||||
if (!handle) {
|
||||
BT_LOGE("%s, handle null", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (uv_is_closing((uv_handle_t*)&handle->cli_pipe)) {
|
||||
BT_LOGE("%s, handle %p is closing", __func__, handle);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (uv_is_active((uv_handle_t*)&handle->cli_pipe)) {
|
||||
BT_LOGE("%s, client is active", __func__);
|
||||
return 0;
|
||||
|
|
@ -232,6 +246,12 @@ int euv_pipe_read_stop(euv_pipe_t* handle)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (uv_is_closing((uv_handle_t*)&handle->cli_pipe)) {
|
||||
/* uv_pipe is closing; cli_pipe.data has been set to handle for cleanup, so don't free it here */
|
||||
BT_LOGE("%s, handle %p is closing", __func__, handle);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
if (handle->cli_pipe.data) {
|
||||
free(handle->cli_pipe.data);
|
||||
handle->cli_pipe.data = NULL;
|
||||
|
|
@ -242,11 +262,6 @@ int euv_pipe_read_stop(euv_pipe_t* handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (uv_is_closing((uv_handle_t*)&handle->cli_pipe)) {
|
||||
BT_LOGE("%s, uv_is_closing", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return uv_read_stop((uv_stream_t*)&handle->cli_pipe);
|
||||
}
|
||||
|
||||
|
|
@ -480,13 +495,14 @@ errout_with_handle:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void euv_pipe_close(euv_pipe_t* handle)
|
||||
void euv_pipe_close_with_cb(euv_pipe_t* handle, euv_close_cb cb)
|
||||
{
|
||||
if (!handle) {
|
||||
BT_LOGE("%s, invalid arg", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
handle->close_cb = cb;
|
||||
if (handle->mode == EUV_PIPE_TYPE_UNKNOWN) {
|
||||
BT_LOGE("%s, unkown mode", __func__);
|
||||
handle->srv_pipe[EUV_PIPE_TYPE_SERVER_LOCAL].data = handle;
|
||||
|
|
@ -509,6 +525,11 @@ void euv_pipe_close(euv_pipe_t* handle)
|
|||
uv_close((uv_handle_t*)&handle->srv_pipe[handle->mode], euv_close_callback);
|
||||
}
|
||||
|
||||
void euv_pipe_close(euv_pipe_t* handle)
|
||||
{
|
||||
euv_pipe_close_with_cb(handle, NULL);
|
||||
}
|
||||
|
||||
void euv_pipe_disconnect(euv_pipe_t* handle)
|
||||
{
|
||||
if (!handle) {
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ const state_t* hsm_get_previous_state(state_machine_t* sm)
|
|||
|
||||
const char* hsm_get_current_state_name(state_machine_t* sm)
|
||||
{
|
||||
if (!sm) {
|
||||
return NULL;
|
||||
if (!sm || !sm->current_state) {
|
||||
return HSM_NONE_STR;
|
||||
}
|
||||
|
||||
return sm->current_state->state_name;
|
||||
|
|
@ -73,7 +73,7 @@ const char* hsm_get_current_state_name(state_machine_t* sm)
|
|||
const char* hsm_get_state_name(const state_t* state)
|
||||
{
|
||||
if (!state) {
|
||||
return NULL;
|
||||
return HSM_NONE_STR;
|
||||
}
|
||||
|
||||
return state->state_name;
|
||||
|
|
|
|||
|
|
@ -56,11 +56,6 @@ typedef struct {
|
|||
uv_sem_t signal;
|
||||
} signal_msg_t;
|
||||
|
||||
typedef struct {
|
||||
thread_loop_work_t work;
|
||||
uv_sem_t signal;
|
||||
} signal_work_t;
|
||||
|
||||
#if defined(ANDROID)
|
||||
#define LOOP_THREAD_STACK_SIZE 40960
|
||||
#else
|
||||
|
|
@ -184,7 +179,7 @@ int thread_loop_run(uv_loop_t* loop, bool start_thread, const char* name)
|
|||
uv_thread_options_t options = {
|
||||
UV_THREAD_HAS_STACK_SIZE | UV_THREAD_HAS_PRIORITY,
|
||||
LOOP_THREAD_STACK_SIZE,
|
||||
CONFIG_BLUETOOTH_SERVICE_LOOP_THREAD_PRIORITY + 1
|
||||
CONFIG_BLUETOOTH_SERVICE_LOOP_THREAD_PRIORITY
|
||||
};
|
||||
ret = uv_thread_create_ex(&priv->thread, &options, thread_schedule_loop, (void*)loop);
|
||||
if (ret != 0) {
|
||||
|
|
@ -223,10 +218,8 @@ void thread_loop_exit(uv_loop_t* loop)
|
|||
uv_sem_wait(&priv->exited);
|
||||
uv_sem_destroy(&priv->exited);
|
||||
} else {
|
||||
if (!uv_loop_is_close(loop)) {
|
||||
uv_run(loop, UV_RUN_ONCE);
|
||||
(void)uv_loop_close(loop);
|
||||
}
|
||||
uv_run(loop, UV_RUN_ONCE);
|
||||
(void)uv_loop_close(loop);
|
||||
}
|
||||
|
||||
uv_mutex_lock(&priv->msg_lock);
|
||||
|
|
@ -342,48 +335,3 @@ void do_in_thread_loop_sync(uv_loop_t* loop, thread_func_t func, void* data)
|
|||
uv_sem_wait(&msg.signal);
|
||||
uv_sem_destroy(&msg.signal);
|
||||
}
|
||||
|
||||
static void work_sync_cb(uv_work_t* req)
|
||||
{
|
||||
signal_work_t* work = req->data;
|
||||
assert(work);
|
||||
|
||||
if (work->work.work_cb)
|
||||
work->work.work_cb(&work->work, work->work.userdata);
|
||||
}
|
||||
|
||||
static void after_work_sync_cb(uv_work_t* req, int status)
|
||||
{
|
||||
signal_work_t* work = req->data;
|
||||
assert(status == 0);
|
||||
assert(work);
|
||||
|
||||
if (work->work.after_work_cb)
|
||||
work->work.after_work_cb(&work->work, work->work.userdata);
|
||||
|
||||
uv_sem_post(&work->signal);
|
||||
}
|
||||
|
||||
void thread_loop_work_sync(uv_loop_t* loop, void* user_data, thread_work_cb_t work_cb,
|
||||
thread_after_work_cb_t after_work_cb)
|
||||
{
|
||||
signal_work_t* work = (signal_work_t*)calloc(1, sizeof(signal_work_t));
|
||||
if (work == NULL)
|
||||
return;
|
||||
|
||||
work->work.userdata = user_data;
|
||||
work->work.work_cb = work_cb;
|
||||
work->work.after_work_cb = after_work_cb;
|
||||
work->work.work.data = work;
|
||||
uv_sem_init(&work->signal, 0);
|
||||
|
||||
if (uv_queue_work(loop, &work->work.work, work_sync_cb, after_work_sync_cb) != 0) {
|
||||
syslog(LOG_DEBUG, "%s uv_queue_work failed", __func__);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
uv_sem_wait(&work->signal);
|
||||
exit:
|
||||
uv_sem_destroy(&work->signal);
|
||||
free(work);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,248 +82,29 @@ extern "C" {
|
|||
#define BT_AD_FLAG_BREDR_NOT_SUPPORT 4
|
||||
#define BT_AD_FLAG_DUAL_MODE 8
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
typedef struct adv_data {
|
||||
uint8_t len;
|
||||
uint8_t type;
|
||||
uint8_t data[0];
|
||||
} adv_data_t;
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
typedef struct advertiser_data_ advertiser_data_t;
|
||||
|
||||
/**
|
||||
* @brief Advertising data dump callback function.
|
||||
*
|
||||
* Function prototype for dumping advertising data in string format.
|
||||
*
|
||||
* @param str - Null-terminated string to dump.
|
||||
*/
|
||||
typedef void (*ad_dump_cb_t)(const char* str);
|
||||
|
||||
/**
|
||||
* @brief Dump advertising data.
|
||||
*
|
||||
* Parses the advertising data and outputs it using the provided dump callback.
|
||||
*
|
||||
* @param data - Pointer to the advertising data buffer.
|
||||
* @param len - Length of the advertising data buffer.
|
||||
* @param dump - Callback function to output the parsed data.
|
||||
* @return true - Parsing and dumping was successful.
|
||||
* @return false - Parsing failed.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void on_scan_result_cb(bt_scanner_t* scanner, ble_scan_result_t* result)
|
||||
{
|
||||
PRINT_ADDR("ScanResult ------[%s]------", &result->addr);
|
||||
PRINT("AddrType:%d", result->addr_type);
|
||||
PRINT("Rssi:%d", result->rssi);
|
||||
PRINT("Type:%d", result->adv_type);
|
||||
advertiser_data_dump((uint8_t*)result->adv_data, result->length, NULL);
|
||||
PRINT("\n");
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bool advertiser_data_dump(uint8_t* data, uint16_t len, ad_dump_cb_t dump);
|
||||
|
||||
/**
|
||||
* @brief Create a new advertiser data object.
|
||||
*
|
||||
* Allocates and initializes a new advertiser data object.
|
||||
*
|
||||
* @return advertiser_data_t* - Pointer to the new advertiser data object; NULL on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
advertiser_data_t* ad = advertiser_data_new();
|
||||
if (ad == NULL) {
|
||||
// Handle allocation failure
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
advertiser_data_t* advertiser_data_new(void);
|
||||
|
||||
/**
|
||||
* @brief Free an advertiser data object.
|
||||
*
|
||||
* Frees the memory associated with an advertiser data object.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object to free.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
advertiser_data_free(ad);
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_free(advertiser_data_t* ad);
|
||||
|
||||
/**
|
||||
* @brief Build the advertising data buffer.
|
||||
*
|
||||
* Constructs the advertising data buffer from the advertiser data object.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param[out] len - Pointer to store the length of the advertising data buffer.
|
||||
* @return uint8_t* - Pointer to the advertising data buffer; NULL on failure.
|
||||
*
|
||||
* **Note:** The returned buffer should be freed by the caller when no longer needed.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
uint16_t len;
|
||||
uint8_t* data = advertiser_data_build(ad, &len);
|
||||
if (data != NULL) {
|
||||
// Use the advertising data buffer
|
||||
free(data);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t* advertiser_data_build(advertiser_data_t* ad, uint16_t* len);
|
||||
|
||||
/**
|
||||
* @brief Set the device name in advertising data.
|
||||
*
|
||||
* Sets the local device name to be included in the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param name - Null-terminated string containing the device name.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
advertiser_data_set_name(ad, "My Device");
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_set_name(advertiser_data_t* ad, const char* name);
|
||||
|
||||
/**
|
||||
* @brief Set the advertising flags.
|
||||
*
|
||||
* Sets the advertising flags to be included in the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param flags - Advertising flags, see BT_AD_FLAG_* definitions.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
advertiser_data_set_flags(ad, BT_AD_FLAG_GENERAL_DISCOVERABLE | BT_AD_FLAG_BREDR_NOT_SUPPORT);
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_set_flags(advertiser_data_t* ad, uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Set the GAP appearance.
|
||||
*
|
||||
* Sets the GAP appearance value to be included in the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param appearance - Appearance value, see GAP Appearance Values.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
advertiser_data_set_appearance(ad, 0x03C0); // HID Generic
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_set_appearance(advertiser_data_t* ad, uint16_t appearance);
|
||||
|
||||
/**
|
||||
* @brief Add custom data to advertising data.
|
||||
*
|
||||
* Adds a custom AD structure to the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param type - AD type, see BT_AD_* definitions.
|
||||
* @param data - Pointer to the data payload.
|
||||
* @param len - Length of the data payload.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
uint8_t custom_data[] = {0x01, 0x02, 0x03};
|
||||
advertiser_data_add_data(ad, BT_AD_MANUFACTURER_DATA, custom_data, sizeof(custom_data));
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_add_data(advertiser_data_t* ad, uint8_t type, uint8_t* data, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief Remove custom data from advertising data.
|
||||
*
|
||||
* Removes a custom AD structure from the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param type - AD type, see BT_AD_* definitions.
|
||||
* @param data - Pointer to the data payload.
|
||||
* @param len - Length of the data payload.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
advertiser_data_remove_data(ad, BT_AD_MANUFACTURER_DATA, custom_data, sizeof(custom_data));
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_remove_data(advertiser_data_t* ad, uint8_t type, uint8_t* data, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief Add manufacturer-specific data to advertising data.
|
||||
*
|
||||
* Adds manufacturer-specific data to the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param manufacture_id - Manufacturer ID assigned by the Bluetooth SIG.
|
||||
* @param data - Pointer to the manufacturer-specific data.
|
||||
* @param length - Length of the manufacturer-specific data.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
uint8_t manuf_data[] = {0x12, 0x34, 0x56};
|
||||
advertiser_data_add_manufacture_data(ad, 0x038F, manuf_data, sizeof(manuf_data)); // 0x038F is Xiaomi Inc.
|
||||
* @endcode
|
||||
*/
|
||||
void advertiser_data_add_manufacture_data(advertiser_data_t* ad,
|
||||
uint16_t manufacture_id,
|
||||
uint8_t* data, uint8_t length);
|
||||
|
||||
/**
|
||||
* @brief Add a service UUID to advertising data.
|
||||
*
|
||||
* Adds a service UUID to the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param uuid - Pointer to the UUID to add, see @ref bt_uuid_t.
|
||||
* @return true - UUID added successfully.
|
||||
* @return false - Failed to add UUID.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_uuid_t service_uuid;
|
||||
bt_uuid_from_string("0000180D-0000-1000-8000-00805F9B34FB", &service_uuid); // Heart Rate Service
|
||||
advertiser_data_add_service_uuid(ad, &service_uuid);
|
||||
* @endcode
|
||||
*/
|
||||
bool advertiser_data_add_service_uuid(advertiser_data_t* ad, const bt_uuid_t* uuid);
|
||||
|
||||
/**
|
||||
* @brief Add service data to advertising data.
|
||||
*
|
||||
* Adds service-specific data associated with a service UUID to the advertising data.
|
||||
*
|
||||
* @param ad - Pointer to the advertiser data object.
|
||||
* @param uuid - Pointer to the UUID of the service, see @ref bt_uuid_t.
|
||||
* @param data - Pointer to the service data payload.
|
||||
* @param len - Length of the service data payload.
|
||||
* @return true - Service data added successfully.
|
||||
* @return false - Failed to add service data.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_uuid_t service_uuid;
|
||||
bt_uuid_from_string("0000180F-0000-1000-8000-00805F9B34FB", &service_uuid); // Battery Service
|
||||
uint8_t battery_level = 85; // 85%
|
||||
advertiser_data_add_service_data(ad, &service_uuid, &battery_level, 1);
|
||||
* @endcode
|
||||
*/
|
||||
bool advertiser_data_add_service_data(advertiser_data_t* ad,
|
||||
const bt_uuid_t* uuid,
|
||||
uint8_t* data, uint8_t len);
|
||||
|
|
|
|||
|
|
@ -32,10 +32,6 @@ extern "C" {
|
|||
#include "callbacks_list.h"
|
||||
#include "uv_thread_loop.h"
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
#ifndef BTSYMBOLS
|
||||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
|
@ -60,6 +56,17 @@ extern "C" {
|
|||
#endif
|
||||
#endif // End of else
|
||||
|
||||
#define CALLBACK_FOREACH(_list, _struct, _cback, ...) \
|
||||
BT_CALLBACK_FOREACH(_list, _struct, _cback, ##__VA_ARGS__)
|
||||
|
||||
#define CALLBACK_REMOTE(_remote, _type, _cback, ...) \
|
||||
do { \
|
||||
_type* _cbs = (_type*)_remote->callbacks; \
|
||||
if (_cbs && _cbs->_cback) { \
|
||||
_cbs->_cback(_remote, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PRIMARY_ADAPTER 0
|
||||
|
||||
typedef uint8_t bt_controller_id_t;
|
||||
|
|
@ -226,10 +233,16 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
BT_DEBUG_MODE_PTS,
|
||||
BT_DEBUG_MODE_RSSI,
|
||||
} bt_debug_mode_t;
|
||||
|
||||
typedef uint8_t bt_128key_t[16];
|
||||
|
||||
typedef struct {
|
||||
uint8_t hash[16];
|
||||
uint8_t rand[16];
|
||||
} bt_oob_data_t;
|
||||
|
||||
#define COD_SERVICE_BITS(c) (c & 0xFFE000) /* The major service classes field */
|
||||
#define COD_DEVICE_MAJOR_BITS(c) (c & 0x001F00) /* The major device classes field */
|
||||
#define COD_DEVICE_CLASS_BITS(c) (c & 0x001FFC) /* The device classes field, including major and minor */
|
||||
|
|
@ -428,6 +441,10 @@ enum {
|
|||
|
||||
typedef struct bt_instance bt_instance_t;
|
||||
|
||||
typedef bool (*bt_allocator_t)(void** data, uint32_t size);
|
||||
|
||||
typedef void (*bt_hci_event_callback_t)(bt_hci_event_t* hci_event, void* context);
|
||||
|
||||
typedef void (*bt_ipc_connected_cb_t)(bt_instance_t* ins, void* user_data);
|
||||
typedef void (*bt_ipc_disconnected_cb_t)(bt_instance_t* ins, void* user_data, int status);
|
||||
|
||||
|
|
@ -470,11 +487,13 @@ typedef struct bt_instance {
|
|||
callbacks_list_t* a2dp_source_callbacks;
|
||||
callbacks_list_t* avrcp_target_callbacks;
|
||||
callbacks_list_t* avrcp_control_callbacks;
|
||||
callbacks_list_t* cs_callbacks;
|
||||
void* adapter_cookie;
|
||||
void* a2dp_sink_cookie;
|
||||
void* a2dp_source_cookie;
|
||||
void* avrcp_target_cookie;
|
||||
void* avrcp_control_cookie;
|
||||
void* cs_cookie;
|
||||
|
||||
callbacks_list_t* hfp_ag_callbacks;
|
||||
callbacks_list_t* hfp_hf_callbacks;
|
||||
|
|
@ -496,224 +515,60 @@ typedef struct bt_instance {
|
|||
} bt_instance_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Allocate memory
|
||||
*
|
||||
* This function pointer allocates a size of memory and is pointed to the allocated memory by *data
|
||||
*
|
||||
* @param data - pointer of the pointer to the allocated memory
|
||||
* @param size - size of the memory to be allocated
|
||||
* @return bool.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static bool bt_socket_allocator(void** data, uint32_t size)
|
||||
{
|
||||
*data = zalloc(size);
|
||||
if (!(*data))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef bool (*bt_allocator_t)(void** data, uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief hci event callback.
|
||||
*
|
||||
* This function pointer is triggered when hci event is received.
|
||||
*
|
||||
* @param hci_event - pointer of hci event(specified by vendor).
|
||||
* @param context - user context.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void bt_hci_event_callback(bt_hci_event_t* hci_event, void* context)
|
||||
{
|
||||
BT_LOGD("%s, evt_code:0x%x, len:%d", __func__, hci_event->evt_code,
|
||||
hci_event->length);
|
||||
// Handle Context.
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*bt_hci_event_callback_t)(bt_hci_event_t* hci_event, void* context);
|
||||
|
||||
/**
|
||||
* @brief Create bluetooth instance
|
||||
* @brief Create bluetooth client instance
|
||||
*
|
||||
* @return bt_instance_t* - ins on success, NULL on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_instance_t* bluetooth_get_instance(void)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = bluetooth_find_instance(getpid());
|
||||
|
||||
if (bluetooth_ins == NULL)
|
||||
return bluetooth_create_instance();
|
||||
else
|
||||
return bluetooth_ins;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_instance_t* BTSYMBOLS(bluetooth_create_instance)(void);
|
||||
|
||||
/**
|
||||
* @brief Get bluetooth instance, If it does not exist, an instance is created
|
||||
* @brief Get bluetooth client instance, If it does not exist, an instance is created
|
||||
*
|
||||
* @return bt_instance_t* - ins if exist or create success, NULL, if create fail.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_instance_t* bluetooth_get_instance(void)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = bluetooth_find_instance(getpid());
|
||||
|
||||
if (bluetooth_ins == NULL)
|
||||
return bluetooth_create_instance();
|
||||
else
|
||||
return bluetooth_ins;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_instance_t* BTSYMBOLS(bluetooth_get_instance)(void);
|
||||
|
||||
/**
|
||||
* @brief Find bluetooth instance
|
||||
* @brief Find bluetooth client instance
|
||||
*
|
||||
* @return bt_instance_t* - ins if exist, NULL otherwise.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_instance_t* bluetooth_get_instance(void)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = bluetooth_find_instance(getpid());
|
||||
|
||||
if (bluetooth_ins == NULL)
|
||||
return bluetooth_create_instance();
|
||||
else
|
||||
return bluetooth_ins;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_instance_t* BTSYMBOLS(bluetooth_find_instance)(pid_t pid);
|
||||
|
||||
/**
|
||||
* @brief Get profile proxy
|
||||
*
|
||||
* @param ins - bluetooth instance.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id - profile ID.
|
||||
* @return void* - profile proxy.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static bool bt_socket_allocator(void** data, uint32_t size)
|
||||
{
|
||||
*data = zalloc(size);
|
||||
if (!(*data))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
void* BTSYMBOLS(bluetooth_get_proxy)(bt_instance_t* ins, enum profile_id id);
|
||||
|
||||
/**
|
||||
* @brief Delete client instance
|
||||
*
|
||||
* @param ins - bluetooth instance.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
int main(int argc, char** argv) {
|
||||
g_app_ins = bluetooth_create_instance();
|
||||
|
||||
while(1) {
|
||||
// Handle events
|
||||
}
|
||||
|
||||
bluetooth_delete_instance(g_app_ins);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
*/
|
||||
void BTSYMBOLS(bluetooth_delete_instance)(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
* @brief Start profile service
|
||||
*
|
||||
* @param ins - bluetooth instance.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id - profile ID.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
int leac_command_init(void* handle)
|
||||
{
|
||||
bt_status_t ret;
|
||||
|
||||
ret = bluetooth_start_service(handle, PROFILE_LEAUDIO_CLIENT);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
PRINT("%s, failed ret:%d", __func__, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
lea_client_callbacks = bt_lea_client_register_callbacks(handle, &lea_client_cbs);
|
||||
return 0;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bluetooth_start_service)(bt_instance_t* ins, enum profile_id id);
|
||||
|
||||
/**
|
||||
* @brief Stop profile service
|
||||
*
|
||||
* @param ins - bluetooth instance.
|
||||
* @param id - profile ID.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id -profile ID.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void leac_command_uninit(void* handle)
|
||||
{
|
||||
bt_status_t ret;
|
||||
|
||||
bt_lea_client_unregister_callbacks(handle, lea_client_callbacks);
|
||||
ret = bluetooth_stop_service(handle, PROFILE_LEAUDIO_CLIENT);
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
PRINT("%s, failed ret:%d", __func__, ret);
|
||||
}
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bluetooth_stop_service)(bt_instance_t* ins, enum profile_id id);
|
||||
|
||||
/**
|
||||
* @brief Set external uv loop
|
||||
*
|
||||
* This function drops external UV_loop into bluetooth instance.
|
||||
*
|
||||
* @param ins - bluetooth instance.
|
||||
* @param ext_loop - external uv loop.
|
||||
* @return bool - true on success, false on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bool bluetooth_set_external_uv(bt_instance_t* ins, uv_loop_t* ext_loop)
|
||||
{
|
||||
BT_SOCKET_INS_VALID(ins, false);
|
||||
|
||||
ins->external_loop = ext_loop;
|
||||
|
||||
return true;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bool BTSYMBOLS(bluetooth_set_external_uv)(bt_instance_t* ins, uv_loop_t* ext_loop);
|
||||
|
||||
/*
|
||||
|
|
@ -737,23 +592,6 @@ bt_instance_t* bluetooth_create_async_instance(uv_loop_t* loop, bt_ipc_connected
|
|||
*/
|
||||
void bluetooth_delete_async_instance(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
* @brief get bluetooth async client instance
|
||||
*
|
||||
* @param loop uv_loop_t
|
||||
* @param connected client instance connected callback
|
||||
* @param disconnected client instance disconnected callback
|
||||
* @return bt_instance_t* - ins on success, NULL on failure.
|
||||
*/
|
||||
bt_instance_t* bluetooth_get_async_instance(uv_loop_t* loop, bt_ipc_connected_cb_t connected, bt_ipc_disconnected_cb_t disconnected, void* user_data);
|
||||
|
||||
/**
|
||||
* @brief Find bluetooth instance
|
||||
*
|
||||
* @return bt_instance_t* - ins if exist, NULL otherwise.
|
||||
*/
|
||||
bt_instance_t* BTSYMBOLS(bluetooth_find_async_instance)(pid_t pid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@
|
|||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
/**
|
||||
* @brief A2DP audio state
|
||||
*/
|
||||
|
|
@ -32,63 +29,23 @@ typedef enum {
|
|||
A2DP_AUDIO_STATE_STOPPED,
|
||||
A2DP_AUDIO_STATE_STARTED,
|
||||
} a2dp_audio_state_t;
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Callback for A2DP connection state changed.
|
||||
* @brief A2DP connection state changed callback
|
||||
*
|
||||
* There are four states for A2DP connection, namely DISCONNECTED, CONNECTING,
|
||||
* CONNECTED, and DISCONNECTING. During the initialization phase of the A2DP,
|
||||
* it is necessary to register callback functions. This callback is triggered
|
||||
* when there is a change in the state of the A2DP connection.
|
||||
*
|
||||
* Stable States:
|
||||
* DISCONNECTED: The initial state.
|
||||
* CONNECTED: The A2DP connection is established.
|
||||
* Transient states:
|
||||
* CONNECTING: The A2DP connection is being established.
|
||||
* DISCONNECTING: The A2DP connection is being terminated.
|
||||
*
|
||||
* @param cookie - Callback cookie.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param state - A2DP profile connection state.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void on_connection_state_changed_cb(void* cookie, bt_address_t* addr, profile_connection_state_t state)
|
||||
{
|
||||
printf("A2DP connection state is: %d", state);
|
||||
}
|
||||
* @endcode
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer A2DP device.
|
||||
* @param state - connection state.
|
||||
*/
|
||||
typedef void (*a2dp_connection_state_callback)(void* cookie, bt_address_t* addr,
|
||||
profile_connection_state_t state);
|
||||
|
||||
/**
|
||||
* @brief Callback for A2DP audio state changed.
|
||||
* @brief A2DP audio connection state changed callback
|
||||
*
|
||||
* There are three states for A2DP audio, namely SUSPEND, STOPPED,
|
||||
* and STARTED. It is important to note that a callback function
|
||||
* is triggered whenever a change occurs in the audio state.
|
||||
*
|
||||
* Stable States:
|
||||
* SUSPEND: The stream is suspended.
|
||||
* STOPPED: The stream is stopped.
|
||||
* STARTED: The stream is started.
|
||||
*
|
||||
* @param cookie - Callback cookie.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param state - A2DP audio connection state.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void on_audio_state_changed_cb(void* cookie, bt_address_t* addr, a2dp_audio_state_t state)
|
||||
{
|
||||
printf("A2DP audio state is: %d", state);
|
||||
}
|
||||
* @endcode
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer A2DP device.
|
||||
* @param state - audio connection state.
|
||||
*/
|
||||
typedef void (*a2dp_audio_state_callback)(void* cookie, bt_address_t* addr,
|
||||
a2dp_audio_state_t state);
|
||||
|
|
|
|||
|
|
@ -25,30 +25,15 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @brief Callback for A2DP audio configuration.
|
||||
* @brief A2DP audio sink config changed callback
|
||||
*
|
||||
* During the initialization process of the A2DP, callback functions are registered.
|
||||
* This callbacks is triggered whenever a change occurs in the audio configuration
|
||||
* of an A2DP connection.
|
||||
*
|
||||
* @param cookie - Callbacks cookie.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void on_audio_config_changed_cb(void* cookie, bt_address_t* addr)
|
||||
{
|
||||
printf("A2DP audio sink configuration is changed");
|
||||
}
|
||||
* @endcode
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
*/
|
||||
typedef void (*a2dp_audio_sink_config_callback)(void* cookie, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
/**
|
||||
* @brief A2DP Sink callback structure
|
||||
* @brief A2DP sink callback structure
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
|
|
@ -58,209 +43,79 @@ typedef struct {
|
|||
a2dp_audio_state_callback audio_state_cb;
|
||||
a2dp_audio_sink_config_callback audio_sink_config_cb;
|
||||
} a2dp_sink_callbacks_t;
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Register callback functions to A2DP Sink service.
|
||||
* @brief Register callback functions to A2DP sink service
|
||||
*
|
||||
* When initializing the A2DP Sink, an application should register callback functions
|
||||
* to the A2DP Sink service, which includes a connection state callback function, an
|
||||
* audio state callback function, and an audio sink configuration callback function.
|
||||
* Subsequently, the A2DP Sink service will notify the application of any state
|
||||
* changes via the registered callback functions.
|
||||
*
|
||||
* @param ins - Buetooth client instance.
|
||||
* @param callbacks - A2DP Sink callback functions.
|
||||
* @return void* - Callbacks cookie, if the callback is registered successfuly. NULL
|
||||
* if the callback is already registered or registration fails.
|
||||
* To obtain more information, refer to bt_remote_callbacks_register().
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static const a2dp_sink_callbacks_t a2dp_sink_cbs = {
|
||||
sizeof(a2dp_sink_cbs),
|
||||
a2dp_sink_connection_state_cb,
|
||||
a2dp_sink_audio_state_cb,
|
||||
a2dp_sink_audio_config_cb,
|
||||
};
|
||||
|
||||
void a2dp_sink_init(void* ins)
|
||||
{
|
||||
static void* sink_cbks_cookie;
|
||||
|
||||
sink_cbks_cookie = bt_a2dp_sink_register_callbacks(ins, &a2dp_sink_cbs);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id - A2DP sink callback functions.
|
||||
* @return void* - callbacks cookie.
|
||||
*/
|
||||
void* BTSYMBOLS(bt_a2dp_sink_register_callbacks)(bt_instance_t* ins, const a2dp_sink_callbacks_t* callbacks);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback functions from A2DP Sink service.
|
||||
* @brief Unregister callback functions to a2dp sink service
|
||||
*
|
||||
* An application may use this interface to stop listening on the A2DP Sink
|
||||
* callbacks and to release the associated resources.
|
||||
*
|
||||
* @param ins - Buetooth client instance.
|
||||
* @param cookie - Callbacks cookie.
|
||||
* @return true - Callback unregistration successful.
|
||||
* @return false - Callback cookie not found or callback unregistration failed.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void* sink_cbks_cookie = bt_a2dp_sink_register_callbacks(ins, &a2dp_sink_cbs);
|
||||
|
||||
void a2dp_sink_uninit(void* ins)
|
||||
{
|
||||
bt_a2dp_sink_unregister_callbacks(ins, sink_cbks_cookie);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id - callbacks cookie.
|
||||
* @return true - on callback unregister success
|
||||
* @return false - on callback cookie not found
|
||||
*/
|
||||
bool BTSYMBOLS(bt_a2dp_sink_unregister_callbacks)(bt_instance_t* ins, void* cookie);
|
||||
|
||||
/**
|
||||
* @brief Check if A2DP is already connected.
|
||||
* @brief Check A2DP sink is connected
|
||||
*
|
||||
* This function serves the purpose of verifying the connection status of A2DP.
|
||||
* It is important to note that the A2DP profile is deemed connected solely when
|
||||
* the A2DP Sink is either in the Opened or Started state.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return true - A2DP Sink connected.
|
||||
* @return false - A2DP Sink not connected.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void a2dp_sink_connected(void* ins, bt_address_t* addr)
|
||||
{
|
||||
bool ret = bt_a2dp_sink_is_connected(ins, addr);
|
||||
|
||||
printf("A2DP sink is %s", ret? "connected" : "not connected");
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
* @return true - connected.
|
||||
* @return false - not connected.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_a2dp_sink_is_connected)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Check if the stream is being transmitted.
|
||||
* @brief Check A2DP sink is playing
|
||||
*
|
||||
* This function is used to verify the streaming status of the A2DP Sink.
|
||||
* The A2DP Sink can only be deemed as playing when it is in the Started
|
||||
* state and the audio is also in the Started state.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return true - Stream is being transmitted .
|
||||
* @return false - No stream transmission.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
void a2dp_sink_playing(void* ins, bt_address_t* addr)
|
||||
{
|
||||
bool ret = bt_a2dp_sink_is_playing(ins, addr);
|
||||
|
||||
printf("A2DP sink is %s", ret? "playing" : "not playing");
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
* @return true - playing.
|
||||
* @return false - not playing.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_a2dp_sink_is_playing)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Obtain A2DP Sink connection state.
|
||||
* @brief get A2DP sink connection state
|
||||
*
|
||||
* There are four states for A2DP connection, namely DISCONNECTED, CONNECTING,
|
||||
* CONNECTED, and DIACONNECTED. This function is used by the application of
|
||||
* the A2DP Sink to obtain the current state of the A2DP profile connection.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return profile_connection_state_t - A2DP profile connection state.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int get_state_cmd(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int state = bt_a2dp_sink_get_connection_state(ins, addr);
|
||||
|
||||
printf("A2DP sink connection state is: %d", state);
|
||||
|
||||
return state;
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
* @return profile_connection_state_t - connection state.
|
||||
*/
|
||||
profile_connection_state_t BTSYMBOLS(bt_a2dp_sink_get_connection_state)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Establish connection with peer A2DP device.
|
||||
* @brief Establish connection with peer A2DP device
|
||||
*
|
||||
* This function is used to establish an A2DP profile connection with a designated
|
||||
* peer device. Following the successful creation of the A2DP connection, the A2DP
|
||||
* Sink transitions to an Opened state and subsequently notifies the application of
|
||||
* its CONNECTED state. Upon reception of audio data from the A2DP Source device,
|
||||
* the A2DP Sink then proceeds to forward the audio data to the Media.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int a2dp_sink_connect(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int ret = bt_a2dp_sink_connect(ins, addr);
|
||||
|
||||
printf("A2DP sink connect %s", ret ? "failed" : "success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_sink_connect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from peer A2DP device.
|
||||
* @brief Disconnect from peer A2DP device
|
||||
*
|
||||
* This function is utilized for the purpose of disconnecting an A2DP profile connection
|
||||
* with a designated peer device. Upon successful disconnection of the A2DP connection,
|
||||
* the A2DP Sink transitions into an Idle state and subsequently notifies the application
|
||||
* of the DISCONNECTED state.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int a2dp_sink_disconnect(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int ret = bt_a2dp_sink_disconnect(ins, addr);
|
||||
|
||||
printf("A2DP sink disconnect %s", ret ? "failed" : "success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_sink_disconnect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/*
|
||||
* @brief Set a peer A2DP Source device as active device.
|
||||
/**
|
||||
* @brief set a peer A2DP source device as active device
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP source device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int enable_source_device(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int ret = bt_a2dp_sink_set_active_device(ins, addr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_sink_set_active_device)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,28 +26,13 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @brief Callback for A2DP audio configuration.
|
||||
* @brief A2DP audio source config changed callback
|
||||
*
|
||||
* During the initialization process of the A2DP, callback functions are registered.
|
||||
* This callbacks is triggered whenever a change occurs in the audio configuration
|
||||
* of an A2DP connection.
|
||||
*
|
||||
* @param cookie - Callback cookie.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void on_audio_config_changed_cb(void* cookie, bt_address_t* addr)
|
||||
{
|
||||
printf("A2DP audio source configuration is changed");
|
||||
}
|
||||
* @endcode
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
*/
|
||||
typedef void (*a2dp_audio_source_config_callback)(void* cookie, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
/**
|
||||
* @brief A2DP source callback structure
|
||||
*
|
||||
|
|
@ -59,227 +44,87 @@ typedef struct {
|
|||
a2dp_audio_state_callback audio_state_cb;
|
||||
a2dp_audio_source_config_callback audio_source_config_cb;
|
||||
} a2dp_source_callbacks_t;
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Register callback functions to A2DP Source service.
|
||||
* @brief Register callback functions to A2DP source service
|
||||
*
|
||||
* When the A2DP Source is initialized, an application registers various callback
|
||||
* functions to the A2DP Source service, such as the connection state callback function,
|
||||
* audio state callback function, and audio source configuration callback function.
|
||||
* The A2DP Source service will notify the application of any state changes via the
|
||||
* registered callback functions.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param callbacks - A2DP Source callback functions.
|
||||
* @return void* - Callbacks cookie, if the callback is registered successfuly.
|
||||
* NULL if the callback is already registered or registration fails.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static const a2dp_source_callbacks_t a2dp_src_cbs = {
|
||||
sizeof(a2dp_src_cbs),
|
||||
a2dp_src_connection_state_cb,
|
||||
a2dp_src_audio_state_cb,
|
||||
a2dp_src_audio_source_config_cb,
|
||||
};
|
||||
|
||||
void a2dp_source_uninit(void* ins)
|
||||
{
|
||||
static void* src_cbks_cookie;
|
||||
|
||||
src_cbks_cookie = bt_a2dp_source_register_callbacks(ins, &a2dp_src_cbs);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id - A2DP source callback functions.
|
||||
* @return void* - callbacks cookie.
|
||||
*/
|
||||
void* BTSYMBOLS(bt_a2dp_source_register_callbacks)(bt_instance_t* ins, const a2dp_source_callbacks_t* callbacks);
|
||||
|
||||
/**
|
||||
* @brief Unregister callback functions to A2DP Source service.
|
||||
* @brief Unregister callback functions to A2DP source service
|
||||
*
|
||||
* An application may use this interface to stop listening on the A2DP Source
|
||||
* callbacks and to release the associated resources.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param cookie - Callbacks cookie.
|
||||
* @return true - Callback unregistration successful.
|
||||
* @return false - Callback cookie not found or callback unregistration failed.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void* src_cbks_cookie = bt_a2dp_source_register_callbacks(ins, &a2dp_src_cbs);
|
||||
|
||||
void a2dp_source_uninit(void* ins)
|
||||
{
|
||||
bt_a2dp_source_unregister_callbacks(ins, src_cbks_cookie);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param id - callbacks cookie.
|
||||
* @return true - on callback unregister success.
|
||||
* @return false - on callback cookie not found.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_a2dp_source_unregister_callbacks)(bt_instance_t* ins, void* cookie);
|
||||
|
||||
/**
|
||||
* @brief Check if A2DP is already connected.
|
||||
* @brief Check A2DP source is connected
|
||||
*
|
||||
* This function serves the purpose of verifying the connection status of A2DP.
|
||||
* It is important to note that the A2DP profile is deemed connected solely when
|
||||
* the A2DP Source is either in the Opened or Started state.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return true - A2DP Source connected.
|
||||
* @return false - A2DP Source not connected.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void a2dp_source_connected(void* ins, bt_address_t* addr)
|
||||
{
|
||||
bool ret = bt_a2dp_source_is_connected(ins, addr);
|
||||
|
||||
printf("A2DP source is %s", ret? "connected" : "not connected");
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return true - connected.
|
||||
* @return false - not connected.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_a2dp_source_is_connected)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Check if the stream is being transmitted.
|
||||
* @brief Check A2DP source is playing
|
||||
*
|
||||
* This function is used to verify the streaming status of the A2DP Source.
|
||||
* The A2DP Source can only be deemed as playing when it is in the Started
|
||||
* state and the audio is also in the Started state.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return true - Stream is being transmitted.
|
||||
* @return false - No stream transmission.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
void a2dp_source_playing(void* ins, bt_address_t* addr)
|
||||
{
|
||||
bool ret = bt_a2dp_source_is_playing(ins, addr);
|
||||
|
||||
printf("A2DP source is %s", ret? "playing" : "not playing");
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return true - playing.
|
||||
* @return false - not playing.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_a2dp_source_is_playing)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Obtain A2DP Source connection state.
|
||||
* @brief get A2DP source connection state
|
||||
*
|
||||
* There are four states for A2DP connection, namely DISCONNECTED, CONNECTING,
|
||||
* CONNECTED, and DIACONNECTED. This function is used by the application of
|
||||
* the A2DP Source to obtain the current state of the A2DP profile connection.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return profile_connection_state_t - A2DP profile connection state.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int get_state_cmd(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int state = bt_a2dp_source_get_connection_state(ins, addr);
|
||||
|
||||
printf("A2DP source connection state is: %d", state);
|
||||
|
||||
return state;
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return profile_connection_state_t - connection state.
|
||||
*/
|
||||
profile_connection_state_t BTSYMBOLS(bt_a2dp_source_get_connection_state)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Establish connection with peer A2DP device.
|
||||
* @brief Establish connection with peer A2DP device
|
||||
*
|
||||
* This function is used to establish an A2DP profile connection with a designated
|
||||
* peer device. Upon successful establishment of the A2DP connection, the A2DP Source
|
||||
* transitions to an Opened state and notifies the application of its CONNECTED status.
|
||||
* Upon receipt of audio data from the media, the A2DP Source subsequently relays the
|
||||
* audio data to the A2DP Sink.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int a2dp_source_connect(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int ret = bt_a2dp_source_connect(ins, &addr);
|
||||
|
||||
printf("A2DP source connect %s", ret ? "failed" : "success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_connect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from peer A2DP device.
|
||||
* @brief Disconnect from peer A2DP device
|
||||
*
|
||||
* This function is used to remove an A2DP profile connection with a specific peer device. Once
|
||||
* the A2DP connection is removed, the A2DP Source turns into the Idle state and reports the
|
||||
* DISCONNECTED state to the application.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int a2dp_source_disconnect(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int ret = bt_a2dp_source_disconnect(ins, addr);
|
||||
|
||||
printf("A2DP source disconnect %s", ret ? "failed" : "success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_disconnect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Set a peer A2DP Sink device as silence device.
|
||||
* @brief set a peer A2DP sink device as silence device
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param silence - True, switch to silence mode to keep this device inactive.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int disable_sink_device(void* ins, bt_address_t* addr, bool silence)
|
||||
{
|
||||
int ret = bt_a2dp_source_set_silence_device(ins, addr, silence);
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_set_silence_device)(bt_instance_t* ins, bt_address_t* addr, bool silence);
|
||||
|
||||
/**
|
||||
* @brief Set a peer A2DP Sink device as active device.
|
||||
* @brief set a peer A2DP sink device as active device
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer A2DP sink device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example**
|
||||
* @code
|
||||
int enable_sink_device(void* ins, bt_address_t* addr)
|
||||
{
|
||||
int ret = bt_a2dp_source_set_active_device(ins, addr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_a2dp_source_set_active_device)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
|
|
|
|||
|
|
@ -598,12 +598,6 @@ if (bt_adapter_disable(ins) == BT_STATUS_SUCCESS) {
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_disable)(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
* @brief Disable bluetooth adapter safely
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_disable_safe)(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
|
|
@ -656,17 +650,6 @@ bt_device_type_t BTSYMBOLS(bt_adapter_get_type)(bt_instance_t* ins);
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_discovery_filter)(bt_instance_t* ins);
|
||||
|
||||
/**
|
||||
* @brief Start device limited discovery.
|
||||
*
|
||||
* Initiates the device limited discovery process to find nearby Bluetooth devices.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param timeout - Maximum amount of time to perform discovery (Time = N * 1.28s, Range: 1.28s to 61.44s).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success; a negative error code on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_start_limited_discovery)(bt_instance_t* ins, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Start device discovery.
|
||||
*
|
||||
|
|
@ -687,6 +670,8 @@ if (bt_adapter_start_discovery(ins, 10) == BT_STATUS_SUCCESS) {
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_start_discovery)(bt_instance_t* ins, uint32_t timeout);
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_adapter_start_limited_discovery)(bt_instance_t* ins, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Cancel device discovery.
|
||||
*
|
||||
|
|
@ -1150,19 +1135,6 @@ bt_status_t BTSYMBOLS(bt_adapter_le_enable_key_derivation)(bt_instance_t* ins,
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_add_whitelist)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Add a device to the BLE whitelist with specified address type.
|
||||
*
|
||||
* Adds a device address to the BLE whitelist, allowing the caller to specify the address type
|
||||
* (e.g., public or random address).
|
||||
*
|
||||
* @param ins Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param addr Address of the device to add, see @ref bt_address_t.
|
||||
* @param type Address type of the device, see @ref ble_addr_type_t.
|
||||
* @return bt_status_t BT_STATUS_SUCCESS on success; a negative error code on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_le_add_whitelist_with_type)(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Remove a device from the BLE whitelist.
|
||||
*
|
||||
|
|
@ -1199,71 +1171,8 @@ bt_status_t BTSYMBOLS(bt_adapter_set_afh_channel_classification)(bt_instance_t*
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_adapter_set_auto_sniff)(bt_instance_t* ins, bt_auto_sniff_params_t* params);
|
||||
|
||||
// async
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
#include "bt_async.h"
|
||||
|
||||
typedef void (*bt_register_callback_cb_t)(bt_instance_t* ins, bt_status_t status, void* cookie, void* userdata);
|
||||
typedef void (*bt_adapter_get_state_cb_t)(bt_instance_t* ins, bt_status_t status, bt_adapter_state_t state, void* userdata);
|
||||
typedef void (*bt_adapter_get_device_type_cb_t)(bt_instance_t* ins, bt_status_t status, bt_device_type_t type, void* userdata);
|
||||
typedef void (*bt_adapter_get_address_cb_t)(bt_instance_t* ins, bt_status_t status, bt_address_t* addr, void* userdata);
|
||||
typedef void (*bt_adapter_get_io_capability_cb_t)(bt_instance_t* ins, bt_status_t status, bt_io_capability_t cap, void* userdata);
|
||||
typedef void (*bt_adapter_get_scan_mode_cb_t)(bt_instance_t* ins, bt_status_t status, bt_scan_mode_t mode, void* userdata);
|
||||
typedef void (*bt_adapter_get_devices_cb_t)(bt_instance_t* ins, bt_status_t status, bt_address_t* addr, int num, void* userdata);
|
||||
typedef void (*bt_adapter_get_uuids_cb_t)(bt_instance_t* ins, bt_status_t status, bt_uuid_t* uuids, uint16_t size, void* userdata);
|
||||
typedef void (*bt_adapter_get_le_address_cb_t)(bt_instance_t* ins, bt_status_t status, bt_address_t* addr, ble_addr_type_t type, void* userdata);
|
||||
|
||||
bt_status_t bt_adapter_register_callback_async(bt_instance_t* ins,
|
||||
const adapter_callbacks_t* adapter_cbs, bt_register_callback_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_unregister_callback_async(bt_instance_t* ins, void* cookie, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_enable_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_disable_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_enable_le_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_disable_le_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_state_async(bt_instance_t* ins, bt_adapter_get_state_cb_t get_state_cb, void* userdata);
|
||||
bt_status_t bt_adapter_is_le_enabled_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_type_async(bt_instance_t* ins, bt_device_type_cb_t get_dtype_cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_discovery_filter_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_start_discovery_async(bt_instance_t* ins, uint32_t timeout, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_cancel_discovery_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_is_discovering_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_address_async(bt_instance_t* ins, bt_address_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_name_async(bt_instance_t* ins, const char* name, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_name_async(bt_instance_t* ins, bt_string_cb_t get_name_cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_uuids_async(bt_instance_t* ins, bt_uuids_cb_t get_uuids_cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_scan_mode_async(bt_instance_t* ins, bt_scan_mode_t mode, bool bondable, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_scan_mode_async(bt_instance_t* ins, bt_adapter_get_scan_mode_cb_t get_scan_mode_cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_device_class_async(bt_instance_t* ins, uint32_t cod, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_device_class_async(bt_instance_t* ins, bt_u32_cb_t get_cod_cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_io_capability_async(bt_instance_t* ins, bt_io_capability_t cap, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_io_capability_async(bt_instance_t* ins, bt_adapter_get_io_capability_cb_t get_ioc_cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_inquiry_scan_parameters_async(bt_instance_t* ins, bt_scan_type_t type,
|
||||
uint16_t interval, uint16_t window, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_page_scan_parameters_async(bt_instance_t* ins, bt_scan_type_t type,
|
||||
uint16_t interval, uint16_t window, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_le_io_capability_async(bt_instance_t* ins, uint32_t le_io_cap, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_le_io_capability_async(bt_instance_t* ins, bt_u32_cb_t get_le_ioc_cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_le_address_async(bt_instance_t* ins, bt_adapter_get_le_address_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_le_address_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_le_identity_address_async(bt_instance_t* ins, bt_address_t* addr, bool is_public, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_le_appearance_async(bt_instance_t* ins, uint16_t appearance, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_le_appearance_async(bt_instance_t* ins, bt_u16_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_le_enable_key_derivation_async(bt_instance_t* ins,
|
||||
bool brkey_to_lekey, bool lekey_to_brkey, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_le_add_whitelist_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_le_remove_whitelist_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_bonded_devices_async(bt_instance_t* ins, bt_transport_t transport, bt_adapter_get_devices_cb_t get_bonded_cb, void* userdata);
|
||||
bt_status_t bt_adapter_get_connected_devices_async(bt_instance_t* ins, bt_transport_t transport, bt_adapter_get_devices_cb_t get_connected_cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_afh_channel_classification_async(bt_instance_t* ins, uint16_t central_frequency,
|
||||
uint16_t band_width, uint16_t number, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_set_auto_sniff_async(bt_instance_t* ins, bt_auto_sniff_params_t* params, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_disconnect_all_devices_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_is_support_bredr_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_is_support_le_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_adapter_is_support_leaudio_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
#endif /* CONFIG_BLUETOOTH_FRAMEWORK_ASYNC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BT_ADAPTER_H__ */
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ typedef struct bt_le_addr {
|
|||
*/
|
||||
bool bt_addr_is_empty(const bt_address_t* addr);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set a Bluetooth address to empty.
|
||||
*
|
||||
|
|
@ -84,6 +85,7 @@ bool bt_addr_is_empty(const bt_address_t* addr);
|
|||
*/
|
||||
void bt_addr_set_empty(bt_address_t* addr);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Compare two Bluetooth addresses.
|
||||
*
|
||||
|
|
@ -104,6 +106,7 @@ void bt_addr_set_empty(bt_address_t* addr);
|
|||
*/
|
||||
int bt_addr_compare(const bt_address_t* a, const bt_address_t* b);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert a Bluetooth address to a string.
|
||||
*
|
||||
|
|
@ -125,6 +128,7 @@ int bt_addr_compare(const bt_address_t* a, const bt_address_t* b);
|
|||
*/
|
||||
int bt_addr_ba2str(const bt_address_t* addr, char* str);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Convert a string to a Bluetooth address.
|
||||
*
|
||||
|
|
@ -145,6 +149,7 @@ int bt_addr_ba2str(const bt_address_t* addr, char* str);
|
|||
*/
|
||||
int bt_addr_str2ba(const char* str, bt_address_t* addr);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the string representation of a Bluetooth address.
|
||||
*
|
||||
|
|
@ -185,6 +190,7 @@ char* bt_addr_bastr(const bt_address_t* addr);
|
|||
*/
|
||||
void bt_addr_set(bt_address_t* addr, const uint8_t* bd);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Swap byte order of a Bluetooth address.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
#define AVRCP_MAX_ATTR_COUNT 9
|
||||
#define AVRCP_ATTR_MAX_TIELE_LEN 64
|
||||
#define AVRCP_ATTR_MAX_ARTIST_LEN 64
|
||||
|
|
@ -31,9 +34,6 @@
|
|||
#define AVRCP_ATTR_MAX_PLAYING_TIMES_LEN 0
|
||||
#define AVRCP_ATTR_MAX_COVER_ART_HANDLE_LEN 0
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
typedef enum {
|
||||
PASSTHROUGH_CMD_ID_SELECT,
|
||||
PASSTHROUGH_CMD_ID_UP,
|
||||
|
|
@ -111,10 +111,10 @@ typedef enum {
|
|||
PLAY_STATUS_ERROR,
|
||||
} avrcp_play_status_t;
|
||||
|
||||
typedef enum {
|
||||
enum {
|
||||
AVRCP_CAPABILITY_ID_COMPANY_ID = 2,
|
||||
AVRCP_CAPABILITY_ID_EVENTS_SUPPORTED,
|
||||
} avrcp_capability_id_t;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
NOTIFICATION_EVT_PALY_STATUS_CHANGED = 0x01,
|
||||
|
|
@ -156,7 +156,6 @@ typedef enum {
|
|||
AVRCP_ATTR_PLAYING_TIME_MS,
|
||||
AVRCP_ATTR_COVER_ART_HANDLE
|
||||
} avrcp_media_attr_type_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint32_t attr_id;
|
||||
uint16_t chr_set;
|
||||
|
|
@ -45,7 +44,6 @@ typedef struct {
|
|||
avrcp_connection_state_callback connection_state_cb;
|
||||
avrcp_get_element_attribute_cb get_element_attribute_cb;
|
||||
} avrcp_control_callbacks_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
|
@ -107,15 +105,24 @@ void avrcp_control_uninit(void* ins)
|
|||
bool BTSYMBOLS(bt_avrcp_control_unregister_callbacks)(bt_instance_t* ins, void* cookie);
|
||||
|
||||
/**
|
||||
* @brief Get element attribute from peer device.
|
||||
* @brief Get element attributes from AVRCP Target.
|
||||
*
|
||||
* This function is used when an application wants to obtain song information
|
||||
* from an AVRCP Target device, including title, artist name, album name, track
|
||||
* number, total number of tracks, genre, playing time.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - Remote BT address.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_status_t start_get_element_attributes(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_status_t ret = bt_avrcp_control_get_element_attributes(ins, addr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_element_attributes)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
|
|
@ -130,41 +137,12 @@ bt_status_t BTSYMBOLS(bt_avrcp_control_get_element_attributes)(bt_instance_t* in
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_send_passthrough_cmd)(bt_instance_t* ins, bt_address_t* addr, uint8_t cmd, uint8_t state);
|
||||
|
||||
/**
|
||||
* @brief Get unit info from peer device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - Remote BT address.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_unit_info)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Get subunit info from peer device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - Remote BT address.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_subunit_info)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Get playback state from peer device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - Remote BT address.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_get_playback_state)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Register notification to peer device, this interface is used for pts.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - Remote BT address.
|
||||
* @param event - Notification event.
|
||||
* @param interval - Notification interval.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_register_notification)(bt_instance_t* ins, bt_address_t* addr, uint8_t event, uint32_t interval);
|
||||
bt_status_t BTSYMBOLS(bt_avrcp_control_register_notification)(bt_instance_t* ins, bt_address_t* addr, avrcp_notification_event_t event, uint32_t interval);
|
||||
|
||||
#endif /* __BT_AVRCP_CONTROL_H__ */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
#ifndef __INCLUDE_BT_CONFIG_H
|
||||
#define __INCLUDE_BT_CONFIG_H
|
||||
|
||||
// Platform: 32-bit or 64-bit
|
||||
#if defined(CONFIG_ARCH_ARM64) || defined(ARCH_X86_64) || defined(ANDROID) || (!defined(CONFIG_SIM_M32) && defined(CONFIG_ARCH_SIM))
|
||||
#define CONFIG_CPU_BIT64 1
|
||||
#elif defined(ARCH_ARM) || defined(ARCH_X86) || defined(__NuttX__)
|
||||
#define CONFIG_CPU_BIT32 1
|
||||
#endif
|
||||
|
||||
// Configuration of Bluetooth Framework/Service/Stack
|
||||
#if defined(__NuttX__)
|
||||
|
||||
|
|
@ -55,7 +62,7 @@
|
|||
#define CONFIG_BLUETOOTH_LEA_SOURCE_DATA_PATH "lea_source_data"
|
||||
#define CONFIG_BLUETOOTH_MAX_SAVED_REMOTE_UUIDS_LEN 80
|
||||
#define CONFIG_BLUETOOTH_SCO_CTRL_PATH "sco_ctrl"
|
||||
#define CONFIG_BLUETOOTH_L2CAP 1
|
||||
// #define CONFIG_BLUETOOTH_L2CAP 1
|
||||
#define CONFIG_BLUETOOTH_L2CAP_OUTGOING_MTU 2048
|
||||
#define CONFIG_BLUETOOTH_GATTC_MAX_CONNECTIONS 8
|
||||
#define CONFIG_BLUETOOTH_GATTS_MAX_ATTRIBUTE_NUM 10
|
||||
|
|
@ -72,14 +79,14 @@
|
|||
#define CONFIG_BLUETOOTH_SPP_SERVER_MAX_CONNECTIONS 8
|
||||
#define CONFIG_BLUETOOTH_MAX_REGISTER_NUM 4
|
||||
#define CONFIG_BLUETOOTH_FRAMEWORK 1
|
||||
//#define CONFIG_BLUETOOTH_FRAMEWORK_LOCAL 1
|
||||
// #define CONFIG_BLUETOOTH_FRAMEWORK_LOCAL 1
|
||||
#define CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC 1
|
||||
#define CONFIG_BLUETOOTH_SOCKET_PORT 6001
|
||||
#define CONFIG_BLUETOOTH_SERVICE 1
|
||||
//#define CONFIG_BLUETOOTH_SERVER 1
|
||||
// #define CONFIG_BLUETOOTH_SERVER 1
|
||||
#define CONFIG_BLUETOOTH_SERVER_NAME "bluetoothd"
|
||||
#define CONFIG_BLUETOOTH_IPC_JOIN_LOOP 1
|
||||
//#define CONFIG_BLUETOOTH_SERVICE_LOG_LEVEL 7
|
||||
// #define CONFIG_BLUETOOTH_SERVICE_LOG_LEVEL 7
|
||||
#define CONFIG_BLUETOOTH_SERVICE_HCI_UART_NAME "/dev/ttyHCI0"
|
||||
#define CONFIG_BLUETOOTH_STACK_BREDR_BLUELET 1
|
||||
#define CONFIG_BLUETOOTH_STACK_LE_BLUELET 1
|
||||
|
|
@ -92,14 +99,17 @@
|
|||
#define CONFIG_NET_RPMSG 1
|
||||
|
||||
// Socket: via IPv4
|
||||
//#define CONFIG_NET_IPv4 1
|
||||
//#define CONFIG_BLUETOOTH_NET_IPv4 1
|
||||
// #define CONFIG_NET_IPv4 1
|
||||
// #define CONFIG_BLUETOOTH_NET_IPv4 1
|
||||
#define CONFIG_INADDR_LOOPBACK 0x0A000202
|
||||
// SPP
|
||||
#define CONFIG_RPMSG_UART 1
|
||||
|
||||
// SPP via RPMsg UART "/dev/ttyDROID"
|
||||
//#define CONFIG_RPMSG_UART 1
|
||||
// #define CONFIG_RPMSG_UART 1
|
||||
|
||||
// SPP via RPMsg socket/pipe
|
||||
#define CONFIG_BLUETOOTH_SPP_RPMSG_NET 1
|
||||
|
||||
/********************* O95 Project Only *********************/
|
||||
#if defined(ANDROID_12)
|
||||
|
|
@ -107,7 +117,7 @@
|
|||
#define CONFIG_BLUETOOTH_RPMSG_CPUNAME "ap"
|
||||
|
||||
/********************* O61 Project Only *********************/
|
||||
#elif defined(ANDROID_14) || defined(ANDROID_15)
|
||||
#elif defined(ANDROID_14)
|
||||
// Socket: RPMsg
|
||||
#define CONFIG_BLUETOOTH_RPMSG_CPUNAME "cp"
|
||||
// A2DP
|
||||
|
|
@ -121,14 +131,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
// Platform: 32-bit or 64-bit
|
||||
#if defined(CONFIG_ARCH_ARM64) || defined(ARCH_X86_64) || defined(ANDROID) || (!defined(CONFIG_SIM_M32) && defined(CONFIG_ARCH_SIM)) || defined(CONFIG_ARCH_X86_64)
|
||||
#define CONFIG_CPU_BIT64 1
|
||||
#elif defined(ARCH_ARM) || defined(ARCH_X86)
|
||||
#define CONFIG_CPU_BIT32 1
|
||||
#endif
|
||||
|
||||
//############################################################################
|
||||
// ############################################################################
|
||||
#define CONFIG_y 1
|
||||
#define CONFIG_m 2
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,203 @@
|
|||
/****************************************************************************
|
||||
* 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_CS_H__
|
||||
#define __BT_CS_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "bt_addr.h"
|
||||
|
||||
#ifndef BTSYMBOLS
|
||||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
||||
#define MAX_TEST_DATA 128
|
||||
|
||||
typedef struct {
|
||||
uint8_t centimeter;
|
||||
uint8_t error_centimeter;
|
||||
uint8_t azimuth_angle;
|
||||
uint8_t error_azimuthAngle;
|
||||
uint8_t altitude_angle;
|
||||
uint8_t error_altitudeAngle;
|
||||
long elapsed_realtime_nanos;
|
||||
uint8_t confidence_level;
|
||||
double delay_spread_meters;
|
||||
uint8_t detected_attack_level;
|
||||
double velocity_meters_persecond;
|
||||
uint8_t method;
|
||||
} bt_distance_measurement_result_t;
|
||||
|
||||
typedef void (*cs_distance_measure_started_cb)(void* cookie, bt_address_t* addr, uint8_t method);
|
||||
typedef void (*cs_distance_measure_stopped_cb)(void* cookie, bt_address_t* addr, uint8_t reason, uint8_t method);
|
||||
typedef void (*cs_distance_measure_result_cb)(void* cookie, bt_address_t* addr, bt_distance_measurement_result_t* result);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
typedef struct {
|
||||
bt_address_t addr;
|
||||
uint8_t method;
|
||||
uint8_t role;
|
||||
uint16_t interval_ms;
|
||||
uint16_t duration_ms;
|
||||
uint8_t submode;
|
||||
uint8_t max_steps;
|
||||
uint8_t mode0_steps;
|
||||
uint8_t rtt_type;
|
||||
uint8_t sync_phy;
|
||||
uint8_t channel_map;
|
||||
uint8_t antenna_paths_mask;
|
||||
uint8_t vendor_specific;
|
||||
uint8_t debug_flags;
|
||||
} bt_distance_measurement_params_t;
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
cs_distance_measure_started_cb cs_distance_measure_started_cb;
|
||||
cs_distance_measure_stopped_cb cs_distance_measure_stopped_cb;
|
||||
cs_distance_measure_result_cb cs_distance_measure_result_cb;
|
||||
} cs_callbacks_t;
|
||||
|
||||
typedef enum {
|
||||
METHOD_AUTO,
|
||||
METHOD_RSSI,
|
||||
METHOD_CS,
|
||||
} cs_method_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief register cs event callback
|
||||
*
|
||||
* register cs event callback.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param callbacks cs event callback function.
|
||||
* @return cookie of cs event callback.
|
||||
*/
|
||||
void* BTSYMBOLS(bt_cs_register_callbacks)(bt_instance_t* ins, const cs_callbacks_t* callbacks);
|
||||
|
||||
/**
|
||||
* @brief unregister cs event callback
|
||||
*
|
||||
* unregister cs event callback.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param cookie cookie of cs event callback.
|
||||
* @return true if success, false otherwise.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_cs_unregister_callbacks)(bt_instance_t* ins, void* cookie);
|
||||
|
||||
/**
|
||||
* @brief start distance measurement
|
||||
*
|
||||
* start distance measurement.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param params distance measurement parameters.
|
||||
* @return bt_status_t.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_cs_start_distance_measurement)(bt_instance_t* ins, const bt_distance_measurement_params_t* params);
|
||||
|
||||
/**
|
||||
* @brief stop distance measurement
|
||||
*
|
||||
* stop distance measurement.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param addr remote device address.
|
||||
* @param method method of distance measurement.
|
||||
* @param timeout timeout flag.
|
||||
* @return bt_status_t.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_cs_stop_distance_measurement)(bt_instance_t* ins, bt_address_t* addr, uint8_t method, bool timeout);
|
||||
|
||||
/**
|
||||
* @brief get max supported security level
|
||||
*
|
||||
* get max supported security level of remote device.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param addr remote device address.
|
||||
* @return bt_status_t.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_get_cs_max_supported_security_level)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief RAS feature bits for ras_feature field
|
||||
*/
|
||||
#define BT_CS_RAS_REAL_TIME_RANGING_DATA 0x01 /**< Bit 0: Real-time Ranging Data */
|
||||
#define BT_CS_RAS_RETRIEVE_LOST_DATA_SEGMENTS 0x02 /**< Bit 1: Retrieve Lost Ranging Data Segments */
|
||||
#define BT_CS_RAS_ABORT_OPERATION 0x04 /**< Bit 2: Abort Operation */
|
||||
#define BT_CS_RAS_FILTER_RANGING_DATA 0x08 /**< Bit 3: Filter Ranging Data */
|
||||
|
||||
/**
|
||||
* @brief CS_SYNC antenna selection values
|
||||
*/
|
||||
#define BT_CS_ANTENNA_SEL_1 0x01 /**< Use antenna identifier 1 */
|
||||
#define BT_CS_ANTENNA_SEL_2 0x02 /**< Use antenna identifier 2 */
|
||||
#define BT_CS_ANTENNA_SEL_3 0x03 /**< Use antenna identifier 3 */
|
||||
#define BT_CS_ANTENNA_SEL_4 0x04 /**< Use antenna identifier 4 */
|
||||
#define BT_CS_ANTENNA_SEL_SINGLE_REPEATE 0xFD /**< Antenna identifiers in repetitive order (0x01, 0x01, ..., Num_Antennae_Supported, Num_Antennae_Supported) */
|
||||
#define BT_CS_ANTENNA_SEL_DOUBLE_REPEATE 0xFE /**< Antenna identifiers in repetitive order from 0x01 to Num_Antennae_Supported */
|
||||
#define BT_CS_ANTENNA_SEL_NO_RECOMMEND 0xFF /**< Host does not have a recommendation */
|
||||
|
||||
/**
|
||||
* @brief CS configuration parameters for set command
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t ras_feature; /**< RAS feature bits: Bit 0 (0x01): Real-time Ranging Data,
|
||||
Bit 1 (0x02): Retrieve Lost Ranging Data Segments,
|
||||
Bit 2 (0x04): Abort Operation,
|
||||
Bit 3 (0x08): Filter Ranging Data */
|
||||
uint8_t role; /**< CS role bits: Bit 0 (0x01): initiator, Bit 1 (0x02): reflector */
|
||||
uint8_t cs_sync_antenna_selection; /**< Antenna selection for CS_SYNC packets, see BT_CS_ANTENNA_SEL_* macros */
|
||||
int8_t max_tx_power; /**< Maximum TX power in dBm (-127 to 20) */
|
||||
} bt_cs_set_params_t;
|
||||
|
||||
/**
|
||||
* @brief set CS configuration
|
||||
*
|
||||
* set CS configuration including RAS feature and default settings.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param addr remote device address.
|
||||
* @param params CS configuration parameters, see @ref bt_cs_set_params_t.
|
||||
* @return bt_status_t.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_cs_set_config)(bt_instance_t* ins, bt_address_t* addr, const bt_cs_set_params_t* params);
|
||||
|
||||
#ifdef CONFIG_BT_CS_RAS_TEST
|
||||
/**
|
||||
* @brief test function
|
||||
*
|
||||
* test function.
|
||||
*
|
||||
* @param ins bt instance.
|
||||
* @param data test subevent result data.
|
||||
* @param len length of test data.
|
||||
* @return bt_status_t.
|
||||
* @note only for test.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_cs_test)(bt_instance_t* ins, const void* data, uint16_t len);
|
||||
#endif /* CONFIG_BT_CS_RAS_TEST */
|
||||
|
||||
#endif /* __BT_CS_H__ */
|
||||
|
|
@ -755,25 +755,6 @@ if (bt_device_connect(ins, &addr) == BT_STATUS_SUCCESS) {
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_device_connect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Connect to peer device with specific Profiles. And open reconnect method.
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - remote device address.if addr is NULL, connect last device in bonded list.
|
||||
* @param transport - transport type (0:BLE, 1:BREDR).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_device_background_connect(ins, &addr, BT_TRANSPORT_BREDR) == BT_STATUS_SUCCESS) {
|
||||
// connection initiated successfully
|
||||
} else {
|
||||
// Handle error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_device_background_connect)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from a remote device.
|
||||
*
|
||||
|
|
@ -794,25 +775,6 @@ if (bt_device_disconnect(ins, &addr) == BT_STATUS_SUCCESS) {
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_device_disconnect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Disconnect specific prfoiles.
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - remote device address.
|
||||
* @param transport - transport type (0:BLE, 1:BREDR).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_device_background_disconnect(ins, &addr, BT_TRANSPORT_BREDR) == BT_STATUS_SUCCESS) {
|
||||
// Disconnection initiated successfully
|
||||
} else {
|
||||
// Handle error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_device_background_disconnect)(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport);
|
||||
|
||||
/**
|
||||
* @brief Connect to a remote LE device.
|
||||
*
|
||||
|
|
@ -885,65 +847,29 @@ void BTSYMBOLS(bt_device_connect_all_profile)(bt_instance_t* ins, bt_address_t*
|
|||
void BTSYMBOLS(bt_device_disconnect_all_profile)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Enable connection enhanced mode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - remote device address.
|
||||
* @param mode - enhanced mode.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
* @brief Enable enhanced mode for a connection.
|
||||
*
|
||||
* Enables an enhanced mode (e.g., eSCO, sniff mode) for a connection with a remote device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param addr - Address of the remote device.
|
||||
* @param mode - Enhanced mode to enable, see @ref bt_enhanced_mode_t.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success; a negative error code on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_device_enable_enhanced_mode)(bt_instance_t* ins, bt_address_t* addr, bt_enhanced_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Disable connection enhanced mode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - remote device address.
|
||||
* @param mode - enhanced mode.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
* @brief Disable enhanced mode for a connection.
|
||||
*
|
||||
* Disables an enhanced mode (e.g., eSCO, sniff mode) for a connection with a remote device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param addr - Address of the remote device.
|
||||
* @param mode - Enhanced mode to disable, see @ref bt_enhanced_mode_t.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success; a negative error code on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_device_disable_enhanced_mode)(bt_instance_t* ins, bt_address_t* addr, bt_enhanced_mode_t mode);
|
||||
|
||||
// async
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
#include "bt_async.h"
|
||||
|
||||
typedef void (*bt_device_get_bond_state_cb_t)(bt_instance_t* ins, bt_status_t status, bond_state_t bstate, void* userdata);
|
||||
typedef void (*bt_device_get_address_type_cb_t)(bt_instance_t* ins, bt_status_t status, ble_addr_type_t atype, void* userdata);
|
||||
|
||||
bt_status_t bt_device_get_identity_address_async(bt_instance_t* ins, bt_address_t* bd_addr, bt_address_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_address_type_async(bt_instance_t* ins, bt_address_t* addr, bt_device_get_address_type_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_device_type_async(bt_instance_t* ins, bt_address_t* addr, bt_device_type_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_name_async(bt_instance_t* ins, bt_address_t* addr, bt_string_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_device_class_async(bt_instance_t* ins, bt_address_t* addr, bt_u32_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_uuids_async(bt_instance_t* ins, bt_address_t* addr, bt_uuids_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_appearance_async(bt_instance_t* ins, bt_address_t* addr, bt_u16_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_rssi_async(bt_instance_t* ins, bt_address_t* addr, bt_s8_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_alias_async(bt_instance_t* ins, bt_address_t* addr, bt_string_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_alias_async(bt_instance_t* ins, bt_address_t* addr, const char* alias, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_is_connected_async(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_is_encrypted_async(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_is_bond_initiate_local_async(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_bond_state_async(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport, bt_device_get_bond_state_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_is_bonded_async(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport, bt_bool_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_connect_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_disconnect_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_connect_le_async(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t type, ble_connect_params_t* param, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_disconnect_le_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_connect_request_reply_async(bt_instance_t* ins, bt_address_t* addr, bool accept, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_connect_all_profile_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_disconnect_all_profile_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_le_phy_async(bt_instance_t* ins, bt_address_t* addr, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_create_bond_async(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_remove_bond_async(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_cancel_bond_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_pair_request_reply_async(bt_instance_t* ins, bt_address_t* addr, bool accept, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_pairing_confirmation_async(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bool accept, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_pin_code_async(bt_instance_t* ins, bt_address_t* addr, bool accept, char* pincode, int len, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_pass_key_async(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bool accept, uint32_t passkey, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_le_legacy_tk_async(bt_instance_t* ins, bt_address_t* addr, bt_128key_t tk_val, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_set_le_sc_remote_oob_data_async(bt_instance_t* ins, bt_address_t* addr, bt_128key_t c_val, bt_128key_t r_val, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_device_get_le_sc_local_oob_data_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ extern "C" {
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "bt_uuid.h"
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
|
@ -145,23 +147,22 @@ typedef enum {
|
|||
|
||||
/* GATT_H_DESCRIPTOR */
|
||||
#define GATT_H_CEPD(_value, _length, _handle) \
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(0x2900), GATT_PERM_READ, ATTR_AUTO_RSP, NULL, NULL, _value, _length, _handle)
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(BT_UUID_GATT_CEPD), GATT_PERM_READ, ATTR_AUTO_RSP, NULL, NULL, _value, _length, _handle)
|
||||
|
||||
/* GATT_H_DESCRIPTOR */
|
||||
#define GATT_H_CUDD(_value, _length, _handle) \
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(0x2901), GATT_PERM_READ, ATTR_AUTO_RSP, NULL, NULL, _value, _length, _handle)
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(BT_UUID_GATT_CUDD), GATT_PERM_READ, ATTR_AUTO_RSP, NULL, NULL, _value, _length, _handle)
|
||||
|
||||
/* GATT_H_DESCRIPTOR */
|
||||
#define GATT_H_CCCD(_perm, _change, _handle) \
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(0x2902), _perm, ATTR_AUTO_RSP_CCC_READ, NULL, _change, NULL, 0, _handle)
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(BT_UUID_GATT_CCCD), _perm, ATTR_AUTO_RSP_CCC_READ, NULL, _change, NULL, 0, _handle)
|
||||
|
||||
/* GATT_H_DESCRIPTOR for CCCD with user response (APP handles read/write) */
|
||||
#define GATT_H_CCCD_USER_RSP(_perm, _read, _write, _handle) \
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(0x2902), _perm, ATTR_RSP_BY_APP, _read, _write, NULL, 0, _handle)
|
||||
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(BT_UUID_GATT_CCCD), _perm, ATTR_RSP_BY_APP, _read, _write, NULL, 0, _handle)
|
||||
/* GATT_H_DESCRIPTOR */
|
||||
#define GATT_H_CPFD(_value, _length, _handle) \
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(0x2904), GATT_PERM_READ, ATTR_AUTO_RSP, NULL, NULL, _value, _length, _handle)
|
||||
GATT_H_DESCRIPTOR(BT_UUID_DECLARE_16(BT_UUID_GATT_CPFD), GATT_PERM_READ, ATTR_AUTO_RSP, NULL, NULL, _value, _length, _handle)
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
|
|
|
|||
|
|
@ -133,11 +133,10 @@ typedef void (*bt_gattc_feature_delete_client_cb_t)(bt_instance_t* ins, gatt_sta
|
|||
* @param ins Bluetooth instance.
|
||||
* @param status Operation status.
|
||||
* @param conn_handle Connection handle.
|
||||
* @param services Array of discovered services (pointer array).
|
||||
* @param count Number of services in the array.
|
||||
* @param service Retrieved service (single entry).
|
||||
*/
|
||||
typedef void (*bt_gattc_feature_get_service_cb_t)(bt_instance_t* ins, gatt_status_t status, gattc_handle_t conn_handle,
|
||||
const gatt_service_t* services[], size_t count);
|
||||
const gatt_service_t* service);
|
||||
|
||||
/**
|
||||
* @brief Read characteristic callback.
|
||||
|
|
@ -233,13 +232,13 @@ bt_status_t bt_gattc_feature_create_client_async(bt_instance_t* ins, bt_address_
|
|||
|
||||
/**
|
||||
* @brief Delete GATT client.
|
||||
* @param ins Bluetooth instance.
|
||||
* @param conn_handle Connection handle (from create).
|
||||
* @param cb Async call status callback.
|
||||
* @param userdata User context.
|
||||
* @param ins Bluetooth instance.
|
||||
* @param addr Remote device address.
|
||||
* @param cb Delete completion callback.
|
||||
* @param userdata User context.
|
||||
* @return bt_status_t
|
||||
*/
|
||||
bt_status_t bt_gattc_feature_delete_client_async(bt_instance_t* ins, gattc_handle_t conn_handle,
|
||||
bt_status_t bt_gattc_feature_delete_client_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_gattc_feature_delete_client_cb_t cb, void* userdata);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ extern "C" {
|
|||
#include "bt_uuid.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
#ifndef BTSYMBOLS
|
||||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
|
@ -47,300 +43,20 @@ typedef struct {
|
|||
|
||||
} gatt_attr_desc_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief callback for connected as GATT client.
|
||||
*
|
||||
* This callback is triggered when gattc connected. BT Service use this callback to notify the application calling
|
||||
* bt_gattc_connect that gattc connection has been established.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param addr - remote device address.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void connect_callback(void* conn_handle, bt_address_t* addr)
|
||||
{
|
||||
gattc_device_t* device = find_gattc_device(conn_handle);
|
||||
|
||||
assert(device);
|
||||
memcpy(&device->remote_address, addr, sizeof(bt_address_t));
|
||||
device->conn_state = CONNECTION_STATE_CONNECTED;
|
||||
PRINT_ADDR("gattc_connect_callback, addr:%s", addr);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_connected_cb_t)(gattc_handle_t conn_handle, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief callback for disconnected as GATT client.
|
||||
*
|
||||
* This callback is triggered when gattc disconnected. BT Service use this callback to notify the application that
|
||||
* the gattc connection is destroyed.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param addr - remote device address.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void disconnect_callback(void* conn_handle, bt_address_t* addr)
|
||||
{
|
||||
gattc_device_t* device = find_gattc_device(conn_handle);
|
||||
|
||||
assert(device);
|
||||
device->conn_state = CONNECTION_STATE_DISCONNECTED;
|
||||
PRINT_ADDR("gattc_disconnect_callback, addr:%s", addr);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_disconnected_cb_t)(gattc_handle_t conn_handle, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client execute Services discover operation.
|
||||
*
|
||||
* This callback is triggered when application initiating service discovery procedure to peer GATT server.
|
||||
* BT Service use this callback to report the result of attributes.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param uuid - uuid of the attribute. uuid == NULL or uuid->type == 0 means discovery procedure completed.
|
||||
* @param start_handle - start handle of Primary services(Secondary services).
|
||||
* @param end_handle - end handle of Primary services(Secondary services).
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void discover_callback(void* conn_handle, gatt_status_t status, bt_uuid_t* uuid, uint16_t start_handle, uint16_t end_handle)
|
||||
{
|
||||
PRINT("gattc_discover_callback result, attr_handle: 0x%04x - 0x%04x", start_handle, end_handle);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_discover_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, bt_uuid_t* uuid, uint16_t start_handle, uint16_t end_handle);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client excute Exchange MTU operation.
|
||||
*
|
||||
* This callback is triggered when application initiating Exchange MTU procedure to peer GATT server.
|
||||
* BT Service use this callback to Report the results of MTU negotiation.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param mtu - negotiated MTU.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void mtu_updated_callback(void* conn_handle, gatt_status_t status, uint32_t mtu)
|
||||
{
|
||||
gattc_device_t* device = find_gattc_device(conn_handle);
|
||||
|
||||
assert(device);
|
||||
if (status == GATT_STATUS_SUCCESS) {
|
||||
device->gatt_mtu = mtu;
|
||||
}
|
||||
PRINT("gattc_mtu_updated_callback, status:%d, mtu:%" PRIu32, status, mtu);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_mtu_updated_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, uint32_t mtu);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client excute attribute read operation.
|
||||
*
|
||||
* This callback is triggered when application initiating read procedure to peer GATT server.
|
||||
* BT Service use this callback to Report the attribute value of corresponding attribute.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param attr_handle - attribute handle.
|
||||
* @param value - attribute value.
|
||||
* @param length - attribute value length.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void read_complete_callback(void* conn_handle, gatt_status_t status, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
PRINT("gattc connection read complete, handle 0x%" PRIx16 ", status:%d", attr_handle, status);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_read_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, uint16_t attr_handle, uint8_t* value, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client excute attribute read operation.
|
||||
*
|
||||
* This callback is triggered when application initiating write procedure to peer GATT server.
|
||||
* BT Service use this callback to Report the status of write procedure to corresponding attribute.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param attr_handle - attribute handle.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void write_complete_callback(void* conn_handle, gatt_status_t status, uint16_t attr_handle)
|
||||
{
|
||||
if (status != GATT_STATUS_SUCCESS) {
|
||||
PRINT("gattc connection write failed, handle 0x%" PRIx16 ", status:%d", attr_handle, status);
|
||||
return;
|
||||
}
|
||||
|
||||
if (throughtput_cursor) {
|
||||
throughtput_cursor--;
|
||||
} else {
|
||||
PRINT("gattc connection write complete, handle 0x%" PRIx16 ", status:%d", attr_handle, status);
|
||||
}
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_write_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, uint16_t attr_handle);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client excute enable/disable cccd operation.
|
||||
*
|
||||
* This callback is triggered when application initiating enable/disable to corresponding cccd.
|
||||
* BT Service use this callback to Report the value of corresponding cccd.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param attr_handle - attribute handle.
|
||||
* @param enable - enable/disable flag.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void subscribe_complete_callback(void* conn_handle, gatt_status_t status, uint16_t attr_handle, bool enable)
|
||||
{
|
||||
PRINT("gattc connection subscribe complete, handle 0x%" PRIx16 ", status:%d, enable:%d", attr_handle, status, enable);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_subscribe_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, uint16_t attr_handle, bool enable);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client recv notification/indication from peer GATT server.
|
||||
*
|
||||
* This callback is triggered when Peer GATT Server initiating notify/indicate procedure. BT Service use this callback
|
||||
* to Report the notify/indicate value received.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param attr_handle - attribute handle.
|
||||
* @param value - notify/indicate value.
|
||||
* @param length - notify/indicate value length.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void notify_received_callback(void* conn_handle, uint16_t attr_handle,
|
||||
uint8_t* value, uint16_t length)
|
||||
{
|
||||
PRINT("gattc connection receive notify, handle 0x%" PRIx16, attr_handle);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_notify_cb_t)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client execute read PHY.
|
||||
*
|
||||
* This callback is triggered when application initiating read PHY procedure. BT Service use this callback to Report
|
||||
* the Tx PHY & Rx PHY.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param tx_phy - current Tx PHY.
|
||||
* @param rx_phy - current Rx PHY.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void phy_read_callback(void* conn_handle, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy)
|
||||
{
|
||||
PRINT("gattc read phy complete, tx:%d, rx:%d", tx_phy, rx_phy);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_phy_read_cb_t)(gattc_handle_t conn_handle, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client execute update PHY operation.
|
||||
*
|
||||
* This callback is triggered when application initiating update PHY procedure. BT Service use this callback to Report
|
||||
* the result of update Tx PHY & Rx PHY.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param tx_phy - Tx PHY after update. If update operation failed, keep original value.
|
||||
* @param rx_phy - Rx PHY after update. If update operation failed, keep original value.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void phy_updated_callback(void* conn_handle, gatt_status_t status, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy)
|
||||
{
|
||||
PRINT("gattc_phy_updated_callback, status:%d, tx:%d, rx:%d", status, tx_phy, rx_phy);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_phy_updated_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, ble_phy_type_t tx_phy, ble_phy_type_t rx_phy);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client execute read RSSI of remote device.
|
||||
*
|
||||
* This callback is triggered when application initiating read remote RSSI procedure. BT Service use this callback to
|
||||
* Report the RSSI of remote device.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param RSSI - value of remote RSSI.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void rssi_read_callback(void* conn_handle, gatt_status_t status, int32_t rssi)
|
||||
{
|
||||
PRINT("gattc read rssi complete, status:%d, rssi:%" PRIi32, status, rssi);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_rssi_read_cb_t)(gattc_handle_t conn_handle, gatt_status_t status, int32_t rssi);
|
||||
|
||||
/**
|
||||
* @brief callback for GATT client execute connnection parameter update operation.
|
||||
*
|
||||
* This callback is triggered when application initiating connnection parameter update procedure. BT Service use this
|
||||
* callback to Report the connection parameter.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*). The Caller use gattc_connection_t as real parameter.
|
||||
* @param status - bt_status_t - GATT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
* @param connection_interval - connection interval(n * 1.25ms).
|
||||
* @param peripheral_latency - peripheral latency.
|
||||
* @param supervision_timeout - supervision timeout(n * 10ms).
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
static void conn_param_updated_callback(void* conn_handle, bt_status_t status, uint16_t connection_interval,
|
||||
uint16_t peripheral_latency, uint16_t supervision_timeout)
|
||||
{
|
||||
PRINT("gattc connection paramter updated, status:%d, interval:%" PRIu16 ", latency:%" PRIu16 ", timeout:%" PRIu16,
|
||||
status, connection_interval, peripheral_latency, supervision_timeout);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*gattc_connection_parameter_updated_cb_t)(gattc_handle_t conn_handle, bt_status_t status, uint16_t connection_interval,
|
||||
uint16_t peripheral_latency, uint16_t supervision_timeout);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
gattc_connected_cb_t on_connected;
|
||||
|
|
@ -357,368 +73,24 @@ typedef struct {
|
|||
gattc_connection_parameter_updated_cb_t on_conn_param_updated;
|
||||
} gattc_callbacks_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief create a gatt client.
|
||||
*
|
||||
* This function is used to create a gatt client.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param phandle - pointer of gattc connection handle(void*).
|
||||
* @param callbacks - gattc callback table.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_create_connect(handle, &g_gattc_devies[conn_id].handle, &gattc_cbs) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_create_connect)(bt_instance_t* ins, gattc_handle_t* phandle, gattc_callbacks_t* callbacks);
|
||||
|
||||
/**
|
||||
* @brief delete a gatt client.
|
||||
*
|
||||
* This function is used to delete a gatt client.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_delete_connect(g_gattc_devies[conn_id].handle) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_delete_connect)(gattc_handle_t conn_handle);
|
||||
|
||||
/**
|
||||
* @brief create a ATT bearer with peer device.
|
||||
*
|
||||
* This function is used to establish a ATT bearer.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param addr - peer bluetooth device address.
|
||||
* @param addr_type - peer address type(ble_addr_type_t).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_connect(g_gattc_devies[conn_id].handle, &addr, BT_LE_ADDR_TYPE_UNKNOWN) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_connect)(gattc_handle_t conn_handle, bt_address_t* addr, ble_addr_type_t addr_type);
|
||||
|
||||
/**
|
||||
* @brief dicconnect ATT bearer.
|
||||
*
|
||||
* This function is used to initiate a disconnection.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_disconnect(g_gattc_devies[conn_id].handle) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_disconnect)(gattc_handle_t conn_handle);
|
||||
|
||||
/**
|
||||
* @brief discover all GATT services or service with specific UUIDs on peer GATT Server.
|
||||
*
|
||||
* This function is used to discover GATT services. If filter_uuid is NULL, all services will be discovered.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param filter_uuid - UUID of service to be discovered. filter_uuid is NULL for discover all service of peer device
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_discover_service(g_gattc_devies[conn_id].handle, NULL) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_discover_service)(gattc_handle_t conn_handle, bt_uuid_t* filter_uuid);
|
||||
|
||||
/**
|
||||
* @brief get attribute by specific Attribute handle.
|
||||
*
|
||||
* This function is used to get attribute by specific Attribute handle, which is stored after Discover Services procedure.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param attr_handle - attribute handle being found.
|
||||
* @param attr_desc - attribute structure(Type, handle, UUID, property). The desired result is stored in this pointer.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_get_attribute_by_handle(conn_handle, attr_handle, &attr_desc) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief get attribute by specific UUID.
|
||||
*
|
||||
* This function is used to get attribute by specific handle, which is stored after Discover Services procedure.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param start_handle - start of the Attribute handle range being found.
|
||||
* @param end_handle - end of the Attribute handle range being found.
|
||||
* @param attr_uuid - attribute UUID being found.
|
||||
* @param attr_desc - attribute structure(Type, handle, UUID, property). The desired result is stored in this pointer.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_get_attribute_by_handle(conn_handle, start_handle, end_handle, &attr_desc.uuid, &attr_desc) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief read attribute value by specific handle.(If This Attribute's permissions is readable)
|
||||
*
|
||||
* This function is used to read a attribute value by specific handle. This function will initiate a ATT Read Request procedure.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param attr_handle - attribute handle being read.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_read(g_gattc_devies[conn_id].handle, attr_handle) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_read)(gattc_handle_t conn_handle, uint16_t attr_handle);
|
||||
|
||||
/**
|
||||
* @brief write data to a specific attribute. (If This Attribute's permissions is Writable)
|
||||
*
|
||||
* This function is used to write data to a specific attribute. This function will initiate a ATT write Request procedure.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param attr_handle - attribute handle being written.
|
||||
* @param value - data to be written.
|
||||
* @param length - the length of value.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_write_without_response(g_gattc_devies[conn_id].handle, attr_handle, value, len) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_write)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief write data to a specific attribute. (If Write Without Response flag of This Attribute's property is set to 1)
|
||||
*
|
||||
* This function is used to write data to a specific attribute. This function will initiate a ATT write command procedure.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param attr_handle - attribute handle being written.
|
||||
* @param value - data to be written.
|
||||
* @param length - the length of value.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_write_without_response(g_gattc_devies[conn_id].handle, attr_handle, value, len) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_write_without_response)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief Write data to a specific attribute (Signed Write Without Response).
|
||||
*
|
||||
* This function writes data to a specific attribute handle using the
|
||||
* ATT "Signed Write Command" procedure. It should be used when the
|
||||
* attribute's properties include the `GATT_PROPERTY_SIGNED_WRITE` flag.
|
||||
*
|
||||
* Unlike a normal Write Without Response, this procedure includes a
|
||||
* signature to provide authentication of the write operation.
|
||||
*
|
||||
* @param conn_handle GATT client connection handle (void*).
|
||||
* @param attr_handle Attribute handle being written.
|
||||
* @param value Pointer to the buffer containing the data to write.
|
||||
* @param length Length of the data buffer.
|
||||
*
|
||||
* @return bt_status_t
|
||||
* - BT_STATUS_SUCCESS on success,
|
||||
* - Other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_write_with_signed(g_gattc_devices[conn_id].handle,
|
||||
attr_handle, value, len) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_write_with_signed)(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief enable a centain CCCD(Client Characteristic Configuration Description).
|
||||
*
|
||||
* This function is used to enable CCCD. Once enabled, it can receive Indication and Notification
|
||||
* from the Server successfully.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param attr_handle - attribute handle of the characteristic you want to enable CCCD.
|
||||
* @param ccc_value - bit 0 is used to enable Notification, bit 1 is used to enable Indication.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_subscribe(g_gattc_devies[conn_id].handle, attr_handle, ccc_value) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_subscribe)(gattc_handle_t conn_handle, uint16_t attr_handle, uint16_t ccc_value);
|
||||
|
||||
/**
|
||||
* @brief disable a centain CCCD(Client Characteristic Configuration Description).
|
||||
*
|
||||
* This function is used to disable CCCD. Once disable, it cannot receive Indication and Notification
|
||||
* from the Server.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param attr_handle - attribute handle of the characteristic you want to disable CCCD.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_unsubscribe(g_gattc_devies[conn_id].handle, attr_handle) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_unsubscribe)(gattc_handle_t conn_handle, uint16_t attr_handle);
|
||||
|
||||
/**
|
||||
* @brief exchange ATT_MTU.
|
||||
*
|
||||
* This function is used to initiate an ATT_MTU negotiation, which will initiate a Exchcange MTU procedure.
|
||||
* In Bluetooth Core Spec, this procedure can be initiated once per connection. If it is initiated more than
|
||||
* once, BT_STATUS_FAIL will be returned.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param mtu - MTU size.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_exchange_mtu(g_gattc_devies[conn_id].handle, mtu) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_exchange_mtu)(gattc_handle_t conn_handle, uint32_t mtu);
|
||||
|
||||
/**
|
||||
* @brief Modify BLE connection parameters.
|
||||
*
|
||||
* This function is used to modify BLE connection parameters.
|
||||
* Note: The following conditions must be met:
|
||||
* min_interval <= max_interval.
|
||||
* min_connection_event_length <= max_connection_event_length.
|
||||
* timeout > (1 + latency) * max_interval * 2
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param min_interval - min connection interval(n * 1.25ms).
|
||||
* @param max_interval - max connection interval(n * 1.25ms).
|
||||
* @param latency - peripheral latency.
|
||||
* @param timeout - supervision timeout(n * 10ms).
|
||||
* @param min_connection_event_length - min connection event length(n * 0.625ms).
|
||||
* @param max_connection_event_length - max connection event length(n * 0.625ms).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_update_connection_parameter(g_gattc_devies[conn_id].handle, min_interval, max_interval, latency,
|
||||
timeout, min_connection_event_length, max_connection_event_length)
|
||||
!= BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief read Tx & Rx PHY.
|
||||
*
|
||||
* This function is used to read PHY.(1M, 2M, Coded)
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_read_phy(g_gattc_devies[conn_id].handle) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_read_phy)(gattc_handle_t conn_handle);
|
||||
|
||||
/**
|
||||
* @brief update PHY.
|
||||
*
|
||||
* This function is used to update PHY type(1M, 2M, Coded).
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @param tx_phy - Tx PHY type wants to update.
|
||||
* @param rx_phy - Rx PHY type wants to update.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_update_phy(g_gattc_devies[conn_id].handle, tx, rx) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief read RSSI.
|
||||
*
|
||||
* This function is used to read RSSI value.
|
||||
*
|
||||
* @param conn_handle - gattc connection handle(void*).
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, and other error codes on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_gattc_read_rssi(g_gattc_devies[conn_id].handle) != BT_STATUS_SUCCESS) {
|
||||
// Handle Error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_gattc_read_rssi)(gattc_handle_t conn_handle);
|
||||
|
||||
// async
|
||||
|
|
|
|||
|
|
@ -120,6 +120,11 @@ typedef enum {
|
|||
HFP_ROAM_STATE_ROAMING,
|
||||
} hfp_roaming_state_t;
|
||||
|
||||
typedef enum {
|
||||
HFP_HF_SERVICE_VOICE = 4,
|
||||
HFP_HF_SERVICE_FAX = 5,
|
||||
} hfp_subscriber_number_service_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -284,6 +284,29 @@ void hfp_ag_at_cmd_received_cb(void* cookie, bt_address_t* addr, const char* at_
|
|||
*/
|
||||
typedef void (*hfp_ag_at_cmd_received_callback)(void* cookie, bt_address_t* addr, const char* at_command);
|
||||
|
||||
/**
|
||||
* @brief Callback for HFP AG received vendor specific AT command.
|
||||
*
|
||||
* This callback is used to notify the application of the vendor specific AT command. During
|
||||
* HFP AG initialization, callback functions will be registered. This callback will be triggered
|
||||
* when AG receives a vendor specific AT command.
|
||||
*
|
||||
* @param cookie - Callback cookie.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param command - The prefix of the AT command.
|
||||
* @param company_id - Bluetooth company ID.
|
||||
* @param value - AT command value.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void hfp_ag_vend_spec_at_cmd_received_cb(void* cookie, bt_address_t* addr, const char* command, uint16_t company_id, const char* value)
|
||||
{
|
||||
printf("hfp_ag_vend_spec_at_cmd_received_cb, command: %s, company_id: %d, value: %s\n", command, company_id, value);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*hfp_ag_vend_spec_at_cmd_received_callback)(void* cookie, bt_address_t* addr, const char* command, uint16_t company_id, const char* value);
|
||||
|
||||
/**
|
||||
* @brief HFP CLCC command received callback
|
||||
*
|
||||
|
|
@ -320,17 +343,6 @@ typedef void (*hfp_ag_cind_cmd_received_callback)(void* cookie, bt_address_t* ad
|
|||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief HFP vendor specific AT command received callback
|
||||
*
|
||||
* @param cookie - callback cookie.
|
||||
* @param command - The prefix of the AT command.
|
||||
* @param company_id - Bluetooth company ID.
|
||||
* @param value - AT command value.
|
||||
* @param addr - address of peer HF device.
|
||||
*/
|
||||
typedef void (*hfp_ag_vend_spec_at_cmd_received_callback)(void* cookie, bt_address_t* addr, const char* command, uint16_t company_id, const char* value);
|
||||
|
||||
/**
|
||||
* @brief HFP AG callback structure
|
||||
*
|
||||
|
|
@ -395,7 +407,7 @@ void app_init_hfp_ag(bt_instance_t* ins)
|
|||
else
|
||||
printf("register callbacks success\n");
|
||||
}
|
||||
* @endcode
|
||||
* @endcode
|
||||
*/
|
||||
void* BTSYMBOLS(bt_hfp_ag_register_callbacks)(bt_instance_t* ins, const hfp_ag_callbacks_t* callbacks);
|
||||
|
||||
|
|
@ -834,7 +846,7 @@ int app_send_specific_volume_control(bt_instance_t* ins, bt_address_t* addr);
|
|||
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);
|
||||
|
||||
/**
|
||||
* @brief Send an AT Command to HF device [Deprecated].
|
||||
* @brief Send an AT Command to HF device.
|
||||
*
|
||||
* This function is used to send specific AT commands to the specified HF device. The
|
||||
* address parameter is used to specify the peer HF device.
|
||||
|
|
@ -864,6 +876,36 @@ int app_send_specific_at_command(bt_instance_t* ins, bt_address_t* addr);
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_hfp_ag_send_at_command)(bt_instance_t* ins, bt_address_t* addr, const char* at_command);
|
||||
|
||||
/**
|
||||
* @brief Send a vendor specific AT Command
|
||||
*
|
||||
* This function is used to send specific vendor AT commands to the specified HF device. The
|
||||
* address parameter is used to specify the peer HF device.
|
||||
*
|
||||
* @param ins - The Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param command - The prefix of the AT command to be send.
|
||||
* @param value - The value of the AT command to be send.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
int app_send_specific_at_command(bt_instance_t* ins, bt_address_t* addr);
|
||||
{
|
||||
bt_status_t status;
|
||||
char at_command[] = "+XIAOMI";
|
||||
char value[] = "123456";
|
||||
|
||||
status = bt_hfp_ag_send_at_command(ins, addr, at_command, value);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
printf("send AT command failed\n");
|
||||
|
||||
return status;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Send CLCC Response
|
||||
*
|
||||
|
|
@ -908,17 +950,6 @@ bt_status_t BTSYMBOLS(bt_hfp_ag_send_clcc_response)(bt_instance_t* ins, bt_addre
|
|||
uint32_t index, hfp_call_direction_t dir, hfp_ag_call_state_t state, hfp_call_mode_t mode,
|
||||
hfp_call_mpty_type_t mpty, hfp_call_addrtype_t type, const char* number);
|
||||
|
||||
/**
|
||||
* @brief Send vendor specific AT Command
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer HF device.
|
||||
* @param command - the prefix of the AT command to be send.
|
||||
* @param value - the value of the AT command to be send.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Send CIND Response
|
||||
*
|
||||
|
|
|
|||
|
|
@ -69,15 +69,6 @@ typedef struct {
|
|||
char name[HFP_NAME_DIGITS_MAX];
|
||||
} hfp_current_call_t;
|
||||
|
||||
/**
|
||||
* @brief HFP subscriber number service
|
||||
*/
|
||||
typedef enum {
|
||||
HFP_HF_SERVICE_UNKNOWN = 0,
|
||||
HFP_HF_SERVICE_VOICE,
|
||||
HFP_HF_SERVICE_FAX,
|
||||
} hfp_subscriber_number_service_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
|
@ -396,35 +387,8 @@ void hfp_hf_callheld_cb(void* cookie, bt_address_t* addr, hfp_callheld_t callhel
|
|||
* @endcode
|
||||
*/
|
||||
typedef void (*hfp_hf_callheld_callback)(void* cookie, bt_address_t* addr, hfp_callheld_t callheld);
|
||||
|
||||
/**
|
||||
* @brief HFP HF get subscriber number callback.
|
||||
*
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer AG device.
|
||||
* @param number - phone number.
|
||||
* @param service - indicates which service this phone number relates to.
|
||||
*/
|
||||
typedef void (*hfp_hf_subscriber_number_callback)(void* cookie, bt_address_t* addr, const char* number, hfp_subscriber_number_service_t service);
|
||||
|
||||
/**
|
||||
* @brief HFP HF +clip callback.
|
||||
*
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer AG device.
|
||||
* @param number - the number of call.
|
||||
* @param name - the name of call.
|
||||
*/
|
||||
typedef void (*hfp_hf_clip_callback)(void* cookie, bt_address_t* addr, const char* number, const char* name);
|
||||
|
||||
/**
|
||||
* @brief HFP HF query current calls callback.
|
||||
*
|
||||
* @param cookie - callback cookie.
|
||||
* @param addr - address of peer AG device.
|
||||
* @param num - number of current calls.
|
||||
* @param calls - list of current calls.
|
||||
*/
|
||||
typedef void (*hfp_hf_subscriber_number_callback)(void* cookie, bt_address_t* addr, const char* number, hfp_subscriber_number_service_t service);
|
||||
typedef void (*hfp_hf_query_current_calls_callback)(void* cookie, bt_address_t* addr, uint8_t num, hfp_current_call_t* calls);
|
||||
|
||||
/**
|
||||
|
|
@ -1189,21 +1153,8 @@ int app_send_dtmf(bt_instance_t* ins, bt_address_t* addr, char dtmf);
|
|||
*/
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_send_dtmf)(bt_instance_t* ins, bt_address_t* addr, char dtmf);
|
||||
|
||||
/**
|
||||
* @brief Get Subscriber Number
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer AG device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_get_subscriber_number)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
/**
|
||||
* @brief Query Current Calls With Callback
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer AG device.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_hfp_hf_query_current_calls_with_callback)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -124,14 +124,15 @@ typedef enum {
|
|||
* @endcond
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief HID device application state callback.
|
||||
*
|
||||
* Callback function invoked when the HID application state changes. This callback
|
||||
* is used to notify the HID device about the state transition in interaction
|
||||
* is used to notify the HID device about the state transition in interaction
|
||||
* with the remote HID host.
|
||||
*
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* See `bt_hid_device_register_callbacks`.
|
||||
* @param state - New HID application state, see @ref hid_app_state_t.
|
||||
*
|
||||
|
|
@ -149,10 +150,10 @@ typedef void (*hidd_app_state_callback)(void* cookie, hid_app_state_t state);
|
|||
* @brief HID device connection state callback.
|
||||
*
|
||||
* Callback function invoked when the HID connection state changes. This callback
|
||||
* is used to notify the HID device about connection state changes with the remote
|
||||
* is used to notify the HID device about connection state changes with the remote
|
||||
* HID host.
|
||||
*
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* See `bt_hid_device_register_callbacks`.
|
||||
* @param addr - Address of the peer device, see @ref bt_address_t.
|
||||
* @param le_hid - TRUE if the connection is over LE; FALSE if over BR/EDR.
|
||||
|
|
@ -174,7 +175,7 @@ typedef void (*hidd_connection_state_callback)(void* cookie, bt_address_t* addr,
|
|||
*
|
||||
* Callback function invoked when a GET_REPORT request is received from the remote HID host.
|
||||
*
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* See `bt_hid_device_register_callbacks`.
|
||||
* @param addr - Address of the peer device, see @ref bt_address_t.
|
||||
* @param rpt_type - Report type, see @ref hid_report_type_t.
|
||||
|
|
@ -198,7 +199,7 @@ typedef void (*hidd_get_report_callback)(void* cookie, bt_address_t* addr, uint8
|
|||
*
|
||||
* Callback function invoked when a SET_REPORT request is received from the remote HID host.
|
||||
*
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* See `bt_hid_device_register_callbacks`.
|
||||
* @param addr - Address of the peer device, see @ref bt_address_t.
|
||||
* @param rpt_type - Report type, see @ref hid_report_type_t.
|
||||
|
|
@ -222,7 +223,7 @@ typedef void (*hidd_set_report_callback)(void* cookie, bt_address_t* addr, uint8
|
|||
*
|
||||
* Callback function invoked when an INPUT report is received from the remote HID host.
|
||||
*
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* See `bt_hid_device_register_callbacks`.
|
||||
* @param addr - Address of the peer device, see @ref bt_address_t.
|
||||
* @param rpt_type - Report type, see @ref hid_report_type_t.
|
||||
|
|
@ -246,7 +247,7 @@ typedef void (*hidd_receive_report_callback)(void* cookie, bt_address_t* addr, u
|
|||
*
|
||||
* Callback function invoked when a virtual cable unplug request is received from the remote HID host.
|
||||
*
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* @param cookie - `remote_callback_t*`.
|
||||
* See `bt_hid_device_register_callbacks`.
|
||||
* @param addr - Address of the peer device, see @ref bt_address_t.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ extern "C" {
|
|||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
||||
#define INVALID_L2CAP_LISTEN_ID 0xFFFF
|
||||
|
||||
enum {
|
||||
LE_PSM_DYNAMIC_MIN = 0x0080,
|
||||
LE_PSM_DYNAMIC_MAX = 0x00FF,
|
||||
|
|
@ -52,21 +50,16 @@ typedef struct {
|
|||
uint16_t mtu; /* Maximum Transmission Unit */
|
||||
uint16_t le_mps; /* Maximum PDU payload Size for LE */
|
||||
uint16_t init_credits; /* initial credits for LE */
|
||||
uint16_t id; /* L2CAP Service socket id */
|
||||
char proxy_name[16]; /* Proxy name */
|
||||
} l2cap_config_option_t;
|
||||
|
||||
typedef struct {
|
||||
bt_address_t addr;
|
||||
bt_transport_t transport;
|
||||
uint16_t cid; /* Local channel id. */
|
||||
uint16_t cid; /* Channel id. */
|
||||
uint16_t psm; /* Dynamic Service PSM */
|
||||
uint16_t incoming_mtu; /* Incoming transmit MTU. */
|
||||
uint16_t outgoing_mtu; /* Outgoing transmit MTU */
|
||||
uint16_t id; /* Connected L2CAP Channel socket id */
|
||||
// for L2CAP listen only.
|
||||
uint16_t listen_id; /* New L2CAP Listen socket id, INVALID_L2CAP_LISTEN_ID indicates invalid */
|
||||
char proxy_name[16]; /* Proxy name for server */
|
||||
uint16_t outgoing_mtu; /* outgoing transmit MTU */
|
||||
const char* pty_name; /* pty device name, like "/dev/pts/0" */
|
||||
} l2cap_connect_params_t;
|
||||
|
||||
/**
|
||||
|
|
@ -82,10 +75,10 @@ typedef void (*l2cap_connected_callback_t)(void* cookie, l2cap_connect_params_t*
|
|||
*
|
||||
* @param cookie - callbacks cookie, the return value of bt_l2cap_register_callbacks.
|
||||
* @param addr - remote addr.
|
||||
* @param id - L2CAP service socket id, used to identify L2CAP service channel resource.
|
||||
* @param cid - channel id.
|
||||
* @param reason - disconnect reason.
|
||||
*/
|
||||
typedef void (*l2cap_disconnected_callback_t)(void* cookie, bt_address_t* addr, uint16_t id, uint32_t reason);
|
||||
typedef void (*l2cap_disconnected_callback_t)(void* cookie, bt_address_t* addr, uint16_t cid, uint32_t reason);
|
||||
|
||||
/**
|
||||
* @brief L2CAP event callback structure
|
||||
|
|
@ -102,7 +95,7 @@ typedef struct {
|
|||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param callbacks - L2CAP callback functions.
|
||||
* @return void* - L2CAP APP handle, NULL on failure.
|
||||
* @return void* - callbacks cookie, NULL on failure.
|
||||
*/
|
||||
void* BTSYMBOLS(bt_l2cap_register_callbacks)(bt_instance_t* ins, const l2cap_callbacks_t* callbacks);
|
||||
|
||||
|
|
@ -110,68 +103,36 @@ void* BTSYMBOLS(bt_l2cap_register_callbacks)(bt_instance_t* ins, const l2cap_cal
|
|||
* @brief Unregister L2CAP callback functions.
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param handle - L2CAP APP handle.
|
||||
* @param cookie - callbacks cookie.
|
||||
* @return true - on callback unregister success
|
||||
* @return false - on callback cookie not found
|
||||
*/
|
||||
bool BTSYMBOLS(bt_l2cap_unregister_callbacks)(bt_instance_t* ins, void* handle);
|
||||
bool BTSYMBOLS(bt_l2cap_unregister_callbacks)(bt_instance_t* ins, void* cookie);
|
||||
|
||||
/**
|
||||
* @brief Listen for a L2CAP connection request
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param handle - L2CAP APP handle.
|
||||
* @param option - L2CAP config option.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_listen)(bt_instance_t* ins, void* handle, l2cap_config_option_t* option);
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_listen)(bt_instance_t* ins, l2cap_config_option_t* option);
|
||||
|
||||
/**
|
||||
* @brief Request L2CAP connection to remote device
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param handle - L2CAP APP handle.
|
||||
* @param addr - remote addr.
|
||||
* @param option - L2CAP config option.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_connect)(bt_instance_t* ins, void* handle, bt_address_t* addr, l2cap_config_option_t* option);
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_connect)(bt_instance_t* ins, bt_address_t* addr, l2cap_config_option_t* option);
|
||||
|
||||
/**
|
||||
* @brief Reqeust to disconnect a L2CAP channel
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param handle - L2CAP APP handle.
|
||||
* @param id - Connected L2CAP Channel socket id.
|
||||
* @param cid - channel id.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_disconnect)(bt_instance_t* ins, void* handle, uint16_t id);
|
||||
|
||||
/**
|
||||
* @brief Stop L2CAP listen
|
||||
*
|
||||
* This function used to stop L2CAP listen rather than disconnect all conected
|
||||
* L2CAP channels for a specific PSM.
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param handle - L2CAP APP handle.
|
||||
* @param psm - LE PSM used for listen.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* @note This function is only used for LE transport scenario.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_stop_listen)(bt_instance_t* ins, void* handle, uint16_t psm);
|
||||
|
||||
/**
|
||||
* @brief Stop L2CAP listen with transport
|
||||
*
|
||||
* This function used to stop L2CAP listen rather than disconnect all conected
|
||||
* L2CAP channels for a specific PSM.
|
||||
*
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param handle - L2CAP APP handle.
|
||||
* @param transport - bt_transport_t, LE or BR/EDR.
|
||||
* @param psm - PSM used for listen.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_stop_listen_with_transport)(bt_instance_t* ins, void* handle, bt_transport_t transport, uint16_t psm);
|
||||
bt_status_t BTSYMBOLS(bt_l2cap_disconnect)(bt_instance_t* ins, uint16_t cid);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@ extern "C" {
|
|||
#define BTSYMBOLS(s) s
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Advertising type
|
||||
*
|
||||
|
|
@ -92,57 +88,23 @@ enum {
|
|||
typedef void bt_advertiser_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Callback for advertising started notification.
|
||||
* @brief Advertising start status callback, invoke on adverting start success or failure
|
||||
*
|
||||
* This callback is used to notify the application of the adverter handle, ID, and
|
||||
* start status of the advertiser. It will be triggered in the following cases:
|
||||
* 1. Advertiser ID allocates failed or the return value of the function "bt_sal_le_start_adv"
|
||||
* is not "BT_STATUS_SUCCESS" within the advertiser starting event.
|
||||
* 2. 1 second after the successful notification of the start of LE advertising to the
|
||||
* Bluetooth protocol stack.
|
||||
* @param adv - advertiser handle.
|
||||
* @param adv_id - advertiser ID.
|
||||
* @param status - advertiser start status, BT_ADV_STATUS_SUCCESS on success.
|
||||
*
|
||||
* @param adv - Notifies the allocated Advertiser handle.
|
||||
* @param adv_id - Notifies the allocated Advertiser ID.
|
||||
* @param status - Notifies the starting status of the advertiser. BT_ADV_STATUS_SUCCESS
|
||||
* indicates that the advertiser has started successfully.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void on_advertising_start(bt_advertiser_t* adv, uint8_t adv_id, uint8_t status)
|
||||
{
|
||||
printf("on_advertising_start, adv_id: %d, status: %d\n", adv_id, status);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
typedef void (*on_advertising_start_cb_t)(bt_advertiser_t* adv, uint8_t adv_id, uint8_t status);
|
||||
|
||||
/**
|
||||
* @brief Callback for advertising stopped notification.
|
||||
* @brief Advertising stopped notification
|
||||
*
|
||||
* This callback is used to notify the application of the handle and ID corresponding to
|
||||
* the stopped advertising.
|
||||
*
|
||||
* @param adv - Advertiser handle.
|
||||
* @param adv_id - Advertiser ID.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void on_advertising_stopped(bt_advertiser_t* adv, uint8_t adv_id)
|
||||
{
|
||||
printf("on_advertising_stopped, adv_id: %d\n", adv_id);
|
||||
}
|
||||
* @endcode
|
||||
* @param adv - advertiser handle
|
||||
* @param adv_id - advertiser ID.
|
||||
*/
|
||||
typedef void (*on_advertising_stopped_cb_t)(bt_advertiser_t* adv, uint8_t adv_id);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Advertising callback functions structure
|
||||
*
|
||||
|
|
@ -168,58 +130,16 @@ typedef struct {
|
|||
} ble_adv_params_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initate LE advertising.
|
||||
* @brief Start LE advertising
|
||||
*
|
||||
* Before using this function to initiate LE advertising, the Bluetooth application
|
||||
* should set appropriate LE advertising parameters, prepare advertising data and scan
|
||||
* response data, and an advertising callback function. When using this function, the
|
||||
* above content is passed as parameters, and an advertiser handle is returned to indicate
|
||||
* the initiated advertising. With this handle, the Bluetooth application can disable the
|
||||
* corresponding advertising at an appropriate time.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param params - Advertising parameter.
|
||||
* @param adv_data - Advertisement data.
|
||||
* @param adv_len - Length of advertisement data.
|
||||
* @param scan_rsp_data - Scan response data.
|
||||
* @param scan_rsp_len - Length of scan response data.
|
||||
* @param cbs - Advertiser callback functions.
|
||||
* @return bt_advertiser_t* - Advertiser handle.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_advertiser_t* adver;
|
||||
|
||||
void app_start_advertising(bt_instance_t* ins)
|
||||
{
|
||||
ble_adv_params_t params;
|
||||
uint8_t adv_data[10];
|
||||
uint8_t scan_rsp_data[10];
|
||||
advertiser_callback_t cbs;
|
||||
|
||||
|
||||
params.adv_type = BT_LE_ADV_IND;
|
||||
params.own_addr_type = BT_LE_ADDR_TYPE_PUBLIC;
|
||||
params.tx_power = -20;
|
||||
params.interval = 100;
|
||||
params.duration = 0;
|
||||
params.channel_map = 7;
|
||||
params.filter_policy = BT_LE_ADV_FILTER_WHITE_LIST_FOR_ALL;
|
||||
|
||||
memset(adv_data, 0, sizeof(adv_data));
|
||||
memset(scan_rsp_data, 0, sizeof(scan_rsp_data));
|
||||
|
||||
cbs.size = sizeof(advertiser_callback_t);
|
||||
cbs.on_advertising_start = on_advertising_start;
|
||||
cbs.on_advertising_stopped = on_advertising_stopped;
|
||||
|
||||
adver = bt_le_start_advertising(ins, ¶ms, adv_data, sizeof(adv_data), scan_rsp_data, sizeof(scan_rsp_data), &cbs);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param params - advertising parameter.
|
||||
* @param adv_data - advertisement data.
|
||||
* @param adv_len - length of advertisement data.
|
||||
* @param scan_rsp_data - scan response data.
|
||||
* @param scan_rsp_len - length of scan response data.
|
||||
* @param cbs - advertiser callback functions.
|
||||
* @return bt_advertiser_t* - advertiser handle.
|
||||
*/
|
||||
bt_advertiser_t* BTSYMBOLS(bt_le_start_advertising)(bt_instance_t* ins,
|
||||
ble_adv_params_t* params,
|
||||
|
|
@ -230,87 +150,30 @@ bt_advertiser_t* BTSYMBOLS(bt_le_start_advertising)(bt_instance_t* ins,
|
|||
advertiser_callback_t* cbs);
|
||||
|
||||
/**
|
||||
* @brief Stop LE advertising by advertiser handle.
|
||||
* @brief Stop LE advertising by advertiser handle
|
||||
*
|
||||
* This function is used to stop the LE advertising indicated by the specified advertiser
|
||||
* handle. Therefore, before using this function, the Bluetooth application should know
|
||||
* the handle corresponding to the initiated advertising. When a Bluetooth application
|
||||
* initiates an advertising, it will be informed of the advertiser handle.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param adver - Advertiser handle.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void app_stop_advertising(bt_instance_t* ins)
|
||||
{
|
||||
if(!adver)
|
||||
return;
|
||||
bt_le_stop_advertising(ins, adver);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param adver - advertiser handle.
|
||||
*/
|
||||
void BTSYMBOLS(bt_le_stop_advertising)(bt_instance_t* ins, bt_advertiser_t* adver);
|
||||
|
||||
/**
|
||||
* @brief Stop LE advertising by advertiser ID.
|
||||
* @brief Stop LE advertising by adver id
|
||||
*
|
||||
* This function is used to stop the LE advertising indicated by the specified advertiser ID.
|
||||
* Therefore, before using this function, the Bluetooth application should know the ID
|
||||
* corresponding to the initiated advertising. When a Bluetooth application successfully initiates
|
||||
* an advertising, the advertiser ID will be informed through the "on_advertising_start_cb_t"
|
||||
* callback function provided when the advertising is initiated by the application.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param adv_id - Advertiser ID.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void app_stop_advertising(bt_instance_t* ins, uint8_t adv_id)
|
||||
{
|
||||
bt_le_stop_advertising_id(ins, adv_id);
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param adv_id - advertiser ID.
|
||||
*/
|
||||
void BTSYMBOLS(bt_le_stop_advertising_id)(bt_instance_t* ins, uint8_t adv_id);
|
||||
|
||||
/**
|
||||
* @brief Check if LE advertising is supported.
|
||||
* @brief Check is advertising supported
|
||||
*
|
||||
* This function is used to check if the Bluetooth protocol stack supports LE advertising for
|
||||
* Bluetooth applications.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @return bool - true represents support for LE advertising, while false represents non-support.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void app_check_advertising_support(bt_instance_t* ins)
|
||||
{
|
||||
if(bt_le_advertising_is_supported(ins))
|
||||
printf("advertising is supported\n");
|
||||
else
|
||||
printf("advertising is not supported\n");
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @return true - support.
|
||||
* @return false - not support.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_le_advertising_is_supported)(bt_instance_t* ins);
|
||||
|
||||
// async
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
#include "bt_async.h"
|
||||
|
||||
typedef void (*bt_le_start_adv_callback_cb_t)(bt_instance_t* ins, bt_status_t status, void* adv, void* userdata);
|
||||
|
||||
bt_status_t bt_le_start_advertising_async(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* adv_cbs, bt_le_start_adv_callback_cb_t cb, void* userdata);
|
||||
bt_status_t bt_le_stop_advertising_async(bt_instance_t* ins, bt_advertiser_t* adver, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_le_stop_advertising_id_async(bt_instance_t* ins, uint8_t adv_id, bt_status_cb_t cb, void* userdata);
|
||||
bt_status_t bt_le_advertising_is_supported_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
|
||||
#endif // CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -22,10 +22,6 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_STACK_LE_ZBLUE
|
||||
#include <zephyr/bluetooth/bluetooth.h>
|
||||
#endif
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include "bt_le_advertiser.h"
|
||||
#ifndef BTSYMBOLS
|
||||
|
|
@ -34,10 +30,6 @@ extern "C" {
|
|||
|
||||
#define BLE_SCAN_FILTER_UUID_MAX_NUM 2
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Scan start status code
|
||||
*
|
||||
|
|
@ -49,8 +41,7 @@ enum {
|
|||
BT_SCAN_STATUS_SCANNER_REG_NOMEM,
|
||||
BT_SCAN_STATUS_SCANNER_EXISTED,
|
||||
BT_SCAN_STATUS_SCANNER_NOT_FOUND,
|
||||
BT_SCAN_STATUS_SCANNER_REMOVED,
|
||||
BT_SCAN_STATUS_INVALID_PARAMETER = 0xFF
|
||||
BT_SCAN_STATUS_SCANNER_REMOVED
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -63,28 +54,19 @@ enum {
|
|||
BT_SCAN_MODE_LOW_LATENCY,
|
||||
};
|
||||
|
||||
#define SCAN_MODE_LOW_POWER_INTERVAL 0x3C0
|
||||
#define SCAN_MODE_LOW_POWER_WINDOW 0x18
|
||||
#define SCAN_MODE_BALANCED_INTERVAL 0x80
|
||||
#define SCAN_MODE_BALANCED_WINDOW 0x20
|
||||
#define SCAN_MODE_LOW_POWER_INTERVAL 0x1000
|
||||
#define SCAN_MODE_LOW_POWER_WINDOW 0x100
|
||||
#define SCAN_MODE_BALANCED_INTERVAL 0x500
|
||||
#define SCAN_MODE_BALANCED_WINDOW 0x140
|
||||
#define SCAN_MODE_LOW_LATENCY_INTERVAL 0xA0
|
||||
#define SCAN_MODE_LOW_LATENCY_WINDOW 0xA0
|
||||
|
||||
typedef void bt_scanner_t;
|
||||
|
||||
#ifdef CONFIG_BLUETOOTH_STACK_LE_ZBLUE
|
||||
#define BT_LE_SCAN_TYPE_PASSIVE BT_LE_SCAN_TYPE_PASSIVE_MODE
|
||||
#define BT_LE_SCAN_TYPE_ACTIVE BT_LE_SCAN_TYPE_ACTIVE_MODE
|
||||
typedef enum {
|
||||
BT_LE_SCAN_TYPE_PASSIVE_MODE = 0,
|
||||
BT_LE_SCAN_TYPE_ACTIVE_MODE
|
||||
} ble_scan_type_t;
|
||||
#else
|
||||
typedef enum {
|
||||
BT_LE_SCAN_TYPE_PASSIVE = 0,
|
||||
BT_LE_SCAN_TYPE_ACTIVE
|
||||
} ble_scan_type_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Scan filter policy
|
||||
|
|
@ -151,76 +133,30 @@ typedef struct {
|
|||
uint8_t active;
|
||||
uint8_t duplicated;
|
||||
} ble_scan_filter_t;
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Scan result callback function.
|
||||
* @brief scan result callback
|
||||
*
|
||||
* Callback function called when a scan result is available.
|
||||
*
|
||||
* @param scanner - Scanner handle.
|
||||
* @param result - Pointer to the scan result, see @ref ble_scan_result_t.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void le_scan_result_callback(bt_scanner_t* scanner, ble_scan_result_t* result)
|
||||
{
|
||||
// Process scan result
|
||||
}
|
||||
|
||||
static scanner_callbacks_t lescan_cbs = {
|
||||
.size = sizeof(lescan_cbs),
|
||||
.on_scan_result = le_scan_result_callback,
|
||||
};
|
||||
* @endcode
|
||||
* @param scanner - scanner handle.
|
||||
* @param result - scan result.
|
||||
*/
|
||||
typedef void (*on_scan_result_cb_t)(bt_scanner_t* scanner, ble_scan_result_t* result);
|
||||
|
||||
/**
|
||||
* @brief Scan start status callback function.
|
||||
* @brief Scan start status callback
|
||||
*
|
||||
* Callback function called when the scan starts or fails to start.
|
||||
*
|
||||
* @param scanner - Scanner handle.
|
||||
* @param status - Scan start status code, see scan status codes.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void on_scan_status(bt_scanner_t* scanner, uint8_t status)
|
||||
{
|
||||
if (status == BT_SCAN_STATUS_SUCCESS) {
|
||||
// Scan started successfully
|
||||
} else {
|
||||
// Handle scan start failure
|
||||
}
|
||||
}
|
||||
* @endcode
|
||||
* @param scanner - scanner handle.
|
||||
* @param result - scan start status, BT_SCAN_STATUS_SUCCESS on success.
|
||||
*/
|
||||
typedef void (*on_scan_status_cb_t)(bt_scanner_t* scanner, uint8_t status);
|
||||
|
||||
/**
|
||||
* @brief Scan stopped callback function.
|
||||
* @brief Scan stopped callback
|
||||
*
|
||||
* Callback function called when the scan is stopped.
|
||||
*
|
||||
* @param scanner - Scanner handle.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void on_scan_stopped(bt_scanner_t* scanner)
|
||||
{
|
||||
// Handle scan stopped event
|
||||
}
|
||||
* @endcode
|
||||
* @param scanner - scanner handle.
|
||||
*/
|
||||
typedef void (*on_scan_stopped_cb_t)(bt_scanner_t* scanner);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Scanner callback structure
|
||||
*
|
||||
|
|
@ -231,79 +167,37 @@ typedef struct {
|
|||
on_scan_status_cb_t on_scan_start_status;
|
||||
on_scan_stopped_cb_t on_scan_stopped;
|
||||
} scanner_callbacks_t;
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Start BLE scan.
|
||||
* @brief Start LE scan
|
||||
*
|
||||
* Initiates a BLE scan with default settings.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param cbs - Pointer to scanner callbacks, see @ref scanner_callbacks_t.
|
||||
* @return bt_scanner_t* - Scanner handle generated by the scan manager.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_scanner_t* scanner = bt_le_start_scan(ins, &my_scanner_callbacks);
|
||||
if (scanner == NULL) {
|
||||
// Handle error
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param cbs - scan callback function.
|
||||
* @return bt_scanner_t* - scanner handle generated by scan manager.
|
||||
*/
|
||||
bt_scanner_t* BTSYMBOLS(bt_le_start_scan)(bt_instance_t* ins, const scanner_callbacks_t* cbs);
|
||||
|
||||
/**
|
||||
* @brief Start BLE scan with specific settings.
|
||||
* @brief Start LE scan with scan settings
|
||||
*
|
||||
* Initiates a BLE scan with provided scan settings.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param settings - Pointer to scan settings, see @ref ble_scan_settings_t.
|
||||
* @param cbs - Pointer to scanner callbacks, see @ref scanner_callbacks_t.
|
||||
* @return bt_scanner_t* - Scanner handle generated by the scan manager.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
ble_scan_settings_t settings = {
|
||||
.scan_mode = BT_SCAN_MODE_LOW_LATENCY,
|
||||
.scan_type = BT_LE_SCAN_TYPE_ACTIVE,
|
||||
// Additional settings...
|
||||
};
|
||||
bt_scanner_t* scanner = bt_le_start_scan_settings(ins, &settings, &my_scanner_callbacks);
|
||||
if (scanner == NULL) {
|
||||
// Handle error
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param settings - scan settings with scan mode and scan phy.
|
||||
* @param cbs - scan callback function.
|
||||
* @return bt_scanner_t* - scanner handle generated by scan manager.
|
||||
*/
|
||||
bt_scanner_t* BTSYMBOLS(bt_le_start_scan_settings)(bt_instance_t* ins,
|
||||
ble_scan_settings_t* settings,
|
||||
const scanner_callbacks_t* cbs);
|
||||
|
||||
/**
|
||||
* @brief Start BLE scan with filters.
|
||||
* @brief Start LE scan with scan filters
|
||||
*
|
||||
* Initiates a BLE scan with specific settings and filters.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param settings - Pointer to scan settings, see @ref ble_scan_settings_t.
|
||||
* @param filter_data - Pointer to filter data, see @ref ble_scan_filter_t.
|
||||
* @param cbs - Pointer to scanner callbacks, see @ref scanner_callbacks_t.
|
||||
* @return bt_scanner_t* - Scanner handle generated by the scan manager.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
ble_scan_filter_t filter = {
|
||||
.uuids = {0x180D, 0x180F}, // Heart Rate and Battery Service UUIDs
|
||||
.active = 1,
|
||||
// Additional filter settings...
|
||||
};
|
||||
bt_scanner_t* scanner = bt_le_start_scan_with_filters(ins, &settings, &filter, &my_scanner_callbacks);
|
||||
if (scanner == NULL) {
|
||||
// Handle error
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param settings - scan settings with scan mode and scan phy.
|
||||
* @param filter_data - filter data.
|
||||
* @param filter_length - filter data length.
|
||||
* @param cbs - scan callback function.
|
||||
* @return bt_scanner_t* - scanner handle generated by scan manager.
|
||||
*/
|
||||
bt_scanner_t* BTSYMBOLS(bt_le_start_scan_with_filters)(bt_instance_t* ins,
|
||||
ble_scan_settings_t* settings,
|
||||
|
|
@ -311,136 +205,24 @@ bt_scanner_t* BTSYMBOLS(bt_le_start_scan_with_filters)(bt_instance_t* ins,
|
|||
const scanner_callbacks_t* cbs);
|
||||
|
||||
/**
|
||||
* @brief Stop BLE scan.
|
||||
* @brief Stop LE scan
|
||||
*
|
||||
* Stops an ongoing BLE scan.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param scanner - Scanner handle generated by the scan manager.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_le_stop_scan(ins, scanner);
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param scanner - scanner handle generated by scan manager.
|
||||
*/
|
||||
void BTSYMBOLS(bt_le_stop_scan)(bt_instance_t* ins, bt_scanner_t* scanner);
|
||||
|
||||
/**
|
||||
* @brief Check if BLE scanning is supported.
|
||||
* @brief Check LE scan is support
|
||||
*
|
||||
* Determines whether BLE scanning is supported by the adapter.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @return true - Scanning is supported.
|
||||
* @return false - Scanning is not supported.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (bt_le_scan_is_supported(ins)) {
|
||||
// Scanning is supported
|
||||
} else {
|
||||
// Scanning is not supported
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @return true - support.
|
||||
* @return false - not support.
|
||||
*/
|
||||
bool BTSYMBOLS(bt_le_scan_is_supported)(bt_instance_t* ins);
|
||||
|
||||
// async
|
||||
#ifdef CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
#include "bt_async.h"
|
||||
|
||||
/**
|
||||
* @brief The asynchronous callback for start BLE scan registered by the caller.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param status - Status of the operation.
|
||||
* @param scan - Scanner handle generated by the scan manager. The caller needs
|
||||
* to save the handle to use when stopping the scan.
|
||||
* @param userdata - User context.
|
||||
*/
|
||||
typedef void (*bt_le_start_scan_cb_t)(bt_instance_t* ins, bt_status_t status, void* scan, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief The asynchronous callback for stop BLE scan registered by the caller.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param userdata - User context.
|
||||
*/
|
||||
typedef void (*bt_le_stop_scan_cb_t)(bt_instance_t* ins, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief Start BLE scan.
|
||||
*
|
||||
* Initiates a BLE scan with default settings.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param scan_cbs - Pointer to scanner callbacks, see @ref scanner_callbacks_t.
|
||||
* @param cb - Callback function for asynchronous call.
|
||||
* @param userdata - User context.
|
||||
* @return bt_status_t - Only return IPC status.
|
||||
*/
|
||||
bt_status_t bt_le_start_scan_async(bt_instance_t* ins, const scanner_callbacks_t* scan_cbs,
|
||||
bt_le_start_scan_cb_t cb, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief Start BLE scan with specific settings.
|
||||
*
|
||||
* Initiates a BLE scan with provided scan settings.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param settings - Pointer to scan settings, see @ref ble_scan_settings_t.
|
||||
* @param scan_cbs - Pointer to scanner callbacks, see @ref scanner_callbacks_t.
|
||||
* @param cb - Callback function for asynchronous call.
|
||||
* @param userdata - User context.
|
||||
* @return bt_status_t - Only return IPC status.
|
||||
*/
|
||||
bt_status_t bt_le_start_scan_settings_async(bt_instance_t* ins, ble_scan_settings_t* settings,
|
||||
const scanner_callbacks_t* scan_cbs, bt_le_start_scan_cb_t cb, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief Start BLE scan with filters.
|
||||
*
|
||||
* Initiates a BLE scan with specific settings and filters.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param settings - Pointer to scan settings, see @ref ble_scan_settings_t.
|
||||
* @param filter_data - Pointer to filter data, see @ref ble_scan_filter_t.
|
||||
* @param scan_cbs - Pointer to scanner callbacks, see @ref scanner_callbacks_t.
|
||||
* @param cb - Callback function for asynchronous call.
|
||||
* @param userdata - User context.
|
||||
* @return bt_status_t - Only return IPC status.
|
||||
*/
|
||||
bt_status_t bt_le_start_scan_with_filters_async(bt_instance_t* ins, ble_scan_settings_t* settings,
|
||||
ble_scan_filter_t* filter, const scanner_callbacks_t* scan_cbs, bt_le_start_scan_cb_t cb, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief Stop BLE scan.
|
||||
*
|
||||
* Stops an ongoing BLE scan.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param scanner - Scanner handle generated by the scan manager.
|
||||
* @param cb - Callback function for asynchronous call.
|
||||
* @param userdata - User context.
|
||||
* @return bt_status_t - Only return IPC status.
|
||||
*/
|
||||
bt_status_t bt_le_stop_scan_async(bt_instance_t* ins, bt_scanner_t* scanner, bt_le_stop_scan_cb_t cb, void* userdata);
|
||||
|
||||
/**
|
||||
* @brief Check if BLE scanning is supported.
|
||||
*
|
||||
* Determines whether BLE scanning is supported by the adapter.
|
||||
*
|
||||
* @param ins - Bluetooth client instance, see @ref bt_instance_t.
|
||||
* @param cb - Callback function for asynchronous call.
|
||||
* @param userdata - User context.
|
||||
* @return bt_status_t - Only return IPC status.
|
||||
*/
|
||||
bt_status_t bt_le_scan_is_supported_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata);
|
||||
#endif // CONFIG_BLUETOOTH_FRAMEWORK_ASYNC
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BT_LE_SCAN_H_ */
|
||||
#endif /* __BT_LE_SCAN_H_ */
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
|
||||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
#include "bt_lea_common.h"
|
||||
#include "lea_audio_common.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
|
||||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
#include "bt_lea_common.h"
|
||||
#include "lea_audio_common.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#define OBJ_ID_SIZE 6
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
|
||||
#include "bt_addr.h"
|
||||
#include "bt_device.h"
|
||||
#include "bt_lea_common.h"
|
||||
#include "lea_audio_common.h"
|
||||
#include <stddef.h>
|
||||
|
||||
typedef void (*lea_tbs_test_callback)(void* cookie, uint8_t value, bool added);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "bt_list_internal.h"
|
||||
#include "list.h"
|
||||
|
||||
typedef void (*bt_list_free_cb_t)(void* data);
|
||||
typedef struct _bt_list bt_list_t;
|
||||
|
|
|
|||
|
|
@ -139,6 +139,15 @@
|
|||
list_initialize(item); \
|
||||
} while (0)
|
||||
|
||||
#define list_merge(list_dst, list_src) \
|
||||
do { \
|
||||
(list_dst)->prev->next = (list_src)->next; \
|
||||
(list_src)->next->prev = (list_dst)->prev; \
|
||||
(list_src)->prev->next = (list_dst); \
|
||||
(list_dst)->prev = (list_src)->prev; \
|
||||
list_initialize(list_src); \
|
||||
} while (0)
|
||||
|
||||
#define list_remove_head_type(list, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_remove_head(list); \
|
||||
|
|
|
|||
|
|
@ -26,11 +26,7 @@
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief PAN role type define.
|
||||
* @brief Pan role type define.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
|
|
@ -54,68 +50,29 @@ typedef enum {
|
|||
} pan_netif_state_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Callback for PAN connection state change.
|
||||
* @brief Pan connection state change callback.
|
||||
*
|
||||
* When the PAN connection state changes, this callback will be triggered to
|
||||
* notify the cookie corresponding to the callback, the latest PAN connection
|
||||
* state, the Bluetooth address of the peer device, and the roles of both
|
||||
* devices in the PAN.
|
||||
*
|
||||
* @param cookie - Callbacks cookie, the return value of bt_pan_register_callbacks.
|
||||
* @param state - PAN connection state
|
||||
* @param bd_addr - The Bluetooth address of the peer device.
|
||||
* @param local_role - Local device PAN role, reference type pan_role_t.
|
||||
* @param remote_role - Remote device PAN role, reference type pan_role_t.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void pan_connection_state_cb(void* cookie, profile_connection_state_t state,
|
||||
bt_address_t* bd_addr, uint8_t local_role,
|
||||
uint8_t remote_role)
|
||||
{
|
||||
printf("pan_connection_state_cb, state: %d, bd_addr: %s, local_role: %d, remote_role: %d\n",
|
||||
state, bd_addr->address, local_role, remote_role);
|
||||
}
|
||||
* @endcode
|
||||
* @param cookie - callbacks cookie, the return value of bt_pan_register_callbacks.
|
||||
* @param state - pan connection state
|
||||
* @param bd_addr - address of peer device.
|
||||
* @param local_role - local device pan role, reference type pan_role_t.
|
||||
* @param remote_role - remote device pan role, reference type pan_role_t.
|
||||
*/
|
||||
typedef void (*pan_connection_state_callback)(void* cookie, profile_connection_state_t state,
|
||||
bt_address_t* bd_addr, uint8_t local_role,
|
||||
uint8_t remote_role);
|
||||
|
||||
/**
|
||||
* @brief Callback for PAN net interface (down/up) state change.
|
||||
* @brief Pan net interface (down/up)state change callback.
|
||||
*
|
||||
* When the PAN interface becomes up or down, this callback will be triggered
|
||||
* to notify the Cookie corresponding to the callback, the latest status of
|
||||
* the interface, the role of the local device in the PAN, and the interface
|
||||
* name.
|
||||
*
|
||||
* @param cookie - Callbacks cookie, the return value of bt_pan_register_callbacks.
|
||||
* @param state - Net interface state.
|
||||
* @param local_role - Local device PAN role.
|
||||
* @param ifname - Net interface name, default "bt-pan".
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void pan_netif_state_cb(void* cookie, pan_netif_state_t state,
|
||||
int local_role, const char* ifname)
|
||||
{
|
||||
printf("pan_netif_state_cb, state: %d, local_role: %d, ifname: %s\n",
|
||||
state, local_role, ifname);
|
||||
}
|
||||
* @endcode
|
||||
* @param cookie - callbacks cookie, the return value of bt_pan_register_callbacks.
|
||||
* @param state - net interface state.
|
||||
* @param local_role - local device pan role
|
||||
* @param ifname - net interface name, default "bt-pan".
|
||||
*/
|
||||
typedef void (*pan_netif_state_callback)(void* cookie, pan_netif_state_t state,
|
||||
int local_role, const char* ifname);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief PAN event callbacks structure
|
||||
*
|
||||
|
|
@ -127,133 +84,41 @@ typedef struct {
|
|||
} pan_callbacks_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Register callback functions to PAN service.
|
||||
* @brief Register callback functions to pan service
|
||||
*
|
||||
* This function is used to register the callback for notifying PAN connection
|
||||
* states and the callback for notifying PAN interface states to the PAN service.
|
||||
* When the PAN service detects the corresponding event, it will notify the
|
||||
* application through the registered callback function. After this function is
|
||||
* called, it returns the cookie corresponding to the callback.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param callbacks - PAN callback functions.
|
||||
* @return void* - Callback cookie, NULL represents fail.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void* pan_cookie;
|
||||
const static pan_callbacks_t callbacks = {
|
||||
.size = sizeof(pan_callbacks_t),
|
||||
.netif_state_cb = pan_netif_state_cb,
|
||||
.connection_state_cb = pan_connection_state_cb,
|
||||
};
|
||||
|
||||
void app_init_pan(bt_instance_t* ins)
|
||||
{
|
||||
pan_cookie = bt_pan_register_callbacks(ins, &callbacks);
|
||||
if (!pan_cookie)
|
||||
printf("register pan callbacks failed\n");
|
||||
else
|
||||
printf("register pan callbacks success\n");
|
||||
}
|
||||
* @endcode
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param callbacks - pan callback functions.
|
||||
* @return void* - callback cookie, NULL on failure.
|
||||
*/
|
||||
void* BTSYMBOLS(bt_pan_register_callbacks)(bt_instance_t* ins, const pan_callbacks_t* callbacks);
|
||||
|
||||
/**
|
||||
* @brief Unregister PAN callback functions.
|
||||
* @brief Unregister pan callback function
|
||||
*
|
||||
* This function is used to unregister callbacks from the PAN service. The caller
|
||||
* needs to provide the cookie corresponding to callbacks.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param cookie - Callbacks cookie.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param cookie - callbacks cookie.
|
||||
* @return true - on callback unregister success
|
||||
* @return false - on callback cookie not found
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void app_deinit_pan(bt_instance_t* ins)
|
||||
{
|
||||
bt_status_t status;
|
||||
if (!pan_cookie)
|
||||
return;
|
||||
|
||||
status = bt_pan_unregister_callbacks(ins, pan_cookie);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
printf("unregister pan callbacks failed\n");
|
||||
else
|
||||
printf("unregister pan callbacks success\n");
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bool BTSYMBOLS(bt_pan_unregister_callbacks)(bt_instance_t* ins, void* cookie);
|
||||
|
||||
/**
|
||||
* @brief Connect to PAN device.
|
||||
* @brief Connect to pan device
|
||||
*
|
||||
* This function is used to connect to a PAN device. The caller needs to provide
|
||||
* the address of the peer device, the role of the local device, and the role of
|
||||
* the peer device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param dst_role - Destination PAN role, reference type pan_role_t.
|
||||
* Only support PANU connect to NAP server, dst_role must be PAN_ROLE_NAP.
|
||||
* @param src_role - Source PAN role, reference type pan_role_t.
|
||||
* Only support PANU connect to NAP server, src_role must be PAN_ROLE_PANU.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer device.
|
||||
* @param dst_role - dest pan role, reference type pan_role_t.
|
||||
* @param src_role - src pan role, reference type pan_role_t.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void app_connect_pan_device(bt_instance_t* ins)
|
||||
{
|
||||
bt_status_t status;
|
||||
bt_address_t addr = {
|
||||
.addr = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06},
|
||||
};
|
||||
|
||||
status = bt_pan_connect(ins, &addr, PAN_ROLE_NAP, PAN_ROLE_PANU);
|
||||
if(status != BT_STATUS_SUCCESS)
|
||||
printf("connect pan device failed\n");
|
||||
else
|
||||
printf("connect pan device success\n");
|
||||
}
|
||||
* @endcode
|
||||
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_pan_connect)(bt_instance_t* ins, bt_address_t* addr, uint8_t dst_role, uint8_t src_role);
|
||||
|
||||
/**
|
||||
* @brief Disconnect from PAN connection.
|
||||
* @brief Disconnect from pan connection
|
||||
*
|
||||
* This function is used to disconnect from a PAN device. The caller needs to
|
||||
* provide the address of the peer device.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param addr - The Bluetooth address of the peer device.
|
||||
* @param ins - bluetooth client instance.
|
||||
* @param addr - address of peer device.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
void app_disconnect_pan_device(bt_instance_t* ins)
|
||||
{
|
||||
bt_status_t status;
|
||||
bt_address_t addr = {
|
||||
.addr = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06},
|
||||
};
|
||||
|
||||
status = bt_pan_disconnect(ins, &addr);
|
||||
if(status != BT_STATUS_SUCCESS)
|
||||
printf("disconnect pan device failed\n");
|
||||
else
|
||||
printf("disconnect pan device success\n");
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
bt_status_t BTSYMBOLS(bt_pan_disconnect)(bt_instance_t* ins, bt_address_t* addr);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
#define PROFILE_A2DP_NAME "A2DP-Src"
|
||||
#define PROFILE_A2DP_SINK_NAME "A2DP-Sink"
|
||||
#define PROFILE_AVRCP_CT_NAME "AVRCP-CT"
|
||||
#define PROFILE_AVRCP_TG_NAME "AVRCP-TG"
|
||||
#define PROFILE_CS_NAME "CS"
|
||||
#define PROFILE_HFP_HF_NAME "HFP-HF"
|
||||
#define PROFILE_HFP_AG_NAME "HFP-AG"
|
||||
#define PROFILE_SPP_NAME "SPP"
|
||||
|
|
@ -64,14 +61,11 @@ enum profile_id {
|
|||
PROFILE_LEAUDIO_MCS,
|
||||
PROFILE_LEAUDIO_TBS,
|
||||
PROFILE_LEAUDIO_VMICP,
|
||||
PROFILE_CS, // TODO: remove this profile
|
||||
PROFILE_UNKOWN,
|
||||
PROFILE_MAX
|
||||
};
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ extern "C" {
|
|||
*/
|
||||
#define BT_UUID_SERVCLASS_SERIAL_PORT 0x1101
|
||||
|
||||
#define SPP_PORT_TYPE_TTY 1
|
||||
|
||||
/**
|
||||
* @brief Spp proxy state
|
||||
*
|
||||
|
|
@ -57,10 +59,6 @@ typedef enum {
|
|||
SPP_PROXY_STATE_CLOSING,
|
||||
} spp_proxy_state_t;
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Callback used to notify SPP connection states.
|
||||
*
|
||||
|
|
@ -147,12 +145,9 @@ void spp_proxy_state_cb(void* handle, bt_address_t* addr, spp_proxy_state_t stat
|
|||
*/
|
||||
typedef void (*spp_proxy_state_callback)(void* handle, bt_address_t* addr, spp_proxy_state_t state, uint16_t scn, uint16_t port, char* name);
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief SPP event callbacks structure
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
size_t size;
|
||||
|
|
@ -331,8 +326,8 @@ bt_status_t BTSYMBOLS(bt_spp_unregister_app)(bt_instance_t* ins, void* handle);
|
|||
* on other devices.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param handle - SPP APP handle.
|
||||
* @param scn - Server channel number, range in <1-28>.
|
||||
* @param handle - SPP application handle.
|
||||
* @param scn - Server channel number, range in 1-28.
|
||||
* @param uuid - Server uuid, default:0x1101.
|
||||
* @param max_connection - Maximum of client connections.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
|
|
@ -369,8 +364,8 @@ bt_status_t BTSYMBOLS(bt_spp_server_start)(bt_instance_t* ins, void* handle, uin
|
|||
* will have stopped the SPP server.
|
||||
*
|
||||
* @param ins - Bluetooth client instance.
|
||||
* @param handle - SPP APP handle.
|
||||
* @param scn - Server channel number, range in <1-28>.
|
||||
* @param handle - SPP application handle.
|
||||
* @param scn - Server channel number, range in 1-28.
|
||||
* @return bt_status_t - BT_STATUS_SUCCESS on success, a negated errno value on failure.
|
||||
*
|
||||
* **Example:**
|
||||
|
|
@ -401,9 +396,9 @@ bt_status_t BTSYMBOLS(bt_spp_server_stop)(bt_instance_t* ins, void* handle, uint
|
|||
* an SPP connection will be established with the remote device.
|
||||
*
|
||||
* @param[in] ins - Bluetooth client instance.
|
||||
* @param[in] handle - SPP APP handle.
|
||||
* @param[in] addr - address of peer device.
|
||||
* @param[in] scn - Server channel number, range in <1-28>.
|
||||
* @param[in] handle - SPP application handle.
|
||||
* @param[in] addr - The Bluetooth address of the peer device.
|
||||
* @param[in] scn - Server channel number, range in 1-28.
|
||||
* - UNKNOWN_SERVER_CHANNEL_NUM: Not specify scn.
|
||||
* @param[in] uuid - Server uuid, default:0x1101.
|
||||
* @param[out] port - The unique port of connection.
|
||||
|
|
|
|||
|
|
@ -23,14 +23,30 @@ extern "C" {
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
|
||||
#define BT_UUID_A2DP_SRC 0x110A
|
||||
#define BT_UUID_A2DP_SNK 0x110B
|
||||
#define BT_UUID_HFP 0x111E
|
||||
#define BT_UUID_HFP_AG 0x111F
|
||||
|
||||
/**
|
||||
* @cond
|
||||
*/
|
||||
/* GATT Descriptor UUIDs (16-bit) */
|
||||
#define BT_UUID_GATT_CEPD 0x2900
|
||||
#define BT_UUID_GATT_CUDD 0x2901
|
||||
#define BT_UUID_GATT_CCCD 0x2902
|
||||
#define BT_UUID_GATT_CPFD 0x2904
|
||||
|
||||
#define BT_UUID_RANGING_VAL 0x185B
|
||||
#define BT_UUID_RANGE_FEAT_VAL 0x2C14
|
||||
#define BT_UUID_RANGE_RTT_DT_VAL 0x2C15
|
||||
#define BT_UUID_RANGE_ON_DEM_DT_VAL 0x2C16
|
||||
#define BT_UUID_RANGE_RAS_CTR_POINT_VAL 0x2C17
|
||||
#define BT_UUID_RANGE_DT_RD_VAL 0x2C18
|
||||
#define BT_UUID_RANGE_DT_OV_WR_VAL 0x2C19
|
||||
|
||||
#define BT_UUID_STR_LENGTH 40
|
||||
|
||||
typedef enum {
|
||||
BT_UUID16_TYPE = 2,
|
||||
|
|
@ -70,172 +86,13 @@ typedef struct {
|
|||
((bt_uuid_t) { .type = BT_UUID128_TYPE, .val.u128 = { value } })
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Converting UUID to a 128-bits UUID.
|
||||
*
|
||||
* @param src - src UUID(16-bits, 32-bits, 128-bits).
|
||||
* @param uuid128 - Converted 128-bits UUID.
|
||||
* @return void.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
int bt_uuid_compare(const bt_uuid_t* uuid1, const bt_uuid_t* uuid2)
|
||||
{
|
||||
bt_uuid_t u1 = { 0 };
|
||||
bt_uuid_t u2 = { 0 };
|
||||
|
||||
bt_uuid_to_uuid128(uuid1, &u1);
|
||||
bt_uuid_to_uuid128(uuid2, &u2);
|
||||
|
||||
return bt_uuid128_cmp(&u1, &u2);
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
void bt_uuid_to_uuid128(const bt_uuid_t* src, bt_uuid_t* uuid128);
|
||||
|
||||
void bt_uuid_to_uuid16(const bt_uuid_t* src, bt_uuid_t* uuid16);
|
||||
|
||||
/**
|
||||
* @brief compare two UUIDs.
|
||||
*
|
||||
* @param uuid1 - UUID1.
|
||||
* @param uuid2 - UUID2.
|
||||
* @return int. If uuid1 is equal to uuid2, return 0.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
if (!bt_uuid_compare(&element->uuid, attr_uuid)) {
|
||||
BT_LOGE("uuid match");
|
||||
// Handle continue
|
||||
} else {
|
||||
BT_LOGE("uuid not match");
|
||||
// Handle error
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
int bt_uuid_compare(const bt_uuid_t* uuid1, const bt_uuid_t* uuid2);
|
||||
|
||||
/**
|
||||
* @brief create a 16-bits UUID.
|
||||
*
|
||||
* @param uuid16 - pointer of the generated UUID16.
|
||||
* @param value - UUID value.
|
||||
* @return int.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bool bt_uuid_create_common(bt_uuid_t* uuid, const uint8_t* data, uint8_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case BT_UUID16_TYPE: {
|
||||
uint16_t val16;
|
||||
STREAM_TO_UINT32(val16, data);
|
||||
bt_uuid16_create(uuid, val16);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
int bt_uuid16_create(bt_uuid_t* uuid16, uint16_t value);
|
||||
|
||||
/**
|
||||
* @brief create a 32-bits UUID.
|
||||
*
|
||||
* @param uuid16 - pointer of the generated UUID32.
|
||||
* @param value - UUID value.
|
||||
* @return int.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bool bt_uuid_create_common(bt_uuid_t* uuid, const uint8_t* data, uint8_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case BT_UUID32_TYPE: {
|
||||
uint32_t val32;
|
||||
STREAM_TO_UINT32(val32, data);
|
||||
bt_uuid32_create(uuid, val32);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
int bt_uuid32_create(bt_uuid_t* uuid32, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief create a 128-bits UUID.
|
||||
*
|
||||
* @param uuid16 - pointer of the generated UUID128.
|
||||
* @param value - UUID value.
|
||||
* @return int.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bool bt_uuid_create_common(bt_uuid_t* uuid, const uint8_t* data, uint8_t type)
|
||||
{
|
||||
switch (type) {
|
||||
case BT_UUID128_TYPE:
|
||||
bt_uuid128_create(uuid, data);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
* @endcode
|
||||
*/
|
||||
int bt_uuid128_create(bt_uuid_t* uuid128, const uint8_t* value);
|
||||
|
||||
/**
|
||||
* @brief Wrapper of UUID create.
|
||||
*
|
||||
* @param uuid - pointer of the generated UUID(16-bits, 32-bits, 128-bits).
|
||||
* @param data - UUID value.
|
||||
* @param type - UUID type(16-bits, 32-bits, 128-bits).
|
||||
* @return bool. If type belongs to (UUID16, UUID32, UUID128)return true, else return false.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_uuid_create_common(&uuid, data, BT_UUID128_TYPE)
|
||||
* @endcode
|
||||
*/
|
||||
bool bt_uuid_create_common(bt_uuid_t* uuid, const uint8_t* data, uint8_t type);
|
||||
|
||||
/**
|
||||
* @brief Converting UUID to string.
|
||||
*
|
||||
* @param uuid - pointer of the generated UUID.
|
||||
* @param str - UUID string.
|
||||
* @param len - string length.
|
||||
* @return int.
|
||||
*
|
||||
* **Example:**
|
||||
* @code
|
||||
bt_device_get_uuids(handle, addr, &uuids, &uuid_cnt, bttool_allocator);
|
||||
if (uuid_cnt) {
|
||||
PRINT("\tUUIDs:[%d]", uuid_cnt);
|
||||
for (int i = 0; i < uuid_cnt; i++) {
|
||||
bt_uuid_to_string(uuids + i, uuid_str, 40);
|
||||
PRINT("\t\tuuid[%-2d]: %s", i, uuid_str);
|
||||
}
|
||||
}
|
||||
free(uuids);
|
||||
* @endcode
|
||||
*/
|
||||
int bt_uuid_to_string(const bt_uuid_t* uuid, char* str, uint32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -33,20 +33,25 @@ typedef enum {
|
|||
EUV_RPMSG_SERVER_PIPE_OPENED = 1 << 2,
|
||||
} euv_pipe_status_t;
|
||||
|
||||
typedef struct euv_pipe {
|
||||
uv_pipe_t cli_pipe;
|
||||
uv_pipe_t srv_pipe[2];
|
||||
euv_pipe_mode_t mode;
|
||||
euv_pipe_status_t status;
|
||||
void* data;
|
||||
} euv_pipe_t;
|
||||
typedef struct euv_pipe euv_pipe_t;
|
||||
|
||||
typedef void (*euv_read_cb)(euv_pipe_t* handle, const uint8_t* buf, ssize_t size);
|
||||
typedef void (*euv_write_cb)(euv_pipe_t* handle, uint8_t* buf, int status);
|
||||
typedef void (*euv_alloc_cb)(euv_pipe_t* handle, uint8_t** buf, size_t* len);
|
||||
typedef void (*euv_connect_cb)(euv_pipe_t* handle, int status, void* user_data);
|
||||
typedef void (*euv_close_cb)(euv_pipe_t* handle);
|
||||
|
||||
struct euv_pipe {
|
||||
uv_pipe_t cli_pipe;
|
||||
uv_pipe_t srv_pipe[2];
|
||||
euv_pipe_mode_t mode;
|
||||
euv_pipe_status_t status;
|
||||
void* data;
|
||||
euv_close_cb close_cb;
|
||||
};
|
||||
|
||||
euv_pipe_t* euv_pipe_open(uv_loop_t* loop, const char* path, euv_connect_cb cb, void* user_data);
|
||||
void euv_pipe_close_with_cb(euv_pipe_t* handle, euv_close_cb cb);
|
||||
void euv_pipe_close(euv_pipe_t* handle);
|
||||
euv_pipe_t* euv_pipe_connect(uv_loop_t* loop, const char* path, euv_connect_cb cb, void* user_data);
|
||||
#ifdef CONFIG_NET_RPMSG
|
||||
|
|
|
|||
|
|
@ -0,0 +1,327 @@
|
|||
/****************************************************************************
|
||||
* include/nuttx/list.h
|
||||
*
|
||||
* Extracted from logic originally written by Travis Geiselbrecht and
|
||||
* released under a public domain license. Re-released here under the 3-
|
||||
* clause BSD license by Pinecone, Inc.
|
||||
*
|
||||
* Copyright (C) 2008 Travis Geiselbrecht. All rights reserved.
|
||||
* Author: Travis Geiselbrecht <geist@foobox.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_LIST_H
|
||||
#define __INCLUDE_NUTTX_LIST_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define FAR
|
||||
#define NEAR
|
||||
#define DSEG
|
||||
#define CODE
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define LIST_INITIAL_VALUE(list) \
|
||||
{ \
|
||||
&(list), &(list) \
|
||||
}
|
||||
#define LIST_INITIAL_CLEARED_VALUE \
|
||||
{ \
|
||||
NULL, NULL \
|
||||
}
|
||||
|
||||
#define list_in_list(item) ((item)->prev != NULL)
|
||||
#define list_is_empty(list) ((list)->next == list)
|
||||
#define list_is_clear(list) ((list)->next == NULL)
|
||||
#define list_is_singular(list) ((list)->next == (list)->prev)
|
||||
|
||||
#define list_initialize(list) \
|
||||
do { \
|
||||
FAR struct list_node* __list = (list); \
|
||||
__list->prev = __list->next = __list; \
|
||||
} while (0)
|
||||
|
||||
#define list_clear_node(item) \
|
||||
do { \
|
||||
FAR struct list_node* __item = (item); \
|
||||
__item->prev = __item->next = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define list_peek_head(list) ((list)->next != (list) ? (list)->next : NULL)
|
||||
#define list_peek_tail(list) ((list)->prev != (list) ? (list)->prev : NULL)
|
||||
|
||||
#define list_prev(list, item) ((item)->prev != (list) ? (item)->prev : NULL)
|
||||
#define list_prev_wrap(list, item) \
|
||||
((item)->prev != (list) ? (item)->prev : (item)->prev->prev != (list) ? (item)->prev->prev \
|
||||
: NULL)
|
||||
|
||||
#define list_next(list, item) ((item)->next != (list) ? (item)->next : NULL)
|
||||
#define list_next_wrap(list, item) \
|
||||
((item)->next != (list) ? (item)->next : (item)->next->next != (list) ? (item)->next->next \
|
||||
: NULL)
|
||||
|
||||
#define list_entry(ptr, type, member) container_of(ptr, type, member)
|
||||
#define list_first_entry(list, type, member) container_of((list)->next, type, member)
|
||||
#define list_last_entry(list, type, member) container_of((list)->prev, type, member)
|
||||
#define list_next_entry(list, type, member) container_of((list)->member.next, type, member)
|
||||
#define list_prev_entry(list, type, member) container_of((list)->member.prev, type, member)
|
||||
|
||||
#define list_add_after(entry, new_entry) list_add_head(entry, new_entry)
|
||||
#define list_add_head(list, item) \
|
||||
do { \
|
||||
FAR struct list_node* __list = (list); \
|
||||
FAR struct list_node* __item = (item); \
|
||||
__item->next = __list->next; \
|
||||
__item->prev = __list; \
|
||||
__list->next->prev = __item; \
|
||||
__list->next = __item; \
|
||||
} while (0)
|
||||
|
||||
#define list_add_before(entry, new_entry) list_add_tail(entry, new_entry)
|
||||
#define list_add_tail(list, item) \
|
||||
do { \
|
||||
FAR struct list_node* __list = (list); \
|
||||
FAR struct list_node* __item = (item); \
|
||||
__item->prev = __list->prev; \
|
||||
__item->next = __list; \
|
||||
__list->prev->next = __item; \
|
||||
__list->prev = __item; \
|
||||
} while (0)
|
||||
|
||||
#define list_delete(item) \
|
||||
do { \
|
||||
FAR struct list_node* __item = (item); \
|
||||
__item->next->prev = __item->prev; \
|
||||
__item->prev->next = __item->next; \
|
||||
__item->prev = __item->next = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define list_delete_init(item) \
|
||||
do { \
|
||||
list_delete(item); \
|
||||
list_initialize(item); \
|
||||
} while (0)
|
||||
|
||||
#define list_merge(list_dst, list_src) \
|
||||
do { \
|
||||
(list_dst)->prev->next = (list_src)->next; \
|
||||
(list_src)->next->prev = (list_dst)->prev; \
|
||||
(list_src)->prev->next = (list_dst); \
|
||||
(list_dst)->prev = (list_src)->prev; \
|
||||
list_initialize(list_src); \
|
||||
} while (0)
|
||||
|
||||
#define list_remove_head_type(list, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_remove_head(list); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_remove_tail_type(list, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_remove_tail(list); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_peek_head_type(list, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_peek_head(list); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_peek_tail_type(list, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_peek_tail(list); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_prev_type(list, item, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_prev(list, item); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_prev_wrap_type(list, item, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_prev_wrap(list, item); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_next_type(list, item, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_next(list, item); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
#define list_next_wrap_type(list, item, type, member) \
|
||||
({ \
|
||||
FAR struct list_node* __node = list_next_wrap(list, item); \
|
||||
FAR type* __t = NULL; \
|
||||
if (__node) { \
|
||||
__t = container_of(__node, type, member); \
|
||||
} \
|
||||
__t; \
|
||||
})
|
||||
|
||||
/* iterates over the list, node should be struct list_node* */
|
||||
|
||||
#define list_for_every(list, node) \
|
||||
for (node = (list)->next; node != (list); node = node->next)
|
||||
|
||||
/* iterates over the list in a safe way for deletion of current node
|
||||
* node and temp_node should be struct list_node*
|
||||
*/
|
||||
|
||||
#define list_for_every_safe(list, node, temp) \
|
||||
for (node = (list)->next, temp = node->next; \
|
||||
node != (list); node = temp, temp = node->next)
|
||||
|
||||
/* iterates over the list, entry should be the container structure type */
|
||||
|
||||
#define list_for_every_entry(list, entry, type, member) \
|
||||
for (entry = container_of((list)->next, type, member); \
|
||||
&entry->member != (list); \
|
||||
entry = container_of(entry->member.next, type, member))
|
||||
|
||||
/* iterates over the list in a safe way for deletion of current node
|
||||
* entry and temp_entry should be the container structure type *
|
||||
*/
|
||||
|
||||
#define list_for_every_entry_safe(list, entry, temp, type, member) \
|
||||
for (entry = container_of((list)->next, type, member), \
|
||||
temp = container_of(entry->member.next, type, member); \
|
||||
&entry->member != (list); entry = temp, \
|
||||
temp = container_of(temp->member.next, type, member))
|
||||
|
||||
/* Iterate from a given entry node in a safe way */
|
||||
|
||||
#define list_for_every_entry_safe_from(list, cur, temp, type, member) \
|
||||
for ((temp) = list_next_entry(cur, type, member); \
|
||||
&(cur)->member != (list); \
|
||||
(cur) = (temp), (temp) = list_next_entry(temp, type, member))
|
||||
|
||||
#define list_for_every_entry_continue(list, head, type, member) \
|
||||
for ((list) = list_next_entry(list, type, member); \
|
||||
&(list)->member != (head); \
|
||||
(list) = list_next_entry(list, type, member))
|
||||
|
||||
/* iterates over the list in reverse order, entry should be the container
|
||||
* structure type
|
||||
*/
|
||||
|
||||
#define list_for_every_entry_reverse(list, entry, type, member) \
|
||||
for (entry = container_of((list)->prev, type, member); \
|
||||
&entry->member != (list); \
|
||||
entry = container_of(entry->member.prev, type, member))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/list_type.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
static inline FAR struct list_node*
|
||||
list_remove_head(FAR struct list_node* list)
|
||||
{
|
||||
if (list->next != list) {
|
||||
FAR struct list_node* item = list->next;
|
||||
list_delete(item);
|
||||
return item;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline FAR struct list_node*
|
||||
list_remove_tail(FAR struct list_node* list)
|
||||
{
|
||||
if (list->prev != list) {
|
||||
FAR struct list_node* item = list->prev;
|
||||
list_delete(item);
|
||||
return item;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static inline size_t list_length(FAR struct list_node* list)
|
||||
{
|
||||
FAR struct list_node* node = list;
|
||||
size_t cnt = 0;
|
||||
|
||||
list_for_every(list, node)
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_LIST_H */
|
||||
|
|
@ -24,6 +24,9 @@ extern "C" {
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Default string returned when state name is NULL */
|
||||
#define HSM_NONE_STR "None"
|
||||
|
||||
typedef struct _state_machine state_machine_t;
|
||||
|
||||
typedef struct _state {
|
||||
|
|
|
|||
|
|
@ -22,17 +22,6 @@
|
|||
|
||||
typedef void (*thread_func_t)(void* data);
|
||||
|
||||
typedef struct thread_loop_work thread_loop_work_t;
|
||||
typedef void (*thread_work_cb_t)(thread_loop_work_t* work, void* userdata);
|
||||
typedef void (*thread_after_work_cb_t)(thread_loop_work_t* work, void* userdata);
|
||||
|
||||
typedef struct thread_loop_work {
|
||||
uv_work_t work;
|
||||
thread_work_cb_t work_cb;
|
||||
thread_after_work_cb_t after_work_cb;
|
||||
void* userdata;
|
||||
} thread_loop_work_t;
|
||||
|
||||
int thread_loop_init(uv_loop_t* loop);
|
||||
int thread_loop_run(uv_loop_t* loop, bool start_thread, const char* name);
|
||||
void thread_loop_exit(uv_loop_t* loop);
|
||||
|
|
@ -44,7 +33,5 @@ uv_timer_t* thread_loop_timer_no_repeating(uv_loop_t* loop, uint64_t timeout, uv
|
|||
void thread_loop_cancel_timer(uv_timer_t* timer);
|
||||
void do_in_thread_loop(uv_loop_t* loop, thread_func_t func, void* data);
|
||||
void do_in_thread_loop_sync(uv_loop_t* loop, thread_func_t func, void* data);
|
||||
void thread_loop_work_sync(uv_loop_t* loop, void* user_data, thread_work_cb_t work_cb,
|
||||
thread_after_work_cb_t after_work_cb);
|
||||
|
||||
#endif /* _UV_THREAD_LOOP_H__ */
|
||||
|
|
@ -30,7 +30,15 @@ static void adapter_status_reply(bt_instance_t* ins, bt_message_packet_t* packet
|
|||
{
|
||||
bt_status_cb_t ret_cb = (bt_status_cb_t)cb;
|
||||
|
||||
HANDLE_BT_ASTNC_CALLBACK(ret_cb, ins, packet, adpt_r, userdata);
|
||||
if (!ret_cb)
|
||||
return;
|
||||
|
||||
if (!packet) {
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
ret_cb(ins, packet->adpt_r.status, userdata);
|
||||
}
|
||||
|
||||
static void adapter_bool_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
|
|
@ -249,7 +257,7 @@ bt_status_t bt_adapter_register_callback_async(bt_instance_t* ins,
|
|||
{
|
||||
bt_register_callback_data_t* data;
|
||||
bt_socket_async_client_t* priv;
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
void* handle;
|
||||
|
||||
|
|
@ -302,7 +310,7 @@ send_message:
|
|||
|
||||
bt_status_t bt_adapter_unregister_callback_async(bt_instance_t* ins, void* cookie, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
bt_socket_async_client_t* priv;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
|
@ -324,7 +332,7 @@ bt_status_t bt_adapter_unregister_callback_async(bt_instance_t* ins, void* cooki
|
|||
|
||||
bt_status_t bt_adapter_enable_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -333,7 +341,7 @@ bt_status_t bt_adapter_enable_async(bt_instance_t* ins, bt_status_cb_t cb, void*
|
|||
|
||||
bt_status_t bt_adapter_disable_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -342,7 +350,7 @@ bt_status_t bt_adapter_disable_async(bt_instance_t* ins, bt_status_cb_t cb, void
|
|||
|
||||
bt_status_t bt_adapter_enable_le_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -351,7 +359,7 @@ bt_status_t bt_adapter_enable_le_async(bt_instance_t* ins, bt_status_cb_t cb, vo
|
|||
|
||||
bt_status_t bt_adapter_disable_le_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -360,7 +368,7 @@ bt_status_t bt_adapter_disable_le_async(bt_instance_t* ins, bt_status_cb_t cb, v
|
|||
|
||||
bt_status_t bt_adapter_get_state_async(bt_instance_t* ins, bt_adapter_get_state_cb_t get_state_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -369,7 +377,7 @@ bt_status_t bt_adapter_get_state_async(bt_instance_t* ins, bt_adapter_get_state_
|
|||
|
||||
bt_status_t bt_adapter_is_le_enabled_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -378,7 +386,7 @@ bt_status_t bt_adapter_is_le_enabled_async(bt_instance_t* ins, bt_bool_cb_t cb,
|
|||
|
||||
bt_status_t bt_adapter_get_type_async(bt_instance_t* ins, bt_device_type_cb_t get_dtype_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -392,7 +400,7 @@ bt_status_t bt_adapter_set_discovery_filter_async(bt_instance_t* ins, bt_status_
|
|||
|
||||
bt_status_t bt_adapter_start_discovery_async(bt_instance_t* ins, uint32_t timeout, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -403,7 +411,7 @@ bt_status_t bt_adapter_start_discovery_async(bt_instance_t* ins, uint32_t timeou
|
|||
|
||||
bt_status_t bt_adapter_cancel_discovery_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -412,7 +420,7 @@ bt_status_t bt_adapter_cancel_discovery_async(bt_instance_t* ins, bt_status_cb_t
|
|||
|
||||
bt_status_t bt_adapter_is_discovering_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -421,7 +429,7 @@ bt_status_t bt_adapter_is_discovering_async(bt_instance_t* ins, bt_bool_cb_t cb,
|
|||
|
||||
bt_status_t bt_adapter_get_address_async(bt_instance_t* ins, bt_address_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -430,7 +438,7 @@ bt_status_t bt_adapter_get_address_async(bt_instance_t* ins, bt_address_cb_t cb,
|
|||
|
||||
bt_status_t bt_adapter_set_name_async(bt_instance_t* ins, const char* name, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -445,7 +453,7 @@ bt_status_t bt_adapter_set_name_async(bt_instance_t* ins, const char* name, bt_s
|
|||
|
||||
bt_status_t bt_adapter_get_name_async(bt_instance_t* ins, bt_string_cb_t get_name_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -454,7 +462,7 @@ bt_status_t bt_adapter_get_name_async(bt_instance_t* ins, bt_string_cb_t get_nam
|
|||
|
||||
bt_status_t bt_adapter_get_uuids_async(bt_instance_t* ins, bt_uuids_cb_t get_uuids_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -463,7 +471,7 @@ bt_status_t bt_adapter_get_uuids_async(bt_instance_t* ins, bt_uuids_cb_t get_uui
|
|||
|
||||
bt_status_t bt_adapter_set_scan_mode_async(bt_instance_t* ins, bt_scan_mode_t mode, bool bondable, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -475,7 +483,7 @@ bt_status_t bt_adapter_set_scan_mode_async(bt_instance_t* ins, bt_scan_mode_t mo
|
|||
|
||||
bt_status_t bt_adapter_get_scan_mode_async(bt_instance_t* ins, bt_adapter_get_scan_mode_cb_t get_scan_mode_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -484,7 +492,7 @@ bt_status_t bt_adapter_get_scan_mode_async(bt_instance_t* ins, bt_adapter_get_sc
|
|||
|
||||
bt_status_t bt_adapter_set_device_class_async(bt_instance_t* ins, uint32_t cod, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -495,7 +503,7 @@ bt_status_t bt_adapter_set_device_class_async(bt_instance_t* ins, uint32_t cod,
|
|||
|
||||
bt_status_t bt_adapter_get_device_class_async(bt_instance_t* ins, bt_u32_cb_t get_cod_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -504,7 +512,7 @@ bt_status_t bt_adapter_get_device_class_async(bt_instance_t* ins, bt_u32_cb_t ge
|
|||
|
||||
bt_status_t bt_adapter_set_io_capability_async(bt_instance_t* ins, bt_io_capability_t cap, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -515,7 +523,7 @@ bt_status_t bt_adapter_set_io_capability_async(bt_instance_t* ins, bt_io_capabil
|
|||
|
||||
bt_status_t bt_adapter_get_io_capability_async(bt_instance_t* ins, bt_adapter_get_io_capability_cb_t get_ioc_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -525,7 +533,7 @@ bt_status_t bt_adapter_get_io_capability_async(bt_instance_t* ins, bt_adapter_ge
|
|||
bt_status_t bt_adapter_set_inquiry_scan_parameters_async(bt_instance_t* ins, bt_scan_type_t type,
|
||||
uint16_t interval, uint16_t window, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -539,7 +547,7 @@ bt_status_t bt_adapter_set_inquiry_scan_parameters_async(bt_instance_t* ins, bt_
|
|||
bt_status_t bt_adapter_set_page_scan_parameters_async(bt_instance_t* ins, bt_scan_type_t type,
|
||||
uint16_t interval, uint16_t window, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -552,7 +560,7 @@ bt_status_t bt_adapter_set_page_scan_parameters_async(bt_instance_t* ins, bt_sca
|
|||
|
||||
bt_status_t bt_adapter_set_le_io_capability_async(bt_instance_t* ins, uint32_t le_io_cap, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -563,7 +571,7 @@ bt_status_t bt_adapter_set_le_io_capability_async(bt_instance_t* ins, uint32_t l
|
|||
|
||||
bt_status_t bt_adapter_get_le_io_capability_async(bt_instance_t* ins, bt_u32_cb_t get_le_ioc_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -572,7 +580,7 @@ bt_status_t bt_adapter_get_le_io_capability_async(bt_instance_t* ins, bt_u32_cb_
|
|||
|
||||
bt_status_t bt_adapter_get_le_address_async(bt_instance_t* ins, bt_adapter_get_le_address_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -581,7 +589,7 @@ bt_status_t bt_adapter_get_le_address_async(bt_instance_t* ins, bt_adapter_get_l
|
|||
|
||||
bt_status_t bt_adapter_set_le_address_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -592,7 +600,7 @@ bt_status_t bt_adapter_set_le_address_async(bt_instance_t* ins, bt_address_t* ad
|
|||
|
||||
bt_status_t bt_adapter_set_le_identity_address_async(bt_instance_t* ins, bt_address_t* addr, bool is_public, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -604,7 +612,7 @@ bt_status_t bt_adapter_set_le_identity_address_async(bt_instance_t* ins, bt_addr
|
|||
|
||||
bt_status_t bt_adapter_set_le_appearance_async(bt_instance_t* ins, uint16_t appearance, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -615,7 +623,7 @@ bt_status_t bt_adapter_set_le_appearance_async(bt_instance_t* ins, uint16_t appe
|
|||
|
||||
bt_status_t bt_adapter_get_le_appearance_async(bt_instance_t* ins, bt_u16_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -625,7 +633,7 @@ bt_status_t bt_adapter_get_le_appearance_async(bt_instance_t* ins, bt_u16_cb_t c
|
|||
bt_status_t bt_adapter_le_enable_key_derivation_async(bt_instance_t* ins,
|
||||
bool brkey_to_lekey, bool lekey_to_brkey, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -637,7 +645,7 @@ bt_status_t bt_adapter_le_enable_key_derivation_async(bt_instance_t* ins,
|
|||
|
||||
bt_status_t bt_adapter_le_add_whitelist_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -648,7 +656,7 @@ bt_status_t bt_adapter_le_add_whitelist_async(bt_instance_t* ins, bt_address_t*
|
|||
|
||||
bt_status_t bt_adapter_le_remove_whitelist_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -659,7 +667,7 @@ bt_status_t bt_adapter_le_remove_whitelist_async(bt_instance_t* ins, bt_address_
|
|||
|
||||
bt_status_t bt_adapter_get_bonded_devices_async(bt_instance_t* ins, bt_transport_t transport, bt_adapter_get_devices_cb_t get_bonded_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -670,7 +678,7 @@ bt_status_t bt_adapter_get_bonded_devices_async(bt_instance_t* ins, bt_transport
|
|||
|
||||
bt_status_t bt_adapter_get_connected_devices_async(bt_instance_t* ins, bt_transport_t transport, bt_adapter_get_devices_cb_t get_connected_cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -682,7 +690,7 @@ bt_status_t bt_adapter_get_connected_devices_async(bt_instance_t* ins, bt_transp
|
|||
bt_status_t bt_adapter_set_afh_channel_classification_async(bt_instance_t* ins, uint16_t central_frequency,
|
||||
uint16_t band_width, uint16_t number, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -700,7 +708,7 @@ bt_status_t bt_adapter_set_auto_sniff_async(bt_instance_t* ins, bt_auto_sniff_pa
|
|||
|
||||
bt_status_t bt_adapter_disconnect_all_devices_async(bt_instance_t* ins, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -709,7 +717,7 @@ bt_status_t bt_adapter_disconnect_all_devices_async(bt_instance_t* ins, bt_statu
|
|||
|
||||
bt_status_t bt_adapter_is_support_bredr_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -718,7 +726,7 @@ bt_status_t bt_adapter_is_support_bredr_async(bt_instance_t* ins, bt_bool_cb_t c
|
|||
|
||||
bt_status_t bt_adapter_is_support_le_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -727,7 +735,7 @@ bt_status_t bt_adapter_is_support_le_async(bt_instance_t* ins, bt_bool_cb_t cb,
|
|||
|
||||
bt_status_t bt_adapter_is_support_leaudio_async(bt_instance_t* ins, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,15 @@ static void device_status_reply(bt_instance_t* ins, bt_message_packet_t* packet,
|
|||
{
|
||||
bt_status_cb_t ret_cb = (bt_status_cb_t)cb;
|
||||
|
||||
HANDLE_BT_ASTNC_CALLBACK(ret_cb, ins, packet, devs_r, userdata);
|
||||
if (!ret_cb)
|
||||
return;
|
||||
|
||||
if (!packet) {
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
ret_cb(ins, packet->devs_r.status, userdata);
|
||||
}
|
||||
|
||||
static void device_bool_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
|
|
@ -206,7 +214,7 @@ static int bt_device_send_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
|
||||
bt_status_t bt_device_get_identity_address_async(bt_instance_t* ins, bt_address_t* bd_addr, bt_address_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -215,7 +223,7 @@ bt_status_t bt_device_get_identity_address_async(bt_instance_t* ins, bt_address_
|
|||
|
||||
bt_status_t bt_device_get_address_type_async(bt_instance_t* ins, bt_address_t* addr, bt_device_get_address_type_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -224,7 +232,7 @@ bt_status_t bt_device_get_address_type_async(bt_instance_t* ins, bt_address_t* a
|
|||
|
||||
bt_status_t bt_device_get_device_type_async(bt_instance_t* ins, bt_address_t* addr, bt_device_type_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -244,7 +252,7 @@ bt_status_t bt_device_get_name_async(bt_instance_t* ins, bt_address_t* addr, bt_
|
|||
|
||||
bt_status_t bt_device_get_device_class_async(bt_instance_t* ins, bt_address_t* addr, bt_u32_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -264,7 +272,7 @@ bt_status_t bt_device_get_uuids_async(bt_instance_t* ins, bt_address_t* addr, bt
|
|||
|
||||
bt_status_t bt_device_get_appearance_async(bt_instance_t* ins, bt_address_t* addr, bt_u16_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -273,7 +281,7 @@ bt_status_t bt_device_get_appearance_async(bt_instance_t* ins, bt_address_t* add
|
|||
|
||||
bt_status_t bt_device_get_rssi_async(bt_instance_t* ins, bt_address_t* addr, bt_s8_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -308,7 +316,7 @@ bt_status_t bt_device_set_alias_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
bt_status_t bt_device_is_connected_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_transport_t transport, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -320,7 +328,7 @@ bt_status_t bt_device_is_connected_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
bt_status_t bt_device_is_encrypted_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_transport_t transport, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -332,7 +340,7 @@ bt_status_t bt_device_is_encrypted_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
bt_status_t bt_device_is_bond_initiate_local_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_transport_t transport, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -344,7 +352,7 @@ bt_status_t bt_device_is_bond_initiate_local_async(bt_instance_t* ins, bt_addres
|
|||
bt_status_t bt_device_get_bond_state_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_transport_t transport, bt_device_get_bond_state_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -356,7 +364,7 @@ bt_status_t bt_device_get_bond_state_async(bt_instance_t* ins, bt_address_t* add
|
|||
bt_status_t bt_device_is_bonded_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_transport_t transport, bt_bool_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -367,7 +375,7 @@ bt_status_t bt_device_is_bonded_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
|
||||
bt_status_t bt_device_connect_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -376,7 +384,7 @@ bt_status_t bt_device_connect_async(bt_instance_t* ins, bt_address_t* addr, bt_s
|
|||
|
||||
bt_status_t bt_device_disconnect_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -388,7 +396,7 @@ bt_status_t bt_device_connect_le_async(bt_instance_t* ins,
|
|||
ble_addr_type_t type,
|
||||
ble_connect_params_t* param, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -401,7 +409,7 @@ bt_status_t bt_device_connect_le_async(bt_instance_t* ins,
|
|||
|
||||
bt_status_t bt_device_disconnect_le_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -411,7 +419,7 @@ bt_status_t bt_device_disconnect_le_async(bt_instance_t* ins, bt_address_t* addr
|
|||
bt_status_t bt_device_connect_request_reply_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bool accept, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -423,7 +431,7 @@ bt_status_t bt_device_connect_request_reply_async(bt_instance_t* ins, bt_address
|
|||
|
||||
bt_status_t bt_device_connect_all_profile_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -432,7 +440,7 @@ bt_status_t bt_device_connect_all_profile_async(bt_instance_t* ins, bt_address_t
|
|||
|
||||
bt_status_t bt_device_disconnect_all_profile_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -444,7 +452,7 @@ bt_status_t bt_device_set_le_phy_async(bt_instance_t* ins,
|
|||
ble_phy_type_t tx_phy,
|
||||
ble_phy_type_t rx_phy, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -458,7 +466,7 @@ bt_status_t bt_device_set_le_phy_async(bt_instance_t* ins,
|
|||
bt_status_t bt_device_create_bond_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_transport_t transport, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -470,7 +478,7 @@ bt_status_t bt_device_create_bond_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
|
||||
bt_status_t bt_device_remove_bond_async(bt_instance_t* ins, bt_address_t* addr, uint8_t transport, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -482,7 +490,7 @@ bt_status_t bt_device_remove_bond_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
|
||||
bt_status_t bt_device_cancel_bond_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -493,7 +501,7 @@ bt_status_t bt_device_cancel_bond_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
|
||||
bt_status_t bt_device_pair_request_reply_async(bt_instance_t* ins, bt_address_t* addr, bool accept, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -506,7 +514,7 @@ bt_status_t bt_device_pair_request_reply_async(bt_instance_t* ins, bt_address_t*
|
|||
bt_status_t bt_device_set_pairing_confirmation_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
uint8_t transport, bool accept, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -520,7 +528,7 @@ bt_status_t bt_device_set_pairing_confirmation_async(bt_instance_t* ins, bt_addr
|
|||
bt_status_t bt_device_set_pin_code_async(bt_instance_t* ins, bt_address_t* addr, bool accept,
|
||||
char* pincode, int len, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
if (len > sizeof(packet.devs_pl._bt_device_set_pin_code.pincode))
|
||||
|
|
@ -537,7 +545,7 @@ bt_status_t bt_device_set_pin_code_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
bt_status_t bt_device_set_pass_key_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
uint8_t transport, bool accept, uint32_t passkey, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -552,7 +560,7 @@ bt_status_t bt_device_set_pass_key_async(bt_instance_t* ins, bt_address_t* addr,
|
|||
bt_status_t bt_device_set_le_legacy_tk_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_128key_t tk_val, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -565,7 +573,7 @@ bt_status_t bt_device_set_le_legacy_tk_async(bt_instance_t* ins, bt_address_t* a
|
|||
bt_status_t bt_device_set_le_sc_remote_oob_data_async(bt_instance_t* ins, bt_address_t* addr,
|
||||
bt_128key_t c_val, bt_128key_t r_val, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
@ -578,7 +586,7 @@ bt_status_t bt_device_set_le_sc_remote_oob_data_async(bt_instance_t* ins, bt_add
|
|||
|
||||
bt_status_t bt_device_get_le_sc_local_oob_data_async(bt_instance_t* ins, bt_address_t* addr, bt_status_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_message_packet_t packet;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,16 +38,19 @@ typedef struct {
|
|||
gattc_handle_t* user_phandle;
|
||||
} bt_gattc_create_connect_data_t;
|
||||
|
||||
typedef struct {
|
||||
void* userdata;
|
||||
void* gattc_remote;
|
||||
} bt_gattc_delete_connect_data_t;
|
||||
|
||||
static void gattc_status_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
{
|
||||
bt_status_cb_t ret_cb = (bt_status_cb_t)cb;
|
||||
|
||||
HANDLE_BT_ASTNC_CALLBACK(ret_cb, ins, packet, gattc_r, userdata);
|
||||
if (!ret_cb)
|
||||
return;
|
||||
|
||||
if (!packet) {
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
ret_cb(ins, packet->gattc_r.status, userdata);
|
||||
}
|
||||
|
||||
static void gattc_get_attribute_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
|
|
@ -75,7 +78,7 @@ static void gattc_create_connect_reply(bt_instance_t* ins, bt_message_packet_t*
|
|||
if (!packet || packet->gattc_r.status != BT_STATUS_SUCCESS)
|
||||
goto error;
|
||||
|
||||
gattc_remote->cookie = PTR2INT(uint64_t) packet->gattc_r.handle;
|
||||
gattc_remote->cookie = INT2PTR(void*) packet->gattc_r.handle;
|
||||
gattc_remote->user_phandle = data->user_phandle;
|
||||
bt_list_add_tail(priv->gattc_remote_list, gattc_remote);
|
||||
*(data->user_phandle) = gattc_remote;
|
||||
|
|
@ -106,40 +109,32 @@ error:
|
|||
|
||||
static void gattc_delete_connect_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
{
|
||||
bt_gattc_delete_connect_data_t* data = userdata;
|
||||
bt_socket_async_client_t* priv = ins->priv;
|
||||
bt_gattc_delete_connect_cb_t ret_cb = (bt_gattc_delete_connect_cb_t)cb;
|
||||
bt_gattc_remote_t* gattc_remote = (bt_gattc_remote_t*)data->gattc_remote;
|
||||
void** user_phandle = gattc_remote->user_phandle;
|
||||
|
||||
bt_list_remove(priv->gattc_remote_list, gattc_remote);
|
||||
*user_phandle = NULL;
|
||||
|
||||
if (!bt_list_length(priv->gattc_remote_list)) {
|
||||
bt_list_free(priv->gattc_remote_list);
|
||||
priv->gattc_remote_list = NULL;
|
||||
}
|
||||
|
||||
if (!ret_cb) {
|
||||
free(userdata);
|
||||
if (!ret_cb)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packet) {
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, data->userdata);
|
||||
free(userdata);
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
ret_cb(ins, packet->gattc_r.status, data->userdata);
|
||||
free(userdata);
|
||||
ret_cb(ins, packet->gattc_r.status, userdata);
|
||||
}
|
||||
|
||||
static void gattc_write_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
{
|
||||
bt_gattc_write_cb_t ret_cb = (bt_gattc_write_cb_t)cb;
|
||||
|
||||
HANDLE_BT_ASTNC_CALLBACK(ret_cb, ins, packet, gattc_r, userdata);
|
||||
if (!ret_cb)
|
||||
return;
|
||||
|
||||
if (!packet) {
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
ret_cb(ins, packet->gattc_r.status, userdata);
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_create_connect_async(bt_instance_t* ins, gattc_handle_t* phandle, gattc_callbacks_t* callbacks,
|
||||
|
|
@ -206,10 +201,11 @@ fail:
|
|||
bt_status_t bt_gattc_delete_connect_async(gattc_handle_t conn_handle, bt_gattc_delete_connect_cb_t cb, void* userdata)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_gattc_delete_connect_data_t* data;
|
||||
bt_socket_async_client_t* priv;
|
||||
bt_status_t status;
|
||||
bt_instance_t* ins;
|
||||
bt_gattc_remote_t* gattc_remote = (bt_gattc_remote_t*)conn_handle;
|
||||
void** user_phandle;
|
||||
|
||||
CHECK_NULL_PTR(gattc_remote);
|
||||
|
||||
|
|
@ -220,11 +216,18 @@ bt_status_t bt_gattc_delete_connect_async(gattc_handle_t conn_handle, bt_gattc_d
|
|||
ins = gattc_remote->ins;
|
||||
packet.gattc_pl._bt_gattc_delete.handle = PTR2INT(uint64_t) gattc_remote->cookie;
|
||||
|
||||
data = calloc(1, sizeof(bt_gattc_delete_connect_data_t));
|
||||
data->userdata = userdata;
|
||||
data->gattc_remote = (void*)gattc_remote;
|
||||
status = bt_socket_client_send_with_reply(ins, &packet, BT_GATT_CLIENT_DELETE_CONNECT, gattc_delete_connect_reply, (void*)cb, userdata);
|
||||
|
||||
return bt_socket_client_send_with_reply(ins, &packet, BT_GATT_CLIENT_DELETE_CONNECT, gattc_delete_connect_reply, (void*)cb, data);
|
||||
user_phandle = gattc_remote->user_phandle;
|
||||
bt_list_remove(priv->gattc_remote_list, gattc_remote);
|
||||
*user_phandle = NULL;
|
||||
|
||||
if (!bt_list_length(priv->gattc_remote_list)) {
|
||||
bt_list_free(priv->gattc_remote_list);
|
||||
priv->gattc_remote_list = NULL;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_connect_async(gattc_handle_t conn_handle, bt_address_t* addr, ble_addr_type_t addr_type, bt_status_cb_t cb, void* userdata)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,15 @@ static void le_advertiser_status_reply(bt_instance_t* ins, bt_message_packet_t*
|
|||
{
|
||||
bt_status_cb_t ret_cb = (bt_status_cb_t)cb;
|
||||
|
||||
HANDLE_BT_ASTNC_CALLBACK(ret_cb, ins, packet, adv_r, context);
|
||||
if (!ret_cb)
|
||||
return;
|
||||
|
||||
if (!packet) {
|
||||
ret_cb(ins, BT_STATUS_UNHANDLED, context);
|
||||
return;
|
||||
}
|
||||
|
||||
ret_cb(ins, packet->adv_r.status, context);
|
||||
}
|
||||
|
||||
static void le_advertiser_bool_reply(bt_instance_t* ins, bt_message_packet_t* packet, void* cb, void* userdata)
|
||||
|
|
@ -101,7 +109,7 @@ bt_status_t bt_le_start_advertising_async(bt_instance_t* ins, ble_adv_params_t*
|
|||
return BT_STATUS_NOMEM;
|
||||
|
||||
adv->ins = ins;
|
||||
adv->callback = adv_cbs;
|
||||
adv->callbacks = adv_cbs;
|
||||
packet.adv_pl._bt_le_start_advertising.adver = PTR2INT(uint64_t) adv;
|
||||
memcpy(&packet.adv_pl._bt_le_start_advertising.params, params, sizeof(*params));
|
||||
if ((adv_len && (adv_len > sizeof(packet.adv_pl._bt_le_start_advertising.adv_data)))
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ bt_status_t bt_le_start_scan_async(bt_instance_t* ins, const scanner_callbacks_t
|
|||
return BT_STATUS_FAIL;
|
||||
|
||||
scan->ins = ins;
|
||||
scan->callback = (scanner_callbacks_t*)scan_cbs;
|
||||
scan->callbacks = (scanner_callbacks_t*)scan_cbs;
|
||||
packet.scan_pl._bt_le_start_scan.remote = PTR2INT(uint64_t) scan;
|
||||
|
||||
data = calloc(1, sizeof(bt_le_start_scan_data_t));
|
||||
|
|
@ -135,7 +135,7 @@ bt_status_t bt_le_start_scan_settings_async(bt_instance_t* ins, ble_scan_setting
|
|||
return BT_STATUS_FAIL;
|
||||
|
||||
scan->ins = ins;
|
||||
scan->callback = (scanner_callbacks_t*)scan_cbs;
|
||||
scan->callbacks = (scanner_callbacks_t*)scan_cbs;
|
||||
packet.scan_pl._bt_le_start_scan_settings.remote = PTR2INT(uint64_t) scan;
|
||||
if (settings)
|
||||
memcpy(&packet.scan_pl._bt_le_start_scan_settings.settings, settings, sizeof(*settings));
|
||||
|
|
@ -170,7 +170,7 @@ bt_status_t bt_le_start_scan_with_filters_async(bt_instance_t* ins, ble_scan_set
|
|||
return BT_STATUS_FAIL;
|
||||
|
||||
scan->ins = ins;
|
||||
scan->callback = (scanner_callbacks_t*)scan_cbs;
|
||||
scan->callbacks = (scanner_callbacks_t*)scan_cbs;
|
||||
packet.scan_pl._bt_le_start_scan_with_filters.remote = PTR2INT(uint64_t) scan;
|
||||
if (settings)
|
||||
memcpy(&packet.scan_pl._bt_le_start_scan_with_filters.settings, settings, sizeof(*settings));
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@
|
|||
#include "manager_service.h"
|
||||
#include "service_loop.h"
|
||||
|
||||
#ifdef CONFIG_NET_RPMSG
|
||||
#include <netpacket/rpmsg.h>
|
||||
#endif
|
||||
|
||||
bt_instance_t* bluetooth_create_instance(void)
|
||||
{
|
||||
bt_status_t status;
|
||||
|
|
@ -111,8 +107,8 @@ bt_instance_t* bluetooth_create_async_instance(uv_loop_t* loop, bt_ipc_connected
|
|||
return NULL;
|
||||
}
|
||||
|
||||
status = manager_create_async_instance(PTR2INT(uint64_t) ins, BLUETOOTH_SYSTEM,
|
||||
"local", getpid(), (uid_t)pthread_self(), &ins->app_id);
|
||||
status = manager_create_instance(PTR2INT(uint64_t) ins, BLUETOOTH_SYSTEM,
|
||||
"local", getpid(), 0, &ins->app_id);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
bt_socket_client_deinit(ins);
|
||||
free(ins);
|
||||
|
|
@ -133,18 +129,6 @@ bt_instance_t* bluetooth_find_instance(pid_t pid)
|
|||
return INT2PTR(bt_instance_t*) handle;
|
||||
}
|
||||
|
||||
bt_instance_t* bluetooth_find_async_instance(pid_t pid)
|
||||
{
|
||||
bt_status_t status;
|
||||
uint64_t handle;
|
||||
|
||||
status = manager_get_async_instance("local", pid, &handle);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
return INT2PTR(bt_instance_t*) handle;
|
||||
}
|
||||
|
||||
bt_instance_t* bluetooth_get_instance(void)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = bluetooth_find_instance(getpid());
|
||||
|
|
@ -155,16 +139,6 @@ bt_instance_t* bluetooth_get_instance(void)
|
|||
return bluetooth_ins;
|
||||
}
|
||||
|
||||
bt_instance_t* bluetooth_get_async_instance(uv_loop_t* loop, bt_ipc_connected_cb_t connected, bt_ipc_disconnected_cb_t disconnected, void* user_data)
|
||||
{
|
||||
bt_instance_t* bluetooth_ins = bluetooth_find_async_instance(getpid());
|
||||
|
||||
if (bluetooth_ins == NULL)
|
||||
return bluetooth_create_async_instance(loop, connected, disconnected, user_data);
|
||||
else
|
||||
return bluetooth_ins;
|
||||
}
|
||||
|
||||
void* bluetooth_get_proxy(bt_instance_t* ins, enum profile_id id)
|
||||
{
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -117,21 +117,6 @@ bt_status_t bt_adapter_disable(bt_instance_t* ins)
|
|||
return packet.adpt_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_disable_safe(bt_instance_t* ins)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_ADAPTER_DISABLE_SAFE);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.adpt_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_enable_le(bt_instance_t* ins)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
|
|
@ -238,22 +223,6 @@ bt_status_t bt_adapter_start_discovery(bt_instance_t* ins, uint32_t timeout)
|
|||
return packet.adpt_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_start_limited_discovery(bt_instance_t* ins, uint32_t timeout)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
packet.adpt_pl._bt_adapter_start_limited_discovery.v32 = timeout;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_ADAPTER_START_LIMITED_DISCOVERY);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.adpt_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_cancel_discovery(bt_instance_t* ins)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
|
|
@ -575,7 +544,7 @@ bt_status_t bt_adapter_set_le_address(bt_instance_t* ins, bt_address_t* addr)
|
|||
return packet.adpt_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_set_le_identity_address(bt_instance_t* ins, bt_address_t* addr, bool is_public)
|
||||
bt_status_t bt_adapter_set_le_identity_address(bt_instance_t* ins, bt_address_t* addr, bool public)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
|
@ -583,7 +552,7 @@ bt_status_t bt_adapter_set_le_identity_address(bt_instance_t* ins, bt_address_t*
|
|||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.adpt_pl._bt_adapter_set_le_identity_address.addr, addr, sizeof(*addr));
|
||||
packet.adpt_pl._bt_adapter_set_le_identity_address.pub = is_public;
|
||||
packet.adpt_pl._bt_adapter_set_le_identity_address.pub = public;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_ADAPTER_SET_LE_IDENTITY_ADDRESS);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
|
|
@ -643,11 +612,6 @@ bt_status_t bt_adapter_le_enable_key_derivation(bt_instance_t* ins,
|
|||
}
|
||||
|
||||
bt_status_t bt_adapter_le_add_whitelist(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
return bt_adapter_le_add_whitelist_with_type(ins, addr, BT_LE_ADDR_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_le_add_whitelist_with_type(bt_instance_t* ins, bt_address_t* addr, ble_addr_type_t type)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
|
@ -655,7 +619,6 @@ bt_status_t bt_adapter_le_add_whitelist_with_type(bt_instance_t* ins, bt_address
|
|||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.adpt_pl._bt_adapter_le_add_whitelist.addr, addr, sizeof(*addr));
|
||||
packet.adpt_pl._bt_adapter_le_add_whitelist.type = (uint8_t)type;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_ADAPTER_LE_ADD_WHITELIST);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
|
|
@ -808,3 +771,24 @@ bool bt_adapter_is_support_leaudio(bt_instance_t* ins)
|
|||
|
||||
return packet.adpt_r.bbool;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_start_limited_discovery(bt_instance_t* ins, uint32_t timeout)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
packet.adpt_pl._bt_adapter_start_limited_discovery.v32 = timeout;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_ADAPTER_START_LIMITED_DISCOVERY);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.adpt_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_adapter_disable_safe(bt_instance_t* ins)
|
||||
{
|
||||
return bt_adapter_disable(ins);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,71 +116,5 @@ bt_status_t bt_avrcp_control_send_passthrough_cmd(bt_instance_t* ins, bt_address
|
|||
return status;
|
||||
}
|
||||
|
||||
return packet.avrcp_control_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_avrcp_control_get_unit_info(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.avrcp_control_pl._bt_avrcp_control_get_unit_info.addr, addr, sizeof(packet.avrcp_control_pl._bt_avrcp_control_get_unit_info.addr));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_AVRCP_CT_GET_UNIT_INFO_CMD);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.avrcp_control_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_avrcp_control_get_subunit_info(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.avrcp_control_pl._bt_avrcp_control_get_subunit_info.addr, addr, sizeof(packet.avrcp_control_pl._bt_avrcp_control_get_subunit_info.addr));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_AVRCP_CT_GET_SUBUNIT_INFO_CMD);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.avrcp_control_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_avrcp_control_get_playback_state(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.avrcp_control_pl._bt_avrcp_control_get_playback_state.addr, addr, sizeof(packet.avrcp_control_pl._bt_avrcp_control_get_playback_state.addr));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_AVRCP_CT_GET_PLAYBACK_STATE_CMD);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.avrcp_control_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_avrcp_control_register_notification(bt_instance_t* ins, bt_address_t* addr, uint8_t event, uint32_t interval)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.avrcp_control_pl._bt_avrcp_control_register_notification.addr, addr, sizeof(packet.avrcp_control_pl._bt_avrcp_control_register_notification.addr));
|
||||
packet.avrcp_control_pl._bt_avrcp_control_register_notification.event = event;
|
||||
packet.avrcp_control_pl._bt_avrcp_control_register_notification.interval = interval;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_AVRCP_CT_REGISTER_NOTIFICATION_CMD);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.avrcp_control_r.status;
|
||||
}
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/****************************************************************************
|
||||
* 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_cs.h"
|
||||
#include "bt_message.h"
|
||||
#include "bt_socket.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void* bt_cs_register_callbacks(bt_instance_t* ins, const cs_callbacks_t* callbacks)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
void* cookie;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, NULL);
|
||||
|
||||
if (ins->cs_callbacks != NULL) {
|
||||
cookie = bt_remote_callbacks_register(ins->cs_callbacks, NULL, (void*)callbacks);
|
||||
return cookie;
|
||||
}
|
||||
|
||||
ins->cs_callbacks = bt_callbacks_list_new(CONFIG_BLUETOOTH_MAX_REGISTER_NUM);
|
||||
|
||||
cookie = bt_remote_callbacks_register(ins->cs_callbacks, NULL, (void*)callbacks);
|
||||
if (cookie == NULL) {
|
||||
bt_callbacks_list_free(ins->cs_callbacks);
|
||||
ins->cs_callbacks = NULL;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_CS_REGISTER_CALLBACKS);
|
||||
if (status != BT_STATUS_SUCCESS || packet.cs_r.status != BT_STATUS_SUCCESS) {
|
||||
bt_callbacks_list_free(ins->cs_callbacks);
|
||||
ins->cs_callbacks = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cookie;
|
||||
}
|
||||
|
||||
bool bt_cs_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, false);
|
||||
|
||||
if (!ins->cs_callbacks)
|
||||
return false;
|
||||
|
||||
bt_remote_callbacks_unregister(ins->cs_callbacks, NULL, cookie);
|
||||
if (bt_callbacks_list_count(ins->cs_callbacks) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bt_callbacks_list_free(ins->cs_callbacks);
|
||||
ins->cs_callbacks = NULL;
|
||||
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_CS_UNREGISTER_CALLBACKS);
|
||||
if (status != BT_STATUS_SUCCESS || packet.cs_r.status != BT_STATUS_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bt_status_t bt_cs_start_distance_measurement(bt_instance_t* ins, const bt_distance_measurement_params_t* params)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
memcpy(&packet.cs_pl._bt_cs_start_distance_measurement.params, params, sizeof(bt_distance_measurement_params_t));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_CS_START_DISTANCE_MEASUREMENT);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
return packet.cs_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_cs_stop_distance_measurement(bt_instance_t* ins, bt_address_t* addr, uint8_t method, bool timeout)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
memcpy(&packet.cs_pl._bt_cs_stop_distance_measurement.addr, addr, sizeof(packet.cs_pl._bt_cs_stop_distance_measurement.addr));
|
||||
packet.cs_pl._bt_cs_stop_distance_measurement.method = method;
|
||||
packet.cs_pl._bt_cs_stop_distance_measurement.timeout_bool = timeout;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_CS_STOP_DISTANCE_MEASUREMENT);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
return packet.cs_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_cs_set_config(bt_instance_t* ins, bt_address_t* addr, const bt_cs_set_params_t* params)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
if (addr)
|
||||
memcpy(&packet.cs_pl._bt_cs_set_config.addr, addr, sizeof(bt_address_t));
|
||||
|
||||
memcpy(&packet.cs_pl._bt_cs_set_config.params, params, sizeof(bt_cs_set_params_t));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_CS_SET_CONFIG);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
return packet.cs_r.status;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_CS_RAS_TEST
|
||||
bt_status_t bt_cs_test(bt_instance_t* ins, const void* data, uint16_t len)
|
||||
{
|
||||
bt_message_packet_t packet = { 0 };
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
if (data) {
|
||||
memcpy(&packet.cs_pl._bt_cs_test.data, data, len);
|
||||
}
|
||||
|
||||
packet.cs_pl._bt_cs_test.len = len;
|
||||
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_CS_TEST);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
return packet.cs_r.status;
|
||||
}
|
||||
#endif /* CONFIG_BT_CS_RAS_TEST */
|
||||
|
|
@ -177,7 +177,7 @@ bool bt_device_get_alias(bt_instance_t* ins, bt_address_t* addr, char* alias, ui
|
|||
}
|
||||
|
||||
strlcpy(alias, packet.devs_pl._bt_device_get_alias.alias,
|
||||
MIN(length, sizeof(packet.devs_pl._bt_device_get_alias.alias)));
|
||||
MIN(length, sizeof(packet.devs_pl._bt_device_get_alias.alias) - 1));
|
||||
|
||||
return packet.devs_r.status;
|
||||
}
|
||||
|
|
@ -288,40 +288,6 @@ bt_status_t bt_device_connect(bt_instance_t* ins, bt_address_t* addr)
|
|||
return packet.devs_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_device_background_connect(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
if (addr)
|
||||
memcpy(&packet.devs_pl._bt_device_background_connect, addr, sizeof(*addr));
|
||||
else
|
||||
bt_addr_set_empty(&packet.devs_pl._bt_device_background_connect.addr);
|
||||
packet.devs_pl._bt_device_background_connect.transport = transport;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_DEVICE_BACKGROUND_CONNECT);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.devs_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_device_background_disconnect(bt_instance_t* ins, bt_address_t* addr, bt_transport_t transport)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
memcpy(&packet.devs_pl._bt_device_background_disconnect, addr, sizeof(*addr));
|
||||
packet.devs_pl._bt_device_background_disconnect.transport = transport;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_DEVICE_BACKGROUND_DISCONNECT);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.devs_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_device_disconnect(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
|
|
@ -548,7 +514,6 @@ bt_status_t bt_device_set_pin_code(bt_instance_t* ins, bt_address_t* addr, bool
|
|||
memcpy(&packet.devs_pl._bt_device_set_pin_code.addr, addr, sizeof(*addr));
|
||||
memcpy(&packet.devs_pl._bt_device_set_pin_code.pincode, pincode, len);
|
||||
packet.devs_pl._bt_device_set_pin_code.len = len;
|
||||
packet.devs_pl._bt_device_set_pin_code.accept = accept;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_DEVICE_SET_PIN_CODE);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
|
|
@ -575,7 +540,7 @@ bt_status_t bt_device_set_pass_key(bt_instance_t* ins, bt_address_t* addr, uint8
|
|||
return packet.devs_r.status;
|
||||
}
|
||||
|
||||
bt_status_t BTSYMBOLS(bt_device_set_le_legacy_tk)(bt_instance_t* ins, bt_address_t* addr, bt_128key_t tk_val)
|
||||
bt_status_t bt_device_set_le_legacy_tk(bt_instance_t* ins, bt_address_t* addr, bt_128key_t tk_val)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
|
@ -626,34 +591,10 @@ bt_status_t bt_device_get_le_sc_local_oob_data(bt_instance_t* ins, bt_address_t*
|
|||
|
||||
bt_status_t bt_device_enable_enhanced_mode(bt_instance_t* ins, bt_address_t* addr, bt_enhanced_mode_t mode)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.devs_pl._bt_device_enable_enhanced_mode.addr, addr, sizeof(packet.devs_pl._bt_device_enable_enhanced_mode.addr));
|
||||
packet.devs_pl._bt_device_enable_enhanced_mode.mode = mode;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_DEVICE_ENABLE_ENHANCED_MODE);
|
||||
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.devs_r.status;
|
||||
return BT_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
bt_status_t bt_device_disable_enhanced_mode(bt_instance_t* ins, bt_address_t* addr, bt_enhanced_mode_t mode)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.devs_pl._bt_device_disable_enhanced_mode.addr, addr, sizeof(packet.devs_pl._bt_device_disable_enhanced_mode.addr));
|
||||
packet.devs_pl._bt_device_disable_enhanced_mode.mode = mode;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_DEVICE_DISABLE_ENHANCED_MODE);
|
||||
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.devs_r.status;
|
||||
return BT_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ bt_status_t bt_gattc_create_connect(bt_instance_t* ins, gattc_handle_t* phandle,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
gattc_remote->cookie = packet.gattc_r.handle;
|
||||
gattc_remote->cookie = INT2PTR(void*) packet.gattc_r.handle;
|
||||
gattc_remote->user_phandle = phandle;
|
||||
bt_list_add_tail(ins->gattc_remote_list, gattc_remote);
|
||||
|
||||
|
|
@ -267,27 +267,6 @@ bt_status_t bt_gattc_write_without_response(gattc_handle_t conn_handle, uint16_t
|
|||
return packet.gattc_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_write_with_signed(gattc_handle_t conn_handle, uint16_t attr_handle, uint8_t* value, uint16_t length)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
bt_gattc_remote_t* gattc_remote = (bt_gattc_remote_t*)conn_handle;
|
||||
|
||||
CHECK_NULL_PTR(gattc_remote);
|
||||
if (length > sizeof(packet.gattc_pl._bt_gattc_write.value))
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
|
||||
packet.gattc_pl._bt_gattc_write.handle = gattc_remote->cookie;
|
||||
packet.gattc_pl._bt_gattc_write.attr_handle = attr_handle;
|
||||
packet.gattc_pl._bt_gattc_write.length = length;
|
||||
memcpy(packet.gattc_pl._bt_gattc_write.value, value, length);
|
||||
status = bt_socket_client_sendrecv(gattc_remote->ins, &packet, BT_GATT_CLIENT_WRITE_WITH_SIGNED);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.gattc_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_gattc_subscribe(gattc_handle_t conn_handle, uint16_t attr_handle, uint16_t ccc_value)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static bt_gatts_remote_t* gatts_remote_new(bt_instance_t* ins, gatts_callbacks_t
|
|||
|
||||
remote->ins = ins;
|
||||
remote->callbacks = callbacks;
|
||||
remote->cookie = 0;
|
||||
remote->cookie = NULL;
|
||||
|
||||
return remote;
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ bt_status_t bt_gatts_register_service(bt_instance_t* ins, gatts_handle_t* phandl
|
|||
goto fail;
|
||||
}
|
||||
|
||||
gatts_remote->cookie = packet.gatts_r.handle;
|
||||
gatts_remote->cookie = INT2PTR(void*) packet.gatts_r.handle;
|
||||
gatts_remote->user_phandle = phandle;
|
||||
bt_list_add_tail(ins->gatts_remote_list, gatts_remote);
|
||||
|
||||
|
|
@ -199,50 +199,42 @@ bt_status_t bt_gatts_add_attr_table(gatts_handle_t srv_handle, gatt_srv_db_t* sr
|
|||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
int32_t attr_offset = 0;
|
||||
int num_max;
|
||||
bt_gatts_remote_t* gatts_remote = (bt_gatts_remote_t*)srv_handle;
|
||||
uint8_t* raw_data;
|
||||
uint8_t* raw_data = (uint8_t*)packet.gatts_pl._bt_gatts_add_attr_table.attr_db;
|
||||
uint32_t data_length = sizeof(packet.gatts_pl._bt_gatts_add_attr_table.attr_db[0]) * srv_db->attr_num;
|
||||
gatt_attr_db_t* attr_inst = srv_db->attr_db;
|
||||
|
||||
CHECK_NULL_PTR(gatts_remote);
|
||||
if (data_length > sizeof(packet.gatts_pl._bt_gatts_add_attr_table.attr_db))
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
|
||||
while (attr_offset < srv_db->attr_num) {
|
||||
num_max = (srv_db->attr_num - attr_offset)
|
||||
> GATTS_MAX_ATTRIBUTE_NUM
|
||||
? GATTS_MAX_ATTRIBUTE_NUM
|
||||
: (srv_db->attr_num - attr_offset);
|
||||
raw_data += data_length;
|
||||
for (int i = 0; i < srv_db->attr_num; i++, attr_inst++) {
|
||||
memcpy(&packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].uuid, &attr_inst->uuid,
|
||||
sizeof(packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].uuid));
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].handle = attr_inst->handle;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].type = attr_inst->type;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].rsp_type = attr_inst->rsp_type;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].properties = attr_inst->properties;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].permissions = attr_inst->permissions;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].attr_length = attr_inst->attr_length;
|
||||
|
||||
raw_data = (uint8_t*)packet.gatts_pl._bt_gatts_add_attr_table.attr_db
|
||||
+ sizeof(packet.gatts_pl._bt_gatts_add_attr_table.attr_db[0]) * num_max;
|
||||
attr_inst = srv_db->attr_db + attr_offset;
|
||||
if (attr_inst->rsp_type == ATTR_AUTO_RSP && attr_inst->attr_length) {
|
||||
data_length += attr_inst->attr_length;
|
||||
if (data_length > sizeof(packet.gatts_pl._bt_gatts_add_attr_table.attr_db))
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
|
||||
for (int i = 0; i < num_max; i++, attr_inst++) {
|
||||
memcpy(&packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].uuid, &attr_inst->uuid,
|
||||
sizeof(packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].uuid));
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].handle = attr_inst->handle;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].type = attr_inst->type;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].rsp_type = attr_inst->rsp_type;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].properties = attr_inst->properties;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].permissions = attr_inst->permissions;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_db[i].attr_length = attr_inst->attr_length;
|
||||
|
||||
if (attr_inst->rsp_type == ATTR_AUTO_RSP && attr_inst->attr_length) {
|
||||
memcpy(raw_data, attr_inst->attr_value, attr_inst->attr_length);
|
||||
raw_data += attr_inst->attr_length;
|
||||
}
|
||||
memcpy(raw_data, attr_inst->attr_value, attr_inst->attr_length);
|
||||
raw_data += attr_inst->attr_length;
|
||||
}
|
||||
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.handle = PTR2INT(uint64_t) gatts_remote->cookie;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_num = srv_db->attr_num;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_num_offset = attr_offset;
|
||||
status = bt_socket_client_sendrecv(gatts_remote->ins, &packet, BT_GATT_SERVER_ADD_ATTR_TABLE);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
attr_offset += num_max;
|
||||
}
|
||||
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.handle = PTR2INT(uint64_t) gatts_remote->cookie;
|
||||
packet.gatts_pl._bt_gatts_add_attr_table.attr_num = srv_db->attr_num;
|
||||
status = bt_socket_client_sendrecv(gatts_remote->ins, &packet, BT_GATT_SERVER_ADD_ATTR_TABLE);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
if (packet.gatts_r.status == BT_STATUS_SUCCESS) {
|
||||
bt_list_add_tail(gatts_remote->db_list, srv_db);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -327,6 +327,23 @@ bt_status_t bt_hfp_ag_send_at_command(bt_instance_t* ins, bt_address_t* addr, co
|
|||
return packet.hfp_ag_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_send_vendor_specific_at_command(bt_instance_t* ins, bt_address_t* addr, const char* command, const char* value)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.addr, addr, sizeof(bt_address_t));
|
||||
strlcpy(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.cmd, command, sizeof(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.cmd));
|
||||
strlcpy(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.value, value, sizeof(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.value));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_HFP_AG_SEND_VENDOR_SPECIFIC_AT_COMMAND);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.hfp_ag_r.status;
|
||||
}
|
||||
|
||||
bt_status_t 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 state, hfp_call_mode_t mode,
|
||||
hfp_call_mpty_type_t mpty, hfp_call_addrtype_t type, const char* number)
|
||||
|
|
@ -355,24 +372,6 @@ bt_status_t bt_hfp_ag_send_clcc_response(bt_instance_t* ins, bt_address_t* addr,
|
|||
return packet.hfp_ag_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_ag_send_vendor_specific_at_command(bt_instance_t* ins, bt_address_t* addr, const char* command, const char* value)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.addr, addr, sizeof(bt_address_t));
|
||||
strlcpy(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.cmd, command, sizeof(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.cmd));
|
||||
strlcpy(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.value, value, sizeof(packet.hfp_ag_pl._bt_hfp_ag_send_vendor_specific_at_cmd.value));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_HFP_AG_SEND_VENDOR_SPECIFIC_AT_COMMAND);
|
||||
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.hfp_ag_r.status;
|
||||
}
|
||||
|
||||
bt_status_t 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)
|
||||
|
|
|
|||
|
|
@ -454,34 +454,3 @@ bt_status_t bt_hfp_hf_send_dtmf(bt_instance_t* ins, bt_address_t* addr, char dtm
|
|||
|
||||
return packet.hfp_hf_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_get_subscriber_number(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.hfp_hf_pl._bt_hfp_hf_get_subscriber_number.addr, addr, sizeof(bt_address_t));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_HFP_HF_GET_SUBSCRIBER_NUMBER);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.hfp_hf_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_hfp_hf_query_current_calls_with_callback(bt_instance_t* ins, bt_address_t* addr)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
memcpy(&packet.hfp_hf_pl._bt_hfp_hf_query_current_calls_with_callback.addr, addr, sizeof(bt_address_t));
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_HFP_HF_QUERY_CURRENT_CALLS_WITH_CALLBACK);
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return packet.hfp_hf_r.status;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ void* bt_l2cap_register_callbacks(bt_instance_t* ins, const l2cap_callbacks_t* c
|
|||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
void* handle;
|
||||
void* cookie;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, NULL);
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ void* bt_l2cap_register_callbacks(bt_instance_t* ins, const l2cap_callbacks_t* c
|
|||
return NULL;
|
||||
}
|
||||
|
||||
handle = bt_remote_callbacks_register(ins->l2cap_callbacks, NULL, (void*)callbacks);
|
||||
if (handle == NULL) {
|
||||
cookie = bt_remote_callbacks_register(ins->l2cap_callbacks, NULL, (void*)callbacks);
|
||||
if (cookie == NULL) {
|
||||
bt_callbacks_list_free(ins->l2cap_callbacks);
|
||||
ins->l2cap_callbacks = NULL;
|
||||
return NULL;
|
||||
|
|
@ -53,10 +53,10 @@ void* bt_l2cap_register_callbacks(bt_instance_t* ins, const l2cap_callbacks_t* c
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return handle;
|
||||
return cookie;
|
||||
}
|
||||
|
||||
bool bt_l2cap_unregister_callbacks(bt_instance_t* ins, void* handle)
|
||||
bool bt_l2cap_unregister_callbacks(bt_instance_t* ins, void* cookie)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
|
@ -68,7 +68,7 @@ bool bt_l2cap_unregister_callbacks(bt_instance_t* ins, void* handle)
|
|||
return false;
|
||||
}
|
||||
|
||||
bt_remote_callbacks_unregister(ins->l2cap_callbacks, NULL, handle);
|
||||
bt_remote_callbacks_unregister(ins->l2cap_callbacks, NULL, cookie);
|
||||
|
||||
cbsl = ins->l2cap_callbacks;
|
||||
ins->l2cap_callbacks = NULL;
|
||||
|
|
@ -82,7 +82,7 @@ bool bt_l2cap_unregister_callbacks(bt_instance_t* ins, void* handle)
|
|||
return true;
|
||||
}
|
||||
|
||||
bt_status_t bt_l2cap_listen(bt_instance_t* ins, void* handle, l2cap_config_option_t* option)
|
||||
bt_status_t bt_l2cap_listen(bt_instance_t* ins, l2cap_config_option_t* option)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
|
@ -94,14 +94,10 @@ bt_status_t bt_l2cap_listen(bt_instance_t* ins, void* handle, l2cap_config_optio
|
|||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
option->psm = packet.l2cap_pl._bt_l2cap_listen.option.psm;
|
||||
option->id = packet.l2cap_pl._bt_l2cap_listen.option.id;
|
||||
strlcpy(option->proxy_name, packet.l2cap_pl._bt_l2cap_listen.option.proxy_name, sizeof(option->proxy_name));
|
||||
|
||||
return packet.l2cap_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_l2cap_connect(bt_instance_t* ins, void* handle, bt_address_t* addr, l2cap_config_option_t* option)
|
||||
bt_status_t bt_l2cap_connect(bt_instance_t* ins, bt_address_t* addr, l2cap_config_option_t* option)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
|
@ -114,55 +110,20 @@ bt_status_t bt_l2cap_connect(bt_instance_t* ins, void* handle, bt_address_t* add
|
|||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
option->id = packet.l2cap_pl._bt_l2cap_connect.option.id;
|
||||
strlcpy(option->proxy_name, packet.l2cap_pl._bt_l2cap_connect.option.proxy_name, sizeof(option->proxy_name));
|
||||
|
||||
return packet.l2cap_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_l2cap_disconnect(bt_instance_t* ins, void* handle, uint16_t id)
|
||||
bt_status_t bt_l2cap_disconnect(bt_instance_t* ins, uint16_t cid)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
packet.l2cap_pl._bt_l2cap_disconnect.id = id;
|
||||
packet.l2cap_pl._bt_l2cap_disconnect.cid = cid;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_L2CAP_DISCONNECT);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.l2cap_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_l2cap_stop_listen(bt_instance_t* ins, void* handle, uint16_t psm)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
packet.l2cap_pl._bt_l2cap_stop_listen.transport = BT_TRANSPORT_BLE;
|
||||
packet.l2cap_pl._bt_l2cap_stop_listen.psm = psm;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_L2CAP_STOP_LISTEN);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.l2cap_r.status;
|
||||
}
|
||||
|
||||
bt_status_t bt_l2cap_stop_listen_with_transport(bt_instance_t* ins, void* handle, bt_transport_t transport, uint16_t psm)
|
||||
{
|
||||
bt_message_packet_t packet;
|
||||
bt_status_t status;
|
||||
|
||||
BT_SOCKET_INS_VALID(ins, BT_STATUS_PARM_INVALID);
|
||||
|
||||
packet.l2cap_pl._bt_l2cap_stop_listen.transport = transport;
|
||||
packet.l2cap_pl._bt_l2cap_stop_listen.psm = psm;
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_L2CAP_STOP_LISTEN);
|
||||
if (status != BT_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
return packet.l2cap_r.status;
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ bt_advertiser_t* bt_le_start_advertising(bt_instance_t* ins,
|
|||
if (adv == NULL)
|
||||
return NULL;
|
||||
|
||||
adv->callback = cbs;
|
||||
adv->callbacks = cbs;
|
||||
packet.adv_pl._bt_le_start_advertising.adver = PTR2INT(uint64_t) adv;
|
||||
memcpy(&packet.adv_pl._bt_le_start_advertising.params, params, sizeof(*params));
|
||||
if ((adv_len && (adv_len > sizeof(packet.adv_pl._bt_le_start_advertising.adv_data)))
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
***************************************************************************/
|
||||
#define LOG_TAG "scan"
|
||||
#define LOG_TAG "adv"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ bt_scanner_t* bt_le_start_scan(bt_instance_t* ins, const scanner_callbacks_t* cb
|
|||
if (scan == NULL)
|
||||
return NULL;
|
||||
|
||||
scan->callback = (scanner_callbacks_t*)cbs;
|
||||
scan->callbacks = (scanner_callbacks_t*)cbs;
|
||||
packet.scan_pl._bt_le_start_scan.remote = PTR2INT(uint64_t) scan;
|
||||
|
||||
status = bt_socket_client_sendrecv(ins, &packet, BT_LE_SCAN_START);
|
||||
|
|
@ -62,7 +62,7 @@ bt_scanner_t* bt_le_start_scan_settings(bt_instance_t* ins,
|
|||
if (scan == NULL)
|
||||
return NULL;
|
||||
|
||||
scan->callback = (scanner_callbacks_t*)cbs;
|
||||
scan->callbacks = (scanner_callbacks_t*)cbs;
|
||||
packet.scan_pl._bt_le_start_scan_settings.remote = PTR2INT(uint64_t) scan;
|
||||
if (settings)
|
||||
memcpy(&packet.scan_pl._bt_le_start_scan_settings.settings, settings, sizeof(*settings));
|
||||
|
|
@ -91,7 +91,7 @@ bt_scanner_t* bt_le_start_scan_with_filters(bt_instance_t* ins,
|
|||
if (scan == NULL)
|
||||
return NULL;
|
||||
|
||||
scan->callback = (scanner_callbacks_t*)cbs;
|
||||
scan->callbacks = (scanner_callbacks_t*)cbs;
|
||||
packet.scan_pl._bt_le_start_scan_with_filters.remote = PTR2INT(uint64_t) scan;
|
||||
if (settings)
|
||||
memcpy(&packet.scan_pl._bt_le_start_scan_with_filters.settings, settings, sizeof(*settings));
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ func frameworkBluetoothHook(ctx android.LoadHookContext) {
|
|||
p.Cflags = append(p.Cflags, "-DANDROID_12")
|
||||
} else if (Version == "14") {
|
||||
p.Cflags = append(p.Cflags, "-DANDROID_14")
|
||||
} else if (Version == "15") {
|
||||
p.Cflags = append(p.Cflags, "-DANDROID_15")
|
||||
}
|
||||
|
||||
ctx.AppendProperties(p)
|
||||
|
|
|
|||
|
|
@ -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 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 get_os_timestamp_ms(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_BOOTTIME, &ts);
|
||||
|
||||
return (uint32_t)((ts.tv_sec * 1000) + (ts.tv_nsec / 1000000UL));
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue