1# @ohos.bluetooth.hid (Bluetooth HID Module) (System API)
2
3The **hid** module provides APIs for using the Bluetooth Human Interface Device Profile (HID).
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.bluetooth.hid (Bluetooth HID Module)](js-apis-bluetooth-hid.md).
9
10
11## Modules to Import
12
13```js
14import { hid } from '@kit.ConnectivityKit';
15```
16
17## HidHostProfile
18
19Before using the **HidHostProfile** APIs, you need to create an instance of this class by using [createHidHostProfile()](js-apis-bluetooth-hid.md#hidcreatehidhostprofile).
20
21### connect
22
23connect(deviceId: string): void
24
25Connects to the HidHost service of a device.
26
27**System API**: This is a system API.
28
29**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
30
31**System capability**: SystemCapability.Communication.Bluetooth.Core
32
33**Parameters**
34
35| Name   | Type    | Mandatory  | Description     |
36| ------ | ------ | ---- | ------- |
37| deviceId | string | Yes   | Address of the remote device.|
38
39**Error codes**
40
41For details about the error codes, see [Bluetooth Error Codes](errorcode-bluetoothManager.md).
42
43| ID| Error Message|
44| -------- | ---------------------------- |
45|201 | Permission denied.                 |
46|202 | Non-system applications are not allowed to use system APIs. |
47|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
48|801 | Capability not supported.          |
49|2900001 | Service stopped.                         |
50|2900003 | Bluetooth disabled.                 |
51|2900004 | Profile not supported.                |
52|2900099 | Operation failed.                        |
53
54**Example**
55
56```js
57import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
58try {
59    let hidHostProfile = hid.createHidHostProfile();
60    hidHostProfile.connect('XX:XX:XX:XX:XX:XX');
61} catch (err) {
62    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
63}
64```
65
66
67### disconnect
68
69disconnect(deviceId: string): void
70
71Disconnects from the HidHost service of a device.
72
73**System API**: This is a system API.
74
75**Required permissions**: ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
76
77**System capability**: SystemCapability.Communication.Bluetooth.Core
78
79**Parameters**
80
81| Name   | Type    | Mandatory  | Description     |
82| ------ | ------ | ---- | ------- |
83| deviceId | string | Yes   | Address of the remote device.|
84
85**Error codes**
86
87For details about the error codes, see [Bluetooth Error Codes](errorcode-bluetoothManager.md).
88
89| ID| Error Message|
90| -------- | ---------------------------- |
91|201 | Permission denied.                 |
92|202 | Non-system applications are not allowed to use system APIs. |
93|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
94|801 | Capability not supported.          |
95|2900001 | Service stopped.                         |
96|2900003 | Bluetooth disabled.                 |
97|2900004 | Profile not supported.                |
98|2900099 | Operation failed.                        |
99
100**Example**
101
102```js
103import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
104try {
105    let hidHostProfile = hid.createHidHostProfile();
106    hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX');
107} catch (err) {
108    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
109}
110```
111