Skip to content

Commit

Permalink
Unknown state fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Markushaldorsen committed Sep 30, 2020
1 parent 4a21a95 commit dcc5220
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/router/from-fimp.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (fc *FromFimpRouter) routeFimpMessage(newMsg *fimpgo.Message) {
} else if fc.states.NowPlaying.PlayStatus == "PAUSE_STATE" {
val = "pause"
} else {
val = "unknown"
val = "pause"
}
adr := &fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: model.ServiceName, ResourceAddress: "1", ServiceName: "media_player", ServiceAddress: addr}
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, val, nil, nil, newMsg.Payload)
Expand Down Expand Up @@ -198,7 +198,7 @@ func (fc *FromFimpRouter) routeFimpMessage(newMsg *fimpgo.Message) {
}
if fc.states.NowPlaying.Source == "STANDBY" {
adr := &fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: model.ServiceName, ResourceAddress: "1", ServiceName: "media_player", ServiceAddress: addr}
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "stop", nil, nil, newMsg.Payload)
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "pause", nil, nil, newMsg.Payload)
fc.mqt.Publish(adr, msg)
} else if fc.states.NowPlaying.PlayStatus == "PLAY_STATE" {
adr := &fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: model.ServiceName, ResourceAddress: "1", ServiceName: "media_player", ServiceAddress: addr}
Expand All @@ -210,7 +210,7 @@ func (fc *FromFimpRouter) routeFimpMessage(newMsg *fimpgo.Message) {
fc.mqt.Publish(adr, msg)
} else {
adr := &fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: model.ServiceName, ResourceAddress: "1", ServiceName: "media_player", ServiceAddress: addr}
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "unknown", nil, nil, newMsg.Payload)
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "pause", nil, nil, newMsg.Payload)
fc.mqt.Publish(adr, msg)
}

Expand Down Expand Up @@ -584,6 +584,10 @@ func (fc *FromFimpRouter) routeFimpMessage(newMsg *fimpgo.Message) {
msg := fimpgo.NewMessage("evt.thing.inclusion_report", "bose", fimpgo.VTypeObject, inclReport, nil, nil, nil)
adr := fimpgo.Address{MsgType: fimpgo.MsgTypeEvt, ResourceType: fimpgo.ResourceTypeAdapter, ResourceName: "bose", ResourceAddress: "1"}
fc.mqt.Publish(&adr, msg)

msg = fimpgo.NewMessage("cmd.playback.get_report", "media_player", fimpgo.VTypeNull, nil, nil, nil, nil)
adr = fimpgo.Address{MsgType: fimpgo.MsgTypeCmd, ResourceType: fimpgo.ResourceTypeDevice, ResourceName: "bose", ResourceAddress: "1", ServiceName: "media_player", ServiceAddress: inclReport.Address}
fc.mqt.Publish(&adr, msg)
}
}
fc.appLifecycle.SetConfigState(model.ConfigStateConfigured)
Expand Down
6 changes: 4 additions & 2 deletions src/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func main() {

if oldPbStateValue != states.NowPlaying.PlayStatus && oldPbStateValue != states.NowPlaying.Source {
if states.NowPlaying.Source == "STANDBY" {
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "stop", nil, nil, nil)
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "pause", nil, nil, nil)
mqtt.Publish(adr, msg)
oldPbStateValue = states.NowPlaying.Source
} else if states.NowPlaying.PlayStatus == "PLAY_STATE" {
Expand All @@ -142,7 +142,7 @@ func main() {
mqtt.Publish(adr, msg)
oldPbStateValue = states.NowPlaying.PlayStatus
} else {
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "unknown", nil, nil, nil)
msg := fimpgo.NewMessage("evt.playback.report", "media_player", fimpgo.VTypeString, "pause", nil, nil, nil)
mqtt.Publish(adr, msg)
oldPbStateValue = states.NowPlaying.PlayStatus
}
Expand Down Expand Up @@ -207,6 +207,8 @@ func main() {
oldMuted = states.Volume.Muteenabled
log.Info("New mute.report sent to fimp")
}
} else {
log.Error("Cant get states from device ", PlayerIP)
}
}
}
Expand Down

0 comments on commit dcc5220

Please sign in to comment.