mqtt

package
v0.0.0-...-8c6d6a4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectHandler

func ConnectHandler(logger zerolog.Logger) func(client pmqtt.Client)

func ConnectLostHandler

func ConnectLostHandler(logger zerolog.Logger) func(client pmqtt.Client, err error)

Types

type Mqtt

type Mqtt struct {
	Topic  string
	MgtUrl string

	ClientID uuid.UUID
	// contains filtered or unexported fields
}

Mqtt represents an MQTT client.

func NewMqtt

func NewMqtt(conf MqttConf, logl int, ctx context.Context, wg *sync.WaitGroup) (*Mqtt, error)

func (*Mqtt) Connect

func (m *Mqtt) Connect() error

func (*Mqtt) ConnectHandler

func (m *Mqtt) ConnectHandler() func(client pmqtt.Client)

ConnectHandler returns a function to handle successful connections to the MQTT broker. The returned function logs an informational message indicating a successful connection.

func (*Mqtt) ConnectLostHandler

func (m *Mqtt) ConnectLostHandler() func(client pmqtt.Client, err error)

ConnectLostHandler returns a function to handle lost connections to the MQTT broker. The returned function logs a warning message indicating a lost connection along with the error encountered.

func (*Mqtt) Disconnect

func (m *Mqtt) Disconnect()

Disconnect terminates the connection to the MQTT broker and logs the disconnection event.

func (*Mqtt) SendAlarm

func (m *Mqtt) SendAlarm(events model.Events) error

SendAlarm sends a list of FCTSDataModel events to the MQTT broker and logs any errors that occur during the process.

func (*Mqtt) SendAlarmRaw

func (m *Mqtt) SendAlarmRaw(b []byte) error

SendAlarmRaw sends a raw alarm message to the MQTT broker and returns an error if the sending fails.

type MqttConf

type MqttConf struct {
	Connection string `yaml:"Connection"`
	Topic      string `yaml:"Topic"`
}

MqttConf holds the configuration for the MQTT client.

Jump to

Keyboard shortcuts

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