David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
88c5099
Branches
Tags
main
dxb_channel.git
components
mytask.brs
first commit
David Blume
commited
88c5099
at 2020-03-06 23:03:37
mytask.brs
Blame
History
Raw
sub init() m.top.functionName = "executeTask" end sub function getDeviceId(deviceInfo as object) as String ' Try to get the Serial Number for an ECP call request = CreateObject("roUrlTransfer") request.SetUrl("http://localhost:8060/query/device-info") root = CreateObject("roXMLElement") if root.Parse(request.GetToString()) then serialnums = root.GetNamedElements("serial-number") if serialnums.Count() > 0 model = root.GetNamedElements("model-number") if model.Count() > 0 return serialnums[0].GetText() + ":" + model[0].GetText() end if end if end if ' That did not work, so make a custom one. clientID = Right(deviceInfo.GetChannelClientId(), 6) modelID = deviceInfo.GetModel() return clientID + "-" + modelID end function function executeTask() as void am = CreateObject("roAppManager") aaRunParams = am.GetRunParams() for each key in aaRunParams val = aaRunParams[key] m.top.updateText = key + " = " + val.ToStr() print "roAppManager.runParams " key " = " val end for deviceInfo = CreateObject("roDeviceInfo") port = CreateObject("roMessagePort") deviceInfo.SetMessagePort(port) success = deviceInfo.EnableLinkStatusEvent(true) if not success m.top.updateTextLower = "EnableLinkStatusEvent failure" success = deviceInfo.EnableAudioDestinationEvent(true) if not success then m.top.updateTextLower = "EnableAudioDestinationEvent failure" success = deviceInfo.EnableAudioGuideChangedEvent(true) if not success then m.top.updateTextLower = "EnableAudioGuideChangedEvent failure" success = deviceInfo.EnableAppFocusEvent(true) if not success then m.top.updateTextLower = "EnableAppFocusEvent failure" success = deviceInfo.EnableCodecCapChangedEvent(true) if not success then m.top.updateTextLower = "EnableCodecCapChangedEvent failure" aaConnectionInfo = deviceInfo.GetConnectionInfo() for each key in aaConnectionInfo val = aaConnectionInfo[key] m.top.updateTextRight = key + " = " + val.ToStr() print "roDeviceInfo.ConnectionInfo " key " = " val end for while(true) msg = wait(0, port) msgType = type(msg) dt = Mid(CreateObject("roDateTime").ToISOString(), 15, 5) if msgType = "roHdmiStatusEvent" aa = msg.GetInfo() v = aa.LookupCI("Plugged") if v <> invalid m.top.updateTextLower = dt + " HDMI plugged " + v.toStr() print "HDMI plugged " v.toStr() end if elseif msgType = "roCECStatusEvent" aa = msg.GetInfo() v = aa.LookupCI("Active") if v <> invalid m.top.updateTextLower = dt + " CEC Status " + v.toStr() print "CEC Status " v.toStr() end if elseif msgType = "roDeviceInfoEvent" aa = msg.GetInfo() v = aa.LookupCI("Mute") if v <> invalid m.top.updateTextLower = dt + " Mute " + v.toStr() print "Mute " v.toStr() end if v = aa.LookupCI("Mode") if v <> invalid m.top.updateTextLower = dt + " Mode " + v.toStr() print "Mode " v.toStr() end if v = aa.LookupCI("linkStatus") if v <> invalid m.top.updateTextLower = dt + " LinkStatus " + v.toStr() print "LinkStatus " v.toStr() end if v = aa.LookupCI("audioGuideEnabled") if v <> invalid m.top.updateTextLower = dt + " AudioGuide " + v.toStr() print "AudioGuide " v.toStr() end if v = aa.LookupCI("appFocused") if v <> invalid m.top.updateTextLower = dt + " appFocused " + v.toStr() print "appFocused " v.toStr() end if v = aa.LookupCI("audioCodecCapabilityChanged") if v <> invalid m.top.updateTextLower = dt + " audioCodecCapabilityChanged " + v.toStr() print "audioCodecCapabilityChanged " v.toStr() end if else m.top.updateTextLower = dt + " msgType " + msgType print "Unknown event msgType " v.toStr() end if end while end function