Documentation
¶
Overview ¶
Package awsiotdev implements offline queueing and reconnecting features of MQTT protocol.
Example (DebugOut_print) ¶
DebugPrintBackend = func(a ...interface{}) { fmt.Print(a...) } s := &debugOut{true} s.print("Test1:", true) s = &debugOut{false} s.print("Test2:", false) DebugPrintBackend = log.Print
Output: Test1:true
Example (DebugOut_printf) ¶
DebugPrintfBackend = func(format string, a ...interface{}) { fmt.Printf(format, a...) } s := &debugOut{true} s.printf("Formatted value 1 (%d)", 10) s = &debugOut{false} s.printf("Formatted value 2 (%d)", 11) DebugPrintfBackend = log.Printf
Output: Formatted value 1 (10)
Example (DebugOut_println) ¶
DebugPrintlnBackend = func(a ...interface{}) { fmt.Println(a...) } s := &debugOut{true} s.println(errors.New("Error string 1")) s = &debugOut{false} s.println(errors.New("Error string 2")) DebugPrintlnBackend = log.Println
Output: Error string 1
Index ¶
- Variables
- type ConnectionLostHandler
- type DeviceClient
- func (s *DeviceClient) AddRoute(topic string, callback mqtt.MessageHandler)
- func (s *DeviceClient) Connect() mqtt.Token
- func (s *DeviceClient) Disconnect(quiesce uint)
- func (s *DeviceClient) IsConnected() bool
- func (s *DeviceClient) IsConnectionOpen() bool
- func (s *DeviceClient) OptionsReader() mqtt.ClientOptionsReader
- func (s *DeviceClient) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token
- func (s *DeviceClient) Subscribe(topic string, qos byte, cb mqtt.MessageHandler) mqtt.Token
- func (s *DeviceClient) SubscribeMultiple(filters map[string]byte, callback mqtt.MessageHandler) mqtt.Token
- func (s *DeviceClient) Unsubscribe(topics ...string) mqtt.Token
- type Options
- type TopicPayload
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Backend function of debug print output. This can be replaced by custom logger. DebugPrintBackend func(...interface{}) = log.Print // Backend function of debug printf output. This can be replaced by custom logger. DebugPrintfBackend func(string, ...interface{}) = log.Printf // Backend function of debug println output. This can be replaced by custom logger. DebugPrintlnBackend func(...interface{}) = log.Println )
Functions ¶
This section is empty.
Types ¶
type ConnectionLostHandler ¶ added in v1.2.0
type ConnectionLostHandler func(*Options)
type DeviceClient ¶
type DeviceClient struct {
// contains filtered or unexported fields
}
DeviceClient inplements mqtt.Client interface. Publishing messages and subscribing topics are queued in the DeviceClient if the network connection is lost. They are re-tried after the connection is resumed.
func New ¶
func New(opt *Options) *DeviceClient
func (*DeviceClient) AddRoute ¶ added in v1.0.0
func (s *DeviceClient) AddRoute(topic string, callback mqtt.MessageHandler)
func (*DeviceClient) Connect ¶ added in v1.0.0
func (s *DeviceClient) Connect() mqtt.Token
func (*DeviceClient) Disconnect ¶
func (s *DeviceClient) Disconnect(quiesce uint)
func (*DeviceClient) IsConnected ¶ added in v1.0.0
func (s *DeviceClient) IsConnected() bool
func (*DeviceClient) IsConnectionOpen ¶ added in v1.0.0
func (s *DeviceClient) IsConnectionOpen() bool
func (*DeviceClient) OptionsReader ¶ added in v1.0.0
func (s *DeviceClient) OptionsReader() mqtt.ClientOptionsReader
func (*DeviceClient) Subscribe ¶
func (s *DeviceClient) Subscribe(topic string, qos byte, cb mqtt.MessageHandler) mqtt.Token
func (*DeviceClient) SubscribeMultiple ¶ added in v1.0.0
func (s *DeviceClient) SubscribeMultiple(filters map[string]byte, callback mqtt.MessageHandler) mqtt.Token
func (*DeviceClient) Unsubscribe ¶
func (s *DeviceClient) Unsubscribe(topics ...string) mqtt.Token
type Options ¶
type Options struct { KeyPath string CertPath string CaPath string ClientId string Region string BaseReconnectTime time.Duration MaximumReconnectTime time.Duration MinimumConnectionTime time.Duration Keepalive time.Duration Url string Protocol string // [deprecated] use Url Host string // [deprecated] use Url Debug bool Qos byte Retain bool Will *TopicPayload OfflineQueueing bool OfflineQueueMaxSize int OfflineQueueDropBehavior string AutoResubscribe bool // OnConnectionLost is called if the MQTT connection is lost. // Pointer to the Options passed as the argument can be modified for the next reconnect. OnConnectionLost ConnectionLostHandler }
type TopicPayload ¶
Click to show internal directories.
Click to hide internal directories.