controller

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package controller ties together transport, protocol framing, session management, secure channel establishment, and interaction model into a single Controller that can commission and communicate with Matter devices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BLEAdapter

type BLEAdapter = transport.BLEAdapter

BLEAdapter is the exported type alias so callers don't need to import the transport package directly.

type Config

type Config struct {
	// Store is the persistent store for fabrics and nodes.
	Store store.Store
	// FabricID is the fabric identity to use. If zero, a default (1) is used.
	FabricID uint64
	// BindAddr is the local UDP address to bind to. Defaults to ":0".
	BindAddr string
}

Config holds configuration for creating a Controller.

type Controller

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

Controller is a Matter controller that can establish PASE/CASE sessions and communicate with devices over the interaction model.

func New

func New(cfg Config) (*Controller, error)

New creates a new Controller with the given configuration.

func NewWithConn

func NewWithConn(cfg Config, conn transport.Conn) (*Controller, error)

NewWithConn creates a Controller using an externally provided transport.Conn. This is primarily useful for testing with mock transports.

func (*Controller) Close

func (c *Controller) Close() error

Close shuts down the controller, stopping the message pump and closing the transport connection.

func (*Controller) CompressedFabricID

func (c *Controller) CompressedFabricID() []byte

CompressedFabricID returns the 8-byte compressed fabric identifier for this controller's fabric. Returns nil if the fabric has not been initialised yet.

func (*Controller) ConnectCASE

func (c *Controller) ConnectCASE(ctx context.Context, addr string, nodeID uint64) (*protocol.Session, error)

ConnectCASE establishes a CASE session with a device at the given address. Returns the secured session.

func (*Controller) ConnectPASE

func (c *Controller) ConnectPASE(ctx context.Context, addr string, passcode uint32) (*protocol.Session, error)

ConnectPASE establishes a PASE session with a device at the given address using the provided passcode. Returns the secured session.

func (*Controller) ConnectPASEoverBLE

func (c *Controller) ConnectPASEoverBLE(ctx context.Context, adapter transport.BLEAdapter, addr transport.BLEAddress, passcode uint32) (*protocol.Session, *transport.BLEConn, error)

ConnectPASEoverBLE establishes a PASE session with a device over BLE/BTP. It creates a temporary sub-controller backed by the BLE transport.

func (*Controller) Exchanges

func (c *Controller) Exchanges() *protocol.ExchangeManager

Exchanges returns the controller's exchange manager.

func (*Controller) NewCommissioner

func (c *Controller) NewCommissioner() *commissioning.Commissioner

NewCommissioner assembles a commissioning.Commissioner wired to this controller.

func (*Controller) NewCommissionerWithTransport

func (c *Controller) NewCommissionerWithTransport(pref TransportPreference, adapter transport.BLEAdapter) *commissioning.Commissioner

NewCommissionerWithTransport assembles a commissioning.Commissioner that uses the given transport preference to select between BLE and IP discovery/session establishment.

func (*Controller) Sessions

func (c *Controller) Sessions() *protocol.SessionTable

Sessions returns the controller's session table.

type StaticDiscoverer

type StaticDiscoverer struct {
	Addr string
}

StaticDiscoverer bypasses mDNS and returns a fixed address. Used for direct IP commissioning.

func (*StaticDiscoverer) DiscoverCommissionable

func (d *StaticDiscoverer) DiscoverCommissionable(_ context.Context, _ uint16, _ commissioning.DiscoveryCapabilities) (string, error)

DiscoverCommissionable returns the pre-configured address regardless of discriminator.

type TransportPreference

type TransportPreference string

TransportPreference controls which transport is used for commissioning.

const (
	// TransportAuto detects the transport from the QR code's DiscoveryCapabilities
	// field, preferring BLE when the device advertises it.
	TransportAuto TransportPreference = "auto"

	// TransportBLE forces BLE commissioning.
	TransportBLE TransportPreference = "ble"

	// TransportIP forces IP/mDNS commissioning.
	TransportIP TransportPreference = "ip"
)

Jump to

Keyboard shortcuts

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