1.2.0 ENABLE.network

Namespaces

nic_type
wifi_security_type

Members

static,constant ENABLE.network.NETWORK_INTERFACE_CHANGED String

Network interface changed

Since:
  • 1.0.0

static,constant ENABLE.network.NETWORK_IP_CHANGED String

STB IP changed

Since:
  • 1.0.0

Network Link Status Down

Since:
  • 1.0.0

Network Link Status Up

Since:
  • 1.0.0

static,constant ENABLE.network.NETWORK_READY String

Network Ready

Since:
  • 1.0.0

static,constant ENABLE.network.SCAN_FAILED String

WiFi Scanning failed

Since:
  • 1.0.1

static,constant ENABLE.network.SCAN_RESULTS_AVAILABLE String

WiFi Scanning result is avalible

Since:
  • 1.0.1

static,constant ENABLE.network.TYPE_DHCP String

Network IP type: DHCP

Since:
  • 1.0.0

static,constant ENABLE.network.TYPE_STATIC String

Network IP type: static

Since:
  • 1.0.0

static,constant ENABLE.network.WIFI_CONNECT_FAILURE String

WiFi connect fail

Since:
  • 1.1.0

static,constant ENABLE.network.WIFI_CONNECT_SUCCESS String

WiFi connect success

Since:
  • 1.1.0

Methods

static ENABLE.network.connectWifi (config) {Object}

Connect to a Wifi Access Point. If Ethernet is connected, active network interface will be switched to wireless when Ethernet is disconnected.
Return ENABLE.status.ERROR if no wireless interface was found

Name Type Description
config Object
Name Type Description
ssid String

SSID of the Wifi Access Point

password String

Password of the Wifi Access Point

security String

Security Type of the Wifi Access Point, support for
ENABLE.network.wifi_security_type.NONE
ENABLE.network.wifi_security_type.WEP
ENABLE.network.wifi_security_type.WPA
ENABLE.network.wifi_security_type.WPA2
ENABLE.network.wifi_security_type.WPA_WPA2

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR or
ENABLE.status.INVALID_ARGUMENT

static ENABLE.network.forgetWifi (network_id) {Object}

Forgor a Wifi Access Point that connected previously.
network_id is returned from ENABLE.network.getConfiguredWifiNetworks

Name Type Description
network_id int

Network Id of the access point

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR or
ENABLE.status.INVALID_ARGUMENT

static ENABLE.network.getConfiguredWifiNetworks () {Object}

Retrieves configured Access Point, that are connected previously.

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR
result Array.<Object> Array of object with following members:
Name Type Description
network_id int Network Id of the access point
ssid String SSID of the access point
password String Passwrod of the access point
security String The security type supported by the access point. ENABLE.network.wifi_security_type

static ENABLE.network.getConnectionInfo ( custom_interface ) {Object}

Retrieves the defails of network configuration of the active network
ENABLE.status.NOT_READY will be return if there is no active network
Members other than status_code will be returned when ENABLE.status.SUCCESS

Name Type Description
custom_interface String optional

Optional, only used when multiple network interface is connected, i.e. WiFi and ethernet

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR or
ENABLE.status.NOT_READY
nic_name String Name of NIC
ip_type String ENABLE.network.TYPE_STATIC or ENABLE.network.TYPE_DHCP
ip_address String IPv4 / IPv6 address, e.g. "10.0.35.106" or "2403:4a00:4001:15:45b7:8109:cf41:44b6"
prefix_length Number Prefix length of IPv4 / IPv6 address
ip_address_v6_list Array.<Object> List of IPv6 Addresses
Name Type Description
ip_address String IPv6 address
prefix_length Number Prefix length of IPv6 address
flag_permanent boolean Permanent address, true for indicating the address is permanent. false for indicating dynamic address (stateless address)
flag_temporary boolean Temporary address, true for indicating the address is temporary. Temporary address is a randomly generated 64-bit number as the interface ID instead of an interface's MAC address. You can use temporary addresses for any interface on an IPv6 node that you want to keep anonymous.
scope String The scope of the area where this address is valid.
global - the address is globally valid.
site - the address is site local.
link - the address is link local.
host - the address is valid only inside this host.
gateway String IP address of default gateway's
dns_servers Array.<String> List of DNS's IP address
bandwidth Number Downstream bandwidth in Kbps
netmask String IPv4 Network mask of STB, e.g. "255.255.255.0", return empty string for IPv6 address
network_id int available when connected to wireless interface, Network Id of the access point
ssid String available when connected to wireless interface, SSID of the access point
signal_level int available when connected to wireless interface, The detected signal level in dBm, also known as the RSSI.
security String available when connected to wireless interface, The security type supported by the access point. ENABLE.network.wifi_security_type

