controller

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 62 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package controller is the controller role's composition root: one call, New, builds what a controller program otherwise wires from nine packages — the database schemas, the certificate authority, our fabric, the UDP socket and its exchanges, the DNS-SD browser, the peers, the client subscriptions, the commissioner and the registry of client nodes — in the order the reference controller builds them, and Controller.Close tears them down in reverse. Controller.Pair commissions a node by its QR or manual pairing code; the nodes are controller/client's (client.Node: Read, Subscribe, Write, Invoke, the typed reads of the generated <cluster>def.StateFrom).

It mirrors matter.js's CommissioningController (packages/matter.js/src/CommissioningController.ts at 862ad75f): one object owns one fabric and the nodes paired into it (:312), start brings the stack up and connects the commissioned nodes (:847-866), commissionNode discovers a node by its setup identifier and commissions it with its passcode (:462-500), close tears it down (:803). matter.js marks that class as the legacy surface of its controller, whose new form is a ServerNode with the controller behaviour; the Go root keeps the role's parts reachable (Controller.Registry, Controller.Commissioner, Controller.Fabric) as the seams docs/guides/advanced-seams.md lists, ADR 0026 principle 2 (one composition root per role).

Index

Constants

View Source
const (
	PairingStarted   = commissioner.StepStarted
	PairingSucceeded = commissioner.StepSucceeded
	PairingFailed    = commissioner.StepFailed
	PairingSkipped   = commissioner.StepSkipped
)

The phases of a PairingStep.

View Source
const (
	// MetricSessionsOpen is a gauge: the secure sessions of the
	// controller's peers, set whenever one is established or leaves its
	// peer.
	MetricSessionsOpen = contract.MetricSessionsOpen
	// MetricMRPRetransmits is a counter: one reliable message the
	// controller's exchanges sent again.
	MetricMRPRetransmits = contract.MetricMRPRetransmits
	// MetricPairFailures is a counter: one failed pairing, a
	// [Controller.Pair] that returned an error.
	MetricPairFailures = contract.MetricPairFailures
	// MetricCASEUnresponsive is a counter: one CASE establishment that
	// retransmitted past its MRP budget unanswered.
	MetricCASEUnresponsive = contract.MetricCASEUnresponsive
	// MetricReachabilityProbes is a counter: one reachability probe run
	// of a peer, whatever its verdict.
	MetricReachabilityProbes = contract.MetricReachabilityProbes
	// MetricICDCheckInsMissed is a counter: one ICD Check-In expected
	// from a registered LIT peer and not received.
	MetricICDCheckInsMissed = contract.MetricICDCheckInsMissed
)

The named metric set the controller reports to Config.Metrics — the contract's names, here so a host reads them where it configures the port. docs/guides/observability.md tables them with their sources.

View Source
const (
	PairingStepDiscoveryIP  = commissioner.StepDiscovery + ".IP"
	PairingStepDiscoveryBLE = commissioner.StepDiscovery + ".BLE"
)

The sub-steps of "Discovery" 2.1 a Pair over both transports reports, one per transport: started when its search starts, then succeeded for the transport of the device that won PASE, skipped for the other, or failed with the search's error. They are this module's names (matter.js reports no step for its discovery), dotted as matter.js's step names are ("GeneralCommissioning.ArmFailsafe"), with Discovery's number 2.1.

View Source
const (
	CameraControllerEndpoint uint16 = 1
	OTAProviderEndpoint      uint16 = 2
)

Endpoint numbers of the controller's tree. The root is 0; the camera controller sits at 1 and the OTA provider at 2, as matterjs-server adds them (packages/ws-controller/src/controller/ControllerNode.ts:140-147 at 0bd06f2: the provider first when enabled, the camera controller after it).

View Source
const DefaultDiscoveryTimeout = 15 * time.Minute

DefaultDiscoveryTimeout bounds Controller.Discover when its timeout is 0 — matter.js discoverCommissionableDevices' Minutes(15) (CommissioningController.ts:918-922 at db021da0).

View Source
const DefaultPairTimeout = time.Minute

DefaultPairTimeout bounds the search of Controller.Pair for the device when its context has no deadline: a code no device answers within it is ErrNoDevice. It does not bound the commissioning of a device that was found — that has the commissioner's own budgets (commissioner.DefaultPASETimeout, commissioner.DefaultCASEConnectionTimeout and the fail-safe), as matter.js's has: its commissionNode sets no overall deadline (CommissioningController.ts:465-511 at db021da0), only the discovery's timeout (CommissioningDiscovery.ts:40-45).

View Source
const DefaultVendorID uint16 = 0xFFF1

DefaultVendorID is the vendor ID of our fabric when Config sets none: 0xFFF1, one of the test vendor IDs (0xFFF1–0xFFF4).

Variables

View Source
var (
	// ErrConfiguration: a required [Config] field is missing.
	ErrConfiguration = errors.New("controller: configuration")
	// ErrNoDevice: no commissionable device answered for the code before
	// the pairing's deadline.
	ErrNoDevice = errors.New("controller: no commissionable device answered")
)

Errors of New and Controller.Pair.

View Source
var ErrPairingCode = errors.New("controller: pairing code")

ErrPairingCode is a pairing code ParsePairingCode refuses; Controller.Pair wraps it the same way. The wrapped error names the rule the code breaks in matter.js's words (PairingCodeSchema.ts).

Functions

func DeviceAt added in v0.12.3

func DeviceAt(addr *net.UDPAddr) (client.Device, error)

DeviceAt is the client.Device of a device known by its address alone, without a DNS-SD answer: no instance id, no TXT record, addr as its one address. It is a supported input of client.Registry.ForDevice — which matches it to no known node and creates one, as matter.js's Peers.forDescriptor does for a descriptor of addresses only (RemoteDescriptor.is matches nothing on an absent identifier, packages/node/src/behavior/system/commissioning/RemoteDescriptor.ts:37-50 at db021da0) — and what PairOptions.Address pairs. An address without an IP or a port is ErrConfiguration.

func OpenDB added in v0.12.1

func OpenDB(path string) (*sql.DB, error)

OpenDB opens the SQLite database file at path for Config.DB with the module's opener (store.OpenSQLite: the pure-Go driver, so a controller program imports no driver of its own; an escaped `file:` URI; foreign keys on, as the schemas' cascades need them on every pooled connection; a busy timeout of 5 s) plus the write-ahead log, the reference controller's settings. A file it creates is owner-only (0600): it holds the CA's root key, unencrypted unless Config.Sealer seals it. The schemas are New's to apply.

The file is opened on first use — New's schemas, which report a path that cannot be opened. The caller closes the database after the controller.

matter.js keeps a controller's fabric and nodes in the StorageService of the controller's Environment: the constructor builds the Environment (packages/matter.js/src/CommissioningController.ts:341-353), and MatterController.create (:419-440, :436), called from #initializeController (:398-459), opens the controller's storage from it (packages/matter.js/src/MatterController.ts:177), and the node's store opens its own there with a "nodes" context (packages/node/src/storage/server/ServerNodeStore.ts:183-188), at b25ed960; the Go controller keeps them in the SQL database the host owns, so the opener is a convenience over database/sql with no matter.js counterpart of its own.

func ProductionTrust added in v0.12.1

func ProductionTrust() (attestation.PAAStore, error)

ProductionTrust is the trust store of a production controller for Config.Attestation: the Product Attestation Authorities and Certification Declaration signers of the DCL snapshot embedded in the module (controller/dcl/snapshot, the production set), and nothing else — attestation.Trust(attestation.Production, snapshot, nil). It reaches no network: a controller that also asks the online ledger layers a dcl.CertificateStore over it with attestation.Trust. A snapshot entry that does not load is an error; the store returned beside it holds the entries loaded until then.

It mirrors the production trust of matter.js's DclCertificateService (packages/protocol/src/dcl/DclCertificateService.ts:304, :330 at db021da0: the production ledger's set, the test ledger only with fetchTestCertificates), as attestation.Trust documents.

func Reseal

func Reseal(ctx context.Context, db *sql.DB, old, next store.Sealer) error

