class

Matter::FailsafeTimer

Inherits Reference < Object

FailsafeTimer manages dual timers for commissioning safety

The failsafe mechanism uses two timers:

  1. Primary timer: Can be re-armed/extended on subsequent ArmFailSafe calls
  2. Cumulative timer: Started once, never extended, provides hard limit

Either timer expiring triggers the expiry callback, which performs rollback.

Matter Core Spec ยง11.10.7.2 - ArmFailSafe Command & Fail Safe Context

Constants

Log = ::Log.for("matter.failsafe")

Constructors

new(fabric_index : UInt8 | Nil, expiry_length : UInt16, max_cumulative : UInt16, expiry_callback : Proc(Nil))

Create a new failsafe timer with dual timer architecture

@param fabric_index Fabric index associated with this failsafe context (or nil for PASE) @param expiry_length Primary timer duration in seconds @param max_cumulative Maximum cumulative duration in seconds @param expiry_callback Callback invoked when either timer expires

Source

Instance methods

associated_fabric_index
Source
associated_fabric_index=(associated_fabric_index : UInt8 | Nil)
Source
close

Close and cleanup the failsafe timer

Should be called when the context is destroyed to ensure clean shutdown.

Source
complete

Mark the failsafe as completed successfully

Stops both timers and prevents expiration callback from firing. Called when CommissioningComplete succeeds.

Source
cumulative_time_remaining

Get time remaining on cumulative timer (nil if expired)

Source
expire

Trigger failsafe expiration and invoke rollback callback

Called automatically when either timer expires, or manually via re_arm(0).

Source
primary_time_remaining

Get time remaining on primary timer (nil if expired)

Source
re_arm(fabric_index : UInt8 | Nil, expiry_length : UInt16) : Nil

Re-arm the primary timer with a new expiry duration

The cumulative timer is NOT extended - it continues counting from the original start. This prevents unbounded commissioning by repeated re-arming.

@param fabric_index Must match the associated fabric (or both nil) @param expiry_length New primary timer duration (0 = immediate expiration)

Source
running?

Check if failsafe is still running (not completed or expired)

Source