pub struct Commissioner { /* private fields */ }Expand description
The commissioning state machine cursor.
One Commissioner per in-flight commissioning. Send but !Sync.
See module docs in crate::state_machine for the driver-loop
example.
Implementations§
Source§impl Commissioner
impl Commissioner
Sourcepub fn new(cfg: CommissionerConfig<'_>) -> Result<Self, CommissioningError>
pub fn new(cfg: CommissionerConfig<'_>) -> Result<Self, CommissioningError>
Construct a new commissioner from a validated config.
§Errors
Returns CommissioningError::InvalidConfig if any field fails
basic validation: zero commissioner_node_id, zero
assigned_node_id, commissioner_node_id == assigned_node_id,
or all-zero ipk_epoch_key.
Sourcepub fn poll(&mut self) -> Result<Action, CommissioningError>
pub fn poll(&mut self) -> Result<Action, CommissioningError>
Drive the state machine forward.
Returns the next Action the caller must perform. Idempotent:
calling poll twice without an intervening on_response returns
the same Action.
§Errors
Returns the typed error that caused a transition into
Stage::Failed — when this happens, the cursor advances to
Failed and the next poll() call emits an
Action::Abort with a rendered summary of the failure.
Sourcepub fn on_response(
&mut self,
expect: Expectation,
payload: &[u8],
) -> Result<(), CommissioningError>
pub fn on_response( &mut self, expect: Expectation, payload: &[u8], ) -> Result<(), CommissioningError>
Feed a response payload back into the state machine.
expect MUST match the Expectation from the last poll()’s
emitted Action.
§Errors
CommissioningError::OutOfOrderResponseif the state machine isn’t currently waiting for a response.CommissioningError::UnexpectedResponseKindifexpectdoesn’t match the lastAction’sExpectation. The cursor does not advance.CommissioningError::MalformedResponseifpayloadfails to decode at the cluster-command level.CommissioningError::DeviceImStatusif the device returned a non-OK Interaction Model status.
Any error other than OutOfOrderResponse and
UnexpectedResponseKind transitions the cursor to
Stage::Failed; the next poll() call emits
Action::Abort with a rendered summary.
Sourcepub fn on_case_established(&mut self) -> Result<(), CommissioningError>
pub fn on_case_established(&mut self) -> Result<(), CommissioningError>
Signal that CASE establishment (mDNS find-operational + the
SIGMA-I handshake — both M6.6 mechanics, owned by the driver)
has succeeded. The state machine advances from
Stage::FindOperationalForComplete to Stage::SendComplete.
§Errors
Returns CommissioningError::OutOfOrderResponse if the state
machine isn’t currently awaiting CASE establishment (i.e., the
cursor is not at FindOperationalForComplete or the
EstablishCase action hasn’t been emitted yet).