brightsign / ez-asset-pool-brs-generator

4 stars 2 forks source link

Update assets and reload with UDP command? #1

Open kjell opened 8 years ago

kjell commented 8 years ago

I'm testing an XD player to run a simple "lobby signage" screen.

I'm showing an html/javascript slideshow on the player to avoid needing to use/learn the BrightAuthor software. This autorun generator fits my needs perfectly so far. The one feature that would be nice is the ability to remotely update the asset pool and restart the web browser. (Without physically power-cycling the player.)

Would it be possible to extend this generator to listen for a UDP "reload" command and refresh the player? For bonus points, could the asset pool update happen while the player was still playing the old assets to prevent the screen going blank until the update finishes completely?

I haven't been able to get both ssh and this ez-asset-pool autorun to work at the same time. I would very much like to be able to SSH in to the brightsign to check on things like network connectivity, so reload-asset-pool could alternatively be one of the shell commands exposed by the player's custom shell interface.

(tagging @jsinai as I'm not sure this is an official support channel, but you've recently been active on https://github.com/brightsign/bsticker)

jsinai commented 8 years ago

I'm showing an html/javascript slideshow on the player to avoid needing to use/learn the BrightAuthor software. This autorun generator fits my needs perfectly so far. The one feature that would be nice is the ability to remotely update the asset pool and restart the web browser. (Without physically power-cycling the player.)

This is already supported. If you look in the autorun file (autorun-manifest-template.brs) you will see a parameter, updateIntervalInSeconds. The script will download new content at that interval and recreate the html browser when the download is complete. The default is every 24 hours.

Would it be possible to extend this generator to listen for a UDP "reload" command and refresh the player?

Yes, but it should not be necessary given the automatic refresh mentioned above.

For bonus points, could the asset pool update happen while the player was still playing the old assets to prevent the screen going blank until the update finishes completely?

The screen should not go blank unless you're loading content continuously, like a video. But yes, it is possible to create a second asset pool and to switch when the content has finished loading. This would require learning some BrightScript. To do it, all places in the script that refer to "pool" (like the following) would have to swap between "pool1" and "pool2".

pool = CreateObject("roAssetPool", "pool")

I haven't been able to get both ssh and this ez-asset-pool autorun to work at the same time. I would very much like to be able to SSH in to the brightsign to check on things like network connectivity, so reload-asset-pool could alternatively be one of the shell commands exposed by the player's custom shell interface.

To enable ssh access: put the following code (changing the password to your preference) on an SD card in a file called autorun.brs, boot the player, take out the SD card, and boot it again. After this, ssh is permanently configured.

Sub Main()

    ' To enable ssh access set the ssh registry key to the port you wish to run ssh on. 
    ' The default ssh port is 22.
    ' Equivalent BrightSign shell command: registry write networking ssh 22
    registrySection = CreateObject("roRegistrySection", "networking")
    registrySection.Write("ssh", "22")
    registrySection.Flush()

    ' To set the password:
    ' Equivalent shell command: ifconfig login-password my-top-secret-password
    n=CreateObject("roNetworkConfiguration", 0)
    n.SetLoginPassword("my-top-secret-password")
    n.Apply()

End Sub
kjell commented 8 years ago

Thanks for the reply!

The interval updates are working perfectly. The idea for a UDP update is to force an update outside of that interval. Occasionally, incorrect information makes it onto the screen, in which case it it would be useful to have the ability to send a reload command (echo reload | nc -u4 <brightsign>?). This needs to happen in the morning, versus waiting all day for the screen to update overnight.

I did enable ssh on the machine. But loading the autorun.brs generated by this project disables the shell interface. I can still authenticate, but instead of logging me in to a shell prompt, it logs me into the log output of the asset pool generator with no interactivity.

⁂ ssh brightsign@<ip address>
brightsign@<ip>'s password: ••••••
BrightSign XD230 X0G3DD000815 v6.0.51

Progress:  7/ 18 08.jpg
File: 08.jpg downloaded  200
Progress:  8/ 18 09.jpg
File: 09.jpg downloaded  200
…
File: 25.jpg downloaded  200
Progress:  18/ 18 26.jpg
File: 26.jpg downloaded  200
Pool download reported complete

So although ssh "works", what good is it if there's no way to run a command?

jsinai commented 8 years ago

It should be pretty easy to add UDP support:

Add this to services.js:

bsApp.constant('udpPort', 5000);

// Creates UDP receiver singleton
bsApp.factory('udpSocket',
    function (udpPort) {
        console.log("creating udp listener on port "+udpPort);
        var sock = new BSDatagramSocket();
        sock.BindLocalPort(udpPort);
        return sock;
    }
);

Change controllers.js as follows:

bsApp.controller('bsController', function ($scope, $window, udpSocket) {

    udpSocket.ondatagram = function (e) {
        $window.location.reload();
    };
});
kjell commented 8 years ago

Thanks. I assume those two angular snippets need to get into the html app that's running on the brightsign player, correct? Is there any documentation on how that works? Right now I'm not using any BS-specific libraries, just "vanilla" JS/HTML/CSS.

Where do I find BSDatagramSocket?. A github search turns up one result: this issue, and when I paste that code I get angular.min.js:84 ReferenceError: BSDatagramSocket is not defined.

And is there any way to get a shell prompt from ssh using the autorun generated here? As I mentioned above, after enabling ssh (and a working interactive shell), now when I ssh to the "XD" player it shows me the logs generated when downloading assets, but there's no way to interact.

jsinai commented 8 years ago

Thanks. I assume those two angular snippets need to get into the html app that's running on the brightsign player, correct? Is there any documentation on how that works?

There are no references / includes / script tags needed. Those objects are automatically made available on the BrightSign devices. The documentation is at http://brightsignbiz.s3.amazonaws.com/documents/JavaScript%20Objects%20for%20BrightScript%20%286.0%29.pdf

Unfortunately, I am not seeing the same issue as you are with ssh. I've emailed a colleague who might know more.

jsinai commented 8 years ago

You need to have script debugging turned on to break out of a running script and get to the prompt. You can either:

If you break out of a running program with the SVC button, you should see:

BrightScript Debugger>

Type "exit", then you should see:

Welcome to the BrightSign Shell version 6.1.24 (2016-02-01)
Type '?' for help or 'help <command>' for help on <command>.

Type:

BrightSign> script debug on
BrightSign> reboot

The next time you log in with SSH, you should be able to break and reach the prompt using Ctrl-C

A couple of notes: