Add some invariant info to the Launch Params panel.
David Blume

David Blume commited on 2020-03-28 13:58:02
Showing 3 changed files, with 33 additions and 12 deletions.

... ...
@@ -2,24 +2,35 @@ sub init()
2 2
     m.top.functionName = "executeTask"
3 3
 end sub
4 4
 
5
-function getDeviceId(deviceInfo as object) as String
6
-    ' Try to get the Serial Number for an ECP call
5
+function getDeviceInfo(deviceInfo as object) as Object
6
+    ' Try to get various info from an ECP call
7
+    aa = {}
7 8
     request = CreateObject("roUrlTransfer")
8 9
     request.SetUrl("http://localhost:8060/query/device-info")
9 10
     root = CreateObject("roXMLElement")
10 11
     if root.Parse(request.GetToString()) then
11
-        serialnums = root.GetNamedElements("serial-number")
12
-        if serialnums.Count() > 0
13
-            model = root.GetNamedElements("model-number")
14
-            if model.Count() > 0
15
-                return serialnums[0].GetText() + ":" + model[0].GetText()
12
+        elements = root.GetNamedElements("serial-number")
13
+        if elements.Count() > 0
14
+            aa["serial number"] = elements[0].GetText()
16 15
         end if
16
+        elements = root.GetNamedElements("device-id")
17
+        if elements.Count() > 0
18
+            aa["device ID"] = elements[0].GetText()
17 19
         end if
20
+        elements = root.GetNamedElements("model-number")
21
+        if elements.Count() > 0
22
+            aa.["model"] = elements[0].GetText()
23
+        end if
24
+        elements = root.GetNamedElements("build-number")
25
+        if elements.Count() > 0
26
+            aa.["firmware version"] = elements[0].GetText()
27
+        end if
28
+        return aa
18 29
     end if
19 30
     ' That did not work, so make a custom one.
20 31
     clientID = Right(deviceInfo.GetChannelClientId(), 6)
21 32
     modelID = deviceInfo.GetModel()
22
-    return clientID + "-" + modelID
33
+    return { "client ID": clientID, "model": modelID }
23 34
 end function
24 35
 
25 36
 function executeTask() as void
... ...
@@ -30,9 +41,18 @@ function executeTask() as void
30 41
         val = aaRunParams[key]
31 42
         m.top.updateText = key + " = " + val.ToStr()
32 43
     end for 
33
-    m.top.updateText = "devID " + CreateObject("roAppInfo").GetDevID()
44
+    ' m.top.updateText = "devID " + CreateObject("roAppInfo").GetDevID()
34 45
 
35 46
     deviceInfo = CreateObject("roDeviceInfo")
47
+    infoaa = getDeviceInfo(deviceInfo)
48
+    if infoaa <> invalid:
49
+        for each key in infoaa
50
+            val = infoaa[key]
51
+            m.top.updateText = key + " = " + val.ToStr()
52
+        end for 
53
+    else
54
+        m.top.updateText = "(Could not get device info.)"
55
+    end if
36 56
     port = CreateObject("roMessagePort")
37 57
     deviceInfo.SetMessagePort(port)
38 58
 
... ...
@@ -45,7 +45,8 @@ function executeTest() as void
45 45
     port = CreateObject("roMessagePort")
46 46
     request.SetMessagePort(port)
47 47
 
48
-    res = request.AsyncPostFromString("My dxb credentials.")
48
+    requestBody = { "token": "auth" }
49
+    res = request.AsyncPostFromString(FormatJson(requestBody))
49 50
     if res = true
50 51
         msg = wait(0, port)
51 52
         if type(msg) = "roUrlEvent"
... ...
@@ -1,7 +1,7 @@
1 1
 title=dxb
2 2
 major_version=0
3
-minor_version=0
4
-build_version=8
3
+minor_version=1
4
+build_version=0
5 5
 ui_resolutions=fhd
6 6
 mm_icon_focus_hd=pkg:/images/mm_icon_focus_hd.png
7 7
 mm_icon_focus_sd=pkg:/images/mm_icon_focus_sd.png
8 8