unitlinq

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

Unitlinq Golang SDK

unitlinq-iot-sdk-go is the official SDK. Check out the official documentation for detailed description of functionalities

Documentation

Index

Constants

View Source
const (
	Memory int = 0
	File   int = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	TlsConfig tls.Config
	MQTT      mqtt.Client
	ClientID  uuid.UUID
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance(options ClientOptions) (Client, error)

Create a new instance of unitlinq client. You can create as many instance you want. The only restriction is that you can not use same client certificate more than once.

func (*Client) CheckRemoteConfig

func (c *Client) CheckRemoteConfig() (ConfigMetaDataResp, bool, error)

func (*Client) Close

func (c *Client) Close()

Close the connection

func (*Client) Connect

func (c *Client) Connect() Token

Establish a connection with unitlinq server

func (*Client) EnergyGateWay added in v0.0.6

func (c *Client) EnergyGateWay(data EnergyStruct, node uuid.UUID) Token

Act as a gateway, Send energy data on behalf of other node. Please note that to act as a gateway for other device, both devices must be registered with the unitlinq platform

func (*Client) GetClientID

func (c *Client) GetClientID() string

Get client ID string parsed from client certificate

func (*Client) GetRemoteConfig

func (c *Client) GetRemoteConfig() (ConfigResp, bool, error)

func (*Client) IsConnected

func (c *Client) IsConnected() bool

Check whether connection is active or not. Returns true if connection is active

func (*Client) NPFloatGateWay added in v0.0.6

func (c *Client) NPFloatGateWay(data NodeParamFloat, node uuid.UUID) Token

Act as a gateway, send parameter data on behalf of other node. Please note that to act as a gateway for other device, both devices must be registered with the unitlinq platform

func (*Client) PushEnergyData

func (c *Client) PushEnergyData(data EnergyStruct) Token

Push Energy readings to the unitlinq platfrom.

func (*Client) PushFloatNP

func (c *Client) PushFloatNP(datapoint NodeParamFloat) Token

type ClientOptions

type ClientOptions struct {
	Cert           string
	CertKey        string
	StorageType    int
	Store          string
	RequestTimeout time.Duration
	OnConnect      OnConnectCallback
	OnConnLost     OnConnLostCallback
}

ClientOptions - A struct describing the client options

type ConfigMetaDataResp

type ConfigMetaDataResp struct {
	UpdatedOn int32 `cbor:"updatedon"`
}

type ConfigResp

type ConfigResp struct {
	Data []byte `cbor:"data"`
}

type EnergyStruct

type EnergyStruct struct {
	V1          float32
	V2          float32
	V3          float32
	V12         float32
	V23         float32
	V31         float32
	I1          float32
	I2          float32
	I3          float32
	Pf1         float32
	Pf2         float32
	Pf3         float32
	W1          float32
	W2          float32
	W3          float32
	ImportkWh   float32
	Exportkwh   float32
	ImportkVArh float32
	ExportkVArh float32
	Freq        float32
	Timestamp   int64
}

func NewDefaultEnergyStruct added in v0.0.6

func NewDefaultEnergyStruct() EnergyStruct

type NodeParamFloat

type NodeParamFloat struct {
	ParamID   []byte
	Value     float32
	Timestamp int64
}

func NewDefaultNpFloat added in v0.0.6

func NewDefaultNpFloat() NodeParamFloat

type OnConnLostCallback added in v0.0.5

type OnConnLostCallback func(Client, error)

type OnConnectCallback added in v0.0.5

type OnConnectCallback func(Client)

type ResponseCallback

type ResponseCallback func(requestID int, payload []byte)

type Subscripiton

type Subscripiton struct {
	Topic    string
	Qos      byte
	Callback mqtt.MessageHandler
}

type Token

type Token = mqtt.Token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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