Player APIs (BrightScript & Ja...
JavaScript APIs
networkconfiguration
20min
the networkconfiguration object allows for configuration of the network interfaces on the player each object instance corresponds to a single network interface (ethernet, wifi, or modem), which is specified using the type attribute this object only allows you to configure/retrieve settings related to the network interfaces on the device for other network information, use the node js® os module networkconfiguration idl \[ constructor(string ifname) ] interface networkinterface { attribute string type; // values wifi, ethernet, modem networkinterfaceconfig defaultconfig(); promise\<networkinterfaceconfig> getconfig(networkinterfaceconfigrequestparams params\[optional]); // promise will be resolved as wifiinterfaceconfig, modeminterfaceconfig, ethernetinterfaceconfig promise\<void> applyconfig(networkinterfaceconfig config); \[type == "ethernet"] promise\<lldpneighborinformation> getneighborinformation(); \[type == "ethernet"] promise\<void> enableleds(); \[type == "wifi"] promise\<wifiaccesspointlist> scan(); \[type == "wifi"] promise\<void> reassociate(); }; interface wifiaccesspointlist { attribute string essid; attribute string bssid; attribute long signal; }; interface lldpneighborinformation { // information is directly converted from lldp fields are defined deep down there }; interface networkinterfaceconfig { attribute long metric; \[optional = config dhcp server] attribute dhcpserverconfig dhcpserverconfig; attribute array\<string> dnsserverlist; attribute ipaddresslist ipaddresslist; attribute long inboundshaperrate; attribute long mtu; \[optional = config vlan] attribute array\<int> vlanidlist; attribute string clientidentifier; attribute string domain; 	attribute array\<string> enabledprotocollist; }; \[optional = config dialup] interface dialupinterfaceconfig public networkinterfaceconfig { attribute string user; attribute string password; attribute string number; attribute string initstring; }; interface dhcpserverconfig { attribute string start; attribute string end; }; interface ipaddress { attribute string family; attribute string address; attribute string netmask; attribute string gateway; attribute string broadcast; }; interface ethernetinterfaceconfig public networkinterfaceconfig { attribute string securitymode; attribute string identity; attribute string eaptlsoptions; attribute string cacertificates; attribute string clientcertificate; attribute string privatekey; }; interface wifiinterfaceconfig public networkinterfaceconfig{ attribute string essid; attribute string passphrase; attribute string obfuscatedpassphrase; attribute string securitymode; attribute string identity; attribute string eaptlsoptions; attribute string cacertificates; attribute string clientcertificate; attribute string privatekey; attribute string frequencies; \[optional = config wifi ap] attribute bool accesspointmode; \[optional = config wifi ap] attribute long accesspointfrequency; \[optional = config wifi ap] attribute bool accesspointhidden; }; object creation to create a networkconfiguration object, first load the brightsign/networkconfiguration module using the require() method then create an instance of the networkconfiguration class using a string value that indicates the network interface associated with the instance var networkconfigclass = require("@brightsign/networkconfiguration"); var networkconfigeth = new networkconfigclass("eth0"); networkinterface use this interface to configure a network interface on the player type string string the network interface type, which can be one of the following "ethernet" an ethernet port on the brightsign player "wifi" the internal wifi "modem" a connected modem the network interface can be configured as a vlan using the following string format "\[parent interface] \[vlan id]" (e g "eth0 42") once the vlan interface(s) are configured, they must be enabled on the parent network interface (e g "eth0") by including them in the vlanidlist of the parent interface vlan interfaces use dhcp by default they are supported on series 4 (xtx44, xdx34, hdx24, ls424) and series 3 (xtx43, xdx33, hdx23, ls423, ho523) players only also see default routing metrics docid 0jdtagrv4albwlyfjnj45 getconfig() promise\<networkinterfaceconfig> getconfig(networkinterfaceconfigrequestparams params\[optional]) returns configuration settings for the network interface depending on the specified type , this method will return an ethernetinterfaceconfig , wifiinterfaceconfig , or modeminterfaceconfig interface if there is a set password, getconfig() will return true for the password parameter if there isn't a set password, getconfig() will return false for the password parameter note that this class concerns itself with the player's persistent network configuration if you wish to determine the current settings (for example the ip address that has been retrieved via dhcp) then use the node js® os module https //nodejs org/api/os html#os os networkinterfaces applyconfig() promise\<void> applyconfig(networkinterfaceconfig config) configures the network interface using the parameters in the passed networkinterfaceconfig object this method returns void upon success to reset a network interface setting to its default value, pass the networkinterfaceconfig object without the corresponding attribute the config parameter should contain the complete desired configuration any previous configuration is overwritten if you wish to change one item while keeping the rest of the configuration the same then first call getconfig and modify the returned object (see the example in the examples section) getneighborinformation() promise\<lldpneighborinformation> getneighborinformation() returns lldp information related to the network, or null this method is available with the ethernet interface only enableleds() promise\<void> enableleds() enables or disables the ethernet activity leds (that is, flashing during link and activity behavior) ethernet leds are enabled by default changes to this setting do not persist across reboots this method is available with the ethernet interface only scan() promise\<wifiaccesspointlist> scan() scans for wifi access points are returns a list of detected access points this method is available with the wifi interface only reassociate() promise\<void> reassociate() attempts to disconnect and reconnect to the currently configured wifi network asynchronously this should not normally be necessary, but could be useful when diagnosing network problems if successful, the returned promise will be resolved if unsuccessful, the returned promise will be rejected with error information this method is present in bos 8 4 20 and above, bos 8 5 26 and above, and in all bos 9 0 versions note that the promise may be resolved before the network has been reconnected use @brightsign/networkhotplug to determine when reconnection is complete wifiaccesspointlist this interface represents the results of a scan for wireless networks each entry in the list contains the following parameters essid string string wifi essid network name bssid string string bssid of the access point signal long long the received signal strength the absolute value of this attribute is usually not relevant, but it can be compared with the reported value on other networks or in different locations lldpneighborinformation this interface contains location information received from the network infrastructure using the ronetworkconfiguration docid\ u6zceyqddlz9xdakttmjs protocol networkinterfaceconfigrequestparams includeencryptedsecrets includeencryptedsecrets bool bool if set to true , encrypted secrets are included, if set to false they are not networkinterfaceconfig this interface contains settings related to a network interface metric long long the routing metric for the default gateway on the interface routes with lower metrics are preferred over routes with higher metrics if not specified the metric will be set to ensure that interfaces are preferred consistently for a given configuration dhcpserverconfig dhcpserverconfig dhcpserverconfig a dhcpserverconfig interface that specifies the dhcp server configuration for the interface the dhcp server can be disabled by setting this attribute to a null value when calling applyconfig() dnsserverlist array\<string> array\<string> a string list containing a maximum of three dns servers each string should contain the dotted quad ip address of a dns server ipaddresslist array\<ipaddress> array\<ipaddress> an array containing zero or one static ipv4 address configurations players do not currently support more than one ipv4 address per interface or static configuration of ipv6 addresses if the array is empty then ip addresses will be assigned using dhcp inboundshaperrate long long the bandwidth limit for inbound traffic in bits per second if undefined, there is no bandwidth limit mtu long long the maximum transmission unit (mtu) for the network interface in bytes if not specified an appropriate mtu value will be chosen automatically vlanidlist array\<unsigned short> array\<unsigned short> a list of vlan ids that this network interface is the parent for clientidentifier string string the dhcp client identifier for the network interface domain string string the domain name for the network interface enabledprotocollist array\<string> array\<string> an optional array containing the set of enabled ip protocols the default value is \[ ipv4 , ipv6 ] dialupinterfaceconfig this interface contains attributes related to the modem interface user string string the username that has been entered some operators will require the username, others will not password string string the password that has been entered some operators will require the password, others will not number string string the "start connection" command, which previously dialed a number now, number is almost always " 99#" initstring string string the general modem setup string, which varies between operators dhcpserverconfig this interface configures a dhcp server on the ethernet port or wireless access point if configuring dhcp for wifi, note that the wifi interface must be in access point mode a static ip address must be assigned to the wlan0 interface for the dhcp server to work correctly to apply a static ip address , refer to networkconfiguration docid 6ms7rdjwwhp21clmedrwv , and use the ipaddresslist setting start string string the beginning of the range of offered ip addresses end string string the end of the range of offered ip addresses gateway string string optional optional ipv4 address of the gateway to be used by clients dnsserverlist array\<string> array\<string> optional optional an array of strings containing the ipv4 addresses of name servers (ipv6 addresses are not currently supported) domain string string optional optional the domain suffix to be used by clients ipaddress this interface represents an ip address configuration family string string the ip configuration (must be set to ipv4) address string string the ip4 address this a string dotted decimal quad, for example "192 168 1 42" netmask string string the ip4 netmask this a string dotted decimal quad, for example "255 255 255 0" gateway string string the ip4 interface configuration this a string dotted decimal quad, for example "192 168 1 2" broadcast string string the ip4 broadcast address this a string dotted decimal quad, for example "192 168 1 255" ethernetinterfaceconfig securitymode string string sets the encryption method identity string string the radius (remote authentication dial in user service) identity if this value is blank, it will be taken from the specified client certificate ("subjectaltname" will be used if present; otherwise, the "commonname" is used) eaptlsoptions string string a string containing eap specific options cacertificates string string the contents of a ca certificate file in text form (that is, a "pem" file) clientcertificate string string the contents of a client certificate file in text form (that is, a "pem" file) privatekey string string the private key for authentication wifiinterfaceconfig this interface contains attributes related to the wifi interface essid string string the essid of the wireless network passphrase string string the plain text passphrase/key for the wireless network obfuscatedpassphrase string string optional optional the passphrase/key for the wireless network that has been obfuscated using a shared secret contact support\@brightsign biz mailto\ support\@brightsign biz to learn more about generating a key for obfuscation and storing it on the player the following attributes relate to wpa enterprise support securitymode string string sets the wifi encryption method by default, both wpa (tkip) and wpa2 (ccmp) encryption are permitted this method accepts a space separated, case insensitive list that can include either "tkip" or "ccmp" values passing an empty string sets the default mode if both ccmp and tkip are allowed, ccmp always has priority identity string string the radius identity if this value is blank, it will be taken from the specified client certificate ("subjectaltname" will be used if present; otherwise, the "commonname" is used) eaptlsoptions string string a string that contains eap specific options currently, this string can be used to enable or disable md5 support ("md5=enable" or "md5=disable") cacertificates string string the contents of a ca certificate file in text form (i e a "pem" file) certificates can also be sent from an eap peer clientcertificate string string the contents of a client certificate in text form (i e a "pem" file) privatekey string string the private key for authentication if the private key is password protected, use the passphrase/obfuscatedpassphrase attribute to set the password if the client certificate and associated private key are in the same pkcs#12 file, the file contents should be specified in the privatekey field and the clientcertificate field should be left blank frequencies string string gets the wifi frequencies list accesspointmode bool bool optional optional whether wifi access point mode is enabled or disabled the essid and passphrase of the wifi access point is set with the essid and passphrase/obfuscatedpassphrase attributes if a passphrase has been set, the wireless access point will use wpa2 authentication–otherwise, it will use no authentication accesspointfrequency long long optional optional the frequency https //en wikipedia org/wiki/list of wlan channels of the wifi access point (in mhz) accesspointhidden bool bool optional optional if hidden is true , the ssid is hidden, if false it is visible the default is non hidden, which was the previous behavior examples var networkconfigclass = require("@brightsign/networkconfiguration"); var nc = new networkconfigclass("etho"); nc getconfig() then( function(data) { console log(" general interface data "); console log(json stringify(data)); }) catch( function(data) { console log(json stringify(data)); }); the following code applies a static ip address to the ethernet interface if a static ip address is not provided, it configures the interface for dhcp instead function main() { process chdir('/storage/sd'); var networkconfig = { ipaddress "10 0 1 20", defaultgateway "10 0 1 1", subnetmask "255 255 255 0", broadcast "10 0 1 255" }; var networkconfigclass = require("@brightsign/networkconfiguration"); var networkconfigethernet = new networkconfigclass("eth0"); var networkconfig = {}; networkconfigethernet getconfig() then( function(data) { console log("=== current config " + json stringify(data)); networkconfig = data; if (networkconfig dnsservers) { networkconfig dnsserverlist = networkconfig dnsservers; } if (networkconfig ipaddress) { // use static ip address var ipaddress = { family "ipv4", address networkconfig ipaddress, netmask networkconfig subnetmask, gateway networkconfig defaultgateway, broadcast networkconfig broadcast, }; networkconfig ipaddresslist = \[ipaddress]; } else { // use dhcp to obtain dynamic ip address networkconfig ipaddresslist = \[]; } console log("=== applying config " + json stringify(networkconfig)); networkconfigethernet applyconfig(networkconfig) then( function () { console log("=== success"); }) catch( function(err) { console log(err); }); }) catch( function(err) { console log(err); }); } window\ main = main; the following code restricts ip version support to ipv4 only var networkconfigclass = require("@brightsign/networkconfiguration"); var networkconfigethernet = new networkconfigclass("eth0"); networkconfigethernet getconfig() then( function(data) { networkconfig = {} networkconfig enabledprotocollist = \["ipv4"]; networkconfigethernet applyconfig(networkconfig) then( function() { console log("success"); }) catch( function(err) { console log(err); }); }) catch( function(err) { console log(err); }); to change one item while keeping the rest of the configuration the same, call getconfig and modify the returned object var networkconfiguration = require('@brightsign/networkconfiguration'); var address = { ipaddress "10 0 1 20", defaultgateway "10 0 1 1", subnetmask "255 255 255 0", broadcast "10 0 1 255" }; var networkconfig = new networkconfiguration("eth0"); networkconfig getconfig() then(function(config) { var ipaddress = { family "ipv4", address address ipaddress, netmask address subnetmask, gateway address defaultgateway, broadcast address broadcast, }; config ipaddresslist = \[ipaddress]; networkconfig applyconfig(config); }) then(function() { console log("success"); }) catch(function(error) { console log(`${json stringify(error)}`); });