dongle

package
v0.0.0-...-9418f78 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailER06 represents bad request error.
	ErrFailER06 = errors.New("ER06")
)
View Source
var (
	// ErrFatal is not retriable error.
	ErrFatal = errors.New("Fatal error")
)

Functions

This section is empty.

Types

type BP35C2

type BP35C2 struct {
	// contains filtered or unexported fields
}

BP35C2 is BP35C0/BP35C2 client implementation.

func NewBP35C2

func NewBP35C2(serialDevice string, baudrate int, readTimeout time.Duration) *BP35C2

NewBP35C2 returns command wrapper for BP35C2.

func (*BP35C2) Close

func (d *BP35C2) Close()

Close closes serial device.

func (*BP35C2) Connect

func (d *BP35C2) Connect() error

Connect connects serial device.

func (*BP35C2) SKINFO

func (d *BP35C2) SKINFO() (*EINFO, error)

SKINFO returns network informations.

func (*BP35C2) SKJOIN

func (d *BP35C2) SKJOIN(ipv6Addr string) error

SKJOIN starts PANA session.

func (*BP35C2) SKLL64

func (d *BP35C2) SKLL64(addr string) (string, error)

SKLL64 returns IPv6 link-local address from MAC address.

func (*BP35C2) SKSCAN

func (d *BP35C2) SKSCAN() (*PAN, error)

SKSCAN scans PAN.

func (*BP35C2) SKSENDTO

func (d *BP35C2) SKSENDTO(handle, ipAddr, port, sec string, data []byte) (string, error)

SKSENDTO sends UDP data.

func (*BP35C2) SKSETPWD

func (d *BP35C2) SKSETPWD(pwd string) error

SKSETPWD generates PSK from pwd and register.

func (*BP35C2) SKSETRBID

func (d *BP35C2) SKSETRBID(rbid string) error

SKSETRBID generates Route-B ID from rbid and register.

func (*BP35C2) SKSREG

func (d *BP35C2) SKSREG(k, v string) error

SKSREG registers virtual register.

func (*BP35C2) SKTERM

func (d *BP35C2) SKTERM() error

SKTERM terminates PANA session.

func (*BP35C2) SKVER

func (d *BP35C2) SKVER() (string, error)

SKVER returns firmware version.

func (*BP35C2) SetIP

func (d *BP35C2) SetIP(ip string)

SetIP sets ipv6 address of client.

func (*BP35C2) SetRemoteIP

func (d *BP35C2) SetRemoteIP(ip string)

SetRemoteIP sets ipv6 address of remote.

type Client

type Client struct {
	Logger   *zap.Logger
	Dongle   Dongle
	Ipv6addr string
	// contains filtered or unexported fields
}

Client represents abstract layer for dongle.

func New

func New(dongle Dongle, opts ...Option) *Client

New returns dongle wrapper.

func (*Client) Close

func (du *Client) Close()

Close closes connection.

func (*Client) Fetch

func (du *Client) Fetch(ctx context.Context, f func(time time.Time, watt int64)) error

Fetch fetches electric energy consumption [watt].

func (*Client) Init

func (du *Client) Init() error

Init initialises connection.

type Dongle

type Dongle interface {
	Connect() error
	Close()

	SKVER() (string, error)
	SKINFO() (*EINFO, error)
	SetIP(ip string)
	SetRemoteIP(ip string)

	SKSETPWD(pwd string) error
	SKSETRBID(rbid string) error
	SKSCAN() (*PAN, error)
	SKSREG(k, v string) error
	SKLL64(addr string) (string, error)
	SKJOIN(ipv6Addr string) error
	SKSENDTO(handle, ipAddr, port, sec string, data []byte) (string, error)
}

Dongle represents command wrapper.

type EINFO

type EINFO struct {
	IP      string
	MAC     string
	Channel string
	PanID   string
	Side    string
}

EINFO is event data for SKINFO.

type Logger

type Logger zap.Logger

Logger represents logger parameter option.

func NewLogger

func NewLogger(l *zap.Logger) *Logger

NewLogger returns logger option.

func (*Logger) Apply

func (l *Logger) Apply(d *Client)

Apply applies logger parameter.

type Option

type Option interface {
	// Apply applies client options.
	Apply(*Client)
}

Option represents hems client option.

type PAN

type PAN struct {
	Channel     string
	ChannelPage string
	PanID       string
	Addr        string
	LQI         string
	PairID      string
}

PAN is Personal Area Network.

type Pwd

type Pwd string

Pwd represents pwd parameter option.

func NewPwd

func NewPwd(v string) Pwd

NewPwd returns pwd option.

func (Pwd) Apply

func (p Pwd) Apply(d *Client)

Apply applies pwd parameter.

type RbID

type RbID string

RbID represents rbID parameter option.

func NewRbID

func NewRbID(v string) RbID

NewRbID returns rbID option.

func (RbID) Apply

func (r RbID) Apply(d *Client)

Apply applies rbID parameter.

Jump to

Keyboard shortcuts

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