client

package
v0.0.0-...-94bc3c9 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Overview

Package client contains utilties for creating Simple IoT clients.

A Simple IoT Client contains the logic for nodes described in the Simple IoT graph store. Examples of built in clients include: Modbus, 1-wire, Upstream, etc.

A client Manager is used to watch the Simple IoT store and create and update new clients as they are created and modified.

See Client and NewManager for ideas on how to get started with your own client.

When debugging client test code, it can be very useful to dump the node tree for inspection. This can be done with the following code:

nodes, err := client.ExportNodes(nc, "root")
if err != nil {
	t.Fatal("Error exporting nodes: ", err)
}

fmt.Println(string(nodes))

This package also contains a number of utility functions for interacting with the Simple IoT NATS API.

Index

Examples

Constants

View Source
const BatchSizeLimit = 1000000

BatchSizeLimit is the largest number of points generated per batch. If the number of points to be generated by a SignalGenerator exceed this limit, the remaining points will be dropped and generated wave signals may experience a phase shift.

View Source
const InfluxMeasurement = "points"

InfluxMeasurement is the Influx measurement to which all points are written

View Source
const NTPConfigPath = "/etc/systemd/timesyncd.conf.d/simpleiot.conf"

NTPConfigPath points to the systemd-timesyncd configuration file

View Source
const RescanTimeoutSeconds = 10

RescanTimeoutSeconds is the maximum number of seconds since LastScan that can elapse before scanning for access points is requested

Variables

View Source
var ErrCobsDecodeError = errors.New("COBS decode error")

ErrCobsDecodeError indicates we got an error decoding a COBS packet

View Source
var ErrCobsLeftoverBufferFull = errors.New("COBS leftover buffer too full")

ErrCobsLeftoverBufferFull indicates our leftover buffer is too full to process

View Source
var ErrCobsTooMuchData = errors.New("COBS decode: too much data without null")

ErrCobsTooMuchData indicates we received too much data without a null in it to delineate packets

Functions

func AdminStoreMaint

func AdminStoreMaint(nc *nats.Conn) error

AdminStoreMaint can be used fix store issues

func AdminStoreVerify

func AdminStoreVerify(nc *nats.Conn) error

AdminStoreVerify can be used verify the store

func DecodeEdgePointsMsg

func DecodeEdgePointsMsg(msg *nats.Msg) (string, string, []data.Point, error)

DecodeEdgePointsMsg decodes NATS message into node ID and points returns nodeID, parentID, points, error

func DecodeNodePointsMsg

func DecodeNodePointsMsg(msg *nats.Msg) (string, []data.Point, error)

DecodeNodePointsMsg decodes NATS message into node ID and points

func DecodeUpEdgePointsMsg

func DecodeUpEdgePointsMsg(msg *nats.Msg) (string, string, string, []data.Point, error)

DecodeUpEdgePointsMsg decodes NATS message into node ID and points returns upID, nodeID, parentID, points, error

func DecodeUpNodePointsMsg

func DecodeUpNodePointsMsg(msg *nats.Msg) (string, string, []data.Point, error)

DecodeUpNodePointsMsg decodes NATS message into node ID and points returns upID, nodeID, points, error

func DeleteNode

func DeleteNode(nc *nats.Conn, id, parent string, origin string) error

DeleteNode removes a node from the specified parent node

func Dump

func Dump(nc *nats.Conn, msg *nats.Msg) error

Dump converts displays a NATS message

func DuplicateNode

func DuplicateNode(nc *nats.Conn, id, newParent, origin string) error

DuplicateNode is used to Duplicate a node and all its children

func EdgeConnect

func EdgeConnect(eo EdgeOptions) (*nats.Conn, error)

EdgeConnect is a function that attempts connections for edge devices with appropriate timeouts, backups, etc. Currently set to disconnect if we don't have a connection after 6m, and then exp backup to try to connect every 6m after that.

func ExpBackoff

func ExpBackoff(attempts int, max time.Duration) time.Duration

ExpBackoff calculates an exponential time backup to max duration + a random fraction of 1s

func ExportNodes

func ExportNodes(nc *nats.Conn, id string) ([]byte, error)

ExportNodes is used to export nodes at a particular location to YAML The YAML format looks like:

nodes:
- id: inst1
  type: device
  parent: root
  points:
  - type: versionApp
  children:
  - id: d7f5bbe9-a300-4197-93fa-b8e5e07f683a
    type: user
    parent: inst1
    points:
    - type: firstName
      text: admin
    - type: lastName
      text: user
    - type: phone
    - type: email
      text: admin
    - type: pass
      text: admin

Key="0" and Tombstone points with value set to 0 are removed from the export to make it easier to read.

func GetNatsURI

func GetNatsURI(nc *nats.Conn) (string, string, error)

GetNatsURI returns the nats URI and auth token for the SIOT server this can be used to set up new NATS connections with different requirements (no echo, etc) return URI, authToken, error

func GetNodes

func GetNodes(nc *nats.Conn, parent, id, typ string, includeDel bool) ([]data.NodeEdge, error)

GetNodes over NATS. Maps to the `p.<id>.<parent>` NATS API. Returns data.ErrDocumentNotFound if node is not found. If parent is set to "none", the edge details are not included and the hash is blank. If parent is set to "all", then all living instances of the node are returned. If parent is set and id is "all", then all child nodes are returned. Parent can be set to "root" and id to "all" to fetch the root node(s).

func GetNodesForUser

func GetNodesForUser(nc *nats.Conn, userID string) ([]data.NodeEdge, error)

GetNodesForUser gets all nodes for a user

func GetNodesType

func GetNodesType[T any](nc *nats.Conn, parent, id string) ([]T, error)

GetNodesType gets node of a custom type. id and parent work the same as GetNodes Deleted nodes are not included.

func GetRootNode

func GetRootNode(nc *nats.Conn) (data.NodeEdge, error)

GetRootNode returns the root node of the instance

func ImportNodes

func ImportNodes(nc *nats.Conn, parent string, yamlData []byte, origin string, preserveIDs bool) error

ImportNodes is used to import nodes at a location in YAML format. New IDs are generated for all nodes unless preserve IDs is set to true. If there multiple references to the same ID, then an attempt is made to replace all of these with the new ID. This also allows you to use "friendly" ID names in hand generated YAML files.

func ListenForFile

