cayennelpp

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 4 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// DigitalInput (1 byte)
	DigitalInput = 0
	// DigitalOutput (1 byte)
	DigitalOutput = 1
	// AnalogInput (2 bytes, 0.01 signed)
	AnalogInput = 2
	// AnalogOutput (2 bytes, 0.01 signed)
	AnalogOutput = 3
	// Luminosity (2 bytes, 1 lux unsigned)
	Luminosity = 101
	// Presence (1 byte, 1)
	Presence = 102
	// Temperature (2 bytes, 0.1°C signed)
	Temperature = 103
	// RelativeHumidity (1 byte, 0.5% unsigned )
	RelativeHumidity = 104
	// Accelerometer 2 bytes per axis, 0.001G
	Accelerometer = 113
	// BarometricPressure (2 bytes 0.1 hPa Unsigned)
	BarometricPressure = 115
	// Gyrometer (2 bytes per axis, 0.01 °/s)
	Gyrometer = 134
	// GPS (3 byte lon/lat 0.0001 °, 3 bytes alt 0.01 meter)
	GPS = 136
)

Variables

View Source
var ErrInvalidChannelType = errors.New("cayennelpp: unknown type")

ErrInvalidChannelType indicates that the channel type is invalid.

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	DecodeUplink(target UplinkTarget) error
	DecodeDownlink(target DownlinkTarget) error
}

Decoder decodes CayenneLPP encoded values.

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder instantiates a CayenneLPP decoder.

type DownlinkTarget

type DownlinkTarget interface {
	Port(channel uint8, value float64)
}

DownlinkTarget represents a target that processes decoded downlink values.

type Encoder

type Encoder interface {
	Grow(n int)
	Bytes() []byte
	Reset()
	WriteTo(w io.Writer) (int64, error)
	AddPort(channel uint8, value float64)
	AddDigitalInput(channel, value uint8)
	AddDigitalOutput(channel, value uint8)
	AddAnalogInput(channel uint8, value float64)
	AddAnalogOutput(channel uint8, value float64)
	AddLuminosity(channel uint8, value uint16)
	AddPresence(channel, value uint8)
	AddTemperature(channel uint8, celcius float64)
	AddRelativeHumidity(channel uint8, rh float64)
	AddAccelerometer(channel uint8, x, y, z float64)
	AddBarometricPressure(channel uint8, hpa float64)
	AddGyrometer(channel uint8, x, y, z float64)
	AddGPS(channel uint8, latitude, longitude, meters float64)
}

Encoder encodes values to CayenneLPP.

func NewEncoder

func NewEncoder() Encoder

NewEncoder instantiates an CayenneLPP encoder.

type UplinkTarget

type UplinkTarget interface {
	DigitalInput(channel, value uint8)
	DigitalOutput(channel, value uint8)
	AnalogInput(channel uint8, value float64)
	AnalogOutput(channel uint8, value float64)
	Luminosity(channel uint8, value uint16)
	Presence(channel, value uint8)
	Temperature(channel uint8, celcius float64)
	RelativeHumidity(channel uint8, rh float64)
	Accelerometer(channel uint8, x, y, z float64)
	BarometricPressure(channel uint8, hpa float64)
	Gyrometer(channel uint8, x, y, z float64)
	GPS(channel uint8, latitude, longitude, altitude float64)
}

UplinkTarget represents a target that processes decoded uplink values.

Jump to

Keyboard shortcuts

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