Documentation
¶
Overview ¶
Package node is the facade over the bridge's bring-up: one Config, one New, Node.Start / Node.Stop / Node.Run, and an Aggregator the host adds its bridged endpoints to (ADR 0018 decision 5).
It mirrors matter.js ServerNode (packages/node/src/node/ServerNode.ts: 107-127 create, :274-309 the root endpoint composition) and Node (Node.ts:114-132 start, :183-186 run, :193 stop): a node is configured by behaviour ids — `network`, `commissioning`, `productDescription`, `basicInformation` — and its root carries the system servers without the host composing them.
What the facade performs is the reference daemon's bring-up (examples/reference-bridge/main.go:84-497 at b4ea1f96^), in the order bridge/bridge.go's package doc lists the ports, with every port wired:
- New: the stores (schemas applied on Config.Store.DB), the group state, the endpoint assembler, bridge.New, the device-type validation mode, AttachACLLister, AttachGroupMessaging, AttachAuxiliaryACL, AttachDiagnosticEvents, the root servers (RootClusters) and AttachRootClusters, the Aggregator servers and AttachAggregatorClusters, then the security wiring — AttachSessionLookup, AttachAckTracker, AttachSubscriptionManager, AttachSessionRegistry, AttachCaseHandlerProvider, AttachSubscriptionStore, AttachOperationalResolver, AttachCaseInitiatorProvider — the commissioning window (AttachCommissioningWindow, with the PASE provider attached while a window is open), the fabric hooks and the event-number persistence; with Config.OTAProvider the OTA provider and AttachBDXResponder; with Config.CommissionerControl the CommissionerControl server on the Aggregator.
- Start: bridge.Start, the DiagnosticLogs provider, StartUp and BootReason, the operational-time keeper, both PartsList providers, the stored fabrics' CASE identities, ReestablishFormerSubscriptions, the OTA requestor, AnnounceFabric for each fabric, and the node's own commissioning window when no fabric exists; the OTA provider's ACL entry once a fabric exists (and after each CommissioningComplete).
The citations of examples/reference-bridge files and lines in this package name the daemon as it stood before it moved onto the facade (commit 30fe7f1; brief R): the code they cite is the facade's now.
A host that assembles its own topology — its own endpoint.Assembler over its own device model — hands the bridge its Snapshotter through Config.Snapshotter and gets no Aggregator; everything else stays the facade's, the group state included (Config.Groups, Node.Groups). Its operator surface reads Node.SessionDiagnostics (the read-only view; Node.Sessions and Node.Subscriptions are the advanced seams below it) and removes a fabric without a commissioner through Node.RemoveFabric (issue #87).
Left to the configuration on purpose: a nil Config.Advertiser is the node's own Zeroconf with the subtype responder (Network.MDNS.Off publishes nothing), a nil Config.OTA mounts no OTA requestor, a nil Config.OTAProvider no OTA provider, a nil Config.CommissionerControl no CommissionerControl server. Left to the host: GeneralDiagnostics' TestEventTrigger enable key, the PowerSource endpoints of PowerSourceConfiguration, and the bridge's observer hook SetOnReassembled — reachable through Node.Root and Node.Bridge; a fabric's installation reaches the host through Observers.OnFabricAdded. The fabric, commissioning-complete and window events reach the host through Config.Observers, chained after the facade's own handlers. The cluster hooks the facade wires (OperationalCredentials SetOnFabricRemoved / SetOnFabricUpdated, GeneralCommissioning SetOnCommissioningComplete, the window's SetTransitionHook, reached through Node.Root and Node.Bridge) keep the facade's handler in a slot of its own: a host that sets one adds its handler, which runs after the facade's. The window itself is the facade's: Node.OpenOwnWindow opens the node's own window with the configured credentials, Node.OpenBasicWindow one with other credentials, Node.CloseWindow closes the open window whoever opened it, Node.Window reads it and Node.SetCommissioningBlocked refuses every new one.
Index ¶
- Constants
- Variables
- func AheadRows() []string
- func CreateOTAImage(opts OTAImageOptions) ([]byte, error)
- func SoftwareVersionFromString(version string) uint32
- func ValidateSetupPIN(pin uint32) error
- type ActionRequest
- type Actions
- type ActionsConfig
- type ActionsHost
- type Advertiser
- type Aggregator
- func (a *Aggregator) Add(ctx context.Context, ep Endpoint) error
- func (a *Aggregator) Batch(ctx context.Context, fn func(b *Batch) error) error
- func (a *Aggregator) Endpoints() []Endpoint
- func (a *Aggregator) Forget(ctx context.Context, key device.SourceKey) error
- func (a *Aggregator) IncreaseConfigurationVersions(ctx context.Context, keys ...device.SourceKey) error
- func (a *Aggregator) Partition(name string) *Partition
- func (a *Aggregator) Partitions() []string
- func (a *Aggregator) Remove(ctx context.Context, key device.SourceKey) error
- func (a *Aggregator) Replace(ctx context.Context, key device.SourceKey, ep Endpoint) error
- func (a *Aggregator) RetirePartition(ctx context.Context, name string) error
- type Attestation
- type AttestationChain
- type AttestationFiles
- type AttributeChange
- type AttributeValue
- type BDXResponder
- type BasicInformation
- type BasicInformationServer
- type Batch
- type BridgeTopology
- type BridgedDevice
- type CapabilityMinimaStruct
- type ClientConfig
- type ClusterInfo
- type CommissionerControlConfig
- type CommissionerControlServer
- type Commissioning
- type CommissioningApprover
- type CommissioningFlow
- type Config
- type DCLClient
- type DCLOTAVersions
- type DCLSoftwareVersion
- type DeviceTypeInfo
- type DeviceTypeValidationMode
- type DiagnosticEvent
- type Diagnostics
- type DiscoveryNames
- type EcosystemDirectory
- type EcosystemInformation
- type Endpoint
- type EndpointInfo
- type EndpointPersistencedeprecated
- type EndpointState
- type Event
- type EventQuery
- type FabricInfo
- type GeneralDiagnosticsFeatures
- type Groups
- type Health
- type HealthSample
- type ICD
- func (i *ICD) Active() bool
- func (i *ICD) EnterIdleMode()
- func (i *ICD) Mode() ICDOperatingMode
- func (i *ICD) OnModeChange(fn func(ICDModeEvent)) (unsubscribe func())
- func (i *ICD) OnModeChangeAsync(fn func(ICDModeEvent)) (unsubscribe func())
- func (i *ICD) RequestActiveMode()
- func (i *ICD) SetOperatingMode(mode ICDOperatingMode) error
- func (i *ICD) TriggerUserActiveMode()
- func (i *ICD) WithdrawForcedOperatingMode() error
- type ICDConfig
- type ICDModeEvent
- type ICDOperatingMode
- type ICDUserActiveModeTrigger
- type Label
- type Limits
- type MDNS
- type MDNSFinding
- type MDNSService
- type Metrics
- type NTPClient
- type Network
- type Node
- func (n *Node) Aggregator() *Aggregator
- func (n *Node) AttestationError() error
- func (n *Node) BDX() *BDXResponder
- func (n *Node) Bindings() *binding.Manager
- func (n *Node) BootReason() uint8
- func (n *Node) Bridge() *bridge.Bridge
- func (n *Node) Clock() clock.Clock
- func (n *Node) CloseWindow(ctx context.Context) error
- func (n *Node) CommissionerControl() *CommissionerControlServer
- func (n *Node) DiagnoseMDNS() []MDNSFinding
- func (n *Node) DiagnosticEvents() []DiagnosticEvent
- func (n *Node) EndpointState() EndpointState
- func (n *Node) Endpoints() []EndpointInfo
- func (n *Node) Events(q EventQuery) []Event
- func (n *Node) FabricInfos(ctx context.Context) ([]FabricInfo, error)
- func (n *Node) FactoryReset(ctx context.Context) error
- func (n *Node) Groups() *Groups
- func (n *Node) Health() (HealthSample, bool)
- func (n *Node) ICD() *ICD
- func (n *Node) LocalAddr() string
- func (n *Node) MDNSEnabled() bool
- func (n *Node) MDNSServices() []MDNSService
- func (n *Node) OTAProvider() *OTAProviderServer
- func (n *Node) OTAProviderEndpoint() (uint16, bool)
- func (n *Node) Observe(o Observers) (unsubscribe func())
- func (n *Node) ObserveAsync(o Observers) (unsubscribe func())
- func (n *Node) OnDiagnosticEvent(fn func(DiagnosticEvent)) (unsubscribe func())
- func (n *Node) OnDiagnosticEventAsync(fn func(DiagnosticEvent)) (unsubscribe func())
- func (n *Node) OnHealthSample(fn func(HealthSample)) (unsubscribe func())
- func (n *Node) OnHealthSampleAsync(fn func(HealthSample)) (unsubscribe func())
- func (n *Node) OnOTAProviderStatus(fn func(peer OTAPeer, status OTAUpdateStatus, version uint32)) (unsubscribe func())
- func (n *Node) OnOTAProviderStatusAsync(fn func(peer OTAPeer, status OTAUpdateStatus, version uint32)) (unsubscribe func())
- func (n *Node) OpenBasicWindow(ctx context.Context, creds WindowCredentials) error
- func (n *Node) OpenOwnWindow(ctx context.Context, timeout time.Duration) error
- func (n *Node) PairingCodesFor(creds WindowCredentials) (qr, manual string, err error)
- func (n *Node) Peers() *peer.Set
- func (n *Node) Persistence() EndpointPersistencedeprecated
- func (n *Node) ReadAttribute(ctx context.Context, endpoint uint16, cluster, attribute uint32) (AttributeValue, error)
- func (n *Node) ReadCluster(ctx context.Context, endpoint uint16, cluster uint32) ([]AttributeValue, error)
- func (n *Node) RemoveFabric(ctx context.Context, fabricIndex uint8) error
- func (n *Node) Root() *RootClusters
- func (n *Node) Run(ctx context.Context) error
- func (n *Node) SessionDiagnostics() SessionDiagnostics
- func (n *Node) SessionParameters() SessionParameters
- func (n *Node) Sessions() *SessionManager
- func (n *Node) SetCommissioningBlocked(ctx context.Context, err error)
- func (n *Node) SetNodeLabel(ctx context.Context, label string) error
- func (n *Node) SetupPayload() (SetupPayload, error)
- func (n *Node) Start(ctx context.Context) error
- func (n *Node) Stop(ctx context.Context) error
- func (n *Node) Store() store.Port
- func (n *Node) Subscriptions() *SubscriptionManager
- func (n *Node) Surface() surface.Report
- func (n *Node) Topology() BridgeTopology
- func (n *Node) TriggerReannounce(ctx context.Context)
- func (n *Node) UniqueID() string
- func (n *Node) Window() WindowSnapshot
- type OTAApplier
- type OTAApplyPolicydeprecated
- type OTABlob
- type OTAConfig
- type OTAConsent
- type OTAConsentState
- type OTADownloadProtocol
- type OTAFileDesignator
- type OTAHTTPClient
- type OTAImage
- type OTAImageHeader
- type OTAImageOptions
- type OTAImageSource
- type OTAPeer
- type OTAProviderConfig
- type OTAProviderServer
- type OTARequestorServer
- type OTAUpdateAttempt
- type OTAUpdateManager
- type OTAUpdateStatus
- type Observers
- type Occupancy
- type Partition
- func (p *Partition) Add(ctx context.Context, ep Endpoint) error
- func (p *Partition) Batch(ctx context.Context, fn func(b *Batch) error) error
- func (p *Partition) Endpoints() []Endpoint
- func (p *Partition) Forget(ctx context.Context, key device.SourceKey) error
- func (p *Partition) Remove(ctx context.Context, key device.SourceKey) error
- func (p *Partition) Replace(ctx context.Context, key device.SourceKey, ep Endpoint) error
- type PowerSourceConfigurationServer
- type ProductDescription
- type ReverseCommissioner
- type RootClusters
- type SemanticTag
- type SessionDiagnostics
- type SessionInfo
- type SessionIntervals
- type SessionManager
- type SessionParameters
- type SetupPayload
- type Snapshotter
- type Store
- type SubscriptionInfo
- type SubscriptionManager
- type TCPConfig
- type TLSConfig
- type TermsAndConditions
- type TimeFormatConfig
- type TimePeerReader
- type TimeSynchronization
- type TimeSynchronizationConfig
- type Topology
- type WebRTCRequestorConfig
- type WiFi
- type WiFiNetworkDiagnosticsServer
- type WiFiReporter
- type WindowCredentials
- type WindowKind
- type WindowSnapshot
- type WindowStatus
Constants ¶
const ( // MaxDiscriminator is the largest 12-bit discriminator // ([setup.MaxDiscriminator]). MaxDiscriminator = setup.MaxDiscriminator // PBKDFIterationsMin and PBKDFIterationsMax bound // [Commissioning].PBKDFIterations ([spake2.IterationsMin], // [spake2.IterationsMax]). PBKDFIterationsMin = spake2.IterationsMin PBKDFIterationsMax = spake2.IterationsMax // PBKDFSaltMin and PBKDFSaltMax bound the length of // [Commissioning].Salt in bytes ([spake2.PBKDFMinSaltSize], // [spake2.PBKDFMaxSaltSize]). PBKDFSaltMin = spake2.PBKDFMinSaltSize PBKDFSaltMax = spake2.PBKDFMaxSaltSize )
The commissioning bounds Config.Validate and Node.OpenBasicWindow check, for a host that validates its own configuration before New.
const ( RegulatoryIndoor = mattercore.RegulatoryIndoor RegulatoryOutdoor = mattercore.RegulatoryOutdoor RegulatoryIndoorOutdoor = mattercore.RegulatoryIndoorOutdoor )
The RegulatoryLocationTypeEnum values (mattercore.RegulatoryIndoor, …). Commissioning.LocationCapability takes RegulatoryOutdoor or RegulatoryIndoorOutdoor; RegulatoryIndoor is its zero value and reads as the default, IndoorOutdoor — Indoor is Commissioning.IndoorOnly.
const ( OTADownloadBDXSynchronous = mattercore.DownloadProtocolBDXSynchronous OTADownloadHTTPS = mattercore.DownloadProtocolHTTPS )
The download protocols OTAConfig.TransferProtocols takes (mattercore.DownloadProtocolBDXSynchronous, mattercore.DownloadProtocolHTTPS).
const ( // MetricSessionsOpen is a gauge: the entries of the secure-session // table (PASE and CASE), set whenever a session is established or // closed. MetricSessionsOpen = contract.MetricSessionsOpen // MetricSubscriptionsActive is a gauge: the subscriptions the node // serves, set whenever one is established, restored or closed. MetricSubscriptionsActive = contract.MetricSubscriptionsActive // MetricIMReceived is a counter: one Interaction Model message // received (GeneralDiagnostics DeviceLoadStatus // TotalInteractionModelMessagesReceived). MetricIMReceived = contract.MetricIMReceived // MetricIMSent is a counter: one Interaction Model message sent // (DeviceLoadStatus TotalInteractionModelMessagesSent). MetricIMSent = contract.MetricIMSent // MetricPASEFailures is a counter: one failed PASE pairing attempt. MetricPASEFailures = contract.MetricPASEFailures // MetricPASELockouts is a counter: one PASE lockout engaged after the // failure cap. MetricPASELockouts = contract.MetricPASELockouts // MetricAggregatorReassemblies is a counter: one completed reassembly // of the bridged-device topology ([Aggregator]). MetricAggregatorReassemblies = contract.MetricAggregatorReassemblies // MetricMRPRetransmits is a counter: one reliable message sent again, // by the device side or the node's client exchanges. MetricMRPRetransmits = contract.MetricMRPRetransmits // MetricPanicsRecovered is a counter: one panic recovered on a // datagram or connection path of the node's sockets. MetricPanicsRecovered = contract.MetricPanicsRecovered )
The named metric set the node 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.
const ( OTAConsentGranted = mattercore.OTAConsentGranted OTAConsentDenied = mattercore.OTAConsentDenied OTAConsentObtaining = mattercore.OTAConsentObtaining OTAConsentUnknown = mattercore.OTAConsentUnknown )
The consent states an OTAConsent answers (matter.js OtaSoftwareUpdateConsentState).
const ( DCLProductionURL = dcl.ProductionURL DCLTestNetURL = dcl.TestNetURL )
The ledger's endpoints for NewDCLClient.
const AggregatorSurfaceKey = "aggregator"
AggregatorSurfaceKey is the key the Aggregator endpoint has in Node.Surface. It is reserved: Aggregator.Add refuses an endpoint, or a part, whose rendered StableKey equals it (ErrReservedKey).
const DCLDefaultMaxImageSize = dcl.DefaultMaxImageSize
DCLDefaultMaxImageSize bounds an image download when DCLOTAVersions.MaxImageSize sets none (dcl.DefaultMaxImageSize).
const DefaultDiagnosticsCapacity = diag.DefaultDiagnosticsCapacity
DefaultDiagnosticsCapacity is the trace's capacity when Diagnostics.Capacity is 0.
const DefaultProbeInterval = bridge.DefaultProbeInterval
DefaultProbeInterval is the probe cadence a zero Health.Interval selects (bridge.DefaultProbeInterval, 30 s).
const Scope = "node"
Scope is the endpoint.Snapshot scope of the Aggregator's default partition, the one its own methods act on (Aggregator.Partition names others); the assembler garbage-collects persisted endpoint numbers per scope.
Variables ¶
var ( // ErrNoStableKey: an endpoint whose Spec has no StableKey cannot keep // its endpoint number and is refused. ErrNoStableKey = errors.New("node: endpoint without a StableKey") // ErrDuplicateKey: an endpoint with the key of one already added, in // any partition. ErrDuplicateKey = errors.New("node: an endpoint with this StableKey is already added") // ErrUnknownKey: no endpoint with this key is added (to the partition // asked). ErrUnknownKey = errors.New("node: no endpoint with this StableKey") // ErrKeyMismatch: a replacement whose StableKey is not the key of the // endpoint it replaces. ErrKeyMismatch = errors.New("node: the replacement has another StableKey") // ErrRetireDefault: [Aggregator.RetirePartition] of the default // partition, which the node always assembles. ErrRetireDefault = errors.New("node: the default partition cannot be retired") // ErrPartitionNotEmpty: [Aggregator.RetirePartition] of a partition // that still holds endpoints. ErrPartitionNotEmpty = errors.New("node: the partition still holds endpoints") )
Aggregator errors.
var ( // ErrAdministratorWindowOpen refuses the node's own window while an // administrator's window is open ([Node.OpenBasicWindow], // [Node.OpenOwnWindow]). ErrAdministratorWindowOpen = bridge.ErrAdministratorWindowOpen // ErrCommissioningBlocked is wrapped by every window open refused // while [Node.SetCommissioningBlocked] holds an error. ErrCommissioningBlocked = bridge.ErrCommissioningBlocked // ErrCommissioningWindowAlreadyOpen refuses a second window while one // is open. // // Deprecated: no node method returns it; its only source is // bridge.CommissioningWindowOpener, which the node does not use — // compare with bridge.ErrCommissioningWindowAlreadyOpen there. // Removable in v0.25.0. ErrCommissioningWindowAlreadyOpen = bridge.ErrCommissioningWindowAlreadyOpen // ErrCommissioningWindowNotConfigured is the window's answer when no // passcode is configured. // // Deprecated: no node method returns it; its only source is // bridge.CommissioningWindowOpener, which the node does not use — // compare with bridge.ErrCommissioningWindowNotConfigured there. // Removable in v0.25.0. ErrCommissioningWindowNotConfigured = bridge.ErrCommissioningWindowNotConfigured )
The commissioning-window errors a host compares with errors.Is. They are the bridge's values, not copies: errors.Is(err, node.ErrX) and errors.Is(err, bridge.ErrX) answer alike.
var ( // ErrScrubIncomplete is wrapped by a [Node.FactoryReset] whose erase // completed but whose scrub of the SQLite file did not finish // (store.ErrScrubIncomplete). ErrScrubIncomplete = store.ErrScrubIncomplete // ErrFabricNotFound is [Node.RemoveFabric]'s answer for an index no // fabric holds (store.ErrFabricNotFound). ErrFabricNotFound = store.ErrFabricNotFound )
The store errors node methods return, for errors.Is. They are the store's values, not copies.
var ErrInvalidConfig = errors.New("node: invalid configuration")
ErrInvalidConfig wraps every Config.Validate failure.
var ErrInvalidWindowCredentials = errors.New("node: invalid window credentials")
ErrInvalidWindowCredentials wraps every Node.OpenBasicWindow credential failure.
var ErrNotStarted = errors.New("node: not started")
ErrNotStarted is returned by a call that needs the running node's assembled topology before Node.Start assembled it (Aggregator.IncreaseConfigurationVersions), and by Node.OpenOwnWindow, Node.OpenBasicWindow and Node.CloseWindow before Start completed: a window needs the node's socket.
var ErrOTAImageTooLarge = dcl.ErrOTAImageTooLarge
ErrOTAImageTooLarge is the cause of the error of a download the size bound refused or cut (dcl.ErrOTAImageTooLarge, the same value).
var ErrPolicyMismatch = errors.New("node: the endpoint was composed under other surface policies than the node's")
ErrPolicyMismatch is the refusal of Aggregator.Add (or Replace) of an endpoint composed under surface policies other than the node's Config.Surface — a device built with another device.Options.Surface. Policies hold for the whole node; a rule for one device is a policy that judges by surface.Element.Endpoint.
var ErrReservedKey = errors.New("node: the endpoint's key is reserved")
ErrReservedKey is the refusal of Aggregator.Add (or Replace) of an endpoint, or a part, whose rendered StableKey is AggregatorSurfaceKey.
var ErrStopped = errors.New("node: stopped")
ErrStopped is returned by Node.Start after Node.Stop: a node is not restarted; a host builds a new one on the same store. Node.OpenOwnWindow, Node.OpenBasicWindow and Node.CloseWindow return it from the first Stop on.
Functions ¶
func AheadRows ¶
func AheadRows() []string
AheadRows returns every "Ahead of matter.js" register ID the module's server declarations name — the root servers' and the device layer's — sorted and once each: the rows a host enables in Config.Surface's Extensions (surface.Policies.Extensions) to select their elements on the root and on a device. The one answer to "which extensions exist" (ADR 0030 Consequences; ADR 0025 principle 2).
func CreateOTAImage ¶ added in v0.10.4
func CreateOTAImage(opts OTAImageOptions) ([]byte, error)
CreateOTAImage builds a Matter OTA image file — header, payload and its digest — from opts (otaimage.Create).
func SoftwareVersionFromString ¶ added in v0.9.1
SoftwareVersionFromString maps a version string such as "1.4.2" to the BasicInformation SoftwareVersion number, for BasicInformation.SoftwareVersion (mattercore.SoftwareVersionFromString: the major, minor and patch components packed, floored at 1).
func ValidateSetupPIN ¶ added in v0.9.1
ValidateSetupPIN reports whether pin is a usable setup passcode: within 1..99999998 and not on the trivially-guessable list (setup.IsValidSetupPIN) — the check Config.Validate applies to Commissioning.Passcode. The error wraps ErrInvalidConfig.
Types ¶
type ActionRequest ¶ added in v0.10.4
type ActionRequest = mattercore.ActionRequest
ActionRequest is one Actions command an ActionsHost decides (mattercore.ActionRequest).
type Actions ¶ added in v0.10.4
type Actions = mattercore.Actions
Actions is the Actions server a host mounts on the Aggregator (Config.AggregatorServers): its action list, endpoint lists and commands, the host deciding each command (mattercore.Actions).
func NewActions ¶ added in v0.10.4
func NewActions(cfg ActionsConfig) (*Actions, error)
NewActions builds an Actions server over cfg (mattercore.NewActions).
type ActionsConfig ¶ added in v0.10.4
type ActionsConfig = mattercore.ActionsConfig
ActionsConfig configures NewActions (mattercore.ActionsConfig).
type ActionsHost ¶ added in v0.10.4
type ActionsHost = mattercore.ActionsHost
ActionsHost is the host port of an Actions server: its actions and endpoint lists, and the decision on each command (mattercore.ActionsHost).
type Advertiser ¶ added in v0.10.0
type Advertiser = mdns.Advertiser
Advertiser is the type of Config.Advertiser: what publishes the node over DNS-SD (mdns.Advertiser). An owned name for the seam; the two names are one type, so a value of either is the other.
type Aggregator ¶
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator is the Aggregator endpoint's set of bridged endpoints — matter.js `server.add(aggregator)` and `aggregator.add(endpoint)` (examples/device-bridge-onoff/src/BridgedDevicesNode.ts:77-78). It keeps the set in insertion order and produces the [endpoint.Snapshot]s the assembler consumes (ADR 0018 decision 4). Before Node.Start an Add or Remove only changes the set (Start's assembly is the first); after it, each one reassembles the running bridge, and a Aggregator.Batch reassembles once for many changes.
Each stable key keeps its endpoint number: Aggregator.Remove reserves it for the key's return, and only Aggregator.Forget (or Aggregator.RetirePartition for a whole partition) frees it — matter.js reserving a number per endpoint store (reserve.go).
A stored key the set does not hold — one a previous run held and this run has not added yet, or never will — keeps its number too: nothing is collected because it is absent, as matter.js keeps every stored number until its store is erased (packages/node/src/storage/server/ ServerEndpointStores.ts:33-45 load, :109-130 assignNumber at db021da0). A host that knows a device is gone for good calls Forget.
The set is partitioned for a host whose devices come from several sources that load independently: Aggregator.Partition names one, with its own snapshot scope, and Aggregator.RetirePartition erases every number stored for a source that left. The Aggregator's own methods act on the default partition, scope Scope; a host without partitions sees one snapshot, as before. A StableKey is unique across all partitions.
A device.Device it holds (or a generated type around one) is bound to the node while it is held: it takes the node's clock, runs its `…Async` callbacks on its own goroutine, and answers device.Device.EndpointNumber, SetReachable and Rename through the node. Remove, Replace and Node.Stop unbind it, waiting for its queued callbacks.
func (*Aggregator) Add ¶
func (a *Aggregator) Add(ctx context.Context, ep Endpoint) error
Add adds ep under the Aggregator — matter.js `aggregator.add(endpoint)` (endpoint/Endpoint.ts:755-770) — and binds a device to the node; a running node reassembles. A device another node holds is refused (device.ErrAddedElsewhere). It adds to the default partition.
func (*Aggregator) Batch ¶ added in v0.10.2
Batch runs fn with a Batch on the default partition and reassembles once for every change fn made; see Partition.Batch.
func (*Aggregator) Endpoints ¶
func (a *Aggregator) Endpoints() []Endpoint
Endpoints returns the default partition's set, in insertion order.
func (*Aggregator) Forget ¶ added in v0.12.2
Forget removes the endpoint with key from the default partition if it holds it, and frees the endpoint numbers stored for key and for the parts it had: a later Add of key gets a fresh number, as a new device would. It erases what the node stored for those keys' servers too — the nonvolatile attribute values the module holds and the UserLabel lists — so the later Add starts from its declaration. It is the counterpart of Aggregator.Remove, which keeps them — matter.js's `delete()` beside `close()` (endpoint/Endpoint.ts:987-992, :1024-1032 at db021da0; ServerEndpointInitializer.ts:59-65 eraseDescendant). A key no partition holds and nothing is stored for is no error; a key another partition holds is ErrUnknownKey. A key the specification level withheld loses its withheld record in Node.Surface.
func (*Aggregator) IncreaseConfigurationVersions ¶ added in v0.8.6
func (a *Aggregator) IncreaseConfigurationVersions(ctx context.Context, keys ...device.SourceKey) error
IncreaseConfigurationVersions raises, as one change of the node, the ConfigurationVersion of the bridged endpoints with keys — each physical device once — and the node's own once, after them, and persists every version raised in one pass, so a version never decreases across a restart. The write runs on ctx's values without its cancellation — a version served is stored even when ctx ends first — and a write the store refuses is returned, after the versions were raised and served. With no key it raises the node's alone. Before the node assembled its topology (Node.Start) it fails with ErrNotStarted; an unknown key fails with ErrUnknownKey before anything is raised. Mirrors matter.js BasicInformationServer.increaseConfigurationVersion(change) (BasicInformationServer.ts:132-138: the change first, one increment afterwards) with the bridged devices raised under the shared context (BridgedDeviceBasicInformationServer.ts:72-90); the bridge's IncreaseNodeConfigurationVersionWith does the raising.
func (*Aggregator) Partition ¶ added in v0.10.2
func (a *Aggregator) Partition(name string) *Partition
Partition returns the handle of the partition name, creating it on first use; the same name gives the same handle. "" and Scope are the default partition, the one the Aggregator's own methods act on. A new partition is assembled from the next reassembly on, as its own endpoint.Snapshot with Scope name, after the default one and the partitions created before it.
func (*Aggregator) Partitions ¶
func (a *Aggregator) Partitions() []string
Partitions are the names of the partitions, the default (Scope) first, then in creation order; a retired one is gone.
func (*Aggregator) Remove ¶
Remove drops the endpoint with key; a running node reassembles. The key keeps its endpoint number, and its parts theirs, across restarts: an Add of the same key gets them back, and no other device is given them. Aggregator.Forget frees them. It mirrors matter.js closing an endpoint, which keeps its number reservation (packages/node/src/node/server/ServerEndpointInitializer.ts: 67-69 at b25ed960) and hands it back to the endpoint that returns (packages/node/src/storage/server/ServerEndpointStores.ts:117-123). It acts on the default partition.
func (*Aggregator) Replace ¶ added in v0.10.0
Replace puts ep in the place of the endpoint with key: ep must carry the same StableKey (ErrKeyMismatch), so it keeps the endpoint number the endpoint store holds for the key, and the running node reassembles once — the Aggregator's PartsList unchanged, the endpoint's Descriptor (device types, server list) the one change a controller sees. The old endpoint is unbound after the reassembly. It mirrors matter.js replacing a part: `close()` keeps the endpoint's number reservation (endpoint/Endpoint.ts:1024-1032, ServerEndpointInitializer.ts:67-69, where `delete()` would erase it, endpoint/Endpoint.ts:987-992) and the new endpoint with the same id is assigned it (ServerEndpointInitializer.ts:34-42). It acts on the default partition.
func (*Aggregator) RetirePartition ¶ added in v0.10.2
func (a *Aggregator) RetirePartition(ctx context.Context, name string) error
RetirePartition gives up the partition name for good: a source that left the host's configuration, whose stored endpoint numbers no snapshot would ever list again. It needs no handle — after a restart there is none. The next assembly first erases every endpoint number stored for scope name and their reservations — matter.js erasing each endpoint's store (packages/node/src/node/server/ServerEndpointInitializer.ts:59-65 eraseDescendant at b25ed960) — and the name is then forgotten. A running node reassembles at once; before Node.Start the retirement rides on Start's assembly. The default partition is refused (ErrRetireDefault), and so is a partition that still holds endpoints (ErrPartitionNotEmpty): Remove them first, or in a Partition.Batch.
type Attestation ¶
type Attestation struct {
// Files names a vendor chain on disk; [New] loads it into Chain and
// CertificationDeclaration, which it excludes. Files that name
// nothing keep the CSA test chain; a chain that does not load fails
// New.
Files *AttestationFiles
// BlockCommissioningOnError keeps a node whose Files do not load
// running: it serves the test chain, refuses every commissioning
// ([Node.SetCommissioningBlocked] with the load error) and reports the
// error in [Node.AttestationError]. Controllers already paired keep
// working — attestation is checked only while a controller
// commissions. It needs Files.
BlockCommissioningOnError bool
// Chain is the DAC, its key and the PAI; nil is the CSA test chain. A
// host with a chain of its own (an HSM-held key, say) sets it here.
// Its DAC and PAI must name the ProductDescription's vendor and
// product, as a chain Files loads must: another product's fails New
// with attestation.ErrProductMismatch.
Chain *AttestationChain
// CertificationDeclaration is the CMS-signed CD; nil is the CSA test
// CD for the vendor and product.
CertificationDeclaration []byte
// Provider supplies the chain and the CD when a commissioner first
// asks for them — the first AttestationRequest, CertificateChainRequest
// or CSRRequest — never at [New] or [Node.Start]; a nil chain or CD it
// returns is the CSA test material, as above. A failed call fails that
// request and is retried on the next; so does a chain of another
// product than ProductDescription's (attestation.ErrProductMismatch). It excludes Files, Chain and
// CertificationDeclaration. Mirrors matter.js
// OperationalCredentialsServer.State.certification, which takes an
// async provider (packages/protocol/src/certificate/
// DeviceCertification.ts:185, built on first use by
// OperationalCredentialsServer.ts:560-572 at db021da0).
Provider func(ctx context.Context) (chain *AttestationChain, certificationDeclaration []byte, err error)
}
Attestation is the device attestation material.
type AttestationChain ¶ added in v0.10.0
type AttestationChain = attestation.Chain
AttestationChain is the type of Attestation.Chain: the DAC, its key and the PAI (attestation.Chain).
type AttestationFiles ¶ added in v0.9.1
type AttestationFiles = attestation.ChainFiles
AttestationFiles names a vendor attestation chain on disk (attestation.ChainFiles): the Device Attestation Certificate, its private key, the Product Attestation Intermediate and the Certification Declaration. Each file may be PEM or DER, the key PKCS#8 or SEC1.
type AttributeChange ¶
AttributeChange is one change Observers.OnAttributeChanged reports: the endpoint and cluster, and the change's attribute ids and origin (contract.Change).
type AttributeValue ¶
type AttributeValue struct {
Endpoint uint16
Cluster uint32
Attribute uint32
// Value is the value as the cluster server's MatterRead returns it —
// the Go value the node encodes on the wire; nil for a null and for
// an attribute whose read failed.
Value any
// DataVersion is the cluster's DataVersion at the read; 0 for an
// attribute whose read failed.
DataVersion uint32
// Status is the IM status of the attribute's read — 0 (SUCCESS) for
// a value, otherwise the status a controller's read reports for the
// path (the value a [contract.StatusError] carries). Only
// [Node.ReadCluster] returns a failed attribute; [Node.ReadAttribute]
// returns its failure as the error.
Status uint8
}
AttributeValue is one attribute value the node serves, as Node.ReadAttribute and Node.ReadCluster return it.
func (AttributeValue) JSON ¶
func (v AttributeValue) JSON() (json.RawMessage, error)
JSON renders Value by name, as a controller of this module renders the same attribute read over the wire (controller/client.DecodeJSON with NameBased and the attribute's type from the generated cluster definitions): a struct keyed by its camelCase field names, a list an array, bytes base64, null for a null. A value of a cluster or attribute without a definition renders untyped, a struct keyed by its context tags.
type BDXResponder ¶
BDXResponder is the BDX responder Node.BDX returns (bdx.Responder).
type BasicInformation ¶
type BasicInformation struct {
VendorName string
ProductName string
ProductLabel string
// NodeLabel is the label the node serves on its first boot; empty is
// the ProductName, as matter.js's BasicInformationServer.ts:68 at
// b25ed960 (setDefault("nodeLabel", state.productName)).
NodeLabel string
SerialNumber string
// UniqueID pins BasicInformation.UniqueID (quality F, Matter
// §11.1.5.13) to a value the host persisted itself; at most 32 UTF-8
// bytes. Empty, the facade pins it: the first boot of a store derives
// one (mattercore.DeriveUniqueID over the vendor, product, NodeLabel
// and SerialNumber) and keeps it under store.SettingUniqueID, every
// later boot serves the stored value — matter.js creates uniqueId
// once when the state has none and persists it
// (BasicInformationServer.ts:89-91), so a later edit to NodeLabel does
// not re-identify the node under a controller's cache. A boot with
// bootid rotation enabled serves a per-boot value and pins nothing, so
// the next boot without rotation serves the value pinned before it.
// Leave the field empty unless the host owns the node's identity: a
// value here replaces the facade's pin, silently.
UniqueID string
HardwareVersion uint16
HardwareVersionString string
SoftwareVersion uint32
SoftwareVersionString string
}
BasicInformation is the root BasicInformation the daemon configures (examples/reference-bridge/wiring.go:105-116 at b4ea1f96^, buildRootClusters), plus ProductLabel from matter.js's example (BridgedDevicesNode.ts:29-65).
type BasicInformationServer ¶ added in v0.10.4
type BasicInformationServer = mattercore.BasicInformation
BasicInformationServer is the root BasicInformation server — its software version after an applied update, its NodeLabel and its reachable event (mattercore.BasicInformation).
type Batch ¶ added in v0.10.2
type Batch struct {
// contains filtered or unexported fields
}
Batch is a set of changes to one partition that reassembles once: each call validates and applies its change at once and returns its own error, and Partition.Batch reassembles after fn returns.
func (*Batch) Add ¶ added in v0.10.2
Add adds ep to the batch's partition; see Aggregator.Add.
func (*Batch) Forget ¶ added in v0.12.2
Forget removes the endpoint with key from the batch's partition if it holds it and frees the numbers stored for key once fn returned; see Aggregator.Forget.
func (*Batch) Remove ¶ added in v0.10.2
Remove drops the endpoint with key from the batch's partition; see Aggregator.Remove. The device is unbound after the batch's reassembly. A key the specification level withheld (its Add returned surface.ErrWithheld; no partition holds it) is known: Remove drops its withheld record from Node.Surface and returns nil.
type BridgeTopology ¶ added in v0.10.0
type BridgeTopology struct {
// Aggregator is the Aggregator's endpoint number; 0 before the node
// assembled its endpoints.
Aggregator uint16
// Devices are the bridged devices, by endpoint number.
Devices []BridgedDevice
}
BridgeTopology is the host's view of the node's bridge: the Aggregator's endpoint number and the bridged devices under it, each with its endpoint number — what Node.Topology returns.
type BridgedDevice ¶ added in v0.10.0
type BridgedDevice struct {
// Key is the device's stable key ([device.Options].StableKey).
Key device.SourceKey
// Endpoint is its endpoint number.
Endpoint uint16
// DeviceType is its device type id, DeviceTypeRevision the revision
// its Descriptor's DeviceTypeList serves for it (the generated
// schema's, schema.DeviceTypeRevision; 0 for an id the schema does
// not know).
DeviceType uint16
DeviceTypeRevision uint16
// Clusters are the cluster servers mounted on the endpoint, in the
// order its Descriptor's ServerList lists them — for every endpoint,
// parts and the endpoints of a host's own [Snapshotter] included.
Clusters []ClusterInfo
// Name is the NodeLabel it serves: a controller's or the host's
// rename, else its Name.
Name string
// Reachable is its Reachable as a controller reads it now.
Reachable bool
// Scope is the snapshot scope the endpoint was assembled from
// (endpoint.Endpoint.Scope): the name of the Aggregator partition that
// holds it — [Scope] for the default one, so [Aggregator.Partition]
// takes it back — or the scope of a host's own [Snapshotter].
Scope string
// Tags are the semantic tags its Descriptor serves in TagList, as a
// controller reads them; nil while the Descriptor serves no TagList —
// the default, and today every bridged endpoint's case: the assembler
// builds its Descriptor without the feature, which Apple's Matter
// stack refuses (cluster/core Descriptor.MatterRead).
Tags []SemanticTag
// Labels are the entries of its FixedLabel LabelList, then of its
// UserLabel LabelList, each when the endpoint serves the cluster.
Labels []Label
// Added is what the host added to the Aggregator under Key (a
// device.Device, the generated type around one, or any [Endpoint]);
// nil for a part and for an endpoint of a host's own [Snapshotter].
Added Endpoint
// Parts are its parts, by endpoint number.
Parts []BridgedDevice
}
BridgedDevice is one bridged device of a BridgeTopology, or a part of one.
type CapabilityMinimaStruct ¶ added in v0.10.0
type CapabilityMinimaStruct = mattercore.CapabilityMinimaStruct
CapabilityMinimaStruct is the type of Config.CapabilityMinima: the BasicInformation CapabilityMinima (mattercore.CapabilityMinimaStruct).
type ClientConfig ¶
type ClientConfig struct {
// Listen is the client socket's bind address; empty is an ephemeral
// port on every address ("[::]:0", "0.0.0.0:0" with
// Network.PreferIPv4). The client stack initiates from its own socket:
// an initiator's source port is free, and the peer answers the source
// it saw.
Listen string
// Names is the DNS-SD cache the peers' operational records are looked
// up in; nil opens one on the mDNS groups (discovery.Open), which the
// node closes on Stop. A Names the host supplies stays the host's.
Names *DiscoveryNames
// contains filtered or unexported fields
}
ClientConfig is the node's client stack: what a server node needs to reach other nodes of its fabrics — the peers its Binding entries direct. matter.js gives every ServerNode its peers (`node.peers`, the PeerSet BindingManager.ts:317 and :445 use); here the stack is opt-in, an optional sub-system a non-nil Config.Client builds (ADR 0025 principle 2).
type ClusterInfo ¶ added in v0.12.2
type ClusterInfo struct {
// ID is the cluster id.
ID uint32
// Name is the cluster's name in the generated schema
// (schema.ClusterName: "OnOff", "LevelControl", …); empty for a
// cluster the schema does not know (a manufacturer-specific one).
Name string
// Revision is the schema's ClusterRevision of the cluster
// (schema.ClusterRevision); 0 for a cluster the schema does not know.
Revision uint16
}
ClusterInfo names one cluster server a BridgedDevice serves.
type CommissionerControlConfig ¶ added in v0.4.0
type CommissionerControlConfig struct {
// Approver approves requests. Required.
Approver CommissioningApprover
// Commissioner commissions an approved client's node. Required.
Commissioner ReverseCommissioner
// SupportedDeviceCategories is the attribute; a fabric-synchronising
// bridge states FabricSynchronization.
SupportedDeviceCategories commctrldef.SupportedDeviceCategoryBitmap
// ApprovalTimeout and ApprovalValidity are
// mattercore.CommissionerControlConfig's.
ApprovalTimeout, ApprovalValidity time.Duration
}
CommissionerControlConfig mounts the CommissionerControl server (0x0751) on the Aggregator endpoint, where the Aggregator device type lists it under FabricSynchronization (device/aggregator_gen.go) and connectedhomeip's fabric-sync bridge serves it (kAggregatorEndpointId, examples/fabric-sync/bridge/CommissionerControlDelegate.h:30 at the harness pin). The two ports are the host's: the approval, and the commissioner that commissions an approved client's node — the node itself has none (ADR 0020: node does not import controller/); a host fills Commissioner with controller/commissioner.
type CommissionerControlServer ¶
type CommissionerControlServer = mattercore.CommissionerControl
CommissionerControlServer is the CommissionerControl server Node.CommissionerControl returns (mattercore.CommissionerControl).
type Commissioning ¶
type Commissioning struct {
// Passcode is the setup passcode; it must pass setup.IsValidSetupPIN.
Passcode uint32
// Discriminator is the 12-bit commissioning discriminator.
Discriminator uint16
// PBKDFIterations is the SPAKE2+ PBKDF2 iteration count, within
// [spake2.IterationsMin, spake2.IterationsMax].
PBKDFIterations uint32
// Salt is a SPAKE2+ salt, spake2.PBKDFMinSaltSize to
// spake2.PBKDFMaxSaltSize bytes, still validated by [Config.Validate].
// The node no longer answers a window with it: its own window and an
// administrator's basic window each draw a fresh 32-byte salt when
// they open, as matter.js does (review II, decision 251). A window the
// host opens with [Node.OpenBasicWindow] takes the salt of its
// [WindowCredentials].
Salt []byte
// LocationCapability is GeneralCommissioning's LocationCapability
// (Matter §11.10.5.3), the regulatory locations the node supports and
// SetRegulatoryConfig admits (GeneralCommissioningServer.ts:172-191),
// and the RegulatoryConfig the node starts with: [RegulatoryOutdoor] or
// [RegulatoryIndoorOutdoor]. The zero value is IndoorOutdoor, matter.js's
// default (packages/model/src/standard/elements/
// general-commissioning.element.ts:31-38 at b25ed960, LocationCapability
// `default: 2`, RegulatoryConfig defaulting to it) — so
// [RegulatoryIndoor], which is 0, reads as the default here; a node
// that supports indoor operation alone sets [Commissioning].IndoorOnly.
LocationCapability uint8
// IndoorOnly states LocationCapability Indoor: SetRegulatoryConfig then
// admits Indoor alone. It excludes a non-zero LocationCapability.
IndoorOnly bool
// BasicCommissioning serves AdministratorCommissioning's Basic feature
// (BC): an administrator's OpenBasicCommissioningWindow opens a
// commissioning window against this Passcode under this Discriminator,
// WindowStatus BasicWindowOpen, where the enhanced command carries its
// own verifier. Off by default, as matter.js serves the feature only
// through AdministratorCommissioningServer.with("Basic")
// (AdministratorCommissioningServer.ts:55-61, :115-127 at db021da0);
// a host that turns it on offers the weaker method knowingly (the
// window's PASE runs against the fixed setup passcode).
BasicCommissioning bool
// TermsAndConditions serves GeneralCommissioning's TermsAndConditions
// feature (TC): the terms a commissioner has to acknowledge with
// SetTCAcknowledgements before CommissioningComplete succeeds, after
// connectedhomeip (register row
// BD-chip-GeneralCommissioning-TermsAndConditions; matter.js serves no
// terms, GeneralCommissioningServer.ts:31 at db021da0). nil leaves the
// feature off. The node keeps the acceptance in its store, reverts a
// tentative one with the fail-safe and resets it with the last fabric.
// The row is served behind [Config].Surface's Extensions (ADR 0030).
TermsAndConditions *TermsAndConditions
// WindowOnDemand leaves the node's own commissioning window to the
// host: the node opens none by itself — not at [Node.Start] while it
// has no fabric, not after its last fabric is removed, not when a
// [Node.OpenBasicWindow] window closes and not when
// [Node.SetCommissioningBlocked] lifts. Until the host calls
// [Node.OpenOwnWindow] (or [Node.OpenBasicWindow]) the node accepts
// no PASE and publishes no commissionable record, over DNS-SD or BLE;
// a commissioned node is unaffected. It is the start of a User-Intent
// product (a button opens the window). The zero value opens the
// window as before. Mirrors matter.js `commissioning.enabled: false`
// (packages/node/src/behavior/system/commissioning/
// CommissioningServer.ts:266-273, the field :410 at db021da0).
WindowOnDemand bool
// RotatingDeviceID advertises the Rotating Device Identifier (TXT key
// RI) in the commissionable record: a random 16-byte unique id the
// node draws once and keeps in its store, and a lifetime counter the
// store keeps too, advanced each time a commissioning window is
// advertised, so the identifier changes with every window and across
// restarts, and is not computable from the node's public identity.
// Off by default, as connectedhomeip's build default
// (src/setup_payload/BUILD.gn:19-22 at 6170af84,
// chip_enable_rotating_device_id = false); matter.js emits no RI
// (packages/protocol/src/advertisement/mdns/
// CommissionableMdnsAdvertisement.ts:84-97 at b25ed960). A store
// failure leaves RI out of that window's record rather than advertise
// a value that does not rotate.
RotatingDeviceID bool
// Flow is the commissioning flow the onboarding payload states
// ([FlowStandard], [FlowUserIntent], [FlowCustom]): the QR code's
// flow field and, for a flow other than Standard, the long manual
// code with the vendor and product id ([Node.SetupPayload],
// [Node.PairingCodesFor]). It states the flow only; whether the node
// opens its window by itself is WindowOnDemand. Mirrors matter.js
// `commissioning.flowType` (CommissioningServer.ts:415, the QR code
// :438, the manual code :446-454 at db021da0).
Flow CommissioningFlow
// PairingHints is the commissionable record's pairing hint (the `PH`
// key): how a user puts the device into commissioning mode, every
// bit of [mdns.PairingHints]. Zero sends powerCycle | deviceManual
// ([mdns.PairingHintsDefault]). A commissioner built on
// connectedhomeip reads a hint with any of bits 16 to 22 set as no
// hint at all (see [mdns.PairingHints]).
PairingHints mdns.PairingHints
// PairingInstruction is the record's `PI` key, the number or text a
// hint that needs one refers to. A hint and an instruction that do
// not belong together fail [Config.Validate] with
// [mdns.ErrInvalidService]: at most one hint that needs an
// instruction, that hint with an instruction, an instruction only
// with such a hint ([mdns.CommissionableServiceConfig.Validate]).
PairingInstruction string
}
Commissioning is matter.js `commissioning` (the State of CommissioningServer.ts:409-419 at b25ed960: passcode, discriminator) plus the SPAKE2+ PBKDF parameters the daemon configures (main.go:91-92 at b4ea1f96^).
func NewCommissioningCredentials ¶ added in v0.9.1
func NewCommissioningCredentials() (Commissioning, error)
NewCommissioningCredentials draws a fresh commissioning secret: a random passcode from the valid set (bridge.RandomPasscode, never on the trivially-guessable list), a random 12-bit discriminator (bridge.RandomDiscriminator), a random salt of PBKDFSaltMax bytes (bridge.RandomSalt) and PBKDFIterationsMin PBKDF iterations — values Config.Validate accepts. LocationCapability is left at its zero value, IndoorOutdoor (Commissioning.LocationCapability). A host that has no configured secret uses it for Config.Commissioning, or copies its fields into the WindowCredentials of one Node.OpenBasicWindow; it persists the result itself when the node's own window must keep its pairing code across restarts.
func (Commissioning) WindowCredentials ¶ added in v0.9.1
func (c Commissioning) WindowCredentials(timeout time.Duration) WindowCredentials
WindowCredentials are c's secret as the credentials of one Node.OpenBasicWindow window that stays open for timeout (0 is the node's own window default) — a fresh window secret is NewCommissioningCredentials().WindowCredentials(timeout).
type CommissioningApprover ¶ added in v0.10.0
type CommissioningApprover = mattercore.CommissioningApprover
CommissioningApprover is the type of CommissionerControlConfig.Approver: the host's decision on a commissioning request (mattercore.CommissioningApprover).
type CommissioningFlow ¶
type CommissioningFlow uint8
CommissioningFlow is the commissioning flow an onboarding payload states (Commissioning.Flow): the QR code's two-bit flow field.
const ( // FlowStandard is the standard flow: the device is commissionable when // powered. FlowStandard CommissioningFlow = iota // FlowUserIntent is the user-intent flow: the user acts on the device // (a button) before it is commissionable — commonly with // [Commissioning].WindowOnDemand. FlowUserIntent // FlowCustom is the custom flow: the vendor's own steps, looked up by // vendor and product id. FlowCustom )
type Config ¶
type Config struct {
// Network mirrors matter.js `network` (NetworkServer.ts:202-223 at
// b25ed960).
Network Network
// Commissioning mirrors matter.js `commissioning`
// (CommissioningServer.ts:409-419 at b25ed960). An uncommissioned
// node's own window closes after 48 h and nothing reopens it: the node
// is then not commissionable until the host calls [Node.OpenOwnWindow]
// ([Observers].OnWindowTransition reports the close).
Commissioning Commissioning
// ProductDescription mirrors matter.js `productDescription`
// (ProductDescriptionServer.ts:70-90): the identity the commissionable
// advertisement carries.
ProductDescription ProductDescription
// BasicInformation mirrors matter.js `basicInformation`
// (examples/device-bridge-onoff/src/BridgedDevicesNode.ts:29-65).
BasicInformation BasicInformation
// Store is where the node keeps its fabrics, credentials, ACL, groups,
// subscriptions, settings and endpoint numbers.
Store Store
// Advertiser publishes the node over DNS-SD. nil is the node's own:
// the module's mDNS responder (mdns.NewResponder), configured by
// [Network].MDNS, or mdns.NewNoop() with [MDNS].Off. [Node.Stop]
// closes it, the host's as the node's. [Network].MDNS configures the
// node's own advertiser only: with Advertiser set, an MDNS with Off,
// HostName or Interfaces set fails [Config.Validate].
Advertiser Advertiser
// DeviceTypeValidation is the bridge's device-type judgement mode
// (bridge.SetDeviceTypeValidation); the zero value is matter.js's
// warn mode.
DeviceTypeValidation DeviceTypeValidationMode
// Attestation is the device attestation material; the zero value is
// the CSA test chain and test Certification Declaration for the
// configured vendor and product (attestation.BuildTestChain,
// attestation.BuildTestCertificationDeclaration) — pairable with every
// commissioner's test PAA, and not shippable.
Attestation Attestation
// OTA mounts the OTA Software Update Requestor on the root when set;
// nil leaves it out (and the OtaRequestor device type with it).
OTA *OTAConfig
// BootReason is the GeneralDiagnostics BootReason this start reports
// (the BootReason event [Node.Start] emits, [Node.BootReason]): a
// BootReasonEnum value of cluster/core (mattercore.BootReasonUnspecified
// … BootReasonSoftwareReset). The zero value is Unspecified, matter.js's
// default (GeneralDiagnosticsServer.ts:417-420 at db021da0, `bootReason
// ?? BootReason.Unspecified`). A start into the version an update of
// the node's own OTA requestor installed is SoftwareUpdateCompleted
// whatever this states: the requestor's record of the update in
// progress names the version that now runs, the record the requestor
// reports VersionApplied on (OtaSoftwareUpdateRequestorServer.ts:255-280
// at b25ed960).
BootReason uint8
// ICD makes the node an intermittently connected device: ICD
// Management on the root, Check-Ins to its registered clients, the
// ICD advertisement ([ICDConfig], [Node.ICD]). nil, the default, is a
// node that is no ICD: nothing mounts and nothing changes.
ICD *ICDConfig
// TLS mounts TlsCertificateManagement and TlsClientManagement on the
// root and hands them to the topology's PushAvStreamTransport servers
// ([TLSConfig], [RootClusters].TLSCertificateManagement); nil mounts
// neither.
TLS *TLSConfig
// OTAProvider serves OTA images: the OTA Software Update Provider on an
// endpoint of device type OtaProvider beside the Aggregator, its images
// over BDX (ADR 0021). nil, or no ImageSource, mounts none. With
// [Config].Snapshotter set the node builds the provider
// ([Node.OTAProvider]) and the host mounts it.
OTAProvider *OTAProviderConfig
// WebRTCRequestor is the node's part of the WebRtcTransportRequestor
// servers its topology mounts (camera.Requestor, the default of
// device.NewCameraController): the fabrics whose ACL gets the entry
// that lets a camera of the fabric invoke them
// ([WebRTCRequestorConfig].GrantFabric). nil grants none.
WebRTCRequestor *WebRTCRequestorConfig
// CommissionerControl mounts the CommissionerControl server on the
// Aggregator (ADR 0020 stage 6); nil mounts none. The reference daemon
// mounts none.
CommissionerControl *CommissionerControlConfig
// FixedLabels is the root FixedLabel list; nil serves an empty list.
FixedLabels []fixedlabeldef.LabelStruct
// Locales are the root LocalizationConfiguration's SupportedLocales,
// the first of them its ActiveLocale; nil is en-US alone. matter.js
// detects the active locale and lists it alone when the host states
// neither (LocalizationConfigurationServer.ts:14-21 initialize); a host
// states its own, as the reference daemon does (en-US, de-DE).
Locales []string
// TimeFormat is the root TimeFormatLocalization's start: its hour
// format, its calendar and the calendars a controller may choose, or
// the server without the CalendarFormat feature ([TimeFormatConfig]).
// nil starts at 24-hour and Gregorian, Gregorian the only calendar
// listed. matter.js detects the hour format and the calendar when the
// host states neither (TimeFormatLocalizationServer.ts:17-42 at
// b25ed960, initialize); detection is the host's here, so a host that
// knows its user's formats states them. A configuration the server
// refuses fails [New] with [mattercore.ErrLocalizationConfig]. A value
// a controller wrote and the node stored is restored over the start,
// as for Locales; a stored calendar the list no longer holds is not,
// and the start stands, with a warning.
TimeFormat *TimeFormatConfig
// Groups, when set, is the group state the node runs on, for a host
// whose own assembler ([Config].Snapshotter) mounts the stack's Groups and
// ScenesManagement servers over it (endpoint.Config.Groups): one
// manager serves the endpoints' servers, the bridge's group-message
// routing and the root's GroupKeyManagement and Groupcast, as matter.js
// has one GroupKeyManagementServer the GroupsServers of every endpoint
// write (GroupsServer.ts). The facade loads it (groups.Manager.Load)
// and attaches it; nil builds one over the credential store, which
// [Node.Groups] returns for a host that binds its assembler after New.
// An advanced seam (docs/guides/advanced-seams.md): a host with the
// facade's own assembler leaves it nil.
Groups *Groups
// Snapshotter, when set, is the host's own topology — a host that
// assembles its endpoints itself (its own endpoint.Assembler over its
// own device model, one endpoint.Snapshot per scope, its own label and
// scene persistence) hands the bridge its Snapshotter here, as the
// reference daemon did before the facade (main.go:188 at b4ea1f96^, bridge.New's
// first argument). The facade then builds no assembler and no
// [Aggregator] ([Node.Aggregator] is nil); the root and Aggregator
// endpoints' servers, the PartsList providers and every port stay the
// facade's. nil is the facade's [Aggregator] under one scope.
Snapshotter Snapshotter
// EndpointState, when set, replaces the facade's own scene and
// bridged-NodeLabel persistence ([NewEndpointState] over the node's
// store) in the facade's assembler and [Aggregator], for a host that
// keeps that state itself. nil is the facade's own (or, while it is
// set, EndpointPersistence adapted).
EndpointState EndpointState
// EndpointPersistence, when set and EndpointState is not, replaces the
// facade's own scene and bridged-NodeLabel persistence; its hooks
// cannot refuse a save. [Node.Persistence] returns it.
//
// Deprecated: use EndpointState, whose saves refuse a controller's
// change the store refuses. Removable in v0.25.0.
EndpointPersistence EndpointPersistence
// AggregatorServers are mounted on the Aggregator endpoint after
// Identify, Descriptor, FixedLabel and UserLabel — an Actions server,
// say (the daemon's buildAggregatorClusters extra, wiring.go:330-345 at b4ea1f96^).
AggregatorServers []contract.ClusterServer
// RootServers are mounted on the root endpoint after the root's own
// servers — a PowerSource on a battery node's root, say: matter.js's
// ServerNode.RootEndpoint.with(...) (ClientNodeTest.ts:3192-3205 at
// db021da0 puts PowerSourceServer.with("Battery") there). A cluster
// the root already serves is refused.
RootServers []contract.ClusterServer
// Surface are the surface policies the node's devices are composed
// under (package surface, ADR 0030). A device carries the digest of the
// policies it was built with (device.Options.Surface), and
// [Aggregator.Add] refuses one whose digest is not this one's
// ([ErrPolicyMismatch]). The zero value is no policy.
Surface surface.Policies
// SupportedFabrics is [Limits].SupportedFabrics.
//
// Deprecated: set Limits.SupportedFabrics, where the node's other
// capacity limits are; removable in v0.25.0. It keeps
// its meaning while Limits.SupportedFabrics is zero.
SupportedFabrics uint8
// TimeSynchronization is the root TimeSynchronization cluster
// (0x0038), mounted by default ([TimeSynchronization]); its Off
// leaves it off the root.
TimeSynchronization TimeSynchronization
// GeneralDiagnosticsFeatures selects the root GeneralDiagnostics'
// features (mattercore.NewGeneralDiagnosticsWith); nil keeps
// matter.js's default selection, DataModelTest
// (GeneralDiagnosticsServer.ts:51-52). Without DataModelTest a
// MaxPathsPerInvoke above one fails [Node.Start]
// (mattercore.GeneralDiagnostics.CheckDataModelTest).
GeneralDiagnosticsFeatures *GeneralDiagnosticsFeatures
// Faults is the host's port of the faults the device detects
// (contract.FaultSource): the root GeneralDiagnostics serves
// ActiveHardwareFaults, ActiveRadioFaults and ActiveNetworkFaults
// from it and emits HardwareFaultChange, RadioFaultChange and
// NetworkFaultChange with the current and the previous list when one
// changes, as matter.js GeneralDiagnosticsServer's register…Fault and
// clear…Fault do (GeneralDiagnosticsServer.ts:296-411 at db021da0).
// nil serves neither the lists nor the events.
Faults contract.FaultSource
// MaxPathsPerInvoke is [Limits].MaxPathsPerInvoke.
//
// Deprecated: set Limits.MaxPathsPerInvoke, where the node's other
// capacity limits are; removable in v0.25.0. It keeps
// its meaning while Limits.MaxPathsPerInvoke is zero.
MaxPathsPerInvoke uint16
// Sessions are the MRP intervals the node reports in its session
// parameters and its operational DNS-SD record ([SessionIntervals]);
// nil is the Matter defaults, 500 ms idle, 300 ms active and a 4000 ms
// active threshold. An ICD's operational record carries the ICD's
// active threshold and, while LIT, no idle interval
// (IcdManagementServer.ts:482-495); its session parameters keep these.
Sessions *SessionIntervals
// CapabilityMinima is the root BasicInformation's CapabilityMinima:
// a zero field takes matter.js's default (the Matter floor of 3 for
// CaseSessionsPerFabric and SubscriptionsPerFabric, 20 for the four
// revision-6 fields, BasicInformationServer.ts initialize), a value
// the host sets wins (CapabilityMinimaTest.ts "caller-provided values
// win").
CapabilityMinima CapabilityMinimaStruct
// Limits are the capacity limits a host may set ([Limits]); the zero
// value keeps every default.
Limits Limits
// Client is the node's client stack ([ClientConfig]): the socket,
// exchanges and peers its Binding entries reach other nodes through.
// nil runs without one ([Node.Peers] is nil, a node Binding entry is
// dropped).
Client *ClientConfig
// Health runs the node's health probe ([Health], [Node.Health]); nil
// runs none.
Health *Health
// Observers are the host's callbacks on fabric and commissioning
// events, each chained after the facade's own handler (observers.go);
// the zero value observes nothing.
Observers Observers
// Metrics receives the node's named counters and gauges ([Metrics],
// the Metric… constants); nil records nothing. node/metrics/expvar
// publishes them on expvar.
Metrics Metrics
// Diagnostics sizes the node's diagnostic trace ([Diagnostics],
// [Node.DiagnosticEvents]); the zero value keeps 256 events.
Diagnostics Diagnostics
// Logger is the node's logger; nil is slog.Default().
// docs/guides/observability.md names the attribute keys and event
// prefixes the module logs with.
Logger *slog.Logger
// Clock is the node's time source; nil is [clock.System]. The node
// hands it to the bridge (every device-side interval: the ack pump,
// MRP, subscriptions' timers, the commissioning window, PASE lockout),
// the session table, the subscription engine, the PASE and CASE
// providers, the operational resolver, an advertiser that takes a
// clock ([mdns.Responder]), the group sender, the root's cluster
// servers, OTA, the store's persist loop and the reopen poll. A test
// passes a [github.com/SukramJ/go-fabric/clock/clocktest.Fake].
Clock clock.Clock
// contains filtered or unexported fields
}
Config is the node's configuration, code-first (ADR 0018 decision 5). Its groups are the behaviour ids matter.js's ServerNode.Configuration keys its options by — `network`, `commissioning`, `productDescription`, `basicInformation` (packages/node/src/node/ServerNode.ts:107-127) — for the subset the reference daemon uses; the rest is what the daemon's bring-up needs beyond them (examples/reference-bridge/main.go:84-497 at b4ea1f96^).
func (*Config) Validate ¶
Validate holds the checks the daemon applies to its flags (main.go:113-131 at b4ea1f96^): the discriminator's 12 bits, the passcode's range and the trivially-guessable list, the PBKDF iteration range and salt length the SPAKE2+ verifier needs, and the identity the bridge and the assembler refuse to start without. The bounds are this package's MaxDiscriminator, PBKDFIterationsMin, PBKDFIterationsMax, PBKDFSaltMin and PBKDFSaltMax; the passcode check is ValidateSetupPIN — a host checks its own configuration against them before New.
An empty BasicInformation.NodeLabel is valid: New serves the ProductName ([BasicInformation.defaultNodeLabel]).
type DCLClient ¶ added in v0.10.4
DCLClient asks the CSA Distributed Compliance Ledger (dcl.Client). Nothing reaches the network unless a host builds one.
func NewDCLClient ¶ added in v0.10.4
NewDCLClient is a ledger client at baseURL (dcl.NewClient).
type DCLOTAVersions ¶ added in v0.10.4
type DCLOTAVersions = dcl.OTAVersions
DCLOTAVersions looks a model's software versions up in the ledger: the update for a current version, one version's record, its download (dcl.OTAVersions). An OTA image source checks what it offers with it.
type DCLSoftwareVersion ¶ added in v0.10.4
type DCLSoftwareVersion = dcl.SoftwareVersion
DCLSoftwareVersion is the ledger's record of one software version (dcl.SoftwareVersion).
type DeviceTypeInfo ¶
DeviceTypeInfo is one entry of a Descriptor DeviceTypeList: the device type id (a 32-bit devtype-id on the wire) and the revision the endpoint reports for it.
type DeviceTypeValidationMode ¶ added in v0.10.0
type DeviceTypeValidationMode = endpoint.DeviceTypeValidationMode
DeviceTypeValidationMode is the type of Config.DeviceTypeValidation: how the node treats a device type that breaks its conformance (endpoint.DeviceTypeValidationMode).
type DiagnosticEvent ¶ added in v0.9.1
DiagnosticEvent is one entry of the node's diagnostic trace (diagevent.Event): the moments that explain a failed pairing.
type Diagnostics ¶ added in v0.10.6
type Diagnostics = diag.Diagnostics
Diagnostics is the type of Config.Diagnostics: the node's diagnostic trace, a bounded in-memory ring of the moments that explain a failed pairing or a lost session (DiagnosticEvent). The ring is memory only; the logs are the durable record. It is diag.Diagnostics, shared with the controller.
type DiscoveryNames ¶
DiscoveryNames is the DNS-SD cache of ClientConfig.Names (discovery.Names).
type EcosystemDirectory ¶ added in v0.10.4
type EcosystemDirectory = mattercore.EcosystemDirectory
EcosystemDirectory is the host port of an EcosystemInformation server: the devices and locations of the host's ecosystem (mattercore.EcosystemDirectory).
type EcosystemInformation ¶ added in v0.10.4
type EcosystemInformation = mattercore.EcosystemInformation
EcosystemInformation is an EcosystemInformation server over an EcosystemDirectory (mattercore.EcosystemInformation); a device declares it with ecosysteminformationdef.Declare{HostServer: …}.
func NewEcosystemInformation ¶ added in v0.10.4
func NewEcosystemInformation(dir EcosystemDirectory) *EcosystemInformation
NewEcosystemInformation builds an EcosystemInformation server over dir (mattercore.NewEcosystemInformation).
type Endpoint ¶
Endpoint is what the Aggregator holds: anything that describes itself as an endpoint.Spec — a device.Device, or any type with a Spec method (ADR 0018 decision 4).
type EndpointInfo ¶
type EndpointInfo struct {
// Endpoint is the endpoint number.
Endpoint uint16
// Parent is the endpoint whose part this one is — the root for the
// Aggregator, the Aggregator for a bridged device, the device for one
// of its parts — valid when HasParent is set. The root has none.
Parent uint16
HasParent bool
// Parts is the Descriptor PartsList the endpoint serves, in its
// order: every endpoint below it (the root's lists every other
// endpoint, a bridged device's its parts), as a controller reads it.
Parts []uint16
// DeviceTypes is the Descriptor DeviceTypeList the endpoint serves,
// in its order, each with the revision it reports.
DeviceTypes []DeviceTypeInfo
// Clusters are the cluster servers the endpoint serves, in the order
// of its Descriptor ServerList.
Clusters []ClusterInfo
// Name is the endpoint's node label, empty for one without.
Name string
// Key is the source key of the host device the endpoint was assembled
// from; nil for an endpoint no host device declared (the root, the
// Aggregator).
Key device.SourceKey
// Scope is the snapshot scope the endpoint was assembled from, as
// [BridgedDevice].Scope names it.
Scope string
}
EndpointInfo is one endpoint the node serves, as Node.Endpoints returns it: its place in the endpoint tree and what its Descriptor serves.
type EndpointPersistence
deprecated
added in
v0.5.0
type EndpointPersistence interface {
endpoint.ScenesStore //nolint:staticcheck // the deprecated port keeps its deprecated shape
// OnNodeLabelWritten persists a commissioner-written NodeLabel of the
// bridged endpoint under key.
OnNodeLabelWritten(key device.SourceKey, label string)
// NodeLabel is the label persisted for key, "" for none.
NodeLabel(ctx context.Context, key device.SourceKey) string
}
EndpointPersistence is the endpoint-level stack state the facade keeps for its own assembler: a bridged endpoint's scene table (under "scenes.<key>") and the per-endpoint NodeLabel a commissioner wrote (under "bridged_node_label.<key>"), each keyed by the endpoint's stable key's String(). A host restores a label by setting its endpoint.Spec's NodeLabel from EndpointPersistence.NodeLabel before assembling.
Deprecated: use EndpointState, whose saves and loads report the store's error. Removable in v0.25.0.
func NewEndpointPersistence
deprecated
added in
v0.5.0
func NewEndpointPersistence(st store.Settings, logger *slog.Logger) EndpointPersistence
NewEndpointPersistence returns the facade's EndpointPersistence over st's settings table — the keys the node uses. st must hold the store schema (store.Apply); a nil logger is slog.Default().
Deprecated: use NewEndpointState. Removable in v0.25.0.
type EndpointState ¶
type EndpointState interface {
endpoint.Persistence
// LoadNodeLabel returns the label stored for key, "" for none.
LoadNodeLabel(ctx context.Context, key device.SourceKey) (string, error)
}
EndpointState is the endpoint-level stack state the facade keeps for its own assembler, exported for a host that keeps it itself or assembles its endpoints itself (Config.Snapshotter, issue #117): a bridged endpoint's scene table (under "scenes.<key>") and the NodeLabel a controller wrote (under "bridged_node_label.<key>"), each keyed by the endpoint's stable key's String(). It is the assembler's endpoint.Persistence — a change a controller causes is stored with the change, and a refused store answers FAILURE (the store-error rule of store/doc.go) — and the label's load: a host restores a label by setting its endpoint.Spec's NodeLabel from LoadNodeLabel before assembling, as the facade's Aggregator does.
func NewEndpointState ¶
func NewEndpointState(st store.Settings, logger *slog.Logger) EndpointState
NewEndpointState returns the facade's EndpointState over st's settings table — the keys the node uses, so a host may build it before New (for the assembler its Config.Snapshotter runs) over a store the node later opens. st must hold the store schema (store.Apply); a nil logger is slog.Default(). A refused save is logged and returned.
type Event ¶
type Event struct {
// Number is the node-wide event number (Matter Core §7.14.2.1).
Number uint64
Priority contract.EventPriority
Endpoint uint16
Cluster uint32
Event uint32
// Time is the event's epoch timestamp, millisecond precision.
Time time.Time
// Payload is the event's data as the cluster server emitted it; nil
// without data.
Payload any
}
Event is one event the node served, as Node.Events returns it and Observers.OnEvent receives it: the record of the node's event log, which answers a controller's event read.
func (Event) JSON ¶
func (e Event) JSON() (json.RawMessage, error)
JSON renders Payload by name, as AttributeValue.JSON renders a value, with the event's type from the generated cluster definitions.
type EventQuery ¶
type EventQuery struct {
Endpoint *uint16
Cluster *uint32
Event *uint32
// MinNumber is the lowest event number returned (inclusive), as a
// controller's EventMin filter.
MinNumber uint64
// Limit, when positive, keeps only the newest Limit matching events.
Limit int
}
EventQuery selects the events Node.Events returns. A nil Endpoint, Cluster or Event matches every one; the zero query matches every event.
type FabricInfo ¶ added in v0.3.1
type FabricInfo struct {
FabricIndex uint8
FabricID uint64
NodeID uint64
RootPublicKey []byte
CompressedFabricID [8]byte
// VendorID is the AdminVendorID AddNOC carried for the fabric.
VendorID uint16
// Label is the fabric's label (UpdateFabricLabel); empty until an
// administrator sets one.
Label string
}
FabricInfo names one fabric, as OperationalCredentials' AddNOC hook carries it (cluster/core OpcredsConfig.OnFabricInstalled: fabric index, fabric id, node id, root public key) plus the compressed fabric id the operational record is named by, and the vendor and label the fabric's administrator set — the fields of the store's record a host shows (Node.FabricInfos).
type GeneralDiagnosticsFeatures ¶ added in v0.10.0
type GeneralDiagnosticsFeatures = mattercore.GeneralDiagnosticsFeatures
GeneralDiagnosticsFeatures is the type of Config.GeneralDiagnosticsFeatures: the feature selection of the root GeneralDiagnostics (mattercore.GeneralDiagnosticsFeatures).
type Groups ¶ added in v0.10.0
Groups is the type of Config.Groups and of what Node.Groups returns: the group state one node shares between its Groups, GroupKeyManagement and Groupcast servers and its group messaging (groups.Manager). An owned name for the seam, as Advertiser is.
type Health ¶ added in v0.9.1
type Health struct {
// Interval is the probe cadence; 0 is [DefaultProbeInterval].
Interval time.Duration
}
Health configures the node's health probe (bridge.StartHealthProbe): from Node.Start to Node.Stop the node checks its operational listener on Config.Clock and hands each verdict to the callbacks Node.OnHealthSample registered; Node.Health returns the last one. A non-nil Config.Health runs the probe, an optional sub-system (ADR 0025 principle 2).
type HealthSample ¶ added in v0.9.1
type HealthSample = bridge.HealthSample
HealthSample is one verdict of the node's health probe (bridge.HealthSample): Healthy while the operational UDP listener is bound, with a stable English Note.
type ICD ¶ added in v0.12.0
type ICD struct {
// contains filtered or unexported fields
}
ICD is the host's handle on an ICD node's mode machine and operating mode (Config.ICD). Every method is safe for concurrent use.
func (*ICD) EnterIdleMode ¶ added in v0.12.0
func (i *ICD) EnterIdleMode()
EnterIdleMode forces idle mode now. Mirrors matter.js IcdManagementServer.ts:653-655 (enterIdleMode).
func (*ICD) Mode ¶ added in v0.12.0
func (i *ICD) Mode() ICDOperatingMode
Mode is the operating mode the node advertises: LIT for a LIT ICD with a registered client or a forced LIT, SIT otherwise.
func (*ICD) OnModeChange ¶ added in v0.12.0
func (i *ICD) OnModeChange(fn func(ICDModeEvent)) (unsubscribe func())
OnModeChange registers fn for every mode event. fn runs inline, on the goroutine of the transition — a command, a host call, the active window's timer — and must not block; ICD.OnModeChangeAsync queues it instead. It returns the unsubscribe function.
func (*ICD) OnModeChangeAsync ¶ added in v0.12.0
func (i *ICD) OnModeChangeAsync(fn func(ICDModeEvent)) (unsubscribe func())
OnModeChangeAsync is ICD.OnModeChange with fn queued on the node's callback goroutine: fn runs later, one call after the other, while the node runs (between Node.Start and Node.Stop). fn must not stop the node.
func (*ICD) RequestActiveMode ¶ added in v0.12.0
func (i *ICD) RequestActiveMode()
RequestActiveMode wakes the device for a full active window — the idle→active transition at which the node sends its Check-Ins. A no-op before Start (IcdManagementServer.ts:632-634).
func (*ICD) SetOperatingMode ¶ added in v0.12.0
func (i *ICD) SetOperatingMode(mode ICDOperatingMode) error
SetOperatingMode switches a LIT ICD between SIT and LIT at run time. With ICDConfig.DynamicSITLIT the mode is forced until ICD.WithdrawForcedOperatingMode or the node's restart; without it the mode follows the registrations and mode must be that mode (IcdManagementServer.ts:666-684).
func (*ICD) TriggerUserActiveMode ¶ added in v0.12.0
func (i *ICD) TriggerUserActiveMode()
TriggerUserActiveMode is the device-physical User Active Mode Trigger: the Check-In back-off resets and the device wakes (IcdManagementServer.ts:642-645).
func (*ICD) WithdrawForcedOperatingMode ¶ added in v0.12.0
WithdrawForcedOperatingMode returns a DynamicSITLIT ICD to the registration-driven mode (IcdManagementServer.ts:694-700).
type ICDConfig ¶ added in v0.12.0
type ICDConfig struct {
// Mode is SIT (Check-In protocol) or LIT (also LongIdleTimeSupport
// and UserActiveModeTrigger, which LIT makes mandatory).
Mode ICDOperatingMode
// IdleModeDuration is the longest time the device is idle, whole
// seconds, 1 s to 18 h.
IdleModeDuration time.Duration
// ActiveModeDuration is the shortest active window after a wake,
// whole milliseconds, at most IdleModeDuration.
ActiveModeDuration time.Duration
// ActiveModeThreshold is how long the device stays active after
// network activity, whole milliseconds, at most 65.535 s.
ActiveModeThreshold time.Duration
// MaximumCheckInBackoff is the longest gap between Check-Ins to a
// client that does not answer, whole seconds, at least
// IdleModeDuration.
MaximumCheckInBackoff time.Duration
// ClientsSupportedPerFabric is the number of Check-In clients a
// fabric may register.
ClientsSupportedPerFabric uint16
// UserActiveModeTrigger, when set, states how a user wakes the
// device; required for LIT (Core §9.16.6.7-8).
UserActiveModeTrigger *ICDUserActiveModeTrigger
// DynamicSITLIT lets the host switch a LIT device between SIT and LIT
// at run time ([ICD.SetOperatingMode]); LIT only.
DynamicSITLIT bool
}
ICDConfig makes the node an intermittently connected device: the root endpoint serves ICD Management with the configured timings, the node counts and sends Check-Ins to its registered clients, advertises the ICD key, pads its MRP backoff by the fast-poll interval and keeps no subscription across a restart. The mode machine is the host's to drive (Node.ICD): a node of this module never truly sleeps.
A zero timing is the schema default: IdleModeDuration 1 s, ActiveModeDuration 300 ms, ActiveModeThreshold 300 ms, ClientsSupportedPerFabric 1; a zero MaximumCheckInBackoff is IdleModeDuration (a Check-In every wake). A LIT ICD needs an ActiveModeThreshold of at least 5 s. Mirrors the configuration matter.js IcdManagementServer takes (IcdManagementServer.ts:184-229, the attribute defaults of icd-management.element.ts:31-69).
type ICDModeEvent ¶ added in v0.12.0
type ICDModeEvent uint8
ICDModeEvent is a transition of the device's idle/active mode (matter.js IcdManagementServer.ts:813-820 at b25ed960, Events).
const ( // ICDActiveModeEntered: the start or an idle→active wake — the node // sends its Check-Ins. Hook the hardware's power-up here. ICDActiveModeEntered ICDModeEvent = ICDModeEvent(mattercore.ICDActiveModeEntered) // ICDIdleModeEntered: the device went idle. Hook the power-down. ICDIdleModeEntered ICDModeEvent = ICDModeEvent(mattercore.ICDIdleModeEntered) // ICDMayEnterIdleMode: the active window elapsed while quiet; the host // may put the device to sleep ([ICD.EnterIdleMode]). ICDMayEnterIdleMode ICDModeEvent = ICDModeEvent(mattercore.ICDMayEnterIdleMode) )
The three events.
func (ICDModeEvent) String ¶ added in v0.12.0
func (e ICDModeEvent) String() string
String is the matter.js event name.
type ICDOperatingMode ¶ added in v0.12.0
type ICDOperatingMode uint8
ICDOperatingMode is an ICD's operating mode: a Short Idle Time or a Long Idle Time device (Core §9.15.1.5-6, OperatingModeEnum).
const ( // ICDModeSIT is a Short Idle Time ICD: the Check-In protocol, no LIT. ICDModeSIT ICDOperatingMode = 0 // ICDModeLIT is a Long Idle Time capable ICD: it operates as LIT // while a client is registered (or while DynamicSITLIT forces it), // as SIT otherwise. ICDModeLIT ICDOperatingMode = 1 )
The two operating modes.
func (ICDOperatingMode) String ¶ added in v0.12.0
func (m ICDOperatingMode) String() string
String is the mode's name.
type ICDUserActiveModeTrigger ¶ added in v0.12.0
type ICDUserActiveModeTrigger struct {
Hint icddef.UserActiveModeTriggerBitmap
Instruction string
}
ICDUserActiveModeTrigger is the UserActiveModeTriggerHint bitmap and its instruction; a hint that names a count or a duration needs the instruction. An empty Instruction leaves UserActiveModeTriggerInstruction out of the cluster, as matter.js does.
type Label ¶
type Label struct {
Label, Value string
// User marks an entry of UserLabel, which a controller may write;
// FixedLabel's otherwise.
User bool
}
Label is one entry of a FixedLabel or UserLabel LabelList a BridgedDevice serves.
type Limits ¶ added in v0.10.7
type Limits struct {
// SupportedFabrics is OperationalCredentials' SupportedFabrics, the
// number of fabrics the node admits (Matter §11.18.4.4: 1 to 254); 0
// is 5, the facade's value before it was configurable. matter.js
// defaults it to 254 when unset (OperationalCredentialsServer.ts:
// 84-88 initialize), which cluster/core does too; the facade keeps 5.
// It replaces [Config].SupportedFabrics; both set and different fail
// [Config.Validate].
SupportedFabrics uint8
// MaxPathsPerInvoke is the most commands one InvokeRequest may carry:
// the root BasicInformation advertises it, the PASE and CASE session
// parameters carry it and the invoke path refuses a larger batch with
// InvalidAction. 0 is im.DefaultMaxPathsPerInvoke (10), matter.js's
// DEFAULT_MAX_PATHS_PER_INVOKE. Mirrors matter.js
// basicInformation.maxPathsPerInvoke, which InteractionServer.ts:198
// enforces. It replaces [Config].MaxPathsPerInvoke; both set and
// different fail [Config.Validate].
MaxPathsPerInvoke uint16
// SubscriptionMaxInterval is the longest MaxInterval the node grants a
// subscription: a subscriber asking for more is negotiated down to it,
// never below its own MinIntervalFloor. Mirrors matter.js
// network.subscriptionOptions.maxInterval (NetworkServer.ts:210,
// applied in ServerSubscription.ts:314-344 at db021da0). 0 is one
// hour (subscription.DefaultMaxIntervalCeilingSeconds, matter.js's
// MAX_INTERVAL_PUBLISHER_LIMIT and chip's publisher limit); matter.js
// defaults to three minutes instead. Bound: whole seconds, 1 s to 1 h
// (MAX_INTERVAL_PUBLISHER_LIMIT caps any larger value in matter.js).
SubscriptionMaxInterval time.Duration
// AccessControlEntriesPerFabric is AccessControl's attribute of that
// name and the most entries one fabric's ACL may hold; a write beyond
// it fails with ResourceExhausted. 0 is 4
// (mattercore.DefaultAccessControlEntriesPerFabric, matter.js
// AccessControlServer.ts:64-66). Bound: 4 to 65534.
AccessControlEntriesPerFabric uint16
// SubjectsPerAccessControlEntry is AccessControl's attribute of that
// name and the most subjects one entry may name. 0 is 4
// (AccessControlServer.ts:58-60). Bound: 4 to 65534.
SubjectsPerAccessControlEntry uint16
// TargetsPerAccessControlEntry is AccessControl's attribute of that
// name and the most targets one entry may name. 0 is 4
// (AccessControlServer.ts:61-63). Bound: 3 to 65534.
TargetsPerAccessControlEntry uint16
// MaxGroupsPerFabric is GroupKeyManagement's attribute of that name and
// the most groups one fabric may hold; a group beyond it is refused
// with ResourceExhausted. 0 is 22 (mattercore.DefaultMaxGroupsPerFabric,
// matter.js GroupKeyManagementServer.ts:610). Bound: the attribute's
// uint16 range.
MaxGroupsPerFabric uint16
// MaxGroupKeysPerFabric is GroupKeyManagement's attribute of that name
// and the most group key sets one fabric may hold, the IPK's implicit
// key set 0 counted as one (GroupKeyManagementServer.ts:379-380);
// KeySetWrite beyond it fails with ResourceExhausted. 0 is 20
// (mattercore.DefaultMaxGroupKeysPerFabric,
// GroupKeyManagementServer.ts:609). Bound: 1 to 65535.
MaxGroupKeysPerFabric uint16
// BDXAdditionalMrpDelay is the margin the node adds to a peer's MRP
// base interval on the exchange of every inbound BDX transfer its BDX
// responder accepts (an OTA requestor's image download); the backoff
// amplifies it. Mirrors matter.js LimitsConfig.bdxAdditionalMrpDelay
// (NetworkServer.ts:152-153 at b25ed960), the BDX class of the network
// profile's MRP margins (NetworkProfile.ts:156-159), applied as the
// exchange's peerAdditionalMrpDelay (BdxProtocol.ts:139-142). 0 adds
// none. Bound: not negative (SoftwareUpdateManager.ts:60-67,
// assertTransferOptions).
BDXAdditionalMrpDelay time.Duration
}
Limits are the capacity limits a host may set: the ones matter.js keeps configurable. Every other limit of the node is a constant, listed with its value on the limits page (docs/guides/limits.md). A zero field is the default its comment names, the value the node had before the field existed; Config.Validate refuses a value outside the field's bound.
SupportedFabrics and MaxPathsPerInvoke sat on Config itself before they moved here; the Config fields are deprecated and still honoured.
type MDNS ¶ added in v0.9.1
type MDNS struct {
// Off publishes nothing (mdns.NewNoop): no commissioner discovers the
// node, which a controller then reaches by address alone.
Off bool
// HostName, when set, is the SRV target of every record
// (mdns.Responder.HostName, without ".local"): a host name the OS
// responder owns and publishes the address records of. Empty is the
// name the advertiser derives from the interface's MAC, whose address
// records it publishes itself. At most 40 bytes, one DNS label
// ([Config.Validate]).
HostName string
// Interfaces, when non-empty, restricts the advertiser to the named
// host interfaces ("eth0", "br30"): it announces and answers on them
// alone, with their addresses. Empty advertises on every
// multicast-capable interface. The default filter still applies to a
// named interface — a container or virtualisation bridge (docker0,
// hassio, veth…, mdns.DefaultInterfaceFilter) stays out when named. A
// name the host does not have is allowed, as interfaces come and go:
// nothing is announced on it until it appears (the interface check),
// and [Node.DiagnoseMDNS] names it. The UDP listen socket is not
// scoped by it ([Network].Listen takes a host address). The case for
// it is a dual-homed host whose gateway relays mDNS between its
// networks: the controllers on one network cache the other network's
// address as well; advertising on the controllers' network alone
// keeps it out. Ahead of matter.js, whose MdnsServer publishes on
// every multicast interface (BD-matterjs-mdns-interface-allowlist).
Interfaces []string
}
MDNS configures the DNS-SD advertiser the node builds when Config.Advertiser is nil. The zero value advertises on the network.
type MDNSFinding ¶ added in v0.9.1
MDNSFinding is one result of Node.DiagnoseMDNS (mdns.Finding).
type MDNSService ¶ added in v0.9.1
MDNSService is one record the node advertises (Node.MDNSServices, mdns.Service).
type Metrics ¶ added in v0.10.6
Metrics is the port Config.Metrics takes (contract.Metrics): the host's counters and gauges. A host's implementation imports contract only; node/metrics/expvar is the stdlib implementation the module ships. Nil records nothing.
type NTPClient ¶
type NTPClient = mattercore.NTPClient
NTPClient is the type of TimeSynchronizationConfig.NTPClient: the host's NTP query the time client falls back to (mattercore.NTPClient).
type Network ¶
type Network struct {
// Listen is the UDP listen address; empty is ":5540".
Listen string
// PreferIPv4 forces an IPv4-only socket.
PreferIPv4 bool
// TCP selects the Matter TCP transport; the zero value is TCP off. A
// TCP role is also what the node's PASE and CASE responders advertise
// in their session parameters (SupportedTransports: tcpServer for
// Incoming, tcpClient for Outgoing), so a peer learns it during the
// handshake and may open TCP to us — matter.js
// ServerNetworkRuntime.ts:355-363.
TCP TCPConfig
// BLE is the host's Bluetooth LE radio in the peripheral role: with
// it an uncommissioned node is commissionable over BLE, and the
// onboarding payload says so (the QR code's BLE discovery bit) —
// matter.js `network.ble` and `discoveryCapabilities.ble`
// (NetworkServer.ts:28-51 at b25ed960). While the node has no fabric,
// its own window (and a [Node.OpenBasicWindow] window) advertises over
// BLE as well as over DNS-SD and serves PASE over BTP. The window's end
// (its timeout, [Node.CloseWindow]) stops only the BLE advertisement
// (BleAdvertisement.ts:69-71): the GATT service and a central stay, so a
// commissioning over BLE completes over the same link. The node leaves
// the radio once it is commissioned — the fail-safe committed at
// CommissioningComplete (ServerNetworkRuntime.ts:294-308) — and at
// [Node.Stop]. A commissioned node never touches the radio, not even
// for a window an administrator opens (:255-275); when its last fabric
// is removed, the own window that reopens is on BLE again. nil is no
// BLE.
//
// Deprecated: set GATT, whose service registration is answered before
// the node advertises; removable in v0.25.0. BLE keeps
// its meaning while GATT is nil; both set fail [Config.Validate].
BLE contract.BLEPeripheral //nolint:staticcheck // the deprecated port, kept for its window
// GATT is the node's Bluetooth LE peripheral ([contract.GATTPeripheral]),
// with what BLE describes: an uncommissioned node is commissionable
// over it, the onboarding payload says so, and the node leaves the
// radio once it is commissioned. The node registers the Matter GATT
// service before it advertises; a registration the platform refuses
// leaves the node off the air, logged as commissioning.ble.start. nil
// (with BLE nil) is no BLE.
GATT contract.GATTPeripheral
// WiFi is the node's Wi-Fi interface: its Driver joins the network a
// commissioner hands it (NetworkCommissioning with the Wi-Fi feature),
// its Reporter answers WiFiNetworkDiagnostics (0x0036). Either or both;
// a non-nil WiFi with neither is a configuration error. The node states
// the RootNode device-type condition WiFi, under which RootNode lists
// WiFiNetworkDiagnostics ("[WiFi]", device/root_node_gen.go), through
// the assembler's RootDeviceConditions — with [Config].Snapshotter the
// host's own assembler states it. EthernetNetworkDiagnostics stays
// mounted beside it. nil is an Ethernet-attached node:
// NetworkCommissioning with the Ethernet feature, no Wi-Fi cluster.
WiFi *WiFi
// MDNS configures the advertiser the node builds when
// [Config].Advertiser is nil; the zero value advertises (the module's
// mDNS responder, which announces on matter.js's broadcast schedule).
MDNS MDNS
// InterfaceCheck is how often the node compares the host's network
// interfaces: the mDNS responder while it publishes, to say goodbye to
// a lost address and announce the current ones, and GeneralDiagnostics
// while NetworkInterfaces is observed, to report the change. Zero is
// matter.js's 60 s (INTERFACE_CHECK_INTERVAL, Network.ts:91-95 at
// b25ed960); negative disables the periodic check — a host that
// learns of changes itself calls [Node.TriggerReannounce], which
// re-announces the mDNS records; GeneralDiagnostics' NetworkInterfaces
// is then current on each read and reports no change of its own.
InterfaceCheck time.Duration
}
Network is matter.js `network` for the keys the daemon uses (NetworkServer.ts:202-223 at b25ed960: port and listening address, ipv4, tcp).
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a Matter node: the bridge, its root and Aggregator endpoints and every port bridge documents, wired in the documented order.
func New ¶
New builds the node: everything the reference daemon builds before bridge.Start (examples/reference-bridge/main.go:135-397 at b4ea1f96^), with every port of bridge/bridge.go's package doc attached in its documented order.
Nothing is left as a noop except what the configuration omits on purpose: a nil Advertiser is the node's own (Zeroconf with the subtype responder, or Noop under Network.MDNS.Off), a nil OTA mounts no OTA requestor. The TestEventTrigger enable key is not armed (Root().GeneralDiagnostics.EnableTestEventTriggers is the host's), and SetOnReassembled stays the bridge's nil-safe hook for the host (a fabric's installation is Config.Observers.OnFabricAdded).
New opens and migrates the store, loads the group state and reads the store under ctx, so a host bounds or cancels the construction; it starts no goroutine of its own. The subscription engine, the session, PASE and CASE reapers and the DNS-SD subtype responder start in Node.Start, so a node that is built and dropped leaks nothing but what the host handed it (ADR 0026 principle 5). The one exception is the opt-in client stack (Config.Client), whose socket and discovery cache open here. Node.Stop releases what New opened, whether or not the node was started. ctx bounds New only: the node's lifetime is its own, ended by Stop. Mirrors matter.js ServerNode.create, the awaited construction (packages/node/src/node/ServerNode.ts:107-127).
func (*Node) Aggregator ¶
func (n *Node) Aggregator() *Aggregator
Aggregator returns the Aggregator endpoint's bridged-device set — nil when the host assembles its own topology (Config.Snapshotter).
func (*Node) AttestationError ¶ added in v0.9.1
AttestationError is the load error of Attestation.Files under Attestation.BlockCommissioningOnError: the node runs on the test chain and refuses every commissioning until the files are fixed and a new node is built. nil when the files loaded, named nothing, or are unset.
func (*Node) BDX ¶ added in v0.13.0
func (n *Node) BDX() *BDXResponder
BDX is the BDX responder the provider serves its images through — the transfers a controller's update manager reads the liveness of and closes (matter.js SoftwareUpdateManager.#bdxSessionFor, SoftwareUpdateManager.ts:322-328 at db021da0); nil without a provider.
func (*Node) Bindings ¶ added in v0.4.0
Bindings returns the binding manager: it resolves the entries of the node's Binding servers into the peers they direct (package binding). Without the client stack, a node entry is dropped ("client stack disabled"); group and self-bindings resolve as ever.
func (*Node) BootReason ¶
BootReason returns the GeneralDiagnostics BootReason the node was built with — the value Node.Start's EmitBootReason reports: Config.BootReason, or SoftwareUpdateCompleted for a start into the update the node's OTA requestor recorded. A host passes it to a lighting OnOff server it builds (onoff.Config.BootReason), which skips StartUpOnOff after a software update (OnOffServer.ts:33-37, :324-329 at db021da0).
func (*Node) Bridge ¶
Bridge returns the bridge, for a host that needs a port the facade does not cover (ADR 0018 decision 5).
func (*Node) Clock ¶ added in v0.12.2
Clock returns the node's time source: Config.Clock, or clock.System when it was nil. Every interval the node keeps runs on it — session activity, the commissioning window's deadline, subscriptions — so a host computes ages against it rather than wall time.
func (*Node) CloseWindow ¶
CloseWindow closes the open commissioning window, whoever opened it — the node's own, a Node.OpenBasicWindow window or an administrator's: the PASE acceptor goes and the commissionable record is withdrawn, while a PASE session already established and an armed fail-safe are left to their commissioner. Without an open window it does nothing. A node without a fabric that closes a basic window reopens its own window, as when that window closes on its timeout (unless Commissioning.WindowOnDemand leaves the window to the host). It returns ctx.Err() when ctx is done before the call, ErrNotStarted before Node.Start completed, and ErrStopped from the first Node.Stop on.
Mirrors matter.js DeviceCommissioner.endCommissioning ("Close the open commissioning window, whoever opened it", packages/protocol/src/protocol/DeviceCommissioner.ts:315-325), whose #closeWindow removes the PASE commissioner and exits commissioning mode (:283-297); ADR 0025 principle 3.
func (*Node) CommissionerControl ¶ added in v0.4.0
func (n *Node) CommissionerControl() *CommissionerControlServer
CommissionerControl returns the CommissionerControl server — nil unless Config.CommissionerControl mounts one on the Aggregator.
func (*Node) DiagnoseMDNS ¶ added in v0.9.1
func (n *Node) DiagnoseMDNS() []MDNSFinding
DiagnoseMDNS inspects the records the node currently advertises and reports what would keep a controller from finding or commissioning it (mdns.Diagnose), and with MDNS.Interfaces each named interface the host does not have, the default filter keeps out or that carries no advertised address (mdns.DiagnoseInterfaces); nil when the advertiser publishes nothing on purpose (MDNS.Off, or a host's Noop). Errors come first.
func (*Node) DiagnosticEvents ¶ added in v0.10.6
func (n *Node) DiagnosticEvents() []DiagnosticEvent
DiagnosticEvents returns the node's diagnostic trace, newest first: a copy the caller may keep (the REST handler of a daemon serialises it).
func (*Node) EndpointState ¶
func (n *Node) EndpointState() EndpointState
EndpointState is the endpoint-level state (scene tables, bridged NodeLabels) the facade's assembler uses: Config.EndpointState when set, the deprecated Config.EndpointPersistence adapted when that is set, else the facade's own over Node.Store — what a host with its own assembler (Config.Snapshotter) hands that assembler as endpoint.Config.Persistence (issue #117).
func (*Node) Endpoints ¶
func (n *Node) Endpoints() []EndpointInfo
Endpoints returns every endpoint the node serves now — the root first, then by endpoint number — with its tree edges and its Descriptor's lists: empty before Node.Start. It reads the assembled endpoint tree (Node.Bridge().Topology()) and each endpoint's Descriptor server as a controller's wildcard Descriptor read reports it.
It is the controller's view, and Node.Topology the host's: Topology lists the bridged devices by the key the host added them under, with their reachability, tags and labels; Endpoints lists every endpoint — the root and the Aggregator included — by number, with the PartsList and DeviceTypeList a controller walks. Neither is derived from the other's purpose.
func (*Node) Events ¶
func (n *Node) Events(q EventQuery) []Event
Events returns the events the node's event log holds that match q, oldest first — the log a controller's event read is answered from, the same records, without access control. The log is bounded (the oldest of the lowest priority go first) and volatile: it is emptied when the node stops. A node not started returns none.
func (*Node) FabricInfos ¶ added in v0.9.1
func (n *Node) FabricInfos(ctx context.Context) ([]FabricInfo, error)
FabricInfos returns the installed fabrics in the store's order (by fabric index): index, fabric and node id, root public key, compressed fabric id, vendor and label.
func (*Node) FactoryReset ¶
FactoryReset returns the node to its factory state and stops it: every fabric is removed through the RemoveFabric fan-out (Node.RemoveFabric: the Leave event, the sessions and subscriptions, the CASE identity, the group state, the host's OnFabricRemoved), then the node stops, and what it persisted is erased — the credential store (store.Eraser: fabrics, ACL, group keys, resumption records, subscriptions, settings and counters, the pinned UniqueID and the Wi-Fi networks among them) and every endpoint record of Config.Store.Endpoints, so the numbers they held are free. A node that is stopped already has its store erased; one whose Store.Path the stop closed has the file reopened for the erase. The stores erased are the ones the node used: a Store.Credentials or Store.Endpoints override as it is, and the store New built on the file for the other. A SQLite file the node's stores are on is scrubbed after every delete (store.Scrub), so none of the erased bytes — endpoint records included — remain in it. A scrub that does not finish (another connection's reader blocks the checkpoint, a full disk fails the VACUUM) does not undo the reset: every other step completes, the fresh UniqueID included, and the error wraps ErrScrubIncomplete — the rows are gone, their bytes may remain in the file until a later store.Scrub of it succeeds. A Store.Endpoints override is erased row by row and not scrubbed: when it keeps its records in a file of the host's own, scrubbing that file is the host's (store.Scrub).
A Go node is single-use — Node.Stop ends it, as ErrStopped says — so the reset does not bring the node back: the host comes back by building a new node on the same store and starting it if the old one ran, exactly as after a restart (fabrictest.Device.FactoryReset does). The new node starts uncommissioned, with a fresh random UniqueID pinned (unless UniqueID rotation is on) and a device-type validation that reports every endpoint again. A host's own Config.EndpointState (or EndpointPersistence) is the host's to erase.
A reset whose stop does not complete — its context ends while a bridge Start or Stop the host runs holds the bridge's lifecycle — erases and closes nothing and returns the stop's error: the fabrics are removed, the node is not stopped and keeps its store, and a later FactoryReset finishes the reset.
FactoryReset is serialised with Start and Stop: it waits for one in progress until ctx ends, and then returns an error wrapping ctx.Err() without resetting anything. Mirrors matter.js ServerNode.erase / eraseWithMutex (packages/node/src/node/ServerNode.ts: 159-200: go offline, reset, erase the storage, come back online if the node was) and resetStorage (:242-256, peers first, then the sessions, fabrics, occurrences, credentials and the node store); the node that comes back is a new one here (BD-Matter-FactoryResetEndsTheNode).
func (*Node) Groups ¶ added in v0.4.0
Groups returns the group state the node runs on — Config.Groups, or the manager the facade built. A host that assembles its own topology binds it into its assembler (endpoint.Config.Groups), so the endpoints' Groups servers, the bridge's group-message routing and the root's GroupKeyManagement share one state.
func (*Node) Health ¶ added in v0.9.1
func (n *Node) Health() (HealthSample, bool)
Health returns the health probe's last verdict; false before the first one and when Config.Health runs no probe.
func (*Node) ICD ¶ added in v0.12.0
ICD returns the node's ICD handle; nil for a node that is no ICD.
func (*Node) LocalAddr ¶ added in v0.9.1
LocalAddr returns the bound `host:port` of the node's operational UDP listener — empty before Node.Start and after Node.Stop (bridge.Bridge.LocalAddr). It is what the health probe checks.
func (*Node) MDNSEnabled ¶ added in v0.9.1
MDNSEnabled reports whether the node's advertiser publishes on the network (mdns.IsEnabled): false for Noop.
func (*Node) MDNSServices ¶ added in v0.9.1
func (n *Node) MDNSServices() []MDNSService
MDNSServices returns the records the node's advertiser currently publishes (mdns.Advertiser.Active).
func (*Node) OTAProvider ¶ added in v0.4.0
func (n *Node) OTAProvider() *OTAProviderServer
OTAProvider returns the OTA Software Update Provider — nil unless Config.OTAProvider names an image source. A host that assembles its own topology (Config.Snapshotter) mounts it on an endpoint of its own; with the facade's Aggregator the node mounts it.
func (*Node) OTAProviderEndpoint ¶ added in v0.13.0
OTAProviderEndpoint is the provider endpoint's number, false without a provider or before Start's assembly.
func (*Node) Observe ¶ added in v0.12.2
Observe registers o's hooks on a running (or not yet started) node: each hook o sets runs after Config.Observers' hook for the same event and after the hooks registered before it, under the same rules — on the event's goroutine, after the facade's own handling, an error or a panic logged and never returned. The returned unsubscribe removes them; it is idempotent, and an event already being dispatched may still reach them. A host that mounts a handler after Node.Start (a web UI) learns of commissionings and fabric changes this way.
matter.js's node events are Observables a handler attaches to and detaches from at any time (packages/general/src/util/Observable.ts:55 `on`, :70 `off` at db021da0 — the FabricManager events of packages/protocol/src/fabric/FabricManager.ts:41-48 among them); Config.Observers is the attach at construction, Observe the attach later.
func (*Node) ObserveAsync ¶
ObserveAsync is Node.Observe with every hook of o queued on the node's callback goroutine: the event's value is taken when it happens, and the hook runs later, one call after the other and in event order, while the node runs (between Node.Start and Node.Stop; Stop returns once every queued call ran). An event while the node does not run is not delivered. A hook must not stop the node. The one callback rule of the facade (ADR 0025 principle 8), as Node.OnDiagnosticEventAsync.
func (*Node) OnDiagnosticEvent ¶ added in v0.10.6
func (n *Node) OnDiagnosticEvent(fn func(DiagnosticEvent)) (unsubscribe func())
OnDiagnosticEvent registers fn for every event the node records from now on. fn runs inline, on the goroutine that recorded the event — the receive path of a pairing or a session — after the trace stored it and outside its lock: it must not block, and may read Node.DiagnosticEvents. Node.OnDiagnosticEventAsync queues it instead. It returns the unsubscribe function.
func (*Node) OnDiagnosticEventAsync ¶ added in v0.10.6
func (n *Node) OnDiagnosticEventAsync(fn func(DiagnosticEvent)) (unsubscribe func())
OnDiagnosticEventAsync is Node.OnDiagnosticEvent with fn queued on the node's callback goroutine: the event is taken when it is recorded, and fn runs later, one call after the other, while the node runs (between Node.Start and Node.Stop; Stop returns once every queued call ran). An event recorded while the node does not run is not delivered. fn must not stop the node.
func (*Node) OnHealthSample ¶
func (n *Node) OnHealthSample(fn func(HealthSample)) (unsubscribe func())
OnHealthSample registers fn for every verdict of the health probe (Config.Health), the first at Node.Start. An unhealthy one (Healthy false) is a condition the probe states, not a sample — what bridge.HealthRecorder.RecordUnhealthy receives — so a host that damps flapping samples records it at once. fn runs inline on the probe's goroutine and must not block; Node.OnHealthSampleAsync queues it instead. It returns the unsubscribe function (ADR 0025 principle 8).
func (*Node) OnHealthSampleAsync ¶
func (n *Node) OnHealthSampleAsync(fn func(HealthSample)) (unsubscribe func())
OnHealthSampleAsync is Node.OnHealthSample with fn queued on the node's callback goroutine, one call after the other, while the node runs; Stop returns once every queued call ran.
func (*Node) OnOTAProviderStatus ¶
func (n *Node) OnOTAProviderStatus(fn func(peer OTAPeer, status OTAUpdateStatus, version uint32)) (unsubscribe func())
OnOTAProviderStatus registers fn for every update state a requestor of the node's OTA provider (Config.OTAProvider) reports: the peer, its status and the version it concerns — the statuses the provider reports to its manager, whichever manager runs (OTAProviderConfig.Manager or the default; mattercore.OTAProviderConfig.OnAttemptStatus). fn runs inline on the provider's goroutine and must not block — a download's WaitForApply is reported on the receive path, when the requestor's final BlockAckEof arrives, so a blocking fn stalls that session's datagrams; Node.OnOTAProviderStatusAsync queues it instead. It returns the unsubscribe function (ADR 0025 principle 8).
func (*Node) OnOTAProviderStatusAsync ¶
func (n *Node) OnOTAProviderStatusAsync(fn func(peer OTAPeer, status OTAUpdateStatus, version uint32)) (unsubscribe func())
OnOTAProviderStatusAsync is Node.OnOTAProviderStatus with fn queued on the node's callback goroutine, one call after the other, while the node runs; Stop returns once every queued call ran.
func (*Node) OpenBasicWindow ¶ added in v0.3.1
func (n *Node) OpenBasicWindow(ctx context.Context, creds WindowCredentials) error
OpenBasicWindow opens the node's own commissioning window with its own credentials: PASE runs against a verifier computed from creds (spake2.NewVerifierContext, the function commissioning/ uses) and installed through the path an administrator's verifier takes, and the node is advertised with CM=1 under creds.Discriminator. The window is the node's own (Window().Kind is WindowBasic): it reads WindowNotOpen on the AdministratorCommissioning cluster, an administrator's OpenCommissioningWindow replaces it, and it closes on its timeout, on CommissioningComplete and on RevokeCommissioning. Opened while a basic window or the node's own window is open, it replaces that window; while an administrator's window is open it returns bridge.ErrAdministratorWindowOpen. Node.OpenOwnWindow while it is open ends it: the restarted window runs with the configured credentials and is advertised under the configured discriminator. Once it closes, the configured credentials are back: a node without a fabric reopens its own window under the configured discriminator (not with Commissioning.WindowOnDemand), a commissioned node publishes no commissionable record until the next window — the facade's window semantics, unchanged. Before Node.Start completed it returns ErrNotStarted, and from the first Node.Stop on ErrStopped; either way it opens nothing.
matter.js has no per-window basic credentials: openBasicCommissioningWindow opens the window with the node's own passcode (packages/node/src/behaviors/administrator-commissioning/ AdministratorCommissioningServer.ts:105-121), and DeviceCommissioner #openWindow advertises `discriminator ?? commissioningConfig.discriminator` (packages/protocol/src/protocol/DeviceCommissioner.ts:236-256). This is a host extension, exposed as the facade's own API rather than as a cluster command.
func (*Node) OpenOwnWindow ¶
OpenOwnWindow opens the node's own commissioning window with the configured credentials (Config.Commissioning) and advertises it with CM=1 under the configured discriminator — the window an uncommissioned node opens at Start. timeout 0 is 48 h while the node has no fabric and 15 min once it has one. Invoked while the node's own or a basic window is open, it restarts the own window; while an administrator's window is open it returns ErrAdministratorWindowOpen; while Node.SetCommissioningBlocked holds an error it wraps ErrCommissioningBlocked.
Mirrors matter.js DeviceCommissioner.allowBasicCommissioning (packages/protocol/src/protocol/DeviceCommissioner.ts:130-137), which opens the window with the node's configured passcode; ADR 0025 principle 3 (the window's wiring stays behind Node.Bridge). Before Node.Start completed it returns ErrNotStarted, and from the first Node.Stop on ErrStopped; either way it opens nothing — a node with Commissioning.WindowOnDemand opens its window here, after Start.
func (*Node) PairingCodesFor ¶ added in v0.9.1
func (n *Node) PairingCodesFor(creds WindowCredentials) (qr, manual string, err error)
PairingCodesFor returns the QR code payload and the manual pairing code of a window the host opens with its own credentials (Node.OpenBasicWindow): creds' passcode and discriminator under the node's vendor and product, on-network discovery and, with a BLE radio (Network.GATT), BLE discovery — what Node.SetupPayload returns for the configured secret.
func (*Node) Peers ¶ added in v0.4.0
Peers returns the client stack's peer set — the nodes of our fabrics the node talks to as a client — or nil when Config.Client is off.
func (*Node) Persistence
deprecated
added in
v0.5.0
func (n *Node) Persistence() EndpointPersistence
Persistence is the endpoint-level persistence (scene tables, bridged NodeLabels) the facade's assembler uses, seen through the deprecated EndpointPersistence: Config.EndpointPersistence when it is the one in use, else Config.EndpointState or the facade's own over Node.Store — what a host with its own assembler (Config.Snapshotter) hands that assembler (issue #117).
Deprecated: use Node.EndpointState, whose saves and loads report the store's error. Removable in v0.25.0.
func (*Node) ReadAttribute ¶
func (n *Node) ReadAttribute(ctx context.Context, endpoint uint16, cluster, attribute uint32) (AttributeValue, error)
ReadAttribute returns the value one attribute of the node serves, read through the node's own read path — the cluster server's MatterRead, as a controller's read reaches it — with the cluster's DataVersion. It applies no access control (the host reads its own node) and no fabric: it reads as matter.js's local actor, so a fabric-scoped list holds every fabric's entries whole, their fabric-sensitive fields included (packages/protocol/src/action/server/AccessControl.ts:250-253, :342-345 and packages/node/src/behavior/state/managed/values/ListManager.ts:609-616 at db021da0). A value read here is the node's own; a host that shows it to a less trusted viewer withholds what that viewer may not see. An attribute the node does not serve is a contract.StatusError with the status a controller's read receives (UNSUPPORTED_ENDPOINT, UNSUPPORTED_CLUSTER, UNSUPPORTED_ATTRIBUTE); before Node.Start it is ErrNotStarted. After Node.Stop it reads the topology the node served last, from servers no controller reaches any more (review II, R2-P6-doc-2454).
func (*Node) ReadCluster ¶
func (n *Node) ReadCluster(ctx context.Context, endpoint uint16, cluster uint32) ([]AttributeValue, error)
ReadCluster returns every attribute one cluster of an endpoint serves, the global attributes among them, in the order a controller's wildcard read reports them, each as Node.ReadAttribute returns it — an attribute whose read fails among them, with its Status and a nil Value, which a controller's wildcard read leaves out (it answers a status for a fully concrete path only). An endpoint or cluster the node does not serve is a contract.StatusError; before Node.Start it is ErrNotStarted. After Node.Stop it reads the topology the node served last, as ReadAttribute does.
func (*Node) RemoveFabric ¶ added in v0.4.0
RemoveFabric removes a fabric without a commissioner — a host's revoke or factory reset — exactly as the RemoveFabric command does: the fabric's rows go, and the same fan-out runs (the Leave event, the OTA providers, the CASE identity and the operational record, the sessions and subscriptions, the group state, the node's own window once the last fabric is gone) followed by the host's OnFabricRemoved observer. matter.js reaches it the same way from the host, Fabric.leave() (Fabric.ts:423-433), the call the command itself makes (OperationalCredentialsServer.ts:425). An unknown index is ErrFabricNotFound.
func (*Node) Run ¶
Run starts the node, waits for ctx to end and stops it — matter.js Node.run (Node.ts:183-186). A Start that fails is followed by Stop, so Run releases what New opened either way. Either Stop is bounded by 5 s; one that does not finish in time leaves the node as Node.Stop describes, and Run returns its error.
func (*Node) SessionDiagnostics ¶ added in v0.12.2
func (n *Node) SessionDiagnostics() SessionDiagnostics
SessionDiagnostics returns the node's sessions, each with its subscription count and idle ages on the node's clock, and the session table's occupancy — the read-only view of what Node.Sessions and Node.Subscriptions hold, through which a host neither closes a session nor a subscription. It reads operational.Manager.Sessions and Occupancy and subscription.Manager.Snapshot, whose ids it groups by session.
matter.js exposes the same per-session facts on its sessions (packages/protocol/src/session/NodeSession.ts:191 `subscriptions`, :256 `fabric`, :268 `id`, :288 `peerNodeId`; the activity timestamps `timestamp` and `activeTimestamp` of packages/protocol/src/session/Session.ts:57, :66, :143-147 at db021da0); the occupancy split is this module's (operational.SessionTableOccupancy).
func (*Node) SessionParameters ¶
func (n *Node) SessionParameters() SessionParameters
SessionParameters are the session parameters the node reports to every PASE and CASE peer (PBKDFParamResponse tag 5, Sigma2's responderSessionParams): the intervals of Config.Sessions, the node's MaxPathsPerInvoke and its TCP roles. Mirrors matter.js SessionManager.sessionParameters (SessionManager.ts:391-400 at db021da0; review II, R2-P6-doc-2906).
func (*Node) Sessions ¶ added in v0.4.0
func (n *Node) Sessions() *SessionManager
Sessions returns the secure-session manager, for a host's diagnostics (operational.Manager.Sessions, Occupancy): which peers hold a PASE or CASE session, on which fabric, and when each was last active. The facade owns its lifecycle; a host reads it and leaves closing to the node.
func (*Node) SetCommissioningBlocked ¶ added in v0.5.4
SetCommissioningBlocked refuses every new commissioning while err is non-nil — the node's own window (at Start and after the last fabric is removed), Node.OpenBasicWindow, the host's opener and both AdministratorCommissioning commands of a paired controller, which answer FAILURE — and ends a commissioning under way, as RevokeCommissioning does: the PASE sessions close, the fail-safe armed over PASE expires and an open window is revoked, whether or not a window is still open; controllers already paired keep working. nil lifts the block and, on a node without a fabric, reopens its own window at once (not with Commissioning.WindowOnDemand, which leaves that to the host). A host that cannot serve the attestation chain it was configured with calls it before Node.Start. See bridge.CommissioningWindow.SetBlocked; matter.js has no counterpart (BD-Matter-CommissioningBlocked).
func (*Node) SetNodeLabel ¶
SetNodeLabel sets the node's own NodeLabel — the root BasicInformation's, the name a controller shows for the node — at run time, with a controller's write semantics: the label is held to the attribute's constraint (at most 32 bytes; empty is allowed) and refused with the status a controller's write gets (CONSTRAINT_ERROR, an im.StatusCodeError) — the server's error is returned unchanged — and otherwise persisted where a controller's written label is (the store's basic_information.node_label, written under New's context without its cancellation, so cancelling ctx does not abort the store write; a store failure is returned, wrapped, with nothing served changed), then set, the cluster's DataVersion advanced and reported to the subscriptions that cover it and to Observers.OnAttributeChanged with contract.OriginHostSet, whatever origin ctx carries.
Before Node.Start the label is configuration: it is the one the node serves when it starts, and it is persisted, but no subscription exists yet and the observers are not told — the notifier is wired when the node starts. matter.js would emit `$Changed` on the behavior before the node is online; reporting only a running node's changes is the facade's decision. Either way the label is persisted, so the next New on the same store restores it — over Config.BasicInformation.NodeLabel, as it restores a controller's written label; that restore at New is not a change and reports nothing. A controller's later write wins in turn, and reaches the observers with contract.OriginControllerWrite. The node's UniqueID does not follow the label (quality F; see BasicInformation.UniqueID).
A bridged device's NodeLabel is device.Device.Rename's. Mirrors matter.js, whose host assigns state.basicInformation.nodeLabel on the server node and whose datasource commits it as it commits a controller's write (mattercore.BasicInformation.SetNodeLabel cites the lines).
func (*Node) SetupPayload ¶ added in v0.12.2
func (n *Node) SetupPayload() (SetupPayload, error)
SetupPayload returns the configured setup payload: passcode, discriminator, vendor and product id, and the QR and manual codes encoded from them. It carries the passcode (see SetupPayload.Passcode). A window opened with other credentials (Node.OpenBasicWindow) has its codes from Node.PairingCodesFor.
Mirrors matter.js CommissioningServer's state — passcode, discriminator and the pairingCodes property derived from them with BasicInformation's vendorId and productId (packages/node/src/behavior/system/commissioning/CommissioningServer.ts: 405-414, :417-450 at 862ad75f).
func (*Node) Start ¶
Start brings the node online: the bridge starts, and the daemon's post-start sequence runs (main.go:428-489 at b4ea1f96^) — the diagnostic-log provider, the StartUp and BootReason events, the operational-time keeper, the PartsList providers, the CASE identities of the fabrics a previous run installed, the re-establishment of their subscriptions, the OTA requestor, their operational records, and the node's own commissioning window when no fabric exists. Start is idempotent, as matter.js Node.start (Node.ts:114-130); after Stop it is ErrStopped.
The node counts as started once Start completed. A Start that fails leaves the node startable, as matter.js's Node.start does — it sets the target state back to "offline" and rethrows (Node.ts:124-126 at b25ed960): the node is not started, a later Start runs the whole start path again, and what New opened (the store file of Store.Path) stays open until Stop. Every step that can fail — the DataModelTest check, the PartsList providers, the bridge's start (topology, sockets) — runs before anything is started, and the bridge's start undoes its own partial work (bridge.Bridge.Start), so a failed Start leaves no goroutine, no socket and no open window behind. A host that gives up calls Stop; Node.Run does.
Start waits for a Stop or Node.FactoryReset in progress until ctx ends, and then returns an error wrapping ctx.Err() without starting.
An uncommissioned node's own window closes after 48 h and nothing reopens it: the node is then not commissionable until the host calls Node.OpenOwnWindow or restarts it; Observers.OnWindowTransition reports the close. With Commissioning.WindowOnDemand Start opens no window at all.
func (*Node) Stop ¶
Stop takes the node offline and releases what New and Start began, in the daemon's shutdown order (main.go:430-450 at b4ea1f96^): an armed fail-safe expired and rolled back (a fabric an unfinished commissioning added goes, and Observers.OnFabricRemoved runs before Stop returns), the OTA requestor, the operational time stored once more, BasicInformation ShutDown (when the node was started), the PASE providers, the CASE reaper, the session table's idle reaper, the subscription engine, the re-announce loop, the health probe, the bridge, the advertiser and the store the node opened for Store.Path. Stop is idempotent (matter.js Node.stop, Node.ts:193) and safe without Start. A context already done cuts short only Stop's waits; Stop returns an error only when the bridge did not stop (a bridge Start or Stop the host runs itself held it until ctx ended, or a Start of the node's own was still running when ctx ended), and then the node is not stopped yet: it keeps its store and the next Stop finishes the work. Start is refused from the first Stop on.
func (*Node) Subscriptions ¶ added in v0.4.0
func (n *Node) Subscriptions() *SubscriptionManager
Subscriptions returns the subscription manager, for a host's diagnostics: Snapshot lists every active subscription with its paths and intervals as copies (SubscriptionInfo), CountBySession and Active count them. The facade owns its lifecycle; a host reads it and leaves closing to the node.
func (*Node) Surface ¶
Surface reports the node's surface: the digest of Config.Surface, the root's decisions (its ahead-of-matter.js features, AheadRows), the effective surface — the root endpoint (key "") from the root's servers, the Aggregator endpoint (AggregatorSurfaceKey) from its servers, and every endpoint added to the Aggregator and each of its parts, ordered by key — and the decisions and withheld elements of every endpoint that reports its own surface (a device.Device), in the same order. An endpoint without a reporter is read from its source's servers, with no decisions.
Once the node has assembled its topology (at Node.Start) the effective surface is the assembled one and the report says so (Assembled): every endpoint of the topology as a controller's wildcard read returns it — the clusters the endpoint assembler mounts on a bridged endpoint (Descriptor, BridgedDeviceBasicInformation, Identify, Groups, ScenesManagement, Binding), the measurement clusters and the device types its Descriptor lists, BridgedNode included — each with its number. An endpoint without a stable key other than the root and the Aggregator has the key "@" and its number. Before the first assembly it is the device-level view: as for a device, the clusters the endpoint assembler mounts are not part of it. Changed lists the surface changes the node announced (Node.Start, Aggregator.Add, Replace, Batch): the last 100.
Under a specification level (Config.Surface's Level) the report names the level; the root's decisions include its clusters (levelRootClusters) and, for the root and the Aggregator endpoint, a keep decision on every served element the level does not know that no candidate decided (surface.Policies.ServerInternal); and an endpoint the level withheld at Add or Replace appears with its decisions and withheld elements, not in the effective surface.
func (*Node) Topology ¶ added in v0.10.0
func (n *Node) Topology() BridgeTopology
Topology returns the host's view of the bridge as the node serves it now: empty before Node.Start. It is the facade's route to what the assembled endpoint tree (Node.Bridge().Topology()) holds — the endpoint numbers matter.js's node assigns its endpoints (packages/node/src/node/server/ServerEndpointInitializer.ts:34-42).
func (*Node) TriggerReannounce ¶ added in v0.5.0
TriggerReannounce announces the node's DNS-SD records now — for a host that observes a link change (interface up, address assigned) and should not wait for the advertiser's broadcast schedule. It forwards to the advertiser's TriggerReannounce (mdns.Responder.TriggerReannounce: one publication of every published service per interface, with the goodbyes of the addresses that left, matter.js MdnsServer.broadcast) and is a no-op on an advertiser without one (mdns.Noop, a custom Advertiser). The responder also follows the interfaces itself at Network.InterfaceCheck.
func (*Node) UniqueID ¶ added in v0.9.1
UniqueID returns the BasicInformation UniqueID the node serves: the host's BasicInformation.UniqueID, else the value the node pinned in its store at the first boot (or, once bootid.EnableRotation ran in the process, this boot's value).
func (*Node) Window ¶ added in v0.12.2
func (n *Node) Window() WindowSnapshot
Window returns the commissioning window as the node serves it now — the value OnWindowTransition receives, readable at any time.
type OTAApplier ¶ added in v0.10.0
type OTAApplier = mattercore.OtaApplier
OTAApplier is the type of OTAConfig.Applier: the requestor's consent and apply hooks (mattercore.OtaApplier).
type OTAApplyPolicy
deprecated
added in
v0.10.0
type OTAApplyPolicy = mattercore.OTAApplyPolicy //nolint:staticcheck // the deprecated alias keeps its type for its window
OTAApplyPolicy is the type of OTAProviderConfig.ApplyPolicy: when a requestor may apply a downloaded image (mattercore.OTAApplyPolicy).
Deprecated: the delay is OTAProviderConfig.ApplyDelay and the apply is the OTAUpdateManager's to decide; removable in v0.26.0.
type OTABlob ¶ added in v0.10.4
OTABlob is what OTAImageSource.Open returns: the bytes of an offered image, read at offsets as the BDX transfer asks (bdx.Blob); one that implements io.Closer is closed when the transfer ends.
type OTAConfig ¶
type OTAConfig struct {
// Dir receives the downloads; mandatory.
Dir string
// Applier carries out an update; nil is the daemon's applier, which
// validates the image and keeps it under Dir/applied.
Applier OTAApplier
// AnnouncedUpdateQueryDelay, when set, replaces the random 1-600 s wait
// between an UpdateAvailable or Urgent announcement and the query it
// schedules — matter.js's announcedUpdateQueryDelay
// (OtaSoftwareUpdateRequestorServer.ts:410, :1323). Harness mode (a test's)
// without it waits 250 ms, as the matter.js cert requestor does.
AnnouncedUpdateQueryDelay *time.Duration
// TransferProtocols are the download protocols the requestor announces
// (mattercore.OTARequestorConfig.TransferProtocols); empty is BDX
// alone. Add [OTADownloadHTTPS] only where the node reaches the image
// hosts; a list without [OTADownloadBDXSynchronous] fails the build.
TransferProtocols []OTADownloadProtocol
// HTTPClient sends an HTTPS download's GET; nil is the module's client,
// which follows a redirect only to an https:// target. A host's client
// keeps its own redirect policy (mattercore.OTARequestorConfig).
HTTPClient OTAHTTPClient
// HTTPSMaxImageSize caps an HTTPS download, HTTPSIdleTimeout the time it
// may receive nothing; 0 is 256 MiB and 60 seconds
// (mattercore.OTARequestorConfig).
HTTPSMaxImageSize int64
HTTPSIdleTimeout time.Duration
// contains filtered or unexported fields
}
OTAConfig mounts the OTA Software Update Requestor (ADR 0019).
type OTAConsent ¶ added in v0.10.0
type OTAConsent = mattercore.OTAConsent
OTAConsent is the type of OTAProviderConfig.Consent: the user-consent port of the provider (mattercore.OTAConsent).
type OTAConsentState ¶ added in v0.10.0
type OTAConsentState = mattercore.OTAConsentState
OTAConsentState is what an OTAConsent answers (mattercore.OTAConsentState).
type OTADownloadProtocol ¶
type OTADownloadProtocol = mattercore.DownloadProtocol
OTADownloadProtocol is the element type of OTAConfig.TransferProtocols (mattercore.DownloadProtocol).
type OTAFileDesignator ¶ added in v0.10.4
type OTAFileDesignator = bdx.FileDesignator
OTAFileDesignator is the type of OTAImage.FileDesignator: the image's name in the provider's "ota" scope (bdx.FileDesignator).
type OTAHTTPClient ¶
type OTAHTTPClient = mattercore.OtaHTTPClient
OTAHTTPClient is the type of OTAConfig.HTTPClient: the GET of an HTTPS download (mattercore.OtaHTTPClient); *http.Client implements it.
type OTAImage ¶ added in v0.10.4
type OTAImage = mattercore.OTAImage
OTAImage is what an OTAImageSource offers a requestor: its file designator, version, HTTPS URI, consent requirement and metadata (mattercore.OTAImage).
type OTAImageHeader ¶ added in v0.10.4
OTAImageHeader is the header of a Matter OTA image file — vendor and product id, the software version and its string, the applicable range, the payload's size and digest (otaimage.Header).
func ReadOTAImage ¶ added in v0.10.4
ReadOTAImage reads an OTA image file from r, writes its payload to w and returns its header, the digest checked; expectedTotalSize, when non-nil, is checked against the file's size (otaimage.ExtractPayload).
func VerifyOTAImage ¶ added in v0.10.4
func VerifyOTAImage(r io.Reader, v DCLSoftwareVersion, log *slog.Logger) (OTAImageHeader, error)
VerifyOTAImage checks an OTA image read from r against the ledger's record of its version — header, size and checksum (dcl.VerifyImage).
type OTAImageOptions ¶ added in v0.10.4
type OTAImageOptions = otaimage.CreateOptions
OTAImageOptions is what CreateOTAImage builds an image from (otaimage.CreateOptions).
type OTAImageSource ¶ added in v0.10.0
type OTAImageSource = mattercore.OTAImageSource
OTAImageSource is the type of OTAProviderConfig.ImageSource: where the provider reads the images it offers (mattercore.OTAImageSource).
type OTAPeer ¶ added in v0.10.0
type OTAPeer = mattercore.OTAPeer
OTAPeer names the requestor an OTAProviderConfig callback is about (mattercore.OTAPeer).
type OTAProviderConfig ¶ added in v0.4.0
type OTAProviderConfig struct {
// ImageSource names and serves the images; nil mounts no provider.
ImageSource OTAImageSource
// Consent asks the user; nil declines an image that needs a consent
// the requestor cannot give.
Consent OTAConsent
// Manager owns the requestors' update attempts and decides the
// queries and applies the provider takes
// (mattercore.OTAProviderConfig.Manager); nil is the provider's
// default manager, which queues no update. [Node.OnOTAProviderStatus]
// learns the statuses with either; with a Manager, RebootQuery,
// TransferBlockSize and DelegateConsentToRequestor are refused at Start.
Manager OTAUpdateManager
// DelegateConsentToRequestor lets the default manager offer a
// requestor that says it can consent an image that needs a consent
// without asking Consent, with UserConsentNeeded
// (mattercore.OTAProviderConfig.DelegateConsentToRequestor); off, as
// matter.js's default, Consent is asked. With a Manager it is refused
// at Start: the manager decides the delegation.
DelegateConsentToRequestor bool
// ApplyDelay is how long a requestor allowed to apply an update waits
// before it applies, in whole seconds rounded up and at most a day
// (mattercore.OTAProviderConfig.ApplyDelay, matter.js
// State.applyDelay); zero applies at once.
ApplyDelay time.Duration
// ApplyPolicy decides an apply before the manager's apply table; nil
// leaves it to the table.
//
// Deprecated: the delay is ApplyDelay and the apply is the Manager's
// to decide; removable in v0.26.0.
ApplyPolicy OTAApplyPolicy
// BDXMaxBlockSize, when set, caps the block size of the image
// transfers.
BDXMaxBlockSize uint16
// RebootQuery learns a QueryImage taken for the requestor's restart
// (mattercore.OTAProviderConfig.RebootQuery); nil ignores it.
//
// Deprecated: the restart is the Manager's to judge; removable in
// v0.26.0.
RebootQuery func(peer OTAPeer, sessionID uint16)
// TransferBlockSize caps one peer's transfer block size in place of
// BDXMaxBlockSize (mattercore.OTAProviderConfig.TransferBlockSize);
// nil uses BDXMaxBlockSize.
//
// Deprecated: the Manager's BDXTransferOptionsFor names a peer's
// transfer options; removable in v0.26.0.
TransferBlockSize func(peer OTAPeer) uint16
// GrantFabric decides, per fabric of the node, whether the provider
// writes its ACL entry into that fabric's ACL: Operate for CASE, no
// subject, the provider's endpoint and cluster — every node of the
// fabric may then invoke the provider. nil writes it into no fabric.
// matter.js writes it only into the first fabric its node's own
// controller administers, by root certificate
// (OtaSoftwareUpdateProviderServer.ts:116-158 at db021da0;
// FabricAuthority.ts:112-114, :126-128), and a [Node] has no controller
// of its own, so no fabric gets it unasked: the fabric's administrator
// grants the access, or the host returns true here for the fabrics it
// opens the provider to. The node asks at Start and after each
// CommissioningComplete, on the calling goroutine.
//
// A grant only ever adds the entry. Withdrawing it — false for a fabric
// granted before, or GrantFabric left nil — removes nothing: the entry
// a granting start wrote, like the one a version before GrantFabric
// wrote into every fabric's ACL, stays in that fabric's ACL, because the
// node cannot tell an entry it wrote from one the fabric's administrator
// wrote. The fabric's administrator removes it by writing the fabric's
// ACL without it.
GrantFabric func(fabric FabricInfo) bool
}
OTAProviderConfig serves OTA software images to the requestors of the node's fabrics: the OTA Software Update Provider (0x0029) on an endpoint of its own, device type OtaProvider (0x0014), next to the Aggregator (ADR 0021). The three ports are the host's part of matter.js's SoftwareUpdateManager (mattercore.OTAProvider).
type OTAProviderServer ¶
type OTAProviderServer = mattercore.OTAProvider
OTAProviderServer is the OTA Software Update Provider Node.OTAProvider returns (mattercore.OTAProvider).
type OTARequestorServer ¶ added in v0.10.4
type OTARequestorServer = mattercore.OTASoftwareUpdateRequestor
OTARequestorServer is the root OTA Software Update Requestor server (mattercore.OTASoftwareUpdateRequestor).
type OTAUpdateAttempt ¶
type OTAUpdateAttempt = mattercore.OTAUpdateAttempt
OTAUpdateAttempt is one requestor's update flow an OTAUpdateManager owns (mattercore.OTAUpdateAttempt).
type OTAUpdateManager ¶
type OTAUpdateManager = mattercore.OTAUpdateManager
OTAUpdateManager is the type of OTAProviderConfig.Manager: the owner of the requestors' update attempts the provider asks (mattercore.OTAUpdateManager).
type OTAUpdateStatus ¶ added in v0.10.0
type OTAUpdateStatus = mattercore.OTAUpdateStatus
OTAUpdateStatus is the status Node.OnOTAProviderStatus reports for a requestor (mattercore.OTAUpdateStatus).
type Observers ¶ added in v0.3.1
type Observers struct {
// OnFabricAdded runs after an AddNOC installed a fabric and the
// facade rebuilt the fabric's CASE identity and announced its
// operational record. Mirrors matter.js FabricManager `events.added`
// (FabricManager.ts:216 at db021da0; review II, R2-P6-doc-2906).
OnFabricAdded func(FabricInfo)
// OnFabricRemoved runs after RemoveFabric (or the fail-safe rollback
// of an AddNOC) deleted a fabric and the facade's cleanup ran — for a
// fabric stored when the node started or reported by OnFabricAdded,
// not for the row of an AddNOC that failed: the
// fabric, its ACL and its keys are gone from the store, its CASE
// identity and operational record are withdrawn, its sessions are
// told and closed (the invoking one after the response). When it was
// the last fabric the node's own window reopens afterwards, once the
// node is idle — no fail-safe armed and no session left (matter.js
// #resetWhenIdle); OnWindowTransition reports that. Mirrors
// matter.js FabricManager `events.deleted` (FabricManager.ts:272 at
// db021da0).
// The removal a fail-safe rollback owes is kept in the store until it
// ran (store.OwedFabricEvent), so it reaches the host at least once:
// after a crash between the rollback and this hook — or in the
// moment after the hook — the next Start runs it, and a host may hear
// the same removal twice. One residual: a store upgraded from a release
// before schema v8 that went down inside a fail-safe window owes the
// removal of that window's AddNOC in memory only — it reaches the host
// only if the first process on the upgraded store starts.
OnFabricRemoved func(FabricInfo)
// OnFabricUpdated runs after an UpdateNOC (or the fail-safe rollback
// of one) changed a fabric's operational identity and the facade
// moved the CASE identity and the operational record and closed the
// fabric's other sessions, and after an UpdateFabricLabel or a
// SetVIDVerificationStatement changed a fabric under the same
// identity (nothing for the facade to move). Mirrors matter.js
// FabricManager `events.replaced` (FabricManager.ts:236-249, :401),
// which a fabric's persist emits too, and CommissioningServer's
// fabricsChanged(index, "updated") (CommissioningServer.ts:118-141 at
// db021da0).
// The revert a fail-safe rollback of an UpdateNOC owes is delivered at
// least once, as OnFabricRemoved's removal is: a host may hear it
// twice after a crash.
OnFabricUpdated func(FabricInfo)
// OnCommissioningComplete runs after a successful
// CommissioningComplete and the facade's own handling of it (pending
// OperationalCredentials state cleared, the OTA requestor's query
// scheduled), with the fabric the commissioning completed for. It
// fires on every CommissioningComplete, whereas matter.js's
// `commissioned` event fires when the fabric count crosses zero
// (CommissioningServer.ts:143-157 #syncCommissioned).
OnCommissioningComplete func(fabricIndex uint8)
// OnWindowTransition runs on every commissioning-window transition
// (open, close, an administrator's AdminFabricIndex cleared), after
// the facade switched the PASE acceptor and published or withdrew
// the commissionable record.
OnWindowTransition func(WindowSnapshot)
// OnSurfaceChanged runs after an assembly changed an endpoint's served
// surface against the one persisted for its key — once the node has
// raised the ConfigurationVersions, bumped the DataVersions, stored
// the new surface and recorded the change ([Node.Surface] lists it
// under Changed) — once per changed endpoint, with the change. The
// announcement is this module's (concept v11 §D, by_design
// BD-Matter-SurfaceChange-ConfigurationVersion); matter.js raises the
// versions and has no event for it, so a host that mirrors a change
// to its own pages (a stream event) observes it here.
OnSurfaceChanged func(surface.SurfaceChange)
// OnSessionOpened runs after a CASE session was established — by a
// controller (the node as responder) or by the node re-establishing a
// controller's subscription — with the session as [Node.SessionDiagnostics]
// lists it. A PASE session is not reported. Mirrors matter.js
// SessionsBehavior's `opened` event (packages/node/src/behavior/system/
// sessions/SessionsBehavior.ts:57-64, declared at :124, at db021da0).
OnSessionOpened func(SessionInfo)
// OnSessionClosed runs after a session OnSessionOpened reported closed,
// with its last state. Mirrors SessionsBehavior's `closed` event
// (SessionsBehavior.ts:66-73, :125 at db021da0).
//
// Given in [Config] or through [Node.Observe], the hook runs on the
// goroutine of the event; for a session replaced under its id by a new one, that is inside the session table's
// establishment order ([github.com/SukramJ/go-fabric/secure/operational.Manager.SetOnSessionSuperseded]):
// it must not block on, or take a lock held across, anything that
// establishes a CASE session on this node (F-b25ed960-40).
// [Node.ObserveAsync] has no such rule.
OnSessionClosed func(SessionInfo)
// OnSubscriptionsChanged runs after a subscription was added to or
// closed on a session OnSessionOpened reported, with the session and
// its new Subscriptions count. Mirrors SessionsBehavior's
// `subscriptionsChanged` event (SessionsBehavior.ts:75-93, :126).
//
// Given in [Config] or through [Node.Observe], the hook runs on the
// goroutine of the event; for a subscription moved by a supersession (a newer session of the
// same subject), that is inside the session table's
// establishment order ([github.com/SukramJ/go-fabric/secure/operational.Manager.SetOnSessionSuperseded]):
// it must not block on, or take a lock held across, anything that
// establishes a CASE session on this node (F-b25ed960-40).
// [Node.ObserveAsync] has no such rule.
OnSubscriptionsChanged func(SessionInfo)
// OnAttributeChanged runs after a cluster server on any endpoint —
// the root, the Aggregator, a bridged device or a part — reported an
// attribute change and the subscriptions marked it for their next
// report: a controller's write (contract.OriginControllerWrite), a
// command's effect, a host's set. It says what moved, not the value;
// the typed Device.OnChanged of a device and the servers' own Get
// give values. It hears the servers that notify their own changes
// (contract.AttributeChangeNotifier, every generated server among
// them); a host port that only signals contract.ChangeNotifier is the
// host's own and is not repeated here. matter.js has the same
// node-wide path beside its per-behavior `$Changed` events:
// ChangeNotificationService.change reports each state update with the
// endpoint, the behavior, the data version and the property names, no
// values (packages/node/src/node/integration/ChangeNotificationService.ts:79-94
// at b25ed960). This hook is its counterpart, for a host that shows
// every change.
OnAttributeChanged func(AttributeChange)
// OnEvent runs after a cluster server on any endpoint emitted an
// event and the node's event log recorded it ([Node.Events] holds it)
// and the subscriptions were told, with the record: its number,
// priority, path, time and payload. It runs on the emitter's
// goroutine. matter.js emits each event on its endpoint's behavior and
// broadcasts the occurrence node-wide through the
// ChangeNotificationService (packages/node/src/behavior/Events.ts:221,
// packages/node/src/node/integration/ChangeNotificationService.ts:97-113
// at b25ed960) — this hook is that broadcast for a host.
OnEvent func(Event)
}
Observers are the host's callbacks on the node's fabric and commissioning events (issue #58). Each is optional, and each is chained after the facade's own handler for the same event: the facade's wiring runs first and unchanged, the observer runs once it has returned, and an observer's panic is logged, never returned to the handler — the event has already happened, so an observer returns nothing.
The name follows matter.js, whose node events are Observables that observers attach to (packages/protocol/src/fabric/ FabricManager.ts:44-51 `#events`); a failing observer is logged and the remaining observers still run (FabricManager.ts:405-411 `unhandled` at db021da0, "Log unhandled errors but do not abort deletion").
They follow the node's one callback rule (ADR 0025 principle 8): Config.Observers and Node.Observe run on the goroutine of the event — for the fabric events, inside the command that caused it and before its response is sent — so an observer that may block registers with Node.ObserveAsync, which queues it on the node's callback goroutine.
type Occupancy ¶ added in v0.12.2
Occupancy is how much of the session-id space the node holds (diag.Occupancy).
type Partition ¶ added in v0.10.2
type Partition struct {
// contains filtered or unexported fields
}
Partition is a named part of the Aggregator's set: its own snapshot scope. Its methods have the Aggregator's semantics, on its endpoints only.
func (*Partition) Add ¶ added in v0.10.2
Add adds ep to the partition; see Aggregator.Add. A key added to any partition is refused (ErrDuplicateKey).
func (*Partition) Batch ¶ added in v0.10.2
Batch runs fn with a Batch bound to the partition. Each of its calls changes the set at once, under the Aggregator's lock as a single Add does, and returns its own error; none reassembles. fn runs without any Aggregator lock held, so it may call other Aggregator methods. After fn, a started node with at least one change applied reassembles exactly once, and the devices removed or replaced are then unbound. What applied stays applied whatever fails: one faulty device does not block a fleet. The result is errors.Join of fn's error and the reassembly's. Before Node.Start a batch only changes the set.
A batch is not a transaction: an Add or Remove from another goroutine during fn reassembles on its own, and that assembly shows the changes the batch has applied so far.
func (*Partition) Endpoints ¶ added in v0.10.2
Endpoints returns the partition's set, in insertion order.
func (*Partition) Forget ¶ added in v0.12.2
Forget forgets key in the partition; see Aggregator.Forget.
func (*Partition) Remove ¶ added in v0.10.2
Remove drops the partition's endpoint with key; see Aggregator.Remove. A key of another partition is ErrUnknownKey.
type PowerSourceConfigurationServer ¶ added in v0.10.4
type PowerSourceConfigurationServer = mattercore.PowerSourceConfiguration
PowerSourceConfigurationServer is the root PowerSourceConfiguration server and its Sources provider (mattercore.PowerSourceConfiguration).
type ProductDescription ¶
type ProductDescription struct {
// Name is the advertised device name; empty is
// BasicInformation.NodeLabel, as the daemon advertises (main.go:285 at b4ea1f96^).
// The name advertised — this one, or the NodeLabel standing in — is at
// most 32 bytes; a longer one fails [Config.Validate] (decision 26).
Name string
// DeviceType is the device type the commissionable advertisement
// carries (the DT key and the _T<id> subtype). 0 infers it from the
// endpoints the node serves when it advertises, as matter.js's
// ProductDescriptionServer does (ProductDescriptionServer.ts:43-63,
// :93-126 at db021da0): the first device type of the first endpoint of
// a simple device type below the root and the Aggregator — a bridged
// device's type. The first type found stays for the node's lifetime;
// while no such endpoint is served the node advertises RootNode
// (0x0016).
DeviceType uint16
// VendorID and ProductID are the node's identity; both mandatory.
VendorID, ProductID uint16
}
ProductDescription is matter.js `productDescription` (ProductDescriptionServer.ts:70-90).
type ReverseCommissioner ¶ added in v0.10.0
type ReverseCommissioner = mattercore.ReverseCommissioner
ReverseCommissioner is the type of CommissionerControlConfig.Commissioner: the host's commissioner of the requesting node (mattercore.ReverseCommissioner).
type RootClusters ¶
type RootClusters struct {
BasicInformation *mattercore.BasicInformation
AccessControl *mattercore.AccessControl
GeneralCommissioning *mattercore.GeneralCommissioning
AdministratorCommissioning *wire.AdministratorCommissioning
// NetworkCommissioning is the Ethernet server; nil when
// [Network].WiFi has a Driver.
NetworkCommissioning *mattercore.NetworkCommissioning
// WiFiNetworkCommissioning is the Wi-Fi server, nil unless
// [Network].WiFi has a Driver.
WiFiNetworkCommissioning *mattercore.WiFiNetworkCommissioning
GeneralDiagnostics *mattercore.GeneralDiagnostics
DiagnosticLogs *mattercore.DiagnosticLogs
// TimeSynchronization is nil when [Config].TimeSynchronization.Off
// is set.
TimeSynchronization *mattercore.TimeSynchronization
OperationalCredentials *mattercore.OperationalCredentials
GroupKeyManagement *mattercore.GroupKeyManagement
Groupcast *mattercore.Groupcast
Descriptor *mattercore.Descriptor
// OTARequestor is nil unless [Config].OTA is set.
OTARequestor *mattercore.OTASoftwareUpdateRequestor
// WiFiNetworkDiagnostics is nil unless [Network].WiFi has a Reporter.
WiFiNetworkDiagnostics *mattercore.WiFiNetworkDiagnostics
// PowerSourceConfiguration lists the node's PowerSource endpoints;
// it starts empty, for the host to fill once the topology exists.
PowerSourceConfiguration *mattercore.PowerSourceConfiguration
// ICDManagement is nil unless [Config].ICD is set.
ICDManagement *mattercore.ICDManagement
// TLSCertificateManagement and TLSClientManagement are nil unless
// [Config].TLS is set.
TLSCertificateManagement *tls.CertificateManagement
TLSClientManagement *tls.ClientManagement
// contains filtered or unexported fields
}
RootClusters is endpoint 0's server set: matter.js's root endpoint composition (ServerNode.ts:274-309) as the reference daemon builds it (examples/reference-bridge/wiring.go:93-299 at b4ea1f96^, buildRootClusters, and root_optional.go). The fields are the servers a host may need a hook on; RootClusters.Servers is the mounted set in mount order.
func (*RootClusters) Servers ¶
func (r *RootClusters) Servers() []contract.ClusterServer
Servers returns the mounted set, in mount order.
type SemanticTag ¶
type SemanticTag = mattercore.SemanticTag
SemanticTag is one entry of a Descriptor's TagList, as BridgedDevice.Tags lists it (mattercore.SemanticTag).
type SessionDiagnostics ¶ added in v0.12.2
type SessionDiagnostics = diag.SessionDiagnostics
SessionDiagnostics is a read-only snapshot of the node's secure sessions and of its session table — what Node.SessionDiagnostics returns (diag.SessionDiagnostics, shared with the controller; Peers is nil on the node).
type SessionInfo ¶ added in v0.12.2
type SessionInfo = diag.SessionInfo
SessionInfo is one open PASE or CASE session (diag.SessionInfo). The node leaves CreatedAt, Resumed, Transport and PeerLost zero.
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, the uint16 the session parameters carry.
ActiveThreshold time.Duration
}
SessionIntervals are the MRP intervals the node reports in the PASE and CASE session parameters and advertises in its operational DNS-SD record (SII, SAI, SAT): how long a peer waits before it retransmits to this node. A zero field is the Matter default. Mirrors matter.js SessionsBehavior.State.intervals (SessionsBehavior.ts:115-120 at db021da0), which ServerNetworkRuntime.ts:364-367 hands the SessionManager's sessionParameters and DeviceAdvertiser.ts:361-364 the operational advertisement; omitted values fall back to SessionIntervals.defaults (SessionIntervals.ts:36-49).
type SessionManager ¶ added in v0.9.1
type SessionManager = operational.Manager
SessionManager is the secure-session table Node.Sessions returns (operational.Manager): Sessions lists the PASE and CASE sessions, Occupancy the session-id space.
type SessionParameters ¶
type SessionParameters = sessionparams.Parameters
SessionParameters is what Node.SessionParameters returns: the session parameters the node's PASE and CASE responders advertise (sessionparams.Parameters, controller/client.SessionParameters on the controller side).
type SetupPayload ¶ added in v0.12.2
type SetupPayload struct {
// Discriminator is the configured 12-bit discriminator
// ([Config].Commissioning).
Discriminator uint16
// Passcode is the configured setup passcode. It is in the payload by
// design: whoever reads it can commission the node while its own
// window is open, so a host serves it to an administrator only.
Passcode uint32
// VendorID and ProductID are the node's ([Config].ProductDescription).
VendorID, ProductID uint16
// Flow is the commissioning flow both codes state
// ([Commissioning].Flow).
Flow CommissioningFlow
// QR is the QR code payload ("MT:…"), Manual the manual pairing code;
// both encoded from Discriminator and Passcode, and for a Flow other
// than [FlowStandard] the manual code is the long form with VendorID
// and ProductID.
QR, Manual string
}
SetupPayload is the node's configured commissioning secret with the identity it is encoded under — the fields of the setup payload and the two codes encoded from them.
type Snapshotter ¶ added in v0.9.1
type Snapshotter = bridge.Snapshotter
Snapshotter is the type of Config.Snapshotter: a host that assembles its own endpoints returns one Topology per call (bridge.Snapshotter).
type Store ¶
type Store struct {
// Path is a SQLite file the node opens (creating it on first use)
// with the pure-Go driver modernc.org/sqlite, foreign keys on and a
// 5 s busy timeout; [Node.Stop] closes it. It excludes DB.
Path string
// DB is a SQLite database the host opened and keeps: the node applies
// both schemas to it and opens its stores on it; [Node.FactoryReset]
// scrubs it ([store.Scrub]) after the erase. It excludes Path. Every
// pooled connection needs PRAGMA foreign_keys(1) on its DSN
// (store.OpenSQLite sets it): store.Apply refuses a handle without it
// ([store.ErrForeignKeysOff]), and New returns that error.
DB *sql.DB
// Credentials overrides the credential store built from DB or Path.
// [Node.FactoryReset] erases it through [store.Eraser]; the erase of a
// SQLite store (store.New) scrubs the file it is on.
Credentials store.Port
// Endpoints overrides the endpoint-number store built from DB or Path.
// [Node.FactoryReset] erases its records row by row and does not scrub
// the file they live in: on the host's own database the deleted bytes
// may stay in it until the host runs [store.Scrub] on that file.
Endpoints endpoint.Store
// Sealer seals the secrets of the credential store the node builds on
// DB or Path (opt-in): New applies the schema (store.Apply) and opens
// the store with store.NewSealed, which seals the clear rows it finds,
// marks the database with its seal canary and scrubs the file; New
// returns its error. A scrub that cannot finish (a full disk, a reader
// on the -wal) is no error: the node logs one warning and a later start
// scrubs (store.Store.ScrubOwed). The key must live outside the
// database (docs/security.md, "Sealing at rest"); store.Reseal moves the
// database to a new key while no node runs on it. Every later start
// needs the same sealer: under another key New fails with an error that
// wraps store.ErrUnseal (NewSealed opens the canary first); a store
// without one reads a sealed secret as store.ErrNoSealer and writes
// none. It excludes
// Credentials (an override is sealed by the host that built it).
Sealer store.Sealer
}
Store names the node's persistence. With DB the node applies both schemas (store.Apply, sqlitestore.Apply) and opens the two stores on it, as the daemon's openDB does (persist.go:95-110); the caller picks the SQLite driver and owns the handle. With Path the node opens that SQLite file itself and treats it as DB. Credentials and Endpoints override the stores built from DB or Path, or stand in for them when both are unset.
type SubscriptionInfo ¶
type SubscriptionInfo = subscription.Info
SubscriptionInfo is one subscription as SubscriptionManager's Snapshot lists it, a copy (subscription.Info).
type SubscriptionManager ¶ added in v0.9.1
type SubscriptionManager = subscription.Manager
SubscriptionManager is the subscription table Node.Subscriptions returns (subscription.Manager): Active counts the subscriptions, CountBySession groups them by session, Snapshot lists them.
type TCPConfig ¶ added in v0.9.1
TCPConfig is the type of Network.TCP: the Matter TCP roles (bridge.TCPConfig).
type TLSConfig ¶
type TLSConfig struct {
// CertificatePort is the node's TLS key store; required.
CertificatePort tls.CertificatePort
// MaxRootCertificates and MaxClientCertificates are the per-fabric
// capacities, 5 to 254; 0 is chip's 5
// (CHIP_CONFIG_TLS_MAX_ROOT_PER_FABRIC_CERTS_TABLE_SIZE,
// CHIP_CONFIG_TLS_MAX_CLIENT_CERTS_PER_FABRIC_TABLE_SIZE,
// src/lib/core/CHIPConfig.h:2043, :2052).
MaxRootCertificates uint8
MaxClientCertificates uint8
// MaxProvisioned is the per-fabric endpoint capacity, 5 to 254; 0 is
// chip's 5 (CHIP_CONFIG_TLS_MAX_PROVISIONED_ENDPOINTS, :2063).
MaxProvisioned uint8
// CertificateStore and EndpointStore persist the tables; nil is the
// node's store.
CertificateStore tls.Store
EndpointStore tls.Store
}
TLSConfig mounts TlsCertificateManagement and TlsClientManagement on endpoint 0 (brief 26-A3, owner decision 2026-10-28): connectedhomeip serves both on the root endpoint only (its example delegates refuse any other, examples/all-clusters-app/all-clusters-common/src/ tls-certificate-management-instance.cpp:261 at 6170af84), and RootNode lists them as optional. The node hands their lookups to every PushAvStreamTransport server of its topology whose declaration names none (cluster/camera PushTransport.AttachTLS), as chip's codegen wires the two TLS delegates into the push transport (push-av-stream-transport-server/ CodegenIntegration.cpp:124, :133).
type TermsAndConditions ¶
TermsAndConditions is the requirement Commissioning.TermsAndConditions states: GeneralCommissioning's TCMinRequiredVersion, the acknowledgement bits every acceptance has to carry, and the optional TCUpdateDeadline (Matter epoch seconds; nil reads null).
type TimeFormatConfig ¶
type TimeFormatConfig struct {
// HourFormat is the hour format the node starts with. Required: nil
// is refused with [mattercore.ErrLocalizationConfig].
HourFormat *tfldef.HourFormatEnum
// ActiveCalendarType is the calendar the node starts with; nil is the
// first of SupportedCalendarTypes. nil with an empty list is refused,
// and so is a set calendar the list does not hold.
ActiveCalendarType *tfldef.CalendarTypeEnum
// SupportedCalendarTypes lists the calendars a controller may choose;
// empty is ActiveCalendarType alone.
SupportedCalendarTypes []tfldef.CalendarTypeEnum
// NoFeatures serves the server without the CalendarFormat feature
// (FeatureMap 0, HourFormat alone). A calendar beside it is refused.
NoFeatures bool
}
TimeFormatConfig is the start of the root's TimeFormatLocalization (Config.TimeFormat). The node passes every field to the server unchanged and adds no default of its own: the rules are the server's (mattercore.NewTimeFormatLocalization).
type TimePeerReader ¶
type TimePeerReader = mattercore.TimePeerReader
TimePeerReader is the type of TimeSynchronizationConfig.PeerReader: the read of the trusted time source's node (mattercore.TimePeerReader); without one the node reads over its client stack.
type TimeSynchronization ¶
type TimeSynchronization struct {
// Off leaves the cluster off the root. Without it GeneralDiagnostics
// has no UTC clock: TimeSnapshot answers SystemTimeMs alone and
// PosixTimeMs null, as matter.js GeneralDiagnosticsServer.timeSnapshot
// does without a TimeSynchronizationBehavior
// (GeneralDiagnosticsServer.ts:235-251 at db021da0).
Off bool
// Config selects the features TZ, NTPC, NTPS and TSC after
// connectedhomeip ([TimeSynchronizationConfig]); nil serves UTCTime
// and Granularity alone. The node persists their state in its store
// and clears a removed fabric's trusted time source; the config's
// Store is the node's. Off excludes it.
//
// The node's UTC — UTCTime, and GeneralDiagnostics' TimeSnapshot — is
// [Config].Clock plus an offset, with or without Config: SetUTCTime
// sets the offset, and so does the time client, which runs from Start
// while the host clock is no time source (Config's PlatformTime): it
// reads the trusted time source's node over the client stack
// ([Config].Client) and falls back to Config's NTPClient asking
// DefaultNTP, emitting TimeFailure when neither answers. The host
// clock is never set, and the offset is not persisted: a restart
// serves the host clock again.
Config *TimeSynchronizationConfig
}
TimeSynchronization is the root TimeSynchronization cluster (0x0038), mounted by default as the facade always did; RootNode carries it under an optional conformance (device/root_node_gen.go, generated from the snapshot). A default-on sub-system: its switch is Off, inside its own configuration (ADR 0025 principle 2).
type TimeSynchronizationConfig ¶
type TimeSynchronizationConfig = mattercore.TimeSynchronizationConfig
TimeSynchronizationConfig is the type of Config.TimeSynchronization: the root TimeSynchronization's features (mattercore.TimeSynchronizationConfig).
type Topology ¶ added in v0.9.1
Topology is the assembled endpoint tree a Snapshotter returns (endpoint.Topology).
type WebRTCRequestorConfig ¶
type WebRTCRequestorConfig struct {
// GrantFabric decides, per fabric of the node, whether the node writes
// the requestor's ACL entry into that fabric's ACL: Operate for CASE,
// no subject, the requestor's endpoint and cluster, one entry for each
// endpoint that serves a [camera.Requestor] — every node of the fabric,
// a camera among them, may then invoke the requestor's commands. nil
// writes it into no fabric. matter.js writes it only into the first
// fabric its node's own controller administers, by root certificate
// (WebRtcTransportRequestorServer.ts:56-94 at db021da0,
// fabricAuthority.fabrics[0] at :58; FabricAuthority.ts:112-114,
// :126-128), and a [Node] has no controller of its own, so no fabric
// gets it unasked: the fabric's administrator grants the access, or the
// host returns true here for the fabrics its cameras signal on. The node
// asks at Start and after each CommissioningComplete, on the calling
// goroutine.
//
// A grant only ever adds the entry. Withdrawing it — false for a fabric
// granted before, or GrantFabric left nil — removes nothing: the entry
// a granting start wrote, like the one a version before GrantFabric
// wrote into the first fabric's ACL, stays in that fabric's ACL, because
// the node cannot tell an entry it wrote from one the fabric's
// administrator wrote. The fabric's administrator removes it by writing
// the fabric's ACL without it.
GrantFabric func(fabric FabricInfo) bool
}
WebRTCRequestorConfig is the node's part of the WebRtcTransportRequestor servers its topology mounts (camera.Requestor, the default of device.NewCameraController): which fabrics the cameras reach them on.
type WiFi ¶ added in v0.4.0
type WiFi struct {
// Driver scans and joins the Wi-Fi networks a commissioner configures:
// non-nil mounts NetworkCommissioning with the Wi-Fi feature in place
// of the Ethernet one — the network list of one, the 10 s scan and
// 20 s connect maxima of connectedhomeip's Linux driver
// (NetworkCommissioningDriver.h:85-87 at 6170af84). The cluster keeps
// the committed network in the node's store and rejoins it inside
// [Node.Start], before the fabrics' operational records are published:
// a network out of range holds Start for up to the connect timeout.
// After a successful ConnectNetwork command the node re-announces its
// DNS-SD records at once ([Node.TriggerReannounce]), as matter.js's
// example does after its connect
// (DummyWifiNetworkCommissioningServer.ts:132-133 at b25ed960); after
// the rejoin at Start the trigger finds nothing published yet, and the
// start sequence publishes the records right after it.
// wifi/wpasupplicant is the Linux driver; nil mounts the Ethernet
// server.
Driver contract.WiFiDriver
// Reporter answers WiFiNetworkDiagnostics' reads and ResetCounts
// (WiFiReporter); nil mounts no cluster.
Reporter WiFiReporter
// Features is the cluster's FeatureMap: wifidiagdef.FeaturePacketCounts
// (PKTCNT) and wifidiagdef.FeatureErrorCounts (ERRCNT, which brings
// ResetCounts).
Features wifidiagdef.Feature
// Attributes are the optional attributes served
// (wifidiagdef.AttrCurrentMaxRate).
Attributes []uint32
}
WiFi is a Wi-Fi node's interface: its commissioning driver and its WiFiNetworkDiagnostics.
type WiFiNetworkDiagnosticsServer ¶ added in v0.10.4
type WiFiNetworkDiagnosticsServer = mattercore.WiFiNetworkDiagnostics
WiFiNetworkDiagnosticsServer is the root Wi-Fi Network Diagnostics server and its events (mattercore.WiFiNetworkDiagnostics).
type WiFiReporter ¶ added in v0.10.0
type WiFiReporter = mattercore.WiFiReporter
WiFiReporter is the type of WiFi.Reporter: the live Wi-Fi diagnostics the host reports (mattercore.WiFiReporter).
type WindowCredentials ¶ added in v0.3.1
type WindowCredentials struct {
// Discriminator is the 12-bit discriminator the window is advertised
// under.
Discriminator uint16
// Passcode is the window's setup passcode; it must pass
// setup.IsValidSetupPIN.
Passcode uint32
// PBKDFIterations is the SPAKE2+ PBKDF2 iteration count, within
// [spake2.IterationsMin, spake2.IterationsMax] — the name and type of
// [Commissioning].PBKDFIterations.
PBKDFIterations uint32
// Salt is the SPAKE2+ salt, spake2.PBKDFMinSaltSize to
// spake2.PBKDFMaxSaltSize bytes.
Salt []byte
// Timeout is how long the window stays open; 0 is the node's own
// window default (bridge.OwnWindowTimeoutUncommissioned while the node
// has no fabric, bridge.OwnWindowTimeoutCommissioned once it has one).
Timeout time.Duration
}
WindowCredentials are the setup credentials of one Node.OpenBasicWindow window.
func NewWindowCredentials ¶ added in v0.12.2
func NewWindowCredentials(timeout time.Duration) (WindowCredentials, error)
NewWindowCredentials draws fresh credentials for one Node.OpenBasicWindow window that stays open for timeout (0 is the node's own window default): a random 12-bit discriminator, a random passcode that passes ValidateSetupPIN, a random 32-byte salt and PBKDFIterationsMin PBKDF iterations — NewCommissioningCredentials() .WindowCredentials(timeout). A host that serves "open a window with a fresh code" draws them here instead of re-implementing the passcode rule; Node.PairingCodesFor encodes their codes.
Mirrors matter.js PaseClient.generateRandomPasscode and generateRandomDiscriminator (packages/protocol/src/session/pase/ PaseClient.ts:55-71 at db021da0; the rule is PairingCodeSchema.ts: 171-178 isValidPasscode) and the random 32-byte salt and 1000 iterations of CommissioningClient.openEnhancedCommissioningWindow (packages/node/src/behavior/system/commissioning/ CommissioningClient.ts:522-525), which draws the same for a window it opens on a peer.
type WindowKind ¶ added in v0.12.2
type WindowKind uint8
WindowKind names the open commissioning window by who opened it with which credentials.
const ( // WindowNone is no window: none is open. WindowNone WindowKind = iota // WindowOwn is the node's own window with the configured credentials // ([Config].Commissioning): the one an uncommissioned node opens, or // one the host opened through CommissioningWindow().OpenOwnWindow — // matter.js's window with byAdministrator false // (DeviceCommissioner.ts:236-266 at db021da0). WindowOwn // WindowBasic is the node's own window [Node.OpenBasicWindow] opened // with the host's credentials (a host extension; see there). WindowBasic // WindowEnhanced is an administrator's OpenCommissioningWindow with // its PAKE verifier — matter.js's EnhancedWindowOpen with // byAdministrator true. WindowEnhanced // WindowAdministratorBasic is an administrator's // OpenBasicCommissioningWindow (the Basic feature): the window the // AdministratorCommissioning cluster reports as BasicWindowOpen, opened // over the node's own setup passcode, which is the one a commissioner // enters (issue 539). WindowAdministratorBasic )
func (WindowKind) String ¶ added in v0.12.2
func (k WindowKind) String() string
String names the kind.
type WindowSnapshot ¶ added in v0.3.1
type WindowSnapshot struct {
// Open reports whether a window is open, whoever opened it.
Open bool
// Own reports whether it is the node's own window — the one an
// uncommissioned node opens, [Node.OpenBasicWindow]'s, or one the
// host opened through CommissioningWindow().OpenOwnWindow — rather
// than an administrator's.
Own bool
// Administrator is the AdministratorCommissioning view of the
// window: WindowStatus, AdminFabricIndex, AdminVendorId. The node's
// own window reads WindowNotOpen there, as matter.js keeps those
// attributes for administrator windows only.
Administrator WindowStatus
// CommissioningMode is the CM value of the commissionable record the
// node publishes after the transition: 0 none, 1 a basic window, 2
// an enhanced window with an administrator's verifier.
CommissioningMode uint8
// Discriminator is the published record's discriminator; 0 when
// CommissioningMode is 0.
Discriminator uint16
// Kind is which window is open; [WindowNone] while none is.
Kind WindowKind
// OpenedAt is when the window opened (or the node restarted its own
// window), and Deadline when its timer closes it, both on the node's
// clock ([Node.Clock]); zero while no window is open.
OpenedAt, Deadline time.Time
// Timeout is the duration the window was opened for; 0 while no
// window is open.
Timeout time.Duration
}
WindowSnapshot is the commissioning window as the node serves it: what OnWindowTransition receives after a transition and Node.Window returns at any time. matter.js keeps the same state in DeviceCommissioner's window — its status, byAdministrator and its timer (packages/protocol/src/protocol/DeviceCommissioner.ts:344-350, :236-266 #openWindow at db021da0) — and the advertised discriminator (`discriminator ?? commissioningConfig.discriminator`, :252).
type WindowStatus ¶ added in v0.10.0
type WindowStatus = wire.WindowStatusSnapshot
WindowStatus is the AdministratorCommissioning view WindowSnapshot.Administrator carries (wire.WindowStatusSnapshot).
Source Files
¶
- aggregator.go
- attestation.go
- client.go
- commissionable_device_type.go
- commissioner_control.go
- commissioner_reach.go
- commissioning.go
- config.go
- credentials.go
- diagnostics.go
- doc.go
- endpoints.go
- fabric_count.go
- fabric_state.go
- facade.go
- factory_reset.go
- failsafe.go
- groupsend.go
- health.go
- icd.go
- inspect.go
- jointfabric.go
- lifecycle.go
- limits.go
- listeners.go
- local_acl.go
- matter_time.go
- mdns.go
- metrics.go
- node.go
- node_label.go
- nonvolatile.go
- observers.go
- ota.go
- ota_provider.go
- peer_path.go
- persist.go
- reannounce.go
- reserve.go
- root.go
- routes.go
- seam.go
- security.go
- served.go
- session_events.go
- sessions.go
- store_path.go
- surface.go
- surface_stability.go
- time_peer_reader.go
- tls.go
- user_labels.go
- webrtc_provider_peers.go
- webrtc_requestor_acl.go
- wifi_driver.go
Directories
¶
| Path | Synopsis |
|---|---|
|
metrics
|
|
|
expvar
Package expvarmetrics implements the node's metrics port (contract.Metrics, node.Config.Metrics) on the standard library's expvar: each name is an expvar.Int published under prefix + name, so a daemon that serves net/http's /debug/vars (expvar's handler) shows the named set without code of its own and without a dependency beyond the standard library (ADR 0025 principle 12).
|
Package expvarmetrics implements the node's metrics port (contract.Metrics, node.Config.Metrics) on the standard library's expvar: each name is an expvar.Int published under prefix + name, so a daemon that serves net/http's /debug/vars (expvar's handler) shows the named set without code of its own and without a dependency beyond the standard library (ADR 0025 principle 12). |