Documentation
¶
Overview ¶
Package common provides shared utilities for Matter device examples.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNode ¶
CreateNode creates a Matter node from Options. This is the common bootstrap for all device examples.
func RunDevice ¶
RunDevice starts a Matter node and blocks until interrupted. This is a convenience function that combines Start, WaitForSignal, and Stop.
func WaitForSignal ¶
func WaitForSignal()
WaitForSignal blocks until SIGINT or SIGTERM is received. Use this in main() to keep the device running until interrupted.
Types ¶
type Options ¶
type Options struct {
// Port is the UDP/TCP port for Matter communication.
Port int
// Discriminator is the 12-bit discriminator for device pairing.
Discriminator uint16
// Passcode is the setup passcode (20000001-99999998).
Passcode uint32
// StoragePath is the path for persistent storage.
// If empty, in-memory storage is used.
StoragePath string
// DeviceName is the human-readable device name.
DeviceName string
// VendorID is the vendor ID (default: 0xFFF1 test vendor).
VendorID uint16
// ProductID is the product ID.
ProductID uint16
}
Options holds standard CLI flags for Matter device examples.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns Options with sensible defaults for testing.
func ParseFlags ¶
func ParseFlags() Options
ParseFlags parses standard CLI flags and returns Options. Flags are standardized across all examples:
-port UDP/TCP port (default: 5540) -discriminator 12-bit discriminator (default: 3840) -passcode Setup passcode (default: 20202021) -storage Path for persistent storage (default: in-memory) -name Device name (default: "Matter Device") -vendor Vendor ID (default: 0xFFF1) -product Product ID (default: 0x8001)