Documentation ¶
Overview ¶
Package mqtt provides Gobot adaptor for the mqtt message service.
Installing:
go get github.com/hybridgroup/gobot/platforms/mqtt
For further information refer to mqtt README: https://github.com/hybridgroup/gobot/blob/master/platforms/mqtt/README.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MqttAdaptor ¶
func NewMqttAdaptor ¶
func NewMqttAdaptor(name string, host string, clientID string) *MqttAdaptor
NewMqttAdaptor creates a new mqtt adaptor with specified name, host and client id
func (*MqttAdaptor) Connect ¶
func (a *MqttAdaptor) Connect() bool
Connect returns true if connection to mqtt is established
func (*MqttAdaptor) Disconnect ¶
func (a *MqttAdaptor) Disconnect() bool
Disconnect returns true if connection to mqtt is closed
func (*MqttAdaptor) Finalize ¶
func (a *MqttAdaptor) Finalize() bool
Finalize returns true if connection to mqtt is finalized succesfully
func (*MqttAdaptor) On ¶
func (a *MqttAdaptor) On(event string, f func(s []byte)) bool
Subscribe to a topic, and then call the message handler function when data is received
func (*MqttAdaptor) Publish ¶
func (a *MqttAdaptor) Publish(topic string, message []byte) bool
Publish a message under a specific topic
func (*MqttAdaptor) Reconnect ¶
func (a *MqttAdaptor) Reconnect() bool
Reconnect retries connection to mqtt. Returns true if successful