sensor

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidColumn = errors.New("invalid column")
	ErrMissingColumn = errors.New("missing mandatory column")
)
View Source
var DefaultColumnMap map[string]string

DefaultColumnMap column mapping where each column has the default name.

View Source
var DefaultColumns = []string{
	"time",
	"mac",
	"name",
	"temperature",
	"humidity",
	"pressure",
	"acceleration_x",
	"acceleration_y",
	"acceleration_z",
	"movement_counter",
	"measurement_number",
	"dew_point",
	"battery_voltage",
	"tx_power",
}

DefaultColumns names of fields contained in a RuuviTag v5 protocol transmission.

Functions

func Float64Pointer added in v1.2.0

func Float64Pointer(v float64) *float64

Float64Pointer returns a pointer to the given float64.

func IntPointer added in v1.2.0

func IntPointer(v int) *int

IntPointer returns a pointer to the given int.

func StringPointer added in v1.2.0

func StringPointer(v string) *string

StringPointer returns a pointer to the given string.

func ValidateColumnMapping added in v1.3.2

func ValidateColumnMapping(columns map[string]string) error

ValidateColumnMapping validates that a given custom column mapping contains necessary fields to look up RuuviTag data.

func ValidateRequestedColumns added in v1.3.2

func ValidateRequestedColumns(columns map[string]string, requested []string) error

ValidateRequestedColumns validates that given requested columns conform to given custom column mapping.

The custom column mapping is expected to be validated with ValidateColumnMapping prior to calling this function.

func ZeroFloat64Pointer added in v1.2.0

func ZeroFloat64Pointer() *float64

ZeroFloat64Pointer returns a pointer to a float64 with zero value.

func ZeroIntPointer added in v1.2.0

func ZeroIntPointer() *int

ZeroIntPointer returns a pointer to an int with zero value.

func ZeroStringPointer added in v1.2.0

func ZeroStringPointer() *string

ZeroStringPointer returns a *string pointer to an empty string.

Types

type Data

type Data struct {
	Timestamp         time.Time `json:"time"`
	Addr              string    `json:"mac"`
	Name              string    `json:"name"`
	Temperature       float64   `json:"temperature"`
	Humidity          float64   `json:"humidity"`
	DewPoint          float64   `json:"dew_point"`
	Pressure          float64   `json:"pressure"`
	BatteryVoltage    float64   `json:"battery_voltage"`
	TxPower           int       `json:"tx_power"`
	AccelerationX     int       `json:"acceleration_x"`
	AccelerationY     int       `json:"acceleration_y"`
	AccelerationZ     int       `json:"acceleration_z"`
	MovementCounter   int       `json:"movement_counter"`
	MeasurementNumber int       `json:"measurement_number"`
}

Data contains all fields of a RuuviTag v5 measurement.

func FromFields added in v1.2.0

func FromFields(f Fields) Data

FromFields creates a new Data struct by copying all non-zero pointer values from the given Fields struct.

type Fields added in v1.2.0

type Fields struct {
	Timestamp         time.Time `json:"time"`
	Addr              *string   `json:"mac,omitempty"`
	Name              *string   `json:"name,omitempty"`
	Temperature       *float64  `json:"temperature,omitempty"`
	Humidity          *float64  `json:"humidity,omitempty"`
	DewPoint          *float64  `json:"dew_point,omitempty"`
	Pressure          *float64  `json:"pressure,omitempty"`
	BatteryVoltage    *float64  `json:"battery_voltage,omitempty"`
	TxPower           *int      `json:"tx_power,omitempty"`
	AccelerationX     *int      `json:"acceleration_x,omitempty"`
	AccelerationY     *int      `json:"acceleration_y,omitempty"`
	AccelerationZ     *int      `json:"acceleration_z,omitempty"`
	MovementCounter   *int      `json:"movement_counter,omitempty"`
	MeasurementNumber *int      `json:"measurement_number,omitempty"`
}

Fields contains all fields of a RuuviTag v5 measurement, but only the time field is mandatory. To be used e.g. with REST APIs that do not need to return empty fields.

func AllZeroFields added in v1.2.0

func AllZeroFields() Fields

AllZeroFields creates a Fields struct with all pointer values set to a zero number.

func FieldsFromColumns added in v1.3.1

func FieldsFromColumns(d Data, columns []string) Fields

func FromData added in v1.2.0

func FromData(d Data) Fields

FromData copies all values from given Data struct regardless of whether they have nonzero value or not.

func NonZeroFields added in v1.2.0

func NonZeroFields(d Data) Fields

NonZeroFields copies fields with non-zero value from the given Data struct.

Jump to

Keyboard shortcuts

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