devices

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2025 License: BSD-2-Clause Imports: 2 Imported by: 0

README

devices

Some sensor type devices written in Go

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

View Source
var (
	ErrNotFound           = errors.New("device not found")
	ErrDeviceExists       = errors.New("device already exists")
	ErrTypeMismatch       = errors.New("device registered with different type")
	ErrTypeNotImplemented = errors.New("method not implemented")
)
View Source
var (
	ErrNotImplemented = errors.New("Method is not implemented")
)

Functions

func IsMock

func IsMock() bool

func SetMock

func SetMock(v bool)

Types

type Device

type Device[T any] interface {
	ID() string
	Type() Type
	Open() error
	Close() error

	Get() (T, error)
	Set(v T) error
}

type DeviceManager

type DeviceManager struct {
	// contains filtered or unexported fields
}

func NewDeviceManager

func NewDeviceManager() *DeviceManager

func (*DeviceManager) Add

func (m *DeviceManager) Add(d Device[any]) error

Register a typed device. Fails if name already used with a different T.

func (*DeviceManager) Get

func (m *DeviceManager) Get(name string) (Device[any], error)

type DeviceState

type DeviceState uint8
const (
	StateUnknown DeviceState = iota
	StateInitializing
	StateRunning
	StateError
	StateStopped
)

type Type

type Type uint8
const (
	TypeBool Type = iota
	TypeInt
	TypeFloat
	TypeAny
	TypeBME280
	TypeGPS
)

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

Jump to

Keyboard shortcuts

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