awsiotdev

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

README

aws-iot-device-sdk-go

GoDoc Build Status codecov License

Package awsiotdev implements offline queueing and reconnecting features of MQTT protocol.

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

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) Publish

func (s *DeviceClient) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token

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

type TopicPayload struct {
	Topic   string
	Payload string
}

Directories

Path Synopsis
Package presigner implements AWS v4 presigner wrapper for AWS IoT websocket connection.
Package presigner implements AWS v4 presigner wrapper for AWS IoT websocket connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL