mqtt

package
v1.4.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Data event when data is available for Driver
	Data = "data"

	// Error event when error occurs in Driver
	Error = "error"
)
View Source
const (
	QOS_0 = iota
	QOS_1
	QOS_2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adaptor

type Adaptor struct {
	Host string
	// contains filtered or unexported fields
}

Adaptor is the Gobot Adaptor for MQTT

func NewAdaptor

func NewAdaptor(host string, clientID string) *Adaptor

NewAdaptor creates a new mqtt adaptor with specified host and client id

func NewAdaptorWithAuth

func NewAdaptorWithAuth(host, clientID, username, password string) *Adaptor

NewAdaptorWithAuth creates a new mqtt adaptor with specified host, client id, username, and password.

func (*Adaptor) AutoReconnect

func (a *Adaptor) AutoReconnect() bool

AutoReconnect returns the MQTT AutoReconnect setting

func (*Adaptor) CleanSession

func (a *Adaptor) CleanSession() bool

CleanSession returns the MQTT CleanSession setting

func (*Adaptor) ClientCert

func (a *Adaptor) ClientCert() string

ClientCert returns the MQTT client SSL cert file

func (*Adaptor) ClientKey

func (a *Adaptor) ClientKey() string

ClientKey returns the MQTT client SSL key file

func (*Adaptor) Connect

func (a *Adaptor) Connect() (err error)

Connect returns true if connection to mqtt is established

func (*Adaptor) Disconnect

func (a *Adaptor) Disconnect() (err error)

Disconnect returns true if connection to mqtt is closed

func (*Adaptor) Finalize

func (a *Adaptor) Finalize() (err error)

Finalize returns true if connection to mqtt is finalized successfully

func (*Adaptor) Name

func (a *Adaptor) Name() string

Name returns the MQTT Adaptor's name

func (*Adaptor) On

func (a *Adaptor) On(event string, qos byte, f func(msg Message)) bool

On subscribes to a topic, and then calls the message handler function when data is received

func (*Adaptor) Port

func (a *Adaptor) Port() string

Port returns the Host name

func (*Adaptor) Publish

func (a *Adaptor) Publish(topic string, qos byte, message []byte) bool

Publish a message under a specific topic

func (*Adaptor) ServerCert

func (a *Adaptor) ServerCert() string

ServerCert returns the MQTT server SSL cert file

func (*Adaptor) SetAutoReconnect

func (a *Adaptor) SetAutoReconnect(val bool)

SetAutoReconnect sets the MQTT AutoReconnect setting

func (*Adaptor) SetCleanSession

func (a *Adaptor) SetCleanSession(val bool)

SetCleanSession sets the MQTT CleanSession setting. Should be false if reconnect is enabled. Otherwise all subscriptions will be lost

func (*Adaptor) SetClientCert

func (a *Adaptor) SetClientCert(val string)

SetClientCert sets the MQTT client SSL cert file

func (*Adaptor) SetClientKey

func (a *Adaptor) SetClientKey(val string)

SetClientKey sets the MQTT client SSL key file

func (*Adaptor) SetName

func (a *Adaptor) SetName(n string)

SetName sets the MQTT Adaptor's name

func (*Adaptor) SetServerCert

func (a *Adaptor) SetServerCert(val string)

SetServerCert sets the MQTT server SSL cert file

func (*Adaptor) SetUseSSL

func (a *Adaptor) SetUseSSL(val bool)

SetUseSSL sets the MQTT server SSL preference

func (*Adaptor) UseSSL

func (a *Adaptor) UseSSL() bool

UseSSL returns the MQTT server SSL preference

type Driver

type Driver struct {
	gobot.Eventer
	gobot.Commander
	// contains filtered or unexported fields
}

Driver for mqtt

func NewDriver

func NewDriver(a *Adaptor, topic string) *Driver

NewDriver returns a new Gobot MQTT Driver

func (*Driver) Connection

func (m *Driver) Connection() gobot.Connection

Connection returns Connections used by the Driver

func (*Driver) Halt

func (m *Driver) Halt() error

Halt halts the Driver

func (*Driver) Name

func (m *Driver) Name() string

Name returns name for the Driver

func (*Driver) On

func (m *Driver) On(n string, f func(msg interface{}), qos byte) error

On subscribes to data updates for the current device topic, and then calls the message handler function when data is received

func (*Driver) Publish

func (m *Driver) Publish(data interface{}, qos byte) bool

Publish a message to the current device topic

func (*Driver) SetName

func (m *Driver) SetName(name string)

Name sets name for the Driver

func (*Driver) SetTopic

func (m *Driver) SetTopic(topic string)

SetTopic sets the current topic for the Driver

func (*Driver) Start

func (m *Driver) Start() error

Start starts the Driver

func (*Driver) Topic

func (m *Driver) Topic() string

Topic returns the current topic for the Driver

type Message

type Message paho.Message

Message is a message received from the broker.

Jump to

Keyboard shortcuts

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