Documentation
¶
Overview ¶
Package device provides a framework for managing hardware devices with support for messaging, periodic operations, and state management. Devices can be controlled via MQTT messages and can publish their state and data periodically.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Device ¶
type Device struct {
Name string // Human readable device name
State DeviceState // Current device state
Period time.Duration // Period for timed operations
Val any // Mock value storage
Opener // Device opening interface
// contains filtered or unexported fields
}
Device represents a physical or virtual device with messaging capabilities
type DeviceManager ¶
type DeviceManager struct {
// contains filtered or unexported fields
}
DeviceManager handles the registration and retrieval of devices. It ensures thread-safe access to the device collection.
func GetDeviceManager ¶
func GetDeviceManager() *DeviceManager
GetDeviceManager returns the singleton instance of DeviceManager. It ensures thread-safe initialization and access to the device manager.
func (*DeviceManager) Add ¶
func (dm *DeviceManager) Add(d Name) error
Add registers a new device with the manager. If a device with the same name exists, it will be replaced.
func (*DeviceManager) Clear ¶
func (dm *DeviceManager) Clear()
Clear removes all devices from the manager.
func (*DeviceManager) Get ¶
func (dm *DeviceManager) Get(name string) (Name, bool)
Get retrieves a device by name. Returns the device and true if found, nil and false otherwise.
func (*DeviceManager) List ¶
func (dm *DeviceManager) List() []string
List returns a slice of all registered device names.
func (*DeviceManager) Remove ¶
func (dm *DeviceManager) Remove(name string) bool
Remove removes a device from the manager. Returns true if the device was removed, false if it didn't exist.
type DeviceState ¶
type DeviceState string
DeviceState represents the current operational state of a device
const ( StateUnknown DeviceState = "unknown" StateInitializing DeviceState = "initializing" StateRunning DeviceState = "running" StateError DeviceState = "error" StateStopped DeviceState = "stopped" )
type Name ¶
type Name interface {
Name() string
}
Name represents a device that has a human-readable name.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bme280 provides a driver for the BME280 temperature, humidity, and pressure sensor using I2C communication.
|
Package bme280 provides a driver for the BME280 temperature, humidity, and pressure sensor using I2C communication. |
|
The drivers include GPIO (digital), analog (via ads1115), serial, I2C at this point.
|
The drivers include GPIO (digital), analog (via ads1115), serial, I2C at this point. |
|
examples
|
|
|
ads1115
command
|
|
|
blink
command
|
|
|
bme280
command
|
|
|
gtu7
command
|
|
|
json
command
|
|
|
oled
command
|
|
|
relay
command
|
|
|
switch
command
|
|
|
vh400
command
|
|