mqtt

package
v3.4.25 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: GPL-3.0 Imports: 7 Imported by: 31

Documentation

Index

Constants

View Source
const ENV = "IOT_MASTER_MQTT_"

Variables

View Source
var Client paho.Client

Functions

func Close

func Close()

func Load added in v3.1.0

func Load() error

func Open

func Open() error

func OpenBy

func OpenBy(fn paho.OpenConnectionFunc) error

func Publish

func Publish(topic string, payload any) paho.Token

func PublishRaw added in v3.4.0

func PublishRaw(topic string, payload []byte, retain bool, qos byte) error

func SetOptions added in v3.1.0

func SetOptions(opts Options)

func Store added in v3.1.0

func Store() error

func Subscribe added in v3.4.0

func Subscribe(topic string, cb Handler) paho.Token

func SubscribeJson added in v3.4.0

func SubscribeJson(topic string, cb func(topic string, data map[string]any)) paho.Token

func SubscribeStruct added in v3.4.0

func SubscribeStruct[T any](topic string, cb func(topic string, data *T)) paho.Token

Types

type Handler added in v3.4.0

type Handler func(topic string, payload []byte)

type Options

type Options struct {
	Url      string `json:"url,omitempty"`
	ClientId string `json:"clientId,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

func Default

func Default() Options

func GetOptions added in v3.1.0

func GetOptions() Options

func (*Options) FromEnv added in v3.1.0

func (options *Options) FromEnv()

func (*Options) ToEnv added in v3.1.0

func (options *Options) ToEnv() []string

Jump to

Keyboard shortcuts

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