func ListenForFile(nc *nats.Conn, dir, deviceID string, callback func(path string)) error

ListenForFile listens for a file sent from server. dir is the directly to place downloaded files.

func Log

func Log(natsServer, authToken string)

Log all nats messages. This function does not block and does not clean up after itself.

func MirrorNode

func MirrorNode(nc *nats.Conn, id, newParent, origin string) error

MirrorNode adds a an existing node to a new parent. A node can have multiple parents.

func MoveNode

func MoveNode(nc *nats.Conn, id, oldParent, newParent, origin string) error

MoveNode moves a node from one parent to another

func NatsSendFileFromHTTP

func NatsSendFileFromHTTP(nc *nats.Conn, deviceID string, url string, callback func(int)) error

NatsSendFileFromHTTP fetchs a file using http and sends via nats. Callback provides % complete (0-100).

func NodeWatcher

func NodeWatcher[T any](nc *nats.Conn, id, parent string) (get func() T, stop func(), err error)

NodeWatcher creates a node watcher. update() is called any time there is an update. Stop can be called to stop the watcher. get() can be called to get the current value.

func ReplaceIDs

func ReplaceIDs(nodes *data.NodeEdgeChildren, parent string)

ReplaceIDs is used to replace IDs tree of nodes. If there multiple references to the same ID, then an attempt is made to replace all of these with the new ID. This function modifies the tree that is passed in. Replace IDs also updates the partent fields.

func SendEdgePoint

func SendEdgePoint(nc *nats.Conn, nodeID, parentID string, point data.Point, ack bool) error

SendEdgePoint sends a edge point using the nats protocol

func SendEdgePoints

func SendEdgePoints(nc *nats.Conn, nodeID, parentID string, points data.Points, ack bool) error

SendEdgePoints sends points using the nats protocol

func SendFile

func SendFile(nc *nats.Conn, deviceID string, reader io.Reader, name string, callback func(int)) error

SendFile can be used to send a file to a device. Callback provides bytes transferred.

func SendNode

func SendNode(nc *nats.Conn, node data.NodeEdge, origin string) error

SendNode is used to send a node to a nats server. Can be used to create nodes.

func SendNodePoint

func SendNodePoint(nc *nats.Conn, nodeID string, point data.Point, ack bool) error

SendNodePoint sends a node point using the nats protocol

func SendNodePoints

func SendNodePoints(nc *nats.Conn, nodeID string, points data.Points, ack bool) error

SendNodePoints sends node points using the nats protocol

func SendNodeType

func SendNodeType[T any](nc *nats.Conn, node T, origin string) error

SendNodeType is used to send a node to a nats server. Can be used to create nodes.

func SendPoints

func SendPoints(nc *nats.Conn, subject string, points data.Points, ack bool) error

SendPoints sends points to specified subject

func SerialDecode

func SerialDecode(d []byte) (byte, string, []byte, error)

SerialDecode can be used to decode serial data in a client. returns seq, subject, payload

func SerialEncode

func SerialEncode(seq byte, subject string, points data.Points) ([]byte, error)

SerialEncode can be used in a client to encode points sent over a serial link.

func String

func String(nc *nats.Conn, msg *nats.Msg) (string, error)

String converts a NATS message to a string

func SubjectEdgeAllPoints

func SubjectEdgeAllPoints() string

SubjectEdgeAllPoints provides subject for all edge points for any node

func SubjectEdgePoints

func SubjectEdgePoints(nodeID, parentID string) string

SubjectEdgePoints constructs a NATS subject for edge points

func SubjectNodeAllPoints

func SubjectNodeAllPoints() string

SubjectNodeAllPoints provides subject for all points for any node

func SubjectNodeHRPoints

func SubjectNodeHRPoints(nodeID string) string

SubjectNodeHRPoints constructs a NATS subject for high rate node points

func SubjectNodePoints

func SubjectNodePoints(nodeID string) string

SubjectNodePoints constructs a NATS subject for node points

func SubscribeEdgePoints

func SubscribeEdgePoints(nc *nats.Conn, id, parent string, callback func(points []data.Point)) (stop func(), err error)

SubscribeEdgePoints subscripts to edge point updates for a node and executes a callback when new points arrive. stop() can be called to clean up the subscription

func SubscribePoints

func SubscribePoints(nc *nats.Conn, id string, callback func(points []data.Point)) (stop func(), err error)

SubscribePoints subscripts to point updates for a node and executes a callback when new points arrive. stop() can be called to clean up the subscription

func UserCheck

func UserCheck(nc *nats.Conn, email, pass string) ([]data.NodeEdge, error)

UserCheck sends a nats message to check auth of user This function returns user nodes and a JWT node which includes a token

Types

type AccessPoint

type AccessPoint struct {
	SSID     string `json:"ssid"`
	BSSID    string `json:"bssid"`
	Strength uint8  `json:"strength"`
	Flags    uint32 `json:"flags"`
	WPAFlags uint32 `json:"wpaFlags"`
	RSNFlags uint32 `json:"rsnFlags"`
}

AccessPoint describes a network access point

func ResolveAccessPoint

func ResolveAccessPoint(ap nm.AccessPoint) (apOut AccessPoint, err error)

ResolveAccessPoint returns an AccessPoint from a NetworkManager AccessPoint

func (AccessPoint) MarshallJSON

func (ap AccessPoint) MarshallJSON() ([]byte, error)

MarshallJSON returns a JSON representation of the AP

type Action

type Action struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
	Disabled    bool   `point:"disabled"`
	Active      bool   `point:"active"`
	Error       string `point:"error"`
	// Action: notify, setValue, playAudio
	Action    string `point:"action"`
	NodeID    string `point:"nodeID"`
	PointType string `point:"pointType"`
	PointKey  string `point:"pointKey"`
	// PointType: number, text, onOff
	ValueType string  `point:"valueType"`
	Value     float64 `point:"value"`
	ValueText string  `point:"valueText"`
	// the following are used for audio playback
	PointChannel  int    `point:"pointChannel"`
	PointDevice   string `point:"pointDevice"`
	PointFilePath string `point:"pointFilePath"`
}

Action defines actions that can be taken if a rule is active.

func (Action) String

func (a Action) String() string

type ActionInactive

