Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicCapability ¶
type BasicCapability interface {
Capability() Capability
Name() string
}
type CapabilityAdded ¶
type CapabilityAdded struct {
// Device with new capability.
Device Device
// Capability being added.
Capability Capability
}
CapabilityAdded signals a new capability has been added to the device.
type CapabilityRemoved ¶
type CapabilityRemoved struct {
// Device with new capability.
Device Device
// Capability being added.
Capability Capability
}
CapabilityRemoved signals a capability is being removed from the device.
type Device ¶
type Device interface {
// Gateway returns the parent gateway.
Gateway() Gateway
// Identifier returns a unique identifier for this device.
Identifier() Identifier
// Capabilities returns a slice of capabilities this Device supports.
Capabilities() []Capability
// Capability returns the concrete implementation of the capability.
Capability(Capability) BasicCapability
}
Device is a set of interfaces that define the identity and capabilities of an abstracted device.
type DeviceAdded ¶
type DeviceAdded struct {
// Device added.
Device Device
}
DeviceAdded has been added to the gateway. Listen for CapabilityAdded to know what abilities are added to the Device.
type DeviceRemoved ¶
type DeviceRemoved struct {
// Device removed.
Device Device
}
DeviceRemoved has been removed from gateway.
type Gateway ¶
type Gateway interface {
// ReadEvent from the gateway about devices, this must always be serviced. context.DeadlineExceeded will be
// returned if the context expires during a read. Use this mechanism if you can not indefinitely wait for an event.
ReadEvent(context.Context) (interface{}, error)
// Capabilities returns a list of all Capabilities that the gateway can support.
Capabilities() []Capability
// Self fetches a device which represents the gateway, this allows a gateway to have optional capabilities.
Self() Device
// Devices fetch a list of all devices on the gateway, including its self.
Devices() []Device
// Start the gateway, including any background routines required. The context is only for the process of starting
// a gateway.
Start(context.Context) error
// Stop the gateway, including any background routines required. Gateways are not required to be reusable,
// and a new gateway should be created if a restart is required. The context is only for the process of stopping
// a gateway.
Stop(context.Context) error
}
Gateway is a provider of devices and Capability objects to control them
type Identifier ¶
type Identifier interface {
// String from identifier.
String() string
}
Identifier provides an interface for any piece of data that uniquely identifies a device within a system.
Click to show internal directories.
Click to hide internal directories.