Skip to main content

NetworkCommissioning

Struct NetworkCommissioning 

Source
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 D

The 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>

Source

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.”

Source

pub fn descriptor(&self) -> ClusterDescriptor<'static>

The descriptor matching this instance’s driver.

Source

pub fn store(&self) -> Ref<'_, NetworkStore<N>>

The Networks list.

Source

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.

Source

pub fn is_enabled(&self) -> bool

InterfaceEnabled (§11.9.6.5).

Source

pub fn on_fail_safe_expired(&self)

Reverts the list — §11.10.7.2.2 step 5. Call this when the fail-safe expires.

Source

pub fn on_commissioning_complete(&self)

Keeps the list — call this on CommissioningComplete.

Source§

impl<D: NetworkDriver, const N: usize> NetworkCommissioning<'_, D, N>

Source

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.

Source

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.”

Source

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.

Source

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.

Source

pub fn reorder_network( &self, id: &[u8], index: u8, breadcrumb: Option<u64>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

ReorderNetwork (§11.9.7.10) → NetworkConfigResponse.

Source

pub fn connect_network( &self, id: &[u8], breadcrumb: Option<u64>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

ConnectNetwork (§11.9.7.8) → ConnectNetworkResponse (§11.9.7.9).

Trait Implementations§

Source§

impl<D: NetworkDriver, const N: usize> Cluster for NetworkCommissioning<'_, D, N>

Source§

const ID: ClusterId = ID

The cluster id this implementation serves.
Source§

impl<D: NetworkDriver, const N: usize> ClusterHandler for NetworkCommissioning<'_, D, N>

Source§

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>

Writes the value of resolved’s attribute under tag. Read more
Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], _op: WriteOp, _ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Writes data — the encoded TLV element, tag included — into the attribute. Read more
Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Runs a command. Read more
Source§

fn data_version(&self, _resolved: &Resolved<'_>) -> Option<u32>

The cluster instance’s data version (§7.10.3), if it tracks one. Read more

Auto Trait Implementations§

§

impl<'a, D, const N: usize> !Freeze for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> !RefUnwindSafe for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> !Send for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> !Sync for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> !UnwindSafe for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> Forget for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> Move for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> Unpin for NetworkCommissioning<'a, D, N>

§

impl<'a, D, const N: usize> UnsafeUnpin for NetworkCommissioning<'a, D, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.