backup

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const FormatVersion = 1

FormatVersion is the current backup format version.

Variables

This section is empty.

Functions

func DecodeHex

func DecodeHex(s string) ([]byte, error)

DecodeHex decodes a hex string to bytes.

func DecodeIEEEAddr

func DecodeIEEEAddr(s string) ([8]byte, error)

DecodeIEEEAddr decodes a hex string to IEEE address.

func EncodeHex

func EncodeHex(data []byte) string

EncodeHex encodes bytes to hex string (no separators).

func EncodeIEEEAddr

func EncodeIEEEAddr(addr [8]byte) string

EncodeIEEEAddr encodes an IEEE address to hex string.

Types

type AdapterInfo

type AdapterInfo struct {
	ZStackVariant int    `json:"zstackVariant"`
	SDKVersion    string `json:"sdkVersion"`
	BuildDate     uint32 `json:"buildDate"`
}

AdapterInfo contains adapter firmware information.

type Backup

type Backup struct {
	Version     int             `json:"version"`
	Created     time.Time       `json:"created"`
	Adapter     AdapterInfo     `json:"adapter"`
	Coordinator CoordinatorInfo `json:"coordinator"`
	Network     NetworkConfig   `json:"network"`
	Security    SecurityInfo    `json:"security"`
	Devices     []DeviceEntry   `json:"devices"`
}

Backup represents a complete adapter backup.

func FromJSON

func FromJSON(data []byte) (*Backup, error)

FromJSON deserializes a backup from JSON.

func New

func New() *Backup

New creates a new backup with default values.

func (*Backup) ToJSON

func (b *Backup) ToJSON() ([]byte, error)

ToJSON serializes the backup to JSON.

func (*Backup) Validate

func (b *Backup) Validate() error

Validate checks if the backup is valid.

type CoordinatorInfo

type CoordinatorInfo struct {
	IEEEAddress    string `json:"ieeeAddress"` // Hex string without colons
	NetworkAddress uint16 `json:"networkAddress"`
}

CoordinatorInfo contains coordinator address information.

type DeviceEntry

type DeviceEntry struct {
	IEEEAddress    string   `json:"ieeeAddress"` // Hex string
	NetworkAddress uint16   `json:"networkAddress"`
	Type           string   `json:"type"` // "router", "endDevice", "unknown"
	LinkKey        *LinkKey `json:"linkKey,omitempty"`
}

DeviceEntry represents a paired device.

type LinkKey

type LinkKey struct {
	Key       string `json:"key"` // Hex string (32 chars)
	TxCounter uint32 `json:"txCounter"`
	RxCounter uint32 `json:"rxCounter"`
}

LinkKey contains link key information for a device.

type NetworkConfig

type NetworkConfig struct {
	PanID              uint16 `json:"panId"`
	ExtendedPanID      string `json:"extendedPanId"` // Hex string
	Channel            uint8  `json:"channel"`
	NetworkKey         string `json:"networkKey"` // Hex string (32 chars) - SENSITIVE
	NetworkKeySequence uint8  `json:"networkKeySequence"`
	SecurityLevel      uint8  `json:"securityLevel"`
	UpdateID           uint8  `json:"updateId"`
}

NetworkConfig contains network configuration.

SECURITY WARNING: This struct contains sensitive cryptographic material. The NetworkKey is the Zigbee network encryption key - if compromised, attackers can decrypt all network traffic and inject malicious commands.

Best practices:

  • Never commit backup files to version control
  • Store backup files with restricted file permissions (0600)
  • Consider encrypting backup files at rest
  • Securely delete backup files when no longer needed

type SecurityInfo

type SecurityInfo struct {
	FrameCounter           uint32 `json:"frameCounter"`
	TrustCenterLinkKeySeed string `json:"trustCenterLinkKeySeed,omitempty"` // Hex string
}

SecurityInfo contains security-related information.

Jump to

Keyboard shortcuts

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