gateway

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: EPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package gateway implements a MQTT-SN version 1.2 transparent gateway with optional DTLS encryption.

Index

Constants

This section is empty.

Variables

View Source
var Cancelled = errors.New("transaction cancelled")
View Source
var ErrIllegalPacketWhenDisconnected = errors.New("illegal packet in disconnected state")
View Source
var ErrMqttConnClosed = errors.New("MQTT broker closed connection")
View Source
var ErrTopicIDsExhausted = errors.New("no more TopicIDs available")
View Source
var Shutdown = errors.New("clean shutdown")

This error is used to shut down the handler from a goroutine. It does not signalize error.

Functions

This section is empty.

Types

type Gateway

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

func NewGateway

func NewGateway(log util.Logger, cfg *GatewayConfig) *Gateway

func (*Gateway) ListenAndServe

func (gw *Gateway) ListenAndServe(ctx context.Context, address string) error

ListenAndServe starts a gateway listening on the given address. It returns only on fatal internal errors or when the given context is canceled.

type GatewayConfig

type GatewayConfig struct {
	MqttBrokerAddress     *net.TCPAddr
	MqttConnectionTimeout time.Duration
	MqttUser              *string
	MqttPassword          []byte
	// UsePSK controls whether pre-shared key should be used to secure the
	// connection to the MQTT-SN gateway. If UsePSK is true, you must provide
	// PSKIdentityHint, PSKAPIBasicAuthUsername, PSKAPIBasicAuthPassword and
	// PSKAPIEndpoint.
	// If UsePSK is true, the client will use PSKKeys instead of the certificate
	// and private key.
	UsePSK                  bool
	PSKKeys                 *cache.Cache
	PSKCacheExpiration      time.Duration
	PSKIdentityHint         string
	PSKAPITimeout           time.Duration
	PSKAPIBasicAuthUsername string
	PSKAPIBasicAuthPassword string
	PSKAPIEndpoint          string
	UseDTLS                 bool
	SelfSigned              bool
	Certificate             *tls.Certificate
	PrivateKey              crypto.PrivateKey
	PerformanceLogTime      time.Duration
	PredefinedTopics        topics.PredefinedTopics
	AuthEnabled             bool
	// TRetry in MQTT-SN specification
	RetryDelay time.Duration
	// NRetry in MQTT-SN specification
	RetryCount uint
}

Jump to

Keyboard shortcuts

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