• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bluetoothManager (Bluetooth)
2
3The **Bluetooth** module provides classic Bluetooth capabilities and Bluetooth Low Energy (BLE) scan and advertising.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - The APIs provided by this module are no longer maintained since API version 10. You are advised to use profile APIs of [@ohos.bluetooth.ble](js-apis-bluetooth-ble.md).
9
10
11
12## Modules to Import
13
14```js
15import bluetoothManager from '@ohos.bluetoothManager';
16```
17
18
19## bluetoothManager.enableBluetooth<sup>(deprecated)</sup><a name="enableBluetooth"></a>
20
21enableBluetooth(): void
22
23Enables Bluetooth.
24
25> **NOTE**<br>
26> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [access.enableBluetooth](js-apis-bluetooth-access.md#accessenablebluetooth).
27
28**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
29
30**System capability**: SystemCapability.Communication.Bluetooth.Core
31
32**Error codes**
33
34For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
35
36| ID| Error Message|
37| -------- | ---------------------------- |
38|2900001 | Service stopped.                         |
39|2900099 | Operation failed.                        |
40
41**Example**
42
43```js
44import { BusinessError } from '@ohos.base';
45try {
46    bluetoothManager.enableBluetooth();
47} catch (err) {
48    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
49}
50```
51
52
53## bluetoothManager.disableBluetooth<sup>(deprecated)</sup><a name="disableBluetooth"></a>
54
55disableBluetooth(): void
56
57Disables Bluetooth.
58
59> **NOTE**<br>
60> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [access.disableBluetooth](js-apis-bluetooth-access.md#accessdisablebluetooth).
61
62**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
63
64**System capability**: SystemCapability.Communication.Bluetooth.Core
65
66**Error codes**
67
68For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
69
70| ID| Error Message|
71| -------- | ---------------------------- |
72|2900001 | Service stopped.                         |
73|2900099 | Operation failed.                        |
74
75**Example**
76
77```js
78import { BusinessError } from '@ohos.base';
79try {
80    bluetoothManager.disableBluetooth();
81} catch (err) {
82    console.error("errCode:" + (err as BusinessError).code + ", errMessage:" + (err as BusinessError).message);
83}
84```
85
86
87## bluetoothManager.getLocalName<sup>(deprecated)</sup><a name="getLocalName"></a>
88
89getLocalName(): string
90
91Obtains the name of the local Bluetooth device.
92
93> **NOTE**<br>
94> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getLocalName](js-apis-bluetooth-connection.md#connectiongetlocalname).
95
96**Required permissions**: ohos.permission.USE_BLUETOOTH
97
98**System capability**: SystemCapability.Communication.Bluetooth.Core
99
100**Return value**
101
102| Type    | Description       |
103| ------ | --------- |
104| string | Name of the local Bluetooth device obtained.|
105
106**Error codes**
107
108For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
109
110| ID| Error Message|
111| -------- | ---------------------------- |
112|2900001 | Service stopped.                         |
113|2900099 | Operation failed.                        |
114
115**Example**
116
117```js
118import { BusinessError } from '@ohos.base';
119try {
120    let localName: string = bluetoothManager.getLocalName();
121} catch (err) {
122    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
123}
124```
125
126
127## bluetoothManager.getState<sup>(deprecated)</sup>
128
129getState(): BluetoothState
130
131Obtains the Bluetooth state.
132
133> **NOTE**<br>
134> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [access.getState](js-apis-bluetooth-access.md#accessgetstate).
135
136**Required permissions**: ohos.permission.USE_BLUETOOTH
137
138**System capability**: SystemCapability.Communication.Bluetooth.Core
139
140**Return value**
141
142| Type                               | Description       |
143| --------------------------------- | --------- |
144| [BluetoothState](#bluetoothstate) | Bluetooth state obtained.|
145
146**Error codes**
147
148For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
149
150| ID| Error Message|
151| -------- | ---------------------------- |
152|2900001 | Service stopped.                         |
153|2900099 | Operation failed.                        |
154
155**Example**
156
157```js
158import { BusinessError } from '@ohos.base';
159try {
160    let state: bluetoothManager.BluetoothState = bluetoothManager.getState();
161} catch (err) {
162    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
163}
164```
165
166
167## bluetoothManager.getBtConnectionState<sup>(deprecated)</sup>
168
169getBtConnectionState(): ProfileConnectionState
170
171Obtains the local profile connection status.
172
173> **NOTE**<br>
174> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getProfileConnectionState](js-apis-bluetooth-connection.md#connectiongetprofileconnectionstate).
175
176**Required permissions**: ohos.permission.USE_BLUETOOTH
177
178**System capability**: SystemCapability.Communication.Bluetooth.Core
179
180**Return value**
181
182| Type                                      | Description                 |
183| ---------------------------------------- | ------------------- |
184| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
185
186**Error codes**
187
188For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
189
190| ID| Error Message|
191| -------- | ---------------------------- |
192|2900001 | Service stopped.                         |
193|2900003 | Bluetooth switch is off.                 |
194|2900099 | Operation failed.                        |
195
196**Example**
197
198```js
199import { BusinessError } from '@ohos.base';
200try {
201    let connectionState: bluetoothManager.ProfileConnectionState = bluetoothManager.getBtConnectionState();
202} catch (err) {
203    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
204}
205```
206
207
208## bluetoothManager.setLocalName<sup>(deprecated)</sup><a name="setLocalName"></a>
209
210setLocalName(name: string): void
211
212Sets the name of the local Bluetooth device.
213
214> **NOTE**<br>
215> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.setLocalName](js-apis-bluetooth-connection.md#connectionsetlocalname).
216
217**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
218
219**System capability**: SystemCapability.Communication.Bluetooth.Core
220
221**Parameters**
222
223| Name | Type    | Mandatory  | Description                   |
224| ---- | ------ | ---- | --------------------- |
225| name | string | Yes   | Bluetooth device name to set. It cannot exceed 248 bytes.|
226
227**Error codes**
228
229For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
230
231| ID| Error Message|
232| -------- | ---------------------------- |
233|2900001 | Service stopped.                         |
234|2900003 | Bluetooth switch is off.                 |
235|2900099 | Operation failed.                        |
236
237**Example**
238
239```js
240import { BusinessError } from '@ohos.base';
241try {
242    bluetoothManager.setLocalName('device_name');
243} catch (err) {
244    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
245}
246```
247
248
249## bluetoothManager.pairDevice<sup>(deprecated)</sup>
250
251pairDevice(deviceId: string): void
252
253Initiates Bluetooth pairing.
254
255> **NOTE**<br>
256> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.pairDevice](js-apis-bluetooth-connection.md#connectionpairdevice).
257
258**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
259
260**System capability**: SystemCapability.Communication.Bluetooth.Core
261
262**Parameters**
263
264| Name     | Type    | Mandatory  | Description                                 |
265| -------- | ------ | ---- | ----------------------------------- |
266| deviceId | string | Yes   | Address of the remote device to pair, for example, XX:XX:XX:XX:XX:XX.|
267
268**Error codes**
269
270For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
271
272| ID| Error Message|
273| -------- | ---------------------------- |
274|2900001 | Service stopped.                         |
275|2900003 | Bluetooth switch is off.                 |
276|2900099 | Operation failed.                        |
277
278**Example**
279
280```js
281import { BusinessError } from '@ohos.base';
282try {
283    // The address can be scanned.
284    bluetoothManager.pairDevice("XX:XX:XX:XX:XX:XX");
285} catch (err) {
286    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
287}
288```
289
290
291## bluetoothManager.getProfileConnectionState<sup>(deprecated)</sup><a name="getProfileConnectionState"></a>
292
293getProfileConnectionState(profileId: ProfileId): ProfileConnectionState
294
295Obtains the connection status of the specified profile.
296
297> **NOTE**<br>
298> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getProfileConnectionState](js-apis-bluetooth-connection.md#connectiongetprofileconnectionstate).
299
300**Required permissions**: ohos.permission.USE_BLUETOOTH
301
302**System capability**: SystemCapability.Communication.Bluetooth.Core
303
304**Parameters**
305
306| Name      | Type       | Mandatory  | Description                                   |
307| --------- | --------- | ---- | ------------------------------------- |
308| ProfileId | profileId | Yes   | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
309
310**Return value**
311
312| Type                                             | Description               |
313| ------------------------------------------------- | ------------------- |
314| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
315
316**Error codes**
317
318For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
319
320| ID| Error Message|
321| -------- | ---------------------------- |
322|2900001 | Service stopped.                         |
323|2900003 | Bluetooth switch is off.                 |
324|2900004 | Profile is not supported.                |
325|2900099 | Operation failed.                        |
326
327**Example**
328
329```js
330import { BusinessError } from '@ohos.base';
331try {
332    let result: bluetoothManager.ProfileConnectionState = bluetoothManager.getProfileConnectionState(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE);
333} catch (err) {
334    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
335}
336```
337
338
339## bluetoothManager.cancelPairedDevice<sup>(deprecated)</sup><a name="cancelPairedDevice"></a>
340
341cancelPairedDevice(deviceId: string): void
342
343Cancels a paired remote device.
344
345> **NOTE**<br>
346> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.cancelPairedDevice](js-apis-bluetooth-connection.md#connectioncancelpaireddevice).
347
348**System API**: This is a system API.
349
350**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
351
352**System capability**: SystemCapability.Communication.Bluetooth.Core
353
354**Parameters**
355
356| Name     | Type    | Mandatory  | Description                                   |
357| -------- | ------ | ---- | ------------------------------------- |
358| deviceId | string | Yes   | Address of the remote device to cancel, for example, XX:XX:XX:XX:XX:XX.|
359
360**Error codes**
361
362For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
363
364| ID| Error Message|
365| -------- | ---------------------------- |
366|2900001 | Service stopped.                         |
367|2900003 | Bluetooth switch is off.                 |
368|2900099 | Operation failed.                        |
369
370**Example**
371
372```js
373import { BusinessError } from '@ohos.base';
374try {
375    bluetoothManager.cancelPairedDevice("XX:XX:XX:XX:XX:XX");
376} catch (err) {
377    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
378}
379```
380
381
382## bluetoothManager.getRemoteDeviceName<sup>(deprecated)</sup><a name="getRemoteDeviceName"></a>
383
384getRemoteDeviceName(deviceId: string): string
385
386Obtains the name of the remote Bluetooth device.
387
388> **NOTE**<br>
389> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getRemoteDeviceName](js-apis-bluetooth-connection.md#connectiongetremotedevicename).
390
391**Required permissions**: ohos.permission.USE_BLUETOOTH
392
393**System capability**: SystemCapability.Communication.Bluetooth.Core
394
395**Parameters**
396
397| Name     | Type    | Mandatory  | Description                               |
398| -------- | ------ | ---- | --------------------------------- |
399| deviceId | string | Yes   | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
400
401**Return value**
402
403| Type    | Description           |
404| ------ | ------------- |
405| string | Device name (a string) obtained.|
406
407**Error codes**
408
409For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
410
411| ID| Error Message|
412| -------- | ---------------------------- |
413|2900001 | Service stopped.                         |
414|2900003 | Bluetooth switch is off.                 |
415|2900099 | Operation failed.                        |
416
417**Example**
418
419```js
420import { BusinessError } from '@ohos.base';
421try {
422    let remoteDeviceName: string = bluetoothManager.getRemoteDeviceName("XX:XX:XX:XX:XX:XX");
423} catch (err) {
424    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
425}
426```
427
428
429## bluetoothManager.getRemoteDeviceClass<sup>(deprecated)</sup><a name="getRemoteDeviceClass"></a>
430
431getRemoteDeviceClass(deviceId: string): DeviceClass
432
433Obtains the class of the remote Bluetooth device.
434
435> **NOTE**<br>
436> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getRemoteDeviceClass](js-apis-bluetooth-connection.md#connectiongetremotedeviceclass).
437
438**Required permissions**: ohos.permission.USE_BLUETOOTH
439
440**System capability**: SystemCapability.Communication.Bluetooth.Core
441
442**Parameters**
443
444| Name     | Type    | Mandatory  | Description                               |
445| -------- | ------ | ---- | --------------------------------- |
446| deviceId | string | Yes   | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
447
448**Return value**
449
450| Type                         | Description      |
451| --------------------------- | -------- |
452| [DeviceClass](#deviceclass) | Class of the remote device obtained.|
453
454**Error codes**
455
456For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
457
458| ID| Error Message|
459| -------- | ---------------------------- |
460|2900001 | Service stopped.                         |
461|2900003 | Bluetooth switch is off.                 |
462|2900099 | Operation failed.                        |
463
464**Example**
465
466```js
467import { BusinessError } from '@ohos.base';
468try {
469    let remoteDeviceClass: bluetoothManager.DeviceClass  = bluetoothManager.getRemoteDeviceClass("XX:XX:XX:XX:XX:XX");
470} catch (err) {
471    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
472}
473```
474
475
476## bluetoothManager.getPairedDevices<sup>(deprecated)</sup><a name="getPairedDevices"></a>
477
478getPairedDevices(): Array&lt;string&gt;
479
480Obtains the paired devices.
481
482> **NOTE**<br>
483> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getPairedDevices](js-apis-bluetooth-connection.md#connectiongetpaireddevices).
484
485**Required permissions**: ohos.permission.USE_BLUETOOTH
486
487**System capability**: SystemCapability.Communication.Bluetooth.Core
488
489**Return value**
490
491| Type                 | Description           |
492| ------------------- | ------------- |
493| Array&lt;string&gt; | Addresses of the paired Bluetooth devices.|
494
495**Error codes**
496
497For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
498
499| ID| Error Message|
500| -------- | ---------------------------- |
501|2900001 | Service stopped.                         |
502|2900003 | Bluetooth switch is off.                 |
503|2900099 | Operation failed.                        |
504
505**Example**
506
507```js
508import { BusinessError } from '@ohos.base';
509try {
510    let devices: Array<string> = bluetoothManager.getPairedDevices();
511} catch (err) {
512    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
513}
514```
515
516
517## bluetoothManager.setBluetoothScanMode<sup>(deprecated)</sup><a name="setBluetoothScanMode"></a>
518
519setBluetoothScanMode(mode: ScanMode, duration: number): void
520
521Sets the Bluetooth scan mode so that the device can be discovered by a remote device.
522
523> **NOTE**<br>
524> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.setBluetoothScanMode](js-apis-bluetooth-connection.md#connectionsetbluetoothscanmode).
525
526**Required permissions**: ohos.permission.USE_BLUETOOTH
527
528**System capability**: SystemCapability.Communication.Bluetooth.Core
529
530**Parameters**
531
532| Name     | Type                   | Mandatory  | Description                          |
533| -------- | --------------------- | ---- | ---------------------------- |
534| mode     | [ScanMode](#scanmode) | Yes   | Bluetooth scan mode to set.                     |
535| duration | number                | Yes   | Duration (in ms) in which the device can be discovered. The value **0** indicates unlimited time.|
536
537**Error codes**
538
539For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
540
541| ID| Error Message|
542| -------- | ---------------------------- |
543|2900001 | Service stopped.                         |
544|2900003 | Bluetooth switch is off.                 |
545|2900099 | Operation failed.                        |
546
547**Example**
548
549```js
550import { BusinessError } from '@ohos.base';
551try {
552    // The device can be discovered and connected only when the discoverable and connectable mode is used.
553    bluetoothManager.setBluetoothScanMode(bluetoothManager.ScanMode.SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
554} catch (err) {
555    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
556}
557```
558
559
560## bluetoothManager.getBluetoothScanMode<sup>(deprecated)</sup><a name="getBluetoothScanMode"></a>
561
562getBluetoothScanMode(): ScanMode
563
564Obtains the Bluetooth scan mode.
565
566> **NOTE**<br>
567> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.getBluetoothScanMode](js-apis-bluetooth-connection.md#connectiongetbluetoothscanmode).
568
569**Required permissions**: ohos.permission.USE_BLUETOOTH
570
571**System capability**: SystemCapability.Communication.Bluetooth.Core
572
573**Return value**
574
575| Type                   | Description     |
576| --------------------- | ------- |
577| [ScanMode](#scanmode) | Bluetooth scan mode to set.|
578
579**Error codes**
580
581For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
582
583| ID| Error Message|
584| -------- | ---------------------------- |
585|2900001 | Service stopped.                         |
586|2900003 | Bluetooth switch is off.                 |
587|2900099 | Operation failed.                        |
588
589**Example**
590
591```js
592import { BusinessError } from '@ohos.base';
593try {
594    let scanMode: bluetoothManager.ScanMode = bluetoothManager.getBluetoothScanMode();
595} catch (err) {
596    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
597}
598```
599
600
601## bluetoothManager.startBluetoothDiscovery<sup>(deprecated)</sup><a name="startBluetoothDiscovery"></a>
602
603startBluetoothDiscovery(): void
604
605Starts Bluetooth scan to discover remote devices.
606
607> **NOTE**<br>
608> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.startBluetoothDiscovery](js-apis-bluetooth-connection.md#connectionstartbluetoothdiscovery).
609
610**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
611
612**System capability**: SystemCapability.Communication.Bluetooth.Core
613
614**Error codes**
615
616For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
617
618| ID| Error Message|
619| -------- | ---------------------------- |
620|2900001 | Service stopped.                         |
621|2900003 | Bluetooth switch is off.                 |
622|2900099 | Operation failed.                        |
623
624**Example**
625
626```js
627import { BusinessError } from '@ohos.base';
628let deviceId: Array<string>;
629function onReceiveEvent(data: Array<string>) {
630    deviceId = data;
631}
632try {
633    bluetoothManager.on('bluetoothDeviceFind', onReceiveEvent);
634    bluetoothManager.startBluetoothDiscovery();
635} catch (err) {
636    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
637}
638```
639
640
641## bluetoothManager.stopBluetoothDiscovery<sup>(deprecated)</sup><a name="stopBluetoothDiscovery"></a>
642
643stopBluetoothDiscovery(): void
644
645Stops Bluetooth scan.
646
647> **NOTE**<br>
648> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.stopBluetoothDiscovery](js-apis-bluetooth-connection.md#connectionstopbluetoothdiscovery).
649
650**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
651
652**System capability**: SystemCapability.Communication.Bluetooth.Core
653
654**Error codes**
655
656For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
657
658| ID| Error Message|
659| -------- | ---------------------------- |
660|2900001 | Service stopped.                         |
661|2900003 | Bluetooth switch is off.                 |
662|2900099 | Operation failed.                        |
663
664**Example**
665
666```js
667import { BusinessError } from '@ohos.base';
668try {
669    bluetoothManager.stopBluetoothDiscovery();
670} catch (err) {
671    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
672}
673```
674
675
676## bluetoothManager.setDevicePairingConfirmation<sup>(deprecated)</sup><a name="setDevicePairingConfirmation"></a>
677
678setDevicePairingConfirmation(device: string, accept: boolean): void
679
680Sets the device pairing confirmation.
681
682> **NOTE**<br>
683> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.setDevicePairingConfirmation](js-apis-bluetooth-connection.md#connectionsetdevicepairingconfirmation).
684
685**Required permissions**: ohos.permission.MANAGE_BLUETOOTH
686
687**System capability**: SystemCapability.Communication.Bluetooth.Core
688
689**Parameters**
690
691| Name   | Type     | Mandatory  | Description                              |
692| ------ | ------- | ---- | -------------------------------- |
693| device | string  | Yes   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
694| accept | boolean | Yes   | Whether to accept the pairing request. The value **true** means to accept the pairing request, and the value **false** means the opposite.       |
695
696**Error codes**
697
698For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
699
700| ID| Error Message|
701| -------- | ---------------------------- |
702|2900001 | Service stopped.                         |
703|2900003 | Bluetooth switch is off.                 |
704|2900099 | Operation failed.                        |
705
706**Example**
707
708```js
709import { BusinessError } from '@ohos.base';
710// Subscribe to the pinRequired event and configure the pairing confirmation after receiving a pairing request from the remote device.
711function onReceivePinRequiredEvent(data: bluetoothManager.PinRequiredParam) { // data is the input parameter for the pairing request.
712    console.info('pin required  = '+ JSON.stringify(data));
713    bluetoothManager.setDevicePairingConfirmation(data.deviceId, true);
714}
715try {
716    bluetoothManager.on("pinRequired", onReceivePinRequiredEvent);
717} catch (err) {
718    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
719}
720```
721
722
723## bluetoothManager.on('bluetoothDeviceFind')<sup>(deprecated)</sup>
724
725on(type: "bluetoothDeviceFind", callback: Callback&lt;Array&lt;string&gt;&gt;): void
726
727Subscribes to the Bluetooth device discovery events.
728
729> **NOTE**<br>
730> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.on('bluetoothDeviceFind')](js-apis-bluetooth-connection.md#connectiononbluetoothdevicefind).
731
732**Required permissions**: ohos.permission.USE_BLUETOOTH
733
734**System capability**: SystemCapability.Communication.Bluetooth.Core
735
736**Parameters**
737
738| Name     | Type                                 | Mandatory  | Description                                    |
739| -------- | ----------------------------------- | ---- | -------------------------------------- |
740| type     | string                              | Yes   | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.|
741| callback | Callback&lt;Array&lt;string&gt;&gt; | Yes   | Callback invoked to return the discovered devices. You need to implement this callback.   |
742
743**Error codes**
744
745For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
746
747| ID| Error Message|
748| -------- | ---------------------------- |
749|2900099 | Operation failed.                        |
750
751**Example**
752
753```js
754import { BusinessError } from '@ohos.base';
755function onReceiveEvent(data: Array<string>) { // data is an array of Bluetooth device addresses.
756    console.info('bluetooth device find = '+ JSON.stringify(data));
757}
758try {
759    bluetoothManager.on('bluetoothDeviceFind', onReceiveEvent);
760} catch (err) {
761    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
762}
763```
764
765
766## bluetoothManager.off('bluetoothDeviceFind')<sup>(deprecated)</sup>
767
768off(type: "bluetoothDeviceFind", callback?: Callback&lt;Array&lt;string&gt;&gt;): void
769
770Unsubscribes from the Bluetooth device discovery events.
771
772> **NOTE**<br>
773> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.off('bluetoothDeviceFind')](js-apis-bluetooth-connection.md#connectionoffbluetoothdevicefind).
774
775**Required permissions**: ohos.permission.USE_BLUETOOTH
776
777**System capability**: SystemCapability.Communication.Bluetooth.Core
778
779**Parameters**
780
781| Name     | Type                                 | Mandatory  | Description                                      |
782| -------- | ----------------------------------- | ---- | ---------------------------------------- |
783| type     | string                              | Yes   | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.  |
784| callback | Callback&lt;Array&lt;string&gt;&gt; | No   | Callback for the **bluetoothDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
785
786**Error codes**
787
788For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
789
790| ID| Error Message|
791| -------- | ---------------------------- |
792|2900099 | Operation failed.                        |
793
794**Example**
795
796```js
797import { BusinessError } from '@ohos.base';
798function onReceiveEvent(data: Array<string>) {
799    console.info('bluetooth device find = '+ JSON.stringify(data));
800}
801try {
802    bluetoothManager.on('bluetoothDeviceFind', onReceiveEvent);
803    bluetoothManager.off('bluetoothDeviceFind', onReceiveEvent);
804} catch (err) {
805    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
806}
807```
808
809
810## bluetoothManager.on('pinRequired')<sup>(deprecated)</sup>
811
812on(type: "pinRequired", callback: Callback&lt;PinRequiredParam&gt;): void
813
814Subscribes to the pairing request events of the remote Bluetooth device.
815
816> **NOTE**<br>
817> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.on('pinRequired')](js-apis-bluetooth-connection.md#connectiononpinrequired).
818
819**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
820
821**System capability**: SystemCapability.Communication.Bluetooth.Core
822
823**Parameters**
824
825| Name     | Type                                      | Mandatory  | Description                              |
826| -------- | ---------------------------------------- | ---- | -------------------------------- |
827| type     | string                                   | Yes   | Event type. The value **pinRequired** indicates a pairing request event.    |
828| callback | Callback&lt;[PinRequiredParam](#pinrequiredparam)&gt; | Yes   | Callback invoked to return the pairing request. You need to implement this callback.|
829
830**Error codes**
831
832For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
833
834| ID| Error Message|
835| -------- | ---------------------------- |
836|2900099 | Operation failed.                        |
837
838**Example**
839
840```js
841import { BusinessError } from '@ohos.base';
842function onReceiveEvent(data: bluetoothManager.PinRequiredParam) { // data is the pairing request parameter.
843    console.info('pin required = '+ JSON.stringify(data));
844}
845try {
846    bluetoothManager.on('pinRequired', onReceiveEvent);
847} catch (err) {
848    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
849}
850```
851
852
853## bluetoothManager.off('pinRequired')<sup>(deprecated)</sup>
854
855off(type: "pinRequired", callback?: Callback&lt;PinRequiredParam&gt;): void
856
857Unsubscribes from the pairing request events of the remote Bluetooth device.
858
859> **NOTE**<br>
860> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.off('pinRequired')](js-apis-bluetooth-connection.md#connectionoffpinrequired).
861
862**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
863
864**System capability**: SystemCapability.Communication.Bluetooth.Core
865
866**Parameters**
867
868| Name     | Type                                      | Mandatory  | Description                                      |
869| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
870| type     | string                                   | Yes   | Event type. The value **pinRequired** indicates a pairing request event.            |
871| callback | Callback&lt;[PinRequiredParam](#pinrequiredparam)&gt; | No   | Callback for the Bluetooth pairing request event. The input parameter is the pairing request parameter. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
872
873**Error codes**
874
875For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
876
877| ID| Error Message|
878| -------- | ---------------------------- |
879|2900099 | Operation failed.                        |
880
881**Example**
882
883```js
884import { BusinessError } from '@ohos.base';
885function onReceiveEvent(data: bluetoothManager.PinRequiredParam) {
886    console.info('pin required = '+ JSON.stringify(data));
887}
888try {
889    bluetoothManager.on('pinRequired', onReceiveEvent);
890    bluetoothManager.off('pinRequired', onReceiveEvent);
891} catch (err) {
892    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
893}
894```
895
896
897## bluetoothManager.on('bondStateChange')<sup>(deprecated)</sup>
898
899on(type: "bondStateChange", callback: Callback&lt;BondStateParam&gt;): void
900
901Subscribes to the Bluetooth pairing state changes.
902
903> **NOTE**<br>
904> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.on('bondStateChange')](js-apis-bluetooth-connection.md#connectiononbondstatechange).
905
906**Required permissions**: ohos.permission.USE_BLUETOOTH
907
908**System capability**: SystemCapability.Communication.Bluetooth.Core
909
910**Parameters**
911
912| Name     | Type                                      | Mandatory  | Description                                  |
913| -------- | ---------------------------------------- | ---- | ------------------------------------ |
914| type     | string                                   | Yes   | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.|
915| callback | Callback&lt;[BondStateParam](#BondStateParam)&gt; | Yes   | Callback invoked to return the pairing state. You need to implement this callback.   |
916
917**Error codes**
918
919For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
920
921| ID| Error Message|
922| -------- | ---------------------------- |
923|2900099 | Operation failed.                        |
924
925**Example**
926
927```js
928import { BusinessError } from '@ohos.base';
929function onReceiveEvent(data: bluetoothManager.BondStateParam) { // data, as the input parameter of the callback, indicates the pairing state.
930    console.info('pair state = '+ JSON.stringify(data));
931}
932try {
933    bluetoothManager.on('bondStateChange', onReceiveEvent);
934} catch (err) {
935    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
936}
937```
938
939
940## bluetoothManager.off('bondStateChange')<sup>(deprecated)</sup>
941
942off(type: "bondStateChange", callback?: Callback&lt;BondStateParam&gt;): void
943
944Unsubscribes from the Bluetooth pairing state changes.
945
946> **NOTE**<br>
947> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.off('bondStateChange')](js-apis-bluetooth-connection.md#connectionoffbondstatechange).
948
949**Required permissions**: ohos.permission.USE_BLUETOOTH
950
951**System capability**: SystemCapability.Communication.Bluetooth.Core
952
953**Parameters**
954
955| Name     | Type                                      | Mandatory  | Description                                      |
956| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
957| type     | string                                   | Yes   | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.    |
958| callback | Callback&lt;[BondStateParam](#BondStateParam)&gt; | No   | Callback for the change of the Bluetooth pairing state. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
959
960**Error codes**
961
962For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
963
964| ID| Error Message|
965| -------- | ---------------------------- |
966|2900099 | Operation failed.                        |
967
968**Example**
969
970```js
971import { BusinessError } from '@ohos.base';
972function onReceiveEvent(data: bluetoothManager.BondStateParam) {
973    console.info('bond state = '+ JSON.stringify(data));
974}
975try {
976    bluetoothManager.on('bondStateChange', onReceiveEvent);
977    bluetoothManager.off('bondStateChange', onReceiveEvent);
978} catch (err) {
979    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
980}
981```
982
983
984## bluetoothManager.on('stateChange')<sup>(deprecated)</sup>
985
986on(type: "stateChange", callback: Callback&lt;BluetoothState&gt;): void
987
988Subscribes to Bluetooth state events.
989
990> **NOTE**<br>
991> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [access.on('stateChange')](js-apis-bluetooth-access.md#accessonstatechange).
992
993**Required permissions**: ohos.permission.USE_BLUETOOTH
994
995**System capability**: SystemCapability.Communication.Bluetooth.Core
996
997**Parameters**
998
999| Name     | Type                                      | Mandatory  | Description                              |
1000| -------- | ---------------------------------------- | ---- | -------------------------------- |
1001| type     | string                                   | Yes   | Event type. The value **stateChange** indicates a Bluetooth connection state change event.  |
1002| callback | Callback&lt;[BluetoothState](#bluetoothstate)&gt; | Yes   | Callback invoked to return the Bluetooth connection state. You need to implement this callback.|
1003
1004**Error codes**
1005
1006For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1007
1008| ID| Error Message|
1009| -------- | ---------------------------- |
1010|2900099 | Operation failed.                        |
1011
1012**Example**
1013
1014```js
1015import { BusinessError } from '@ohos.base';
1016function onReceiveEvent(data: bluetoothManager.BluetoothState) {
1017    console.info('bluetooth state = '+ JSON.stringify(data));
1018}
1019try {
1020    bluetoothManager.on('stateChange', onReceiveEvent);
1021} catch (err) {
1022    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1023}
1024```
1025
1026
1027## bluetoothManager.off('stateChange')<sup>(deprecated)</sup>
1028
1029off(type: "stateChange", callback?: Callback&lt;BluetoothState&gt;): void
1030
1031Unsubscribes from Bluetooth state events.
1032
1033> **NOTE**<br>
1034> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [access.off('stateChange')](js-apis-bluetooth-access.md#accessoffstatechange).
1035
1036**Required permissions**: ohos.permission.USE_BLUETOOTH
1037
1038**System capability**: SystemCapability.Communication.Bluetooth.Core
1039
1040**Parameters**
1041
1042| Name     | Type                                      | Mandatory  | Description                                      |
1043| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1044| type     | string                                   | Yes   | Event type. The value **stateChange** indicates a Bluetooth connection state change event.          |
1045| callback | Callback&lt;[BluetoothState](#bluetoothstate)&gt; | No   | Callback for the Bluetooth connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
1046
1047**Error codes**
1048
1049For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1050
1051| ID| Error Message|
1052| -------- | ---------------------------- |
1053|2900099 | Operation failed.                        |
1054
1055**Example**
1056
1057```js
1058import { BusinessError } from '@ohos.base';
1059function onReceiveEvent(data: bluetoothManager.BluetoothState) {
1060    console.info('bluetooth state = '+ JSON.stringify(data));
1061}
1062try {
1063    bluetoothManager.on('stateChange', onReceiveEvent);
1064    bluetoothManager.off('stateChange', onReceiveEvent);
1065} catch (err) {
1066    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1067}
1068```
1069
1070
1071## bluetoothManager.sppListen<sup>(deprecated)</sup><a name="sppListen"></a>
1072
1073sppListen(name: string, option: SppOption, callback: AsyncCallback&lt;number&gt;): void
1074
1075Creates a server listening socket.
1076
1077> **NOTE**<br>
1078> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.sppListen](js-apis-bluetooth-socket.md#socketspplisten).
1079
1080**Required permissions**: ohos.permission.USE_BLUETOOTH
1081
1082**System capability**: SystemCapability.Communication.Bluetooth.Core
1083
1084**Parameters**
1085
1086| Name     | Type                         | Mandatory  | Description                     |
1087| -------- | --------------------------- | ---- | ----------------------- |
1088| name     | string                      | Yes   | Name of the service.                 |
1089| option   | [SppOption](#sppoption)     | Yes   | Serial port profile (SPP) listening configuration.             |
1090| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the server socket ID.|
1091
1092**Error codes**
1093
1094For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1095
1096| ID| Error Message|
1097| -------- | ---------------------------- |
1098|2900001 | Service stopped.                         |
1099|2900003 | Bluetooth switch is off.                 |
1100|2900004 | Profile is not supported.                |
1101|2900099 | Operation failed.                        |
1102
1103**Example**
1104
1105```js
1106import { BusinessError } from '@ohos.base';
1107let serverNumber = -1;
1108function serverSocket(code: BusinessError, number: number) {
1109  console.log('bluetooth error code: ' + code.code);
1110  if (code.code == 0) {
1111    console.log('bluetooth serverSocket Number: ' + number);
1112    serverNumber = number;
1113  }
1114}
1115
1116let sppOption: bluetoothManager.SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
1117try {
1118    bluetoothManager.sppListen('server1', sppOption, serverSocket);
1119} catch (err) {
1120    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1121}
1122```
1123
1124
1125## bluetoothManager.sppAccept<sup>(deprecated)</sup><a name="sppAccept"></a>
1126
1127sppAccept(serverSocket: number, callback: AsyncCallback&lt;number&gt;): void
1128
1129Listens for a connection to be made to this socket from the client and accepts it.
1130
1131> **NOTE**<br>
1132> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.sppAccept](js-apis-bluetooth-socket.md#socketsppaccept).
1133
1134**System capability**: SystemCapability.Communication.Bluetooth.Core
1135
1136**Parameters**
1137
1138| Name         | Type                         | Mandatory  | Description                     |
1139| ------------ | --------------------------- | ---- | ----------------------- |
1140| serverSocket | number                      | Yes   | Server socket ID.          |
1141| callback     | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the client socket ID.|
1142
1143**Error codes**
1144
1145For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1146
1147| ID| Error Message|
1148| -------- | ---------------------------- |
1149|2900001 | Service stopped.                         |
1150|2900003 | Bluetooth switch is off.                 |
1151|2900004 | Profile is not supported.                |
1152|2900099 | Operation failed.                        |
1153
1154**Example**
1155
1156```js
1157import { BusinessError } from '@ohos.base';
1158let serverNumber = -1;
1159function serverSocket(code: BusinessError, number: number) {
1160  console.log('bluetooth error code: ' + code.code);
1161  if (code.code == 0) {
1162    console.log('bluetooth serverSocket Number: ' + number);
1163    serverNumber = number;
1164  }
1165}
1166let clientNumber = -1;
1167function acceptClientSocket(code: BusinessError, number: number) {
1168  console.log('bluetooth error code: ' + code.code);
1169  if (code.code == 0) {
1170    console.log('bluetooth clientSocket Number: ' + number);
1171    // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the server.
1172    clientNumber = number;
1173  }
1174}
1175try {
1176    bluetoothManager.sppAccept(serverNumber, acceptClientSocket);
1177} catch (err) {
1178    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1179}
1180```
1181
1182
1183## bluetoothManager.sppConnect<sup>(deprecated)</sup><a name="sppConnect"></a>
1184
1185sppConnect(device: string, option: SppOption, callback: AsyncCallback&lt;number&gt;): void
1186
1187Initiates an SPP connection to a remote device from the client.
1188
1189> **NOTE**<br>
1190> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.sppConnect](js-apis-bluetooth-socket.md#socketsppconnect).
1191
1192**Required permissions**: ohos.permission.USE_BLUETOOTH
1193
1194**System capability**: SystemCapability.Communication.Bluetooth.Core
1195
1196**Parameters**
1197
1198| Name     | Type                         | Mandatory  | Description                            |
1199| -------- | --------------------------- | ---- | ------------------------------ |
1200| device   | string                      | Yes   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
1201| option   | [SppOption](#sppoption)     | Yes   | Configuration for connecting to the SPP client.                 |
1202| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the client socket ID.       |
1203
1204**Error codes**
1205
1206For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1207
1208| ID| Error Message|
1209| -------- | ---------------------------- |
1210|2900001 | Service stopped.                         |
1211|2900003 | Bluetooth switch is off.                 |
1212|2900004 | Profile is not supported.                |
1213|2900099 | Operation failed.                        |
1214
1215**Example**
1216
1217```js
1218import { BusinessError } from '@ohos.base';
1219
1220let clientNumber = -1;
1221function clientSocket(code: BusinessError, number: number) {
1222  if (code.code != 0 || code == null) {
1223    return;
1224  }
1225  console.log('bluetooth serverSocket Number: ' + number);
1226  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1227  clientNumber = number;
1228}
1229let sppOption: bluetoothManager.SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
1230try {
1231    bluetoothManager.sppConnect('XX:XX:XX:XX:XX:XX', sppOption, clientSocket);
1232} catch (err) {
1233    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1234}
1235```
1236
1237
1238## bluetoothManager.sppCloseServerSocket<sup>(deprecated)</sup><a name="sppCloseServerSocket"></a>
1239
1240sppCloseServerSocket(socket: number): void
1241
1242Closes the listening socket of the server.
1243
1244> **NOTE**<br>
1245> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.sppCloseServerSocket](js-apis-bluetooth-socket.md#socketsppcloseserversocket).
1246
1247**System capability**: SystemCapability.Communication.Bluetooth.Core
1248
1249**Parameters**
1250
1251| Name   | Type    | Mandatory  | Description             |
1252| ------ | ------ | ---- | --------------- |
1253| socket | number | Yes   | ID of the listening socket on the server. The ID is obtained by **sppListen**.|
1254
1255**Error codes**
1256
1257For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1258
1259| ID| Error Message|
1260| -------- | ---------------------------- |
1261|2900001 | Service stopped.                         |
1262|2900099 | Operation failed.                        |
1263
1264**Example**
1265
1266```js
1267import { BusinessError } from '@ohos.base';
1268let serverNumber = -1;
1269function serverSocket(code: BusinessError, number: number) {
1270  console.log('bluetooth error code: ' + code.code);
1271  if (code.code == 0) {
1272    console.log('bluetooth serverSocket Number: ' + number);
1273    serverNumber = number;
1274  }
1275}
1276try {
1277    bluetoothManager.sppCloseServerSocket(serverNumber);
1278} catch (err) {
1279    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1280}
1281```
1282
1283
1284## bluetoothManager.sppCloseClientSocket<sup>(deprecated)</sup><a name="sppCloseClientSocket"></a>
1285
1286sppCloseClientSocket(socket: number): void
1287
1288Closes the client socket.
1289
1290> **NOTE**<br>
1291> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.sppCloseClientSocket](js-apis-bluetooth-socket.md#socketsppcloseclientsocket).
1292
1293**System capability**: SystemCapability.Communication.Bluetooth.Core
1294
1295**Parameters**
1296
1297| Name   | Type    | Mandatory  | Description           |
1298| ------ | ------ | ---- | ------------- |
1299| Name   | Type    | Mandatory  | Description           |
1300| socket | number | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
1301
1302**Error codes**
1303
1304For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1305
1306| ID| Error Message|
1307| -------- | ---------------------------- |
1308|2900001 | Service stopped.                         |
1309|2900099 | Operation failed.                        |
1310
1311**Example**
1312
1313```js
1314import { BusinessError } from '@ohos.base';
1315let clientNumber = -1;
1316function clientSocket(code: BusinessError, number: number) {
1317  if (code.code != 0 || code == null) {
1318    return;
1319  }
1320  console.log('bluetooth serverSocket Number: ' + number);
1321  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1322  clientNumber = number;
1323}
1324try {
1325    bluetoothManager.sppCloseClientSocket(clientNumber);
1326} catch (err) {
1327    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1328}
1329```
1330
1331
1332## bluetoothManager.sppWrite<sup>(deprecated)</sup><a name="sppWrite"></a>
1333
1334sppWrite(clientSocket: number, data: ArrayBuffer): void
1335
1336Writes data to the remote device through the socket.
1337
1338> **NOTE**<br>
1339> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.sppWrite](js-apis-bluetooth-socket.md#socketsppwrite).
1340
1341**System capability**: SystemCapability.Communication.Bluetooth.Core
1342
1343**Parameters**
1344
1345| Name         | Type         | Mandatory  | Description           |
1346| ------------ | ----------- | ---- | ------------- |
1347| clientSocket | number      | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
1348| data         | ArrayBuffer | Yes   | Data to write.       |
1349
1350**Error codes**
1351
1352For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1353
1354| ID| Error Message|
1355| -------- | ---------------------------- |
1356|2901054 | IO error.                                |
1357|2900099 | Operation failed.                        |
1358
1359**Example**
1360
1361```js
1362import { BusinessError } from '@ohos.base';
1363let clientNumber = -1;
1364function clientSocket(code: BusinessError, number: number) {
1365  if (code.code != 0 || code == null) {
1366    return;
1367  }
1368  console.log('bluetooth serverSocket Number: ' + number);
1369  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1370  clientNumber = number;
1371}
1372let arrayBuffer = new ArrayBuffer(8);
1373let data = new Uint8Array(arrayBuffer);
1374data[0] = 123;
1375try {
1376    bluetoothManager.sppWrite(clientNumber, arrayBuffer);
1377} catch (err) {
1378    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1379}
1380```
1381
1382
1383## bluetoothManager.on('sppRead')<sup>(deprecated)</sup>
1384
1385on(type: "sppRead", clientSocket: number, callback: Callback&lt;ArrayBuffer&gt;): void
1386
1387Subscribes to the SPP read request events.
1388
1389> **NOTE**<br>
1390> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.on('sppRead')](js-apis-bluetooth-socket.md#socketonsppread).
1391
1392**System capability**: SystemCapability.Communication.Bluetooth.Core
1393
1394**Parameters**
1395
1396| Name         | Type                         | Mandatory  | Description                        |
1397| ------------ | --------------------------- | ---- | -------------------------- |
1398| type         | string                      | Yes   | Event type. The value **sppRead** indicates an SPP read request event.|
1399| clientSocket | number                      | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.             |
1400| callback     | Callback&lt;ArrayBuffer&gt; | Yes   | Callback invoked to return the data read.         |
1401
1402**Error codes**
1403
1404For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1405
1406| ID| Error Message|
1407| -------- | ---------------------------- |
1408|2901054 | IO error.                                |
1409|2900099 | Operation failed.                        |
1410
1411**Example**
1412
1413```js
1414import { BusinessError } from '@ohos.base';
1415let clientNumber = -1;
1416function clientSocket(code: BusinessError, number: number) {
1417  if (code.code != 0 || code == null) {
1418    return;
1419  }
1420  console.log('bluetooth serverSocket Number: ' + number);
1421  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1422  clientNumber = number;
1423}
1424function dataRead(dataBuffer: ArrayBuffer) {
1425  let data = new Uint8Array(dataBuffer);
1426  console.log('bluetooth data is: ' + data[0]);
1427}
1428try {
1429    bluetoothManager.on('sppRead', clientNumber, dataRead);
1430} catch (err) {
1431    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1432}
1433```
1434
1435
1436## bluetoothManager.off('sppRead')<sup>(deprecated)</sup>
1437
1438off(type: "sppRead", clientSocket: number, callback?: Callback&lt;ArrayBuffer&gt;): void
1439
1440Unsubscribes from the SPP read request events.
1441
1442> **NOTE**<br>
1443> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.off('sppRead')](js-apis-bluetooth-socket.md#socketoffsppread).
1444
1445**System capability**: SystemCapability.Communication.Bluetooth.Core
1446
1447**Parameters**
1448
1449| Name         | Type                         | Mandatory  | Description                                      |
1450| ------------ | --------------------------- | ---- | ---------------------------------------- |
1451| type         | string                      | Yes   | Event type. The value **sppRead** indicates an SPP read request event.              |
1452| clientSocket | number                      | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.                           |
1453| callback     | Callback&lt;ArrayBuffer&gt; | No   | Callback for the SPP read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
1454
1455**Example**
1456
1457```js
1458import { BusinessError } from '@ohos.base';
1459let clientNumber = -1;
1460function clientSocket(code: BusinessError, number: number) {
1461  if (code.code != 0 || code == null) {
1462    return;
1463  }
1464  console.log('bluetooth serverSocket Number: ' + number);
1465  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1466  clientNumber = number;
1467}
1468try {
1469    bluetoothManager.off('sppRead', clientNumber);
1470} catch (err) {
1471    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1472}
1473```
1474
1475## bluetoothManager.getProfileInstance<sup>(deprecated)</sup><a name="getProfileInstance"></a>
1476
1477getProfileInstance(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile | HidHostProfile | PanProfile
1478
1479Obtains a profile instance. API version 9 is added with **HidHostProfile** and **PanProfile**.
1480
1481**System capability**: SystemCapability.Communication.Bluetooth.Core
1482
1483**Parameters**
1484
1485| Name      | Type       | Mandatory  | Description                                   |
1486| --------- | --------- | ---- | ------------------------------------- |
1487| profileId | [ProfileId](#ProfileId) | Yes   | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
1488
1489**Return value**
1490
1491| Type                                                        | Description                                                        |
1492| ------------------------------------------------------------ | ------------------------------------------------------------ |
1493| [A2dpSourceProfile](#a2dpsourceprofile), [HandsFreeAudioGatewayProfile](#handsfreeaudiogatewayprofile), [HidHostProfile](#hidhostprofile), or [PanProfile](#panprofile)| Profile instance obtained, which can be **A2dpSourceProfile**, **HandsFreeAudioGatewayProfile**, **HidHostProfile**, or **PanProfile**.|
1494
1495**Example**
1496
1497```js
1498import { BusinessError } from '@ohos.base';
1499try {
1500    let hidHost: bluetoothManager.HidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST);
1501} catch (err) {
1502    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1503}
1504```
1505
1506
1507## bluetoothManager.BLE
1508
1509### createGattServer<sup>(deprecated)</sup>
1510
1511createGattServer(): GattServer
1512
1513Creates a **GattServer** instance.
1514
1515> **NOTE**<br>
1516> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.createGattServer](js-apis-bluetooth-ble.md#blecreategattserver).
1517
1518**System capability**: SystemCapability.Communication.Bluetooth.Core
1519
1520**Return value**
1521
1522| Type                       | Description                                  |
1523| ------------------------- | ------------------------------------ |
1524| [GattServer](#gattserver) | **GattServer** instance created. Before using an API of this class, you must create a **GattSever** instance.|
1525
1526**Example**
1527
1528```js
1529let gattServer: bluetoothManager.GattServer  = bluetoothManager.BLE.createGattServer();
1530```
1531
1532
1533### createGattClientDevice<sup>(deprecated)</sup>
1534
1535createGattClientDevice(deviceId: string): GattClientDevice
1536
1537Creates a **GattClientDevice** instance.
1538
1539> **NOTE**<br>
1540> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.createGattClientDevice](js-apis-bluetooth-ble.md#blecreategattclientdevice).
1541
1542**System capability**: SystemCapability.Communication.Bluetooth.Core
1543
1544**Parameters**
1545
1546| Name     | Type    | Mandatory  | Description                                  |
1547| -------- | ------ | ---- | ------------------------------------ |
1548| deviceId | string | Yes   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
1549
1550**Return value**
1551
1552| Type                                   | Description                                  |
1553| ------------------------------------- | ------------------------------------ |
1554| [GattClientDevice](#gattclientdevice) | **GattClientDevice** instance created. Before using an API of the client, you must create a **GattClientDevice** instance.|
1555
1556**Example**
1557
1558```js
1559import { BusinessError } from '@ohos.base';
1560try {
1561    let device: bluetoothManager.GattClientDevice = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
1562} catch (err) {
1563    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1564}
1565```
1566
1567
1568### getConnectedBLEDevices<sup>(deprecated)</sup>
1569
1570getConnectedBLEDevices(): Array&lt;string&gt;
1571
1572Obtains the BLE devices connected to this device.
1573
1574> **NOTE**<br>
1575> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.getConnectedBLEDevices](js-apis-bluetooth-ble.md#blegetconnectedbledevices).
1576
1577**Required permissions**: ohos.permission.USE_BLUETOOTH
1578
1579**System capability**: SystemCapability.Communication.Bluetooth.Core
1580
1581**Return value**
1582
1583| Type                 | Description                 |
1584| ------------------- | ------------------- |
1585| Array&lt;string&gt; | Addresses of the BLE devices connected to this device.|
1586
1587**Error codes**
1588
1589For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1590
1591| ID| Error Message|
1592| -------- | ---------------------------- |
1593|2900001 | Service stopped.                         |
1594|2900003 | Bluetooth switch is off.                 |
1595|2900099 | Operation failed.                        |
1596
1597**Example**
1598
1599```js
1600import { BusinessError } from '@ohos.base';
1601try {
1602    let result: Array<string>  = bluetoothManager.BLE.getConnectedBLEDevices();
1603} catch (err) {
1604    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1605}
1606```
1607
1608
1609### startBLEScan<sup>(deprecated)</sup>
1610
1611startBLEScan(filters: Array&lt;ScanFilter&gt;, options?: ScanOptions): void
1612
1613Starts a BLE scan.
1614
1615> **NOTE**<br>
1616> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.startBLEScan](js-apis-bluetooth-ble.md#blestartblescan).
1617
1618**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH, ohos.permission.MANAGE_BLUETOOTH, ohos.permission.LOCATION, and ohos.permission.APPROXIMATELY_LOCATION
1619
1620**System capability**: SystemCapability.Communication.Bluetooth.Core
1621
1622**Parameters**
1623
1624| Name    | Type                                    | Mandatory  | Description                                 |
1625| ------- | -------------------------------------- | ---- | ----------------------------------- |
1626| filters | Array&lt;[ScanFilter](#scanfilter)&gt; | Yes   | Criteria for filtering the scan result. Set this parameter to **null** if you do not want to filter the scan result.|
1627| options | [ScanOptions](#scanoptions)            | No   | Scan options.                    |
1628
1629**Error codes**
1630
1631For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1632
1633| ID| Error Message|
1634| -------- | ---------------------------- |
1635|2900001 | Service stopped.                         |
1636|2900003 | Bluetooth switch is off.                 |
1637|2900099 | Operation failed.                        |
1638
1639**Example**
1640
1641```js
1642import { BusinessError } from '@ohos.base';
1643function onReceiveEvent(data: Array<bluetoothManager.ScanResult>) {
1644    console.info('BLE scan device find result = '+ JSON.stringify(data));
1645}
1646try {
1647    bluetoothManager.BLE.on("BLEDeviceFind", onReceiveEvent);
1648    let scanfilter: bluetoothManager.ScanFilter = {
1649        deviceId:"XX:XX:XX:XX:XX:XX",
1650        name:"test",
1651        serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
1652    };
1653    let scanoptions: bluetoothManager.ScanOptions = {
1654        interval: 500,
1655        dutyMode: bluetoothManager.ScanDuty.SCAN_MODE_LOW_POWER,
1656        matchMode: bluetoothManager.MatchMode.MATCH_MODE_AGGRESSIVE,
1657    }
1658    bluetoothManager.BLE.startBLEScan([scanfilter], scanoptions);
1659} catch (err) {
1660    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1661}
1662```
1663
1664
1665### stopBLEScan<sup>(deprecated)</sup>
1666
1667stopBLEScan(): void
1668
1669Stops the BLE scan.
1670
1671> **NOTE**<br>
1672> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.startBLEScan](js-apis-bluetooth-ble.md#blestopblescan).
1673
1674**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1675
1676**System capability**: SystemCapability.Communication.Bluetooth.Core
1677
1678**Error codes**
1679
1680For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1681
1682| ID| Error Message|
1683| -------- | ---------------------------- |
1684|2900001 | Service stopped.                         |
1685|2900003 | Bluetooth switch is off.                 |
1686|2900099 | Operation failed.                        |
1687
1688**Example**
1689
1690```js
1691import { BusinessError } from '@ohos.base';
1692try {
1693    bluetoothManager.BLE.stopBLEScan();
1694} catch (err) {
1695    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1696}
1697```
1698
1699
1700### on('BLEDeviceFind')<sup>(deprecated)</sup>
1701
1702on(type: "BLEDeviceFind", callback: Callback&lt;Array&lt;ScanResult&gt;&gt;): void
1703
1704Subscribe to the BLE device discovery events.
1705
1706> **NOTE**<br>
1707> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.on('BLEDeviceFind')](js-apis-bluetooth-ble.md#bleonbledevicefind).
1708
1709**Required permissions**: ohos.permission.USE_BLUETOOTH
1710
1711**System capability**: SystemCapability.Communication.Bluetooth.Core
1712
1713**Parameters**
1714
1715| Name     | Type                                      | Mandatory  | Description                                 |
1716| -------- | ---------------------------------------- | ---- | ----------------------------------- |
1717| type     | string                                   | Yes   | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered.  |
1718| callback | Callback&lt;Array&lt;[ScanResult](#scanresult)&gt;&gt; | Yes   | Callback invoked to return the discovered devices. You need to implement this callback.|
1719
1720**Error codes**
1721
1722For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1723
1724| ID| Error Message|
1725| -------- | ---------------------------- |
1726|2900099 | Operation failed.                        |
1727
1728**Example**
1729
1730```js
1731import { BusinessError } from '@ohos.base';
1732function onReceiveEvent(data: Array<bluetoothManager.ScanResult>) {
1733    console.info('bluetooth device find = '+ JSON.stringify(data));
1734}
1735try {
1736    bluetoothManager.BLE.on('BLEDeviceFind', onReceiveEvent);
1737} catch (err) {
1738    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1739}
1740```
1741
1742
1743### off('BLEDeviceFind')<sup>(deprecated)</sup>
1744
1745off(type: "BLEDeviceFind", callback?: Callback&lt;Array&lt;ScanResult&gt;&gt;): void
1746
1747Unsubscribes from the BLE device discovery events.
1748
1749> **NOTE**<br>
1750> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.off('BLEDeviceFind')](js-apis-bluetooth-ble.md#bleoffbledevicefind).
1751
1752**Required permissions**: ohos.permission.USE_BLUETOOTH
1753
1754**System capability**: SystemCapability.Communication.Bluetooth.Core
1755
1756**Parameters**
1757
1758| Name     | Type                                      | Mandatory  | Description                                      |
1759| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1760| type     | string                                   | Yes   | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered.       |
1761| callback | Callback&lt;Array&lt;[ScanResult](#scanresult)&gt;&gt; | No   | Callback for the **BLEDeviceFind** event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
1762
1763**Error codes**
1764
1765For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1766
1767| ID| Error Message|
1768| -------- | ---------------------------- |
1769|2900099 | Operation failed.                        |
1770
1771**Example**
1772
1773```js
1774import { BusinessError } from '@ohos.base';
1775function onReceiveEvent(data: Array<bluetoothManager.ScanResult>) {
1776    console.info('bluetooth device find = '+ JSON.stringify(data));
1777}
1778try {
1779    bluetoothManager.BLE.on('BLEDeviceFind', onReceiveEvent);
1780    bluetoothManager.BLE.off('BLEDeviceFind', onReceiveEvent);
1781} catch (err) {
1782    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1783}
1784```
1785
1786
1787## BaseProfile
1788
1789Provides the profile base class.
1790
1791
1792### getConnectionDevices<sup>(deprecated)</sup><a name="getConnectionDevices"></a>
1793
1794getConnectionDevices(): Array&lt;string&gt;
1795
1796Obtains the connected devices.
1797
1798> **NOTE**<br>
1799> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.getConnectedDevices](js-apis-bluetooth-baseProfile.md#baseprofilegetconnecteddevices).
1800
1801**Required permissions**: ohos.permission.USE_BLUETOOTH
1802
1803**System capability**: SystemCapability.Communication.Bluetooth.Core
1804
1805**Return value**
1806
1807| Type                 | Description           |
1808| ------------------- | ------------- |
1809| Array&lt;string&gt; | Addresses of the connected devices.|
1810
1811**Error codes**
1812
1813For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1814
1815| ID| Error Message|
1816| -------- | ---------------------------- |
1817|2900001 | Service stopped.                         |
1818|2900003 | Bluetooth switch is off.                 |
1819|2900004 | Profile is not supported.                |
1820|2900099 | Operation failed.                        |
1821
1822**Example**
1823
1824```js
1825import { BusinessError } from '@ohos.base';
1826try {
1827    let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
1828    let retArray: Array<string> = a2dpSrc.getConnectionDevices();
1829} catch (err) {
1830    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1831}
1832```
1833
1834### getDeviceState<sup>(deprecated)</sup><a name="getDeviceState"></a>
1835
1836getDeviceState(device: string): ProfileConnectionState
1837
1838Obtains the connection state of the profile.
1839
1840> **NOTE**<br>
1841> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.getConnectionState](js-apis-bluetooth-baseProfile.md#baseprofilegetconnectionstate).
1842
1843**Required permissions**: ohos.permission.USE_BLUETOOTH
1844
1845**System capability**: SystemCapability.Communication.Bluetooth.Core
1846
1847**Parameters**
1848
1849| Name   | Type    | Mandatory  | Description     |
1850| ------ | ------ | ---- | ------- |
1851| device | string | Yes   | Address of the target device.|
1852
1853**Return value**
1854
1855| Type                                             | Description                   |
1856| ------------------------------------------------- | ----------------------- |
1857| [ProfileConnectionState](#profileconnectionstate) | Profile connection state obtained.|
1858
1859**Error codes**
1860
1861For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1862
1863| ID| Error Message|
1864| -------- | ---------------------------- |
1865|2900001 | Service stopped.                         |
1866|2900003 | Bluetooth switch is off.                 |
1867|2900004 | Profile is not supported.                |
1868|2900099 | Operation failed.                        |
1869
1870**Example**
1871
1872```js
1873import { BusinessError } from '@ohos.base';
1874try {
1875    let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
1876    let ret: bluetoothManager.ProfileConnectionState = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
1877} catch (err) {
1878    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1879}
1880```
1881
1882
1883## A2dpSourceProfile
1884
1885Before using an API of **A2dpSourceProfile**, you need to create an instance of this class by using **getProfile()**.
1886
1887> **NOTE**<br>
1888> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [a2dp.A2dpSourceProfile](js-apis-bluetooth-a2dp.md#a2dpsourceprofile).
1889
1890
1891### connect<sup>(deprecated)</sup><a name="a2dp-connect"></a>
1892
1893connect(device: string): void
1894
1895Sets up an Advanced Audio Distribution Profile (A2DP) connection.
1896
1897> **NOTE**<br>
1898> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [a2dp.A2dpSourceProfile#connect](js-apis-bluetooth-a2dp.md#connect).
1899
1900**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1901
1902**System capability**: SystemCapability.Communication.Bluetooth.Core
1903
1904**Parameters**
1905
1906| Name   | Type    | Mandatory  | Description     |
1907| ------ | ------ | ---- | ------- |
1908| device | string | Yes   | Address of the target device.|
1909
1910**Error codes**
1911
1912For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1913
1914| ID| Error Message|
1915| -------- | ---------------------------- |
1916|2900001 | Service stopped.                         |
1917|2900003 | Bluetooth switch is off.                 |
1918|2900004 | Profile is not supported.                |
1919|2900099 | Operation failed.                        |
1920
1921**Example**
1922
1923```js
1924import { BusinessError } from '@ohos.base';
1925try {
1926    let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
1927    a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
1928} catch (err) {
1929    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1930}
1931```
1932
1933
1934### disconnect<sup>(deprecated)</sup><a name="a2dp-disconnect"></a>
1935
1936disconnect(device: string): void
1937
1938Disconnects an A2DP connection.
1939
1940> **NOTE**<br>
1941> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [a2dp.A2dpSourceProfile#disconnect](js-apis-bluetooth-a2dp.md#disconnect).
1942
1943**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1944
1945**System capability**: SystemCapability.Communication.Bluetooth.Core
1946
1947**Parameters**
1948
1949| Name   | Type    | Mandatory  | Description     |
1950| ------ | ------ | ---- | ------- |
1951| device | string | Yes   | Address of the target device.|
1952
1953**Error codes**
1954
1955For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
1956
1957| ID| Error Message|
1958| -------- | ---------------------------- |
1959|2900001 | Service stopped.                         |
1960|2900003 | Bluetooth switch is off.                 |
1961|2900004 | Profile is not supported.                |
1962|2900099 | Operation failed.                        |
1963
1964**Example**
1965
1966```js
1967import { BusinessError } from '@ohos.base';
1968try {
1969    let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
1970    a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
1971} catch (err) {
1972    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
1973}
1974```
1975
1976
1977### on('connectionStateChange')<sup>(deprecated)</sup>
1978
1979on(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
1980
1981Subscribes to the A2DP connection state changes.
1982
1983> **NOTE**<br>
1984> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.on('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileonconnectionstatechange).
1985
1986**System capability**: SystemCapability.Communication.Bluetooth.Core
1987
1988**Parameters**
1989
1990| Name     | Type                                      | Mandatory  | Description                                      |
1991| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1992| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates a A2DP connection state change event.|
1993| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | Yes   | Callback invoked to return the A2DP connection state change event.                              |
1994
1995**Return value**
1996
1997No value is returned.
1998
1999**Example**
2000
2001```js
2002import { BusinessError } from '@ohos.base';
2003function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2004    console.info('a2dp state = '+ JSON.stringify(data));
2005}
2006try {
2007let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
2008a2dpSrc.on('connectionStateChange', onReceiveEvent);
2009} catch (err) {
2010    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
2011}
2012```
2013
2014
2015### off('connectionStateChange')<sup>(deprecated)</sup>
2016
2017off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2018
2019Unsubscribes from the A2DP connection state changes.
2020
2021> **NOTE**<br>
2022> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.off('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileoffconnectionstatechange).
2023
2024**System capability**: SystemCapability.Communication.Bluetooth.Core
2025
2026**Parameters**
2027
2028| Name     | Type                                      | Mandatory  | Description                                      |
2029| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2030| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates a A2DP connection state change event.|
2031| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | No   | Callback for the A2DP connection state change event.                              |
2032
2033**Return value**
2034
2035No value is returned.
2036
2037**Example**
2038
2039```js
2040import { BusinessError } from '@ohos.base';
2041function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2042    console.info('a2dp state = '+ JSON.stringify(data));
2043}
2044try {
2045let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
2046a2dpSrc.on('connectionStateChange', onReceiveEvent);
2047a2dpSrc.off('connectionStateChange', onReceiveEvent);
2048} catch (err) {
2049    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
2050}
2051```
2052
2053
2054### getPlayingState<sup>(deprecated)</sup>
2055
2056getPlayingState(device: string): PlayingState
2057
2058Obtains the playing state of a device.
2059
2060> **NOTE**<br>
2061> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [a2dp.A2dpSourceProfile#getPlayingState](js-apis-bluetooth-a2dp.md#getPlayingState).
2062
2063**System capability**: SystemCapability.Communication.Bluetooth.Core
2064
2065**Parameters**
2066
2067| Name   | Type    | Mandatory  | Description     |
2068| ------ | ------ | ---- | ------- |
2069| device | string | Yes   | Address of the target device.|
2070
2071**Return value**
2072
2073| Type                           | Description        |
2074| ----------------------------- | ---------- |
2075| [PlayingState](#PlayingState) | Playing state of the remote device obtained.|
2076
2077**Error codes**
2078
2079For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2080
2081| ID| Error Message|
2082| -------- | ---------------------------- |
2083|2900001 | Service stopped.                         |
2084|2900003 | Bluetooth switch is off.                 |
2085|2900004 | Profile is not supported.                |
2086|2900099 | Operation failed.                        |
2087
2088**Example**
2089
2090```js
2091import { BusinessError } from '@ohos.base';
2092try {
2093    let a2dpSrc: bluetoothManager.A2dpSourceProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_A2DP_SOURCE) as bluetoothManager.A2dpSourceProfile;
2094    let state: bluetoothManager.PlayingState  = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
2095} catch (err) {
2096    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2097}
2098```
2099
2100
2101## HandsFreeAudioGatewayProfile<sup>(deprecated)</sup>
2102
2103Before using an API of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using **getProfile()**.
2104
2105> **NOTE**<br>
2106> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [hfp.HandsFreeAudioGatewayProfile](js-apis-bluetooth-hfp.md#HandsFreeAudioGatewayProfile).
2107
2108
2109### connect<a name="hfp-connect"></a>
2110
2111connect(device: string): void
2112
2113Sets up a Hands-free Profile (HFP) connection of a device.
2114
2115> **NOTE**<br>
2116> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [hfp.HandsFreeAudioGatewayProfile#connect](js-apis-bluetooth-hfp.md#connect).
2117
2118**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2119
2120**System capability**: SystemCapability.Communication.Bluetooth.Core
2121
2122**Parameters**
2123
2124| Name   | Type    | Mandatory  | Description     |
2125| ------ | ------ | ---- | ------- |
2126| device | string | Yes   | Address of the target device.|
2127
2128**Error codes**
2129
2130For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2131
2132| ID| Error Message|
2133| -------- | ---------------------------- |
2134|2900001 | Service stopped.                         |
2135|2900003 | Bluetooth switch is off.                 |
2136|2900004 | Profile is not supported.                |
2137|2900099 | Operation failed.                        |
2138
2139**Example**
2140
2141```js
2142import { BusinessError } from '@ohos.base';
2143try {
2144    let hfpAg: bluetoothManager.HandsFreeAudioGatewayProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as bluetoothManager.HandsFreeAudioGatewayProfile;
2145    hfpAg.connect('XX:XX:XX:XX:XX:XX');
2146} catch (err) {
2147    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2148}
2149```
2150
2151
2152### disconnect<sup>(deprecated)</sup><a name="hfp-disconnect"></a>
2153
2154disconnect(device: string): void
2155
2156Disconnects the HFP connection of a device.
2157
2158> **NOTE**<br>
2159> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [hfp.HandsFreeAudioGatewayProfile#disconnect](js-apis-bluetooth-hfp.md#disconnect).
2160
2161**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2162
2163**System capability**: SystemCapability.Communication.Bluetooth.Core
2164
2165**Parameters**
2166
2167| Name   | Type    | Mandatory  | Description     |
2168| ------ | ------ | ---- | ------- |
2169| device | string | Yes   | Address of the target device.|
2170
2171**Error codes**
2172
2173For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2174
2175| ID| Error Message|
2176| -------- | ---------------------------- |
2177|2900001 | Service stopped.                         |
2178|2900003 | Bluetooth switch is off.                 |
2179|2900004 | Profile is not supported.                |
2180|2900099 | Operation failed.                        |
2181
2182**Example**
2183
2184```js
2185import { BusinessError } from '@ohos.base';
2186try {
2187    let hfpAg: bluetoothManager.HandsFreeAudioGatewayProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as bluetoothManager.HandsFreeAudioGatewayProfile;
2188    hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
2189} catch (err) {
2190    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2191}
2192```
2193
2194
2195### on('connectionStateChange')<sup>(deprecated)</sup>
2196
2197on(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2198
2199Subscribes to the HFP connection state changes.
2200
2201> **NOTE**<br>
2202> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.on('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileonconnectionstatechange).
2203
2204**System capability**: SystemCapability.Communication.Bluetooth.Core
2205
2206**Parameters**
2207
2208| Name     | Type                                      | Mandatory  | Description                                      |
2209| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2210| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates an HFP connection state change event.|
2211| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | Yes   | Callback invoked to return the HFP connection state change event.                              |
2212
2213**Example**
2214
2215```js
2216import { BusinessError } from '@ohos.base';
2217function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2218    console.info('hfp state = '+ JSON.stringify(data));
2219}
2220try {
2221let hfpAg: bluetoothManager.HandsFreeAudioGatewayProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
2222  bluetoothManager.HandsFreeAudioGatewayProfile;
2223hfpAg.on('connectionStateChange', onReceiveEvent);
2224} catch (err) {
2225    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2226}
2227```
2228
2229
2230### off('connectionStateChange')<sup>(deprecated)</sup>
2231
2232off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2233
2234Unsubscribes from the HFP connection state changes.
2235
2236> **NOTE**<br>
2237> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.off('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileoffconnectionstatechange).
2238
2239**System capability**: SystemCapability.Communication.Bluetooth.Core
2240
2241**Parameters**
2242
2243| Name     | Type                                      | Mandatory  | Description                                      |
2244| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2245| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates an HFP connection state change event.|
2246| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | No   | Callback for the HFP connection state change event.                              |
2247
2248**Example**
2249
2250```js
2251import { BusinessError } from '@ohos.base';
2252function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2253    console.info('hfp state = '+ JSON.stringify(data));
2254}
2255try {
2256let hfpAg: bluetoothManager.HandsFreeAudioGatewayProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY) as
2257  bluetoothManager.HandsFreeAudioGatewayProfile;
2258hfpAg.on('connectionStateChange', onReceiveEvent);
2259hfpAg.off('connectionStateChange', onReceiveEvent);
2260} catch (err) {
2261    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2262}
2263```
2264
2265
2266## HidHostProfile<sup>(deprecated)</sup>
2267
2268Before using an API of **HidHostProfile**, you need to create an instance of this class by using **getProfile()**.
2269
2270
2271### connect<a name="HidHost-connect"></a>
2272
2273connect(device: string): void
2274
2275Connects to the HidHost service of a device.
2276
2277> **NOTE**<br>
2278> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [hid.HidHostProfile#connect](js-apis-bluetooth-hid.md#connect).
2279
2280**System API**: This is a system API.
2281
2282**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2283
2284**System capability**: SystemCapability.Communication.Bluetooth.Core
2285
2286**Parameters**
2287
2288| Name   | Type    | Mandatory  | Description     |
2289| ------ | ------ | ---- | ------- |
2290| device | string | Yes   | Address of the target device.|
2291
2292**Error codes**
2293
2294For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2295
2296| ID| Error Message|
2297| -------- | ---------------------------- |
2298|2900001 | Service stopped.                         |
2299|2900003 | Bluetooth switch is off.                 |
2300|2900004 | Profile is not supported.                |
2301|2900099 | Operation failed.                        |
2302
2303**Example**
2304
2305```js
2306import { BusinessError } from '@ohos.base';
2307try {
2308    let hidHostProfile: bluetoothManager.HidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
2309    hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
2310} catch (err) {
2311    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2312}
2313```
2314
2315
2316### disconnect<sup>(deprecated)</sup><a name="HidHost-disconnect"></a>
2317
2318disconnect(device: string): void
2319
2320Disconnects from the HidHost service of a device.
2321
2322> **NOTE**<br>
2323> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [hid.HidHostProfile#disconnect](js-apis-bluetooth-hid.md#disconnect).
2324
2325**System API**: This is a system API.
2326
2327**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2328
2329**System capability**: SystemCapability.Communication.Bluetooth.Core
2330
2331**Parameters**
2332
2333| Name   | Type    | Mandatory  | Description     |
2334| ------ | ------ | ---- | ------- |
2335| device | string | Yes   | Address of the target device.|
2336
2337**Error codes**
2338
2339For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2340
2341| ID| Error Message|
2342| -------- | ---------------------------- |
2343|2900001 | Service stopped.                         |
2344|2900003 | Bluetooth switch is off.                 |
2345|2900004 | Profile is not supported.                |
2346|2900099 | Operation failed.                        |
2347
2348**Example**
2349
2350```js
2351import { BusinessError } from '@ohos.base';
2352try {
2353    let hidHostProfile: bluetoothManager.HidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
2354    hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
2355} catch (err) {
2356    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2357}
2358```
2359
2360
2361### on('connectionStateChange')<sup>(deprecated)</sup>
2362
2363on(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2364
2365Subscribes to the HidHost connection state changes.
2366
2367> **NOTE**<br>
2368> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.on('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileonconnectionstatechange).
2369
2370**System capability**: SystemCapability.Communication.Bluetooth.Core
2371
2372**Parameters**
2373
2374| Name     | Type                                      | Mandatory  | Description                                      |
2375| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2376| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates a HidHost connection state change event. |
2377| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | Yes   | Callback invoked to return the HidHost connection state change event.                |
2378
2379**Example**
2380
2381```js
2382import { BusinessError } from '@ohos.base';
2383function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2384    console.info('hidHost state = '+ JSON.stringify(data));
2385}
2386try {
2387let hidHost: bluetoothManager.HidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
2388hidHost.on('connectionStateChange', onReceiveEvent);
2389} catch (err) {
2390    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2391}
2392```
2393
2394
2395### off('connectionStateChange')<sup>(deprecated)</sup>
2396
2397off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2398
2399Unsubscribes from the HidHost connection state changes.
2400
2401> **NOTE**<br>
2402> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.off('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileoffconnectionstatechange).
2403
2404**System capability**: SystemCapability.Communication.Bluetooth.Core
2405
2406**Parameters**
2407
2408| Name  | Type                                                 | Mandatory| Description                                                     |
2409| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- |
2410| type     | string                                                | Yes  | Event type. The value **connectionStateChange** indicates a HidHost connection state change event. |
2411| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | No  | Callback for the HidHost connection state change event.                            |
2412
2413**Example**
2414
2415```js
2416import { BusinessError } from '@ohos.base';
2417function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2418    console.info('hidHost state = '+ JSON.stringify(data));
2419}
2420try {
2421let hidHost: bluetoothManager.HidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile;
2422hidHost.on('connectionStateChange', onReceiveEvent);
2423hidHost.off('connectionStateChange', onReceiveEvent);
2424} catch (err) {
2425    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2426}
2427```
2428
2429
2430## PanProfile
2431
2432Before using an API of **PanProfile**, you need to create an instance of this class by using **getProfile()**.
2433
2434> **NOTE**<br>
2435> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [pan.PanProfile](js-apis-bluetooth-pan.md#panprofile).
2436
2437
2438### disconnect<sup>(deprecated)</sup><a name="PanP-disconnect"></a>
2439
2440disconnect(device: string): void
2441
2442Disconnects from the Personal Area Network (PAN) service of a device.
2443
2444> **NOTE**<br>
2445> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [pan.PanProfile#disconnect](js-apis-bluetooth-pan.md#disconnect).
2446
2447**System API**: This is a system API.
2448
2449**Required permissions**: ohos.permission.USE_BLUETOOTH
2450
2451**System capability**: SystemCapability.Communication.Bluetooth.Core
2452
2453**Parameters**
2454
2455| Name   | Type    | Mandatory  | Description     |
2456| ------ | ------ | ---- | ------- |
2457| device | string | Yes   | Address of the target device.|
2458
2459**Error codes**
2460
2461For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2462
2463| ID| Error Message|
2464| -------- | ---------------------------- |
2465|2900001 | Service stopped.                         |
2466|2900003 | Bluetooth switch is off.                 |
2467|2900004 | Profile is not supported.                |
2468|2900099 | Operation failed.                        |
2469
2470**Example**
2471
2472```js
2473import { BusinessError } from '@ohos.base';
2474try {
2475    let panProfile: bluetoothManager.PanProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
2476    panProfile.disconnect('XX:XX:XX:XX:XX:XX');
2477} catch (err) {
2478    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2479}
2480```
2481
2482
2483### on('connectionStateChange')<sup>(deprecated)</sup>
2484
2485on(type: "connectionStateChange", callback: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2486
2487Subscribes to the PAN connection state changes.
2488
2489> **NOTE**<br>
2490> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.on('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileonconnectionstatechange).
2491
2492**System capability**: SystemCapability.Communication.Bluetooth.Core
2493
2494**Parameters**
2495
2496| Name     | Type                                      | Mandatory  | Description                                      |
2497| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2498| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates a PAN connection state change event.|
2499| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | Yes   | Callback invoked to return the PAN connection state change event.                              |
2500
2501**Example**
2502
2503```js
2504import { BusinessError } from '@ohos.base';
2505function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2506    console.info('pan state = '+ JSON.stringify(data));
2507}
2508try {
2509let panProfile: bluetoothManager.PanProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
2510panProfile.on('connectionStateChange', onReceiveEvent);
2511} catch (err) {
2512    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2513}
2514```
2515
2516
2517### off('connectionStateChange')<sup>(deprecated)</sup>
2518
2519off(type: "connectionStateChange", callback?: Callback&lt;[StateChangeParam](#StateChangeParam)&gt;): void
2520
2521Unsubscribes from the PAN connection state changes.
2522
2523> **NOTE**<br>
2524> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.off('connectionStateChange')](js-apis-bluetooth-baseProfile.md#baseprofileoffconnectionstatechange).
2525
2526**System capability**: SystemCapability.Communication.Bluetooth.Core
2527
2528**Parameters**
2529
2530| Name  | Type                                                 | Mandatory| Description                                                     |
2531| -------- | ----------------------------------------------------- | ---- | --------------------------------------------------------- |
2532| type     | string                                                | Yes  | Event type. The value **connectionStateChange** indicates a PAN connection state change event.|
2533| callback | Callback&lt;[StateChangeParam](#StateChangeParam)&gt; | No  | Callback for the PAN connection state change event.                                     |
2534
2535**Example**
2536
2537```js
2538import { BusinessError } from '@ohos.base';
2539function onReceiveEvent(data: bluetoothManager.StateChangeParam) {
2540    console.info('pan state = '+ JSON.stringify(data));
2541}
2542try {
2543let panProfile: bluetoothManager.PanProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
2544panProfile.on('connectionStateChange', onReceiveEvent);
2545panProfile.off('connectionStateChange', onReceiveEvent);
2546} catch (err) {
2547    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2548}
2549```
2550
2551
2552### setTethering<sup>(deprecated)</sup><a name="setTethering"></a>
2553
2554setTethering(enable: boolean): void
2555
2556Sets tethering.
2557
2558> **NOTE**<br>
2559> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [pan.PanProfile#setTethering](js-apis-bluetooth-pan.md#setTethering).
2560
2561**System API**: This is a system API.
2562
2563**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2564
2565**System capability**: SystemCapability.Communication.Bluetooth.Core
2566
2567**Parameters**
2568
2569| Name   | Type    | Mandatory  | Description     |
2570| ------ | ------ | ---- | ------- |
2571| value | boolean | Yes   | Whether to set tethering over a Bluetooth PAN.|
2572
2573**Error codes**
2574
2575For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2576
2577| ID| Error Message|
2578| -------- | ---------------------------- |
2579|2900001 | Service stopped.                         |
2580|2900003 | Bluetooth switch is off.                 |
2581|2900004 | Profile is not supported.                |
2582|2900099 | Operation failed.                        |
2583
2584**Example**
2585
2586```js
2587import { BusinessError } from '@ohos.base';
2588try {
2589    let panProfile: bluetoothManager.PanProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
2590    panProfile.setTethering(true);
2591} catch (err) {
2592    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2593}
2594```
2595
2596
2597### isTetheringOn<sup>(deprecated)</sup><a name="isTetheringOn"></a>
2598
2599isTetheringOn(): boolean
2600
2601Obtains the network sharing status.
2602
2603> **NOTE**<br>
2604> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [pan.PanProfile#isTetheringOn](js-apis-bluetooth-pan.md#isTetheringOn).
2605
2606**System API**: This is a system API.
2607
2608**System capability**: SystemCapability.Communication.Bluetooth.Core
2609
2610**Return value**
2611
2612| Type     | Description                 |
2613| --------------------- | --------------------------------- |
2614| boolean | Returns **true** if tethering is available over a Bluetooth PAN; return **false** otherwise.|
2615
2616**Example**
2617
2618```js
2619import { BusinessError } from '@ohos.base';
2620try {
2621    let panProfile: bluetoothManager.PanProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile;
2622    panProfile.isTetheringOn();
2623} catch (err) {
2624    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2625}
2626```
2627
2628
2629## GattServer
2630
2631Implements the Generic Attribute Profile (GATT) server. Before using an API of this class, you need to create a **GattServer** instance using **createGattServer()**.
2632
2633> **NOTE**<br>
2634> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer](js-apis-bluetooth-ble.md#GattServer).
2635
2636
2637### startAdvertising<sup>(deprecated)</sup>
2638
2639startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void
2640
2641Starts BLE advertising.
2642
2643> **NOTE**<br>
2644> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.startAdvertising](js-apis-bluetooth-ble.md#blestartadvertising).
2645
2646**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2647
2648**System capability**: SystemCapability.Communication.Bluetooth.Core
2649
2650**Parameters**
2651
2652| Name        | Type                                   | Mandatory  | Description            |
2653| ----------- | ------------------------------------- | ---- | -------------- |
2654| setting     | [AdvertiseSetting](#advertisesetting) | Yes   | Settings related to BLE advertising.   |
2655| advData     | [AdvertiseData](#advertisedata)       | Yes   | Content of the BLE advertisement packet.     |
2656| advResponse | [AdvertiseData](#advertisedata)       | No   | Response to the BLE scan request.|
2657
2658**Error codes**
2659
2660For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2661
2662| ID| Error Message|
2663| -------- | ---------------------------- |
2664|2900001 | Service stopped.                         |
2665|2900003 | Bluetooth switch is off.                 |
2666|2900099 | Operation failed.                        |
2667
2668**Example**
2669
2670```js
2671import { BusinessError } from '@ohos.base';
2672let manufactureValueBuffer = new Uint8Array(4);
2673manufactureValueBuffer[0] = 1;
2674manufactureValueBuffer[1] = 2;
2675manufactureValueBuffer[2] = 3;
2676manufactureValueBuffer[3] = 4;
2677
2678let serviceValueBuffer = new Uint8Array(4);
2679serviceValueBuffer[0] = 4;
2680serviceValueBuffer[1] = 6;
2681serviceValueBuffer[2] = 7;
2682serviceValueBuffer[3] = 8;
2683console.info('manufactureValueBuffer = '+ JSON.stringify(manufactureValueBuffer));
2684console.info('serviceValueBuffer = '+ JSON.stringify(serviceValueBuffer));
2685let gattServer = bluetoothManager.BLE.createGattServer();
2686try {
2687    let setting: bluetoothManager.AdvertiseSetting = {
2688        interval:150,
2689        txPower:0,
2690        connectable:true,
2691    };
2692    let manufactureDataUnit: bluetoothManager.ManufactureData = {
2693        manufactureId:4567,
2694        manufactureValue:manufactureValueBuffer.buffer
2695    };
2696    let serviceDataUnit: bluetoothManager.ServiceData = {
2697        serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
2698        serviceValue:serviceValueBuffer.buffer
2699    };
2700    let advData: bluetoothManager.AdvertiseData = {
2701        serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
2702        manufactureData:[manufactureDataUnit],
2703        serviceData:[serviceDataUnit],
2704    };
2705    let advResponse: bluetoothManager.AdvertiseData = {
2706        serviceUuids:["00001888-0000-1000-8000-00805f9b34fb"],
2707        manufactureData:[manufactureDataUnit],
2708        serviceData:[serviceDataUnit],
2709    };
2710    gattServer.startAdvertising(setting, advData ,advResponse);
2711} catch (err) {
2712    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2713}
2714```
2715
2716
2717### stopAdvertising<sup>(deprecated)</sup>
2718
2719stopAdvertising(): void
2720
2721Stops BLE advertising.
2722
2723> **NOTE**<br>
2724> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.stopAdvertising](js-apis-bluetooth-ble.md#blestopadvertising).
2725
2726**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
2727
2728**System capability**: SystemCapability.Communication.Bluetooth.Core
2729
2730**Error codes**
2731
2732For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2733
2734| ID| Error Message|
2735| -------- | ---------------------------- |
2736|2900001 | Service stopped.                         |
2737|2900003 | Bluetooth switch is off.                 |
2738|2900099 | Operation failed.                        |
2739
2740**Example**
2741
2742```js
2743import { BusinessError } from '@ohos.base';
2744let server = bluetoothManager.BLE.createGattServer();
2745try {
2746    server.stopAdvertising();
2747} catch (err) {
2748    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2749}
2750```
2751
2752
2753### addService<sup>(deprecated)</sup>
2754
2755addService(service: GattService): void
2756
2757Adds a service to this GATT server.
2758
2759> **NOTE**<br>
2760> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#addService](js-apis-bluetooth-ble.md#addservice).
2761
2762**Required permissions**: ohos.permission.USE_BLUETOOTH
2763
2764**System capability**: SystemCapability.Communication.Bluetooth.Core
2765
2766**Parameters**
2767
2768| Name    | Type                         | Mandatory  | Description                      |
2769| ------- | --------------------------- | ---- | ------------------------ |
2770| service | [GattService](#gattservice) | Yes   | Service to add. Settings related to BLE advertising.|
2771
2772**Error codes**
2773
2774For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2775
2776| ID| Error Message|
2777| -------- | ---------------------------- |
2778|2900001 | Service stopped.                         |
2779|2900003 | Bluetooth switch is off.                 |
2780|2900099 | Operation failed.                        |
2781
2782**Example**
2783
2784```js
2785import { BusinessError } from '@ohos.base';
2786// Create descriptors.
2787let descriptors: Array<bluetoothManager.BLEDescriptor> = [];
2788let arrayBuffer = new ArrayBuffer(8);
2789let descV = new Uint8Array(arrayBuffer);
2790descV[0] = 11;
2791let descriptor: bluetoothManager.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2792    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2793    descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
2794descriptors[0] = descriptor;
2795
2796// Create characteristics.
2797let characteristics: Array<bluetoothManager.BLECharacteristic> = [];
2798let arrayBufferC = new ArrayBuffer(8);
2799let cccV = new Uint8Array(arrayBufferC);
2800cccV[0] = 1;
2801let characteristic: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2802    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
2803let characteristicN: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2804    characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
2805characteristics[0] = characteristic;
2806
2807// Create a gattService instance.
2808let gattService: bluetoothManager.GattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true, characteristics:characteristics, includeServices:[]};
2809
2810let gattServer  = bluetoothManager.BLE.createGattServer();
2811try {
2812    gattServer.addService(gattService);
2813} catch (err) {
2814    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2815}
2816```
2817
2818
2819### removeService<sup>(deprecated)</sup>
2820
2821removeService(serviceUuid: string): void
2822
2823Removes a service from this GATT server.
2824
2825> **NOTE**<br>
2826> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#removeService](js-apis-bluetooth-ble.md#removeservice).
2827
2828**Required permissions**: ohos.permission.USE_BLUETOOTH
2829
2830**System capability**: SystemCapability.Communication.Bluetooth.Core
2831
2832**Parameters**
2833
2834| Name        | Type    | Mandatory  | Description                                      |
2835| ----------- | ------ | ---- | ---------------------------------------- |
2836| serviceUuid | string | Yes   | Universally unique identifier (UUID) of the service to remove, for example, **00001810-0000-1000-8000-00805F9B34FB**.|
2837
2838**Error codes**
2839
2840For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2841
2842| ID| Error Message|
2843| -------- | ---------------------------- |
2844|2900001 | Service stopped.                         |
2845|2900003 | Bluetooth switch is off.                 |
2846|2900004 | Profile is not supported.                |
2847|2900099 | Operation failed.                        |
2848
2849**Example**
2850
2851```js
2852import { BusinessError } from '@ohos.base';
2853let server = bluetoothManager.BLE.createGattServer();
2854try {
2855    server.removeService('00001810-0000-1000-8000-00805F9B34FB');
2856} catch (err) {
2857    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2858}
2859```
2860
2861
2862### close<sup>(deprecated)</sup>
2863
2864close(): void
2865
2866Closes this GATT server to unregister it from the protocol stack. After this method is called, this [GattServer](#gattserver) cannot be used.
2867
2868> **NOTE**<br>
2869> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#close](js-apis-bluetooth-ble.md#close).
2870
2871**Required permissions**: ohos.permission.USE_BLUETOOTH
2872
2873**System capability**: SystemCapability.Communication.Bluetooth.Core
2874
2875**Error codes**
2876
2877For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2878
2879| ID| Error Message|
2880| -------- | ---------------------------- |
2881|2900001 | Service stopped.                         |
2882|2900003 | Bluetooth switch is off.                 |
2883|2900099 | Operation failed.                        |
2884
2885**Example**
2886
2887```js
2888import { BusinessError } from '@ohos.base';
2889let server = bluetoothManager.BLE.createGattServer();
2890try {
2891    server.close();
2892} catch (err) {
2893    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2894}
2895```
2896
2897
2898### notifyCharacteristicChanged<sup>(deprecated)</sup>
2899
2900notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): void
2901
2902Notifies the connected client device when a characteristic value changes.
2903
2904> **NOTE**<br>
2905> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#notifyCharacteristicChanged](js-apis-bluetooth-ble.md#notifycharacteristicchanged).
2906
2907**Required permissions**: ohos.permission.USE_BLUETOOTH
2908
2909**System capability**: SystemCapability.Communication.Bluetooth.Core
2910
2911**Parameters**
2912
2913| Name                 | Type                                      | Mandatory  | Description                                     |
2914| -------------------- | ---------------------------------------- | ---- | --------------------------------------- |
2915| deviceId             | string                                   | Yes   | Address of the client that receives notifications, for example, XX:XX:XX:XX:XX:XX.|
2916| notifyCharacteristic | [NotifyCharacteristic](#notifycharacteristic) | Yes   | New characteristic value.                              |
2917
2918**Error codes**
2919
2920For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2921
2922| ID| Error Message|
2923| -------- | ---------------------------- |
2924|2900001 | Service stopped.                         |
2925|2900003 | Bluetooth switch is off.                 |
2926|2900099 | Operation failed.                        |
2927
2928**Example**
2929
2930```js
2931import { BusinessError } from '@ohos.base';
2932// Create descriptors.
2933let descriptors: Array<bluetoothManager.BLEDescriptor> = [];
2934let arrayBuffer = new ArrayBuffer(8);
2935let descV = new Uint8Array(arrayBuffer);
2936descV[0] = 11;
2937let descriptor: bluetoothManager.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2938    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2939    descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
2940descriptors[0] = descriptor;
2941let arrayBufferC = new ArrayBuffer(8);
2942let characteristic: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2943  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
2944let notifyCharacteristic: bluetoothManager.NotifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2945  characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: characteristic.characteristicValue, confirm: false};
2946let server = bluetoothManager.BLE.createGattServer();
2947try {
2948    server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
2949} catch (err) {
2950    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
2951}
2952```
2953
2954
2955### sendResponse<sup>(deprecated)</sup>
2956
2957sendResponse(serverResponse: ServerResponse): void
2958
2959Sends a response to a read or write request from the GATT client.
2960
2961> **NOTE**<br>
2962> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#sendResponse](js-apis-bluetooth-ble.md#sendresponse).
2963
2964**Required permissions**: ohos.permission.USE_BLUETOOTH
2965
2966**System capability**: SystemCapability.Communication.Bluetooth.Core
2967
2968**Parameters**
2969
2970| Name           | Type                               | Mandatory  | Description             |
2971| -------------- | --------------------------------- | ---- | --------------- |
2972| serverResponse | [ServerResponse](#serverresponse) | Yes   | Response returned by the GATT server.|
2973
2974**Error codes**
2975
2976For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
2977
2978| ID| Error Message|
2979| -------- | ---------------------------- |
2980|2900001 | Service stopped.                         |
2981|2900003 | Bluetooth switch is off.                 |
2982|2900099 | Operation failed.                        |
2983
2984**Example**
2985
2986```js
2987import { BusinessError } from '@ohos.base';
2988/* send response */
2989let arrayBufferCCC = new ArrayBuffer(8);
2990let cccValue = new Uint8Array(arrayBufferCCC);
2991cccValue[0] = 1123;
2992let serverResponse: bluetoothManager.ServerResponse = {
2993    deviceId: 'XX:XX:XX:XX:XX:XX',
2994    transId: 0,
2995    status: 0,
2996    offset: 0,
2997    value: arrayBufferCCC,
2998};
2999
3000let gattServer = bluetoothManager.BLE.createGattServer();
3001try {
3002    gattServer.sendResponse(serverResponse);
3003} catch (err) {
3004    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3005}
3006```
3007
3008
3009### on('characteristicRead')<sup>(deprecated)</sup>
3010
3011on(type: "characteristicRead", callback: Callback&lt;CharacteristicReadRequest&gt;): void
3012
3013Subscribes to the characteristic read request events.
3014
3015> **NOTE**<br>
3016> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#on('characteristicRead')](js-apis-bluetooth-ble.md#oncharacteristicread).
3017
3018**Required permissions**: ohos.permission.USE_BLUETOOTH
3019
3020**System capability**: SystemCapability.Communication.Bluetooth.Core
3021
3022**Parameters**
3023
3024| Name     | Type                                      | Mandatory  | Description                                   |
3025| -------- | ---------------------------------------- | ---- | ------------------------------------- |
3026| type     | string                                   | Yes   | Event type. The value **characteristicRead** indicates a characteristic read request event.|
3027| callback | Callback&lt;[CharacteristicReadRequest](#characteristicreadrequest)&gt; | Yes   | Callback invoked to return a characteristic read request event from the GATT client.           |
3028
3029**Example**
3030
3031```js
3032import { BusinessError } from '@ohos.base';
3033let arrayBufferCCC = new ArrayBuffer(8);
3034let cccValue = new Uint8Array(arrayBufferCCC);
3035cccValue[0] = 1123;
3036function ReadCharacteristicReq(characteristicReadRequest: bluetoothManager.CharacteristicReadRequest) {
3037    let deviceId: string = characteristicReadRequest.deviceId;
3038    let transId: number = characteristicReadRequest.transId;
3039    let offset: number = characteristicReadRequest.offset;
3040    let characteristicUuid: string = characteristicReadRequest.characteristicUuid;
3041
3042    let serverResponse: bluetoothManager.ServerResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferCCC};
3043
3044    try {
3045        gattServer.sendResponse(serverResponse);
3046    } catch (err) {
3047        console.error('errCode: ' + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3048    }
3049}
3050
3051let gattServer = bluetoothManager.BLE.createGattServer();
3052gattServer.on("characteristicRead", ReadCharacteristicReq);
3053```
3054
3055
3056### off('characteristicRead')<sup>(deprecated)</sup>
3057
3058off(type: "characteristicRead", callback?: Callback&lt;CharacteristicReadRequest&gt;): void
3059
3060Unsubscribes from the characteristic read request events.
3061
3062> **NOTE**<br>
3063> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#off('characteristicRead')](js-apis-bluetooth-ble.md#offcharacteristicread).
3064
3065**Required permissions**: ohos.permission.USE_BLUETOOTH
3066
3067**System capability**: SystemCapability.Communication.Bluetooth.Core
3068
3069**Parameters**
3070
3071| Name     | Type                                      | Mandatory  | Description                                      |
3072| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3073| type     | string                                   | Yes   | Event type. The value **characteristicRead** indicates a characteristic read request event.   |
3074| callback | Callback&lt;[CharacteristicReadRequest](#characteristicreadrequest)&gt; | No   | Callback for the characteristic read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
3075
3076**Example**
3077
3078```js
3079import { BusinessError } from '@ohos.base';
3080try {
3081let gattServer = bluetoothManager.BLE.createGattServer();
3082gattServer.off("characteristicRead");
3083} catch (err) {
3084    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3085}
3086```
3087
3088
3089### on('characteristicWrite')<sup>(deprecated)</sup>
3090
3091on(type: "characteristicWrite", callback: Callback&lt;CharacteristicWriteRequest&gt;): void
3092
3093Subscribes to the characteristic write request events.
3094
3095> **NOTE**<br>
3096> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#on('characteristicWrite')](js-apis-bluetooth-ble.md#oncharacteristicwrite).
3097
3098**Required permissions**: ohos.permission.USE_BLUETOOTH
3099
3100**System capability**: SystemCapability.Communication.Bluetooth.Core
3101
3102**Parameters**
3103
3104| Name     | Type                                      | Mandatory  | Description                                    |
3105| -------- | ---------------------------------------- | ---- | -------------------------------------- |
3106| type     | string                                   | Yes   | Event type. The value **characteristicWrite** indicates a characteristic write request event.|
3107| callback | Callback&lt;[CharacteristicWriteRequest](#characteristicwriterequest)&gt; | Yes   | Callback invoked to return a characteristic write request from the GATT client.            |
3108
3109**Example**
3110
3111```js
3112import { BusinessError } from '@ohos.base';
3113let arrayBufferCCC = new ArrayBuffer(8);
3114let cccValue = new Uint8Array(arrayBufferCCC);
3115function WriteCharacteristicReq(characteristicWriteRequest: bluetoothManager.CharacteristicWriteRequest) {
3116    let deviceId: string = characteristicWriteRequest.deviceId;
3117    let transId: number = characteristicWriteRequest.transId;
3118    let offset: number = characteristicWriteRequest.offset;
3119    let isPrep: boolean = characteristicWriteRequest.isPrep;
3120    let needRsp: boolean = characteristicWriteRequest.needRsp;
3121    let value: Uint8Array =  new Uint8Array(characteristicWriteRequest.value);
3122    let characteristicUuid: string = characteristicWriteRequest.characteristicUuid;
3123
3124    cccValue[0] = value[0];
3125    let serverResponse: bluetoothManager.ServerResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferCCC};
3126
3127    try {
3128        gattServer.sendResponse(serverResponse);
3129    } catch (err) {
3130        console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
3131    }
3132}
3133
3134let gattServer = bluetoothManager.BLE.createGattServer();
3135gattServer.on("characteristicWrite", WriteCharacteristicReq);
3136```
3137
3138
3139### off('characteristicWrite')<sup>(deprecated)</sup>
3140
3141off(type: "characteristicWrite", callback?: Callback&lt;CharacteristicWriteRequest&gt;): void
3142
3143Unsubscribes from the characteristic write request events.
3144
3145> **NOTE**<br>
3146> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#off('characteristicWrite')](js-apis-bluetooth-ble.md#offcharacteristicwrite).
3147
3148**Required permissions**: ohos.permission.USE_BLUETOOTH
3149
3150**System capability**: SystemCapability.Communication.Bluetooth.Core
3151
3152**Parameters**
3153
3154| Name     | Type                                      | Mandatory  | Description                                      |
3155| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3156| type     | string                                   | Yes   | Event type. The value **characteristicWrite** indicates a characteristic write request event.  |
3157| callback | Callback&lt;[CharacteristicWriteRequest](#characteristicwriterequest)&gt; | No   | Callback for the characteristic write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
3158
3159**Example**
3160
3161```js
3162import { BusinessError } from '@ohos.base';
3163try {
3164let gattServer = bluetoothManager.BLE.createGattServer();
3165gattServer.off("characteristicWrite");
3166} catch (err) {
3167    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3168}
3169```
3170
3171
3172### on('descriptorRead')<sup>(deprecated)</sup>
3173
3174on(type: "descriptorRead", callback: Callback&lt;DescriptorReadRequest&gt;): void
3175
3176Subscribes to the descriptor read request events.
3177
3178> **NOTE**<br>
3179> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#on('descriptorRead')](js-apis-bluetooth-ble.md#ondescriptorread).
3180
3181**Required permissions**: ohos.permission.USE_BLUETOOTH
3182
3183**System capability**: SystemCapability.Communication.Bluetooth.Core
3184
3185**Parameters**
3186
3187| Name     | Type                                      | Mandatory  | Description                               |
3188| -------- | ---------------------------------------- | ---- | --------------------------------- |
3189| type     | string                                   | Yes   | Event type. The value **descriptorRead** indicates a descriptor read request event.|
3190| callback | Callback&lt;[DescriptorReadRequest](#descriptorreadrequest)&gt; | Yes   | Callback invoked to return a descriptor read request event from the GATT client.       |
3191
3192**Example**
3193
3194```js
3195import { BusinessError } from '@ohos.base';
3196let arrayBufferDesc = new ArrayBuffer(8);
3197let descValue = new Uint8Array(arrayBufferDesc);
3198descValue[0] = 1101;
3199function ReadDescriptorReq(descriptorReadRequest: bluetoothManager.DescriptorReadRequest) {
3200    let deviceId: string = descriptorReadRequest.deviceId;
3201    let transId: number = descriptorReadRequest.transId;
3202    let offset: number = descriptorReadRequest.offset;
3203    let descriptorUuid: string = descriptorReadRequest.descriptorUuid;
3204
3205    let serverResponse: bluetoothManager.ServerResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
3206
3207    try {
3208        gattServer.sendResponse(serverResponse);
3209    } catch (err) {
3210        console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
3211    }
3212}
3213
3214let gattServer = bluetoothManager.BLE.createGattServer();
3215gattServer.on("descriptorRead", ReadDescriptorReq);
3216```
3217
3218
3219### off('descriptorRead')<sup>(deprecated)</sup>
3220
3221off(type: "descriptorRead", callback?: Callback&lt;DescriptorReadRequest&gt;): void
3222
3223Unsubscribes from the descriptor read request events.
3224
3225> **NOTE**<br>
3226> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#off('descriptorRead')](js-apis-bluetooth-ble.md#offdescriptorread).
3227
3228**Required permissions**: ohos.permission.USE_BLUETOOTH
3229
3230**System capability**: SystemCapability.Communication.Bluetooth.Core
3231
3232**Parameters**
3233
3234| Name     | Type                                      | Mandatory  | Description                                      |
3235| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3236| type     | string                                   | Yes   | Event type. The value **descriptorRead** indicates a descriptor read request event.       |
3237| callback | Callback&lt;[DescriptorReadRequest](#descriptorreadrequest)&gt; | No   | Callback for the descriptor read request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
3238
3239**Example**
3240
3241```js
3242import { BusinessError } from '@ohos.base';
3243try {
3244let gattServer = bluetoothManager.BLE.createGattServer();
3245gattServer.off("descriptorRead");
3246} catch (err) {
3247    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3248}
3249```
3250
3251
3252### on('descriptorWrite')<sup>(deprecated)</sup>
3253
3254on(type: "descriptorWrite", callback: Callback&lt;DescriptorWriteRequest&gt;): void
3255
3256Subscribes to the descriptor write request events.
3257
3258> **NOTE**<br>
3259> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#on('descriptorWrite')](js-apis-bluetooth-ble.md#ondescriptorwrite).
3260
3261**Required permissions**: ohos.permission.USE_BLUETOOTH
3262
3263**System capability**: SystemCapability.Communication.Bluetooth.Core
3264
3265**Parameters**
3266
3267| Name     | Type                                      | Mandatory  | Description                                |
3268| -------- | ---------------------------------------- | ---- | ---------------------------------- |
3269| type     | string                                   | Yes   | Event type. The value **descriptorWrite** indicates a descriptor write request event.|
3270| callback | Callback&lt;[DescriptorWriteRequest](#descriptorwriterequest)&gt; | Yes   | Callback invoked to return a descriptor write request from the GATT client.        |
3271
3272**Example**
3273
3274```js
3275import { BusinessError } from '@ohos.base';
3276let arrayBufferDesc = new ArrayBuffer(8);
3277let descValue = new Uint8Array(arrayBufferDesc);
3278function WriteDescriptorReq(descriptorWriteRequest: bluetoothManager.DescriptorWriteRequest) {
3279    let deviceId: string = descriptorWriteRequest.deviceId;
3280    let transId: number = descriptorWriteRequest.transId;
3281    let offset: number = descriptorWriteRequest.offset;
3282    let isPrep: boolean = descriptorWriteRequest.isPrep;
3283    let needRsp: boolean = descriptorWriteRequest.needRsp;
3284    let value: Uint8Array = new Uint8Array(descriptorWriteRequest.value);
3285    let descriptorUuid: string = descriptorWriteRequest.descriptorUuid;
3286
3287    descValue[0] = value[0];
3288    let serverResponse: bluetoothManager.ServerResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
3289
3290    try {
3291        gattServer.sendResponse(serverResponse);
3292    } catch (err) {
3293        console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
3294    }
3295}
3296
3297let gattServer = bluetoothManager.BLE.createGattServer();
3298gattServer.on("descriptorWrite", WriteDescriptorReq);
3299```
3300
3301
3302### off('descriptorWrite')<sup>(deprecated)</sup>
3303
3304off(type: "descriptorWrite", callback?: Callback&lt;DescriptorWriteRequest&gt;): void
3305
3306Unsubscribes from the descriptor write request events.
3307
3308> **NOTE**<br>
3309> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#off('descriptorWrite')](js-apis-bluetooth-ble.md#offdescriptorwrite).
3310
3311**Required permissions**: ohos.permission.USE_BLUETOOTH
3312
3313**System capability**: SystemCapability.Communication.Bluetooth.Core
3314
3315**Parameters**
3316
3317| Name     | Type                                      | Mandatory  | Description                                      |
3318| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3319| type     | string                                   | Yes   | Event type. The value **descriptorWrite** indicates a descriptor write request event.      |
3320| callback | Callback&lt;[DescriptorWriteRequest](#descriptorwriterequest)&gt; | No   | Callback for the descriptor write request event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
3321
3322**Example**
3323
3324```js
3325import { BusinessError } from '@ohos.base';
3326try {
3327let gattServer = bluetoothManager.BLE.createGattServer();
3328gattServer.off("descriptorWrite");
3329} catch (err) {
3330    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3331}
3332```
3333
3334
3335### on('connectStateChange')<sup>(deprecated)</sup>
3336
3337on(type: "connectStateChange", callback: Callback&lt;BLEConnectChangedState&gt;): void
3338
3339Subscribes to the BLE connection state changes.
3340
3341> **NOTE**<br>
3342> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#on('connectionStateChange')](js-apis-bluetooth-ble.md#onconnectionstatechange).
3343
3344**Required permissions**: ohos.permission.USE_BLUETOOTH
3345
3346**System capability**: SystemCapability.Communication.Bluetooth.Core
3347
3348**Parameters**
3349
3350| Name     | Type                                      | Mandatory  | Description                                      |
3351| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3352| type     | string                                   | Yes   | Event type. The value **connectStateChange** indicates a BLE connection state change event.|
3353| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstate)&gt; | Yes   | Callback invoked to return the BLE connection state.                         |
3354
3355**Example**
3356
3357```js
3358import { BusinessError } from '@ohos.base';
3359function Connected(BLEConnectChangedState: bluetoothManager.BLEConnectChangedState) {
3360  let deviceId: string = BLEConnectChangedState.deviceId;
3361  let status: bluetoothManager.ProfileConnectionState  = BLEConnectChangedState.state;
3362}
3363try {
3364let gattServer = bluetoothManager.BLE.createGattServer();
3365gattServer.on("connectStateChange", Connected);
3366} catch (err) {
3367    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3368}
3369```
3370
3371
3372### off('connectStateChange')<sup>(deprecated)</sup>
3373
3374off(type: "connectStateChange", callback?: Callback&lt;BLEConnectChangedState&gt;): void
3375
3376Unsubscribes from the BLE connection state changes.
3377
3378> **NOTE**<br>
3379> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattServer#off('connectionStateChange')](js-apis-bluetooth-ble.md#offconnectionstatechange).
3380
3381**Required permissions**: ohos.permission.USE_BLUETOOTH
3382
3383**System capability**: SystemCapability.Communication.Bluetooth.Core
3384
3385**Parameters**
3386
3387| Name     | Type                                      | Mandatory  | Description                                      |
3388| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3389| type     | string                                   | Yes   | Event type. The value **connectStateChange** indicates a BLE connection state change event.|
3390| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstate)&gt; | No   | Callback for the BLE connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
3391
3392**Example**
3393
3394```js
3395import { BusinessError } from '@ohos.base';
3396try {
3397let gattServer = bluetoothManager.BLE.createGattServer();
3398gattServer.off("connectStateChange");
3399} catch (err) {
3400    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3401}
3402```
3403
3404
3405## GattClientDevice
3406
3407Implements the GATT client. Before using an API of this class, you must create a **GattClientDevice** instance using **createGattClientDevice(deviceId: string)**.
3408
3409> **NOTE**<br>
3410> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice](js-apis-bluetooth-ble.md#gattclientdevice).
3411
3412
3413### connect<sup>(deprecated)</sup>
3414
3415connect(): void
3416
3417Initiates a connection to the remote BLE device.
3418
3419> **NOTE**<br>
3420> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#connect](js-apis-bluetooth-ble.md#connect).
3421
3422**Required permissions**: ohos.permission.USE_BLUETOOTH
3423
3424**System capability**: SystemCapability.Communication.Bluetooth.Core
3425
3426**Error codes**
3427
3428For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3429
3430| ID| Error Message|
3431| -------- | ---------------------------- |
3432|2900001 | Service stopped.                         |
3433|2900003 | Bluetooth switch is off.                 |
3434|2900099 | Operation failed.                        |
3435
3436**Example**
3437
3438```js
3439import { BusinessError } from '@ohos.base';
3440try {
3441    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3442    device.connect();
3443} catch (err) {
3444    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3445}
3446```
3447
3448
3449### disconnect<sup>(deprecated)</sup>
3450
3451disconnect(): void
3452
3453Disconnects from the remote BLE device.
3454
3455> **NOTE**<br>
3456> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#disconnect](js-apis-bluetooth-ble.md#disconnect).
3457
3458**Required permissions**: ohos.permission.USE_BLUETOOTH
3459
3460**System capability**: SystemCapability.Communication.Bluetooth.Core
3461
3462**Error codes**
3463
3464For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3465
3466| ID| Error Message|
3467| -------- | ---------------------------- |
3468|2900001 | Service stopped.                         |
3469|2900003 | Bluetooth switch is off.                 |
3470|2900099 | Operation failed.                        |
3471
3472**Example**
3473
3474```js
3475import { BusinessError } from '@ohos.base';
3476try {
3477    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3478    device.disconnect();
3479} catch (err) {
3480    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3481}
3482```
3483
3484
3485### close<sup>(deprecated)</sup>
3486
3487close(): void
3488
3489Closes this GATT client to unregister it from the protocol stack. After this method is called, this [GattClientDevice](#gattclientdevice) instance cannot be used.
3490
3491> **NOTE**<br>
3492> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#close](js-apis-bluetooth-ble.md#close).
3493
3494**Required permissions**: ohos.permission.USE_BLUETOOTH
3495
3496**System capability**: SystemCapability.Communication.Bluetooth.Core
3497
3498**Error codes**
3499
3500For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3501
3502| ID| Error Message|
3503| -------- | ---------------------------- |
3504|2900001 | Service stopped.                         |
3505|2900003 | Bluetooth switch is off.                 |
3506|2900099 | Operation failed.                        |
3507
3508**Example**
3509
3510```js
3511import { BusinessError } from '@ohos.base';
3512try {
3513    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3514    device.close();
3515} catch (err) {
3516    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3517}
3518```
3519
3520
3521
3522
3523### getServices<sup>(deprecated)</sup>
3524
3525getServices(callback: AsyncCallback&lt;Array&lt;GattService&gt;&gt;): void
3526
3527Obtains all services of the remote BLE device. This API uses an asynchronous callback to return the result.
3528
3529> **NOTE**<br>
3530> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#getServices](js-apis-bluetooth-ble.md#getservices).
3531
3532**Required permissions**: ohos.permission.USE_BLUETOOTH
3533
3534**System capability**: SystemCapability.Communication.Bluetooth.Core
3535
3536**Parameters**
3537
3538| Name     | Type                                      | Mandatory  | Description                      |
3539| -------- | ---------------------------------------- | ---- | ------------------------ |
3540| callback | AsyncCallback&lt;Array&lt;[GattService](#gattservice)&gt;&gt; | Yes   | Callback invoked to return the services obtained.|
3541
3542**Error codes**
3543
3544For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3545
3546| ID| Error Message|
3547| -------- | ---------------------------- |
3548|2900001 | Service stopped.                         |
3549|2900099 | Operation failed.                        |
3550
3551**Example**
3552
3553```js
3554import { BusinessError } from '@ohos.base';
3555// Callback
3556function getServices(code: BusinessError, gattServices: Array<bluetoothManager.GattService>) {
3557  if (code.code == 0) {
3558      let services: Array<bluetoothManager.GattService> = gattServices;
3559      console.log('bluetooth code is ' + code.code);
3560      console.log("bluetooth services size is ", services.length);
3561
3562      for (let i = 0; i < services.length; i++) {
3563        console.log('bluetooth serviceUuid is ' + services[i].serviceUuid);
3564      }
3565  }
3566}
3567
3568try {
3569    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3570    device.connect();
3571    device.getServices(getServices);
3572} catch (err) {
3573    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3574}
3575```
3576
3577
3578### getServices<sup>(deprecated)</sup>
3579
3580getServices(): Promise&lt;Array&lt;GattService&gt;&gt;
3581
3582Obtains all services of the remote BLE device. This API uses a promise to return the result.
3583
3584> **NOTE**<br>
3585> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#getServices](js-apis-bluetooth-ble.md#getservices-1).
3586
3587**Required permissions**: ohos.permission.USE_BLUETOOTH
3588
3589**System capability**: SystemCapability.Communication.Bluetooth.Core
3590
3591**Return value**
3592
3593| Type                                      | Description                         |
3594| ---------------------------------------- | --------------------------- |
3595| Promise&lt;Array&lt;[GattService](#gattservice)&gt;&gt; | Promise used to return the services obtained.|
3596
3597**Error codes**
3598
3599For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3600
3601| ID| Error Message|
3602| -------- | ---------------------------- |
3603|2900001 | Service stopped.                         |
3604|2900099 | Operation failed.                        |
3605
3606**Example**
3607
3608```js
3609import { BusinessError } from '@ohos.base';
3610// Promise
3611try {
3612    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3613    device.connect();
3614    device.getServices().then(result => {
3615        console.info("getServices successfully:" + JSON.stringify(result));
3616    });
3617} catch (err) {
3618    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3619}
3620```
3621
3622
3623### readCharacteristicValue<sup>(deprecated)</sup>
3624
3625readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback&lt;BLECharacteristic&gt;): void
3626
3627Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result.
3628
3629> **NOTE**<br>
3630> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#readCharacteristicValue](js-apis-bluetooth-ble.md#readcharacteristicvalue).
3631
3632**Required permissions**: ohos.permission.USE_BLUETOOTH
3633
3634**System capability**: SystemCapability.Communication.Bluetooth.Core
3635
3636**Parameters**
3637
3638| Name           | Type                                      | Mandatory  | Description                     |
3639| -------------- | ---------------------------------------- | ---- | ----------------------- |
3640| characteristic | [BLECharacteristic](#blecharacteristic)  | Yes   | Characteristic value to read.               |
3641| callback       | AsyncCallback&lt;[BLECharacteristic](#blecharacteristic)&gt; | Yes   | Callback invoked to return the characteristic value read.|
3642
3643**Error codes**
3644
3645For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3646
3647| ID| Error Message|
3648| -------- | ---------------------------- |
3649|2900001 | Service stopped.                         |
3650|2901000 | Read forbidden.                         |
3651|2900099 | Operation failed.                        |
3652
3653**Example**
3654
3655```js
3656import { BusinessError } from '@ohos.base';
3657function readCcc(code: BusinessError, BLECharacteristic: bluetoothManager.BLECharacteristic) {
3658    if (code.code != 0) {
3659        return;
3660    }
3661    console.log('bluetooth characteristic uuid: ' + BLECharacteristic.characteristicUuid);
3662    let value = new Uint8Array(BLECharacteristic.characteristicValue);
3663    console.log('bluetooth characteristic value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
3664}
3665
3666let descriptors: Array<bluetoothManager.BLEDescriptor> = [];
3667let bufferDesc = new ArrayBuffer(8);
3668let descV = new Uint8Array(bufferDesc);
3669descV[0] = 11;
3670let descriptor: bluetoothManager.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3671    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3672    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
3673descriptors[0] = descriptor;
3674
3675let bufferCCC = new ArrayBuffer(8);
3676let cccV = new Uint8Array(bufferCCC);
3677cccV[0] = 1;
3678let characteristic: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3679    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3680    characteristicValue: bufferCCC, descriptors:descriptors};
3681
3682try {
3683    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3684    device.readCharacteristicValue(characteristic, readCcc);
3685} catch (err) {
3686    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3687}
3688```
3689
3690
3691### readCharacteristicValue<sup>(deprecated)</sup>
3692
3693readCharacteristicValue(characteristic: BLECharacteristic): Promise&lt;BLECharacteristic&gt;
3694
3695Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result.
3696
3697> **NOTE**<br>
3698> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#readCharacteristicValue](js-apis-bluetooth-ble.md#readcharacteristicvalue-1).
3699
3700**Required permissions**: ohos.permission.USE_BLUETOOTH
3701
3702**System capability**: SystemCapability.Communication.Bluetooth.Core
3703
3704**Parameters**
3705
3706| Name           | Type                                     | Mandatory  | Description      |
3707| -------------- | --------------------------------------- | ---- | -------- |
3708| characteristic | [BLECharacteristic](#blecharacteristic) | Yes   | Characteristic value to read.|
3709
3710**Return value**
3711
3712| Type                                      | Description                        |
3713| ---------------------------------------- | -------------------------- |
3714| Promise&lt;[BLECharacteristic](#blecharacteristic)&gt; | Promise used to return the characteristic value read.|
3715
3716**Error codes**
3717
3718For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3719
3720| ID| Error Message|
3721| -------- | ---------------------------- |
3722|2900001 | Service stopped.                         |
3723|2901000 | Read forbidden.                         |
3724|2900099 | Operation failed.                        |
3725
3726**Example**
3727
3728```js
3729import { BusinessError } from '@ohos.base';
3730let descriptors: Array<bluetoothManager.BLEDescriptor> = [];
3731let bufferDesc = new ArrayBuffer(8);
3732let descV = new Uint8Array(bufferDesc);
3733descV[0] = 11;
3734let descriptor: bluetoothManager.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3735    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3736    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
3737descriptors[0] = descriptor;
3738
3739let bufferCCC = new ArrayBuffer(8);
3740let cccV = new Uint8Array(bufferCCC);
3741cccV[0] = 1;
3742let characteristic: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3743    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3744    characteristicValue: bufferCCC, descriptors:descriptors};
3745
3746try {
3747    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3748    device.readCharacteristicValue(characteristic);
3749} catch (err) {
3750    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3751}
3752```
3753
3754
3755### readDescriptorValue<sup>(deprecated)</sup>
3756
3757readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback&lt;BLEDescriptor&gt;): void
3758
3759Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result.
3760
3761> **NOTE**<br>
3762> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#readDescriptorValue](js-apis-bluetooth-ble.md#readdescriptorvalue).
3763
3764**Required permissions**: ohos.permission.USE_BLUETOOTH
3765
3766**System capability**: SystemCapability.Communication.Bluetooth.Core
3767
3768**Parameters**
3769
3770| Name       | Type                                      | Mandatory  | Description                     |
3771| ---------- | ---------------------------------------- | ---- | ----------------------- |
3772| descriptor | [BLEDescriptor](#bledescriptor)          | Yes   | Descriptor to read.               |
3773| callback   | AsyncCallback&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes   | Callback invoked to return the descriptor read.|
3774
3775**Error codes**
3776
3777For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3778
3779| ID| Error Message|
3780| -------- | ---------------------------- |
3781|2900001 | Service stopped.                         |
3782|2901000 | Read forbidden.                         |
3783|2900099 | Operation failed.                        |
3784
3785**Example**
3786
3787```js
3788import { BusinessError } from '@ohos.base';
3789function readDesc(code: BusinessError, BLEDescriptor: bluetoothManager.BLEDescriptor) {
3790    if (code.code != 0) {
3791        return;
3792    }
3793    console.log('bluetooth descriptor uuid: ' + BLEDescriptor.descriptorUuid);
3794    let value = new Uint8Array(BLEDescriptor.descriptorValue);
3795    console.log('bluetooth descriptor value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
3796}
3797
3798let bufferDesc = new ArrayBuffer(8);
3799let descV = new Uint8Array(bufferDesc);
3800descV[0] = 11;
3801let descriptor: bluetoothManager.BLEDescriptor = {
3802    serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3803    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3804    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB',
3805    descriptorValue: bufferDesc
3806};
3807try {
3808    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3809    device.readDescriptorValue(descriptor, readDesc);
3810} catch (err) {
3811    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3812}
3813```
3814
3815
3816### readDescriptorValue<sup>(deprecated)</sup>
3817
3818readDescriptorValue(descriptor: BLEDescriptor): Promise&lt;BLEDescriptor&gt;
3819
3820Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result.
3821
3822> **NOTE**<br>
3823> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#readDescriptorValue](js-apis-bluetooth-ble.md#readdescriptorvalue-1).
3824
3825**Required permissions**: ohos.permission.USE_BLUETOOTH
3826
3827**System capability**: SystemCapability.Communication.Bluetooth.Core
3828
3829**Parameters**
3830
3831| Name       | Type                             | Mandatory  | Description      |
3832| ---------- | ------------------------------- | ---- | -------- |
3833| descriptor | [BLEDescriptor](#bledescriptor) | Yes   | Descriptor to read.|
3834
3835**Return value**
3836
3837| Type                                      | Description                        |
3838| ---------------------------------------- | -------------------------- |
3839| Promise&lt;[BLEDescriptor](#bledescriptor)&gt; | Promise used to return the descriptor read.|
3840
3841**Error codes**
3842
3843For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3844
3845| ID| Error Message|
3846| -------- | ---------------------------- |
3847|2900001 | Service stopped.                         |
3848|2901000 | Read forbidden.                         |
3849|2900099 | Operation failed.                        |
3850
3851**Example**
3852
3853```js
3854import { BusinessError } from '@ohos.base';
3855let bufferDesc = new ArrayBuffer(8);
3856let descV = new Uint8Array(bufferDesc);
3857descV[0] = 11;
3858let descriptor: bluetoothManager.BLEDescriptor = {
3859    serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3860    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3861    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB',
3862    descriptorValue: bufferDesc
3863};
3864try {
3865    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3866    device.readDescriptorValue(descriptor);
3867} catch (err) {
3868    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3869}
3870```
3871
3872
3873### writeCharacteristicValue<sup>(deprecated)</sup>
3874
3875writeCharacteristicValue(characteristic: BLECharacteristic): void
3876
3877Writes a characteristic value to the remote BLE device.
3878
3879> **NOTE**<br>
3880> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#writeCharacteristicValue](js-apis-bluetooth-ble.md#writecharacteristicvalue).
3881
3882**Required permissions**: ohos.permission.USE_BLUETOOTH
3883
3884**System capability**: SystemCapability.Communication.Bluetooth.Core
3885
3886**Parameters**
3887
3888| Name           | Type                                     | Mandatory  | Description                 |
3889| -------------- | --------------------------------------- | ---- | ------------------- |
3890| characteristic | [BLECharacteristic](#blecharacteristic) | Yes   | Binary value and other parameters of the BLE device characteristic.|
3891
3892**Error codes**
3893
3894For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3895
3896| ID| Error Message|
3897| -------- | ---------------------------- |
3898|2900001 | Service stopped.                         |
3899|2901001 | Write forbidden.                        |
3900|2900099 | Operation failed.                        |
3901
3902**Example**
3903
3904```js
3905import { BusinessError } from '@ohos.base';
3906let descriptors: Array<bluetoothManager.BLEDescriptor> = [];
3907let bufferDesc = new ArrayBuffer(8);
3908let descV = new Uint8Array(bufferDesc);
3909descV[0] = 11;
3910let descriptor: bluetoothManager.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3911    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3912    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
3913descriptors[0] = descriptor;
3914
3915let bufferCCC = new ArrayBuffer(8);
3916let cccV = new Uint8Array(bufferCCC);
3917cccV[0] = 1;
3918let characteristic: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3919    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3920    characteristicValue: bufferCCC, descriptors:descriptors};
3921try {
3922    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3923    device.writeCharacteristicValue(characteristic);
3924} catch (err) {
3925    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3926}
3927```
3928
3929
3930### writeDescriptorValue<sup>(deprecated)</sup>
3931
3932writeDescriptorValue(descriptor: BLEDescriptor): void
3933
3934Writes binary data to the specific descriptor of the remote BLE device.
3935
3936> **NOTE**<br>
3937> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#writeCharacteristicValue](js-apis-bluetooth-ble.md#writecharacteristicvalue-1).
3938
3939**Required permissions**: ohos.permission.USE_BLUETOOTH
3940
3941**System capability**: SystemCapability.Communication.Bluetooth.Core
3942
3943**Parameters**
3944
3945| Name       | Type                             | Mandatory  | Description                |
3946| ---------- | ------------------------------- | ---- | ------------------ |
3947| descriptor | [BLEDescriptor](#bledescriptor) | Yes   | Binary value and other parameters of the BLE device descriptor.|
3948| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
3949
3950**Error codes**
3951
3952For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
3953
3954| ID| Error Message|
3955| -------- | ---------------------------- |
3956|2900001 | Service stopped.                         |
3957|2901001 | Write forbidden.                        |
3958|2900099 | Operation failed.                        |
3959
3960**Example**
3961
3962```js
3963import { BusinessError } from '@ohos.base';
3964let bufferDesc = new ArrayBuffer(8);
3965let descV = new Uint8Array(bufferDesc);
3966descV[0] = 22;
3967let descriptor: bluetoothManager.BLEDescriptor = {
3968    serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
3969    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
3970    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB',
3971    descriptorValue: bufferDesc
3972};
3973try {
3974    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3975    device.writeDescriptorValue(descriptor);
3976} catch (err) {
3977    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
3978}
3979```
3980
3981
3982### setBLEMtuSize<sup>(deprecated)</sup>
3983
3984setBLEMtuSize(mtu: number): void
3985
3986Sets the maximum transmission unit (MTU) that can be transmitted between the GATT client and its remote BLE device. This API can be used only after a connection is set up by calling [connect](#connect).
3987
3988> **NOTE**<br>
3989> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#setBLEMtuSize](js-apis-bluetooth-ble.md#setBLEMtuSize).
3990
3991**Required permissions**: ohos.permission.USE_BLUETOOTH
3992
3993**System capability**: SystemCapability.Communication.Bluetooth.Core
3994
3995**Parameters**
3996
3997| Name | Type    | Mandatory  | Description            |
3998| ---- | ------ | ---- | -------------- |
3999| mtu  | number | Yes   | MTU to set, which ranges from 22 to 512 bytes.|
4000
4001**Error codes**
4002
4003For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
4004
4005| ID| Error Message|
4006| -------- | ---------------------------- |
4007|2900001 | Service stopped.                         |
4008|2900099 | Operation failed.                        |
4009
4010**Example**
4011
4012```js
4013import { BusinessError } from '@ohos.base';
4014try {
4015    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
4016    device.setBLEMtuSize(128);
4017} catch (err) {
4018    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4019}
4020```
4021
4022
4023### setNotifyCharacteristicChanged<sup>(deprecated)</sup>
4024
4025setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): void
4026
4027Sets the function of notifying the GATT client when the characteristic value of the remote BLE device changes.
4028
4029> **NOTE**<br>
4030> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#setCharacteristicChangeNotification](js-apis-bluetooth-ble.md#setcharacteristicchangenotification).
4031
4032**Required permissions**: ohos.permission.USE_BLUETOOTH
4033
4034**System capability**: SystemCapability.Communication.Bluetooth.Core
4035
4036**Parameters**
4037
4038| Name           | Type                                     | Mandatory  | Description                           |
4039| -------------- | --------------------------------------- | ---- | ----------------------------- |
4040| characteristic | [BLECharacteristic](#blecharacteristic) | Yes   | BLE characteristic to listen for.                     |
4041| enable         | boolean                                 | Yes   | Whether to enable the notify function. The value **true** means to enable the notify function, and the value **false** means the opposite.|
4042
4043**Error codes**
4044
4045For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
4046
4047| ID| Error Message|
4048| -------- | ---------------------------- |
4049|2900001 | Service stopped.                         |
4050|2900099 | Operation failed.                        |
4051
4052**Example**
4053
4054```js
4055import { BusinessError } from '@ohos.base';
4056// Create descriptors.
4057let descriptors: Array<bluetoothManager.BLEDescriptor> = [];
4058let bufferDesc = new ArrayBuffer(8);
4059let descV = new Uint8Array(bufferDesc);
4060descV[0] = 11;
4061let descriptor: bluetoothManager.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
4062    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
4063    descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
4064descriptors[0] = descriptor;
4065
4066let bufferCCC = new ArrayBuffer(8);
4067let cccV = new Uint8Array(bufferCCC);
4068cccV[0] = 1;
4069let characteristic: bluetoothManager.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
4070    characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
4071    characteristicValue: bufferCCC, descriptors:descriptors};
4072try {
4073    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
4074    device.setNotifyCharacteristicChanged(characteristic, false);
4075} catch (err) {
4076    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4077}
4078
4079```
4080
4081
4082### on('BLECharacteristicChange')<sup>(deprecated)</sup>
4083
4084on(type: "BLECharacteristicChange", callback: Callback&lt;BLECharacteristic&gt;): void
4085
4086Subscribes to the BLE characteristic changes. The client can receive a notification from the server only after the **setNotifyCharacteristicChanged** method is called.
4087
4088> **NOTE**<br>
4089> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#on('BLECharacteristicChange')](js-apis-bluetooth-ble.md#onblecharacteristicchange).
4090
4091**Required permissions**: ohos.permission.USE_BLUETOOTH
4092
4093**System capability**: SystemCapability.Communication.Bluetooth.Core
4094
4095**Parameters**
4096
4097| Name     | Type                                      | Mandatory  | Description                                      |
4098| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
4099| type     | string                                   | Yes   | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
4100| callback | Callback&lt;[BLECharacteristic](#blecharacteristic)&gt; | Yes   | Callback invoked to return the characteristic value changes.                 |
4101
4102**Example**
4103
4104```js
4105import { BusinessError } from '@ohos.base';
4106function CharacteristicChange(characteristicChangeReq: ble.BLECharacteristic) {
4107    let serviceUuid: string = characteristicChangeReq.serviceUuid;
4108    let characteristicUuid: string = characteristicChangeReq.characteristicUuid;
4109    let value: Uint8Array = new Uint8Array(characteristicChangeReq.characteristicValue);
4110}
4111try {
4112    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
4113    device.on('BLECharacteristicChange', CharacteristicChange);
4114} catch (err) {
4115    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4116}
4117```
4118
4119
4120### off('BLECharacteristicChange')<sup>(deprecated)</sup>
4121
4122off(type: "BLECharacteristicChange", callback?: Callback&lt;BLECharacteristic&gt;): void
4123
4124Unsubscribes from the BLE characteristic changes.
4125
4126> **NOTE**<br>
4127> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#off('BLECharacteristicChange')](js-apis-bluetooth-ble.md#offblecharacteristicchange).
4128
4129**Required permissions**: ohos.permission.USE_BLUETOOTH
4130
4131**System capability**: SystemCapability.Communication.Bluetooth.Core
4132
4133**Parameters**
4134
4135| Name     | Type                                      | Mandatory  | Description                                      |
4136| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
4137| type     | string                                   | Yes   | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
4138| callback | Callback&lt;[BLECharacteristic](#blecharacteristic)&gt; | No   | Callback for the characteristic value change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
4139
4140**Example**
4141
4142```js
4143import { BusinessError } from '@ohos.base';
4144try {
4145    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
4146    device.off('BLECharacteristicChange');
4147} catch (err) {
4148    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4149}
4150```
4151
4152
4153### on('BLEConnectionStateChange')<sup>(deprecated)</sup>
4154
4155on(type: "BLEConnectionStateChange", callback: Callback&lt;BLEConnectChangedState&gt;): void
4156
4157Subscribes to the BLE connection state changes.
4158
4159> **NOTE**<br>
4160> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#on('BLEConnectionStateChange')](js-apis-bluetooth-ble.md#onbleconnectionstatechange).
4161
4162**Required permissions**: ohos.permission.USE_BLUETOOTH
4163
4164**System capability**: SystemCapability.Communication.Bluetooth.Core
4165
4166**Parameters**
4167
4168| Name     | Type                                      | Mandatory  | Description                                      |
4169| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
4170| type     | string                                   | Yes   | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
4171| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstate)&gt; | Yes   | Callback invoked to return the BLE connection state.                          |
4172
4173**Example**
4174
4175```js
4176import { BusinessError } from '@ohos.base';
4177function ConnectStateChanged(state: bluetoothManager.BLEConnectChangedState) {
4178    console.log('bluetooth connect state changed');
4179    let connectState: bluetoothManager.ProfileConnectionState = state.state;
4180}
4181try {
4182    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
4183    device.on('BLEConnectionStateChange', ConnectStateChanged);
4184} catch (err) {
4185    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4186}
4187```
4188
4189
4190### off('BLEConnectionStateChange')<sup>(deprecated)</sup>
4191
4192off(type: "BLEConnectionStateChange", callback?: Callback&lt;BLEConnectChangedState&gt;): void
4193
4194Unsubscribes from the BLE connection state changes.
4195
4196> **NOTE**<br>
4197> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#off('BLEConnectionStateChange')](js-apis-bluetooth-ble.md#offbleconnectionstatechange).
4198
4199**Required permissions**: ohos.permission.USE_BLUETOOTH
4200
4201**System capability**: SystemCapability.Communication.Bluetooth.Core
4202
4203**Parameters**
4204
4205| Name     | Type                                      | Mandatory  | Description                                      |
4206| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
4207| type     | string                                   | Yes   | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
4208| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstate)&gt; | No   | Callback for the BLE connection state change event. If this parameter is not set, this method unsubscribes from all callbacks corresponding to **type**.|
4209
4210**Example**
4211
4212```js
4213import { BusinessError } from '@ohos.base';
4214try {
4215    let device = bluetoothManager.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
4216    device.off('BLEConnectionStateChange');
4217} catch (err) {
4218    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4219}
4220```
4221
4222
4223### getDeviceName<sup>(deprecated)</sup>
4224
4225getDeviceName(callback: AsyncCallback&lt;string&gt;): void
4226
4227Obtains the name of the remote BLE device. This API uses an asynchronous callback to return the result.
4228
4229> **NOTE**<br>
4230> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#getDeviceName](js-apis-bluetooth-ble.md#getdevicename).
4231
4232**Required permissions**: ohos.permission.USE_BLUETOOTH
4233
4234**System capability**: SystemCapability.Communication.Bluetooth.Core
4235
4236**Parameters**
4237
4238| Name     | Type                         | Mandatory  | Description                             |
4239| -------- | --------------------------- | ---- | ------------------------------- |
4240| callback | AsyncCallback&lt;string&gt; | Yes   | Callback invoked to return the remote BLE device name obtained.|
4241
4242**Error codes**
4243
4244For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
4245
4246| ID| Error Message|
4247| -------- | ---------------------------- |
4248|2900001 | Service stopped.                         |
4249|2900099 | Operation failed.                        |
4250
4251**Example**
4252
4253```js
4254import { BusinessError } from '@ohos.base';
4255// callback
4256try {
4257    let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
4258    gattClient.connect();
4259    let deviceName = gattClient.getDeviceName((err, data)=> {
4260        console.info('device name err ' + JSON.stringify(err));
4261        console.info('device name' + JSON.stringify(data));
4262    })
4263} catch (err) {
4264    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4265}
4266```
4267
4268
4269### getDeviceName<sup>(deprecated)</sup>
4270
4271getDeviceName(): Promise&lt;string&gt;
4272
4273Obtains the name of the remote BLE device. This API uses a promise to return the result.
4274
4275> **NOTE**<br>
4276> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#getDeviceName](js-apis-bluetooth-ble.md#getdevicename-1).
4277
4278**Required permissions**: ohos.permission.USE_BLUETOOTH
4279
4280**System capability**: SystemCapability.Communication.Bluetooth.Core
4281
4282**Return value**
4283
4284| Type                   | Description                                |
4285| --------------------- | ---------------------------------- |
4286| Promise&lt;string&gt; | Promise used to return the remote BLE device name.|
4287
4288**Error codes**
4289
4290For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
4291
4292| ID| Error Message|
4293| -------- | ---------------------------- |
4294|2900001 | Service stopped.                         |
4295|2900099 | Operation failed.                        |
4296
4297**Example**
4298
4299```js
4300import { BusinessError } from '@ohos.base';
4301// promise
4302try {
4303    let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
4304    gattClient.connect();
4305    let deviceName = gattClient.getDeviceName().then((data) => {
4306        console.info('device name' + JSON.stringify(data));
4307    })
4308} catch (err) {
4309    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4310}
4311```
4312
4313
4314### getRssiValue<sup>(deprecated)</sup>
4315
4316getRssiValue(callback: AsyncCallback&lt;number&gt;): void
4317
4318Obtains the received signal strength indication (RSSI) of the remote BLE device. This API uses an asynchronous callback to return the result. It can be used only after a connection is set up by calling [connect](#connect).
4319
4320> **NOTE**<br>
4321> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#getRssiValue](js-apis-bluetooth-ble.md#getrssivalue).
4322
4323**Required permissions**: ohos.permission.USE_BLUETOOTH
4324
4325**System capability**: SystemCapability.Communication.Bluetooth.Core
4326
4327**Parameters**
4328
4329| Name     | Type                         | Mandatory  | Description                            |
4330| -------- | --------------------------- | ---- | ------------------------------ |
4331| callback | AsyncCallback&lt;number&gt; | Yes   | Callback invoked to return the RSSI, in dBm.|
4332
4333**Error codes**
4334
4335For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
4336
4337| ID| Error Message|
4338| -------- | ---------------------------- |
4339|2900099 | Operation failed.                        |
4340
4341**Example**
4342
4343```js
4344import { BusinessError } from '@ohos.base';
4345// callback
4346try {
4347    let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
4348    gattClient.connect();
4349    let rssi = gattClient.getRssiValue((err: BusinessError, data: number)=> {
4350        console.info('rssi err ' + JSON.stringify(err));
4351        console.info('rssi value' + JSON.stringify(data));
4352    })
4353} catch (err) {
4354    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4355}
4356```
4357
4358
4359### getRssiValue<sup>(deprecated)</sup>
4360
4361getRssiValue(): Promise&lt;number&gt;
4362
4363Obtains the RSSI of the remote BLE device. This API uses a promise to return the result. It can be used only after a connection is set up by calling [connect](#connect).
4364
4365> **NOTE**<br>
4366> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattClientDevice#getRssiValue](js-apis-bluetooth-ble.md#getrssivalue-1).
4367
4368**Required permissions**: ohos.permission.USE_BLUETOOTH
4369
4370**System capability**: SystemCapability.Communication.Bluetooth.Core
4371
4372**Return value**
4373
4374| Type                   | Description                               |
4375| --------------------- | --------------------------------- |
4376| Promise&lt;number&gt; | Promise used to return the RSSI, in dBm.|
4377
4378**Error codes**
4379
4380For details about the error codes, see [Bluetooth Error Codes](../errorcodes/errorcode-bluetoothManager.md).
4381
4382| ID| Error Message|
4383| -------- | ---------------------------- |
4384|2900099 | Operation failed.                        |
4385
4386**Example**
4387
4388```js
4389import { BusinessError } from '@ohos.base';
4390// promise
4391try {
4392    let gattClient = bluetoothManager.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
4393    let rssi = gattClient.getRssiValue().then((data: number) => {
4394        console.info('rssi' + JSON.stringify(data));
4395    })
4396} catch (err) {
4397    console.error("errCode:" + (err as BusinessError).code + ",errMessage:" + (err as BusinessError).message);
4398}
4399```
4400
4401## ScanMode<sup>(deprecated)</sup><a name="ScanMode"></a>
4402
4403Enumerates the scan modes.
4404
4405> **NOTE**<br>
4406> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.ScanMode](js-apis-bluetooth-connection.md#scanmode).
4407
4408**System capability**: SystemCapability.Communication.Bluetooth.Core
4409
4410| Name                                      | Value | Description             |
4411| ---------------------------------------- | ---- | --------------- |
4412| SCAN_MODE_NONE                           | 0    | No scan mode.        |
4413| SCAN_MODE_CONNECTABLE                    | 1    | Connectable mode.       |
4414| SCAN_MODE_GENERAL_DISCOVERABLE           | 2    | General discoverable mode.   |
4415| SCAN_MODE_LIMITED_DISCOVERABLE           | 3    | Limited discoverable mode.   |
4416| SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE | 4    | General connectable and discoverable mode.|
4417| SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE | 5    | Limited connectable and discoverable mode.|
4418
4419## BondState<sup>(deprecated)</sup><a name="BondState"></a>
4420
4421Enumerates the pairing states.
4422
4423> **NOTE**<br>
4424> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.BondState](js-apis-bluetooth-connection.md#bondstate).
4425
4426**System capability**: SystemCapability.Communication.Bluetooth.Core
4427
4428| Name                | Value | Description    |
4429| ------------------ | ---- | ------ |
4430| BOND_STATE_INVALID | 0    | Invalid pairing.|
4431| BOND_STATE_BONDING | 1    | Pairing. |
4432| BOND_STATE_BONDED  | 2    | Paired.  |
4433
4434
4435## SppOption<sup>(deprecated)</sup><a name="SppOption"></a>
4436
4437Defines the SPP configuration parameters.
4438
4439> **NOTE**<br>
4440> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.SppOption](js-apis-bluetooth-socket.md#sppoptions).
4441
4442**System capability**: SystemCapability.Communication.Bluetooth.Core
4443
4444| Name    | Type               | Readable  | Writable  | Description         |
4445| ------ | ------------------- | ---- | ---- | ----------- |
4446| uuid   | string              | Yes   | Yes   | UUID of the SPP.|
4447| secure | boolean             | Yes   | Yes   | Whether it is a secure channel.   |
4448| type   | [SppType](#spptype) | Yes   | Yes   | Type of the SPP link.   |
4449
4450
4451## SppType<sup>(deprecated)</sup><a name="SppType"></a>
4452
4453Enumerates the SPP link types.
4454
4455> **NOTE**<br>
4456> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [socket.SppType](js-apis-bluetooth-socket.md#spptype).
4457
4458**System capability**: SystemCapability.Communication.Bluetooth.Core
4459
4460| Name        | Value | Description           |
4461| ---------- | ---- | ------------- |
4462| SPP_RFCOMM | 0    | Radio frequency communication (RFCOMM) link type.|
4463
4464
4465## GattService<sup>(deprecated)</sup>
4466
4467Defines the GATT service API parameters.
4468
4469> **NOTE**<br>
4470> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.GattService](js-apis-bluetooth-ble.md#gattservice).
4471
4472**System capability**: SystemCapability.Communication.Bluetooth.Core
4473
4474| Name             | Type                                    | Readable  | Writable  | Description                                      |
4475| --------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
4476| serviceUuid     | string                                   | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4477| isPrimary       | boolean                                  | Yes   | Yes   | Whether the service is a primary service. The value **true** means a primary service.               |
4478| characteristics | Array&lt;[BLECharacteristic](#blecharacteristic)&gt; | Yes   | Yes   | List of characteristics of the service.                            |
4479| includeServices | Array&lt;[GattService](#gattservice)&gt; | Yes   | Yes   | Services on which the service depends.                            |
4480
4481
4482## BLECharacteristic<sup>(deprecated)</sup>
4483
4484Defines the characteristic API parameters.
4485
4486> **NOTE**<br>
4487> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.BLECharacteristic](js-apis-bluetooth-ble.md#blecharacteristic).
4488
4489**System capability**: SystemCapability.Communication.Bluetooth.Core
4490
4491| Name                 | Type                                    | Readable  | Writable  | Description                                |
4492| ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
4493| serviceUuid         | string                                   | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4494| characteristicUuid  | string                                   | Yes   | Yes   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4495| characteristicValue | ArrayBuffer                              | Yes   | Yes   | Binary value of the characteristic.                     |
4496| descriptors         | Array&lt;[BLEDescriptor](#bledescriptor)&gt; | Yes   | Yes   | List of descriptors of the characteristic.               |
4497
4498
4499## BLEDescriptor<sup>(deprecated)</sup>
4500
4501Defines the descriptor API parameters.
4502
4503> **NOTE**<br>
4504> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.BLEDescriptor](js-apis-bluetooth-ble.md#bledescriptor).
4505
4506**System capability**: SystemCapability.Communication.Bluetooth.Core
4507
4508| Name                | Type       | Readable  | Writable  | Description                                      |
4509| ------------------ | ----------- | ---- | ---- | ---------------------------------------- |
4510| serviceUuid        | string      | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4511| characteristicUuid | string      | Yes   | Yes   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4512| descriptorUuid     | string      | Yes   | Yes   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
4513| descriptorValue    | ArrayBuffer | Yes   | Yes   | Binary value of the descriptor.                             |
4514
4515
4516## NotifyCharacteristic<sup>(deprecated)</sup>
4517
4518Defines the parameters in the notifications sent when the server characteristic value changes.
4519
4520> **NOTE**<br>
4521> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.NotifyCharacteristic](js-apis-bluetooth-ble.md#notifycharacteristic).
4522
4523**System capability**: SystemCapability.Communication.Bluetooth.Core
4524
4525| Name                 | Type       | Readable  | Writable  | Description                                      |
4526| ------------------- | ----------- | ---- | ---- | ---------------------------------------- |
4527| serviceUuid         | string      | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4528| characteristicUuid  | string      | Yes   | Yes   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4529| characteristicValue | ArrayBuffer | Yes   | Yes   | Binary value of the characteristic.                              |
4530| confirm             | boolean     | Yes   | Yes   | Whether the notification needs to be confirmed by the remote end. For a notification, set it to **true**. In this case, the remote end must confirm the receipt of the notification. For an indication, set it to **false**. In this case, the remote end does not need to confirm the receipt of the notification.|
4531
4532
4533## CharacteristicReadRequest<sup>(deprecated)</sup>
4534
4535Defines the parameters of the **CharacteristicReadReq** event received by the server.
4536
4537> **NOTE**<br>
4538> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.CharacteristicReadRequest](js-apis-bluetooth-ble.md#characteristicreadrequest).
4539
4540**System capability**: SystemCapability.Communication.Bluetooth.Core
4541
4542| Name                | Type  | Readable  | Writable  | Description                                      |
4543| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
4544| deviceId           | string | Yes   | No   | Address of the remote device that sends the **CharacteristicReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
4545| transId            | number | Yes   | No   | Transmission ID of the read request. The response returned by the server must use the same transmission ID.      |
4546| offset             | number | Yes   | No   | Position from which the characteristic value is read. For example, **k** means to read from the kth byte. The response returned by the server must use the same offset.|
4547| characteristicUuid | string | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4548| serviceUuid        | string | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4549
4550
4551## CharacteristicWriteRequest<sup>(deprecated)</sup>
4552
4553Defines the parameters of the **CharacteristicWriteReq** event received by the server.
4554
4555> **NOTE**<br>
4556> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.CharacteristicWriteRequest](js-apis-bluetooth-ble.md#characteristicwriterequest).
4557
4558**System capability**: SystemCapability.Communication.Bluetooth.Core
4559
4560| Name                | Type  | Readable  | Writable  | Description                                      |
4561| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
4562| deviceId           | string | Yes   | No   | Address of the remote device that sends the **CharacteristicWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
4563| transId            | number | Yes   | No   | Transmission ID of the write request. The response returned by the server must use the same transmission ID.      |
4564| offset             | number | Yes   | No   | Start position for writing the characteristic value. For example, **k** means to write from the kth byte. The response returned by the server must use the same offset.|
4565| descriptorUuid     | string | Yes   | No   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
4566| characteristicUuid | string | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4567| serviceUuid        | string | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4568
4569
4570## DescriptorReadRequest<sup>(deprecated)</sup>
4571
4572Defines the parameters of the **DescriptorReadReq** event received by the server.
4573
4574> **NOTE**<br>
4575> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.DescriptorReadRequest](js-apis-bluetooth-ble.md#descriptorreadrequest).
4576
4577**System capability**: SystemCapability.Communication.Bluetooth.Core
4578
4579| Name                | Type  | Readable  | Writable  | Description                                      |
4580| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
4581| deviceId           | string | Yes   | No   | Address of the remote device that sends a **DescriptorReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
4582| transId            | number | Yes   | No   | Transmission ID of the read request. The response returned by the server must use the same transmission ID.      |
4583| offset             | number | Yes   | No   | Position from which the descriptor is read. For example, **k** means to read from the kth byte. The response returned by the server must use the same offset.|
4584| descriptorUuid     | string | Yes   | No   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
4585| characteristicUuid | string | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4586| serviceUuid        | string | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4587
4588
4589## DescriptorWriteRequest<sup>(deprecated)</sup>
4590
4591Defines the parameters of the **DescriptorWriteReq** event received by the server.
4592
4593> **NOTE**<br>
4594> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.DescriptorWriteRequest](js-apis-bluetooth-ble.md#descriptorwriterequest).
4595
4596**System capability**: SystemCapability.Communication.Bluetooth.Core
4597
4598| Name                | Type       | Readable  | Writable  | Description                                      |
4599| ------------------ | ----------- | ---- | ---- | ---------------------------------------- |
4600| deviceId           | string      | Yes   | No   | Address of the remote device that sends a **DescriptorWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
4601| transId            | number      | Yes   | No   | Transmission ID of the write request. The response returned by the server must use the same transmission ID.      |
4602| offset             | number      | Yes   | No   | Start position for writing the descriptor. For example, **k** means to write from the kth byte. The response returned by the server must use the same offset.|
4603| isPrep             | boolean     | Yes   | No   | Whether the write request is executed immediately.                            |
4604| needRsp            | boolean     | Yes   | No   | Whether to send a response to the GATT client.                      |
4605| value              | ArrayBuffer | Yes   | No   | Binary value of the descriptor to write.                          |
4606| descriptorUuid     | string      | Yes   | No   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
4607| characteristicUuid | string      | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
4608| serviceUuid        | string      | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4609
4610
4611## ServerResponse<sup>(deprecated)</sup>
4612
4613Defines the parameters of the server's response to the GATT client's read/write request.
4614
4615> **NOTE**<br>
4616> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ServerResponse](js-apis-bluetooth-ble.md#serverresponse).
4617
4618**System capability**: SystemCapability.Communication.Bluetooth.Core
4619
4620| Name      | Type       | Readable  | Writable  | Description                                    |
4621| -------- | ----------- | ---- | ---- | -------------------------------------- |
4622| deviceId | string      | Yes   | No   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.      |
4623| transId  | number      | Yes   | No   | Transmission ID of the request. The value must be the same as the ID carried in the read/write request received.       |
4624| status   | number      | Yes   | No   | Response state. Set this parameter to **0**, which indicates a normal response.                  |
4625| offset   | number      | Yes   | No   | Start read/write position. The value must be the same as the offset carried in the read/write request.|
4626| value    | ArrayBuffer | Yes   | No   | Binary data in the response.                         |
4627
4628
4629## BLEConnectChangedState<sup>(deprecated)</sup>
4630
4631Defines the parameters of **BLEConnectChangedState**.
4632
4633> **NOTE**<br>
4634> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [BLEConnectionChangeState](js-apis-bluetooth-ble.md#bleconnectionchangestate).
4635
4636**System capability**: SystemCapability.Communication.Bluetooth.Core
4637
4638| Name    | Type                                         | Readable| Writable| Description                                         |
4639| -------- | ------------------------------------------------- | ---- | ---- | --------------------------------------------- |
4640| deviceId | string                                            | Yes  | No  | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
4641| state    | [ProfileConnectionState](#profileconnectionstate) | Yes  | Yes  | BLE connection state.                      |
4642
4643
4644## ProfileConnectionState<sup>(deprecated)</sup>
4645
4646Enumerates the profile connection states.
4647
4648> **NOTE**<br>
4649> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [constant.ProfileConnectionState](js-apis-bluetooth-constant.md#profileconnectionstate).
4650
4651**System capability**: SystemCapability.Communication.Bluetooth.Core
4652
4653| Name                 | Value | Description            |
4654| ------------------- | ---- | -------------- |
4655| STATE_DISCONNECTED  | 0    | Disconnected. |
4656| STATE_CONNECTING    | 1    | Connecting.|
4657| STATE_CONNECTED     | 2    | Connected. |
4658| STATE_DISCONNECTING | 3    | Disconnecting.|
4659
4660
4661## ScanFilter<sup>(deprecated)</sup>
4662
4663Defines the scan filter parameters.
4664
4665> **NOTE**<br>
4666> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ScanFilter](js-apis-bluetooth-ble.md#scanfilter).
4667
4668**System capability**: SystemCapability.Communication.Bluetooth.Core
4669
4670| Name                                    | Type   | Readable| Writable| Description                                                        |
4671| ---------------------------------------- | ----------- | ---- | ---- | ------------------------------------------------------------ |
4672| deviceId                                 | string      | Yes  | Yes  | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX.          |
4673| name                                     | string      | Yes  | Yes  | Name of the BLE device to filter.                                       |
4674| serviceUuid                              | string      | Yes  | Yes  | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
4675| serviceUuidMask             | string      | Yes  | Yes  | Service UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
4676| serviceSolicitationUuid     | string      | Yes  | Yes  | Service solicitation UUID of the device to filter, for example, **00001888-0000-1000-8000-00805F9B34FB**.|
4677| serviceSolicitationUuidMask | string      | Yes  | Yes  | Service solicitation UUID mask of the device to filter, for example, **FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF**.|
4678| serviceData                 | ArrayBuffer | Yes  | Yes  | Service data of the device to filter, for example, **[0x90, 0x00, 0xF1, 0xF2]**.|
4679| serviceDataMask             | ArrayBuffer | Yes  | Yes  | Service data mask of the device to filter, for example, **[0xFF,0xFF,0xFF,0xFF]**.|
4680| manufactureId               | number      | Yes  | Yes  | Manufacturer ID of the device to filter, for example, **0x0006**.                |
4681| manufactureData             | ArrayBuffer | Yes  | Yes  | Manufacturer data of the device to filter, for example, **[0x1F,0x2F,0x3F]**.|
4682| manufactureDataMask         | ArrayBuffer | Yes  | Yes  | Manufacturer data mask of the device to filter, for example, **[0xFF, 0xFF, 0xFF]**.|
4683
4684
4685## ScanOptions<sup>(deprecated)</sup>
4686
4687Defines the scan configuration parameters.
4688
4689> **NOTE**<br>
4690> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ScanOptions](js-apis-bluetooth-ble.md#scanoptions).
4691
4692**System capability**: SystemCapability.Communication.Bluetooth.Core
4693
4694| Name       | Type                   | Readable  | Writable  | Description                                    |
4695| --------- | ----------------------- | ---- | ---- | -------------------------------------- |
4696| interval  | number                  | Yes   | Yes   | Delay in reporting the scan result. The default value is **0**.                   |
4697| dutyMode  | [ScanDuty](#scanduty)   | Yes   | Yes   | Scan duty. The default value is SCAN_MODE_LOW_POWER.       |
4698| matchMode | [MatchMode](#matchmode) | Yes   | Yes   | Hardware filtering match mode. The default value is **MATCH_MODE_AGGRESSIVE**.|
4699
4700
4701## ScanDuty<sup>(deprecated)</sup>
4702
4703Enumerates the scan duty options.
4704
4705> **NOTE**<br>
4706> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ScanDuty](js-apis-bluetooth-ble.md#scanduty).
4707
4708**System capability**: SystemCapability.Communication.Bluetooth.Core
4709
4710| Name                   | Value | Description          |
4711| --------------------- | ---- | ------------ |
4712| SCAN_MODE_LOW_POWER   | 0    | Low-power mode, which is the default value.|
4713| SCAN_MODE_BALANCED    | 1    | Balanced mode.     |
4714| SCAN_MODE_LOW_LATENCY | 2    | Low-latency mode.    |
4715
4716
4717## MatchMode<sup>(deprecated)</sup>
4718
4719Enumerates the hardware match modes of BLE scan filters.
4720
4721> **NOTE**<br>
4722> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.MatchMode](js-apis-bluetooth-ble.md#matchmode).
4723
4724**System capability**: SystemCapability.Communication.Bluetooth.Core
4725
4726| Name                   | Value | Description                                      |
4727| --------------------- | ---- | ---------------------------------------- |
4728| MATCH_MODE_AGGRESSIVE | 1    | Hardware reports the scan result with a lower threshold of signal strength and few number of matches in a duration. This is the default value.|
4729| MATCH_MODE_STICKY     | 2    | Hardware reports the scan result with a higher threshold of signal strength and sightings.      |
4730
4731
4732## ScanResult<sup>(deprecated)</sup>
4733
4734Defines the scan result.
4735
4736> **NOTE**<br>
4737> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ScanResult](js-apis-bluetooth-ble.md#scanresult).
4738
4739**System capability**: SystemCapability.Communication.Bluetooth.Core
4740
4741| Name      | Type       | Readable  | Writable  | Description                                |
4742| -------- | ----------- | ---- | ---- | ---------------------------------- |
4743| deviceId | string      | Yes   | No   | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.|
4744| rssi     | number      | Yes   | No   | RSSI of the device.                   |
4745| data     | ArrayBuffer | Yes   | No   | Advertisement packets sent by the device.                   |
4746
4747
4748## BluetoothState<sup>(deprecated)</sup>
4749
4750Enumerates the Bluetooth states.
4751
4752> **NOTE**<br>
4753> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [access.BluetoothState](js-apis-bluetooth-access.md#bluetoothstate).
4754
4755**System capability**: SystemCapability.Communication.Bluetooth.Core
4756
4757| Name                   | Value | Description                |
4758| --------------------- | ---- | ------------------ |
4759| STATE_OFF             | 0    | Bluetooth is turned off.          |
4760| STATE_TURNING_ON      | 1    | Bluetooth is being turned on.         |
4761| STATE_ON              | 2    | Bluetooth is turned on.          |
4762| STATE_TURNING_OFF     | 3    | Bluetooth is being turned off.         |
4763| STATE_BLE_TURNING_ON  | 4    | The LE-only mode is being turned on for Bluetooth.|
4764| STATE_BLE_ON          | 5    | Bluetooth is in LE-only mode. |
4765| STATE_BLE_TURNING_OFF | 6    | The LE-only mode is being turned off for Bluetooth.|
4766
4767
4768## AdvertiseSetting<sup>(deprecated)</sup>
4769
4770Defines the BLE advertising parameters.
4771
4772> **NOTE**<br>
4773> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.AdvertiseSetting](js-apis-bluetooth-ble.md#advertisesetting).
4774
4775**System capability**: SystemCapability.Communication.Bluetooth.Core
4776
4777| Name         | Type   | Readable  | Writable  | Description                                      |
4778| ----------- | ------- | ---- | ---- | ---------------------------------------- |
4779| interval    | number  | Yes   | Yes   | Interval for BLE advertising. The minimum value is **32** slots (20 ms). The maximum value is **16384** slots. The default value is **1600** slots (1s).|
4780| txPower     | number  | Yes   | Yes   | Transmit power, in dBm. The value range is -127 to 1. The default value is **-7**.  |
4781| connectable | boolean | Yes   | Yes   | Whether the advertisement is connectable. The default value is **true**.                  |
4782
4783
4784## AdvertiseData<sup>(deprecated)</sup>
4785
4786Defines the content of a BLE advertisement packet.
4787
4788> **NOTE**<br>
4789> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.AdvertiseData](js-apis-bluetooth-ble.md#advertisedata).
4790
4791**System capability**: SystemCapability.Communication.Bluetooth.Core
4792
4793| Name             | Type                                    | Readable  | Writable  | Description                         |
4794| --------------- | ---------------------------------------- | ---- | ---- | --------------------------- |
4795| serviceUuids    | Array&lt;string&gt;                      | Yes   | Yes   | List of service UUIDs to broadcast.|
4796| manufactureData | Array&lt;[ManufactureData](#manufacturedata)&gt; | Yes   | Yes   | List of manufacturers to broadcast.          |
4797| serviceData     | Array&lt;[ServiceData](#servicedata)&gt; | Yes   | Yes   | List of service data to broadcast.              |
4798
4799
4800## ManufactureData<sup>(deprecated)</sup>
4801
4802Defines the content of a BLE advertisement packet.
4803
4804> **NOTE**<br>
4805> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ManufactureData](js-apis-bluetooth-ble.md#manufacturedata).
4806
4807**System capability**: SystemCapability.Communication.Bluetooth.Core
4808
4809| Name              | Type               | Readable  | Writable  | Description                |
4810| ---------------- | ------------------- | ---- | ---- | ------------------ |
4811| manufactureId    | number  | Yes   | Yes   | Manufacturer ID allocated by the Bluetooth SIG.|
4812| manufactureValue | ArrayBuffer         | Yes   | Yes   | Manufacturer data.    |
4813
4814
4815## ServiceData<sup>(deprecated)</sup>
4816
4817Defines the service data contained in an advertisement packet.
4818
4819> **NOTE**<br>
4820> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [ble.ServiceData](js-apis-bluetooth-ble.md#servicedata).
4821
4822**System capability**: SystemCapability.Communication.Bluetooth.Core
4823
4824| Name          | Type       | Readable  | Writable  | Description        |
4825| ------------ | ----------- | ---- | ---- | ---------- |
4826| serviceUuid  | string      | Yes   | Yes   | Service UUID.|
4827| serviceValue | ArrayBuffer | Yes   | Yes   | Service data.   |
4828
4829
4830## PinRequiredParam<sup>(deprecated)</sup><a name="PinRequiredParam"></a>
4831
4832Defines the pairing request parameters.
4833
4834> **NOTE**<br>
4835> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.PinRequiredParam](js-apis-bluetooth-connection.md#pinrequiredparam).
4836
4837**System capability**: SystemCapability.Communication.Bluetooth.Core
4838
4839| Name      | Type  | Readable  | Writable  | Description         |
4840| -------- | ------ | ---- | ---- | ----------- |
4841| deviceId | string | Yes   | No   | ID of the device to pair.|
4842| pinCode  | string | Yes   | No   | Key for the device pairing.  |
4843
4844
4845## BondStateParam<sup>(deprecated)</sup><a name="BondStateParam"></a>
4846
4847Defines the pairing state parameters.
4848
4849> **NOTE**<br>
4850> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.BondStateParam](js-apis-bluetooth-connection.md#bondstateparam).
4851
4852**System capability**: SystemCapability.Communication.Bluetooth.Core
4853
4854| Name      | Type  | Readable  | Writable  | Description         |
4855| -------- | ------ | ---- | ---- | ----------- |
4856| deviceId | string      | Yes   | No   | ID of the device to pair.|
4857| state    | BondState   | Yes   | No   | State of the device.|
4858
4859
4860## StateChangeParam<sup>(deprecated)</sup><a name="StateChangeParam"></a>
4861
4862Defines the profile state change parameters.
4863
4864> **NOTE**<br>
4865> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [baseProfile.StateChangeParam](js-apis-bluetooth-baseProfile.md#statechangeparam).
4866
4867**System capability**: SystemCapability.Communication.Bluetooth.Core
4868
4869| Name    | Type                                         | Readable| Writable| Description                           |
4870| -------- | ------------------------------------------------- | ---- | ---- | ------------------------------- |
4871| deviceId | string                                            | Yes  | No  | Address of a Bluetooth device.             |
4872| state    | [ProfileConnectionState](#profileconnectionstate) | Yes  | No  | Profile connection state of the device.|
4873
4874
4875## DeviceClass<sup>(deprecated)</sup><a name="DeviceClass"></a>
4876
4877Defines the class of a Bluetooth device.
4878
4879> **NOTE**<br>
4880> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [connection.DeviceClass](js-apis-bluetooth-connection.md#deviceclass).
4881
4882**System capability**: SystemCapability.Communication.Bluetooth.Core
4883
4884| Name             | Type                               | Readable  | Writable  | Description              |
4885| --------------- | ----------------------------------- | ---- | ---- | ---------------- |
4886| majorClass      | [MajorClass](#majorclass)           | Yes   | No   | Major classes of Bluetooth devices.  |
4887| majorMinorClass | [MajorMinorClass](#majorminorclass) | Yes   | No   | Major and minor classes of Bluetooth devices.|
4888| classOfDevice   | number                              | Yes   | No   | Class of the device.         |
4889
4890
4891## MajorClass<sup>(deprecated)</sup><a name="MajorClass"></a>
4892
4893Enumerates the major classes of Bluetooth devices.
4894
4895> **NOTE**<br>
4896> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [constant.MajorClass](js-apis-bluetooth-constant.md#majorclass).
4897
4898**System capability**: SystemCapability.Communication.Bluetooth.Core
4899
4900| Name                 | Value   | Description        |
4901| ------------------- | ------ | ---------- |
4902| MAJOR_MISC          | 0x0000 | Miscellaneous device.   |
4903| MAJOR_COMPUTER      | 0x0100 | Computer.  |
4904| MAJOR_PHONE         | 0x0200 | Mobile phone.   |
4905| MAJOR_NETWORKING    | 0x0300 | Network device.   |
4906| MAJOR_AUDIO_VIDEO   | 0x0400 | Audio or video device.|
4907| MAJOR_PERIPHERAL    | 0x0500 | Peripheral device.   |
4908| MAJOR_IMAGING       | 0x0600 | Imaging device.   |
4909| MAJOR_WEARABLE      | 0x0700 | Wearable device.  |
4910| MAJOR_TOY           | 0x0800 | Toy.   |
4911| MAJOR_HEALTH        | 0x0900 | Health device.   |
4912| MAJOR_UNCATEGORIZED | 0x1F00 | Unclassified device.  |
4913
4914
4915## MajorMinorClass<sup>(deprecated)</sup><a name="MajorMinorClass"></a>
4916
4917Enumerates the major and minor classes of Bluetooth devices.
4918
4919> **NOTE**<br>
4920> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [constant.MajorMinorClass](js-apis-bluetooth-constant.md#majorminorclass).
4921
4922**System capability**: SystemCapability.Communication.Bluetooth.Core
4923
4924| Name                                      | Value   | Description             |
4925| ---------------------------------------- | ------ | --------------- |
4926| COMPUTER_UNCATEGORIZED                   | 0x0100 | Unclassified computer.    |
4927| COMPUTER_DESKTOP                         | 0x0104 | Desktop computer.     |
4928| COMPUTER_SERVER                          | 0x0108 | Server.       |
4929| COMPUTER_LAPTOP                          | 0x010C | Laptop.    |
4930| COMPUTER_HANDHELD_PC_PDA                 | 0x0110 | Hand-held computer.    |
4931| COMPUTER_PALM_SIZE_PC_PDA                | 0x0114 | Palmtop computer.      |
4932| COMPUTER_WEARABLE                        | 0x0118 | Wearable computer.    |
4933| COMPUTER_TABLET                          | 0x011C | Tablet.      |
4934| PHONE_UNCATEGORIZED                      | 0x0200 | Unclassified mobile phone.     |
4935| PHONE_CELLULAR                           | 0x0204 | Portable phone.     |
4936| PHONE_CORDLESS                           | 0x0208 | Cordless phone.      |
4937| PHONE_SMART                              | 0x020C | Smartphone.      |
4938| PHONE_MODEM_OR_GATEWAY                   | 0x0210 | Modem or gateway phone.|
4939| PHONE_ISDN                               | 0x0214 | ISDN phone.    |
4940| NETWORK_FULLY_AVAILABLE                  | 0x0300 | Device with network fully available.    |
4941| NETWORK_1_TO_17_UTILIZED                 | 0x0320 | Device used on network 1 to 17.  |
4942| NETWORK_17_TO_33_UTILIZED                | 0x0340 | Device used on network 17 to 33. |
4943| NETWORK_33_TO_50_UTILIZED                | 0x0360 | Device used on network 33 to 50. |
4944| NETWORK_60_TO_67_UTILIZED                | 0x0380 | Device used on network 60 to 67. |
4945| NETWORK_67_TO_83_UTILIZED                | 0x03A0 | Device used on network 67 to 83. |
4946| NETWORK_83_TO_99_UTILIZED                | 0x03C0 | Device used on network 83 to 99. |
4947| NETWORK_NO_SERVICE                       | 0x03E0 | Device without network service     |
4948| AUDIO_VIDEO_UNCATEGORIZED                | 0x0400 | Unclassified audio or video device.   |
4949| AUDIO_VIDEO_WEARABLE_HEADSET             | 0x0404 | Wearable audio or video headset.  |
4950| AUDIO_VIDEO_HANDSFREE                    | 0x0408 | Hands-free audio or video device.    |
4951| AUDIO_VIDEO_MICROPHONE                   | 0x0410 | Audio or video microphone.   |
4952| AUDIO_VIDEO_LOUDSPEAKER                  | 0x0414 | Audio or video loudspeaker.   |
4953| AUDIO_VIDEO_HEADPHONES                   | 0x0418 | Audio or video headphones.   |
4954| AUDIO_VIDEO_PORTABLE_AUDIO               | 0x041C | Portable audio or video device.   |
4955| AUDIO_VIDEO_CAR_AUDIO                    | 0x0420 | In-vehicle audio or video device.    |
4956| AUDIO_VIDEO_SET_TOP_BOX                  | 0x0424 | Audio or video STB device.   |
4957| AUDIO_VIDEO_HIFI_AUDIO                   | 0x0428 | High-fidelity speaker device.     |
4958| AUDIO_VIDEO_VCR                          | 0x042C | Video cassette recording (VCR) device.   |
4959| AUDIO_VIDEO_VIDEO_CAMERA                 | 0x0430 | Camera.   |
4960| AUDIO_VIDEO_CAMCORDER                    | 0x0434 | Camcorder   |
4961| AUDIO_VIDEO_VIDEO_MONITOR                | 0x0438 | Audio or video monitor.   |
4962| AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER | 0x043C | Video display or loudspeaker. |
4963| AUDIO_VIDEO_VIDEO_CONFERENCING           | 0x0440 | Video conferencing device.    |
4964| AUDIO_VIDEO_VIDEO_GAMING_TOY             | 0x0448 | Audio or video gaming toy.  |
4965| PERIPHERAL_NON_KEYBOARD_NON_POINTING     | 0x0500 | Non-keyboard or non-pointing peripheral device.  |
4966| PERIPHERAL_KEYBOARD                      | 0x0540 | Keyboard device.      |
4967| PERIPHERAL_POINTING_DEVICE               | 0x0580 | Pointing peripheral device.    |
4968| PERIPHERAL_KEYBOARD_POINTING             | 0x05C0 | Keyboard pointing device.    |
4969| PERIPHERAL_UNCATEGORIZED                 | 0x0500 | Unclassified peripheral device.     |
4970| PERIPHERAL_JOYSTICK                      | 0x0504 | Peripheral joystick.     |
4971| PERIPHERAL_GAMEPAD                       | 0x0508 | Peripheral game pad     |
4972| PERIPHERAL_REMOTE_CONTROL                | 0x05C0 | Peripheral remote control device    |
4973| PERIPHERAL_SENSING_DEVICE                | 0x0510 | Peripheral sensing device.    |
4974| PERIPHERAL_DIGITIZER_TABLET              | 0x0514 | Peripheral digitizer tablet.|
4975| PERIPHERAL_CARD_READER                   | 0x0518 | Peripheral card reader.     |
4976| PERIPHERAL_DIGITAL_PEN                   | 0x051C | Peripheral digital pen.     |
4977| PERIPHERAL_SCANNER_RFID                  | 0x0520 | Peripheral RFID scanner. |
4978| PERIPHERAL_GESTURAL_INPUT                | 0x0522 | Gesture input device.    |
4979| IMAGING_UNCATEGORIZED                    | 0x0600 | Unclassified imaging device.    |
4980| IMAGING_DISPLAY                          | 0x0610 | Imaging display device.      |
4981| IMAGING_CAMERA                           | 0x0620 | Imaging camera device.     |
4982| IMAGING_SCANNER                          | 0x0640 | Imaging scanner.     |
4983| IMAGING_PRINTER                          | 0x0680 | Imaging printer.     |
4984| WEARABLE_UNCATEGORIZED                   | 0x0700 | Unclassified wearable device.   |
4985| WEARABLE_WRIST_WATCH                     | 0x0704 | Smart watch.     |
4986| WEARABLE_PAGER                           | 0x0708 | Wearable pager.    |
4987| WEARABLE_JACKET                          | 0x070C | Smart jacket.     |
4988| WEARABLE_HELMET                          | 0x0710 | Wearable helmet.     |
4989| WEARABLE_GLASSES                         | 0x0714 | Wearable glasses.     |
4990| TOY_UNCATEGORIZED                        | 0x0800 | Unclassified toy.    |
4991| TOY_ROBOT                                | 0x0804 | Toy robot.     |
4992| TOY_VEHICLE                              | 0x0808 | Toy vehicle.       |
4993| TOY_DOLL_ACTION_FIGURE                   | 0x080C | Humanoid toy doll.    |
4994| TOY_CONTROLLER                           | 0x0810 | Toy controller.     |
4995| TOY_GAME                                 | 0x0814 | Toy gaming device.      |
4996| HEALTH_UNCATEGORIZED                     | 0x0900 | Unclassified health devices.     |
4997| HEALTH_BLOOD_PRESSURE                    | 0x0904 | Blood pressure device.      |
4998| HEALTH_THERMOMETER                       | 0x0908 | Thermometer     |
4999| HEALTH_WEIGHING                          | 0x090C | Body scale.      |
5000| HEALTH_GLUCOSE                           | 0x0910 | Blood glucose monitor.     |
5001| HEALTH_PULSE_OXIMETER                    | 0x0914 | Pulse oximeter.   |
5002| HEALTH_PULSE_RATE                        | 0x0918 | Heart rate monitor.     |
5003| HEALTH_DATA_DISPLAY                      | 0x091C | Health data display.    |
5004| HEALTH_STEP_COUNTER                      | 0x0920 | Step counter.   |
5005| HEALTH_BODY_COMPOSITION_ANALYZER         | 0x0924 | Body composition analyzer. |
5006| HEALTH_PEAK_FLOW_MONITOR                  | 0x0928 | Hygrometer.     |
5007| HEALTH_MEDICATION_MONITOR                | 0x092C | Medication monitor.   |
5008| HEALTH_KNEE_PROSTHESIS                   | 0x0930 | Prosthetic knee.    |
5009| HEALTH_ANKLE_PROSTHESIS                  | 0x0934 | Prosthetic ankle.    |
5010| HEALTH_GENERIC_HEALTH_MANAGER            | 0x0938 | Generic health management device.    |
5011| HEALTH_PERSONAL_MOBILITY_DEVICE          | 0x093C | Personal mobility device.    |
5012
5013
5014## PlayingState<sup>(deprecated)</sup><a name="PlayingState"></a>
5015
5016Enumerates the A2DP playing states.
5017
5018> **NOTE**<br>
5019> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [a2dp.PlayingState](js-apis-bluetooth-a2dp.md#playingstate).
5020
5021**System capability**: SystemCapability.Communication.Bluetooth.Core
5022
5023| Name               | Value   | Description     |
5024| ----------------- | ------ | ------- |
5025| STATE_NOT_PLAYING | 0x0000 | Not playing. |
5026| STATE_PLAYING     | 0x0001 | Playing.|
5027
5028
5029## ProfileId<sup>(deprecated)</sup><a name="ProfileId"></a>
5030
5031Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST** and **PROFILE_PAN_NETWORK**.
5032
5033> **NOTE**<br>
5034> This API is supported since API version 9 and deprecated since API version 10. You are advised to use [constant.ProfileId](js-apis-bluetooth-constant.md#profileid).
5035
5036**System capability**: SystemCapability.Communication.Bluetooth.Core
5037
5038| Name                              | Value   | Description             |
5039| -------------------------------- | ------ | --------------- |
5040| PROFILE_A2DP_SOURCE              | 1 | A2DP profile.|
5041| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
5042| PROFILE_HID_HOST | 6 | Human Interface Device (HID) profile. |
5043| PROFILE_PAN_NETWORK | 7 | PAN profile. |
5044