• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ConnectivityKit
19 */
20
21import type baseProfile from './@ohos.bluetooth.baseProfile';
22
23/**
24 * Provides methods to accessing bluetooth HID(Human Interface Device)-related capabilities.
25 *
26 * @namespace hid
27 * @syscap SystemCapability.Communication.Bluetooth.Core
28 * @since 10
29 */
30declare namespace hid {
31  /**
32   * Base interface of profile.
33   *
34   * @typedef { baseProfile.BaseProfile } BaseProfile
35   * @syscap SystemCapability.Communication.Bluetooth.Core
36   * @since 10
37   */
38  type BaseProfile = baseProfile.BaseProfile;
39
40  /**
41   * create the instance of hid profile.
42   *
43   * @returns { HidHostProfile } Returns the instance of hid profile.
44   * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
45   * <br>2. Incorrect parameter types. 3. Parameter verification failed.
46   * @throws { BusinessError } 801 - Capability not supported.
47   * @syscap SystemCapability.Communication.Bluetooth.Core
48   * @since 10
49   */
50  function createHidHostProfile(): HidHostProfile;
51
52  /**
53   * Manager hid host profile.
54   *
55   * @typedef HidHostProfile
56   * @syscap SystemCapability.Communication.Bluetooth.Core
57   * @since 10
58   */
59  interface HidHostProfile extends BaseProfile {
60    /**
61     * Initiate an HID connection to a remote device.
62     *
63     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
64     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
65     * @throws { BusinessError } 201 - Permission denied.
66     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
67     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
68     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
69     * @throws { BusinessError } 801 - Capability not supported.
70     * @throws { BusinessError } 2900001 - Service stopped.
71     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
72     * @throws { BusinessError } 2900004 - Profile is not supported.
73     * @throws { BusinessError } 2900099 - Operation failed.
74     * @syscap SystemCapability.Communication.Bluetooth.Core
75     * @systemapi
76     * @since 10
77     */
78    connect(deviceId: string): void;
79
80    /**
81     * Disconnect the HID connection with the remote device.
82     *
83     * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH
84     * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF".
85     * @throws { BusinessError } 201 - Permission denied.
86     * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs.
87     * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified.
88     * <br>2. Incorrect parameter types. 3. Parameter verification failed.
89     * @throws { BusinessError } 801 - Capability not supported.
90     * @throws { BusinessError } 2900001 - Service stopped.
91     * @throws { BusinessError } 2900003 - Bluetooth switch is off.
92     * @throws { BusinessError } 2900004 - Profile is not supported.
93     * @throws { BusinessError } 2900099 - Operation failed.
94     * @syscap SystemCapability.Communication.Bluetooth.Core
95     * @systemapi
96     * @since 10
97     */
98    disconnect(deviceId: string): void;
99  }
100}
101
102export default hid;