Documentation ¶
Index ¶
- func MakeResource(namespace, service, instance string) *xbospb.Resource
- func Manage(cfg Config, drivers ...XBOSDriver) error
- func ParseResource(namespace, uri string) *xbospb.Resource
- func ResourceToString(res *xbospb.Resource) string
- type Config
- type Driver
- func (driver *Driver) AddActuationCallback(service, instance string, ...) error
- func (driver *Driver) AddReport(service, instance string, cb func() (*xbospb.XBOSIoTDeviceState, error)) error
- func (driver *Driver) AddToContext(triples []Triple)
- func (driver *Driver) BlockUntilError() error
- func (driver *Driver) ExitWithError(err error)
- func (driver *Driver) Report(service, instance string, msg *xbospb.XBOSIoTDeviceState) error
- func (driver *Driver) ReportContext(instance string) error
- func (driver *Driver) Respond(service, instance string, requestid uint64, msg *xbospb.XBOSIoTDeviceState) error
- type Triple
- type URI
- type XBOSDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeResource ¶
func Manage ¶
func Manage(cfg Config, drivers ...XBOSDriver) error
func ParseResource ¶
func ResourceToString ¶
Types ¶
type Config ¶
type Config struct { // base64 encoded namespace Namespace string // path to the entity file for this driver EntityFile string // local site router address SiteRouter string // default report rate ReportRate time.Duration Params map[string]interface{} }
Driver configuration struct
func ReadConfigFromEnviron ¶
func ReadConfigFromFile ¶
func (Config) GetStringSlice ¶
type Driver ¶
A Driver is a persistent process that handles the reporting+actuation to and from one or more devices
func (*Driver) AddActuationCallback ¶
func (driver *Driver) AddActuationCallback(service, instance string, cb func(msg *xbospb.XBOSIoTDeviceActuation, received time.Time) error) error
Call the given function whenever the driver receives an actuation request for a given device
func (*Driver) AddReport ¶
func (driver *Driver) AddReport(service, instance string, cb func() (*xbospb.XBOSIoTDeviceState, error)) error
Call the given function at config.ReportRate and publish the returned device state
func (*Driver) AddToContext ¶
add triples to the driver's context. These will be deduped automatically so adding triples is idempotent. This method does *not* report any triples; use ReportContext() to do this.
func (*Driver) BlockUntilError ¶
func (*Driver) ExitWithError ¶
func (*Driver) Report ¶
func (driver *Driver) Report(service, instance string, msg *xbospb.XBOSIoTDeviceState) error
This method is called by device drivers to publish a reading, encapsulated in an XBOSIoTDeviceState message. This is called automatically by AddReport(), which uses a regular timer. Respond() is used when publishing in response to the receipt of an actuation message If a time is not provided in msg, Report will add the current timestamp.
func (*Driver) ReportContext ¶
publishes the driver's device context TODO: where is good URI to publish this?