Documentation ¶
Overview ¶
Package app contains helper functions to create application and drivers
Drivers are standalone applications that control devices. A driver is an app which registers its' devices to the inventory and responds to commands to devices under its' control
Index ¶
- type App
- func (app *App) Debug() bool
- func (app *App) DeviceList() []*message.Device
- func (app *App) FilterMessages(b bool)
- func (app *App) GCDeviceList(t time.Time)
- func (app *App) NewDevice(name string) *message.Device
- func (app *App) Publish(topic queue.Topic, m message.Message)
- func (app *App) Register(devices ...*message.Device)
- func (app *App) RegisterAll(to string)
- func (app *App) SetHandler(topic queue.Topic, handler message.Handler)
- func (app *App) Start() (err error)
- func (app *App) Stop()
- func (app *App) Unregister(devices ...*message.Device)
- func (app *App) UnregisterAll(to string)
- func (app *App) Wait()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { ID string Log log.Logger Name string Broker *mqtt.ClientConn Signal chan os.Signal // contains filtered or unexported fields }
App is a helper to create a driver or application. It takes away the burden of (un)registering devices at startup and responding to discovery messages.
func (*App) DeviceList ¶
DeviceList will return the list of devices
func (*App) FilterMessages ¶
FilterMessages allows the app to control automatic message filtering By default messages are filtered
func (*App) GCDeviceList ¶
GCDeviceList will remove all devices older then time t
func (*App) RegisterAll ¶
RegisterAll will send the Register message to the inventory.
func (*App) SetHandler ¶
SetHandler will set the message handler
func (*App) Start ¶
Start starts this app. It connects to the message hub and registers devices. It also starts a goroutine to respond to discovery messages.
func (*App) Stop ¶
func (app *App) Stop()
Stop will stop this app. It will stop the discovery goroutine, disconnect from the message hub and close its connection.
func (*App) Unregister ¶
Unregister will remove the devices from this app.
func (*App) UnregisterAll ¶
UnregisterAll will unregister all devices from the inventory. This is usually done on shutdown.