Reseal moves a controller's database from the sealer old to the sealer next — the rotation of Config.Sealer's key — in one transaction over both stores the controller keeps there: store's (the CA, the fabric, the resumption records, the group key sets; store.Reseal) and the node registry's (the kept onboarding codes and ICD keys; sqlstore.Reseal). Each store's seal canary is opened under old first (the key check) and written under next after its values; then one store.Scrub of the file removes the values sealed under old, with each store's mark of an owed scrub until it finished (decision 195). Two separate calls would leave, between them, a database whose one store opens only under next and the other only under old, which no New can open; one transaction leaves either the old state or the new.

A wrong old key, a value that does not open under it and a secret in clear (New under old seals it first) are store.ErrUnseal, and leave the database as it was. Every error after the commit wraps store.ErrScrubIncomplete: the values are sealed under next, the scrub stays owed and the next New under next runs it again.

No controller may be open on db while Reseal runs, and no other process may write the file: a running controller holds the old sealer. db must carry the schemas a New applied. There is no unseal: the way back to a clear database is a restore or a factory reset (Controller.Erase).

Types

type Advertise struct {
	// Name is the DN TXT key (the device name a device shows); "" omits it.
	Name string
	// DeviceType is the commissioner's device type (DT and `_T<type>`);
	// 0 omits both, as matter.js's optional deviceType.
	DeviceType uint32
	// VendorID and ProductID are the VP TXT key and the `_V<vendor>`
	// subtype; a VendorID of 0 is our fabric's vendor ID.
	VendorID  uint16
	ProductID uint16
	// PrivacyMasked omits VP and `_V<vendor>`, matter.js's
	// omitPrivateDetails (packages/protocol/src/advertisement/
	// Advertisement.ts:189-191).
	PrivacyMasked bool
}

Advertise is the commissioner record a controller publishes over DNS-SD (`_matterd._udp`, Matter §4.3.3), so a device that offers commissioner discovery (user-directed commissioning) finds it: matter.js's ServiceDescription.Commissioner (packages/protocol/src/advertisement/ ServiceDescription.ts:93-109 at b25ed960), broadcast by its CommissionerMdnsAdvertisement (packages/protocol/src/advertisement/mdns/ CommissionerMdnsAdvertisement.ts:21-76). matter.js advertises it only when the program asks; so does Config.Advertise.

type BorderRouterConfig

type BorderRouterConfig struct {
	// Disabled leaves the controller without a registry:
	// [Controller.BorderRouters] is nil.
	Disabled bool
}

BorderRouterConfig configures the controller's border-router registry (Config.BorderRouters).

type CameraConfig

type CameraConfig struct{}

CameraConfig turns on the controller side of Matter cameras: endpoint CameraControllerEndpoint with the Camera Controller device type and a WebRtcTransportRequestor the cameras of the fabric reach (matter.js packages/node/src/devices/camera-controller.ts:133 mandates the requestor; the entry that lets a camera reach it mirrors WebRtcTransportRequestorServer.ts:45-94). The stream management over it is the camera service (controller/camera).

type CameraSignal

type CameraSignal struct {
	Kind    CameraSignalKind
	Session camera.WebRTCSession
	// SDP is the offer's or answer's SDP.
	SDP string
	// Offer carries the Offer command's remaining fields.
	Offer wrdef.OfferRequest
	// Candidates are the ICECandidates command's candidates.
	Candidates []camera.ICECandidate
	// Reason is the End command's reason.
	Reason uint8
	// Refused is the command of a CameraSignalRefused.
	Refused camera.Signal
}

CameraSignal is one command a camera invoked on the controller's WebRtcTransportRequestor, with the session it names.

type CameraSignalKind

type CameraSignalKind uint8

CameraSignalKind names a signal the camera sent to the requestor.

const (
	CameraSignalOffer CameraSignalKind = iota + 1
	CameraSignalAnswer
	CameraSignalICECandidates
	CameraSignalEnd
	// CameraSignalRefused is a command the requestor answered NOT_FOUND,
	// because it holds no session of that id for the camera's fabric and
	// node; CameraSignal.Refused names the command, and the Session
	// carries the id, the fabric and the node only.
	CameraSignalRefused
)

The requestor's signals (WebRtcTransportRequestor's commands: Offer, Answer, ICECandidates, End), and the refusal of one.

type Config

