Documentation ¶
Index ¶
- func ConsumeFromDeviceSource(dm DeviceMessage) error
- func Start(dfg cc.Config, sp DeviceEventProvider, sscp SchedulerProvider, repo Repository, ...) (CoreService, *SiteNetworks)
- func Stop()
- func TopicsFromDevice(dv Device) []string
- type Broadcast
- type CoreService
- type CoreType
- type Device
- type DeviceAttribute
- type DeviceAttributeProperty
- type DeviceAttributePropertyProperty
- type DeviceEventIntf
- type DeviceEventProvider
- type DeviceMessage
- func (dm DeviceMessage) Ack()
- func (dm *DeviceMessage) Broadcast() bool
- func (dm DeviceMessage) Duplicate() bool
- func (dm DeviceMessage) MessageID() uint16
- func (dm *DeviceMessage) OTAAborted() bool
- func (dm *DeviceMessage) OTAActive() bool
- func (dm *DeviceMessage) OTAComplete() bool
- func (dm *DeviceMessage) OTACurrent() bool
- func (dm *DeviceMessage) OTAFirmwareError() bool
- func (dm *DeviceMessage) OTAFlashError() bool
- func (dm *DeviceMessage) OTAPublishMessage() bool
- func (dm *DeviceMessage) OTARejected() bool
- func (dm *DeviceMessage) OTAStatus() bool
- func (dm *DeviceMessage) Parts() []string
- func (dm *DeviceMessage) PartsLen() int
- func (dm DeviceMessage) Payload() []byte
- func (dm DeviceMessage) Qos() byte
- func (dm DeviceMessage) Retained() bool
- func (dm *DeviceMessage) Schedulable() bool
- func (dm *DeviceMessage) Settable() bool
- func (dm *DeviceMessage) String() string
- func (dm DeviceMessage) Topic() string
- type DeviceNode
- type DeviceNodeAttribute
- type DeviceNodeProperty
- type DeviceNodePropertyAttribute
- type EID
- type EntityBuilder
- type Firmware
- type FirmwareTools
- type Network
- type OTATransport
- type QueueMessage
- type Repository
- type Schedule
- type ScheduleTools
- type SchedulerProvider
- type SiteNetworks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsumeFromDeviceSource ¶
func ConsumeFromDeviceSource(dm DeviceMessage) error
ConsumeFromDeviceSource Handles incoming channel DM message -- Called directly from deviceSources
func Start ¶
func Start(dfg cc.Config, sp DeviceEventProvider, sscp SchedulerProvider, repo Repository, discoveredNetworks []string) (CoreService, *SiteNetworks)
* Start() * * Initialize this service
func TopicsFromDevice ¶
TopicsFromDevice() decode device into topics -/D/A/P/P -/D/A/P -/D/A -/D/N/P/A -/D/N/P -/D/N/A
Types ¶
type Broadcast ¶
type Broadcast struct { ID string ElementType CoreType Parent string Topic string Level string Value string Received time.Time }
Broadcast Alert Messages on Network
func NewBroadcast ¶
NewBroadcast Creates Component
type CoreService ¶
type CoreService interface { AllNetworks() SiteNetworks PrivateSiteNetworks() *SiteNetworks NetworkDevices(networkName string) (map[string]Device, error) NetworkByName(networkName string) Network DeviceByName(deviceName, networkName string) (Device, error) DeviceByID(deviceID string, networkName string) (Device, error) RemoveDeviceByID(deviceID string, networkName string) error PublishNetworkMessage(dm DeviceMessage) AllSchedules() []Schedule CreateSchedule(networkName string, deviceID string, transport OTATransport, firmwareID EID) (string, error) RemoveSchedule(scheduleID string) error ScheduleByID(scheduleID string) Schedule ScheduleByDeviceID(deviceID string) *Schedule AllFirmwares() []Firmware CreateFirmware(srcFile, dstFile string) (EID, error) RemoveFirmwareByID(firmwareID EID) FirmwareByID(firmwareID EID) (Firmware, error) FirmwareByName(firmwareName string) (Firmware, error) AllBroadcasts() []Broadcast RemoveBroadcastByID(broadcastID string) BroadcastByID(broadcastID string) (Broadcast, error) }
* Interactions with UI
func NewCoreService ¶
func NewCoreService(dfg cc.Config, sp DeviceEventProvider, sscp SchedulerProvider, repo Repository) CoreService
*
- NewCoreService() *
- Create a New NewCoreService and initializes it.
type CoreType ¶
type CoreType int
Globals required for DeviceMessage Types
const ( CoreTypeDevice CoreType = (iota + 10) CoreTypeDeviceAttribute CoreTypeDeviceAttributeProperty CoreTypeDeviceAttributePropertyProperty CoreTypeDeviceNode CoreTypeDeviceNodeAttribute CoreTypeDeviceNodeProperty CoreTypeDeviceNodePropertyAttribute CoreTypeDeviceDelete CoreTypePublishMessage CoreTypeBroadcast CoreTypeFirmware CoreTypeSchedule CoreTypeNetwork CoreTypeSiteNetworks )
CoreType Basic object types
type Device ¶
type Device struct { ID string Title string ElementType CoreType OTAEnabled bool Parent string Name string Attrs map[string]DeviceAttribute Nodes map[string]DeviceNode }
Device represent a physical device
type DeviceAttribute ¶
type DeviceAttribute struct { ID EID ElementType CoreType Parent string Name string Value string Props map[string]DeviceAttributeProperty }
DeviceAttribute of a Device allowing sub properties, representing a single value or measurement
func NewDeviceAttribute ¶
func NewDeviceAttribute(parent, name, value string) DeviceAttribute
NewDeviceAttribute Creates Component
type DeviceAttributeProperty ¶
type DeviceAttributeProperty struct { ID EID ElementType CoreType Parent string Name string Value string Props map[string]DeviceAttributePropertyProperty }
DeviceAttributeProperty of a Device Attribute, representing a single value or measurement $implementation/ota/status -- where status will be a regular attribute
func NewDeviceAttributeProperty ¶
func NewDeviceAttributeProperty(parent, name, value string) DeviceAttributeProperty
NewDeviceAttributeProperty Creates Component of a Device Attribute, representing a single value or measurement $implementation/fw -- where status will be a regular attribute
$DeviceAttr / Property
type DeviceAttributePropertyProperty ¶
type DeviceAttributePropertyProperty struct { ID EID ElementType CoreType Parent string Name string Value string }
DeviceAttributePropertyProperty of a Device Attribute, representing a single value or measurement $implementation/ota/status -- where status will be a regular attribute
func NewDeviceAttributePropertyProperty ¶
func NewDeviceAttributePropertyProperty(parent, name, value string) DeviceAttributePropertyProperty
NewDeviceAttributePropertyProperty Creates Component of a Device Attribute, representing a single value or measurement $implementation/fw/version -- where status will be a regular attribute
$DeviceAttr / Property / Property
type DeviceEventIntf ¶
type DeviceEventIntf interface { String() string Schedulable() bool Settable() bool OTAPublishMessage() bool OTAStatus() bool OTAActive() bool OTACurrent() bool OTARejected() bool OTAAborted() bool OTAFlashError() bool OTAFirmwareError() bool OTAComplete() bool Broadcast() bool Parts() []string PartsLen() int }
* Device Management Methods
type DeviceEventProvider ¶
type DeviceEventProvider interface { ActivateStreamProvider() ApplyDeviceEvent(dm DeviceMessage) PublishToStreamProvider(dm DeviceMessage) ConsumeDeviceStream(dm DeviceMessage) error }
* Interactions with DeviceSource
type DeviceMessage ¶
type DeviceMessage struct { ID uint16 HomieType CoreType OTATrigger bool RetainedB bool Qosb byte NetworkID []byte DeviceID []byte NodeID []byte PropertyID []byte PPropertyID []byte AttributeID []byte TopicS string Value []byte }
* DeviceMessage * Transposed MQTT Message for Internal Use
func NewDeviceMessage ¶
func NewDeviceMessage(topic string, payload []byte, idCounter uint16, retained bool, qos byte, plog log.Logger) (DeviceMessage, error)
NewDeviceMessage()
- Create a New DeviceMessage and initializes it.
- Called outside of the service
func NewQueueMessage ¶
func NewQueueMessage(msg QueueMessage, plog log.Logger) (DeviceMessage, error)
NewEventMessage()
- Create a New DeviceMessage and initializes it.
- Called outside of the service
func (DeviceMessage) Ack ¶
func (dm DeviceMessage) Ack()
func (*DeviceMessage) Broadcast ¶
func (dm *DeviceMessage) Broadcast() bool
Broadcast() determines if this is a Homie Broadcast message
func (DeviceMessage) Duplicate ¶
func (dm DeviceMessage) Duplicate() bool
func (DeviceMessage) MessageID ¶
func (dm DeviceMessage) MessageID() uint16
func (*DeviceMessage) OTAAborted ¶
func (dm *DeviceMessage) OTAAborted() bool
OTAAborted() determines if device is downloading firmware
func (*DeviceMessage) OTAActive ¶
func (dm *DeviceMessage) OTAActive() bool
OTAactive() determines if device is downloading firmware
func (*DeviceMessage) OTAComplete ¶
func (dm *DeviceMessage) OTAComplete() bool
OTAComplete determines if device has accepted new firmware Filtered on create of event message, use Topic to bypass Filtering
func (*DeviceMessage) OTACurrent ¶
func (dm *DeviceMessage) OTACurrent() bool
OTACurrent() determines if device is downloading firmware
func (*DeviceMessage) OTAFirmwareError ¶
func (dm *DeviceMessage) OTAFirmwareError() bool
func (*DeviceMessage) OTAFlashError ¶
func (dm *DeviceMessage) OTAFlashError() bool
func (*DeviceMessage) OTAPublishMessage ¶
func (dm *DeviceMessage) OTAPublishMessage() bool
OTAactive() determines if device is downloading firmware
func (*DeviceMessage) OTARejected ¶
func (dm *DeviceMessage) OTARejected() bool
OTARejected() determines if device is downloading firmware
func (*DeviceMessage) OTAStatus ¶
func (dm *DeviceMessage) OTAStatus() bool
OTAStatus() determines if device is downloading firmware
func (*DeviceMessage) Parts ¶
func (dm *DeviceMessage) Parts() []string
Parts() returns the individual parts of the original MQTT message
func (*DeviceMessage) PartsLen ¶
func (dm *DeviceMessage) PartsLen() int
PartsLen() returns number of parts in Topic
func (DeviceMessage) Payload ¶
func (dm DeviceMessage) Payload() []byte
func (DeviceMessage) Qos ¶
func (dm DeviceMessage) Qos() byte
func (DeviceMessage) Retained ¶
func (dm DeviceMessage) Retained() bool
func (*DeviceMessage) Schedulable ¶
func (dm *DeviceMessage) Schedulable() bool
Schedulable() also -- $stats/uptime
func (*DeviceMessage) Settable ¶
func (dm *DeviceMessage) Settable() bool
Settable() determine is property is settable
func (*DeviceMessage) String ¶
func (dm *DeviceMessage) String() string
String ToString - utility function
func (DeviceMessage) Topic ¶
func (dm DeviceMessage) Topic() string
* QueueMessage implementation for DeviceMessage
type DeviceNode ¶
type DeviceNode struct { ID EID ElementType CoreType Parent string Name string Attrs map[string]DeviceNodeAttribute Props map[string]DeviceNodeProperty }
DeviceNode representing the capabilities or features of device
func NewDeviceNode ¶
func NewDeviceNode(parent, name string) DeviceNode
NewDeviceNode Creates Component
type DeviceNodeAttribute ¶
type DeviceNodeAttribute struct { ID EID ElementType CoreType Parent string Name string Value string }
DeviceNodeAttribute used by Devices, Nodes, and Properties. Used to describe format
func NewDeviceNodeAttribute ¶
func NewDeviceNodeAttribute(parent, name, value string) DeviceNodeAttribute
NewDeviceNodeAttribute Creates Component
type DeviceNodeProperty ¶
type DeviceNodeProperty struct { ID EID ElementType CoreType Parent string Name string Value string Attrs map[string]DeviceNodePropertyAttribute }
DeviceNodeProperty of a Node, representing a single value or measurement
func NewDeviceNodeProperty ¶
func NewDeviceNodeProperty(parent, name, value string) DeviceNodeProperty
NewDeviceNodeProperty Creates Component
type DeviceNodePropertyAttribute ¶
type DeviceNodePropertyAttribute struct { ID EID ElementType CoreType Parent string Name string Value string }
DeviceNodePropertyAttribute used by Devices, Nodes, and Properties. Used to describe format
func NewDeviceNodePropertyAttribute ¶
func NewDeviceNodePropertyAttribute(parent, name, value string) DeviceNodePropertyAttribute
NewDeviceNodePropertyAttribute Creates Component
type EntityBuilder ¶
type EntityBuilder interface {
// contains filtered or unexported methods
}
EntityBuilder - based on Network Entity - manages creation and deletion of components
type Firmware ¶
type Firmware struct { ID EID ElementType CoreType Name string FileName string Version string Path string Size int64 MD5Digest string Brand string Created time.Time }
Firmware basic firmware model
type FirmwareTools ¶
type FirmwareTools interface {
String()
}
type Network ¶
type Network struct { ID string Title string ElementType CoreType // network name Name string // any Devices map[string]Device }
Network contains all known devices in application
type OTATransport ¶
type OTATransport int
OTATransport Flag used to choose OTA transport Format
const ( Binary OTATransport = iota + 30 Base64 Base64Strict RFC4648URLSafeWithPadding RFC4648URLSafeWithoutPadding )
OTATransport Flags used to choose OTA transport Format
type QueueMessage ¶
type QueueMessage interface { Topic() string Payload() []byte MessageID() uint16 Retained() bool Qos() byte Duplicate() bool Ack() }
QueueMessage maps a mqtt.Message into this domain entity
type Repository ¶
type Repository interface { Store(d DeviceMessage) error Remove(d DeviceMessage) error RestoreNetworkFromDB(networkName string) Network LoadSchedules() map[string]Schedule StoreSchedule(d Schedule) error RemoveSchedule(scheduleID string) error LoadBroadcasts(networkName string) []Broadcast RemoveAllBroadcasts(networkName string) error }
Device Source Storage Repository
type Schedule ¶
type Schedule struct { ID string ElementType CoreType DeviceID string FirmwareID EID State string Status string Retries int Transport OTATransport Scheduled time.Time Completed time.Time }
Schedule the ota schedule details
type ScheduleTools ¶
type ScheduleTools interface {
String()
}
type SchedulerProvider ¶
type SchedulerProvider interface { ActivateStreamProvider() ApplySiteNetworks(sn *SiteNetworks) Schedules() []Schedule BuildScheduleCatalog() map[string]Schedule FindScheduleByDeviceID(deviceID string) *Schedule CreateSchedule(networkName string, deviceID string, transport OTATransport, firmwareID EID) (string, error) DeleteSchedule(scheduleID string) error BuildFirmwareCatalog() []Firmware Firmwares() []Firmware GetFirmware(id EID) (Firmware, error) CreateFirmware(srcFile, dstFile string) (EID, error) DeleteFirmware(id EID) error }
* Interactions with device Scheduling Service
type SiteNetworks ¶
type SiteNetworks struct { ID EID ElementType CoreType // site name SiteName string Title string Names []string // any Broadcasts []Broadcast Firmwares []Firmware Schedules map[string]Schedule // by EID DeviceNetworks map[string]Network // by Device Name }
SiteNetworks contains all known/valid Collections
func NewSiteNetworks ¶
func NewSiteNetworks(siteName, siteTitle string, networks []string, firmwares []Firmware, schedules map[string]Schedule) *SiteNetworks
NewSiteNetworks Creates Component