import { ChannelConfiguration, type LogConfig, MPDU, type MaybeNotKnown, RFRegion, type RSSI } from "@zwave-js/core"; import { MessageHeaders, RCPMessage, type ZWaveSerialBindingFactory, type ZWaveSerialPortImplementation } from "@zwave-js/serial"; import { type ChannelInfo, RadioCapability } from "@zwave-js/serial/rcp"; import { type BytesView, type DeepPartial, type Expand, TypedEventTarget } from "@zwave-js/shared"; import type { ZWaveOptions } from "../driver/ZWaveOptions.js"; import { type MpduRxInfo, type PHYLayer, type RegionConfig, type TransmitBeamOptions, type TransmitOptions, type TransmitResult, type TxPowerRange } from "./PHYLayer.js"; export interface RCPHostEventCallbacks { ready: () => void; error: (err: Error) => void; "mpdu received": (mpdu: MPDU, info: MpduRxInfo) => void; } export type RCPHostEvents = Extract; export interface RCPHostOptions { /** * Optional log configuration */ logConfig?: Partial; host?: ZWaveOptions["host"]; /** Specify timeouts in milliseconds */ timeouts: { /** how long to wait for an ACK */ ack: number; /** * How long to wait for a controller response. Usually this should never elapse, but when it does, * the driver will abort the transmission and try to recover the controller if it is unresponsive. */ response: number; callback: number; }; } export type PartialRCPHostOptions = Expand> & Partial> & { logConfig?: Partial; }>; export declare class RCPHost extends TypedEventTarget implements PHYLayer { private port; constructor(port: string | ZWaveSerialPortImplementation | ZWaveSerialBindingFactory, options?: PartialRCPHostOptions); private _options; /** * The host bindings used to access file system etc. */ private bindings; private serialFactory; /** The serial port instance */ private serial; private _destroyPromise; private get wasDestroyed(); private _logContainer; private rcpLog; private queue; /** Used to immediately abort the ongoing Serial API command */ private abortSerialAPICommand; /** A list of awaited message headers */ private awaitedMessageHeaders; /** A list of awaited messages */ private awaitedMessages; private supportedFunctionTypes; private rcpFirmwareVersion; private radioLibraryVersion; private radioLibrary; /** Whether a beam transmission is currently being executed by the firmware */ private beamActive; private rfRegion; private channelConfig; private channels; private _txPowerRange; get txPowerRange(): MaybeNotKnown; private _radioCapabilities; get radioCapabilities(): MaybeNotKnown; get regionConfig(): MaybeNotKnown; start(): Promise; private interview; private handleSerialData; private serialport_onData; /** Handles a decoding error and returns the desired reply to the stick */ private handleDecodeError; /** * Sends a low-level message like ACK or NAK immediately * @param header The low-level message to send */ private writeHeader; private writeSerial; private drainTransactionQueue; private executeSerialAPICommand; /** * Sends a message to the Firmware * @param msg The message to send */ queueSerialApiCommand(msg: RCPMessage): Promise; private getFirmwareInfo; queryRegion(): Promise; queryTxPowerRange(): Promise; setRegion(region: RFRegion, channelConfig: ChannelConfiguration): Promise; /** * Transmits an MPDU on the given channel and returns whether the transmit has successfully been executed. * Does not wait for an ACK or anything else. */ transmit(data: BytesView, options: TransmitOptions): Promise; private assertFunctionSupported; /** * Transmits a beam and returns whether it was executed successfully. * The firmware executes the beam on its own and reports back when it is done or was aborted. */ transmitBeam(options: TransmitBeamOptions): Promise; get supportsAbortBeam(): boolean; /** Measures the noise floor on the given channel, in dBm */ measureNoiseFloor(channel: number): Promise; get supportsMeasureNoiseFloor(): boolean; get supportsTransmitReplacements(): boolean; /** Queries the optional features the firmware implements */ queryRadioCapabilities(): Promise; /** * Stops an ongoing beam transmission. Resolves when no beam is running, * either because the firmware stopped one or because there was none. */ abortBeam(): Promise; private handleReceivedMessage; /** * Is called when a Response-type message was received */ private handleResponse; /** * Is called when a Callback-type message was received */ private handleCallback; private handleReceiveCallback; /** * Is called when a Request-type message was received */ private handleRequest; /** * Waits until a matching message header is received or an optional 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 message headers. */ waitForMessageHeader(predicate: (header: MessageHeaders) => boolean, timeout?: number, abortSignal?: AbortSignal): Promise; /** * Waits until an unsolicited serial message is received or an optional 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. */ waitForMessage(predicate: (msg: RCPMessage) => boolean, timeout?: number, refreshPredicate?: (msg: RCPMessage) => boolean, abortSignal?: AbortSignal): Promise; private destroySerialAPIQueue; private destroyWithMessage; /** * Terminates the RCPHost instance and closes the underlying serial connection. * Must be called under any circumstances. */ destroy(): Promise; } //# sourceMappingURL=RCPHost.d.ts.map