@spcsn/taro 0.1.0

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 (140) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +147 -0
  3. package/dist/index.js.map +1 -0
  4. package/index.js +9 -0
  5. package/package.json +86 -0
  6. package/types/api/ad/index.d.ts +197 -0
  7. package/types/api/ai/face.d.ts +133 -0
  8. package/types/api/ai/inference.d.ts +129 -0
  9. package/types/api/ai/visionkit.d.ts +874 -0
  10. package/types/api/alipay/index.d.ts +69 -0
  11. package/types/api/base/crypto.d.ts +104 -0
  12. package/types/api/base/debug.d.ts +329 -0
  13. package/types/api/base/env.d.ts +19 -0
  14. package/types/api/base/index.d.ts +102 -0
  15. package/types/api/base/performance.d.ts +258 -0
  16. package/types/api/base/system.d.ts +742 -0
  17. package/types/api/base/update.d.ts +130 -0
  18. package/types/api/base/weapp/app-event.d.ts +265 -0
  19. package/types/api/base/weapp/life-cycle.d.ts +155 -0
  20. package/types/api/canvas/index.d.ts +2162 -0
  21. package/types/api/cloud/index.d.ts +2622 -0
  22. package/types/api/data-analysis/index.d.ts +122 -0
  23. package/types/api/device/accelerometer.d.ts +102 -0
  24. package/types/api/device/accessibility.d.ts +26 -0
  25. package/types/api/device/battery.d.ts +46 -0
  26. package/types/api/device/bluetooth-ble.d.ts +601 -0
  27. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  28. package/types/api/device/bluetooth.d.ts +463 -0
  29. package/types/api/device/calendar.d.ts +98 -0
  30. package/types/api/device/clipboard.d.ts +81 -0
  31. package/types/api/device/compass.d.ts +105 -0
  32. package/types/api/device/contact.d.ts +110 -0
  33. package/types/api/device/gyroscope.d.ts +85 -0
  34. package/types/api/device/iBeacon.d.ts +168 -0
  35. package/types/api/device/keyboard.d.ts +97 -0
  36. package/types/api/device/memory.d.ts +52 -0
  37. package/types/api/device/motion.d.ts +88 -0
  38. package/types/api/device/network.d.ts +172 -0
  39. package/types/api/device/nfc.d.ts +1238 -0
  40. package/types/api/device/phone.d.ts +30 -0
  41. package/types/api/device/scan.d.ts +111 -0
  42. package/types/api/device/screen.d.ts +217 -0
  43. package/types/api/device/sms.d.ts +26 -0
  44. package/types/api/device/vibrate.d.ts +51 -0
  45. package/types/api/device/wifi.d.ts +301 -0
  46. package/types/api/ext/index.d.ts +64 -0
  47. package/types/api/files/index.d.ts +1472 -0
  48. package/types/api/framework/index.d.ts +51 -0
  49. package/types/api/location/index.d.ts +517 -0
  50. package/types/api/media/audio.d.ts +1013 -0
  51. package/types/api/media/background-audio.d.ts +291 -0
  52. package/types/api/media/camera.d.ts +207 -0
  53. package/types/api/media/editor.d.ts +239 -0
  54. package/types/api/media/image.d.ts +469 -0
  55. package/types/api/media/live.d.ts +461 -0
  56. package/types/api/media/map.d.ts +638 -0
  57. package/types/api/media/media-recorder.d.ts +117 -0
  58. package/types/api/media/recorder.d.ts +317 -0
  59. package/types/api/media/video-decoder.d.ts +117 -0
  60. package/types/api/media/video-processing.d.ts +84 -0
  61. package/types/api/media/video.d.ts +527 -0
  62. package/types/api/media/voip.d.ts +393 -0
  63. package/types/api/navigate/index.d.ts +327 -0
  64. package/types/api/network/download.d.ts +173 -0
  65. package/types/api/network/mdns.d.ts +191 -0
  66. package/types/api/network/request.d.ts +480 -0
  67. package/types/api/network/tcp.d.ts +181 -0
  68. package/types/api/network/udp.d.ts +218 -0
  69. package/types/api/network/upload.d.ts +201 -0
  70. package/types/api/network/websocket.d.ts +383 -0
  71. package/types/api/open-api/account.d.ts +51 -0
  72. package/types/api/open-api/address.d.ts +68 -0
  73. package/types/api/open-api/authorize.d.ts +80 -0
  74. package/types/api/open-api/card.d.ts +110 -0
  75. package/types/api/open-api/channels.d.ts +225 -0
  76. package/types/api/open-api/customer-service.d.ts +45 -0
  77. package/types/api/open-api/device-voip.d.ts +103 -0
  78. package/types/api/open-api/facial.d.ts +98 -0
  79. package/types/api/open-api/favorites.d.ts +101 -0
  80. package/types/api/open-api/group.d.ts +59 -0
  81. package/types/api/open-api/invoice.d.ts +87 -0
  82. package/types/api/open-api/license-plate.d.ts +27 -0
  83. package/types/api/open-api/login.d.ts +115 -0
  84. package/types/api/open-api/my-miniprogram.d.ts +28 -0
  85. package/types/api/open-api/privacy.d.ts +107 -0
  86. package/types/api/open-api/redpackage.d.ts +24 -0
  87. package/types/api/open-api/settings.d.ts +174 -0
  88. package/types/api/open-api/soter.d.ts +184 -0
  89. package/types/api/open-api/sticker.d.ts +83 -0
  90. package/types/api/open-api/subscribe-message.d.ts +305 -0
  91. package/types/api/open-api/user-info.d.ts +182 -0
  92. package/types/api/open-api/werun.d.ts +101 -0
  93. package/types/api/payment/index.d.ts +119 -0
  94. package/types/api/qq/index.d.ts +354 -0
  95. package/types/api/route/index.d.ts +324 -0
  96. package/types/api/share/index.d.ts +354 -0
  97. package/types/api/skyline/index.d.ts +345 -0
  98. package/types/api/storage/background-fetch.d.ts +131 -0
  99. package/types/api/storage/cache-manager.d.ts +249 -0
  100. package/types/api/storage/index.d.ts +405 -0
  101. package/types/api/swan/bookshelf.d.ts +307 -0
  102. package/types/api/swan/download-package.d.ts +80 -0
  103. package/types/api/swan/index.d.ts +251 -0
  104. package/types/api/swan/pay.d.ts +139 -0
  105. package/types/api/taro.extend.d.ts +233 -0
  106. package/types/api/taro.hooks.d.ts +148 -0
  107. package/types/api/ui/animation.d.ts +427 -0
  108. package/types/api/ui/background.d.ts +69 -0
  109. package/types/api/ui/custom-component.d.ts +23 -0
  110. package/types/api/ui/fonts.d.ts +77 -0
  111. package/types/api/ui/interaction.d.ts +281 -0
  112. package/types/api/ui/menu.d.ts +29 -0
  113. package/types/api/ui/navigation-bar.d.ts +130 -0
  114. package/types/api/ui/pull-down-refresh.d.ts +50 -0
  115. package/types/api/ui/scroll.d.ts +114 -0
  116. package/types/api/ui/sticky.d.ts +32 -0
  117. package/types/api/ui/tab-bar.d.ts +196 -0
  118. package/types/api/ui/window.d.ts +71 -0
  119. package/types/api/worker/index.d.ts +83 -0
  120. package/types/api/wxml/index.d.ts +540 -0
  121. package/types/compile/compiler.d.ts +32 -0
  122. package/types/compile/config/h5.d.ts +134 -0
  123. package/types/compile/config/harmony.d.ts +118 -0
  124. package/types/compile/config/index.d.ts +8 -0
  125. package/types/compile/config/manifest.d.ts +155 -0
  126. package/types/compile/config/mini.d.ts +118 -0
  127. package/types/compile/config/plugin.d.ts +34 -0
  128. package/types/compile/config/project.d.ts +338 -0
  129. package/types/compile/config/rn.d.ts +85 -0
  130. package/types/compile/config/util.d.ts +179 -0
  131. package/types/compile/hooks.d.ts +13 -0
  132. package/types/compile/index.d.ts +11 -0
  133. package/types/compile/viteCompilerContext.d.ts +167 -0
  134. package/types/global.d.ts +428 -0
  135. package/types/index.d.ts +190 -0
  136. package/types/taro.api.d.ts +130 -0
  137. package/types/taro.component.d.ts +168 -0
  138. package/types/taro.config.d.ts +712 -0
  139. package/types/taro.lifecycle.d.ts +220 -0
  140. package/types/taro.runtime.d.ts +9 -0
