things

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn        *nats.Conn
	EncodedConn *nats.EncodedConn
}

Client represents a Thigns client, holding the decoding and connection to the NATS server.

func NewClient

func NewClient(url, topic string) (*Client, error)

NewClient creates and returns a new Things client.

func (*Client) Close

func (c *Client) Close()

Close closes the connection to the server.

type Message

type Message struct {
	// Commands []Command       `json:"commands,omitempty"`
	// Device string `json:"id,omitempty"`
	// Events   []Event         `json:"events,omitempty"`
	Topic string `json:"topic,omitempty"`

	// sketch stats
	Sketch string `json:"sketch,omitempty"`

	// wifi stats
	BSSID string `json:"bssid,omitempty"`
	IP    string `json:"ip,omitempty"`
	RSSI  int    `json:"rssi,omitempty"`
	SSID  string `json:"ssid,omitempty"`

	// air stats
	Humidity    float32 `json:"humidity,omitempty"`
	Temperature float32 `json:"temperature,omitempty"`
	HeatIndex   float32 `json:"heatindex,omitempty"`
}

type MessageHandler

type MessageHandler func(chan Message)

type Server

type Server struct {
	URL         string
	Topic       string
	Conn        *nats.Conn
	EncodedConn *nats.EncodedConn
}

func NewServer

func NewServer(url, topic string) (*Server, error)

func (Server) Close

func (s Server) Close()

func (Server) Listen

func (s Server) Listen(messages chan Message)

Listen

Jump to

Keyboard shortcuts

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