1# @ohos.bluetooth (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 7. 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 9. 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 bluetooth from '@ohos.bluetooth';
16```
17
18
19## bluetooth.enableBluetooth<sup>8+</sup><sup>(deprecated)</sup>
20
21enableBluetooth(): boolean
22
23Enables Bluetooth.
24
25> **NOTE**<br>
26> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.enableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerenablebluetoothdeprecated) instead.
27
28**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
29
30**System capability**: SystemCapability.Communication.Bluetooth.Core
31
32**Return value**
33
34| Type     | Description                      |
35| ------- | ------------------------ |
36| boolean | Returns **true** if Bluetooth is enabled; returns **false** otherwise.|
37
38**Example**
39
40```js
41let enable : boolean = bluetooth.enableBluetooth();
42```
43
44
45## bluetooth.disableBluetooth<sup>8+</sup><sup>(deprecated)</sup>
46
47disableBluetooth(): boolean
48
49Disables Bluetooth.
50
51> **NOTE**<br>
52> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.disableBluetooth](js-apis-bluetoothManager.md#bluetoothmanagerdisablebluetoothdeprecated) instead.
53
54**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
55
56**System capability**: SystemCapability.Communication.Bluetooth.Core
57
58**Return value**
59
60| Type     | Description                      |
61| ------- | ------------------------ |
62| boolean | Returns **true** if Bluetooth is disabled; returns **false** otherwise.|
63
64**Example**
65
66```js
67let disable : boolean = bluetooth.disableBluetooth();
68```
69
70
71## bluetooth.getLocalName<sup>8+</sup><sup>(deprecated)</sup>
72
73getLocalName(): string
74
75Obtains the name of the local Bluetooth device.
76
77> **NOTE**<br>
78> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getLocalName](js-apis-bluetoothManager.md#bluetoothmanagergetlocalnamedeprecated) instead.
79
80**Required permissions**: ohos.permission.USE_BLUETOOTH
81
82**System capability**: SystemCapability.Communication.Bluetooth.Core
83
84**Return value**
85
86| Type    | Description       |
87| ------ | --------- |
88| string | Name of the local Bluetooth device obtained.|
89
90**Example**
91
92```js
93let localName : string = bluetooth.getLocalName();
94```
95
96
97## bluetooth.getState<sup>(deprecated)</sup>
98
99getState(): BluetoothState
100
101Obtains the Bluetooth state.
102
103> **NOTE**<br>
104> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.getState](js-apis-bluetoothManager.md#bluetoothmanagergetstatedeprecated) instead.
105
106**Required permissions**: ohos.permission.USE_BLUETOOTH
107
108**System capability**: SystemCapability.Communication.Bluetooth.Core
109
110**Return value**
111
112| Type                               | Description       |
113| --------------------------------- | --------- |
114| [BluetoothState](#bluetoothstatedeprecated) | Bluetooth state obtained.|
115
116**Example**
117
118```js
119let state : bluetooth.BluetoothState = bluetooth.getState();
120```
121
122
123## bluetooth.getBtConnectionState<sup>(deprecated)</sup>
124
125getBtConnectionState(): ProfileConnectionState
126
127Obtains the local profile connection state.
128
129> **NOTE**<br>
130> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.getBtConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetbtconnectionstatedeprecated) instead.
131
132**Required permissions**: ohos.permission.USE_BLUETOOTH
133
134**System capability**: SystemCapability.Communication.Bluetooth.Core
135
136**Return value**
137
138| Type                                      | Description                 |
139| ---------------------------------------- | ------------------- |
140| [ProfileConnectionState](#profileconnectionstatedeprecated) | Profile connection state obtained.|
141
142**Example**
143
144```js
145let connectionState : bluetooth.ProfileConnectionState = bluetooth.getBtConnectionState();
146```
147
148
149## bluetooth.setLocalName<sup>8+</sup><sup>(deprecated)</sup>
150
151setLocalName(name: string): boolean
152
153Sets the name of the local Bluetooth device.
154
155> **NOTE**<br>
156> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.setLocalName](js-apis-bluetoothManager.md#bluetoothmanagersetlocalnamedeprecated) instead.
157
158**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
159
160**System capability**: SystemCapability.Communication.Bluetooth.Core
161
162**Parameters**
163
164| Name | Type    | Mandatory  | Description                   |
165| ---- | ------ | ---- | --------------------- |
166| name | string | Yes   | Bluetooth device name to set. It cannot exceed 248 bytes.|
167
168**Return value**
169
170| Type     | Description                            |
171| ------- | ------------------------------ |
172| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
173
174**Example**
175
176```js
177let ret : boolean = bluetooth.setLocalName('device_name');
178```
179
180
181## bluetooth.pairDevice<sup>(deprecated)</sup>
182
183pairDevice(deviceId: string): boolean
184
185Initiates Bluetooth pairing.
186
187> **NOTE**<br>
188> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.pairDevice](js-apis-bluetoothManager.md#bluetoothmanagerpairdevicedeprecated) instead.
189
190**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
191
192**System capability**: SystemCapability.Communication.Bluetooth.Core
193
194**Parameters**
195
196| Name     | Type    | Mandatory  | Description                                 |
197| -------- | ------ | ---- | ----------------------------------- |
198| deviceId | string | Yes   | Address of the remote device to pair, for example, XX:XX:XX:XX:XX:XX.|
199
200**Return value**
201
202| Type     | Description                        |
203| ------- | -------------------------- |
204| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
205
206**Example**
207
208```js
209// The address can be scanned.
210let result : boolean = bluetooth.pairDevice("XX:XX:XX:XX:XX:XX");
211```
212
213
214## bluetooth.getProfileConnState<sup>8+</sup><sup>(deprecated)</sup>
215
216getProfileConnState(profileId: ProfileId): ProfileConnectionState
217
218Obtains the connection status of the specified profile.
219
220> **NOTE**<br>
221> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getProfileConnectionState](js-apis-bluetoothManager.md#bluetoothmanagergetprofileconnectionstatedeprecated) instead.
222
223**Required permissions**: ohos.permission.USE_BLUETOOTH
224
225**System capability**: SystemCapability.Communication.Bluetooth.Core
226
227**Parameters**
228
229| Name      | Type       | Mandatory  | Description                                   |
230| --------- | --------- | ---- | ------------------------------------- |
231| profileId | ProfileId | Yes   | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
232
233**Return value**
234
235| Type                                             | Description               |
236| ------------------------------------------------- | ------------------- |
237| [ProfileConnectionState](#profileconnectionstatedeprecated) | Profile connection state obtained.|
238
239**Example**
240
241```js
242let result : bluetooth.ProfileConnectionState = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
243```
244
245
246## bluetooth.getRemoteDeviceName<sup>8+</sup><sup>(deprecated)</sup>
247
248getRemoteDeviceName(deviceId: string): string
249
250Obtains the name of the remote Bluetooth device.
251
252> **NOTE**<br>
253> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getRemoteDeviceName](js-apis-bluetoothManager.md#bluetoothmanagergetremotedevicenamedeprecated) instead.
254
255**Required permissions**: ohos.permission.USE_BLUETOOTH
256
257**System capability**: SystemCapability.Communication.Bluetooth.Core
258
259**Parameters**
260
261| Name     | Type    | Mandatory  | Description                               |
262| -------- | ------ | ---- | --------------------------------- |
263| deviceId | string | Yes   | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
264
265**Return value**
266
267| Type    | Description           |
268| ------ | ------------- |
269| string | Device name (a string) obtained.|
270
271**Example**
272
273```js
274let remoteDeviceName : string = bluetooth.getRemoteDeviceName("XX:XX:XX:XX:XX:XX");
275```
276
277
278## bluetooth.getRemoteDeviceClass<sup>8+</sup><sup>(deprecated)</sup>
279
280getRemoteDeviceClass(deviceId: string): DeviceClass
281
282Obtains the class of the remote Bluetooth device.
283
284> **NOTE**<br>
285> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getRemoteDeviceClass](js-apis-bluetoothManager.md#bluetoothmanagergetremotedeviceclassdeprecated) instead.
286
287**Required permissions**: ohos.permission.USE_BLUETOOTH
288
289**System capability**: SystemCapability.Communication.Bluetooth.Core
290
291**Parameters**
292
293| Name     | Type    | Mandatory  | Description                               |
294| -------- | ------ | ---- | --------------------------------- |
295| deviceId | string | Yes   | Address of the target remote device, for example, XX:XX:XX:XX:XX:XX.|
296
297**Return value**
298
299| Type                         | Description      |
300| --------------------------- | -------- |
301| [DeviceClass](#deviceclassdeprecated) | Class of the remote device obtained.|
302
303**Example**
304
305```js
306let remoteDeviceClass : bluetooth.DeviceClass = bluetooth.getRemoteDeviceClass("XX:XX:XX:XX:XX:XX");
307```
308
309
310## bluetooth.getPairedDevices<sup>8+</sup><sup>(deprecated)</sup>
311
312getPairedDevices(): Array&lt;string&gt;
313
314Obtains the paired devices.
315
316> **NOTE**<br>
317> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getPairedDevices](js-apis-bluetoothManager.md#bluetoothmanagergetpaireddevicesdeprecated) instead.
318
319**Required permissions**: ohos.permission.USE_BLUETOOTH
320
321**System capability**: SystemCapability.Communication.Bluetooth.Core
322
323**Return value**
324
325| Type                 | Description           |
326| ------------------- | ------------- |
327| Array&lt;string&gt; | Addresses of the paired Bluetooth devices.|
328
329**Example**
330
331```js
332let devices : Array<string> = bluetooth.getPairedDevices();
333```
334
335
336## bluetooth.setBluetoothScanMode<sup>(deprecated)</sup>
337
338setBluetoothScanMode(mode: ScanMode, duration: number): boolean
339
340Sets the Bluetooth scan mode so that the device can be discovered by a remote device.
341
342> **NOTE**<br>
343> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.setBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagersetbluetoothscanmodedeprecated) instead.
344
345**Required permissions**: ohos.permission.USE_BLUETOOTH
346
347**System capability**: SystemCapability.Communication.Bluetooth.Core
348
349**Parameters**
350
351| Name     | Type                   | Mandatory  | Description                          |
352| -------- | --------------------- | ---- | ---------------------------- |
353| mode     | [ScanMode](#scanmodedeprecated) | Yes   | Bluetooth scan mode to set.                     |
354| duration | number                | Yes   | Duration (in ms) in which the device can be discovered. The value **0** indicates unlimited time.|
355
356**Return value**
357
358| Type     | Description                        |
359| ------- | -------------------------- |
360| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
361
362**Example**
363
364```js
365// The device can be discovered and connected only when the discoverable and connectable mode is used.
366let result : boolean = bluetooth.setBluetoothScanMode(bluetooth.ScanMode
367    .SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE, 100);
368```
369
370
371## bluetooth.getBluetoothScanMode<sup>8+</sup><sup>(deprecated)</sup>
372
373getBluetoothScanMode(): ScanMode
374
375Obtains the Bluetooth scan mode.
376
377> **NOTE**<br>
378> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getBluetoothScanMode](js-apis-bluetoothManager.md#bluetoothmanagergetbluetoothscanmodedeprecated) instead.
379
380**Required permissions**: ohos.permission.USE_BLUETOOTH
381
382**System capability**: SystemCapability.Communication.Bluetooth.Core
383
384**Return value**
385
386| Type                   | Description     |
387| --------------------- | ------- |
388| [ScanMode](#scanmodedeprecated) | Bluetooth scan mode to set.|
389
390**Example**
391
392```js
393let scanMode : bluetooth.ScanMode = bluetooth.getBluetoothScanMode();
394```
395
396
397## bluetooth.startBluetoothDiscovery<sup>8+</sup><sup>(deprecated)</sup>
398
399startBluetoothDiscovery(): boolean
400
401Starts Bluetooth scan to discover remote devices.
402
403> **NOTE**<br>
404> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.startBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstartbluetoothdiscoverydeprecated) instead.
405
406**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH and ohos.permission.LOCATION
407
408**System capability**: SystemCapability.Communication.Bluetooth.Core
409
410**Return value**
411
412| Type     | Description                        |
413| ------- | -------------------------- |
414| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
415
416**Example**
417
418```js
419let deviceId : Array<string>;
420function onReceiveEvent(data : Array<string>) {
421    deviceId = data;
422}
423bluetooth.on('bluetoothDeviceFind', onReceiveEvent);
424let result : boolean = bluetooth.startBluetoothDiscovery();
425```
426
427
428## bluetooth.stopBluetoothDiscovery<sup>8+</sup><sup>(deprecated)</sup>
429
430stopBluetoothDiscovery(): boolean
431
432Stops Bluetooth scan.
433
434> **NOTE**<br>
435> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.stopBluetoothDiscovery](js-apis-bluetoothManager.md#bluetoothmanagerstopbluetoothdiscoverydeprecated) instead.
436
437**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
438
439**System capability**: SystemCapability.Communication.Bluetooth.Core
440
441**Return value**
442
443| Type     | Description                        |
444| ------- | -------------------------- |
445| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
446
447**Example**
448
449```js
450let result : boolean = bluetooth.stopBluetoothDiscovery();
451```
452
453
454## bluetooth.setDevicePairingConfirmation<sup>8+</sup><sup>(deprecated)</sup>
455
456setDevicePairingConfirmation(device: string, accept: boolean): boolean
457
458Sets the device pairing confirmation.
459
460> **NOTE**<br>
461> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.setDevicePairingConfirmation](js-apis-bluetoothManager.md#bluetoothmanagersetdevicepairingconfirmationdeprecated) instead.
462
463**Required permissions**: ohos.permission.MANAGE_BLUETOOTH (available only for system applications)
464
465**System capability**: SystemCapability.Communication.Bluetooth.Core
466
467**Parameters**
468
469| Name   | Type     | Mandatory  | Description                              |
470| ------ | ------- | ---- | -------------------------------- |
471| device | string  | Yes   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
472| 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.       |
473
474**Return value**
475
476| Type     | Description                          |
477| ------- | ---------------------------- |
478| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
479
480**Example**
481
482```js
483// Subscribe to the pinRequired event and configure the pairing confirmation after receiving a pairing request from the remote device.
484function onReceivePinRequiredEvent(data : bluetooth.PinRequiredParam) { // data is the input parameter for the pairing request.
485    console.info('pin required  = '+ JSON.stringify(data));
486    bluetooth.setDevicePairingConfirmation(data.deviceId, true);
487}
488bluetooth.on("pinRequired", onReceivePinRequiredEvent);
489```
490
491
492## bluetooth.on('bluetoothDeviceFind')<sup>8+</sup><sup>(deprecated)</sup>
493
494on(type: 'bluetoothDeviceFind', callback: Callback&lt;Array&lt;string&gt;&gt;): void
495
496Subscribes to the Bluetooth device discovery events.
497
498> **NOTE**<br>
499> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.on('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageronbluetoothdevicefinddeprecated) instead.
500
501**Required permissions**: ohos.permission.USE_BLUETOOTH
502
503**System capability**: SystemCapability.Communication.Bluetooth.Core
504
505**Parameters**
506
507| Name     | Type                                 | Mandatory  | Description                                    |
508| -------- | ----------------------------------- | ---- | -------------------------------------- |
509| type     | string                              | Yes   | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.|
510| callback | Callback&lt;Array&lt;string&gt;&gt; | Yes   | Callback used to return the discovered devices. You need to implement this callback.   |
511
512**Return value**
513
514No value is returned.
515
516**Example**
517
518```js
519function onReceiveEvent(data : Array<string>) { // data is an array of Bluetooth device addresses.
520    console.info('bluetooth device find = '+ JSON.stringify(data));
521}
522bluetooth.on('bluetoothDeviceFind', onReceiveEvent);
523```
524
525
526## bluetooth.off('bluetoothDeviceFind')<sup>8+</sup><sup>(deprecated)</sup>
527
528off(type: 'bluetoothDeviceFind', callback?: Callback&lt;Array&lt;string&gt;&gt;): void
529
530Unsubscribes from the Bluetooth device discovery events.
531
532> **NOTE**<br>
533> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.off('bluetoothDeviceFind')](js-apis-bluetoothManager.md#bluetoothmanageroffbluetoothdevicefinddeprecated) instead.
534
535**Required permissions**: ohos.permission.USE_BLUETOOTH
536
537**System capability**: SystemCapability.Communication.Bluetooth.Core
538
539**Parameters**
540
541| Name     | Type                                 | Mandatory  | Description                                      |
542| -------- | ----------------------------------- | ---- | ---------------------------------------- |
543| type     | string                              | Yes   | Event type. The value **bluetoothDeviceFind** indicates an event reported when a Bluetooth device is discovered.  |
544| callback | Callback&lt;Array&lt;string&gt;&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
545
546**Return value**
547
548No value is returned.
549
550**Example**
551
552```js
553function onReceiveEvent(data : Array<string>) {
554    console.info('bluetooth device find = '+ JSON.stringify(data));
555}
556bluetooth.on('bluetoothDeviceFind', onReceiveEvent);
557bluetooth.off('bluetoothDeviceFind', onReceiveEvent);
558```
559
560
561## bluetooth.on('pinRequired')<sup>8+</sup><sup>(deprecated)</sup>
562
563on(type: 'pinRequired', callback: Callback&lt;PinRequiredParam&gt;): void
564
565Subscribes to the pairing request events of the remote Bluetooth device.
566
567> **NOTE**<br>
568> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.on('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageronpinrequireddeprecated) instead.
569
570**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
571
572**System capability**: SystemCapability.Communication.Bluetooth.Core
573
574**Parameters**
575
576| Name     | Type                                      | Mandatory  | Description                              |
577| -------- | ---------------------------------------- | ---- | -------------------------------- |
578| type     | string                                   | Yes   | Event type. The value **pinRequired** indicates a pairing request event.    |
579| callback | Callback&lt;[PinRequiredParam](#pinrequiredparamdeprecated)&gt; | Yes   | Callback used to return the pairing request. You need to implement this callback.|
580
581**Return value**
582
583No value is returned.
584
585**Example**
586
587```js
588function onReceiveEvent(data : bluetooth.PinRequiredParam) { // data is the pairing request parameter.
589    console.info('pin required = '+ JSON.stringify(data));
590}
591bluetooth.on('pinRequired', onReceiveEvent);
592```
593
594
595## bluetooth.off('pinRequired')<sup>8+</sup><sup>(deprecated)</sup>
596
597off(type: 'pinRequired', callback?: Callback&lt;PinRequiredParam&gt;): void
598
599Unsubscribes from the pairing request events of the remote Bluetooth device.
600
601> **NOTE**<br>
602> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.off('pinRequired')](js-apis-bluetoothManager.md#bluetoothmanageroffpinrequireddeprecated) instead.
603
604**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
605
606**System capability**: SystemCapability.Communication.Bluetooth.Core
607
608**Parameters**
609
610| Name     | Type                                      | Mandatory  | Description                                      |
611| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
612| type     | string                                   | Yes   | Event type. The value **pinRequired** indicates a pairing request event.            |
613| callback | Callback&lt;[PinRequiredParam](#pinrequiredparamdeprecated)&gt; | No   | Callback to unregister. The input parameter is the pairing request parameter. If this parameter is not set, this API unregisters all callbacks for **type**.|
614
615**Return value**
616
617No value is returned.
618
619**Example**
620
621```js
622function onReceiveEvent(data : bluetooth.PinRequiredParam) {
623    console.info('pin required = '+ JSON.stringify(data));
624}
625bluetooth.on('pinRequired', onReceiveEvent);
626bluetooth.off('pinRequired', onReceiveEvent);
627```
628
629
630## bluetooth.on('bondStateChange')<sup>(deprecated)</sup>
631
632on(type: 'bondStateChange', callback: Callback&lt;BondStateParam&gt;): void
633
634Subscribes to the Bluetooth pairing state changes.
635
636> **NOTE**<br>
637> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.on('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageronbondstatechangedeprecated) instead.
638
639**Required permissions**: ohos.permission.USE_BLUETOOTH
640
641**System capability**: SystemCapability.Communication.Bluetooth.Core
642
643**Parameters**
644
645| Name     | Type                                      | Mandatory  | Description                                  |
646| -------- | ---------------------------------------- | ---- | ------------------------------------ |
647| type     | string                                   | Yes   | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.|
648| callback | Callback&lt;[BondStateParam](#bondstateparamdeprecated)&gt; | Yes   | Callback used to return the pairing state. You need to implement this callback.   |
649
650**Return value**
651
652No value is returned.
653
654**Example**
655
656```js
657function onReceiveEvent(data : bluetooth.BondStateParam) { // data, as the input parameter of the callback, indicates the pairing state.
658    console.info('pair state = '+ JSON.stringify(data));
659}
660bluetooth.on('bondStateChange', onReceiveEvent);
661```
662
663
664## bluetooth.off('bondStateChange')<sup>8+</sup><sup>(deprecated)</sup>
665
666off(type: 'bondStateChange', callback?: Callback&lt;BondStateParam&gt;): void
667
668Unsubscribes from the Bluetooth pairing state changes.
669
670> **NOTE**<br>
671> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.off('bondStateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffbondstatechangedeprecated) instead.
672
673**Required permissions**: ohos.permission.USE_BLUETOOTH
674
675**System capability**: SystemCapability.Communication.Bluetooth.Core
676
677**Parameters**
678
679| Name     | Type                                      | Mandatory  | Description                                      |
680| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
681| type     | string                                   | Yes   | Event type. The value **bondStateChange** indicates a Bluetooth pairing state change event.    |
682| callback | Callback&lt;[BondStateParam](#bondstateparamdeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
683
684**Return value**
685
686No value is returned.
687
688**Example**
689
690```js
691function onReceiveEvent(data : bluetooth.BondStateParam) {
692    console.info('bond state = '+ JSON.stringify(data));
693}
694bluetooth.on('bondStateChange', onReceiveEvent);
695bluetooth.off('bondStateChange', onReceiveEvent);
696```
697
698
699## bluetooth.on('stateChange')<sup>8+</sup><sup>(deprecated)</sup>
700
701on(type: 'stateChange', callback: Callback&lt;BluetoothState&gt;): void
702
703Subscribes to the Bluetooth connection state changes.
704
705> **NOTE**<br>
706> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.on('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageronstatechangedeprecated) instead.
707
708**Required permissions**: ohos.permission.USE_BLUETOOTH
709
710**System capability**: SystemCapability.Communication.Bluetooth.Core
711
712**Parameters**
713
714| Name     | Type                                      | Mandatory  | Description                              |
715| -------- | ---------------------------------------- | ---- | -------------------------------- |
716| type     | string                                   | Yes   | Event type. The value **stateChange** indicates a Bluetooth connection state change event.  |
717| callback | Callback&lt;[BluetoothState](#bluetoothstatedeprecated)&gt; | Yes   | Callback used to return the Bluetooth connection state. You need to implement this callback.|
718
719**Return value**
720
721No value is returned.
722
723**Example**
724
725```js
726function onReceiveEvent(data : bluetooth.BluetoothState) {
727    console.info('bluetooth state = '+ JSON.stringify(data));
728}
729bluetooth.on('stateChange', onReceiveEvent);
730```
731
732
733## bluetooth.off('stateChange')<sup>8+</sup><sup>(deprecated)</sup>
734
735off(type: 'stateChange', callback?: Callback&lt;BluetoothState&gt;): void
736
737Unsubscribes from the Bluetooth connection state changes.
738
739> **NOTE**<br>
740> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.off('stateChange')](js-apis-bluetoothManager.md#bluetoothmanageroffstatechangedeprecated) instead.
741
742**Required permissions**: ohos.permission.USE_BLUETOOTH
743
744**System capability**: SystemCapability.Communication.Bluetooth.Core
745
746**Parameters**
747
748| Name     | Type                                      | Mandatory  | Description                                      |
749| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
750| type     | string                                   | Yes   | Event type. The value **stateChange** indicates a Bluetooth connection state change event.          |
751| callback | Callback&lt;[BluetoothState](#bluetoothstatedeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
752
753**Return value**
754
755No value is returned.
756
757**Example**
758
759```js
760function onReceiveEvent(data : bluetooth.BluetoothState) {
761    console.info('bluetooth state = '+ JSON.stringify(data));
762}
763bluetooth.on('stateChange', onReceiveEvent);
764bluetooth.off('stateChange', onReceiveEvent);
765```
766
767
768## bluetooth.sppListen<sup>8+</sup><sup>(deprecated)</sup>
769
770sppListen(name: string, option: SppOption, callback: AsyncCallback&lt;number&gt;): void
771
772Creates a server listening socket.
773
774> **NOTE**<br>
775> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.sppListen](js-apis-bluetoothManager.md#bluetoothmanagerspplistendeprecated) instead.
776
777**Required permissions**: ohos.permission.USE_BLUETOOTH
778
779**System capability**: SystemCapability.Communication.Bluetooth.Core
780
781**Parameters**
782
783| Name     | Type                         | Mandatory  | Description                     |
784| -------- | --------------------------- | ---- | ----------------------- |
785| name     | string                      | Yes   | Name of the service.                 |
786| option   | [SppOption](#sppoptiondeprecated)     | Yes   | Serial port profile (SPP) listening configuration.             |
787| callback | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the server socket ID.|
788
789**Example**
790
791```js
792import { BusinessError } from '@ohos.base';
793let serverNumber = -1;
794function serverSocket(code : BusinessError, number : number) {
795  console.log('bluetooth error code: ' + code.code);
796  if (code.code == 0) {
797    console.log('bluetooth serverSocket Number: ' + number);
798    serverNumber = number;
799  }
800}
801
802let sppOption : bluetooth.SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
803bluetooth.sppListen('server1', sppOption, serverSocket);
804```
805
806
807## bluetooth.sppAccept<sup>8+</sup><sup>(deprecated)</sup>
808
809sppAccept(serverSocket: number, callback: AsyncCallback&lt;number&gt;): void
810
811Listens for a connection to be made to this socket from the client and accepts it.
812
813> **NOTE**<br>
814> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.sppAccept](js-apis-bluetoothManager.md#bluetoothmanagersppacceptdeprecated) instead.
815
816**System capability**: SystemCapability.Communication.Bluetooth.Core
817
818**Parameters**
819
820| Name         | Type                         | Mandatory  | Description                     |
821| ------------ | --------------------------- | ---- | ----------------------- |
822| serverSocket | number                      | Yes   | Server socket ID.          |
823| callback     | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the client socket ID.|
824
825**Example**
826
827```js
828import { BusinessError } from '@ohos.base';
829let serverNumber = -1;
830function serverSocket(code : BusinessError, number : number) {
831  console.log('bluetooth error code: ' + code.code);
832  if (code.code == 0) {
833    console.log('bluetooth serverSocket Number: ' + number);
834    serverNumber = number;
835  }
836}
837let clientNumber = -1;
838function acceptClientSocket(code : BusinessError, number : number) {
839  console.log('bluetooth error code: ' + code.code);
840  if (code.code == 0) {
841    console.log('bluetooth clientSocket Number: ' + number);
842    // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the server.
843    clientNumber = number;
844  }
845}
846bluetooth.sppAccept(serverNumber, acceptClientSocket);
847```
848
849
850## bluetooth.sppConnect<sup>(deprecated)</sup>
851
852sppConnect(device: string, option: SppOption, callback: AsyncCallback&lt;number&gt;): void
853
854Initiates an SPP connection to a remote device from the client.
855
856> **NOTE**<br>
857> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.sppConnect](js-apis-bluetoothManager.md#bluetoothmanagersppconnectdeprecated) instead.
858
859**Required permissions**: ohos.permission.USE_BLUETOOTH
860
861**System capability**: SystemCapability.Communication.Bluetooth.Core
862
863**Parameters**
864
865| Name     | Type                         | Mandatory  | Description                            |
866| -------- | --------------------------- | ---- | ------------------------------ |
867| device   | string                      | Yes   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
868| option   | [SppOption](#sppoptiondeprecated)     | Yes   | Configuration for connecting to the SPP client.                 |
869| callback | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the client socket ID.       |
870
871**Example**
872
873```js
874import { BusinessError } from '@ohos.base';
875let clientNumber = -1;
876function clientSocket(code : BusinessError, number : number) {
877  if (code.code != 0 || code == null) {
878    return;
879  }
880  console.log('bluetooth serverSocket Number: ' + number);
881  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
882  clientNumber = number;
883}
884let sppOption : bluetooth.SppOption = {uuid: '00001810-0000-1000-8000-00805F9B34FB', secure: false, type: 0};
885bluetooth.sppConnect('XX:XX:XX:XX:XX:XX', sppOption, clientSocket);
886```
887
888
889## bluetooth.sppCloseServerSocket<sup>8+</sup><sup>(deprecated)</sup>
890
891sppCloseServerSocket(socket: number): void
892
893Closes the listening socket of the server.
894
895> **NOTE**<br>
896> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.sppCloseServerSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseserversocketdeprecated) instead.
897
898**System capability**: SystemCapability.Communication.Bluetooth.Core
899
900**Parameters**
901
902| Name   | Type    | Mandatory  | Description             |
903| ------ | ------ | ---- | --------------- |
904| socket | number | Yes   | ID of the listening socket on the server. The ID is obtained by **sppListen**.|
905
906**Example**
907
908```js
909import { BusinessError } from '@ohos.base';
910let serverNumber = -1;
911function serverSocket(code : BusinessError, number : number) {
912  console.log('bluetooth error code: ' + code.code);
913  if (code.code == 0) {
914    console.log('bluetooth serverSocket Number: ' + number);
915    serverNumber = number;
916  }
917}
918bluetooth.sppCloseServerSocket(serverNumber);
919```
920
921
922## bluetooth.sppCloseClientSocket<sup>8+</sup><sup>(deprecated)</sup>
923
924sppCloseClientSocket(socket: number): void
925
926Closes the client socket.
927
928> **NOTE**<br>
929> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.sppCloseClientSocket](js-apis-bluetoothManager.md#bluetoothmanagersppcloseclientsocketdeprecated) instead.
930
931**System capability**: SystemCapability.Communication.Bluetooth.Core
932
933**Parameters**
934
935| Name   | Type    | Mandatory  | Description     |
936| ------ | ------ | ---- | ------------- |
937| socket | number | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
938
939**Example**
940
941```js
942import { BusinessError } from '@ohos.base';
943let clientNumber = -1;
944function clientSocket(code : BusinessError, number : number) {
945  if (code.code != 0 || code == null) {
946    return;
947  }
948  console.log('bluetooth serverSocket Number: ' + number);
949  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
950  clientNumber = number;
951}
952bluetooth.sppCloseClientSocket(clientNumber);
953```
954
955
956## bluetooth.sppWrite<sup>8+</sup><sup>(deprecated)</sup>
957
958sppWrite(clientSocket: number, data: ArrayBuffer): boolean
959
960Writes data to the remote device through the socket.
961
962> **NOTE**<br>
963> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.sppWrite](js-apis-bluetoothManager.md#bluetoothmanagersppwritedeprecated) instead.
964
965**System capability**: SystemCapability.Communication.Bluetooth.Core
966
967**Parameters**
968
969| Name         | Type         | Mandatory  | Description           |
970| ------------ | ----------- | ---- | ------------- |
971| clientSocket | number      | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.|
972| data         | ArrayBuffer | Yes   | Data to write.       |
973
974**Return value**
975
976| Type     | Description                       |
977| ------- | ------------------------- |
978| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
979
980**Example**
981
982```js
983import { BusinessError } from '@ohos.base';
984let clientNumber = -1;
985function clientSocket(code : BusinessError, number : number) {
986  if (code.code != 0 || code == null) {
987    return;
988  }
989  console.log('bluetooth serverSocket Number: ' + number);
990  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
991  clientNumber = number;
992}
993let arrayBuffer = new ArrayBuffer(8);
994let data = new Uint8Array(arrayBuffer);
995data[0] = 123;
996let ret : boolean = bluetooth.sppWrite(clientNumber, arrayBuffer);
997if (ret) {
998  console.log('spp write successfully');
999} else {
1000  console.log('spp write failed');
1001}
1002```
1003
1004
1005## bluetooth.on('sppRead')<sup>8+</sup><sup>(deprecated)</sup>
1006
1007on(type: 'sppRead', clientSocket: number, callback: Callback&lt;ArrayBuffer&gt;): void
1008
1009> **NOTE**<br>
1010> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.on('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageronsppreaddeprecated) instead.
1011
1012Subscribes to the SPP read request events.
1013
1014**System capability**: SystemCapability.Communication.Bluetooth.Core
1015
1016**Parameters**
1017
1018| Name         | Type                         | Mandatory  | Description                        |
1019| ------------ | --------------------------- | ---- | -------------------------- |
1020| type         | string                      | Yes   | Event type. The value **sppRead** indicates an SPP read request event.|
1021| clientSocket | number                      | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.             |
1022| callback     | Callback&lt;ArrayBuffer&gt; | Yes   | Callback used to return the data read.         |
1023
1024**Return value**
1025
1026No value is returned.
1027
1028**Example**
1029
1030```js
1031import { BusinessError } from '@ohos.base';
1032let clientNumber = -1;
1033function clientSocket(code : BusinessError, number : number) {
1034  if (code.code != 0 || code == null) {
1035    return;
1036  }
1037  console.log('bluetooth serverSocket Number: ' + number);
1038  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1039  clientNumber = number;
1040}
1041function dataRead(dataBuffer : ArrayBuffer) {
1042  let data = new Uint8Array(dataBuffer);
1043  console.log('bluetooth data is: ' + data[0]);
1044}
1045bluetooth.on('sppRead', clientNumber, dataRead);
1046```
1047
1048
1049## bluetooth.off('sppRead')<sup>8+</sup><sup>(deprecated)</sup>
1050
1051off(type: 'sppRead', clientSocket: number, callback?: Callback&lt;ArrayBuffer&gt;): void
1052
1053Unsubscribes from the SPP read request events.
1054
1055> **NOTE**<br>
1056> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.off('sppRead')](js-apis-bluetoothManager.md#bluetoothmanageroffsppreaddeprecated) instead.
1057
1058**System capability**: SystemCapability.Communication.Bluetooth.Core
1059
1060**Parameters**
1061
1062| Name         | Type                         | Mandatory  | Description                                      |
1063| ------------ | --------------------------- | ---- | ---------------------------------------- |
1064| type         | string                      | Yes   | Event type. The value **sppRead** indicates an SPP read request event.              |
1065| clientSocket | number                      | Yes   | Client socket ID, which is obtained by **sppAccept** or **sppConnect**.                           |
1066| callback     | Callback&lt;ArrayBuffer&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
1067
1068**Return value**
1069
1070No value is returned.
1071
1072**Example**
1073
1074```js
1075import { BusinessError } from '@ohos.base';
1076let clientNumber = -1;
1077function clientSocket(code : BusinessError, number : number) {
1078  if (code.code != 0 || code == null) {
1079    return;
1080  }
1081  console.log('bluetooth serverSocket Number: ' + number);
1082  // The obtained clientNumber is used as the socket ID for subsequent read/write operations on the client.
1083  clientNumber = number;
1084}
1085bluetooth.off('sppRead', clientNumber);
1086```
1087
1088
1089## bluetooth.getProfile<sup>8+</sup><sup>(deprecated)</sup>
1090
1091getProfile(profileId: ProfileId): A2dpSourceProfile | HandsFreeAudioGatewayProfile
1092
1093Obtains a profile object.
1094
1095> **NOTE**<br>
1096> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.getProfileInstance](js-apis-bluetoothManager.md#bluetoothmanagergetprofileinstancedeprecated) instead.
1097
1098**System capability**: SystemCapability.Communication.Bluetooth.Core
1099
1100**Parameters**
1101
1102| Name      | Type       | Mandatory  | Description                                   |
1103| --------- | --------- | ---- | ------------------------------------- |
1104| profileId | [ProfileId](#profileiddeprecated) | Yes   | ID of the profile to obtain, for example, **PROFILE_A2DP_SOURCE**.|
1105
1106**Return value**
1107
1108| Type                                                        | Description                                                        |
1109| ------------------------------------------------------------ | ------------------------------------------------------------ |
1110| [A2dpSourceProfile](#a2dpsourceprofile) or [HandsFreeAudioGatewayProfile](#handsfreeaudiogatewayprofile)| Profile object obtained. Only **A2dpSourceProfile** and **HandsFreeAudioGatewayProfile** are supported.|
1111
1112**Example**
1113
1114```js
1115let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1116```
1117
1118
1119## BLE
1120
1121### createGattServer<sup>(deprecated)</sup>
1122
1123createGattServer(): GattServer
1124
1125Creates a **GattServer** instance.
1126
1127> **NOTE**<br>
1128> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.createGattServer](js-apis-bluetoothManager.md#creategattserverdeprecated) instead.
1129
1130**System capability**: SystemCapability.Communication.Bluetooth.Core
1131
1132**Return value**
1133
1134| Type                       | Description                                  |
1135| ------------------------- | ------------------------------------ |
1136| [GattServer](#gattserver) | **GattServer** instance created. Before using a method of the server, you must create a **GattSever** instance.|
1137
1138**Example**
1139
1140```js
1141let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1142```
1143
1144
1145### createGattClientDevice<sup>(deprecated)</sup>
1146
1147createGattClientDevice(deviceId: string): GattClientDevice
1148
1149Creates a **GattClientDevice** instance.
1150
1151> **NOTE**<br>
1152> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.createGattClientDevice](js-apis-bluetoothManager.md#creategattclientdevicedeprecated) instead.
1153
1154**System capability**: SystemCapability.Communication.Bluetooth.Core
1155
1156**Parameters**
1157
1158| Name     | Type    | Mandatory  | Description                                  |
1159| -------- | ------ | ---- | ------------------------------------ |
1160| deviceId | string | Yes   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
1161
1162**Return value**
1163
1164| Type                                   | Description                                  |
1165| ------------------------------------- | ------------------------------------ |
1166| [GattClientDevice](#gattclientdevice) | **GattClientDevice** instance created. Before using a method of the client, you must create a **GattClientDevice** instance.|
1167
1168**Example**
1169
1170```js
1171let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
1172```
1173
1174
1175### getConnectedBLEDevices<sup>(deprecated)</sup>
1176
1177getConnectedBLEDevices(): Array&lt;string&gt;
1178
1179Obtains the BLE devices connected to this device.
1180
1181> **NOTE**<br>
1182> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.getConnectedBLEDevices](js-apis-bluetoothManager.md#getconnectedbledevicesdeprecated) instead.
1183
1184**Required permissions**: ohos.permission.USE_BLUETOOTH
1185
1186**System capability**: SystemCapability.Communication.Bluetooth.Core
1187
1188**Return value**
1189
1190| Type                 | Description                 |
1191| ------------------- | ------------------- |
1192| Array&lt;string&gt; | Addresses of the BLE devices connected to this device.|
1193
1194**Example**
1195
1196```js
1197let result : Array<string> = bluetooth.BLE.getConnectedBLEDevices();
1198```
1199
1200
1201### startBLEScan<sup>(deprecated)</sup>
1202
1203startBLEScan(filters: Array&lt;ScanFilter&gt;, options?: ScanOptions): void
1204
1205Starts a BLE scan.
1206
1207> **NOTE**<br>
1208> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.startBLEScan](js-apis-bluetoothManager.md#startblescandeprecated) instead.
1209
1210**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH, ohos.permission.MANAGE_BLUETOOTH (available only for system applications), and ohos.permission.LOCATION
1211
1212**System capability**: SystemCapability.Communication.Bluetooth.Core
1213
1214**Parameters**
1215
1216| Name    | Type                                    | Mandatory  | Description                                 |
1217| ------- | -------------------------------------- | ---- | ----------------------------------- |
1218| filters | Array&lt;[ScanFilter](#scanfilterdeprecated)&gt; | Yes   | Criteria for filtering the scan result. Set this parameter to **null** if you do not want to filter the scan result.|
1219| options | [ScanOptions](#scanoptionsdeprecated)            | No   | Scan options.                    |
1220
1221**Return value**
1222
1223No value is returned.
1224
1225**Example**
1226
1227```js
1228function onReceiveEvent(data : Array<bluetooth.ScanResult>) {
1229    console.info('BLE scan device find result = '+ JSON.stringify(data));
1230}
1231bluetooth.BLE.on("BLEDeviceFind", onReceiveEvent);
1232let scanOptions : bluetooth.ScanOptions = {
1233    interval: 500,
1234    dutyMode: bluetooth.ScanDuty.SCAN_MODE_LOW_POWER,
1235    matchMode: bluetooth.MatchMode.MATCH_MODE_AGGRESSIVE,
1236}
1237
1238let scanFilter : bluetooth.ScanFilter = {
1239    deviceId:"XX:XX:XX:XX:XX:XX",
1240    name:"test",
1241    serviceUuid:"00001888-0000-1000-8000-00805f9b34fb"
1242}
1243bluetooth.BLE.startBLEScan(
1244    [scanFilter], scanOptions
1245);
1246```
1247
1248
1249### stopBLEScan<sup>(deprecated)</sup>
1250
1251stopBLEScan(): void
1252
1253Stops the BLE scan.
1254
1255> **NOTE**<br>
1256> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.stopBLEScan](js-apis-bluetoothManager.md#stopblescandeprecated) instead.
1257
1258**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1259
1260**System capability**: SystemCapability.Communication.Bluetooth.Core
1261
1262**Return value**
1263
1264No value is returned.
1265
1266**Example**
1267
1268```js
1269bluetooth.BLE.stopBLEScan();
1270```
1271
1272
1273### on('BLEDeviceFind')<sup>(deprecated)</sup>
1274
1275on(type: 'BLEDeviceFind', callback: Callback&lt;Array&lt;ScanResult&gt;&gt;): void
1276
1277Subscribe to the BLE device discovery events.
1278
1279> **NOTE**<br>
1280> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.on('BLEDeviceFind')](js-apis-bluetoothManager.md#onbledevicefinddeprecated) instead.
1281
1282**Required permissions**: ohos.permission.USE_BLUETOOTH
1283
1284**System capability**: SystemCapability.Communication.Bluetooth.Core
1285
1286**Parameters**
1287
1288| Name     | Type                                      | Mandatory  | Description                                 |
1289| -------- | ---------------------------------------- | ---- | ----------------------------------- |
1290| type     | string                                   | Yes   | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered.  |
1291| callback | Callback&lt;Array&lt;[ScanResult](#scanresultdeprecated)&gt;&gt; | Yes   | Callback used to return the discovered devices. You need to implement this callback.|
1292
1293**Return value**
1294
1295No value is returned.
1296
1297**Example**
1298
1299```js
1300function onReceiveEvent(data : Array<bluetooth.ScanResult>) {
1301    console.info('bluetooth device find = '+ JSON.stringify(data));
1302}
1303bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
1304```
1305
1306
1307### off('BLEDeviceFind')<sup>(deprecated)</sup>
1308
1309off(type: 'BLEDeviceFind', callback?: Callback&lt;Array&lt;ScanResult&gt;&gt;): void
1310
1311Unsubscribes from the BLE device discovery events.
1312
1313> **NOTE**<br>
1314> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLE.off('BLEDeviceFind')](js-apis-bluetoothManager.md#offbledevicefinddeprecated) instead.
1315
1316**Required permissions**: ohos.permission.USE_BLUETOOTH
1317
1318**System capability**: SystemCapability.Communication.Bluetooth.Core
1319
1320**Parameters**
1321
1322| Name     | Type                                      | Mandatory  | Description                                      |
1323| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1324| type     | string                                   | Yes   | Event type. The value **BLEDeviceFind** indicates an event reported when a BLE device is discovered.       |
1325| callback | Callback&lt;Array&lt;[ScanResult](#scanresultdeprecated)&gt;&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
1326
1327**Return value**
1328
1329No value is returned.
1330
1331**Example**
1332
1333```js
1334function onReceiveEvent(data : Array<bluetooth.ScanResult>) {
1335    console.info('bluetooth device find = '+ JSON.stringify(data));
1336}
1337bluetooth.BLE.on('BLEDeviceFind', onReceiveEvent);
1338bluetooth.BLE.off('BLEDeviceFind', onReceiveEvent);
1339```
1340
1341
1342## BaseProfile
1343
1344Provides the profile base class.
1345
1346
1347### getConnectionDevices<sup>8+</sup><sup>(deprecated)</sup>
1348
1349getConnectionDevices(): Array&lt;string&gt;
1350
1351Obtains the connected devices.
1352
1353> **NOTE**<br>
1354> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.BaseProfile.getConnectionDevices](js-apis-bluetoothManager.md#getconnectiondevicesdeprecated) instead.
1355
1356**Required permissions**: ohos.permission.USE_BLUETOOTH
1357
1358**System capability**: SystemCapability.Communication.Bluetooth.Core
1359
1360**Return value**
1361
1362| Type                 | Description           |
1363| ------------------- | ------------- |
1364| Array&lt;string&gt; | Addresses of the connected devices.|
1365
1366**Example**
1367
1368```js
1369let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1370let retArray : Array<string> = a2dpSrc.getConnectionDevices();
1371```
1372
1373### getDeviceState<sup>8+</sup><sup>(deprecated)</sup>
1374
1375getDeviceState(device: string): ProfileConnectionState
1376
1377Obtains the connection state of the profile.
1378
1379> **NOTE**<br>
1380> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.BaseProfile.getDeviceState](js-apis-bluetoothManager.md#getdevicestatedeprecated) instead.
1381
1382**Required permissions**: ohos.permission.USE_BLUETOOTH
1383
1384**System capability**: SystemCapability.Communication.Bluetooth.Core
1385
1386**Parameters**
1387
1388| Name   | Type    | Mandatory  | Description     |
1389| ------ | ------ | ---- | ------- |
1390| device | string | Yes   | Address of the target device.|
1391
1392**Return value**
1393
1394| Type                                             | Description                   |
1395| ------------------------------------------------- | ----------------------- |
1396| [ProfileConnectionState](#profileconnectionstatedeprecated) | Profile connection state obtained.|
1397
1398**Example**
1399
1400```js
1401let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1402let ret : bluetooth.ProfileConnectionState = a2dpSrc.getDeviceState('XX:XX:XX:XX:XX:XX');
1403```
1404
1405## A2dpSourceProfile
1406
1407Before using a method of **A2dpSourceProfile**, you need to create an instance of this class by using the **getProfile()** method.
1408
1409
1410### connect<sup>8+</sup><sup>(deprecated)</sup>
1411
1412connect(device: string): boolean
1413
1414Sets up an Advanced Audio Distribution Profile (A2DP) connection.
1415
1416> **NOTE**<br>
1417> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.A2dpSourceProfile.connect](js-apis-bluetoothManager.md#connectdeprecated) instead.
1418
1419**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1420
1421**System capability**: SystemCapability.Communication.Bluetooth.Core
1422
1423**Parameters**
1424
1425| Name   | Type    | Mandatory  | Description     |
1426| ------ | ------ | ---- | ------- |
1427| device | string | Yes   | Address of the target device.|
1428
1429**Return value**
1430
1431| Type     | Description                 |
1432| ------- | ------------------- |
1433| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1434
1435**Example**
1436
1437```js
1438let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1439let ret : boolean = a2dpSrc.connect('XX:XX:XX:XX:XX:XX');
1440```
1441
1442
1443### disconnect<sup>8+</sup><sup>(deprecated)</sup>
1444
1445disconnect(device: string): boolean
1446
1447Disconnects an A2DP connection.
1448
1449> **NOTE**<br>
1450> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.A2dpSourceProfile.disconnect](js-apis-bluetoothManager.md#disconnectdeprecated) instead.
1451
1452**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1453
1454**System capability**: SystemCapability.Communication.Bluetooth.Core
1455
1456**Parameters**
1457
1458| Name   | Type    | Mandatory  | Description     |
1459| ------ | ------ | ---- | ------- |
1460| device | string | Yes   | Address of the target device.|
1461
1462**Return value**
1463
1464| Type     | Description                 |
1465| ------- | ------------------- |
1466| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1467
1468**Example**
1469
1470```js
1471let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1472let ret : boolean = a2dpSrc.disconnect('XX:XX:XX:XX:XX:XX');
1473```
1474
1475
1476### on('connectionStateChange')<sup>8+</sup><sup>(deprecated)</sup>
1477
1478on(type: 'connectionStateChange', callback: Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt;): void
1479
1480Subscribes to the A2DP connection state changes.
1481
1482> **NOTE**<br>
1483> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.A2dpSourceProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechangedeprecated) instead.
1484
1485**System capability**: SystemCapability.Communication.Bluetooth.Core
1486
1487**Parameters**
1488
1489| Name     | Type                                      | Mandatory  | Description                                      |
1490| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1491| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
1492| callback | Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt; | Yes   | Callback used to return the A2DP connection state change event.                              |
1493
1494**Return value**
1495
1496No value is returned.
1497
1498**Example**
1499
1500```js
1501function onReceiveEvent(data : bluetooth.StateChangeParam) {
1502    console.info('a2dp state = '+ JSON.stringify(data));
1503}
1504let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1505a2dpSrc.on('connectionStateChange', onReceiveEvent);
1506```
1507
1508
1509### off('connectionStateChange')<sup>8+</sup><sup>(deprecated)</sup>
1510
1511off(type: 'connectionStateChange', callback?: Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt;): void
1512
1513Unsubscribes from the A2DP connection state changes.
1514
1515> **NOTE**<br>
1516> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.A2dpSourceProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechangedeprecated) instead.
1517
1518**System capability**: SystemCapability.Communication.Bluetooth.Core
1519
1520**Parameters**
1521
1522| Name     | Type                                      | Mandatory  | Description                                      |
1523| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1524| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
1525| callback | Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt; | No   | Callback to unregister.                              |
1526
1527**Return value**
1528
1529No value is returned.
1530
1531**Example**
1532
1533```js
1534function onReceiveEvent(data : bluetooth.StateChangeParam) {
1535    console.info('a2dp state = '+ JSON.stringify(data));
1536}
1537let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1538a2dpSrc.on('connectionStateChange', onReceiveEvent);
1539a2dpSrc.off('connectionStateChange', onReceiveEvent);
1540```
1541
1542
1543### getPlayingState<sup>8+</sup><sup>(deprecated)</sup>
1544
1545getPlayingState(device: string): PlayingState
1546
1547Obtains the playing state of a device.
1548
1549> **NOTE**<br>
1550> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.A2dpSourceProfile.getPlayingState](js-apis-bluetoothManager.md#getplayingstatedeprecated) instead.
1551
1552**System capability**: SystemCapability.Communication.Bluetooth.Core
1553
1554**Parameters**
1555
1556| Name   | Type    | Mandatory  | Description     |
1557| ------ | ------ | ---- | ------- |
1558| device | string | Yes   | Address of the target device.|
1559
1560**Return value**
1561
1562| Type                           | Description        |
1563| ----------------------------- | ---------- |
1564| [PlayingState](#playingstatedeprecated) | Playing state of the remote device obtained.|
1565
1566**Example**
1567
1568```js
1569let a2dpSrc : bluetooth.A2dpSourceProfile = bluetooth.getProfile(bluetooth.ProfileId.PROFILE_A2DP_SOURCE) as bluetooth.A2dpSourceProfile;
1570let state : bluetooth.PlayingState = a2dpSrc.getPlayingState('XX:XX:XX:XX:XX:XX');
1571```
1572
1573
1574## HandsFreeAudioGatewayProfile
1575
1576Before using a method of **HandsFreeAudioGatewayProfile**, you need to create an instance of this class by using the **getProfile()** method.
1577
1578
1579### connect<sup>8+</sup><sup>(deprecated)</sup>
1580
1581connect(device: string): boolean
1582
1583Sets up a Hands-free Profile (HFP) connection of a device.
1584
1585> **NOTE**<br>
1586> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.HandsFreeAudioGatewayProfile.connect](js-apis-bluetoothManager.md#connect) instead.
1587
1588**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1589
1590**System capability**: SystemCapability.Communication.Bluetooth.Core
1591
1592**Parameters**
1593
1594| Name   | Type    | Mandatory  | Description     |
1595| ------ | ------ | ---- | ------- |
1596| device | string | Yes   | Address of the target device.|
1597
1598**Return value**
1599
1600| Type     | Description                 |
1601| ------- | ------------------- |
1602| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1603
1604**Example**
1605
1606```js
1607let hfpAg : bluetooth.HandsFreeAudioGatewayProfile= bluetooth.getProfile(bluetooth.ProfileId
1608    .PROFILE_HANDS_FREE_AUDIO_GATEWAY);
1609let ret : boolean = hfpAg.connect('XX:XX:XX:XX:XX:XX');
1610```
1611
1612
1613### disconnect<sup>8+</sup><sup>(deprecated)</sup>
1614
1615disconnect(device: string): boolean
1616
1617Disconnects the HFP connection of a device.
1618
1619> **NOTE**<br>
1620> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.HandsFreeAudioGatewayProfile.disconnect](js-apis-bluetoothManager.md#disconnectdeprecated-1) instead.
1621
1622**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1623
1624**System capability**: SystemCapability.Communication.Bluetooth.Core
1625
1626**Parameters**
1627
1628| Name   | Type    | Mandatory  | Description     |
1629| ------ | ------ | ---- | ------- |
1630| device | string | Yes   | Address of the target device.|
1631
1632**Return value**
1633
1634| Type     | Description                 |
1635| ------- | ------------------- |
1636| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1637
1638**Example**
1639
1640```js
1641let hfpAg : bluetooth.HandsFreeAudioGatewayProfile = bluetooth.getProfile(bluetooth.ProfileId
1642    .PROFILE_HANDS_FREE_AUDIO_GATEWAY);
1643let ret : boolean = hfpAg.disconnect('XX:XX:XX:XX:XX:XX');
1644```
1645
1646
1647### on('connectionStateChange')<sup>8+</sup><sup>(deprecated)</sup>
1648
1649on(type: 'connectionStateChange', callback: Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt;): void
1650
1651Subscribes to the HFP connection state changes.
1652
1653> **NOTE**<br>
1654> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.HandsFreeAudioGatewayProfile.on('connectionStateChange')](js-apis-bluetoothManager.md#onconnectionstatechangedeprecated-1) instead.
1655
1656**System capability**: SystemCapability.Communication.Bluetooth.Core
1657
1658**Parameters**
1659
1660| Name     | Type                                      | Mandatory  | Description                                      |
1661| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1662| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
1663| callback | Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt; | Yes   | Callback used to return the A2DP connection state change event.                              |
1664
1665**Return value**
1666
1667No value is returned.
1668
1669**Example**
1670
1671```js
1672function onReceiveEvent(data : bluetooth.StateChangeParam) {
1673    console.info('hfp state = '+ JSON.stringify(data));
1674}
1675let hfpAg : bluetooth.HandsFreeAudioGatewayProfile= bluetooth.getProfile(bluetooth.ProfileId
1676    .PROFILE_HANDS_FREE_AUDIO_GATEWAY);
1677hfpAg.on('connectionStateChange', onReceiveEvent);
1678```
1679
1680
1681### off('connectionStateChange')<sup>8+</sup><sup>(deprecated)</sup>
1682
1683off(type: 'connectionStateChange', callback?: Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt;): void
1684
1685Unsubscribes from the HFP connection state changes.
1686
1687> **NOTE**<br>
1688> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.HandsFreeAudioGatewayProfile.off('connectionStateChange')](js-apis-bluetoothManager.md#offconnectionstatechangedeprecated-1) instead.
1689
1690**System capability**: SystemCapability.Communication.Bluetooth.Core
1691
1692**Parameters**
1693
1694| Name     | Type                                      | Mandatory  | Description                                      |
1695| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
1696| type     | string                                   | Yes   | Event type. The value **connectionStateChange** indicates an A2DP connection state change event.|
1697| callback | Callback&lt;[StateChangeParam](#statechangeparamdeprecated)&gt; | No   | Callback to unregister.                              |
1698
1699**Return value**
1700
1701No value is returned.
1702
1703**Example**
1704
1705```js
1706function onReceiveEvent(data : bluetooth.StateChangeParam) {
1707    console.info('hfp state = '+ JSON.stringify(data));
1708}
1709let hfpAg : bluetooth.HandsFreeAudioGatewayProfile= bluetooth.getProfile(bluetooth.ProfileId
1710    .PROFILE_HANDS_FREE_AUDIO_GATEWAY);
1711hfpAg.on('connectionStateChange', onReceiveEvent);
1712hfpAg.off('connectionStateChange', onReceiveEvent);
1713```
1714
1715
1716## GattServer
1717
1718Implements the Generic Attribute Profile (GATT) server. Before using a method of this class, you need to create a **GattServer** instance using the **createGattServer()** method.
1719
1720
1721### startAdvertising<sup>(deprecated)</sup>
1722
1723startAdvertising(setting: AdvertiseSetting, advData: AdvertiseData, advResponse?: AdvertiseData): void
1724
1725Starts BLE advertising.
1726
1727> **NOTE**<br>
1728> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.startAdvertising](js-apis-bluetoothManager.md#startadvertisingdeprecated) instead.
1729
1730**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1731
1732**System capability**: SystemCapability.Communication.Bluetooth.Core
1733
1734**Parameters**
1735
1736| Name        | Type                                   | Mandatory  | Description            |
1737| ----------- | ------------------------------------- | ---- | -------------- |
1738| setting     | [AdvertiseSetting](#advertisesettingdeprecated) | Yes   | Settings related to BLE advertising.   |
1739| advData     | [AdvertiseData](#advertisedatadeprecated)       | Yes   | Content of the BLE advertisement packet.     |
1740| advResponse | [AdvertiseData](#advertisedatadeprecated)       | No   | Response to the BLE scan request.|
1741
1742**Return value**
1743
1744No value is returned.
1745
1746**Example**
1747
1748```js
1749let manufactureValueBuffer = new Uint8Array(4);
1750manufactureValueBuffer[0] = 1;
1751manufactureValueBuffer[1] = 2;
1752manufactureValueBuffer[2] = 3;
1753manufactureValueBuffer[3] = 4;
1754
1755let serviceValueBuffer = new Uint8Array(4);
1756serviceValueBuffer[0] = 4;
1757serviceValueBuffer[1] = 6;
1758serviceValueBuffer[2] = 7;
1759serviceValueBuffer[3] = 8;
1760console.info('manufactureValueBuffer = '+ JSON.stringify(manufactureValueBuffer));
1761console.info('serviceValueBuffer = '+ JSON.stringify(serviceValueBuffer));
1762let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1763let setting : bluetooth.AdvertiseSetting = {
1764    interval:150,
1765    txPower:60,
1766    connectable:true,
1767}
1768
1769let manufactureData : bluetooth.ManufactureData = {
1770    manufactureId:4567,
1771    manufactureValue:manufactureValueBuffer.buffer
1772}
1773
1774let serviceData : bluetooth.ServiceData = {
1775    serviceUuid:"00001888-0000-1000-8000-00805f9b34fb",
1776    serviceValue:serviceValueBuffer.buffer
1777}
1778
1779let advData : bluetooth.AdvertiseData = {
1780    serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
1781    manufactureData:[manufactureData],
1782    serviceData:[serviceData],
1783}
1784
1785let advResponse : bluetooth.AdvertiseData = {
1786    serviceUuids:["00001889-0000-1000-8000-00805f9b34fb"],
1787    manufactureData:[manufactureData],
1788    serviceData:[serviceData],
1789}
1790gattServer.startAdvertising(setting, advData, advResponse);
1791```
1792
1793
1794### stopAdvertising<sup>(deprecated)</sup>
1795
1796stopAdvertising(): void
1797
1798Stops BLE advertising.
1799
1800> **NOTE**<br>
1801> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.stopAdvertising](js-apis-bluetoothManager.md#stopadvertisingdeprecated) instead.
1802
1803**Required permissions**: ohos.permission.DISCOVER_BLUETOOTH
1804
1805**System capability**: SystemCapability.Communication.Bluetooth.Core
1806
1807**Return value**
1808
1809No value is returned.
1810
1811**Example**
1812
1813```js
1814let server : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1815server.stopAdvertising();
1816```
1817
1818
1819### addService<sup>(deprecated)</sup>
1820
1821addService(service: GattService): boolean
1822
1823Adds a service to this GATT server.
1824
1825> **NOTE**<br>
1826> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.addService](js-apis-bluetoothManager.md#addservicedeprecated) instead.
1827
1828**Required permissions**: ohos.permission.USE_BLUETOOTH
1829
1830**System capability**: SystemCapability.Communication.Bluetooth.Core
1831
1832**Parameters**
1833
1834| Name    | Type                         | Mandatory  | Description                      |
1835| ------- | --------------------------- | ---- | ------------------------ |
1836| service | [GattService](#gattservicedeprecated) | Yes   | Service to add. Settings related to BLE advertising.|
1837
1838**Return value**
1839
1840| Type     | Description                        |
1841| ------- | -------------------------- |
1842| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1843
1844**Example**
1845
1846```js
1847// Create descriptors.
1848let descriptors : Array<bluetooth.BLEDescriptor> = [];
1849let arrayBuffer = new ArrayBuffer(8);
1850let descV = new Uint8Array(arrayBuffer);
1851descV[0] = 11;
1852let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
1853  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
1854  descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
1855descriptors[0] = descriptor;
1856
1857// Create characteristics.
1858let characteristics : Array<bluetooth.BLECharacteristic> = [];
1859let arrayBufferC = new ArrayBuffer(8);
1860let cccV = new Uint8Array(arrayBufferC);
1861cccV[0] = 1;
1862let characteristic : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
1863  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
1864let characteristicN : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
1865  characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
1866characteristics[0] = characteristic;
1867
1868// Create a gattService instance.
1869let gattService : bluetooth.GattService = {serviceUuid:'00001810-0000-1000-8000-00805F9B34FB', isPrimary: true, characteristics:characteristics, includeServices:[]};
1870
1871let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1872let ret : boolean = gattServer.addService(gattService);
1873if (ret) {
1874   console.log("add service successfully");
1875} else {
1876   console.log("add service failed");
1877}
1878```
1879
1880
1881### removeService<sup>(deprecated)</sup>
1882
1883removeService(serviceUuid: string): boolean
1884
1885Removes a service from this GATT server.
1886
1887> **NOTE**<br>
1888> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.removeService](js-apis-bluetoothManager.md#removeservicedeprecated) instead.
1889
1890**Required permissions**: ohos.permission.USE_BLUETOOTH
1891
1892**System capability**: SystemCapability.Communication.Bluetooth.Core
1893
1894**Parameters**
1895
1896| Name        | Type    | Mandatory  | Description                                      |
1897| ----------- | ------ | ---- | ---------------------------------------- |
1898| serviceUuid | string | Yes   | Universally unique identifier (UUID) of the service to remove, for example, **00001810-0000-1000-8000-00805F9B34FB**.|
1899
1900**Return value**
1901
1902| Type     | Description                        |
1903| ------- | -------------------------- |
1904| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1905
1906**Example**
1907
1908```js
1909let server : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1910server.removeService('00001810-0000-1000-8000-00805F9B34FB');
1911```
1912
1913
1914### close<sup>(deprecated)</sup>
1915
1916close(): void
1917
1918Closes this GATT server to unregister it from the protocol stack. After this method is called, this [GattServer](#gattserver) cannot be used.
1919
1920> **NOTE**<br>
1921> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.close](js-apis-bluetoothManager.md#closedeprecated) instead.
1922
1923**Required permissions**: ohos.permission.USE_BLUETOOTH
1924
1925**System capability**: SystemCapability.Communication.Bluetooth.Core
1926
1927**Example**
1928
1929```js
1930let server : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1931server.close();
1932```
1933
1934
1935### notifyCharacteristicChanged<sup>(deprecated)</sup>
1936
1937notifyCharacteristicChanged(deviceId: string, notifyCharacteristic: NotifyCharacteristic): boolean
1938
1939Notifies the connected client device when a characteristic value changes.
1940
1941> **NOTE**<br>
1942> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.notifyCharacteristicChanged](js-apis-bluetoothManager.md#notifycharacteristicchangeddeprecated) instead.
1943
1944**Required permissions**: ohos.permission.USE_BLUETOOTH
1945
1946**System capability**: SystemCapability.Communication.Bluetooth.Core
1947
1948**Parameters**
1949
1950| Name                 | Type                                      | Mandatory  | Description                                     |
1951| -------------------- | ---------------------------------------- | ---- | --------------------------------------- |
1952| deviceId             | string                                   | Yes   | Address of the client that receives notifications, for example, XX:XX:XX:XX:XX:XX.|
1953| notifyCharacteristic | [NotifyCharacteristic](#notifycharacteristicdeprecated) | Yes   | New characteristic value.                              |
1954
1955**Return value**
1956
1957| Type     | Description                      |
1958| ------- | ------------------------ |
1959| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
1960
1961**Example**
1962
1963```js
1964// Create descriptors.
1965let descriptors : Array<bluetooth.BLEDescriptor> = [];
1966let arrayBuffer = new ArrayBuffer(8);
1967let descV = new Uint8Array(arrayBuffer);
1968descV[0] = 11;
1969let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
1970  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
1971  descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
1972descriptors[0] = descriptor;
1973let arrayBufferC = new ArrayBuffer(8);
1974let characteristic : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
1975  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
1976let notifyCharacteristic : bluetooth.NotifyCharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
1977  characteristicUuid: '00001821-0000-1000-8000-00805F9B34FB', characteristicValue: characteristic.characteristicValue, confirm: false};
1978let server : bluetooth.GattServer = bluetooth.BLE.createGattServer();
1979server.notifyCharacteristicChanged('XX:XX:XX:XX:XX:XX', notifyCharacteristic);
1980```
1981
1982
1983### sendResponse<sup>(deprecated)</sup>
1984
1985sendResponse(serverResponse: ServerResponse): boolean
1986
1987Sends a response to a read or write request from the GATT client.
1988
1989> **NOTE**<br>
1990> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.sendResponse](js-apis-bluetoothManager.md#sendresponsedeprecated) instead.
1991
1992**Required permissions**: ohos.permission.USE_BLUETOOTH
1993
1994**System capability**: SystemCapability.Communication.Bluetooth.Core
1995
1996**Parameters**
1997
1998| Name           | Type                               | Mandatory  | Description             |
1999| -------------- | --------------------------------- | ---- | --------------- |
2000| serverResponse | [ServerResponse](#serverresponsedeprecated) | Yes   | Response returned by the GATT server.|
2001
2002**Return value**
2003
2004| Type     | Description                        |
2005| ------- | -------------------------- |
2006| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2007
2008**Example**
2009
2010```js
2011/* send response */
2012let arrayBufferCCC = new ArrayBuffer(8);
2013let cccValue = new Uint8Array(arrayBufferCCC);
2014cccValue[0] = 1123;
2015let serverResponse : bluetooth.ServerResponse = {
2016    "deviceId": "XX:XX:XX:XX:XX:XX",
2017    "transId": 0,
2018    "status": 0,
2019    "offset": 0,
2020    "value": arrayBufferCCC,
2021};
2022
2023let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2024let ret : boolean = gattServer.sendResponse(serverResponse);
2025if (ret) {
2026  console.log('bluetooth sendResponse successfully');
2027} else {
2028  console.log('bluetooth sendResponse failed');
2029}
2030```
2031
2032
2033### on('characteristicRead')<sup>(deprecated)</sup>
2034
2035on(type: 'characteristicRead', callback: Callback&lt;CharacteristicReadReq&gt;): void
2036
2037Subscribes to the characteristic read request events.
2038
2039> **NOTE**<br>
2040> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.on('characteristicRead')](js-apis-bluetoothManager.md#oncharacteristicreaddeprecated) instead.
2041
2042**Required permissions**: ohos.permission.USE_BLUETOOTH
2043
2044**System capability**: SystemCapability.Communication.Bluetooth.Core
2045
2046**Parameters**
2047
2048| Name     | Type                                      | Mandatory  | Description                                   |
2049| -------- | ---------------------------------------- | ---- | ------------------------------------- |
2050| type     | string                                   | Yes   | Event type. The value **characteristicRead** indicates a characteristic read request event.|
2051| callback | Callback&lt;[CharacteristicReadReq](#characteristicreadreqdeprecated)&gt; | Yes   | Callback used to return a characteristic read request event from the GATT client.           |
2052
2053**Return value**
2054
2055No value is returned.
2056
2057**Example**
2058
2059```js
2060let arrayBufferCCC = new ArrayBuffer(8);
2061let cccValue = new Uint8Array(arrayBufferCCC);
2062cccValue[0] = 1123;
2063function ReadCharacteristicReq(CharacteristicReadReq : bluetooth.CharacteristicReadReq) {
2064  let deviceId : string = CharacteristicReadReq.deviceId;
2065  let transId : number = CharacteristicReadReq.transId;
2066  let offset : number = CharacteristicReadReq.offset;
2067  let characteristicUuid : string = CharacteristicReadReq.characteristicUuid;
2068
2069  let serverResponse : bluetooth.ServerResponse = {deviceId: deviceId, transId: transId, status: 0,
2070  offset: offset, value:arrayBufferCCC};
2071
2072  let ret : boolean = gattServer.sendResponse(serverResponse);
2073  if (ret) {
2074    console.log('bluetooth sendResponse successfully');
2075  } else {
2076    console.log('bluetooth sendResponse failed');
2077  }
2078}
2079
2080let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2081gattServer.on("characteristicRead", ReadCharacteristicReq);
2082```
2083
2084
2085### off('characteristicRead')<sup>(deprecated)</sup>
2086
2087off(type: 'characteristicRead', callback?: Callback&lt;CharacteristicReadReq&gt;): void
2088
2089Unsubscribes from the characteristic read request events.
2090
2091> **NOTE**<br>
2092> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.off('characteristicRead')](js-apis-bluetoothManager.md#offcharacteristicreaddeprecated) instead.
2093
2094**Required permissions**: ohos.permission.USE_BLUETOOTH
2095
2096**System capability**: SystemCapability.Communication.Bluetooth.Core
2097
2098**Parameters**
2099
2100| Name     | Type                                      | Mandatory  | Description                                      |
2101| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2102| type     | string                                   | Yes   | Event type. The value **characteristicRead** indicates a characteristic read request event.   |
2103| callback | Callback&lt;[CharacteristicReadReq](#characteristicreadreqdeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
2104
2105**Return value**
2106
2107No value is returned.
2108
2109**Example**
2110
2111```js
2112let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2113gattServer.off("characteristicRead");
2114```
2115
2116
2117### on('characteristicWrite')<sup>(deprecated)</sup>
2118
2119on(type: 'characteristicWrite', callback: Callback&lt;CharacteristicWriteReq&gt;): void
2120
2121Subscribes to the characteristic write request events.
2122
2123> **NOTE**<br>
2124> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.on('characteristicWrite')](js-apis-bluetoothManager.md#oncharacteristicwritedeprecated) instead.
2125
2126**Required permissions**: ohos.permission.USE_BLUETOOTH
2127
2128**System capability**: SystemCapability.Communication.Bluetooth.Core
2129
2130**Parameters**
2131
2132| Name     | Type                                      | Mandatory  | Description                                    |
2133| -------- | ---------------------------------------- | ---- | -------------------------------------- |
2134| type     | string                                   | Yes   | Event type. The value **characteristicWrite** indicates a characteristic write request event.|
2135| callback | Callback&lt;[CharacteristicWriteReq](#characteristicwritereqdeprecated)&gt; | Yes   | Callback used to return a characteristic write request from the GATT client.            |
2136
2137**Return value**
2138
2139No value is returned.
2140
2141**Example**
2142
2143```js
2144let arrayBufferCCC = new ArrayBuffer(8);
2145let cccValue = new Uint8Array(arrayBufferCCC);
2146function WriteCharacteristicReq(CharacteristicWriteReq : bluetooth.CharacteristicWriteReq) {
2147  let deviceId : string = CharacteristicWriteReq.deviceId;
2148  let transId : number = CharacteristicWriteReq.transId;
2149  let offset : number = CharacteristicWriteReq.offset;
2150  let isPrep : boolean = CharacteristicWriteReq.isPrep;
2151  let needRsp : boolean = CharacteristicWriteReq.needRsp;
2152  let value =  new Uint8Array(arrayBufferCCC);
2153  let characteristicUuid : string = CharacteristicWriteReq.characteristicUuid;
2154
2155  cccValue.set(new Uint8Array(value));
2156  let serverResponse : bluetooth.ServerResponse = {deviceId: deviceId, transId: transId, status: 0,
2157  offset: offset, value:arrayBufferCCC};
2158
2159  let ret : boolean = gattServer.sendResponse(serverResponse);
2160  if (ret) {
2161    console.log('bluetooth sendResponse successfully');
2162  } else {
2163    console.log('bluetooth sendResponse failed');
2164  }
2165}
2166
2167let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2168gattServer.on("characteristicWrite", WriteCharacteristicReq);
2169```
2170
2171
2172### off('characteristicWrite')<sup>(deprecated)</sup>
2173
2174off(type: 'characteristicWrite', callback?: Callback&lt;CharacteristicWriteReq&gt;): void
2175
2176Unsubscribes from the characteristic write request events.
2177
2178> **NOTE**<br>
2179> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.off('characteristicWrite')](js-apis-bluetoothManager.md#offcharacteristicwritedeprecated) instead.
2180
2181**Required permissions**: ohos.permission.USE_BLUETOOTH
2182
2183**System capability**: SystemCapability.Communication.Bluetooth.Core
2184
2185**Parameters**
2186
2187| Name     | Type                                      | Mandatory  | Description                                      |
2188| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2189| type     | string                                   | Yes   | Event type. The value **characteristicWrite** indicates a characteristic write request event.  |
2190| callback | Callback&lt;[CharacteristicWriteReq](#characteristicwritereqdeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
2191
2192**Return value**
2193
2194No value is returned.
2195
2196**Example**
2197
2198```js
2199let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2200gattServer.off("characteristicWrite");
2201```
2202
2203
2204### on('descriptorRead')<sup>(deprecated)</sup>
2205
2206on(type: 'descriptorRead', callback: Callback&lt;DescriptorReadReq&gt;): void
2207
2208Subscribes to the descriptor read request events.
2209
2210> **NOTE**<br>
2211> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.on('descriptorRead')](js-apis-bluetoothManager.md#ondescriptorreaddeprecated) instead.
2212
2213**Required permissions**: ohos.permission.USE_BLUETOOTH
2214
2215**System capability**: SystemCapability.Communication.Bluetooth.Core
2216
2217**Parameters**
2218
2219| Name     | Type                                      | Mandatory  | Description                               |
2220| -------- | ---------------------------------------- | ---- | --------------------------------- |
2221| type     | string                                   | Yes   | Event type. The value **descriptorRead** indicates a descriptor read request event.|
2222| callback | Callback&lt;[DescriptorReadReq](#descriptorreadreqdeprecated)&gt; | Yes   | Callback used to return a characteristic read request event from the GATT client.       |
2223
2224**Return value**
2225
2226No value is returned.
2227
2228**Example**
2229
2230```js
2231let arrayBufferDesc = new ArrayBuffer(8);
2232let descValue = new Uint8Array(arrayBufferDesc);
2233descValue[0] = 1101;
2234function ReadDescriptorReq(DescriptorReadReq : bluetooth.DescriptorReadReq) {
2235  let deviceId : string = DescriptorReadReq.deviceId;
2236  let transId : number = DescriptorReadReq.transId;
2237  let offset : number = DescriptorReadReq.offset;
2238  let descriptorUuid : string = DescriptorReadReq.descriptorUuid;
2239
2240  let serverResponse : bluetooth.ServerResponse = {deviceId: deviceId, transId: transId, status: 0,
2241  offset: offset, value:arrayBufferDesc};
2242
2243  let ret : boolean = gattServer.sendResponse(serverResponse);
2244  if (ret) {
2245    console.log('bluetooth sendResponse successfully');
2246  } else {
2247    console.log('bluetooth sendResponse failed');
2248  }
2249}
2250
2251let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2252gattServer.on("descriptorRead", ReadDescriptorReq);
2253```
2254
2255
2256### off('descriptorRead')<sup>(deprecated)</sup>
2257
2258off(type: 'descriptorRead', callback?: Callback&lt;DescriptorReadReq&gt;): void
2259
2260Unsubscribes from the descriptor read request events.
2261
2262> **NOTE**<br>
2263> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.off('descriptorRead')](js-apis-bluetoothManager.md#offdescriptorreaddeprecated) instead.
2264
2265**Required permissions**: ohos.permission.USE_BLUETOOTH
2266
2267**System capability**: SystemCapability.Communication.Bluetooth.Core
2268
2269**Parameters**
2270
2271| Name     | Type                                      | Mandatory  | Description                                      |
2272| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2273| type     | string                                   | Yes   | Event type. The value **descriptorRead** indicates a descriptor read request event.       |
2274| callback | Callback&lt;[DescriptorReadReq](#descriptorreadreqdeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
2275
2276**Return value**
2277
2278No value is returned.
2279
2280**Example**
2281
2282```js
2283let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2284gattServer.off("descriptorRead");
2285```
2286
2287
2288### on('descriptorWrite')<sup>(deprecated)</sup>
2289
2290on(type: 'descriptorWrite', callback: Callback&lt;DescriptorWriteReq&gt;): void
2291
2292Subscribes to the descriptor write request events.
2293
2294> **NOTE**<br>
2295> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.on('descriptorWrite')](js-apis-bluetoothManager.md#ondescriptorwritedeprecated) instead.
2296
2297**Required permissions**: ohos.permission.USE_BLUETOOTH
2298
2299**System capability**: SystemCapability.Communication.Bluetooth.Core
2300
2301**Parameters**
2302
2303| Name     | Type                                      | Mandatory  | Description                                |
2304| -------- | ---------------------------------------- | ---- | ---------------------------------- |
2305| type     | string                                   | Yes   | Event type. The value **descriptorWrite** indicates a descriptor write request event.|
2306| callback | Callback&lt;[DescriptorWriteReq](#descriptorwritereqdeprecated)&gt; | Yes   | Callback used to return a characteristic write request from the GATT client.        |
2307
2308**Return value**
2309
2310No value is returned.
2311
2312**Example**
2313
2314```js
2315let arrayBufferDesc = new ArrayBuffer(8);
2316let descValue = new Uint8Array(arrayBufferDesc);
2317function WriteDescriptorReq(DescriptorWriteReq : bluetooth.DescriptorWriteReq) {
2318  let deviceId : string = DescriptorWriteReq.deviceId;
2319  let transId : number = DescriptorWriteReq.transId;
2320  let offset : number = DescriptorWriteReq.offset;
2321  let isPrep : boolean = DescriptorWriteReq.isPrep;
2322  let needRsp : boolean = DescriptorWriteReq.needRsp;
2323  let value = new Uint8Array(arrayBufferDesc);
2324  let descriptorUuid : string = DescriptorWriteReq.descriptorUuid;
2325
2326  descValue.set(new Uint8Array(value));
2327  let serverResponse : bluetooth.ServerResponse = {deviceId: deviceId, transId: transId, status: 0, offset: offset, value:arrayBufferDesc};
2328
2329  let ret : boolean = gattServer.sendResponse(serverResponse);
2330  if (ret) {
2331    console.log('bluetooth sendResponse successfully');
2332  } else {
2333    console.log('bluetooth sendResponse failed');
2334  }
2335}
2336
2337let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2338gattServer.on("descriptorWrite", WriteDescriptorReq);
2339```
2340
2341
2342### off('descriptorWrite')<sup>(deprecated)</sup>
2343
2344off(type: 'descriptorWrite', callback?: Callback&lt;DescriptorWriteReq&gt;): void
2345
2346Unsubscribes from the descriptor write request events.
2347
2348> **NOTE**<br>
2349> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.off('descriptorWrite')](js-apis-bluetoothManager.md#offdescriptorwritedeprecated) instead.
2350
2351**Required permissions**: ohos.permission.USE_BLUETOOTH
2352
2353**System capability**: SystemCapability.Communication.Bluetooth.Core
2354
2355**Parameters**
2356
2357| Name     | Type                                      | Mandatory  | Description                                      |
2358| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2359| type     | string                                   | Yes   | Event type. The value **descriptorWrite** indicates a descriptor write request event.      |
2360| callback | Callback&lt;[DescriptorWriteReq](#descriptorwritereqdeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
2361
2362**Return value**
2363
2364No value is returned.
2365
2366**Example**
2367
2368```js
2369let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2370gattServer.off("descriptorWrite");
2371```
2372
2373
2374### on('connectStateChange')<sup>(deprecated)</sup>
2375
2376on(type: 'connectStateChange', callback: Callback&lt;BLEConnectChangedState&gt;): void
2377
2378Subscribes to the BLE connection state changes.
2379
2380> **NOTE**<br>
2381> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.on('connectStateChange')](js-apis-bluetoothManager.md#onconnectstatechangedeprecated) instead.
2382
2383**Required permissions**: ohos.permission.USE_BLUETOOTH
2384
2385**System capability**: SystemCapability.Communication.Bluetooth.Core
2386
2387**Parameters**
2388
2389| Name     | Type                                      | Mandatory  | Description                                      |
2390| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2391| type     | string                                   | Yes   | Event type. The value **connectStateChange** indicates a BLE connection state change event.|
2392| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstatedeprecated)&gt; | Yes   | Callback used to return the BLE connection state.                         |
2393
2394**Return value**
2395
2396No value is returned.
2397
2398**Example**
2399
2400```js
2401function Connected(BLEConnectChangedState : bluetooth.BLEConnectChangedState) {
2402  let deviceId : string = BLEConnectChangedState.deviceId;
2403  let status : bluetooth.ProfileConnectionState = BLEConnectChangedState.state;
2404}
2405
2406let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2407gattServer.on("connectStateChange", Connected);
2408```
2409
2410
2411### off('connectStateChange')<sup>(deprecated)</sup>
2412
2413off(type: 'connectStateChange', callback?: Callback&lt;BLEConnectChangedState&gt;): void
2414
2415Unsubscribes from the BLE connection state changes.
2416
2417> **NOTE**<br>
2418> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattServer.off('connectStateChange')](js-apis-bluetoothManager.md#offconnectstatechangedeprecated) instead.
2419
2420**Required permissions**: ohos.permission.USE_BLUETOOTH
2421
2422**System capability**: SystemCapability.Communication.Bluetooth.Core
2423
2424**Parameters**
2425
2426| Name     | Type                                      | Mandatory  | Description                                      |
2427| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2428| type     | string                                   | Yes   | Event type. The value **connectStateChange** indicates a BLE connection state change event.|
2429| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstatedeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
2430
2431**Return value**
2432
2433No value is returned.
2434
2435**Example**
2436
2437```js
2438let gattServer : bluetooth.GattServer = bluetooth.BLE.createGattServer();
2439gattServer.off("connectStateChange");
2440```
2441
2442
2443## GattClientDevice
2444
2445Implements the GATT client. Before using a method of this class, you must create a **GattClientDevice** instance using the **createGattClientDevice(deviceId: string)** method.
2446
2447
2448### connect<sup>(deprecated)</sup>
2449
2450connect(): boolean
2451
2452Initiates a connection to the remote BLE device.
2453
2454> **NOTE**<br>
2455> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.connect](js-apis-bluetoothManager.md#connectdeprecated-1) instead.
2456
2457**Required permissions**: ohos.permission.USE_BLUETOOTH
2458
2459**System capability**: SystemCapability.Communication.Bluetooth.Core
2460
2461**Return value**
2462
2463| Type     | Description                       |
2464| ------- | ------------------------- |
2465| boolean | Returns **true** if the connection is successful; returns **false** otherwise.|
2466
2467**Example**
2468
2469```js
2470let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2471let ret : boolean = device.connect();
2472```
2473
2474
2475### disconnect<sup>(deprecated)</sup>
2476
2477disconnect(): boolean
2478
2479Disconnects from the remote BLE device.
2480
2481> **NOTE**<br>
2482> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.disconnect](js-apis-bluetoothManager.md#disconnectdeprecated-4) instead.
2483
2484**Required permissions**: ohos.permission.USE_BLUETOOTH
2485
2486**System capability**: SystemCapability.Communication.Bluetooth.Core
2487
2488**Return value**
2489
2490| Type     | Description                          |
2491| ------- | ---------------------------- |
2492| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2493
2494**Example**
2495
2496```js
2497let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2498let ret : boolean = device.disconnect();
2499```
2500
2501
2502### close<sup>(deprecated)</sup>
2503
2504close(): boolean
2505
2506Closes this GATT client to unregister it from the protocol stack. After this method is called, this [GattClientDevice](#gattclientdevice) instance cannot be used.
2507
2508> **NOTE**<br>
2509> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.close](js-apis-bluetoothManager.md#closedeprecated-1) instead.
2510
2511**Required permissions**: ohos.permission.USE_BLUETOOTH
2512
2513**System capability**: SystemCapability.Communication.Bluetooth.Core
2514
2515**Return value**
2516
2517| Type     | Description                        |
2518| ------- | -------------------------- |
2519| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2520
2521**Example**
2522
2523```js
2524let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2525let ret : boolean = device.close();
2526```
2527
2528
2529
2530
2531### getServices<sup>(deprecated)</sup>
2532
2533getServices(callback: AsyncCallback&lt;Array&lt;GattService&gt;&gt;): void
2534
2535Obtains all services of the remote BLE device. This API uses an asynchronous callback to return the result.
2536
2537> **NOTE**<br>
2538> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservicesdeprecated) instead.
2539
2540**Required permissions**: ohos.permission.USE_BLUETOOTH
2541
2542**System capability**: SystemCapability.Communication.Bluetooth.Core
2543
2544**Parameters**
2545
2546| Name     | Type                                      | Mandatory  | Description                      |
2547| -------- | ---------------------------------------- | ---- | ------------------------ |
2548| callback | AsyncCallback&lt;Array&lt;[GattService](#gattservicedeprecated)&gt;&gt; | Yes   | Callback used to return the services obtained.|
2549
2550**Return value**
2551
2552No value is returned.
2553
2554**Example**
2555
2556```js
2557import { BusinessError } from '@ohos.base';
2558// Callback mode.
2559function getServices(code : BusinessError, gattServices : Array<bluetooth.GattService>) {
2560  if (code.code == 0) {
2561      let services : Array<bluetooth.GattService> = gattServices;
2562      console.log('bluetooth code is ' + code.code);
2563      console.log("bluetooth services size is ", services.length);
2564
2565      for (let i = 0; i < services.length; i++) {
2566        console.log('bluetooth serviceUuid is ' + services[i].serviceUuid);
2567      }
2568  }
2569}
2570
2571let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2572device.connect();
2573device.getServices(getServices);
2574```
2575
2576
2577### getServices<sup>(deprecated)</sup>
2578
2579getServices(): Promise&lt;Array&lt;GattService&gt;&gt;
2580
2581Obtains all services of the remote BLE device. This API uses a promise to return the result.
2582
2583> **NOTE**<br>
2584> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.getServices](js-apis-bluetoothManager.md#getservicesdeprecated-1) instead.
2585
2586**Required permissions**: ohos.permission.USE_BLUETOOTH
2587
2588**System capability**: SystemCapability.Communication.Bluetooth.Core
2589
2590**Return value**
2591
2592| Type                                      | Description                         |
2593| ---------------------------------------- | --------------------------- |
2594| Promise&lt;Array&lt;[GattService](#gattservicedeprecated)&gt;&gt; | Promise used to return the services obtained.|
2595
2596**Example**
2597
2598```js
2599// Promise
2600let device : bluetooth.GattClientDevice= bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2601device.connect();
2602device.getServices().then((result : Array<bluetooth.GattService>) => {
2603    console.info("getServices successfully:" + JSON.stringify(result));
2604});
2605```
2606
2607
2608### readCharacteristicValue<sup>(deprecated)</sup>
2609
2610readCharacteristicValue(characteristic: BLECharacteristic, callback: AsyncCallback&lt;BLECharacteristic&gt;): void
2611
2612Reads the characteristic value of the specific service of the remote BLE device. This API uses an asynchronous callback to return the result.
2613
2614> **NOTE**<br>
2615> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvaluedeprecated) instead.
2616
2617**Required permissions**: ohos.permission.USE_BLUETOOTH
2618
2619**System capability**: SystemCapability.Communication.Bluetooth.Core
2620
2621**Parameters**
2622
2623| Name           | Type                                      | Mandatory  | Description                     |
2624| -------------- | ---------------------------------------- | ---- | ----------------------- |
2625| characteristic | [BLECharacteristic](#blecharacteristicdeprecated)  | Yes   | Characteristic value to read.               |
2626| callback       | AsyncCallback&lt;[BLECharacteristic](#blecharacteristicdeprecated)&gt; | Yes   | Callback used to return the characteristic value read.|
2627
2628**Return value**
2629
2630No value is returned.
2631
2632**Example**
2633
2634```js
2635import { BusinessError } from '@ohos.base';
2636function readCcc(code : BusinessError, BLECharacteristic : bluetooth.BLECharacteristic) {
2637  if (code.code != 0) {
2638      return;
2639  }
2640  console.log('bluetooth characteristic uuid: ' + BLECharacteristic.characteristicUuid);
2641  let value = new Uint8Array(BLECharacteristic.characteristicValue);
2642  console.log('bluetooth characteristic value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
2643}
2644
2645let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2646let descriptors : Array<bluetooth.BLEDescriptor> = [];
2647let bufferDesc : ArrayBuffer = new ArrayBuffer(8);
2648let descV : Uint8Array = new Uint8Array(bufferDesc);
2649descV[0] = 11;
2650let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2651characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2652descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
2653descriptors[0] = descriptor;
2654
2655let bufferCCC = new ArrayBuffer(8);
2656let cccV = new Uint8Array(bufferCCC);
2657cccV[0] = 1;
2658let characteristic : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2659characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2660characteristicValue: bufferCCC, descriptors:descriptors};
2661
2662device.readCharacteristicValue(characteristic, readCcc);
2663```
2664
2665
2666### readCharacteristicValue<sup>(deprecated)</sup>
2667
2668readCharacteristicValue(characteristic: BLECharacteristic): Promise&lt;BLECharacteristic&gt;
2669
2670Reads the characteristic value of the specific service of the remote BLE device. This API uses a promise to return the result.
2671
2672> **NOTE**<br>
2673> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.readCharacteristicValue](js-apis-bluetoothManager.md#readcharacteristicvaluedeprecated-1) instead.
2674
2675**Required permissions**: ohos.permission.USE_BLUETOOTH
2676
2677**System capability**: SystemCapability.Communication.Bluetooth.Core
2678
2679**Parameters**
2680
2681| Name           | Type                                     | Mandatory  | Description      |
2682| -------------- | --------------------------------------- | ---- | -------- |
2683| characteristic | [BLECharacteristic](#blecharacteristicdeprecated) | Yes   | Characteristic value to read.|
2684
2685**Return value**
2686
2687| Type                                      | Description                        |
2688| ---------------------------------------- | -------------------------- |
2689| Promise&lt;[BLECharacteristic](#blecharacteristicdeprecated)&gt; | Promise used to return the characteristic value read.|
2690
2691**Example**
2692
2693```js
2694let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2695let descriptors : Array<bluetooth.BLEDescriptor> = [];
2696let bufferDesc = new ArrayBuffer(8);
2697let descV = new Uint8Array(bufferDesc);
2698descV[0] = 11;
2699let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2700characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2701descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
2702descriptors[0] = descriptor;
2703
2704let bufferCCC = new ArrayBuffer(8);
2705let cccV = new Uint8Array(bufferCCC);
2706cccV[0] = 1;
2707let characteristic : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2708characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2709characteristicValue: bufferCCC, descriptors:descriptors};
2710
2711device.readCharacteristicValue(characteristic);
2712```
2713
2714
2715### readDescriptorValue<sup>(deprecated)</sup>
2716
2717readDescriptorValue(descriptor: BLEDescriptor, callback: AsyncCallback&lt;BLEDescriptor&gt;): void
2718
2719Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses an asynchronous callback to return the result.
2720
2721> **NOTE**<br>
2722> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvaluedeprecated) instead.
2723
2724**Required permissions**: ohos.permission.USE_BLUETOOTH
2725
2726**System capability**: SystemCapability.Communication.Bluetooth.Core
2727
2728**Parameters**
2729
2730| Name       | Type                                      | Mandatory  | Description                     |
2731| ---------- | ---------------------------------------- | ---- | ----------------------- |
2732| descriptor | [BLEDescriptor](#bledescriptordeprecated)          | Yes   | Descriptor to read.               |
2733| callback   | AsyncCallback&lt;[BLEDescriptor](#bledescriptordeprecated)&gt; | Yes   | Callback used to return the descriptor read.|
2734
2735**Return value**
2736
2737No value is returned.
2738
2739**Example**
2740
2741```js
2742import { BusinessError } from '@ohos.base';
2743function readDesc(code : BusinessError, BLEDescriptor : bluetooth.BLEDescriptor) {
2744  if (code.code != 0) {
2745      return;
2746  }
2747  console.log('bluetooth descriptor uuid: ' + BLEDescriptor.descriptorUuid);
2748  let value = new Uint8Array(BLEDescriptor.descriptorValue);
2749  console.log('bluetooth descriptor value: ' + value[0] +','+ value[1]+','+ value[2]+','+ value[3]);
2750}
2751
2752let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2753let bufferDesc = new ArrayBuffer(8);
2754let descV = new Uint8Array(bufferDesc);
2755descV[0] = 11;
2756let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2757  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2758  descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
2759device.readDescriptorValue(descriptor, readDesc);
2760```
2761
2762
2763### readDescriptorValue<sup>(deprecated)</sup>
2764
2765readDescriptorValue(descriptor: BLEDescriptor): Promise&lt;BLEDescriptor&gt;
2766
2767Reads the descriptor contained in the specific characteristic of the remote BLE device. This API uses a promise to return the result.
2768
2769> **NOTE**<br>
2770> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.readDescriptorValue](js-apis-bluetoothManager.md#readdescriptorvaluedeprecated-1) instead.
2771
2772**Required permissions**: ohos.permission.USE_BLUETOOTH
2773
2774**System capability**: SystemCapability.Communication.Bluetooth.Core
2775
2776**Parameters**
2777
2778| Name       | Type                             | Mandatory  | Description      |
2779| ---------- | ------------------------------- | ---- | -------- |
2780| descriptor | [BLEDescriptor](#bledescriptordeprecated) | Yes   | Descriptor to read.|
2781
2782**Return value**
2783
2784| Type                                      | Description                        |
2785| ---------------------------------------- | -------------------------- |
2786| Promise&lt;[BLEDescriptor](#bledescriptordeprecated)&gt; | Promise used to return the descriptor read.|
2787
2788**Example**
2789
2790```js
2791let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2792let bufferDesc = new ArrayBuffer(8);
2793let descV = new Uint8Array(bufferDesc);
2794descV[0] = 11;
2795let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2796  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2797  descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
2798device.readDescriptorValue(descriptor);
2799```
2800
2801
2802### writeCharacteristicValue<sup>(deprecated)</sup>
2803
2804writeCharacteristicValue(characteristic: BLECharacteristic): boolean
2805
2806Writes a characteristic value to the remote BLE device.
2807
2808> **NOTE**<br>
2809> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.writeCharacteristicValue](js-apis-bluetoothManager.md#writecharacteristicvaluedeprecated) instead.
2810
2811**Required permissions**: ohos.permission.USE_BLUETOOTH
2812
2813**System capability**: SystemCapability.Communication.Bluetooth.Core
2814
2815**Parameters**
2816
2817| Name           | Type                                     | Mandatory  | Description                 |
2818| -------------- | --------------------------------------- | ---- | ------------------- |
2819| characteristic | [BLECharacteristic](#blecharacteristicdeprecated) | Yes   | Binary value and other parameters of the BLE device characteristic.|
2820
2821**Return value**
2822
2823| Type     | Description                         |
2824| ------- | --------------------------- |
2825| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2826
2827**Example**
2828
2829```js
2830let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2831let descriptors : Array<bluetooth.BLEDescriptor> = [];
2832let bufferDesc = new ArrayBuffer(8);
2833let descV = new Uint8Array(bufferDesc);
2834descV[0] = 11;
2835let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2836  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2837  descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
2838descriptors[0] = descriptor;
2839
2840let bufferCCC = new ArrayBuffer(8);
2841let cccV = new Uint8Array(bufferCCC);
2842cccV[0] = 1;
2843let characteristic : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2844  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2845  characteristicValue: bufferCCC, descriptors:descriptors};
2846let retWriteCcc : boolean = device.writeCharacteristicValue(characteristic);
2847if (retWriteCcc) {
2848  console.log('write characteristic successfully');
2849} else {
2850  console.log('write characteristic failed');
2851}
2852```
2853
2854
2855### writeDescriptorValue<sup>(deprecated)</sup>
2856
2857writeDescriptorValue(descriptor: BLEDescriptor): boolean
2858
2859Writes binary data to the specific descriptor of the remote BLE device.
2860
2861> **NOTE**<br>
2862> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.writeDescriptorValue](js-apis-bluetoothManager.md#writedescriptorvaluedeprecated) instead.
2863
2864**Required permissions**: ohos.permission.USE_BLUETOOTH
2865
2866**System capability**: SystemCapability.Communication.Bluetooth.Core
2867
2868**Parameters**
2869
2870| Name       | Type                             | Mandatory  | Description                |
2871| ---------- | ------------------------------- | ---- | ------------------ |
2872| descriptor | [BLEDescriptor](#bledescriptordeprecated) | Yes   | Binary value and other parameters of the BLE device descriptor.|
2873
2874**Return value**
2875
2876| Type     | Description                         |
2877| ------- | --------------------------- |
2878| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2879
2880**Example**
2881
2882```js
2883let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2884let bufferDesc = new ArrayBuffer(8);
2885let descV = new Uint8Array(bufferDesc);
2886descV[0] = 22;
2887let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2888  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2889  descriptorUuid: '00002903-0000-1000-8000-00805F9B34FB', descriptorValue: bufferDesc};
2890let retWriteDesc : boolean = device.writeDescriptorValue(descriptor);
2891if (retWriteDesc) {
2892  console.log('bluetooth write descriptor successfully');
2893} else {
2894  console.log('bluetooth write descriptor failed');
2895}
2896```
2897
2898
2899### setBLEMtuSize<sup>(deprecated)</sup>
2900
2901setBLEMtuSize(mtu: number): boolean
2902
2903Sets 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](#connectdeprecated).
2904
2905> **NOTE**<br>
2906> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.setBLEMtuSize](js-apis-bluetoothManager.md#setblemtusizedeprecated) instead.
2907
2908**Required permissions**: ohos.permission.USE_BLUETOOTH
2909
2910**System capability**: SystemCapability.Communication.Bluetooth.Core
2911
2912**Parameters**
2913
2914| Name | Type    | Mandatory  | Description            |
2915| ---- | ------ | ---- | -------------- |
2916| mtu  | number | Yes   | MTU to set, which ranges from 22 to 512 bytes.|
2917
2918**Return value**
2919
2920| Type     | Description                          |
2921| ------- | ---------------------------- |
2922| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2923
2924**Example**
2925
2926```js
2927let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2928device.setBLEMtuSize(128);
2929```
2930
2931
2932### setNotifyCharacteristicChanged<sup>(deprecated)</sup>
2933
2934setNotifyCharacteristicChanged(characteristic: BLECharacteristic, enable: boolean): boolean
2935
2936Sets the function of notifying the GATT client when the characteristic value of the remote BLE device changes.
2937
2938> **NOTE**<br>
2939> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.setNotifyCharacteristicChanged](js-apis-bluetoothManager.md#setnotifycharacteristicchangeddeprecated) instead.
2940
2941**Required permissions**: ohos.permission.USE_BLUETOOTH
2942
2943**System capability**: SystemCapability.Communication.Bluetooth.Core
2944
2945**Parameters**
2946
2947| Name           | Type                                     | Mandatory  | Description                           |
2948| -------------- | --------------------------------------- | ---- | ----------------------------- |
2949| characteristic | [BLECharacteristic](#blecharacteristicdeprecated) | Yes   | BLE characteristic to listen for.                     |
2950| 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.|
2951
2952**Return value**
2953
2954| Type     | Description                       |
2955| ------- | ------------------------- |
2956| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
2957
2958**Example**
2959
2960```js
2961// Create descriptors.
2962let descriptors : Array<bluetooth.BLEDescriptor> = [];
2963let arrayBuffer = new ArrayBuffer(8);
2964let descV = new Uint8Array(arrayBuffer);
2965descV[0] = 11;
2966let descriptor : bluetooth.BLEDescriptor = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2967  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB',
2968  descriptorUuid: '00002902-0000-1000-8000-00805F9B34FB', descriptorValue: arrayBuffer};
2969descriptors[0] = descriptor;
2970let arrayBufferC = new ArrayBuffer(8);
2971let characteristic : bluetooth.BLECharacteristic = {serviceUuid: '00001810-0000-1000-8000-00805F9B34FB',
2972  characteristicUuid: '00001820-0000-1000-8000-00805F9B34FB', characteristicValue: arrayBufferC, descriptors:descriptors};
2973let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
2974device.setNotifyCharacteristicChanged(characteristic, false);
2975```
2976
2977
2978### on('BLECharacteristicChange')<sup>(deprecated)</sup>
2979
2980on(type: 'BLECharacteristicChange', callback: Callback&lt;BLECharacteristic&gt;): void
2981
2982Subscribes to the BLE characteristic changes. The client can receive a notification from the server only after the **setNotifyCharacteristicChanged** method is called.
2983
2984> **NOTE**<br>
2985> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.on('BLECharacteristicChange')](js-apis-bluetoothManager.md#onblecharacteristicchangedeprecated) instead.
2986
2987**Required permissions**: ohos.permission.USE_BLUETOOTH
2988
2989**System capability**: SystemCapability.Communication.Bluetooth.Core
2990
2991**Parameters**
2992
2993| Name     | Type                                      | Mandatory  | Description                                      |
2994| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
2995| type     | string                                   | Yes   | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
2996| callback | Callback&lt;[BLECharacteristic](#blecharacteristicdeprecated)&gt; | Yes   | Callback used to return the characteristic value changes.                 |
2997
2998**Return value**
2999
3000No value is returned.
3001
3002**Example**
3003
3004```js
3005function CharacteristicChange(CharacteristicChangeReq : bluetooth.BLECharacteristic) {
3006  let serviceUuid : string = CharacteristicChangeReq.serviceUuid;
3007  let characteristicUuid : string = CharacteristicChangeReq.characteristicUuid;
3008  let value = new Uint8Array(CharacteristicChangeReq.characteristicValue);
3009}
3010let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3011device.on('BLECharacteristicChange', CharacteristicChange);
3012```
3013
3014
3015### off('BLECharacteristicChange')<sup>(deprecated)</sup>
3016
3017off(type: 'BLECharacteristicChange', callback?: Callback&lt;BLECharacteristic&gt;): void
3018
3019Unsubscribes from the BLE characteristic changes.
3020
3021> **NOTE**<br>
3022> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.off('BLECharacteristicChange')](js-apis-bluetoothManager.md#offblecharacteristicchangedeprecated) instead.
3023
3024**Required permissions**: ohos.permission.USE_BLUETOOTH
3025
3026**System capability**: SystemCapability.Communication.Bluetooth.Core
3027
3028**Parameters**
3029
3030| Name     | Type                                      | Mandatory  | Description                                      |
3031| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3032| type     | string                                   | Yes   | Event type. The value **BLECharacteristicChange** indicates a characteristic value change event.|
3033| callback | Callback&lt;[BLECharacteristic](#blecharacteristicdeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
3034
3035**Return value**
3036
3037No value is returned.
3038
3039**Example**
3040
3041```js
3042let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3043device.off('BLECharacteristicChange');
3044```
3045
3046
3047### on('BLEConnectionStateChange')<sup>(deprecated)</sup>
3048
3049on(type: 'BLEConnectionStateChange', callback: Callback&lt;BLEConnectChangedState&gt;): void
3050
3051Subscribes to the BLE connection state changes.
3052
3053> **NOTE**<br>
3054> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.on('BLEConnectionStateChange')](js-apis-bluetoothManager.md#onbleconnectionstatechangedeprecated) instead.
3055
3056**Required permissions**: ohos.permission.USE_BLUETOOTH
3057
3058**System capability**: SystemCapability.Communication.Bluetooth.Core
3059
3060**Parameters**
3061
3062| Name     | Type                                      | Mandatory  | Description                                      |
3063| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3064| type     | string                                   | Yes   | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
3065| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstatedeprecated)&gt; | Yes   | Callback used to return the BLE connection state.                          |
3066
3067**Return value**
3068
3069No value is returned.
3070
3071**Example**
3072
3073```js
3074function ConnectStateChanged(state : bluetooth.BLEConnectChangedState) {
3075  console.log('bluetooth connect state changed');
3076  let connectState : bluetooth.ProfileConnectionState = state.state;
3077}
3078let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3079device.on('BLEConnectionStateChange', ConnectStateChanged);
3080```
3081
3082
3083### off('BLEConnectionStateChange')<sup>(deprecated)</sup>
3084
3085off(type: 'BLEConnectionStateChange', callback?: Callback&lt;BLEConnectChangedState&gt;): void
3086
3087Unsubscribes from the BLE connection state changes.
3088
3089> **NOTE**<br>
3090> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.off('BLEConnectionStateChange')](js-apis-bluetoothManager.md#offbleconnectionstatechangedeprecated) instead.
3091
3092**Required permissions**: ohos.permission.USE_BLUETOOTH
3093
3094**System capability**: SystemCapability.Communication.Bluetooth.Core
3095
3096**Parameters**
3097
3098| Name     | Type                                      | Mandatory  | Description                                      |
3099| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
3100| type     | string                                   | Yes   | Event type. The value **BLEConnectionStateChange** indicates a BLE connection state change event.|
3101| callback | Callback&lt;[BLEConnectChangedState](#bleconnectchangedstatedeprecated)&gt; | No   | Callback to unregister. If this parameter is not set, this API unregisters all callbacks for **type**.|
3102
3103**Return value**
3104
3105No value is returned.
3106
3107**Example**
3108
3109```js
3110let device : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice('XX:XX:XX:XX:XX:XX');
3111device.off('BLEConnectionStateChange');
3112```
3113
3114
3115### getDeviceName<sup>(deprecated)</sup>
3116
3117getDeviceName(callback: AsyncCallback&lt;string&gt;): void
3118
3119Obtains the name of the remote BLE device. This API uses an asynchronous callback to return the result.
3120
3121> **NOTE**<br>
3122> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicenamedeprecated) instead.
3123
3124**Required permissions**: ohos.permission.USE_BLUETOOTH
3125
3126**System capability**: SystemCapability.Communication.Bluetooth.Core
3127
3128**Parameters**
3129
3130| Name     | Type                         | Mandatory  | Description                             |
3131| -------- | --------------------------- | ---- | ------------------------------- |
3132| callback | AsyncCallback&lt;string&gt; | Yes   | Callback used to return the remote BLE device name obtained.|
3133
3134**Return value**
3135
3136No value is returned.
3137
3138**Example**
3139
3140```js
3141import { BusinessError } from '@ohos.base';
3142// callback
3143let gattClient : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
3144let deviceName : void = gattClient.getDeviceName((err : BusinessError, data : string)=> {
3145    console.info('device name err ' + JSON.stringify(err));
3146    console.info('device name' + JSON.stringify(data));
3147})
3148```
3149
3150
3151### getDeviceName<sup>(deprecated)</sup>
3152
3153getDeviceName(): Promise&lt;string&gt;
3154
3155Obtains the name of the remote BLE device. This API uses a promise to return the result.
3156
3157> **NOTE**<br>
3158> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.getDeviceName](js-apis-bluetoothManager.md#getdevicenamedeprecated-1) instead.
3159
3160**Required permissions**: ohos.permission.USE_BLUETOOTH
3161
3162**System capability**: SystemCapability.Communication.Bluetooth.Core
3163
3164**Return value**
3165
3166| Type                   | Description                                |
3167| --------------------- | ---------------------------------- |
3168| Promise&lt;string&gt; | Promise used to return the remote BLE device name.|
3169
3170**Example**
3171
3172```js
3173// promise
3174let gattClient : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
3175gattClient.getDeviceName().then((data) => {
3176    console.info('device name' + JSON.stringify(data));
3177})
3178```
3179
3180
3181### getRssiValue<sup>(deprecated)</sup>
3182
3183getRssiValue(callback: AsyncCallback&lt;number&gt;): void
3184
3185Obtains 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](#connectdeprecated).
3186
3187> **NOTE**<br>
3188> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivaluedeprecated) instead.
3189
3190**Required permissions**: ohos.permission.USE_BLUETOOTH
3191
3192**System capability**: SystemCapability.Communication.Bluetooth.Core
3193
3194**Parameters**
3195
3196| Name     | Type                         | Mandatory  | Description                            |
3197| -------- | --------------------------- | ---- | ------------------------------ |
3198| callback | AsyncCallback&lt;number&gt; | Yes   | Callback used to return the RSSI, in dBm.|
3199
3200**Return value**
3201
3202No value is returned.
3203
3204**Example**
3205
3206```js
3207import { BusinessError } from '@ohos.base';
3208// callback
3209let gattClient : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
3210let ret : boolean = gattClient.connect();
3211gattClient.getRssiValue((err : BusinessError, data : number)=> {
3212    console.info('rssi err ' + JSON.stringify(err));
3213    console.info('rssi value' + JSON.stringify(data));
3214})
3215```
3216
3217
3218### getRssiValue<sup>(deprecated)</sup>
3219
3220getRssiValue(): Promise&lt;number&gt;
3221
3222Obtains 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](#connectdeprecated).
3223
3224> **NOTE**<br>
3225> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattClientDevice.getRssiValue](js-apis-bluetoothManager.md#getrssivaluedeprecated-1) instead.
3226
3227**Required permissions**: ohos.permission.USE_BLUETOOTH
3228
3229**System capability**: SystemCapability.Communication.Bluetooth.Core
3230
3231**Return value**
3232
3233| Type                   | Description                               |
3234| --------------------- | --------------------------------- |
3235| Promise&lt;number&gt; | Promise used to return the RSSI, in dBm.|
3236
3237**Example**
3238
3239```js
3240// promise
3241let gattClient : bluetooth.GattClientDevice = bluetooth.BLE.createGattClientDevice("XX:XX:XX:XX:XX:XX");
3242gattClient.getRssiValue().then((data : number) => {
3243    console.info('rssi' + JSON.stringify(data));
3244})
3245```
3246
3247## ScanMode<sup>(deprecated)</sup>
3248
3249Enumerates the scan modes.
3250
3251> **NOTE**<br>
3252> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.ScanMode](js-apis-bluetoothManager.md#scanmodedeprecated) instead.
3253
3254**System capability**: SystemCapability.Communication.Bluetooth.Core
3255
3256| Name                                      | Value | Description             |
3257| ---------------------------------------- | ---- | --------------- |
3258| SCAN_MODE_NONE                           | 0    | No scan mode.        |
3259| SCAN_MODE_CONNECTABLE                    | 1    | Connectable mode.       |
3260| SCAN_MODE_GENERAL_DISCOVERABLE           | 2    | General discoverable mode.   |
3261| SCAN_MODE_LIMITED_DISCOVERABLE           | 3    | Limited discoverable mode.   |
3262| SCAN_MODE_CONNECTABLE_GENERAL_DISCOVERABLE | 4    | General connectable and discoverable mode.|
3263| SCAN_MODE_CONNECTABLE_LIMITED_DISCOVERABLE | 5    | Limited connectable and discoverable mode.|
3264
3265## BondState<sup>(deprecated)</sup>
3266
3267Enumerates the pairing states.
3268
3269> **NOTE**<br>
3270> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.BondState](js-apis-bluetoothManager.md#bondstatedeprecated) instead.
3271
3272**System capability**: SystemCapability.Communication.Bluetooth.Core
3273
3274| Name                | Value | Description    |
3275| ------------------ | ---- | ------ |
3276| BOND_STATE_INVALID | 0    | Invalid pairing.|
3277| BOND_STATE_BONDING | 1    | Pairing. |
3278| BOND_STATE_BONDED  | 2    | Paired.  |
3279
3280
3281## SppOption<sup>(deprecated)</sup>
3282
3283Defines the SPP configuration parameters.
3284
3285> **NOTE**<br>
3286> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.SppOption](js-apis-bluetoothManager.md#sppoptiondeprecated) instead.
3287
3288**System capability**: SystemCapability.Communication.Bluetooth.Core
3289
3290| Name    | Type               | Readable  | Writable  | Description         |
3291| ------ | ------------------- | ---- | ---- | ----------- |
3292| uuid   | string              | Yes   | Yes   | UUID of the SPP.|
3293| secure | boolean             | Yes   | Yes   | Whether it is a secure channel.   |
3294| type   | [SppType](#spptypedeprecated) | Yes   | Yes   | Type of the SPP link.   |
3295
3296
3297## SppType<sup>(deprecated)</sup>
3298
3299Enumerates the SPP link types.
3300
3301> **NOTE**<br>
3302> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.SppType](js-apis-bluetoothManager.md#spptypedeprecated) instead.
3303
3304**System capability**: SystemCapability.Communication.Bluetooth.Core
3305
3306| Name        | Value | Description           |
3307| ---------- | ---- | ------------- |
3308| SPP_RFCOMM | 0    | Radio frequency communication (RFCOMM) link type.|
3309
3310
3311## GattService<sup>(deprecated)</sup>
3312
3313Defines the GATT service API parameters.
3314
3315> **NOTE**<br>
3316> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.GattService](js-apis-bluetoothManager.md#gattservice) instead.
3317
3318**System capability**: SystemCapability.Communication.Bluetooth.Core
3319
3320| Name             | Type                                    | Readable  | Writable  | Description                                      |
3321| --------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
3322| serviceUuid     | string                                   | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3323| isPrimary       | boolean                                  | Yes   | Yes   | Whether the service is a primary service. The value **true** means a primary service.               |
3324| characteristics | Array&lt;[BLECharacteristic](#blecharacteristicdeprecated)&gt; | Yes   | Yes   | List of characteristics of the service.                            |
3325| includeServices | Array&lt;[GattService](#gattservicedeprecated)&gt; | Yes   | Yes   | Services on which the service depends.                            |
3326
3327
3328## BLECharacteristic<sup>(deprecated)</sup>
3329
3330Defines the characteristic API parameters.
3331
3332> **NOTE**<br>
3333> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLECharacteristic](js-apis-bluetoothManager.md#blecharacteristicdeprecated) instead.
3334
3335**System capability**: SystemCapability.Communication.Bluetooth.Core
3336
3337| Name                 | Type                                    | Readable  | Writable  | Description                                      |
3338| ------------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
3339| serviceUuid         | string                                   | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3340| characteristicUuid  | string                                   | Yes   | Yes   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3341| characteristicValue | ArrayBuffer                              | Yes   | Yes   | Binary value of the characteristic.                              |
3342| descriptors         | Array&lt;[BLEDescriptor](#bledescriptordeprecated)&gt; | Yes   | Yes   | List of descriptors of the characteristic.                             |
3343
3344
3345## BLEDescriptor<sup>(deprecated)</sup>
3346
3347Defines the descriptor API parameters.
3348
3349> **NOTE**<br>
3350> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLEDescriptor](js-apis-bluetoothManager.md#bledescriptordeprecated) instead.
3351
3352**System capability**: SystemCapability.Communication.Bluetooth.Core
3353
3354| Name                | Type       | Readable  | Writable  | Description                                      |
3355| ------------------ | ----------- | ---- | ---- | ---------------------------------------- |
3356| serviceUuid        | string      | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3357| characteristicUuid | string      | Yes   | Yes   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3358| descriptorUuid     | string      | Yes   | Yes   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
3359| descriptorValue    | ArrayBuffer | Yes   | Yes   | Binary value of the descriptor.                             |
3360
3361
3362## NotifyCharacteristic<sup>(deprecated)</sup>
3363
3364Defines the parameters in the notifications sent when the server characteristic value changes.
3365
3366> **NOTE**<br>
3367> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.NotifyCharacteristic](js-apis-bluetoothManager.md#notifycharacteristicdeprecated) instead.
3368
3369**System capability**: SystemCapability.Communication.Bluetooth.Core
3370
3371| Name                 | Type       | Readable  | Writable  | Description                                      |
3372| ------------------- | ----------- | ---- | ---- | ---------------------------------------- |
3373| serviceUuid         | string      | Yes   | Yes   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3374| characteristicUuid  | string      | Yes   | Yes   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3375| characteristicValue | ArrayBuffer | Yes   | Yes   | Binary value of the characteristic.                              |
3376| 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.|
3377
3378
3379## CharacteristicReadReq<sup>(deprecated)</sup>
3380
3381Defines the parameters of the **CharacteristicReadReq** event received by the server.
3382
3383> **NOTE**<br>
3384> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.CharacteristicReadRequest](js-apis-bluetoothManager.md#characteristicreadrequestdeprecated) instead.
3385
3386**System capability**: SystemCapability.Communication.Bluetooth.Core
3387
3388| Name                | Type  | Readable  | Writable  | Description                                      |
3389| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
3390| deviceId           | string | Yes   | No   | Address of the remote device that sends the **CharacteristicReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
3391| transId            | number | Yes   | No   | Transmission ID of the read request. The response returned by the server must use the same transmission ID.      |
3392| 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.|
3393| characteristicUuid | string | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3394| serviceUuid        | string | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3395
3396
3397## CharacteristicWriteReq<sup>(deprecated)</sup>
3398
3399Defines the parameters of the **CharacteristicWriteReq** event received by the server.
3400
3401> **NOTE**<br>
3402> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.CharacteristicWriteRequest](js-apis-bluetoothManager.md#characteristicwriterequestdeprecated) instead.
3403
3404**System capability**: SystemCapability.Communication.Bluetooth.Core
3405
3406| Name                | Type  | Readable  | Writable  | Description                                      |
3407| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
3408| deviceId           | string | Yes   | No   | Address of the remote device that sends the **CharacteristicWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
3409| transId            | number | Yes   | No   | Transmission ID of the write request. The response returned by the server must use the same transmission ID.      |
3410| 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.|
3411| characteristicUuid | string | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3412| serviceUuid        | string | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3413
3414
3415## DescriptorReadReq<sup>(deprecated)</sup>
3416
3417Defines the parameters of the **DescriptorReadReq** event received by the server.
3418
3419> **NOTE**<br>
3420> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.DescriptorReadRequest](js-apis-bluetoothManager.md#descriptorreadrequestdeprecated) instead.
3421
3422**System capability**: SystemCapability.Communication.Bluetooth.Core
3423
3424| Name                | Type  | Readable  | Writable  | Description                                      |
3425| ------------------ | ------ | ---- | ---- | ---------------------------------------- |
3426| deviceId           | string | Yes   | No   | Address of the remote device that sends a **DescriptorReadReq** event, for example, XX:XX:XX:XX:XX:XX.|
3427| transId            | number | Yes   | No   | Transmission ID of the read request. The response returned by the server must use the same transmission ID.      |
3428| 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.|
3429| descriptorUuid     | string | Yes   | No   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
3430| characteristicUuid | string | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3431| serviceUuid        | string | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3432
3433
3434## DescriptorWriteReq<sup>(deprecated)</sup>
3435
3436Defines the parameters of the **DescriptorWriteReq** event received by the server.
3437
3438> **NOTE**<br>
3439> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.DescriptorWriteRequest](js-apis-bluetoothManager.md#descriptorwriterequestdeprecated) instead.
3440
3441**System capability**: SystemCapability.Communication.Bluetooth.Core
3442
3443| Name                | Type       | Readable  | Writable  | Description                                      |
3444| ------------------ | ----------- | ---- | ---- | ---------------------------------------- |
3445| deviceId           | string      | Yes   | No   | Address of the remote device that sends a **DescriptorWriteReq** event, for example, XX:XX:XX:XX:XX:XX.|
3446| transId            | number      | Yes   | No   | Transmission ID of the write request. The response returned by the server must use the same transmission ID.      |
3447| 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.|
3448| isPrep             | boolean     | Yes   | No   | Whether the write request is executed immediately.                            |
3449| needRsp            | boolean     | Yes   | No   | Whether to send a response to the GATT client.                      |
3450| value              | ArrayBuffer | Yes   | No   | Binary value of the descriptor to write.                          |
3451| descriptorUuid     | string      | Yes   | No   | UUID of the descriptor, for example, **00002902-0000-1000-8000-00805f9b34fb**.|
3452| characteristicUuid | string      | Yes   | No   | UUID of the characteristic, for example, **00002a11-0000-1000-8000-00805f9b34fb**.|
3453| serviceUuid        | string      | Yes   | No   | UUID of the service, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3454
3455
3456## ServerResponse<sup>(deprecated)</sup>
3457
3458Defines the parameters of the server's response to the GATT client's read/write request.
3459
3460> **NOTE**<br>
3461> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ServerResponse](js-apis-bluetoothManager.md#serverresponsedeprecated) instead.
3462
3463**System capability**: SystemCapability.Communication.Bluetooth.Core
3464
3465| Name      | Type       | Readable  | Writable  | Description                                    |
3466| -------- | ----------- | ---- | ---- | -------------------------------------- |
3467| deviceId | string      | Yes   | No   | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.      |
3468| 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.       |
3469| status   | number      | Yes   | No   | Response state. Set this parameter to **0**, which indicates a normal response.                  |
3470| offset   | number      | Yes   | No   | Start read/write position. The value must be the same as the offset carried in the read/write request.|
3471| value    | ArrayBuffer | Yes   | No   | Binary data in the response.                         |
3472
3473
3474## BLEConnectChangedState<sup>(deprecated)</sup>
3475
3476Defines the parameters of **BLEConnectChangedState**.
3477
3478> **NOTE**<br>
3479> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BLEConnectChangedState](js-apis-bluetoothManager.md#bleconnectchangedstatedeprecated) instead.
3480
3481**System capability**: SystemCapability.Communication.Bluetooth.Core
3482
3483| Name    | Type                                         | Readable| Writable| Description                                         |
3484| -------- | ------------------------------------------------- | ---- | ---- | --------------------------------------------- |
3485| deviceId | string                                            | Yes  | No  | Address of the remote device, for example, XX:XX:XX:XX:XX:XX.|
3486| state    | [ProfileConnectionState](#profileconnectionstatedeprecated) | Yes  | Yes  | BLE connection state.                      |
3487
3488
3489## ProfileConnectionState<sup>(deprecated)</sup>
3490
3491Enumerates the profile connection states.
3492
3493> **NOTE**<br>
3494> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ProfileConnectionState](js-apis-bluetoothManager.md#profileconnectionstatedeprecated) instead.
3495
3496**System capability**: SystemCapability.Communication.Bluetooth.Core
3497
3498| Name                 | Value | Description            |
3499| ------------------- | ---- | -------------- |
3500| STATE_DISCONNECTED  | 0    | Disconnected. |
3501| STATE_CONNECTING    | 1    | Connecting.|
3502| STATE_CONNECTED     | 2    | Connected. |
3503| STATE_DISCONNECTING | 3    | Disconnecting.|
3504
3505
3506## ScanFilter<sup>(deprecated)</sup>
3507
3508Defines the scan filter parameters.
3509
3510> **NOTE**<br>
3511> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ScanFilter](js-apis-bluetoothManager.md#scanfilterdeprecated) instead.
3512
3513**System capability**: SystemCapability.Communication.Bluetooth.Core
3514
3515| Name                                    | Type   | Readable| Writable| Description                                                        |
3516| ---------------------------------------- | ----------- | ---- | ---- | ------------------------------------------------------------ |
3517| deviceId                                 | string      | Yes  | Yes  | Address of the BLE device to filter, for example, XX:XX:XX:XX:XX:XX.          |
3518| name                                     | string      | Yes  | Yes  | Name of the BLE device to filter.                                       |
3519| serviceUuid                              | string      | Yes  | Yes  | Service UUID of the device to filter, for example, **00001888-0000-1000-8000-00805f9b34fb**.|
3520
3521
3522## ScanOptions<sup>(deprecated)</sup>
3523
3524Defines the scan configuration parameters.
3525
3526> **NOTE**<br>
3527> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ScanOptions](js-apis-bluetoothManager.md#scanoptionsdeprecated) instead.
3528
3529**System capability**: SystemCapability.Communication.Bluetooth.Core
3530
3531| Name       | Type                   | Readable  | Writable  | Description                                    |
3532| --------- | ----------------------- | ---- | ---- | -------------------------------------- |
3533| interval  | number                  | Yes   | Yes   | Delay in reporting the scan result. The default value is **0**.                   |
3534| dutyMode  | [ScanDuty](#scandutydeprecated)   | Yes   | Yes   | Scan duty. The default value is SCAN_MODE_LOW_POWER.       |
3535| matchMode | [MatchMode](#matchmodedeprecated) | Yes   | Yes   | Hardware filtering match mode. The default value is **MATCH_MODE_AGGRESSIVE**.|
3536
3537
3538## ScanDuty<sup>(deprecated)</sup>
3539
3540Enumerates the scan duty options.
3541
3542> **NOTE**<br>
3543> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ScanDuty](js-apis-bluetoothManager.md#scandutydeprecated) instead.
3544
3545**System capability**: SystemCapability.Communication.Bluetooth.Core
3546
3547| Name                   | Value | Description          |
3548| --------------------- | ---- | ------------ |
3549| SCAN_MODE_LOW_POWER   | 0    | Low-power mode, which is the default value.|
3550| SCAN_MODE_BALANCED    | 1    | Balanced mode.     |
3551| SCAN_MODE_LOW_LATENCY | 2    | Low-latency mode.    |
3552
3553
3554## MatchMode<sup>(deprecated)</sup>
3555
3556Enumerates the hardware match modes of BLE scan filters.
3557
3558> **NOTE**<br>
3559> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.MatchMode](js-apis-bluetoothManager.md#matchmodedeprecated) instead.
3560
3561**System capability**: SystemCapability.Communication.Bluetooth.Core
3562
3563| Name                   | Value | Description                                      |
3564| --------------------- | ---- | ---------------------------------------- |
3565| 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.|
3566| MATCH_MODE_STICKY     | 2    | Hardware reports the scan result with a higher threshold of signal strength and sightings.      |
3567
3568
3569## ScanResult<sup>(deprecated)</sup>
3570
3571Defines the scan result.
3572
3573> **NOTE**<br>
3574> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ScanResult](js-apis-bluetoothManager.md#scanresultdeprecated) instead.
3575
3576**System capability**: SystemCapability.Communication.Bluetooth.Core
3577
3578| Name      | Type       | Readable  | Writable  | Description                                |
3579| -------- | ----------- | ---- | ---- | ---------------------------------- |
3580| deviceId | string      | Yes   | No   | Address of the scanned device, for example, XX:XX:XX:XX:XX:XX.|
3581| rssi     | number      | Yes   | No   | RSSI of the device.                   |
3582| data     | ArrayBuffer | Yes   | No   | Advertisement packets sent by the device.                   |
3583
3584
3585## BluetoothState<sup>(deprecated)</sup>
3586
3587Enumerates the Bluetooth states.
3588
3589> **NOTE**<br>
3590> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.BluetoothState](js-apis-bluetoothManager.md#bluetoothstatedeprecated) instead.
3591
3592**System capability**: SystemCapability.Communication.Bluetooth.Core
3593
3594| Name                   | Value | Description                |
3595| --------------------- | ---- | ------------------ |
3596| STATE_OFF             | 0    | Bluetooth is turned off.          |
3597| STATE_TURNING_ON      | 1    | Bluetooth is being turned on.         |
3598| STATE_ON              | 2    | Bluetooth is turned on.          |
3599| STATE_TURNING_OFF     | 3    | Bluetooth is being turned off.         |
3600| STATE_BLE_TURNING_ON  | 4    | The LE-only mode is being turned on for Bluetooth.|
3601| STATE_BLE_ON          | 5    | Bluetooth is in LE-only mode. |
3602| STATE_BLE_TURNING_OFF | 6    | The LE-only mode is being turned off for Bluetooth.|
3603
3604
3605## AdvertiseSetting<sup>(deprecated)</sup>
3606
3607Defines the BLE advertising parameters.
3608
3609> **NOTE**<br>
3610> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.AdvertiseSetting](js-apis-bluetoothManager.md#advertisesettingdeprecated) instead.
3611
3612**System capability**: SystemCapability.Communication.Bluetooth.Core
3613
3614| Name         | Type   | Readable  | Writable  | Description                                      |
3615| ----------- | ------- | ---- | ---- | ---------------------------------------- |
3616| 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).|
3617| txPower     | number  | Yes   | Yes   | Transmit power, in dBm. The value range is -127 to 1. The default value is **-7**.  |
3618| connectable | boolean | Yes   | Yes   | Whether the advertisement is connectable. The default value is **true**.                  |
3619
3620
3621## AdvertiseData<sup>(deprecated)</sup>
3622
3623Defines the content of a BLE advertisement packet.
3624
3625> **NOTE**<br>
3626> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.AdvertiseData](js-apis-bluetoothManager.md#advertisedatadeprecated) instead.
3627
3628**System capability**: SystemCapability.Communication.Bluetooth.Core
3629
3630| Name             | Type                                    | Readable  | Writable  | Description                         |
3631| --------------- | ---------------------------------------- | ---- | ---- | --------------------------- |
3632| serviceUuids    | Array&lt;string&gt;                      | Yes   | Yes   | List of service UUIDs to broadcast.|
3633| manufactureData | Array&lt;[ManufactureData](#manufacturedatadeprecated)&gt; | Yes   | Yes   | List of manufacturers to broadcast.          |
3634| serviceData     | Array&lt;[ServiceData](#servicedatadeprecated)&gt; | Yes   | Yes   | List of service data to broadcast.              |
3635
3636
3637## ManufactureData<sup>(deprecated)</sup>
3638
3639Defines the content of a BLE advertisement packet.
3640
3641> **NOTE**<br>
3642> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ManufactureData](js-apis-bluetoothManager.md#manufacturedatadeprecated) instead.
3643
3644**System capability**: SystemCapability.Communication.Bluetooth.Core
3645
3646| Name              | Type               | Readable  | Writable  | Description                |
3647| ---------------- | ------------------- | ---- | ---- | ------------------ |
3648| manufactureId    | number  | Yes   | Yes   | Manufacturer ID allocated by the Bluetooth SIG.|
3649| manufactureValue | ArrayBuffer         | Yes   | Yes   | Manufacturer data.    |
3650
3651
3652## ServiceData<sup>(deprecated)</sup>
3653
3654Defines the service data contained in an advertisement packet.
3655
3656> **NOTE**<br>
3657> This API is supported since API version 7 and deprecated since API version 9. Use [bluetoothManager.ServiceData](js-apis-bluetoothManager.md#servicedatadeprecated) instead.
3658
3659**System capability**: SystemCapability.Communication.Bluetooth.Core
3660
3661| Name          | Type       | Readable  | Writable  | Description        |
3662| ------------ | ----------- | ---- | ---- | ---------- |
3663| serviceUuid  | string      | Yes   | Yes   | Service UUID.|
3664| serviceValue | ArrayBuffer | Yes   | Yes   | Service data.   |
3665
3666
3667## PinRequiredParam<sup>(deprecated)</sup>
3668
3669Defines the pairing request parameters.
3670
3671> **NOTE**<br>
3672> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.PinRequiredParam](js-apis-bluetoothManager.md#pinrequiredparamdeprecated) instead.
3673
3674**System capability**: SystemCapability.Communication.Bluetooth.Core
3675
3676| Name      | Type  | Readable  | Writable  | Description         |
3677| -------- | ------ | ---- | ---- | ----------- |
3678| deviceId | string | Yes   | No   | ID of the device to pair.|
3679| pinCode  | string | Yes   | No   | Key for the device pairing.  |
3680
3681
3682## BondStateParam<sup>(deprecated)</sup>
3683
3684Defines the pairing state parameters.
3685
3686> **NOTE**<br>
3687> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.BondStateParam](js-apis-bluetoothManager.md#bondstateparamdeprecated) instead.
3688
3689**System capability**: SystemCapability.Communication.Bluetooth.Core
3690
3691| Name      | Type  | Readable  | Writable  | Description         |
3692| -------- | ------ | ---- | ---- | ----------- |
3693| deviceId | string      | Yes   | No   | ID of the device to pair.|
3694| state    | BondState   | Yes   | No   | State of the device.|
3695
3696
3697## StateChangeParam<sup>(deprecated)</sup>
3698
3699Defines the profile state change parameters.
3700
3701> **NOTE**<br>
3702> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.StateChangeParam](js-apis-bluetoothManager.md#statechangeparam) instead.
3703
3704**System capability**: SystemCapability.Communication.Bluetooth.Core
3705
3706| Name    | Type                                         | Readable| Writable| Description                           |
3707| -------- | ------------------------------------------------- | ---- | ---- | ------------------------------- |
3708| deviceId | string                                            | Yes  | No  | Address of a Bluetooth device.             |
3709| state    | [ProfileConnectionState](#profileconnectionstatedeprecated) | Yes  | No  | Profile connection state of the device.|
3710
3711
3712## DeviceClass<sup>(deprecated)</sup>
3713
3714Defines the class of a Bluetooth device.
3715
3716> **NOTE**<br>
3717> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.DeviceClass](js-apis-bluetoothManager.md#deviceclassdeprecated) instead.
3718
3719**System capability**: SystemCapability.Communication.Bluetooth.Core
3720
3721| Name             | Type                               | Readable  | Writable  | Description              |
3722| --------------- | ----------------------------------- | ---- | ---- | ---------------- |
3723| majorClass      | [MajorClass](#majorclassdeprecated)           | Yes   | No   | Major classes of Bluetooth devices.  |
3724| majorMinorClass | [MajorMinorClass](#majorminorclassdeprecated) | Yes   | No   | Major and minor classes of Bluetooth devices.|
3725| classOfDevice   | number                              | Yes   | No   | Class of the device.         |
3726
3727
3728
3729## MajorClass<sup>(deprecated)</sup>
3730
3731Enumerates the major classes of Bluetooth devices.
3732
3733> **NOTE**<br>
3734> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.MajorClass](js-apis-bluetoothManager.md#majorclassdeprecated) instead.
3735
3736**System capability**: SystemCapability.Communication.Bluetooth.Core
3737
3738| Name                 | Value   | Description        |
3739| ------------------- | ------ | ---------- |
3740| MAJOR_MISC          | 0x0000 | Miscellaneous device.   |
3741| MAJOR_COMPUTER      | 0x0100 | Computer.  |
3742| MAJOR_PHONE         | 0x0200 | Mobile phone.   |
3743| MAJOR_NETWORKING    | 0x0300 | Network device.   |
3744| MAJOR_AUDIO_VIDEO   | 0x0400 | Audio or video device.|
3745| MAJOR_PERIPHERAL    | 0x0500 | Peripheral device.   |
3746| MAJOR_IMAGING       | 0x0600 | Imaging device.   |
3747| MAJOR_WEARABLE      | 0x0700 | Wearable device.  |
3748| MAJOR_TOY           | 0x0800 | Toy.   |
3749| MAJOR_HEALTH        | 0x0900 | Health device.   |
3750| MAJOR_UNCATEGORIZED | 0x1F00 | Unclassified device.  |
3751
3752
3753## MajorMinorClass<sup>(deprecated)</sup>
3754
3755Enumerates the major and minor classes of Bluetooth devices.
3756
3757> **NOTE**<br>
3758> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.MajorMinorClass](js-apis-bluetoothManager.md#majorminorclassdeprecated) instead.
3759
3760**System capability**: SystemCapability.Communication.Bluetooth.Core
3761
3762| Name                                      | Value   | Description             |
3763| ---------------------------------------- | ------ | --------------- |
3764| COMPUTER_UNCATEGORIZED                   | 0x0100 | Unclassified computer.    |
3765| COMPUTER_DESKTOP                         | 0x0104 | Desktop computer.     |
3766| COMPUTER_SERVER                          | 0x0108 | Server.       |
3767| COMPUTER_LAPTOP                          | 0x010C | Laptop.    |
3768| COMPUTER_HANDHELD_PC_PDA                 | 0x0110 | Hand-held computer.    |
3769| COMPUTER_PALM_SIZE_PC_PDA                | 0x0114 | Palmtop computer.      |
3770| COMPUTER_WEARABLE                        | 0x0118 | Wearable computer.    |
3771| COMPUTER_TABLET                          | 0x011C | Tablet.      |
3772| PHONE_UNCATEGORIZED                      | 0x0200 | Unclassified mobile phone.     |
3773| PHONE_CELLULAR                           | 0x0204 | Portable phone.     |
3774| PHONE_CORDLESS                           | 0x0208 | Cordless phone.      |
3775| PHONE_SMART                              | 0x020C | Smartphone.      |
3776| PHONE_MODEM_OR_GATEWAY                   | 0x0210 | Modem or gateway phone.|
3777| PHONE_ISDN                               | 0x0214 | ISDN phone.    |
3778| NETWORK_FULLY_AVAILABLE                  | 0x0300 | Device with network fully available.    |
3779| NETWORK_1_TO_17_UTILIZED                 | 0x0320 | Device used on network 1 to 17.  |
3780| NETWORK_17_TO_33_UTILIZED                | 0x0340 | Device used on network 17 to 33. |
3781| NETWORK_33_TO_50_UTILIZED                | 0x0360 | Device used on network 33 to 50. |
3782| NETWORK_60_TO_67_UTILIZED                | 0x0380 | Device used on network 60 to 67. |
3783| NETWORK_67_TO_83_UTILIZED                | 0x03A0 | Device used on network 67 to 83. |
3784| NETWORK_83_TO_99_UTILIZED                | 0x03C0 | Device used on network 83 to 99. |
3785| NETWORK_NO_SERVICE                       | 0x03E0 | Device without network service     |
3786| AUDIO_VIDEO_UNCATEGORIZED                | 0x0400 | Unclassified audio or video device.   |
3787| AUDIO_VIDEO_WEARABLE_HEADSET             | 0x0404 | Wearable audio or video headset.  |
3788| AUDIO_VIDEO_HANDSFREE                    | 0x0408 | Hands-free audio or video device.    |
3789| AUDIO_VIDEO_MICROPHONE                   | 0x0410 | Audio or video microphone.   |
3790| AUDIO_VIDEO_LOUDSPEAKER                  | 0x0414 | Audio or video loudspeaker.   |
3791| AUDIO_VIDEO_HEADPHONES                   | 0x0418 | Audio or video headphones.   |
3792| AUDIO_VIDEO_PORTABLE_AUDIO               | 0x041C | Portable audio or video device.   |
3793| AUDIO_VIDEO_CAR_AUDIO                    | 0x0420 | In-vehicle audio or video device.    |
3794| AUDIO_VIDEO_SET_TOP_BOX                  | 0x0424 | Audio or video STB device.   |
3795| AUDIO_VIDEO_HIFI_AUDIO                   | 0x0428 | High-fidelity speaker device.     |
3796| AUDIO_VIDEO_VCR                          | 0x042C | Video cassette recording (VCR) device.   |
3797| AUDIO_VIDEO_VIDEO_CAMERA                 | 0x0430 | Camera.   |
3798| AUDIO_VIDEO_CAMCORDER                    | 0x0434 | Camcorder   |
3799| AUDIO_VIDEO_VIDEO_MONITOR                | 0x0438 | Audio or video monitor.   |
3800| AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER | 0x043C | Video display or loudspeaker. |
3801| AUDIO_VIDEO_VIDEO_CONFERENCING           | 0x0440 | Video conferencing device.    |
3802| AUDIO_VIDEO_VIDEO_GAMING_TOY             | 0x0448 | Audio or video gaming toy.  |
3803| PERIPHERAL_NON_KEYBOARD_NON_POINTING     | 0x0500 | Non-keyboard or non-pointing peripheral device.  |
3804| PERIPHERAL_KEYBOARD                      | 0x0540 | Keyboard device.      |
3805| PERIPHERAL_POINTING_DEVICE               | 0x0580 | Pointing peripheral device.    |
3806| PERIPHERAL_KEYBOARD_POINTING             | 0x05C0 | Keyboard pointing device.    |
3807| PERIPHERAL_UNCATEGORIZED                 | 0x0500 | Unclassified peripheral device.     |
3808| PERIPHERAL_JOYSTICK                      | 0x0504 | Peripheral joystick.     |
3809| PERIPHERAL_GAMEPAD                       | 0x0508 | Peripheral game pad     |
3810| PERIPHERAL_REMOTE_CONTROL                | 0x05C0 | Peripheral remote control device    |
3811| PERIPHERAL_SENSING_DEVICE                | 0x0510 | Peripheral sensing device.    |
3812| PERIPHERAL_DIGITIZER_TABLET              | 0x0514 | Peripheral digitizer tablet.|
3813| PERIPHERAL_CARD_READER                   | 0x0518 | Peripheral card reader.     |
3814| PERIPHERAL_DIGITAL_PEN                   | 0x051C | Peripheral digital pen.     |
3815| PERIPHERAL_SCANNER_RFID                  | 0x0520 | Peripheral RFID scanner. |
3816| PERIPHERAL_GESTURAL_INPUT                | 0x0522 | Gesture input device.    |
3817| IMAGING_UNCATEGORIZED                    | 0x0600 | Unclassified imaging device.    |
3818| IMAGING_DISPLAY                          | 0x0610 | Imaging display device.      |
3819| IMAGING_CAMERA                           | 0x0620 | Imaging camera device.     |
3820| IMAGING_SCANNER                          | 0x0640 | Imaging scanner.     |
3821| IMAGING_PRINTER                          | 0x0680 | Imaging printer.     |
3822| WEARABLE_UNCATEGORIZED                   | 0x0700 | Unclassified wearable device.   |
3823| WEARABLE_WRIST_WATCH                     | 0x0704 | Smart watch.     |
3824| WEARABLE_PAGER                           | 0x0708 | Wearable pager.    |
3825| WEARABLE_JACKET                          | 0x070C | Smart jacket.     |
3826| WEARABLE_HELMET                          | 0x0710 | Wearable helmet.     |
3827| WEARABLE_GLASSES                         | 0x0714 | Wearable glasses.     |
3828| TOY_UNCATEGORIZED                        | 0x0800 | Unclassified toy.    |
3829| TOY_ROBOT                                | 0x0804 | Toy robot.     |
3830| TOY_VEHICLE                              | 0x0808 | Toy vehicle.       |
3831| TOY_DOLL_ACTION_FIGURE                   | 0x080C | Humanoid toy doll.    |
3832| TOY_CONTROLLER                           | 0x0810 | Toy controller.     |
3833| TOY_GAME                                 | 0x0814 | Toy gaming device.      |
3834| HEALTH_UNCATEGORIZED                     | 0x0900 | Unclassified health devices.     |
3835| HEALTH_BLOOD_PRESSURE                    | 0x0904 | Blood pressure device.      |
3836| HEALTH_THERMOMETER                       | 0x0908 | Thermometer     |
3837| HEALTH_WEIGHING                          | 0x090C | Body scale.      |
3838| HEALTH_GLUCOSE                           | 0x0910 | Blood glucose monitor.     |
3839| HEALTH_PULSE_OXIMETER                    | 0x0914 | Pulse oximeter.   |
3840| HEALTH_PULSE_RATE                        | 0x0918 | Heart rate monitor.     |
3841| HEALTH_DATA_DISPLAY                      | 0x091C | Health data display.    |
3842| HEALTH_STEP_COUNTER                      | 0x0920 | Step counter.   |
3843| HEALTH_BODY_COMPOSITION_ANALYZER         | 0x0924 | Body composition analyzer. |
3844| HEALTH_PEAK_FLOW_MOITOR                  | 0x0928 | Hygrometer.     |
3845| HEALTH_MEDICATION_MONITOR                | 0x092C | Medication monitor.   |
3846| HEALTH_KNEE_PROSTHESIS                   | 0x0930 | Prosthetic knee.    |
3847| HEALTH_ANKLE_PROSTHESIS                  | 0x0934 | Prosthetic ankle.    |
3848| HEALTH_GENERIC_HEALTH_MANAGER            | 0x0938 | Generic health management device.    |
3849| HEALTH_PERSONAL_MOBILITY_DEVICE          | 0x093C | Personal mobility device.    |
3850
3851
3852## PlayingState<sup>(deprecated)</sup>
3853
3854Enumerates the A2DP playing states.
3855
3856> **NOTE**<br>
3857> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.PlayingState](js-apis-bluetoothManager.md#playingstatedeprecated) instead.
3858
3859**System capability**: SystemCapability.Communication.Bluetooth.Core
3860
3861| Name               | Value   | Description     |
3862| ----------------- | ------ | ------- |
3863| STATE_NOT_PLAYING | 0x0000 | Not playing. |
3864| STATE_PLAYING     | 0x0001 | Playing.|
3865
3866
3867## ProfileId<sup>(deprecated)</sup>
3868
3869Enumerates the Bluetooth profiles. API version 9 is added with **PROFILE_HID_HOST** and **PROFILE_PAN_NETWORK**.
3870
3871> **NOTE**<br>
3872> This API is supported since API version 8 and deprecated since API version 9. Use [bluetoothManager.ProfileId](js-apis-bluetoothManager.md#profileiddeprecated) instead.
3873
3874**System capability**: SystemCapability.Communication.Bluetooth.Core
3875
3876| Name                              | Value   | Description             |
3877| -------------------------------- | ------ | --------------- |
3878| PROFILE_A2DP_SOURCE              | 1 | A2DP profile.|
3879| PROFILE_HANDS_FREE_AUDIO_GATEWAY | 4 | HFP profile. |
3880