type Config struct {
	// DB is the database the controller keeps its fabric, its CA and the
	// paired nodes in (required). The host opens it with the SQLite
	// driver of its choice; New applies the schemas (store.Apply,
	// sqlstore.Apply). The controller does not close it.
	DB *sql.DB
	// Attestation is the trust store of the Product Attestation
	// Authorities a node's attestation is checked against (required) —
	// attestation.TestStore() for development devices, a DCL-backed
	// store (controller/dcl) in production. There is no default: a
	// controller that trusts the test PAAs by accident commissions
	// counterfeit devices.
	Attestation attestation.PAAStore
	// Scanners are told to forget a device once it is commissioned — a
	// BLE scanner (controller/ble.Scanner) still holding its commissioning
	// advertisement, say: matter.js's ScannerSet, which the commissioner
	// walks after the commissioning steps succeeded
	// (packages/protocol/src/peer/ControllerCommissioner.ts:321-341,
	// :721-723 at db021da0). nil is none.
	Scanners []commissioner.CommissionedScanner
	// Listen is the UDP address to listen on; "" is "[::]:0".
	Listen string
	// VendorID is our fabric's vendor ID on its first run; 0 is
	// [DefaultVendorID]. A loaded fabric keeps its own.
	VendorID uint16
	// Label is our fabric's label on its first run.
	Label string
	// Logger receives the stack's logs; nil is slog.Default().
	Logger *slog.Logger
	// Node configures every client node of the registry (client.Config;
	// its Logger defaults to Logger, its Clock to Clock).
	Node client.Config
	// HooksFor, when set, returns the hooks of the client node with local
	// id ("peer1", …) in place of Node.Hooks, so a host tells its nodes'
	// reports, events and subscription signals apart
	// (client.RegistryConfig.HooksFor) — matter.js gives each paired node
	// its own events (packages/matter.js/src/device/PairedNode.ts:277-290
	// at db021da0, attributeChanged and eventTriggered among them).
	HooksFor func(id string) client.Hooks
	// ManualStart leaves the commissioned nodes stopped when New returns;
	// false starts each, as matter.js's start connects them unless
	// autoConnect is false (CommissioningController.ts:878-880 at db021da0). A
	// program that only pairs, or reads once, sets it.
	ManualStart bool
	// KeepOnboardingCodes keeps the QR or manual pairing code of every
	// device [Controller.Pair] commissions with the node
	// (client.Node.OnboardingCode), so that [Controller.Inventory] can
	// show it again when the paper is lost. It is kept when the
	// commissioning succeeded — also when the node's start then failed —
	// and the device advertised Basic commissioning mode: not for an
	// Enhanced Commissioning Window, whose code ends with it, not for a
	// pairing by PairOptions.Address, which sees no advertisement, and
	// not when PairOptions.Edit replaced the passcode. Off by default: the code is a
	// secret — with it and a factory reset anyone can commission the
	// device — and the database then holds one per node.
	KeepOnboardingCodes bool
	// Sealer seals the secrets of the controller's database at rest
	// (opt-in, off by default), the same sealer node.Store.Sealer takes.
	// New opens the store with store.NewSealed and the node registry with
	// sqlstore.NewSealed: what is sealed is the CA (controller.ca, with
	// its root and ICAC key), the controller's fabric (controller.ca.fabric,
	// with its IPK and operational key), the CASE resumption records, the
	// group key sets, and in the registry the kept onboarding codes and the
	// ICD Check-In keys. The rest — certificates, fabric and node ids, the
	// nodes' attribute values — stays readable. A database written without
	// a sealer is sealed on the way in and its file scrubbed, as a node's
	// store is (store.NewSealed): each store records the scrub it owes with
	// its sealing; a scrub that did not finish (a reader holding the -wal,
	// a full disk, or a process that ended first) does not fail New — both
	// stores open sealed, the scrub stays owed (store.Store.ScrubOwed,
	// sqlstore.Store.ScrubOwed; New logs it once) and the next New runs it.
	// To rotate the key, [Reseal] moves both stores in one transaction
	// while no controller is open on the database. The key must live
	// outside the database (docs/security.md, "Sealing at rest"). Every
	// later New needs the same sealer: under another key New fails with an
	// error that wraps store.ErrUnseal (the stores open one sealed value
	// first); without one, New fails reading the sealed CA with
	// store.ErrNoSealer. The node registry carries its own seal canary
	// (sqlstore.NewSealed).
	Sealer store.Sealer
	// Names opens the DNS-SD browser; nil is discovery.Open. A test
	// passes one over its own socket.
	Names func(*slog.Logger) (*discovery.Names, error)
	// Clock is the time source of the whole stack — the exchanges' and
	// MRP's timers, the certificate authority's issuing instant, the
	// peers' back-off, the subscriptions' liveness, the registry's
	// expiry; nil is the system clock. A test passes its fake clock
	// (fabrictest.Site.ControllerConfig).
	Clock clock.Clock
	// Listener, when set, is the UDP socket the controller serves on in
	// place of opening Listen: New serves its datagrams and Close closes
	// it, as a New that fails does. A test passes one on its own network
	// (fabrictest.Site.ControllerConfig); a program leaves it nil.
	Listener *udp.Listener
	// CAKey, when set, is the root key of our certificate authority, held
	// outside the database: a P-256 crypto.Signer over a key file
	// (controller/ca/keyfile), an HSM or a KMS (ca.Config.RootSigner). A
	// new CA issues its root certificate for it; a stored CA must have
	// been made under it, and a stored root private key is then dropped
	// from the database. nil keeps the root key in the database.
	// matter.js has no such seam: its CertificateAuthority keeps the key
	// pair in its storage (packages/protocol/src/certificate/
	// CertificateAuthority.ts:53, :169 at db021da0).
	CAKey crypto.Signer
	// Advertise, when set, publishes our commissioner record
	// (`_matterd._udp`) on the controller's UDP port until Close
	// ([Advertise]); nil publishes none, as matter.js advertises a
	// commissioner only when asked.
	Advertise *Advertise
	// Networks overrides the network profiles' templates field-wise — the
	// throttles and MRP margins the peers' connections and exchanges use
	// (client/peer NetworkProfiles; matter.js NetworkServer.State.profiles,
	// packages/node/src/behavior/system/network/NetworkServer.ts:162-183,
	// :254 at db021da0). nil keeps the defaults.
	Networks *peer.ProfilesConfig
	// OwnNetworkProfile is the profile of our own network, whose margin
	// pads every exchange's sends: matter.js ownNetworkProfileId
	// (NetworkServer.ts:238-242, "fast" by default, "thread" on a Thread
	// node; applied at ServerNetworkRuntime.ts:405-406). "" is "fast"; a
	// name no profile has is [ErrConfiguration].
	OwnNetworkProfile string
	// TCP selects the controller's TCP roles ([TCPConfig]); the zero value
	// is TCP off, as matter.js's (NetworkServer.ts:211-217).
	TCP TCPConfig
	// Sessions sets the session intervals the controller reports in its
	// handshakes (PBKDFParamRequest / Sigma1 SessionParameters) —
	// matter.js's sessions.intervals fed into the SessionManager
	// (ServerNetworkRuntime.ts:362-367 at b25ed960), the controller-side
	// counterpart of node.Config.Sessions. nil is the Matter defaults
	// (500 ms / 300 ms / 4000 ms); an interval outside whole milliseconds
	// from 0 to the field's bound is [ErrConfiguration].
	Sessions *SessionIntervals
	// TransportPreference is the transport each peer prefers for its
	// connections: exchange.TransportTCP is a soft hint — a connection
	// falls back to UDP when the peer does not serve TCP — and needs
	// TCP.Outgoing; anything else is UDP (NetworkServer.ts:225-228,
	// NetworkClient.ts:73-79 at b25ed960).
	TransportPreference exchange.Transport
	// PeerTiming sets the connection timing of the controller's peer set,
	// every parameter [client.Timing] names: the connection timeout, the
	// address stagger, the delays after an error, the kick and probe
	// cooldowns, the address-change delays and ProvenAddressRetention. It
	// overrides client/peer's DefaultTiming field-wise, a cooldown group
	// member by member: a zero field keeps the default; nil is the
	// defaults. A negative ProvenAddressRetention retains nothing.
	PeerTiming *client.Timing
	// OTA, when set, turns on the OTA push: the update manager and the
	// OTA provider on the controller's endpoint tree ([OTAConfig],
	// [OTAProviderEndpoint]); nil runs neither.
	OTA *OTAConfig
	// GroupTransport is the transport group messages leave on; nil is the
	// controller's own UDP socket, as matter.js's node sends from its own
	// interface. A test hands a redirecting transport here.
	GroupTransport groups.MulticastTransport
	// BorderRouters configures the passive Thread border-router registry
	// the controller keeps on its DNS-SD cache ([Controller.BorderRouters],
	// thread/brdiscovery); the zero value keeps one, as matterjs-server's
	// controller always does.
	BorderRouters BorderRouterConfig
	// Camera, when set, turns on the controller side of Matter cameras
	// ([CameraConfig]): the controller serves a Camera Controller endpoint
	// with a WebRtcTransportRequestor under its own identity and
	// publishes its operational record; nil serves none.
	Camera *CameraConfig
	// Advertiser publishes the Advertise record; nil is
	// mdns.NewResponder(), which Close closes. A test passes
	// mdns.NewNoop().
	Advertiser mdns.Advertiser
	// DCL configures the controller's ledger services ([DCLConfig]); the
	// zero value is the production ledger, online.
	DCL DCLConfig
	// Diagnostics sizes the controller's diagnostic trace
	// ([Controller.DiagnosticEvents]); the zero value keeps
	// diag.DefaultDiagnosticsCapacity events.
	Diagnostics diag.Diagnostics
	// MaxReportBytesPerSession bounds the report chunks the interactions of
	// one session hold while the rest of their chunks arrive, each charged
	// its message payload, its entries and its decoded elements (the
	// memory they hold, interaction.DefaultMaxReportBytesPerSession) —
	// reads, subscription reports and invoke responses of the paired nodes
	// together: the chunk that would pass it is answered ResourceExhausted
	// and the call returns interaction.ErrReportTooLarge. 0 is
	// interaction.DefaultMaxReportBytesPerSession (16 MiB, about 70 000
	// scalar attributes of a wildcard read); a negative
	// bound is [ErrConfiguration]. It holds for every interaction with a
	// paired node, the reads a pairing makes once the node is commissioned
	// included; the commissioning steps themselves, over PASE and the CASE
	// session they open, keep the default.
	MaxReportBytesPerSession int
	// MaxImageBytesPerNode bounds what one paired node's reports leave in
	// the controller's image of it and in DB: the image is charged the
	// bytes of its attribute values in their stored form and, for each
	// endpoint, cluster, attribute and TLV element, what that entry holds
	// in memory, so the bound holds the image's heap within a factor of
	// two and DB's rows of the node too: one row per attribute, charged at
	// least 248 bytes, and one per cluster, charged 2048. A report that
	// would raise the image above it is not applied (the image stays as it
	// was), and an image stored above it is cut back to what the node's
	// own structure names when it loads. Below it, the image keeps only
	// what the node's structure names or the interaction asked for. 0 is
	// client.DefaultMaxImageBytesPerNode (32 MiB); a negative bound is
	// [ErrConfiguration].
	MaxImageBytesPerNode int
	// Metrics receives the controller's named counters and gauges
	// (controller/metrics.go: sessions.open, mrp.retransmits,
	// pair.failures, case.unresponsive, reachability.probes,
	// icd.checkins_missed); nil records nothing. node/metrics/expvar
	// implements it.
	Metrics contract.Metrics
}

Config configures a Controller.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is a running controller: one fabric, the nodes paired into it, and the stack under them. Its methods are safe for concurrent use, Controller.Close included: once Close has begun, a method that returns an error returns one wrapping ErrConfiguration, and one that does not returns its zero result — no component, an empty list, an unsubscribe that does nothing. Fabric, Clock, TCP, Addr and TCPAddr, fixed at New, keep answering, and Erase is the reset that runs after a Close.

func New

func New(ctx context.Context, cfg Config) (_ *Controller, err error)

New builds the controller over cfg.DB: the fabric is created on the first run (a random fabric ID and node ID, saved) and loaded afterwards; then the socket, DNS-SD, the peers, the commissioner and the registry, which loads the nodes paired before. A failure tears down what was built.

func (*Controller) Addr

func (c *Controller) Addr() *net.UDPAddr

Addr is the controller's UDP address: where its sessions, its commissioner record and, with a served tree, its operational record point.

func (*Controller) BDX

func (c *Controller) BDX() *bdx.Responder

BDX is the provider's BDX responder, the transfers a node downloads an image through; nil without Config.OTA and once Close has begun.

func (*Controller) BorderRouters

func (c *Controller) BorderRouters() *brdiscovery.Registry

BorderRouters is the passive registry of the Thread border routers the controller's DNS-SD cache sees (`_meshcop`, `_trel`), which controller/topology classifies Thread neighbours by — matterjs-server's controller keeps one always (NetworkTopologyService.ts:88-89 of matterjs-server at 0bd06f2). Nil when BorderRouterConfig.Disabled; the registry's methods are safe on nil (no entries, no events). Nil once Close has begun.

func (*Controller) CameraRequestor

func (c *Controller) CameraRequestor() *camera.Requestor

CameraRequestor is the WebRtcTransportRequestor the controller serves at CameraControllerEndpoint, nil without Config.Camera and once Close has begun.

func (*Controller) Clock

func (c *Controller) Clock() clock.Clock

Clock is the time source of the controller's stack (Config.Clock, the system clock without one), for a service composed over the controller that paces on the same clock.

func (*Controller) Close

func (c *Controller) Close(ctx context.Context) error

