@doubao-dev/plugin-app-dev 0.0.0-stage → 0.0.40-canary-dea0ddc73-20261026073950

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +10 -2
  2. package/dist/147.js +9 -0
  3. package/dist/assets.d.ts +5 -0
  4. package/dist/assets.js +4 -0
  5. package/dist/index.d.ts +43 -0
  6. package/dist/index.js +1378 -0
  7. package/dist/plugin.d.ts +102 -0
  8. package/dist/plugin.js +4995 -0
  9. package/dist/preview.js +16 -0
  10. package/dist/rslib-runtime.js +33 -0
  11. package/dist/skills/doubao-plugin-app/SKILL.md +21 -0
  12. package/dist/skills/doubao-plugin-app/references/app-development.md +85 -0
  13. package/dist/skills/doubao-plugin-app/references/frontend/components/container-overlay.md +131 -0
  14. package/dist/skills/doubao-plugin-app/references/frontend/components/form-controls.md +146 -0
  15. package/dist/skills/doubao-plugin-app/references/frontend/components/interactive-controls.md +120 -0
  16. package/dist/skills/doubao-plugin-app/references/frontend/components/map-canvas.md +107 -0
  17. package/dist/skills/doubao-plugin-app/references/frontend/components/overview.md +43 -0
  18. package/dist/skills/doubao-plugin-app/references/frontend/components/scroll-list.md +149 -0
  19. package/dist/skills/doubao-plugin-app/references/frontend/components/text-media.md +209 -0
  20. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +1389 -0
  21. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +1376 -0
  22. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/03-/350/207/252/345/256/232/344/271/211/351/200/232/344/277/241.md +127 -0
  23. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/04-/345/256/232/344/275/215.md +784 -0
  24. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/05-/345/255/230/345/202/250.md +1176 -0
  25. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +839 -0
  26. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +376 -0
  27. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +1319 -0
  28. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/09-/350/276/223/345/205/245.md +192 -0
  29. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/347/275/221/347/273/234.md +900 -0
  30. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +1496 -0
  31. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/12-/344/270/232/345/212/241/350/203/275/345/212/233.md +1281 -0
  32. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/13-/347/231/273/345/275/225.md +511 -0
  33. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/14-/346/224/257/344/273/230.md +943 -0
  34. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/15-/346/225/260/346/215/256/345/210/206/346/236/220.md +124 -0
  35. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/16-/350/223/235/347/211/231.md +3364 -0
  36. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/17-wi-fi.md +1028 -0
  37. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/18-/345/212/240/351/200/237/345/272/246/350/256/241.md +354 -0
  38. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/19-ibeacon.md +508 -0
  39. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/20-/347/275/227/347/233/230.md +320 -0
  40. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/21-/350/256/276/345/244/207/346/226/271/345/220/221.md +351 -0
  41. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/22-/351/231/200/350/236/272/344/273/252.md +354 -0
  42. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/23-/345/252/222/344/275/223-/350/256/276/345/244/207-/347/275/221/347/273/234.md +264 -0
  43. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/24-/347/237/255/344/277/241.md +155 -0
  44. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/25-/346/227/240/351/232/234/347/242/215.md +144 -0
  45. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/26-/345/237/272/347/241/200/344/277/241/346/201/257.md +238 -0
  46. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/27-/347/224/265/346/261/240.md +235 -0
  47. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/28-/345/211/252/350/264/264/346/235/277.md +303 -0
  48. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/29-/345/212/240/345/257/206.md +126 -0
  49. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/30-/346/227/245/345/216/206.md +417 -0
  50. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/31-/347/224/265/350/257/235.md +144 -0
  51. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/32-/346/211/253/347/240/201.md +236 -0
  52. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/33-/345/261/217/345/271/225.md +747 -0
  53. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/34-/351/234/207/345/212/250.md +277 -0
  54. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/35-/346/226/207/344/273/266/347/263/273/347/273/237.md +431 -0
  55. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/common-errors.md +69 -0
  56. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +43 -0
  57. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +436 -0
  58. package/dist/skills/doubao-plugin-app/references/frontend/examples/common-patterns.md +590 -0
  59. package/dist/skills/doubao-plugin-app/references/frontend/examples/doubao-agentic-service-api-recipes.md +209 -0
  60. package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-basics.md +368 -0
  61. package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-recipes.md +65 -0
  62. package/dist/skills/doubao-plugin-app/references/frontend/framework/core.md +283 -0
  63. package/dist/skills/doubao-plugin-app/references/frontend/guides/auth.md +277 -0
  64. package/dist/skills/doubao-plugin-app/references/frontend/guides/best-practices.md +574 -0
  65. package/dist/skills/doubao-plugin-app/references/frontend/guides/client-tools-and-events.md +209 -0
  66. package/dist/skills/doubao-plugin-app/references/frontend/guides/component-development.md +832 -0
  67. package/dist/skills/doubao-plugin-app/references/frontend/guides/debugger-mcp.md +537 -0
  68. package/dist/skills/doubao-plugin-app/references/frontend/guides/expired-widget.md +101 -0
  69. package/dist/skills/doubao-plugin-app/references/frontend/guides/performance-optimization.md +417 -0
  70. package/dist/skills/doubao-plugin-app/references/frontend/guides/troubleshooting.md +278 -0
  71. package/dist/skills/doubao-plugin-app/references/frontend/lynx/best-practices.md +720 -0
  72. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/pseudo-classes.md +149 -0
  73. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/selectors.md +224 -0
  74. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/supported-properties.md +269 -0
  75. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/values-and-units.md +314 -0
  76. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/flex-layout.md +334 -0
  77. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/grid-layout.md +408 -0
  78. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/linear-layout.md +355 -0
  79. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/relative-layout.md +189 -0
  80. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/css-differences.md +737 -0
  81. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/migration-guide.md +669 -0
  82. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/unsupported-features.md +290 -0
  83. package/dist/skills/doubao-plugin-app/references/frontend/lynx/overview.md +60 -0
  84. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/animation.md +243 -0
  85. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/responsive.md +194 -0
  86. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/theming.md +143 -0
  87. package/dist/skills/doubao-plugin-app/references/frontend/lynx/quick-reference.md +229 -0
  88. package/dist/skills/doubao-plugin-app/references/frontend/rules/dos-and-donts.md +479 -0
  89. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/design-boundary.md +46 -0
  90. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/overview.md +118 -0
  91. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +301 -0
  92. package/dist/skills/doubao-plugin-app/references/mcp-and-cards.md +38 -0
  93. package/dist/templates/README.md.template +11 -0
  94. package/dist/templates/com.doubao/app/manifest.yaml +41 -0
  95. package/dist/templates/com.doubao/app/package.json.template +13 -0
  96. package/dist/templates/com.doubao/app/src/app.config.ts.template +5 -0
  97. package/dist/templates/com.doubao/app/src/app.ts.template +3 -0
  98. package/dist/templates/com.doubao/app/src/pages/home/index.css +14 -0
  99. package/dist/templates/com.doubao/app/src/pages/home/index.tsx.template +14 -0
  100. package/dist/templates/com.doubao/app/src/widgets/example/index.tsx.template +29 -0
  101. package/dist/templates/com.doubao/app/tsconfig.json +19 -0
  102. package/dist/templates/mcp.json +9 -0
  103. package/dist/templates/plugin.json.template +29 -0
  104. package/dist/templates/skills/example/SKILL.md.template +14 -0
  105. package/dist/upload.d.ts +44 -0
  106. package/dist/upload.js +38 -0
  107. package/package.json +60 -3
