David Blume commited on 2018-10-21 12:12:16
Showing 9 changed files, with 156 additions and 83 deletions.
... | ... |
@@ -6,8 +6,8 @@ all: $(ZIPFILE) |
6 | 6 |
-F "mysubmit=Install" --output /dev/null --write-out "%{http_code}" \ |
7 | 7 |
http://$(ROKU_DEV_TARGET)/plugin_install |
8 | 8 |
|
9 |
-$(ZIPFILE): manifest source/*.brs images/*.png |
|
10 |
- zip $@ manifest source/*.* images/*.* |
|
9 |
+$(ZIPFILE): manifest source/*.brs components/*.xml images/*.png |
|
10 |
+ zip $@ manifest source/*.brs components/*.xml images/*.png |
|
11 | 11 |
|
12 | 12 |
clean: |
13 | 13 |
rm $(ZIPFILE) |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
# IP Tagger |
2 | 2 |
|
3 |
-IP Tagger is a test [channel for Roku devices](http://sdkdocs.roku.com/display/sdkdoc/Getting+Started). |
|
4 |
-It uses the BrightScript language. |
|
3 |
+IP Tagger is a test [channel for Roku devices](https://sdkdocs.roku.com/display/sdkdoc/SceneGraph+Samples). |
|
4 |
+It uses SceneGraph and the BrightScript language. |
|
5 | 5 |
|
6 | 6 |
# Getting the project |
7 | 7 |
|
... | ... |
@@ -16,9 +16,9 @@ If you're me, and you want to contribute to the repo, then you can clone it like |
16 | 16 |
|
17 | 17 |
# Building it |
18 | 18 |
|
19 |
-In the source directory, move the file "[settings.brs.sample](http://git.dlma.com/roku_ip_tagger.git/blob/master/source/settings.brs.sample)" to "settings.brs" and update its `url` and `auth` fields. |
|
19 |
+In the components directory, move the file "[settings.xml.sample](http://git.dlma.com/roku_ip_tagger.git/blob/master/components/settings.xml.sample)" to "settings.xml" and update its `url` and `auth` fields. |
|
20 | 20 |
|
21 |
-[Ensure you can sideload a dev channel](http://sdkdocs.roku.com/display/sdkdoc/Loading+and+Running+Your+Application+Walkthrough). |
|
21 |
+[Ensure you can sideload a dev channel](https://sdkdocs.roku.com/display/sdkdoc/Loading+and+Running+Your+Application). |
|
22 | 22 |
Then see the "build\_systems" command in ip\_tagger.sublime-project to see how the channel is zipped and deployed. |
23 | 23 |
|
24 | 24 |
# Corresponding Server Code |
... | ... |
@@ -31,8 +31,7 @@ Here's [the corresponding server code](http://git.dlma.com/kvs.git/). |
31 | 31 |
|
32 | 32 |
# To Do |
33 | 33 |
|
34 |
-1. Try the new SDK |
|
35 |
-2. Add splash\_screen\_sd keywords to the manifest file. |
|
34 |
+1. Replace roDeviceInfo.GetDeviceUniqueId with GetChannelClientId() |
|
36 | 35 |
|
37 | 36 |
# Licence |
38 | 37 |
|
... | ... |
@@ -0,0 +1,58 @@ |
1 |
+<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
+<component name="IPTagger" extends="Scene"> |
|
3 |
+ <children> |
|
4 |
+ <Label id="title" |
|
5 |
+ text="IP Tagger" |
|
6 |
+ width="1200" |
|
7 |
+ height="100" |
|
8 |
+ horizAlign="right" |
|
9 |
+ vertAlign="top" /> |
|
10 |
+ <Label id="updates" |
|
11 |
+ text="" |
|
12 |
+ width="1200" |
|
13 |
+ height="600" |
|
14 |
+ horizAlign="left" |
|
15 |
+ vertAlign="bottom" |
|
16 |
+ wrap="true" /> |
|
17 |
+ <Timer |
|
18 |
+ id = "textTimer" |
|
19 |
+ repeat = "true" |
|
20 |
+ duration = "4" /> |
|
21 |
+ </children> |
|
22 |
+<script type="text/brightscript" > |
|
23 |
+<![CDATA[ |
|
24 |
+ |
|
25 |
+ function init() |
|
26 |
+ m.title = m.top.findNode("title") |
|
27 |
+ m.title.font.size=92 |
|
28 |
+ m.title.color="0x72D7EEFF" |
|
29 |
+ m.title.translation = [40, 20] |
|
30 |
+ |
|
31 |
+ m.updates = m.top.findNode("updates") |
|
32 |
+ m.updates.font.size=46 |
|
33 |
+ m.updates.color="0x62EE97FF" |
|
34 |
+ m.updates.translation = [40, 100] |
|
35 |
+ |
|
36 |
+ m.tagTask = CreateObject("roSGNode", "TagTask") |
|
37 |
+ m.tagTask.ObserveField("updateText", "onUpdateText") |
|
38 |
+ m.tagTask.control = "RUN" |
|
39 |
+ |
|
40 |
+ texttimer = m.top.findNode("textTimer") |
|
41 |
+ texttimer.observeField("fire", "timerUpdate") |
|
42 |
+ texttimer.control = "start" |
|
43 |
+ |
|
44 |
+ m.top.setFocus(true) |
|
45 |
+ end function |
|
46 |
+ |
|
47 |
+ function onUpdateText() as void |
|
48 |
+ m.updates.text = m.updates.text + chr(10) + m.tagTask.updateText |
|
49 |
+ end function |
|
50 |
+ |
|
51 |
+ sub timerUpdate() |
|
52 |
+ ' Not needed, but nice to have as an example. |
|
53 |
+ ' print "timerUpdate called." |
|
54 |
+ end sub |
|
55 |
+ |
|
56 |
+]]> |
|
57 |
+</script> |
|
58 |
+</component> |
... | ... |
@@ -0,0 +1,65 @@ |
1 |
+<?xml version="1.0" encoding="utf-8" ?> |
|
2 |
+ |
|
3 |
+<component name="TagTask" extends="Task"> |
|
4 |
+ |
|
5 |
+<interface> |
|
6 |
+ <field id="updateText" type="string" value="Tagging from TagTask"/> |
|
7 |
+</interface> |
|
8 |
+<children> |
|
9 |
+ <Settings id="MySettings" /> |
|
10 |
+</children> |
|
11 |
+ |
|
12 |
+<script type="text/brightscript" > |
|
13 |
+<![CDATA[ |
|
14 |
+ |
|
15 |
+sub init() |
|
16 |
+ m.top.functionName = "executeTask" |
|
17 |
+ m.settings = m.top.findNode("MySettings") |
|
18 |
+end sub |
|
19 |
+ |
|
20 |
+function executeTask() as void |
|
21 |
+ m.port = CreateObject("roMessagePort") |
|
22 |
+ |
|
23 |
+ deviceInfo = CreateObject("roDeviceInfo") |
|
24 |
+ deviceID = deviceInfo.GetDeviceUniqueId() |
|
25 |
+ aaIPAddrs = deviceInfo.GetIPAddrs() |
|
26 |
+ |
|
27 |
+ for each key in aaIPAddrs |
|
28 |
+ ipAddr = aaipAddrs[key] |
|
29 |
+ if ipAddr <> invalid and ipAddr.Len() > 0 |
|
30 |
+ ' m.top.updateText = key + " = " + ipAddr |
|
31 |
+ end if |
|
32 |
+ end for |
|
33 |
+ |
|
34 |
+ sendRequest(ipAddr, deviceID) |
|
35 |
+end function |
|
36 |
+ |
|
37 |
+sub sendRequest(ipAddr as String, deviceID as String) |
|
38 |
+ request = CreateObject("roUrlTransfer") |
|
39 |
+ request.SetCertificatesFile("common:/certs/ca-bundle.crt") |
|
40 |
+ request.SetPort(m.port) |
|
41 |
+ request.SetUrl(m.settings.url) |
|
42 |
+ params = deviceID+"="+ipAddr+"&auth="+m.settings.auth |
|
43 |
+ m.top.updateText = "Tagging "+ipAddr+" for "+deviceID+"..." |
|
44 |
+ if request.AsyncPostFromString(params) |
|
45 |
+ print "Request was sent!" |
|
46 |
+ endif |
|
47 |
+ |
|
48 |
+ while true |
|
49 |
+ msg = wait(0, m.port) |
|
50 |
+ if type(msg) = "roUrlEvent" |
|
51 |
+ if msg.GetInt() = 1 |
|
52 |
+ if msg.GetResponseCode() = 200 |
|
53 |
+ m.top.updateText = "Success!" + chr(10) + "You can get this device's IP address with:" |
|
54 |
+ m.top.updateText = m.settings.url+"?k="+deviceID |
|
55 |
+ else |
|
56 |
+ m.top.updateText = "It didn't work. Got code " + str(msg.GetResponseCode()) |
|
57 |
+ endif |
|
58 |
+ endif |
|
59 |
+ end if |
|
60 |
+ end while |
|
61 |
+end sub |
|
62 |
+ |
|
63 |
+]]> |
|
64 |
+</script> |
|
65 |
+</component> |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
title=IP Tagger |
2 |
-major_version=1 |
|
2 |
+major_version=2 |
|
3 | 3 |
minor_version=0 |
4 |
-build_version=5 |
|
4 |
+build_version=0 |
|
5 | 5 |
mm_icon_focus_hd=pkg:/images/mm_icon_focus_hd.png |
6 | 6 |
mm_icon_focus_sd=pkg:/images/mm_icon_focus_sd.png |
7 | 7 |
splash_screen_hd=pkg:/images/splash_screen_hd.png |
... | ... |
@@ -1,66 +1,19 @@ |
1 |
-sub RunUserInterface(params As Object) |
|
2 |
- if params.contentID <> invalid |
|
3 |
- contentID = params.contentID |
|
4 |
- else |
|
5 |
- contentID = "" |
|
6 |
- end if |
|
7 |
- |
|
8 |
- if params.options <> invalid |
|
9 |
- options = params.options |
|
10 |
- else |
|
11 |
- options = "" |
|
12 |
- end if |
|
13 |
- |
|
14 |
- showScreen(contentID, options) |
|
15 |
-end sub |
|
16 |
- |
|
17 |
- |
|
18 |
-sub showScreen(contentID As String, options As String) |
|
19 |
- screen = CreateObject("roParagraphScreen") |
|
20 |
- port = CreateObject("roMessagePort") |
|
21 |
- screen.SetMessagePort(port) |
|
22 |
- |
|
23 |
- deviceInfo = CreateObject("roDeviceInfo") |
|
24 |
- deviceID = deviceInfo.GetDeviceUniqueId() |
|
25 |
- aaIPAddrs = deviceInfo.GetIPAddrs() |
|
26 |
- |
|
27 |
- screen.SetTitle("IP Tagger") |
|
28 |
- for each key in aaIPAddrs |
|
29 |
- ipAddr = aaipAddrs[key] |
|
30 |
- if ipAddr <> invalid and ipAddr.Len() > 0 |
|
31 |
- screen.addParagraph(key + " = " + ipAddr) |
|
32 |
- end if |
|
33 |
- end for |
|
34 |
- |
|
35 |
- settings = GetSettings() |
|
36 |
- |
|
37 |
- request = CreateObject("roUrlTransfer") |
|
38 |
- request.SetCertificatesFile("common:/certs/ca-bundle.crt") |
|
39 |
- request.SetPort(port) |
|
40 |
- request.SetUrl(settings.url) |
|
41 |
- params = deviceID+"="+ipAddr+"&auth="+settings.auth |
|
42 |
- screen.addParagraph("Tagging "+ipAddr+" for "+deviceID+"...") |
|
43 |
- if request.AsyncPostFromString(params) |
|
44 |
- print "Post was sent!" |
|
45 |
- endif |
|
46 |
- screen.Show() |
|
47 |
- |
|
48 |
- while true |
|
49 |
- msg = wait(0, port) |
|
50 |
- if type(msg) = "roParagraphScreenEvent" |
|
51 |
- if msg.isScreenClosed() |
|
52 |
- exit while |
|
53 |
- end if |
|
54 |
- else if type(msg) = "roUrlEvent" |
|
55 |
- if msg.GetInt() = 1 |
|
56 |
- if msg.GetResponseCode() = 200 |
|
57 |
- screen.addParagraph("Success! You can get this device's IP address from the following URL:") |
|
58 |
- screen.addParagraph(settings.url+"?k="+deviceID) |
|
59 |
- else |
|
60 |
- screen.addParagraph("It didn't work. Got code " + str(msg.GetResponseCode())) |
|
61 |
- endif |
|
62 |
- endif |
|
1 |
+sub Main() |
|
2 |
+ ' Indicate this is a Roku SceneGraph application' |
|
3 |
+ screen = CreateObject("roSGScreen") |
|
4 |
+ m.port = CreateObject("roMessagePort") |
|
5 |
+ screen.SetMessagePort(m.port) |
|
6 |
+ |
|
7 |
+ ' Create a scene and load /components/iptagger.xml' |
|
8 |
+ m.scene = screen.CreateScene("IPTagger") |
|
9 |
+ screen.show() |
|
10 |
+ |
|
11 |
+ while(true) |
|
12 |
+ msg = wait(0, m.port) |
|
13 |
+ msgType = type(msg) |
|
14 |
+ if msgType = "roSGScreenEvent" |
|
15 |
+ if msg.isScreenClosed() then return |
|
63 | 16 |
end if |
64 | 17 |
end while |
65 |
- screen.Close() ' Wonder if this is needed |
|
66 | 18 |
end sub |
19 |
+ |