type ActionInactive struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
	Active      bool   `point:"active"`
	// Action: notify, setValue, playAudio
	Action    string `point:"action"`
	NodeID    string `point:"nodeID"`
	PointType string `point:"pointType"`
	PointKey  string `point:"pointKey"`
	// PointType: number, text, onOff
	ValueType string  `point:"valueType"`
	Value     float64 `point:"value"`
	ValueText string  `point:"valueText"`
	// the following are used for audio playback
	PointChannel  int    `point:"pointChannel"`
	PointDevice   string `point:"pointDevice"`
	PointFilePath string `point:"pointFilePath"`
}

ActionInactive defines actions that can be taken if a rule is inactive. this is defined for use with the client.SendNodeType API

type CanBus

type CanBus struct {
	ID                  string `node:"id"`
	Parent              string `node:"parent"`
	Description         string `point:"description"`
	Device              string `point:"device"`
	BitRate             string `point:"bitRate"`
	MsgsInDb            int    `point:"msgsInDb"`
	SignalsInDb         int    `point:"signalsInDb"`
	MsgsRecvdDb         int    `point:"msgsRecvdDb"`
	MsgsRecvdDbReset    bool   `point:"msgsRecvdDbReset"`
	MsgsRecvdOther      int    `point:"msgsRecvdOther"`
	MsgsRecvdOtherReset bool   `point:"msgsRecvdOtherReset"`
	Databases           []File `child:"file"`
}

CanBus represents a CAN socket config. The name matches the front-end node type "canBus" to link the two so that when a canBus node is created on the frontend the client manager knows to start a CanBus client.

type CanBusClient

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

CanBusClient is a SIOT client used to communicate on a CAN bus

func (*CanBusClient) EdgePoints

func (cb *CanBusClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*CanBusClient) Points

func (cb *CanBusClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*CanBusClient) Run

func (cb *CanBusClient) Run() error

Run the main logic for this client and blocks until stopped There are several main aspects of the CAN bus client

  • the listener function is a process that recieves CAN bus frames from the Linux SocketCAN socket and sends the frames out on the canMsgRx channel

  • when a frame is recieved on the canMsgRx channel in the main loop, it is decoded and a point is sent out for each canparse.Signal in the frame. The key of each point contains the message name, signal name, and signal units

func (*CanBusClient) Stop

func (cb *CanBusClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type Client

type Client interface {
	RunStop

	Points(string, []data.Point)
	EdgePoints(string, string, []data.Point)
}

Client interface describes methods a Simple Iot client must implement. This is to be kept as simple as possible, and the ClientManager does all the heavy lifting of interacting with the rest of the SIOT system. Run should block until Stop is called. Run MUST return when Stop is called. Stop does not block -- wait until Run returns if you need to know the client is stopped. Points and EdgePoints are called when there are updates to the client node. The client Manager filters out all points with Origin set to "" because it assumes the point was generated by the client and the client already knows about it. Thus, if you want points to get to a client, Origin must be set.

func NewCanBusClient

func NewCanBusClient(nc *nats.Conn, config CanBus) Client

NewCanBusClient returns a new CanBusClient with a NATS connection and a config

func NewDbClient

func NewDbClient(nc *nats.Conn, config Db) Client

NewDbClient ...

func NewFileClient

func NewFileClient(nc *nats.Conn, config File) Client

NewFileClient ...

func NewMetricsClient

func NewMetricsClient(nc *nats.Conn, config Metrics) Client

NewMetricsClient ...

func NewNTPClient

func NewNTPClient(nc *nats.Conn, config NTP) Client

NewNTPClient returns a new NTPClient using its configuration read from the Client Manager

func NewNetworkManagerClient

func NewNetworkManagerClient(nc *nats.Conn, config NetworkManager) Client

NewNetworkManagerClient returns a new NetworkManagerClient using its configuration read from the Client Manager

func NewParticleClient

func NewParticleClient(nc *nats.Conn, config Particle) Client

NewParticleClient ...

func NewRuleClient

func NewRuleClient(nc *nats.Conn, config Rule) Client

NewRuleClient constructor ...

func NewSerialDevClient

func NewSerialDevClient(nc *nats.Conn, config SerialDev) Client

NewSerialDevClient ...

func NewShellyClient

func NewShellyClient(nc *nats.Conn, config Shelly) Client

NewShellyClient ...

func NewShellyIOClient

func NewShellyIOClient(nc *nats.Conn, config ShellyIo) Client

NewShellyIOClient ...

func NewSignalGeneratorClient

func NewSignalGeneratorClient(nc *nats.Conn, config SignalGenerator) Client

NewSignalGeneratorClient ...

func NewSyncClient

func NewSyncClient(nc *nats.Conn, config Sync) Client

NewSyncClient constructor

func NewUpdateClient

func NewUpdateClient(nc *nats.Conn, config Update) Client

NewUpdateClient ...

type CobsWrapper

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

CobsWrapper can be used to wrap an io.ReadWriteCloser to COBS encode/decode data

func NewCobsWrapper

func NewCobsWrapper(dev io.ReadWriteCloser, maxMessageLength int) *CobsWrapper

NewCobsWrapper creates a new cobs wrapper

func (*CobsWrapper) Close

func (cw *CobsWrapper) Close() error

Close the device wrapped.

func (*CobsWrapper) Read

func (cw *CobsWrapper) Read(b []byte) (int, error)

Read a COBS encoded data stream. The stream may optionally start with one or more NULL bytes and must end with a NULL byte. This Read blocks until we get an entire packet or an error. b must be large enough to hold the entire packet.

func (*CobsWrapper) SetDebug

func (cw *CobsWrapper) SetDebug(debug int)

SetDebug sets the debug level. If >= 9, then it dumps the raw data received.

func (*CobsWrapper) Write

func (cw *CobsWrapper) Write(b []byte) (int, error)

type Condition

type Condition struct {
	// general parameters
	ID            string  `node:"id"`
	Parent        string  `node:"parent"`
	Description   string  `point:"description"`
	Disabled      bool    `point:"disabled"`
	ConditionType string  `point:"conditionType"`
	MinActive     float64 `point:"minActive"`
	Active        bool    `point:"active"`
	Error         string  `point:"error"`

	// used with point value rules
	NodeID     string  `point:"nodeID"`
	PointType  string  `point:"pointType"`
	PointKey   string  `point:"pointKey"`
	PointIndex int     `point:"pointIndex"`
	ValueType  string  `point:"valueType"`
	Operator   string  `point:"operator"`
	Value      float64 `point:"value"`
	ValueText  string  `point:"valueText"`

	// used with shedule rules
	Start    string   `point:"start"`
	End      string   `point:"end"`
	Weekdays []bool   `point:"weekday"`
	Dates    []string `point:"date"`
}

Condition defines parameters to look for in a point or a schedule.

func (Condition) String

func (c Condition) String() string

type Db

type Db struct {
	ID            string   `node:"id"`
	Parent        string   `node:"parent"`
	Description   string   `point:"description"`
	URI           string   `point:"uri"`
	Org           string   `point:"org"`
	Bucket        string   `point:"bucket"`
	AuthToken     string   `point:"authToken"`
	TagPointTypes []string `point:"tagPointType"`
}

Db represents the configuration for a SIOT DB client

type DbClient

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

DbClient is a SIOT database client

func (*DbClient) EdgePoints

func (dbc *DbClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*DbClient) Points

func (dbc *DbClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*DbClient) Run

func (dbc *DbClient) Run() error

Run runs the main logic for this client and blocks until stopped

func (*DbClient) Stop

func (dbc *DbClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type Destination

type Destination struct {
	// NodeID indicating the destination for points; if not specified, the point
	// destination is determined by the Parent field
	NodeID string `point:"nodeID"`
	// Parent is set if points should be sent to the parent node; otherwise,
	// points are send to the origin node.
	Parent bool `point:"parent"`
	// HighRate indicates that points should be sent over the phrup NATS
	// subject. If set, points are never sent to the origin node; rather, it is
	// implied that points will be sent to the NodeID (if set) or the parent
	// node.
	HighRate bool `point:"highRate"`
	// PointType indicates the point type for generated points
	PointType string `point:"pointType"`
	// PointKey indicates the point key for generated points
	PointKey string `point:"pointKey"`
}

Destination indicates the destination for generated points, including the point type and key

func (Destination) Subject

func (sd Destination) Subject(originID string, parentID string) string

Subject returns the NATS subject on which points for this Destination shall be published

type Device

type Device struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
}

Device represents the instance SIOT is running on

type EdgeOptions

type EdgeOptions struct {
	URI          string
	AuthToken    string
	NoEcho       bool
	Connected    func()
	Disconnected func()
	Reconnected  func()
	Closed       func()
}

EdgeOptions describes options for connecting edge devices

type File

type File struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
	Name        string `point:"name"`
	Data        string `point:"data"`
	Size        string `point:"size"`
	Binary      bool   `point:"binary"`
	Hash        string `point:"hash"`
}

