onboarding

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package onboarding builds the Matter setup payload: the "MT:" QR-code string and the 11-digit manual pairing code, per the Matter Core spec §5.1.

Everything here is deterministic from the SetupPayload fields, so it can be unit-tested against known vectors without any network or crypto.

Index

Constants

View Source
const (
	DiscoverySoftAP    = 1 << 0
	DiscoveryBLE       = 1 << 1
	DiscoveryOnNetwork = 1 << 2 // IP / mDNS — what a Wi-Fi/Ethernet device advertises
)

Discovery capability bitmask (rendezvous information), spec §5.1.3.1.

Variables

This section is empty.

Functions

This section is empty.

Types

type SetupPayload

type SetupPayload struct {
	Version       uint8  // 3 bits, currently 0
	VendorID      uint16 // 16 bits
	ProductID     uint16 // 16 bits
	CommFlow      uint8  // 2 bits: 0=standard, 1=user-intent, 2=custom
	Discovery     uint8  // 8 bits: DiscoveryOnNetwork | …
	Discriminator uint16 // 12 bits (0..4095)
	Passcode      uint32 // 27 bits (the 8-digit PIN), 1..0x5F5E0FE
}

SetupPayload holds the commissioning credentials and identity advertised to a commissioner (a Matter admin).

func (SetupPayload) ManualCode

func (p SetupPayload) ManualCode() (flat, grouped string)

ManualCode returns the 11-digit manual pairing code (no separators) plus a human-friendly grouped form ("XXXX-XXX-XXXX").

Short code layout (no VID/PID), spec §5.1.4.1. The manual code uses only the top 4 bits of the 12-bit discriminator ("short" below):

chunk1 (1 digit) : VID/PID-present(0)<<2 | short[3:2]
chunk2 (5 digits): short[1:0]<<14 | passcode[13:0]
chunk3 (4 digits): passcode[26:14]
+ Verhoeff check digit

func (SetupPayload) QRString

func (p SetupPayload) QRString() string

QRString returns the "MT:…" payload to be rendered as a QR code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL