import { ConnectionState } from '@iotize/tap/protocol/api';
import { QueueComProtocol } from '@iotize/tap/protocol/core';
import { Observable } from 'rxjs';
export declare namespace UniversalBleProtocolAdapter {
    interface Options {
        /**
         * BLE maximum transfer unit size (in bytes)
         */
        mtu: number;
        /**
         * Maximum buffer length for received frames
         */
        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<T extends ServiceAdapterInterface = ServiceAdapterInterface> extends QueueComProtocol {
    peripheral: PeripheralAdapterInterface<T>;
    private _lwm2mCharc?;
    private _useSplitter;
    private _readPromise?;
    bleOptions: UniversalBleProtocolAdapter.Options;
    private get lwm2mCharc();
    constructor(peripheral: PeripheralAdapterInterface<T>, bleOptions?: Partial<UniversalBleProtocolAdapter.Options>);
    private sanitizeUUID;
    _connect(): Observable<any>;
    _disconnect(): Observable<any>;
    private setupLwm2mCharacteristic;
    private _selectLwm2mCharacteristic;
    private _getLargeFrameLwm2mCharacteristic;
    private _getLegacyLwm2mCharacteristic;
    read(): Promise<Uint8Array>;
    readUnit(): Promise<Uint8Array>;
    write(data: Uint8Array): Promise<any>;
    get useSplitter(): boolean;
    get chunkSize(): number;
    writeUnit(data: Uint8Array): Promise<any>;
    private _createReadPromise;
}
export interface PeripheralAdapterInterface<T extends ServiceAdapterInterface = ServiceAdapterInterface> {
    state: string;
    stateChange: Observable<ConnectionState>;
    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<Key extends string = string>(serviceUUIDs?: Key[]): Promise<Partial<Record<Key, T>>>;
    connect(): Promise<void>;
    disconnect(): Promise<void>;
    getService(uuid: string): Promise<T>;
}
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<CharacteristicType extends CharacteristicAdapterInterface = CharacteristicAdapterInterface> {
    uuid: string;
    /**
     * Get characteristic identified by the given UUID
     * @throws if characteristic does not exist
     *
     * @param charcUUID
     */
    getCharacteristic(charcUUID: string): Promise<CharacteristicType>;
    getCharacteristics(): Promise<CharacteristicType[]>;
}
export interface CharacteristicAdapterInterface<DescriptorType extends DescriptorAdapterInterface = DescriptorAdapterInterface> {
    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<Uint8Array>;
    /**
     * Read characteristic value
     */
    read(): Promise<Uint8Array>;
    /**
     * Start/Stop notifications with indication or notification accordording to
     * characteristic configuration
     * @param enabled
     */
    enableNotifications(enabled: boolean): Promise<void>;
    /**
     * Get descriptors
     */
    getDescriptors(): Promise<DescriptorType[]>;
}
export interface DescriptorAdapterInterface {
    /**
     * Descriptor UUID
     */
    uuid: string;
    /**
     * Write descriptor value
     */
    writeValue(data: Uint8Array): Promise<void>;
    /**
     * Read descriptor value
     */
    readValue(): Promise<Uint8Array>;
}
