mqtt

package
v0.0.0-...-9a529fd Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2017 License: MIT Imports: 10 Imported by: 10

Documentation

Index

Constants

View Source
const QoS = 0x02

Variables

View Source
var (
	// ConnectRetries says how many times the client should retry a failed connection
	ConnectRetries = 10
	// ConnectRetryDelay says how long the client should wait between retries
	ConnectRetryDelay = time.Second
)

Functions

This section is empty.

Types

type ActivationHandler

type ActivationHandler func(client Client, appEUI types.AppEUI, devEUI types.DevEUI, req core.OTAAAppReq)

type Client

type Client interface {
	Connect() error
	Disconnect()

	IsConnected() bool

	// Uplink pub/sub
	PublishUplink(appEUI types.AppEUI, devEUI types.DevEUI, payload core.DataUpAppReq) Token
	SubscribeDeviceUplink(appEUI types.AppEUI, devEUI types.DevEUI, handler UplinkHandler) Token
	SubscribeAppUplink(appEUI types.AppEUI, handler UplinkHandler) Token
	SubscribeUplink(handler UplinkHandler) Token

	// Downlink pub/sub
	PublishDownlink(appEUI types.AppEUI, devEUI types.DevEUI, payload core.DataDownAppReq) Token
	SubscribeDeviceDownlink(appEUI types.AppEUI, devEUI types.DevEUI, handler DownlinkHandler) Token
	SubscribeAppDownlink(appEUI types.AppEUI, handler DownlinkHandler) Token
	SubscribeDownlink(handler DownlinkHandler) Token

	// Activation pub/sub
	PublishActivation(appEUI types.AppEUI, devEUI types.DevEUI, payload core.OTAAAppReq) Token
	SubscribeDeviceActivations(appEUI types.AppEUI, devEUI types.DevEUI, handler ActivationHandler) Token
	SubscribeAppActivations(appEUI types.AppEUI, handler ActivationHandler) Token
	SubscribeActivations(handler ActivationHandler) Token
}

Client connects to the MQTT server and can publish/subscribe on uplink, downlink and activations from devices

func NewClient

func NewClient(ctx log.Interface, id, username, password string, brokers ...string) Client

type DeviceTopic

type DeviceTopic struct {
	AppEUI types.AppEUI
	DevEUI types.DevEUI
	Type   DeviceTopicType
}

DeviceTopic represents an MQTT topic for application devices If the DevEUI is an empty []byte{}, it is considered to be a wildcard

func ParseDeviceTopic

func ParseDeviceTopic(topic string) (*DeviceTopic, error)

ParseDeviceTopic parses an MQTT device topic string to a DeviceTopic struct

func (DeviceTopic) String

func (t DeviceTopic) String() string

String implements the Stringer interface

type DeviceTopicType

type DeviceTopicType string

DeviceTopicType represents the type of a device topic

const (
	// Activations of devices
	Activations DeviceTopicType = "activations"
	// Uplink data from devices
	Uplink DeviceTopicType = "up"
	// Downlink data to devices
	Downlink DeviceTopicType = "down"
)

type DownlinkHandler

type DownlinkHandler func(client Client, appEUI types.AppEUI, devEUI types.DevEUI, req core.DataDownAppReq)

type Token

type Token interface {
	Wait() bool
	WaitTimeout(time.Duration) bool
	Error() error
}

type UplinkHandler

type UplinkHandler func(client Client, appEUI types.AppEUI, devEUI types.DevEUI, req core.DataUpAppReq)

Jump to

Keyboard shortcuts

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