dblume commited on 2024-03-02 13:53:06
Showing 4 changed files, with 54 additions and 22 deletions.
| ... | ... |
@@ -15,19 +15,23 @@ Clicking the link will take you directly to a confirmation page for getting the |
| 15 | 15 |
|
| 16 | 16 |
# Getting the project |
| 17 | 17 |
|
| 18 |
-You can get a copy of this project by clicking on the |
|
| 19 |
-[ZIP](https://git.dlma.com/dxb_channel.git/zipball/main) |
|
| 20 |
-or [TAR](https://git.dlma.com/dxb_channel.git/tarball/main) buttons |
|
| 21 |
-near the top right of the GitList web page. |
|
| 18 |
+At [git.dlma.com](https://git.dlma.com/dxb_channel.git) click Download and |
|
| 19 |
+select Download ZIP or Download TAR. |
|
| 22 | 20 |
|
| 23 | 21 |
If you're me, and you want to contribute to the repo, then you can clone it like so: |
| 24 | 22 |
|
| 25 |
- git clone ssh://USERNAME@dlma.com/~/git/dxb_channel.git |
|
| 23 |
+ git clone ssh://$USER@dlma.com/~/git/dxb_channel.git |
|
| 26 | 24 |
|
| 27 | 25 |
## Building it |
| 28 | 26 |
|
| 29 | 27 |
[Ensure you can sideload a dev channel](https://sdkdocs.roku.com/display/sdkdoc/Loading+and+Running+Your+Application). |
| 30 | 28 |
|
| 29 |
+It is convenient to set environment variables `$ROKU_DEV_TARGET` and `$DEVPASSWORD` in a |
|
| 30 |
+local file ".env". For example: |
|
| 31 |
+ |
|
| 32 |
+ ROKU_DEV_TARGET=192.168.1.2 |
|
| 33 |
+ DEVPASSWORD=mooltipass |
|
| 34 |
+ |
|
| 31 | 35 |
### CLI |
| 32 | 36 |
|
| 33 | 37 |
Running make will build and deploy if you have `$ROKU_DEV_TARGET` and `$DEVPASSWORD` set. |
| ... | ... |
@@ -40,23 +44,21 @@ You can automatically make and deploy with each changed file with the following |
| 40 | 44 |
|
| 41 | 45 |
### VS Code |
| 42 | 46 |
|
| 43 |
-VS Code can also use the Makefile with [VC Code Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools). |
|
| 44 |
-You can set environment variables `$ROKU_DEV_TARGET` and `$DEVPASSWORD` in a file ".env". For example: |
|
| 45 |
- |
|
| 46 |
- ROKU_DEV_TARGET=192.168.1.2 |
|
| 47 |
- DEVPASSWORD=mooltipass |
|
| 47 |
+VS Code can also use the Makefile with |
|
| 48 |
+[VC Code Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools). |
|
| 48 | 49 |
|
| 49 | 50 |
Use dxb\_channel.code-workspace as your workspace file for the project. |
| 50 | 51 |
|
| 51 | 52 |
### Sublime Text |
| 52 | 53 |
|
| 53 |
-See the "build\_systems" command in dxb\_channel.sublime-project to see how the channel is zipped and deployed. |
|
| 54 |
+See the "build\_systems" command in dxb\_channel.sublime-project to see how |
|
| 55 |
+the channel is zipped and deployed. |
|
| 54 | 56 |
|
| 55 | 57 |
## Experimenting |
| 56 | 58 |
|
| 57 | 59 |
The code in [`components/testtask.brs`](https://git.dlma.com/dxb_channel.git/blob/main/components/testtask.brs) |
| 58 |
-is run every time the OK button is pressed (while the "Test Output" pane has focus). |
|
| 59 |
-That's a good place to experiment with new code. |
|
| 60 |
+is run every time the OK button is pressed (while the "Test Output" pane has |
|
| 61 |
+focus). That's a good place to experiment with new code. |
|
| 60 | 62 |
|
| 61 | 63 |
# Is it any good? |
| 62 | 64 |
|
| ... | ... |
@@ -2,10 +2,19 @@ sub init() |
| 2 | 2 |
m.top.functionName = "executeTask" |
| 3 | 3 |
end sub |
| 4 | 4 |
|
| 5 |
-function getDeviceInfo(deviceInfo as object) as Object |
|
| 5 |
+function getDeviceInfo(deviceInfo as object, lastExit as String) as Object |
|
| 6 | 6 |
' Try to get various info from an ECP call |
| 7 | 7 |
aa = {}
|
| 8 |
- aa["RIDA"] = deviceInfo.GetRIDA() |
|
| 8 |
+ |
|
| 9 |
+ ' Getting exit_code here may be a dupe of Launch Param LastExitOrTerminationReason |
|
| 10 |
+ am = CreateObject("roAppManager")
|
|
| 11 |
+ if FindMemberFunction(am, "GetLastExitInfo") <> invalid: |
|
| 12 |
+ lastExitInfo = CreateObject("roAppManager").GetLastExitInfo()
|
|
| 13 |
+ if lastExitInfo <> invalid and lastExitInfo.exit_code <> lastExit: |
|
| 14 |
+ aa["exit code"] = Mid(lastExitInfo.exit_code, 6) + " at " + Mid(lastExitInfo.timestamp, 12, 8) |
|
| 15 |
+ endif |
|
| 16 |
+ endif |
|
| 17 |
+ |
|
| 9 | 18 |
print "Client ID = " deviceInfo.GetChannelClientId() |
| 10 | 19 |
request = CreateObject("roUrlTransfer")
|
| 11 | 20 |
request.SetUrl("http://localhost:8060/query/device-info")
|
| ... | ... |
@@ -35,14 +44,14 @@ function getDeviceInfo(deviceInfo as object) as Object |
| 35 | 44 |
end if |
| 36 | 45 |
aa["friendly name"] = deviceInfo.GetFriendlyName() |
| 37 | 46 |
deets = deviceInfo.GetModelDetails() |
| 38 |
- aa["model"] = deviceInfo.GetModel() + " (" + deets["VendorName"] + " " ++ deets["ModelNumber"] + ")"
|
|
| 47 |
+ aa["model"] = deviceInfo.GetModel() + " (" + deets.VendorName + " " + deets.ModelNumber + ")"
|
|
| 39 | 48 |
return aa |
| 40 | 49 |
end if |
| 41 | 50 |
' That did not work, so make a custom one. |
| 42 | 51 |
deets = deviceInfo.GetModelDetails() |
| 43 |
- aa["model"] = deviceInfo.GetModel() + " (" + deets["VendorName"] + " " ++ deets["ModelNumber"] + ")"
|
|
| 52 |
+ aa.model = deviceInfo.GetModel() + " (" + deets.VendorName + " " + deets.ModelNumber + ")"
|
|
| 44 | 53 |
mmrb = deviceInfo.GetOSVersion() ' major minor revision build |
| 45 |
- aa["firmware version"] = mmrb["major"]+"."+mmrb["minor"] +"."+mmrb["revision"]+" build "+mmrb["build"] |
|
| 54 |
+ aa["firmware version"] = mmrb.major+"."+mmrb.minor+"."+mmrb.revision+" build "+mmrb.build |
|
| 46 | 55 |
aa["friendly name"] = deviceInfo.GetFriendlyName() |
| 47 | 56 |
return aa |
| 48 | 57 |
end function |
| ... | ... |
@@ -58,7 +67,7 @@ function executeTask() as void |
| 58 | 67 |
' m.top.updateText = "devID " + CreateObject("roAppInfo").GetDevID()
|
| 59 | 68 |
|
| 60 | 69 |
deviceInfo = CreateObject("roDeviceInfo")
|
| 61 |
- infoaa = getDeviceInfo(deviceInfo) |
|
| 70 |
+ infoaa = getDeviceInfo(deviceInfo, aaRunParams.lastExitOrTerminationReason) |
|
| 62 | 71 |
if infoaa <> invalid: |
| 63 | 72 |
for each key in infoaa.Keys() |
| 64 | 73 |
val = infoaa[key] |
| ... | ... |
@@ -97,7 +106,10 @@ function executeTask() as void |
| 97 | 106 |
success = deviceInfo.EnableInternetStatusEvent(true) |
| 98 | 107 |
if not success then m.top.updateTextLower = "EnableInternetStatusEvent failure" |
| 99 | 108 |
success = deviceInfo.EnableLowGeneralMemoryEvent(true) |
| 100 |
- if not success then m.top.updateTextLower = "EnableLowGeneralMemoryEvent failure" |
|
| 109 |
+ if FindMemberFunction(deviceInfo, "EnableAudioOutputEvent") <> invalid: |
|
| 110 |
+ success = deviceInfo.EnableAudioOutputEvent(true, "all") |
|
| 111 |
+ if not success then m.top.updateTextLower = "EnableAudioOutputEvent failure" |
|
| 112 |
+ endif |
|
| 101 | 113 |
|
| 102 | 114 |
while(true) |
| 103 | 115 |
msg = wait(0, port) |
| ... | ... |
@@ -145,6 +157,12 @@ function executeTask() as void |
| 145 | 157 |
if v <> invalid then m.top.updateTextLower = dt + " GeneralMemoryLevel " + v.toStr() |
| 146 | 158 |
v = aa.LookupCI("internetStatus")
|
| 147 | 159 |
if v <> invalid then m.top.updateTextLower = dt + " InternetStatus " + v.toStr() |
| 160 |
+ v = aa.LookupCI("audioOutputEvent")
|
|
| 161 |
+ if v <> invalid then |
|
| 162 |
+ m.top.updateTextLower = dt + " audioOutput " + v.toStr() |
|
| 163 |
+ vol = aa.LookupCI("volume")
|
|
| 164 |
+ if vol <> invalid then m.top.updateTextLower = dt + " volume = " + vol.toStr() |
|
| 165 |
+ end if |
|
| 148 | 166 |
elseif msgType = "roInputEvent" |
| 149 | 167 |
info = msg.GetInfo() |
| 150 | 168 |
m.top.updateTextLower = dt + " Input " + FormatJSON(info) |
| ... | ... |
@@ -77,4 +77,16 @@ function executeTest() as void |
| 77 | 77 |
else |
| 78 | 78 |
m.top.updateText = "AsyncPostFromString failed" |
| 79 | 79 |
end if |
| 80 |
+ |
|
| 81 |
+ appMemMon = CreateObject("roAppMemoryMonitor")
|
|
| 82 |
+ if appMemMon <> invalid: |
|
| 83 |
+ m.top.updateText = "roAppMemoryMonitor.GetChannelMemoryLimit" |
|
| 84 |
+ m.top.updateText = " Available Memory MiB = " + (appMemMon.GetChannelAvailableMemory() / 1024).ToStr() + " (" + appMemMon.GetMemoryLimitPercent().ToStr() + "% used)"
|
|
| 85 |
+ if FindMemberFunction(appMemMon, "GetChannelMemoryLimit") <> invalid: |
|
| 86 |
+ ' printAA(appMemMon.GetChannelMemoryLimit()) |
|
| 87 |
+ memFields = appMemMon.GetChannelMemoryLimit() |
|
| 88 |
+ m.top.updateText = " maxForegroundMemory MiB = " + (memFields.maxForegroundMemory / 1024).ToStr() |
|
| 89 |
+ m.top.updateText = " maxBackgroundMemory MiB = " + (memFields.maxBackgroundMemory / 1024).ToStr() |
|
| 90 |
+ endif |
|
| 91 |
+ endif |
|
| 80 | 92 |
end function |