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.
This package also contains a number of utility functions for interacting with the Simple IoT NATS API.
Index ¶
- Variables
- func AdminStoreMaint(nc *nats.Conn) error
- func AdminStoreVerify(nc *nats.Conn) error
- func DecodeEdgePointsMsg(msg *nats.Msg) (string, string, []data.Point, error)
- func DecodeNodePointsMsg(msg *nats.Msg) (string, []data.Point, error)
- func DecodeUpEdgePointsMsg(msg *nats.Msg) (string, string, string, []data.Point, error)
- func DecodeUpNodePointsMsg(msg *nats.Msg) (string, string, []data.Point, error)
- func DeleteNode(nc *nats.Conn, id, parent string, origin string) error
- func Dump(nc *nats.Conn, msg *nats.Msg) error
- func DuplicateNode(nc *nats.Conn, id, newParent, origin string) error
- func EdgeConnect(eo EdgeOptions) (*nats.Conn, error)
- func ExpBackoff(attempts int, max time.Duration) time.Duration
- func GetNatsURI(nc *nats.Conn) (string, string, error)
- func GetNodes(nc *nats.Conn, parent, id, typ string, includeDel bool) ([]data.NodeEdge, error)
- func GetNodesForUser(nc *nats.Conn, userID string) ([]data.NodeEdge, error)
- func GetNodesType[T any](nc *nats.Conn, parent, id string) ([]T, error)
- func GetRootNode(nc *nats.Conn) (data.NodeEdge, error)
- func ListenForFile(nc *nats.Conn, dir, deviceID string, callback func(path string)) error
- func Log(natsServer, authToken string)
- func MirrorNode(nc *nats.Conn, id, newParent, origin string) error
- func MoveNode(nc *nats.Conn, id, oldParent, newParent, origin string) error
- func NatsSendFileFromHTTP(nc *nats.Conn, deviceID string, url string, callback func(int)) error
- func NodeWatcher[T any](nc *nats.Conn, id, parent string) (get func() T, stop func(), err error)
- func SendEdgePoint(nc *nats.Conn, nodeID, parentID string, point data.Point, ack bool) error
- func SendEdgePoints(nc *nats.Conn, nodeID, parentID string, points data.Points, ack bool) error
- func SendFile(nc *nats.Conn, deviceID string, reader io.Reader, name string, ...) error
- func SendNode(nc *nats.Conn, node data.NodeEdge, origin string) error
- func SendNodePoint(nc *nats.Conn, nodeID string, point data.Point, ack bool) error
- func SendNodePoints(nc *nats.Conn, nodeID string, points data.Points, ack bool) error
- func SendNodeType[T any](nc *nats.Conn, node T, origin string) error
- func SendPoints(nc *nats.Conn, subject string, points data.Points, ack bool) error
- func SerialDecode(d []byte) (byte, string, []byte, error)
- func SerialEncode(seq byte, subject string, points data.Points) ([]byte, error)
- func String(nc *nats.Conn, msg *nats.Msg) (string, error)
- func SubjectEdgeAllPoints() string
- func SubjectEdgePoints(nodeID, parentID string) string
- func SubjectNodeAllPoints() string
- func SubjectNodeHRPoints(nodeID string) string
- func SubjectNodePoints(nodeID string) string
- func SubscribeEdgePoints(nc *nats.Conn, id, parent string, callback func(points []data.Point)) (stop func(), err error)
- func SubscribePoints(nc *nats.Conn, id string, callback func(points []data.Point)) (stop func(), err error)
- func UserCheck(nc *nats.Conn, email, pass string) ([]data.NodeEdge, error)
- type Action
- type ActionInactive
- type CanBus
- type CanBusClient
- type Client
- func NewCanBusClient(nc *nats.Conn, config CanBus) Client
- func NewDbClient(nc *nats.Conn, config Db) Client
- func NewMetricsClient(nc *nats.Conn, config Metrics) Client
- func NewParticleClient(nc *nats.Conn, config Particle) Client
- func NewRuleClient(nc *nats.Conn, config Rule) Client
- func NewSerialDevClient(nc *nats.Conn, config SerialDev) Client
- func NewShellyClient(nc *nats.Conn, config Shelly) Client
- func NewShellyIOClient(nc *nats.Conn, config ShellyIo) Client
- func NewSignalGeneratorClient(nc *nats.Conn, config SignalGenerator) Client
- func NewSyncClient(nc *nats.Conn, config Sync) Client
- type CobsWrapper
- type Condition
- type Db
- type DbClient
- type Device
- type EdgeOptions
- type File
- type Group
- type Manager
- type Metric
- type Metrics
- type MetricsClient
- type NewPoints
- type Particle
- type ParticleClient
- type ParticleEvent
- type Rule
- type RuleClient
- type RunStop
- type SerialDev
- type SerialDevClient
- type Shelly
- type ShellyClient
- type ShellyGen
- type ShellyIOClient
- type ShellyIOConfig
- type ShellyIo
- func (sio *ShellyIo) Desc() string
- func (sio *ShellyIo) Gen() ShellyGen
- func (sio *ShellyIo) GetConfig() (ShellyIOConfig, error)
- func (sio *ShellyIo) GetStatus() (data.Points, error)
- func (sio *ShellyIo) IsSettableOnOff() bool
- func (sio *ShellyIo) SetName(name string) error
- func (sio *ShellyIo) SetOnOff(on bool) (data.Points, error)
- type SignalGenerator
- type SignalGeneratorClient
- type Sync
- type SyncClient
- type User
- type Variable
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCobsDecodeError = errors.New("COBS decode error")
ErrCobsDecodeError indicates we got an error decoding a COBS packet
var ErrCobsLeftoverBufferFull = errors.New("COBS leftover buffer too full")
ErrCobsLeftoverBufferFull indicates our leftover buffer is too full to process
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 ¶ added in v0.6.0
func AdminStoreMaint(nc *nats.Conn) error
AdminStoreMaint can be used fix store issues
func AdminStoreVerify ¶ added in v0.6.0
func AdminStoreVerify(nc *nats.Conn) error
AdminStoreVerify can be used verify the store
func DecodeEdgePointsMsg ¶
DecodeEdgePointsMsg decodes NATS message into node ID and points returns nodeID, parentID, points, error
func DecodeNodePointsMsg ¶
DecodeNodePointsMsg decodes NATS message into node ID and points
func DecodeUpEdgePointsMsg ¶ added in v0.6.0
DecodeUpEdgePointsMsg decodes NATS message into node ID and points returns upID, nodeID, parentID, points, error
func DecodeUpNodePointsMsg ¶ added in v0.6.0
DecodeUpNodePointsMsg decodes NATS message into node ID and points returns upID, nodeID, points, error
func DeleteNode ¶
DeleteNode removes a node from the specified parent node
func DuplicateNode ¶
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 ¶
ExpBackoff calculates an exponential time backup to max duration + a random fraction of 1s
func GetNatsURI ¶ added in v0.6.0
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 ¶ added in v0.6.0
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 ¶
GetNodesForUser gets all nodes for a user
func GetNodesType ¶ added in v0.6.0
GetNodesType gets node of a custom type. id and parent work the same as GetNodes Deleted nodes are not included.
func GetRootNode ¶ added in v0.6.0
GetRootNode returns the root node of the instance
func ListenForFile ¶
ListenForFile listens for a file sent from server. dir is the directly to place downloaded files.
func Log ¶ added in v0.5.2
func Log(natsServer, authToken string)
Log all nats messages. This function does not block and does not clean up after itself.
func MirrorNode ¶
MirrorNode adds a an existing node to a new parent. A node can have multiple parents.
func NatsSendFileFromHTTP ¶ added in v0.5.1
NatsSendFileFromHTTP fetchs a file using http and sends via nats. Callback provides % complete (0-100).
func NodeWatcher ¶ added in v0.4.0
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 SendEdgePoint ¶
SendEdgePoint sends a edge point using the nats protocol
func SendEdgePoints ¶
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 SendNodePoint ¶
SendNodePoint sends a node point using the nats protocol
func SendNodePoints ¶
SendNodePoints sends node points using the nats protocol
func SendNodeType ¶ added in v0.4.0
SendNodeType is used to send a node to a nats server. Can be used to create nodes.
func SendPoints ¶ added in v0.4.0
SendPoints sends points to specified subject
func SerialDecode ¶ added in v0.4.0
SerialDecode can be used to decode serial data in a client. returns seq, subject, payload
func SerialEncode ¶ added in v0.4.0
SerialEncode can be used in a client to encode points sent over a serial link.
func SubjectEdgeAllPoints ¶
func SubjectEdgeAllPoints() string
SubjectEdgeAllPoints provides subject for all edge points for any node
func SubjectEdgePoints ¶
SubjectEdgePoints constructs a NATS subject for edge points
func SubjectNodeAllPoints ¶
func SubjectNodeAllPoints() string
SubjectNodeAllPoints provides subject for all points for any node
func SubjectNodeHRPoints ¶ added in v0.5.1
SubjectNodeHRPoints constructs a NATS subject for high rate node points
func SubjectNodePoints ¶
SubjectNodePoints constructs a NATS subject for node points
func SubscribeEdgePoints ¶ added in v0.4.0
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
Types ¶
type Action ¶ added in v0.5.0
type Action 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"` // 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.
type ActionInactive ¶ added in v0.5.0
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"` // 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 ¶ added in v0.7.0
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 ¶ added in v0.7.0
type CanBusClient struct {
// contains filtered or unexported fields
}
CanBusClient is a SIOT client used to communicate on a CAN bus
func (*CanBusClient) EdgePoints ¶ added in v0.7.0
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 ¶ added in v0.7.0
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 ¶ added in v0.7.1
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 ¶ added in v0.7.0
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. Start 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 ¶ added in v0.7.0
NewCanBusClient returns a new CanBusClient with a NATS connection and a config
func NewDbClient ¶ added in v0.5.0
NewDbClient ...
func NewMetricsClient ¶ added in v0.8.0
NewMetricsClient ...
func NewParticleClient ¶ added in v0.9.0
NewParticleClient ...
func NewRuleClient ¶ added in v0.5.0
NewRuleClient constructor ...
func NewSerialDevClient ¶ added in v0.4.0
NewSerialDevClient ...
func NewShellyClient ¶ added in v0.10.0
NewShellyClient ...
func NewShellyIOClient ¶ added in v0.10.0
NewShellyIOClient ...
func NewSignalGeneratorClient ¶ added in v0.5.1
func NewSignalGeneratorClient(nc *nats.Conn, config SignalGenerator) Client
NewSignalGeneratorClient ...
func NewSyncClient ¶ added in v0.6.0
NewSyncClient constructor
type CobsWrapper ¶ added in v0.4.0
type CobsWrapper struct {
// contains filtered or unexported fields
}
CobsWrapper can be used to wrap an io.ReadWriteCloser to COBS encode/decode data
func NewCobsWrapper ¶ added in v0.4.0
func NewCobsWrapper(dev io.ReadWriteCloser, maxMessageLength int) *CobsWrapper
NewCobsWrapper creates a new cobs wrapper
func (*CobsWrapper) Close ¶ added in v0.4.0
func (cw *CobsWrapper) Close() error
Close the device wrapped.
func (*CobsWrapper) Read ¶ added in v0.4.0
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.
func (*CobsWrapper) SetDebug ¶ added in v0.5.3
func (cw *CobsWrapper) SetDebug(debug int)
SetDebug sets the debug level. If >= 9, then it dumps the raw data received.
type Condition ¶ added in v0.5.0
type Condition struct { // general parameters ID string `node:"id"` Parent string `node:"parent"` Description string `point:"description"` ConditionType string `point:"conditionType"` MinActive float64 `point:"minActive"` Active bool `point:"active"` // 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"` }
Condition defines parameters to look for in a point or a schedule.
type Db ¶ added in v0.5.0
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"` }
Db represents the configuration for a SIOT DB client
type DbClient ¶ added in v0.5.0
type DbClient struct {
// contains filtered or unexported fields
}
DbClient is a SIOT database client
func (*DbClient) EdgePoints ¶ added in v0.5.0
EdgePoints is called by the Manager when new edge points for this node are received.
func (*DbClient) Points ¶ added in v0.5.0
Points is called by the Manager when new points for this node are received.
type Device ¶ added in v0.6.0
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 ¶ added in v0.7.0
File represents a CAN database file in common formats such as KCD and DBC.
type Group ¶ added in v0.5.2
type Group struct {
// contains filtered or unexported fields
}
Group 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 ¶ added in v0.5.2
DefaultClients returns an actor for the default group of built in clients
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 ¶
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.
Example ¶
package main import ( "log" "github.com/nats-io/nats.go" "github.com/simpleiot/simpleiot/client" "github.com/simpleiot/simpleiot/data" "github.com/simpleiot/simpleiot/server" ) // exNode is decoded data from the client node type exNode struct { ID string `node:"id"` Parent string `node:"parent"` Description string `point:"description"` Port int `point:"port"` Role string `edgepoint:"role"` } // exNodeClient contains the logic for this client type exNodeClient struct { nc *nats.Conn config exNode stop chan struct{} stopped chan struct{} newPoints chan client.NewPoints newEdgePoints chan client.NewPoints chGetConfig chan chan exNode } // newExNodeClient is passed to the NewManager() function call -- when // a new node is detected, the Manager will call this function to construct // a new client. func newExNodeClient(nc *nats.Conn, config exNode) client.Client { return &exNodeClient{ nc: nc, config: config, stop: make(chan struct{}), newPoints: make(chan client.NewPoints), newEdgePoints: make(chan client.NewPoints), } } // Run the main logic for this client and blocks until stopped func (tnc *exNodeClient) Run() error { for { select { case <-tnc.stop: close(tnc.stopped) return nil case pts := <-tnc.newPoints: err := data.MergePoints(pts.ID, pts.Points, &tnc.config) if err != nil { log.Println("error merging new points: ", err) } log.Printf("New config: %+v\n", tnc.config) case pts := <-tnc.newEdgePoints: err := data.MergeEdgePoints(pts.ID, pts.Parent, pts.Points, &tnc.config) if err != nil { log.Println("error merging new points: ", err) } case ch := <-tnc.chGetConfig: ch <- tnc.config } } } // Stop sends a signal to the Run function to exit func (tnc *exNodeClient) Stop(_ error) { close(tnc.stop) } // Points is called by the Manager when new points for this // node are received. func (tnc *exNodeClient) Points(id string, points []data.Point) { tnc.newPoints <- client.NewPoints{id, "", points} } // EdgePoints is called by the Manager when new edge points for this // node are received. func (tnc *exNodeClient) EdgePoints(id, parent string, points []data.Point) { tnc.newEdgePoints <- client.NewPoints{id, parent, points} } func main() { nc, root, stop, err := server.TestServer() if err != nil { log.Println("Error starting test server: ", err) } defer stop() testConfig := testNode{"", "", "fancy test node", 8118, "admin"} // Convert our custom struct to a data.NodeEdge struct ne, err := data.Encode(testConfig) if err != nil { log.Println("Error encoding node: ", err) } ne.Parent = root.ID // hydrate database with test node err = client.SendNode(nc, ne, "test") if err != nil { log.Println("Error sending node: ", err) } // Create a new manager for nodes of type "testNode". The manager looks for new nodes under the // root and if it finds any, it instantiates a new client, and sends point updates to it m := client.NewManager(nc, newExNodeClient) err = m.Run() if err != nil { log.Println("Error running: ", err) } // Now any updates to the node will trigger Points/EdgePoints callbacks in the above client }
Output:
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.
type Metrics ¶ added in v0.8.0
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 ¶ added in v0.8.0
type MetricsClient struct {
// contains filtered or unexported fields
}
MetricsClient is a SIOT client used to collect system or app metrics
func (*MetricsClient) EdgePoints ¶ added in v0.8.0
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 ¶ added in v0.8.0
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 ¶ added in v0.8.0
func (m *MetricsClient) Run() error
Run the main logic for this client and blocks until stopped
func (*MetricsClient) Stop ¶ added in v0.8.0
func (m *MetricsClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type NewPoints ¶ added in v0.5.0
NewPoints is used to pass new points through channels in client drivers
type Particle ¶ added in v0.9.0
type Particle struct { ID string `node:"id"` Parent string `node:"parent"` Description string `point:"description"` Disable bool `point:"disable"` AuthToken string `point:"authToken"` }
Particle represents the configuration for the SIOT Particle client
type ParticleClient ¶ added in v0.9.0
type ParticleClient struct {
// contains filtered or unexported fields
}
ParticleClient is a SIOT particle client
func (*ParticleClient) EdgePoints ¶ added in v0.9.0
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 ¶ added in v0.9.0
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 ¶ added in v0.9.0
func (pc *ParticleClient) Run() error
Run runs the main logic for this client and blocks until stopped
func (*ParticleClient) Stop ¶ added in v0.9.0
func (pc *ParticleClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type ParticleEvent ¶ added in v0.9.0
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 ¶ added in v0.5.0
type Rule struct { ID string `node:"id"` Parent string `node:"parent"` Description string `point:"description"` Disable bool `point:"disable"` Active bool `point:"active"` Conditions []Condition `child:"condition"` Actions []Action `child:"action"` ActionsInactive []Action `child:"actionInactive"` }
Rule represent a rule node config
type RuleClient ¶ added in v0.5.0
type RuleClient struct {
// contains filtered or unexported fields
}
RuleClient is a SIOT client used to run rules
func (*RuleClient) EdgePoints ¶ added in v0.5.0
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 ¶ added in v0.5.0
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 ¶ added in v0.7.1
func (rc *RuleClient) Run() error
Run runs the main logic for this client and blocks until stopped
func (*RuleClient) Stop ¶ added in v0.5.0
func (rc *RuleClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type RunStop ¶ added in v0.7.1
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 ¶ added in v0.4.0
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"` Debug int `point:"debug"` Disable bool `point:"disable"` Log string `point:"log"` Rx int `point:"rx"` RxReset bool `point:"rxReset"` Tx int `point:"tx"` TxReset bool `point:"txReset"` Uptime int `point:"uptime"` ErrorCount int `point:"errorCount"` ErrorCountReset bool `point:"errorCountReset"` Rate bool `point:"rate"` Connected bool `point:"connected"` }
SerialDev represents a serial (MCU) config
type SerialDevClient ¶ added in v0.4.0
type SerialDevClient struct {
// contains filtered or unexported fields
}
SerialDevClient is a SIOT client used to manage serial devices
func (*SerialDevClient) EdgePoints ¶ added in v0.4.0
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 ¶ added in v0.4.0
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 ¶ added in v0.7.1
func (sd *SerialDevClient) Run() error
Run the main logic for this client and blocks until stopped
func (*SerialDevClient) Stop ¶ added in v0.4.0
func (sd *SerialDevClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type Shelly ¶ added in v0.10.0
type Shelly struct { ID string `node:"id"` Parent string `node:"parent"` Description string `point:"description"` Disable bool `point:"disable"` IOs []ShellyIo `child:"shellyIo"` }
Shelly describes the shelly client config
type ShellyClient ¶ added in v0.10.0
type ShellyClient struct {
// contains filtered or unexported fields
}
ShellyClient is a SIOT particle client
func (*ShellyClient) EdgePoints ¶ added in v0.10.0
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 ¶ added in v0.10.0
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 ¶ added in v0.10.0
func (sc *ShellyClient) Run() error
Run runs the main logic for this client and blocks until stopped
func (*ShellyClient) Stop ¶ added in v0.10.0
func (sc *ShellyClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type ShellyGen ¶ added in v0.10.0
type ShellyGen int
ShellyGen describes the generation of device (Gen1/Gen2)
type ShellyIOClient ¶ added in v0.10.0
type ShellyIOClient struct {
// contains filtered or unexported fields
}
ShellyIOClient is a SIOT particle client
func (*ShellyIOClient) EdgePoints ¶ added in v0.10.0
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 ¶ added in v0.10.0
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 ¶ added in v0.10.0
func (sioc *ShellyIOClient) Run() error
Run runs the main logic for this client and blocks until stopped
func (*ShellyIOClient) Stop ¶ added in v0.10.0
func (sioc *ShellyIOClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type ShellyIOConfig ¶ added in v0.10.0
type ShellyIOConfig struct {
Name string `json:"name"`
}
ShellyIOConfig describes the configuration of a Shelly device
type ShellyIo ¶ added in v0.10.0
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"` Offline bool `point:"offline"` Control bool `point:"control"` }
ShellyIo describes the config/state for a shelly io
func (*ShellyIo) GetConfig ¶ added in v0.10.0
func (sio *ShellyIo) GetConfig() (ShellyIOConfig, error)
GetConfig returns the configuration of Shelly Device
func (*ShellyIo) IsSettableOnOff ¶ added in v0.10.0
IsSettableOnOff returns true if the device can be turned on/off
func (*ShellyIo) SetOnOff ¶ added in v0.10.0
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 ¶ added in v0.5.1
type SignalGenerator struct { ID string `node:"id"` Parent string `node:"parent"` Description string `point:"description"` Frequency float64 `point:"frequency"` Amplitude float64 `point:"amplitude"` Offset float64 `point:"offset"` SampleRate float64 `point:"sampleRate"` Value float64 `point:"value"` Units string `point:"units"` HighRate bool `point:"highRate"` BatchPeriod int `point:"batchPeriod"` Disable bool `point:"disable"` }
SignalGenerator config
type SignalGeneratorClient ¶ added in v0.5.1
type SignalGeneratorClient struct {
// contains filtered or unexported fields
}
SignalGeneratorClient for signal generator nodes
func (*SignalGeneratorClient) EdgePoints ¶ added in v0.5.1
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 ¶ added in v0.5.1
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 ¶ added in v0.7.1
func (sgc *SignalGeneratorClient) Run() error
Run the main logic for this client and blocks until stopped
func (*SignalGeneratorClient) Stop ¶ added in v0.5.1
func (sgc *SignalGeneratorClient) Stop(_ error)
Stop sends a signal to the Run function to exit
type Sync ¶ added in v0.6.0
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"` Disable bool `point:"disable"` SyncCount int `point:"syncCount"` SyncCountReset bool `point:"syncCountReset"` }
Sync represents an sync node config
type SyncClient ¶ added in v0.6.0
type SyncClient struct {
// contains filtered or unexported fields
}
SyncClient is a SIOT client used to handle upstream connections
func (*SyncClient) EdgePoints ¶ added in v0.6.0
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 ¶ added in v0.6.0
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 ¶ added in v0.7.1
func (up *SyncClient) Run() error
Run the main logic for this client and blocks until stopped
func (*SyncClient) Stop ¶ added in v0.6.0
func (up *SyncClient) Stop(_ error)
Stop sends a signal to the Run function to exit
Source Files ¶
- admin.go
- auth.go
- backoff.go
- can.go
- client-state.go
- client.go
- cobs-wrapper.go
- db.go
- debug.go
- device.go
- doc.go
- edge.go
- file.go
- group.go
- manager.go
- metric.go
- metrics.go
- msg.go
- node.go
- particle.go
- point.go
- rule.go
- schedule.go
- send-file.go
- serial-wrapper.go
- serial.go
- shelly-io.go
- shelly.go
- signal-generator.go
- start-stop.go
- subject.go
- sync.go
- update.go
- uri.go
- user.go
- variable.go