import { type LogConfig, type MPDU, ProtocolDataRate, ProtocolHeaderFormat, RoutedZWaveMPDU } from "@zwave-js/core"; import { type ChannelInfo } from "@zwave-js/serial"; import { type BytesView, TypedEventTarget } from "@zwave-js/shared"; import type { ZWaveOptions } from "../driver/ZWaveOptions.js"; import type { MACLayer } from "./MACLayer.js"; import { type PHYLayerFactory } from "./PHYLayer.js"; import { type MACDestinationWakeup, type MACTransmitAckOptions, type MACTransmitOptions, type MACTransmitReport, MACTransmitResult } from "./_Types.js"; interface TransmitAttempt { /** * Resolved when the attempt is made, so an LR primary channel change during * an ongoing transmission takes effect */ channel: () => ChannelInfo; speedModified: boolean; } /** * How long to wait for an ack after a transmission, in milliseconds. The result * includes the host transport allowance on top of the duration the MAC mandates */ export declare function ackWaitDuration(dataRate: ProtocolDataRate, headerFormat: ProtocolHeaderFormat): number; /** * Plan the transmit attempts of a classic frame in a 2-channel region, fastest * rate first */ export declare function classic2ChannelAttemptSchedule(channels: readonly ChannelInfo[]): TransmitAttempt[]; /** The random backoff to wait before a retransmission, in milliseconds */ export declare function randomRetransmitDelay(isLongRange: boolean): number; /** How long a frame of the given length occupies the channel, in milliseconds */ export declare function frameDuration(frameLength: number, dataRate: ProtocolDataRate, headerFormat: ProtocolHeaderFormat): number; /** * Time to wait for a routed acknowledgement or routed error, measured from the moment * repeater 0 has repeated the frame. */ export declare function routedAckTimeout(numRepeaters: number, frameDurationMs: number): number; /** Whether the frame is a routed frame that its last repeater has delivered to the destination */ export declare function isFinalHopOfRoutedFrame(mpdu: MPDU): mpdu is RoutedZWaveMPDU; export interface BeamParameters { /** Whether this is a continuous beam */ continuous: boolean; numFragments: number; fragmentDurationMs: number; fragmentPeriodMs: number; } /** * Translate a destination's wakeup interval into the beam the header format * demands. Throws when the wakeup type does not match the header format. */ export declare function getBeamParameters(wakeup: MACDestinationWakeup, headerFormat: ProtocolHeaderFormat): BeamParameters; export interface ProtocolControllerOptions { /** * Optional log configuration */ logConfig?: Partial; host?: Pick>, "log">; phy: PHYLayerFactory; } export interface ProtocolControllerEventCallbacks { ready: () => void; error: (err: Error) => void; } export type ProtocolControllerEvents = Extract; export declare class ProtocolController extends TypedEventTarget implements MACLayer { constructor(options: ProtocolControllerOptions); private _options; /** * The host bindings used to access file system etc. */ private bindings; private phyLayer; private _logContainer; private protocolLog; ownHomeId: number | undefined; ownNodeId: number | undefined; autoAck: boolean; /** The TX power in dBm for the acknowledgements the controller sends by itself */ autoAckTXPower: number; /** * The TX power the controller acknowledges with, clamped into the range the radio reported. */ private getSafeAutoAckTXPower; /** A list of awaited MPDUs */ private awaitedMPDUs; /** Resolves once the frame exchange currently holding the radio is done */ private radioIdle; private sequenceNumber; /** The LR channel this node transmits on */ private primaryLongRangeChannel; private _destroyPromise; private get wasDestroyed(); start(): Promise; private nextSequenceNumber; private getProtocolDataRateOrThrow; /** Serialize an MPDU and log it */ private serializeOutbound; private sendFrame; private sendMPDU; /** * Ask the firmware to patch a freshly measured noise floor into an outgoing * Long Range frame, where the serialized frame carries the "not available" * placeholder. A caller-supplied noise floor is left alone. */ private getNoiseFloorReplacements; private getAdvertisedNoiseFloor; private getChannelsForProtocolOrThrow; private getPrimaryLongRangeChannel; private getSecondaryLongRangeChannel; /** The channel the first transmit attempt of a frame goes out on */ private getInitialChannel; /** * Plan the transmit attempts of a frame, in order. G.9959 mandates the number * of attempts, the channel each retry uses is left to the implementation */ private getAttemptSchedule; private wakeDestination; /** * Send a frame and report what came back. Concurrent calls are serialized, * so their attempts and backoffs do not interleave on air. */ transmitData(data: BytesView, options: MACTransmitOptions): Promise; private withRadio; private transmitDataExclusive; transmitACK(options: MACTransmitAckOptions): Promise; private acknowledgeReceivedFrame; private transmitRoutedAck; private handleReceivedMPDU; /** * Waits until an MPDU matching the predicate is received or a timeout has elapsed. Returns the received message. * @param timeout The number of milliseconds to wait. If the timeout elapses, the returned promise will be rejected * @param predicate A predicate function to test all incoming messages. * @param refreshPredicate A predicate function to test partial messages. If this returns `true` for a message, the timer will be restarted. */ waitForMPDU(predicate: (mpdu: MPDU) => boolean, timeout?: number, abortSignal?: AbortSignal): Promise; destroy(): Promise; } export {}; //# sourceMappingURL=ProtocolController.d.ts.map