Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder interface { DecodeEntry([]byte) (Entry, error) DecodeMessage([]byte) (Message, error) }
Decoder interface
type Encoder ¶
type Encoder interface { EncodeMessage(*Message) ([]byte, error) EncodeEntry(*Entry) ([]byte, error) }
Encoder interface
type Entry ¶
type Entry struct { Name string `json:"n,omitempty"` Units string `json:"u,omitempty"` Value *float64 `json:"v,omitempty"` StringValue *string `json:"sv,omitempty"` BooleanValue *bool `json:"bv,omitempty"` Sum *float64 `json:"s,omitempty"` Time int64 `json:"t,omitempty"` UpdateTime int64 `json:"ut,omitempty"` }
Entry is a measurement of Parameter Entry
type JSONDecoder ¶
type JSONDecoder struct{}
JSONDecoder decodes SenML messages from JSON
func (*JSONDecoder) DecodeEntry ¶
func (jd *JSONDecoder) DecodeEntry(data []byte) (Entry, error)
DecodeEntry decodes a SenML entry from JSON
func (*JSONDecoder) DecodeMessage ¶
func (jd *JSONDecoder) DecodeMessage(data []byte) (Message, error)
DecodeMessage decodes a SenML messages from JSON
type JSONEncoder ¶
type JSONEncoder struct{}
JSONEncoder encodes SenML messages to JSON
func (*JSONEncoder) EncodeEntry ¶
func (je *JSONEncoder) EncodeEntry(e *Entry) ([]byte, error)
EncodeEntry encodes a SenML entry to JSON
func (*JSONEncoder) EncodeMessage ¶
func (je *JSONEncoder) EncodeMessage(m *Message) ([]byte, error)
EncodeMessage encodes a SenML message to JSON
type Message ¶
type Message struct { BaseName string `json:"bn,omitempty"` BaseTime int64 `json:"bt,omitempty"` BaseUnits string `json:"bu,omitempty"` Version int `json:"ver"` Entries []Entry `json:"e"` }
Message is the root SenML variable
func NewMessage ¶
NewMessage creates a SenML message from a number of entries
func (*Message) Compact ¶
Compact returns a copy of the message with all Entries compacted (common data put into Message)
Click to show internal directories.
Click to hide internal directories.