@iotize/ionic
Version:
Iotize specific building blocks on top of @ionic/angular.
72 lines (71 loc) • 3.34 kB
TypeScript
import { NgZone } from '@angular/core';
import { Platform } from '@ionic/angular';
import { CordovaBLEScanResult } from '@iotize/device-com-ble.cordova';
import { DeviceScanner } from '@iotize/tap/scanner/api';
import { Observable, UnaryFunction } from 'rxjs';
import { WebBluetoothManufacturerDataFilter } from './manufacturer-data-filter';
import { PeripheralAdapter, WebBluetoothDevice } from '@iotize/device-com-web-bluetooth.js';
import { ServiceList } from '@iotize/device-com-ble.cordova/lib/definitions';
import * as i0 from "@angular/core";
export type BleScannerOptions = {
filters?: {
services?: string[];
manufacturerData?: WebBluetoothManufacturerDataFilter[];
}[];
};
export type scannerResult = CordovaBLEScanResult | WebBluetoothDevice;
export type BLEScanResultWithRecords = {
address: string;
name: string;
rssi?: number;
txPower?: number;
records?: {
type: number;
data: Uint8Array;
}[];
};
export type PeripheralAdapterWithRecords = PeripheralAdapter & {
rssi?: number;
txPower?: number;
scanRecord?: number[];
watchAdvertisementsAbortController?: AbortController;
};
export declare function filterUndefined<T>(): UnaryFunction<Observable<T | undefined>, Observable<T>>;
export declare class BleService {
private platform;
private ngZone;
private bleScanner?;
private scannerSubscription?;
private plugin?;
private webBluetoothPeripheralAdapters;
private lastResults?;
private _results$;
readonly results: Observable<scannerResult[]>;
readonly resultsWithRecords: Observable<BLEScanResultWithRecords[]>;
constructor(platform: Platform, ngZone: NgZone);
createNewScanner(options?: BleScannerOptions): DeviceScanner<scannerResult>;
private emitNexResults;
private clearPreviousScanner;
startScan(options?: BleScannerOptions): Promise<any>;
stopScan(): Promise<any>;
connectByName(bleDeviceName: string): Observable<import("@iotize/tap/protocol/api").ConnectionState>;
disconnectByName(bleDeviceName: string): Promise<"OK">;
closeByName(bleDeviceName: string): Promise<'OK'>;
readCharacteristic(deviceName: string, serviceId: string, characteristicId: string): Promise<Uint8Array>;
writeCharacteristic(deviceName: string, serviceId: string, characteristicId: string, data: Uint8Array, withResponse?: boolean): Promise<true>;
listenCharacteristicChange(deviceName: string, serviceId: string, characteristicId: string): Observable<Uint8Array>;
discoverServices(deviceName: string): Promise<ServiceList>;
startNotification(deviceName: string, serviceId: string, characteristicId: string): Promise<'OK'>;
stopNotification(deviceName: string, serviceId: string, characteristicId: string): Promise<true>;
private getDeviceFromPeripheralAdapter;
private getDeviceFromPeripheralAdapterOrThrow;
private getDeviceServiceFromPeripheralAdapter;
private getCharacteristicFromPeripheralAdapterObservable;
private getCharacteristicFromPeripheralAdapterPromise;
private setWatchAdvertisement;
private unsetWatchAdvertisement;
private updateAdvertisementData;
private companyIdentifierToNumber;
static ɵfac: i0.ɵɵFactoryDeclaration<BleService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<BleService>;
}