Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel describes the different levels of importance a logging message can have.
const ( // TraceLevel represents the lowest logging level for tracing. TraceLevel LogLevel = iota // DebugLevel represents the second lowest logging level and is used for // debug messages. DebugLevel // InfoLevel represents logging messages a user should see during the // execution of the library. InfoLevel // WarnLevel represents the logging level if something noteworthy happened // which likely could be or lead to unintended behavior. WarnLevel // ErrorLevel represents events which seriously intercept the execution // of the application. ErrorLevel // PanicLevel represents events which will lead to a panicking of the // application. PanicLevel )
type Logger ¶
Logger is the log function used in the library. It takes the message and defines the handling of this message. The message can be used as format string.
type MqttToOscHandler ¶
type MqttToOscHandler struct { // Path to the MQTT topic to be listen to. MqttTopic string `yaml:"mqtt_topic"` // OscAddress points to the address the OSC command should be sent // on an MQTT event. Learn more about the ability to apply templates // in the Handler type documentation. OscAddress string `yaml:"osc_address"` // Translate is the function which can be used to alter the output // OSC address and payload. It gets the concrete MQTT topic which was // called as well as the payload (if any). It returns a map of strings // which will be applied to the template in the OSC address. Note that // no keys beginning with `_` (ex `_1`) are allowed in this map as these // are used to store the content of the wildcard match-groups. Translate *TranslateFunc `yaml:"-"` // RelayPayload states whether the MQTT message should be relayed to // the OSC recipient. RelayPayload bool `yaml:"relay_payload"` // contains filtered or unexported fields }
MqttToOscHandler listen to one MQTT event and describes the effects it will have. This library contains some handler functions for the most common cases.
To increase the flexibility of the handlers the output OSC Address can contain template items. The Translate function can be used to define the data for this template. The matching-groups from the MQTT topic can be accessed by index using `{{ ._1 }}`. The content of the MQTT payload (also known as message) can be accessed using the `{{ .Payload }}` argument.
type Relay ¶
type Relay struct { // MqttHost is the hostname of the MQTT broker. MqttHost string `yaml:"mqtt_host"` // MqttPort is the port of the MQTT broker. MqttPort int `yaml:"mqtt_port"` // MqttClientId sets the MQTT Id of this Relay. MqttClientId string `yaml:"mqtt_client_id"` // MqttUser states the user name used for the authentication // with the MQTT broker. MqttUser string `yaml:"mqtt_user"` // MqttUser states the password used for the authentication // with the MQTT broker. MqttPassword string `yaml:"mqtt_password"` // OscHost is the hostname of the OSC server. OscHost string `yaml:"osc_host"` // OscPort is the port of the OSC server. OscPort int `yaml:"osc_port"` // Handlers is the collection of handler the relay handles. Handlers []MqttToOscHandler `yaml:"handlers"` // LogFunc provides the possibility to customize the log functionality. // The function is called on each log. If no method is set, the debug // output will be outputted to standard output. LogFunc *Logger `yaml:"-"` }
Relay provides the forwarding of messages from MQTT to OSC. It consist contains a slice of Handlers each describing one MQTT event to be listen to.