mqtt

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

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

func NewPublisher

func NewPublisher(mqttUrl, topicRoot, username, password string) Publisher

NewPublisher instantiates a MQTT publisher.

It connects to `mqttUrl` with `username` and `password` if specified. TopicRoot will be used as prefix of topic for all MQTT messages.

func (*Publisher) Connect

func (p *Publisher) Connect() error

Connect connects to the MQTT server;

The Publisher must have been instantiated first using NewPublisher.

func (*Publisher) Disconnect

func (p *Publisher) Disconnect()

func (*Publisher) Publish

func (p *Publisher) Publish(sensorName string, payload interface{}) error

Publish sends the message to MQTT server.

The `sensorName` will be in the topic. The payload must be JSON serializable.

Jump to

Keyboard shortcuts

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