import { ConnectionState } from '@iotize/tap/protocol/api'; import { QueueComProtocol } from '@iotize/tap/protocol/core'; import { Observable } from 'rxjs'; export declare namespace UniversalBleProtocolAdapter { interface Options { /** * Force BLE maximum transfer unit size (in bytes) */ mtu?: number; /** * Maximum buffer length when response is splitted into multiple chunck * (only used for legacy ble service) */ maximumBufferLength: number; /** * True to wait for write characteristic acknowledge * According to firmware implementation, write acknowledge is not * always returns, leading to a timeout exception in client */ waitForWriteAcknowledge: boolean; /** * TapNLinks may have 2 different BLE characteristic to communicate * You can define which one should be used in priority * If it does not exist, it will use the other one */ preferedComServiceType?: 'legacy' | 'large-frame'; /** * True if you want to remove '-' character from ID */ sanitizeUUID?: boolean; } } export declare const DEFAULT_BLE_OPTIONS: UniversalBleProtocolAdapter.Options; /** * BLE communication * * With ble communication, data is split into sub packets. * This class handles creation of packet chunks. * * - You must only implement the function to send one packet chunk writeLwm2mPacketChunk() * - */ export declare class UniversalBleProtocolAdapter extends QueueComProtocol { peripheral: PeripheralAdapterInterface; private _lwm2mCharc?; private _useSplitter; private _readPromise?; bleOptions: UniversalBleProtocolAdapter.Options; private _unexpectedBleDisconnection; constructor(peripheral: PeripheralAdapterInterface, bleOptions?: Partial); get lwm2mCharc(): CharacteristicAdapterInterface; private sanitizeUUID; _connect(): Observable; _disconnect(): Observable; private setupLwm2mCharacteristic; private _selectLwm2mCharacteristic; private _getLargeFrameLwm2mCharacteristic; private _getLegacyLwm2mCharacteristic; read(): Promise; readUnit(): Promise; write(data: Uint8Array): Promise; get useSplitter(): boolean; get chunkSize(): number; writeUnit(data: Uint8Array): Promise; private _createReadPromise; } export interface PeripheralAdapterInterface { state: string; stateChange: Observable; name?: string; id: string; /** * Discover services * @param serviceUUIDs if not provided it will discover all services, if provided it will discover the given services * @returns returns a map of services discovered. If a listed service is not discovered, it will be set to undefined */ discoverServices(serviceUUIDs?: Key[]): Promise>>; connect(): Promise; disconnect(): Promise; getService(uuid: string): Promise; } export interface CharacteristicProperties { readonly broadcast: boolean; readonly read: boolean; readonly writeWithoutResponse: boolean; readonly write: boolean; readonly notify: boolean; readonly indicate: boolean; readonly authenticatedSignedWrites: boolean; readonly reliableWrite: boolean; readonly writableAuxiliaries: boolean; } export interface ServiceAdapterInterface { uuid: string; /** * Get characteristic identified by the given UUID * @throws if characteristic does not exist * * @param charcUUID */ getCharacteristic(charcUUID: string): Promise; getCharacteristics(): Promise; } export interface CharacteristicAdapterInterface { uuid: string; properties: CharacteristicProperties; data: Observable<{ data: Uint8Array; isNotification: boolean; }>; /** * Write characteristic value * If successful, returns the written data * @param data * @param writeWithoutResponse */ write(data: Uint8Array, writeWithoutResponse: boolean): Promise; /** * Read characteristic value */ read(): Promise; /** * Start/Stop notifications with indication or notification accordording to * characteristic configuration * @param enabled */ enableNotifications(enabled: boolean): Promise; /** * Get descriptors */ getDescriptors(): Promise; } export interface DescriptorAdapterInterface { /** * Descriptor UUID */ uuid: string; /** * Write descriptor value */ writeValue(data: Uint8Array): Promise; /** * Read descriptor value */ readValue(): Promise; }