common

package
v0.0.0-...-02ded7e Latest Latest
Warning

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

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

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

func CreateNode(opts Options) (*matter.Node, error)

CreateNode creates a Matter node from Options. This is the common bootstrap for all device examples.

func PrintUsage

func PrintUsage()

PrintUsage prints usage information to stderr.

func RunDevice

func RunDevice(node *matter.Node) error

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)

Jump to

Keyboard shortcuts

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