/**
 * @license
 * Copyright 2025-2026 Open Home Foundation
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * BLE Proxy Protocol constants, types, and codec.
 * See docs/ble-proxy-protocol.md for the full specification.
 */
export declare const BLE_PROXY_PROTOCOL_VERSION = 1;
export interface HelloMessage {
    type: "hello";
    version: number;
}
export interface HelloResponseMessage {
    type: "hello_response";
    version: number;
    error?: string;
    message?: string;
}
export type HandshakeMessage = HelloMessage | HelloResponseMessage;
export declare const BleProxyCommand: {
    readonly StartScan: "start_scan";
    readonly StopScan: "stop_scan";
    readonly Connect: "connect";
    readonly Disconnect: "disconnect";
    readonly DiscoverServices: "discover_services";
    readonly DiscoverCharacteristics: "discover_characteristics";
    readonly ReadCharacteristic: "read_characteristic";
    readonly WriteCharacteristic: "write_characteristic";
    readonly SubscribeCharacteristic: "subscribe_characteristic";
    readonly WriteAndSubscribe: "write_and_subscribe";
    readonly UnsubscribeCharacteristic: "unsubscribe_characteristic";
    readonly RequestMtu: "request_mtu";
};
export type BleProxyCommandName = (typeof BleProxyCommand)[keyof typeof BleProxyCommand];
export declare const BleProxyEvent: {
    readonly DeviceDiscovered: "device_discovered";
    readonly Disconnected: "disconnected";
    readonly ScanStopped: "scan_stopped";
    readonly CharacteristicNotification: "characteristic_notification";
};
export type BleProxyEventName = (typeof BleProxyEvent)[keyof typeof BleProxyEvent];
export interface StartScanArgs {
    service_uuids?: string[];
    allow_duplicates?: boolean;
}
export interface ConnectArgs {
    address: string;
    timeout?: number;
}
export interface DisconnectArgs {
    connection_handle: number;
}
export interface DiscoverServicesArgs {
    connection_handle: number;
}
export interface DiscoverCharacteristicsArgs {
    connection_handle: number;
    service_uuid: string;
}
export interface ReadCharacteristicArgs {
    connection_handle: number;
    characteristic_uuid: string;
}
export interface WriteCharacteristicArgs {
    connection_handle: number;
    characteristic_uuid: string;
    value: string;
    response?: boolean;
}
export interface SubscribeCharacteristicArgs {
    connection_handle: number;
    characteristic_uuid: string;
}
/**
 * Atomic write-then-subscribe. The client performs the write to `write_uuid`, awaits the
 * GATT Write Response, then enables CCCD on `subscribe_uuid` without any intervening
 * WebSocket round-trip. Used for the Matter BTP handshake on C1/C2 where a peripheral may
 * push the handshake response indication before the client has had time to enable CCCD if
 * the two ops are split across WS commands.
 */
