-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupCommon.brs
More file actions
815 lines (611 loc) · 23.7 KB
/
setupCommon.brs
File metadata and controls
815 lines (611 loc) · 23.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
Sub CheckStorageDeviceIsWritable()
' determine if the storage device is writable
tmpFileName$ = "bs~69-96.txt"
WriteAsciiFile(tmpFileName$, "1")
readValue$ = ReadAsciiFile(tmpFileName$)
if len(readValue$) = 1 and readValue$ = "1" then
DeleteFile(tmpFileName$)
else
videoMode = CreateObject("roVideoMode")
resX = videoMode.GetResX()
resY = videoMode.GetResY()
videoMode = invalid
r = CreateObject("roRectangle", 0, 0, resX, resY)
twParams = CreateObject("roAssociativeArray")
twParams.LineCount = 1
twParams.TextMode = 2
twParams.Rotation = 0
twParams.Alignment = 1
tw=CreateObject("roTextWidget",r,1,2,twParams)
tw.PushString("")
tw.Show()
r=CreateObject("roRectangle",0,resY/2-resY/32,resX,resY/32)
tw=CreateObject("roTextWidget",r,1,2,twParams)
tw.PushString("The attached storage device is write protected.")
tw.Show()
r2=CreateObject("roRectangle",0,resY/2,resX,resY/32)
tw2=CreateObject("roTextWidget",r2,1,2,twParams)
tw2.PushString("Remove it, enable writing, and reboot the device.")
tw2.Show()
msgPort = CreateObject("roMessagePort")
msg = wait(0, msgPort)
endif
End Sub
Sub CheckFirmwareVersion()
modelObject = CreateObject("roDeviceInfo")
' check to see whether or not the current firmware meets the minimum compatibility requirements
versionNumber% = modelObject.GetVersionNumber()
if modelObject.GetFamily() = "panther" then
minVersionNumber% = 327952
minVersion$ = "5.1.16"
else if modelObject.GetFamily() = "cheetah" then
minVersionNumber% = 327952
minVersion$ = "5.1.16"
else if modelObject.GetFamily() = "puma" then
minVersionNumber% = 327952
minVersion$ = "5.1.16"
else if modelObject.GetFamily() = "tiger" then
minVersionNumber% = 327952
minVersion$ = "5.1.16"
else if modelObject.GetFamily() = "bobcat" then
minVersionNumber% = 327952
minVersion$ = "5.1.16"
else if modelObject.GetFamily() = "lynx" then
minVersionNumber% = 327952
minVersion$ = "5.1.16"
else
minVersionNumber% = 199435
minVersion$ = "3.11.11"
endif
if versionNumber% < minVersionNumber% then
videoMode = CreateObject("roVideoMode")
resX = videoMode.GetResX()
resY = videoMode.GetResY()
videoMode = invalid
r=CreateObject("roRectangle",0,resY/2-resY/64,resX,resY/32)
twParams = CreateObject("roAssociativeArray")
twParams.LineCount = 1
twParams.TextMode = 2
twParams.Rotation = 0
twParams.Alignment = 1
tw=CreateObject("roTextWidget",r,1,2,twParams)
tw.PushString("Firmware needs to be upgraded to " + minVersion$ + " or greater")
tw.Show()
msgPort = CreateObject("roMessagePort")
gpioPort = CreateObject("roGpioControlPort")
gpioPort.SetPort(msgPort)
while true
msg = wait(0, msgPort)
if type(msg) = "roGpioButton" and msg.GetInt()=12 then
stop
endif
end while
endif
End Sub
Sub ClearRegistryKeys(registrySection As Object)
' Clear legacy registry keys
registrySection.Delete("next")
registrySection.Delete("event")
registrySection.Delete("error")
registrySection.Delete("deviceerror")
registrySection.Delete("devicedownload")
registrySection.Delete("recurl")
registrySection.Delete("timezone")
registrySection.Delete("unitName")
registrySection.Delete("unitNamingMethod")
registrySection.Delete("unitDescription")
registrySection.Delete("timeBetweenNetConnects")
registrySection.Delete("contentDownloadsRestricted")
registrySection.Delete("contentDownloadRangeStart")
registrySection.Delete("contentDownloadRangeLength")
registrySection.Delete("useDHCP")
registrySection.Delete("staticIPAddress")
registrySection.Delete("subnetMask")
registrySection.Delete("gateway")
registrySection.Delete("broadcast")
registrySection.Delete("dns1")
registrySection.Delete("dns2")
registrySection.Delete("dns3")
registrySection.Delete("timeServer")
registrySection.Delete("account")
registrySection.Delete("user")
registrySection.Delete("password")
registrySection.Delete("group")
' Clear other keys in case they're no longer used
registrySection.Delete("cdrs")
registrySection.Delete("cdrl")
registrySection.Delete("ps")
registrySection.Delete("ss")
registrySection.Delete("pp")
registrySection.Delete("ncp2")
registrySection.Delete("cwf")
registrySection.Delete("twf")
registrySection.Delete("hwf")
registrySection.Delete("mwf")
registrySection.Delete("lwf")
registrySection.Delete("sip")
registrySection.Delete("sip")
registrySection.Delete("sm")
registrySection.Delete("gw")
registrySection.Delete("d1")
registrySection.Delete("d2")
registrySection.Delete("d3")
registrySection.Delete("rlmow")
registrySection.Delete("rlrow")
registrySection.Delete("rlmiw")
registrySection.Delete("rlriw")
registrySection.Delete("rlmid")
registrySection.Delete("rlrid")
registrySection.Delete("sip2")
registrySection.Delete("sm2")
registrySection.Delete("gw2")
registrySection.Delete("d12")
registrySection.Delete("d22")
registrySection.Delete("d32")
registrySection.Delete("rlmow2")
registrySection.Delete("rlrow2")
registrySection.Delete("rlmiw2")
registrySection.Delete("rlriw2")
registrySection.Delete("rlmid2")
registrySection.Delete("rlrid2")
registrySection.Delete("uup")
registrySection.Delete("cfv")
registrySection.Delete("brightWallName")
registrySection.Delete("brightWallScreenNumber")
End Sub
Function GetRateLimits(setupParams As Object, rateLimitModeKey$ As String, rateLimitRateKey$ As String)
rateLimitModeSpec$ = GetEntry(setupParams, rateLimitModeKey$)
rateLimitMode$ = "default"
rateLimitRate$ = "0"
rateLimitRate% = -1
if rateLimitModeSpec$ = "unlimited" then
rateLimitMode$ = "unlimited"
rateLimitRate% = 0
else if rateLimitModeSpec$ = "specified" then
rateLimitMode$ = "specified"
rateLimitRate$ = GetEntry(setupParams, rateLimitRateKey$)
rateLimitRate% = int(val(rateLimitRate$))
endif
rateLimits = { }
rateLimits.rateLimitMode$ = rateLimitMode$
rateLimits.rateLimitRate$ = rateLimitRate$
rateLimits.rateLimitRate% = rateLimitRate%
return rateLimits
End Function
Function SetNetworkConfiguration(setupParams As Object, registrySection As Object, keySuffix$ As String, registrySuffix$ As String)
networkingParameters = { }
networkingParameters.useDHCP$ = GetEntry(setupParams, "useDHCP" + keySuffix$)
if networkingParameters.useDHCP$ = "no" then
networkingParameters.staticIPAddress$ = GetEntry(setupParams, "staticIPAddress" + keySuffix$)
networkingParameters.subnetMask$ = GetEntry(setupParams, "subnetMask" + keySuffix$)
networkingParameters.gateway$ = GetEntry(setupParams, "gateway" + keySuffix$)
networkingParameters.dns1$ = GetEntry(setupParams, "dns1" + keySuffix$)
networkingParameters.dns2$ = GetEntry(setupParams, "dns2" + keySuffix$)
networkingParameters.dns3$ = GetEntry(setupParams, "dns3" + keySuffix$)
registrySection.Write("dhcp" + registrySuffix$, "no")
registrySection.Write("sip" + registrySuffix$, networkingParameters.staticIPAddress$)
registrySection.Write("sm" + registrySuffix$, networkingParameters.subnetMask$)
registrySection.Write("gw" + registrySuffix$, networkingParameters.gateway$)
registrySection.Write("d1" + registrySuffix$, networkingParameters.dns1$)
registrySection.Write("d2" + registrySuffix$, networkingParameters.dns2$)
registrySection.Write("d3" + registrySuffix$, networkingParameters.dns3$)
else
registrySection.Write("dhcp" + registrySuffix$, "yes")
endif
rateLimits = GetRateLimits(setupParams, "rateLimitModeOutsideWindow" + keySuffix$, "rateLimitRateOutsideWindow" + keySuffix$)
rlmow$ = rateLimits.rateLimitMode$
rlrow$ = rateLimits.rateLimitRate$
rateLimits = GetRateLimits(setupParams, "rateLimitModeInWindow" + keySuffix$, "rateLimitRateInWindow" + keySuffix$)
rlmiw$ = rateLimits.rateLimitMode$
rlriw$ = rateLimits.rateLimitRate$
rateLimits = GetRateLimits(setupParams, "rateLimitModeInitialDownloads" + keySuffix$, "rateLimitRateInitialDownloads" + keySuffix$)
rlmid$ = rateLimits.rateLimitMode$
rlrid$ = rateLimits.rateLimitRate$
networkingParameters.rl% = rateLimits.rateLimitRate%
registrySection.Write("rlmow" + registrySuffix$, rlmow$)
registrySection.Write("rlrow" + registrySuffix$, rlrow$)
registrySection.Write("rlmiw" + registrySuffix$, rlmiw$)
registrySection.Write("rlriw" + registrySuffix$, rlriw$)
registrySection.Write("rlmid" + registrySuffix$, rlmid$)
registrySection.Write("rlrid" + registrySuffix$, rlrid$)
return networkingParameters
End Function
Function SetLogging(setupParams As Object, registrySection As Object) As Object
enabled = GetBooleanEntry(setupParams, "playbackLoggingEnabled")
playbackLoggingEnabled$ = "no"
if enabled then playbackLoggingEnabled$ = "yes"
enabled = GetBooleanEntry(setupParams, "eventLoggingEnabled")
eventLoggingEnabled$ = "no"
if enabled then eventLoggingEnabled$ = "yes"
enabled = GetBooleanEntry(setupParams, "stateLoggingEnabled")
stateLoggingEnabled$ = "no"
if enabled then stateLoggingEnabled$ = "yes"
enabled = GetBooleanEntry(setupParams, "diagnosticLoggingEnabled")
diagnosticLoggingEnabled$ = "no"
if enabled then diagnosticLoggingEnabled$ = "yes"
enabled = GetBooleanEntry(setupParams, "diagnosticLoggingEnabled")
diagnosticLoggingEnabled$ = "no"
if enabled then diagnosticLoggingEnabled$ = "yes"
enabled = GetBooleanEntry(setupParams, "variableLoggingEnabled")
variableLoggingEnabled$ = "no"
if enabled then variableLoggingEnabled$ = "yes"
enabled = GetBooleanEntry(setupParams, "uploadLogFilesAtBoot")
uploadLogFilesAtBoot$ = "no"
if enabled then uploadLogFilesAtBoot$ = "yes"
enabled = GetBooleanEntry(setupParams, "uploadLogFilesAtSpecificTime")
uploadLogFilesAtSpecificTime$ = "no"
if enabled then uploadLogFilesAtSpecificTime$ = "yes"
uploadLogFilesTime$ = GetEntry(setupParams, "uploadLogFilesTime")
' if uploadLogFilesTime$ <> "" then uploadLogFilesTime% = int(val(uploadLogFilesTime$))
' uploadLogFilesTime% = 0
if type(registrySection) = "roRegistrySection" then
registrySection.Write("ple", playbackLoggingEnabled$)
registrySection.Write("ele", eventLoggingEnabled$)
registrySection.Write("sle", stateLoggingEnabled$)
registrySection.Write("dle", diagnosticLoggingEnabled$)
registrySection.Write("vle", variableLoggingEnabled$)
registrySection.Write("uab", uploadLogFilesAtBoot$)
registrySection.Write("uat", uploadLogFilesAtSpecificTime$)
registrySection.Write("ut", uploadLogFilesTime$)
endif
End Function
Function GetEntry(setupParams As Object, key$ As String) As String
if setupParams.DoesExist(key$) then
return setupParams.Lookup(key$)
endif
return ""
End Function
Function GetModelSupportsWifi()
modelSupportsWifi = false
nc = CreateObject("roNetworkConfiguration", 1)
if type(nc) = "roNetworkConfiguration" then
currentConfig = nc.GetCurrentConfig()
if type(currentConfig) = "roAssociativeArray" then
modelSupportsWifi = true
endif
endif
nc = invalid
return modelSupportsWifi
End Function
Sub SetLWS(spec As Object, registrySection As Object)
' delete obsolete lws keys
registrySection.Delete("lws")
registrySection.Delete("lwsu")
registrySection.Delete("lwsp")
' local web server
lwsConfig$ = GetEntry(spec, "lwsConfig")
lwsUserName$ = GetEntry(spec, "lwsUserName")
lwsPassword$ = GetEntry(spec, "lwsPassword")
lwsEnableUpdateNotifications$ = GetEntry(spec, "lwsEnableUpdateNotifications")
if lwsEnableUpdateNotifications$ = "" then
lwsEnableUpdateNotifications$ = "yes"
endif
if lwsConfig$ = "content" or lwsConfig$ = "status" then
registrySection.Write("nlws", Left(lwsConfig$, 1))
registrySection.Write("nlwsu", lwsUserName$)
registrySection.Write("nlwsp", lwsPassword$)
registrySection.Write("nlwseun", lwsEnableUpdateNotifications$)
else
registrySection.Delete("nlws")
registrySection.Delete("nlwsu")
registrySection.Delete("nlwsp")
registrySection.Delete("nlwseun")
endif
End Sub
Sub SetHostname(spec As Object)
specifyHostname$ = GetEntry(spec, "specifyHostname")
if specifyHostname$ = "yes" then
hostname$ = GetEntry(spec, "hostname")
nc = CreateObject("roNetworkConfiguration", 0)
if type(nc) <> "roNetworkConfiguration" then
nc = CreateObject("roNetworkConfiguration", 1)
endif
if type(nc) = "roNetworkConfiguration" then
ok = nc.SetHostname(hostname$)
if ok nc.Apply()
nc = invalid
endif
endif
End Sub
Sub SetDWS(spec As Object, registrySection As Object)
' diagnostic web server
dwsEnabled$ = GetEntry(spec, "dwsEnabled")
dwsPassword$ = GetEntry(spec, "dwsPassword")
dwsAA = CreateObject("roAssociativeArray")
if dwsEnabled$ = "yes" then
dwsAA["port"] = "80"
dwsAA["password"] = dwsPassword$
else
dwsAA["port"] = 0
endif
registrySection.Write("dwse", dwsEnabled$)
registrySection.Write("dwsp", dwsPassword$)
' set DWS on device
nc = CreateObject("roNetworkConfiguration", 0)
if type(nc) <> "roNetworkConfiguration" then
nc = CreateObject("roNetworkConfiguration", 1)
endif
if type(nc) = "roNetworkConfiguration" then
rebootRequired = nc.SetupDWS(dwsAA)
endif
End Sub
Sub ConfigureEthernet(ethernetNetworkingParameters As Object, networkConnectionPriorityWired$ As String, timeServer$ As String, proxySpec$ As String)
nc = CreateObject("roNetworkConfiguration", 0)
if type(nc) = "roNetworkConfiguration" then
ConfigureNetwork(nc, ethernetNetworkingParameters, networkConnectionPriorityWired$, timeServer$, proxySpec$)
else
print "Unable to create roNetworkConfiguration - index = 0"
endif
End Sub
Sub ConfigureWifi(wifiNetworkingParameters As Object, ssid$ As String, passphrase$ As String, networkConnectionPriorityWireless$ As String, timeServer$ As String, proxySpec$ As String)
nc = CreateObject("roNetworkConfiguration", 1)
if type(nc) = "roNetworkConfiguration" then
nc.SetWiFiESSID(ssid$)
nc.SetObfuscatedWifiPassphrase(passphrase$)
ConfigureNetwork(nc, wifiNetworkingParameters, networkConnectionPriorityWireless$, timeServer$, proxySpec$)
else
print "Unable to create roNetworkConfiguration - index = 1"
endif
End Sub
Sub ConfigureNetwork(nc As Object, networkingParameters As Object, networkConnectionPriority$ As String, timeServer$ As String, proxySpec$ As String)
if networkingParameters.useDHCP$ = "no" then
nc.SetIP4Address(networkingParameters.staticIPAddress$)
nc.SetIP4Netmask(networkingParameters.subnetMask$)
nc.SetIP4Gateway(networkingParameters.gateway$)
if networkingParameters.dns1$ <> "" then nc.AddDNSServer(networkingParameters.dns1$)
if networkingParameters.dns2$ <> "" then nc.AddDNSServer(networkingParameters.dns2$)
if networkingParameters.dns3$ <> "" then nc.AddDNSServer(networkingParameters.dns3$)
else
nc.SetDHCP()
endif
nc.SetRoutingMetric(int(val(networkConnectionPriority$)))
nc.SetTimeServer(timeServer$)
nc.SetProxy(proxySpec$)
nc.SetInboundShaperRate(networkingParameters.rl%)
success = nc.Apply()
End Sub
Sub DisableWireless()
nc = CreateObject("roNetworkConfiguration", 1)
if type(nc) = "roNetworkConfiguration" then
nc.SetDHCP()
nc.SetWiFiESSID("")
nc.SetObfuscatedWifiPassphrase("")
nc.Apply()
endif
End Sub
Sub SetWiredParameters(spec As Object, registrySection As Object, useWireless$ As String)
if useWireless$ = "yes" then
registrySection.Write("ncp", GetEntry(spec, "networkConnectionPriorityWired"))
registrySection.Write("cwr", GetEntry(spec, "contentDataTypeEnabledWired"))
registrySection.Write("twr", GetEntry(spec, "textFeedsDataTypeEnabledWired"))
registrySection.Write("hwr", GetEntry(spec, "healthDataTypeEnabledWired"))
registrySection.Write("mwr", GetEntry(spec, "mediaFeedsDataTypeEnabledWired"))
registrySection.Write("lwr", GetEntry(spec, "logUploadsDataTypeEnabledWired"))
else
registrySection.Write("ncp", "0")
registrySection.Write("cwr", "True")
registrySection.Write("twr", "True")
registrySection.Write("hwr", "True")
registrySection.Write("mwr", "True")
registrySection.Write("lwr", "True")
endif
End Sub
Function SetWirelessParameters(spec As Object, registrySection As Object, modelSupportsWifi As Boolean) As String
useWireless = GetEntry(spec, "useWireless")
' if the user specifies wireless on a system that doesn't support wireless, don't try to use wireless
if not modelSupportsWifi
useWireless = "no"
endif
if useWireless = "yes" then
ssid$ = GetEntry(spec, "ssid")
passphrase$ = GetEntry(spec, "passphrase")
registrySection.Write("wifi", "yes")
registrySection.Write("ss", ssid$)
registrySection.Write("pp", passphrase$)
registrySection.Write("ncp2", GetEntry(spec, "networkConnectionPriorityWireless"))
registrySection.Write("cwf", GetEntry(spec, "contentDataTypeEnabledWireless"))
registrySection.Write("twf", GetEntry(spec, "textFeedsDataTypeEnabledWireless"))
registrySection.Write("hwf", GetEntry(spec, "healthDataTypeEnabledWireless"))
registrySection.Write("mwf", GetEntry(spec, "mediaFeedsDataTypeEnabledWireless"))
registrySection.Write("lwf", GetEntry(spec, "logUploadsDataTypeEnabledWireless"))
else
registrySection.Write("wifi", "no")
endif
return useWireless
End Function
Function GetProxy(spec As Object, registrySection As Object) As String
useProxy = false
useProxy$ = GetEntry(spec, "useProxy")
proxySpec$ = ""
if lcase(useProxy$) = "yes" then
useProxy = true
proxySpec$ = GetEntry(spec, "proxy")
registrySection.Write("up", "yes")
registrySection.Write("ps", proxySpec$)
else
registrySection.Write("up", "no")
endif
return proxySpec$
End Function
Function GetDataTransferEnabled(spec$ As String) As Boolean
dataTransferEnabled = true
if lcase(spec$) = "false" then dataTransferEnabled = false
return dataTransferEnabled
End Function
Function GetBinding(wiredTransferEnabled As Boolean, wirelessTransferEnabled As Boolean) As Integer
binding% = -1
if wiredTransferEnabled <> wirelessTransferEnabled then
if wiredTransferEnabled then
binding% = 0
else
binding% = 1
endif
endif
return binding%
End Function
Function GetModelSupportsTuner() As Boolean
modelSupportsTuner = false
modelObject = CreateObject("roDeviceInfo")
if modelObject.GetModel() = "XD1230" return true
return false
End Function
Sub SetupTunerData()
if GetModelSupportsTuner() then
tunerData$ = ReadAsciiFile("ScannedChannelsForSetup.xml")
if tunerData$ <> "" then
cdataStartTag$ = "<![CDATA["
cdataEndTag$ = " ]]>"
docEndTag$ = "</BrightSignRFChannels>"
cdataIndex% = instr(1, tunerData$, cdataStartTag$)
if cdataIndex% > 0 then
fwXML$ = mid(tunerData$, cdataIndex% + len(cdataStartTag$) + 1, len(tunerData$) - (cdataIndex% + len(cdataStartTag$) + 1) - (len(cdataEndTag$) + len(docEndTag$) + 1))
channelManager = CreateObject("roChannelManager")
ok = channelManager.ImportFromXml(fwXML$)
endif
endif
endif
End Sub
Function GetBooleanEntry(setupParams As Object, metadataField$ As String) As Boolean
if setupParams.DoesExist(metadataField$) then
value$ = setupParams.Lookup(metadataField$)
if lcase(value$) = "true" or lcase(value$) = "yes" then
return true
endif
endif
return false
End Function
Sub SetRemoteSnapshot(spec As Object, registrySection As Object)
enableRemoteSnapshot$ = GetEntry(spec, "deviceScreenShotsEnabled")
registrySection.Write("enableRemoteSnapshot", enableRemoteSnapshot$)
if lcase(enableRemoteSnapshot$) = "yes" then
remoteSnapshotInterval$ = GetEntry(spec, "deviceScreenShotsInterval")
registrySection.Write("remoteSnapshotInterval", remoteSnapshotInterval$)
remoteSnapshotMaxImages$ = GetEntry(spec, "deviceScreenShotsCountLimit")
registrySection.Write("remoteSnapshotMaxImages", remoteSnapshotMaxImages$)
remoteSnapshotJpegQualityLevel$ = GetEntry(spec, "deviceScreenShotsQuality")
registrySection.Write("remoteSnapshotJpegQualityLevel", remoteSnapshotJpegQualityLevel$)
remoteSnapshotDisplayPortrait$ = GetEntry(spec, "deviceScreenShotsDisplayPortrait")
registrySection.Write("remoteSnapshotDisplayPortrait", remoteSnapshotDisplayPortrait$)
endif
End Sub
Sub SetIdleColor(spec As Object, registrySection As Object)
idleScreenColor$ = GetEntry(spec, "idleScreenColor")
registrySection.Write("isc", idleScreenColor$)
End Sub
Sub SetCustomSplashScreen(spec As Object, registrySection As Object, featureMinRevs As Object)
customSplashScreenSupported = IsFeatureSupported("CustomSplashScreen", featureMinRevs)
if customSplashScreenSupported then
useCustomSplashScreen = GetBooleanEntry(spec, "useCustomSplashScreen")
deviceCustomization = CreateObject("roDeviceCustomization")
if useCustomSplashScreen then
ok = deviceCustomization.WriteSplashScreen("customSplashScreen")
else
ok = deviceCustomization.WriteSplashScreen("")
endif
endif
End Sub
Function ParseFeatureMinRevs() As Object
path$ = "featureMinRevs.xml"
featureMinRevs = {}
featureMinRevs$ = ReadAsciiFile(path$)
if len(featureMinRevs$) > 0 then
featureMinRevsXML = CreateObject("roXMLElement")
featureMinRevsXML.Parse(featureMinRevs$)
' verify that this is a valid FeatureMinRevs XML file
if featureMinRevsXML.GetName() <> "FeatureMinRevs" then print "Invalid FeatureMinRevs XML file - name not FeatureMinRevs" : stop
if not IsString(featureMinRevsXML@version) then print "Invalid FeatureMinRevs XML file - version not found" : stop
featuresXML = featureMinRevsXML.feature
for each featureXML in featuresXML
featureName$ = featureXML.name.GetText()
minRev$ = featureXML.minFWRev.GetText()
featureMinRevs.AddReplace(featureName$, minRev$)
next
endif
return featureMinRevs
End Function
Function IsFeatureSupported(featureName$ As String, featureMinRevs As Object) As Boolean
modelObject = CreateObject("roDeviceInfo")
fwVersion$ = modelObject.GetVersion()
featureExists = featureMinRevs.DoesExist(featureName$)
if featureExists then
featureMinFWRev = featureMinRevs[featureName$]
featureMinFWRevVSFWVersion% = CompareFirmwareVersions(featureMinFWRev, fwVersion$)
if featureMinFWRevVSFWVersion% <= 0 return true
endif
return false
End Function
Function CompareFirmwareVersions(a$ As String, b$ As String) As Integer
start_a% = 0
start_b% = 0
while true
if start_a% >= len(a$) then
if start_b% >= len(b$) then
return 0
else
return -1
endif
else if start_b% >= len(b$) then
return 1
endif
aChar$ = mid(a$, start_a% + 1, 1)
a_digit = IsDigit(aChar$)
bChar$ = mid(b$, start_b% + 1, 1)
b_digit = IsDigit(bChar$)
if a_digit and b_digit then
' Now we need to find the end of each of the sequences of digits.
aa = {}
aa.index = start_a%
a_number% = ReadDigits(a$, aa)
start_a% = aa.index
bb = {}
bb.index = start_b%
b_number% = ReadDigits(b$, bb)
start_b% = bb.index
if a_number% < b_number% then
return -1
else if a_number% > b_number% then
return 1
endif
else if a_digit then
' The first string has a digit but the second one has a
' non-digit so it must be greater.
return 1
else if b_digit then
return -1
else
aChar$ = mid(a$, start_a% + 1, 1)
bChar$ = mid(b$, start_b% + 1, 1)
if asc(aChar$) < asc(bChar$) then
return -1
else if asc(aChar$) > asc(bChar$)
return 1
endif
' Otherwise we've dealt with this character
start_a% = start_a% + 1
start_b% = start_b% + 1
endif
endwhile
End Function
Function IsDigit(a$ As String) As Boolean
if asc(a$) >= 48 and asc(a$) <= 57 return true
return false
End Function
Function ReadDigits(s$ As String, aa As Object) as Integer
value% = 0
index% = aa.index
sChar$ = mid(s$, index% + 1, 1)
while index% < len(s$) and IsDigit(sChar$)
new_value% = value% * 10 + asc(sChar$) - asc("0")
index% = index% + 1
value% = new_value%
if len(s$) > index% then
sChar$ = mid(s$, index% + 1, 1)
endif
endwhile
aa.index = index%
return value%
End Function
Function IsString(inputVariable As Object) As Boolean
if type(inputVariable) = "roString" or type(inputVariable) = "String" then return true
return false
End Function