Skip to main content

matter_kit/clusters/generated/
network_commissioning.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// Network Commissioning — cluster 0x0031.
4//
5// Regenerate with `cargo xtask clusters --dm <checkout>/data_model/1.6`; `cargo xtask check`
6// is the CI gate that keeps this file honest. The XML itself is not vendored here — it
7// carries the CSA's own copyright notice and is not redistributable.
8
9//! Network Commissioning (cluster `0x0031`, revision 2).
10//!
11//! 20 identifiers, 3 feature bits, and the specification's own conformance for
12//! every element. `CLUSTER` is the whole table.
13
14#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23    ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26/// The cluster id.
27pub const ID: ClusterId = 0x0031;
28
29/// The highest revision the specification's history defines — what `ClusterRevision`
30/// must report (Core §7.13.1).
31pub const REVISION: u16 = 2;
32
33/// The PICS code, which a certification declaration names the cluster by.
34pub const PICS: &str = "CNET";
35
36/// The `FeatureMap` bits (Core §7.13.2).
37///
38/// A feature has conformance of its own: a device may not claim one the
39/// specification forbids it alongside another.
40pub mod feature {
41    /// Wi-Fi related features
42    ///
43    /// Code `WI`, bit 0.
44    pub const WI_FI_NETWORK_INTERFACE: u32 = 1 << 0;
45    /// Thread related features
46    ///
47    /// Code `TH`, bit 1.
48    pub const THREAD_NETWORK_INTERFACE: u32 = 1 << 1;
49    /// Ethernet related features
50    ///
51    /// Code `ET`, bit 2.
52    pub const ETHERNET_NETWORK_INTERFACE: u32 = 1 << 2;
53}
54
55/// Every feature bit, with its conformance.
56pub const FEATURES: &[Feature] = &[
57    Feature {
58        bit: 0,
59        code: "WI",
60        name: "WiFiNetworkInterface",
61        conform: Conform::OPTIONAL,
62    },
63    Feature {
64        bit: 1,
65        code: "TH",
66        name: "ThreadNetworkInterface",
67        conform: Conform::OPTIONAL,
68    },
69    Feature {
70        bit: 2,
71        code: "ET",
72        name: "EthernetNetworkInterface",
73        conform: Conform::OPTIONAL,
74    },
75];
76
77/// The attribute ids.
78pub mod attribute {
79    use crate::im::AttributeId;
80
81    /// `MaxNetworks`.
82    pub const MAX_NETWORKS: AttributeId = 0x00;
83    /// `Networks`.
84    pub const NETWORKS: AttributeId = 0x01;
85    /// `ScanMaxTimeSeconds`.
86    pub const SCAN_MAX_TIME_SECONDS: AttributeId = 0x02;
87    /// `ConnectMaxTimeSeconds`.
88    pub const CONNECT_MAX_TIME_SECONDS: AttributeId = 0x03;
89    /// `InterfaceEnabled`.
90    pub const INTERFACE_ENABLED: AttributeId = 0x04;
91    /// `LastNetworkingStatus`.
92    pub const LAST_NETWORKING_STATUS: AttributeId = 0x05;
93    /// `LastNetworkID`.
94    pub const LAST_NETWORK_ID: AttributeId = 0x06;
95    /// `LastConnectErrorValue`.
96    pub const LAST_CONNECT_ERROR_VALUE: AttributeId = 0x07;
97    /// `SupportedWiFiBands`.
98    pub const SUPPORTED_WI_FI_BANDS: AttributeId = 0x08;
99    /// `SupportedThreadFeatures`.
100    pub const SUPPORTED_THREAD_FEATURES: AttributeId = 0x09;
101    /// `ThreadVersion`.
102    pub const THREAD_VERSION: AttributeId = 0x0A;
103}
104
105/// The command ids.
106pub mod command {
107    use crate::im::CommandId;
108
109    /// `ScanNetworks`.
110    pub const SCAN_NETWORKS: CommandId = 0x00;
111    /// `ScanNetworksResponse`.
112    pub const SCAN_NETWORKS_RESPONSE: CommandId = 0x01;
113    /// `AddOrUpdateWiFiNetwork`.
114    pub const ADD_OR_UPDATE_WI_FI_NETWORK: CommandId = 0x02;
115    /// `AddOrUpdateThreadNetwork`.
116    pub const ADD_OR_UPDATE_THREAD_NETWORK: CommandId = 0x03;
117    /// `RemoveNetwork`.
118    pub const REMOVE_NETWORK: CommandId = 0x04;
119    /// `NetworkConfigResponse`.
120    pub const NETWORK_CONFIG_RESPONSE: CommandId = 0x05;
121    /// `ConnectNetwork`.
122    pub const CONNECT_NETWORK: CommandId = 0x06;
123    /// `ConnectNetworkResponse`.
124    pub const CONNECT_NETWORK_RESPONSE: CommandId = 0x07;
125    /// `ReorderNetwork`.
126    pub const REORDER_NETWORK: CommandId = 0x08;
127}
128
129/// `NetworkCommissioningStatusEnum`.
130#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
131#[repr(u8)]
132pub enum NetworkCommissioningStatusEnum {
133    /// OK, no error
134    Success = 0,
135    /// Value Outside Range
136    OutOfRange = 1,
137    /// A collection would exceed its size limit
138    BoundsExceeded = 2,
139    /// The NetworkID is not among the collection of added networks
140    NetworkIDNotFound = 3,
141    /// The NetworkID is already among the collection of added networks
142    DuplicateNetworkID = 4,
143    /// Cannot find AP: SSID Not found
144    NetworkNotFound = 5,
145    /// Cannot find AP: Mismatch on band/channels/regulatory domain / 2.4GHz vs 5GHz
146    RegulatoryError = 6,
147    /// Cannot associate due to authentication failure
148    AuthFailure = 7,
149    /// Cannot associate due to unsupported security mode
150    UnsupportedSecurity = 8,
151    /// Other association failure
152    OtherConnectionFailure = 9,
153    /// Failure to generate an IPv6 address
154    IPV6Failed = 10,
155    /// Failure to bind Wi-Fi +<->+ IP interfaces
156    IPBindFailed = 11,
157    /// Unknown error
158    UnknownError = 12,
159}
160
161impl NetworkCommissioningStatusEnum {
162    /// Reads a wire value, or `None` for one this revision does not define.
163    #[must_use]
164    pub const fn from_value(value: u8) -> Option<Self> {
165        match value {
166            0 => Some(Self::Success),
167            1 => Some(Self::OutOfRange),
168            2 => Some(Self::BoundsExceeded),
169            3 => Some(Self::NetworkIDNotFound),
170            4 => Some(Self::DuplicateNetworkID),
171            5 => Some(Self::NetworkNotFound),
172            6 => Some(Self::RegulatoryError),
173            7 => Some(Self::AuthFailure),
174            8 => Some(Self::UnsupportedSecurity),
175            9 => Some(Self::OtherConnectionFailure),
176            10 => Some(Self::IPV6Failed),
177            11 => Some(Self::IPBindFailed),
178            12 => Some(Self::UnknownError),
179            _ => None,
180        }
181    }
182
183    /// Its wire value.
184    #[must_use]
185    pub const fn value(self) -> u8 {
186        self as u8
187    }
188}
189
190impl ToTlv for NetworkCommissioningStatusEnum {
191    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
192        self.value().to_tlv(w, tag)
193    }
194}
195
196impl<'a> FromTlv<'a> for NetworkCommissioningStatusEnum {
197    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
198        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
199        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
200    }
201}
202
203/// `WiFiBandEnum`.
204#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
205#[repr(u8)]
206pub enum WiFiBandEnum {
207    /// 2.4GHz - 2.401GHz to 2.495GHz (802.11b/g/n/ax)
208    N2G4 = 0,
209    /// 3.65GHz - 3.655GHz to 3.695GHz (802.11y)
210    N3G65 = 1,
211    /// 5GHz - 5.150GHz to 5.895GHz (802.11a/n/ac/ax)
212    N5G = 2,
213    /// 6GHz - 5.925GHz to 7.125GHz (802.11ax / Wi-Fi 6E)
214    N6G = 3,
215    /// 60GHz - 57.24GHz to 70.20GHz (802.11ad/ay)
216    N60G = 4,
217    /// Sub-1GHz - 755MHz to 931MHz (802.11ah)
218    N1G = 5,
219}
220
221impl WiFiBandEnum {
222    /// Reads a wire value, or `None` for one this revision does not define.
223    #[must_use]
224    pub const fn from_value(value: u8) -> Option<Self> {
225        match value {
226            0 => Some(Self::N2G4),
227            1 => Some(Self::N3G65),
228            2 => Some(Self::N5G),
229            3 => Some(Self::N6G),
230            4 => Some(Self::N60G),
231            5 => Some(Self::N1G),
232            _ => None,
233        }
234    }
235
236    /// Its wire value.
237    #[must_use]
238    pub const fn value(self) -> u8 {
239        self as u8
240    }
241}
242
243impl ToTlv for WiFiBandEnum {
244    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
245        self.value().to_tlv(w, tag)
246    }
247}
248
249impl<'a> FromTlv<'a> for WiFiBandEnum {
250    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
251        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
252        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
253    }
254}
255
256bitflags::bitflags! {
257    /// `ThreadCapabilitiesBitmap`.
258    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
259    pub struct ThreadCapabilitiesBitmap: u8 {
260        /// Thread Border Router functionality is present
261        const IS_BORDER_ROUTER_CAPABLE = 1 << 0;
262        /// Router mode is supported (interface could be in router or REED mode)
263        const IS_ROUTER_CAPABLE = 1 << 1;
264        /// Sleepy end-device mode is supported
265        const IS_SLEEPY_END_DEVICE_CAPABLE = 1 << 2;
266        /// Device is a full Thread device (opposite of Minimal Thread Device)
267        const IS_FULL_THREAD_DEVICE = 1 << 3;
268        /// Synchronized sleepy end-device mode is supported
269        const IS_SYNCHRONIZED_SLEEPY_END_DEVICE_CAPABLE = 1 << 4;
270    }
271}
272
273impl ToTlv for ThreadCapabilitiesBitmap {
274    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
275        self.bits().to_tlv(w, tag)
276    }
277}
278
279impl<'a> FromTlv<'a> for ThreadCapabilitiesBitmap {
280    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
281        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
282        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
283    }
284}
285
286bitflags::bitflags! {
287    /// `WiFiSecurityBitmap`.
288    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
289    pub struct WiFiSecurityBitmap: u8 {
290        /// Supports unencrypted Wi-Fi
291        const UNENCRYPTED = 1 << 0;
292        /// Supports Wi-Fi using WEP security
293        const WEP = 1 << 1;
294        /// Supports Wi-Fi using WPA-Personal security
295        const WPA_PERSONAL = 1 << 2;
296        /// Supports Wi-Fi using WPA2-Personal security
297        const WPA2_PERSONAL = 1 << 3;
298        /// Supports Wi-Fi using WPA3-Personal security
299        const WPA3_PERSONAL = 1 << 4;
300    }
301}
302
303impl ToTlv for WiFiSecurityBitmap {
304    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
305        self.bits().to_tlv(w, tag)
306    }
307}
308
309impl<'a> FromTlv<'a> for WiFiSecurityBitmap {
310    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
311        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
312        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
313    }
314}
315
316/// `NetworkInfoStruct`.
317#[derive(Debug, Clone, Copy, PartialEq)]
318pub struct NetworkInfoStruct<'a> {
319    /// `NetworkID`, field 0.
320    pub network_id: &'a [u8],
321    /// `Connected`, field 1.
322    pub connected: bool,
323}
324
325impl<'a> ToTlv for NetworkInfoStruct<'a> {
326    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
327        w.start_structure(tag)?;
328        self.network_id.to_tlv(w, Tag::Context(0))?;
329        self.connected.to_tlv(w, Tag::Context(1))?;
330        w.end_container()
331    }
332}
333
334impl<'a> FromTlv<'a> for NetworkInfoStruct<'a> {
335    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
336        if element.value.container() != Some(ContainerKind::Structure) {
337            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
338        }
339        let mut network_id = None;
340        let mut connected = None;
341        loop {
342            let Some(field) = reader.next_element()? else {
343                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
344            };
345            if field.value == Value::EndOfContainer {
346                break;
347            }
348            match field.tag.context() {
349                Some(0) => network_id = Some(<&'a [u8]>::from_tlv(reader, &field)?),
350                Some(1) => connected = Some(<bool>::from_tlv(reader, &field)?),
351                // A field this revision does not define. §7.19.2: a receiver
352                // ignores what it does not know rather than refusing the whole
353                // structure, which is what lets a newer peer talk to an older one.
354                _ => reader.skip_value(&field)?,
355            }
356        }
357        Ok(Self {
358            network_id: network_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
359            connected: connected.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
360        })
361    }
362}
363
364/// `ThreadInterfaceScanResultStruct`.
365#[derive(Debug, Clone, Copy, PartialEq)]
366pub struct ThreadInterfaceScanResultStruct<'a> {
367    /// `PanId`, field 0.
368    pub pan_id: u16,
369    /// `ExtendedPanId`, field 1.
370    pub extended_pan_id: u64,
371    /// `NetworkName`, field 2.
372    pub network_name: &'a str,
373    /// `Channel`, field 3.
374    pub channel: u16,
375    /// `Version`, field 4.
376    pub version: u8,
377    /// `ExtendedAddress`, field 5.
378    pub extended_address: &'a [u8],
379    /// `RSSI`, field 6.
380    pub rssi: i8,
381    /// `LQI`, field 7.
382    pub lqi: u8,
383}
384
385impl<'a> ToTlv for ThreadInterfaceScanResultStruct<'a> {
386    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
387        w.start_structure(tag)?;
388        self.pan_id.to_tlv(w, Tag::Context(0))?;
389        self.extended_pan_id.to_tlv(w, Tag::Context(1))?;
390        self.network_name.to_tlv(w, Tag::Context(2))?;
391        self.channel.to_tlv(w, Tag::Context(3))?;
392        self.version.to_tlv(w, Tag::Context(4))?;
393        self.extended_address.to_tlv(w, Tag::Context(5))?;
394        self.rssi.to_tlv(w, Tag::Context(6))?;
395        self.lqi.to_tlv(w, Tag::Context(7))?;
396        w.end_container()
397    }
398}
399
400impl<'a> FromTlv<'a> for ThreadInterfaceScanResultStruct<'a> {
401    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
402        if element.value.container() != Some(ContainerKind::Structure) {
403            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
404        }
405        let mut pan_id = None;
406        let mut extended_pan_id = None;
407        let mut network_name = None;
408        let mut channel = None;
409        let mut version = None;
410        let mut extended_address = None;
411        let mut rssi = None;
412        let mut lqi = None;
413        loop {
414            let Some(field) = reader.next_element()? else {
415                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
416            };
417            if field.value == Value::EndOfContainer {
418                break;
419            }
420            match field.tag.context() {
421                Some(0) => pan_id = Some(<u16>::from_tlv(reader, &field)?),
422                Some(1) => extended_pan_id = Some(<u64>::from_tlv(reader, &field)?),
423                Some(2) => network_name = Some(<&'a str>::from_tlv(reader, &field)?),
424                Some(3) => channel = Some(<u16>::from_tlv(reader, &field)?),
425                Some(4) => version = Some(<u8>::from_tlv(reader, &field)?),
426                Some(5) => extended_address = Some(<&'a [u8]>::from_tlv(reader, &field)?),
427                Some(6) => rssi = Some(<i8>::from_tlv(reader, &field)?),
428                Some(7) => lqi = Some(<u8>::from_tlv(reader, &field)?),
429                // A field this revision does not define. §7.19.2: a receiver
430                // ignores what it does not know rather than refusing the whole
431                // structure, which is what lets a newer peer talk to an older one.
432                _ => reader.skip_value(&field)?,
433            }
434        }
435        Ok(Self {
436            pan_id: pan_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
437            extended_pan_id: extended_pan_id
438                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
439            network_name: network_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
440            channel: channel.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
441            version: version.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
442            extended_address: extended_address
443                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
444            rssi: rssi.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
445            lqi: lqi.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
446        })
447    }
448}
449
450/// `WiFiInterfaceScanResultStruct`.
451#[derive(Debug, Clone, Copy, PartialEq)]
452pub struct WiFiInterfaceScanResultStruct<'a> {
453    /// `Security`, field 0.
454    pub security: WiFiSecurityBitmap,
455    /// `SSID`, field 1.
456    pub ssid: &'a [u8],
457    /// `BSSID`, field 2.
458    pub bssid: &'a [u8],
459    /// `Channel`, field 3.
460    pub channel: u16,
461    /// `WiFiBand`, field 4.
462    pub wi_fi_band: Option<WiFiBandEnum>,
463    /// `RSSI`, field 5.
464    pub rssi: Option<i8>,
465}
466
467impl<'a> ToTlv for WiFiInterfaceScanResultStruct<'a> {
468    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
469        w.start_structure(tag)?;
470        self.security.to_tlv(w, Tag::Context(0))?;
471        self.ssid.to_tlv(w, Tag::Context(1))?;
472        self.bssid.to_tlv(w, Tag::Context(2))?;
473        self.channel.to_tlv(w, Tag::Context(3))?;
474        if let Some(value) = &self.wi_fi_band {
475            value.to_tlv(w, Tag::Context(4))?;
476        }
477        if let Some(value) = &self.rssi {
478            value.to_tlv(w, Tag::Context(5))?;
479        }
480        w.end_container()
481    }
482}
483
484impl<'a> FromTlv<'a> for WiFiInterfaceScanResultStruct<'a> {
485    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
486        if element.value.container() != Some(ContainerKind::Structure) {
487            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
488        }
489        let mut security = None;
490        let mut ssid = None;
491        let mut bssid = None;
492        let mut channel = None;
493        let mut wi_fi_band = None;
494        let mut rssi = None;
495        loop {
496            let Some(field) = reader.next_element()? else {
497                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
498            };
499            if field.value == Value::EndOfContainer {
500                break;
501            }
502            match field.tag.context() {
503                Some(0) => security = Some(<WiFiSecurityBitmap>::from_tlv(reader, &field)?),
504                Some(1) => ssid = Some(<&'a [u8]>::from_tlv(reader, &field)?),
505                Some(2) => bssid = Some(<&'a [u8]>::from_tlv(reader, &field)?),
506                Some(3) => channel = Some(<u16>::from_tlv(reader, &field)?),
507                Some(4) => wi_fi_band = Some(<WiFiBandEnum>::from_tlv(reader, &field)?),
508                Some(5) => rssi = Some(<i8>::from_tlv(reader, &field)?),
509                // A field this revision does not define. §7.19.2: a receiver
510                // ignores what it does not know rather than refusing the whole
511                // structure, which is what lets a newer peer talk to an older one.
512                _ => reader.skip_value(&field)?,
513            }
514        }
515        Ok(Self {
516            security: security.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
517            ssid: ssid.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
518            bssid: bssid.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
519            channel: channel.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
520            wi_fi_band,
521            rssi,
522        })
523    }
524}
525
526/// The fields of `ScanNetworks` (command `0x00`).
527#[derive(Debug, Clone, Copy, PartialEq)]
528pub struct ScanNetworksFields<'a> {
529    /// `SSID`, field 0.
530    pub ssid: Option<Nullable<&'a [u8]>>,
531    /// `Breadcrumb`, field 1.
532    pub breadcrumb: Option<u64>,
533}
534
535impl<'a> ToTlv for ScanNetworksFields<'a> {
536    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
537        w.start_structure(tag)?;
538        if let Some(value) = &self.ssid {
539            value.to_tlv(w, Tag::Context(0))?;
540        }
541        if let Some(value) = &self.breadcrumb {
542            value.to_tlv(w, Tag::Context(1))?;
543        }
544        w.end_container()
545    }
546}
547
548impl<'a> FromTlv<'a> for ScanNetworksFields<'a> {
549    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
550        if element.value.container() != Some(ContainerKind::Structure) {
551            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
552        }
553        let mut ssid = None;
554        let mut breadcrumb = None;
555        loop {
556            let Some(field) = reader.next_element()? else {
557                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
558            };
559            if field.value == Value::EndOfContainer {
560                break;
561            }
562            match field.tag.context() {
563                Some(0) => ssid = Some(<Nullable<&'a [u8]>>::from_tlv(reader, &field)?),
564                Some(1) => breadcrumb = Some(<u64>::from_tlv(reader, &field)?),
565                // A field this revision does not define. §7.19.2: a receiver
566                // ignores what it does not know rather than refusing the whole
567                // structure, which is what lets a newer peer talk to an older one.
568                _ => reader.skip_value(&field)?,
569            }
570        }
571        Ok(Self { ssid, breadcrumb })
572    }
573}
574
575/// The fields of `ScanNetworksResponse` (command `0x01`).
576#[derive(Debug, Clone, Copy, PartialEq)]
577pub struct ScanNetworksResponseFields<'a> {
578    /// `NetworkingStatus`, field 0.
579    pub networking_status: NetworkCommissioningStatusEnum,
580    /// `DebugText`, field 1.
581    pub debug_text: Option<&'a str>,
582    /// `WiFiScanResults`, field 2.
583    pub wi_fi_scan_results: Option<TlvList<'a, WiFiInterfaceScanResultStruct<'a>>>,
584    /// `ThreadScanResults`, field 3.
585    pub thread_scan_results: Option<TlvList<'a, ThreadInterfaceScanResultStruct<'a>>>,
586}
587
588impl<'a> ToTlv for ScanNetworksResponseFields<'a> {
589    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
590        w.start_structure(tag)?;
591        self.networking_status.to_tlv(w, Tag::Context(0))?;
592        if let Some(value) = &self.debug_text {
593            value.to_tlv(w, Tag::Context(1))?;
594        }
595        if let Some(value) = &self.wi_fi_scan_results {
596            value.to_tlv(w, Tag::Context(2))?;
597        }
598        if let Some(value) = &self.thread_scan_results {
599            value.to_tlv(w, Tag::Context(3))?;
600        }
601        w.end_container()
602    }
603}
604
605impl<'a> FromTlv<'a> for ScanNetworksResponseFields<'a> {
606    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
607        if element.value.container() != Some(ContainerKind::Structure) {
608            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
609        }
610        let mut networking_status = None;
611        let mut debug_text = None;
612        let mut wi_fi_scan_results = None;
613        let mut thread_scan_results = None;
614        loop {
615            let Some(field) = reader.next_element()? else {
616                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
617            };
618            if field.value == Value::EndOfContainer {
619                break;
620            }
621            match field.tag.context() {
622                Some(0) => {
623                    networking_status =
624                        Some(<NetworkCommissioningStatusEnum>::from_tlv(reader, &field)?)
625                }
626                Some(1) => debug_text = Some(<&'a str>::from_tlv(reader, &field)?),
627                Some(2) => {
628                    wi_fi_scan_results = Some(
629                        <TlvList<'a, WiFiInterfaceScanResultStruct<'a>>>::from_tlv(reader, &field)?,
630                    )
631                }
632                Some(3) => {
633                    thread_scan_results = Some(
634                        <TlvList<'a, ThreadInterfaceScanResultStruct<'a>>>::from_tlv(
635                            reader, &field,
636                        )?,
637                    )
638                }
639                // A field this revision does not define. §7.19.2: a receiver
640                // ignores what it does not know rather than refusing the whole
641                // structure, which is what lets a newer peer talk to an older one.
642                _ => reader.skip_value(&field)?,
643            }
644        }
645        Ok(Self {
646            networking_status: networking_status
647                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
648            debug_text,
649            wi_fi_scan_results,
650            thread_scan_results,
651        })
652    }
653}
654
655/// The fields of `AddOrUpdateWiFiNetwork` (command `0x02`).
656#[derive(Debug, Clone, Copy, PartialEq)]
657pub struct AddOrUpdateWiFiNetworkFields<'a> {
658    /// `SSID`, field 0.
659    pub ssid: &'a [u8],
660    /// `Credentials`, field 1.
661    pub credentials: &'a [u8],
662    /// `Breadcrumb`, field 2.
663    pub breadcrumb: Option<u64>,
664}
665
666impl<'a> ToTlv for AddOrUpdateWiFiNetworkFields<'a> {
667    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
668        w.start_structure(tag)?;
669        self.ssid.to_tlv(w, Tag::Context(0))?;
670        self.credentials.to_tlv(w, Tag::Context(1))?;
671        if let Some(value) = &self.breadcrumb {
672            value.to_tlv(w, Tag::Context(2))?;
673        }
674        w.end_container()
675    }
676}
677
678impl<'a> FromTlv<'a> for AddOrUpdateWiFiNetworkFields<'a> {
679    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
680        if element.value.container() != Some(ContainerKind::Structure) {
681            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
682        }
683        let mut ssid = None;
684        let mut credentials = None;
685        let mut breadcrumb = None;
686        loop {
687            let Some(field) = reader.next_element()? else {
688                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
689            };
690            if field.value == Value::EndOfContainer {
691                break;
692            }
693            match field.tag.context() {
694                Some(0) => ssid = Some(<&'a [u8]>::from_tlv(reader, &field)?),
695                Some(1) => credentials = Some(<&'a [u8]>::from_tlv(reader, &field)?),
696                Some(2) => breadcrumb = Some(<u64>::from_tlv(reader, &field)?),
697                // A field this revision does not define. §7.19.2: a receiver
698                // ignores what it does not know rather than refusing the whole
699                // structure, which is what lets a newer peer talk to an older one.
700                _ => reader.skip_value(&field)?,
701            }
702        }
703        Ok(Self {
704            ssid: ssid.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
705            credentials: credentials.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
706            breadcrumb,
707        })
708    }
709}
710
711/// The fields of `AddOrUpdateThreadNetwork` (command `0x03`).
712#[derive(Debug, Clone, Copy, PartialEq)]
713pub struct AddOrUpdateThreadNetworkFields<'a> {
714    /// `OperationalDataset`, field 0.
715    pub operational_dataset: &'a [u8],
716    /// `Breadcrumb`, field 1.
717    pub breadcrumb: Option<u64>,
718}
719
720impl<'a> ToTlv for AddOrUpdateThreadNetworkFields<'a> {
721    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
722        w.start_structure(tag)?;
723        self.operational_dataset.to_tlv(w, Tag::Context(0))?;
724        if let Some(value) = &self.breadcrumb {
725            value.to_tlv(w, Tag::Context(1))?;
726        }
727        w.end_container()
728    }
729}
730
731impl<'a> FromTlv<'a> for AddOrUpdateThreadNetworkFields<'a> {
732    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
733        if element.value.container() != Some(ContainerKind::Structure) {
734            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
735        }
736        let mut operational_dataset = None;
737        let mut breadcrumb = None;
738        loop {
739            let Some(field) = reader.next_element()? else {
740                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
741            };
742            if field.value == Value::EndOfContainer {
743                break;
744            }
745            match field.tag.context() {
746                Some(0) => operational_dataset = Some(<&'a [u8]>::from_tlv(reader, &field)?),
747                Some(1) => breadcrumb = Some(<u64>::from_tlv(reader, &field)?),
748                // A field this revision does not define. §7.19.2: a receiver
749                // ignores what it does not know rather than refusing the whole
750                // structure, which is what lets a newer peer talk to an older one.
751                _ => reader.skip_value(&field)?,
752            }
753        }
754        Ok(Self {
755            operational_dataset: operational_dataset
756                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
757            breadcrumb,
758        })
759    }
760}
761
762/// The fields of `RemoveNetwork` (command `0x04`).
763#[derive(Debug, Clone, Copy, PartialEq)]
764pub struct RemoveNetworkFields<'a> {
765    /// `NetworkID`, field 0.
766    pub network_id: &'a [u8],
767    /// `Breadcrumb`, field 1.
768    pub breadcrumb: Option<u64>,
769}
770
771impl<'a> ToTlv for RemoveNetworkFields<'a> {
772    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
773        w.start_structure(tag)?;
774        self.network_id.to_tlv(w, Tag::Context(0))?;
775        if let Some(value) = &self.breadcrumb {
776            value.to_tlv(w, Tag::Context(1))?;
777        }
778        w.end_container()
779    }
780}
781
782impl<'a> FromTlv<'a> for RemoveNetworkFields<'a> {
783    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
784        if element.value.container() != Some(ContainerKind::Structure) {
785            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
786        }
787        let mut network_id = None;
788        let mut breadcrumb = None;
789        loop {
790            let Some(field) = reader.next_element()? else {
791                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
792            };
793            if field.value == Value::EndOfContainer {
794                break;
795            }
796            match field.tag.context() {
797                Some(0) => network_id = Some(<&'a [u8]>::from_tlv(reader, &field)?),
798                Some(1) => breadcrumb = Some(<u64>::from_tlv(reader, &field)?),
799                // A field this revision does not define. §7.19.2: a receiver
800                // ignores what it does not know rather than refusing the whole
801                // structure, which is what lets a newer peer talk to an older one.
802                _ => reader.skip_value(&field)?,
803            }
804        }
805        Ok(Self {
806            network_id: network_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
807            breadcrumb,
808        })
809    }
810}
811
812/// The fields of `NetworkConfigResponse` (command `0x05`).
813#[derive(Debug, Clone, Copy, PartialEq)]
814pub struct NetworkConfigResponseFields<'a> {
815    /// `NetworkingStatus`, field 0.
816    pub networking_status: NetworkCommissioningStatusEnum,
817    /// `DebugText`, field 1.
818    pub debug_text: Option<&'a str>,
819    /// `NetworkIndex`, field 2.
820    pub network_index: Option<u8>,
821}
822
823impl<'a> ToTlv for NetworkConfigResponseFields<'a> {
824    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
825        w.start_structure(tag)?;
826        self.networking_status.to_tlv(w, Tag::Context(0))?;
827        if let Some(value) = &self.debug_text {
828            value.to_tlv(w, Tag::Context(1))?;
829        }
830        if let Some(value) = &self.network_index {
831            value.to_tlv(w, Tag::Context(2))?;
832        }
833        w.end_container()
834    }
835}
836
837impl<'a> FromTlv<'a> for NetworkConfigResponseFields<'a> {
838    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
839        if element.value.container() != Some(ContainerKind::Structure) {
840            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
841        }
842        let mut networking_status = None;
843        let mut debug_text = None;
844        let mut network_index = None;
845        loop {
846            let Some(field) = reader.next_element()? else {
847                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
848            };
849            if field.value == Value::EndOfContainer {
850                break;
851            }
852            match field.tag.context() {
853                Some(0) => {
854                    networking_status =
855                        Some(<NetworkCommissioningStatusEnum>::from_tlv(reader, &field)?)
856                }
857                Some(1) => debug_text = Some(<&'a str>::from_tlv(reader, &field)?),
858                Some(2) => network_index = Some(<u8>::from_tlv(reader, &field)?),
859                // A field this revision does not define. §7.19.2: a receiver
860                // ignores what it does not know rather than refusing the whole
861                // structure, which is what lets a newer peer talk to an older one.
862                _ => reader.skip_value(&field)?,
863            }
864        }
865        Ok(Self {
866            networking_status: networking_status
867                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
868            debug_text,
869            network_index,
870        })
871    }
872}
873
874/// The fields of `ConnectNetwork` (command `0x06`).
875#[derive(Debug, Clone, Copy, PartialEq)]
876pub struct ConnectNetworkFields<'a> {
877    /// `NetworkID`, field 0.
878    pub network_id: &'a [u8],
879    /// `Breadcrumb`, field 1.
880    pub breadcrumb: Option<u64>,
881}
882
883impl<'a> ToTlv for ConnectNetworkFields<'a> {
884    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
885        w.start_structure(tag)?;
886        self.network_id.to_tlv(w, Tag::Context(0))?;
887        if let Some(value) = &self.breadcrumb {
888            value.to_tlv(w, Tag::Context(1))?;
889        }
890        w.end_container()
891    }
892}
893
894impl<'a> FromTlv<'a> for ConnectNetworkFields<'a> {
895    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
896        if element.value.container() != Some(ContainerKind::Structure) {
897            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
898        }
899        let mut network_id = None;
900        let mut breadcrumb = None;
901        loop {
902            let Some(field) = reader.next_element()? else {
903                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
904            };
905            if field.value == Value::EndOfContainer {
906                break;
907            }
908            match field.tag.context() {
909                Some(0) => network_id = Some(<&'a [u8]>::from_tlv(reader, &field)?),
910                Some(1) => breadcrumb = Some(<u64>::from_tlv(reader, &field)?),
911                // A field this revision does not define. §7.19.2: a receiver
912                // ignores what it does not know rather than refusing the whole
913                // structure, which is what lets a newer peer talk to an older one.
914                _ => reader.skip_value(&field)?,
915            }
916        }
917        Ok(Self {
918            network_id: network_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
919            breadcrumb,
920        })
921    }
922}
923
924/// The fields of `ConnectNetworkResponse` (command `0x07`).
925#[derive(Debug, Clone, Copy, PartialEq)]
926pub struct ConnectNetworkResponseFields<'a> {
927    /// `NetworkingStatus`, field 0.
928    pub networking_status: NetworkCommissioningStatusEnum,
929    /// `DebugText`, field 1.
930    pub debug_text: Option<&'a str>,
931    /// `ErrorValue`, field 2.
932    pub error_value: Nullable<i32>,
933}
934
935impl<'a> ToTlv for ConnectNetworkResponseFields<'a> {
936    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
937        w.start_structure(tag)?;
938        self.networking_status.to_tlv(w, Tag::Context(0))?;
939        if let Some(value) = &self.debug_text {
940            value.to_tlv(w, Tag::Context(1))?;
941        }
942        self.error_value.to_tlv(w, Tag::Context(2))?;
943        w.end_container()
944    }
945}
946
947impl<'a> FromTlv<'a> for ConnectNetworkResponseFields<'a> {
948    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
949        if element.value.container() != Some(ContainerKind::Structure) {
950            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
951        }
952        let mut networking_status = None;
953        let mut debug_text = None;
954        let mut error_value = None;
955        loop {
956            let Some(field) = reader.next_element()? else {
957                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
958            };
959            if field.value == Value::EndOfContainer {
960                break;
961            }
962            match field.tag.context() {
963                Some(0) => {
964                    networking_status =
965                        Some(<NetworkCommissioningStatusEnum>::from_tlv(reader, &field)?)
966                }
967                Some(1) => debug_text = Some(<&'a str>::from_tlv(reader, &field)?),
968                Some(2) => error_value = Some(<Nullable<i32>>::from_tlv(reader, &field)?),
969                // A field this revision does not define. §7.19.2: a receiver
970                // ignores what it does not know rather than refusing the whole
971                // structure, which is what lets a newer peer talk to an older one.
972                _ => reader.skip_value(&field)?,
973            }
974        }
975        Ok(Self {
976            networking_status: networking_status
977                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
978            debug_text,
979            error_value: error_value.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
980        })
981    }
982}
983
984/// The fields of `ReorderNetwork` (command `0x08`).
985#[derive(Debug, Clone, Copy, PartialEq)]
986pub struct ReorderNetworkFields<'a> {
987    /// `NetworkID`, field 0.
988    pub network_id: &'a [u8],
989    /// `NetworkIndex`, field 1.
990    pub network_index: u8,
991    /// `Breadcrumb`, field 2.
992    pub breadcrumb: Option<u64>,
993}
994
995impl<'a> ToTlv for ReorderNetworkFields<'a> {
996    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
997        w.start_structure(tag)?;
998        self.network_id.to_tlv(w, Tag::Context(0))?;
999        self.network_index.to_tlv(w, Tag::Context(1))?;
1000        if let Some(value) = &self.breadcrumb {
1001            value.to_tlv(w, Tag::Context(2))?;
1002        }
1003        w.end_container()
1004    }
1005}
1006
1007impl<'a> FromTlv<'a> for ReorderNetworkFields<'a> {
1008    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1009        if element.value.container() != Some(ContainerKind::Structure) {
1010            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1011        }
1012        let mut network_id = None;
1013        let mut network_index = None;
1014        let mut breadcrumb = None;
1015        loop {
1016            let Some(field) = reader.next_element()? else {
1017                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1018            };
1019            if field.value == Value::EndOfContainer {
1020                break;
1021            }
1022            match field.tag.context() {
1023                Some(0) => network_id = Some(<&'a [u8]>::from_tlv(reader, &field)?),
1024                Some(1) => network_index = Some(<u8>::from_tlv(reader, &field)?),
1025                Some(2) => breadcrumb = Some(<u64>::from_tlv(reader, &field)?),
1026                // A field this revision does not define. §7.19.2: a receiver
1027                // ignores what it does not know rather than refusing the whole
1028                // structure, which is what lets a newer peer talk to an older one.
1029                _ => reader.skip_value(&field)?,
1030            }
1031        }
1032        Ok(Self {
1033            network_id: network_id.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1034            network_index: network_index.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1035            breadcrumb,
1036        })
1037    }
1038}
1039
1040/// Every attribute the specification defines, with its conformance.
1041pub const ATTRIBUTES: &[Attribute] = &[
1042    Attribute {
1043        id: 0x0000,
1044        name: "MaxNetworks",
1045        kind: "uint8",
1046        access: Access::read_only(Privilege::Administer),
1047        qualities: AttributeQualities::FIXED,
1048        reporting: Reporting::OnChange,
1049        conform: Conform::MANDATORY,
1050    },
1051    Attribute {
1052        id: 0x0001,
1053        name: "Networks",
1054        kind: "list[NetworkInfoStruct]",
1055        access: Access::read_only(Privilege::Administer),
1056        qualities: AttributeQualities::empty(),
1057        reporting: Reporting::OnChange,
1058        conform: Conform::MANDATORY,
1059    },
1060    Attribute {
1061        id: 0x0002,
1062        name: "ScanMaxTimeSeconds",
1063        kind: "uint8",
1064        access: Access::read_only(Privilege::View),
1065        qualities: AttributeQualities::FIXED,
1066        reporting: Reporting::OnChange,
1067        conform: Conform {
1068            clauses: &[Clause {
1069                verdict: Conformance::Mandatory,
1070                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1071            }],
1072        },
1073    },
1074    Attribute {
1075        id: 0x0003,
1076        name: "ConnectMaxTimeSeconds",
1077        kind: "uint8",
1078        access: Access::read_only(Privilege::View),
1079        qualities: AttributeQualities::FIXED,
1080        reporting: Reporting::OnChange,
1081        conform: Conform {
1082            clauses: &[Clause {
1083                verdict: Conformance::Mandatory,
1084                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1085            }],
1086        },
1087    },
1088    Attribute {
1089        id: 0x0004,
1090        name: "InterfaceEnabled",
1091        kind: "bool",
1092        access: Access::read_write_with(Privilege::View, Privilege::Administer),
1093        qualities: AttributeQualities::NON_VOLATILE,
1094        reporting: Reporting::OnChange,
1095        conform: Conform::MANDATORY,
1096    },
1097    Attribute {
1098        id: 0x0005,
1099        name: "LastNetworkingStatus",
1100        kind: "NetworkCommissioningStatusEnum",
1101        access: Access::read_only(Privilege::Administer),
1102        qualities: AttributeQualities::NULLABLE,
1103        reporting: Reporting::OnChange,
1104        conform: Conform::MANDATORY,
1105    },
1106    Attribute {
1107        id: 0x0006,
1108        name: "LastNetworkID",
1109        kind: "octstr",
1110        access: Access::read_only(Privilege::Administer),
1111        qualities: AttributeQualities::NULLABLE,
1112        reporting: Reporting::OnChange,
1113        conform: Conform::MANDATORY,
1114    },
1115    Attribute {
1116        id: 0x0007,
1117        name: "LastConnectErrorValue",
1118        kind: "int32",
1119        access: Access::read_only(Privilege::Administer),
1120        qualities: AttributeQualities::NULLABLE,
1121        reporting: Reporting::OnChange,
1122        conform: Conform::MANDATORY,
1123    },
1124    Attribute {
1125        id: 0x0008,
1126        name: "SupportedWiFiBands",
1127        kind: "list[WiFiBandEnum]",
1128        access: Access::read_only(Privilege::View),
1129        qualities: AttributeQualities::FIXED,
1130        reporting: Reporting::OnChange,
1131        conform: Conform {
1132            clauses: &[Clause {
1133                verdict: Conformance::Mandatory,
1134                when: Condition::Feature(0),
1135            }],
1136        },
1137    },
1138    Attribute {
1139        id: 0x0009,
1140        name: "SupportedThreadFeatures",
1141        kind: "ThreadCapabilitiesBitmap",
1142        access: Access::read_only(Privilege::View),
1143        qualities: AttributeQualities::FIXED,
1144        reporting: Reporting::OnChange,
1145        conform: Conform {
1146            clauses: &[Clause {
1147                verdict: Conformance::Mandatory,
1148                when: Condition::Feature(1),
1149            }],
1150        },
1151    },
1152    Attribute {
1153        id: 0x000A,
1154        name: "ThreadVersion",
1155        kind: "uint16",
1156        access: Access::read_only(Privilege::View),
1157        qualities: AttributeQualities::FIXED,
1158        reporting: Reporting::OnChange,
1159        conform: Conform {
1160            clauses: &[Clause {
1161                verdict: Conformance::Mandatory,
1162                when: Condition::Feature(1),
1163            }],
1164        },
1165    },
1166];
1167
1168/// Every command, with its conformance.
1169pub const COMMANDS: &[Command] = &[
1170    Command {
1171        id: 0x00,
1172        name: "ScanNetworks",
1173        to_server: true,
1174        response: Some(0x01),
1175        access: Access::invoke(Privilege::Administer),
1176        conform: Conform {
1177            clauses: &[Clause {
1178                verdict: Conformance::Mandatory,
1179                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1180            }],
1181        },
1182    },
1183    Command {
1184        id: 0x01,
1185        name: "ScanNetworksResponse",
1186        to_server: false,
1187        response: None,
1188        access: Access::invoke(Privilege::Operate),
1189        conform: Conform {
1190            clauses: &[Clause {
1191                verdict: Conformance::Mandatory,
1192                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1193            }],
1194        },
1195    },
1196    Command {
1197        id: 0x02,
1198        name: "AddOrUpdateWiFiNetwork",
1199        to_server: true,
1200        response: Some(0x05),
1201        access: Access::invoke(Privilege::Administer),
1202        conform: Conform {
1203            clauses: &[Clause {
1204                verdict: Conformance::Mandatory,
1205                when: Condition::Feature(0),
1206            }],
1207        },
1208    },
1209    Command {
1210        id: 0x03,
1211        name: "AddOrUpdateThreadNetwork",
1212        to_server: true,
1213        response: Some(0x05),
1214        access: Access::invoke(Privilege::Administer),
1215        conform: Conform {
1216            clauses: &[Clause {
1217                verdict: Conformance::Mandatory,
1218                when: Condition::Feature(1),
1219            }],
1220        },
1221    },
1222    Command {
1223        id: 0x04,
1224        name: "RemoveNetwork",
1225        to_server: true,
1226        response: Some(0x05),
1227        access: Access::invoke(Privilege::Administer),
1228        conform: Conform {
1229            clauses: &[Clause {
1230                verdict: Conformance::Mandatory,
1231                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1232            }],
1233        },
1234    },
1235    Command {
1236        id: 0x05,
1237        name: "NetworkConfigResponse",
1238        to_server: false,
1239        response: None,
1240        access: Access::invoke(Privilege::Operate),
1241        conform: Conform {
1242            clauses: &[Clause {
1243                verdict: Conformance::Mandatory,
1244                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1245            }],
1246        },
1247    },
1248    Command {
1249        id: 0x06,
1250        name: "ConnectNetwork",
1251        to_server: true,
1252        response: Some(0x07),
1253        access: Access::invoke(Privilege::Administer),
1254        conform: Conform {
1255            clauses: &[Clause {
1256                verdict: Conformance::Mandatory,
1257                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1258            }],
1259        },
1260    },
1261    Command {
1262        id: 0x07,
1263        name: "ConnectNetworkResponse",
1264        to_server: false,
1265        response: None,
1266        access: Access::invoke(Privilege::Operate),
1267        conform: Conform {
1268            clauses: &[Clause {
1269                verdict: Conformance::Mandatory,
1270                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1271            }],
1272        },
1273    },
1274    Command {
1275        id: 0x08,
1276        name: "ReorderNetwork",
1277        to_server: true,
1278        response: Some(0x05),
1279        access: Access::invoke(Privilege::Administer),
1280        conform: Conform {
1281            clauses: &[Clause {
1282                verdict: Conformance::Mandatory,
1283                when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1284            }],
1285        },
1286    },
1287];
1288
1289/// Every event, with its conformance.
1290pub const EVENTS: &[Event] = &[];
1291
1292/// The whole cluster, as the specification defines it.
1293pub const CLUSTER: Cluster = Cluster {
1294    id: ID,
1295    name: "Network Commissioning",
1296    revision: REVISION,
1297    pics: "CNET",
1298    derived_from: None,
1299    features: FEATURES,
1300    attributes: ATTRIBUTES,
1301    commands: COMMANDS,
1302    events: EVENTS,
1303};