@@ -0,0 +1,601 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace writeBLECharacteristicValue {
5
+ interface Promised extends TaroGeneral.BluetoothError {
6
+ /** 成功:ok,错误:详细信息 */
7
+ errMsg: string
8
+ }
9
+ interface Option {
10
+ /** 蓝牙特征值的 uuid */
11
+ characteristicId: string
12
+ /** 蓝牙设备 id */
13
+ deviceId: string
14
+ /** 蓝牙特征值对应服务的 uuid */
15
+ serviceId: string
16
+ /** 蓝牙设备特征值对应的二进制值 */
17
+ value: ArrayBuffer
18
+ /** 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。(基础库 2.22.0 开始支持) */
19
+ writeType?: keyof WriteType
20
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
21
+ complete?: (res: TaroGeneral.BluetoothError) => void
22
+ /** 接口调用失败的回调函数 */
23
+ fail?: (res: TaroGeneral.BluetoothError) => void
24
+ /** 接口调用成功的回调函数 */
25
+ success?: (res: TaroGeneral.BluetoothError) => void
26
+ }
27
+ interface WriteType {
28
+ /** 强制回复写,不支持时报错 */
29
+ write
30
+ /** 强制无回复写,不支持时报错 */
31
+ writeNoResponse
32
+ }
33
+ }
34
+
35
+ namespace setBLEMTU {
36
+ type Promised = FailCallbackResult | SuccessCallbackResult
37
+ interface Option {
38
+ /** 蓝牙设备 id */
39
+ deviceId: string
40
+ /** 最大传输单元。设置范围为 (22,512) 区间内,单位 bytes */
41
+ mtu: number
42
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
43
+ complete?: (res: Promised) => void
44
+ /** 接口调用失败的回调函数 */
45
+ fail?: (res: FailCallbackResult) => void
46
+ /** 接口调用成功的回调函数 */
47
+ success?: (res: SuccessCallbackResult) => void
48
+ }
49
+ interface FailCallbackResult extends TaroGeneral.BluetoothError {
50
+ /** 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。 */
51
+ mtu: string
52
+ }
53
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
54
+ /** 最终协商的 MTU 值,与传入参数一致。安卓客户端 8.0.9 开始支持。 */
55
+ mtu: string
56
+ }
57
+ }
58
+
59
+ namespace readBLECharacteristicValue {
60
+ interface Option {
61
+ /** 蓝牙特征值的 uuid */
62
+ characteristicId: string
63
+ /** 蓝牙设备 id */
64
+ deviceId: string
65
+ /** 蓝牙特征值对应服务的 uuid */
66
+ serviceId: string
67
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
68
+ complete?: (res: TaroGeneral.BluetoothError) => void
69
+ /** 接口调用失败的回调函数 */
70
+ fail?: (res: TaroGeneral.BluetoothError) => void
71
+ /** 接口调用成功的回调函数 */
72
+ success?: (res: TaroGeneral.BluetoothError) => void
73
+ }
74
+ }
75
+
76
+ namespace onBLEMTUChange {
77
+ interface CallbackResult {
78
+ /** 蓝牙设备ID */
79
+ deviceId: string
80
+ /** 最大传输单元 */
81
+ mtu: string
82
+ }
83
+ /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
84
+ type Callback = (
85
+ result: CallbackResult,
86
+ ) => void
87
+ }
88
+
89
+ namespace onBLEConnectionStateChange {
90
+ interface CallbackResult {
91
+ /** 是否处于已连接状态 */
92
+ connected: boolean
93
+ /** 蓝牙设备ID */
94
+ deviceId: string
95
+ }
96
+ /** 低功耗蓝牙连接状态的改变事件的回调函数 */
97
+ type Callback = (
98
+ result: CallbackResult,
99
+ ) => void
100
+ }
101
+
102
+ namespace onBLECharacteristicValueChange {
103
+ /** 低功耗蓝牙设备的特征值变化事件的回调函数 */
104
+ type Callback = (
105
+ result: CallbackResult,
106
+ ) => void
107
+ interface CallbackResult {
108
+ /** 蓝牙特征值的 uuid */
109
+ characteristicId: string
110
+ /** 蓝牙设备 id */
111
+ deviceId: string
112
+ /** 蓝牙特征值对应服务的 uuid */
113
+ serviceId: string
114
+ /** 特征值最新的值 */
115
+ value: ArrayBuffer
116
+ }
117
+ }
118
+
119
+ namespace notifyBLECharacteristicValueChange {
120
+ interface Promised extends TaroGeneral.BluetoothError {
121
+ /** 成功:ok,错误:详细信息 */
122
+ errMsg: string
123
+ }
124
+ interface Option {
125
+ /** 蓝牙特征值的 uuid */
126
+ characteristicId: string
127
+ /** 蓝牙设备 id */
128
+ deviceId: string
129
+ /** 蓝牙特征值对应服务的 uuid */
130
+ serviceId: string
131
+ /** 是否启用 notify */
132
+ state: boolean
133
+ /** 设置特征订阅类型,有效值有 notification 和 indication
134
+ * @default "indication"
135
+ */
136
+ type?: keyof Type
137
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
138
+ complete?: (res: TaroGeneral.BluetoothError) => void
139
+ /** 接口调用失败的回调函数 */
140
+ fail?: (res: TaroGeneral.BluetoothError) => void
141
+ /** 接口调用成功的回调函数 */
142
+ success?: (res: TaroGeneral.BluetoothError) => void
143
+ }
144
+ interface Type {
145
+ notification
146
+ indication
147
+ }
148
+ }
149
+
150
+ namespace getBLEMTU {
151
+ interface Option {
152
+ /** 蓝牙设备 id */
153
+ deviceId: string
154
+ /** 写模式 (iOS 特有参数)
155
+ * @default "write"
156
+ */
157
+ writeType?: keyof WriteType
158
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
159
+ complete?: (res: TaroGeneral.BluetoothError) => void
160
+ /** 接口调用失败的回调函数 */
161
+ fail?: (res: TaroGeneral.BluetoothError) => void
162
+ /** 接口调用成功的回调函数 */
163
+ success?: (
164
+ result: SuccessCallbackResult,
165
+ ) => void
166
+ }
167
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
168
+ /** 最大传输单元 */
169
+ mtu: number
170
+ }
171
+ /** 写模式合法值 */
172
+ interface WriteType {
173
+ /** 有回复写 */
174
+ write
175
+ /** 无回复写 */
176
+ writeNoResponse
177
+ }
178
+ }
179
+
180
+ namespace getBLEDeviceServices {
181
+ interface Option {
182
+ /** 蓝牙设备 id */
183
+ deviceId: string
184
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
185
+ complete?: (res: TaroGeneral.BluetoothError) => void
186
+ /** 接口调用失败的回调函数 */
187
+ fail?: (res: TaroGeneral.BluetoothError) => void
188
+ /** 接口调用成功的回调函数 */
189
+ success?: (
190
+ result: SuccessCallbackResult,
191
+ ) => void
192
+ }
193
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
194
+ /** 设备服务列表 */
195
+ services: BLEService[]
196
+ /** 成功:ok,错误:详细信息 */
197
+ errMsg: string
198
+ }
199
+ /** 设备服务列表 */
200
+ interface BLEService {
201
+ /** 该服务是否为主服务 */
202
+ isPrimary: boolean
203
+ /** 蓝牙设备服务的 uuid */
204
+ uuid: string
205
+ }
206
+ }
207
+
208
+ namespace getBLEDeviceRSSI {
209
+ interface Option {
210
+ /** 蓝牙设备 id */
211
+ deviceId: string
212
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
213
+ complete?: (res: TaroGeneral.BluetoothError) => void
214
+ /** 接口调用失败的回调函数 */
215
+ fail?: (res: TaroGeneral.BluetoothError) => void
216
+ /** 接口调用成功的回调函数 */
217
+ success?: (
218
+ result: SuccessCallbackResult,
219
+ ) => void
220
+ }
221
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
222
+ /** 信号强度,单位 dBm */
223
+ RSSI: number
224
+ }
225
+ }
226
+
227
+ namespace getBLEDeviceCharacteristics {
228
+ interface Option {
229
+ /** 蓝牙设备 id */
230
+ deviceId: string
231
+ /** 蓝牙服务 uuid,需要使用 `getBLEDeviceServices` 获取 */
232
+ serviceId: string
233
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
234
+ complete?: (res: TaroGeneral.BluetoothError) => void
235
+ /** 接口调用失败的回调函数 */
236
+ fail?: (res: TaroGeneral.BluetoothError) => void
237
+ /** 接口调用成功的回调函数 */
238
+ success?: (res: SuccessCallbackResult) => void
239
+ }
240
+ interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
241
+ /** 设备特征值列表 */
242
+ characteristics: BLECharacteristic[]
243
+ /** 成功:ok,错误:详细信息 */
244
+ errMsg: string
245
+ }
246
+ /** 设备特征值列表 */
247
+ interface BLECharacteristic {
248
+ /** 该特征值支持的操作类型 */
249
+ properties: Properties
250
+ /** 蓝牙设备特征值的 uuid */
251
+ uuid: string
252
+ }
253
+ /** 该特征值支持的操作类型 */
254
+ interface Properties {
255
+ /** 该特征值是否支持 indicate 操作 */
256
+ indicate: boolean
257
+ /** 该特征值是否支持 notify 操作 */
258
+ notify: boolean
259
+ /** 该特征值是否支持 read 操作 */
260
+ read: boolean
261
+ /** 该特征值是否支持 write 操作 */
262
+ write: boolean
263
+ /** 该特征是否支持无回复写操作 */
264
+ writeNoResponse: boolean
265
+ /** 该特征是否支持有回复写操作 */
266
+ writeDefault: boolean
267
+ }
268
+ }
269
+
270
+ namespace createBLEConnection {
271
+ interface Promised extends TaroGeneral.BluetoothError {
272
+ /** 成功:ok,错误:详细信息 */
273
+ errMsg: string
274
+ }
275
+ interface Option {
276
+ /** 用于区分设备的 id */
277
+ deviceId: string
278
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
279
+ complete?: (res: TaroGeneral.BluetoothError) => void
280
+ /** 接口调用失败的回调函数 */
281
+ fail?: (res: TaroGeneral.BluetoothError) => void
282
+ /** 接口调用成功的回调函数 */
283
+ success?: (res: TaroGeneral.BluetoothError) => void
284
+ /** 超时时间,单位ms,不填表示不会超时 */
285
+ timeout?: number
286
+ }
287
+ }
288
+
289
+ namespace closeBLEConnection {
290
+ interface Promised extends TaroGeneral.BluetoothError {
291
+ /** 成功:ok,错误:详细信息 */
292
+ errMsg: string
293
+ }
294
+ interface Option {
295
+ /** 用于区分设备的 id */
296
+ deviceId: string
297
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
298
+ complete?: (res: TaroGeneral.BluetoothError) => void
299
+ /** 接口调用失败的回调函数 */
300
+ fail?: (res: TaroGeneral.BluetoothError) => void
301
+ /** 接口调用成功的回调函数 */
302
+ success?: (res: TaroGeneral.BluetoothError) => void
303
+ }
304
+ }
305
+
306
+ interface TaroStatic {
307
+ /** 向低功耗蓝牙设备特征值中写入二进制数据。注意:必须设备的特征值支持 write 才可以成功调用。
308
+ *
309
+ * **注意**
310
+ * - 并行调用多次会存在写失败的可能性。
311
+ * - 小程序不会对写入数据包大小做限制,但系统与蓝牙设备会限制蓝牙4.0单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过20字节。
312
+ * - 若单次写入数据过长,iOS 上存在系统不会有任何回调的情况(包括错误回调)。
313
+ * - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误
314
+ * @supported weapp, alipay, jd
315
+ * @example
316
+ * ```tsx
317
+ * // 向蓝牙设备发送一个0x00的16进制数据
318
+ * let buffer = new ArrayBuffer(1)
319
+ * let dataView = new DataView(buffer)
320
+ * dataView.setUint8(0, 0)
321
+ * Taro.writeBLECharacteristicValue({
322
+ * // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
323
+ * deviceId,
324
+ * // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
325
+ * serviceId,
326
+ * // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
327
+ * characteristicId,
328
+ * // 这里的value是ArrayBuffer类型
329
+ * value: buffer,
330
+ * success: function (res) {
331
+ * console.log('writeBLECharacteristicValue success', res.errMsg)
332
+ * }
333
+ * })
334
+ * ```
335
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html
336
+ */
337
+ writeBLECharacteristicValue(
338
+ option: writeBLECharacteristicValue.Option,
339
+ ): Promise<writeBLECharacteristicValue.Promised>
340
+
341
+ /** 协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU)
342
+ *
343
+ * - 需在 Taro.createBLEConnection 调用成功后调用
344
+ * - 仅安卓系统 5.1 以上版本有效,iOS 因系统限制不支持。
345
+ * @supported weapp, alipay, jd
346
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html
347
+ */
348
+ setBLEMTU(
349
+ option: setBLEMTU.Option,
350
+ ): Promise<setBLEMTU.Promised>
351
+
352
+ /** 读取低功耗蓝牙设备的特征值的二进制数据值。注意:必须设备的特征值支持 read 才可以成功调用。
353
+ *
354
+ * **注意**
355
+ * - 并行调用多次会存在读失败的可能性。
356
+ * - 接口读取到的信息需要在 `onBLECharacteristicValueChange` 方法注册的回调中获取。
357
+ * @supported weapp, alipay, jd
358
+ * @example
359
+ * ```tsx
360
+ * // 必须在这里的回调才能获取
361
+ * Taro.onBLECharacteristicValueChange(function(characteristic) {
362
+ * console.log('characteristic value comed:', characteristic)
363
+ * })
364
+ * Taro.readBLECharacteristicValue({
365
+ * // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
366
+ * deviceId,
367
+ * // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
368
+ * serviceId,
369
+ * // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
370
+ * characteristicId,
371
+ * success: function (res) {
372
+ * console.log('readBLECharacteristicValue:', res.errCode)
373
+ * }
374
+ * })
375
+ * ```
376
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.readBLECharacteristicValue.html
377
+ */
378
+ readBLECharacteristicValue(
379
+ option: readBLECharacteristicValue.Option,
380
+ ): Promise<TaroGeneral.BluetoothError>
381
+
382
+ /** 监听蓝牙低功耗的最大传输单元变化事件(仅安卓触发)
383
+ * @supported weapp
384
+ * @example
385
+ * ```tsx
386
+ * Taro.onBLEMTUChange(function (res) {
387
+ * console.log('bluetooth mtu is', res.mtu)
388
+ * })
389
+ * ```
390
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEMTUChange.html
391
+ */
392
+ onBLEMTUChange(
393
+ /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
394
+ callback: onBLEMTUChange.Callback,
395
+ ): void
396
+
397
+ /** 监听低功耗蓝牙连接状态的改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等
398
+ * @supported weapp, alipay, jd
399
+ * @example
400
+ * ```tsx
401
+ * Taro.onBLEConnectionStateChange(function (res) {
402
+ * // 该方法回调中可以用于处理连接意外断开等异常情况
403
+ * console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
404
+ * })
405
+ * ```
406
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEConnectionStateChange.html
407
+ */
408
+ onBLEConnectionStateChange(
409
+ /** 低功耗蓝牙连接状态的改变事件的回调函数 */
410
+ callback: onBLEConnectionStateChange.Callback,
411
+ ): void
412
+
413
+ /** 监听低功耗蓝牙设备的特征值变化事件。必须先启用 `notifyBLECharacteristicValueChange` 接口才能接收到设备推送的 notification。
414
+ * @supported weapp, alipay, jd
415
+ * @example
416
+ * ```tsx
417
+ * // ArrayBuffer转16进制字符串示例
418
+ * function ab2hex(buffer) {
419
+ * let hexArr = Array.prototype.map.call(
420
+ * new Uint8Array(buffer),
421
+ * function(bit) {
422
+ * return ('00' + bit.toString(16)).slice(-2)
423
+ * }
424
+ * )
425
+ * return hexArr.join('');
426
+ * }
427
+ * Taro.onBLECharacteristicValueChange(function (res) {
428
+ * console.log(`characteristic ${res.characteristicId} has changed, now is ${res.value}`)
429
+ * console.log(ab2hex(res.value))
430
+ * })
431
+ * ```
432
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLECharacteristicValueChange.html
433
+ */
434
+ onBLECharacteristicValueChange(
435
+ /** 低功耗蓝牙设备的特征值变化事件的回调函数 */
436
+ callback: onBLECharacteristicValueChange.Callback,
437
+ ): void
438
+
439
+ /** 取消监听蓝牙低功耗的最大传输单元变化事件
440
+ * @supported weapp
441
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEMTUChange.html
442
+ */
443
+ offBLEMTUChange(
444
+ /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */
445
+ callback?: onBLEMTUChange.Callback,
446
+ ): void
447
+
448
+ /** 取消监听蓝牙低功耗连接状态的改变事件
449
+ * @supported weapp, alipay
450
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html
451
+ */
452
+ offBLEConnectionStateChange(
453
+ /** 蓝牙低功耗连接状态的改变事件的回调函数 */
454
+ callback?: onBLEConnectionStateChange.Callback,
455
+ ): void
456
+
457
+ /** 取消监听蓝牙低功耗设备的特征值变化事件
458
+ * @supported weapp, alipay
459
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html
460
+ */
461
+ offBLECharacteristicValueChange(
462
+ /** 低功耗蓝牙设备的特征值变化事件的回调函数 */
463
+ callback: onBLECharacteristicValueChange.Callback,
464
+ ): void
465
+
466
+ /** 启用低功耗蓝牙设备特征值变化时的 notify 功能,订阅特征值。注意:必须设备的特征值支持 notify 或者 indicate 才可以成功调用。
467
+ *
468
+ * 另外,必须先启用 `notifyBLECharacteristicValueChange` 才能监听到设备 `characteristicValueChange` 事件
469
+ *
470
+ * **注意**
471
+ * - 订阅操作成功后需要设备主动更新特征值的 value,才会触发 Taro.onBLECharacteristicValueChange 回调。
472
+ * - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误
473
+ * @supported weapp, alipay, jd
474
+ * @example
475
+ * ```tsx
476
+ * Taro.notifyBLECharacteristicValueChange({
477
+ * state: true, // 启用 notify 功能
478
+ * // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
479
+ * deviceId,
480
+ * // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
481
+ * serviceId,
482
+ * // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
483
+ * characteristicId,
484
+ * success: function (res) {
485
+ * console.log('notifyBLECharacteristicValueChange success', res.errMsg)
486
+ * }
487
+ * })
488
+ * ```
489
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.notifyBLECharacteristicValueChange.html
490
+ */
491
+ notifyBLECharacteristicValueChange(
492
+ option: notifyBLECharacteristicValueChange.Option,
493
+ ): Promise<notifyBLECharacteristicValueChange.Promised>
494
+
495
+ /** 获取蓝牙低功耗的最大传输单元。需在 [Taro.createBLEConnection](/docs/apis/device/bluetooth-ble/createBLEConnection) 调用成功后调用。
496
+ *
497
+ * 注意:
498
+ * - 小程序中 MTU 为 ATT_MTU,包含 Op-Code 和 Attribute Handle 的长度,实际可以传输的数据长度为 ATT_MTU - 3
499
+ * - iOS 系统中 MTU 为固定值;安卓系统中,MTU 会在系统协商成功之后发生改变,建议使用 [Taro.onBLEMTUChange](/docs/apis/device/bluetooth-ble/onBLEMTUChange) 监听。
500
+ * @supported weapp, alipay, jd
501
+ * @example
502
+ * ```tsx
503
+ * Taro.getBLEMTU({
504
+ * deviceId: '',
505
+ * writeType: 'write',
506
+ * success (res) {
507
+ * console.log(res)
508
+ * }
509
+ * })
510
+ * ```
511
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEMTU.html
512
+ */
513
+ getBLEMTU(
514
+ option: getBLEMTU.Option,
515
+ ): Promise<getBLEMTU.SuccessCallbackResult>
516
+
517
+ /** 获取蓝牙设备所有服务(service)。
518
+ * @supported weapp, alipay, jd
519
+ * @example
520
+ * ```tsx
521
+ * Taro.getBLEDeviceServices({
522
+ * // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
523
+ * deviceId,
524
+ * success: function (res) {
525
+ * console.log('device services:', res.services)
526
+ * }
527
+ * })
528
+ * ```
529
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceServices.html
530
+ */
531
+ getBLEDeviceServices(
532
+ option: getBLEDeviceServices.Option,
533
+ ): Promise<getBLEDeviceServices.SuccessCallbackResult>
534
+
535
+ /** 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。
536
+ * @supported weapp, alipay, jd
537
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html
538
+ */
539
+ getBLEDeviceRSSI(
540
+ option: getBLEDeviceRSSI.Option,
541
+ ): Promise<getBLEDeviceRSSI.SuccessCallbackResult>
542
+
543
+ /** 获取蓝牙设备某个服务中所有特征值(characteristic)。
544
+ * @supported weapp, alipay, jd
545
+ * @example
546
+ * ```tsx
547
+ * Taro.getBLEDeviceCharacteristics({
548
+ * // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
549
+ * deviceId,
550
+ * // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
551
+ * serviceId,
552
+ * success: function (res) {
553
+ * console.log('device getBLEDeviceCharacteristics:', res.characteristics)
554
+ * }
555
+ * })
556
+ * ```
557
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceCharacteristics.html
558
+ */
559
+ getBLEDeviceCharacteristics(
560
+ option: getBLEDeviceCharacteristics.Option,
561
+ ): Promise<getBLEDeviceCharacteristics.SuccessCallbackResult>
562
+
563
+ /** 连接低功耗蓝牙设备。
564
+ *
565
+ * 若小程序在之前已有搜索过某个蓝牙设备,并成功建立连接,可直接传入之前搜索获取的 deviceId 直接尝试连接该设备,无需进行搜索操作。
566
+ *
567
+ * **注意**
568
+ * - 请保证尽量成对的调用 `createBLEConnection` 和 `closeBLEConnection` 接口。安卓如果多次调用 `createBLEConnection` 创建连接,有可能导致系统持有同一设备多个连接的实例,导致调用 `closeBLEConnection` 的时候并不能真正的断开与设备的连接。
569
+ * - 蓝牙连接随时可能断开,建议监听 Taro.onBLEConnectionStateChange 回调事件,当蓝牙设备断开时按需执行重连操作
570
+ * - 若对未连接的设备或已断开连接的设备调用数据读写操作的接口,会返回 10006 错误,建议进行重连操作。
571
+ * @supported weapp, alipay, jd
572
+ * @example
573
+ * ```tsx
574
+ * Taro.createBLEConnection({
575
+ * // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
576
+ * deviceId,
577
+ * success: function (res) {
578
+ * console.log(res)
579
+ * }
580
+ * })
581
+ * ```
582
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html
583
+ */
584
+ createBLEConnection(option: createBLEConnection.Option): Promise<createBLEConnection.Promised>
585
+
586
+ /** 断开与低功耗蓝牙设备的连接。
587
+ * @supported weapp, alipay, jd
588
+ * @example
589
+ * ```tsx
590
+ * Taro.closeBLEConnection({
591
+ * deviceId,
592
+ * success: function (res) {
593
+ * console.log(res)
594
+ * }
595
+ * })
596
+ * ```
597
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.closeBLEConnection.html
598
+ */
599
+ closeBLEConnection(option: closeBLEConnection.Option): Promise<closeBLEConnection.Promised>
600
+ }
601
+ }