gobot: gobot.io/x/gobot/platforms/mqtt Index | Files

package mqtt

import "gobot.io/x/gobot/platforms/mqtt"

Package mqtt provides Gobot adaptor for the mqtt message service.

Installing:

go get gobot.io/x/gobot/platforms/mqtt

For further information refer to mqtt README: https://github.com/hybridgroup/gobot/blob/master/platforms/mqtt/README.md

Index

Package Files

doc.go mqtt_adaptor.go mqtt_driver.go

Constants

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

    // Error event when error occurs in Driver
    Error = "error"
)

Variables

var (
    // ErrNilClient is returned when a client action can't be taken because the struct has no client
    ErrNilClient = errors.New("no MQTT client available")
)

type Adaptor Uses

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

Adaptor is the Gobot Adaptor for MQTT

func NewAdaptor Uses

func NewAdaptor(host string, clientID string) *Adaptor

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

func NewAdaptorWithAuth Uses

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 Uses

func (a *Adaptor) AutoReconnect() bool

AutoReconnect returns the MQTT AutoReconnect setting

func (*Adaptor) CleanSession Uses

func (a *Adaptor) CleanSession() bool

CleanSession returns the MQTT CleanSession setting

func (*Adaptor) ClientCert Uses

func (a *Adaptor) ClientCert() string

ClientCert returns the MQTT client SSL cert file

func (*Adaptor) ClientKey Uses

func (a *Adaptor) ClientKey() string

ClientKey returns the MQTT client SSL key file

func (*Adaptor) Connect Uses

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

Connect returns true if connection to mqtt is established

func (*Adaptor) Disconnect Uses

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

Disconnect returns true if connection to mqtt is closed

func (*Adaptor) Finalize Uses

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

Finalize returns true if connection to mqtt is finalized successfully

func (*Adaptor) Name Uses

func (a *Adaptor) Name() string

Name returns the MQTT Adaptor's name

func (*Adaptor) On Uses

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

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

func (*Adaptor) OnWithQOS Uses

func (a *Adaptor) OnWithQOS(event string, qos int, f func(msg Message)) (paho.Token, error)

OnWithQOS allows per-subscribe QOS values to be set and returns a paho.Token

func (*Adaptor) Port Uses

func (a *Adaptor) Port() string

Port returns the Host name

func (*Adaptor) Publish Uses

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

Publish a message under a specific topic

func (*Adaptor) PublishWithQOS Uses

func (a *Adaptor) PublishWithQOS(topic string, qos int, message []byte) (paho.Token, error)

PublishWithQOS allows per-publish QOS values to be set and returns a poken.Token

func (*Adaptor) ServerCert Uses

func (a *Adaptor) ServerCert() string

ServerCert returns the MQTT server SSL cert file

func (*Adaptor) SetAutoReconnect Uses

func (a *Adaptor) SetAutoReconnect(val bool)

SetAutoReconnect sets the MQTT AutoReconnect setting

func (*Adaptor) SetCleanSession Uses

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 Uses

func (a *Adaptor) SetClientCert(val string)

SetClientCert sets the MQTT client SSL cert file

func (*Adaptor) SetClientKey Uses

func (a *Adaptor) SetClientKey(val string)

SetClientKey sets the MQTT client SSL key file

func (*Adaptor) SetName Uses

func (a *Adaptor) SetName(n string)

SetName sets the MQTT Adaptor's name

func (*Adaptor) SetQoS Uses

func (a *Adaptor) SetQoS(qos int)

SetQoS sets the QoS value passed into the MTT client on Publish/Subscribe events

func (*Adaptor) SetServerCert Uses

func (a *Adaptor) SetServerCert(val string)

SetServerCert sets the MQTT server SSL cert file

func (*Adaptor) SetUseSSL Uses

func (a *Adaptor) SetUseSSL(val bool)

SetUseSSL sets the MQTT server SSL preference

func (*Adaptor) UseSSL Uses

func (a *Adaptor) UseSSL() bool

UseSSL returns the MQTT server SSL preference

type Driver Uses

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

Driver for mqtt

func NewDriver Uses

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

NewDriver returns a new Gobot MQTT Driver

func (*Driver) Connection Uses

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

Connection returns Connections used by the Driver

func (*Driver) Halt Uses

func (m *Driver) Halt() error

Halt halts the Driver

func (*Driver) Name Uses

func (m *Driver) Name() string

Name returns name for the Driver

func (*Driver) On Uses

func (m *Driver) On(n string, f func(msg interface{})) 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 Uses

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

Publish a message to the current device topic

func (*Driver) SetName Uses

func (m *Driver) SetName(name string)

Name sets name for the Driver

func (*Driver) SetTopic Uses

func (m *Driver) SetTopic(topic string)

SetTopic sets the current topic for the Driver

func (*Driver) Start Uses

func (m *Driver) Start() error

Start starts the Driver

func (*Driver) Topic Uses

func (m *Driver) Topic() string

Topic returns the current topic for the Driver

type Message Uses

type Message paho.Message

Message is a message received from the broker.

Package mqtt imports 7 packages (graph). Updated 2019-05-22. Refresh now. Tools for package owners.