File represents a file that a user uploads or is present in some location

func (*File) GetContents

func (f *File) GetContents() ([]byte, error)

GetContents reads the file contents and does any decoding necessary if it is a binary file

type FileClient

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

FileClient is used to manage files

func (*FileClient) EdgePoints

func (f *FileClient) EdgePoints(
	_ string, _ string, _ []data.Point,
)

EdgePoints is called when the client's node edge points are updated

func (*FileClient) Points

func (f *FileClient) Points(nodeID string, points []data.Point)

Points is called when the client's node points are updated

func (*FileClient) Run

func (f *FileClient) Run() error

Run the main logic for the file client

func (*FileClient) Stop

func (f *FileClient) Stop(error)

Stop stops the File Client

type Group

type Group struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
}

Group represents a group node

type IPv4Address

type IPv4Address string

IPv4Address is a string representation of an IPv4 address

func IPv4AddressUint32

func IPv4AddressUint32(n uint32, order binary.ByteOrder) IPv4Address

IPv4AddressUint32 converts an IPv4 address in uint32 format to a string

func (IPv4Address) String

func (addr IPv4Address) String() string

String returns the underlying string

func (IPv4Address) Uint32

func (addr IPv4Address) Uint32(order binary.ByteOrder) uint32

Uint32 convert an IPv4 address in string format to a uint32

func (IPv4Address) Valid

func (addr IPv4Address) Valid() bool

Valid returns true if string is valid IPv4 address

type IPv4Config

type IPv4Config struct {
	StaticIP   bool        `json:"staticIP" point:"staticIP"`
	Address    IPv4Address `json:"address" point:"address"`
	Netmask    IPv4Netmask `json:"netmask" point:"netmask"`
	Gateway    IPv4Address `json:"gateway" point:"gateway"`
	DNSServer1 IPv4Address `json:"dnsServer1" point:"dnsServer1"`
	DNSServer2 IPv4Address `json:"dnsServer2" point:"dnsServer2"`
}

IPv4Config defines data for IPv4 config

func ResolveIPv4Config

func ResolveIPv4Config(settings map[string]any) IPv4Config

ResolveIPv4Config creates a new IPv4Config from a map of D-Bus settings

func (IPv4Config) DBus

func (c IPv4Config) DBus() map[string]any

DBus returns the IPv4 settings in a generic map to be sent over D-Bus See https://developer-old.gnome.org/NetworkManager/stable/settings-ipv4.html

func (IPv4Config) Equal

func (c IPv4Config) Equal(c2 IPv4Config) bool

Equal returns true if and only if the two IPv4Config structs are equivalent

func (IPv4Config) Method

func (c IPv4Config) Method() string

Method returns the IP configuration method (i.e. "auto" or "manual")

type IPv4Netmask

type IPv4Netmask IPv4Address

IPv4Netmask is a string representation of an IPv4 netmask

func IPv4NetmaskPrefix

func IPv4NetmaskPrefix(prefix uint8) IPv4Netmask

IPv4NetmaskPrefix converts an integer IPv4 prefix to netmask string

func (IPv4Netmask) Prefix

func (str IPv4Netmask) Prefix() uint32

Prefix converts a subnet mask string to IPv4 prefix

func (IPv4Netmask) Valid

func (str IPv4Netmask) Valid() bool

Valid returns true if subnet mask in dot notation is valid

type IPv6Address

type IPv6Address string

IPv6Address is a string representation of an IPv4 address

func NewIPv6Address

func NewIPv6Address(bs []byte) IPv6Address

NewIPv6Address converts an IPv6 address in []byte format to a string

func (IPv6Address) Bytes

func (addr IPv6Address) Bytes() []byte

Bytes convert an IPv6 address in string format to []byte

func (IPv6Address) String

func (addr IPv6Address) String() string

String returns the underlying string

func (IPv6Address) Valid

