mqtt

package
v0.0.0-...-ad5a82a Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QOSAtMostOnce  = byte(0)
	QOSAtLeastOnce = byte(1)
)

Constants for connecting to the MQTT broker

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

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

Connection for MQTT protocol

func GetConnection

func GetConnection(enroll *domain.Enrollment) (*Connection, error)

GetConnection fetches or creates an MQTT connection

func (*Connection) Close

func (c *Connection) Close()

Close closes the connection to the MQTT broker

func (*Connection) Health

func (c *Connection) Health()

Health publishes a health message to indicate that the device is still active

func (*Connection) Metrics

func (c *Connection) Metrics()

Metrics publishes a metrics messages to indicate so the device can be monitored

func (*Connection) SubscribeHandler

func (c *Connection) SubscribeHandler(client MQTT.Client, msg MQTT.Message)

SubscribeHandler is the handler for the main subscription topic

func (*Connection) SubscribeToActions

func (c *Connection) SubscribeToActions() error

SubscribeToActions subscribes to the action topic

type MockClient

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

MockClient mocks the MQTT client

func (*MockClient) AddRoute

func (cli *MockClient) AddRoute(topic string, callback MQTT.MessageHandler)

AddRoute mocks routing

func (*MockClient) Connect

func (cli *MockClient) Connect() MQTT.Token

Connect mocks connecting to broker

func (*MockClient) Disconnect

func (cli *MockClient) Disconnect(quiesce uint)

Disconnect mocks client close

func (*MockClient) IsConnected

func (cli *MockClient) IsConnected() bool

IsConnected mocks the connect status

func (*MockClient) IsConnectionOpen

func (cli *MockClient) IsConnectionOpen() bool

IsConnectionOpen mocks the connect status

func (*MockClient) OptionsReader

func (cli *MockClient) OptionsReader() MQTT.ClientOptionsReader

OptionsReader mocks the options reader (badly)

func (*MockClient) Publish

func (cli *MockClient) Publish(topic string, qos byte, retained bool, payload interface{}) MQTT.Token

Publish mocks a publish message

func (*MockClient) Subscribe

func (cli *MockClient) Subscribe(topic string, qos byte, callback MQTT.MessageHandler) MQTT.Token

Subscribe mocks a subscribe message

func (*MockClient) SubscribeMultiple

func (cli *MockClient) SubscribeMultiple(filters map[string]byte, callback MQTT.MessageHandler) MQTT.Token

SubscribeMultiple mocks subscribe messages

func (*MockClient) Unsubscribe

func (cli *MockClient) Unsubscribe(topics ...string) MQTT.Token

Unsubscribe mocks a unsubscribe message

type MockMessage

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

MockMessage implements an MQTT message

func (*MockMessage) Ack

func (m *MockMessage) Ack()

Ack mocks the message ack

func (*MockMessage) Duplicate

func (m *MockMessage) Duplicate() bool

Duplicate mocks a duplicate message check

func (*MockMessage) MessageID

func (m *MockMessage) MessageID() uint16

MessageID mocks the message ID

func (*MockMessage) Payload

func (m *MockMessage) Payload() []byte

Payload mocks the payload retrieval

func (*MockMessage) Qos

func (m *MockMessage) Qos() byte

Qos mocks the QoS flag

func (*MockMessage) Retained

func (m *MockMessage) Retained() bool

Retained mocks the retained flag

func (*MockMessage) Topic

func (m *MockMessage) Topic() string

Topic mocks the topic

type MockToken

type MockToken struct{}

MockToken implements a Token

func (*MockToken) Error

func (t *MockToken) Error() error

Error mocks a token error check

func (*MockToken) Wait

func (t *MockToken) Wait() bool

Wait mocks the token wait

func (*MockToken) WaitTimeout

func (t *MockToken) WaitTimeout(time.Duration) bool

WaitTimeout mocks the token wait timeout

type SubscribeAction

type SubscribeAction struct {
	ID     string `json:"id"`
	Action string `json:"action"`
	Snap   string `json:"snap"`
	Data   string `json:"data"`
}

SubscribeAction is the message format for the action topic

func (*SubscribeAction) Device

func (act *SubscribeAction) Device(orgID, deviceID string) domain.PublishResponse

Device gets details of the device

func (*SubscribeAction) SnapAck

func (act *SubscribeAction) SnapAck() domain.PublishResponse

SnapAck adds an assertion to the device

func (*SubscribeAction) SnapConf

func (act *SubscribeAction) SnapConf() domain.PublishResponse

SnapConf gets the config for a snap

func (*SubscribeAction) SnapDisable

func (act *SubscribeAction) SnapDisable() domain.PublishResponse

SnapDisable disables an existing snap

func (*SubscribeAction) SnapEnable

func (act *SubscribeAction) SnapEnable() domain.PublishResponse

SnapEnable enables an existing snap

func (*SubscribeAction) SnapInfo

func (act *SubscribeAction) SnapInfo() domain.PublishResponse

SnapInfo gets the info for a snap

func (*SubscribeAction) SnapInstall

func (act *SubscribeAction) SnapInstall() domain.PublishResponse

SnapInstall installs a new snap

func (*SubscribeAction) SnapList

func (act *SubscribeAction) SnapList(deviceID string) domain.PublishResponse

SnapList lists installed snaps

func (*SubscribeAction) SnapRefresh

func (act *SubscribeAction) SnapRefresh() domain.PublishResponse

SnapRefresh refreshes an existing snap

func (*SubscribeAction) SnapRemove

func (act *SubscribeAction) SnapRemove() domain.PublishResponse

SnapRemove removes an existing snap

func (*SubscribeAction) SnapRevert

func (act *SubscribeAction) SnapRevert() domain.PublishResponse

SnapRevert reverts an existing snap

func (*SubscribeAction) SnapServerVersion

func (act *SubscribeAction) SnapServerVersion(deviceID string) domain.PublishResponse

SnapServerVersion gets details of the device

func (*SubscribeAction) SnapSetConf

func (act *SubscribeAction) SnapSetConf() domain.PublishResponse

SnapSetConf sets the config for a snap

Jump to

Keyboard shortcuts

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