Documentation ¶
Index ¶
- func BaseTopics(devices []*Device) []string
- type Component
- type Device
- type Frameworks
- type Inventory
- func (i *Inventory) Collect(duration time.Duration) ([]*Device, error)
- func (i *Inventory) Debug(pattern string, delete bool, duration time.Duration) (map[*Device][]byte, error)
- func (i *Inventory) DeviceByBaseTopic(baseTopic string) *Device
- func (i *Inventory) Discover(pattern string, timeout time.Duration) ([]*Device, error)
- func (i *Inventory) FilterDevices(pattern string) []*Device
- func (i *Inventory) GetParams(pattern, param string, timeout time.Duration) ([]*Device, error)
- func (i *Inventory) Monitor(pattern string, quit chan struct{}, timeout time.Duration, ...) error
- func (i *Inventory) Ping(pattern string, timeout time.Duration) error
- func (i *Inventory) Record(pattern string, quit chan struct{}, timeout time.Duration, ...) error
- func (i *Inventory) Save(path string) error
- func (i *Inventory) Send(pattern, topic, message string, timeout time.Duration) error
- func (i *Inventory) SetParams(pattern, param, value string, timeout time.Duration) ([]*Device, error)
- func (i *Inventory) UnsetParams(pattern, param string, timeout time.Duration) ([]*Device, error)
- func (i *Inventory) Update(version, pattern string, firmware []byte, jobs int, timeout time.Duration, ...) error
- type Project
- func (p *Project) Attach(device string, out io.Writer, in io.Reader) error
- func (p *Project) Build(overrides map[string]string, clean, reconfigure, appOnly bool, out io.Writer) error
- func (p *Project) BuildTrace(cpuCore, baudRate string, clean, reconfigure, appOnly bool, out io.Writer) error
- func (p *Project) Config(file, device string, out io.Writer) error
- func (p *Project) Debug(pattern string, delete bool, duration time.Duration, out io.Writer) error
- func (p *Project) Exec(cmd string, out io.Writer, in io.Reader) error
- func (p *Project) Flash(device, baudRate string, erase bool, appOnly, alt bool, out io.Writer) error
- func (p *Project) Format(out io.Writer) error
- func (p *Project) Install(force bool, out io.Writer) error
- func (p *Project) SaveInventory() error
- func (p *Project) Tree() string
- func (p *Project) Update(version, pattern string, jobs int, timeout time.Duration, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseTopics ¶ added in v0.8.0
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 ReadInventory ¶
ReadInventory will attempt to read the inventory file at the specified path.
func (*Inventory) Collect ¶
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 ¶
DeviceByBaseTopic returns the first device that has the matching base topic.
func (*Inventory) Discover ¶
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 ¶
FilterDevices will return a list of devices that have a name matching the supplied glob pattern.
func (*Inventory) GetParams ¶
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 ¶
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) Send ¶
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 ¶
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 ¶
A Project is a project available on disk.
func CreateProject ¶
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 ¶
OpenProject will open the project in the specified path.
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
Config will write settings and parameters to an attached device.
func (*Project) Debug ¶
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) 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 ¶
Format will format all source files in the project if 'clang-format' is available.
func (*Project) Install ¶
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 ¶
SaveInventory will save the associated inventory to disk.
func (*Project) Tree ¶
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.