@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.
- package/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
4
|
+
namespace onBLEPeripheralConnectionStateChanged {
|
|
5
|
+
/** 当前外围设备被连接或断开连接事件的回调函数 */
|
|
6
|
+
type Callback = (
|
|
7
|
+
result: CallbackResult,
|
|
8
|
+
) => void
|
|
9
|
+
|
|
10
|
+
interface CallbackResult {
|
|
11
|
+
/** 蓝牙设备 id */
|
|
12
|
+
deviceId: string
|
|
13
|
+
/** server 的 UUID */
|
|
14
|
+
serverId: string
|
|
15
|
+
/** 连接目前状态 */
|
|
16
|
+
connected: boolean
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
namespace createBLEPeripheralServer {
|
|
21
|
+
interface Option {
|
|
22
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
23
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
24
|
+
/** 接口调用失败的回调函数 */
|
|
25
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
26
|
+
/** 接口调用成功的回调函数 */
|
|
27
|
+
success?: (res: SuccessCallbackResult) => void
|
|
28
|
+
}
|
|
29
|
+
interface SuccessCallbackResult extends TaroGeneral.BluetoothError {
|
|
30
|
+
/** 外围设备的服务端 */
|
|
31
|
+
server: BLEPeripheralServer
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 外围设备的服务端
|
|
36
|
+
* @supported weapp
|
|
37
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.html
|
|
38
|
+
*/
|
|
39
|
+
interface BLEPeripheralServer {
|
|
40
|
+
/** 添加服务
|
|
41
|
+
* @supported weapp, jd
|
|
42
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.addService.html
|
|
43
|
+
*/
|
|
44
|
+
addService(option: BLEPeripheralServer.addService.Option): Promise<TaroGeneral.BluetoothError>
|
|
45
|
+
/** 关闭当前服务端
|
|
46
|
+
* @supported weapp
|
|
47
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.close.html
|
|
48
|
+
*/
|
|
49
|
+
close(option: BLEPeripheralServer.close.Option): Promise<TaroGeneral.BluetoothError>
|
|
50
|
+
/** 取消监听已连接的设备请求读当前外围设备的特征值事件
|
|
51
|
+
* @supported weapp, jd
|
|
52
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicReadRequest.html
|
|
53
|
+
*/
|
|
54
|
+
offCharacteristicReadRequest(
|
|
55
|
+
/** 已连接的设备请求读当前外围设备的特征值事件的回调函数 */
|
|
56
|
+
callback?: BLEPeripheralServer.onCharacteristicReadRequest.Callback,
|
|
57
|
+
): void
|
|
58
|
+
/** 取消监听特征订阅事件
|
|
59
|
+
* @supported weapp, jd
|
|
60
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicSubscribed.html
|
|
61
|
+
*/
|
|
62
|
+
offCharacteristicSubscribed(
|
|
63
|
+
/** 特征订阅事件的回调函数 */
|
|
64
|
+
callback?: BLEPeripheralServer.onCharacteristicSubscribed.Callback,
|
|
65
|
+
): void
|
|
66
|
+
/** 取消监听取消特征订阅事件
|
|
67
|
+
* @supported weapp
|
|
68
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicUnsubscribed.html
|
|
69
|
+
*/
|
|
70
|
+
offCharacteristicUnsubscribed(
|
|
71
|
+
/** 取消特征订阅事件的回调函数 */
|
|
72
|
+
callback?: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback,
|
|
73
|
+
): void
|
|
74
|
+
/** 取消监听已连接的设备请求写当前外围设备的特征值事件
|
|
75
|
+
* @supported weapp, jd
|
|
76
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicWriteRequest.html
|
|
77
|
+
*/
|
|
78
|
+
offCharacteristicWriteRequest(
|
|
79
|
+
/** 已连接的设备请求写当前外围设备的特征值事件的回调函数 */
|
|
80
|
+
callback?: BLEPeripheralServer.onCharacteristicWriteRequest.Callback,
|
|
81
|
+
): void
|
|
82
|
+
/** 监听已连接的设备请求读当前外围设备的特征值事件
|
|
83
|
+
*
|
|
84
|
+
* 收到该消息后需要立刻调用 [writeCharacteristicValue](/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer#writecharacteristicvalue) 写回数据,否则主机不会收到响应。
|
|
85
|
+
* @supported weapp, jd
|
|
86
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicReadRequest.html
|
|
87
|
+
*/
|
|
88
|
+
onCharacteristicReadRequest(
|
|
89
|
+
/** 已连接的设备请求读当前外围设备的特征值事件的回调函数 */
|
|
90
|
+
callback: BLEPeripheralServer.onCharacteristicReadRequest.Callback,
|
|
91
|
+
): void
|
|
92
|
+
/** 监听特征订阅事件,仅 iOS 支持
|
|
93
|
+
* @supported weapp, jd
|
|
94
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicSubscribed.html
|
|
95
|
+
*/
|
|
96
|
+
onCharacteristicSubscribed(
|
|
97
|
+
/** 特征订阅事件的回调函数 */
|
|
98
|
+
callback: BLEPeripheralServer.onCharacteristicSubscribed.Callback,
|
|
99
|
+
): void
|
|
100
|
+
/** 监听取消特征订阅事件,仅 iOS 支持
|
|
101
|
+
* @supported weapp, jd
|
|
102
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicUnsubscribed.html
|
|
103
|
+
*/
|
|
104
|
+
onCharacteristicUnsubscribed(
|
|
105
|
+
/** 取消特征订阅事件的回调函数 */
|
|
106
|
+
callback: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback,
|
|
107
|
+
): void
|
|
108
|
+
/** 监听已连接的设备请求写当前外围设备的特征值事件
|
|
109
|
+
* @supported weapp, jd
|
|
110
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicWriteRequest.html
|
|
111
|
+
*/
|
|
112
|
+
onCharacteristicWriteRequest(
|
|
113
|
+
/** 已连接的设备请求写当前外围设备的特征值事件的回调函数 */
|
|
114
|
+
callback: BLEPeripheralServer.onCharacteristicWriteRequest.Callback,
|
|
115
|
+
): void
|
|
116
|
+
/** 移除服务
|
|
117
|
+
* @supported weapp, jd
|
|
118
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.removeService.html
|
|
119
|
+
*/
|
|
120
|
+
removeService(option: BLEPeripheralServer.removeService.Option): Promise<TaroGeneral.BluetoothError>
|
|
121
|
+
/** 开始广播本地创建的外围设备
|
|
122
|
+
* @supported weapp, jd
|
|
123
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.startAdvertising.html
|
|
124
|
+
*/
|
|
125
|
+
startAdvertising(option: BLEPeripheralServer.startAdvertising.Option): Promise<TaroGeneral.BluetoothError>
|
|
126
|
+
/** 停止广播
|
|
127
|
+
* @supported weapp, jd
|
|
128
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.stopAdvertising.html
|
|
129
|
+
*/
|
|
130
|
+
stopAdvertising(option: BLEPeripheralServer.stopAdvertising.Option): Promise<TaroGeneral.BluetoothError>
|
|
131
|
+
/** 往指定特征写入二进制数据值,并通知已连接的主机,从机的特征值已发生变化,该接口会处理是走回包还是走订阅
|
|
132
|
+
* @supported weapp, jd
|
|
133
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html
|
|
134
|
+
*/
|
|
135
|
+
writeCharacteristicValue(option: BLEPeripheralServer.writeCharacteristicValue.Option): Promise<TaroGeneral.BluetoothError>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
namespace BLEPeripheralServer {
|
|
139
|
+
namespace addService {
|
|
140
|
+
interface Option {
|
|
141
|
+
/** 描述 service 的 Object */
|
|
142
|
+
service: service
|
|
143
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
144
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
145
|
+
/** 接口调用失败的回调函数 */
|
|
146
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
147
|
+
/** 接口调用成功的回调函数 */
|
|
148
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
149
|
+
}
|
|
150
|
+
interface service {
|
|
151
|
+
/** 蓝牙服务的 UUID */
|
|
152
|
+
uuid: string
|
|
153
|
+
/** characteristics 列表 */
|
|
154
|
+
characteristics: characteristic[]
|
|
155
|
+
}
|
|
156
|
+
interface characteristic {
|
|
157
|
+
/** characteristic 的 UUID */
|
|
158
|
+
uuid: string
|
|
159
|
+
/** 特征支持的操作 */
|
|
160
|
+
properties?: properties
|
|
161
|
+
/** 特征权限 */
|
|
162
|
+
permission?: characteristicPermission
|
|
163
|
+
/** 特征对应的二进制值 */
|
|
164
|
+
value?: ArrayBuffer
|
|
165
|
+
/** 描述符数据 */
|
|
166
|
+
descriptors?: descriptor[]
|
|
167
|
+
}
|
|
168
|
+
/** 特征支持的操作 */
|
|
169
|
+
interface properties {
|
|
170
|
+
/** 写
|
|
171
|
+
* @default false
|
|
172
|
+
*/
|
|
173
|
+
write?: boolean
|
|
174
|
+
/** 无回复写
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
writeNoResponse?: boolean
|
|
178
|
+
/** 读
|
|
179
|
+
* @default false
|
|
180
|
+
*/
|
|
181
|
+
read?: boolean
|
|
182
|
+
/** 订阅
|
|
183
|
+
* @default false
|
|
184
|
+
*/
|
|
185
|
+
notify?: boolean
|
|
186
|
+
/** 回包
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
indicate?: boolean
|
|
190
|
+
}
|
|
191
|
+
/** 特征权限 */
|
|
192
|
+
interface characteristicPermission {
|
|
193
|
+
/** 可读
|
|
194
|
+
* @default false
|
|
195
|
+
*/
|
|
196
|
+
readable?: boolean
|
|
197
|
+
/** 可写
|
|
198
|
+
* @default false
|
|
199
|
+
*/
|
|
200
|
+
writeable?: boolean
|
|
201
|
+
/** 加密读请求
|
|
202
|
+
* @default false
|
|
203
|
+
*/
|
|
204
|
+
readEncryptionRequired?: boolean
|
|
205
|
+
/** 加密写请求
|
|
206
|
+
* @default false
|
|
207
|
+
*/
|
|
208
|
+
writeEncryptionRequired?: boolean
|
|
209
|
+
}
|
|
210
|
+
/** 描述符数据 */
|
|
211
|
+
interface descriptor {
|
|
212
|
+
/** Descriptor 的 UUID */
|
|
213
|
+
uuid: string
|
|
214
|
+
/** 描述符的权限 */
|
|
215
|
+
permission?: descriptorPermission
|
|
216
|
+
/** 描述符数据 */
|
|
217
|
+
value: ArrayBuffer
|
|
218
|
+
}
|
|
219
|
+
/** 描述符的权限 */
|
|
220
|
+
interface descriptorPermission {
|
|
221
|
+
/** 写
|
|
222
|
+
* @default false
|
|
223
|
+
*/
|
|
224
|
+
write?: boolean
|
|
225
|
+
/** 读
|
|
226
|
+
* @default false
|
|
227
|
+
*/
|
|
228
|
+
read?: boolean
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
namespace close {
|
|
232
|
+
interface Option {
|
|
233
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
234
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
235
|
+
/** 接口调用失败的回调函数 */
|
|
236
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
237
|
+
/** 接口调用成功的回调函数 */
|
|
238
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
namespace onCharacteristicReadRequest {
|
|
242
|
+
/** 已连接的设备请求读当前外围设备的特征值事件的回调函数 */
|
|
243
|
+
type Callback = (
|
|
244
|
+
result: CallbackResult,
|
|
245
|
+
) => void
|
|
246
|
+
|
|
247
|
+
interface CallbackResult {
|
|
248
|
+
/** 蓝牙特征对应服务的 UUID */
|
|
249
|
+
serviceId: string
|
|
250
|
+
/** 蓝牙特征的 UUID */
|
|
251
|
+
characteristicId: string
|
|
252
|
+
/** 唯一标识码,调用 [writeCharacteristicValue](/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer#writecharacteristicvalue) 时使用 */
|
|
253
|
+
callbackId: number
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
namespace onCharacteristicSubscribed {
|
|
257
|
+
/** 特征订阅事件的回调函数 */
|
|
258
|
+
type Callback = (
|
|
259
|
+
result: CallbackResult,
|
|
260
|
+
) => void
|
|
261
|
+
|
|
262
|
+
interface CallbackResult {
|
|
263
|
+
/** 蓝牙特征对应服务的 UUID */
|
|
264
|
+
serviceId: string
|
|
265
|
+
/** 蓝牙特征的 UUID */
|
|
266
|
+
characteristicId: string
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
namespace onCharacteristicUnsubscribed {
|
|
270
|
+
/** 取消特征订阅事件的回调函数 */
|
|
271
|
+
type Callback = (
|
|
272
|
+
result: CallbackResult,
|
|
273
|
+
) => void
|
|
274
|
+
|
|
275
|
+
interface CallbackResult {
|
|
276
|
+
/** 蓝牙特征对应服务的 UUID */
|
|
277
|
+
serviceId: string
|
|
278
|
+
/** 蓝牙特征的 UUID */
|
|
279
|
+
characteristicId: string
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
namespace onCharacteristicWriteRequest {
|
|
283
|
+
/** 已连接的设备请求写当前外围设备的特征值事件的回调函数 */
|
|
284
|
+
type Callback = (
|
|
285
|
+
result: CallbackResult,
|
|
286
|
+
) => void
|
|
287
|
+
|
|
288
|
+
interface CallbackResult {
|
|
289
|
+
/** 蓝牙特征对应服务的 UUID */
|
|
290
|
+
serviceId: string
|
|
291
|
+
/** 蓝牙特征的 UUID */
|
|
292
|
+
characteristicId: string
|
|
293
|
+
/** 唯一标识码,调用 [writeCharacteristicValue](/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer#writecharacteristicvalue) 时使用 */
|
|
294
|
+
callbackId: number
|
|
295
|
+
/** 请求写入特征的二进制数据值 */
|
|
296
|
+
value: ArrayBuffer
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
namespace removeService {
|
|
300
|
+
interface Option {
|
|
301
|
+
/** service 的 UUID */
|
|
302
|
+
serviceId: string
|
|
303
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
304
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
305
|
+
/** 接口调用失败的回调函数 */
|
|
306
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
307
|
+
/** 接口调用成功的回调函数 */
|
|
308
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
namespace startAdvertising {
|
|
312
|
+
interface Option {
|
|
313
|
+
/** 广播自定义参数 */
|
|
314
|
+
advertiseRequest: advertiseRequest
|
|
315
|
+
/** 广播功率
|
|
316
|
+
* @default "medium"
|
|
317
|
+
*/
|
|
318
|
+
powerLevel?: keyof PowerLevel
|
|
319
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
320
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
321
|
+
/** 接口调用失败的回调函数 */
|
|
322
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
323
|
+
/** 接口调用成功的回调函数 */
|
|
324
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
325
|
+
}
|
|
326
|
+
/** 广播自定义参数 */
|
|
327
|
+
interface advertiseRequest {
|
|
328
|
+
/** 当前设备是否可连接
|
|
329
|
+
* @default true
|
|
330
|
+
*/
|
|
331
|
+
connectable?: boolean
|
|
332
|
+
/** 广播中 deviceName 字段,默认为空
|
|
333
|
+
* @default ""
|
|
334
|
+
*/
|
|
335
|
+
deviceName?: string
|
|
336
|
+
/** 要广播的服务 UUID 列表。使用 16/32 位 UUID 时请参考注意事项。 */
|
|
337
|
+
serviceUuids?: string[]
|
|
338
|
+
/** 广播的制造商信息。仅安卓支持,iOS 因系统限制无法定制。 */
|
|
339
|
+
manufacturerData?: manufacturerData[]
|
|
340
|
+
/** 以 beacon 设备形式广播的参数。 */
|
|
341
|
+
beacon?: beacon
|
|
342
|
+
}
|
|
343
|
+
/** 广播的制造商信息。仅安卓支持,iOS 因系统限制无法定制。 */
|
|
344
|
+
interface manufacturerData {
|
|
345
|
+
/** 制造商ID,0x 开头的十六进制 */
|
|
346
|
+
manufacturerId: string
|
|
347
|
+
/** 制造商信息 */
|
|
348
|
+
manufacturerSpecificData?: ArrayBuffer
|
|
349
|
+
}
|
|
350
|
+
/** 以 beacon 设备形式广播的参数。 */
|
|
351
|
+
interface beacon {
|
|
352
|
+
/** Beacon 设备广播的 UUID */
|
|
353
|
+
uuid: string
|
|
354
|
+
/** Beacon 设备的主 ID */
|
|
355
|
+
major: number
|
|
356
|
+
/** Beacon 设备的次 ID */
|
|
357
|
+
minor: number
|
|
358
|
+
/** 用于判断距离设备 1 米时 RSSI 大小的参考值 */
|
|
359
|
+
measuredPower?: number
|
|
360
|
+
}
|
|
361
|
+
/** 广播功率合法值 */
|
|
362
|
+
interface PowerLevel {
|
|
363
|
+
/** 功率低 */
|
|
364
|
+
low
|
|
365
|
+
/** 功率适中 */
|
|
366
|
+
medium
|
|
367
|
+
/** 功率高 */
|
|
368
|
+
high
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
namespace stopAdvertising {
|
|
372
|
+
interface Option {
|
|
373
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
374
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
375
|
+
/** 接口调用失败的回调函数 */
|
|
376
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
377
|
+
/** 接口调用成功的回调函数 */
|
|
378
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
namespace writeCharacteristicValue {
|
|
382
|
+
interface Option {
|
|
383
|
+
/** 蓝牙特征对应服务的 UUID */
|
|
384
|
+
serviceId: string
|
|
385
|
+
/** 蓝牙特征的 UUID */
|
|
386
|
+
characteristicId: string
|
|
387
|
+
/** characteristic 对应的二进制值 */
|
|
388
|
+
value: ArrayBuffer
|
|
389
|
+
/** 是否需要通知主机 value 已更新 */
|
|
390
|
+
needNotify: boolean
|
|
391
|
+
/** 可选,处理回包时使用 */
|
|
392
|
+
callbackId?: number
|
|
393
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
394
|
+
complete?: (res: TaroGeneral.BluetoothError) => void
|
|
395
|
+
/** 接口调用失败的回调函数 */
|
|
396
|
+
fail?: (res: TaroGeneral.BluetoothError) => void
|
|
397
|
+
/** 接口调用成功的回调函数 */
|
|
398
|
+
success?: (res: TaroGeneral.BluetoothError) => void
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
interface TaroStatic {
|
|
404
|
+
/** 监听当前外围设备被连接或断开连接事件
|
|
405
|
+
* @supported weapp, jd
|
|
406
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.onBLEPeripheralConnectionStateChanged.html
|
|
407
|
+
*/
|
|
408
|
+
onBLEPeripheralConnectionStateChanged(
|
|
409
|
+
/** 监听当前外围设备被连接或断开连接事件 */
|
|
410
|
+
callback: onBLEPeripheralConnectionStateChanged.Callback,
|
|
411
|
+
): void
|
|
412
|
+
|
|
413
|
+
/** 取消监听当前外围设备被连接或断开连接事件
|
|
414
|
+
* @supported weapp, jd
|
|
415
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.offBLEPeripheralConnectionStateChanged.html
|
|
416
|
+
*/
|
|
417
|
+
offBLEPeripheralConnectionStateChanged(
|
|
418
|
+
/** 当前外围设备被连接或断开连接事件的回调函数 */
|
|
419
|
+
callback?: onBLEPeripheralConnectionStateChanged.Callback,
|
|
420
|
+
): void
|
|
421
|
+
|
|
422
|
+
/** 建立本地作为蓝牙低功耗外围设备的服务端,可创建多个
|
|
423
|
+
* @supported weapp, jd
|
|
424
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.createBLEPeripheralServer.html
|
|
425
|
+
*/
|
|
426
|
+
createBLEPeripheralServer(
|
|
427
|
+
option: createBLEPeripheralServer.Option,
|
|
428
|
+
): Promise<createBLEPeripheralServer.SuccessCallbackResult>
|
|
429
|
+
}
|
|
430
|
+
}
|