interfaces

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Debugger

type Debugger interface {
	Debug()
}

TODO: Debugger is an optional interface implemented by driver that support debugging for device profile.

type DeviceHandler

type DeviceHandler interface {
	// AddDevice is a callback function that is invoked when a new device associated with this driver is added
	AddDevice(device *contracts.Device) error
	// UpdateDevice is a callback function that is invoked when a device associated with this driver is updated
	UpdateDevice(device *contracts.Device) error
	// RemoveDevice is a callback function that is invoked when a device associated with this driver is removed
	RemoveDevice(device *contracts.Device) error
}

DeviceHandler is an optional interface to handle the system event of device

type Discovery

type Discovery interface {
	// Discover triggers protocol specific device discovery.
	Discover(ctx context.Context, param *requests.DiscoveryParameter, deviceCh chan<- *contracts.Device)
}

Discovery is an optional interface implemented by driver that support dynamic device discovery.

type Driver

type Driver interface {
	// Initialize performs protocol-specific initialization for the device service.
	// The given *AsyncValues channel can be used to push asynchronous readings to Core Data.
	Initialize(logger logger.Logger, asyncCh chan<- *contracts.AsyncValues) error
	// ReadProperty passes a slice of ReadRequest each representing a read operation for the specific device resource.
	// The device service has the flexibility to set the final result of the request.
	// SetResult: set the value read by driver instance.
	// Failed: set error encountered when performing a read operation.
	// Skip: just skip the request.
	ReadProperty(device *contracts.Device, reqs []contracts.ReadRequest) error
	// WriteProperty passes a slice of WriteRequest each representing a write operation for the specific device resource.
	// The parameter can be obtained through the Param function.
	WriteProperty(device *contracts.Device, reqs []contracts.WriteRequest) error
	// CallService passes a CallRequest which representing a service call operation for the specific device resource.
	// The payload can be obtained through the Payload function.
	CallService(device *contracts.Device, reqs []contracts.CallRequest) error
	// Stop instructs the protocol-specific DS code to shut down gracefully, or
	// if the force parameter is 'true', immediately. The driver is responsible
	// for closing any in-use channels, including the channel used to send async
	// readings (if supported).
	Stop(force bool) error
}

Driver is a minimal interface to interact with a specific class of devices.

type Reporter added in v1.1.0

type Reporter interface {
	ReportEvent(event *contracts.AsyncValues) error
}

Reporter is the interface to report device events

type StatusManager added in v1.1.0

type StatusManager interface {
	// OnAddDevice is a callback function that is invoked when a new device is added
	OnAddDevice(deviceName string)
	// OnRemoveDevice is a callback function that is invoked when a device is removed
	OnRemoveDevice(deviceName string)
	// OnHandleCommandsFailed is a callback function that is invoked when failed to
	// handle read/write commands or call service.
	OnHandleCommandsFailed(deviceName string, n int64)
	// OnHandleCommandsSuccessfully is a callback function that is invoked when handling
	// read/write commands or calling service or reporting async data
	OnHandleCommandsSuccessfully(deviceName string, n int64)
	// SetDeviceOffline will set the specified device to offline status
	SetDeviceOffline(deviceName string, reason string)
	// SetDeviceOnline will set the specified device to online status
	SetDeviceOnline(deviceName string)
	// UpdateDeviceStatus supports to set the customized device status.
	UpdateDeviceStatus(deviceName string, status string, reason string)
}

type Webhook added in v1.1.6

type Webhook interface {
	OnStreamNotFound(ctx context.Context, schema string, deviceName string) error
	OnStreamNoneReader(ctx context.Context, schema string, deviceName string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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