mqtt

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StatusSubtopic is used for sending important system-wide messages
	StatusSubtopic = "/status"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AghastMsgT

type AghastMsgT struct {
	Subtopic string
	Qos      byte
	Retained bool
	Payload  interface{}
}

AghastMsgT is the type of messages sent via the AGHAST MQTT channels

type GeneralMsgT

type GeneralMsgT struct {
	Topic    string
	Qos      byte
	Retained bool
	Payload  interface{}
}

GeneralMsgT is the type of messages received or sent to third-parties

type MQTT

type MQTT struct {
	PublishChan    chan AghastMsgT
	ThirdPartyChan chan GeneralMsgT
	// contains filtered or unexported fields
}

MQTT encapsulates a connection to an MQTT Broker

func (*MQTT) Disconnect

func (m *MQTT) Disconnect()

Disconnect from the MQTT Broker after 100ms

func (*MQTT) Start

func (m *MQTT) Start(broker string, port int, username string, password string, clientID string, baseTopic string) chan AghastMsgT

func (*MQTT) SubscribeToTopic

func (m *MQTT) SubscribeToTopic(topic string) chan GeneralMsgT

SubscribeToTopic returns a channel which will receive any MQTT messages published to the topic

func (*MQTT) SubscribeToTopicUsingChan

func (m *MQTT) SubscribeToTopicUsingChan(topic string, c chan GeneralMsgT)

SubscribeToTopicUsingChan uses the provided chan to receive any MQTT messages published to the topic

func (*MQTT) UnsubscribeFromTopic

func (m *MQTT) UnsubscribeFromTopic(topic string, ch chan GeneralMsgT)

UnsubscribeFromTopic taked a chan as another parm and use it to correctly remove the right subbed chan from the subscription map

Jump to

Keyboard shortcuts

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