/** * @license * Copyright 2022-2026 Matter.js Authors * SPDX-License-Identifier: Apache-2.0 */ import { NodeActivity } from "#behavior/context/NodeActivity.js"; import { Bytes, Duration, Observable } from "@matter/general"; import { IcdAdvertisement, IcdCheckInBackOff, IcdCheckInSender, IcdCounter } from "@matter/protocol"; import { FabricIndex, NodeId } from "@matter/types"; import { IcdManagement } from "@matter/types/clusters/icd-management"; import { IcdModeState } from "./IcdMode.js"; /** * MRP backoff addend applied while operating as an ICD. An ICD in Active Mode polls for the acknowledgement only at * its fast-poll cadence, so the sender pads its retransmission backoff by one such interval. Mirrors the default of * CHIP's `ICDConfigurationData::GetFastPollingInterval()`. * @see {@link MatterSpecification.v161.Core} § 4.12.2.1 */ export declare const ICD_FAST_POLLING_INTERVAL: Duration; declare const IcdManagementLogicBase: import("../../index.js").ClusterBehavior.Type {}, "icdManagement"> & { readonly id: "icdManagement"; }, import("@matter/types").ClusterType.WithSupportedFeatures, import("@matter/types").ClusterType.Concrete, new () => {}, "icdManagement">; /** * Default device-side ICD Management server implementation. Enables the Check-In Protocol Support (CIP) feature and * validates spec constraints on the timing attributes at startup. Use {@link IcdManagementServer.with} to specialize * for additional features, or extend this class to override its behavior. * * ## Idle/active mode * * The server tracks the ICD idle/active mode (distinct from the SIT/LIT {@link IcdManagement.OperatingMode}). matter.js * nodes never truly sleep and stay reachable, so the mode is **fully externally driven** — the device never sleeps or * wakes on its own. It is meant for spec/cert completeness, for verifying a controller against a real ICD peer, and as * power hooks for a node that proxies real sleepy hardware. The device enters active mode at startup and on every * idle→active wake; it stays active until told to sleep. * * Events (subscribe via `events.`): * - `activeModeEntered` — entered active mode (initial power-up or an idle→active wake). On a CIP device this is the * idle→active transition at which Check-Ins are sent (§ 9.15.1). Hook hardware power-up here. * - `idleModeEntered` — entered idle mode. Hook hardware power-down here. * - `mayEnterIdleMode` — the active window (≥ `activeModeDuration`, extended by network activity and StayActive) has * elapsed while quiet: the application may now put the device to sleep. Advisory only — no transition happens. * * Runtime methods: * - {@link requestActiveMode} — wake into active mode for a full active window. * - {@link enterIdleMode} — force idle now (unconditional); pairs with `mayEnterIdleMode`. * - {@link triggerUserActiveMode} — simulate the device-physical User Active Mode Trigger (UAT feature; wakes the * device). UAT exposes no Matter command. * - {@link setOperatingMode} — switch SIT↔LIT at runtime (DSLS feature; orthogonal to idle/active mode). * * Inbound network activity also extends/wakes active mode automatically. Idle/active transitions only happen via these * methods, a StayActiveRequest, or inbound activity — never on an internal timer. * * **For tests / a cert harness:** drive transitions deterministically — call {@link enterIdleMode} to go quiet, then * {@link requestActiveMode}/{@link triggerUserActiveMode} (or send any request to the device) to force the idle→active * transition that triggers Check-In sending. Advance a mock time source to elapse the active window. * * ## Extension points * * Override {@link stayActive} to customize the StayActiveRequest response: return the duration actually promised. * The default drives the mode machine and honors the spec floor (`min(30s, requested)`); override for a custom policy. * * ## Long Idle Time (LITS) * * Enable LITS with `IcdManagementServer.with(IcdManagement.Feature.CheckInProtocolSupport, * IcdManagement.Feature.LongIdleTimeSupport, IcdManagement.Feature.UserActiveModeTrigger)` — CIP and UAT are mandatory * under LITS and `.with` replaces (does not augment) the feature set, so all three must be listed. The mandatory * `operatingMode` attribute has no spec-defined default and must be configured by the application (initialization * throws otherwise); set it to * {@link IcdManagement.OperatingMode.Sit} unless the device starts in LIT. DSLS devices may additionally call * {@link setOperatingMode} to switch SIT↔LIT at runtime. * * ### Dynamic SIT/LIT (DSLS) * * When also enabled via `IcdManagement.Feature.DynamicSitLitSupport`, the application may call * {@link setOperatingMode} at runtime to switch between SIT and LIT even when registrations exist — for example * when a mains-powered device switches to battery. * * ## User Active Mode Trigger (UAT) * * Enable with `IcdManagement.Feature.UserActiveModeTrigger`. The application configures `userActiveModeTriggerHint` * (which physical action wakes the device) and, when the hint requires it, `userActiveModeTriggerInstruction` * (initialization throws if a hint bit that depends on the instruction is set without one). UAT defines no Matter * command — call {@link triggerUserActiveMode} to simulate the physical trigger. * * @see {@link MatterSpecification.v161.Core} § 9.16 */ export declare class IcdManagementBaseServer extends IcdManagementLogicBase { #private; internal: IcdManagementBaseServer.Internal; readonly state: IcdManagementBaseServer.State; readonly events: IcdManagementBaseServer.Events; initialize(): void; /** * Builds the Check-In sender. Override in tests to record sends. Resolution uses the peer's cached operational * address (tagged from its last session, refreshed by mDNS); the send opens a one-shot unsecured Secure Channel * session and transmits unreliably. * * @see {@link MatterSpecification.v161.Core} § 9.15.1 */ protected createCheckInSender(): IcdCheckInSender; [Symbol.asyncDispose](): Promise; /** * @see {@link MatterSpecification.v161.Core} § 9.16.7.1 */ registerClient(request: IcdManagement.RegisterClientRequest): Promise; /** * @see {@link MatterSpecification.v161.Core} § 9.16.7.4 */ stayActiveRequest(request: IcdManagement.StayActiveRequest): IcdManagement.StayActiveResponse; /** * Extend the device's active window by the requested duration and return the duration actually promised: the real * remaining active duration, never less than the spec floor of `min(30s, requested)`. Override for a custom policy. * * @see {@link MatterSpecification.v161.Core} § 9.16.7.5.1.1 */ protected stayActive(requestedDuration: Duration): Duration; /** * Wake the device into Active mode for a full active window (the idle→active transition; on a CIP device this is * where a CIP ICD sends Check-Ins). No-op before the node is online. * * @see {@link MatterSpecification.v161.Core} § 9.15.1 */ requestActiveMode(): void; /** * Simulate the device-physical User Active Mode Trigger (button press, power cycle, etc.): wakes the device into * Active mode. UAT exposes no Matter command — this is a device-side action. * * @see {@link MatterSpecification.v161.Core} § 9.16.6.7 */ triggerUserActiveMode(): void; /** * Put the device into Idle mode (e.g. when the application/test decides to "sleep"). Forces idle unconditionally. * No-op before the node is online. * * @see {@link MatterSpecification.v161.Core} § 9.15.1 */ enterIdleMode(): void; /** * Set the ICD operating mode at runtime. * * Requires the Long Idle Time feature. Without Dynamic SIT/LIT Support the mode is registration-driven and the * requested mode must match the current registration state; with DSLS the mode may be forced either way (e.g. a * mains-powered device dropping to battery). * * @see {@link MatterSpecification.v161.Core} § 9.15.1.6.4 */ setOperatingMode(mode: IcdManagement.OperatingMode): void; /** * Withdraw a forced operating mode set via {@link setOperatingMode}, reverting to the registration-driven mode * (SIT with no registrations, LIT otherwise). A DSLS device calls this when the condition that forced the mode * clears (e.g. a smoke alarm losing mains power and dropping to battery-saving LIT). Requires the Dynamic SIT/LIT * Support feature; a no-op when no override is active. * * @see {@link MatterSpecification.v161.Core} § 9.15.1.6.4 */ withdrawForcedOperatingMode(): void; /** * @see {@link MatterSpecification.v161.Core} § 9.16.7.3 */ unregisterClient(request: IcdManagement.UnregisterClientRequest): Promise; } export declare namespace IcdManagementBaseServer { /** Persisted key entry. */ class IcdKeyEntry { fabricIndex: FabricIndex; checkInNodeId: NodeId; key: Bytes; } class State extends IcdManagementLogicBase.State { /** Persisted ICDToken keys, mirroring the per-registration key not stored in the RegisteredClients attribute. */ icdKeys: IcdKeyEntry[]; } class Internal { icdCounter?: IcdCounter; icdKeys: Map; /** Cached advertisement data read by the DeviceAdvertiser provider outside a behavior transaction. */ currentIcdAdvertisement?: IcdAdvertisement; /** Runtime-only; not persisted, so a restart reverts to the registration-driven mode. {@link IcdManagementBaseServer.setOperatingMode} */ forcedOperatingMode?: IcdManagement.OperatingMode; /** Idle/active mode machine; created once on first online, (re)started on each subsequent online. */ modeState?: IcdModeState; /** Direct NodeActivity.inactive subscription, stored for cleanup (reactTo would recurse). */ inactiveObserver?: { inactive: NodeActivity["inactive"]; observer: () => void; }; /** Per-client Check-In back-off; runtime-only, created on first online. */ checkInBackOff?: IcdCheckInBackOff; /** Check-In sender; built via createCheckInSender(), overridable in tests. */ checkInSender?: IcdCheckInSender; /** True while a Check-In send pass is in flight, to prevent overlapping passes on rapid re-wakes. */ sendingCheckIns?: boolean; } class Events extends IcdManagementLogicBase.Events { /** Idle→Active transition (also fires on initial power-up); hook hardware power-up / Check-In send. */ activeModeEntered: Observable; /** Active→Idle transition; hook hardware power-down. */ idleModeEntered: Observable; /** Active window elapsed and quiet: the app may now put the device to sleep via enterIdleMode. */ mayEnterIdleMode: Observable; } const ExtensionInterface: { stayActive(requestedDuration: Duration): Duration; requestActiveMode(): void; enterIdleMode(): void; triggerUserActiveMode(): void; }; } declare const IcdManagementServer_base: import("../../index.js").ClusterBehavior.Type, { checkInProtocolSupport: true; dynamicSitLitSupport: false; longIdleTimeSupport: false; userActiveModeTrigger: false; }>, import("@matter/types").ClusterType.Concrete, typeof IcdManagementBaseServer.Internal, "icdManagement">; /** * The default {@link IcdManagementBehavior} server implementation, with the Check-In Protocol Support feature. * * The active feature set is reset to CIP-only here even though the logic base includes LITS. This matches the * OnOff/SmokeCoAlarm pattern: the base composes all features for type safety, the exported class narrows to the * deployed set. To also enable LITS use * `IcdManagementServer.with(IcdManagement.Feature.CheckInProtocolSupport, IcdManagement.Feature.LongIdleTimeSupport)`. */ export declare class IcdManagementServer extends IcdManagementServer_base { } export {}; //# sourceMappingURL=IcdManagementServer.d.ts.map