config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides the config file schema and utilities to load the config into concrete outlet and outlet group types.

Index

Constants

View Source
const (
	// DefaultListenAddress defines the default address to listen on.
	DefaultListenAddress = ":3333"

	// DefaultTransmitPin defines the default gpio pin for transmitting rf codes.
	DefaultTransmitPin uint = 17

	// DefaultReceivePin defines the default gpio pin for receiving rf codes.
	DefaultReceivePin uint = 27

	// DefaultProtocol defines the default rf protocol.
	DefaultProtocol int = 1

	// DefaultPulseLength defines the default pulse length.
	DefaultPulseLength uint = 189
)

Variables

DefaultConfig contains the default values which are chosen if a file is omitted in the config file.

Functions

This section is empty.

Types

type Config

type Config struct {
	ListenAddress    string              `json:"listenAddress"`
	StateFile        string              `json:"stateFile"`
	DetectStateDrift bool                `json:"detectStateDrift"`
	GPIO             GPIOConfig          `json:"gpio"`
	OutletGroups     []OutletGroupConfig `json:"outletGroups"`
}

Config is the structure of the config file.

func Load

func Load(file string) (*Config, error)

Load loads the config from a file.

func LoadWithDefaults

func LoadWithDefaults(file string) (*Config, error)

LoadWithDefaults loads config from file and merges in the default config for unset fields.

func LoadWithReader

func LoadWithReader(r io.Reader) (*Config, error)

LoadWithReader loads the config using reader.

func (Config) BuildOutletGroups

func (c Config) BuildOutletGroups() []*outlet.Group

BuildOutletGroups builds outlet groups from c.

type GPIOConfig

type GPIOConfig struct {
	ReceivePin         uint `json:"receivePin"`
	TransmitPin        uint `json:"transmitPin"`
	DefaultPulseLength uint `json:"defaultPulseLength"`
	DefaultProtocol    int  `json:"defaultProtocol"`
	TransmissionCount  int  `json:"transmissionCount"`
}

GPIOConfig is the structure of the gpio config section.

type OutletConfig

type OutletConfig struct {
	ID          string `json:"id"`
	DisplayName string `json:"displayName"`
	CodeOn      uint64 `json:"codeOn"`
	CodeOff     uint64 `json:"codeOff"`
	Protocol    int    `json:"protocol"`
	PulseLength uint   `json:"pulseLength"`
}

OutletConfig is the structure of the config for a single outlet.

type OutletGroupConfig

type OutletGroupConfig struct {
	ID          string         `json:"id"`
	DisplayName string         `json:"displayName"`
	Outlets     []OutletConfig `json:"outlets"`
}

OutletGroupConfig is the structure of the config for a single outlet group.

Jump to

Keyboard shortcuts

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