naos

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseTopics added in v0.8.0

func BaseTopics(devices []*Device) []string

BaseTopics returns a list of base topics from the provided devices.

Types

type Component

type Component struct {
	Path       string `json:"path"`
	Repository string `json:"repository"`
	Version    string `json:"version"`
}

A Component represents an installable NAOS component.

type Device

type Device struct {
	BaseTopic       string            `json:"base_topic"`
	Name            string            `json:"name"`
	Type            string            `json:"type"`
	FirmwareVersion string            `json:"firmware_version"`
	Parameters      map[string]string `json:"parameters"`
}

A Device represents a single device in an Inventory.

type Frameworks added in v0.10.0

type Frameworks struct {
	Audio string `json:"audio,omitempty"`
}

Frameworks represents the official frameworks.

type Inventory

type Inventory struct {
	Version    string                `json:"version"`
	Target     string                `json:"target"`
	BaudRate   string                `json:"baud_rate,omitempty"`
	Embeds     []string              `json:"embeds"`
	Overrides  map[string]string     `json:"overrides"`
	Components map[string]*Component `json:"components"`
	Frameworks Frameworks            `json:"frameworks,omitempty"`
	Broker     string                `json:"broker,omitempty"`
	Devices    map[string]*Device    `json:"devices,omitempty"`
}

An Inventory represents the contents of the inventory file.

func NewInventory

func NewInventory() *Inventory

NewInventory creates a new Inventory.

func ReadInventory

func ReadInventory(path string) (*Inventory, error)

ReadInventory will attempt to read the inventory file at the specified path.

func (*Inventory) Collect

func (i *Inventory) Collect(duration time.Duration) ([]*Device, error)

Collect will collect announcements and update the inventory with found devices for the given amount of time. It will return a list of devices that have been added to the inventory.

func (*Inventory) Debug

func (i *Inventory) Debug(pattern string, delete bool, duration time.Duration) (map[*Device][]byte, error)

Debug will load the coredump data from the devices that match the supplied glob pattern.

func (*Inventory) DeviceByBaseTopic

func (i *Inventory) DeviceByBaseTopic(baseTopic string) *Device

DeviceByBaseTopic returns the first device that has the matching base topic.

func (*Inventory) Discover

func (i *Inventory) Discover(pattern string, timeout time.Duration) ([]*Device, error)

Discover will request the list of parameters from all devices matching the supplied glob pattern. The inventory is updated with the reported parameters and a list of answering devices is returned.

func (*Inventory) FilterDevices

func (i *Inventory) FilterDevices(pattern string) []*Device

FilterDevices will return a list of devices that have a name matching the supplied glob pattern.

func (*Inventory) GetParams

func (i *Inventory) GetParams(pattern, param string, timeout time.Duration) ([]*Device, error)

GetParams will request specified parameter from all devices matching the supplied glob pattern. The inventory is updated with the reported value and a list of answering devices is returned.

func (*Inventory) Monitor

func (i *Inventory) Monitor(pattern string, quit chan struct{}, timeout time.Duration, callback func(*Device, *fleet.Heartbeat)) error

Monitor will monitor the devices that match the supplied glob pattern and update the inventory accordingly. The specified callback is called for every heartbeat with the update device and the heartbeat available at device.LastHeartbeat.

func (*Inventory) Ping

func (i *Inventory) Ping(pattern string, timeout time.Duration) error

Ping will send a ping message to all devices matching the supplied glob pattern.

func (*Inventory) Record

func (i *Inventory) Record(pattern string, quit chan struct{}, timeout time.Duration, callback func(*Device, string)) error

Record will enable log recording mode and yield the received log messages until the provided channel has been closed.

func (*Inventory) Save

func (i *Inventory) Save(path string) error

Save will write the inventory file to the specified path.

func (*Inventory) Send

func (i *Inventory) Send(pattern, topic, message string, timeout time.Duration) error

Send will send a message to all devices matching the supplied glob pattern.

func (*Inventory) SetParams

func (i *Inventory) SetParams(pattern, param, value string, timeout time.Duration) ([]*Device, error)

SetParams will set the specified parameter on all devices matching the supplied glob pattern. The inventory is updated with the saved value and a list of updated devices is returned.

func (*Inventory) UnsetParams

func (i *Inventory) UnsetParams(pattern, param string, timeout time.Duration) ([]*Device, error)

UnsetParams will unset the specified parameter on all devices matching the supplied glob pattern. The inventory is updated with the removed value and a list of updated devices is returned.

func (*Inventory) Update

func (i *Inventory) Update(version, pattern string, firmware []byte, jobs int, timeout time.Duration, callback func(*Device, *fleet.UpdateStatus)) error

Update will update the devices that match the supplied glob pattern with the specified image. The specified callback is called for every change in state or progress.

type Project

type Project struct {
	Location  string
	Inventory *Inventory
}

A Project is a project available on disk.

func CreateProject

func CreateProject(path string, force, cmake bool, out io.Writer) (*Project, error)

CreateProject will initialize a project in the specified directory. If out is not nil, it will be used to log information about the process.

func OpenProject

func OpenProject(path string) (*Project, error)

OpenProject will open the project in the specified path.

func (*Project) Attach

func (p *Project) Attach(device string, out io.Writer, in io.Reader) error

Attach will attach to the attached device.

func (*Project) Build

func (p *Project) Build(overrides map[string]string, clean, reconfigure, appOnly bool, out io.Writer) error

Build will build the project.

func (*Project) BuildTrace added in v0.10.0

func (p *Project) BuildTrace(cpuCore, baudRate string, clean, reconfigure, appOnly bool, out io.Writer) error

BuildTrace will build the project with tracing enabled.

func (*Project) Config added in v0.8.0

func (p *Project) Config(file, device string, out io.Writer) error

Config will write settings and parameters to an attached device.

func (*Project) Debug

func (p *Project) Debug(pattern string, delete bool, duration time.Duration, out io.Writer) error

Debug will request coredumps from the devices that match the supplied glob pattern. The coredumps are saved to the 'debug' directory in the project.

func (*Project) Exec added in v0.10.0

func (p *Project) Exec(cmd string, out io.Writer, in io.Reader) error

Exec will execute a command withing the tree.

func (*Project) Flash

func (p *Project) Flash(device, baudRate string, erase bool, appOnly, alt bool, out io.Writer) error

Flash will flash the project to the attached device.

func (*Project) Format

func (p *Project) Format(out io.Writer) error

Format will format all source files in the project if 'clang-format' is available.

func (*Project) Install

func (p *Project) Install(force bool, out io.Writer) error

Install will download necessary dependencies. Any existing dependencies will be removed if force is set to true. If out is not nil, it will be used to log information about the process.

func (*Project) SaveInventory

func (p *Project) SaveInventory() error

SaveInventory will save the associated inventory to disk.

func (*Project) Tree

func (p *Project) Tree() string

Tree returns the internal directory used to store the toolchain, development framework and other necessary files.

func (*Project) Update

func (p *Project) Update(version, pattern string, jobs int, timeout time.Duration, callback func(*Device, *fleet.UpdateStatus)) error

Update will update the devices that match the supplied glob pattern with the previously built image. The specified callback is called for every change in state or progress.

Jump to

Keyboard shortcuts

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