summaryrefslogtreecommitdiff
path: root/src/rhctl/audio_switch.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-03-30 00:06:52 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-03-30 00:06:52 (GMT)
commita8345a1ac7105a4393ab189e45c5ef0aead7577e (patch)
tree8b9226a9c73970b9ca30c6c004bfe4994f584c06 /src/rhctl/audio_switch.go
parent4ee99882db8019a6b49fd22f42b23fc00d2644d6 (diff)
add support for listening to status messages
Diffstat (limited to 'src/rhctl/audio_switch.go')
-rw-r--r--src/rhctl/audio_switch.go30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go
index 4f1ef31..764a231 100644
--- a/src/rhctl/audio_switch.go
+++ b/src/rhctl/audio_switch.go
@@ -33,6 +33,16 @@ const (
SwitchError
)
+func (c SwitchResult) String() string {
+ switch c {
+ case SwitchOK:
+ return "OK"
+ case SwitchError:
+ return "error"
+ }
+ return "unknown"
+}
+
type SwitchResponse struct {
Result SwitchResult
Message string
@@ -46,13 +56,29 @@ type SwitchCommand struct {
type SwitchUpdateType uint8
const (
- SwitchStatus SwitchUpdateType = iota
+ SwitchAudio SwitchUpdateType = iota
SwitchGPI
SwitchOC
SwitchRelay
SwitchSilence
)
+func (c SwitchUpdateType) String() string {
+ switch c {
+ case SwitchAudio:
+ return "audio"
+ case SwitchGPI:
+ return "gpi"
+ case SwitchOC:
+ return "oc"
+ case SwitchRelay:
+ return "relay"
+ case SwitchSilence:
+ return "silence"
+ }
+ return "unknown"
+}
+
type SwitchUpdate struct {
Type SwitchUpdateType
Data string
@@ -92,7 +118,7 @@ func (sw *AudioSwitch) handleData(data string) {
rhl.Printf("Audioswitch: ignoring unexpected response: %q", data)
}
case "S0L":
- sw.Updates <- SwitchUpdate{SwitchStatus, data}
+ sw.Updates <- SwitchUpdate{SwitchAudio, data}
case "S0P":
sw.Updates <- SwitchUpdate{SwitchGPI, data}
case "S0O":