mqttcli

package module
v0.0.0-...-640575b Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

README

package mqttcli is a program that provides two subcommands (pub and sub) that allow command-line level access to an MQTT broker.

sub subscribes to a topic and prints messages received to standard output. pub publishes the provided message to the provided topic. Both programs accept flags that can be provided as a config file.

Examples

Flags

  • go run ./cmd/sub -broker tcp://test.mosquitto.org:1883 -topic mqttcli/test
  • echo hello | go run ./cmd/pub -broker tcp://test.mosquitto.org:1883 -topic mqttcli/test

Config File

cat > sub.cfg << EOF
broker tcp://test.mosquitto.org:1883
topic mqttcli/test
EOF
go run ./cmd/sub -config sub.cfg
cat > pub.cfg << EOF
broker tcp://test.mosquitto.org:1883
topic mqttcli/test
EOF
echo hello | go run ./cmd/pub -config pub.cfg

Documentation

Index

Constants

View Source
const Version = "0.2.5"

Variables

View Source
var (
	Broker               string
	Topics               flagvar.Strings
	ClientID             string
	Username             string
	Password             string
	CARoot               string
	QoS                  int
	Verbose              bool
	Clean                bool
	Headers              flagvar.AssignmentsMap
	CertFile             flagvar.File
	KeyFile              flagvar.File
	ConnectRetry         bool
	ConnectRetryInterval time.Duration
	AutoReconnect        bool
	PrintVersion         bool
	TLSALPN              flagvar.Strings
)

Functions

func GlobalFlagSet

func GlobalFlagSet(name string, errorHandling flag.ErrorHandling) *flag.FlagSet

GlobalFlagSet returns a new flag set configured with flags common to publish and subscribe clients.

func NewMQTTClientOptions

func NewMQTTClientOptions() (*mqtt.ClientOptions, error)

NewMQTTClientOptions returns a MQTT client option structure, prepopulated with values read from the flag variables. It is an error to call this function before parsing flags.

Types

This section is empty.

Directories

Path Synopsis
cmd
pub
sub

Jump to

Keyboard shortcuts

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