• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @syscap SystemCapability.Communication.Bluetooth.Lite
18 * @since 6
19 */
20export interface StartBLEScanOptions {
21  interval: number;
22  success: () => void;
23  fail: (data: string, code: number) => void;
24  complete: () => void;
25}
26
27/**
28 * @syscap SystemCapability.Communication.Bluetooth.Lite
29 * @since 6
30 */
31export interface StopBLEScanOptions {
32  success: () => void;
33  fail: (data: string, code: number) => void;
34  complete: () => void;
35}
36
37/**
38 * @syscap SystemCapability.Communication.Bluetooth.Lite
39 * @since 6
40 */
41export interface BluetoothDevice {
42  addrType: "public" | "random";
43  addr: string;
44  rssi: number;
45  txpower: string;
46  data: string;
47}
48
49/**
50 * @syscap SystemCapability.Communication.Bluetooth.Lite
51 * @since 6
52 */
53export interface BLEFoundResponse {
54  devices: Array<BluetoothDevice>;
55}
56
57/**
58 * @syscap SystemCapability.Communication.Bluetooth.Lite
59 * @since 6
60 */
61export interface SubscribeBLEFoundOptions {
62    success: (data: BLEFoundResponse) => void;
63    fail: (data: string, code: number) => void;
64}
65
66/**
67 * Provides methods to manage BLE scan.
68 * @since 6
69 * @syscap SystemCapability.Communication.Bluetooth.Lite
70 */
71export default class Bluetooth {
72  /**
73   * Start BLE scan
74   * @param options Options
75   */
76  static startBLEScan(options: StartBLEScanOptions): void;
77
78  /**
79   * Stop BLE scan
80   * @param options Options
81   */
82  static stopBLEScan(options: StopBLEScanOptions): void;
83
84  /**
85   * Subscribe BLE found
86   * @param options Options
87   */
88  static subscribeBLEFound(options: SubscribeBLEFoundOptions): void;
89
90  /**
91   * Stop the subscription of BLE found
92   */
93  static unsubscribeBLEFound(): void;
94}