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 */ 20 export 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 */ 31 export 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 */ 41 export 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 */ 53 export interface BLEFoundResponse { 54 devices: Array<BluetoothDevice>; 55 } 56 57 /** 58 * @syscap SystemCapability.Communication.Bluetooth.Lite 59 * @since 6 60 */ 61 export interface SubscribeBLEFoundOptions { 62 success: (data: BLEFoundResponse) => void; 63 fail: (data: string, code: number) => void; 64 } 65 66 /** 67 * @syscap SystemCapability.Communication.Bluetooth.Lite 68 * @since 6 69 */ 70 export default class Bluetooth { 71 /** 72 * Start BLE scan 73 * @param options Options 74 */ 75 static startBLEScan(options: StartBLEScanOptions): void; 76 77 /** 78 * Stop BLE scan 79 * @param options Options 80 */ 81 static stopBLEScan(options: StopBLEScanOptions): void; 82 83 /** 84 * Subscribe BLE found 85 * @param options Options 86 */ 87 static subscribeBLEFound(options: SubscribeBLEFoundOptions): void; 88 89 /** 90 * Stop the subscription of BLE found 91 */ 92 static unsubscribeBLEFound(): void; 93 } 94