• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

Network Service

The network service facilitates network access for applications. A network can be accessed either by Ethernet or Wi-Fi depending on what hardware resources are available.

Only one network is accessible at any given time. This network is called the boot network by the network service. This is the same network that the STB uses during boot, hence its name.

The boot network

The boot network will always use Ethernet if it is connected. If Wi-Fi is available it will only be used as long as Ethernet has no link.

The network settings of the platform's boot network are the same settings that can be accessed from the boot loader menu.

The STB's network components (network interface, gateway etc) are configured by the network service based on the settings provided by the user either through the boot loader menu or through the TOI API.

Since the boot network is used when booting from both Ethernet and Wi-Fi it is important that it is configured so that the boot server / boot image can be reached.

Network Capabilities

Since the KreaTV platform may support simultaneous access to multiple networks in the future, and due to differences in hardware configurations, each network represented in the network service has a set of network capabilities associated with it.

The network capabilities determine what kind of functionality is available and what settings the network will accept. For example, if the network has Wi-Fi capabilities it will accept Wi-Fi settings and allow the user to perform Wi-Fi related operations, such as scans, on that network.

See this page for a complete set of capabilities.

It is important that an application respects a network's capabilities!

Network State

A network can be in any of four states:

  • DISABLED - Network resources not available.
  • FAILED - Current settings could not be applied.
  • WAITING - Network is being configured.
  • READY - Network is ready to be used.

TOI API Overview

The service is accessed through the ToiNetService interface.

The entry point to a network is the ToiNetwork interface. This type of object is retrieved by calling ToiNetService::getNetwork() and passing the name of the network as a single argument. The name of the boot network is defined by ToiNetService::BOOT_NETWORK.

    
this.network = toi.netService.getNetwork(toi.consts.ToiNetService.BOOT_NETWORK);
  

TOI usage examples

This section will illustrate a couple of common use cases using TOI together with the boot network.

Check if the network is ready

A network is ready when it has link and at least one configured IP address. This information is available in the network information.

    
var network = toi.netService.getNetwork(
  toi.consts.ToiNetService.BOOT_NETWORK);
var networkInfo = network.getNetworkInfo();

switch (networkInfo.state) {
  case toi.consts.ToiNetwork.STATE_DISABLED:
    ...
    break;
  case toi.consts.ToiNetwork.STATE_FAILED:
    ...
    break;
  case toi.consts.ToiNetwork.STATE_WAITING:
    ...
    break;
  case toi.consts.ToiNetwork.STATE_READY:
    ...
    break;
}
  

It is possible to be notified when the state changes by listening for the `network info changed` event.

    
var network = toi.netService.getNetwork(
  toi.consts.ToiNetService.BOOT_NETWORK);

network.addEventListener(
  toi.consts.ToiNetwork.ON_NETWORK_INFO_CHANGED,
  this.updateNetworkInfo);
  

Scan Wi-Fi

Use the ToiNetwork::scanWifi function to perform an asynchronous scan of the wireless network.

    
this.network.scanWifi({
  onError: function(operation) {
    console.log("onError WIFI");
  },
  onResult: function(operation, aps) {
    // Create a map of available networks with ssid as key
    var accessPoints = {};
    for (var i = 0; i < aps.length; ++i) {
      // Calculate the signal strength
      var signal = (((aps[i].rcpi + 110) / 110) * 100).toFixed(0);

      // Add AP if it doesn't already exists or if the signal is better
      if (!(aps[i].ssid in accessPoints) ||
          signal > accessPoints[aps[i].ssid].signal) {
        accessPoints[aps[i].ssid] = {
          signal: signal,
          status: (aps[i].band === toi.consts.ToiNetwork.WIFI_BAND_2G ?
                   "2.4GHz" : "5GHz"),
          ap: aps[i]
        };
      }
    }
  }
}, "");

Connect to Wi-Fi

Use the ToiNetwork::applySettings function and supply the appropriate wifi settings like this:

    
this.network.applySettings({}, {
  wifiSettings: {
    bssid: apInfo.bssid,
    authenticationType: apInfo.authentication,
    encryptionType: apInfo.encryption,
    presharedKey: password
  }
});
  
See TOI Network Service Interface

5.0.1

Copyright (c) 2016 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.