/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Bytes, MatterError, Observable } from "@matter/general";
export declare class BtpMatterError extends MatterError {
}
export declare class BtpProtocolError extends BtpMatterError {
}
export declare class BtpFlowError extends BtpMatterError {
}
export declare class BtpSessionHandler {
    #private;
    private readonly role;
    private readonly fragmentSize;
    private readonly clientWindowSize;
    private readonly writeBleCallback;
    private readonly disconnectBleCallback;
    private readonly handleMatterMessagePayload;
    private currentIncomingSegmentedMsgLength;
    private currentIncomingSegmentedPayload;
    private prevIncomingSequenceNumber;
    private prevIncomingAckNumber;
    private readonly ackReceiveTimer;
    private sequenceNumber;
    private prevAckedSequenceNumber;
    private readonly queuedOutgoingMatterMessages;
    private sendInProgress;
    private readonly sendAckTimer;
    private isActive;
    private idleTimeout;
    /** Emitted exactly once when the session transitions to closed. */
    get closed(): Observable<[], void>;
    /** Factory method to create a new BTPSessionHandler from a received handshake request */
    static createFromHandshakeRequest(maxDataSize: number | undefined, handshakeRequestPayload: Bytes, writeBleCallback: (data: Bytes) => Promise<void>, disconnectBleCallback: () => Promise<void>, handleMatterMessagePayload: (data: Bytes) => Promise<void>): Promise<BtpSessionHandler>;
    static createAsCentral(handshakeResponsePayload: Bytes, writeBleCallback: (data: Bytes) => Promise<void>, disconnectBleCallback: () => Promise<void>, handleMatterMessagePayload: (data: Bytes) => Promise<void>): Promise<BtpSessionHandler>;
    /**
     * Creates a new BTP session handler
     *
     * @param role The role of the BTP session handler
     * @param btpVersion The BTP protocol version to use
     * @param fragmentSize The fragment size to use for the messages
     * @param clientWindowSize The client window size to use
     * @param writeBleCallback Callback to write data to the BLE transport
     * @param disconnectBleCallback Callback to disconnect the BLE transport
     * @param handleMatterMessagePayload Callback to handle a Matter message payload
     */
    constructor(role: "central" | "peripheral", btpVersion: number, fragmentSize: number, clientWindowSize: number, writeBleCallback: (data: Bytes) => Promise<void>, disconnectBleCallback: () => Promise<void>, handleMatterMessagePayload: (data: Bytes) => Promise<void>);
    /**
     * Handle incoming data from the transport layer and hand over completely received matter messages to the
     * ExchangeManager layer
     *
     * @param data ByteArray containing the data
     */
    handleIncomingBleData(data: Bytes): Promise<void>;
    /**
     * Send a Matter message to the transport layer, but before that encode it into a BTP packet and potentially split
     * it into multiple segments. This Method is indirectly called by the ExchangeManager layer when a Matter message
     * should be sent.
     *
     * @param data ByteArray containing the Matter message
     */
    sendMatterMessage(data: Bytes): Promise<void>;
    private processSendQueue;
    /**
     * Close the BTP session. This method is called when the BLE transport is disconnected and so the BTP session gets closed.
     */
    close(): Promise<void>;
    private btpSendAckTimeoutTriggered;
    private sendImmediateAckIfWindowLow;
    private sendStandaloneAck;
    private btpAckTimeoutTriggered;
    /**
     * Increments sequence number for the packets and round it off to 0 when it reaches the maximum limit.
     */
    getNextSequenceNumber(): number;
    /** Wrap-safe forward distance between two sequence numbers (modulo 256); the -1 sentinels read as 255. */
    private modularDistance;
    /** Free slots in the remote peer's receive window; gates our sending (§4.19.4.7). */
    private remoteWindowFreeSlots;
    /** Free slots in our own receive window; drives proactive acknowledgement (§4.19.4.8). */
    private localWindowFreeSlots;
    /** §4.19.4.7: a data-only packet must leave the last window slot free; an ack-bearing packet may use it. */
    private canSend;
}
//# sourceMappingURL=BtpSessionHandler.d.ts.map