mqtt

package
v0.0.0-...-0dca507 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClientID random length specifies the length of client-id random part.
	ClientIDRandomLength = 10

	// DisconnectTimeout is a waiting time for MQTT client disconnect in ms.
	DisconnectTimeout = 10
)

Variables

This section is empty.

Functions

func Handler

func Handler(p protocol.Protocol, ch chan<- model.Data) paho.MessageHandler

Handler generates specific handler for each protocol.

Types

type Service

type Service struct {
	IsRun bool
	// contains filtered or unexported fields
}

Service is MQTT service for handling device communication.

func New

func New(cfg config.MQTT) *Service

New creates a new MQTT service instance. MQTT service receives messages from protocols and publish them on its channel.

func (*Service) Channel

func (s *Service) Channel() <-chan model.Data

Channel returns a channel for consuming the received data Consuming this channel makes MQTT service work.

func (*Service) Exit

func (s *Service) Exit()

Exit closes MQTT connection then closes all channels and return from all pipeline stages.

func (*Service) Protocols

func (s *Service) Protocols() []string

Protocols returns list of registered protocol's names.

func (*Service) Register

func (s *Service) Register(p protocol.Protocol)

Register registers given protocol on MQTT service.

func (*Service) Run

func (s *Service) Run() error

Run runs application. This function connects MQTT client and then register its topic.

Jump to

Keyboard shortcuts

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