Network
The Network module handles network configuration.
Function getInterfaces will give you the description of all the available Interfaces on the box. This is probably more information than you need.
Call getActiveInterface to get the id of the currenly connected to the Internet Interface. Then pass that id to getInterfaceInfo to get its entire Interface object.
To configure an Interface, call configureInterface, and pass an object containing the fields that you want to change.
Wireless Networks Call startWirelessScan to start scanning for Wireless networks. As the scan progresses, the onWirelessScanStateChanged Signal will be fired to report the current WirelessScanState and any found WirelessNetwork.
To connect to a wireless network, call configureInterface, passing the ssid and the password of the desired network to the configuration object in the ssid and key property fields respectively. Once connected to a wireless network, the system stores the password and future attempts will not require it to connect.
Members
ConnectionState
Enum for connection states.
Properties:
| Name | Type | Description |
|---|---|---|
| DISCONNECTED | Disconnected | |
| CONNECTING | Connecting | |
| CONNECTED | Connected |
InterfaceType
Enum for interface types.
Properties:
| Name | Type | Description |
|---|---|---|
| ETHERNET | Ethernet | |
| WIRELESS | Wireless |
onActiveInterfaceChanged
Signal fired when the active interface changes e.g. from Ethernet to Wifi or vice versa.
onWifiAuthenticated
Signal fired on successful Wifi authentication when trying to connect to a Wireless network.
onWirelessScanStateChanged
Signal fired whenever the Wireless scanner's status changes. The listener's first argument is scan_state. If scan_state is FOUND, then the second argument will be data.
- scan_state: An Enum value of type WirelessScanState indicating the Wireless scanner's state.
- data: A list of objects of type WirelessNetwork representing the list of discovered networks.
WirelessScanState
Enum for wireless scan states.
Properties:
| Name | Type | Description |
|---|---|---|
| STARTED | The scan has started. | |
| FOUND | The scan has found a new Wireless network. | |
| FINISHED | The scan has finished. | |
| ERROR | An error has occured during scanning. |
WirelessSecurityMode
Enum for wireless security modes.
Properties:
| Name | Type | Description |
|---|---|---|
| NONE | No Security | |
| WEP | WEP | |
| WPA | WPA | |
| WPA2 | WPA2 | |
| WPA_AES | WPA Advanced Encryption Standard | |
| WPA2_TKIP | WPA2 Temporal Key Integrity Protocol |
Methods
configureInterface(id, config)
Configure a network interface. This function receives the network id and a configuration object as its arguments. The configuration object is similar to the Interface object, except it only includes configurable parameters. Common practice is to call getInterfaceInfo, change some of the fields, and pass the resulting object to this function.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | Number | The id of the Interface that is to be configured. | ||||||||||||||||||||||||||||||
config | Object | The configuration object. Properties:
|
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
getActiveInterface()
Get the id of the active Interface. Active Interface is defined as the currently connected to the Internet Interface. This function is deprecated. Use getInterfaces() to retrieve a complete list of the available interfaces. The provided properties 'connected' and/or 'configured' can be used to determine the connection state of each interface.
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - id: The active Interface's id property. |
getInterfaceInfo(id)
Get an entire Interface description.
Parameters:
| Name | Type | Description |
|---|---|---|
id | Number | The Interface's unique identifier. |
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - Interface: An Object of type Interface. |
getInterfaces()
List all available Interfaces.
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - Interface: An Array of Objects of type Interface. |
startWirelessScan()
Scan for available Wireless Networks.
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
getVlans()
List all available Vlans.
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - Vlan: An Array of Objects of type Vlan. |
addVlan()
Adds a new Vlan to a physical network interface. This function receives the network id on which the Vlan should be added and a configuration object as its arguments. A new network interface is created for this vlan. The Interface.name of the new interface will match the returned vlan name. Use configureInterface() to configure the new Interface.
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
id | Number | The id of the physical Interface where the Vlan should be added. | ||||||
config | Object | The configuration object. Properties:
|
Returns:
| Type | Description |
|---|---|
| A promise. | The completion handler will be passed the following arguments: - vlan: Name of the new vlan. Can be matched to Interface.name. |
removeVlan()
Removes a existing Vlan. This function receives the vlan that should be removed.
Parameters:
| Name | Type | Description |
|---|---|---|
vlan | String | Name of the vlan to remove. |
Returns:
| Type | Description |
|---|---|
| A promise. | No arguments are passed to the completion handler. |
Type Definitions
Interface
Description for an Interface.
Properties:
| Name | Type | Description |
|---|---|---|
id | Number | The Interface's unique identifier. |
name | String | The Interface's name. |
type | InterfaceType | The Interface's type. |
mac | String | The Interface's mac address. |
dhcp | Boolean | Will be true if DHCP is enabled for this Interface. |
ip | String | The Interface's IP address. |
mask | String | The Interface's netmask. |
gateway | String | The Interface's gateway. |
dns1 | String | The Interface's primary DNS server. |
dns2 | String | The Interface's secondary DNS server. |
activeness | Boolean | Will be true if the interface can be always up. |
configured | Boolean | Will be true if the interface is up and has an IP. If the interface is Wifi, then it also needs to have an SSID. |
connected | Boolean | Will be true if the interface is configured and has a connection to the Internet. |
linkState | Boolean | Only for Ethernet Interfaces: Will be true if the cable is connected. |
ssid | String | Only for Wireless Interfaces: The SSID of the network the Interface is connected to. |
security | WirelessSecurityMode | Only for Wireless Interfaces: The security mode of the network the Interface is connected to. |
signal | Number | Only for Wireless Interfaces: The signal strength of the network the Interface is connected to. Values from 0 to 100. |
ipv4_enable | Boolean | Will be true when IPv4 is enabled for the interface, else disabled. |
configurable | Boolean | Will be true when the interface can be configured. |
WirelessNetwork
Description of a Wireless network.
Properties:
| Name | Type | Description |
|---|---|---|
ssid | String | The network's SSID. |
signal | Number | The network's signal strength. |
security | WirelessSecurityMode | The network's Security Mode. |
connected | Boolean | True if the system is connected to this wireless network, false otherwise. |
Vlan
Description of a Vlan.
Properties:
| Name | Type | Description |
|---|---|---|
vlan | String | Name of the Vlan. Can be matched to Interface:.name. |
vlan_id | Number | 802.1q Vlan ID used by this Vlan |
network_interface | String | The physical network interface the vlan is based on. Can be matched to Interface:.name. |