Get time remaining on primary timer
class
Matter::FailsafeContext
- Matter::FailsafeContext
- Reference
- Object
Overview
FailsafeContext manages commissioning state and coordinates rollback on failure
The failsafe context is created when ArmFailSafe is invoked and tracks all commissioning state changes (fabric operations, network config, etc.) so that they can be rolled back if the failsafe timer expires.
Matter Core Spec §11.10.7 - General Commissioning Cluster Matter Core Spec §5.5 - Commissioning Flows
Defined in:
matter/failsafe_context.crConstant Summary
-
Log =
::Log.for("matter.failsafe_context")
Constructors
-
.new(associated_fabric_index : UInt8 | Nil, breadcrumb : UInt64, expiry_callback : Proc(Nil))
Create a new failsafe context
Instance Method Summary
-
#added_fabric_index : UInt8 | Nil
Whether a new fabric was added during this context
-
#added_fabric_index=(added_fabric_index : UInt8 | Nil)
Whether a new fabric was added during this context
-
#arm(expiry_length : UInt16, max_cumulative : UInt16) : Nil
Arm the failsafe timer with specified durations
-
#armed? : Bool
Check if the failsafe timer is currently armed
-
#associated_fabric_index : UInt8 | Nil
Fabric index associated with this context (nil for PASE/initial commissioning)
-
#associated_fabric_index=(associated_fabric_index : UInt8 | Nil)
Fabric index associated with this context (nil for PASE/initial commissioning)
-
#breadcrumb : UInt64
Breadcrumb value for progress tracking
-
#breadcrumb=(breadcrumb : UInt64)
Breadcrumb value for progress tracking
-
#close : Nil
Close and cleanup the failsafe context
-
#csr_nonce : Bytes | Nil
CSR nonce for pairing (tracks session ID)
-
#csr_nonce=(csr_nonce : Bytes | Nil)
CSR nonce for pairing (tracks session ID)
-
#cumulative_time_remaining : Time::Span | Nil
Get time remaining on cumulative timer
-
#disarm : Nil
Disarm the failsafe timer (mark as completed without triggering rollback)
-
#for_update_noc : Bool
Whether this is for updating an existing NOC (vs adding new)
-
#for_update_noc=(for_update_noc : Bool)
Whether this is for updating an existing NOC (vs adding new)
-
#mark_for_update_noc : Nil
Mark this context as being for UpdateNOC (vs AddNOC)
-
#matches_fabric?(fabric_index : UInt8 | Nil) : Bool
Validate that fabric index matches this context
-
#max_cumulative_seconds : UInt16
Maximum cumulative failsafe timeout (hard limit)
-
#max_cumulative_seconds=(max_cumulative_seconds : UInt16)
Maximum cumulative failsafe timeout (hard limit)
-
#network_state_snapshot : Hash(String, String) | Nil
Network commissioning state snapshot (for rollback)
-
#network_state_snapshot=(network_state_snapshot : Hash(String, String) | Nil)
Network commissioning state snapshot (for rollback)
-
#noc_update_snapshot : Tuple(UInt8, Bytes, Bytes) | Nil
NOC update snapshot (for UpdateNOC rollback) Stores: (fabric_index, operational_cert, operational_key)
-
#noc_update_snapshot=(noc_update_snapshot : Tuple(UInt8, Bytes, Bytes) | Nil)
NOC update snapshot (for UpdateNOC rollback) Stores: (fabric_index, operational_cert, operational_key)
-
#primary_time_remaining : Time::Span | Nil
Get time remaining on primary timer
-
#record_added_fabric(fabric_index : UInt8) : Nil
Record that a new fabric was added during commissioning
-
#record_csr_nonce(nonce : Bytes) : Nil
Record CSR nonce for session tracking
-
#record_network_state(state : Hash(String, String)) : Nil
Record network commissioning state for rollback
-
#record_noc_update(fabric_index : UInt8, operational_cert : Bytes, operational_key : Bytes) : Nil
Record NOC state before UpdateNOC for rollback
-
#record_regulatory_config(location_type : UInt8, country_code : String) : Nil
Record regulatory config state for rollback
-
#record_root_cert(cert : Bytes) : Nil
Record root certificate for validation
-
#regulatory_config_snapshot : Tuple(UInt8, String) | Nil
Regulatory config snapshot (for rollback)
-
#regulatory_config_snapshot=(regulatory_config_snapshot : Tuple(UInt8, String) | Nil)
Regulatory config snapshot (for rollback)
-
#rollback(fabric_manager : FabricManager | Nil = nil, session_manager : SessionManager | Nil = nil, network_commissioning : Cluster::NetworkCommissioningCluster | Nil = nil, commissioning_window : CommissioningWindow | Nil = nil, general_commissioning : Cluster::GeneralCommissioningCluster | Nil = nil) : Nil
Perform complete rollback of all commissioning state
-
#root_cert : Bytes | Nil
Root certificate bytes (for validation)
-
#root_cert=(root_cert : Bytes | Nil)
Root certificate bytes (for validation)
Constructor Detail
Create a new failsafe context
@param fabric_index Fabric index for CASE sessions (nil for PASE) @param breadcrumb Progress tracking value @param expiry_callback Callback invoked when failsafe expires (performs rollback)
Instance Method Detail
Whether a new fabric was added during this context
Arm the failsafe timer with specified durations
@param expiry_length Primary timer duration in seconds (0 = disarm) @param max_cumulative Maximum cumulative duration in seconds
Fabric index associated with this context (nil for PASE/initial commissioning)
Fabric index associated with this context (nil for PASE/initial commissioning)
Close and cleanup the failsafe context
Should be called when context is destroyed.
Whether this is for updating an existing NOC (vs adding new)
Validate that fabric index matches this context
@param fabric_index Fabric index to validate @return true if matches, false otherwise
Maximum cumulative failsafe timeout (hard limit)
Network commissioning state snapshot (for rollback)
Network commissioning state snapshot (for rollback)
NOC update snapshot (for UpdateNOC rollback) Stores: (fabric_index, operational_cert, operational_key)
NOC update snapshot (for UpdateNOC rollback) Stores: (fabric_index, operational_cert, operational_key)
Record that a new fabric was added during commissioning
This will be rolled back if failsafe expires.
Record CSR nonce for session tracking
@param nonce CSR nonce bytes
Record network commissioning state for rollback
@param state Snapshot of network configuration
Record NOC state before UpdateNOC for rollback
@param fabric_index Fabric index being updated @param operational_cert Current operational certificate @param operational_key Current operational private key
Record regulatory config state for rollback
@param location_type Current regulatory location type (as UInt8) @param country_code Current country code (2-character string)
Record root certificate for validation
@param cert Root certificate bytes
Regulatory config snapshot (for rollback)
Regulatory config snapshot (for rollback)
Perform complete rollback of all commissioning state
This implements the 9-step rollback sequence from Matter spec:
- Revoke added fabric (if AddNOC was used)
- Revert UpdateNOC changes
- Restore network commissioning state
- Clear PASE sessions
- Reset breadcrumb to 0
- Close commissioning windows
- Clear CSR session
- Reset regulatory config
- Clean up temporary state
@param fabric_manager FabricManager for fabric operations @param session_manager SessionManager for PASE cleanup @param network_commissioning NetworkCommissioning cluster for network state restoration @param commissioning_window For closing windows @param general_commissioning GeneralCommissioning cluster for regulatory config reset