pub struct NetworkCommissioning<'a, D: NetworkDriver, const N: usize> {
pub driver: &'a D,
pub fail_safe: &'a RefCell<FailSafe>,
pub capabilities: Capabilities<'a>,
/* private fields */
}Expand description
One Network Commissioning instance: one interface, one Networks list, one driver.
The fail-safe is shared with General Commissioning and Operational Credentials, because it is node state and because §11.10.7.2.2 step 5 reverts this list when it expires.
Fields§
§driver: &'a DThe interface’s radio, or EthernetDriver for a wire.
fail_safe: &'a RefCell<FailSafe>The node’s fail-safe. Every command here requires it armed.
capabilities: Capabilities<'a>The fixed capability values this instance reports.
Implementations§
Source§impl<'a, D: NetworkDriver, const N: usize> NetworkCommissioning<'a, D, N>
impl<'a, D: NetworkDriver, const N: usize> NetworkCommissioning<'a, D, N>
Sourcepub fn new(
driver: &'a D,
fail_safe: &'a RefCell<FailSafe>,
capabilities: Capabilities<'a>,
) -> Self
pub fn new( driver: &'a D, fail_safe: &'a RefCell<FailSafe>, capabilities: Capabilities<'a>, ) -> Self
An instance over a driver.
The three Last* attributes start null: §11.9.6.6 says so — “If no such attempt was
made, or no network configurations exist in the Networks attribute, then this attribute
SHALL be set to null.”
Sourcepub fn descriptor(&self) -> ClusterDescriptor<'static>
pub fn descriptor(&self) -> ClusterDescriptor<'static>
The descriptor matching this instance’s driver.
Sourcepub fn store(&self) -> Ref<'_, NetworkStore<N>>
pub fn store(&self) -> Ref<'_, NetworkStore<N>>
The Networks list.
Sourcepub fn store_mut(&self) -> RefMut<'_, NetworkStore<N>>
pub fn store_mut(&self) -> RefMut<'_, NetworkStore<N>>
The Networks list, mutably — for an Ethernet instance’s
seed, and for a driver reporting a link change.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
InterfaceEnabled (§11.9.6.5).
Sourcepub fn on_fail_safe_expired(&self)
pub fn on_fail_safe_expired(&self)
Reverts the list — §11.10.7.2.2 step 5. Call this when the fail-safe expires.
Sourcepub fn on_commissioning_complete(&self)
pub fn on_commissioning_complete(&self)
Keeps the list — call this on CommissioningComplete.
Source§impl<D: NetworkDriver, const N: usize> NetworkCommissioning<'_, D, N>
impl<D: NetworkDriver, const N: usize> NetworkCommissioning<'_, D, N>
Sourcepub fn scan(
&self,
ssid: Option<&[u8]>,
breadcrumb: Option<u64>,
ctx: &InteractionContext<'_>,
scratch: &mut [u8],
w: &mut TlvWriter<'_>,
tag: Tag,
) -> Result<(), Status>
pub fn scan( &self, ssid: Option<&[u8]>, breadcrumb: Option<u64>, ctx: &InteractionContext<'_>, scratch: &mut [u8], w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>
ScanNetworks (§11.9.7.1) → ScanNetworksResponse (§11.9.7.2).
The results are built into scratch before anything is written to w, because the
response’s NetworkingStatus is field 0 and the results are fields 2 and 3 — and the
status is not known until the driver has finished. Emitting the fields out of order
would be a non-canonical structure (§A.2.4), and guessing the status and rewriting it
would mean a half-written response on the failure path.
Sourcepub fn add_or_update_wifi(
&self,
ssid: &[u8],
credentials: &[u8],
breadcrumb: Option<u64>,
ctx: &InteractionContext<'_>,
w: &mut TlvWriter<'_>,
tag: Tag,
) -> Result<(), Status>
pub fn add_or_update_wifi( &self, ssid: &[u8], credentials: &[u8], breadcrumb: Option<u64>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>
AddOrUpdateWiFiNetwork (§11.9.7.3) → NetworkConfigResponse.
The credentials go to the driver and stop there. §11.9.7.3: “The Credentials associated with the network are not readable after execution of this command, as they do not appear in the Networks attribute, for security reasons.”
Sourcepub fn add_or_update_thread(
&self,
dataset: &[u8],
breadcrumb: Option<u64>,
ctx: &InteractionContext<'_>,
w: &mut TlvWriter<'_>,
tag: Tag,
) -> Result<(), Status>
pub fn add_or_update_thread( &self, dataset: &[u8], breadcrumb: Option<u64>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>
AddOrUpdateThreadNetwork (§11.9.7.4) → NetworkConfigResponse.
“The XPAN ID in the OperationalDataset serves as the NetworkID”, so the dataset is parsed for exactly that one field and otherwise passed through opaque.
Sourcepub fn remove_network(
&self,
id: &[u8],
breadcrumb: Option<u64>,
ctx: &InteractionContext<'_>,
w: &mut TlvWriter<'_>,
tag: Tag,
) -> Result<(), Status>
pub fn remove_network( &self, id: &[u8], breadcrumb: Option<u64>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>
RemoveNetwork (§11.9.7.6) → NetworkConfigResponse.
Trait Implementations§
Source§impl<D: NetworkDriver, const N: usize> Cluster for NetworkCommissioning<'_, D, N>
impl<D: NetworkDriver, const N: usize> Cluster for NetworkCommissioning<'_, D, N>
Source§impl<D: NetworkDriver, const N: usize> ClusterHandler for NetworkCommissioning<'_, D, N>
impl<D: NetworkDriver, const N: usize> ClusterHandler for NetworkCommissioning<'_, D, N>
Source§fn on_lifecycle(&self, event: Lifecycle)
fn on_lifecycle(&self, event: Lifecycle)
The network list is the one thing the fail-safe stages that is not a fabric: §11.10.7.2.2
step 5 reverts it on expiry, and §11.10.7.6 makes it permanent on
CommissioningComplete. A node that never commits reverts to its first snapshot at
the next expiry, whenever that is.
Source§fn read(
&self,
resolved: &Resolved<'_>,
_ctx: &InteractionContext<'_>,
w: &mut TlvWriter<'_>,
tag: Tag,
) -> Result<(), Status>
fn read( &self, resolved: &Resolved<'_>, _ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>
Source§fn write(
&self,
resolved: &Resolved<'_>,
data: &[u8],
_op: WriteOp,
_ctx: &InteractionContext<'_>,
) -> Result<(), Status>
fn write( &self, resolved: &Resolved<'_>, data: &[u8], _op: WriteOp, _ctx: &InteractionContext<'_>, ) -> Result<(), Status>
data — the encoded TLV element, tag included — into the attribute. Read more