• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 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
16export interface StartBLEScanOptions {
17  interval: number;
18
19  success: () => void;
20
21  fail: (data: string, code: number) => void;
22
23  complete: () => void;
24}
25
26export interface StopBLEScanOptions {
27  success: () => void;
28
29  fail: (data: string, code: number) => void;
30
31  complete: () => void;
32}
33
34export interface BluetoothDevice {
35  addrType: "public" | "random";
36
37  addr: string;
38
39  rssi: number;
40
41  txpower: string;
42
43  data: string;
44}
45
46export interface BLEFoundResponse {
47  devices: Array<BluetoothDevice>;
48}
49
50export interface SubscribeBLEFoundOptions{
51    success: (data: BLEFoundResponse) => void;
52
53    fail: (data: string, code: number) => void;
54}
55
56export default class Bluetooth {
57  /**
58   * Start BLE scan
59   * @param options Options
60   */
61  static startBLEScan(options: StartBLEScanOptions): void;
62
63  /**
64   * Stop BLE scan
65   * @param options Options
66   */
67  static stopBLEScan(options: StopBLEScanOptions): void;
68
69  /**
70   * Subscribe BLE found
71   * @param options Options
72   */
73  static subscribeBLEFound(options: SubscribeBLEFoundOptions): void;
74
75  /**
76   * Stop the subscription of BLE found
77   */
78  static unsubscribeBLEFound(): void;
79}