• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2021-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 * @since 7
21 * @import import bluetooth frome '@ohos.bluetooth';
22 * @syscap SystemCapability.Communication.Bluetooth.Core
23 */
24declare namespace bluetooth {
25    /**
26     * Obtains the Bluetooth status of a device.
27     *
28     * @return Returns the Bluetooth status, which can be {@link BluetoothState#STATE_OFF},
29     * {@link BluetoothState#STATE_TURNING_ON}, {@link BluetoothState#STATE_ON}, {@link BluetoothState#STATE_TURNING_OFF},
30     * {@link BluetoothState#STATE_BLE_TURNING_ON}, {@link BluetoothState#STATE_BLE_ON},
31     * or {@link BluetoothState#STATE_BLE_TURNING_OFF}.
32     * @since 7
33     * @permission ohos.permission.USE_BLUETOOTH
34     */
35    function getState(): BluetoothState;
36
37    /**
38     * Get the local device connection state to any profile of any remote device.
39     *
40     * @return One of {@link ProfileConnectionState#STATE_DISCONNECTED},
41     * {@link ProfileConnectionState#STATE_CONNECTING}, {@link ProfileConnectionState#STATE_CONNECTED},
42     * {@link ProfileConnectionState#STATE_DISCONNECTING}.
43     * @since 7
44     * @permission ohos.permission.USE_BLUETOOTH
45     */
46    function getBtConnectionState(): ProfileConnectionState;
47
48    /**
49     * Starts pairing with a remote Bluetooth device.
50     *
51     * @param deviceId The address of the remote device to pair.
52     * @return Returns {@code true} if the pairing process is started; returns {@code false} otherwise.
53     * @since 7
54     * @permission ohos.permission.DISCOVER_BLUETOOTH
55     */
56    function pairDevice(deviceId: string): boolean;
57
58    /**
59     * Remove a paired remote device.
60     *
61     * @param deviceId The address of the remote device to be removed.
62     * @return Returns {@code true} if the cancel process is started; returns {@code false} otherwise.
63     * @since 8
64     * @permission ohos.permission.DISCOVER_BLUETOOTH
65     * @systemapi Hide this for inner system use
66     */
67    function cancelPairedDevice(deviceId: string): boolean;
68
69    /**
70     * Obtains the name of a peer Bluetooth device.
71     *
72     * @param deviceId The address of the remote device.
73     * @return Returns the device name in character string format.
74     * @since 8
75     * @permission ohos.permission.USE_BLUETOOTH
76     */
77    function getRemoteDeviceName(deviceId: string): string;
78
79    /**
80     * Obtains the class of a peer Bluetooth device.
81     *
82     * @param deviceId The address of the remote device.
83     * @return The class of the remote device, {@link DeviceClass}.
84     * @since 8
85     * @permission ohos.permission.USE_BLUETOOTH
86     */
87    function getRemoteDeviceClass(deviceId: string): DeviceClass;
88
89    /**
90     * Enables Bluetooth on a device.
91     *
92     * @return Returns {@code true} if Bluetooth is being enabled; returns {@code false} if an error occurs.
93     * @since 8
94     * @permission ohos.permission.DISCOVER_BLUETOOTH
95     */
96    function enableBluetooth(): boolean;
97
98    /**
99     * Disables Bluetooth on a device.
100     *
101     * @return Returns {@code true} if Bluetooth is being disabled; returns {@code false} if an error occurs.
102     * @since 8
103     * @permission ohos.permission.DISCOVER_BLUETOOTH
104     */
105    function disableBluetooth(): boolean;
106
107    /**
108     * Obtains the Bluetooth local name of a device.
109     *
110     * @return Returns the name the device.
111     * @since 8
112     * @permission ohos.permission.USE_BLUETOOTH
113     */
114    function getLocalName(): string;
115
116    /**
117     * Obtains the list of Bluetooth devices that have been paired with the current device.
118     *
119     * @return Returns a list of paired Bluetooth devices's address.
120     * @since 8
121     * @permission ohos.permission.USE_BLUETOOTH
122     */
123    function getPairedDevices(): Array<string>;
124
125    /**
126     * Obtains the connection state of profile.
127     *
128     * @param profileId The profile id.
129     * @return Returns the connection state.
130     * @since 8
131     * @permission ohos.permission.USE_BLUETOOTH
132     */
133    function getProfileConnState(profileId: ProfileId): ProfileConnectionState;
134
135    /**
136     * Sets the confirmation of pairing with a certain device.
137     *
138     * @param device The address of the remote device.
139     * @param accept Indicates whether to accept the pairing request, {@code true} indicates accept or {@code false} otherwise.
140     * @return Returns {@code true} if the pairing confirmation is set; returns {@code false} otherwise.
141     * @since 8
142     * @permission ohos.permission.MANAGE_BLUETOOTH
143     */
144    function setDevicePairingConfirmation(device: string, accept: boolean): boolean;
145
146    /**
147     * Sets the Bluetooth friendly name of a device.
148     *
149     * @param name Indicates a valid Bluetooth name.
150     * @return Returns {@code true} if the Bluetooth name is set successfully; returns {@code false} otherwise.
151     * @since 8
152     * @permission ohos.permission.DISCOVER_BLUETOOTH
153     */
154    function setLocalName(name: string): boolean;
155
156    /**
157     * Sets the Bluetooth scan mode for a device.
158     *
159     * @param mode Indicates the Bluetooth scan mode to set, {@link ScanMode}.
160     * @param duration Indicates the duration in seconds, in which the host is discoverable.
161     * @return Returns {@code true} if the Bluetooth scan mode is set; returns {@code false} otherwise.
162     * @since 8
163     * @permission ohos.permission.USE_BLUETOOTH
164     */
165    function setBluetoothScanMode(mode: ScanMode, duration: number): boolean;
166
167    /**
168     * Obtains the Bluetooth scanning mode of a device.
169     *
170     * @return Returns the Bluetooth scanning mode, {@link ScanMode}.
171     * @since 8
172     * @permission ohos.permission.USE_BLUETOOTH
173     */
174    function getBluetoothScanMode(): ScanMode;
175
176    /**
177     * Starts scanning Bluetooth devices.
178     *
179     * @return Returns {@code true} if the scan is started successfully; returns {@code false} otherwise.
180     * @since 8
181     * @permission ohos.permission.DISCOVER_BLUETOOTH
182     * @permission ohos.permission.LOCATION
183     */
184    function startBluetoothDiscovery(): boolean;
185
186    /**
187     * Stops Bluetooth device scanning.
188     *
189     * @return Returns {@code true} if scanning is stopped successfully; returns {@code false} otherwise.
190     * @since 8
191     * @permission ohos.permission.DISCOVER_BLUETOOTH
192     */
193    function stopBluetoothDiscovery(): boolean;
194
195    /**
196     * Subscribe the event reported when a remote Bluetooth device is discovered.
197     *
198     * @param type Type of the discovering event to listen for.
199     * @param callback Callback used to listen for the discovering event.
200     * @since 8
201     * @permission ohos.permission.USE_BLUETOOTH
202     */
203    function on(type: "bluetoothDeviceFind", callback: Callback<Array<string>>): void;
204
205    /**
206     * Unsubscribe the event reported when a remote Bluetooth device is discovered.
207     *
208     * @param type Type of the discovering event to listen for.
209     * @param callback Callback used to listen for the discovering event.
210     * @since 8
211     * @permission ohos.permission.USE_BLUETOOTH
212     */
213    function off(type: "bluetoothDeviceFind", callback?: Callback<Array<string>>): void;
214
215    /**
216     * Subscribe the event reported when a remote Bluetooth device is bonded.
217     *
218     * @param type Type of the bond state event to listen for.
219     * @param callback Callback used to listen for the bond state event, {@link BondStateParam}.
220     * @since 8
221     * @permission ohos.permission.USE_BLUETOOTH
222     */
223    function on(type: "bondStateChange", callback: Callback<BondStateParam>): void;
224
225    /**
226     * Unsubscribe the event reported when a remote Bluetooth device is bonded.
227     *
228     * @param type Type of the bond state event to listen for.
229     * @param callback Callback used to listen for the bond state event.
230     * @since 8
231     * @permission ohos.permission.USE_BLUETOOTH
232     */
233    function off(type: "bondStateChange", callback?: Callback<BondStateParam>): void;
234
235    /**
236     * Subscribe the event of a pairing request from a remote Bluetooth device.
237     *
238     * @param type Type of the pairing request event to listen for.
239     * @param callback Callback used to listen for the pairing request event.
240     * @since 8
241     * @permission ohos.permission.DISCOVER_BLUETOOTH
242     */
243    function on(type: "pinRequired", callback: Callback<PinRequiredParam>): void;
244
245    /**
246     * Unsubscribe the event of a pairing request from a remote Bluetooth device.
247     *
248     * @param type Type of the pairing request event to listen for.
249     * @param callback Callback used to listen for the pairing request event.
250     * @since 8
251     * @permission ohos.permission.DISCOVER_BLUETOOTH
252     */
253    function off(type: "pinRequired", callback?: Callback<PinRequiredParam>): void;
254
255    /**
256     * Subscribe the event reported when the Bluetooth state changes.
257     *
258     * @param type Type of the Bluetooth state changes event to listen for.
259     * @param callback Callback used to listen for the Bluetooth state event.
260     * @since 8
261     * @permission ohos.permission.USE_BLUETOOTH
262     */
263    function on(type: "stateChange", callback: Callback<BluetoothState>): void;
264
265    /**
266     * Unsubscribe the event reported when the Bluetooth state changes.
267     *
268     * @param type Type of the Bluetooth state changes event to listen for.
269     * @param callback Callback used to listen for the Bluetooth state event.
270     * @since 8
271     * @permission ohos.permission.USE_BLUETOOTH
272     */
273    function off(type: "stateChange", callback?: Callback<BluetoothState>): void;
274
275    /**
276     * Creates a Bluetooth server listening socket.
277     *
278     * @param name Indicates the service name.
279     * @param option Indicates the listen parameters {@link SppOption}.
280     * @param callback Callback used to return a server socket ID.
281     * @since 8
282     * @permission ohos.permission.USE_BLUETOOTH
283     */
284    function sppListen(name: string, option: SppOption, callback: AsyncCallback<number>): void;
285
286    /**
287     * Waits for a remote device to connect.
288     *
289     * @param serverSocket Indicates the server socket ID, returned by {@link sppListen}.
290     * @param callback Callback used to return a client socket ID.
291     * @since 8
292     */
293    function sppAccept(serverSocket: number, callback: AsyncCallback<number>): void;
294
295    /**
296     * Connects to a remote device over the socket.
297     *
298     * @param device The address of the remote device to connect.
299     * @param option Indicates the connect parameters {@link SppOption}.
300     * @param callback Callback used to return a client socket ID.
301     * @since 8
302     * @permission ohos.permission.USE_BLUETOOTH
303     */
304    function sppConnect(device: string, option: SppOption, callback: AsyncCallback<number>): void;
305
306    /**
307     * Disables an spp server socket and releases related resources.
308     *
309     * @param socket Indicates the server socket ID, returned by {@link sppListen}.
310     * @since 8
311     */
312    function sppCloseServerSocket(socket: number): void;
313
314    /**
315     * Disables an spp client socket and releases related resources.
316     *
317     * @param socket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}.
318     * @since 8
319     */
320    function sppCloseClientSocket(socket: number): void;
321
322    /**
323     * Write data through the socket.
324     *
325     * @param clientSocket Indicates the client socket ID, returned by {@link sppAccept} or {@link sppConnect}.
326     * @param data Indicates the data to write.
327     * @return Returns {@code true} if the data is write successfully; returns {@code false} otherwise.
328     * @since 8
329     */
330    function sppWrite(clientSocket: number, data: ArrayBuffer): boolean;
331
332    /**
333     * Subscribe the event reported when data is read from the socket.
334     *
335     * @param type Type of the spp read event to listen for.
336     * @param callback Callback used to listen for the spp read event.
337     * @since 8
338     */
339    function on(type: "sppRead", clientSocket: number, callback: Callback<ArrayBuffer>): void;
340
341    /**
342     * Unsubscribe the event reported when data is read from the socket.
343     *
344     * @param type Type of the spp read event to listen for.
345     * @param callback Callback used to listen for the spp read event.
346     * @since 8
347     */
348    function off(type: "sppRead", clientSocket: number, callback?: Callback<ArrayBuffer>): void;
349
350    /**
351     * Obtains the instance of profile.
352     *
353     * @param profileId The profile id..
354     * @return Returns instance of profile.
355     * @since 8
356     */
357    function getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile;
358
359    /**
360     * Base interface of profile.
361     */
362    interface BaseProfile {
363        /**
364         * Obtains the connected devices list of profile.
365         *
366         * @return Returns the address of connected devices list.
367         * @since 8
368         * @permission ohos.permission.USE_BLUETOOTH
369         */
370        getConnectionDevices(): Array<string>;
371
372        /**
373         * Obtains the profile state of device.
374         *
375         * @param device The address of bluetooth device.
376         * @return Returns {@link ProfileConnectionState} of device.
377         * @since 8
378         * @permission ohos.permission.USE_BLUETOOTH
379         */
380        getDeviceState(device: string): ProfileConnectionState;
381    }
382
383    /**
384     * Manager a2dp source profile.
385     */
386    interface A2dpSourceProfile extends BaseProfile {
387        /**
388         * Connect to device with a2dp.
389         *
390         * @param device The address of the remote device to connect.
391         * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise.
392         * @since 8
393         * @permission permission ohos.permission.DISCOVER_BLUETOOTH
394         */
395        connect(device: string): boolean;
396
397        /**
398         * Disconnect to device with a2dp.
399         *
400         * @param device The address of the remote device to disconnect.
401         * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise.
402         * @since 8
403         * @permission permission ohos.permission.DISCOVER_BLUETOOTH
404         */
405        disconnect(device: string): boolean;
406
407        /**
408         * Subscribe the event reported when the profile connection state changes .
409         *
410         * @param type Type of the profile connection state changes event to listen for .
411         * @param callback Callback used to listen for event.
412         * @since 8
413         */
414        on(type: "connectionStateChange", callback: Callback<StateChangeParam>): void;
415
416        /**
417         * Unsubscribe the event reported when the profile connection state changes .
418         *
419         * @param type Type of the profile connection state changes event to listen for .
420         * @param callback Callback used to listen for event.
421         * @since 8
422         */
423        off(type: "connectionStateChange", callback?: Callback<StateChangeParam>): void;
424
425        /**
426         * Obtains the playing state of device.
427         *
428         * @param device The address of the remote device.
429         * @return Returns {@link PlayingState} of the remote device.
430         *
431         */
432        getPlayingState(device: string): PlayingState;
433    }
434
435    /**
436     * Manager handsfree AG profile.
437     */
438    interface HandsFreeAudioGatewayProfile extends BaseProfile {
439        /**
440         * Connect to device with hfp.
441         *
442         * @param device The address of the remote device to connect.
443         * @return Returns {@code true} if the connect is in process; returns {@code false} otherwise.
444         * @since 8
445         * @permission permission ohos.permission.DISCOVER_BLUETOOTH
446         */
447        connect(device: string): boolean;
448
449        /**
450         * Disconnect to device with hfp.
451         *
452         * @param device The address of the remote device to disconnect.
453         * @return Returns {@code true} if the disconnect is in process; returns {@code false} otherwise.
454         * @since 8
455         * @permission permission ohos.permission.DISCOVER_BLUETOOTH
456         */
457        disconnect(device: string): boolean;
458
459        /**
460         * Subscribe the event reported when the profile connection state changes .
461         *
462         * @param type Type of the profile connection state changes event to listen for .
463         * @param callback Callback used to listen for event.
464         * @since 8
465         */
466        on(type: "connectionStateChange", callback: Callback<StateChangeParam>): void;
467
468        /**
469         * Unsubscribe the event reported when the profile connection state changes .
470         *
471         * @param type Type of the profile connection state changes event to listen for .
472         * @param callback Callback used to listen for event.
473         * @since 8
474         */
475        off(type: "connectionStateChange", callback?: Callback<StateChangeParam>): void;
476    }
477
478    namespace BLE {
479        /**
480         * create a JavaScript Gatt server instance.
481         *
482         * @return Returns a JavaScript Gatt server instance {@code GattServer}.
483         * @since 7
484         */
485        function createGattServer(): GattServer;
486
487        /**
488         * create a JavaScript Gatt client device instance.
489         *
490         * @param deviceId The address of the remote device.
491         * @return Returns a JavaScript Gatt client device instance {@code GattClientDevice}.
492         * @since 7
493         */
494        function createGattClientDevice(deviceId: string): GattClientDevice;
495
496        /**
497         * Obtains the list of devices in the connected status.
498         *
499         * @return Returns the list of device address.
500         * @since 7
501         * @permission ohos.permission.USE_BLUETOOTH
502         */
503        function getConnectedBLEDevices(): Array<string>;
504
505        /**
506         * Starts scanning for specified BLE devices with filters.
507         *
508         * @param filters Indicates the list of filters used to filter out specified devices.
509         * If you do not want to use filter, set this parameter to {@code null}.
510         * @param options Indicates the parameters for scanning and if the user does not assign a value, the default value will be used.
511         * {@link ScanOptions#interval} set to 0, {@link ScanOptions#dutyMode} set to {@link SCAN_MODE_LOW_POWER}
512         * and {@link ScanOptions#matchMode} set to {@link MATCH_MODE_AGGRESSIVE}.
513         * @since 7
514         * @permission ohos.permission.DISCOVER_BLUETOOTH
515         * @permission ohos.permission.MANAGE_BLUETOOTH
516         * @permission ohos.permission.LOCATION
517         */
518        function startBLEScan(filters: Array<ScanFilter>, options?: ScanOptions): void;
519
520        /**
521         * Stops BLE scanning.
522         *
523         * @since 7
524         * @permission ohos.permission.DISCOVER_BLUETOOTH
525         */
526        function stopBLEScan(): void;
527
528        /**
529         * Subscribe BLE scan result.
530         *
531         * @param type Type of the scan result event to listen for.
532         * @param callback Callback used to listen for the scan result event.
533         * @since 7
534         * @permission ohos.permission.USE_BLUETOOTH
535         */
536        function on(type: "BLEDeviceFind", callback: Callback<Array<ScanResult>>): void;
537
538        /**
539         * Unsubscribe BLE scan result.
540         *
541         * @param type Type of the scan result event to listen for.
542         * @param callback Callback used to listen for the scan result event.
543         * @since 7
544         * @permission ohos.permission.USE_BLUETOOTH
545         */
546        function off(type: "BLEDeviceFind", callback?: Callback<Array<ScanResult>>): void;
547    }
548
549    /**
550     * Manages GATT server. Before calling an Gatt server method, you must use {@link createGattServer} to create an GattServer instance.
551     */
552    interface GattServer {
553        /**
554         * Starts BLE advertising.
555         *
556         * @param setting Indicates the settings for BLE advertising.
557         * If you need to use the default value, set this parameter to {@code null}.
558         * @param advData Indicates the advertising data.
559         * @param advResponse Indicates the scan response associated with the advertising data.
560         * @since 7
561         * @permission ohos.permission.DISCOVER_BLUETOOTH
562         */
563        startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void;
564
565        /**
566         * Stops BLE advertising.
567         *
568         * @since 7
569         * @permission ohos.permission.DISCOVER_BLUETOOTH
570         */
571        stopAdvertising(): void;
572
573        /**
574         * Adds a specified service to be hosted.
575         *
576         * <p>The added service and its characteristics are provided by the local device.
577         *
578         * @param service Indicates the service to add.
579         * @return Returns {@code true} if the service is added; returns {@code false} otherwise.
580         * @since 7
581         * @permission ohos.permission.USE_BLUETOOTH
582         */
583        addService(service: GattService): boolean;
584
585        /**
586         * Removes a specified service from the list of GATT services provided by this device.
587         *
588         * @param serviceUuid Indicates the UUID of the service to remove.
589         * @return Returns {@code true} if the service is removed; returns {@code false} otherwise.
590         * @since 7
591         * @permission ohos.permission.USE_BLUETOOTH
592         */
593        removeService(serviceUuid: string): boolean;
594
595        /**
596         * Closes this {@code GattServer} object and unregisters its callbacks.
597         *
598         * @since 7
599         * @permission ohos.permission.USE_BLUETOOTH
600         */
601        close(): void;
602
603        /**
604         * Sends a notification of a change in a specified local characteristic.
605         *
606         * <p>This method should be called for every BLE peripheral device that has requested notifications.
607         *
608         * @param deviceId Indicates the address of the BLE peripheral device to receive the notification.
609         * @param notifyCharacteristic Indicates the local characteristic that has changed.
610         * @return Returns {@code true} if the notification is sent successfully; returns {@code false} otherwise.
611         * @since 7
612         * @permission ohos.permission.USE_BLUETOOTH
613         */
614        notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): boolean;
615
616        /**
617         * Sends a response to a specified read or write request to a given BLE peripheral device.
618         *
619         * @param serverResponse Indicates the response parameters {@link ServerResponse}.
620         * @return Returns {@code true} if the response is sent successfully; returns {@code false} otherwise.
621         * @since 7
622         * @permission ohos.permission.USE_BLUETOOTH
623         */
624        sendResponse(serverResponse: ServerResponse): boolean;
625
626        /**
627         * Subscribe characteristic read event.
628         *
629         * @param type Type of the characteristic read event to listen for.
630         * @param callback Callback used to listen for the characteristic read event.
631         * @since 7
632         * @permission ohos.permission.USE_BLUETOOTH
633         */
634        on(type: "characteristicRead", callback: Callback<CharacteristicReadReq>): void;
635
636        /**
637         * Unsubscribe characteristic read event.
638         *
639         * @param type Type of the characteristic read event to listen for.
640         * @param callback Callback used to listen for the characteristic read event.
641         * @since 7
642         * @permission ohos.permission.USE_BLUETOOTH
643         */
644        off(type: "characteristicRead", callback?: Callback<CharacteristicReadReq>): void;
645
646        /**
647         * Subscribe characteristic write event.
648         *
649         * @param type Type of the characteristic write event to listen for.
650         * @param callback Callback used to listen for the characteristic write event.
651         * @since 7
652         * @permission ohos.permission.USE_BLUETOOTH
653         */
654        on(type: "characteristicWrite", callback: Callback<CharacteristicWriteReq>): void;
655
656        /**
657         * Unsubscribe characteristic write event.
658         *
659         * @param type Type of the characteristic write event to listen for.
660         * @param callback Callback used to listen for the characteristic write event.
661         * @since 7
662         * @permission ohos.permission.USE_BLUETOOTH
663         */
664        off(type: "characteristicWrite", callback?: Callback<CharacteristicWriteReq>): void;
665
666        /**
667         * Subscribe descriptor read event.
668         *
669         * @param type Type of the descriptor read event to listen for.
670         * @param callback Callback used to listen for the descriptor read event.
671         * @since 7
672         * @permission ohos.permission.USE_BLUETOOTH
673         */
674        on(type: "descriptorRead", callback: Callback<DescriptorReadReq>): void;
675
676        /**
677         * Unsubscribe descriptor read event.
678         *
679         * @param type Type of the descriptor read event to listen for.
680         * @param callback Callback used to listen for the descriptor read event.
681         * @since 7
682         * @permission ohos.permission.USE_BLUETOOTH
683         */
684        off(type: "descriptorRead", callback?: Callback<DescriptorReadReq>): void;
685
686        /**
687         * Subscribe descriptor write event.
688         *
689         * @param type Type of the descriptor write event to listen for.
690         * @param callback Callback used to listen for the descriptor write event.
691         * @since 7
692         * @permission ohos.permission.USE_BLUETOOTH
693         */
694        on(type: "descriptorWrite", callback: Callback<DescriptorWriteReq>): void;
695
696        /**
697         * Unsubscribe descriptor write event.
698         *
699         * @param type Type of the descriptor write event to listen for.
700         * @param callback Callback used to listen for the descriptor write event.
701         * @since 7
702         * @permission ohos.permission.USE_BLUETOOTH
703         */
704        off(type: "descriptorWrite", callback?: Callback<DescriptorWriteReq>): void;
705
706        /**
707         * Subscribe server connection state changed event.
708         *
709         * @param type Type of the connection state changed event to listen for.
710         * @param callback Callback used to listen for the connection state changed event.
711         * @since 7
712         * @permission ohos.permission.USE_BLUETOOTH
713         */
714        on(type: "connectStateChange", callback: Callback<BLEConnectChangedState>): void;
715
716        /**
717         * Unsubscribe server connection state changed event.
718         *
719         * @param type Type of the connection state changed event to listen for.
720         * @param callback Callback used to listen for the connection state changed event.
721         * @since 7
722         * @permission ohos.permission.USE_BLUETOOTH
723         */
724        off(type: "connectStateChange", callback?: Callback<BLEConnectChangedState>): void;
725    }
726
727    /**
728     * Manages GATT client. Before calling an Gatt client method, you must use {@link createGattClientDevice} to create an GattClientDevice instance.
729     */
730    interface GattClientDevice {
731
732        /**
733         * Connects to a BLE peripheral device.
734         *
735         * <p>The 'BLEConnectionStateChange' event is subscribed to return the connection state.
736         *
737         * @return Returns {@code true} if the connection process starts; returns {@code false} otherwise.
738         * @since 7
739         * @permission ohos.permission.USE_BLUETOOTH
740         */
741        connect(): boolean;
742
743        /**
744         * Disconnects from or stops an ongoing connection to a BLE peripheral device.
745         *
746         * @return Returns {@code true} if the disconnection process starts; returns {@code false} otherwise.
747         * @since 7
748         * @permission ohos.permission.USE_BLUETOOTH
749         */
750        disconnect(): boolean;
751
752        /**
753         * Disables a BLE peripheral device.
754         *
755         * <p> This method unregisters the device and clears the registered callbacks and handles.
756         *
757         * @return Returns {@code true} if the the device is disabled; returns {@code false} otherwise.
758         * @since 7
759         * @permission ohos.permission.USE_BLUETOOTH
760         */
761        close(): boolean;
762
763        /**
764         * Obtains the name of BLE peripheral device.
765         *
766         * @return Returns a string representation of the name if obtained;
767         * returns {@code null} if the name fails to be obtained or the name does not exist.
768         * @since 7
769         * @permission ohos.permission.USE_BLUETOOTH
770         */
771        getDeviceName(callback: AsyncCallback<string>): void;
772        getDeviceName(): Promise<string>;
773
774        /**
775         * Starts discovering services.
776         *
777         * @return Returns the list of services {@link GattService} of the BLE peripheral device.
778         * @since 7
779         * @permission ohos.permission.USE_BLUETOOTH
780         */
781        getServices(callback: AsyncCallback<Array<GattService>>): void;
782        getServices(): Promise<Array<GattService>>;
783
784        /**
785         * Reads the characteristic of a BLE peripheral device.
786         *
787         * @param characteristic Indicates the characteristic to read.
788         * @since 7
789         * @permission ohos.permission.USE_BLUETOOTH
790         */
791        readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback<BLECharacteristic>): void;
792        readCharacteristicValue(characteristic: BLECharacteristic): Promise<BLECharacteristic>;
793
794        /**
795         * Reads the descriptor of a BLE peripheral device.
796         *
797         * @param descriptor Indicates the descriptor to read.
798         * @since 7
799         * @permission ohos.permission.USE_BLUETOOTH
800         */
801        readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback<BLEDescriptor>): void;
802        readDescriptorValue(descriptor: BLEDescriptor): Promise<BLEDescriptor>;
803
804        /**
805         * Writes the characteristic of a BLE peripheral device.
806         *
807         * @param characteristic Indicates the characteristic to write.
808         * @return Returns {@code true} if the characteristic is written successfully; returns {@code false} otherwise.
809         * @since 7
810         * @permission ohos.permission.USE_BLUETOOTH
811         */
812        writeCharacteristicValue(characteristic: BLECharacteristic): boolean;
813
814        /**
815         * Writes the descriptor of a BLE peripheral device.
816         *
817         * @param descriptor Indicates the descriptor to write.
818         * @return Returns {@code true} if the descriptor is written successfully; returns {@code false} otherwise.
819         * @since 7
820         * @permission ohos.permission.USE_BLUETOOTH
821         */
822        writeDescriptorValue(descriptor: BLEDescriptor): boolean;
823
824        /**
825         * Get the RSSI value of this BLE peripheral device.
826         *
827         * @return Returns the RSSI value.
828         * @since 7
829         * @permission ohos.permission.USE_BLUETOOTH
830         */
831        getRssiValue(callback: AsyncCallback<number>): void;
832        getRssiValue(): Promise<number>;
833
834        /**
835         * Set the mtu size of a BLE peripheral device.
836         *
837         * @param mtu The maximum transmission unit.
838         * @return Returns {@code true} if the set mtu is successfully; returns {@code false} otherwise.
839         * @since 7
840         * @permission ohos.permission.USE_BLUETOOTH
841         */
842        setBLEMtuSize(mtu: number): boolean;
843
844        /**
845         * Enables or disables notification of a characteristic when value changed.
846         *
847         * @param enable Specifies whether to enable notification of the characteristic. The value {@code true} indicates
848         * that notification is enabled, and the value {@code false} indicates that notification is disabled.
849         * @return Returns {@code true} if notification of the characteristic is enabled or disabled;
850         * returns {@code false} otherwise.
851         * @since 7
852         * @permission ohos.permission.USE_BLUETOOTH
853         */
854        setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean;
855
856        /**
857         * Subscribe characteristic value changed event.
858         *
859         * @param type Type of the characteristic value changed event to listen for.
860         * @param callback Callback used to listen for the characteristic value changed event.
861         * @since 7
862         * @permission ohos.permission.USE_BLUETOOTH
863         */
864        on(type: "BLECharacteristicChange", callback: Callback<BLECharacteristic>): void;
865
866        /**
867         * Unsubscribe characteristic value changed event.
868         *
869         * @param type Type of the characteristic value changed event to listen for.
870         * @param callback Callback used to listen for the characteristic value changed event.
871         * @since 7
872         * @permission ohos.permission.USE_BLUETOOTH
873         */
874        off(type: "BLECharacteristicChange", callback?: Callback<BLECharacteristic>): void;
875
876        /**
877         * Subscribe client connection state changed event.
878         *
879         * @param type Type of the connection state changed event to listen for.
880         * @param callback Callback used to listen for the connection state changed event.
881         * @since 7
882         * @permission ohos.permission.USE_BLUETOOTH
883         */
884        on(type: "BLEConnectionStateChange", callback: Callback<BLEConnectChangedState>): void;
885
886        /**
887         * Unsubscribe client connection state changed event.
888         *
889         * @param type Type of the connection state changed event to listen for.
890         * @param callback Callback used to listen for the connection state changed event.
891         * @since 7
892         * @permission ohos.permission.USE_BLUETOOTH
893         */
894        off(type: "BLEConnectionStateChange", callback?: Callback<BLEConnectChangedState>): void;
895    }
896
897    /**
898     * Describes the Gatt service.
899     *
900     * @since 7
901     */
902    interface GattService {
903        /** The UUID of a GattService instance */
904        serviceUuid: string;
905        /** Indicates whether the GattService instance is primary or secondary. */
906        isPrimary: boolean;
907        /** The {@link BLECharacteristic} list belongs to this GattService instance */
908        characteristics: Array<BLECharacteristic>;
909        /** The list of GATT services contained in the service */
910        includeServices?: Array<GattService>;
911    }
912
913    /**
914     * Describes the Gatt characteristic.
915     *
916     * @since 7
917     */
918    interface BLECharacteristic {
919        /** The UUID of the {@link GattService} instance to which the characteristic belongs */
920        serviceUuid: string;
921        /** The UUID of a BLECharacteristic instance */
922        characteristicUuid: string;
923        /** The value of a BLECharacteristic instance */
924        characteristicValue: ArrayBuffer;
925        /** The list of {@link BLEDescriptor} contained in the characteristic */
926        descriptors: Array<BLEDescriptor>;
927    }
928
929    /**
930     * Describes the Gatt descriptor.
931     *
932     * @since 7
933     */
934    interface BLEDescriptor {
935        /** The UUID of the {@link GattService} instance to which the descriptor belongs */
936        serviceUuid: string;
937        /** The UUID of the {@link BLECharacteristic} instance to which the descriptor belongs */
938        characteristicUuid: string;
939        /** The UUID of the BLEDescriptor instance */
940        descriptorUuid: string;
941        /** The value of the BLEDescriptor instance */
942        descriptorValue: ArrayBuffer;
943    }
944
945    /**
946     * Describes the value of the indication or notification sent by the Gatt server.
947     *
948     * @since 7
949     */
950    interface NotifyCharacteristic {
951        /** The UUID of the {@link GattService} instance to which the characteristic belongs */
952        serviceUuid: string;
953        /** The UUID of a NotifyCharacteristic instance */
954        characteristicUuid: string;
955        /** The value of a NotifyCharacteristic instance */
956        characteristicValue: ArrayBuffer;
957        /**
958         * Specifies whether to request confirmation from the BLE peripheral device (indication) or
959         * send a notification. Value {@code true} indicates the former and {@code false} indicates the latter.
960         */
961        confirm: boolean;
962    }
963
964    /**
965     * Describes the parameters of the Gatt client's characteristic read request.
966     *
967     * @since 7
968     */
969    interface CharacteristicReadReq {
970        /** Indicates the address of the client that initiates the read request */
971        deviceId: string;
972        /** The Id of the read request */
973        transId: number;
974        /** Indicates the byte offset of the start position for reading characteristic value */
975        offset: number;
976        /** The UUID of a CharacteristicReadReq instance */
977        characteristicUuid: string;
978        /** The UUID of the service to which the characteristic belongs */
979        serviceUuid: string;
980    }
981
982    /**
983     * Describes the parameters of the of the Gatt client's characteristic write request.
984     *
985     * @since 7
986     */
987    interface CharacteristicWriteReq {
988        /** Indicates the address of the client that initiates the write request */
989        deviceId: string;
990        /** The Id of the write request */
991        transId: number;
992        /** Indicates the byte offset of the start position for writing characteristic value */
993        offset: number;
994        /** Whether this request should be pending for later operation */
995        isPrep: boolean;
996        /** Whether the remote client need a response */
997        needRsp: boolean;
998        /** Indicates the value to be written */
999        value: ArrayBuffer;
1000        /** The UUID of a CharacteristicWriteReq instance */
1001        characteristicUuid: string;
1002        /** The UUID of the service to which the characteristic belongs */
1003        serviceUuid: string;
1004    }
1005
1006    /**
1007     * Describes the parameters of the Gatt client's descriptor read request.
1008     *
1009     * @since 7
1010     */
1011    interface DescriptorReadReq {
1012        /** Indicates the address of the client that initiates the read request */
1013        deviceId: string;
1014        /** The Id of the read request */
1015        transId: number;
1016        /** Indicates the byte offset of the start position for reading characteristic value */
1017        offset: number;
1018        /** The UUID of a DescriptorReadReq instance */
1019        descriptorUuid: string;
1020        /** The UUID of the characteristic to which the descriptor belongs */
1021        characteristicUuid: string;
1022        /** The UUID of the service to which the descriptor belongs */
1023        serviceUuid: string;
1024    }
1025
1026    /**
1027     * Describes the parameters of the Gatt client's characteristic write request.
1028     *
1029     * @since 7
1030     */
1031    interface DescriptorWriteReq {
1032        /** Indicates the address of the client that initiates the write request */
1033        deviceId: string;
1034        /** The Id of the write request */
1035        transId: number;
1036        /** Indicates the byte offset of the start position for writing characteristic value */
1037        offset: number;
1038        /** Whether this request should be pending for later operation */
1039        isPrep: boolean;
1040        /** Whether the remote client need a response */
1041        needRsp: boolean;
1042        /** Indicates the value to be written */
1043        value: ArrayBuffer;
1044        /** The UUID of a DescriptorWriteReq instance */
1045        descriptorUuid: string;
1046        /** The UUID of the characteristic to which the descriptor belongs */
1047        characteristicUuid: string;
1048        /** The UUID of the service to which the descriptor belongs */
1049        serviceUuid: string;
1050    }
1051
1052    /**
1053     * Describes the parameters of a response send by the server to a specified read or write request.
1054     *
1055     * @since 7
1056     */
1057    interface ServerResponse {
1058        /** Indicates the address of the client to which to send the response */
1059        deviceId: string;
1060        /** The Id of the write request */
1061        transId: number;
1062        /** Indicates the status of the read or write request, set this parameter to '0' in normal cases */
1063        status: number;
1064        /** Indicates the byte offset of the start position for reading or writing operation */
1065        offset: number;
1066        /** Indicates the value to be sent */
1067        value: ArrayBuffer;
1068    }
1069
1070    /**
1071     * Describes the Gatt profile connection state.
1072     *
1073     * @since 7
1074     */
1075    interface BLEConnectChangedState {
1076        /** Indicates the peer device address */
1077        deviceId: string;
1078        /** Connection state of the Gatt profile */
1079        state: ProfileConnectionState;
1080    }
1081
1082    /**
1083     * Describes the contents of the scan results.
1084     *
1085     * @since 7
1086     */
1087    interface ScanResult {
1088        /** Address of the scanned device */
1089        deviceId: string;
1090        /** RSSI of the remote device */
1091        rssi: number;
1092        /** The raw data of broadcast packet */
1093        data: ArrayBuffer;
1094    }
1095
1096    /**
1097     * Describes the settings for BLE advertising.
1098     *
1099     * @since 7
1100     */
1101    interface AdvertiseSetting {
1102        /**
1103         * Minimum slot value for the advertising interval, which is {@code 32} (20 ms)
1104         * Maximum slot value for the advertising interval, which is {@code 16777215} (10485.759375s)
1105         * Default slot value for the advertising interval, which is {@code 1600} (1s)
1106         */
1107        interval?: number;
1108        /**
1109         * Minimum transmission power level for advertising, which is {@code -127}
1110         * Maximum transmission power level for advertising, which is {@code 1}
1111         * Default transmission power level for advertising, which is {@code -7}
1112         */
1113        txPower?: number;
1114        /** Indicates whether the BLE is connectable, default is {@code true} */
1115        connectable?: boolean;
1116    }
1117
1118    /**
1119     * Describes the advertising data.
1120     *
1121     * @since 7
1122     */
1123    interface AdvertiseData {
1124        /** The specified service UUID list to this advertisement */
1125        serviceUuids: Array<string>;
1126        /** The specified manufacturer data list to this advertisement */
1127        manufactureData: Array<ManufactureData>;
1128        /** The specified service data list to this advertisement */
1129        serviceData: Array<ServiceData>;
1130    }
1131
1132    /**
1133     * Describes the manufacturer data.
1134     *
1135     * @since 7
1136     */
1137    interface ManufactureData {
1138        /** Indicates the manufacturer ID assigned by Bluetooth SIG */
1139        manufactureId: number;
1140        /** Indicates the manufacturer data to add */
1141        manufactureValue: ArrayBuffer;
1142    }
1143
1144    /**
1145     * Describes the service data.
1146     *
1147     * @since 7
1148     */
1149    interface ServiceData {
1150        /** Indicates the UUID of the service data to add */
1151        serviceUuid: string;
1152        /** Indicates the service data to add */
1153        serviceValue: ArrayBuffer;
1154    }
1155
1156    /**
1157     * Describes the criteria for filtering scanning results can be set.
1158     *
1159     * @since 7
1160     */
1161    interface ScanFilter {
1162        /** The address of a BLE peripheral device */
1163        deviceId?: string;
1164        /** The name of a BLE peripheral device */
1165        name?: string;
1166        /** The service UUID of a BLE peripheral device */
1167        serviceUuid?: string;
1168    }
1169
1170    /**
1171     * Describes the parameters for scan.
1172     *
1173     * @since 7
1174     */
1175    interface ScanOptions {
1176        /** Time of delay for reporting the scan result */
1177        interval?: number;
1178        /** Bluetooth LE scan mode */
1179        dutyMode?: ScanDuty;
1180        /** Match mode for Bluetooth LE scan filters hardware match */
1181        matchMode?: MatchMode;
1182    }
1183
1184    /**
1185     * Describes the spp parameters.
1186     *
1187     * @since 8
1188     */
1189    interface SppOption {
1190        /** Indicates the UUID in the SDP record. */
1191        uuid: string;
1192        /** Indicates secure channel or not */
1193        secure: boolean;
1194        /** Spp link type {@link SppType}*/
1195        type: SppType;
1196    }
1197
1198    /**
1199     * Describes the bond key param.
1200     *
1201     * @since 8
1202     */
1203    interface PinRequiredParam {
1204        deviceId: string;
1205        pinCode: string;
1206    }
1207
1208    /**
1209     * Describes the class of a bluetooth device.
1210     *
1211     * @since 8
1212     */
1213    interface DeviceClass {
1214        majorClass: MajorClass;
1215        majorMinorClass: MajorMinorClass;
1216        classOfDevice: number;
1217    }
1218
1219    /**
1220     * Describes the class of a bluetooth device.
1221     *
1222     * @since 8
1223     */
1224    interface BondStateParam {
1225        deviceId: string;
1226        state: BondState;
1227    }
1228
1229    enum ScanDuty {
1230        /** low power mode */
1231        SCAN_MODE_LOW_POWER = 0,
1232        /** balanced power mode */
1233        SCAN_MODE_BALANCED = 1,
1234        /** Scan using highest duty cycle */
1235        SCAN_MODE_LOW_LATENCY = 2
1236    }
1237
1238    enum MatchMode {
1239        /** aggressive mode */
1240        MATCH_MODE_AGGRESSIVE = 1,
1241        /** sticky mode */
1242        MATCH_MODE_STICKY = 2
1243    }
1244
1245    enum ProfileConnectionState {
1246        /** the current profile is disconnected */
1247        STATE_DISCONNECTED = 0,
1248        /** the current profile is being connected */
1249        STATE_CONNECTING = 1,
1250        /** the current profile is connected */
1251        STATE_CONNECTED = 2,
1252        /** the current profile is being disconnected */
1253        STATE_DISCONNECTING = 3
1254    }
1255
1256    enum BluetoothState {
1257        /** Indicates the local Bluetooth is off */
1258        STATE_OFF = 0,
1259        /** Indicates the local Bluetooth is turning on */
1260        STATE_TURNING_ON = 1,
1261        /** Indicates the local Bluetooth is on, and ready for use */
1262        STATE_ON = 2,
1263        /** Indicates the local Bluetooth is turning off */
1264        STATE_TURNING_OFF = 3,
1265        /** Indicates the local Bluetooth is turning LE mode on */
1266        STATE_BLE_TURNING_ON = 4,
1267        /** Indicates the local Bluetooth is in LE only mode */
1268        STATE_BLE_ON = 5,
1269        /** Indicates the local Bluetooth is turning off LE only mode */
1270        STATE_BLE_TURNING_OFF = 6
1271    }
1272
1273    /**
1274     * The enum of SPP type.
1275     *
1276     * @since 8
1277     */
1278    enum SppType {
1279        /** RFCOMM */
1280        SPP_RFCOMM
1281    }
1282
1283    /**
1284     * The enum of BR scan mode.
1285     *
1286     * @since 8
1287     */
1288    enum ScanMode {
1289        /** Indicates the scan mode is none */
1290        SCAN_MODE_NONE = 0,
1291        /** Indicates the scan mode is connectable */
1292        SCAN_MODE_CONNECTABLE = 1,
1293        /** Indicates the scan mode is general discoverable */
1294        SCAN_MODE_GENERAL_DISCOVERABLE = 2,
1295        /** Indicates the scan mode is limited discoverable */
1296        SCAN_MODE_LIMITED_DISCOVERABLE = 3,
1297        /** Indicates the scan mode is connectable and general discoverable */
1298        SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE = 4,
1299        /** Indicates the scan mode is connectable and limited discoverable */
1300        SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE = 5
1301    }
1302
1303    /**
1304     * The enum of bond state.
1305     *
1306     * @since 8
1307     */
1308    enum BondState {
1309        /** Indicate the bond state is invalid */
1310        BOND_STATE_INVALID = 0,
1311        /** Indicate the bond state is bonding */
1312        BOND_STATE_BONDING = 1,
1313        /** Indicate the bond state is bonded*/
1314        BOND_STATE_BONDED = 2
1315    }
1316
1317    /**
1318     * The enum of major class of a bluetooth device.
1319     *
1320     * @since 8
1321     */
1322    enum MajorClass {
1323        MAJOR_MISC = 0x0000,
1324        MAJOR_COMPUTER = 0x0100,
1325        MAJOR_PHONE = 0x0200,
1326        MAJOR_NETWORKING = 0x0300,
1327        MAJOR_AUDIO_VIDEO = 0x0400,
1328        MAJOR_PERIPHERAL = 0x0500,
1329        MAJOR_IMAGING = 0x0600,
1330        MAJOR_WEARABLE = 0x0700,
1331        MAJOR_TOY = 0x0800,
1332        MAJOR_HEALTH = 0x0900,
1333        MAJOR_UNCATEGORIZED = 0x1F00
1334    }
1335
1336    /**
1337     * The enum of major minor class of a bluetooth device.
1338     *
1339     * @since 8
1340     */
1341    enum MajorMinorClass {
1342        // The Minor Device Class field
1343        // Computer Major Class
1344        COMPUTER_UNCATEGORIZED = 0x0100,
1345        COMPUTER_DESKTOP = 0x0104,
1346        COMPUTER_SERVER = 0x0108,
1347        COMPUTER_LAPTOP = 0x010C,
1348        COMPUTER_HANDHELD_PC_PDA = 0x0110,
1349        COMPUTER_PALM_SIZE_PC_PDA = 0x0114,
1350        COMPUTER_WEARABLE = 0x0118,
1351        COMPUTER_TABLET = 0x011C,
1352
1353        // Phone Major Class
1354        PHONE_UNCATEGORIZED = 0x0200,
1355        PHONE_CELLULAR = 0x0204,
1356        PHONE_CORDLESS = 0x0208,
1357        PHONE_SMART = 0x020C,
1358        PHONE_MODEM_OR_GATEWAY = 0x0210,
1359        PHONE_ISDN = 0x0214,
1360
1361        // LAN/Network Access Point Major Class
1362        NETWORK_FULLY_AVAILABLE = 0x0300,
1363        NETWORK_1_TO_17_UTILIZED = 0x0320,
1364        NETWORK_17_TO_33_UTILIZED = 0x0340,
1365        NETWORK_33_TO_50_UTILIZED = 0x0360,
1366        NETWORK_60_TO_67_UTILIZED = 0x0380,
1367        NETWORK_67_TO_83_UTILIZED = 0x03A0,
1368        NETWORK_83_TO_99_UTILIZED = 0x03C0,
1369        NETWORK_NO_SERVICE = 0x03E0,
1370
1371        // Audio/Video Major Class
1372        AUDIO_VIDEO_UNCATEGORIZED = 0x0400,
1373        AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404,
1374        AUDIO_VIDEO_HANDSFREE = 0x0408,
1375        AUDIO_VIDEO_MICROPHONE = 0x0410,
1376        AUDIO_VIDEO_LOUDSPEAKER = 0x0414,
1377        AUDIO_VIDEO_HEADPHONES = 0x0418,
1378        AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C,
1379        AUDIO_VIDEO_CAR_AUDIO = 0x0420,
1380        AUDIO_VIDEO_SET_TOP_BOX = 0x0424,
1381        AUDIO_VIDEO_HIFI_AUDIO = 0x0428,
1382        AUDIO_VIDEO_VCR = 0x042C,
1383        AUDIO_VIDEO_VIDEO_CAMERA = 0x0430,
1384        AUDIO_VIDEO_CAMCORDER = 0x0434,
1385        AUDIO_VIDEO_VIDEO_MONITOR = 0x0438,
1386        AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C,
1387        AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440,
1388        AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448,
1389
1390        // Peripheral Major Class
1391        PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500,
1392        PERIPHERAL_KEYBOARD = 0x0540,
1393        PERIPHERAL_POINTING_DEVICE = 0x0580,
1394        PERIPHERAL_KEYBOARD_POINTING = 0x05C0,
1395        PERIPHERAL_UNCATEGORIZED = 0x0500,
1396        PERIPHERAL_JOYSTICK = 0x0504,
1397        PERIPHERAL_GAMEPAD = 0x0508,
1398        PERIPHERAL_REMOTE_CONTROL = 0x05C0,
1399        PERIPHERAL_SENSING_DEVICE = 0x0510,
1400        PERIPHERAL_DIGITIZER_TABLET = 0x0514,
1401        PERIPHERAL_CARD_READER = 0x0518,
1402        PERIPHERAL_DIGITAL_PEN = 0x051C,
1403        PERIPHERAL_SCANNER_RFID = 0x0520,
1404        PERIPHERAL_GESTURAL_INPUT = 0x0522,
1405
1406        // Imaging Major Class
1407        IMAGING_UNCATEGORIZED = 0x0600,
1408        IMAGING_DISPLAY = 0x0610,
1409        IMAGING_CAMERA = 0x0620,
1410        IMAGING_SCANNER = 0x0640,
1411        IMAGING_PRINTER = 0x0680,
1412
1413        // Wearable Major Class
1414        WEARABLE_UNCATEGORIZED = 0x0700,
1415        WEARABLE_WRIST_WATCH = 0x0704,
1416        WEARABLE_PAGER = 0x0708,
1417        WEARABLE_JACKET = 0x070C,
1418        WEARABLE_HELMET = 0x0710,
1419        WEARABLE_GLASSES = 0x0714,
1420
1421        // Minor Device Class field - Toy Major Class
1422        TOY_UNCATEGORIZED = 0x0800,
1423        TOY_ROBOT = 0x0804,
1424        TOY_VEHICLE = 0x0808,
1425        TOY_DOLL_ACTION_FIGURE = 0x080C,
1426        TOY_CONTROLLER = 0x0810,
1427        TOY_GAME = 0x0814,
1428
1429        // Minor Device Class field - Health
1430        HEALTH_UNCATEGORIZED = 0x0900,
1431        HEALTH_BLOOD_PRESSURE = 0x0904,
1432        HEALTH_THERMOMETER = 0x0908,
1433        HEALTH_WEIGHING = 0x090C,
1434        HEALTH_GLUCOSE = 0x0910,
1435        HEALTH_PULSE_OXIMETER = 0x0914,
1436        HEALTH_PULSE_RATE = 0x0918,
1437        HEALTH_DATA_DISPLAY = 0x091C,
1438        HEALTH_STEP_COUNTER = 0x0920,
1439        HEALTH_BODY_COMPOSITION_ANALYZER = 0x0924,
1440        HEALTH_PEAK_FLOW_MOITOR = 0x0928,
1441        HEALTH_MEDICATION_MONITOR = 0x092C,
1442        HEALTH_KNEE_PROSTHESIS = 0x0930,
1443        HEALTH_ANKLE_PROSTHESIS = 0x0934,
1444        HEALTH_GENERIC_HEALTH_MANAGER = 0x0938,
1445        HEALTH_PERSONAL_MOBILITY_DEVICE = 0x093C,
1446    }
1447
1448    /**
1449     * Profile state change parameters.
1450     *
1451     * @since 8
1452     */
1453    interface StateChangeParam {
1454        /** The address of device */
1455        deviceId: string;
1456
1457        /** Profile state value */
1458        state: ProfileConnectionState;
1459    }
1460
1461    /**
1462     * The enum of a2dp playing state.
1463     *
1464     * @since 8
1465     */
1466    enum PlayingState {
1467        STATE_NOT_PLAYING,
1468        STATE_PLAYING,
1469    }
1470
1471    /**
1472     * The enum of profile id.
1473     *
1474     * @since 8
1475     */
1476    enum ProfileId {
1477        PROFILE_A2DP_SOURCE = 1,
1478        PROFILE_HANDS_FREE_AUDIO_GATEWAY = 4,
1479    }
1480}
1481
1482export default bluetooth;
1483