device

package
v0.0.0-...-1a36b3a Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPair

type KeyPair struct {
	PrivateKeyPath    string
	CertificatePath   string
	CACertificatePath string
}

KeyPair the structure contains the path to the AWS MQTT credentials

type Shadow

type Shadow []byte

Shadow device shadow data

func (Shadow) String

func (s Shadow) String() string

String converts the Shadow to string

type ShadowError

type ShadowError = Shadow

ShadowError represents the model for handling the errors occurred during updating the device shadow

type Thing

type Thing struct {
	// contains filtered or unexported fields
}

Thing a structure for working with the AWS IoT device shadows

func NewThing

func NewThing(keyPair KeyPair, awsEndpoint string, thingName ThingName) (*Thing, error)

NewThing returns a new instance of Thing

func (*Thing) DeleteThingShadow

func (t *Thing) DeleteThingShadow() error

DeleteThingShadow publishes a message to remove the device's shadow and waits for the result. In case shadow delete was rejected the method will return error

func (*Thing) Disconnect

func (t *Thing) Disconnect()

Disconnect terminates the MQTT connection between the client and the AWS server. Recommended to use in defer to avoid connection leaks.

func (*Thing) GetThingShadow

func (t *Thing) GetThingShadow() (Shadow, error)

GetThingShadow returns the current thing shadow

func (*Thing) PublishToCustomTopic

func (t *Thing) PublishToCustomTopic(payload Shadow, topic string) error

PublishToCustomTopic publishes an async message to the custom topic. The specified topic argument will be prepended by a prefix "$aws/things/<thing_name>"

func (*Thing) SubscribeForCustomTopic

func (t *Thing) SubscribeForCustomTopic(topic string) (chan Shadow, error)

SubscribeForCustomTopic subscribes for the custom topic and returns the channel with the topic messages. The specified topic argument will be prepended by a prefix "$aws/things/<thing_name>"

func (*Thing) SubscribeForThingShadowChanges

func (t *Thing) SubscribeForThingShadowChanges() (chan Shadow, chan ShadowError, error)

SubscribeForThingShadowChanges subscribes for the device shadow update topic and returns two channels: shadow and shadow error. The shadow channel will handle all accepted device shadow updates. The shadow error channel will handle all rejected device shadow updates

func (Thing) UnsubscribeFromCustomTopic

func (t Thing) UnsubscribeFromCustomTopic(topic string) error

UnsubscribeFromCustomTopic terminates the subscription to the custom topic. The specified topic argument will be prepended by a prefix "$aws/things/<thing_name>"

func (*Thing) UpdateThingShadow

func (t *Thing) UpdateThingShadow(payload Shadow) error

UpdateThingShadow publishes an async message with new thing shadow

func (*Thing) UpdateThingShadowDocument

func (t *Thing) UpdateThingShadowDocument(payload Shadow) error

UpdateThingShadowDocument publishes an async message with new thing shadow document

type ThingName

type ThingName = string

ThingName the name of the AWS IoT device representation

Jump to

Keyboard shortcuts

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