Skip to main content

Module thread_network_diagnostics

Module thread_network_diagnostics 

Source
Expand description

Thread Network Diagnostics, cluster 0x0035 (Core §11.14).

The largest of the three network diagnostics clusters — sixty-five attributes — and the same shape as the other two: every number belongs to a radio and a Thread stack this crate does not own, so the cluster is a ThreadDriver the integrator implements. It needs no radio to compile or to test; the openthread crate is one source for the numbers, and nothing here depends on it.

§Three kinds of attribute, and three shapes in the trait

  • The network’s state — Channel, RoutingRole, NetworkName, the timestamps — is mandatory and nullable. A driver returns Option, where None is the specification’s null: the Thread interface is not configured or operational. There is no third answer, because a Thread device reports these or is not a Thread device.

  • The tables — NeighborTable, RouteTable, ActiveNetworkFaultsList — are mandatory lists, and empty is a perfectly good answer. A driver returns a slice, which is also the only list shape a no_std crate can hand over without allocating.

  • The counters are conditional on §11.14.4’s features and optional within them. They arrive as MacCounters and MleCounters, one struct each, because that is how a Thread stack hands them over and because forty-two separate trait methods would be forty-two chances to wire one to the wrong attribute. A field left None is a counter the device does not keep, and it belongs out of the Optional list too.

    OverrunCount is the exception: §11.14.6 makes it mandatory within ERRCNT and does not make it nullable, so it is a plain u64 a device claiming ERRCNT has promised to count.

use matter_kit::clusters::thread_network_diagnostics::{
    RoutingRoleEnum, ThreadDriver, ThreadNetworkDiagnostics,
};

struct Stack;
impl ThreadDriver for Stack {
    fn channel(&self) -> Option<u16> { Some(15) }
    fn routing_role(&self) -> Option<RoutingRoleEnum> { Some(RoutingRoleEnum::Router) }
    fn network_name(&self) -> Option<&str> { Some("matter-kit") }
    fn pan_id(&self) -> Option<u16> { Some(0x1234) }
    fn extended_pan_id(&self) -> Option<u64> { Some(0xDEAD_BEEF_0000_0001) }
}

// No feature bits: this driver reports the network and counts nothing.
let cluster = ThreadNetworkDiagnostics::<_, 4>::new(&Stack, 0);

Re-exports§

pub use spec_thread::ConnectionStatusEnum;
pub use spec_thread::ID;
pub use spec_thread::NeighborTableStruct;
pub use spec_thread::NetworkFaultEnum;
pub use spec_thread::OperationalDatasetComponents;
pub use spec_thread::PICS;
pub use spec_thread::REVISION;
pub use spec_thread::RouteTableStruct;
pub use spec_thread::RoutingRoleEnum;
pub use spec_thread::SecurityPolicy;
pub use spec_thread::feature;
pub use spec_thread::event::CONNECTION_STATUS;
pub use spec_thread::event::NETWORK_FAULT_CHANGE;

Structs§

MacCounters
The MACCNT counters of §11.14.6, as a Thread stack hands them over.
MleCounters
The MLECNT counters of §11.14.6 — how often this node changed role, re-attached, or followed a better partition.
ThreadNetworkDiagnostics
The Thread Network Diagnostics cluster (§11.14).
Unknown
The driver for a device with no Thread metrics to report.

Enums§

Event
One of §11.14.8’s events, as the Thread stack noticed it.

Constants§

ALL_OPTIONALprovisional
Every attribute, command and event §11.14 leaves to the product, including §2.13’s two provisional attributes.
COUNTERS
Every counter §11.14.4’s MLECNT and MACCNT features bring, each of which §11.14.6 leaves optional within its feature.

Traits§

ThreadDriver
What a device’s Thread stack can report (§11.14.6).

Functions§

conforming
Builds a descriptor for a feature map and the optional elements a product implements.