@@ -0,0 +1,3364 @@
1
+ # 豆包应用插件的端能力 API: 蓝牙
2
+
3
+ 蓝牙和 BLE 能力;通常先打开适配器,再扫描、连接和读写。
4
+
5
+ [返回目录](./groups.md) | [返回速查](./quick-reference.md)
6
+
7
+ ## 速查
8
+
9
+ | API | 说明 |
10
+ | --- | --- |
11
+ | [openBluetoothAdapter](#openbluetoothadapter) | 打开蓝牙适配器。 |
12
+ | [startBluetoothDevicesDiscovery](#startbluetoothdevicesdiscovery) | 开始搜索附近的蓝牙设备。 |
13
+ | [stopBluetoothDevicesDiscovery](#stopbluetoothdevicesdiscovery) | 停止搜索附近的蓝牙设备。 |
14
+ | [getBluetoothAdapterState](#getbluetoothadapterstate) | 获取蓝牙适配器状态。 |
15
+ | [getBluetoothDevices](#getbluetoothdevices) | 获取当前蓝牙模块发现的设备列表。 |
16
+ | [getConnectedBluetoothDevices](#getconnectedbluetoothdevices) | 获取已连接的蓝牙设备列表。 |
17
+ | [makeBluetoothPair](#makebluetoothpair) | 发起蓝牙配对。 |
18
+ | [isBluetoothDevicePaired](#isbluetoothdevicepaired) | 查询蓝牙设备是否已经配对。 |
19
+ | [closeBluetoothAdapter](#closebluetoothadapter) | 关闭蓝牙适配器。 |
20
+ | [createBLEConnection](#createbleconnection) | 创建 BLE 连接。 |
21
+ | [closeBLEConnection](#closebleconnection) | 关闭 BLE 连接。 |
22
+ | [getBLEDeviceServices](#getbledeviceservices) | 获取 BLE 服务列表。 |
23
+ | [getBLEDeviceCharacteristics](#getbledevicecharacteristics) | 获取 BLE 特征值列表。 |
24
+ | [getBLEDeviceRSSI](#getbledevicerssi) | 获取 BLE 设备 RSSI。 |
25
+ | [getBLEMTU](#getblemtu) | 获取 BLE MTU。 |
26
+ | [notifyBLECharacteristicValueChange](#notifyblecharacteristicvaluechange) | 订阅 BLE 特征值变化。 |
27
+ | [readBLECharacteristicValue](#readblecharacteristicvalue) | 读取 BLE 特征值。 |
28
+ | [setBLEMTU](#setblemtu) | 设置 BLE MTU。 |
29
+ | [writeBLECharacteristicValue](#writeblecharacteristicvalue) | 写入 BLE 特征值。 |
30
+ | [onBluetoothAdapterStateChange](#onbluetoothadapterstatechange) | 注册蓝牙适配器状态变化回调。<br><br>返回取消监听函数。 |
31
+ | [onBluetoothDeviceFound](#onbluetoothdevicefound) | 注册发现蓝牙设备回调。<br><br>返回取消监听函数。 |
32
+ | [onBLEConnectionStateChange](#onbleconnectionstatechange) | 注册 BLE 连接状态变化回调。<br><br>返回取消监听函数。 |
33
+ | [onBLECharacteristicValueChange](#onblecharacteristicvaluechange) | 注册 BLE 特征值变化回调。<br><br>返回取消监听函数。 |
34
+
35
+ ## API 详情
36
+
37
+ <a id="openbluetoothadapter"></a>
38
+ ### openBluetoothAdapter()
39
+
40
+ # openBluetoothAdapter
41
+
42
+ 打开蓝牙适配器。
43
+
44
+ ## 扫码预览
45
+ ![扫码预览 openBluetoothAdapter](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-adapter%252Findex)
46
+
47
+ ## 支持版本
48
+
49
+ 前端库版本不低于 `0.0.25`。
50
+
51
+ ## 支持平台
52
+
53
+ <table>
54
+ <thead>
55
+ <tr><th>平台</th><th>支持情况</th></tr>
56
+ </thead>
57
+ <tbody>
58
+ <tr><td>Android</td><td>支持</td></tr>
59
+ <tr><td>iOS</td><td>支持</td></tr>
60
+ <tr><td>PC</td><td>不支持</td></tr>
61
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
62
+ </tbody>
63
+ </table>
64
+
65
+ ## 支持场景
66
+
67
+ <table>
68
+ <thead>
69
+ <tr><th>场景</th><th>支持情况</th></tr>
70
+ </thead>
71
+ <tbody>
72
+ <tr><td>页面</td><td>支持</td></tr>
73
+ <tr><td>卡片</td><td>不支持</td></tr>
74
+ </tbody>
75
+ </table>
76
+
77
+ ## 接入准备
78
+
79
+ ### 权限要求
80
+
81
+ <table>
82
+ <thead>
83
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
84
+ </thead>
85
+ <tbody>
86
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限,Android 低版本扫描附近设备还需定位权限</td></tr>
87
+ </tbody>
88
+ </table>
89
+
90
+ ### 授权行为
91
+
92
+ - 首次使用蓝牙能力时会触发系统蓝牙权限申请;用户拒绝后调用失败,需引导用户在系统设置中开启蓝牙权限
93
+
94
+ ## 使用说明
95
+
96
+ 蓝牙流程入口。
97
+
98
+ - 蓝牙流程入口,后续搜索、连接能力都需要先成功打开适配器
99
+
100
+ ## 调用方式
101
+
102
+ ### 异步 API
103
+
104
+ ```typescript
105
+ openBluetoothAdapter(params?: object): Promise<object>
106
+ ```
107
+
108
+ ## 入参
109
+
110
+ 无。
111
+
112
+ ## 调用示例
113
+
114
+ ```typescript
115
+ import { openBluetoothAdapter } from '@doubao-dev/framework/api';
116
+
117
+ await openBluetoothAdapter();
118
+ ```
119
+
120
+ ## 成功返回
121
+
122
+ 无返回字段。
123
+
124
+ ### 返回示例
125
+
126
+ ```json
127
+ {}
128
+ ```
129
+
130
+ ## 错误处理
131
+
132
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
133
+
134
+ ### 错误码
135
+
136
+ #### 通用错误码
137
+
138
+ <table>
139
+ <thead>
140
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
141
+ </thead>
142
+ <tbody>
143
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
144
+ <tr><td><code>106</code></td><td><code>system permission denied</code></td><td>系统权限未授予</td><td>Android、iOS</td></tr>
145
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
146
+ <tr><td><code>118</code></td><td><code>already exists</code></td><td>资源已存在</td><td>Android、iOS</td></tr>
147
+ </tbody>
148
+ </table>
149
+
150
+ <a id="startbluetoothdevicesdiscovery"></a>
151
+ ### startBluetoothDevicesDiscovery()
152
+
153
+ # startBluetoothDevicesDiscovery
154
+
155
+ 开始搜索附近的蓝牙设备。
156
+
157
+ ## 扫码预览
158
+ ![扫码预览 startBluetoothDevicesDiscovery](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-discovery%252Findex)
159
+
160
+ ## 支持版本
161
+
162
+ 前端库版本不低于 `0.0.25`。
163
+
164
+ ## 支持平台
165
+
166
+ <table>
167
+ <thead>
168
+ <tr><th>平台</th><th>支持情况</th></tr>
169
+ </thead>
170
+ <tbody>
171
+ <tr><td>Android</td><td>支持</td></tr>
172
+ <tr><td>iOS</td><td>支持</td></tr>
173
+ <tr><td>PC</td><td>不支持</td></tr>
174
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
175
+ </tbody>
176
+ </table>
177
+
178
+ ## 支持场景
179
+
180
+ <table>
181
+ <thead>
182
+ <tr><th>场景</th><th>支持情况</th></tr>
183
+ </thead>
184
+ <tbody>
185
+ <tr><td>页面</td><td>支持</td></tr>
186
+ <tr><td>卡片</td><td>不支持</td></tr>
187
+ </tbody>
188
+ </table>
189
+
190
+ ## 接入准备
191
+
192
+ ### 权限要求
193
+
194
+ <table>
195
+ <thead>
196
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
197
+ </thead>
198
+ <tbody>
199
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>扫描附近蓝牙设备需要系统蓝牙权限,Android 低版本还需定位权限</td></tr>
200
+ </tbody>
201
+ </table>
202
+
203
+ ### 授权行为
204
+
205
+ - 首次搜索时会触发系统蓝牙权限申请;用户拒绝后调用失败,需引导用户在系统设置中开启蓝牙权限
206
+
207
+ ### 前置条件
208
+
209
+ - 需先调用 openBluetoothAdapter 打开蓝牙适配器
210
+
211
+ ## 使用说明
212
+
213
+ 通常先调用 openBluetoothAdapter。
214
+
215
+ - 通过 onBluetoothDeviceFound 接收扫描结果,不再需要搜索时应调用 stopBluetoothDevicesDiscovery 以降低功耗
216
+
217
+ ## 调用方式
218
+
219
+ ### 异步 API
220
+
221
+ ```typescript
222
+ startBluetoothDevicesDiscovery(params?: StartBluetoothDevicesDiscoveryParams): Promise<object>
223
+ ```
224
+
225
+ ## 入参
226
+
227
+ <table>
228
+ <thead>
229
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
230
+ </thead>
231
+ <tbody>
232
+ <tr><td><code>allowDuplicatesKey</code></td><td><code>boolean</code></td><td>否</td><td><code>false</code></td><td>-</td><td>是否允许重复上报同一设备。</td></tr>
233
+ <tr><td><code>interval</code></td><td><code>number</code></td><td>否</td><td><code>由平台使用默认上报间隔</code></td><td>-</td><td>上报设备的间隔,单位毫秒。</td></tr>
234
+ <tr><td><code>powerLevel</code></td><td><code>BluetoothPowerLevel</code></td><td>否</td><td><code>medium</code></td><td>-</td><td>扫描功耗等级。</td></tr>
235
+ <tr><td><code>services</code></td><td><code>string[]</code></td><td>否</td><td><code>不按服务 UUID 过滤</code></td><td>-</td><td>按主服务 UUID 过滤搜索范围。</td></tr>
236
+ </tbody>
237
+ </table>
238
+
239
+ ## 调用示例
240
+
241
+ ```typescript
242
+ import { openBluetoothAdapter, startBluetoothDevicesDiscovery } from '@doubao-dev/framework/api';
243
+
244
+ await openBluetoothAdapter();
245
+ await startBluetoothDevicesDiscovery({ allowDuplicatesKey: false });
246
+ ```
247
+
248
+ ## 成功返回
249
+
250
+ 无返回字段。
251
+
252
+ ### 返回示例
253
+
254
+ ```json
255
+ {}
256
+ ```
257
+
258
+ ## 错误处理
259
+
260
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
261
+
262
+ ### 错误码
263
+
264
+ #### 通用错误码
265
+
266
+ <table>
267
+ <thead>
268
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
269
+ </thead>
270
+ <tbody>
271
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
272
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
273
+ <tr><td><code>106</code></td><td><code>system permission denied</code></td><td>系统权限未授予</td><td>Android、iOS</td></tr>
274
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
275
+ <tr><td><code>118</code></td><td><code>already exists</code></td><td>资源已存在</td><td>Android、iOS</td></tr>
276
+ </tbody>
277
+ </table>
278
+
279
+ <a id="stopbluetoothdevicesdiscovery"></a>
280
+ ### stopBluetoothDevicesDiscovery()
281
+
282
+ # stopBluetoothDevicesDiscovery
283
+
284
+ 停止搜索附近的蓝牙设备。
285
+
286
+ ## 扫码预览
287
+ ![扫码预览 stopBluetoothDevicesDiscovery](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-discovery%252Findex)
288
+
289
+ ## 支持版本
290
+
291
+ 前端库版本不低于 `0.0.25`。
292
+
293
+ ## 支持平台
294
+
295
+ <table>
296
+ <thead>
297
+ <tr><th>平台</th><th>支持情况</th></tr>
298
+ </thead>
299
+ <tbody>
300
+ <tr><td>Android</td><td>支持</td></tr>
301
+ <tr><td>iOS</td><td>支持</td></tr>
302
+ <tr><td>PC</td><td>不支持</td></tr>
303
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
304
+ </tbody>
305
+ </table>
306
+
307
+ ## 支持场景
308
+
309
+ <table>
310
+ <thead>
311
+ <tr><th>场景</th><th>支持情况</th></tr>
312
+ </thead>
313
+ <tbody>
314
+ <tr><td>页面</td><td>支持</td></tr>
315
+ <tr><td>卡片</td><td>不支持</td></tr>
316
+ </tbody>
317
+ </table>
318
+
319
+ ## 接入准备
320
+
321
+ ### 权限要求
322
+
323
+ <table>
324
+ <thead>
325
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
326
+ </thead>
327
+ <tbody>
328
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
329
+ </tbody>
330
+ </table>
331
+
332
+ ### 授权行为
333
+
334
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
335
+
336
+ ### 前置条件
337
+
338
+ - 需先调用 startBluetoothDevicesDiscovery 开始搜索
339
+
340
+ ## 使用说明
341
+
342
+ - 搜索到目标设备后应尽快停止搜索以降低功耗
343
+
344
+ ## 调用方式
345
+
346
+ ### 异步 API
347
+
348
+ ```typescript
349
+ stopBluetoothDevicesDiscovery(params?: object): Promise<object>
350
+ ```
351
+
352
+ ## 入参
353
+
354
+ 无。
355
+
356
+ ## 调用示例
357
+
358
+ ```typescript
359
+ import { stopBluetoothDevicesDiscovery } from '@doubao-dev/framework/api';
360
+
361
+ await stopBluetoothDevicesDiscovery();
362
+ ```
363
+
364
+ ## 成功返回
365
+
366
+ 无返回字段。
367
+
368
+ ### 返回示例
369
+
370
+ ```json
371
+ {}
372
+ ```
373
+
374
+ ## 错误处理
375
+
376
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
377
+
378
+ ### 错误码
379
+
380
+ #### 通用错误码
381
+
382
+ <table>
383
+ <thead>
384
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
385
+ </thead>
386
+ <tbody>
387
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
388
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
389
+ </tbody>
390
+ </table>
391
+
392
+ <a id="getbluetoothadapterstate"></a>
393
+ ### getBluetoothAdapterState()
394
+
395
+ # getBluetoothAdapterState
396
+
397
+ 获取蓝牙适配器状态。
398
+
399
+ ## 扫码预览
400
+ ![扫码预览 getBluetoothAdapterState](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-adapter%252Findex)
401
+
402
+ ## 支持版本
403
+
404
+ 前端库版本不低于 `0.0.25`。
405
+
406
+ ## 支持平台
407
+
408
+ <table>
409
+ <thead>
410
+ <tr><th>平台</th><th>支持情况</th></tr>
411
+ </thead>
412
+ <tbody>
413
+ <tr><td>Android</td><td>支持</td></tr>
414
+ <tr><td>iOS</td><td>支持</td></tr>
415
+ <tr><td>PC</td><td>不支持</td></tr>
416
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
417
+ </tbody>
418
+ </table>
419
+
420
+ ## 支持场景
421
+
422
+ <table>
423
+ <thead>
424
+ <tr><th>场景</th><th>支持情况</th></tr>
425
+ </thead>
426
+ <tbody>
427
+ <tr><td>页面</td><td>支持</td></tr>
428
+ <tr><td>卡片</td><td>不支持</td></tr>
429
+ </tbody>
430
+ </table>
431
+
432
+ ## 接入准备
433
+
434
+ ### 权限要求
435
+
436
+ <table>
437
+ <thead>
438
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
439
+ </thead>
440
+ <tbody>
441
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
442
+ </tbody>
443
+ </table>
444
+
445
+ ### 授权行为
446
+
447
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
448
+
449
+ ### 前置条件
450
+
451
+ - 需先调用 openBluetoothAdapter 打开蓝牙适配器
452
+
453
+ ## 使用说明
454
+
455
+ - 通过 available 判断蓝牙是否可用,discovering 判断是否正在搜索
456
+
457
+ ## 调用方式
458
+
459
+ ### 异步 API
460
+
461
+ ```typescript
462
+ getBluetoothAdapterState(params?: object): Promise<GetBluetoothAdapterStateResult>
463
+ ```
464
+
465
+ ## 入参
466
+
467
+ 无。
468
+
469
+ ## 调用示例
470
+
471
+ ```typescript
472
+ import { getBluetoothAdapterState } from '@doubao-dev/framework/api';
473
+
474
+ const { available, discovering } = await getBluetoothAdapterState();
475
+
476
+ console.log(available, discovering);
477
+ ```
478
+
479
+ ## 成功返回
480
+
481
+ <table>
482
+ <thead>
483
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
484
+ </thead>
485
+ <tbody>
486
+ <tr><td><code>available</code></td><td><code>boolean</code></td><td>是</td><td>蓝牙适配器是否可用。</td></tr>
487
+ <tr><td><code>discovering</code></td><td><code>boolean</code></td><td>是</td><td>是否正在搜索蓝牙设备。</td></tr>
488
+ </tbody>
489
+ </table>
490
+
491
+ ### 返回示例
492
+
493
+ ```json
494
+ {
495
+ "available": true,
496
+ "discovering": false
497
+ }
498
+ ```
499
+
500
+ ## 错误处理
501
+
502
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
503
+
504
+ ### 错误码
505
+
506
+ #### 通用错误码
507
+
508
+ <table>
509
+ <thead>
510
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
511
+ </thead>
512
+ <tbody>
513
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
514
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
515
+ </tbody>
516
+ </table>
517
+
518
+ <a id="getbluetoothdevices"></a>
519
+ ### getBluetoothDevices()
520
+
521
+ # getBluetoothDevices
522
+
523
+ 获取当前蓝牙模块发现的设备列表。
524
+
525
+ ## 扫码预览
526
+ ![扫码预览 getBluetoothDevices](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-discovery%252Findex)
527
+
528
+ ## 支持版本
529
+
530
+ 前端库版本不低于 `0.0.25`。
531
+
532
+ ## 支持平台
533
+
534
+ <table>
535
+ <thead>
536
+ <tr><th>平台</th><th>支持情况</th></tr>
537
+ </thead>
538
+ <tbody>
539
+ <tr><td>Android</td><td>支持</td></tr>
540
+ <tr><td>iOS</td><td>支持</td></tr>
541
+ <tr><td>PC</td><td>不支持</td></tr>
542
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
543
+ </tbody>
544
+ </table>
545
+
546
+ ## 支持场景
547
+
548
+ <table>
549
+ <thead>
550
+ <tr><th>场景</th><th>支持情况</th></tr>
551
+ </thead>
552
+ <tbody>
553
+ <tr><td>页面</td><td>支持</td></tr>
554
+ <tr><td>卡片</td><td>不支持</td></tr>
555
+ </tbody>
556
+ </table>
557
+
558
+ ## 接入准备
559
+
560
+ ### 权限要求
561
+
562
+ <table>
563
+ <thead>
564
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
565
+ </thead>
566
+ <tbody>
567
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
568
+ </tbody>
569
+ </table>
570
+
571
+ ### 授权行为
572
+
573
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
574
+
575
+ ### 前置条件
576
+
577
+ - 需先调用 startBluetoothDevicesDiscovery 开始搜索
578
+
579
+ ## 使用说明
580
+
581
+ 通常先调用 startBluetoothDevicesDiscovery。
582
+
583
+ - `advertisData` 与 `serviceData` 以 ArrayBuffer 返回
584
+
585
+ ## 调用方式
586
+
587
+ ### 异步 API
588
+
589
+ ```typescript
590
+ getBluetoothDevices(params: object): Promise<GetBluetoothDevicesResult>
591
+ ```
592
+
593
+ ## 入参
594
+
595
+ 无。
596
+
597
+ ## 调用示例
598
+
599
+ ```typescript
600
+ import { getBluetoothDevices } from '@doubao-dev/framework/api';
601
+
602
+ const { devices } = await getBluetoothDevices();
603
+
604
+ console.log(devices.map((device) => device.name));
605
+ ```
606
+
607
+ ## 成功返回
608
+
609
+ <table>
610
+ <thead>
611
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
612
+ </thead>
613
+ <tbody>
614
+ <tr><td><code>devices</code></td><td><code>BluetoothDevice[]</code></td><td>是</td><td>当前蓝牙模块已发现的设备列表。</td></tr>
615
+ <tr><td><code>devices[].advertisData</code></td><td><code>ArrayBuffer</code></td><td>否</td><td>广播二进制数据。</td></tr>
616
+ <tr><td><code>devices[].advertisServiceUUIDs</code></td><td><code>string[]</code></td><td>否</td><td>广播中的服务 UUID 列表。</td></tr>
617
+ <tr><td><code>devices[].connectable</code></td><td><code>boolean</code></td><td>否</td><td>是否可连接。</td></tr>
618
+ <tr><td><code>devices[].deviceId</code></td><td><code>string</code></td><td>是</td><td>设备 ID。</td></tr>
619
+ <tr><td><code>devices[].localName</code></td><td><code>string</code></td><td>否</td><td>广播中的本地名称。</td></tr>
620
+ <tr><td><code>devices[].name</code></td><td><code>string</code></td><td>是</td><td>设备名称。</td></tr>
621
+ <tr><td><code>devices[].RSSI</code></td><td><code>number</code></td><td>是</td><td>RSSI 信号强度,单位 dBm。</td></tr>
622
+ <tr><td><code>devices[].serviceData</code></td><td><code>BluetoothBinaryField</code></td><td>否</td><td>广播中的服务数据。</td></tr>
623
+ </tbody>
624
+ </table>
625
+
626
+ ### 返回示例
627
+
628
+ ```json
629
+ {
630
+ "devices": [
631
+ {
632
+ "deviceId": "device-id",
633
+ "name": "Doubao BLE",
634
+ "RSSI": -60,
635
+ "connectable": true
636
+ }
637
+ ]
638
+ }
639
+ ```
640
+
641
+ ## 错误处理
642
+
643
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
644
+
645
+ ### 错误码
646
+
647
+ #### 通用错误码
648
+
649
+ <table>
650
+ <thead>
651
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
652
+ </thead>
653
+ <tbody>
654
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
655
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
656
+ </tbody>
657
+ </table>
658
+
659
+ <a id="getconnectedbluetoothdevices"></a>
660
+ ### getConnectedBluetoothDevices()
661
+
662
+ # getConnectedBluetoothDevices
663
+
664
+ 获取已连接的蓝牙设备列表。
665
+
666
+ ## 扫码预览
667
+ ![扫码预览 getConnectedBluetoothDevices](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-discovery%252Findex)
668
+
669
+ ## 支持版本
670
+
671
+ 前端库版本不低于 `0.0.25`。
672
+
673
+ ## 支持平台
674
+
675
+ <table>
676
+ <thead>
677
+ <tr><th>平台</th><th>支持情况</th></tr>
678
+ </thead>
679
+ <tbody>
680
+ <tr><td>Android</td><td>支持</td></tr>
681
+ <tr><td>iOS</td><td>支持</td></tr>
682
+ <tr><td>PC</td><td>不支持</td></tr>
683
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
684
+ </tbody>
685
+ </table>
686
+
687
+ ## 支持场景
688
+
689
+ <table>
690
+ <thead>
691
+ <tr><th>场景</th><th>支持情况</th></tr>
692
+ </thead>
693
+ <tbody>
694
+ <tr><td>页面</td><td>支持</td></tr>
695
+ <tr><td>卡片</td><td>不支持</td></tr>
696
+ </tbody>
697
+ </table>
698
+
699
+ ## 接入准备
700
+
701
+ ### 权限要求
702
+
703
+ <table>
704
+ <thead>
705
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
706
+ </thead>
707
+ <tbody>
708
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
709
+ </tbody>
710
+ </table>
711
+
712
+ ### 授权行为
713
+
714
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
715
+
716
+ ### 前置条件
717
+
718
+ - 需先调用 openBluetoothAdapter 打开蓝牙适配器
719
+
720
+ ## 使用说明
721
+
722
+ - 需传入主服务 UUID 列表 services 才能过滤出目标设备
723
+
724
+ ## 调用方式
725
+
726
+ ### 异步 API
727
+
728
+ ```typescript
729
+ getConnectedBluetoothDevices(params: GetConnectedBluetoothDevicesParams): Promise<GetConnectedBluetoothDevicesResult>
730
+ ```
731
+
732
+ ## 入参
733
+
734
+ <table>
735
+ <thead>
736
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
737
+ </thead>
738
+ <tbody>
739
+ <tr><td><code>services</code></td><td><code>string[]</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙主服务 UUID 列表。</td></tr>
740
+ </tbody>
741
+ </table>
742
+
743
+ ## 调用示例
744
+
745
+ ```typescript
746
+ import { getConnectedBluetoothDevices } from '@doubao-dev/framework/api';
747
+
748
+ const { devices } = await getConnectedBluetoothDevices({
749
+ services: ['0000180D-0000-1000-8000-00805F9B34FB']
750
+ });
751
+
752
+ console.log(devices);
753
+ ```
754
+
755
+ ## 成功返回
756
+
757
+ <table>
758
+ <thead>
759
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
760
+ </thead>
761
+ <tbody>
762
+ <tr><td><code>devices</code></td><td><code>ConnectedBluetoothDevice[]</code></td><td>是</td><td>已连接设备列表。</td></tr>
763
+ <tr><td><code>devices[].deviceId</code></td><td><code>string</code></td><td>是</td><td>设备 ID。</td></tr>
764
+ <tr><td><code>devices[].name</code></td><td><code>string</code></td><td>是</td><td>设备名称。</td></tr>
765
+ </tbody>
766
+ </table>
767
+
768
+ ### 返回示例
769
+
770
+ ```json
771
+ {
772
+ "devices": [
773
+ {
774
+ "deviceId": "device-id",
775
+ "name": "Doubao BLE"
776
+ }
777
+ ]
778
+ }
779
+ ```
780
+
781
+ ## 错误处理
782
+
783
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
784
+
785
+ ### 错误码
786
+
787
+ #### 通用错误码
788
+
789
+ <table>
790
+ <thead>
791
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
792
+ </thead>
793
+ <tbody>
794
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
795
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
796
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
797
+ </tbody>
798
+ </table>
799
+
800
+ <a id="makebluetoothpair"></a>
801
+ ### makeBluetoothPair()
802
+
803
+ # makeBluetoothPair
804
+
805
+ 发起蓝牙配对。
806
+
807
+ ## 扫码预览
808
+ ![扫码预览 makeBluetoothPair](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-connection%252Findex)
809
+
810
+ ## 使用限制
811
+
812
+ > [!WARNING]
813
+ > **iOS**:豆包 iOS 的 makeBluetoothPair 固定返回不支持;iOS 上调用无法发起蓝牙配对。
814
+
815
+ ## 支持版本
816
+
817
+ 前端库版本不低于 `0.0.25`。
818
+
819
+ ## 支持平台
820
+
821
+ <table>
822
+ <thead>
823
+ <tr><th>平台</th><th>支持情况</th></tr>
824
+ </thead>
825
+ <tbody>
826
+ <tr><td>Android</td><td>支持</td></tr>
827
+ <tr><td>iOS</td><td>不支持</td></tr>
828
+ <tr><td>PC</td><td>不支持</td></tr>
829
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
830
+ </tbody>
831
+ </table>
832
+
833
+ ## 支持场景
834
+
835
+ <table>
836
+ <thead>
837
+ <tr><th>场景</th><th>支持情况</th></tr>
838
+ </thead>
839
+ <tbody>
840
+ <tr><td>页面</td><td>支持</td></tr>
841
+ <tr><td>卡片</td><td>不支持</td></tr>
842
+ </tbody>
843
+ </table>
844
+
845
+ ## 接入准备
846
+
847
+ ### 权限要求
848
+
849
+ <table>
850
+ <thead>
851
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
852
+ </thead>
853
+ <tbody>
854
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android</td><td>发起配对需要系统蓝牙权限</td></tr>
855
+ </tbody>
856
+ </table>
857
+
858
+ ### 授权行为
859
+
860
+ - **Android**:依赖已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
861
+
862
+ ### 前置条件
863
+
864
+ - **Android**:需先调用 openBluetoothAdapter 打开蓝牙适配器
865
+
866
+ ## 使用说明
867
+
868
+ - 该能力仅在 Android 生效,iOS 调用会返回不支持
869
+
870
+ ## 调用方式
871
+
872
+ ### 异步 API
873
+
874
+ ```typescript
875
+ makeBluetoothPair(params: MakeBluetoothPairParams): Promise<object>
876
+ ```
877
+
878
+ ## 入参
879
+
880
+ <table>
881
+ <thead>
882
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
883
+ </thead>
884
+ <tbody>
885
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
886
+ <tr><td><code>pin</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>配对 PIN 码。</td></tr>
887
+ <tr><td><code>timeout</code></td><td><code>number</code></td><td>否</td><td><code>20000</code></td><td>-</td><td>超时时间,单位毫秒。</td></tr>
888
+ </tbody>
889
+ </table>
890
+
891
+ ## 调用示例
892
+
893
+ ```typescript
894
+ import { makeBluetoothPair } from '@doubao-dev/framework/api';
895
+
896
+ await makeBluetoothPair({
897
+ deviceId: 'device-id',
898
+ pin: '000000',
899
+ timeout: 10000
900
+ });
901
+ ```
902
+
903
+ ## 成功返回
904
+
905
+ 无返回字段。
906
+
907
+ ### 返回示例
908
+
909
+ ```json
910
+ {}
911
+ ```
912
+
913
+ ## 错误处理
914
+
915
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
916
+
917
+ ### 错误码
918
+
919
+ #### 通用错误码
920
+
921
+ <table>
922
+ <thead>
923
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
924
+ </thead>
925
+ <tbody>
926
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
927
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>iOS</td></tr>
928
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android</td></tr>
929
+ <tr><td><code>106</code></td><td><code>system permission denied</code></td><td>系统权限未授予</td><td>Android</td></tr>
930
+ <tr><td><code>114</code></td><td><code>operation cancelled</code></td><td>操作已取消</td><td>Android</td></tr>
931
+ <tr><td><code>115</code></td><td><code>operation timeout</code></td><td>操作超时</td><td>Android</td></tr>
932
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android</td></tr>
933
+ <tr><td><code>118</code></td><td><code>already exists</code></td><td>资源已存在</td><td>Android</td></tr>
934
+ </tbody>
935
+ </table>
936
+
937
+ <a id="isbluetoothdevicepaired"></a>
938
+ ### isBluetoothDevicePaired()
939
+
940
+ # isBluetoothDevicePaired
941
+
942
+ 查询蓝牙设备是否已经配对。
943
+
944
+ ## 扫码预览
945
+ ![扫码预览 isBluetoothDevicePaired](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-connection%252Findex)
946
+
947
+ ## 使用限制
948
+
949
+ > [!WARNING]
950
+ > **iOS**:豆包 iOS 的 isBluetoothDevicePaired 固定返回不支持;iOS 上调用无法查询设备是否已配对。
951
+
952
+ ## 支持版本
953
+
954
+ 前端库版本不低于 `0.0.25`。
955
+
956
+ ## 支持平台
957
+
958
+ <table>
959
+ <thead>
960
+ <tr><th>平台</th><th>支持情况</th></tr>
961
+ </thead>
962
+ <tbody>
963
+ <tr><td>Android</td><td>支持</td></tr>
964
+ <tr><td>iOS</td><td>不支持</td></tr>
965
+ <tr><td>PC</td><td>不支持</td></tr>
966
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
967
+ </tbody>
968
+ </table>
969
+
970
+ ## 支持场景
971
+
972
+ <table>
973
+ <thead>
974
+ <tr><th>场景</th><th>支持情况</th></tr>
975
+ </thead>
976
+ <tbody>
977
+ <tr><td>页面</td><td>支持</td></tr>
978
+ <tr><td>卡片</td><td>不支持</td></tr>
979
+ </tbody>
980
+ </table>
981
+
982
+ ## 接入准备
983
+
984
+ ### 权限要求
985
+
986
+ <table>
987
+ <thead>
988
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
989
+ </thead>
990
+ <tbody>
991
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android</td><td>查询配对状态需要系统蓝牙权限</td></tr>
992
+ </tbody>
993
+ </table>
994
+
995
+ ### 授权行为
996
+
997
+ - **Android**:依赖已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
998
+
999
+ ### 前置条件
1000
+
1001
+ - **Android**:需先调用 openBluetoothAdapter 打开蓝牙适配器
1002
+
1003
+ ## 使用说明
1004
+
1005
+ - 该能力仅在 Android 生效,iOS 调用会返回不支持
1006
+
1007
+ ## 调用方式
1008
+
1009
+ ### 异步 API
1010
+
1011
+ ```typescript
1012
+ isBluetoothDevicePaired(params: IsBluetoothDevicePairedParams): Promise<object>
1013
+ ```
1014
+
1015
+ ## 入参
1016
+
1017
+ <table>
1018
+ <thead>
1019
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1020
+ </thead>
1021
+ <tbody>
1022
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1023
+ </tbody>
1024
+ </table>
1025
+
1026
+ ## 调用示例
1027
+
1028
+ ```typescript
1029
+ import { isBluetoothDevicePaired } from '@doubao-dev/framework/api';
1030
+
1031
+ await isBluetoothDevicePaired({ deviceId: 'device-id' });
1032
+ ```
1033
+
1034
+ ## 成功返回
1035
+
1036
+ 无返回字段。
1037
+
1038
+ ### 返回示例
1039
+
1040
+ ```json
1041
+ {}
1042
+ ```
1043
+
1044
+ ## 错误处理
1045
+
1046
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1047
+
1048
+ ### 错误码
1049
+
1050
+ #### 通用错误码
1051
+
1052
+ <table>
1053
+ <thead>
1054
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1055
+ </thead>
1056
+ <tbody>
1057
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
1058
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>iOS</td></tr>
1059
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android</td></tr>
1060
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android</td></tr>
1061
+ </tbody>
1062
+ </table>
1063
+
1064
+ <a id="closebluetoothadapter"></a>
1065
+ ### closeBluetoothAdapter()
1066
+
1067
+ # closeBluetoothAdapter
1068
+
1069
+ 关闭蓝牙适配器。
1070
+
1071
+ ## 扫码预览
1072
+ ![扫码预览 closeBluetoothAdapter](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-adapter%252Findex)
1073
+
1074
+ ## 支持版本
1075
+
1076
+ 前端库版本不低于 `0.0.25`。
1077
+
1078
+ ## 支持平台
1079
+
1080
+ <table>
1081
+ <thead>
1082
+ <tr><th>平台</th><th>支持情况</th></tr>
1083
+ </thead>
1084
+ <tbody>
1085
+ <tr><td>Android</td><td>支持</td></tr>
1086
+ <tr><td>iOS</td><td>支持</td></tr>
1087
+ <tr><td>PC</td><td>不支持</td></tr>
1088
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1089
+ </tbody>
1090
+ </table>
1091
+
1092
+ ## 支持场景
1093
+
1094
+ <table>
1095
+ <thead>
1096
+ <tr><th>场景</th><th>支持情况</th></tr>
1097
+ </thead>
1098
+ <tbody>
1099
+ <tr><td>页面</td><td>支持</td></tr>
1100
+ <tr><td>卡片</td><td>不支持</td></tr>
1101
+ </tbody>
1102
+ </table>
1103
+
1104
+ ## 接入准备
1105
+
1106
+ ### 权限要求
1107
+
1108
+ <table>
1109
+ <thead>
1110
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1111
+ </thead>
1112
+ <tbody>
1113
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1114
+ </tbody>
1115
+ </table>
1116
+
1117
+ ### 授权行为
1118
+
1119
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1120
+
1121
+ ## 使用说明
1122
+
1123
+ 会关闭蓝牙模块。
1124
+
1125
+ - 会释放蓝牙模块资源并断开相关连接,蓝牙流程结束时调用
1126
+
1127
+ ## 调用方式
1128
+
1129
+ ### 异步 API
1130
+
1131
+ ```typescript
1132
+ closeBluetoothAdapter(params?: object): Promise<object>
1133
+ ```
1134
+
1135
+ ## 入参
1136
+
1137
+ 无。
1138
+
1139
+ ## 调用示例
1140
+
1141
+ ```typescript
1142
+ import { closeBluetoothAdapter } from '@doubao-dev/framework/api';
1143
+
1144
+ await closeBluetoothAdapter();
1145
+ ```
1146
+
1147
+ ## 成功返回
1148
+
1149
+ 无返回字段。
1150
+
1151
+ ### 返回示例
1152
+
1153
+ ```json
1154
+ {}
1155
+ ```
1156
+
1157
+ ## 错误处理
1158
+
1159
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1160
+
1161
+ ### 错误码
1162
+
1163
+ #### 通用错误码
1164
+
1165
+ <table>
1166
+ <thead>
1167
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1168
+ </thead>
1169
+ <tbody>
1170
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1171
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1172
+ </tbody>
1173
+ </table>
1174
+
1175
+ <a id="createbleconnection"></a>
1176
+ ### createBLEConnection()
1177
+
1178
+ # createBLEConnection
1179
+
1180
+ 创建 BLE 连接。
1181
+
1182
+ ## 扫码预览
1183
+ ![扫码预览 createBLEConnection](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-connection%252Findex)
1184
+
1185
+ ## 支持版本
1186
+
1187
+ 前端库版本不低于 `0.0.25`。
1188
+
1189
+ ## 支持平台
1190
+
1191
+ <table>
1192
+ <thead>
1193
+ <tr><th>平台</th><th>支持情况</th></tr>
1194
+ </thead>
1195
+ <tbody>
1196
+ <tr><td>Android</td><td>支持</td></tr>
1197
+ <tr><td>iOS</td><td>支持</td></tr>
1198
+ <tr><td>PC</td><td>不支持</td></tr>
1199
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1200
+ </tbody>
1201
+ </table>
1202
+
1203
+ ## 支持场景
1204
+
1205
+ <table>
1206
+ <thead>
1207
+ <tr><th>场景</th><th>支持情况</th></tr>
1208
+ </thead>
1209
+ <tbody>
1210
+ <tr><td>页面</td><td>支持</td></tr>
1211
+ <tr><td>卡片</td><td>不支持</td></tr>
1212
+ </tbody>
1213
+ </table>
1214
+
1215
+ ## 接入准备
1216
+
1217
+ ### 权限要求
1218
+
1219
+ <table>
1220
+ <thead>
1221
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1222
+ </thead>
1223
+ <tbody>
1224
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1225
+ </tbody>
1226
+ </table>
1227
+
1228
+ ### 授权行为
1229
+
1230
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1231
+
1232
+ ### 前置条件
1233
+
1234
+ - 需先通过搜索或已连接列表获得目标 deviceId
1235
+
1236
+ ## 使用说明
1237
+
1238
+ 需要传入 deviceId。
1239
+
1240
+ - 连接成功后可通过 onBLEConnectionStateChange 监听连接状态变化
1241
+
1242
+ ## 调用方式
1243
+
1244
+ ### 异步 API
1245
+
1246
+ ```typescript
1247
+ createBLEConnection(params: CreateBLEConnectionParams): Promise<object>
1248
+ ```
1249
+
1250
+ ## 入参
1251
+
1252
+ <table>
1253
+ <thead>
1254
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1255
+ </thead>
1256
+ <tbody>
1257
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1258
+ <tr><td><code>timeout</code></td><td><code>number</code></td><td>否</td><td><code>20000</code></td><td>-</td><td>超时时间,单位毫秒。</td></tr>
1259
+ </tbody>
1260
+ </table>
1261
+
1262
+ ## 调用示例
1263
+
1264
+ ```typescript
1265
+ import { createBLEConnection } from '@doubao-dev/framework/api';
1266
+
1267
+ await createBLEConnection({
1268
+ deviceId: 'device-id',
1269
+ timeout: 10000
1270
+ });
1271
+ ```
1272
+
1273
+ ## 成功返回
1274
+
1275
+ 无返回字段。
1276
+
1277
+ ### 返回示例
1278
+
1279
+ ```json
1280
+ {}
1281
+ ```
1282
+
1283
+ ## 错误处理
1284
+
1285
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1286
+
1287
+ ### 错误码
1288
+
1289
+ #### 通用错误码
1290
+
1291
+ <table>
1292
+ <thead>
1293
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1294
+ </thead>
1295
+ <tbody>
1296
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1297
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1298
+ <tr><td><code>115</code></td><td><code>operation timeout</code></td><td>操作超时</td><td>Android、iOS</td></tr>
1299
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1300
+ <tr><td><code>118</code></td><td><code>already exists</code></td><td>资源已存在</td><td>Android、iOS</td></tr>
1301
+ </tbody>
1302
+ </table>
1303
+
1304
+ <a id="closebleconnection"></a>
1305
+ ### closeBLEConnection()
1306
+
1307
+ # closeBLEConnection
1308
+
1309
+ 关闭 BLE 连接。
1310
+
1311
+ ## 扫码预览
1312
+ ![扫码预览 closeBLEConnection](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-connection%252Findex)
1313
+
1314
+ ## 支持版本
1315
+
1316
+ 前端库版本不低于 `0.0.25`。
1317
+
1318
+ ## 支持平台
1319
+
1320
+ <table>
1321
+ <thead>
1322
+ <tr><th>平台</th><th>支持情况</th></tr>
1323
+ </thead>
1324
+ <tbody>
1325
+ <tr><td>Android</td><td>支持</td></tr>
1326
+ <tr><td>iOS</td><td>支持</td></tr>
1327
+ <tr><td>PC</td><td>不支持</td></tr>
1328
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1329
+ </tbody>
1330
+ </table>
1331
+
1332
+ ## 支持场景
1333
+
1334
+ <table>
1335
+ <thead>
1336
+ <tr><th>场景</th><th>支持情况</th></tr>
1337
+ </thead>
1338
+ <tbody>
1339
+ <tr><td>页面</td><td>支持</td></tr>
1340
+ <tr><td>卡片</td><td>不支持</td></tr>
1341
+ </tbody>
1342
+ </table>
1343
+
1344
+ ## 接入准备
1345
+
1346
+ ### 权限要求
1347
+
1348
+ <table>
1349
+ <thead>
1350
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1351
+ </thead>
1352
+ <tbody>
1353
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1354
+ </tbody>
1355
+ </table>
1356
+
1357
+ ### 授权行为
1358
+
1359
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1360
+
1361
+ ### 前置条件
1362
+
1363
+ - 需先调用 createBLEConnection 建立连接
1364
+
1365
+ ## 使用说明
1366
+
1367
+ - 不再使用设备时应主动断开连接以释放资源
1368
+
1369
+ ## 调用方式
1370
+
1371
+ ### 异步 API
1372
+
1373
+ ```typescript
1374
+ closeBLEConnection(params: CloseBLEConnectionParams): Promise<object>
1375
+ ```
1376
+
1377
+ ## 入参
1378
+
1379
+ <table>
1380
+ <thead>
1381
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1382
+ </thead>
1383
+ <tbody>
1384
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1385
+ </tbody>
1386
+ </table>
1387
+
1388
+ ## 调用示例
1389
+
1390
+ ```typescript
1391
+ import { closeBLEConnection } from '@doubao-dev/framework/api';
1392
+
1393
+ await closeBLEConnection({ deviceId: 'device-id' });
1394
+ ```
1395
+
1396
+ ## 成功返回
1397
+
1398
+ 无返回字段。
1399
+
1400
+ ### 返回示例
1401
+
1402
+ ```json
1403
+ {}
1404
+ ```
1405
+
1406
+ ## 错误处理
1407
+
1408
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1409
+
1410
+ ### 错误码
1411
+
1412
+ #### 通用错误码
1413
+
1414
+ <table>
1415
+ <thead>
1416
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1417
+ </thead>
1418
+ <tbody>
1419
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1420
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1421
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1422
+ </tbody>
1423
+ </table>
1424
+
1425
+ <a id="getbledeviceservices"></a>
1426
+ ### getBLEDeviceServices()
1427
+
1428
+ # getBLEDeviceServices
1429
+
1430
+ 获取 BLE 服务列表。
1431
+
1432
+ ## 扫码预览
1433
+ ![扫码预览 getBLEDeviceServices](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-services%252Findex)
1434
+
1435
+ ## 支持版本
1436
+
1437
+ 前端库版本不低于 `0.0.25`。
1438
+
1439
+ ## 支持平台
1440
+
1441
+ <table>
1442
+ <thead>
1443
+ <tr><th>平台</th><th>支持情况</th></tr>
1444
+ </thead>
1445
+ <tbody>
1446
+ <tr><td>Android</td><td>支持</td></tr>
1447
+ <tr><td>iOS</td><td>支持</td></tr>
1448
+ <tr><td>PC</td><td>不支持</td></tr>
1449
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1450
+ </tbody>
1451
+ </table>
1452
+
1453
+ ## 支持场景
1454
+
1455
+ <table>
1456
+ <thead>
1457
+ <tr><th>场景</th><th>支持情况</th></tr>
1458
+ </thead>
1459
+ <tbody>
1460
+ <tr><td>页面</td><td>支持</td></tr>
1461
+ <tr><td>卡片</td><td>不支持</td></tr>
1462
+ </tbody>
1463
+ </table>
1464
+
1465
+ ## 接入准备
1466
+
1467
+ ### 权限要求
1468
+
1469
+ <table>
1470
+ <thead>
1471
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1472
+ </thead>
1473
+ <tbody>
1474
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1475
+ </tbody>
1476
+ </table>
1477
+
1478
+ ### 授权行为
1479
+
1480
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1481
+
1482
+ ### 前置条件
1483
+
1484
+ - 需先调用 createBLEConnection 建立连接
1485
+
1486
+ ## 使用说明
1487
+
1488
+ 通常先调用 createBLEConnection。
1489
+
1490
+ - 通过返回的 uuid 进一步获取特征值列表
1491
+
1492
+ ## 调用方式
1493
+
1494
+ ### 异步 API
1495
+
1496
+ ```typescript
1497
+ getBLEDeviceServices(params: GetBLEDeviceServicesParams): Promise<GetBLEDeviceServicesResult>
1498
+ ```
1499
+
1500
+ ## 入参
1501
+
1502
+ <table>
1503
+ <thead>
1504
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1505
+ </thead>
1506
+ <tbody>
1507
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1508
+ </tbody>
1509
+ </table>
1510
+
1511
+ ## 调用示例
1512
+
1513
+ ```typescript
1514
+ import { getBLEDeviceServices } from '@doubao-dev/framework/api';
1515
+
1516
+ const { services } = await getBLEDeviceServices({ deviceId: 'device-id' });
1517
+
1518
+ console.log(services);
1519
+ ```
1520
+
1521
+ ## 成功返回
1522
+
1523
+ <table>
1524
+ <thead>
1525
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
1526
+ </thead>
1527
+ <tbody>
1528
+ <tr><td><code>services</code></td><td><code>BluetoothService[]</code></td><td>是</td><td>设备服务列表。</td></tr>
1529
+ <tr><td><code>services[].isPrimary</code></td><td><code>boolean</code></td><td>是</td><td>是否为主服务。</td></tr>
1530
+ <tr><td><code>services[].uuid</code></td><td><code>string</code></td><td>是</td><td>服务 UUID。</td></tr>
1531
+ </tbody>
1532
+ </table>
1533
+
1534
+ ### 返回示例
1535
+
1536
+ ```json
1537
+ {
1538
+ "services": [
1539
+ {
1540
+ "uuid": "0000180D-0000-1000-8000-00805F9B34FB",
1541
+ "isPrimary": true
1542
+ }
1543
+ ]
1544
+ }
1545
+ ```
1546
+
1547
+ ## 错误处理
1548
+
1549
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1550
+
1551
+ ### 错误码
1552
+
1553
+ #### 通用错误码
1554
+
1555
+ <table>
1556
+ <thead>
1557
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1558
+ </thead>
1559
+ <tbody>
1560
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1561
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1562
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1563
+ </tbody>
1564
+ </table>
1565
+
1566
+ <a id="getbledevicecharacteristics"></a>
1567
+ ### getBLEDeviceCharacteristics()
1568
+
1569
+ # getBLEDeviceCharacteristics
1570
+
1571
+ 获取 BLE 特征值列表。
1572
+
1573
+ ## 扫码预览
1574
+ ![扫码预览 getBLEDeviceCharacteristics](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-services%252Findex)
1575
+
1576
+ ## 支持版本
1577
+
1578
+ 前端库版本不低于 `0.0.25`。
1579
+
1580
+ ## 支持平台
1581
+
1582
+ <table>
1583
+ <thead>
1584
+ <tr><th>平台</th><th>支持情况</th></tr>
1585
+ </thead>
1586
+ <tbody>
1587
+ <tr><td>Android</td><td>支持</td></tr>
1588
+ <tr><td>iOS</td><td>支持</td></tr>
1589
+ <tr><td>PC</td><td>不支持</td></tr>
1590
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1591
+ </tbody>
1592
+ </table>
1593
+
1594
+ ## 支持场景
1595
+
1596
+ <table>
1597
+ <thead>
1598
+ <tr><th>场景</th><th>支持情况</th></tr>
1599
+ </thead>
1600
+ <tbody>
1601
+ <tr><td>页面</td><td>支持</td></tr>
1602
+ <tr><td>卡片</td><td>不支持</td></tr>
1603
+ </tbody>
1604
+ </table>
1605
+
1606
+ ## 接入准备
1607
+
1608
+ ### 权限要求
1609
+
1610
+ <table>
1611
+ <thead>
1612
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1613
+ </thead>
1614
+ <tbody>
1615
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1616
+ </tbody>
1617
+ </table>
1618
+
1619
+ ### 授权行为
1620
+
1621
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1622
+
1623
+ ### 前置条件
1624
+
1625
+ - 需先调用 getBLEDeviceServices 获取服务列表
1626
+
1627
+ ## 使用说明
1628
+
1629
+ 通常先获取 BLE 服务列表。
1630
+
1631
+ - 通过 properties 判断特征值支持的读写与订阅能力
1632
+
1633
+ ## 调用方式
1634
+
1635
+ ### 异步 API
1636
+
1637
+ ```typescript
1638
+ getBLEDeviceCharacteristics(params: GetBLEDeviceCharacteristicsParams): Promise<GetBLEDeviceCharacteristicsResult>
1639
+ ```
1640
+
1641
+ ## 入参
1642
+
1643
+ <table>
1644
+ <thead>
1645
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1646
+ </thead>
1647
+ <tbody>
1648
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1649
+ <tr><td><code>serviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>服务 ID。</td></tr>
1650
+ </tbody>
1651
+ </table>
1652
+
1653
+ ## 调用示例
1654
+
1655
+ ```typescript
1656
+ import { getBLEDeviceCharacteristics } from '@doubao-dev/framework/api';
1657
+
1658
+ const { characteristics } = await getBLEDeviceCharacteristics({
1659
+ deviceId: 'device-id',
1660
+ serviceId: 'service-id'
1661
+ });
1662
+
1663
+ console.log(characteristics);
1664
+ ```
1665
+
1666
+ ## 成功返回
1667
+
1668
+ <table>
1669
+ <thead>
1670
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
1671
+ </thead>
1672
+ <tbody>
1673
+ <tr><td><code>characteristics</code></td><td><code>BluetoothCharacteristic[]</code></td><td>是</td><td>特征值列表。</td></tr>
1674
+ <tr><td><code>characteristics[].properties</code></td><td><code>BluetoothCharacteristicProperties</code></td><td>是</td><td>特征值能力。</td></tr>
1675
+ <tr><td><code>characteristics[].properties.indicate</code></td><td><code>boolean</code></td><td>是</td><td>是否支持 indicate。</td></tr>
1676
+ <tr><td><code>characteristics[].properties.notify</code></td><td><code>boolean</code></td><td>是</td><td>是否支持 notify。</td></tr>
1677
+ <tr><td><code>characteristics[].properties.read</code></td><td><code>boolean</code></td><td>是</td><td>是否支持 read。</td></tr>
1678
+ <tr><td><code>characteristics[].properties.write</code></td><td><code>boolean</code></td><td>是</td><td>是否支持 write。</td></tr>
1679
+ <tr><td><code>characteristics[].properties.writeDefault</code></td><td><code>boolean</code></td><td>是</td><td>是否支持带响应写入。</td></tr>
1680
+ <tr><td><code>characteristics[].properties.writeNoResponse</code></td><td><code>boolean</code></td><td>是</td><td>是否支持无响应写入。</td></tr>
1681
+ <tr><td><code>characteristics[].uuid</code></td><td><code>string</code></td><td>是</td><td>特征值 UUID。</td></tr>
1682
+ </tbody>
1683
+ </table>
1684
+
1685
+ ### 返回示例
1686
+
1687
+ ```json
1688
+ {
1689
+ "characteristics": [
1690
+ {
1691
+ "uuid": "00002A37-0000-1000-8000-00805F9B34FB",
1692
+ "properties": {
1693
+ "indicate": false,
1694
+ "notify": true,
1695
+ "read": true,
1696
+ "write": false,
1697
+ "writeNoResponse": false,
1698
+ "writeDefault": false
1699
+ }
1700
+ }
1701
+ ]
1702
+ }
1703
+ ```
1704
+
1705
+ ## 错误处理
1706
+
1707
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1708
+
1709
+ ### 错误码
1710
+
1711
+ #### 通用错误码
1712
+
1713
+ <table>
1714
+ <thead>
1715
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1716
+ </thead>
1717
+ <tbody>
1718
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1719
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1720
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1721
+ </tbody>
1722
+ </table>
1723
+
1724
+ <a id="getbledevicerssi"></a>
1725
+ ### getBLEDeviceRSSI()
1726
+
1727
+ # getBLEDeviceRSSI
1728
+
1729
+ 获取 BLE 设备 RSSI。
1730
+
1731
+ ## 扫码预览
1732
+ ![扫码预览 getBLEDeviceRSSI](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-services%252Findex)
1733
+
1734
+ ## 支持版本
1735
+
1736
+ 前端库版本不低于 `0.0.25`。
1737
+
1738
+ ## 支持平台
1739
+
1740
+ <table>
1741
+ <thead>
1742
+ <tr><th>平台</th><th>支持情况</th></tr>
1743
+ </thead>
1744
+ <tbody>
1745
+ <tr><td>Android</td><td>支持</td></tr>
1746
+ <tr><td>iOS</td><td>支持</td></tr>
1747
+ <tr><td>PC</td><td>不支持</td></tr>
1748
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1749
+ </tbody>
1750
+ </table>
1751
+
1752
+ ## 支持场景
1753
+
1754
+ <table>
1755
+ <thead>
1756
+ <tr><th>场景</th><th>支持情况</th></tr>
1757
+ </thead>
1758
+ <tbody>
1759
+ <tr><td>页面</td><td>支持</td></tr>
1760
+ <tr><td>卡片</td><td>不支持</td></tr>
1761
+ </tbody>
1762
+ </table>
1763
+
1764
+ ## 接入准备
1765
+
1766
+ ### 权限要求
1767
+
1768
+ <table>
1769
+ <thead>
1770
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1771
+ </thead>
1772
+ <tbody>
1773
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1774
+ </tbody>
1775
+ </table>
1776
+
1777
+ ### 授权行为
1778
+
1779
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1780
+
1781
+ ### 前置条件
1782
+
1783
+ - 需先调用 createBLEConnection 建立连接
1784
+
1785
+ ## 使用说明
1786
+
1787
+ - RSSI 单位为 dBm,值越接近 0 信号越强
1788
+
1789
+ ## 调用方式
1790
+
1791
+ ### 异步 API
1792
+
1793
+ ```typescript
1794
+ getBLEDeviceRSSI(params: GetBLEDeviceRSSIParams): Promise<GetBLEDeviceRSSIResult>
1795
+ ```
1796
+
1797
+ ## 入参
1798
+
1799
+ <table>
1800
+ <thead>
1801
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1802
+ </thead>
1803
+ <tbody>
1804
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1805
+ </tbody>
1806
+ </table>
1807
+
1808
+ ## 调用示例
1809
+
1810
+ ```typescript
1811
+ import { getBLEDeviceRSSI } from '@doubao-dev/framework/api';
1812
+
1813
+ const { RSSI } = await getBLEDeviceRSSI({ deviceId: 'device-id' });
1814
+
1815
+ console.log(RSSI);
1816
+ ```
1817
+
1818
+ ## 成功返回
1819
+
1820
+ <table>
1821
+ <thead>
1822
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
1823
+ </thead>
1824
+ <tbody>
1825
+ <tr><td><code>RSSI</code></td><td><code>number</code></td><td>是</td><td>RSSI 信号强度,单位 dBm。</td></tr>
1826
+ </tbody>
1827
+ </table>
1828
+
1829
+ ### 返回示例
1830
+
1831
+ ```json
1832
+ {
1833
+ "RSSI": -55
1834
+ }
1835
+ ```
1836
+
1837
+ ## 错误处理
1838
+
1839
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1840
+
1841
+ ### 错误码
1842
+
1843
+ #### 通用错误码
1844
+
1845
+ <table>
1846
+ <thead>
1847
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1848
+ </thead>
1849
+ <tbody>
1850
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1851
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1852
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1853
+ </tbody>
1854
+ </table>
1855
+
1856
+ <a id="getblemtu"></a>
1857
+ ### getBLEMTU()
1858
+
1859
+ # getBLEMTU
1860
+
1861
+ 获取 BLE MTU。
1862
+
1863
+ ## 扫码预览
1864
+ ![扫码预览 getBLEMTU](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-mtu%252Findex)
1865
+
1866
+ ## 支持版本
1867
+
1868
+ 前端库版本不低于 `0.0.25`。
1869
+
1870
+ ## 支持平台
1871
+
1872
+ <table>
1873
+ <thead>
1874
+ <tr><th>平台</th><th>支持情况</th></tr>
1875
+ </thead>
1876
+ <tbody>
1877
+ <tr><td>Android</td><td>支持</td></tr>
1878
+ <tr><td>iOS</td><td>支持</td></tr>
1879
+ <tr><td>PC</td><td>不支持</td></tr>
1880
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
1881
+ </tbody>
1882
+ </table>
1883
+
1884
+ ## 支持场景
1885
+
1886
+ <table>
1887
+ <thead>
1888
+ <tr><th>场景</th><th>支持情况</th></tr>
1889
+ </thead>
1890
+ <tbody>
1891
+ <tr><td>页面</td><td>支持</td></tr>
1892
+ <tr><td>卡片</td><td>不支持</td></tr>
1893
+ </tbody>
1894
+ </table>
1895
+
1896
+ ## 接入准备
1897
+
1898
+ ### 权限要求
1899
+
1900
+ <table>
1901
+ <thead>
1902
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
1903
+ </thead>
1904
+ <tbody>
1905
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
1906
+ </tbody>
1907
+ </table>
1908
+
1909
+ ### 授权行为
1910
+
1911
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
1912
+
1913
+ ### 前置条件
1914
+
1915
+ - 需先调用 createBLEConnection 建立连接
1916
+
1917
+ ## 使用说明
1918
+
1919
+ - 通过 mtu 判断单次可传输的最大字节数
1920
+
1921
+ ## 调用方式
1922
+
1923
+ ### 异步 API
1924
+
1925
+ ```typescript
1926
+ getBLEMTU(params: GetBLEMTUParams): Promise<GetBLEMTUResult>
1927
+ ```
1928
+
1929
+ ## 入参
1930
+
1931
+ <table>
1932
+ <thead>
1933
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
1934
+ </thead>
1935
+ <tbody>
1936
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
1937
+ <tr><td><code>writeType</code></td><td><code>BluetoothWriteType</code></td><td>否</td><td><code>由平台按当前连接选择写入模式</code></td><td>-</td><td>写入模式。</td></tr>
1938
+ </tbody>
1939
+ </table>
1940
+
1941
+ ## 调用示例
1942
+
1943
+ ```typescript
1944
+ import { getBLEMTU } from '@doubao-dev/framework/api';
1945
+
1946
+ const { mtu } = await getBLEMTU({ deviceId: 'device-id' });
1947
+
1948
+ console.log(mtu);
1949
+ ```
1950
+
1951
+ ## 成功返回
1952
+
1953
+ <table>
1954
+ <thead>
1955
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
1956
+ </thead>
1957
+ <tbody>
1958
+ <tr><td><code>mtu</code></td><td><code>number</code></td><td>是</td><td>当前 MTU。</td></tr>
1959
+ </tbody>
1960
+ </table>
1961
+
1962
+ ### 返回示例
1963
+
1964
+ ```json
1965
+ {
1966
+ "mtu": 23
1967
+ }
1968
+ ```
1969
+
1970
+ ## 错误处理
1971
+
1972
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
1973
+
1974
+ ### 错误码
1975
+
1976
+ #### 通用错误码
1977
+
1978
+ <table>
1979
+ <thead>
1980
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
1981
+ </thead>
1982
+ <tbody>
1983
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
1984
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
1985
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
1986
+ </tbody>
1987
+ </table>
1988
+
1989
+ <a id="notifyblecharacteristicvaluechange"></a>
1990
+ ### notifyBLECharacteristicValueChange()
1991
+
1992
+ # notifyBLECharacteristicValueChange
1993
+
1994
+ 订阅 BLE 特征值变化。
1995
+
1996
+ ## 扫码预览
1997
+ ![扫码预览 notifyBLECharacteristicValueChange](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-characteristic%252Findex)
1998
+
1999
+ ## 支持版本
2000
+
2001
+ 前端库版本不低于 `0.0.25`。
2002
+
2003
+ ## 支持平台
2004
+
2005
+ <table>
2006
+ <thead>
2007
+ <tr><th>平台</th><th>支持情况</th></tr>
2008
+ </thead>
2009
+ <tbody>
2010
+ <tr><td>Android</td><td>支持</td></tr>
2011
+ <tr><td>iOS</td><td>支持</td></tr>
2012
+ <tr><td>PC</td><td>不支持</td></tr>
2013
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2014
+ </tbody>
2015
+ </table>
2016
+
2017
+ ## 支持场景
2018
+
2019
+ <table>
2020
+ <thead>
2021
+ <tr><th>场景</th><th>支持情况</th></tr>
2022
+ </thead>
2023
+ <tbody>
2024
+ <tr><td>页面</td><td>支持</td></tr>
2025
+ <tr><td>卡片</td><td>不支持</td></tr>
2026
+ </tbody>
2027
+ </table>
2028
+
2029
+ ## 接入准备
2030
+
2031
+ ### 权限要求
2032
+
2033
+ <table>
2034
+ <thead>
2035
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2036
+ </thead>
2037
+ <tbody>
2038
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
2039
+ </tbody>
2040
+ </table>
2041
+
2042
+ ### 授权行为
2043
+
2044
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
2045
+
2046
+ ### 前置条件
2047
+
2048
+ - 需先调用 getBLEDeviceCharacteristics 确认特征值支持 notify 或 indicate
2049
+
2050
+ ## 使用说明
2051
+
2052
+ 订阅指定特征值变化。
2053
+
2054
+ - 订阅开启后特征值变化会通过 onBLECharacteristicValueChange 回传
2055
+
2056
+ ## 调用方式
2057
+
2058
+ ### 异步 API
2059
+
2060
+ ```typescript
2061
+ notifyBLECharacteristicValueChange(params: NotifyBLECharacteristicValueChangeParams): Promise<object>
2062
+ ```
2063
+
2064
+ ## 入参
2065
+
2066
+ <table>
2067
+ <thead>
2068
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
2069
+ </thead>
2070
+ <tbody>
2071
+ <tr><td><code>characteristicId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>特征值 ID。</td></tr>
2072
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
2073
+ <tr><td><code>serviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>服务 ID。</td></tr>
2074
+ <tr><td><code>state</code></td><td><code>boolean</code></td><td>是</td><td>-</td><td>-</td><td>是否启用订阅。</td></tr>
2075
+ <tr><td><code>type</code></td><td><code>BluetoothNotifyType</code></td><td>否</td><td><code>indication</code></td><td>-</td><td>订阅类型。</td></tr>
2076
+ </tbody>
2077
+ </table>
2078
+
2079
+ ## 调用示例
2080
+
2081
+ ```typescript
2082
+ import { notifyBLECharacteristicValueChange } from '@doubao-dev/framework/api';
2083
+
2084
+ await notifyBLECharacteristicValueChange({
2085
+ deviceId: 'device-id',
2086
+ serviceId: 'service-id',
2087
+ characteristicId: 'characteristic-id',
2088
+ state: true
2089
+ });
2090
+ ```
2091
+
2092
+ ## 成功返回
2093
+
2094
+ 无返回字段。
2095
+
2096
+ ### 返回示例
2097
+
2098
+ ```json
2099
+ {}
2100
+ ```
2101
+
2102
+ ## 错误处理
2103
+
2104
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
2105
+
2106
+ ### 错误码
2107
+
2108
+ #### 通用错误码
2109
+
2110
+ <table>
2111
+ <thead>
2112
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
2113
+ </thead>
2114
+ <tbody>
2115
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
2116
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>Android、iOS</td></tr>
2117
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
2118
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
2119
+ </tbody>
2120
+ </table>
2121
+
2122
+ <a id="readblecharacteristicvalue"></a>
2123
+ ### readBLECharacteristicValue()
2124
+
2125
+ # readBLECharacteristicValue
2126
+
2127
+ 读取 BLE 特征值。
2128
+
2129
+ ## 扫码预览
2130
+ ![扫码预览 readBLECharacteristicValue](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-characteristic%252Findex)
2131
+
2132
+ ## 支持版本
2133
+
2134
+ 前端库版本不低于 `0.0.25`。
2135
+
2136
+ ## 支持平台
2137
+
2138
+ <table>
2139
+ <thead>
2140
+ <tr><th>平台</th><th>支持情况</th></tr>
2141
+ </thead>
2142
+ <tbody>
2143
+ <tr><td>Android</td><td>支持</td></tr>
2144
+ <tr><td>iOS</td><td>支持</td></tr>
2145
+ <tr><td>PC</td><td>不支持</td></tr>
2146
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2147
+ </tbody>
2148
+ </table>
2149
+
2150
+ ## 支持场景
2151
+
2152
+ <table>
2153
+ <thead>
2154
+ <tr><th>场景</th><th>支持情况</th></tr>
2155
+ </thead>
2156
+ <tbody>
2157
+ <tr><td>页面</td><td>支持</td></tr>
2158
+ <tr><td>卡片</td><td>不支持</td></tr>
2159
+ </tbody>
2160
+ </table>
2161
+
2162
+ ## 接入准备
2163
+
2164
+ ### 权限要求
2165
+
2166
+ <table>
2167
+ <thead>
2168
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2169
+ </thead>
2170
+ <tbody>
2171
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
2172
+ </tbody>
2173
+ </table>
2174
+
2175
+ ### 授权行为
2176
+
2177
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
2178
+
2179
+ ### 前置条件
2180
+
2181
+ - 需先调用 getBLEDeviceCharacteristics 确认特征值支持 read
2182
+
2183
+ ## 使用说明
2184
+
2185
+ 需要传入 serviceId 和 characteristicId。
2186
+
2187
+ - 读取到的数据不在本接口返回,需通过 onBLECharacteristicValueChange 接收
2188
+
2189
+ ## 调用方式
2190
+
2191
+ ### 异步 API
2192
+
2193
+ ```typescript
2194
+ readBLECharacteristicValue(params: ReadBLECharacteristicValueParams): Promise<object>
2195
+ ```
2196
+
2197
+ ## 入参
2198
+
2199
+ <table>
2200
+ <thead>
2201
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
2202
+ </thead>
2203
+ <tbody>
2204
+ <tr><td><code>characteristicId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>特征值 ID。</td></tr>
2205
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
2206
+ <tr><td><code>serviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>服务 ID。</td></tr>
2207
+ </tbody>
2208
+ </table>
2209
+
2210
+ ## 调用示例
2211
+
2212
+ ```typescript
2213
+ import { readBLECharacteristicValue } from '@doubao-dev/framework/api';
2214
+
2215
+ await readBLECharacteristicValue({
2216
+ deviceId: 'device-id',
2217
+ serviceId: 'service-id',
2218
+ characteristicId: 'characteristic-id'
2219
+ });
2220
+ ```
2221
+
2222
+ ## 成功返回
2223
+
2224
+ 无返回字段。
2225
+
2226
+ ### 返回示例
2227
+
2228
+ ```json
2229
+ {}
2230
+ ```
2231
+
2232
+ ## 错误处理
2233
+
2234
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
2235
+
2236
+ ### 错误码
2237
+
2238
+ #### 通用错误码
2239
+
2240
+ <table>
2241
+ <thead>
2242
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
2243
+ </thead>
2244
+ <tbody>
2245
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
2246
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>Android、iOS</td></tr>
2247
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
2248
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
2249
+ </tbody>
2250
+ </table>
2251
+
2252
+ <a id="setblemtu"></a>
2253
+ ### setBLEMTU()
2254
+
2255
+ # setBLEMTU
2256
+
2257
+ 设置 BLE MTU。
2258
+
2259
+ ## 扫码预览
2260
+ ![扫码预览 setBLEMTU](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-mtu%252Findex)
2261
+
2262
+ ## 使用限制
2263
+
2264
+ > [!WARNING]
2265
+ > **iOS**:豆包 iOS 的 setBLEMTU 固定返回不支持;iOS 上调用无法设置 MTU。
2266
+
2267
+ ## 支持版本
2268
+
2269
+ 前端库版本不低于 `0.0.25`。
2270
+
2271
+ ## 支持平台
2272
+
2273
+ <table>
2274
+ <thead>
2275
+ <tr><th>平台</th><th>支持情况</th></tr>
2276
+ </thead>
2277
+ <tbody>
2278
+ <tr><td>Android</td><td>支持</td></tr>
2279
+ <tr><td>iOS</td><td>不支持</td></tr>
2280
+ <tr><td>PC</td><td>不支持</td></tr>
2281
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2282
+ </tbody>
2283
+ </table>
2284
+
2285
+ ## 支持场景
2286
+
2287
+ <table>
2288
+ <thead>
2289
+ <tr><th>场景</th><th>支持情况</th></tr>
2290
+ </thead>
2291
+ <tbody>
2292
+ <tr><td>页面</td><td>支持</td></tr>
2293
+ <tr><td>卡片</td><td>不支持</td></tr>
2294
+ </tbody>
2295
+ </table>
2296
+
2297
+ ## 接入准备
2298
+
2299
+ ### 权限要求
2300
+
2301
+ <table>
2302
+ <thead>
2303
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2304
+ </thead>
2305
+ <tbody>
2306
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android</td><td>设置 MTU 需要系统蓝牙权限</td></tr>
2307
+ </tbody>
2308
+ </table>
2309
+
2310
+ ### 授权行为
2311
+
2312
+ - **Android**:依赖已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
2313
+
2314
+ ### 前置条件
2315
+
2316
+ - **Android**:需先调用 createBLEConnection 建立连接
2317
+
2318
+ ## 使用说明
2319
+
2320
+ - 该能力仅在 Android 生效,返回的 mtu 为最终协商结果,iOS 调用会返回不支持
2321
+
2322
+ ## 调用方式
2323
+
2324
+ ### 异步 API
2325
+
2326
+ ```typescript
2327
+ setBLEMTU(params: SetBLEMTUParams): Promise<SetBLEMTUResult>
2328
+ ```
2329
+
2330
+ ## 入参
2331
+
2332
+ <table>
2333
+ <thead>
2334
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
2335
+ </thead>
2336
+ <tbody>
2337
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
2338
+ <tr><td><code>mtu</code></td><td><code>number</code></td><td>是</td><td>-</td><td>-</td><td>目标 MTU。</td></tr>
2339
+ </tbody>
2340
+ </table>
2341
+
2342
+ ## 调用示例
2343
+
2344
+ ```typescript
2345
+ import { setBLEMTU } from '@doubao-dev/framework/api';
2346
+
2347
+ const { mtu } = await setBLEMTU({
2348
+ deviceId: 'device-id',
2349
+ mtu: 512
2350
+ });
2351
+
2352
+ console.log(mtu);
2353
+ ```
2354
+
2355
+ ## 成功返回
2356
+
2357
+ <table>
2358
+ <thead>
2359
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
2360
+ </thead>
2361
+ <tbody>
2362
+ <tr><td><code>mtu</code></td><td><code>number</code></td><td>是</td><td>最终协商得到的 MTU。</td></tr>
2363
+ </tbody>
2364
+ </table>
2365
+
2366
+ ### 返回示例
2367
+
2368
+ ```json
2369
+ {
2370
+ "mtu": 512
2371
+ }
2372
+ ```
2373
+
2374
+ ## 错误处理
2375
+
2376
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
2377
+
2378
+ ### 错误码
2379
+
2380
+ #### 通用错误码
2381
+
2382
+ <table>
2383
+ <thead>
2384
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
2385
+ </thead>
2386
+ <tbody>
2387
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android</td></tr>
2388
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>iOS</td></tr>
2389
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android</td></tr>
2390
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android</td></tr>
2391
+ </tbody>
2392
+ </table>
2393
+
2394
+ <a id="writeblecharacteristicvalue"></a>
2395
+ ### writeBLECharacteristicValue()
2396
+
2397
+ # writeBLECharacteristicValue
2398
+
2399
+ 写入 BLE 特征值。
2400
+
2401
+ ## 扫码预览
2402
+ ![扫码预览 writeBLECharacteristicValue](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fdevice%252Fbluetooth-characteristic%252Findex)
2403
+
2404
+ ## 支持版本
2405
+
2406
+ 前端库版本不低于 `0.0.25`。
2407
+
2408
+ ## 支持平台
2409
+
2410
+ <table>
2411
+ <thead>
2412
+ <tr><th>平台</th><th>支持情况</th></tr>
2413
+ </thead>
2414
+ <tbody>
2415
+ <tr><td>Android</td><td>支持</td></tr>
2416
+ <tr><td>iOS</td><td>支持</td></tr>
2417
+ <tr><td>PC</td><td>不支持</td></tr>
2418
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2419
+ </tbody>
2420
+ </table>
2421
+
2422
+ ## 支持场景
2423
+
2424
+ <table>
2425
+ <thead>
2426
+ <tr><th>场景</th><th>支持情况</th></tr>
2427
+ </thead>
2428
+ <tbody>
2429
+ <tr><td>页面</td><td>支持</td></tr>
2430
+ <tr><td>卡片</td><td>不支持</td></tr>
2431
+ </tbody>
2432
+ </table>
2433
+
2434
+ ## 接入准备
2435
+
2436
+ ### 权限要求
2437
+
2438
+ <table>
2439
+ <thead>
2440
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2441
+ </thead>
2442
+ <tbody>
2443
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
2444
+ </tbody>
2445
+ </table>
2446
+
2447
+ ### 授权行为
2448
+
2449
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后调用失败,需引导用户在系统设置中开启蓝牙权限
2450
+
2451
+ ### 前置条件
2452
+
2453
+ - 需先调用 getBLEDeviceCharacteristics 确认特征值支持写入
2454
+
2455
+ ## 使用说明
2456
+
2457
+ value 需要是 ArrayBuffer。
2458
+
2459
+ - value 需传入 ArrayBuffer,单次写入长度不应超过当前 MTU
2460
+
2461
+ ## 调用方式
2462
+
2463
+ ### 异步 API
2464
+
2465
+ ```typescript
2466
+ writeBLECharacteristicValue(params: WriteBLECharacteristicValueParams): Promise<object>
2467
+ ```
2468
+
2469
+ ## 入参
2470
+
2471
+ <table>
2472
+ <thead>
2473
+ <tr><th>名称</th><th>类型</th><th>必填</th><th>默认值</th><th>约束</th><th>说明</th></tr>
2474
+ </thead>
2475
+ <tbody>
2476
+ <tr><td><code>characteristicId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>特征值 ID。</td></tr>
2477
+ <tr><td><code>deviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>蓝牙设备 ID。</td></tr>
2478
+ <tr><td><code>serviceId</code></td><td><code>string</code></td><td>是</td><td>-</td><td>-</td><td>服务 ID。</td></tr>
2479
+ <tr><td><code>value</code></td><td><code>ArrayBuffer</code></td><td>是</td><td>-</td><td>-</td><td>要写入的二进制数据。</td></tr>
2480
+ <tr><td><code>writeType</code></td><td><code>BluetoothWriteType</code></td><td>否</td><td><code>由平台按特征值能力选择写入模式</code></td><td>-</td><td>写入模式。</td></tr>
2481
+ </tbody>
2482
+ </table>
2483
+
2484
+ ## 调用示例
2485
+
2486
+ ```typescript
2487
+ import { writeBLECharacteristicValue } from '@doubao-dev/framework/api';
2488
+
2489
+ await writeBLECharacteristicValue({
2490
+ deviceId: 'device-id',
2491
+ serviceId: 'service-id',
2492
+ characteristicId: 'characteristic-id',
2493
+ value: new Uint8Array([1, 2, 3]).buffer
2494
+ });
2495
+ ```
2496
+
2497
+ ## 成功返回
2498
+
2499
+ 无返回字段。
2500
+
2501
+ ### 返回示例
2502
+
2503
+ ```json
2504
+ {}
2505
+ ```
2506
+
2507
+ ## 错误处理
2508
+
2509
+ 错误对象和通用错误码见 [通用错误处理](./common-errors.md#错误返回)。
2510
+
2511
+ ### 错误码
2512
+
2513
+ #### 通用错误码
2514
+
2515
+ <table>
2516
+ <thead>
2517
+ <tr><th>errNo</th><th>errMsg</th><th>说明</th><th>平台</th></tr>
2518
+ </thead>
2519
+ <tbody>
2520
+ <tr><td><code>102</code></td><td><code>internal error</code></td><td>内部错误</td><td>Android、iOS</td></tr>
2521
+ <tr><td><code>103</code></td><td><code>feature not support</code></td><td>当前环境不支持该能力</td><td>Android、iOS</td></tr>
2522
+ <tr><td><code>104</code></td><td><code>invalid parameter</code></td><td>参数不合法</td><td>Android、iOS</td></tr>
2523
+ <tr><td><code>116</code></td><td><code>resource not found</code></td><td>资源不存在</td><td>Android、iOS</td></tr>
2524
+ </tbody>
2525
+ </table>
2526
+
2527
+ <a id="onbluetoothadapterstatechange"></a>
2528
+ ### onBluetoothAdapterStateChange()
2529
+
2530
+ # onBluetoothAdapterStateChange
2531
+
2532
+ 注册蓝牙适配器状态变化回调。
2533
+
2534
+ ## 支持版本
2535
+
2536
+ 前端库版本不低于 `0.0.36`。
2537
+
2538
+ ## 支持平台
2539
+
2540
+ <table>
2541
+ <thead>
2542
+ <tr><th>平台</th><th>支持情况</th></tr>
2543
+ </thead>
2544
+ <tbody>
2545
+ <tr><td>Android</td><td>支持</td></tr>
2546
+ <tr><td>iOS</td><td>支持</td></tr>
2547
+ <tr><td>PC</td><td>不支持</td></tr>
2548
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2549
+ </tbody>
2550
+ </table>
2551
+
2552
+ ## 支持场景
2553
+
2554
+ <table>
2555
+ <thead>
2556
+ <tr><th>场景</th><th>支持情况</th></tr>
2557
+ </thead>
2558
+ <tbody>
2559
+ <tr><td>页面</td><td>支持</td></tr>
2560
+ <tr><td>卡片</td><td>不支持</td></tr>
2561
+ </tbody>
2562
+ </table>
2563
+
2564
+ ## 接入准备
2565
+
2566
+ ### 权限要求
2567
+
2568
+ <table>
2569
+ <thead>
2570
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2571
+ </thead>
2572
+ <tbody>
2573
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
2574
+ </tbody>
2575
+ </table>
2576
+
2577
+ ### 授权行为
2578
+
2579
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后事件不再回调,需引导用户在系统设置中开启蓝牙权限
2580
+
2581
+ ### 前置条件
2582
+
2583
+ - 需先调用 openBluetoothAdapter 打开蓝牙适配器
2584
+
2585
+ ## 使用说明
2586
+
2587
+ - 通过 available 与 discovering 感知适配器可用性与搜索状态变化
2588
+
2589
+ ## 调用方式
2590
+
2591
+ ### 事件监听 API
2592
+
2593
+ ```typescript
2594
+ onBluetoothAdapterStateChange(callback: (event: GetBluetoothAdapterStateResult) => void): () => void
2595
+ ```
2596
+
2597
+ ## 入参
2598
+
2599
+ 无。
2600
+
2601
+ ## 调用示例
2602
+
2603
+ ```typescript
2604
+ import { onBluetoothAdapterStateChange } from '@doubao-dev/framework/api';
2605
+
2606
+ const off = onBluetoothAdapterStateChange(({ available, discovering }) => {
2607
+ console.log(available, discovering);
2608
+ });
2609
+
2610
+ off();
2611
+ ```
2612
+
2613
+ ## 回调参数
2614
+
2615
+ <table>
2616
+ <thead>
2617
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
2618
+ </thead>
2619
+ <tbody>
2620
+ <tr><td><code>event.available</code></td><td><code>boolean</code></td><td>是</td><td>蓝牙适配器是否可用。</td></tr>
2621
+ <tr><td><code>event.discovering</code></td><td><code>boolean</code></td><td>是</td><td>是否正在搜索蓝牙设备。</td></tr>
2622
+ </tbody>
2623
+ </table>
2624
+
2625
+ ## 返回值
2626
+
2627
+ 返回取消当前监听函数的函数。
2628
+
2629
+ ### 回调示例
2630
+
2631
+ ```json
2632
+ {
2633
+ "available": true,
2634
+ "discovering": false
2635
+ }
2636
+ ```
2637
+
2638
+ <a id="onbluetoothdevicefound"></a>
2639
+ ### onBluetoothDeviceFound()
2640
+
2641
+ # onBluetoothDeviceFound
2642
+
2643
+ 注册发现蓝牙设备回调。
2644
+
2645
+ ## 支持版本
2646
+
2647
+ 前端库版本不低于 `0.0.36`。
2648
+
2649
+ ## 支持平台
2650
+
2651
+ <table>
2652
+ <thead>
2653
+ <tr><th>平台</th><th>支持情况</th></tr>
2654
+ </thead>
2655
+ <tbody>
2656
+ <tr><td>Android</td><td>支持</td></tr>
2657
+ <tr><td>iOS</td><td>支持</td></tr>
2658
+ <tr><td>PC</td><td>不支持</td></tr>
2659
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2660
+ </tbody>
2661
+ </table>
2662
+
2663
+ ## 支持场景
2664
+
2665
+ <table>
2666
+ <thead>
2667
+ <tr><th>场景</th><th>支持情况</th></tr>
2668
+ </thead>
2669
+ <tbody>
2670
+ <tr><td>页面</td><td>支持</td></tr>
2671
+ <tr><td>卡片</td><td>不支持</td></tr>
2672
+ </tbody>
2673
+ </table>
2674
+
2675
+ ## 接入准备
2676
+
2677
+ ### 权限要求
2678
+
2679
+ <table>
2680
+ <thead>
2681
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2682
+ </thead>
2683
+ <tbody>
2684
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>扫描附近蓝牙设备需要系统蓝牙权限,Android 低版本还需定位权限</td></tr>
2685
+ </tbody>
2686
+ </table>
2687
+
2688
+ ### 授权行为
2689
+
2690
+ - 依赖 startBluetoothDevicesDiscovery 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后事件不再回调,需引导用户在系统设置中开启蓝牙权限
2691
+
2692
+ ### 前置条件
2693
+
2694
+ - 需先调用 startBluetoothDevicesDiscovery 开始搜索
2695
+
2696
+ ## 使用说明
2697
+
2698
+ - `advertisData` 与 `serviceData` 以 ArrayBuffer 返回
2699
+
2700
+ ## 调用方式
2701
+
2702
+ ### 事件监听 API
2703
+
2704
+ ```typescript
2705
+ onBluetoothDeviceFound(callback: BluetoothDeviceFoundListener): () => void
2706
+ ```
2707
+
2708
+ ## 入参
2709
+
2710
+ 无。
2711
+
2712
+ ## 调用示例
2713
+
2714
+ ```typescript
2715
+ import { onBluetoothDeviceFound } from '@doubao-dev/framework/api';
2716
+
2717
+ const off = onBluetoothDeviceFound(({ devices }) => {
2718
+ console.log(devices);
2719
+ });
2720
+
2721
+ off();
2722
+ ```
2723
+
2724
+ ## 回调参数
2725
+
2726
+ <table>
2727
+ <thead>
2728
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
2729
+ </thead>
2730
+ <tbody>
2731
+ <tr><td><code>event.devices</code></td><td><code>BluetoothDeviceFoundDevice[]</code></td><td>是</td><td>本次扫描上报的新发现设备列表。</td></tr>
2732
+ <tr><td><code>event.devices[].advertisData</code></td><td><code>ArrayBuffer</code></td><td>否</td><td>广播二进制数据。</td></tr>
2733
+ <tr><td><code>event.devices[].advertisServiceUUIDs</code></td><td><code>string[]</code></td><td>否</td><td>广播中的服务 UUID 列表。</td></tr>
2734
+ <tr><td><code>event.devices[].connectable</code></td><td><code>boolean</code></td><td>否</td><td>是否可连接。</td></tr>
2735
+ <tr><td><code>event.devices[].deviceId</code></td><td><code>string</code></td><td>是</td><td>设备 ID。</td></tr>
2736
+ <tr><td><code>event.devices[].localName</code></td><td><code>string</code></td><td>否</td><td>广播中的本地名称。</td></tr>
2737
+ <tr><td><code>event.devices[].name</code></td><td><code>string</code></td><td>是</td><td>设备名称。</td></tr>
2738
+ <tr><td><code>event.devices[].RSSI</code></td><td><code>number</code></td><td>是</td><td>RSSI 信号强度,单位 dBm。</td></tr>
2739
+ <tr><td><code>event.devices[].serviceData</code></td><td><code>BluetoothBinaryField</code></td><td>否</td><td>广播中的服务数据。</td></tr>
2740
+ </tbody>
2741
+ </table>
2742
+
2743
+ ## 返回值
2744
+
2745
+ 返回取消当前监听函数的函数。
2746
+
2747
+ ### 回调示例
2748
+
2749
+ ```json
2750
+ {
2751
+ "devices": [
2752
+ {
2753
+ "deviceId": "device-id",
2754
+ "name": "Doubao BLE",
2755
+ "RSSI": -60,
2756
+ "connectable": true
2757
+ }
2758
+ ]
2759
+ }
2760
+ ```
2761
+
2762
+ <a id="onbleconnectionstatechange"></a>
2763
+ ### onBLEConnectionStateChange()
2764
+
2765
+ # onBLEConnectionStateChange
2766
+
2767
+ 注册 BLE 连接状态变化回调。
2768
+
2769
+ ## 支持版本
2770
+
2771
+ 前端库版本不低于 `0.0.36`。
2772
+
2773
+ ## 支持平台
2774
+
2775
+ <table>
2776
+ <thead>
2777
+ <tr><th>平台</th><th>支持情况</th></tr>
2778
+ </thead>
2779
+ <tbody>
2780
+ <tr><td>Android</td><td>支持</td></tr>
2781
+ <tr><td>iOS</td><td>支持</td></tr>
2782
+ <tr><td>PC</td><td>不支持</td></tr>
2783
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2784
+ </tbody>
2785
+ </table>
2786
+
2787
+ ## 支持场景
2788
+
2789
+ <table>
2790
+ <thead>
2791
+ <tr><th>场景</th><th>支持情况</th></tr>
2792
+ </thead>
2793
+ <tbody>
2794
+ <tr><td>页面</td><td>支持</td></tr>
2795
+ <tr><td>卡片</td><td>不支持</td></tr>
2796
+ </tbody>
2797
+ </table>
2798
+
2799
+ ## 接入准备
2800
+
2801
+ ### 权限要求
2802
+
2803
+ <table>
2804
+ <thead>
2805
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2806
+ </thead>
2807
+ <tbody>
2808
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
2809
+ </tbody>
2810
+ </table>
2811
+
2812
+ ### 授权行为
2813
+
2814
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后事件不再回调,需引导用户在系统设置中开启蓝牙权限
2815
+
2816
+ ### 前置条件
2817
+
2818
+ - 需先调用 createBLEConnection 建立连接
2819
+
2820
+ ## 使用说明
2821
+
2822
+ - 设备主动断开或连接恢复时都会回调,通过 connected 判断当前状态
2823
+
2824
+ ## 调用方式
2825
+
2826
+ ### 事件监听 API
2827
+
2828
+ ```typescript
2829
+ onBLEConnectionStateChange(callback: (event: BLEConnectionStateChangeEvent) => void): () => void
2830
+ ```
2831
+
2832
+ ## 入参
2833
+
2834
+ 无。
2835
+
2836
+ ## 调用示例
2837
+
2838
+ ```typescript
2839
+ import { onBLEConnectionStateChange } from '@doubao-dev/framework/api';
2840
+
2841
+ const off = onBLEConnectionStateChange(({ deviceId, connected }) => {
2842
+ console.log(deviceId, connected);
2843
+ });
2844
+
2845
+ off();
2846
+ ```
2847
+
2848
+ ## 回调参数
2849
+
2850
+ <table>
2851
+ <thead>
2852
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
2853
+ </thead>
2854
+ <tbody>
2855
+ <tr><td><code>event.connected</code></td><td><code>boolean</code></td><td>是</td><td>是否已连接。</td></tr>
2856
+ <tr><td><code>event.deviceId</code></td><td><code>string</code></td><td>是</td><td>蓝牙设备 ID。</td></tr>
2857
+ </tbody>
2858
+ </table>
2859
+
2860
+ ## 返回值
2861
+
2862
+ 返回取消当前监听函数的函数。
2863
+
2864
+ ### 回调示例
2865
+
2866
+ ```json
2867
+ {
2868
+ "deviceId": "device-id",
2869
+ "connected": true
2870
+ }
2871
+ ```
2872
+
2873
+ <a id="onblecharacteristicvaluechange"></a>
2874
+ ### onBLECharacteristicValueChange()
2875
+
2876
+ # onBLECharacteristicValueChange
2877
+
2878
+ 注册 BLE 特征值变化回调。
2879
+
2880
+ ## 支持版本
2881
+
2882
+ 前端库版本不低于 `0.0.36`。
2883
+
2884
+ ## 支持平台
2885
+
2886
+ <table>
2887
+ <thead>
2888
+ <tr><th>平台</th><th>支持情况</th></tr>
2889
+ </thead>
2890
+ <tbody>
2891
+ <tr><td>Android</td><td>支持</td></tr>
2892
+ <tr><td>iOS</td><td>支持</td></tr>
2893
+ <tr><td>PC</td><td>不支持</td></tr>
2894
+ <tr><td>HarmonyOS</td><td>不支持</td></tr>
2895
+ </tbody>
2896
+ </table>
2897
+
2898
+ ## 支持场景
2899
+
2900
+ <table>
2901
+ <thead>
2902
+ <tr><th>场景</th><th>支持情况</th></tr>
2903
+ </thead>
2904
+ <tbody>
2905
+ <tr><td>页面</td><td>支持</td></tr>
2906
+ <tr><td>卡片</td><td>不支持</td></tr>
2907
+ </tbody>
2908
+ </table>
2909
+
2910
+ ## 接入准备
2911
+
2912
+ ### 权限要求
2913
+
2914
+ <table>
2915
+ <thead>
2916
+ <tr><th>类型</th><th>标识</th><th>是否必须</th><th>平台</th><th>说明</th></tr>
2917
+ </thead>
2918
+ <tbody>
2919
+ <tr><td>系统权限</td><td>蓝牙权限</td><td>按条件</td><td>Android、iOS</td><td>使用蓝牙能力需要系统蓝牙权限</td></tr>
2920
+ </tbody>
2921
+ </table>
2922
+
2923
+ ### 授权行为
2924
+
2925
+ - 依赖 openBluetoothAdapter 阶段已获得的系统蓝牙权限;权限被拒绝或在系统设置中撤销后事件不再回调,需引导用户在系统设置中开启蓝牙权限
2926
+
2927
+ ### 前置条件
2928
+
2929
+ - 需先调用 readBLECharacteristicValue 读取或 notifyBLECharacteristicValueChange 开启订阅
2930
+
2931
+ ## 使用说明
2932
+
2933
+ `readBLECharacteristicValue` 读到的数据和 `notifyBLECharacteristicValueChange` 开启后的通知都会从此事件回传。
2934
+
2935
+ - 读取结果与订阅通知都会从此事件回传,`value` 以 ArrayBuffer 返回
2936
+
2937
+ ## 调用方式
2938
+
2939
+ ### 事件监听 API
2940
+
2941
+ ```typescript
2942
+ onBLECharacteristicValueChange(callback: BLECharacteristicValueChangeListener): () => void
2943
+ ```
2944
+
2945
+ ## 入参
2946
+
2947
+ 无。
2948
+
2949
+ ## 调用示例
2950
+
2951
+ ```typescript
2952
+ import { onBLECharacteristicValueChange } from '@doubao-dev/framework/api';
2953
+
2954
+ const off = onBLECharacteristicValueChange(({ deviceId, value }) => {
2955
+ console.log(deviceId, value?.byteLength ?? 0);
2956
+ });
2957
+
2958
+ off();
2959
+ ```
2960
+
2961
+ ## 回调参数
2962
+
2963
+ <table>
2964
+ <thead>
2965
+ <tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
2966
+ </thead>
2967
+ <tbody>
2968
+ <tr><td><code>event.characteristicId</code></td><td><code>string</code></td><td>是</td><td>特征值 ID。</td></tr>
2969
+ <tr><td><code>event.deviceId</code></td><td><code>string</code></td><td>是</td><td>蓝牙设备 ID。</td></tr>
2970
+ <tr><td><code>event.serviceId</code></td><td><code>string</code></td><td>是</td><td>服务 ID。</td></tr>
2971
+ <tr><td><code>event.value</code></td><td><code>ArrayBuffer</code></td><td>否</td><td>特征值最新的二进制值。</td></tr>
2972
+ </tbody>
2973
+ </table>
2974
+
2975
+ ## 返回值
2976
+
2977
+ 返回取消当前监听函数的函数。
2978
+
2979
+ ### 回调示例
2980
+
2981
+ ```json
2982
+ {
2983
+ "deviceId": "device-id",
2984
+ "serviceId": "service-id",
2985
+ "characteristicId": "characteristic-id"
2986
+ }
2987
+ ```
2988
+
2989
+ ## 相关类型
2990
+
2991
+ <a id="bluetoothpowerlevel"></a>
2992
+ ### BluetoothPowerLevel
2993
+
2994
+ 蓝牙扫描功耗等级。
2995
+
2996
+ #### Type
2997
+
2998
+ `'low' | 'medium' | 'high'`
2999
+
3000
+ <a id="startbluetoothdevicesdiscoveryparams"></a>
3001
+ ### StartBluetoothDevicesDiscoveryParams
3002
+
3003
+ 开始搜索蓝牙设备的请求参数。
3004
+
3005
+ #### Properties
3006
+
3007
+ • **allowDuplicatesKey?**: `boolean` - 是否允许重复上报同一设备
3008
+ • **interval?**: `number` - 上报设备的间隔,单位毫秒
3009
+ • **services?**: `string[]` - 按主服务 UUID 过滤搜索范围
3010
+ • **powerLevel?**: `BluetoothPowerLevel` - 扫描功耗等级
3011
+
3012
+ <a id="getbluetoothadapterstateresult"></a>
3013
+ ### GetBluetoothAdapterStateResult
3014
+
3015
+ 蓝牙适配器状态。
3016
+
3017
+ #### Properties
3018
+
3019
+ • **available**: `boolean` - 蓝牙适配器是否可用
3020
+ • **discovering**: `boolean` - 是否正在搜索蓝牙设备
3021
+
3022
+ <a id="bluetoothbinaryfield"></a>
3023
+ ### BluetoothBinaryField
3024
+
3025
+ 蓝牙广播二进制字段。
3026
+
3027
+ #### Type
3028
+
3029
+ `Record<string, ArrayBuffer>`
3030
+
3031
+ <a id="bluetoothdevice"></a>
3032
+ ### BluetoothDevice
3033
+
3034
+ 蓝牙设备信息。
3035
+
3036
+ #### Properties
3037
+
3038
+ • **deviceId**: `string` - 设备 ID
3039
+ • **name**: `string` - 设备名称
3040
+ • **localName?**: `string` - 广播中的本地名称
3041
+ • **RSSI**: `number` - RSSI 信号强度,单位 dBm
3042
+ • **advertisData?**: `ArrayBuffer` - 广播二进制数据
3043
+ • **advertisServiceUUIDs?**: `string[]` - 广播中的服务 UUID 列表
3044
+ • **serviceData?**: `BluetoothBinaryField` - 广播中的服务数据
3045
+ • **connectable?**: `boolean` - 是否可连接
3046
+
3047
+ <a id="getbluetoothdevicesresult"></a>
3048
+ ### GetBluetoothDevicesResult
3049
+
3050
+ 获取蓝牙设备列表的返回结果。
3051
+
3052
+ #### Properties
3053
+
3054
+ • **devices**: `BluetoothDevice[]` - 当前蓝牙模块已发现的设备列表
3055
+
3056
+ <a id="getconnectedbluetoothdevicesparams"></a>
3057
+ ### GetConnectedBluetoothDevicesParams
3058
+
3059
+ 获取已连接蓝牙设备的请求参数。
3060
+
3061
+ #### Properties
3062
+
3063
+ • **services**: `string[]` - 蓝牙主服务 UUID 列表
3064
+
3065
+ <a id="connectedbluetoothdevice"></a>
3066
+ ### ConnectedBluetoothDevice
3067
+
3068
+ 已连接蓝牙设备信息。
3069
+
3070
+ #### Properties
3071
+
3072
+ • **deviceId**: `string` - 设备 ID
3073
+ • **name**: `string` - 设备名称
3074
+
3075
+ <a id="getconnectedbluetoothdevicesresult"></a>
3076
+ ### GetConnectedBluetoothDevicesResult
3077
+
3078
+ 获取已连接蓝牙设备的返回结果。
3079
+
3080
+ #### Properties
3081
+
3082
+ • **devices**: `ConnectedBluetoothDevice[]` - 已连接设备列表
3083
+
3084
+ <a id="makebluetoothpairparams"></a>
3085
+ ### MakeBluetoothPairParams
3086
+
3087
+ 蓝牙配对请求参数。
3088
+
3089
+ #### Properties
3090
+
3091
+ • **deviceId**: `string` - 蓝牙设备 ID
3092
+ • **pin**: `string` - 配对 PIN 码
3093
+ • **timeout?**: `number` - 超时时间,单位毫秒
3094
+
3095
+ <a id="isbluetoothdevicepairedparams"></a>
3096
+ ### IsBluetoothDevicePairedParams
3097
+
3098
+ 查询蓝牙设备配对状态的请求参数。
3099
+
3100
+ #### Properties
3101
+
3102
+ • **deviceId**: `string` - 蓝牙设备 ID
3103
+
3104
+ <a id="createbleconnectionparams"></a>
3105
+ ### CreateBLEConnectionParams
3106
+
3107
+ 创建 BLE 连接的请求参数。
3108
+
3109
+ #### Properties
3110
+
3111
+ • **deviceId**: `string` - 蓝牙设备 ID
3112
+ • **timeout?**: `number` - 超时时间,单位毫秒
3113
+
3114
+ <a id="closebleconnectionparams"></a>
3115
+ ### CloseBLEConnectionParams
3116
+
3117
+ 关闭 BLE 连接的请求参数。
3118
+
3119
+ #### Properties
3120
+
3121
+ • **deviceId**: `string` - 蓝牙设备 ID
3122
+
3123
+ <a id="bluetoothservice"></a>
3124
+ ### BluetoothService
3125
+
3126
+ 蓝牙服务信息。
3127
+
3128
+ #### Properties
3129
+
3130
+ • **uuid**: `string` - 服务 UUID
3131
+ • **isPrimary**: `boolean` - 是否为主服务
3132
+
3133
+ <a id="getbledeviceservicesparams"></a>
3134
+ ### GetBLEDeviceServicesParams
3135
+
3136
+ 获取 BLE 服务列表的请求参数。
3137
+
3138
+ #### Properties
3139
+
3140
+ • **deviceId**: `string` - 蓝牙设备 ID
3141
+
3142
+ <a id="getbledeviceservicesresult"></a>
3143
+ ### GetBLEDeviceServicesResult
3144
+
3145
+ 获取 BLE 服务列表的返回结果。
3146
+
3147
+ #### Properties
3148
+
3149
+ • **services**: `BluetoothService[]` - 设备服务列表
3150
+
3151
+ <a id="bluetoothcharacteristicproperties"></a>
3152
+ ### BluetoothCharacteristicProperties
3153
+
3154
+ 蓝牙特征值支持的能力。
3155
+
3156
+ #### Properties
3157
+
3158
+ • **indicate**: `boolean` - 是否支持 indicate
3159
+ • **notify**: `boolean` - 是否支持 notify
3160
+ • **read**: `boolean` - 是否支持 read
3161
+ • **write**: `boolean` - 是否支持 write
3162
+ • **writeNoResponse**: `boolean` - 是否支持无响应写入
3163
+ • **writeDefault**: `boolean` - 是否支持带响应写入
3164
+
3165
+ <a id="bluetoothcharacteristic"></a>
3166
+ ### BluetoothCharacteristic
3167
+
3168
+ 蓝牙特征值信息。
3169
+
3170
+ #### Properties
3171
+
3172
+ • **uuid**: `string` - 特征值 UUID
3173
+ • **properties**: `BluetoothCharacteristicProperties` - 特征值能力
3174
+
3175
+ <a id="getbledevicecharacteristicsparams"></a>
3176
+ ### GetBLEDeviceCharacteristicsParams
3177
+
3178
+ 获取 BLE 特征值列表的请求参数。
3179
+
3180
+ #### Properties
3181
+
3182
+ • **deviceId**: `string` - 蓝牙设备 ID
3183
+ • **serviceId**: `string` - 服务 ID
3184
+
3185
+ <a id="getbledevicecharacteristicsresult"></a>
3186
+ ### GetBLEDeviceCharacteristicsResult
3187
+
3188
+ 获取 BLE 特征值列表的返回结果。
3189
+
3190
+ #### Properties
3191
+
3192
+ • **characteristics**: `BluetoothCharacteristic[]` - 特征值列表
3193
+
3194
+ <a id="getbledevicerssiparams"></a>
3195
+ ### GetBLEDeviceRSSIParams
3196
+
3197
+ 获取 BLE RSSI 的请求参数。
3198
+
3199
+ #### Properties
3200
+
3201
+ • **deviceId**: `string` - 蓝牙设备 ID
3202
+
3203
+ <a id="getbledevicerssiresult"></a>
3204
+ ### GetBLEDeviceRSSIResult
3205
+
3206
+ 获取 BLE RSSI 的返回结果。
3207
+
3208
+ #### Properties
3209
+
3210
+ • **RSSI**: `number` - RSSI 信号强度,单位 dBm
3211
+
3212
+ <a id="bluetoothwritetype"></a>
3213
+ ### BluetoothWriteType
3214
+
3215
+ 蓝牙写入模式。
3216
+
3217
+ #### Type
3218
+
3219
+ `'write' | 'writeNoResponse'`
3220
+
3221
+ <a id="getblemtuparams"></a>
3222
+ ### GetBLEMTUParams
3223
+
3224
+ 获取 BLE MTU 的请求参数。
3225
+
3226
+ #### Properties
3227
+
3228
+ • **deviceId**: `string` - 蓝牙设备 ID
3229
+ • **writeType?**: `BluetoothWriteType` - 写入模式
3230
+
3231
+ <a id="getblemturesult"></a>
3232
+ ### GetBLEMTUResult
3233
+
3234
+ 获取 BLE MTU 的返回结果。
3235
+
3236
+ #### Properties
3237
+
3238
+ • **mtu**: `number` - 当前 MTU
3239
+
3240
+ <a id="bluetoothnotifytype"></a>
3241
+ ### BluetoothNotifyType
3242
+
3243
+ 蓝牙特征值订阅类型。
3244
+
3245
+ #### Type
3246
+
3247
+ `'notification' | 'indication'`
3248
+
3249
+ <a id="notifyblecharacteristicvaluechangeparams"></a>
3250
+ ### NotifyBLECharacteristicValueChangeParams
3251
+
3252
+ 订阅 BLE 特征值变化的请求参数。
3253
+
3254
+ #### Properties
3255
+
3256
+ • **deviceId**: `string` - 蓝牙设备 ID
3257
+ • **serviceId**: `string` - 服务 ID
3258
+ • **characteristicId**: `string` - 特征值 ID
3259
+ • **state**: `boolean` - 是否启用订阅
3260
+ • **type?**: `BluetoothNotifyType` - 订阅类型
3261
+
3262
+ <a id="readblecharacteristicvalueparams"></a>
3263
+ ### ReadBLECharacteristicValueParams
3264
+
3265
+ 读取 BLE 特征值的请求参数。
3266
+
3267
+ #### Properties
3268
+
3269
+ • **deviceId**: `string` - 蓝牙设备 ID
3270
+ • **serviceId**: `string` - 服务 ID
3271
+ • **characteristicId**: `string` - 特征值 ID
3272
+
3273
+ <a id="setblemtuparams"></a>
3274
+ ### SetBLEMTUParams
3275
+
3276
+ 设置 BLE MTU 的请求参数。
3277
+
3278
+ #### Properties
3279
+
3280
+ • **deviceId**: `string` - 蓝牙设备 ID
3281
+ • **mtu**: `number` - 目标 MTU
3282
+
3283
+ <a id="setblemturesult"></a>
3284
+ ### SetBLEMTUResult
3285
+
3286
+ 设置 BLE MTU 的返回结果。
3287
+
3288
+ #### Properties
3289
+
3290
+ • **mtu**: `number` - 最终协商得到的 MTU
3291
+
3292
+ <a id="writeblecharacteristicvalueparams"></a>
3293
+ ### WriteBLECharacteristicValueParams
3294
+
3295
+ 写入 BLE 特征值的请求参数。
3296
+
3297
+ #### Properties
3298
+
3299
+ • **deviceId**: `string` - 蓝牙设备 ID
3300
+ • **serviceId**: `string` - 服务 ID
3301
+ • **characteristicId**: `string` - 特征值 ID
3302
+ • **value**: `ArrayBuffer` - 要写入的二进制数据
3303
+ • **writeType?**: `BluetoothWriteType` - 写入模式
3304
+
3305
+ <a id="bluetoothdevicefounddevice"></a>
3306
+ ### BluetoothDeviceFoundDevice
3307
+
3308
+ 蓝牙设备发现事件中的设备信息。
3309
+
3310
+ #### Properties
3311
+
3312
+ • **deviceId**: `string` - 设备 ID
3313
+ • **name**: `string` - 设备名称
3314
+ • **localName?**: `string` - 广播中的本地名称
3315
+ • **RSSI**: `number` - RSSI 信号强度,单位 dBm
3316
+ • **advertisData?**: `ArrayBuffer` - 广播二进制数据
3317
+ • **advertisServiceUUIDs?**: `string[]` - 广播中的服务 UUID 列表
3318
+ • **serviceData?**: `BluetoothBinaryField` - 广播中的服务数据
3319
+ • **connectable?**: `boolean` - 是否可连接
3320
+
3321
+ <a id="bluetoothdevicefoundlistener"></a>
3322
+ ### BluetoothDeviceFoundListener
3323
+
3324
+ #### Type
3325
+
3326
+ `(event: BluetoothDeviceFoundEvent) => void`
3327
+
3328
+ <a id="bluetoothdevicefoundevent"></a>
3329
+ ### BluetoothDeviceFoundEvent
3330
+
3331
+ 蓝牙设备发现事件。
3332
+
3333
+ #### Properties
3334
+
3335
+ • **devices**: `BluetoothDeviceFoundDevice[]` - 本次扫描上报的新发现设备列表
3336
+
3337
+ <a id="bleconnectionstatechangeevent"></a>
3338
+ ### BLEConnectionStateChangeEvent
3339
+
3340
+ BLE 连接状态变化事件。
3341
+
3342
+ #### Properties
3343
+
3344
+ • **deviceId**: `string` - 蓝牙设备 ID
3345
+ • **connected**: `boolean` - 是否已连接
3346
+
3347
+ <a id="blecharacteristicvaluechangelistener"></a>
3348
+ ### BLECharacteristicValueChangeListener
3349
+
3350
+ #### Type
3351
+
3352
+ `(event: BLECharacteristicValueChangeEvent) => void`
3353
+
3354
+ <a id="blecharacteristicvaluechangeevent"></a>
3355
+ ### BLECharacteristicValueChangeEvent
3356
+
3357
+ BLE 特征值变化事件。
3358
+
3359
+ #### Properties
3360
+
3361
+ • **deviceId**: `string` - 蓝牙设备 ID
3362
+ • **serviceId**: `string` - 服务 ID
3363
+ • **characteristicId**: `string` - 特征值 ID
3364
+ • **value?**: `ArrayBuffer` - 特征值最新的二进制值