pub struct OnboardingPayload {
pub vendor_id: VendorId,
pub product_id: u16,
pub custom_flow: CustomFlow,
pub discovery: DiscoveryCapabilities,
pub discriminator: u16,
pub passcode: Passcode,
}Expand description
Everything printed on a device’s label (§5.1.1).
Fields§
§vendor_id: VendorIdWho made it.
product_id: u16What it is.
custom_flow: CustomFlowWhether the user has to do something before commissioning can start.
discovery: DiscoveryCapabilitiesHow to find it.
discriminator: u16A 12-bit value the device also advertises, so a commissioner can tell two otherwise identical devices apart (§5.1.1.5).
passcode: PasscodeThe shared secret PASE proves possession of.
Implementations§
Source§impl OnboardingPayload
impl OnboardingPayload
Sourcepub fn new(
vendor_id: VendorId,
product_id: u16,
discriminator: u16,
passcode: Passcode,
discovery: DiscoveryCapabilities,
custom_flow: CustomFlow,
) -> Result<Self>
pub fn new( vendor_id: VendorId, product_id: u16, discriminator: u16, passcode: Passcode, discovery: DiscoveryCapabilities, custom_flow: CustomFlow, ) -> Result<Self>
Builds a payload, checking the discriminator fits 12 bits.
Sourcepub const fn short_discriminator(&self) -> u8
pub const fn short_discriminator(&self) -> u8
The top four bits of the discriminator — all a manual pairing code carries (§5.1.1.5).
Sourcepub fn pack(&self) -> [u8; 11]
pub fn pack(&self) -> [u8; 11]
Packs the structure of Core Table 59 into 11 octets.
“The bits of each fixed-size value are placed in the packed binary data structure in order from least significant to most significant”, and the whole is “padded with ‘0’ bits at the end of the structure to the nearest byte boundary”.
Sourcepub fn to_qr(&self) -> Result<String<QR_LEN_NO_TLV>>
pub fn to_qr(&self) -> Result<String<QR_LEN_NO_TLV>>
Renders the QR payload: MT: followed by the base-38 encoding.
Sourcepub fn from_qr(text: &str) -> Result<Self>
pub fn from_qr(text: &str) -> Result<Self>
Parses a QR payload.
Accepts the string with or without its MT: prefix; a camera app that strips it is
common enough that refusing would be unhelpful.
Sourcepub fn to_manual_code(
&self,
include_vid_pid: bool,
) -> Result<String<MANUAL_CODE_MAX_DIGITS>>
pub fn to_manual_code( &self, include_vid_pid: bool, ) -> Result<String<MANUAL_CODE_MAX_DIGITS>>
Renders the manual pairing code (§5.1.4).
include_vid_pid produces the 21-digit form. §5.1.4.1.2 ties this to the
commissioning flow: a standard-flow device uses the short form, and a user-intent
or custom-flow device “SHALL” use the long one — so this refuses the combination
the specification forbids rather than producing a code a commissioner will
misread as standard flow.
Sourcepub fn from_manual_code(text: &str) -> Result<Self>
pub fn from_manual_code(text: &str) -> Result<Self>
Parses a manual pairing code.
“The receiving application SHALL be robust against characters like dashes and
spaces that may be included in the string” (§5.1.4.2), so those are stripped before
anything else — a user who types 3497-011-2665 has typed a valid code.
The discriminator that comes back has only its top four bits set; the rest are zero, because a manual code does not carry them.