Close tears the stack down in the reverse order of New, once no request for the endpoints the controller serves is dispatched any more and the one in flight has returned: the update manager and the OTA provider, the registry (its nodes and their subscriptions), the client subscriptions, the commissioner, the peers, the commissioner record, the exchanges, the socket, DNS-SD. The database stays open. It is idempotent: a second Close waits for the first to return, within ctx (ctx's error when ctx ends first). When the first returned an error with nodes still stopping, a later Close waits for those stops within its own ctx and returns their error — nil once every node stopped, the way a node's Stop finishes its work on the next call; nil otherwise.

func (*Controller) Commissioner

func (c *Controller) Commissioner() *commissioner.Commissioner

Commissioner is the commissioner the registry pairs through. A seam of the role. Nil once Close has begun.

func (*Controller) DiagnoseMDNS

func (c *Controller) DiagnoseMDNS() []mdns.Finding

DiagnoseMDNS reports what keeps the controller's DNS-SD from working: mdns.Diagnose of the records it advertises (the commissioner record of Config.Advertise, the operational record of a served tree) — without its no_commissionable_service finding, since a controller is not commissioned through its advertisement — and the browse-side mdns.CodeNoOperationalNames when a commissioned node waits for device discovery and the DNS-SD cache holds none of the commissioned nodes' operational records. The controller has no interface allow-list (the node's MDNS.Interfaces), so mdns.DiagnoseInterfaces is not called. Errors come first, the order otherwise stable — the order of node.Node.DiagnoseMDNS. It asks the DNS-SD cache: it must not be called from a callback the cache runs.

func (*Controller) DiagnosticEvents

func (c *Controller) DiagnosticEvents() []diag.Event

DiagnosticEvents returns the controller's diagnostic trace, newest first: a copy the caller may keep. The trace holds what the controller observes — pairing steps that failed, sessions established, lost and closed, connection-state transitions, operational records and border routers appearing, reachability probes, ICD Check-Ins, software-update statuses and refused camera signals — each with an operator sentence (diagevent.Kind…). Its size is Config.Diagnostics. None once Close has begun.

func (*Controller) Discover added in v0.12.1

func (c *Controller) Discover(ctx context.Context, id discovery.Identifier, timeout time.Duration) ([]client.Device, error)

Discover searches DNS-SD for the commissionable devices id selects until timeout passes on the controller's clock (0 is DefaultDiscoveryTimeout) or ctx ends, and returns every device found, each once, in the order they answered — matter.js CommissioningController.discoverCommissionableDevices (CommissioningController.ts:918-931, runDiscoverCommissionableDevices :84-116 at db021da0; a ContinuousDiscovery, Peers.discover, packages/node/src/node/client/Peers.ts:204-206). The end of the search's time or of ctx is no error; a closed controller is.

func (*Controller) DiscoverWith added in v0.12.3

func (c *Controller) DiscoverWith(ctx context.Context, id discovery.Identifier, timeout time.Duration, opts DiscoverOptions) ([]client.Device, error)

DiscoverWith is Controller.Discover with options: with DiscoverOptions.First it returns as soon as the first matching device answers instead of when the timeout passes. The search is a discovery.FindAll session (matter.js ContinuousDiscovery), with First a discovery.FindInstance one (InstanceDiscovery); a device is reported once it has an address.

func (*Controller) Erase

func (c *Controller) Erase(ctx context.Context) error

Erase is the controller's factory reset: it closes the controller and erases what it persisted in Config.DB — every commissioned node with its cached values, the fabric record and the CA's key material ("controller.ca", "controller.ca.fabric"), and the rest of the node store the controller keeps there. A Config.CAKey held outside the database (an HSM) is the host's to retire.

Erase deletes nothing while a node is still stopping, nor while another Close it could not wait for within ctx is still running: a node whose report queue a hook holds past ctx (client.Node.Stop) still writes its queued values and the store's final flush, and a row deleted before them would come back. Erase waits for those stops within ctx — a node's second Close does — and when ctx ends first it returns ctx's error with the database untouched; an Erase called again once the hook returned completes the reset. Concurrent Erase calls run one after the other.

An error that wraps store.ErrScrubIncomplete is a completed reset whose scrub of the file did not finish (another connection's reader holds its -wal, a full disk fails the VACUUM): every row is gone, and the erased bytes may remain in the file until a later store.Scrub of Config.DB succeeds.

A Go controller is single-use, as the node is: the host comes back by building a new controller on the same DB, which mints a new CA and fabric and holds no peer (BD-Matter-FactoryResetEndsTheNode). Mirrors matter.js ServerNode.resetStorage for a controller (packages/node/src/node/ServerNode.ts:242-256: the peers first, then ServerEnvironment.eraseCredentials, packages/node/src/node/server/ ServerEnvironment.ts:72-89, which erases the CertificateAuthority, and the node store).

func (*Controller) Fabric

func (c *Controller) Fabric() *commissioner.Fabric

Fabric is our fabric: its ID, our node ID, the root of trust. A seam of the role.

func (*Controller) Groups

func (c *Controller) Groups() *groups.Manager

Groups is the controller's group manager: the key sets it holds for the groups it created and the senders over them (groups.Manager.Sender). Nil once Close has begun.

func (*Controller) Inventory

func (c *Controller) Inventory() []InventoryEntry

Inventory lists every commissioned node with its onboarding code, in the order of Controller.Nodes. A node has a code when Controller.Pair kept it (Config.KeepOnboardingCodes), or one was attached to it (client.Node.SetOnboardingCode); a code cannot be read from a commissioned device, which holds a verifier and not the passcode. A stored code that no longer decodes is listed as none; a node decommissioned while the list is built is left out. None once Close has begun.

func (*Controller) Nodes

func (c *Controller) Nodes() []*client.Node

Nodes are the commissioned nodes, in the registry's order; none once Close has begun.

func (*Controller) OnCameraSignal

func (c *Controller) OnCameraSignal(fn func(CameraSignal)) (unsubscribe func())

OnCameraSignal calls fn for every command a camera invokes on the requestor, on the serving goroutine; the camera service subscribes here. The returned function unsubscribes. Without Config.Camera, and once Close has begun, fn is never called.

func (*Controller) OnDiagnosticEvent

func (c *Controller) OnDiagnosticEvent(fn func(diag.Event)) (unsubscribe func())

OnDiagnosticEvent registers fn for every event the controller records from now on. fn runs inline, on the goroutine that recorded the event — the receive path, a peer's worker, the DNS-SD cache's goroutine — after the trace stored it and outside its lock: it must not block, may read Controller.DiagnosticEvents, and must not call Controller.SessionDiagnostics or Controller.DiagnoseMDNS, which wait for the DNS-SD cache that records the discovery events. There is no queued variant: the controller keeps no ordered callback queue (the node's OnDiagnosticEventAsync runs on one). It returns the unsubscribe function; once Close has begun it registers nothing.

func (*Controller) Pair

func (c *Controller) Pair(ctx context.Context, code string, opts PairOptions) (*client.Node, error)

Pair finds the commissionable device a QR code ("MT:…") or a manual pairing code names, over DNS-SD by its discriminator, and commissions it into our fabric with the code's passcode: PASE, attestation against Config.Attestation, the operational certificate, CommissioningComplete. A code ParsePairingCode refuses is ErrPairingCode; with a ctx without a deadline the search for the device ends after DefaultPairTimeout, and a code no device answers before it is ErrNoDevice; the commissioning of a found device is bounded by ctx and the commissioner's own budgets, not by that timeout — PairOptions.CommissionTimeout bounds that. With PairOptions.BLE the device is found over BLE and commissioned over BTP; with PairOptions.Address it is dialled at that address without discovery. Mirrors CommissioningController.commissionNode (CommissioningController.ts:465-511 at db021da0), whose discovery takes BLE when the options name a BLE capability (discoveryCapabilities, :283-286).

The pairing enters the diagnostic trace (Controller.DiagnosticEvents): its start and each failed step (a warning: one discovery transport of a race may fail while another wins), recorded through the Progress hook before opts.Progress runs (an opts.Edit that replaces the commissioner's Progress replaces that recording too), then the paired node, or — when Pair returns an error — the failed pairing as an error, counted once as pair.failures (Config.Metrics). Controller.PairDiscovered runs the same pipeline for a device a discovery found.

func (*Controller) PairDiscovered

func (c *Controller) PairDiscovered(ctx context.Context, dev client.Device, passcode uint32, opts PairOptions) (*client.Node, error)

PairDiscovered commissions dev, a commissionable device a discovery found (Controller.Discover, client.Registry.ForDevice's input), into our fabric with passcode, the device's setup passcode: the pairing of Controller.Pair with PairOptions.Address, the device's own addresses in place of that one. It is the same pipeline as Pair's: "Discovery" 2.1 reported as skipped, the attestation policy of PairOptions.OnAttestationFailure (the zero value rejects), the network and terms options, Edit, and the diagnostic trace — the pairing's start ("Pairing started.", with dev's discriminator), each failed step, then the paired node or the failed pairing, counted once as pair.failures (Config.Metrics). There is no onboarding code, so Config.KeepOnboardingCodes keeps none.

dev names how the device is reached, so PairOptions.BLE and PairOptions.Address are ErrConfiguration, and so are a dev without an address, an address without IP or port, and a passcode the setup codes refuse (setup.IsValidPasscode), as [Pair] refuses it in the code.

func (*Controller) Peers added in v0.12.2

func (c *Controller) Peers() *peer.Set

Peers is the peer set the registry and the commissioner reach nodes through: a program that talks to a node it did not pair through the registry (its own node on a known address, say) adds it here (peer.Set.AddKnownPeer) and reaches it with Commissioner().Interaction. A seam of the role — matter.js's node peers (packages/node/src/node/client/Peers.ts:93 at db021da0). Nil once Close has begun.

func (*Controller) Registry

func (c *Controller) Registry() *client.Registry

Registry is the registry of the paired nodes: Commissioned lists them, Get finds one by id. A seam of the role (docs/guides/advanced-seams.md). Nil once Close has begun.

func (*Controller) SessionDiagnostics

func (c *Controller) SessionDiagnostics() diag.SessionDiagnostics

SessionDiagnostics returns the controller's sessions and peers: every session of every peer, flat in Sessions, and one diag.PeerInfo per peer — its client node's connection state, its connection process, its DNS-SD service, its ICD Check-Ins — referencing its sessions by id. It is the shape node.Node.SessionDiagnostics returns, so one page model serves both roles; Occupancy stays zero (Capacity 0: the controller's exchange manager keeps no id-occupancy figure) and each session's Subscriptions 0 (the controller's subscriptions are kept by peer).

It reads the peer set's clone of its peers and each peer's clone of its sessions, so it holds no lock across the peers, and asks the DNS-SD cache for each peer's names: it must not be called from a callback the cache runs (an Controller.OnDiagnosticEvent function among them).

matter.js exposes the same state as live sets — PeerSet.peers (packages/protocol/src/peer/PeerSet.ts:218 at db021da0) and SessionManager.sessions (session/SessionManager.ts:376) — and serves a host no snapshot of it (BD-Matter-ControllerDiagnostics). Once Close has begun it is the zero value.

func (*Controller) SetGroupKey

func (c *Controller) SetGroupKey(ctx context.Context, keySet store.GroupKeySet, groupID uint16) error

SetGroupKey keeps a key set in the controller's own tables and maps groupID to it — what KeySetWrite and a GroupKeyMap write do on a member node — so that [Groups] can send to the group. The caller writes the same key set to the members. On a closed controller it writes nothing and returns ErrConfiguration. An invalid key set — EpochKey0 not 16 bytes, or EpochKey1 / EpochKey2 present and not 16 bytes — is refused by the store and nothing is written.

func (*Controller) SoftwareUpdates added in v0.13.0

func (c *Controller) SoftwareUpdates() *softwareupdate.Manager

SoftwareUpdates is the update manager — matter.js's SoftwareUpdateManager (docs/OTA.md "Triggering an Update", "Monitoring Update Progress" at 862ad75f): AddUpdateConsent, ForceUpdate, RemoveConsent, QueryUpdates, QueuedUpdates; nil without Config.OTA and once Close has begun.

func (*Controller) TCP

func (c *Controller) TCP() TCPConfig

TCP is the controller's TCP configuration (Config.TCP): whether it accepts and whether it opens TCP connections.

func (*Controller) TCPAddr added in v0.13.0

func (c *Controller) TCPAddr() *net.TCPAddr

TCPAddr is the controller's TCP listener address, nil without TCPConfig.Incoming.

func (*Controller) VendorInfo

func (c *Controller) VendorInfo(ctx context.Context) (*dcl.VendorInfoService, error)

VendorInfo is the controller's vendor information service, built on the first call — matter.js DclBehavior.vendorInfoService (DclBehavior.ts:101-115), which creates DclVendorInfoService with the production configuration and the node's offline switch: seeded from the DCL snapshot embedded in the module (controller/dcl/snapshot), refreshed from the ledger unless offline. The first call waits for the first refresh, within its ctx; a call meanwhile waits for that one, within its own; a failed refresh is logged and leaves the seeded and static vendors. Close closes it without waiting for a first refresh in flight; once Close has begun it builds none and returns an error wrapping ErrConfiguration, and one that finishes after is closed.

type DCLConfig

type DCLConfig struct {
	// ProductionURL is the production ledger; "" is dcl.ProductionURL
	// (DclConfig.production).
	ProductionURL string
	// Offline keeps the services off the network (dcl.offline, :188-198).
	Offline bool
	// VendorStore keeps the vendors the ledger answered across runs; nil
	// keeps them in memory (a dcl.SettingStore over the host's settings,
	// say).
	VendorStore dcl.Store
	// VendorUpdateInterval is the vendor refresh's period; 0 is
	// dcl.DefaultVendorUpdateInterval, negative disables it.
	VendorUpdateInterval time.Duration
}

DCLConfig configures the controller's ledger services — matter.js DclBehavior's state (packages/node/src/behavior/system/dcl/DclBehavior.ts:180-206 at b25ed960): the production ledger's URL and the offline switch, which keeps every service off the network.

type DiscoverOptions added in v0.12.3

type DiscoverOptions struct {
	// First ends the search at the first device id selects that DNS-SD
	// reports with an address, and returns that device alone — matter.js
	// Peers.locate, whose InstanceDiscovery takes the first node found as
	// its result and stops (packages/node/src/node/client/Peers.ts:189-194,
	// packages/node/src/behavior/system/controller/discovery/
	// InstanceDiscovery.ts:25-31 at db021da0), as commissionNode's
	// discovery by identifier stops at the first device
	// (CommissioningController.ts:465-503). None before timeout is an
	// empty result, as for a full search.
	First bool
}

DiscoverOptions are the options of Controller.DiscoverWith.

type InventoryEntry

type InventoryEntry struct {
	// Node is the node.
	Node *client.Node
	// NodeID is its node id on the fabric.
	NodeID uint64
	// Label is the node's NodeLabel, the name its user gave it; "" when
	// unset or not read yet.
	Label string
	// VendorName, ProductName and SerialNumber are the node's Basic
	// Information; "" when the image does not hold the attribute.
	VendorName, ProductName, SerialNumber string
	// VendorID and ProductID are the node's ids, 0 when unknown.
	VendorID, ProductID uint16
	// HasCode reports a stored onboarding code; the fields below are
	// zero without one.
	HasCode bool
	// QRCode is the QR code's text ("MT:…"); zero when the stored code is
	// a manual pairing code, from which no QR code is made up.
	QRCode client.SecretCode
	// ManualCode is the manual pairing code, 11 or 21 digits.
	ManualCode client.SecretCode
	// Source tells whether the device accepted the code at pairing or it
	// was attached afterwards and is unproven.
	Source client.OnboardingSource
	// Checks are the identity checks an attached code passed.
	Checks client.OnboardingChecks
	// StoredAt is when the code was stored.
	StoredAt time.Time
}

InventoryEntry is one commissioned node of the fabric with the onboarding code kept for it: what a host shows or prints so that the code survives the paper it came on. The strings are the module's part; drawing the QR code is the host's.

QRCode and ManualCode are secrets: with one of them and physical access to the device (a factory reset) anyone can commission it. They are client.SecretCode values, redacted wherever an entry is formatted, logged or serialised; Reveal reads the text, and what a host does with it — an export, an API response — needs the protection of the controller's database.

func (InventoryEntry) GoString

func (e InventoryEntry) GoString() string

GoString keeps the codes out of a %#v.

func (InventoryEntry) LogValue

func (e InventoryEntry) LogValue() slog.Value

LogValue keeps the codes out of a log record.

func (InventoryEntry) String

func (e InventoryEntry) String() string

String keeps the codes out of a formatted entry.

type OTAConfig added in v0.13.0

type OTAConfig struct {
	// Images is the image store and the ledger lookups; nil is an
	// in-memory store without ledgers, which offers local images only.
	Images *softwareupdate.Images
	// AllowTestImages, UpdateCheckInterval, AnnounceAsDefaultProvider,
	// AnnouncementInterval, MaxBDXBlockSize, BDXAdditionalMrpDelay and
	// ApplyDelay are the manager's ([softwareupdate.Config]).
	AllowTestImages           bool
	UpdateCheckInterval       time.Duration
	AnnounceAsDefaultProvider bool
	AnnouncementInterval      time.Duration
	MaxBDXBlockSize           uint16
	BDXAdditionalMrpDelay     *time.Duration
	ApplyDelay                time.Duration
	// DelegateConsentToRequestor is the manager's
	// ([softwareupdate.Config].DelegateConsentToRequestor, default off):
	// on, a node whose QueryImage says it can obtain the user's consent
	// itself is offered the newest applicable stored image without a
	// consent given to the manager, with UserConsentNeeded, and may apply
	// it.
	DelegateConsentToRequestor bool
	// RequestConsent, OnUpdateAvailable, OnUpdateApplying, OnUpdateDone,
	// OnUpdateFailed and OnStatus are the manager's hooks. OnStatus may run
	// on the receive path: a download's WaitForApply is reported when the
	// node's final BlockAckEof arrives, on that session's turn of the
	// controller's socket. It must not block and must not call back into
	// the controller synchronously; a blocking hook stalls the session's
	// datagrams.
	RequestConsent                                 func(ctx context.Context, p softwareupdate.Peer, req softwareupdate.QueryImageRequest, d softwareupdate.AvailableDetails) (softwareupdate.ConsentState, time.Duration)
	OnUpdateAvailable                              func(p softwareupdate.Peer, info softwareupdate.SoftwareUpdateInfo)
	OnUpdateApplying, OnUpdateDone, OnUpdateFailed func(p softwareupdate.Peer)
	OnStatus                                       func(p softwareupdate.Peer, status softwareupdate.Status, version uint32)
	// ScriptQueryImage, ScriptApplyUpdate and OnProviderExchange are the
	// manager's test-harness seam: they script the provider's answers and
	// report what it answered ([softwareupdate.Config]).
	ScriptQueryImage   func(p softwareupdate.Peer, req softwareupdate.QueryImageRequest) (softwareupdate.QueryImageScript, bool)
	ScriptApplyUpdate  func(p softwareupdate.Peer, req provdef.ApplyUpdateRequestRequest) (softwareupdate.ApplyUpdateScript, bool)
	OnProviderExchange func(x softwareupdate.ProviderExchange)
}

OTAConfig turns on the controller's OTA push — matter.js's SoftwareUpdateManager with the OtaSoftwareUpdateProviderServer on the controller's own node (packages/node/src/behavior/system/software-update/ SoftwareUpdateManager.ts, packages/node/src/behaviors/ ota-software-update-provider/OtaSoftwareUpdateProviderServer.ts at 862ad75f; docs/OTA.md "Enable OTA Provider on Controller Creation").

The controller serves the provider itself, under its one operational identity: New builds the update manager (controller/softwareupdate) and the device side's provider server (cluster/core.NewOTAProvider) over the manager's image source, consent and apply policy, mounts the server at OTAProviderEndpoint of the controller's endpoint tree (serve.go) and gives the manager the fabric's root node id and that endpoint as the provider it announces; the provider's BDX responder serves the downloads on the controller's own exchanges (ota_provider.go). Until phase 37 the provider ran on a second node the controller commissioned into its fabric; a database of that time is migrated on its next start (retireOwnNode), with or without OTAConfig. The provider is one implementation, the device-side one.

type PairOptions

type PairOptions struct {
	// AutoSubscribe, when non-nil, overrides the registry's default
	// subscription of the new node (client.CommissionOptions.AutoSubscribe);
	// nil keeps it, as a resident program wants.
	AutoSubscribe *bool
	// OnAttestationFailure decides a node whose attestation fails; the zero
	// value rejects it (attestation.Reject()).
	OnAttestationFailure attestation.Policy
	// BLE, when set, is the Bluetooth LE central Pair finds the device
	// through, by its advertisement in place of DNS-SD, and commissions it
	// over BTP: PASE over BLE, then the network steps put the device on
	// WiFi or Thread, where CASE finds it over DNS-SD (ADR 0024). A device
	// on BLE has no network yet, so one of WiFi and Thread is required
	// ([ErrConfiguration] otherwise). The BlueZ central is ble/bluez's.
	BLE ble.Central
	// Address, when set, is the device's UDP address: Pair dials it
	// without DNS-SD — no advertisement is needed — as a client.Device
	// holding that address alone (no instance id, no TXT record, so the
	// registry never matches it to a node it knows). The code still
	// supplies the passcode; its discriminator is not checked. Mirrors
	// matter.js MatterController.commission, which commissions a
	// discovery's knownAddress through Peers.forDescriptor({addresses})
	// without a scan (packages/matter.js/src/MatterController.ts:539-565 at
	// db021da0; the option is CommissioningController.ts:292). Address
	// and BLE together are [ErrConfiguration].
	Address *net.UDPAddr
	// WiFi and Thread are the operational network the commissioning
	// provisions on a device that advertises Wi-Fi or Thread
	// (commissioner.Options.WiFiNetwork, ThreadNetwork); nil provisions
	// none.
	WiFi   *commissioner.WiFiNetwork
	Thread *commissioner.ThreadNetwork
	// TermsAndConditions is the user's acknowledgement of the device's
	// terms and conditions (commissioner.Options.TermsAndConditions): the
	// commissioning sends it with SetTCAcknowledgements before
	// CommissioningComplete. A device that requires terms this does not
	// acknowledge — nil, or a Version below the device's
	// TCMinRequiredVersion — fails Pair early, before AddNOC, with a
	// *commissioner.TermsRequiredError naming the version; a caller shows
	// the terms and pairs again with the acknowledgement. nil acknowledges
	// nothing, as a device without terms needs.
	TermsAndConditions *commissioner.TermsAndConditionsAcknowledgement
	// Progress, when set, is called as each step of the pairing starts
	// and ends ([PairingStep]): the search for the device (skipped with
	// Address), PASE, the commissioning steps under matter.js's names,
	// then the node's start, "Subscribe" 21.1. A failed step is the last
	// report. It runs on the pairing's goroutines — Pair's, and in a
	// discovery race each transport's search and each attempt — one call
	// at a time. Pair waits for it, so it must not block.
	// It is the commissioner's Options.Progress, which Edit may replace.
	Progress func(PairingStep)
	// Edit adjusts the commissioner's options last (a seam).
	Edit func(*commissioner.Options)
	// CommissionTimeout, when positive, bounds the commissioning of a
	// device once it is reached — from PASE to the node's start, for each
	// device a search found and for one [PairOptions].Address or
	// [Controller.PairDiscovered] names — on the controller's clock,
	// independently of the search's bound: a ctx without a deadline keeps
	// [DefaultPairTimeout] on the search and this on what follows it. A
	// commissioning that outlasts it is given up as a caller's
	// cancellation is — the fail-safe disarmed within
	// commissioner.FailSafeMaxSendTime — and ends with an error that is
	// context.DeadlineExceeded.
	// Zero (or less) sets none, as matter.js's commissionNode sets no
	// overall deadline (CommissioningController.ts:465-511 at db021da0);
	// ctx, the commissioner's own budgets and the fail-safe still apply
	// (go-fabric#554).
	CommissionTimeout time.Duration
	// contains filtered or unexported fields
}

PairOptions configure Controller.Pair and Controller.PairDiscovered; the zero value pairs with the defaults.

type PairingCode added in v0.12.1

type PairingCode struct {
	// Manual is true for a manual pairing code, false for a QR code.
	Manual bool
	// Version is the QR payload's format version (0 in Matter 1.x); 0 for
	// a manual code.
	Version uint8
	// VendorID and ProductID are the code's vendor and product; 0 is
	// unspecified, as an 11-digit manual code always is.
	VendorID, ProductID uint16
	// Flow is the QR payload's commissioning flow: 0 Standard, 1 User
	// Action Required, 2 Custom; 0 for a manual code, which carries none.
	Flow uint8
	// Capabilities is the QR payload's discovery capabilities bitmap: bit
	// 0 SoftAP, bit 1 BLE, bit 2 on the IP network; 0 for a manual code.
	Capabilities uint8
	// Discriminator is the 12-bit long discriminator of a QR code, or the
	// 4-bit short discriminator of a manual code.
	Discriminator uint16
	// Passcode is the 27-bit setup passcode.
	Passcode uint32
	// HasExtra reports a QR payload with optional TLV data after its
	// header (a serial number, PBKDF parameters, vendor elements).
	HasExtra bool
}

PairingCode is a decoded onboarding payload: a QR code ("MT:…") or a manual pairing code (11 or 21 digits) — matter.js's QrCodeData and ManualPairingData (packages/types/src/schema/PairingCodeSchema.ts:106-116, :409-421 at db021da0).

func ParsePairingCode added in v0.12.1

func ParsePairingCode(code string) (PairingCode, error)

ParsePairingCode decodes a QR code ("MT:…", one payload) or a manual pairing code (11 or 21 digits; other characters are ignored), with matter.js's validation: QrPairingCodeCodec.decode and ManualPairingCodeCodec.decode (PairingCodeSchema.ts:330-345, :461-493 at db021da0), each validating the passcode and the vendor and product identity. A code it refuses is ErrPairingCode.

func (PairingCode) Identifier added in v0.12.1

func (p PairingCode) Identifier() discovery.Identifier

Identifier is the DNS-SD (or BLE) selector of the device the code names: its long discriminator for a QR code, its short one for a manual code — the identifier matter.js's commissionNode discovers by (CommissioningController.ts:465-503 at db021da0).

type PairingPhase

type PairingPhase = commissioner.StepPhase

PairingPhase is a PairingStep's phase: started, then succeeded, failed or skipped (commissioner.StepPhase).

type PairingStep

type PairingStep = commissioner.Step

PairingStep is one report of PairOptions.Progress: the step's number, sub-step and name — matter.js's step names verbatim (packages/protocol/src/peer/ControllerCommissioningFlow.ts:536-656 at db021da0), so a UI can show them, "Discovery" 2.1 and "PASE" 2.2, this module's names for the steps before matter.js's flow, and "Subscribe" 21.1, its name for the node's start after it (the initial read and the default subscription) — its phase, and the error of a failed step (commissioner.Step).

type SessionIntervals

type SessionIntervals struct {
	// Idle is SESSION_IDLE_INTERVAL; 0 is 500 ms.
	Idle time.Duration
	// Active is SESSION_ACTIVE_INTERVAL; 0 is 300 ms.
	Active time.Duration
	// ActiveThreshold is SESSION_ACTIVE_THRESHOLD; 0 is 4000 ms. At most
	// 65535 ms.
	ActiveThreshold time.Duration
}

SessionIntervals are the controller's own session intervals, reported to every peer in its handshakes (Config.Sessions). The same shape as node.SessionIntervals; matter.js keeps one SessionIntervals for both roles (SessionIntervals.ts:45-49 at db021da0, the defaults; the active threshold is bounded by the uint16 it is encoded as, SessionManager.ts:58-68).

type TCPConfig added in v0.13.0

type TCPConfig struct {
	// Incoming accepts TCP connections on the controller's UDP port (the
	// tcpServer role, ServerNetworkRuntime.ts:334-338; the listener :203-226).
	Incoming bool
	// Outgoing opens TCP connections to peers that serve TCP when an
	// interaction requires or prefers it (the tcpClient role).
	Outgoing bool
	// MaxInboundConnections is the most inbound connections the TCP
	// listener holds in all, whatever their source addresses; at the
	// bound a new connection takes the place of the held one idle longest
	// (no message received or sent for the longest time) among those that
	// carried no traffic within the secure session's idle timeout (5
	// minutes), or is closed when every held one did. Zero is the
	// controller's default, 256; a negative value is [ErrConfiguration].
	MaxInboundConnections int
	// MaxMessageSize is the largest TCP message, its 4-byte length prefix
	// not counted, the controller accepts and sends: its session
	// parameters state it as MAX_TCP_MESSAGE_SIZE, and every TCP
	// connection, inbound and outbound, holds to it. Zero is 64 000
	// (sessionparams.DefaultMaxTCPMessageSize). With a TCP role, a value
	// below exchange.MaxUDPMessageSize (1232) or above 2^32−1 is
	// [ErrConfiguration]; without one it is not used. Mirrors matter.js
	// NetworkServer.resolveTcpConfig and
	// SessionParameters.assertMaxTcpMessageSize
	// (packages/node/src/behavior/system/network/NetworkServer.ts:276-291,
	// packages/protocol/src/session/SessionParameters.ts:128-137 at
	// db021da0; review II, R2-P6-par-3209), except that matter.js defaults
	// an absent value and refuses an explicit 0 (:131); here zero is the
	// absent value.
	MaxMessageSize int
}

TCPConfig selects the controller's Matter TCP roles — matter.js NetworkServer.State.tcp resolved by resolveTcpConfig (packages/node/src/behavior/system/network/NetworkServer.ts:276-291 at db021da0; the state :212-223, its TcpConfig :264-268). The zero value is TCP off.

Directories

Path Synopsis
Package attestation is the commissioner's device attestation check: the port of matter.js packages/protocol/src/certificate/DeviceAttestationValidator.ts (DeviceAttestationValidator.validate, :283-293, and the validateCollecting it wraps, :295-694) at b25ed960, ADR 0020 stage 2, with a static trust store (PAAStore, StaticStore, TestStore) where matter.js consults its DclCertificateService.
Package attestation is the commissioner's device attestation check: the port of matter.js packages/protocol/src/certificate/DeviceAttestationValidator.ts (DeviceAttestationValidator.validate, :283-293, and the validateCollecting it wraps, :295-694) at b25ed960, ADR 0020 stage 2, with a static trust store (PAAStore, StaticStore, TestStore) where matter.js consults its DclCertificateService.
ble
Package ble is the commissioner's seam to Bluetooth LE (ADR 0024, decision 2): the interfaces a platform BLE stack implements (Central, Connection), the scanner that turns Matter advertisements into commissionable devices (Scanner) and the commissioning channel that runs PASE over a BTP session to one peripheral (Dial, Channel).
Package ble is the commissioner's seam to Bluetooth LE (ADR 0024, decision 2): the interfaces a platform BLE stack implements (Central, Connection), the scanner that turns Matter advertisements into commissionable devices (Scanner) and the commissioning channel that runs PASE over a BTP session to one peripheral (Dial, Channel).
bletest
Package bletest is an in-memory BLE stack for tests: a Central that implements ble.Central and the [Peripheral]s it reaches, each a GATT server of the Matter service whose BTP side is a transport/btp peripheral session.
Package bletest is an in-memory BLE stack for tests: a Central that implements ble.Central and the [Peripheral]s it reaches, each a GATT server of the Matter service whose BTP side is a transport/btp peripheral session.
ca
Package ca is the controller's certificate authority: the root of trust of a fabric the controller owns (its RCAC, optionally an ICAC), which issues the controller's own NOC and the NOC of every node it commissions.
Package ca is the controller's certificate authority: the root of trust of a fabric the controller owns (its RCAC, optionally an ICAC), which issues the controller's own NOC and the NOC of every node it commissions.
keyfile
Package keyfile keeps a P-256 key in a passphrase-encrypted file and signs with it as a crypto.Signer — the alternative to the SQLite record for [ca.Config.RootSigner], [ca.Config.ICACSigner] and commissioner.FabricConfig.OperationalSigner.
Package keyfile keeps a P-256 key in a passphrase-encrypted file and signs with it as a crypto.Signer — the alternative to the SQLite record for [ca.Config.RootSigner], [ca.Config.ICACSigner] and commissioner.FabricConfig.OperationalSigner.
Package camera is the controller side of Matter camera streaming: how the controller picks, allocates, reuses and frees a camera's streams and keeps the WebRTC sessions it opens on them.
Package camera is the controller side of Matter camera streaming: how the controller picks, allocates, reuses and frees a camera's streams and keeps the WebRTC sessions it opens on them.
cameratest
Package cameratest is a test camera for a host's in-process tests of controller/camera: a Camera device to bridge into a fabrictest site, and the scripted Port it serves its WebRTC transport and its streams on.
Package cameratest is a test camera for a host's in-process tests of controller/camera: a Camera device to bridge into a fabrictest site, and the scripted Port it serves its WebRTC transport and its streams on.
Package client is the controller's image of a remote node (ADR 0020, stage 4, first half): what the node reports, kept as endpoints and clusters, cached and persisted, and kept live by one sustained subscription.
Package client is the controller's image of a remote node (ADR 0020, stage 4, first half): what the node reports, kept as endpoints and clusters, cached and persisted, and kept live by one sustained subscription.
sqlstore
Package sqlstore is a durable client.Store on SQLite (brief AL §8; ADR 0020, stage 4): the images, settings and commissioning records of a controller's client nodes, in the tables matter_client_values and matter_client_versions.
Package sqlstore is a durable client.Store on SQLite (brief AL §8; ADR 0020, stage 4): the images, settings and commissioning records of a controller's client nodes, in the tables matter_client_values and matter_client_versions.
Package commissioner commissions Matter nodes onto a fabric the controller owns (ADR 0020, stage 2): the port of matter.js packages/protocol/src/peer/ControllerCommissioner.ts, CommissioningConnection.ts and ControllerCommissioningFlow.ts at 0ceb202d, for nodes on an IP network and, over Options.Channel, over BLE (ADR 0024).
Package commissioner commissions Matter nodes onto a fabric the controller owns (ADR 0020, stage 2): the port of matter.js packages/protocol/src/peer/ControllerCommissioner.ts, CommissioningConnection.ts and ControllerCommissioningFlow.ts at 0ceb202d, for nodes on an IP network and, over Options.Channel, over BLE (ADR 0024).
dcl
Package dcl is the controller's client of the CSA Distributed Compliance Ledger: the port of matter.js packages/protocol/src/dcl/ at 0ceb202d (ADR 0020 stage 6) — Client is DclClient.ts, CertificateStore the parts of DclCertificateService.ts the attestation check consults (the PAA and CD signer trust store, refreshed daily, and the CRL revocation check of Matter Core §6.2.6.1), OTAVersions the parts of DclOtaUpdateService.ts that answer whether a software version is in the ledger and with which checksum.
Package dcl is the controller's client of the CSA Distributed Compliance Ledger: the port of matter.js packages/protocol/src/dcl/ at 0ceb202d (ADR 0020 stage 6) — Client is DclClient.ts, CertificateStore the parts of DclCertificateService.ts the attestation check consults (the PAA and CD signer trust store, refreshed daily, and the CRL revocation check of Matter Core §6.2.6.1), OTAVersions the parts of DclOtaUpdateService.ts that answer whether a software version is in the ledger and with which checksum.
snapshot
Package snapshot is the controller's offline DCL trust set: the production PAAs and Certification Declaration signers of the CSA Distributed Compliance Ledger as DER files with a SOURCE manifest, embedded from data/ and refreshed by `make update-dcl-snapshot` — a review step like the schema refresh, never automatic.
Package snapshot is the controller's offline DCL trust set: the production PAAs and Certification Declaration signers of the CSA Distributed Compliance Ledger as DER files with a SOURCE manifest, embedded from data/ and refreshed by `make update-dcl-snapshot` — a review step like the schema refresh, never automatic.
Package softwareupdate is the controller's OTA push: matter.js's SoftwareUpdateManager and OtaAnnouncements (packages/node/src/behavior/system/software-update/ at b25ed960) and the storage half of its DclOtaUpdateService (packages/protocol/src/dcl/DclOtaUpdateService.ts).
Package softwareupdate is the controller's OTA push: matter.js's SoftwareUpdateManager and OtaAnnouncements (packages/node/src/behavior/system/software-update/ at b25ed960) and the storage half of its DclOtaUpdateService (packages/protocol/src/dcl/DclOtaUpdateService.ts).
Package topology is the network graph of the controller's commissioned nodes: a port of matterjs-server's NetworkTopologyService at 0bd06f22 (github.com/matter-js/matterjs-server, packages/ws-controller/src/controller/NetworkTopologyService.ts) and the derivation it shares with its dashboard (packages/ws-client/src/topology/topology-utils.ts), whose wire types (packages/ws-client/src/models/model.ts) name this package's.
Package topology is the network graph of the controller's commissioned nodes: a port of matterjs-server's NetworkTopologyService at 0bd06f22 (github.com/matter-js/matterjs-server, packages/ws-controller/src/controller/NetworkTopologyService.ts) and the derivation it shares with its dashboard (packages/ws-client/src/topology/topology-utils.ts), whose wire types (packages/ws-client/src/models/model.ts) name this package's.

Jump to

Keyboard shortcuts

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