David Blume's GitList
Repositories
dxb_channel.git
Code
Commits
Branches
Tags
Search
Tree:
5720af9
Branches
Tags
main
dxb_channel.git
components
mytask.brs
Add ModelNumber form GetModelDetails
dblume
commited
5720af9
at 2023-02-22 13:28:26
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 = {} aa["RIDA"] = deviceInfo.GetRIDA() aa["client ID"] = deviceInfo.GetChannelClientId() 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 fv = elements[0].GetText() elements = root.GetNamedElements("software-version") if elements.Count() > 0 aa.["firmware version"] = fv + " (" + elements[0].GetText() + " " + mid(fv, 9, 4) + ")" else aa.["firmware version"] = fv end if end if return aa end if ' That did not work, so make a custom one. aa["model"] = deviceInfo.GetModel() + " (" + deviceInfo.GetModelDetails()["ModelNumber"] + ")" mmrb = deviceInfo.GetOSVersion() ' major minor revision build aa["firmware version"] = mmrb["major"]+"."+mmrb["minor"] +"."+mmrb["revision"]+" build "+mmrb["build"] return aa end function function executeTask() as void am = CreateObject("roAppManager") aaRunParams = am.GetRunParams() for each key in aaRunParams.Keys() 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.Keys() 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) input = CreateObject("roInput") input.SetMessagePort(port) cecstatus = CreateObject("roCECStatus") cecStatus.SetMessagePort(port) hdmistatus = CreateObject("roHDMIStatus") hdmistatus.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 Active " + 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 + " Caption 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() elseif msgType = "roInputEvent" info = msg.GetInfo() m.top.updateTextLower = dt + " Input " + FormatJSON(info) else m.top.updateTextLower = dt + " msgType " + msgType end if end while end function