func (addr IPv6Address) Valid() bool

Valid return true if string is valid IPv6 address

type IPv6Config

type IPv6Config struct {
	StaticIP   bool        `json:"staticIP"`
	Address    IPv6Address `json:"address"`
	Prefix     uint8       `json:"prefix"`
	Gateway    IPv6Address `json:"gateway"`
	DNSServer1 IPv6Address `json:"dnsServer1"`
	DNSServer2 IPv6Address `json:"dnsServer2"`
}

IPv6Config defines data for IPv6 configs

func ResolveIPv6Config

func ResolveIPv6Config(settings map[string]any) IPv6Config

ResolveIPv6Config creates a new IPv6Config from a map of D-Bus settings

func (IPv6Config) DBus

func (c IPv6Config) DBus() map[string]any

DBus returns the IPv6 settings in a generic map to be sent over D-Bus See https://developer-old.gnome.org/NetworkManager/stable/settings-ipv6.html

func (IPv6Config) Equal

func (c IPv6Config) Equal(c2 IPv6Config) bool

Equal returns true if and only if the two IPv6Config structs are equivalent

func (IPv6Config) Method

func (c IPv6Config) Method() string

Method returns the IP configuration method (i.e. "auto" or "manual")

type Manager

type Manager[T any] struct {
	// contains filtered or unexported fields
}

Manager manages a node type, watches for changes, adds/removes instances that get added/deleted

func NewManager

func NewManager[T any](nc *nats.Conn,
	construct func(nc *nats.Conn, config T) Client, parentTypes []string) *Manager[T]

NewManager takes constructor for a node client and returns a Manager for that client The Node Type is inferred from the Go type passed in, so you must name Go client Types to manage the node type definitions. The manager recursively finds nodes that are children of group nodes and the node types found in parentTypes.

Example
Output:

func (*Manager[T]) Run

func (m *Manager[T]) Run() error

Run node manager. This function looks for children of a certain node type. When new nodes are found, the data is decoded into the client type config, and the constructor for the node client is called. This call blocks until Stop is called.

func (*Manager[T]) Stop

func (m *Manager[T]) Stop(_ error)

Stop manager. This also stops all registered clients and causes Start to exit.

type Metric

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

Metric is a type that can be used to track metrics and periodically report them to a node point. Data is queued and averaged and then the average is sent out as a point.

func NewMetric

func NewMetric(nc *nats.Conn, nodeID, pointType string, reportPeriod time.Duration) *Metric

NewMetric creates a new metric

func (*Metric) AddSample

func (m *Metric) AddSample(s float64) error

AddSample adds a sample and reports it if reportPeriod has expired

func (*Metric) SetNodeID

func (m *Metric) SetNodeID(id string)

SetNodeID -- this is a bit of a hack to get around some init issues

type Metrics

type Metrics struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
	Type        string `point:"type"`
	Name        string `point:"name"`
	Period      int    `point:"period"`
}

Metrics represents the config of a metrics node type

type MetricsClient

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

MetricsClient is a SIOT client used to collect system or app metrics

func (*MetricsClient) EdgePoints

func (m *MetricsClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*MetricsClient) Points

func (m *MetricsClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*MetricsClient) Run

func (m *MetricsClient) Run() error

Run the main logic for this client and blocks until stopped

func (*MetricsClient) Stop

