Player APIs (BrightScript & Ja...
JavaScript APIs
deviceinfo
18min
the deviceinfo object lets you identify device hardware, firmware, and features deviceinfo idl interface deviceinfo { attribute string model; attribute string osversion; attribute string bootversion; attribute string serialnumber; attribute string family; int osversioncompare(string version); int bootversioncompare(string bootversion); bool osversionisatleast(string version); bool bootversionisatleast(string bootversion); bool hasfeature(string feature); promise \<string> getloadstatistics(string item); promise \<temperaturelocation> gettemperature(); promise \<usbtopologyinterface> getusbtopology(); }; dictionary temperaturelocation { float celsius; }; interface usbtopologyinterface { attribute string vid; attribute string pid; attribute string raw; attribute string fid; \[optional] attribute string category; \[optional] attribute string ident; attribute array\<usbtopologyinterface> children; }; object creation to create a deviceinfo object, load the @brightsign/deviceinfo module using the require() method diclass = require("@brightsign/deviceinfo"); di = new diclass(); deviceinfo getloadstatistics() promise \<string> getloadstatistics(string item) provides current performance information related to the linux kernel the item can be any of the following loadavg provides information about system performance the first three columns measure cpu and i/o utilization over the past 1, 5, and 10 minutes, respectively the fourth column displays the number of currently running processes and the total number of processes the last column displays the id of the most recently used process meminfo displays physical and swap memory usage slabinfo provides information about memory usage at the slab level stat provides overall statistics about the system (for example, the number of page faults since the system booted) vmstat displays detailed virtual memory statistics from the kernel zoneinfo provides overall statistics about the system, broken down by system node interrupts displays which interrupts are in use and how many of each type there have been version provides the kernel version gettemperature() \<temperaturelocation> gettemperature() returns key string string a dynamic string location key value float float the device temperature as a floating point value getusbtopology() \<usbtopologyinterface> getusbtopology() gets the usb topology of the player these attributes return information about the brightsign player model string string returns the model name for the brightsign device running the script, as a string (for example, "hd1020" or "xd230") osversion string string returns the os version number for the brightsign device running the script bootversion string string returns the version number of the brightsign boot firmware, also known as "safe mode", as a string (for example, "1 0 4") serialnumber string string returns the device serial number which, if not an empty string, is unique to the unit running the script family string string returns a single string that indicates the family to which the device belongs a device family is a set of models that are all capable of running the same firmware osversioncompare() int osversioncompare(string version) this function returns an integer greater than zero if the current os version is greater than the parameter, 0 if it is exactly equal, or less than zero if lesser for example if (di osversioncompare("8 2") > 0) { console log("firmware version is greater than 8 2") } or if (di osversioncompare("8 4") < 0) { console log("firmware version is less than 8 4") } bootversioncompare() int bootversioncompare(string bootversion) this function returns an integer greater than zero if the current boot loader version is greater than the parameter, 0 if it is exactly equal, or less than zero if lesser (see the examples for osversioncompare() ) osversionisatleast() bool osversionisatleast(string version) returns true if the brightsign os version on the device is greater than or equal to the version number represented by the passed string (for example, "4 0 13") bootversionisatleast() bool bootversionisatleast(string bootversion) returns true if the brightsign boot os version on the device is greater than or equal to the version number represented by the passed string (for example, "4 4 22") hasfeature() bool hasfeature(string feature) returns true if the player feature in the passed string (which is passed as a case insensitive string parameter) is present on the current device and firmware the possible features that can be queried from the script are listed below if you pass a parameter other than one of those listed below, it may return false even if the feature is available on the hardware and firmware "5v serial" a 5v serial port "audio1" the first audio output "audio2" a second audio output "audio3" a third audio output "brightscript1" brightscript version 1 "brightscript2" brightscript version 2 "component video" a component video output "ethernet" an ethernet interface "gpio connector" a da15 or pheonix style gpio port "hdmi" an hdmi ® output "hdmi input" an hdmi input "hevc decode" an h 265 video decoder "media decryption" the ability to decrypt aes encrypted media, including video, image, and audio files "nand storage" nand storage for the boot loader and firmware "networking" any form of networking capability a false return may indicate that no network is currently available "reset button" a reset button "registry" on board persistent storage "rtc" a real time clock (rtc) "sd" sd or sdhc compatible storage "sdhc" sdhc compatible storage only "serial port 0" the first serial port "serial port 1" a second serial port "serial port 2" a third serial port "svc button" a service ("svc") button passing the legacy term "gpio12 button" will yield the same result "usb" one or more usb interfaces "vga" a vga output "video encoder" a video encoder/transcoder temperaturelocation celsius float float returns the temperature of the device in celsius, as a floating point number usbtopologyinterface these attributes return the usb topology of the player, which can be used to determine whether certain usb devices are connected to certain ports vid string string four character strings encoding the vendor id and product id in hexadecimal leading zeros are present and alpha characters are lower case (for example, vid = "0b95") pid string string four character strings encoding the vendor id and product id in hexadecimal leading zeros are present and alpha characters are lower case (for example, pid = "0b95") raw string string this is an internal (linux) usb device node id fid string string ports that have usb devices connected to them will include a fid (friendly id) value, which can be used to determine which physical port the usb device is connected to on the player see rodeviceinfo docid\ utkdmpos1ulxaoylx1ns6 for more information category string string optional optional this optional string describes the device type (for example, "hub", "serial", "net", "hid", "audio", or "other") ident string string optional optional this is an additional identifier for devices of category "net", the ident is the system network interface name (for example, "usb0") children array<\<usbtopologyinterface> array<\<usbtopologyinterface> optional optional children are present for devices of category "hub" child devices have the same structure, so nested hubs will produce nested child data example this example returns the usb topology for the device diclass = require("@brightsign/deviceinfo"); di = new diclass(); usbtopology = await di getusbtopology(); parsetopology = function(usbt) { for(i in usbt) { let device = usbt\[i]; if (device category === "hub") parsetopology(device children); if (device category === "net") console log("found " + device fid + " interface " + device ident); } }; parsetopology(usbtopology); to replace bsdeviceinfo with the deviceinfo object if (typeof(bsdeviceinfo) === typeof undefined) { global bsdeviceinfo = class bsdeviceinfo { constructor() { let fs = require('fs'); let deviceinfoclass = require('@brightsign/deviceinfo'); let deviceinfo = new deviceinfoclass(); // map properties and getters this model = deviceinfo model; this version = deviceinfo osversion; this bootversion = deviceinfo bootversion; this deviceuniqueid = deviceinfo serialnumber; this family = deviceinfo family; object defineproperty(this, 'deviceuptime', { get object getownpropertydescriptor(deviceinfo, 'deviceuptime') get, enumerable true, }); // and methods this versioncompare = deviceinfo osversioncompare; this bootversioncompare = deviceinfo bootversioncompare; this firmwareisatleast = deviceinfo osversionisatleast; this bootfirmwareisatleast = deviceinfo bootversionisatleast; this hasfeature = deviceinfo hasfeature; this getloadstatistics = function(s) { let stats = new set(\[ 'zoneinfo', 'loadavg', 'meminfo', 'stat', 'vmstat', 'interrupts', 'version', 'boardid' ]); var result = 'n/a'; if (stats has(s)) { result = fs readfilesync('/proc/' + s) tostring(); } return result; }; // gettemperature and getusbtopology are not present in the bsdeviceinfo class }; }; }