mqtt_utils

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MQTTClient

type MQTTClient struct {
	ClientId string
	// contains filtered or unexported fields
}

func NewMQTTClient

func NewMQTTClient(config MQTTConfiguration, topicMap map[string]byte, defaultCallback mqtt.MessageHandler) *MQTTClient

func (*MQTTClient) ConnectionLostHandler

func (c *MQTTClient) ConnectionLostHandler(client mqtt.Client, err error)

func (*MQTTClient) OnConnectHandler

func (c *MQTTClient) OnConnectHandler(client mqtt.Client)

func (*MQTTClient) Publish

func (c *MQTTClient) Publish(r *MQTTPublishRequest) ([]byte, error)

func (*MQTTClient) Subscribe

func (c *MQTTClient) Subscribe(topicMap map[string]byte, callback func(client mqtt.Client, msg mqtt.Message))

func (*MQTTClient) SubscribeDefault

func (c *MQTTClient) SubscribeDefault()

func (*MQTTClient) Unsubscribe

func (c *MQTTClient) Unsubscribe(topicList []string)

type MQTTConfiguration

type MQTTConfiguration struct {
	ID       string `yaml:"id"`
	URL      string `yaml:"url"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type MQTTHandler

type MQTTHandler interface {
	OnConnectHandler(client mqtt.Client)
	ConnectionLostHandler(client mqtt.Client, err error)
}

type MQTTPublishRequest

type MQTTPublishRequest struct {
	Topic    string
	Qos      byte
	Retained bool
	Payload  any
}

func NewMQTTPublishRequest

func NewMQTTPublishRequest(topic string, qos byte, retained bool, payload any) *MQTTPublishRequest

Jump to

Keyboard shortcuts

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