func (m *MetricsClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type NTP

type NTP struct {
	ID              string   `node:"id"`
	Parent          string   `node:"parent"`
	Servers         []string `point:"server"`
	FallbackServers []string `point:"fallbackServer"`
}

NTP client configuration

type NTPClient

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

NTPClient is a SimpleIoT client that synchronizes NTP servers to local systemd-timesync configuration

func (*NTPClient) EdgePoints

func (c *NTPClient) EdgePoints(
	_ string, _ string, _ []data.Point,
)

EdgePoints is called when the client's node edge points are updated

func (*NTPClient) Points

func (c *NTPClient) Points(nodeID string, points []data.Point)

Points is called when the client's node points are updated

func (*NTPClient) Run

func (c *NTPClient) Run() error

Run starts the NTP Client

func (*NTPClient) Stop

func (c *NTPClient) Stop(error)

Stop stops the NTP Client

func (*NTPClient) UpdateConfig

func (c *NTPClient) UpdateConfig() error

UpdateConfig writes the NTP configuration to NTPConfigPath and restarts system-timesyncd

type NetworkManager

type NetworkManager struct {
	ID                      string                 `node:"id"`
	Parent                  string                 `node:"parent"`
	Description             string                 `point:"description"`
	Disabled                bool                   `point:"disabled"`
	Hostname                string                 `point:"hostname"`
	RequestWiFiScan         bool                   `point:"requestWiFiScan"`
	NetworkingEnabled       *bool                  `point:"networkingEnabled"`
	WirelessEnabled         *bool                  `point:"wirelessEnabled"`
	WirelessHardwareEnabled *bool                  `point:"wirelessHardwareEnabled"`
	Devices                 []NetworkManagerDevice `child:"networkManagerDevice"`
	Connections             []NetworkManagerConn   `child:"networkManagerConn"`
}

NetworkManager client configuration

type NetworkManagerClient

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

NetworkManagerClient is a SimpleIoT client that manages network interfaces and their connections using NetworkManager via D-Bus. Network connections and device states are synchronized between NetworkManager and the SimpleIoT node tree.

==========================      ======================== ---    device state     --> ==================
| NetworkManager (D-Bus) | <--> | NetworkManagerClient |                             | SimpleIoT Tree |
==========================      ======================== <-- connection settings --> ==================

The NetworkManagerClient only controls SimpleIoT "managed" connections within NetworkManager. Although all connections will be added to the SIOT tree, unmanaged NetworkManager connections will not be updated or deleted by SimpleIoT.

func (*NetworkManagerClient) EdgePoints

func (c *NetworkManagerClient) EdgePoints(
	_ string, _ string, _ []data.Point,
)

EdgePoints is called when the client's node edge points are updated

func (*NetworkManagerClient) Points

func (c *NetworkManagerClient) Points(nodeID string, points []data.Point)

Points is called when the client's node points are updated

func (*NetworkManagerClient) Run

func (c *NetworkManagerClient) Run() error

Run starts the NetworkManager Client. Restarts if `networkManager` nodes or their descendants are added / removed.

func (*NetworkManagerClient) Stop

func (c *NetworkManagerClient) Stop(error)

Stop stops the NetworkManager Client

func (*NetworkManagerClient) SyncConnections

func (c *NetworkManagerClient) SyncConnections() (errs []error, fatal error)

SyncConnections performs a one-way synchronization of the NetworkManagerConn nodes in the SIOT tree with connections in NetworkManager via D-Bus. The sync direction is determined by the connection's Managed flag. If set, the connection in NetworkManager is updated with the data in the SIOT tree; otherwise, the SIOT tree is updated with the data in NetworkManager. Returns a list of errors in the order in which they are encountered. If a fatal error occurs that aborts the sync operation, that will be included in `errs` and returned as `fatal`.

func (*NetworkManagerClient) SyncDevices

func (c *NetworkManagerClient) SyncDevices() (errs []error, fatal error)

SyncDevices performs a one-way synchronization of the devices in NetworkManager with the NetworkManagerDevices nodes in the SIOT tree via D-Bus. Additionally, the NetworkingEnabled and WirelessHardwareEnabled flags are copied to the SIOT tree; the WirelessEnabled flag is copied to NetworkManager if it is non-nil and copied to the SIOT tree if it is nil. Returns a list of errors in the order in which they are encountered. If a fatal error occurs that aborts the sync operation, that will be included in `errs` and returned as `fatal`.

func (*NetworkManagerClient) SyncHostname

func (c *NetworkManagerClient) SyncHostname() (errs []error, fatal error)

SyncHostname writes the hostname from the SimpleIoT tree to NetworkManager; however, if SimpleIoT does not have a hostname set, the current hostname will be stored in the tree instead.

func (*NetworkManagerClient) WifiScan

func (c *NetworkManagerClient) WifiScan() error

WifiScan scans for Wi-Fi access points using available Wi-Fi devices. When scanning is complete, the access points are saved as points on the NetworkManagerDevice node.

type NetworkManagerConn

type NetworkManagerConn struct {
	ID          string `node:"id"` // matches UUID in NetworkManager
	Parent      string `node:"parent"`
	Description string `point:"description"` // matches ID in NetworkManager
	// Type is one of the NetworkManager connection types (i.e. 802-3-ethernet)
	// See https://developer-old.gnome.org/NetworkManager/stable/
	Type string `point:"type"`
	// Managed flag indicates that SimpleIoT is managing this connection.
	// All connections in NetworkManager are added to the SIOT tree, but if a
	// connection is flagged "managed", the SIOT tree is used as the source of
	// truth, and settings are synchronized one-way from SIOT to NetworkManager.
	Managed             bool   `point:"managed"`
	AutoConnect         bool   `point:"autoConnect"`
	AutoConnectPriority int32  `point:"autoConnectPriority"`
	InterfaceName       string `point:"interfaceName"`
	// LastActivated is the timestamp the connection was last activated in
	// seconds since the UNIX epoch. Called "timestamp" in NetworkManager.
	LastActivated uint64     `point:"lastActivated"`
	IPv4Config    IPv4Config `point:"ipv4Config"`
	IPv6Config    IPv6Config `point:"ipv6Config"`
	WiFiConfig    WiFiConfig `point:"wiFiConfig"`
	// Error contains an error message from the last NetworkManager sync or an
	// empty string if sync was successful
	Error string `point:"error"`
}

NetworkManagerConn defines a NetworkManager connection

func ResolveNetworkManagerConn

func ResolveNetworkManagerConn(settings nm.ConnectionSettings) NetworkManagerConn

ResolveNetworkManagerConn returns a NetworkManagerConn from D-Bus settings Note: Secrets must be added to the connection manually

func (NetworkManagerConn) DBus

DBus returns an object that can be passed over D-Bus Returns nil if the connection ID does not include the prefix `SimpleIoT:` See https://developer-old.gnome.org/NetworkManager/stable/ch01.html

func (NetworkManagerConn) Equal

Equal returns true if and only if the two connections will produce the same DBus settings

type NetworkManagerDevice

type NetworkManagerDevice struct {
	ID         string `node:"id"`
	Parent     string `node:"parent"`
	Path       string `point:"path"`
	Interface  string `point:"interface"`
	State      string `point:"state"`
	DeviceType string `point:"deviceType"`
	// ActiveConnectionID
	IPv4Addresses   []IPv4Address `point:"ipv4Addresses"`
	IPv4Netmasks    []IPv4Netmask `point:"ipv4Netmasks"`
	IPv4Gateway     IPv4Address   `point:"ipv4Gateway"`
	IPv4Nameservers []IPv4Address `point:"ipv4Nameservers"`
	IPv6Addresses   []IPv6Address `point:"ipv6Addresses"`
	IPv6Prefixes    []uint8       `point:"ipv6Prefixes"`
	IPv6Gateway     IPv6Address   `point:"ipv6Gateway"`
	IPv6Nameservers []IPv6Address `point:"ipv6Nameservers"`
	HardwareAddress string        `point:"hardwareAddress"`
	Managed         bool
	// Wi-Fi specific properties
	ActiveAccessPoint *AccessPoint `point:"activeAccessPoint"`
	AccessPoints      []string     `point:"accessPoints"` // JSON-encoded strings
}

NetworkManagerDevice is a device managed by NetworkManager

func ResolveDevice

func ResolveDevice(parent string, device nm.Device) (
	dev NetworkManagerDevice, err error,
)

ResolveDevice returns a NetworkManagerDevice from a NetworkManager Device

type NewPoints

type NewPoints struct {
	ID     string
	Parent string
	Points data.Points
}

NewPoints is used to pass new points through channels in client drivers

func (NewPoints) String

func (np NewPoints) String() string

type Particle

type Particle struct {
	ID          string `node:"id"`
	Parent      string `node:"parent"`
	Description string `point:"description"`
	Disabled    bool   `point:"disabled"`
	AuthToken   string `point:"authToken"`
}

Particle represents the configuration for the SIOT Particle client

type ParticleClient

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

ParticleClient is a SIOT particle client

func (*ParticleClient) EdgePoints

func (pc *ParticleClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*ParticleClient) Points

func (pc *ParticleClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*ParticleClient) Run

func (pc *ParticleClient) Run() error

Run runs the main logic for this client and blocks until stopped

func (*ParticleClient) Stop

func (pc *ParticleClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type ParticleEvent

type ParticleEvent struct {
	Data      string    `json:"data"`
	TTL       uint32    `json:"ttl"`
	Timestamp time.Time `json:"published_at"`
	CoreID    string    `json:"coreid"`
}

ParticleEvent from particle

type Rule

type Rule struct {
	ID              string      `node:"id"`
	Parent          string      `node:"parent"`
	Description     string      `point:"description"`
	Disabled        bool        `point:"disabled"`
	Active          bool        `point:"active"`
	Error           string      `point:"error"`
	Conditions      []Condition `child:"condition"`
	Actions         []Action    `child:"action"`
	ActionsInactive []Action    `child:"actionInactive"`
}

Rule represent a rule node config

func (Rule) String

func (r Rule) String() string

type RuleClient

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

RuleClient is a SIOT client used to run rules

func (*RuleClient) EdgePoints

func (rc *RuleClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*RuleClient) Points

func (rc *RuleClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*RuleClient) Run

func (rc *RuleClient) Run() error

Run runs the main logic for this client and blocks until stopped

func (*RuleClient) Stop

func (rc *RuleClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type RunGroup

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

RunGroup is used to group a list of clients and start/stop them currently a thin wrapper around run.Group that adds a Stop() function

func DefaultClients

func DefaultClients(nc *nats.Conn) (*RunGroup, error)

DefaultClients returns an actor for the default group of built in clients

func NewRunGroup

func NewRunGroup(name string) *RunGroup

NewRunGroup creates a new client group

func (*RunGroup) Add

func (g *RunGroup) Add(client RunStop)

Add client to group

func (*RunGroup) Run

func (g *RunGroup) Run() error

Run clients. This function blocks until error or stopped. all clients must be added before runner is started

func (*RunGroup) Stop

func (g *RunGroup) Stop(_ error)

Stop clients

type RunStop

type RunStop interface {
	Run() error
	Stop(error)
}

RunStop is an interface that implements the Run() and Stop() methods. This pattern is used wherever long running processes are required. Warning!!! Stop() may get called after Run() has exitted when using mechanisms like run.Group, so be sure that Stop() never blocks -- it must return for things to work properly.

type SerialDev

type SerialDev struct {
	ID                string `node:"id"`
	Parent            string `node:"parent"`
	Description       string `point:"description"`
	Port              string `point:"port"`
	Baud              string `point:"baud"`
	MaxMessageLength  int    `point:"maxMessageLength"`
	HRDestNode        string `point:"hrDest"`
	SyncParent        bool   `point:"syncParent"`
	Debug             int    `point:"debug"`
	Disabled          bool   `point:"disabled"`
	Log               string `point:"log"`
	Rx                int    `point:"rx"`
	RxReset           bool   `point:"rxReset"`
	Tx                int    `point:"tx"`
	TxReset           bool   `point:"txReset"`
	HrRx              int64  `point:"hrRx"`
	HrRxReset         bool   `point:"hrRxReset"`
	Uptime            int    `point:"uptime"`
	ErrorCount        int    `point:"errorCount"`
	ErrorCountReset   bool   `point:"errorCountReset"`
	ErrorCountHR      int    `point:"errorCountHR"`
	ErrorCountResetHR bool   `point:"errorCountResetHR"`
	Rate              bool   `point:"rate"`
	RateHR            bool   `point:"rate"`
	Connected         bool   `point:"connected"`
	Download          string `point:"download"`
	Progress          int    `point:"progress"`
	Files             []File `child:"file"`
}

SerialDev represents a serial (MCU) config

type SerialDevClient

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

SerialDevClient is a SIOT client used to manage serial devices

func (*SerialDevClient) EdgePoints

func (sd *SerialDevClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*SerialDevClient) Points

func (sd *SerialDevClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*SerialDevClient) Run

func (sd *SerialDevClient) Run() error

Run the main logic for this client and blocks until stopped

func (*SerialDevClient) Stop

func (sd *SerialDevClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type Shelly

type Shelly struct {
	ID          string     `node:"id"`
	Parent      string     `node:"parent"`
	Description string     `point:"description"`
	Disabled    bool       `point:"disabled"`
	IOs         []ShellyIo `child:"shellyIo"`
}

Shelly describes the shelly client config

type ShellyClient

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

ShellyClient is a SIOT particle client

func (*ShellyClient) EdgePoints

func (sc *ShellyClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*ShellyClient) Points

func (sc *ShellyClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*ShellyClient) Run

func (sc *ShellyClient) Run() error

Run runs the main logic for this client and blocks until stopped

func (*ShellyClient) Stop

func (sc *ShellyClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type ShellyGen

type ShellyGen int

ShellyGen describes the generation of device (Gen1/Gen2)

const (
	ShellyGenUnknown ShellyGen = iota
	ShellyGen1
	ShellyGen2
)

Shelly Generations

type ShellyIOClient

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

ShellyIOClient is a SIOT particle client

func (*ShellyIOClient) EdgePoints

func (sioc *ShellyIOClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*ShellyIOClient) Points

func (sioc *ShellyIOClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*ShellyIOClient) Run

func (sioc *ShellyIOClient) Run() error

Run runs the main logic for this client and blocks until stopped

func (*ShellyIOClient) Stop

func (sioc *ShellyIOClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type ShellyIo

type ShellyIo struct {
	ID          string    `node:"id"`
	Parent      string    `node:"parent"`
	Description string    `point:"description"`
	DeviceID    string    `point:"deviceID"`
	Type        string    `point:"type"`
	IP          string    `point:"ip"`
	Value       []float64 `point:"value"`
	ValueSet    []float64 `point:"valueSet"`
	Switch      []bool    `point:"switch"`
	SwitchSet   []bool    `point:"switchSet"`
	Light       []bool    `point:"light"`
	LightSet    []bool    `point:"lightSet"`
	Input       []bool    `point:"input"`
	Offline     bool      `point:"offline"`
	Controlled  bool      `point:"controlled"`
	Disabled    bool      `point:"disabled"`
}

ShellyIo describes the config/state for a shelly io

func (*ShellyIo) Desc

func (sio *ShellyIo) Desc() string

Desc gets the description of a Shelly IO

func (*ShellyIo) Gen

func (sio *ShellyIo) Gen() ShellyGen

Gen returns generation of Shelly device

func (*ShellyIo) GetStatus

func (sio *ShellyIo) GetStatus() (data.Points, error)

GetStatus gets the current status of the device

func (*ShellyIo) IsSettableOnOff

func (sio *ShellyIo) IsSettableOnOff() bool

IsSettableOnOff returns true if the device can be turned on/off

func (*ShellyIo) SetName

func (sio *ShellyIo) SetName(name string) error

SetName is use to set the name in a device

func (*ShellyIo) SetOnOff

func (sio *ShellyIo) SetOnOff(comp string, index int, on bool) (data.Points, error)

SetOnOff sets on/off state of device BulbDuo: http://10.0.0.130/light/0?turn=on PlugUS: http://192.168.33.1/rpc/Switch.Set?id=0&on=true

type SignalGenerator

type SignalGenerator struct {
	ID          string      `node:"id"`
	Parent      string      `node:"parent"`
	Description string      `point:"description"`
	Disabled    bool        `point:"disabled"`
	Destination Destination `point:"destination"`
	Units       string      `point:"units"`
	// SignalType must be one of: "sine", "square", "triangle", or "random walk"
	SignalType string  `point:"signalType"`
	MinValue   float64 `point:"minValue"`
	MaxValue   float64 `point:"maxValue"`
	// InitialValue is the starting value for the signal generator.
	// For random walk, this must be between MinValue and MaxValue. For wave
	// functions, this must be in radians (i.e. between 0 and 2 * Pi).
	InitialValue float64 `point:"initialValue"`
	RoundTo      float64 `point:"roundTo"`
	// SampleRate in Hz.
	SampleRate float64 `point:"sampleRate"`
	// BatchPeriod is the batch timer interval in ms. When the timer fires, it
	// generates a batch of points at the specified SampleRate. If not set,
	// timer will fire for each sample at SampleRate.
	BatchPeriod int `point:"batchPeriod"`
	// Frequency for wave functions (in Hz.)
	Frequency float64 `point:"frequency"`
	// Min./Max. increment amount for random walk function
	MinIncrement float64 `point:"minIncrement"`
	MaxIncrement float64 `point:"maxIncrement"`
	// Current value
	Value float64           `point:"value"`
	Tags  map[string]string `point:"tag"`
}

SignalGenerator config

type SignalGeneratorClient

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

SignalGeneratorClient for signal generator nodes

func (*SignalGeneratorClient) EdgePoints

func (sgc *SignalGeneratorClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*SignalGeneratorClient) Points

func (sgc *SignalGeneratorClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*SignalGeneratorClient) Run

func (sgc *SignalGeneratorClient) Run() error

Run the main logic for this client and blocks until stopped

func (*SignalGeneratorClient) Stop

func (sgc *SignalGeneratorClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type SiotExport

type SiotExport struct {
	Nodes []data.NodeEdgeChildren
}

SiotExport is the format used for exporting and importing data (currently YAML)

type Sync

type Sync struct {
	ID             string `node:"id"`
	Parent         string `node:"parent"`
	Description    string `point:"description"`
	URI            string `point:"uri"`
	AuthToken      string `point:"authToken"`
	Period         int    `point:"period"`
	Disabled       bool   `point:"disabled"`
	SyncCount      int    `point:"syncCount"`
	SyncCountReset bool   `point:"syncCountReset"`
}

Sync represents an sync node config

type SyncClient

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

SyncClient is a SIOT client used to handle upstream connections

func (*SyncClient) EdgePoints

func (up *SyncClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*SyncClient) Points

func (up *SyncClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*SyncClient) Run

func (up *SyncClient) Run() error

Run the main logic for this client and blocks until stopped

func (*SyncClient) Stop

func (up *SyncClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type Update

type Update struct {
	ID              string   `node:"id"`
	Parent          string   `node:"parent"`
	Description     string   `point:"description"`
	VersionOS       string   `point:"versionOS"`
	URI             string   `point:"uri"`
	OSUpdates       []string `point:"osUpdate"`
	DownloadOS      string   `point:"downloadOS"`
	OSDownloaded    string   `point:"osDownloaded"`
	DiscardDownload string   `point:"discardDownload"`
	Prefix          string   `point:"prefix"`
	Directory       string   `point:"directory"`
	PollPeriod      int      `point:"pollPeriod"`
	Refresh         bool     `point:"refresh"`
	AutoDownload    bool     `point:"autoDownload"`
	AutoReboot      bool     `point:"autoReboot"`
}

Update represents the config of a metrics node type

type UpdateClient

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

UpdateClient is a SIOT client used to collect system or app metrics

func (*UpdateClient) EdgePoints

func (m *UpdateClient) EdgePoints(nodeID, parentID string, points []data.Point)

EdgePoints is called by the Manager when new edge points for this node are received.

func (*UpdateClient) Points

func (m *UpdateClient) Points(nodeID string, points []data.Point)

Points is called by the Manager when new points for this node are received.

func (*UpdateClient) Run

func (m *UpdateClient) Run() error

Run the main logic for this client and blocks until stopped

func (*UpdateClient) Stop

func (m *UpdateClient) Stop(_ error)

Stop sends a signal to the Run function to exit

type User

type User struct {
	ID        string `node:"id"`
	Parent    string `node:"parent"`
	FirstName string `point:"firstName"`
	LastName  string `point:"lastName"`
	Phone     string `point:"phone"`
	Email     string `point:"email"`
	Pass      string `point:"pass"`
}

User represents a user node

type Variable

type Variable struct {
	ID           string             `node:"id"`
	Parent       string             `node:"parent"`
	Description  string             `point:"description"`
	VariableType string             `point:"variableType"`
	Value        map[string]float64 `point:"value"`
}

Variable represents the config of a variable node type

type WiFiConfig

type WiFiConfig struct {
	SSID string `point:"ssid"`
	// From NetworkManager: Key management used for the connection. One of
	// "none" (WEP), "ieee8021x" (Dynamic WEP), "wpa-none" (Ad-Hoc WPA-PSK),
	// "wpa-psk" (infrastructure WPA-PSK), "sae" (SAE) or "wpa-eap"
	// (WPA-Enterprise). This property must be set for any Wi-Fi connection that
	// uses security.
	KeyManagement string `point:"keyManagement"`
	PSK           string `point:"psk"`
}

WiFiConfig defines 802.11 wireless configuration

Jump to

Keyboard shortcuts

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