mqtt

package
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TokenType = "mqtt"

Variables

This section is empty.

Functions

func NewClientOptions

func NewClientOptions(brokerURL, clientIDPrefix string) *mqtt.ClientOptions

NewClientOptions creates and configures MQTT client options based on a broker URL. The clientIDPrefix is used to generate a unique client ID (e.g., "zaparoo-mqtt-" or "zaparoo-publisher-").

func ParseMQTTPath

func ParseMQTTPath(path string) (broker, topic string, err error)

ParseMQTTPath parses an MQTT connection path in the format "broker:port/topic" and returns the broker address and topic separately.

Examples:

  • "localhost:1883/zaparoo/tokens" -> ("localhost:1883", "zaparoo/tokens")
  • "mqtt.example.com:8883/home/zaparoo" -> ("mqtt.example.com:8883", "home/zaparoo")

Types

type ClientFactory

type ClientFactory func(opts *mqtt.ClientOptions) mqtt.Client

ClientFactory creates MQTT clients. This interface allows for testing by injecting mock clients.

var DefaultClientFactory ClientFactory = mqtt.NewClient

DefaultClientFactory is the standard factory that creates real MQTT clients.

type MQTTProtocolInfo

type MQTTProtocolInfo struct {
	Protocol  string
	Scheme    string
	Remainder string
	UseTLS    bool
}

MQTTProtocolInfo contains parsed MQTT protocol information.

func ParseMQTTProtocol

func ParseMQTTProtocol(urlStr string) MQTTProtocolInfo

ParseMQTTProtocol extracts protocol information from an MQTT URL string.

Examples:

  • "mqtts://broker:8883" -> {Protocol: "ssl", UseTLS: true, Scheme: "mqtts", Remainder: "broker:8883"}
  • "ssl://broker:8883" -> {Protocol: "ssl", UseTLS: true, Scheme: "ssl", Remainder: "broker:8883"}
  • "mqtt://broker:1883" -> {Protocol: "tcp", UseTLS: false, Scheme: "mqtt", Remainder: "broker:1883"}
  • "broker:1883" -> {Protocol: "tcp", UseTLS: false, Scheme: "", Remainder: "broker:1883"}

type Reader

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

func NewReader

func NewReader(cfg *config.Instance) *Reader

func (*Reader) CancelWrite

func (*Reader) CancelWrite()

func (*Reader) Capabilities

func (*Reader) Capabilities() []readers.Capability

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Connected

func (r *Reader) Connected() bool

func (*Reader) Detect

func (*Reader) Detect(_ []string) string

func (*Reader) IDs

func (*Reader) IDs() []string

func (*Reader) Info

func (r *Reader) Info() string

func (*Reader) Metadata

func (*Reader) Metadata() readers.DriverMetadata

func (*Reader) OnMediaChange

func (*Reader) OnMediaChange(*models.ActiveMedia) error

func (*Reader) Open

func (r *Reader) Open(device config.ReadersConnect, scanQueue chan<- readers.Scan, _ readers.OpenOpts) error

func (*Reader) Path added in v2.9.0

func (r *Reader) Path() string

func (*Reader) ReaderID added in v2.9.0

func (r *Reader) ReaderID() string

func (*Reader) Write

func (*Reader) Write(_ string) (*tokens.Token, error)

Jump to

Keyboard shortcuts

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