import { EventEmitter } from "events"; import { KNXBusInterface } from "../types"; import { CEMIFrame } from "../frames"; /** * KNXnet/IP Tunneling implementation that provides point-to-point exchange of KNX telegrams * over an IP network between a KNXnet/IP server and client. * * Features: * - Full KNXnet/IP tunneling protocol compliance with proper sequence number handling * - Automatic retry logic with 1-second timeouts per specification * - Connection management with heartbeat and state monitoring * - Support for both normal tunneling and busmonitor modes * - Device configuration capabilities (property read/write) * * Sequence Number Handling: * - Validates incoming sequence numbers per KNXnet/IP specification * - Handles duplicates (sequence n-1) by acknowledging but not processing * - Triggers reconnection on invalid sequence numbers * - Implements proper retry logic with connection termination on failures */ export declare class KNXNetTunnelingImpl extends EventEmitter implements KNXBusInterface { private socket; private isConnected; private readonly options; private connectionId; private sequenceCounter; private expectedIncomingSequence; private pendingRequests; private heartbeatTimer; private connectionTimer; private serverEndpoint; private localEndpoint; private readonly busmonitorMode; constructor(serverAddress: string, serverPort?: number, localPort?: number, busmonitorMode?: boolean); open(): Promise; /** * Sends a cEMI frame through the tunneling connection with proper sequence number handling. * * Implements KNXnet/IP compliant retry logic: * - 1-second timeout for acknowledgments * - Single retry with same sequence number on timeout/error * - Connection termination on repeated failures * * @param frame The cEMI frame to send * @throws Error if not connected, in busmonitor mode, or transmission fails */ send(frame: CEMIFrame): Promise; close(): Promise; /** * Check if this connection is in busmonitor mode */ isBusmonitorMode(): boolean; writeProperty(interfaceObject: number, objectInstance: number, propertyId: number, numberOfElements: number, startIndex: number, data: Buffer): Promise; readProperty(interfaceObject: number, objectInstance: number, propertyId: number, numberOfElements: number, startIndex: number): Promise; on(event: "recv", listener: (frame: CEMIFrame) => void): this; on(event: "error", listener: (error: Error) => void): this; private setupSocket; private establishConnection; private createDeviceConfigurationFrame; private createConnectRequestFrame; /** * Creates a TUNNELLING_REQUEST frame with proper sequence number handling. * * @param cemiFrame The cEMI frame data to encapsulate * @returns Object containing the complete frame buffer and sequence number used */ private createTunnelingRequestFrame; private parseHPAI; private isConnectResponse; private parseConnectResponse; private parseTunnelingAck; private handleIncomingMessage; /** * Processes incoming TUNNELLING_REQUEST frames with proper sequence number validation. * * Implements KNXnet/IP sequence number validation: * - Expected sequence: Process frame and send ACK * - Duplicate (n-1): Send ACK but don't process (silent discard) * - Invalid sequence: Send NACK and emit error for reconnection * * @param msg The raw TUNNELLING_REQUEST message buffer */ private handleTunnelingRequest; private sendTunnelingAck; private handleConnectionStateRequest; /** * Validates incoming sequence numbers according to KNXnet/IP specification. * * @param sequence The received sequence number (0-255) * @returns Validation result with flags for processing decisions * * Sequence Number Rules: * - Expected sequence (n): Valid, process frame and increment expected counter * - Previous sequence (n-1): Valid duplicate, acknowledge but don't process * - Any other sequence: Invalid, send NACK and trigger reconnection */ private isValidIncomingSequence; /** * Handles timeout for TUNNELLING_REQUEST frames according to KNXnet/IP specification. * * Per spec: If no TUNNELLING_ACK is received within 1 second, retry once with the same * sequence number. If retry also fails, terminate the connection. * * @param sequence The sequence number of the timed-out request */ private handleTunnelingTimeout; /** * Processes incoming TUNNELLING_ACK frames and manages pending requests. * * Validates that the ACK sequence number matches a pending request and handles * success/error responses. On error ACKs, implements retry logic per specification. * * @param msg The raw TUNNELLING_ACK message buffer */ private handleTunnelingAck; private sendConnectionStateResponse; private sendDisconnectRequest; private startHeartbeat; private sendConnectionStateRequest; private cleanup; } //# sourceMappingURL=tunneling.d.ts.map