gateway

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package gateway provides a pico-cs MQTT broker gateway.

Index

Constants

View Source
const (
	DefaultTopicRoot = "pico-cs"
	DefaultHost      = "localhost"
	DefaultPort      = "1883"
)

Default values.

Variables

View Source
var ReservedFctNames = []string{"dir", "speed"}

ReservedFctNames is the list of reserved function names which cannot be used in loco configurations.

Functions

This section is empty.

Types

type CS

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

A CS represents a gateway command station.

func NewCS

func NewCS(config *CSConfig, gateway *Gateway) (*CS, error)

NewCS returns a new command station instance.

func (*CS) AddLoco

func (cs *CS) AddLoco(config *LocoConfig) (bool, error)

AddLoco adds a loco via a loco configuration to the command station.

func (*CS) Close

func (cs *CS) Close() error

Close closes the command station and the underlying client connection.

func (*CS) String

func (cs *CS) String() string

type CSConfig

type CSConfig struct {
	// command station name (used in topic)
	Name string
	// pico_w host in case of WiFi TCP/IP connection
	Host string
	// TCP/IP port (WiFi) or serial port (serial over USB)
	Port string
	// list of regular expressions defining which set of objects should be controlled by this command station
	// as the primary command station
	Incls []string
	// list of regular expressions defining which set of objects should be controlled by this command station
	// as a secondary command station
	// excluding regular expressions do have precedence over including regular expressions
	Excls []string // List of regular expressions defining
}

CSConfig represents configuration data for a command station.

func (*CSConfig) String

func (c *CSConfig) String() string

type Config

type Config struct {
	// root part of all gateway MQTT topics
	TopicRoot string
	// MQTT broker host
	Host string
	// MQTT broker port
	Port string
	// MQTT authentication username
	Username string
	// MQTT authentication password
	Password string
}

Config represents configuration data for the gateway.

type Gateway

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

Gateway represents a MQTT broker gateway.

func New

func New(config *Config) (*Gateway, error)

New returns a new gateway instance.

func (*Gateway) Close

func (gw *Gateway) Close() error

Close closes the gateway and the MQTT connection.

type LocoConfig

type LocoConfig struct {
	// loco name (used in topic)
	Name string
	// loco decoder address
	Addr uint
	// loco function mapping (key is used in topic)
	Fcts map[string]LocoFctConfig
}

LocoConfig represents configuration data for a loco.

type LocoFctConfig

type LocoFctConfig struct {
	// loco decoder function number
	No uint
}

LocoFctConfig represents configuration data for a loco function.

Jump to

Keyboard shortcuts

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