@iotize/device-com-ble.cordova
Version:
Bluetooth Low Energy (BLE) for IoTize modules Plugin
59 lines (58 loc) • 3.01 kB
TypeScript
import { ConnectionState } from "@iotize/tap/protocol/api";
import { CharacteristicAdapterInterface, PeripheralAdapterInterface, ServiceAdapterInterface, DescriptorAdapterInterface, CharacteristicProperties } from "@iotize/tap/protocol/ble/common";
import { Observable } from "rxjs";
import { CharacteristicDescription, DescriptorDescription, ServiceDescription } from "./definitions";
import { IoTizeBleCordovaPlugin } from "./iotize-ble-cordova-plugin";
export declare class CordovaPeripheralAdapter implements PeripheralAdapterInterface<CordovaServiceAdapter> {
readonly deviceId: string;
readonly cordovaPlugin: IoTizeBleCordovaPlugin;
private _stateChange;
private connectionStateSubscription?;
private serviceListCache?;
get stateChange(): Observable<ConnectionState>;
get name(): string;
get id(): string;
constructor(deviceId: string, cordovaPlugin?: IoTizeBleCordovaPlugin);
get state(): string;
discoverServices<Key extends string = string>(serviceUUIDs?: Key[]): Promise<Partial<Record<Key, CordovaServiceAdapter>>>;
connect(): Promise<void>;
disconnect(): Promise<void>;
close(): Promise<void>;
getService(uuid: string): Promise<CordovaServiceAdapter>;
}
export declare class CordovaServiceAdapter implements ServiceAdapterInterface {
private readonly config;
readonly peripheral: CordovaPeripheralAdapter;
get uuid(): string;
constructor(config: ServiceDescription, peripheral: CordovaPeripheralAdapter);
getCharacteristic(charcUUID: string): Promise<CordovaCharacteristicAdapter>;
getCharacteristics(): Promise<CordovaCharacteristicAdapter[]>;
}
export declare class CordovaCharacteristicAdapter implements CharacteristicAdapterInterface {
readonly service: CordovaServiceAdapter;
readonly config: CharacteristicDescription;
private _dataStream?;
get uuid(): string;
constructor(service: CordovaServiceAdapter, config: CharacteristicDescription);
get properties(): CharacteristicProperties;
get data(): Observable<{
data: Uint8Array;
isNotification: boolean;
}>;
protected get deviceId(): string;
protected get pluginInterface(): IoTizeBleCordovaPlugin;
read(): Promise<Uint8Array>;
getDescriptor(): Promise<CordovaDescriptorAdapter>;
getDescriptors(): Promise<DescriptorAdapterInterface[]>;
write(data: Uint8Array, writeWithoutResponse: boolean): Promise<Uint8Array>;
enableNotifications(enabled?: boolean): Promise<void>;
setupDataStreamIfRequired(): Observable<Uint8Array>;
}
export declare class CordovaDescriptorAdapter implements DescriptorAdapterInterface {
readonly config: DescriptorDescription;
readonly characteristic: CordovaCharacteristicAdapter;
get uuid(): string;
constructor(config: DescriptorDescription, characteristic: CordovaCharacteristicAdapter);
readValue(): Promise<Uint8Array>;
writeValue(data: Uint8Array): Promise<void>;
}