fleet

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: 8 Imported by: 0

Documentation

Overview

Package fleet provides a low-level implementation of the NAOS fleet management protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(url string, baseTopics []string, delete bool, duration time.Duration) (map[string][]byte, error)

Debug will request coredump debug information from the specified devices.

func Discover

func Discover(url string, baseTopics []string, timeout time.Duration) (map[string][]string, error)

Discover will connect to the specified MQTT broker and publish the 'discover' command to receive a list of available parameters.

func GetParams

func GetParams(url, param string, baseTopics []string, timeout time.Duration) (map[string]string, error)

GetParams will connect to the specified MQTT broker and publish the 'get' command to receive the provided parameter for all specified base topics.

func Monitor

func Monitor(url string, baseTopics []string, quit chan struct{}, timeout time.Duration, cb func(*Heartbeat)) error

Monitor will connect to the specified MQTT broker and listen on the passed base topics for heartbeats and call the supplied callback until the specified quit channel is closed.

Note: Not correctly formatted heartbeats are ignored.

func Record

func Record(url string, baseTopics []string, quit chan struct{}, timeout time.Duration, cb func(*LogMessage)) error

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

func Send

func Send(url string, topics []string, message string, timeout time.Duration) error

Send will send a message to all provided topics.

func SetParams

func SetParams(url, param, value string, baseTopics []string, timeout time.Duration) (map[string]string, error)

SetParams will connect to the specified MQTT broker and publish the 'set' command to receive the provided updated parameter for all specified base topics.

func UnsetParams

func UnsetParams(url, param string, baseTopics []string, timeout time.Duration) error

UnsetParams will connect to the specified MQTT broker and publish the 'unset' command to unset the provided parameter for all specified base topics.

func Update

func Update(url string, baseTopics []string, firmware []byte, jobs int, timeout time.Duration, callback func(string, *UpdateStatus)) error

Update will concurrently perform a firmware update and block until all devices have updated or returned errors. If a callback is provided it will be called with the current status of the update.

Types

type Announcement

type Announcement struct {
	ReceivedAt      time.Time
	BaseTopic       string
	DeviceName      string
	DeviceType      string
	FirmwareVersion string
}

An Announcement is returned by Collect.

func Collect

func Collect(url string, duration time.Duration) ([]*Announcement, error)

Collect will collect Announcements from devices by connecting to the provided MQTT broker and sending the 'collect' command.

Note: Not correctly formatted announcements are ignored.

type Heartbeat

type Heartbeat struct {
	ReceivedAt      time.Time
	BaseTopic       string
	DeviceName      string
	DeviceType      string
	FirmwareVersion string
	FreeHeapSize    int64
	UpTime          time.Duration
	StartPartition  string
	BatteryLevel    float64 // -1, 0 - 1
	SignalStrength  int64   // -50 - -100
	CPU0Usage       float64 // 0 - 1
	CPU1Usage       float64 // 0 - 1
}

A Heartbeat is emitted by Monitor.

type LogMessage

type LogMessage struct {
	BaseTopic string
	Content   string
}

LogMessage is emitted by Record.

type UpdateStatus

type UpdateStatus struct {
	Progress float64
	Error    error
}

UpdateStatus is emitted by updateOne and Update.

Jump to

Keyboard shortcuts

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