Skip to main content

SessionParams

Struct SessionParams 

Source
pub struct SessionParams {
    pub idle_interval_ms: u32,
    pub active_interval_ms: u32,
    pub active_threshold_ms: u16,
    pub data_model_revision: u16,
    pub interaction_model_revision: u16,
    pub specification_version: u32,
    pub max_paths_per_invoke: u16,
    pub supported_transports: TransportModes,
    pub max_tcp_message_size: Option<u32>,
}
Expand description

session-parameter-struct — what each side announces about itself during session establishment (Core §4.13.1, Table 23).

It rides in five messages: CASE Sigma1, Sigma2 and Sigma2_Resume, and PASE PBKDFParamRequest and PBKDFParamResponse. Nine fields, and the shape of the struct is not the shape of the schema, deliberately:

TagField§4.13.1Here
1SESSION_IDLE_INTERVALoptionalalways sent
2SESSION_ACTIVE_INTERVALoptionalalways sent — see below
3SESSION_ACTIVE_THRESHOLDoptionalalways sent
4DATA_MODEL_REVISIONmandatorySelf::data_model_revision
5INTERACTION_MODEL_REVISIONmandatorySelf::interaction_model_revision
6SPECIFICATION_VERSIONmandatorySelf::specification_version
7MAX_PATHS_PER_INVOKEmandatorySelf::max_paths_per_invoke
8SUPPORTED_TRANSPORTSmandatorySelf::supported_transports
9MAX_TCP_MESSAGE_SIZEoptionalSelf::max_tcp_message_size

Why no field is an Option except the last. Tags 4–8 have been mandatory since Matter 1.3, so a struct that can omit them is a struct that can represent a message the specification forbids. Tags 1–3 stay optional in the schema, but §4.13.1 adds “if any tag after tag 2 (SESSION_ACTIVE_INTERVAL) is present, then the SESSION_ACTIVE_INTERVAL SHALL also be present” — and tags 4–8 are always present — so tag 2 is mandatory in practice, and sending 1 and 3 alongside it costs eight octets and removes two more Options. What is left optional is the one field that genuinely is: MAX_TCP_MESSAGE_SIZE, which is meaningless on a node that does not speak TCP.

The consequence that matters is that this struct cannot encode to an empty structure. The previous shape — three Options and a derived Default — could, and did: every released CHIP SDK refuses an empty session-parameter-struct, because PairingSession::DecodeSessionParametersIfPresent calls Next() once without guarding it against CHIP_END_OF_TLV where every later call in the same function is guarded. A conformant struct is never empty, so conformance and interoperability close the same hole.

Receiving is the asymmetric half. A peer older than 1.3 sends only tags 1–3, so SessionParams::decode — crate-private, because a peer’s parameters reach this crate only inside a message it parses — starts from SessionParams::legacy_peer, Table 23’s default for every parameter, and overwrites what the peer actually sent. Table 23 requires exactly that: “A Node SHALL use the provided default value for each parameter unless the message recipient Node advertises an alternate value”.

Fields§

§idle_interval_ms: u32

SESSION_IDLE_INTERVAL [1], in milliseconds — “minimum amount of time between sender retries when the destination node is Idle”. Table 23’s default is 500 ms.

§active_interval_ms: u32

SESSION_ACTIVE_INTERVAL [2], in milliseconds — the same when the destination is Active. Table 23’s default is 300 ms.

§active_threshold_ms: u16

SESSION_ACTIVE_THRESHOLD [3], in milliseconds — “minimum amount of time the node SHOULD stay active after network activity”. Table 23’s default is 4000 ms.

§data_model_revision: u16

DATA_MODEL_REVISION [4] — §7.1.1’s revision. crate::DATA_MODEL_REVISION here.

§interaction_model_revision: u16

INTERACTION_MODEL_REVISION [5] — §8.1.1’s revision. crate::im::INTERACTION_MODEL_REVISION here.

§specification_version: u32

SPECIFICATION_VERSION [6] — §11.1.5.22’s four component bytes. crate::SPECIFICATION_VERSION here.

§max_paths_per_invoke: u16

