controller

package
v0.0.0-...-cc86588 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// MQTT handlers
	HealthHandler(client MQTT.Client, msg MQTT.Message)
	ActionHandler(client MQTT.Client, msg MQTT.Message)

	// Passthrough to the device twin service
	DeviceSnaps(orgID, clientID string) ([]domain.DeviceSnap, error)
	DeviceList(orgID string) ([]domain.Device, error)
	DeviceGet(orgID, clientID string) (domain.Device, error)
	GroupCreate(orgID, name string) error
	GroupList(orgID string) ([]domain.Group, error)
	GroupGet(orgID, name string) (domain.Group, error)
	GroupLinkDevice(orgID, name, clientID string) error
	GroupUnlinkDevice(orgID, name, clientID string) error
	GroupGetDevices(orgID, name string) ([]domain.Device, error)
	GroupGetExcludedDevices(orgID, name string) ([]domain.Device, error)

	// Actions on a device
	DeviceSnapList(orgID, clientID string) error
	DeviceSnapInstall(orgID, clientID, snap string) error
	DeviceSnapRemove(orgID, clientID, snap string) error
	DeviceSnapUpdate(orgID, clientID, snap, action string) error
	DeviceSnapConf(orgID, clientID, snap, settings string) error
	ActionList(orgID, clientID string) ([]domain.Action, error)
}

Controller interface for the service

type Service

type Service struct {
	Settings   *config.Settings
	MQTT       mqtt.Connect
	DeviceTwin devicetwin.DeviceTwin
}

Service implementation of the devicetwin service use cases

func NewService

func NewService(settings *config.Settings, m mqtt.Connect, twin devicetwin.DeviceTwin) *Service

NewService creates an implementation of the devicetwin use cases

func (*Service) ActionHandler

func (srv *Service) ActionHandler(client MQTT.Client, msg MQTT.Message)

ActionHandler is the handler for the main subscription topic

func (*Service) ActionList

func (srv *Service) ActionList(orgID, clientID string) ([]domain.Action, error)

ActionList gets the action log for a device

func (*Service) DeviceGet

func (srv *Service) DeviceGet(orgID, clientID string) (domain.Device, error)

DeviceGet gets the device from the database cache

func (*Service) DeviceList

func (srv *Service) DeviceList(orgID string) ([]domain.Device, error)

DeviceList gets the devices from the database cache

func (*Service) DeviceSnapConf

func (srv *Service) DeviceSnapConf(orgID, clientID, snap, settings string) error

DeviceSnapConf triggers a snap settings update on a device

func (*Service) DeviceSnapInstall

func (srv *Service) DeviceSnapInstall(orgID, clientID, snap string) error

DeviceSnapInstall triggers installing a snap on a device

func (*Service) DeviceSnapList

func (srv *Service) DeviceSnapList(orgID, clientID string) error

DeviceSnapList triggers listing snaps on a device

func (*Service) DeviceSnapRemove

func (srv *Service) DeviceSnapRemove(orgID, clientID, snap string) error

DeviceSnapRemove triggers uninstalling a snap on a device

func (*Service) DeviceSnapUpdate

func (srv *Service) DeviceSnapUpdate(orgID, clientID, snap, action string) error

DeviceSnapUpdate triggers a snap update on a device

func (*Service) DeviceSnaps

func (srv *Service) DeviceSnaps(orgID, clientID string) ([]domain.DeviceSnap, error)

DeviceSnaps gets the device's snaps from the database cache

func (*Service) GroupCreate

func (srv *Service) GroupCreate(orgID, name string) error

GroupCreate creates a device group

func (*Service) GroupGet

func (srv *Service) GroupGet(orgID, name string) (domain.Group, error)

GroupGet retrieves a device group

func (*Service) GroupGetDevices

func (srv *Service) GroupGetDevices(orgID, name string) ([]domain.Device, error)

GroupGetDevices retrieves the devices from a group

func (*Service) GroupGetExcludedDevices

func (srv *Service) GroupGetExcludedDevices(orgID, name string) ([]domain.Device, error)

GroupGetExcludedDevices retrieves the devices not in a group

func (*Service) GroupLinkDevice

func (srv *Service) GroupLinkDevice(orgID, name, clientID string) error

GroupLinkDevice links a device to a group

func (*Service) GroupList

func (srv *Service) GroupList(orgID string) ([]domain.Group, error)

GroupList lists the groups for an organization

func (*Service) GroupUnlinkDevice

func (srv *Service) GroupUnlinkDevice(orgID, name, clientID string) error

GroupUnlinkDevice unlinks a device from a group

func (*Service) HealthHandler

func (srv *Service) HealthHandler(client MQTT.Client, msg MQTT.Message)

HealthHandler is the handler for the devices health messages

func (*Service) SubscribeToActions

func (srv *Service) SubscribeToActions() error

SubscribeToActions subscribes to the published topics from the devices

Jump to

Keyboard shortcuts

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