README
¶
reference-controller
The module's controller role as a command-line tool: it pairs Matter nodes
over IP or BLE, reads, writes, invokes and subscribes, provisions groups and
bindings, and serves an OTA image. It is an example (the command line is
package cli beside this file), not API — copy from it, do not build
against it.
go build ./examples/reference-controller
./reference-controller --db home.db pair --code MT:-24J0AFN00KA0648G00
This build has no BLE. The BLE build is
ble/bluez/cmd/reference-controller,
the same command line over BlueZ (§BLE below);
ble/esphome/cmd/reference-controller
reaches BLE through ESPHome Bluetooth proxies instead (--bluetooth-proxy,
--bluetooth-proxy-discover, §BLE).
Every command opens the database, does its work and exits; the next command is the same fabric, so every node paired before still trusts it.
Global flags
They go before or after the command.
| Flag | Default | |
|---|---|---|
--db <file> |
reference-controller.db |
The SQLite database (see The database). |
--trust development|production|none |
development |
Which roots pair's attestation check trusts: the embedded DCL snapshot (controller/dcl/snapshot) and the CSA test PAAs, the snapshot only, or none (no chain check). The snapshot's fetch time is in the --log-level debug log. |
--trust-dir <path> |
unset | A DCL snapshot directory (paa/, cd-signers/, SOURCE, as make update-dcl-snapshot writes it) in place of the embedded one — a newer set without a rebuild. |
--dcl prod|testnet|off |
off |
The online CSA Distributed Compliance Ledger (or its test net) on top of the trust set: roots newer than the snapshot, CD signers fetched on demand, and the CRL revocation check, which only the online ledger answers. |
--attestation accept|reject|ask |
ask on a terminal, reject otherwise |
What an attestation finding does to a pairing. |
--log-level debug|info|warn|error |
warn |
The log, as slog text on stderr. |
--listen <addr> |
[::]:0 |
The controller's UDP socket. |
--node-listen <addr> |
[::]:0 |
Deprecated: accepted, without effect since v0.18.0, which retired the controller's second node — the group sender and the OTA provider use the controller's socket (--listen). The flag will be removed. |
--timeout <duration> |
60s |
How long a command waits for the network (a bare number is seconds). |
--ca-key file:<path> |
unset | The CA root key in a passphrase-encrypted key file instead of the database; the passphrase comes from GOFABRIC_KEY_PASSPHRASE. A missing file is created: with the root key the database holds (which then leaves the database), or a new key for a new database. Every later run needs the flag. |
--seal-key file:<path> |
unset | Seal the database's secrets at rest (controller.Config.Sealer with store.NewAESGCMSealer) under a 32-byte key kept in the named file as 64 hex digits. A missing file is created with a new random key, mode 0600; a clear database is sealed on the way in. Every later run needs the flag and the same file — see The database. |
A <node> argument is the node id, decimal or 0x hex, or the registry's
local id (peer1). A path is <endpoint>/<Cluster>/<element>: the cluster
by its matter.js name (OnOff, BasicInformation) or id, the element — an
attribute, command or event — by name or id; * is a wildcard where the
Interaction Model allows one. A JSON value follows chip-tool's conventions
(cluster/spec/json.go): numbers, or "0x…" strings for unsigned ones;
octet strings as "hex:…", "base64:…" or "str:…"; structs as objects by
field name; lists as arrays; null; an enum also by value name, a bitmap
also as an object of member names. A command fails with exit status 1 and
its error on stderr.
Commands
-
pair --code <MT:… | 11 or 21 digits> | --passcode N --discriminator N [--node-id N] [--label L] [--wifi-ssid S --wifi-credentials C | --thread-dataset HEX] [--ble [--ble-adapter hci0]]Finds the device over DNS-SD by its discriminator (long from a QR code or--discriminator, short from a manual code), runs PASE, checks its attestation, installs the NOC, keeps the node in the registry and prints its node id and device view (each endpoint's device type and clusters).--labelwritesBasicInformation.NodeLabel.--wifi-ssidwith--wifi-credentials, or--thread-dataset(the operational dataset as hex), add the network steps of the commissioning flow (AddOrUpdateWiFiNetwork/AddOrUpdateThreadNetwork,ConnectNetwork), which matter.js runs only on a BLE channel; here they also run over IP when the credentials are given (BD-Controller-NetworkStepsOverIP). The passphrase and the dataset need not be on the command line, wherepsand the shell history show them:--wifi-credentials @fileand--thread-dataset @fileread the file, and without the flag they come fromGOFABRIC_WIFI_CREDENTIALSandGOFABRIC_THREAD_DATASET.reference-controller pair --code 34970112332 --node-id 0x4321 --label kitchen--ble(the BLE build only) finds the device by its BLE advertisement instead — by the same discriminator — and runs PASE over BTP on the adapter--ble-adapter(defaulthci0). A device on BLE has no network yet, so--bleneeds--wifi-ssidwith--wifi-credentials, or--thread-dataset; the network steps put the device on that network, and operational discovery then finds it over DNS-SD for CASE. In the plain build--bleanswers that the build has none.reference-controller pair --ble --code MT:-24J0AFN00KA0648G00 --wifi-ssid lab --wifi-credentials secret12 -
discover [--code <MT:… | 11 or 21 digits> | --discriminator N] [--first]— searches DNS-SD for the commissionable devices the code's or the long discriminator selects (every one with neither) until--timeoutpasses, and prints each with its discriminator, vendor and product, commissioning mode and addresses;--firststops at the first that answers (Controller.DiscoverWith,DiscoverOptions.First). -
unpair <node>— RemoveFabric on the node, then its record is deleted.reference-controller unpair 0x4321 -
nodes— every paired node: node id, local id, label, whether it answers a read within--timeout(5 s here unless given), and the conformance verdict of its image.reference-controller nodes -
node <node>— reads every attribute and prints the node's full image: endpoints, device types, conformance, clusters, attribute values.reference-controller node 0x4321 -
read <node> <ep>/<Cluster>/<Attribute>…— one JSON line per attribute.reference-controller read 0x4321 0/BasicInformation/NodeLabel '*/OnOff/OnOff' -
write <node> <ep>/<Cluster>/<Attribute> <json> [--timed ms]reference-controller write 0x4321 0/BasicInformation/NodeLabel '"pantry"' -
invoke <node> <ep>/<Cluster>/<Command> [<json>] [--timed ms]— prints the status and the response's fields as a JSON line.reference-controller invoke 0x4321 1/LevelControl/MoveToLevel '{"level": 128, "transitionTime": 10, "optionsMask": 0, "optionsOverride": 0}' -
subscribe <node> <path>… [--min s] [--max s] [--count n]— attribute or event paths; every report as JSON lines until Ctrl-C (or--countreports).reference-controller subscribe 0x4321 1/OnOff/OnOff --max 30 -
events <node> <ep>/<Cluster>/<Event>…— reads events, one JSON line each.reference-controller events 0x4321 0/BasicInformation/StartUp -
group create <id> --key <hex|random> --nodes <n,n…> --endpoints <e,e…> [--keyset N]— writes the key set (GroupKeyManagement KeySetWrite) on each node and joins the group on its endpoints with Groupcast JoinGroup and the auxiliary ACL entry; the controller keeps the key set in its own database, as the sender. The key set id defaults to the group id. A node whose root ServerList lacks Groupcast (before Matter 1.5) is provisioned the pre-1.5 way instead: GroupKeyMap entry, Groups AddGroup on each endpoint and a Group ACL entry granting the group Operate on them.reference-controller group create 257 --key random --nodes 0x4321,0x4322 --endpoints 1 -
group send <id> <Cluster>/<Command> [<json>]— a group command from the controller, sent as the fabric's root node id.reference-controller group send 257 OnOff/Toggle -
bind <node> <ep> --to <node>/<ep>[/<Cluster>]— adds the Binding entry on the source endpoint and the ACL entry on the target that grants the source Operate on the target endpoint (and cluster).bind <node> <ep> --group <id>— adds a group Binding entry and gives the source the group's key set and GroupKeyMap entry.reference-controller bind 0x4322 1 --to 0x4321/1/OnOff -
ota serve --image <file> [--version N] [--vendor N] [--product N] [--announce <node>] [--once] [--yes]— serves the image through the controller's OTA push (controller.Config.OTA): the image goes into the update manager's store and is offered by its header, so--version,--vendorand--productmust match it. With--announcethe console grants that node's consent (unless--yes) and the manager announces the provider and follows the update — the node gets a default subscription for the time it runs; without it every paired node of the vendor and product gets the consent and the image when it queries. Each status is printed. Runs until Ctrl-C, or--onceuntil one update is done.reference-controller ota serve --image light-v2.ota --announce 0x4321 --once -
window open <node> [--timeout s] [--basic]— opens a commissioning window on a paired node so a second administrator (Apple Home, Google Home, another controller) can add it. Enhanced (the default) draws a random discriminator, passcode and 32-byte salt, sends OpenCommissioningWindow with the PAKE verifier (1000 PBKDF iterations) and prints the discriminator, passcode, manual code and QR code; the node's vendor and product ids are read for the QR code.--basicsends OpenBasicCommissioningWindow — the device's own code — and fails when the node does not advertise the Basic (BC) feature.--timeoutis the window's lifetime in seconds (default 900); afterwindow openit is the window's, so the network--timeoutgoes before the command. Any window already open is revoked first. Both follow matter.js'sCommissioningClient(openEnhancedCommissioningWindow,openBasicCommissioningWindow).window revoke <node>— RevokeCommissioning; a node without an open window is reported, not an error.reference-controller window open 0x4321 --timeout 600
BLE
cd ble/bluez && go build -o reference-controller ./cmd/reference-controller
ble/bluez is a Go module of its own (ADR 0024 decision 3), so the main
module never pulls its D-Bus dependency; its cmd/reference-controller is
this command line with cli.Options.Central set to bluez.NewCentral. It
speaks BlueZ over the D-Bus system bus, without cgo, on Linux only.
- Rights. BlueZ answers callers its D-Bus policy admits: root and, on
most distributions, members of the
bluetoothgroup (sudo usermod -aG bluetooth $USER, then log in again); elsewhere a polkit rule or a D-Bus policy file fororg.bluez. Without the rightpair --blefails withorg.freedesktop.DBus.Error.AccessDeniedin the message; an adapter that is off fails withorg.bluez.Error.NotReady(bluetoothctl power on). - BlueZ. Verified against BlueZ 5.72 over virtual controllers only:
the module's tests run over an in-process bus, and the live path is the
manually started
ble-virtualworkflow (make ble-virtual-test; Ubuntu 24.04 on arm64, two LE-onlybtvirtcontrollers): this build pairs a matter.js node with@matter/nodejs-ble(script/ble-virtual/peripheral.mjs, bleno, a Wi-Fi NetworkCommissioning server) withpair --ble, reads it over CASE and opens a window, and matter.js's own controller pairs the same peripheral as the control leg. It is a virtual counterpart, not a field test: a real device stays the proof. The ATT_MTU comes from the characteristic'sMTUproperty; a BlueZ without it runs BTP at the 20-byte minimum segment. - Adapter.
--ble-adapternames the adapter as BlueZ does (hci0,hci1, …;bluetoothctl list).
Through ESPHome Bluetooth proxies
cd ble/esphome && go build -o reference-controller ./cmd/reference-controller
reference-controller pair --bluetooth-proxy proxy-office.local,$KEY --code MT:-24J0AFN00KA0648G00 --wifi-ssid lab --wifi-credentials secret12
reference-controller pair --bluetooth-proxy-discover --bluetooth-proxy-key kitchen-proxy=$KEY --code MT:-24J0AFN00KA0648G00 --wifi-ssid lab --wifi-credentials secret12
ble/esphome is the other BLE module: its cmd/reference-controller is this
command line with cli.Options.Proxies set to esphome.NewCentral.
--bluetooth-proxy host[:port][,key] (repeatable, port 6053 by default, the
key as the device's api: encryption: key: holds it) names an ESPHome
Bluetooth proxy with active: true, and implies --ble.
--bluetooth-proxy-discover finds the proxies over DNS-SD as well, and
--bluetooth-proxy-key name=key (repeatable) gives a discovered device's key
by its name or MAC. A discovered device without a key is skipped (logged as
ble.esphome.proxy_skipped): the plaintext API authenticates neither side,
so any host announcing _esphomelib._tcp would carry the pairing.
--bluetooth-proxy-allow-plaintext dials such a device anyway, over the
plaintext API, with a warning per proxy. A proxy named with
--bluetooth-proxy is used as given. The host needs no adapter. A proxy serves one API subscriber, so the pairing takes it from Home
Assistant while it runs
(guide).
The controller's own identity
A group message is sealed and sent by a node of the fabric, and an OTA
image is served by one. The controller is that node: it sends group
messages and serves the OTA provider under its one operational identity,
the fabric's root node id, over its own socket (--listen) — matter.js's
one controller node. group and ota therefore open the controller with
its OTA push (controller.Config.OTA): the provider sits at
controller.OTAProviderEndpoint of the controller's own endpoint tree, the
controller advertises its operational record on DNS-SD while the command
runs, and group send goes through Controller.Groups(). pair, read,
write, invoke, subscribe, events, bind and unpair open the
controller without the OTA push.
Until v0.18.0 the tool ran a second node for both, commissioned into its
own fabric (--node-listen was its socket; the flag is still accepted and
does nothing). A database of that time is migrated by the first group or
ota command: the node's record is removed and the registry forgets the
node.
The database
One SQLite file holds:
| Where | What |
|---|---|
matter_settings controller.ca |
The CA: root certificate, root key, certificate counter (JSON, matter.js CertificateAuthority field names). With --ca-key the root key is not here; rootKeyRef names the key file. |
matter_settings controller.ca.fabric |
The fabric: fabric id, root node id, vendor id, IPK, fabric index, label, the controller's operational key and NOC (matter.js Fabric.Config names). |
matter_settings controller.dcl.trust |
The DCL trust store, with --dcl prod or testnet. |
matter_settings controller.group.<id> |
Each group group create made (key set id, members, endpoints). The epoch key is not here: it is in the controller's key set (matter_group_keys). A record an earlier version wrote with an epochKey is rewritten without it by the next bind --group of that group. |
matter_settings controller.self, controller.ownnode |
Only in a database from before v0.18.0: the record of the second node the tool ran then (passcode, discriminator, salt, node id). The first group or ota command removes it. |
matter_client_values, matter_client_versions |
The client registry: every paired node's record and cached image (controller/client/sqlstore). |
matter_group_keys, matter_group_key_map |
The key sets of the groups the controller sends to (Controller.SetGroupKey). |
matter_resumption |
One CASE resumption record per node the tool had a session with: that session's shared secret, so a later run resumes instead of running full CASE (controller.New's store). |
the other matter_* tables |
In a database from before v0.18.0: the store of the second node the tool ran then (its fabric, keys, ACL). The migration removes that node's record and the registry's node, not these rows. |
The file holds private keys and session secrets: keep it as private as the
devices it controls. Without --seal-key they are in clear — the CA and
its root key (unless --ca-key), the fabric's IPK and operational key, the
group key sets and the resumption records — and the file's 0600 mode is
all that protects them. With --seal-key file:<path> the controller seals
each of them under the key in that file
(docs/security.md, "Sealing at rest");
the certificates, ids and the nodes' cached attributes stay readable. Keep
the key file off the database's disk and backup: a database sealed under it
does not open without it.
What leaves the host
With --dcl off (the default) nothing but Matter traffic: DNS-SD on the local
network and the Matter messages to the devices. The DCL snapshot is embedded
in the binary; using it asks nobody. Without --dcl no revocation is
checked: the snapshot holds trust anchors, not CRLs.
With --dcl prod or --dcl testnet, pair — and only pair — opens the
ledger trust store (controller/dcl): it updates the store from the ledger
(https://on.dcl.csa-iot.org, or https://on.test-net.dcl.csa-iot.org)
over HTTPS — the PAA list — and, while it attests the device, looks up the
CD signer and the revocation points by their subject key identifiers. The
ledger learns which manufacturers' devices the controller commissions; no
device identity, passcode or fabric key is sent. The store is kept in the
database between runs. GitHub's development certificates are not fetched.
The other commands never contact the ledger: ota serve's image store has
none, so it offers the given image only.
Documentation
¶
Overview ¶
Command reference-controller is the module's controller role as a command-line tool (package cli beside this file), built without BLE: pair --ble answers that this build has none. The BLE build is ble/bluez/cmd/reference-controller.
It is an example, not API (README.md §API stability): copy from it, do not build against it. README.md beside this file lists every command.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli is the reference controller's command line: the module's controller role as a tool that pairs Matter nodes over IP or BLE, reads, writes, invokes and subscribes, creates groups and bindings and serves an OTA image.
|
Package cli is the reference controller's command line: the module's controller role as a tool that pairs Matter nodes over IP or BLE, reads, writes, invokes and subscribes, creates groups and bindings and serves an OTA image. |