MAX_PATHS_PER_INVOKE [7] — “the maximum number of elements in the InvokeRequests list that the Node is able to process”. §11.1.5.23: “If the MaxPathsPerInvoke attribute is absent or zero … clients SHALL assume a value of 1”, so 1 is the floor and never 0.

§supported_transports: TransportModes

SUPPORTED_TRANSPORTS [8] — Table 7’s bitmap, “in addition to MRP”. Empty means MRP only, which is every node that does not speak TCP.

§max_tcp_message_size: Option<u32>

MAX_TCP_MESSAGE_SIZE [9], in octets — “maximum size of the message carried over TCP, excluding the framing message length field, that the node is capable of receiving”. None on a node with no TCP; Table 23’s default is 64000.

Implementations§

Source§

impl SessionParams

Source

pub const DEFAULT_MAX_TCP_MESSAGE_SIZE: u32 = 64_000

Table 23’s default MAX_TCP_MESSAGE_SIZE.

The three MRP timings have defaults too, and they are not repeated here: Table 22 and Table 23 are the same three numbers, and MrpParams::default already carries them. Two copies of a specification default are two things to forget at an uplift.

Source

pub fn legacy_peer() -> Self

What a peer is assumed to be when it sends no session-parameter-struct at all, or one from before Matter 1.3 — every parameter at Table 23’s default.

The revisions are the floors, not this crate’s values, and that is the whole point: §4.13.1 says “if the DATA_MODEL_REVISION field is missing, it implies a DataModelRevision value of either 16 or 17”, so a peer that omitted it is a 1.0-era peer and must be treated as one. Assuming this node’s own revisions for a silent peer would be assuming the peer understands everything this node does.

Source

pub fn announce(mrp: &MrpParams) -> Self

What this node announces: its own MRP timings, and this crate’s revisions.

MAX_PATHS_PER_INVOKE starts at 1 — §11.1.5.23’s floor, and the value a node that has not thought about batched Invoke must report — and SUPPORTED_TRANSPORTS starts empty. Both are raised with the builders below, and both must match what the node actually does: a peer is entitled to send MAX_PATHS_PER_INVOKE commands in one Invoke and to open a TCP connection if this says it may.

Source

pub const fn with_max_paths_per_invoke(self, max: u16) -> Self

Announces a MAX_PATHS_PER_INVOKE above the floor.

Clamped to at least 1, because §11.1.5.23 makes zero mean one and a zero on the wire would be read as “absent” by a peer that follows it.

Source

pub const fn with_transports( self, modes: TransportModes, max_tcp_message: u32, ) -> Self

Announces the transports this node supports in addition to MRP, and the largest TCP message it can receive.

The two travel together because one without the other is a contradiction: a size for a transport that was not announced tells a peer nothing, and announcing TransportModes::TCP_SERVER without a size leaves the peer on Table 23’s 64000.

Source

pub fn to_mrp(self) -> MrpParams

Turns an announcement into MRP parameters, clamping what the peer sent.

The clamping is not optional politeness: these values decide how long this node waits before retransmitting, and they came from a stranger.

Source

pub const fn accepts_tcp(&self) -> bool

Whether the peer said it will accept a TCP connection (Table 7, bit 2).

Source

pub const fn max_tcp_message_size_or_default(&self) -> u32

The largest TCP message the peer said it can receive, or Table 23’s default.

Trait Implementations§

Source§

impl Clone for SessionParams

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SessionParams

Source§

impl Debug for SessionParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SessionParams

Source§

fn default() -> Self

This node’s announcement with Table 22’s MRP timings — the same thing SessionParams::announce builds from MrpParams::default.

A Default here was once the defect rather than the convenience: when every field was an Option, the derived Default was three Nones and encoded to an empty structure that every released CHIP SDK refuses. It is safe now for a structural reason rather than a careful one — §4.13.1’s tags 4-8 are mandatory, so they are plain fields, and there is no combination of this type that encodes to an empty container.

Source§

impl Eq for SessionParams

Source§

impl PartialEq for SessionParams

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SessionParams

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.