@iotize/tap
Version:
IoTize Device client for Javascript
52 lines (51 loc) • 2.46 kB
TypeScript
import { ConnectionState } from '@iotize/tap/protocol/api';
import { CharacteristicAdapterInterface, CharacteristicProperties, DescriptorAdapterInterface, PeripheralAdapterInterface, ServiceAdapterInterface } from '@iotize/tap/protocol/ble/common';
import { BehaviorSubject, Observable } from 'rxjs';
export declare class MockPeripheralAdapter implements PeripheralAdapterInterface<MockServiceAdapter> {
options: {
state: 'connected' | 'disconnected';
connectDelay: number;
disconnectDelay: number;
name: string;
id: string;
};
services: Partial<Record<string, MockServiceAdapter>>;
stateChange: BehaviorSubject<ConnectionState>;
constructor(options?: {
state: 'connected' | 'disconnected';
connectDelay: number;
disconnectDelay: number;
name: string;
id: string;
});
get id(): string;
get name(): string;
get state(): "connected" | "disconnected";
connect(): Promise<void>;
disconnect(): Promise<void>;
discoverServices(): Promise<Partial<Record<string, MockServiceAdapter>>>;
getService(uuid: string): Promise<MockServiceAdapter>;
close(): void;
}
export declare class MockServiceAdapter implements ServiceAdapterInterface {
uuid: string;
characteristics: CharacteristicAdapterInterface<DescriptorAdapterInterface>[];
constructor(uuid: string, characteristics?: CharacteristicAdapterInterface<DescriptorAdapterInterface>[]);
getCharacteristics(): Promise<CharacteristicAdapterInterface<DescriptorAdapterInterface>[]>;
getCharacteristic(charcUUID: string): Promise<CharacteristicAdapterInterface<DescriptorAdapterInterface>>;
}
export declare class MockCharacteristicAdapter implements CharacteristicAdapterInterface<DescriptorAdapterInterface> {
readonly uuid: string;
readonly properties: CharacteristicProperties;
readonly descriptors: DescriptorAdapterInterface[];
notificationEnabled: boolean;
data: Observable<{
data: Uint8Array;
isNotification: boolean;
}>;
constructor(uuid: string, properties: CharacteristicProperties, descriptors?: DescriptorAdapterInterface[]);
write(data: Uint8Array, writeWithoutResponse: boolean): Promise<Uint8Array>;
read(): Promise<Uint8Array>;
enableNotifications(enabled: boolean): Promise<void>;
getDescriptors(): Promise<DescriptorAdapterInterface[]>;
}