import { DataPointAbstract } from './dpts'; import { KnxCemiFrame } from './knx-common'; import { type KnxEventMap, type KnxEventName, type KnxLinkConstructorOptions, type LinkInfo } from './knx-common'; import { KnxGroupSchema } from './types'; type KnxEventListener> = (arg: KnxEventMap[K]) => void; export declare class KnxLink { private readonly events; private readonly connection; private readonly options; /** * Create a KNX/IP tunnel link to a gateway. * * All `options` fields are optional. Defaults applied when omitted: * * | Option | Default | * | --- | --- | * | `maxTelegramsPerSecond` | `24` | * | `maxConcurrentMessages` | `16` | * | `readTimeout` | `10000` | * | `connectionTimeout` | `10000` | * | `maxRetry` | `Infinity` | * | `retryPause` | `3000` | * | `autoReconnect` | `true` | * | `port` | `3671` | */ constructor(ip: string, options?: KnxLinkConstructorOptions); /** * Register a listener for a link event. * * Events: * * | Event | Payload | * | --- | --- | * | `error` | `KnxLinkException` | * | `cemi-frame` | `KnxCemiFrame` | * | `connecting` | `{ ip, port }` | * | `network-connection-established` | `{ ip, port }` | * | `starting-session` | `{ ip, port }` | * | `connected` | `LinkInfo` | * | `reconnecting` | `{ delayMs }` | * | `disconnected` | `{ reason }` | */ on>(eventName: K, listener: KnxEventListener): this; /** Remove a listener previously registered with {@link on} or {@link once}. */ off>(eventName: K, listener: KnxEventListener): this; /** Register a one-shot listener; it is removed automatically after the first invocation. */ once>(eventName: K, listener: KnxEventListener): this; /** Emit an event to registered listeners. Returns `true` when at least one listener handled it. */ emit>(eventName: K, arg: KnxEventMap[K]): boolean; /** * Open a KNX/IP tunnel to the gateway. * * Register an `error` listener with {@link on} before calling this method; otherwise * unhandled errors may crash the process and a console warning is printed. * * Retries with `maxRetry` / `retryPause` when the gateway rejects the connection. * Throws `CONNECTION_ALREADY_ESTABLISHED` or `CONNECTION_IN_PROGRESS` on a second call. */ connect(): Promise; /** * Return metadata about the active tunnel session. * * @throws `NO_CONNECTION` when {@link connect} has not completed successfully. */ getLinkInfo(): LinkInfo; /** * Send a raw CEMI frame through the tunnel. * * Prefer typed group operations via {@link group} for normal read/write traffic. * * @throws `NO_CONNECTION` when the tunnel is not established. */ sendCemiFrame(cemiFrame: Buffer): Promise; /** * Gracefully close the KNX/IP tunnel. * * @remarks * Call this on process shutdown (e.g. `SIGINT`, `SIGTERM`) so the gateway * releases the tunnel channel. Exiting without disconnecting can leave KNX * channels occupied until the gateway times them out. * * Does not trigger automatic reconnect. Throws `NO_CONNECTION` when not connected. */ disconnect(): Promise; /** * Abort an in-flight {@link connect}. No-op when not connecting. * * @remarks * Call when the consumer cancels startup while {@link connect} is still retrying. * Does not replace {@link disconnect} after a successful connection. */ abortConnect(): void; /** * Create a typed client for a group address on this link. * * @template T DPT class from `schema.DataType` (e.g. `DPT_Switch`). * @param schema Group address and DPT class from the schema definition. * @param init Optional callback invoked on the new instance before it is returned. * @returns An instance of `T` bound to `schema.address`. Use `read()`, `write()`, * `onValue()`, and DPT-specific helpers (e.g. `on()` / `off()` on `DPT_Switch`). */ group>({ address, DataType }: KnxGroupSchema, init?: (dataPoint: T) => void): T; } export {}; //# sourceMappingURL=KnxLink.d.ts.map