appconfig

package
v0.0.0-...-17bb7b9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

This package provides functionality to define configuration option with their values, and also define dependencies on other configuration options.

Configuration values are not ordered in the output, and dependencies are managed on very basic level.

Configuration values already added to global list for now are treated as required, which is not necessarily correct.

Index

Constants

View Source
const (
	Yes = "y"
	No  = "n"
)

Variables

View Source
var (
	// Zephyr config
	CONFIG_CPP = NewValue("CONFIG_CPP").Default(Yes)

	// Logging
	CONFIG_LOG              = NewValue("CONFIG_LOG").Default(No)
	CONFIG_SERIAL           = NewValue("CONFIG_SERIAL").Default(No)
	CONFIG_CONSOLE          = NewValue("CONFIG_CONSOLE").Default(No)
	CONFIG_UART_CONSOLE     = NewValue("CONFIG_UART_CONSOLE").Default(No)
	CONFIG_UART_LINE_CTRL   = NewValue("CONFIG_UART_LINE_CTRL").Default(Yes)
	CONFIG_LOG_BACKEND_UART = NewValue("CONFIG_LOG_BACKEND_UART").Default(Yes)
	CONFIG_PRINTK           = NewValue("CONFIG_PRINTK").Default(Yes)

	// USB
	CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT = NewValue("CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT").Default(No)
	CONFIG_USB_DEVICE_PRODUCT            = NewValue("CONFIG_USB_DEVICE_PRODUCT").Default(`"Dongle: Zigbee Device"`)
	CONFIG_USB_DEVICE_PID                = NewValue("CONFIG_USB_DEVICE_PID").Default(`0x0004`)
	CONFIG_USB_DEVICE_STACK              = NewValue("CONFIG_USB_DEVICE_STACK").Default(No)

	// Drivers / peripherals
	CONFIG_I2C        = NewValue("CONFIG_I2C").Default(Yes)
	CONFIG_SENSOR     = NewValue("CONFIG_SENSOR").Default(No)
	CONFIG_BME280     = NewValue("CONFIG_BME280").Default(No).Depends(CONFIG_I2C.Required(Yes), CONFIG_SENSOR.Required(Yes))
	CONFIG_DK_LIBRARY = NewValue("CONFIG_DK_LIBRARY").Default(Yes)

	// Zigbee
	CONFIG_ZIGBEE                              = NewValue("CONFIG_ZIGBEE").Default(Yes)
	CONFIG_ZIGBEE_APP_UTILS                    = NewValue("CONFIG_ZIGBEE_APP_UTILS").Default(Yes)
	CONFIG_ZIGBEE_CHANNEL_MASK                 = NewValue("CONFIG_ZIGBEE_CHANNEL_MASK").Default("0x7FFF800")
	CONFIG_ZIGBEE_ROLE_END_DEVICE              = NewValue("CONFIG_ZIGBEE_ROLE_END_DEVICE").Default(Yes)
	CONFIG_ZIGBEE_ROLE_ROUTER                  = NewValue("CONFIG_ZIGBEE_ROLE_ROUTER").Default(Yes)
	CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI = NewValue("CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI").Default(Yes)

	// Cryptography
	CONFIG_CRYPTO               = NewValue("CONFIG_CRYPTO").Default(Yes)
	CONFIG_CRYPTO_NRF_ECB       = NewValue("CONFIG_CRYPTO_NRF_ECB").Default(Yes).Depends(CONFIG_CRYPTO)
	CONFIG_CRYPTO_INIT_PRIORITY = NewValue("CONFIG_CRYPTO_INIT_PRIORITY").Default(`80`)

	// Power configuration
	CONFIG_RAM_POWER_DOWN_LIBRARY = NewValue("CONFIG_RAM_POWER_DOWN_LIBRARY").Default(Yes)

	// Network
	CONFIG_NET_IPV6          = NewValue("CONFIG_NET_IPV6").Default(No)
	CONFIG_NET_IP_ADDR_CHECK = NewValue("CONFIG_NET_IP_ADDR_CHECK").Default(No)
	CONFIG_NET_UDP           = NewValue("CONFIG_NET_UDP").Default(No)

	// Sensors
	CONFIG_DHT = NewValue("CONFIG_DHT").Default(Yes)
)

NOTE: This values are fetched from original `prj.conf` of this project, and some were updated to disable/remove some things as default. As such they do not represent good/best configurations, but mostly the ones that work for this project.

Functions

This section is empty.

Types

type AppConfig

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

func NewDefaultAppConfig

func NewDefaultAppConfig(opts DefaultAppConfigOptions) (*AppConfig, error)

func NewEmptyAppConfig

func NewEmptyAppConfig() *AppConfig

func (*AppConfig) AddValue

func (c *AppConfig) AddValue(configValues ...ConfigValue) *AppConfig

func (*AppConfig) WriteTo

func (c *AppConfig) WriteTo(w io.StringWriter) error

type ConfigValue

type ConfigValue struct {
	Name          string
	DefaultValue  string
	RequiredValue string
	QuotedValue   bool

	Dependencies []ConfigValue
}

func NewValue

func NewValue(name string) ConfigValue

func (ConfigValue) Copy

func (v ConfigValue) Copy() ConfigValue

func (ConfigValue) Default

func (v ConfigValue) Default(val string) ConfigValue

func (ConfigValue) Depends

func (v ConfigValue) Depends(cfgs ...ConfigValue) ConfigValue

func (ConfigValue) Quoted

func (v ConfigValue) Quoted() ConfigValue

func (ConfigValue) Required

func (v ConfigValue) Required(val string) ConfigValue

func (ConfigValue) Value

func (v ConfigValue) Value() string

type DefaultAppConfigOptions

type DefaultAppConfigOptions struct {
	IsRouter       bool
	ZigbeeChannels []int
}

type Provider

type Provider interface {
	AppConfig() []ConfigValue
}

Jump to

Keyboard shortcuts

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