Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Disconnected : no connection to broker Disconnected int8 = 0 // Connected : connection established to broker Connected int8 = 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.0.4
type Config struct { Brokers []string // MQTT Broker address. Format: scheme://host:port ClientID string // Client ID Username string // Username to connect the broker(s) Password string // Password to connect the broker(s) Topics []string // Topics for subscription QoS int // QoS Retained bool // Retain Message AutoReconnect bool // Reconnect if connection is lost MaxReconnectInterval time.Duration // Maximum time that will be waited between reconnection attempts PersistentSession bool // Set persistent(clean start for v5) of session KeepAlive uint16 // Keep Alive time in sec TLSCA string // CA file path TLSCert string // Cert file path TLSKey string // Key file path Version Version // MQTT Version of client Crypto string // Crypto algorithm EncryptionKey string // Encryption key file path Publisher bool // Publisher }
Config contains configurable options for connecting to broker(s).
func (*Config) CreateConnection ¶ added in v0.0.4
CreateConnection will automatically create connection to broker(s) with MQTTConfig parameters.
type ConnectionState ¶ added in v0.0.4
type ConnectionState struct {
// contains filtered or unexported fields
}
func (*ConnectionState) GetStatus ¶ added in v0.0.4
func (c *ConnectionState) GetStatus() int8
func (*ConnectionState) MarshalJSON ¶ added in v0.0.4
func (cs *ConnectionState) MarshalJSON() ([]byte, error)
func (*ConnectionState) ResetCounter ¶ added in v0.0.4
func (c *ConnectionState) ResetCounter()
type MQTT ¶ added in v0.0.4
type MQTT interface { // Handle handles new messages to subscribed topics. Handle(handler) // Publish sends a message to broker with a specific topic. Publish(string, string, any) error // Request sends a message to broker and waits for the response. Request(string, any, time.Duration, handler) error // RequestWith sends a message to broker with specific response topic, // and waits for the response. RequestWith(string, string, any, time.Duration, handler) error // SubscribeResponse creates new subscription for response topic. SubscribeResponse(string) error // Respond sends message to response topic with correlation id (use inside HandleRequest). Respond(string, any, []byte) error // HandleRequest handles imcoming request. HandleRequest(responseHandler) // GetConnectionStatus returns the connection status: Connected or Disconnected GetConnectionStatus() int8 // Disconnect will close the connection to broker. Disconnect() }
MQTT is an interface for mqttv3 and mqttv5 structs.
Click to show internal directories.
Click to hide internal directories.