codec

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CodecMaxExecTime = 10 * time.Millisecond

CodecMaxExecTime holds the max. time the (custom) codec is allowed to run.

Functions

This section is empty.

Types

type Accelerometer

type Accelerometer struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

Accelerometer defines the accelerometer data.

type CayenneLPP

type CayenneLPP struct {
	DigitalInput      map[byte]uint8         `json:"digitalInput,omitempty" influxdb:"digital_input"`
	DigitalOutput     map[byte]uint8         `json:"digitalOutput,omitempty" influxdb:"digital_output"`
	AnalogInput       map[byte]float64       `json:"analogInput,omitempty" influxdb:"analog_input"`
	AnalogOutput      map[byte]float64       `json:"analogOutput,omitempty" influxdb:"analog_output"`
	IlluminanceSensor map[byte]uint16        `json:"illuminanceSensor,omitempty" influxdb:"illuminance_sensor"`
	PresenceSensor    map[byte]uint8         `json:"presenceSensor,omitempty" influxdb:"presence_sensor"`
	TemperatureSensor map[byte]float64       `json:"temperatureSensor,omitempty" influxdb:"temperature_sensor"`
	HumiditySensor    map[byte]float64       `json:"humiditySensor,omitempty" influxdb:"humidity_sensor"`
	Accelerometer     map[byte]Accelerometer `json:"accelerometer,omitempty" influxdb:"accelerometer"`
	Barometer         map[byte]float64       `json:"barometer,omitempty" influxdb:"barometer"`
	Gyrometer         map[byte]Gyrometer     `json:"gyrometer,omitempty" influxdb:"gyrometer"`
	GPSLocation       map[byte]GPSLocation   `json:"gpsLocation,omitempty" influxdb:"gps_location"`
}

CayenneLPP defines the Cayenne LPP data structure.

func (*CayenneLPP) DecodeBytes

func (c *CayenneLPP) DecodeBytes(data []byte) error

DecodeBytes decodes the payload from a slice of bytes.

func (CayenneLPP) EncodeToBytes

func (c CayenneLPP) EncodeToBytes() ([]byte, error)

EncodeToBytes encodes the payload to a slice of bytes.

func (CayenneLPP) Object

func (c CayenneLPP) Object() interface{}

Object returns the CayenneLPP data object.

type CustomJS

type CustomJS struct {
	Data interface{}
	// contains filtered or unexported fields
}

CustomJS is a scriptable JS codec.

func NewCustomJS

func NewCustomJS(fPort uint8, encodeScript, decodeScript string) *CustomJS

NewCustomJS creates a new custom JS codec.

func (*CustomJS) DecodeBytes

func (c *CustomJS) DecodeBytes(data []byte) (err error)

DecodeBytes decodes the payload from a slice of bytes.

func (CustomJS) EncodeToBytes

func (c CustomJS) EncodeToBytes() (b []byte, err error)

EncodeToBytes encodes the payload to a slice of bytes.

func (CustomJS) MarshalJSON

func (c CustomJS) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (CustomJS) Object

func (c CustomJS) Object() interface{}

Object returns the object data.

func (*CustomJS) UnmarshalJSON

func (c *CustomJS) UnmarshalJSON(text []byte) error

UnmarshalJSON implement json.Unmarshaler.

type GPSLocation

type GPSLocation struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Altitude  float64 `json:"altitude"`
}

GPSLocation defines the GPS location data.

type Gyrometer

type Gyrometer struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

Gyrometer defines the gyrometer data.

type Payload

type Payload interface {
	DecodeBytes(data []byte) error
	EncodeToBytes() ([]byte, error)
	Object() interface{}
}

Payload defines a codec payload.

func NewPayload

func NewPayload(t Type, fPort uint8, encodeScript, decodeScript string) Payload

NewPayload returns a new codec payload. In case of an unknown Type, nil is returned.

type Type

type Type string

Type defines the codec type.

const (
	CayenneLPPType Type = "CAYENNE_LPP"
	CustomJSType   Type = "CUSTOM_JS"
)

Available codec types.

Jump to

Keyboard shortcuts

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