class Matter::FailsafeTimer

Overview

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

Defined in:

matter/failsafe_timer.cr

Constant Summary

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

Constructors

Instance Method Summary

Constructor Detail

def self.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


[View source]

Instance Method Detail

def associated_fabric_index : UInt8 | Nil #

[View source]
def associated_fabric_index=(associated_fabric_index : UInt8 | Nil) #

[View source]
def close : Nil #

Close and cleanup the failsafe timer

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


[View source]
def complete : Nil #

Mark the failsafe as completed successfully

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


[View source]
def cumulative_time_remaining : Time::Span | Nil #

Get time remaining on cumulative timer (nil if expired)


[View source]
def expire : Nil #

Trigger failsafe expiration and invoke rollback callback

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


[View source]
def primary_time_remaining : Time::Span | Nil #

Get time remaining on primary timer (nil if expired)


[View source]
def 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)


[View source]
def running? : Bool #

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


[View source]