sensor

package
v0.0.0-...-aa48383 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeFake = iota + 1
	TypeAtmospheric
)

Variables

This section is empty.

Functions

func NameByType

func NameByType(typ int) string

NameByType maps human readable names to sensor types

Types

type AtmosphericDataLine

type AtmosphericDataLine struct {
	Timestamp   time.Time
	Temperature float32
	Humidity    float32
	Pressure    float32
	Altitude    float32
	VOCIndex    float32
}

func ParseValidAtmosphericSensorLine

func ParseValidAtmosphericSensorLine(line string) AtmosphericDataLine

ParseValidAtmosphericSensorLine assumes the sensor line is well-formed. If a part is missing, an empty struct is returned. If all parts are present but not valid types, that field will be unset.

type AtmosphericSensor

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

AtmosphericSensor tracks sensor input from the BME280 and SGP40 sensor boards from Adafruit

func NewAtmospheric

func NewAtmospheric(executable string, sensorPollFreqSec int) *AtmosphericSensor

func (*AtmosphericSensor) Close

func (a *AtmosphericSensor) Close()

func (*AtmosphericSensor) Data

func (a *AtmosphericSensor) Data() (chan Data, chan error)

func (*AtmosphericSensor) Init

func (a *AtmosphericSensor) Init() error

func (*AtmosphericSensor) Ping

func (a *AtmosphericSensor) Ping() error

func (*AtmosphericSensor) Type

func (a *AtmosphericSensor) Type() uint8

func (*AtmosphericSensor) TypeStr

func (a *AtmosphericSensor) TypeStr() string

type Data

type Data struct {
	Typ  uint8
	Data []byte
}

Data is the wire format for sensor readings

type FakeSensor

type FakeSensor struct {
	Buf string
}

func (*FakeSensor) Close

func (f *FakeSensor) Close()

func (*FakeSensor) Data

func (f *FakeSensor) Data() (chan Data, chan error)

func (*FakeSensor) Init

func (f *FakeSensor) Init() error

func (*FakeSensor) Ping

func (f *FakeSensor) Ping() error

func (*FakeSensor) Type

func (f *FakeSensor) Type() uint8

func (*FakeSensor) TypeStr

func (f *FakeSensor) TypeStr() string

type Sensor

type Sensor interface {
	// Type denotes the sensor type in the message.
	// If type is 0, it corresponds to a non-data message (ping, etc)
	Type() uint8
	TypeStr() string
	// Init starts or initializes the connection with the sensor
	Init() error
	Ping() error
	// Data returns error and data channels from the sensor.
	// The channels do not have to be buffered
	Data() (chan Data, chan error)
	Close()
}

Jump to

Keyboard shortcuts

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