/** * Device discovery for authenticated HTTP TP-Link Kasa devices. * * Discovers devices on port 80 by attempting TPAP, KLAP, and AES handshakes, * then creates adapter instances compatible with the existing HomeKit * device layer. */ import { EventEmitter } from "node:events"; import { KlapBulb } from "./KlapBulb.js"; import { KlapPlug } from "./KlapPlug.js"; import type { KasaCredentials } from "./types.js"; type KlapDevice = KlapPlug | KlapBulb; interface DiscoveryOptions { credentials?: KasaCredentials; devices?: Array<{ host: string; port?: number; }>; broadcast?: string; discoveryInterval: number; timeout?: number; } export declare class KlapDiscovery extends EventEmitter { private readonly credentials; private readonly explicitDevices; private readonly broadcast; private readonly discoveryInterval; private readonly timeout; private readonly knownDevices; private intervalTimer; private running; constructor(options: DiscoveryOptions); /** * Begin periodic discovery. Runs an initial probe immediately, then * repeats every `discoveryInterval` ms. */ start(): void; /** * Stop discovery and close all transport sessions. */ stop(): void; /** * Returns the map of currently known devices keyed by device ID. */ getDevices(): Map; private discoveryInProgress; private runDiscoveryCycle; /** * Check all known devices by sending getSysInfo. If a device fails to * respond, mark it offline and emit 'device-offline'. */ private checkExistingDevices; /** * Build the list of IPs to probe. Combines explicit device list with * optional subnet scanning. */ private buildCandidateList; /** * Probe a single candidate IP: * 1. Detect protocol (TPAP, KLAP, or AES) * 2. Create transport and complete handshake * 3. Fetch sysinfo to identify the device * 4. Create adapter and emit events */ private probeCandidate; /** * Detect which protocol the device speaks, create the appropriate * transport, and complete the handshake. Returns null if the device * does not respond to either protocol. */ private establishTransport; /** * Fetch device sysinfo by trying the legacy IOT protocol first, * then falling back to the SMART protocol. */ private fetchSysinfo; /** * Classify the device, then either update an existing record or create * a new adapter and emit discovery events. */ private registerDevice; } export {}; //# sourceMappingURL=KlapDiscovery.d.ts.map