/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { Message } from "#codec/MessageCodec.js"; import { ExchangeProvider } from "#protocol/index.js"; import { MessageExchange } from "#protocol/MessageExchange.js"; import type { ExchangeLogContext } from "#protocol/MessageExchange.js"; import { Duration } from "@matter/general"; import { BdxMessageType, BdxStatusCode } from "@matter/types"; import { BdxReceiveAccept, BdxSendAccept } from "./schema/BdxAcceptMessagesSchema.js"; import { BdxBlock, BdxBlockAck, BdxBlockAckEof, BdxBlockEof, BdxBlockQuery, BdxBlockQueryWithSkip } from "./schema/BdxBlockMessagesSchema.js"; import { BdxInit } from "./schema/BdxInitMessagesSchema.js"; import { BdxMessage } from "./schema/BdxMessage.js"; export declare const BDX_TRANSFER_IDLE_TIMEOUT: Duration; /** Messenger class that contains all Bdx Messages */ export declare class BdxMessenger { #private; /** Creates a new BdxMessenger instance by initiating a new MessageExchange from the given ExchangeProvider. */ static create(exchangeProvider: ExchangeProvider, messageTimeout?: Duration, abort?: AbortSignal): Promise; /** * Creates a new BdxMessenger instance. * @param exchange Exchange to use for the messaging * @param messageTimeout Communication Timeout for the Bdx Messages, defaults to 5 minutes as defined for Matter OTA transfers */ constructor(exchange: MessageExchange, messageTimeout?: Duration); get channel(): import("#protocol/index.js").MessageChannel; get exchange(): MessageExchange; get maxPayloadSize(): number; /** * Waits for the next message and returns it. * A List of allowed expected message types can be provided. * If the message type is not in the list, an error will be thrown. */ nextMessage(expectedMessageTypes: BdxMessageType[], timeout?: Duration, expectedMessageInfo?: string): Promise>; send(bdxMessage: BdxMessage, logContext?: ExchangeLogContext): Promise; /** Sends a Bdx SendInit message and waits for the SendAccept message as a response and returns it decoded. */ sendSendInit(message: BdxInit): Promise; /** Sends a ReceiveInit message and waits for the ReceiveAccept message as a response and returns it decoded. */ sendReceiveInit(message: BdxInit): Promise; /** Encodes and sends a Bdx SendAccept message. */ sendSendAccept(message: BdxSendAccept): Promise; /** Encodes and sends a Bdx ReceiveAccept message. */ sendReceiveAccept(message: BdxReceiveAccept): Promise; /** Encodes and sends a Bdx Block message. */ sendBlock(message: BdxBlock): Promise; /** * Encodes and sends a Bdx BlockQuery message. * * `received` names the Block this query follows. A driving receiver acks nothing until the transfer ends, so * its next query is the only message that can carry what the last one delivered — and this query's own counter * is the block being asked for, not the one that arrived. */ sendBlockQuery(message: BdxBlockQuery, received?: { blockCounter: number; dataLength: number; }): Promise; /** Encodes and sends a Bdx BlockQueryWithSkip message. */ sendBlockQueryWithSkip(message: BdxBlockQueryWithSkip): Promise; /** Encodes and sends a Bdx BlockEof message. */ sendBlockEof(message: BdxBlockEof): Promise; /** * Encodes and sends a Bdx BlockAck message. * * `acknowledgedLength` is the data length of the Block being acknowledged. An inbound message is logged on * arrival, before BDX decodes it, so the receiver's own ack is where a reader learns what arrived. */ sendBlockAck(message: BdxBlockAck, acknowledgedLength?: number): Promise; /** Encodes and sends a Bdx BlockAckEof message. `acknowledgedLength` as for {@link sendBlockAck}. */ sendBlockAckEof(message: BdxBlockAckEof, acknowledgedLength?: number): Promise; /** Read the next Block message, accepts Block and BlockEof messages. Returns the decoded message and it's type. */ readBlock(): Promise>; /** * Read the next BlockQuery message, accepts BlockQuery and BlockQueryWithSkip and BlockAck messages. * When a BlockAck is received, it will be validated and the next BlockQuery message will be read. * Returns the decoded message and it's type. */ readBlockQuery(): Promise>; /** Reads the next BlockAckEof message and returns the decoded message. */ readBlockAckEof(): Promise; /** Reads the next BlockAck message and returns the decoded message. */ readBlockAck(): Promise; /** Sends a Bdx Error StatusReport message with the given protocol status. */ sendError(code: BdxStatusCode): Promise; protected throwIfErrorStatusReport(message: Message, logHint?: string): void; close(): Promise; [Symbol.asyncDispose](): Promise; /** * Ensure that the value is a safe JavaScript "number" type and that it is not too large. Matter spec allows also * 64bit values, but they make little sense for now, so make sure we handle them as too large. MAX_SAFE_INTEGER is * 2^53-1 and is enough for now. */ static asSafeNumber(value: number | bigint | undefined, context?: string, bdxErrorCode?: BdxStatusCode): number; } //# sourceMappingURL=BdxMessenger.d.ts.map