da

package module
v0.0.0-...-c921021 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: Apache-2.0 Imports: 1 Imported by: 18

README

Shimmering Bee: Device Adapter

license standard-readme compliant Actions Status

Abstractions of common device functionality for Shimmering Bee, written in Go.

Table of Contents

Background

The Device Adapter is a suite of interfaces which define standard behaviour for devices to interact with, including an actual device gateway.

Install

Add an import and most IDEs will go get automatically, if it doesn't go build will fetch.

import "github.com/shimmeringbee/da"

Usage

This libraries API is unstable and should not yet be relied upon.

This piece of software is not ready for general use.

Maintainers

@pwood

Contributing

Feel free to dive in! Open an issue or submit PRs.

All Shimmering Bee projects follow the Contributor Covenant Code of Conduct.

License

Copyright 2019-2020 Shimmering Bee Contributors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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 Capability

type Capability uint16

Capability identifier.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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