David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
ee23104
Branches
Tags
main
dxb_channel.git
components
mytask.brs
Add some invariant info to the Launch Params panel.
David Blume
commited
ee23104
at 2020-03-28 13:58:02
mytask.brs
Blame
History
Raw
sub init() m.top.functionName = "executeTask" end sub function getDeviceInfo(deviceInfo as object) as Object ' Try to get various info from an ECP call aa = {} request = CreateObject("roUrlTransfer") request.SetUrl("http://localhost:8060/query/device-info") root = CreateObject("roXMLElement") if root.Parse(request.GetToString()) then elements = root.GetNamedElements("serial-number") if elements.Count() > 0 aa["serial number"] = elements[0].GetText() end if elements = root.GetNamedElements("device-id") if elements.Count() > 0 aa["device ID"] = elements[0].GetText() end if elements = root.GetNamedElements("model-number") if elements.Count() > 0 aa.["model"] = elements[0].GetText() end if elements = root.GetNamedElements("build-number") if elements.Count() > 0 aa.["firmware version"] = elements[0].GetText() end if return aa end if ' That did not work, so make a custom one. clientID = Right(deviceInfo.GetChannelClientId(), 6) modelID = deviceInfo.GetModel() return { "client ID": clientID, "model": 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() end for ' m.top.updateText = "devID " + CreateObject("roAppInfo").GetDevID() deviceInfo = CreateObject("roDeviceInfo") infoaa = getDeviceInfo(deviceInfo) if infoaa <> invalid: for each key in infoaa val = infoaa[key] m.top.updateText = key + " = " + val.ToStr() end for else m.top.updateText = "(Could not get device info.)" end if 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" 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 then m.top.updateTextLower = dt + " HDMI plugged " + v.toStr() elseif msgType = "roCECStatusEvent" aa = msg.GetInfo() v = aa.LookupCI("Active") if v <> invalid then m.top.updateTextLower = dt + " CEC Status " + v.toStr() elseif msgType = "roDeviceInfoEvent" aa = msg.GetInfo() v = aa.LookupCI("Mute") if v <> invalid then m.top.updateTextLower = dt + " Mute " + v.toStr() v = aa.LookupCI("Mode") if v <> invalid then m.top.updateTextLower = dt + " Mode " + v.toStr() v = aa.LookupCI("linkStatus") if v <> invalid then m.top.updateTextLower = dt + " LinkStatus " + v.toStr() v = aa.LookupCI("audioGuideEnabled") if v <> invalid then m.top.updateTextLower = dt + " AudioGuide " + v.toStr() v = aa.LookupCI("appFocused") if v <> invalid then m.top.updateTextLower = dt + " appFocused " + v.toStr() v = aa.LookupCI("audioCodecCapabilityChanged") if v <> invalid then m.top.updateTextLower = dt + " audioCodecCapabilityChanged " + v.toStr() else m.top.updateTextLower = dt + " msgType " + msgType end if end while end function