static ENABLE.network.getInterfaceInfo () {Object}

Retrieves the defails of network interface.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR
result Array.<Object> Array of object with following members:
Name Type Description
nic_name String Name of NIC
nic_type String Type of NIC, ETHERNET or WIFI
mac_address String Mac address of the NIC
linking Boolean true if NIC is up

static ENABLE.network.getLastScanResult () {Object}

Retrieves the latest AP scanning result.

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR
result Array.<Object> Array of object with following members:
Name Type Description
ssid String SSID of the access point
signal_level int The detected signal level in dBm, also known as the RSSI.
frequency String The center frequency (Mhz) of the channel over which the client is communicating with the access point.
bssid String Mac address of the access point
security String The security type supported by the access point. ENABLE.network.wifi_security_type

static ENABLE.network.isWifiEnabled () {Object}

Get wifi enabled state

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR
result boolean true for enabled or enabling, false to disabled or disabling

static ENABLE.network.setDhcpConfig ( custom_interface ) {Object}

Use connection config from DHCP server on current network interface

Calling ENABLE.network.setStaticConfig will update result of ENABLE.network.getConnectionInfo

  • ip_type will become ENABLE.network.TYPE_DHCP
Name Type Description
custom_interface String optional

Optional, only used when multiple network interface is connected, i.e. WiFi and ethernet

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR

static ENABLE.network.setEventCallback (callback) {Object}

Register network callback function for JavaScript application.
Only one callback function can be registered. Pass null to unregister.
Example:

let callback = function(obj) {
    if (obj.event === ENABLE.network.NETWORK_READY) {
        console.log("A network interface is ready to use");
    }
};
ENABLE.network.setEventCallback(callback);
Name Type Description
callback ENABLE.network#Callback

Callback function will be involved when events arrived.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.INVALID_ARGUMENT

static ENABLE.network.setStaticConfig (config, custom_interface ) {Object}

Use specified connection config on current network interface

Calling ENABLE.network.setStaticConfig will update result of ENABLE.network.getConnectionInfo

  • ip_type will become ENABLE.network.TYPE_STATIC

Remarks:
IPv4 address will be expected in format "192.168.1.2"

Sample code calling ENABLE.network.setStaticConfig :

var config = {
    "ip_address": "10.0.35.219",
    "prefix_length": 22,
    "gateway": "10.0.32.6",
    "dns_servers": [ "192.169.1.22" ]
};
ENABLE.network.setStaticConfig(config);
Name Type Description
config Object
Name Type Description
ip_address String

IPv4 address of the STB

prefix_length Number

Prefix length of ip_address

gateway String

IPv4 address of the gateway

dns_servers Array.<String>

List of IPv4 address of DNS, expected 1 to 2 address

custom_interface String optional

Optional, only used when multiple network interface is connected, i.e. WiFi and ethernet

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR or
ENABLE.status.INVALID_ARGUMENT

static ENABLE.network.setWifiEnabled (enabled) {Object}

Switch on/off Wifi
Return ENABLE.status.ERROR if no wireless interface was found

Name Type Description
enabled boolean

true to enable Wifi, false to disable

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR or
ENABLE.status.INVALID_ARGUMENT

static ENABLE.network.wifiScan () {Object}

Scan Wifi once.
Result is available by calling ENABLE.network.getLastScanResult after recieved event ENABLE.network.SCAN_RESULTS_AVAILABLE from callback
Return ENABLE.status.ERROR if no wireless interface was found

Since:
  • 1.1.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR

Type Definitions

Callback (object)

Callback function for ENABLE.network.setEventCallback

Name Type Description
object Object
Name Type Description
event Object

Possible values of event:
ENABLE.network.NETWORK_IP_CHANGED
ENABLE.network.NETWORK_INTERFACE_CHANGED
ENABLE.network.NETWORK_LINK_STATUS_UP
ENABLE.network.NETWORK_LINK_STATUS_DOWN
ENABLE.network.NETWORK_READY
ENABLE.network.SCAN_RESULTS_AVAILABLE
ENABLE.network.SCAN_FAILED
ENABLE.network.WIFI_CONNECT_SUCCESS
ENABLE.network.WIFI_CONNECT_FAILURE

Since:
  • 1.1.0