• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback, Callback } from './basic';
17
18/**
19 * Provides methods to operate or manage Bluetooth.
20 * @namespace bluetoothManager
21 * @syscap SystemCapability.Communication.Bluetooth.Core
22 * @since 9
23 */
24declare namespace bluetoothManager {
25    /**
26     * Obtains the Bluetooth status of a device.
27     *
28     * @permission ohos.permission.USE_BLUETOOTH
29     * @returns { BluetoothState } Returns the Bluetooth status, which can be {@link BluetoothState#STATE_OFF},
30     * {@link BluetoothState#STATE_TURNING_ON}, {@link BluetoothState#STATE_ON}, {@link BluetoothState#STATE_TURNING_OFF},
31     * {@link BluetoothState#STATE_BLE_TURNING_ON}, {@link BluetoothState#STATE_BLE_ON},
32     * or {@link BluetoothState#STATE_BLE_TURNING_OFF}.
33     * @throws { BusinessError } 201 - Permission denied.
34     * @throws { BusinessError } 801 - Capability not supported.
35     * @throws { BusinessError } 2900001 - Service stopped.
36     * @throws { BusinessError } 2900099 - Operation failed.
37     * @since 9
38     */
39    function getState(): BluetoothState;
40
41    /**
42     * Get the local device connection state to any profile of any remote device.
43     *
44     * @permission ohos.permission.USE_BLUETOOTH
45     * @returns { ProfileConnectionState } One of {@link ProfileConnectionState#STATE_DISCONNECTED},
46     * {@link ProfileConnectionState#STATE_CONNECTING}, {@link ProfileConnectionState#STATE_CONNECTED},
47     * {@link ProfileConnectionState#STATE_DISCONNECTING}.
48     * @throws { BusinessError } 201 - Permission denied.
49     * @throws { BusinessError } 801 - Capability not supported.
50     * @throws { BusinessError } 2900001 - Service stopped.
51     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
52     * @throws { BusinessError } 2900099 - Operation failed.
53     * @since 9
54     */
55    function getBtConnectionState(): ProfileConnectionState;
56
57    /**
58     * Starts pairing with a remote Bluetooth device.
59     *
60     * @permission ohos.permission.DISCOVER_BLUETOOTH
61     * @param deviceId The address of the remote device to pair.
62     * @throws { BusinessError } 201 - Permission denied.
63     * @throws { BusinessError } 401 - Invalid parameter.
64     * @throws { BusinessError } 801 - Capability not supported.
65     * @throws { BusinessError } 2900001 - Service stopped.
66     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
67     * @throws { BusinessError } 2900099 - Operation failed.
68     * @since 9
69     */
70    function pairDevice(deviceId: string): void;
71
72    /**
73     * Remove a paired remote device.
74     *
75     * @permission ohos.permission.DISCOVER_BLUETOOTH
76     * @param deviceId The address of the remote device to be removed.
77     * @throws { BusinessError } 201 - Permission denied.
78     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
79     * @throws { BusinessError } 401 - Invalid parameter.
80     * @throws { BusinessError } 801 - Capability not supported.
81     * @throws { BusinessError } 2900001 - Service stopped.
82     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
83     * @throws { BusinessError } 2900099 - Operation failed.
84     * @systemapi Hide this for inner system use.
85     * @since 9
86     */
87    function cancelPairedDevice(deviceId: string): void;
88
89    /**
90     * Obtains the name of a peer Bluetooth device.
91     *
92     * @permission ohos.permission.USE_BLUETOOTH
93     * @param deviceId The address of the remote device.
94     * @returns { string } Returns the device name in character string format.
95     * @throws { BusinessError } 201 - Permission denied.
96     * @throws { BusinessError } 401 - Invalid parameter.
97     * @throws { BusinessError } 801 - Capability not supported.
98     * @throws { BusinessError } 2900001 - Service stopped.
99     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
100     * @throws { BusinessError } 2900099 - Operation failed.
101     * @since 9
102     */
103    function getRemoteDeviceName(deviceId: string): string;
104
105    /**
106     * Obtains the class of a peer Bluetooth device.
107     *
108     * @permission ohos.permission.USE_BLUETOOTH
109     * @param deviceId The address of the remote device.
110     * @returns { DeviceClass } The class of the remote device, {@link DeviceClass}.
111     * @throws { BusinessError } 201 - Permission denied.
112     * @throws { BusinessError } 401 - Invalid parameter.
113     * @throws { BusinessError } 801 - Capability not supported.
114     * @throws { BusinessError } 2900001 - Service stopped.
115     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
116     * @throws { BusinessError } 2900099 - Operation failed.
117     * @since 9
118     */
119    function getRemoteDeviceClass(deviceId: string): DeviceClass;
120
121    /**
122     * Enables Bluetooth on a device.
123     *
124     * @permission ohos.permission.DISCOVER_BLUETOOTH
125     * @throws { BusinessError } 201 - Permission denied.
126     * @throws { BusinessError } 801 - Capability not supported.
127     * @throws { BusinessError } 2900001 - Service stopped.
128     * @throws { BusinessError } 2900099 - Operation failed.
129     * @since 9
130     */
131    function enableBluetooth(): void;
132
133    /**
134     * Disables Bluetooth on a device.
135     *
136     * @permission ohos.permission.DISCOVER_BLUETOOTH
137     * @throws { BusinessError } 201 - Permission denied.
138     * @throws { BusinessError } 801 - Capability not supported.
139     * @throws { BusinessError } 2900001 - Service stopped.
140     * @throws { BusinessError } 2900099 - Operation failed.
141     * @since 9
142     */
143    function disableBluetooth(): void;
144
145    /**
146     * Obtains the Bluetooth local name of a device.
147     *
148     * @permission ohos.permission.USE_BLUETOOTH
149     * @returns { string } Returns the name the device.
150     * @throws { BusinessError } 201 - Permission denied.
151     * @throws { BusinessError } 801 - Capability not supported.
152     * @throws { BusinessError } 2900001 - Service stopped.
153     * @throws { BusinessError } 2900099 - Operation failed.
154     * @since 9
155     */
156    function getLocalName(): string;
157
158    /**
159     * Obtains the list of Bluetooth devices that have been paired with the current device.
160     *
161     * @permission ohos.permission.USE_BLUETOOTH
162     * @returns { Array<string> } Returns a list of paired Bluetooth devices's address.
163     * @throws { BusinessError } 201 - Permission denied.
164     * @throws { BusinessError } 801 - Capability not supported.
165     * @throws { BusinessError } 2900001 - Service stopped.
166     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
167     * @throws { BusinessError } 2900099 - Operation failed.
168     * @since 9
169     */
170    function getPairedDevices(): Array<string>;
171
172    /**
173     * Obtains the connection state of profile.
174     *
175     * @permission ohos.permission.USE_BLUETOOTH
176     * @param profileId The profile id.
177     * @returns { ProfileConnectionState } Returns the connection state.
178     * @throws { BusinessError } 201 - Permission denied.
179     * @throws { BusinessError } 401 - Invalid parameter.
180     * @throws { BusinessError } 801 - Capability not supported.
181     * @throws { BusinessError } 2900001 - Service stopped.
182     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
183     * @throws { BusinessError } 2900004 - Profile is not supported.
184     * @throws { BusinessError } 2900099 - Operation failed.
185     * @since 9
186     */
187    function getProfileConnectionState(profileId: ProfileId): ProfileConnectionState;
188
189    /**
190     * Sets the confirmation of pairing with a certain device.
191     *
192     * @permission ohos.permission.MANAGE_BLUETOOTH
193     * @param device The address of the remote device.
194     * @param accept Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise.
195     * @throws { BusinessError } 201 - Permission denied.
196     * @throws { BusinessError } 401 - Invalid parameter.
197     * @throws { BusinessError } 801 - Capability not supported.
198     * @throws { BusinessError } 2900001 - Service stopped.
199     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
200     * @throws { BusinessError } 2900099 - Operation failed.
201     * @since 9
202     */
203    function setDevicePairingConfirmation(device: string, accept: boolean): void;
204
205    /**
206     * Sets the Bluetooth friendly name of a device.
207     *
208     * @permission ohos.permission.DISCOVER_BLUETOOTH
209     * @param name Indicates a valid Bluetooth name.
210     * @throws { BusinessError } 201 - Permission denied.
211     * @throws { BusinessError } 401 - Invalid parameter.
212     * @throws { BusinessError } 801 - Capability not supported.
213     * @throws { BusinessError } 2900001 - Service stopped.
214     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
215     * @throws { BusinessError } 2900099 - Operation failed.
216     * @since 9
217     */
218    function setLocalName(name: string): void;
219
220    /**
221     * Sets the Bluetooth scan mode for a device.
222     *
223     * @permission ohos.permission.USE_BLUETOOTH
224     * @param mode Indicates the Bluetooth scan mode to set, {@link ScanMode}.
225     * @param duration Indicates the duration in seconds, in which the host is discoverable.
226     * @throws { BusinessError } 201 - Permission denied.
227     * @throws { BusinessError } 401 - Invalid parameter.
228     * @throws { BusinessError } 801 - Capability not supported.
229     * @throws { BusinessError } 2900001 - Service stopped.
230     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
231     * @throws { BusinessError } 2900099 - Operation failed.
232     * @since 9
233     */
234    function setBluetoothScanMode(mode: ScanMode, duration: number): void;
235
236    /**
237     * Obtains the Bluetooth scanning mode of a device.
238     *
239     * @permission ohos.permission.USE_BLUETOOTH
240     * @returns { ScanMode } Returns the Bluetooth scanning mode, {@link ScanMode}.
241     * @throws { BusinessError } 201 - Permission denied.
242     * @throws { BusinessError } 801 - Capability not supported.
243     * @throws { BusinessError } 2900001 - Service stopped.
244     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
245     * @throws { BusinessError } 2900099 - Operation failed.
246     * @since 9
247     */
248    function getBluetoothScanMode(): ScanMode;
249
250    /**
251     * Starts scanning Bluetooth devices.
252     *
253     * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
254     *     and ohos.permission.APPROXIMATELY_LOCATION
255     * @throws { BusinessError } 201 - Permission denied.
256     * @throws { BusinessError } 801 - Capability not supported.
257     * @throws { BusinessError } 2900001 - Service stopped.
258     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
259     * @throws { BusinessError } 2900099 - Operation failed.
260     * @since 9
261     */
262    function startBluetoothDiscovery(): void;
263
264    /**
265     * Stops Bluetooth device scanning.
266     *
267     * @permission ohos.permission.DISCOVER_BLUETOOTH
268     * @throws { BusinessError } 201 - Permission denied.
269     * @throws { BusinessError } 801 - Capability not supported.
270     * @throws { BusinessError } 2900001 - Service stopped.
271     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
272     * @throws { BusinessError } 2900099 - Operation failed.
273     * @since 9
274     */
275    function stopBluetoothDiscovery(): void;
276
277    /**
278     * Subscribe the event reported when a remote Bluetooth device is discovered.
279     *
280     * @permission ohos.permission.USE_BLUETOOTH
281     * @param type Type of the discovering event to listen for.
282     * @param callback Callback used to listen for the discovering event.
283     * @throws { BusinessError } 201 - Permission denied.
284     * @throws { BusinessError } 401 - Invalid parameter.
285     * @throws { BusinessError } 801 - Capability not supported.
286     * @throws { BusinessError } 2900099 - Operation failed.
287     * @since 9
288     */
289    function on(type: "bluetoothDeviceFind", callback: Callback<Array<string>>): void;
290
291    /**
292     * Unsubscribe the event reported when a remote Bluetooth device is discovered.
293     *
294     * @permission ohos.permission.USE_BLUETOOTH
295     * @param type Type of the discovering event to listen for.
296     * @param callback Callback used to listen for the discovering event.
297     * @throws { BusinessError } 201 - Permission denied.
298     * @throws { BusinessError } 801 - Capability not supported.
299     * @throws { BusinessError } 2900099 - Operation failed.
300     * @since 9
301     */
302    function off(type: "bluetoothDeviceFind", callback?: Callback<Array<string>>): void;
303
304    /**
305     * Subscribe the event reported when a remote Bluetooth device is bonded.
306     *
307     * @permission ohos.permission.USE_BLUETOOTH
308     * @param type Type of the bond state event to listen for.
309     * @param callback Callback used to listen for the bond state event, {@link BondStateParam}.
310     * @throws { BusinessError } 201 - Permission denied.
311     * @throws { BusinessError } 401 - Invalid parameter.
312     * @throws { BusinessError } 801 - Capability not supported.
313     * @throws { BusinessError } 2900099 - Operation failed.
314     * @since 9
315     */
316    function on(type: "bondStateChange", callback: Callback<BondStateParam>): void;
317
318    /**
319     * Unsubscribe the event reported when a remote Bluetooth device is bonded.
320     *
321     * @permission ohos.permission.USE_BLUETOOTH
322     * @param type Type of the bond state event to listen for.
323     * @param callback Callback used to listen for the bond state event.
324     * @throws { BusinessError } 201 - Permission denied.
325     * @throws { BusinessError } 401 - Invalid parameter.
326     * @throws { BusinessError } 801 - Capability not supported.
327     * @throws { BusinessError } 2900099 - Operation failed.
328     * @since 9
329     */
330    function off(type: "bondStateChange", callback?: Callback<BondStateParam>): void;
331
332    /**
333     * Subscribe the event of a pairing request from a remote Bluetooth device.
334     *
335     * @permission ohos.permission.DISCOVER_BLUETOOTH
336     * @param type Type of the pairing request event to listen for.
337     * @param callback Callback used to listen for the pairing request event.
338     * @throws { BusinessError } 201 - Permission denied.
339     * @throws { BusinessError } 401 - Invalid parameter.
340     * @throws { BusinessError } 801 - Capability not supported.
341     * @throws { BusinessError } 2900099 - Operation failed.
342     * @since 9
343     */
344    function on(type: "pinRequired", callback: Callback<PinRequiredParam>): void;
345
346    /**
347     * Unsubscribe the event of a pairing request from a remote Bluetooth device.
348     *
349     * @permission ohos.permission.DISCOVER_BLUETOOTH
350     * @param type Type of the pairing request event to listen for.
351     * @param callback Callback used to listen for the pairing request event.
352     * @throws { BusinessError } 201 - Permission denied.
353     * @throws { BusinessError } 401 - Invalid parameter.
354     * @throws { BusinessError } 801 - Capability not supported.
355     * @throws { BusinessError } 2900099 - Operation failed.
356     * @since 9
357     */
358    function off(type: "pinRequired", callback?: Callback<PinRequiredParam>): void;
359
360    /**
361     * Subscribe the event reported when the Bluetooth state changes.
362     *
363     * @permission ohos.permission.USE_BLUETOOTH
364     * @param type Type of the Bluetooth state changes event to listen for.
365     * @param callback Callback used to listen for the Bluetooth state event.
366     * @throws { BusinessError } 201 - Permission denied.
367     * @throws { BusinessError } 401 - Invalid parameter.
368     * @throws { BusinessError } 801 - Capability not supported.
369     * @throws { BusinessError } 2900099 - Operation failed.
370     * @since 9
371     */
372    function on(type: "stateChange", callback: Callback<BluetoothState>): void;
373
374    /**
375     * Unsubscribe the event reported when the Bluetooth state changes.
376     *
377     * @permission ohos.permission.USE_BLUETOOTH
378     * @param type Type of the Bluetooth state changes event to listen for.
379     * @param callback Callback used to listen for the Bluetooth state event.
380     * @throws { BusinessError } 201 - Permission denied.
381     * @throws { BusinessError } 401 - Invalid parameter.
382     * @throws { BusinessError } 801 - Capability not supported.
383     * @throws { BusinessError } 2900099 - Operation failed.
384     * @since 9
385     */
386    function off(type: "stateChange", callback?: Callback<BluetoothState>): void;
387
388    /**
389     * Creates a Bluetooth server listening socket.
390     *
391     * @permission ohos.permission.USE_BLUETOOTH
392     * @param name Indicates the service name.
393     * @param option Indicates the listen parameters {@link SppOption}.
394     * @param callback Callback used to return a server socket ID.
395     * @throws { BusinessError } 201 - Permission denied.
396     * @throws { BusinessError } 401 - Invalid parameter.
397     * @throws { BusinessError } 801 - Capability not supported.
398     * @throws { BusinessError } 2900001 - Service stopped.
399     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
400     * @throws { BusinessError } 2900004 - Profile is not supported.
401     * @throws { BusinessError } 2900099 - Operation failed.
402     * @since 9
403     */
404    function sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void;
405
406    /**
407     * Waits for a remote device to connect.
408     *
409     * @param serverSocket Indicates the server socket ID, returned by {@link sppListen}.
410     * @param callback Callback used to return a client socket ID.
411     * @throws { BusinessError } 401 - Invalid parameter.
412     * @throws { BusinessError } 801 - Capability not supported.
413     * @throws { BusinessError } 2900001 - Service stopped.
414     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
415     * @throws { BusinessError } 2900004 - Profile is not supported.
416     * @throws { BusinessError } 2900099 - Operation failed.
417     * @since 9
418     */
419    function sppAccept(serverSocket: number, callback: AsyncCallback<number>): void;
420
421    /**
422     * Connects to a remote device over the socket.
423     *
424     * @permission ohos.permission.USE_BLUETOOTH
425     * @param device The address of the remote device to connect.
426     * @param option Indicates the connect parameters {@link SppOption}.
427     * @param callback Callback used to return a client socket ID.
428     * @throws { BusinessError } 201 - Permission denied.
429     * @throws { BusinessError } 401 - Invalid parameter.
430     * @throws { BusinessError } 801 - Capability not supported.
431     * @throws { BusinessError } 2900001 - Service stopped.
432     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
433     * @throws { BusinessError } 2900004 - Profile is not supported.
434     * @throws { BusinessError } 2900099 - Operation failed.
435     * @since 9
436     */
437    function sppConnect(device: string, option: SppOption, callback: AsyncCallback<number>): void;
438
439    /**
440     * Disables an spp server socket and releases related resources.
441     *
442     * @param socket Indicates the server socket ID, returned by {@link sppListen}.
443     * @throws { BusinessError } 401 - Invalid parameter.
444     * @throws { BusinessError } 801 - Capability not supported.
445     * @throws { BusinessError } 2900001 - Service stopped.
446     * @throws { BusinessError } 2900099 - Operation failed.
447     * @since 9
448     */
449    function sppCloseServerSocket(socket: number): void;
450
451    /**
452     * Disables an spp client socket and releases related resources.
453     *
454     * @param socket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}.
455     * @throws { BusinessError } 401 - Invalid parameter.
456     * @throws { BusinessError } 801 - Capability not supported.
457     * @throws { BusinessError } 2900001 - Service stopped.
458     * @throws { BusinessError } 2900099 - Operation failed.
459     * @since 9
460     */
461    function sppCloseClientSocket(socket: number): void;
462
463    /**
464     * Write data through the socket.
465     *
466     * @param clientSocket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}.
467     * @param data Indicates the data to write.
468     * @throws { BusinessError } 401 - Invalid parameter.
469     * @throws { BusinessError } 801 - Capability not supported.
470     * @throws { BusinessError } 2901054 - IO error.
471     * @throws { BusinessError } 2900099 - Operation failed.
472     * @since 9
473     */
474    function sppWrite(clientSocket: number, data: ArrayBuffer): void;
475
476    /**
477     * Subscribe the event reported when data is read from the socket.
478     *
479     * @param type Type of the spp read event to listen for.
480     * @param callback Callback used to listen for the spp read event.
481     * @throws { BusinessError } 401 - Invalid parameter.
482     * @throws { BusinessError } 801 - Capability not supported.
483     * @throws { BusinessError } 2901054 - IO error.
484     * @throws { BusinessError } 2900099 - Operation failed.
485     * @since 9
486     */
487    function on(type: "sppRead", clientSocket: number, callback: Callback<ArrayBuffer>): void;
488
489    /**
490     * Unsubscribe the event reported when data is read from the socket.
491     *
492     * @param type Type of the spp read event to listen for.
493     * @param callback Callback used to listen for the spp read event.
494     * @throws { BusinessError } 401 - Invalid parameter.
495     * @throws { BusinessError } 801 - Capability not supported.
496     * @since 9
497     */
498    function off(type: "sppRead", clientSocket: number, callback?: Callback<ArrayBuffer>): void;
499
500    /**
501     * Obtains the instance of profile.
502     *
503     * @param profileId The profile id..
504     * @returns { A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile } Returns the instance of profile.
505     * @throws { BusinessError } 401 - Invalid parameter.
506     * @throws { BusinessError } 801 - Capability not supported.
507     * @since 9
508     */
509    function getProfileInstance(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile;
510
511    /**
512     * Base interface of profile.
513     */
514    interface BaseProfile {
515        /**
516         * Obtains the connected devices list of profile.
517         *
518         * @permission ohos.permission.USE_BLUETOOTH
519         * @returns { Array<string> } Returns the address of connected devices list.
520         * @throws { BusinessError } 201 - Permission denied.
521         * @throws { BusinessError } 801 - Capability not supported.
522         * @throws { BusinessError } 2900001 - Service stopped.
523         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
524         * @throws { BusinessError } 2900004 - Profile is not supported.
525         * @throws { BusinessError } 2900099 - Operation failed.
526         * @since 9
527         */
528        getConnectionDevices(): Array<string>;
529
530        /**
531         * Obtains the profile state of device.
532         *
533         * @permission ohos.permission.USE_BLUETOOTH
534         * @param device The address of bluetooth device.
535         * @returns { ProfileConnectionState } Returns {@link ProfileConnectionState} of device.
536         * @throws { BusinessError } 201 - Permission denied.
537         * @throws { BusinessError } 401 - Invalid parameter.
538         * @throws { BusinessError } 801 - Capability not supported.
539         * @throws { BusinessError } 2900001 - Service stopped.
540         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
541         * @throws { BusinessError } 2900004 - Profile is not supported.
542         * @throws { BusinessError } 2900099 - Operation failed.
543         * @since 9
544         */
545        getDeviceState(device: string): ProfileConnectionState;
546    }
547
548    /**
549     * Manager a2dp source profile.
550     */
551    interface A2dpSourceProfile extends BaseProfile {
552        /**
553         * Connect to device with a2dp.
554         *
555         * @permission ohos.permission.DISCOVER_BLUETOOTH
556         * @param device The address of the remote device to connect.
557         * @throws { BusinessError } 201 - Permission denied.
558         * @throws { BusinessError } 401 - Invalid parameter.
559         * @throws { BusinessError } 801 - Capability not supported.
560         * @throws { BusinessError } 2900001 - Service stopped.
561         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
562         * @throws { BusinessError } 2900004 - Profile is not supported.
563         * @throws { BusinessError } 2900099 - Operation failed.
564         * @since 9
565         */
566        connect(device: string): void;
567
568        /**
569         * Disconnect to device with a2dp.
570         *
571         * @permission ohos.permission.DISCOVER_BLUETOOTH
572         * @param device The address of the remote device to disconnect.
573         * @throws { BusinessError } 201 - Permission denied.
574         * @throws { BusinessError } 401 - Invalid parameter.
575         * @throws { BusinessError } 801 - Capability not supported.
576         * @throws { BusinessError } 2900001 - Service stopped.
577         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
578         * @throws { BusinessError } 2900004 - Profile is not supported.
579         * @throws { BusinessError } 2900099 - Operation failed.
580         * @since 9
581         */
582        disconnect(device: string): void;
583
584        /**
585         * Subscribe the event reported when the profile connection state changes .
586         *
587         * @param type Type of the profile connection state changes event to listen for .
588         * @param callback Callback used to listen for event.
589         * @throws { BusinessError } 401 - Invalid parameter.
590         * @throws { BusinessError } 801 - Capability not supported.
591         * @since 9
592         */
593        on(type: "connectionStateChange", callback: Callback<StateChangeParam>): void;
594
595        /**
596         * Unsubscribe the event reported when the profile connection state changes .
597         *
598         * @param type Type of the profile connection state changes event to listen for .
599         * @param callback Callback used to listen for event.
600         * @throws { BusinessError } 401 - Invalid parameter.
601         * @throws { BusinessError } 801 - Capability not supported.
602         * @since 9
603         */
604        off(type: "connectionStateChange", callback?: Callback<StateChangeParam>): void;
605
606        /**
607         * Obtains the playing state of device.
608         *
609         * @param device The address of the remote device.
610         * @returns { PlayingState } Returns {@link PlayingState} of the remote device.
611         * @throws { BusinessError } 401 - Invalid parameter.
612         * @throws { BusinessError } 801 - Capability not supported.
613         * @throws { BusinessError } 2900001 - Service stopped.
614         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
615         * @throws { BusinessError } 2900004 - Profile is not supported.
616         * @throws { BusinessError } 2900099 - Operation failed.
617         * @since 9
618         */
619        getPlayingState(device: string): PlayingState;
620    }
621
622    /**
623     * Manager handsfree AG profile.
624     */
625    interface HandsFreeAudioGatewayProfile extends BaseProfile {
626        /**
627         * Connect to device with hfp.
628         *
629         * @permission ohos.permission.DISCOVER_BLUETOOTH
630         * @param device The address of the remote device to connect.
631         * @throws { BusinessError } 201 - Permission denied.
632         * @throws { BusinessError } 401 - Invalid parameter.
633         * @throws { BusinessError } 801 - Capability not supported.
634         * @throws { BusinessError } 2900001 - Service stopped.
635         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
636         * @throws { BusinessError } 2900004 - Profile is not supported.
637         * @throws { BusinessError } 2900099 - Operation failed.
638         * @since 9
639         */
640        connect(device: string): void;
641
642        /**
643         * Disconnect to device with hfp.
644         *
645         * @permission ohos.permission.DISCOVER_BLUETOOTH
646         * @param device The address of the remote device to disconnect.
647         * @throws { BusinessError } 201 - Permission denied.
648         * @throws { BusinessError } 401 - Invalid parameter.
649         * @throws { BusinessError } 801 - Capability not supported.
650         * @throws { BusinessError } 2900001 - Service stopped.
651         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
652         * @throws { BusinessError } 2900004 - Profile is not supported.
653         * @throws { BusinessError } 2900099 - Operation failed.
654         * @since 9
655         */
656        disconnect(device: string): void;
657
658        /**
659         * Subscribe the event reported when the profile connection state changes .
660         *
661         * @param type Type of the profile connection state changes event to listen for .
662         * @param callback Callback used to listen for event.
663         * @throws { BusinessError } 401 - Invalid parameter.
664         * @throws { BusinessError } 801 - Capability not supported.
665         * @since 9
666         */
667        on(type: "connectionStateChange", callback: Callback<StateChangeParam>): void;
668
669        /**
670         * Unsubscribe the event reported when the profile connection state changes .
671         *
672         * @param type Type of the profile connection state changes event to listen for .
673         * @param callback Callback used to listen for event.
674         * @throws { BusinessError } 401 - Invalid parameter.
675         * @throws { BusinessError } 801 - Capability not supported.
676         * @since 9
677         */
678        off(type: "connectionStateChange", callback?: Callback<StateChangeParam>): void;
679    }
680
681    /**
682     * Manager hid host profile.
683     */
684    interface HidHostProfile extends BaseProfile {
685        /**
686         * Connect to device with hid host.
687         *
688         * @permission ohos.permission.DISCOVER_BLUETOOTH
689         * @param device The address of the remote device to connect.
690         * @throws { BusinessError } 201 - Permission denied.
691         * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
692         * @throws { BusinessError } 401 - Invalid parameter.
693         * @throws { BusinessError } 801 - Capability not supported.
694         * @throws { BusinessError } 2900001 - Service stopped.
695         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
696         * @throws { BusinessError } 2900004 - Profile is not supported.
697         * @throws { BusinessError } 2900099 - Operation failed.
698         * @systemapi Hide this for inner system use.
699         * @since 9
700         */
701        connect(device: string): void;
702
703        /**
704         * Disconnect to device with hid host.
705         *
706         * @permission ohos.permission.DISCOVER_BLUETOOTH
707         * @param device The address of the remote device to disconnect.
708         * @throws { BusinessError } 201 - Permission denied.
709         * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
710         * @throws { BusinessError } 401 - Invalid parameter.
711         * @throws { BusinessError } 801 - Capability not supported.
712         * @throws { BusinessError } 2900001 - Service stopped.
713         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
714         * @throws { BusinessError } 2900004 - Profile is not supported.
715         * @throws { BusinessError } 2900099 - Operation failed.
716         * @systemapi Hide this for inner system use.
717         * @since 9
718         */
719        disconnect(device: string): void;
720
721        /**
722         * Subscribe the event reported when the profile connection state changes .
723         *
724         * @param type Type of the profile connection state changes event to listen for .
725         * @param callback Callback used to listen for event.
726         * @throws { BusinessError } 401 - Invalid parameter.
727         * @throws { BusinessError } 801 - Capability not supported.
728         * @since 9
729         */
730        on(type: "connectionStateChange", callback: Callback<StateChangeParam>): void;
731
732        /**
733         * Unsubscribe the event reported when the profile connection state changes.
734         *
735         * @param type Type of the profile connection state changes event to listen for.
736         * @param callback Callback used to listen for event.
737         * @throws { BusinessError } 401 - Invalid parameter.
738         * @throws { BusinessError } 801 - Capability not supported.
739         * @since 9
740         */
741        off(type: "connectionStateChange", callback?: Callback<StateChangeParam>): void;
742    }
743
744    /**
745     * Manager pan profile.
746     */
747    interface PanProfile extends BaseProfile {
748        /**
749         * Disconnect to device with pan.
750         *
751         * @permission ohos.permission.USE_BLUETOOTH
752         * @param device The address of the remote device to disconnect.
753         * @throws { BusinessError } 201 - Permission denied.
754         * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
755         * @throws { BusinessError } 401 - Invalid parameter.
756         * @throws { BusinessError } 801 - Capability not supported.
757         * @throws { BusinessError } 2900001 - Service stopped.
758         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
759         * @throws { BusinessError } 2900004 - Profile is not supported.
760         * @throws { BusinessError } 2900099 - Operation failed.
761         * @systemapi Hide this for inner system use.
762         * @since 9
763         */
764        disconnect(device: string): void;
765
766        /**
767         * Subscribe the event reported when the profile connection state changes .
768         *
769         * @param type Type of the profile connection state changes event to listen for .
770         * @param callback Callback used to listen for event.
771         * @throws { BusinessError } 401 - Invalid parameter.
772         * @throws { BusinessError } 801 - Capability not supported.
773         * @since 9
774         */
775        on(type: "connectionStateChange", callback: Callback<StateChangeParam>): void;
776
777        /**
778         * Unsubscribe the event reported when the profile connection state changes.
779         *
780         * @param type Type of the profile connection state changes event to listen for.
781         * @param callback Callback used to listen for event.
782         * @throws { BusinessError } 401 - Invalid parameter.
783         * @throws { BusinessError } 801 - Capability not supported.
784         * @since 9
785         */
786        off(type: "connectionStateChange", callback?: Callback<StateChangeParam>): void;
787
788        /**
789         * Enable bluetooth tethering.
790         *
791         * @permission ohos.permission.DISCOVER_BLUETOOTH
792         * @param enable Specifies whether to enable tethering. The value {@code true} indicates
793         * that tethering is enabled, and the value {@code false} indicates that tethering is disabled.
794         * @throws { BusinessError } 201 - Permission denied.
795         * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
796         * @throws { BusinessError } 401 - Invalid parameter.
797         * @throws { BusinessError } 801 - Capability not supported.
798         * @throws { BusinessError } 2900001 - Service stopped.
799         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
800         * @throws { BusinessError } 2900004 - Profile is not supported.
801         * @throws { BusinessError } 2900099 - Operation failed.
802         * @systemapi Hide this for inner system use.
803         * @since 9
804         */
805        setTethering(enable: boolean): void;
806
807        /**
808         * Obtains the tethering enable or disable.
809         *
810         * @returns { boolean } Returns the value {@code true} is tethering is on, returns {@code false} otherwise.
811         * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
812         * @throws { BusinessError } 801 - Capability not supported.
813         * @systemapi Hide this for inner system use.
814         * @since 9
815         */
816        isTetheringOn(): boolean;
817    }
818
819    namespace BLE {
820        /**
821         * create a JavaScript Gatt server instance.
822         *
823         * @returns { GattServer } Returns a JavaScript Gatt server instance {@code GattServer}.
824         * @since 9
825         */
826        function createGattServer(): GattServer;
827
828        /**
829         * create a JavaScript Gatt client device instance.
830         *
831         * @param deviceId The address of the remote device.
832         * @returns { GattClientDevice } Returns a JavaScript Gatt client device instance {@code GattClientDevice}.
833         * @since 9
834         * @throws { BusinessError } 401 - Invalid parameter.
835         * @throws { BusinessError } 801 - Capability not supported.
836         */
837        function createGattClientDevice(deviceId: string): GattClientDevice;
838
839        /**
840         * Obtains the list of devices in the connected status.
841         *
842         * @permission ohos.permission.USE_BLUETOOTH
843         * @returns { Array<string> } Returns the list of device address.
844         * @throws { BusinessError } 201 - Permission denied.
845         * @throws { BusinessError } 801 - Capability not supported.
846         * @throws { BusinessError } 2900001 - Service stopped.
847         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
848         * @throws { BusinessError } 2900099 - Operation failed.
849         * @since 9
850         */
851        function getConnectedBLEDevices(): Array<string>;
852
853        /**
854         * Starts scanning for specified BLE devices with filters.
855         *
856         * @permission ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH and ohos.permission.LOCATION
857         *     and ohos.permission.APPROXIMATELY_LOCATION
858         * @param filters Indicates the list of filters used to filter out specified devices.
859         * If you do not want to use filter, set this parameter to {@code null}.
860         * @param options Indicates the parameters for scanning and if the user does not assign a value, the default value will be used.
861         * {@link ScanOptions#interval} set to 0, {@link ScanOptions#dutyMode} set to {@link SCAN_MODE_LOW_POWER}
862         * and {@link ScanOptions#matchMode} set to {@link MATCH_MODE_AGGRESSIVE}.
863         * @throws { BusinessError } 201 - Permission denied.
864         * @throws { BusinessError } 401 - Invalid parameter.
865         * @throws { BusinessError } 801 - Capability not supported.
866         * @throws { BusinessError } 2900001 - Service stopped.
867         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
868         * @throws { BusinessError } 2900099 - Operation failed.
869         * @since 9
870         */
871        function startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void;
872
873        /**
874         * Stops BLE scanning.
875         *
876         * @since 9
877         * @permission ohos.permission.DISCOVER_BLUETOOTH
878         * @throws { BusinessError } 201 - Permission denied.
879         * @throws { BusinessError } 801 - Capability not supported.
880         * @throws { BusinessError } 2900001 - Service stopped.
881         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
882         * @throws { BusinessError } 2900099 - Operation failed.
883         */
884        function stopBLEScan(): void;
885
886        /**
887         * Subscribe BLE scan result.
888         *
889         * @permission ohos.permission.USE_BLUETOOTH
890         * @param type Type of the scan result event to listen for.
891         * @param callback Callback used to listen for the scan result event.
892         * @throws { BusinessError } 201 - Permission denied.
893         * @throws { BusinessError } 401 - Invalid parameter.
894         * @throws { BusinessError } 801 - Capability not supported.
895         * @throws { BusinessError } 2900099 - Operation failed.
896         * @since 9
897         */
898        function on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): void;
899
900        /**
901         * Unsubscribe BLE scan result.
902         *
903         * @permission ohos.permission.USE_BLUETOOTH
904         * @param type Type of the scan result event to listen for.
905         * @param callback Callback used to listen for the scan result event.
906         * @throws { BusinessError } 201 - Permission denied.
907         * @throws { BusinessError } 401 - Invalid parameter.
908         * @throws { BusinessError } 801 - Capability not supported.
909         * @throws { BusinessError } 2900099 - Operation failed.
910         * @since 9
911         */
912        function off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): void;
913    }
914
915    /**
916     * Manages GATT server. Before calling an Gatt server method, you must use {@link createGattServer} to create an GattServer instance.
917     */
918    interface GattServer {
919        /**
920         * Starts BLE advertising.
921         *
922         * @permission ohos.permission.DISCOVER_BLUETOOTH
923         * @param setting Indicates the settings for BLE advertising.
924         * If you need to use the default value, set this parameter to {@code null}.
925         * @param advData Indicates the advertising data.
926         * @param advResponse Indicates the scan response associated with the advertising data.
927         * @throws { BusinessError } 201 - Permission denied.
928         * @throws { BusinessError } 401 - Invalid parameter.
929         * @throws { BusinessError } 801 - Capability not supported.
930         * @throws { BusinessError } 2900001 - Service stopped.
931         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
932         * @throws { BusinessError } 2900099 - Operation failed.
933         * @since 9
934         */
935        startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void;
936
937        /**
938         * Stops BLE advertising.
939         *
940         * @permission ohos.permission.DISCOVER_BLUETOOTH
941         * @throws { BusinessError } 201 - Permission denied.
942         * @throws { BusinessError } 801 - Capability not supported.
943         * @throws { BusinessError } 2900001 - Service stopped.
944         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
945         * @throws { BusinessError } 2900099 - Operation failed.
946         * @since 9
947         */
948        stopAdvertising(): void;
949
950        /**
951         * Adds a specified service to be hosted.
952         *
953         * <p>The added service and its characteristics are provided by the local device.
954         *
955         * @permission ohos.permission.USE_BLUETOOTH
956         * @param service Indicates the service to add.
957         * @throws { BusinessError } 201 - Permission denied.
958         * @throws { BusinessError } 401 - Invalid parameter.
959         * @throws { BusinessError } 801 - Capability not supported.
960         * @throws { BusinessError } 2900001 - Service stopped.
961         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
962         * @throws { BusinessError } 2900099 - Operation failed.
963         * @since 9
964         */
965        addService(service: GattService): void;
966
967        /**
968         * Removes a specified service from the list of GATT services provided by this device.
969         *
970         * @permission ohos.permission.USE_BLUETOOTH
971         * @param serviceUuid Indicates the UUID of the service to remove.
972         * @throws { BusinessError } 201 - Permission denied.
973         * @throws { BusinessError } 401 - Invalid parameter.
974         * @throws { BusinessError } 801 - Capability not supported.
975         * @throws { BusinessError } 2900001 - Service stopped.
976         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
977         * @throws { BusinessError } 2900004 - Profile is not supported.
978         * @throws { BusinessError } 2900099 - Operation failed.
979         * @since 9
980         */
981        removeService(serviceUuid: string): void;
982
983        /**
984         * Closes this {@code GattServer} object and unregisters its callbacks.
985         *
986         * @permission ohos.permission.USE_BLUETOOTH
987         * @throws { BusinessError } 201 - Permission denied.
988         * @throws { BusinessError } 801 - Capability not supported.
989         * @throws { BusinessError } 2900001 - Service stopped.
990         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
991         * @throws { BusinessError } 2900099 - Operation failed.
992         * @since 9
993         */
994        close(): void;
995
996        /**
997         * Sends a notification of a change in a specified local characteristic.
998         *
999         * <p>This method should be called for every BLE peripheral device that has requested notifications.
1000         *
1001         * @permission ohos.permission.USE_BLUETOOTH
1002         * @param deviceId Indicates the address of the BLE peripheral device to receive the notification.
1003         * @param notifyCharacteristic Indicates the local characteristic that has changed.
1004         * @throws { BusinessError } 201 - Permission denied.
1005         * @throws { BusinessError } 401 - Invalid parameter.
1006         * @throws { BusinessError } 801 - Capability not supported.
1007         * @throws { BusinessError } 2900001 - Service stopped.
1008         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
1009         * @throws { BusinessError } 2900099 - Operation failed.
1010         * @since 9
1011         */
1012        notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): void;
1013
1014        /**
1015         * Sends a response to a specified read or write request to a given BLE peripheral device.
1016         *
1017         * @permission ohos.permission.USE_BLUETOOTH
1018         * @param serverResponse Indicates the response parameters {@link ServerResponse}.
1019         * @throws { BusinessError } 201 - Permission denied.
1020         * @throws { BusinessError } 401 - Invalid parameter.
1021         * @throws { BusinessError } 801 - Capability not supported.
1022         * @throws { BusinessError } 2900001 - Service stopped.
1023         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
1024         * @throws { BusinessError } 2900099 - Operation failed.
1025         * @since 9
1026         */
1027        sendResponse(serverResponse: ServerResponse): void;
1028
1029        /**
1030         * Subscribe characteristic read event.
1031         *
1032         * @permission ohos.permission.USE_BLUETOOTH
1033         * @param type Type of the characteristic read event to listen for.
1034         * @param callback Callback used to listen for the characteristic read event.
1035         * @throws { BusinessError } 201 - Permission denied.
1036         * @throws { BusinessError } 401 - Invalid parameter.
1037         * @throws { BusinessError } 801 - Capability not supported.
1038         * @since 9
1039         */
1040        on(type: "characteristicRead", callback: Callback<CharacteristicReadRequest>): void;
1041
1042        /**
1043         * Unsubscribe characteristic read event.
1044         *
1045         * @permission ohos.permission.USE_BLUETOOTH
1046         * @param type Type of the characteristic read event to listen for.
1047         * @param callback Callback used to listen for the characteristic read event.
1048         * @throws { BusinessError } 201 - Permission denied.
1049         * @throws { BusinessError } 401 - Invalid parameter.
1050         * @throws { BusinessError } 801 - Capability not supported.
1051         * @since 9
1052         */
1053        off(type: "characteristicRead", callback?: Callback<CharacteristicReadRequest>): void;
1054
1055        /**
1056         * Subscribe characteristic write event.
1057         *
1058         * @permission ohos.permission.USE_BLUETOOTH
1059         * @param type Type of the characteristic write event to listen for.
1060         * @param callback Callback used to listen for the characteristic write event.
1061         * @throws { BusinessError } 201 - Permission denied.
1062         * @throws { BusinessError } 401 - Invalid parameter.
1063         * @throws { BusinessError } 801 - Capability not supported.
1064         * @since 9
1065         */
1066        on(type: "characteristicWrite", callback: Callback<CharacteristicWriteRequest>): void;
1067
1068        /**
1069         * Unsubscribe characteristic write event.
1070         *
1071         * @permission ohos.permission.USE_BLUETOOTH
1072         * @param type Type of the characteristic write event to listen for.
1073         * @param callback Callback used to listen for the characteristic write event.
1074         * @throws { BusinessError } 201 - Permission denied.
1075         * @throws { BusinessError } 401 - Invalid parameter.
1076         * @throws { BusinessError } 801 - Capability not supported.
1077         * @since 9
1078         */
1079        off(type: "characteristicWrite", callback?: Callback<CharacteristicWriteRequest>): void;
1080
1081        /**
1082         * Subscribe descriptor read event.
1083         *
1084         * @permission ohos.permission.USE_BLUETOOTH
1085         * @param type Type of the descriptor read event to listen for.
1086         * @param callback Callback used to listen for the descriptor read event.
1087         * @throws { BusinessError } 201 - Permission denied.
1088         * @throws { BusinessError } 401 - Invalid parameter.
1089         * @throws { BusinessError } 801 - Capability not supported.
1090         * @since 9
1091         */
1092        on(type: "descriptorRead", callback: Callback<DescriptorReadRequest>): void;
1093
1094        /**
1095         * Unsubscribe descriptor read event.
1096         *
1097         * @permission ohos.permission.USE_BLUETOOTH
1098         * @param type Type of the descriptor read event to listen for.
1099         * @param callback Callback used to listen for the descriptor read event.
1100         * @throws { BusinessError } 201 - Permission denied.
1101         * @throws { BusinessError } 401 - Invalid parameter.
1102         * @throws { BusinessError } 801 - Capability not supported.
1103         * @since 9
1104         */
1105        off(type: "descriptorRead", callback?: Callback<DescriptorReadRequest>): void;
1106
1107        /**
1108         * Subscribe descriptor write event.
1109         *
1110         * @permission ohos.permission.USE_BLUETOOTH
1111         * @param type Type of the descriptor write event to listen for.
1112         * @param callback Callback used to listen for the descriptor write event.
1113         * @throws { BusinessError } 201 - Permission denied.
1114         * @throws { BusinessError } 401 - Invalid parameter.
1115         * @throws { BusinessError } 801 - Capability not supported.
1116         * @since 9
1117         */
1118        on(type: "descriptorWrite", callback: Callback<DescriptorWriteRequest>): void;
1119
1120        /**
1121         * Unsubscribe descriptor write event.
1122         *
1123         * @permission ohos.permission.USE_BLUETOOTH
1124         * @param type Type of the descriptor write event to listen for.
1125         * @param callback Callback used to listen for the descriptor write event.
1126         * @throws { BusinessError } 201 - Permission denied.
1127         * @throws { BusinessError } 401 - Invalid parameter.
1128         * @throws { BusinessError } 801 - Capability not supported.
1129         * @since 9
1130         */
1131        off(type: "descriptorWrite", callback?: Callback<DescriptorWriteRequest>): void;
1132
1133        /**
1134         * Subscribe server connection state changed event.
1135         *
1136         * @permission ohos.permission.USE_BLUETOOTH
1137         * @param type Type of the connection state changed event to listen for.
1138         * @param callback Callback used to listen for the connection state changed event.
1139         * @throws { BusinessError } 201 - Permission denied.
1140         * @throws { BusinessError } 401 - Invalid parameter.
1141         * @throws { BusinessError } 801 - Capability not supported.
1142         * @since 9
1143         */
1144        on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void;
1145
1146        /**
1147         * Unsubscribe server connection state changed event.
1148         *
1149         * @permission ohos.permission.USE_BLUETOOTH
1150         * @param type Type of the connection state changed event to listen for.
1151         * @param callback Callback used to listen for the connection state changed event.
1152         * @throws { BusinessError } 201 - Permission denied.
1153         * @throws { BusinessError } 401 - Invalid parameter.
1154         * @throws { BusinessError } 801 - Capability not supported.
1155         * @since 9
1156         */
1157        off(type: "connectStateChange", callback?: Callback<BLEConnectChangedState>): void;
1158    }
1159
1160    /**
1161     * Manages GATT client. Before calling an Gatt client method, you must use {@link createGattClientDevice} to create an GattClientDevice instance.
1162     */
1163    interface GattClientDevice {
1164
1165        /**
1166         * Connects to a BLE peripheral device.
1167         *
1168         * <p>The 'BLEConnectionStateChange' event is subscribed to return the connection state.
1169         *
1170         * @permission ohos.permission.USE_BLUETOOTH
1171         * @throws { BusinessError } 201 - Permission denied.
1172         * @throws { BusinessError } 801 - Capability not supported.
1173         * @throws { BusinessError } 2900001 - Service stopped.
1174         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
1175         * @throws { BusinessError } 2900099 - Operation failed.
1176         * @since 9
1177         */
1178        connect(): void;
1179
1180        /**
1181         * Disconnects from or stops an ongoing connection to a BLE peripheral device.
1182         *
1183         * @permission ohos.permission.USE_BLUETOOTH
1184         * @throws { BusinessError } 201 - Permission denied.
1185         * @throws { BusinessError } 801 - Capability not supported.
1186         * @throws { BusinessError } 2900001 - Service stopped.
1187         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
1188         * @throws { BusinessError } 2900099 - Operation failed.
1189         * @since 9
1190         */
1191        disconnect(): void;
1192
1193        /**
1194         * Disables a BLE peripheral device.
1195         *
1196         * <p> This method unregisters the device and clears the registered callbacks and handles.
1197         *
1198         * @permission ohos.permission.USE_BLUETOOTH
1199         * @returns { boolean } Returns {@code true} if the the device is disabled; returns {@code false} otherwise.
1200         * @throws { BusinessError } 201 - Permission denied.
1201         * @throws { BusinessError } 801 - Capability not supported.
1202         * @throws { BusinessError } 2900001 - Service stopped.
1203         * @throws { BusinessError } 2900003 - Bluetooth switch is off.
1204         * @throws { BusinessError } 2900099 - Operation failed.
1205         * @since 9
1206         */
1207        close(): void;
1208
1209        /**
1210         * Obtains the name of BLE peripheral device.
1211         *
1212         * @permission ohos.permission.USE_BLUETOOTH
1213         * @returns { Promise<string> } Returns a string representation of the name if obtained;
1214         * returns {@code null} if the name fails to be obtained or the name does not exist.
1215         * @throws { BusinessError } 201 - Permission denied.
1216         * @throws { BusinessError } 401 - Invalid parameter.
1217         * @throws { BusinessError } 801 - Capability not supported.
1218         * @throws { BusinessError } 2900001 - Service stopped.
1219         * @throws { BusinessError } 2900099 - Operation failed.
1220         * @since 9
1221         */
1222        getDeviceName(callback: AsyncCallback<string>): void;
1223        getDeviceName(): Promise<string>;
1224
1225        /**
1226         * Starts discovering services.
1227         *
1228         * @permission ohos.permission.USE_BLUETOOTH
1229         * @returns { Promise<Array<GattService>> } Returns the list of services {@link GattService} of the BLE peripheral device.
1230         * @throws { BusinessError } 201 - Permission denied.
1231         * @throws { BusinessError } 401 - Invalid parameter.
1232         * @throws { BusinessError } 801 - Capability not supported.
1233         * @throws { BusinessError } 2900001 - Service stopped.
1234         * @throws { BusinessError } 2900099 - Operation failed.
1235         * @since 9
1236         */
1237        getServices(callback: AsyncCallback<Array<GattService>>): void;
1238        getServices(): Promise<Array<GattService>>;
1239
1240        /**
1241         * Reads the characteristic of a BLE peripheral device.
1242         *
1243         * @permission ohos.permission.USE_BLUETOOTH
1244         * @param characteristic Indicates the characteristic to read.
1245         * @throws { BusinessError } 201 - Permission denied.
1246         * @throws { BusinessError } 401 - Invalid parameter.
1247         * @throws { BusinessError } 801 - Capability not supported.
1248         * @throws { BusinessError } 2900001 - Service stopped.
1249         * @throws { BusinessError } 2901000 - Read forbidden.
1250         * @throws { BusinessError } 2900099 - Operation failed.
1251         * @since 9
1252         */
1253        readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback<BLECharacteristic>): void;
1254        readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharacteristic>;
1255
1256        /**
1257         * Reads the descriptor of a BLE peripheral device.
1258         *
1259         * @permission ohos.permission.USE_BLUETOOTH
1260         * @param descriptor Indicates the descriptor to read.
1261         * @throws { BusinessError } 201 - Permission denied.
1262         * @throws { BusinessError } 401 - Invalid parameter.
1263         * @throws { BusinessError } 801 - Capability not supported.
1264         * @throws { BusinessError } 2900001 - Service stopped.
1265         * @throws { BusinessError } 2901000 - Read forbidden.
1266         * @throws { BusinessError } 2900099 - Operation failed.
1267         * @since 9
1268         */
1269        readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDescriptor>): void;
1270        readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor>;
1271
1272        /**
1273         * Writes the characteristic of a BLE peripheral device.
1274         *
1275         * @permission ohos.permission.USE_BLUETOOTH
1276         * @param characteristic Indicates the characteristic to write.
1277         * @throws { BusinessError } 201 - Permission denied.
1278         * @throws { BusinessError } 401 - Invalid parameter.
1279         * @throws { BusinessError } 801 - Capability not supported.
1280         * @throws { BusinessError } 2900001 - Service stopped.
1281         * @throws { BusinessError } 2901001 - Write forbidden.
1282         * @throws { BusinessError } 2900099 - Operation failed.
1283         * @since 9
1284         */
1285        writeCharacteristicValue(characteristic: BLECharacteristic): void;
1286
1287        /**
1288         * Writes the descriptor of a BLE peripheral device.
1289         *
1290         * @permission ohos.permission.USE_BLUETOOTH
1291         * @param descriptor Indicates the descriptor to write.
1292         * @throws { BusinessError } 201 - Permission denied.
1293         * @throws { BusinessError } 401 - Invalid parameter.
1294         * @throws { BusinessError } 801 - Capability not supported.
1295         * @throws { BusinessError } 2900001 - Service stopped.
1296         * @throws { BusinessError } 2901001 - Write forbidden.
1297         * @throws { BusinessError } 2900099 - Operation failed.
1298         * @since 9
1299         */
1300        writeDescriptorValue(descriptor: BLEDescriptor): void;
1301
1302        /**
1303         * Get the RSSI value of this BLE peripheral device.
1304         *
1305         * @permission ohos.permission.USE_BLUETOOTH
1306         * @returns { Promise<number> } Returns the RSSI value.
1307         * @throws { BusinessError } 201 - Permission denied.
1308         * @throws { BusinessError } 401 - Invalid parameter.
1309         * @throws { BusinessError } 801 - Capability not supported.
1310         * @throws { BusinessError } 2900099 - Operation failed.
1311         * @since 9
1312         */
1313        getRssiValue(callback: AsyncCallback<number>): void;
1314        getRssiValue(): Promise<number>;
1315
1316        /**
1317         * Set the mtu size of a BLE peripheral device.
1318         *
1319         * @permission ohos.permission.USE_BLUETOOTH
1320         * @param mtu The maximum transmission unit.
1321         * @throws { BusinessError } 201 - Permission denied.
1322         * @throws { BusinessError } 401 - Invalid parameter.
1323         * @throws { BusinessError } 801 - Capability not supported.
1324         * @throws { BusinessError } 2900001 - Service stopped.
1325         * @throws { BusinessError } 2900099 - Operation failed.
1326         * @since 9
1327         */
1328        setBLEMtuSize(mtu: number): void;
1329
1330        /**
1331         * Enables or disables notification of a characteristic when value changed.
1332         *
1333         * @permission ohos.permission.USE_BLUETOOTH
1334         * @param enable Specifies whether to enable notification of the characteristic. The value {@code true} indicates
1335         * that notification is enabled, and the value {@code false} indicates that notification is disabled.
1336         * @throws { BusinessError } 201 - Permission denied.
1337         * @throws { BusinessError } 401 - Invalid parameter.
1338         * @throws { BusinessError } 801 - Capability not supported.
1339         * @throws { BusinessError } 2900001 - Service stopped.
1340         * @throws { BusinessError } 2900099 - Operation failed.
1341         * @since 9
1342         */
1343        setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): void;
1344
1345        /**
1346         * Subscribe characteristic value changed event.
1347         *
1348         * @permission ohos.permission.USE_BLUETOOTH
1349         * @param type Type of the characteristic value changed event to listen for.
1350         * @param callback Callback used to listen for the characteristic value changed event.
1351         * @throws { BusinessError } 201 - Permission denied.
1352         * @throws { BusinessError } 801 - Capability not supported.
1353         * @since 9
1354         */
1355        on(type: "BLECharacteristicChange", callback: Callback<BLECharacteristic>): void;
1356
1357        /**
1358         * Unsubscribe characteristic value changed event.
1359         *
1360         * @permission ohos.permission.USE_BLUETOOTH
1361         * @param type Type of the characteristic value changed event to listen for.
1362         * @param callback Callback used to listen for the characteristic value changed event.
1363         * @throws { BusinessError } 201 - Permission denied.
1364         * @throws { BusinessError } 801 - Capability not supported.
1365         * @since 9
1366         */
1367        off(type: "BLECharacteristicChange", callback?: Callback<BLECharacteristic>): void;
1368
1369        /**
1370         * Subscribe client connection state changed event.
1371         *
1372         * @permission ohos.permission.USE_BLUETOOTH
1373         * @param type Type of the connection state changed event to listen for.
1374         * @param callback Callback used to listen for the connection state changed event.
1375         * @throws { BusinessError } 201 - Permission denied.
1376         * @throws { BusinessError } 801 - Capability not supported.
1377         * @since 9
1378         */
1379        on(type: "BLEConnectionStateChange", callback: Callback<BLEConnectChangedState>): void;
1380
1381        /**
1382         * Unsubscribe client connection state changed event.
1383         *
1384         * @permission ohos.permission.USE_BLUETOOTH
1385         * @param type Type of the connection state changed event to listen for.
1386         * @param callback Callback used to listen for the connection state changed event.
1387         * @throws { BusinessError } 201 - Permission denied.
1388         * @throws { BusinessError } 801 - Capability not supported.
1389         * @since 9
1390         */
1391        off(type: "BLEConnectionStateChange", callback?: Callback<BLEConnectChangedState>): void;
1392    }
1393
1394    /**
1395     * Describes the Gatt service.
1396     *
1397     * @since 9
1398     */
1399    interface GattService {
1400        /** The UUID of a GattService instance */
1401        serviceUuid: string;
1402        /** Indicates whether the GattService instance is primary or secondary. */
1403        isPrimary: boolean;
1404        /** The {@link BLECharacteristic} list belongs to this GattService instance */
1405        characteristics: Array<BLECharacteristic>;
1406        /** The list of GATT services contained in the service */
1407        includeServices?: Array<GattService>;
1408    }
1409
1410    /**
1411     * Describes the Gatt characteristic.
1412     *
1413     * @since 9
1414     */
1415    interface BLECharacteristic {
1416        /** The UUID of the {@link GattService} instance to which the characteristic belongs */
1417        serviceUuid: string;
1418        /** The UUID of a BLECharacteristic instance */
1419        characteristicUuid: string;
1420        /** The value of a BLECharacteristic instance */
1421        characteristicValue: ArrayBuffer;
1422        /** The list of {@link BLEDescriptor} contained in the characteristic */
1423        descriptors: Array<BLEDescriptor>;
1424    }
1425
1426    /**
1427     * Describes the Gatt descriptor.
1428     *
1429     * @since 9
1430     */
1431    interface BLEDescriptor {
1432        /** The UUID of the {@link GattService} instance to which the descriptor belongs */
1433        serviceUuid: string;
1434        /** The UUID of the {@link BLECharacteristic} instance to which the descriptor belongs */
1435        characteristicUuid: string;
1436        /** The UUID of the BLEDescriptor instance */
1437        descriptorUuid: string;
1438        /** The value of the BLEDescriptor instance */
1439        descriptorValue: ArrayBuffer;
1440    }
1441
1442    /**
1443     * Describes the value of the indication or notification sent by the Gatt server.
1444     *
1445     * @since 9
1446     */
1447    interface NotifyCharacteristic {
1448        /** The UUID of the {@link GattService} instance to which the characteristic belongs */
1449        serviceUuid: string;
1450        /** The UUID of a NotifyCharacteristic instance */
1451        characteristicUuid: string;
1452        /** The value of a NotifyCharacteristic instance */
1453        characteristicValue: ArrayBuffer;
1454        /**
1455         * Specifies whether to request confirmation from the BLE peripheral device (indication) or
1456         * send a notification. Value {@code true} indicates the former and {@code false} indicates the latter.
1457         */
1458        confirm: boolean;
1459    }
1460
1461    /**
1462     * Describes the parameters of the Gatt client's characteristic read request.
1463     *
1464     * @since 9
1465     */
1466    interface CharacteristicReadRequest {
1467        /** Indicates the address of the client that initiates the read request */
1468        deviceId: string;
1469        /** The Id of the read request */
1470        transId: number;
1471        /** Indicates the byte offset of the start position for reading characteristic value */
1472        offset: number;
1473        /** The UUID of a CharacteristicReadRequest instance */
1474        characteristicUuid: string;
1475        /** The UUID of the service to which the characteristic belongs */
1476        serviceUuid: string;
1477    }
1478
1479    /**
1480     * Describes the parameters of the of the Gatt client's characteristic write request.
1481     *
1482     * @since 9
1483     */
1484    interface CharacteristicWriteRequest {
1485        /** Indicates the address of the client that initiates the write request */
1486        deviceId: string;
1487        /** The Id of the write request */
1488        transId: number;
1489        /** Indicates the byte offset of the start position for writing characteristic value */
1490        offset: number;
1491        /** Whether this request should be pending for later operation */
1492        isPrep: boolean;
1493        /** Whether the remote client need a response */
1494        needRsp: boolean;
1495        /** Indicates the value to be written */
1496        value: ArrayBuffer;
1497        /** The UUID of a CharacteristicWriteRequest instance */
1498        characteristicUuid: string;
1499        /** The UUID of the service to which the characteristic belongs */
1500        serviceUuid: string;
1501    }
1502
1503    /**
1504     * Describes the parameters of the Gatt client's descriptor read request.
1505     *
1506     * @since 9
1507     */
1508    interface DescriptorReadRequest {
1509        /** Indicates the address of the client that initiates the read request */
1510        deviceId: string;
1511        /** The Id of the read request */
1512        transId: number;
1513        /** Indicates the byte offset of the start position for reading characteristic value */
1514        offset: number;
1515        /** The UUID of a DescriptorReadRequest instance */
1516        descriptorUuid: string;
1517        /** The UUID of the characteristic to which the descriptor belongs */
1518        characteristicUuid: string;
1519        /** The UUID of the service to which the descriptor belongs */
1520        serviceUuid: string;
1521    }
1522
1523    /**
1524     * Describes the parameters of the Gatt client's characteristic write request.
1525     *
1526     * @since 9
1527     */
1528    interface DescriptorWriteRequest {
1529        /** Indicates the address of the client that initiates the write request */
1530        deviceId: string;
1531        /** The Id of the write request */
1532        transId: number;
1533        /** Indicates the byte offset of the start position for writing characteristic value */
1534        offset: number;
1535        /** Whether this request should be pending for later operation */
1536        isPrep: boolean;
1537        /** Whether the remote client need a response */
1538        needRsp: boolean;
1539        /** Indicates the value to be written */
1540        value: ArrayBuffer;
1541        /** The UUID of a DescriptorWriteRequest instance */
1542        descriptorUuid: string;
1543        /** The UUID of the characteristic to which the descriptor belongs */
1544        characteristicUuid: string;
1545        /** The UUID of the service to which the descriptor belongs */
1546        serviceUuid: string;
1547    }
1548
1549    /**
1550     * Describes the parameters of a response send by the server to a specified read or write request.
1551     *
1552     * @since 9
1553     */
1554    interface ServerResponse {
1555        /** Indicates the address of the client to which to send the response */
1556        deviceId: string;
1557        /** The Id of the write request */
1558        transId: number;
1559        /** Indicates the status of the read or write request, set this parameter to '0' in normal cases */
1560        status: number;
1561        /** Indicates the byte offset of the start position for reading or writing operation */
1562        offset: number;
1563        /** Indicates the value to be sent */
1564        value: ArrayBuffer;
1565    }
1566
1567    /**
1568     * Describes the Gatt profile connection state.
1569     *
1570     * @since 9
1571     */
1572    interface BLEConnectChangedState {
1573        /** Indicates the peer device address */
1574        deviceId: string;
1575        /** Connection state of the Gatt profile */
1576        state: ProfileConnectionState;
1577    }
1578
1579    /**
1580     * Describes the contents of the scan results.
1581     *
1582     * @since 9
1583     */
1584    interface ScanResult {
1585        /** Address of the scanned device */
1586        deviceId: string;
1587        /** RSSI of the remote device */
1588        rssi: number;
1589        /** The raw data of broadcast packet */
1590        data: ArrayBuffer;
1591    }
1592
1593    /**
1594     * Describes the settings for BLE advertising.
1595     *
1596     * @since 9
1597     */
1598    interface AdvertiseSetting {
1599        /**
1600         * Minimum slot value for the advertising interval, which is {@code 32} (20 ms)
1601         * Maximum slot value for the advertising interval, which is {@code 16777215} (10485.759375s)
1602         * Default slot value for the advertising interval, which is {@code 1600} (1s)
1603         */
1604        interval?: number;
1605        /**
1606         * Minimum transmission power level for advertising, which is {@code -127}
1607         * Maximum transmission power level for advertising, which is {@code 1}
1608         * Default transmission power level for advertising, which is {@code -7}
1609         */
1610        txPower?: number;
1611        /** Indicates whether the BLE is connectable, default is {@code true} */
1612        connectable?: boolean;
1613    }
1614
1615    /**
1616     * Describes the advertising data.
1617     *
1618     * @since 9
1619     */
1620    interface AdvertiseData {
1621        /** The specified service UUID list to this advertisement */
1622        serviceUuids: Array<string>;
1623        /** The specified manufacturer data list to this advertisement */
1624        manufactureData: Array<ManufactureData>;
1625        /** The specified service data list to this advertisement */
1626        serviceData: Array<ServiceData>;
1627    }
1628
1629    /**
1630     * Describes the manufacturer data.
1631     *
1632     * @since 9
1633     */
1634    interface ManufactureData {
1635        /** Indicates the manufacturer ID assigned by Bluetooth SIG */
1636        manufactureId: number;
1637        /** Indicates the manufacturer data to add */
1638        manufactureValue: ArrayBuffer;
1639    }
1640
1641    /**
1642     * Describes the service data.
1643     *
1644     * @since 9
1645     */
1646    interface ServiceData {
1647        /** Indicates the UUID of the service data to add */
1648        serviceUuid: string;
1649        /** Indicates the service data to add */
1650        serviceValue: ArrayBuffer;
1651    }
1652
1653    /**
1654     * Describes the criteria for filtering scanning results can be set.
1655     *
1656     * @since 9
1657     */
1658    interface ScanFilter {
1659        /**
1660         * The address of a BLE peripheral device
1661         * @since 9
1662         */
1663        deviceId?: string;
1664
1665        /**
1666         * The name of a BLE peripheral device
1667         * @since 9
1668         */
1669        name?: string;
1670
1671        /**
1672         * The service UUID of a BLE peripheral device
1673         * @since 9
1674         */
1675        serviceUuid?: string;
1676
1677        /**
1678         * Service UUID mask.
1679         * @since 9
1680         */
1681        serviceUuidMask?: string;
1682
1683        /**
1684         * Service solicitation UUID.
1685         * @since 9
1686         */
1687        serviceSolicitationUuid?: string;
1688
1689        /**
1690         * Service solicitation UUID mask.
1691         * @since 9
1692         */
1693        serviceSolicitationUuidMask?: string;
1694
1695        /**
1696         * Service data.
1697         * @since 9
1698         */
1699        serviceData?: ArrayBuffer;
1700
1701        /**
1702         * Service data mask.
1703         * @since 9
1704         */
1705        serviceDataMask?: ArrayBuffer;
1706
1707        /**
1708         * Manufacture id.
1709         * @since 9
1710         */
1711        manufactureId?: number;
1712
1713        /**
1714         * Manufacture data.
1715         * @since 9
1716         */
1717        manufactureData?: ArrayBuffer;
1718
1719        /**
1720         * Manufacture data mask.
1721         * @since 9
1722         */
1723        manufactureDataMask?: ArrayBuffer;
1724    }
1725
1726    /**
1727     * Describes the parameters for scan.
1728     *
1729     * @since 9
1730     */
1731    interface ScanOptions {
1732        /** Time of delay for reporting the scan result */
1733        interval?: number;
1734        /** Bluetooth LE scan mode */
1735        dutyMode?: ScanDuty;
1736        /** Match mode for Bluetooth LE scan filters hardware match */
1737        matchMode?: MatchMode;
1738    }
1739
1740    /**
1741     * Describes the spp parameters.
1742     *
1743     * @since 9
1744     */
1745    interface SppOption {
1746        /** Indicates the UUID in the SDP record. */
1747        uuid: string;
1748        /** Indicates secure channel or not */
1749        secure: boolean;
1750        /** Spp link type {@link SppType}*/
1751        type: SppType;
1752    }
1753
1754    /**
1755     * Describes the bond key param.
1756     *
1757     * @since 9
1758     */
1759    interface PinRequiredParam {
1760        deviceId: string;
1761        pinCode: string;
1762    }
1763
1764    /**
1765     * Describes the class of a bluetooth device.
1766     *
1767     * @since 9
1768     */
1769    interface DeviceClass {
1770        majorClass: MajorClass;
1771        majorMinorClass: MajorMinorClass;
1772        classOfDevice: number;
1773    }
1774
1775    /**
1776     * Describes the class of a bluetooth device.
1777     *
1778     * @since 9
1779     */
1780    interface BondStateParam {
1781        deviceId: string;
1782        state: BondState;
1783    }
1784
1785    /**
1786     * Profile state change parameters.
1787     *
1788     * @since 9
1789     */
1790    interface StateChangeParam {
1791        /** The address of device */
1792        deviceId: string;
1793
1794        /** Profile state value */
1795        state: ProfileConnectionState;
1796    }
1797
1798    /**
1799     * The enum of scan duty.
1800     *
1801     * @since 9
1802     */
1803    enum ScanDuty {
1804        /** low power mode */
1805        SCAN_MODE_LOW_POWER = 0,
1806        /** balanced power mode */
1807        SCAN_MODE_BALANCED = 1,
1808        /** Scan using highest duty cycle */
1809        SCAN_MODE_LOW_LATENCY = 2
1810    }
1811
1812    /**
1813     * The enum of BLE match mode.
1814     *
1815     * @since 9
1816     */
1817    enum MatchMode {
1818        /** aggressive mode */
1819        MATCH_MODE_AGGRESSIVE = 1,
1820        /** sticky mode */
1821        MATCH_MODE_STICKY = 2
1822    }
1823
1824    /**
1825     * The enum of profile connection state.
1826     *
1827     * @since 9
1828     */
1829    enum ProfileConnectionState {
1830        /** the current profile is disconnected */
1831        STATE_DISCONNECTED = 0,
1832        /** the current profile is being connected */
1833        STATE_CONNECTING = 1,
1834        /** the current profile is connected */
1835        STATE_CONNECTED = 2,
1836        /** the current profile is being disconnected */
1837        STATE_DISCONNECTING = 3
1838    }
1839
1840    /**
1841     * The enum of bluetooth state.
1842     *
1843     * @since 9
1844     */
1845    enum BluetoothState {
1846        /** Indicates the local Bluetooth is off */
1847        STATE_OFF = 0,
1848        /** Indicates the local Bluetooth is turning on */
1849        STATE_TURNING_ON = 1,
1850        /** Indicates the local Bluetooth is on, and ready for use */
1851        STATE_ON = 2,
1852        /** Indicates the local Bluetooth is turning off */
1853        STATE_TURNING_OFF = 3,
1854        /** Indicates the local Bluetooth is turning LE mode on */
1855        STATE_BLE_TURNING_ON = 4,
1856        /** Indicates the local Bluetooth is in LE only mode */
1857        STATE_BLE_ON = 5,
1858        /** Indicates the local Bluetooth is turning off LE only mode */
1859        STATE_BLE_TURNING_OFF = 6
1860    }
1861
1862    /**
1863     * The enum of SPP type.
1864     *
1865     * @since 9
1866     */
1867    enum SppType {
1868        /** RFCOMM */
1869        SPP_RFCOMM
1870    }
1871
1872    /**
1873     * The enum of BR scan mode.
1874     *
1875     * @since 9
1876     */
1877    enum ScanMode {
1878        /** Indicates the scan mode is none */
1879        SCAN_MODE_NONE = 0,
1880        /** Indicates the scan mode is connectable */
1881        SCAN_MODE_CONNECTABLE = 1,
1882        /** Indicates the scan mode is general discoverable */
1883        SCAN_MODE_GENERAL_DISCOVERABLE = 2,
1884        /** Indicates the scan mode is limited discoverable */
1885        SCAN_MODE_LIMITED_DISCOVERABLE = 3,
1886        /** Indicates the scan mode is connectable and general discoverable */
1887        SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4,
1888        /** Indicates the scan mode is connectable and limited discoverable */
1889        SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5
1890    }
1891
1892    /**
1893     * The enum of bond state.
1894     *
1895     * @since 9
1896     */
1897    enum BondState {
1898        /** Indicate the bond state is invalid */
1899        BOND_STATE_INVALID = 0,
1900        /** Indicate the bond state is bonding */
1901        BOND_STATE_BONDING = 1,
1902        /** Indicate the bond state is bonded*/
1903        BOND_STATE_BONDED = 2
1904    }
1905
1906    /**
1907     * The enum of major class of a bluetooth device.
1908     *
1909     * @since 9
1910     */
1911    enum MajorClass {
1912        MAJOR_MISC = 0x0000,
1913        MAJOR_COMPUTER = 0x0100,
1914        MAJOR_PHONE = 0x0200,
1915        MAJOR_NETWORKING = 0x0300,
1916        MAJOR_AUDIO_VIDEO = 0x0400,
1917        MAJOR_PERIPHERAL = 0x0500,
1918        MAJOR_IMAGING = 0x0600,
1919        MAJOR_WEARABLE = 0x0700,
1920        MAJOR_TOY = 0x0800,
1921        MAJOR_HEALTH = 0x0900,
1922        MAJOR_UNCATEGORIZED = 0x1F00
1923    }
1924
1925    /**
1926     * The enum of major minor class of a bluetooth device.
1927     *
1928     * @since 9
1929     */
1930    enum MajorMinorClass {
1931        // The Minor Device Class field
1932        // Computer Major Class
1933        COMPUTER_UNCATEGORIZED = 0x0100,
1934        COMPUTER_DESKTOP = 0x0104,
1935        COMPUTER_SERVER = 0x0108,
1936        COMPUTER_LAPTOP = 0x010C,
1937        COMPUTER_HANDHELD_PC_PDA = 0x0110,
1938        COMPUTER_PALM_SIZE_PC_PDA = 0x0114,
1939        COMPUTER_WEARABLE = 0x0118,
1940        COMPUTER_TABLET = 0x011C,
1941
1942        // Phone Major Class
1943        PHONE_UNCATEGORIZED = 0x0200,
1944        PHONE_CELLULAR = 0x0204,
1945        PHONE_CORDLESS = 0x0208,
1946        PHONE_SMART = 0x020C,
1947        PHONE_MODEM_OR_GATEWAY = 0x0210,
1948        PHONE_ISDN = 0x0214,
1949
1950        // LAN/Network Access Point Major Class
1951        NETWORK_FULLY_AVAILABLE = 0x0300,
1952        NETWORK_1_TO_17_UTILIZED = 0x0320,
1953        NETWORK_17_TO_33_UTILIZED = 0x0340,
1954        NETWORK_33_TO_50_UTILIZED = 0x0360,
1955        NETWORK_60_TO_67_UTILIZED = 0x0380,
1956        NETWORK_67_TO_83_UTILIZED = 0x03A0,
1957        NETWORK_83_TO_99_UTILIZED = 0x03C0,
1958        NETWORK_NO_SERVICE = 0x03E0,
1959
1960        // Audio/Video Major Class
1961        AUDIO_VIDEO_UNCATEGORIZED = 0x0400,
1962        AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404,
1963        AUDIO_VIDEO_HANDSFREE = 0x0408,
1964        AUDIO_VIDEO_MICROPHONE = 0x0410,
1965        AUDIO_VIDEO_LOUDSPEAKER = 0x0414,
1966        AUDIO_VIDEO_HEADPHONES = 0x0418,
1967        AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C,
1968        AUDIO_VIDEO_CAR_AUDIO = 0x0420,
1969        AUDIO_VIDEO_SET_TOP_BOX = 0x0424,
1970        AUDIO_VIDEO_HIFI_AUDIO = 0x0428,
1971        AUDIO_VIDEO_VCR = 0x042C,
1972        AUDIO_VIDEO_VIDEO_CAMERA = 0x0430,
1973        AUDIO_VIDEO_CAMCORDER = 0x0434,
1974        AUDIO_VIDEO_VIDEO_MONITOR = 0x0438,
1975        AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C,
1976        AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440,
1977        AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448,
1978
1979        // Peripheral Major Class
1980        PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500,
1981        PERIPHERAL_KEYBOARD = 0x0540,
1982        PERIPHERAL_POINTING_DEVICE = 0x0580,
1983        PERIPHERAL_KEYBOARD_POINTING = 0x05C0,
1984        PERIPHERAL_UNCATEGORIZED = 0x0500,
1985        PERIPHERAL_JOYSTICK = 0x0504,
1986        PERIPHERAL_GAMEPAD = 0x0508,
1987        PERIPHERAL_REMOTE_CONTROL = 0x05C0,
1988        PERIPHERAL_SENSING_DEVICE = 0x0510,
1989        PERIPHERAL_DIGITIZER_TABLET = 0x0514,
1990        PERIPHERAL_CARD_READER = 0x0518,
1991        PERIPHERAL_DIGITAL_PEN = 0x051C,
1992        PERIPHERAL_SCANNER_RFID = 0x0520,
1993        PERIPHERAL_GESTURAL_INPUT = 0x0522,
1994
1995        // Imaging Major Class
1996        IMAGING_UNCATEGORIZED = 0x0600,
1997        IMAGING_DISPLAY = 0x0610,
1998        IMAGING_CAMERA = 0x0620,
1999        IMAGING_SCANNER = 0x0640,
2000        IMAGING_PRINTER = 0x0680,
2001
2002        // Wearable Major Class
2003        WEARABLE_UNCATEGORIZED = 0x0700,
2004        WEARABLE_WRIST_WATCH = 0x0704,
2005        WEARABLE_PAGER = 0x0708,
2006        WEARABLE_JACKET = 0x070C,
2007        WEARABLE_HELMET = 0x0710,
2008        WEARABLE_GLASSES = 0x0714,
2009
2010        // Minor Device Class field - Toy Major Class
2011        TOY_UNCATEGORIZED = 0x0800,
2012        TOY_ROBOT = 0x0804,
2013        TOY_VEHICLE = 0x0808,
2014        TOY_DOLL_ACTION_FIGURE = 0x080C,
2015        TOY_CONTROLLER = 0x0810,
2016        TOY_GAME = 0x0814,
2017
2018        // Minor Device Class field - Health
2019        HEALTH_UNCATEGORIZED = 0x0900,
2020        HEALTH_BLOOD_PRESSURE = 0x0904,
2021        HEALTH_THERMOMETER = 0x0908,
2022        HEALTH_WEIGHING = 0x090C,
2023        HEALTH_GLUCOSE = 0x0910,
2024        HEALTH_PULSE_OXIMETER = 0x0914,
2025        HEALTH_PULSE_RATE = 0x0918,
2026        HEALTH_DATA_DISPLAY = 0x091C,
2027        HEALTH_STEP_COUNTER = 0x0920,
2028        HEALTH_BODY_COMPOSITION_ANALYZER = 0x0924,
2029        HEALTH_PEAK_FLOW_MONITOR = 0x0928,
2030        HEALTH_MEDICATION_MONITOR = 0x092C,
2031        HEALTH_KNEE_PROSTHESIS = 0x0930,
2032        HEALTH_ANKLE_PROSTHESIS = 0x0934,
2033        HEALTH_GENERIC_HEALTH_MANAGER = 0x0938,
2034        HEALTH_PERSONAL_MOBILITY_DEVICE = 0x093C,
2035    }
2036
2037    /**
2038     * The enum of a2dp playing state.
2039     *
2040     * @since 9
2041     */
2042    enum PlayingState {
2043        STATE_NOT_PLAYING,
2044        STATE_PLAYING,
2045    }
2046
2047    /**
2048     * The enum of profile id.
2049     *
2050     * @since 9
2051     */
2052    enum ProfileId {
2053        /**
2054         * @since 9
2055         */
2056        PROFILE_A2DP_SOURCE = 1,
2057
2058        /**
2059         * @since 9
2060         */
2061        PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4,
2062
2063        /**
2064         * @since 9
2065         */
2066        PROFILE_HID_HOST = 6,
2067
2068        /**
2069         * @since 9
2070         */
2071        PROFILE_PAN_NETWORK = 7,
2072    }
2073}
2074
2075export default bluetoothManager;