base

package
v0.0.0-...-aecb995 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	// Connect initiates connection and starts is message loop, delivering all received messages to receiver.
	Connect(host, port string, receiver Receiver)
	// ExpectRead tells connection that a read is imminent, so it knows there is trouble if not received in time.
	ExpectRead()
	// SendMessage tells connection to send the given message.
	SendMessage(message []byte)
}

func NewTLSSocketConnection

func NewTLSSocketConnection() Connection

type Controller

type Controller interface {
	SetStateNotifier(stateNotifier StateNotifier)
	Connect()
	SetPowerMode(powerMode string)
	SetOpMode(mode string)
	SetFanMode(fanMode string)
	SetTemperature(temperature string)
}

type MQTT

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

func NewMQTT

func NewMQTT(broker string, clientId string) *MQTT

func (*MQTT) Connect

func (m *MQTT) Connect()

func (*MQTT) RegisterController

func (m *MQTT) RegisterController(id string, prefix string, controller Controller) StateNotifier

type MQTTNotifier

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

func (*MQTTNotifier) UpdateAction

func (m *MQTTNotifier) UpdateAction(action string)

func (*MQTTNotifier) UpdateAttributes

func (m *MQTTNotifier) UpdateAttributes(attributes map[string]string)

func (*MQTTNotifier) UpdateCurrentTemperature

func (m *MQTTNotifier) UpdateCurrentTemperature(temperature string)

func (*MQTTNotifier) UpdateFanMode

func (m *MQTTNotifier) UpdateFanMode(fanMode string)

func (*MQTTNotifier) UpdateOpMode

func (m *MQTTNotifier) UpdateOpMode(opMode string)

func (*MQTTNotifier) UpdateTemperature

func (m *MQTTNotifier) UpdateTemperature(temperature string)

type Receiver

type Receiver interface {
	OnConnectionEstablished()
	HandleMessage(message []byte)
}

type StateNotifier

type StateNotifier interface {
	UpdateAction(action string)
	UpdateOpMode(mode string)
	UpdateFanMode(fanMode string)
	UpdateTemperature(temperature string)
	UpdateCurrentTemperature(temperature string)
	UpdateAttributes(attributes map[string]string)
}

type TLSSocketConnection

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

TLSSocketConnection runs a persistent connection over TLS socket, trying to reconnect on failures.

func (*TLSSocketConnection) Connect

func (c *TLSSocketConnection) Connect(host, port string, receiver Receiver)

func (*TLSSocketConnection) ExpectRead

func (c *TLSSocketConnection) ExpectRead()

We know that a message should arrive. Will fail and retry connection if not.

func (*TLSSocketConnection) SendMessage

func (c *TLSSocketConnection) SendMessage(message []byte)

Jump to

Keyboard shortcuts

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