Documentation ¶
Index ¶
- Constants
- func DisconnectTimeout(sec time.Duration) func(*Config)
- func KeepAlive(sec time.Duration) func(*Config)
- func Timeout(sec time.Duration) func(*Config)
- type BrokerError
- type Command
- type Commander
- func (cm *Commander) DisableAllLights() error
- func (cm *Commander) PlatformColor(platformID byte, rgb RGB) error
- func (cm *Commander) PlatformFadePixels(platformID byte, rgb RGB, delay byte) error
- func (cm *Commander) PlatformRotateColor(platformID byte, rgb RGB, delay int) error
- func (cm *Commander) PlatformSensorReading(platformID byte) error
- type Config
- type MQTT
- type RGB
Constants ¶
const ( // CmdOn represents command for lighting the stands CmdOn byte = iota // CmdOff represents command for disabling lights on stands CmdOff // CmdAnimate represents command for lighting stand led by led CmdAnimate // CmdSensor represents command for getting sensor data CmdSensor // CmdFade represents command for slowly lighting the stand CmdFade // CmdOffAll represents command for disabling lights on all stands CmdOffAll )
List of commands that can be sent.
Variables ¶
This section is empty.
Functions ¶
func DisconnectTimeout ¶
DisconnectTimeout is a functional option for creating MQTT clients.
Types ¶
type BrokerError ¶
type BrokerError string
BrokerError informs about possible failures when connecting to the broker.
const ( // BrokerConnectionError when client can not connect to broker. BrokerConnectionError BrokerError = "BROKER_CONNECTION_ERROR - Could not connect to the MQTT broker" )
type Commander ¶
type Commander struct {
// contains filtered or unexported fields
}
Commander helps in constructing commands for MQTT client.
func NewCommander ¶
func NewCommander(cli publisher) *Commander
NewCommander creates commander, that sends commands through given MQTT client.
func (*Commander) DisableAllLights ¶
DisableAllLights turns off all lights.
func (*Commander) PlatformColor ¶
PlatformColor lights up platform.
func (*Commander) PlatformFadePixels ¶
PlatformFadePixels turns on every single pixel one by one.
func (*Commander) PlatformRotateColor ¶
PlatformRotateColor rotates pixel around the platform.
func (*Commander) PlatformSensorReading ¶
PlatformSensorReading enables reading callback events.
type Config ¶
type Config struct { MQTT struct { Broker string `envconfig:"default=tcp://test.mosquitto.org:1883"` KeepAlive struct { Seconds time.Duration `envconfig:"default=2s"` } Timeout struct { Seconds time.Duration `envconfig:"default=2s"` } Disconnect struct { Milliseconds time.Duration `envconfig:"default=250ms"` } } }
Config for MQTT supporting envconfig for environmental variable parsing. If initialized correctly (by envconfig), contains sane defaults.
type MQTT ¶
MQTT is an abstraction over MQTT client with API specific for Bullseye slab control.
func FromConfig ¶
FromConfig initializes MQTT client based on config, as opposed to New, which initializes based on functional options.
func (*MQTT) Disconnect ¶
Disconnect from the server.