Documentation ¶
Overview ¶
Package mqtt provides Gobot adaptor for the mqtt message service.
Installing:
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to mqtt README: https://github.com/hybridgroup/gobot/blob/release/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() error
- func (a *Adaptor) Disconnect() error
- func (a *Adaptor) Finalize() 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) PublishAndRetain(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 = fmt.Errorf("no MQTT client available")
ErrNilClient is returned when a client action can't be taken because the struct has no client
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 ¶
NewAdaptor creates a new mqtt adaptor with specified host and client id
func NewAdaptorWithAuth ¶
NewAdaptorWithAuth creates a new mqtt adaptor with specified host, client id, username, and password.
func (*Adaptor) AutoReconnect ¶
AutoReconnect returns the MQTT AutoReconnect setting
func (*Adaptor) CleanSession ¶
CleanSession returns the MQTT CleanSession setting
func (*Adaptor) ClientCert ¶
ClientCert returns the MQTT client SSL cert file
func (*Adaptor) Disconnect ¶
Disconnect returns true if connection to mqtt is closed
func (*Adaptor) On ¶
On subscribes to a topic, and then calls the message handler function when data is received
func (*Adaptor) OnWithQOS ¶
OnWithQOS allows per-subscribe QOS values to be set and returns a paho.Token
func (*Adaptor) PublishAndRetain ¶
PublishAndRetain publishes a message under a specific topic with retain flag
func (*Adaptor) PublishWithQOS ¶
PublishWithQOS allows per-publish QOS values to be set and returns a paho.Token
func (*Adaptor) ServerCert ¶
ServerCert returns the MQTT server SSL cert file
func (*Adaptor) SetAutoReconnect ¶
SetAutoReconnect sets the MQTT AutoReconnect setting
func (*Adaptor) SetCleanSession ¶
SetCleanSession sets the MQTT CleanSession setting. Should be false if reconnect is enabled. Otherwise all subscriptions will be lost
func (*Adaptor) SetClientCert ¶
SetClientCert sets the MQTT client SSL cert file
func (*Adaptor) SetClientKey ¶
SetClientKey sets the MQTT client SSL key file
func (*Adaptor) SetQoS ¶
SetQoS sets the QoS value passed into the MTT client on Publish/Subscribe events
func (*Adaptor) SetServerCert ¶
SetServerCert sets the MQTT server SSL cert file
type Driver ¶
type Driver struct { gobot.Eventer gobot.Commander // contains filtered or unexported fields }
Driver for mqtt
func (*Driver) Connection ¶
func (m *Driver) Connection() gobot.Connection
Connection returns Connections used by the Driver
func (*Driver) On ¶
On subscribes to data updates for the current device topic, and then calls the message handler function when data is received