Get time remaining on primary timer (nil if expired)
class
Matter::FailsafeTimer
- Matter::FailsafeTimer
- Reference
- Object
Overview
FailsafeTimer manages dual timers for commissioning safety
The failsafe mechanism uses two timers:
- Primary timer: Can be re-armed/extended on subsequent ArmFailSafe calls
- 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.crConstant Summary
-
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
Instance Method Summary
- #associated_fabric_index : UInt8 | Nil
- #associated_fabric_index=(associated_fabric_index : UInt8 | Nil)
-
#close : Nil
Close and cleanup the failsafe timer
-
#complete : Nil
Mark the failsafe as completed successfully
-
#cumulative_time_remaining : Time::Span | Nil
Get time remaining on cumulative timer (nil if expired)
-
#expire : Nil
Trigger failsafe expiration and invoke rollback callback
-
#primary_time_remaining : Time::Span | Nil
Get time remaining on primary timer (nil if expired)
-
#re_arm(fabric_index : UInt8 | Nil, expiry_length : UInt16) : Nil
Re-arm the primary timer with a new expiry duration
-
#running? : Bool
Check if failsafe is still running (not completed or expired)
Constructor Detail
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
Instance Method Detail
Close and cleanup the failsafe timer
Should be called when the context is destroyed to ensure clean shutdown.
Mark the failsafe as completed successfully
Stops both timers and prevents expiration callback from firing. Called when CommissioningComplete succeeds.
Get time remaining on cumulative timer (nil if expired)
Trigger failsafe expiration and invoke rollback callback
Called automatically when either timer expires, or manually via re_arm(0).
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)