export interface WriteAndSubscribeArgs {
    connection_handle: number;
    write_uuid: string;
    write_value: string;
    write_response?: boolean;
    subscribe_uuid: string;
}
export interface UnsubscribeCharacteristicArgs {
    connection_handle: number;
    characteristic_uuid: string;
}
export interface RequestMtuArgs {
    connection_handle: number;
    mtu: number;
}
export interface ConnectResult {
    connection_handle: number;
    mtu: number;
}
export interface DiscoverServicesResult {
    services: Array<{
        uuid: string;
    }>;
}
export interface DiscoverCharacteristicsResult {
    characteristics: Array<{
        uuid: string;
        properties: string[];
    }>;
}
export interface ReadCharacteristicResult {
    value: string;
}
export interface RequestMtuResult {
    mtu: number;
}
export interface DeviceDiscoveredData {
    address: string;
    name?: string;
    rssi?: number;
    connectable: boolean;
    service_data?: Record<string, string>;
    manufacturer_data?: Record<string, string>;
    service_uuids?: string[];
}
export interface DisconnectedData {
    connection_handle: number;
    reason?: string;
}
export interface ScanStoppedData {
    reason: string;
}
export interface CharacteristicNotificationData {
    connection_handle: number;
    characteristic_uuid: string;
    value: string;
}
/** Maps each command name to its args and result types for type-safe sendCommand. */
export interface BleProxyCommandMap {
    [BleProxyCommand.StartScan]: {
        args: StartScanArgs;
        result: void;
    };
    [BleProxyCommand.StopScan]: {
        args: undefined;
        result: void;
    };
    [BleProxyCommand.Connect]: {
        args: ConnectArgs;
        result: ConnectResult;
    };
    [BleProxyCommand.Disconnect]: {
        args: DisconnectArgs;
        result: void;
    };
    [BleProxyCommand.DiscoverServices]: {
        args: DiscoverServicesArgs;
        result: DiscoverServicesResult;
    };
    [BleProxyCommand.DiscoverCharacteristics]: {
        args: DiscoverCharacteristicsArgs;
        result: DiscoverCharacteristicsResult;
    };
    [BleProxyCommand.ReadCharacteristic]: {
        args: ReadCharacteristicArgs;
        result: ReadCharacteristicResult;
    };
    [BleProxyCommand.WriteCharacteristic]: {
        args: WriteCharacteristicArgs;
        result: void;
    };
    [BleProxyCommand.SubscribeCharacteristic]: {
        args: SubscribeCharacteristicArgs;
        result: void;
    };
    [BleProxyCommand.WriteAndSubscribe]: {
        args: WriteAndSubscribeArgs;
        result: void;
    };
    [BleProxyCommand.UnsubscribeCharacteristic]: {
        args: UnsubscribeCharacteristicArgs;
        result: void;
    };
    [BleProxyCommand.RequestMtu]: {
        args: RequestMtuArgs;
        result: RequestMtuResult;
    };
}
export interface CommandMessage {
    id: number;
    command: BleProxyCommandName;
    args?: Record<string, unknown>;
}
export interface SuccessResponseMessage {
    id: number;
    success: true;
    result?: Record<string, unknown>;
}
export interface ErrorResponseMessage {
    id: number;
    success: false;
    error: string;
    message: string;
}
export type ResponseMessage = SuccessResponseMessage | ErrorResponseMessage;
export interface EventMessage {
    event: BleProxyEventName;
    data: Record<string, unknown>;
}
export declare const BleProxyErrorCode: {
    readonly BluetoothUnavailable: "bluetooth_unavailable";
    readonly AlreadyScanning: "already_scanning";
    readonly NotScanning: "not_scanning";
    readonly DeviceNotFound: "device_not_found";
    readonly ConnectionFailed: "connection_failed";
    readonly AlreadyConnected: "already_connected";
    readonly NotConnected: "not_connected";
    readonly Timeout: "timeout";
    readonly ServiceNotFound: "service_not_found";
    readonly CharacteristicNotFound: "characteristic_not_found";
    readonly ReadFailed: "read_failed";
    readonly WriteFailed: "write_failed";
    readonly SubscribeFailed: "subscribe_failed";
    readonly NotSubscribed: "not_subscribed";
    readonly NotifyNotSupported: "notify_not_supported";
    readonly MtuRequestFailed: "mtu_request_failed";
    readonly DiscoveryFailed: "discovery_failed";
    readonly InternalError: "internal_error";
};
export type BleProxyErrorCodeValue = (typeof BleProxyErrorCode)[keyof typeof BleProxyErrorCode];
export declare const BinaryFrameOpcode: {
    /** Server -> Client: write payload to the active write characteristic */
    readonly WriteData: 1;
    /** Client -> Server: notification data from a subscribed characteristic */
    readonly Notification: 2;
    /** Client -> Server: response data for a read_characteristic command */
    readonly ReadResponse: 3;
};
export type BinaryFrameOpcodeValue = (typeof BinaryFrameOpcode)[keyof typeof BinaryFrameOpcode];
export interface BinaryFrame {
    opcode: number;
    connectionHandle: number;
    payload: Uint8Array;
}
export declare function encodeBinaryFrame(opcode: number, connectionHandle: number, payload: Uint8Array): Uint8Array;
export declare function decodeBinaryFrame(data: Uint8Array): BinaryFrame;
//# sourceMappingURL=BleProxyProtocol.d.ts.map