Documentation ¶
Overview ¶
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 ¶
- Constants
- Variables
- type Adaptor
- func (a *Adaptor) AutoReconnect() bool
- func (a *Adaptor) CleanSession() bool
- func (a *Adaptor) ClientCert() string
- func (a *Adaptor) ClientKey() string
- func (a *Adaptor) Connect() (err error)
- func (a *Adaptor) Disconnect() (err error)
- func (a *Adaptor) Finalize() (err error)
- func (a *Adaptor) Name() string
- func (a *Adaptor) On(event string, f func(msg Message)) bool
- func (a *Adaptor) OnWithQOS(event string, qos int, f func(msg Message)) (paho.Token, error)
- func (a *Adaptor) Port() string
- func (a *Adaptor) Publish(topic string, message []byte) bool
- func (a *Adaptor) PublishWithQOS(topic string, qos int, message []byte) (paho.Token, error)
- func (a *Adaptor) ServerCert() string
- func (a *Adaptor) SetAutoReconnect(val bool)
- func (a *Adaptor) SetCleanSession(val bool)
- func (a *Adaptor) SetClientCert(val string)
- func (a *Adaptor) SetClientKey(val string)
- func (a *Adaptor) SetName(n string)
- func (a *Adaptor) SetQoS(qos int)
- func (a *Adaptor) SetServerCert(val string)
- func (a *Adaptor) SetUseSSL(val bool)
- func (a *Adaptor) UseSSL() bool
- type Driver
- func (m *Driver) Connection() gobot.Connection
- func (m *Driver) Halt() error
- func (m *Driver) Name() string
- func (m *Driver) On(n string, f func(msg interface{})) error
- func (m *Driver) Publish(data interface{}) bool
- func (m *Driver) SetName(name string)
- func (m *Driver) SetTopic(topic string)
- func (m *Driver) Start() error
- func (m *Driver) Topic() string
- type Message
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") )
Functions ¶
This section is empty.
Types ¶
type Adaptor ¶ added in v1.0.0
type Adaptor struct { Host string // contains filtered or unexported fields }
Adaptor is the Gobot Adaptor for MQTT
func NewAdaptor ¶ added in v1.0.0
NewAdaptor creates a new mqtt adaptor with specified host and client id
func NewAdaptorWithAuth ¶ added in v1.0.0
NewAdaptorWithAuth creates a new mqtt adaptor with specified host, client id, username, and password.
func (*Adaptor) AutoReconnect ¶ added in v1.2.0
AutoReconnect returns the MQTT AutoReconnect setting
func (*Adaptor) CleanSession ¶ added in v1.7.0
CleanSession returns the MQTT CleanSession setting
func (*Adaptor) ClientCert ¶ added in v1.2.0
ClientCert returns the MQTT client SSL cert file
func (*Adaptor) Disconnect ¶ added in v1.0.0
Disconnect returns true if connection to mqtt is closed
func (*Adaptor) Finalize ¶ added in v1.0.0
Finalize returns true if connection to mqtt is finalized successfully
func (*Adaptor) On ¶ added in v1.0.0
On subscribes to a topic, and then calls the message handler function when data is received
func (*Adaptor) OnWithQOS ¶ added in v1.13.0
OnWithQOS allows per-subscribe QOS values to be set and returns a paho.Token
func (*Adaptor) PublishWithQOS ¶ added in v1.13.0
PublishWithQOS allows per-publish QOS values to be set and returns a poken.Token
func (*Adaptor) ServerCert ¶ added in v1.2.0
ServerCert returns the MQTT server SSL cert file
func (*Adaptor) SetAutoReconnect ¶ added in v1.2.0
SetAutoReconnect sets the MQTT AutoReconnect setting
func (*Adaptor) SetCleanSession ¶ added in v1.7.0
SetCleanSession sets the MQTT CleanSession setting. Should be false if reconnect is enabled. Otherwise all subscriptions will be lost
func (*Adaptor) SetClientCert ¶ added in v1.2.0
SetClientCert sets the MQTT client SSL cert file
func (*Adaptor) SetClientKey ¶ added in v1.2.0
SetClientKey sets the MQTT client SSL key file
func (*Adaptor) SetQoS ¶ added in v1.13.0
SetQoS sets the QoS value passed into the MTT client on Publish/Subscribe events
func (*Adaptor) SetServerCert ¶ added in v1.2.0
SetServerCert sets the MQTT server SSL cert file
type Driver ¶ added in v1.2.0
Driver for mqtt
func (*Driver) Connection ¶ added in v1.2.0
func (m *Driver) Connection() gobot.Connection
Connection returns Connections used by the Driver
func (*Driver) On ¶ added in v1.2.0
On subscribes to data updates for the current device topic, and then calls the message handler function when data is received