Documentation
¶
Index ¶
- Variables
- func Float64Pointer(v float64) *float64
- func IntPointer(v int) *int
- func StringPointer(v string) *string
- func ValidateColumnMapping(columns map[string]string) error
- func ValidateRequestedColumns(columns map[string]string, requested []string) error
- func ZeroFloat64Pointer() *float64
- func ZeroIntPointer() *int
- func ZeroStringPointer() *string
- type Data
- type Fields
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidColumn = errors.New("invalid column") ErrMissingColumn = errors.New("missing mandatory column") )
var DefaultColumnMap map[string]string
DefaultColumnMap column mapping where each column has the default name.
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
Float64Pointer returns a pointer to the given float64.
func IntPointer ¶ added in v1.2.0
IntPointer returns a pointer to the given int.
func StringPointer ¶ added in v1.2.0
StringPointer returns a pointer to the given string.
func ValidateColumnMapping ¶ added in v1.3.2
ValidateColumnMapping validates that a given custom column mapping contains necessary fields to look up RuuviTag data.
func ValidateRequestedColumns ¶ added in v1.3.2
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
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 FromData ¶ added in v1.2.0
FromData copies all values from given Data struct regardless of whether they have nonzero value or not.
func NonZeroFields ¶ added in v1.2.0
NonZeroFields copies fields with non-zero value from the given Data struct.