mqtt

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mqtt is a minimal MQTT 3.1.1 publish-only client: enough to feed motion and status into mosquitto / Home Assistant / Frigate without pulling in a full client library. It publishes QoS 0 or QoS 1, reconnects on the next Publish after any error, and uses keep-alive 0 so an idle connection is never dropped by the broker (there is no subscribe path to service pings).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client publishes to a single broker. It is safe for concurrent use; each Publish is serialised. A dropped connection is re-established on the next Publish, so a broker restart heals itself.

func New

func New(addr, clientID, user, pass string) *Client

New returns a client for broker addr ("host:port"). clientID must be unique on the broker; user and pass may be empty for an anonymous broker.

func (*Client) Close

func (c *Client) Close() error

Close drops the connection. The client may be reused afterwards.

func (*Client) Publish

func (c *Client) Publish(topic string, payload []byte, qos byte, retain bool) error

Publish sends payload to topic. qos is 0 or 1; a QoS 1 publish waits for the broker's PUBACK. retain asks the broker to keep the message as the topic's last known value.

Jump to

Keyboard shortcuts

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