tools

package
v0.0.0-...-fd2512f Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MqttLorhammerTopic    = "/lorhammer"
	MqttOrchestratorTopic = "/lorhammer/orchestrator"
)

Channels mqtt to use

Variables

This section is empty.

Functions

func FreeTCPPort

func FreeTCPPort() (int, error)

FreeTCPPort return free tcp port on host

func Hostname

func Hostname(port int) (string, error)

Hostname return unique hostname_ip:port string

func Random

func Random(min, max int) int

Random generate random int between min and max Deprecated: use Random64 instead

func Random16Bytes

func Random16Bytes() [16]byte

Random16Bytes generate random [16]byte

func Random2Bytes

func Random2Bytes() [2]byte

Random2Bytes generate random [2]byte

func Random4Bytes

func Random4Bytes() [4]byte

Random4Bytes generate random [4]byte

func Random64

func Random64(min, max int64) int64

Random64 generate random int64 between min and max

func Random8Bytes

func Random8Bytes() [8]byte

Random8Bytes generate random [8]byte

func RandomBytes

func RandomBytes(nb int) []byte

RandomBytes generate random int64 between min and max

func RandomDuration

func RandomDuration(min, max time.Duration) time.Duration

RandomDuration generate random time.Duration between min and max

Types

type Mqtt

type Mqtt interface {
	Connect() error
	Disconnect()
	GetAddress() string
	Handle(topics []string, handle func(message []byte)) error
	HandleCmd(topics []string, handle func(cmd model.CMD)) error
	PublishCmd(topic string, cmdName model.CommandName) error
	PublishSubCmd(topic string, cmdName model.CommandName, subCmd interface{}) error
}

Mqtt is responsible of communication with the mqtt server

func NewMqtt

func NewMqtt(hostname string, mqttAddr string) (Mqtt, error)

NewMqtt return a Mqtt based on mqttAddr (protocol://ip:port) and set clientID with hostname

func NewMqttBasic

func NewMqttBasic(url string, clientID string) (Mqtt, error)

NewMqttBasic return a Mqtt client

Jump to

Keyboard shortcuts

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