Compare commits
No commits in common. "main" and "v0.2" have entirely different histories.
16
Dockerfile
16
Dockerfile
@ -1,16 +0,0 @@
|
|||||||
FROM golang:1.20
|
|
||||||
|
|
||||||
# Build app
|
|
||||||
WORKDIR /app
|
|
||||||
COPY go.mod go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
COPY *.go ./
|
|
||||||
RUN go build -o /midi-request-trigger
|
|
||||||
WORKDIR /app
|
|
||||||
RUN rm -Rf /app; mkdir /etc/midi-request-trigger
|
|
||||||
|
|
||||||
# Configuration volume
|
|
||||||
VOLUME ["/etc/midi-request-trigger"]
|
|
||||||
|
|
||||||
# Command
|
|
||||||
CMD ["/midi-request-trigger"]
|
|
90
README.md
90
README.md
@ -110,7 +110,7 @@ On MacOS, there is an IAC Driver that can be enabled in Audio MIDI Setup.
|
|||||||
midi_routers:
|
midi_routers:
|
||||||
- name: service_notifications
|
- name: service_notifications
|
||||||
device: IAC Driver Bus 1
|
device: IAC Driver Bus 1
|
||||||
log_level: 2
|
debug_listener: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example note trigger configuration
|
### Example note trigger configuration
|
||||||
@ -120,7 +120,7 @@ midi_routers:
|
|||||||
midi_routers:
|
midi_routers:
|
||||||
- name: service_notifications
|
- name: service_notifications
|
||||||
device: IAC Driver Bus 1
|
device: IAC Driver Bus 1
|
||||||
log_level: 2
|
debug_listener: true
|
||||||
note_triggers:
|
note_triggers:
|
||||||
- channel: 0
|
- channel: 0
|
||||||
note: 0
|
note: 0
|
||||||
@ -136,7 +136,7 @@ midi_routers:
|
|||||||
midi_routers:
|
midi_routers:
|
||||||
- name: service_notifications
|
- name: service_notifications
|
||||||
device: IAC Driver Bus 1
|
device: IAC Driver Bus 1
|
||||||
log_level: 2
|
debug_listener: true
|
||||||
request_triggers:
|
request_triggers:
|
||||||
- channel: 0
|
- channel: 0
|
||||||
note: 0
|
note: 0
|
||||||
@ -152,7 +152,7 @@ midi_routers:
|
|||||||
midi_routers:
|
midi_routers:
|
||||||
- name: service_notifications
|
- name: service_notifications
|
||||||
device: IAC Driver Bus 1
|
device: IAC Driver Bus 1
|
||||||
log_level: 3
|
debug_listener: true
|
||||||
note_triggers:
|
note_triggers:
|
||||||
- channel: 0
|
- channel: 0
|
||||||
note: 0
|
note: 0
|
||||||
@ -174,85 +174,5 @@ midi_routers:
|
|||||||
headers:
|
headers:
|
||||||
Content-Type:
|
Content-Type:
|
||||||
- multipart/form-data; boundary=---------------------------888832887744
|
- multipart/form-data; boundary=---------------------------888832887744
|
||||||
```
|
debug_request: true
|
||||||
|
|
||||||
### Example mqtt config
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
---
|
|
||||||
midi_routers:
|
|
||||||
- name: Wing Midi Signals
|
|
||||||
device: WING Port 4
|
|
||||||
mqtt:
|
|
||||||
host: 10.0.0.2
|
|
||||||
port: 1883
|
|
||||||
client_id: midi_mqtt_bridge
|
|
||||||
user: mqtt
|
|
||||||
password: password
|
|
||||||
topic: midi/behringer_wing
|
|
||||||
log_level: 4
|
|
||||||
note_triggers:
|
|
||||||
- channel: 0
|
|
||||||
note: 1
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "1"
|
|
||||||
- channel: 0
|
|
||||||
note: 2
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "2"
|
|
||||||
- channel: 0
|
|
||||||
note: 3
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "3"
|
|
||||||
- channel: 0
|
|
||||||
note: 4
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "4"
|
|
||||||
- channel: 0
|
|
||||||
note: 5
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "5"
|
|
||||||
- channel: 0
|
|
||||||
note: 6
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "6"
|
|
||||||
- channel: 0
|
|
||||||
note: 7
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "7"
|
|
||||||
- channel: 0
|
|
||||||
note: 8
|
|
||||||
match_all_velocities: true
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/enc/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "8"
|
|
||||||
- channel: 0
|
|
||||||
match_all_notes: true
|
|
||||||
match_all_velocities: true
|
|
||||||
delay_before: 200ms
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/bu/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "1"
|
|
||||||
- channel: 0
|
|
||||||
match_all_notes: true
|
|
||||||
match_all_velocities: true
|
|
||||||
delay_before: 200ms
|
|
||||||
mqtt_topic: osc/behringer_wing/send/$ctl/user/2/2/bu/val
|
|
||||||
mqtt_payload:
|
|
||||||
- "0"
|
|
||||||
delay_after: 200ms
|
|
||||||
```
|
```
|
||||||
|
@ -48,7 +48,7 @@ func (a *App) ReadConfig() {
|
|||||||
} else if _, err := os.Stat(etcConfig); err == nil {
|
} else if _, err := os.Stat(etcConfig); err == nil {
|
||||||
configFile = etcConfig
|
configFile = etcConfig
|
||||||
} else {
|
} else {
|
||||||
log.Println("Unable to find a configuration file.")
|
log.Fatal("Unable to find a configuration file.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the configuration file.
|
// Load the configuration file.
|
||||||
@ -68,7 +68,6 @@ func (a *App) ReadConfig() {
|
|||||||
fig.Dirs(filePath),
|
fig.Dirs(filePath),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.config = config
|
|
||||||
log.Printf("Error parsing configuration: %s\n", err)
|
log.Printf("Error parsing configuration: %s\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -15,7 +15,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
serviceName = "midi-request-trigger"
|
serviceName = "midi-request-trigger"
|
||||||
serviceDescription = "Takes trigger MIDI messages by HTTP or MQTT requests and trigger HTTP or MQTT requests by MIDI messages"
|
serviceDescription = "Takes trigger MIDI messages by HTTP or MQTT requests and trigger HTTP or MQTT requests by MIDI messages"
|
||||||
serviceVersion = "0.3"
|
serviceVersion = "0.2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// App is the global application structure for communicating between servers and storing information.
|
// App is the global application structure for communicating between servers and storing information.
|
||||||
|
107
midiRouter.go
107
midiRouter.go
@ -11,7 +11,6 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||||
"gitlab.com/gomidi/midi/v2"
|
"gitlab.com/gomidi/midi/v2"
|
||||||
@ -22,10 +21,8 @@ import (
|
|||||||
type LogLevel int
|
type LogLevel int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Logs info messages.
|
// Logs only errors.
|
||||||
InfoLog LogLevel = iota
|
ErrorLog LogLevel = iota
|
||||||
// Log only errors.
|
|
||||||
ErrorLog
|
|
||||||
// MQTT, HTTP, and MIDI receive logging.
|
// MQTT, HTTP, and MIDI receive logging.
|
||||||
ReceiveLog
|
ReceiveLog
|
||||||
// MQTT, HTTP, and MIDI send logging.
|
// MQTT, HTTP, and MIDI send logging.
|
||||||
@ -36,7 +33,7 @@ const (
|
|||||||
|
|
||||||
// Provides a string value for a log level.
|
// Provides a string value for a log level.
|
||||||
func (l LogLevel) String() string {
|
func (l LogLevel) String() string {
|
||||||
return [...]string{"Info", "Error", "Receive", "Send", "Debug"}[l]
|
return [...]string{"Error", "Receive", "Send", "Debug"}[l]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configurations relating to MQTT connection.
|
// Configurations relating to MQTT connection.
|
||||||
@ -73,25 +70,20 @@ type MQTTPayload struct {
|
|||||||
|
|
||||||
// Triggers that occur from MIDI messages received.
|
// Triggers that occur from MIDI messages received.
|
||||||
type NoteTrigger struct {
|
type NoteTrigger struct {
|
||||||
|
// If set, every note played will be matched.
|
||||||
|
MatchAllNotes bool `fig:"match_all_notes"`
|
||||||
// Channel to match.
|
// Channel to match.
|
||||||
Channel uint8 `fig:"channel"`
|
Channel uint8 `fig:"channel"`
|
||||||
// If we should match all channel values.
|
|
||||||
MatchAllChannels bool `fig:"match_all_channels"`
|
|
||||||
// Note to match.
|
// Note to match.
|
||||||
Note uint8 `fig:"note"`
|
Note uint8 `fig:"note"`
|
||||||
// If we should match all note values.
|
|
||||||
MatchAllNotes bool `fig:"match_all_notes"`
|
|
||||||
// Velocity to match.
|
// Velocity to match.
|
||||||
Velocity uint8 `fig:"velocity"`
|
Velocity uint8 `fig:"velocity"`
|
||||||
// If we should match all velocity values.
|
// If we should match all velocity values.
|
||||||
MatchAllVelocities bool `fig:"match_all_velocities"`
|
MatchAllVelocities bool `fig:"match_all_velocities"`
|
||||||
// Allow delaying the request.
|
|
||||||
DelayBefore time.Duration `fig:"delay_before"`
|
|
||||||
DelayAfter time.Duration `fig:"deplay_after"`
|
|
||||||
// Custom MQTT message. Do not set to ignore MQTT.
|
// Custom MQTT message. Do not set to ignore MQTT.
|
||||||
MqttTopic string `fig:"mqtt_topic"`
|
MqttTopic string `fig:"mqtt_topic"`
|
||||||
// Nil payload will generate a payload with midi info.
|
// Nil payload will generate a payload with midi info.
|
||||||
MqttPayload interface{} `fig:"mqtt_payload"`
|
MqttPayload []interface{} `fig:"mqtt_payload"`
|
||||||
// If the HTTP request should includ midi info.
|
// If the HTTP request should includ midi info.
|
||||||
MidiInfoInRequest bool `fig:"midi_info_in_request"`
|
MidiInfoInRequest bool `fig:"midi_info_in_request"`
|
||||||
// Should SSL requests require a valid certificate.
|
// Should SSL requests require a valid certificate.
|
||||||
@ -140,19 +132,18 @@ type MidiRouter struct {
|
|||||||
RequestTriggers []RequestTrigger `fig:"request_triggers"`
|
RequestTriggers []RequestTrigger `fig:"request_triggers"`
|
||||||
|
|
||||||
// How much logging.
|
// How much logging.
|
||||||
// 0 - Info
|
// 0 - Errors
|
||||||
// 1 - Errors
|
// 1 - MQTT and OSC receive logging.
|
||||||
// 2 - MQTT, HTTP, and MIDI receive logging.
|
// 2 - MQTT and OSC send logging.
|
||||||
// 3 - MQTT, HTTP, and MIDI send logging.
|
// 3 - Debug
|
||||||
// 4 - Debug
|
LogLevel LogLevel `yaml:"log_level" json:"log_level"`
|
||||||
LogLevel LogLevel `fig:"log_level"`
|
|
||||||
|
|
||||||
// Connection to MIDI device.
|
// Connection to MIDI device.
|
||||||
MidiOut drivers.Out `fig:"-"`
|
MidiOut drivers.Out `fig:"-"`
|
||||||
// Function to stop listening to MIDI device.
|
// Function to stop listening to MIDI device.
|
||||||
ListenerStop func() `fig:"-"`
|
ListenerStop func() `fig:"-"`
|
||||||
// The client connection to MQTT.
|
// The client connection to MQTT.
|
||||||
MqttClient mqtt.Client `fig:"-"`
|
MqttClient mqtt.Client `yaml:"-" json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging function to allow log levels.
|
// Logging function to allow log levels.
|
||||||
@ -165,7 +156,7 @@ func (r *MidiRouter) Log(level LogLevel, format string, args ...interface{}) {
|
|||||||
// When a MIDI message occurs, send the HTTP request.
|
// When a MIDI message occurs, send the HTTP request.
|
||||||
func (r *MidiRouter) sendRequest(channel, note, velocity uint8) {
|
func (r *MidiRouter) sendRequest(channel, note, velocity uint8) {
|
||||||
// If MQTT firehose not disabled, send to general cmd topic.
|
// If MQTT firehose not disabled, send to general cmd topic.
|
||||||
if r.MqttClient != nil && !r.MQTT.DisableMidiFirehose {
|
if r.MQTT.Host != "" && r.MQTT.Port != 0 && !r.MQTT.DisableMidiFirehose {
|
||||||
payload := MQTTPayload{
|
payload := MQTTPayload{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
Note: note,
|
Note: note,
|
||||||
@ -177,7 +168,7 @@ func (r *MidiRouter) sendRequest(channel, note, velocity uint8) {
|
|||||||
} else {
|
} else {
|
||||||
topic := r.MQTT.Topic + "/cmd"
|
topic := r.MQTT.Topic + "/cmd"
|
||||||
r.MqttClient.Publish(topic, 0, true, data)
|
r.MqttClient.Publish(topic, 0, true, data)
|
||||||
r.Log(SendLog, "-> [MQTT] %s: %s", topic, string(data))
|
r.Log(SendLog, "-> [MQTT] %s", topic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,26 +177,15 @@ func (r *MidiRouter) sendRequest(channel, note, velocity uint8) {
|
|||||||
// If match all notes, process this request.
|
// If match all notes, process this request.
|
||||||
// If not, check if channel, note, and velocity matches.
|
// If not, check if channel, note, and velocity matches.
|
||||||
// The velocity may be defined to accept all.
|
// The velocity may be defined to accept all.
|
||||||
if (trig.Channel == channel || trig.MatchAllChannels) && (trig.Note == note || trig.MatchAllNotes) && (trig.Velocity == velocity || trig.MatchAllVelocities) {
|
if trig.MatchAllNotes || (trig.Channel == channel && trig.Note == note && (trig.Velocity == velocity || trig.MatchAllVelocities)) {
|
||||||
// For all logging, we want to print the message so setup a common string to print.
|
// For all logging, we want to print the message so setup a common string to print.
|
||||||
logInfo := fmt.Sprintf("note %s(%d) on channel %v with velocity %v", midi.Note(note), note, channel, velocity)
|
logInfo := fmt.Sprintf("note %s(%d) on channel %v with velocity %v", midi.Note(note), note, channel, velocity)
|
||||||
|
|
||||||
// Delay before.
|
if trig.MqttTopic != "" {
|
||||||
time.Sleep(trig.DelayBefore)
|
|
||||||
|
|
||||||
// If MQTT trigger, send the MQTT request.
|
|
||||||
if trig.MqttTopic != "" && r.MqttClient != nil {
|
|
||||||
// If payload provided, send the defined payload.
|
|
||||||
if trig.MqttPayload != nil {
|
if trig.MqttPayload != nil {
|
||||||
data, err := json.Marshal(trig.MqttPayload)
|
r.MqttClient.Publish(trig.MqttTopic, 0, true, trig.MqttPayload)
|
||||||
if err != nil {
|
r.Log(SendLog, "-> [MQTT] %s", trig.MqttTopic)
|
||||||
r.Log(ErrorLog, "Json Encode: %s", err)
|
|
||||||
} else {
|
} else {
|
||||||
r.MqttClient.Publish(trig.MqttTopic, 0, true, data)
|
|
||||||
r.Log(SendLog, "-> [MQTT] %s: %s", trig.MqttTopic, string(data))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If no payload provided, send the note information as JSON.
|
|
||||||
payload := MQTTPayload{
|
payload := MQTTPayload{
|
||||||
Channel: channel,
|
Channel: channel,
|
||||||
Note: note,
|
Note: note,
|
||||||
@ -216,12 +196,11 @@ func (r *MidiRouter) sendRequest(channel, note, velocity uint8) {
|
|||||||
r.Log(ErrorLog, "Json Encode: %s", err)
|
r.Log(ErrorLog, "Json Encode: %s", err)
|
||||||
} else {
|
} else {
|
||||||
r.MqttClient.Publish(trig.MqttTopic, 0, true, data)
|
r.MqttClient.Publish(trig.MqttTopic, 0, true, data)
|
||||||
r.Log(SendLog, "-> [MQTT] %s: %s", trig.MqttTopic, string(data))
|
r.Log(SendLog, "-> [MQTT] %s", trig.MqttTopic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If URL trigger defined, perform a HTTP request.
|
|
||||||
if trig.URL != "" {
|
if trig.URL != "" {
|
||||||
// Default method to GET if nothing is defined.
|
// Default method to GET if nothing is defined.
|
||||||
if trig.Method == "" {
|
if trig.Method == "" {
|
||||||
@ -290,9 +269,6 @@ func (r *MidiRouter) sendRequest(channel, note, velocity uint8) {
|
|||||||
r.Log(DebugLog, "Trigger response: %s\n%s", logInfo, string(body))
|
r.Log(DebugLog, "Trigger response: %s\n%s", logInfo, string(body))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delay after.
|
|
||||||
time.Sleep(trig.DelayAfter)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,34 +455,24 @@ func (r *MidiRouter) MqttSubscribe(topic string) {
|
|||||||
func (r *MidiRouter) Connect() {
|
func (r *MidiRouter) Connect() {
|
||||||
// If request triggers defined, find the out port.
|
// If request triggers defined, find the out port.
|
||||||
if len(r.RequestTriggers) != 0 {
|
if len(r.RequestTriggers) != 0 {
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
out, err := midi.FindOutPort(r.Device)
|
out, err := midi.FindOutPort(r.Device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log(ErrorLog, "Can't find output device: %s", r.Device)
|
log.Println("Can't find output device:", r.Device)
|
||||||
} else {
|
} else {
|
||||||
r.MidiOut = out
|
r.MidiOut = out
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.Log(ErrorLog, "Retrying in 1 minute.")
|
|
||||||
time.Sleep(time.Minute)
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
// If listener is disabled, stop here.
|
// If listener is disabled, stop here.
|
||||||
if !r.DisableListener {
|
if r.DisableListener {
|
||||||
go func() {
|
return
|
||||||
for {
|
}
|
||||||
|
|
||||||
// Try finding input port.
|
// Try finding input port.
|
||||||
r.Log(InfoLog, "Connecting to input device: %s", r.Device)
|
log.Println("Connecting to device:", r.Device)
|
||||||
in, err := midi.FindInPort(r.Device)
|
in, err := midi.FindInPort(r.Device)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log(ErrorLog, "Can't find input device: %s", r.Device)
|
log.Println("Can't find device:", r.Device)
|
||||||
r.Log(ErrorLog, "Retrying in 1 minute.")
|
return
|
||||||
time.Sleep(time.Minute)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start listening to MIDI messages.
|
// Start listening to MIDI messages.
|
||||||
@ -530,22 +496,13 @@ func (r *MidiRouter) Connect() {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Log(ErrorLog, "Error listening to device: %s", err)
|
r.Log(ErrorLog, "Error listening to device: %s", err)
|
||||||
r.Log(ErrorLog, "Retrying in 1 minute.")
|
return
|
||||||
time.Sleep(time.Minute)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
r.Log(InfoLog, "Connected to input device: %s", r.Device)
|
|
||||||
|
|
||||||
// Update stop function for disconnects.
|
// Update stop function for disconnects.
|
||||||
r.ListenerStop = stop
|
r.ListenerStop = stop
|
||||||
break
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
if r.MQTT.Host != "" && r.MQTT.Port != 0 {
|
if r.MQTT.Host != "" && r.MQTT.Port != 0 {
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
// Connect to MQTT.
|
// Connect to MQTT.
|
||||||
mqtt_opts := mqtt.NewClientOptions()
|
mqtt_opts := mqtt.NewClientOptions()
|
||||||
mqtt_opts.AddBroker(fmt.Sprintf("tcp://%s:%d", r.MQTT.Host, r.MQTT.Port))
|
mqtt_opts.AddBroker(fmt.Sprintf("tcp://%s:%d", r.MQTT.Host, r.MQTT.Port))
|
||||||
@ -558,9 +515,7 @@ func (r *MidiRouter) Connect() {
|
|||||||
r.Log(DebugLog, "Connecting to MQTT")
|
r.Log(DebugLog, "Connecting to MQTT")
|
||||||
if t := r.MqttClient.Connect(); t.Wait() && t.Error() != nil {
|
if t := r.MqttClient.Connect(); t.Wait() && t.Error() != nil {
|
||||||
log.Fatalf("MQTT error: %s", t.Error())
|
log.Fatalf("MQTT error: %s", t.Error())
|
||||||
r.Log(ErrorLog, "Retrying in 1 minute.")
|
return
|
||||||
time.Sleep(time.Minute)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe to MQTT topics.
|
// Subscribe to MQTT topics.
|
||||||
@ -575,9 +530,6 @@ func (r *MidiRouter) Connect() {
|
|||||||
r.MqttSubscribe(r.MQTT.Topic + "/" + trig.MqttSubTopic)
|
r.MqttSubscribe(r.MQTT.Topic + "/" + trig.MqttSubTopic)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,5 +539,4 @@ func (r *MidiRouter) Disconnect() {
|
|||||||
if r.ListenerStop != nil {
|
if r.ListenerStop != nil {
|
||||||
r.ListenerStop()
|
r.ListenerStop()
|
||||||
}
|
}
|
||||||
r.MqttClient.Disconnect(0)
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user