LuCI.network. WifiNetwork

A Network.WifiNetwork instance represents a wireless network (vif) configured on top of a radio device and provides functions for querying the runtime state of the network. Most radio devices support multiple such networks in parallel.

Methods

disconnectClient(mac, deauthopt, reasonopt, ban_timeopt) → {Promise.<number>}

Forcibly disconnect the given client from the wireless network.

Parameters:
NameTypeAttributesDefaultDescription
macstring

The MAC address of the client to disconnect.

deauthboolean<optional>
false

Specifies whether to de-authenticate (true) or disassociate (false) the client.

reasonnumber<optional>
1

Specifies the IEEE 802.11 reason code to disassoc/deauth the client with. Default is 1 which corresponds to Unspecified reason.

ban_timenumber<optional>
0

Specifies the number of milliseconds to ban the client from reconnecting. By default, no ban time is set which allows the client to re-associate / reauthenticate immediately.

Returns:

Returns a promise resolving to the underlying ubus call result code which is typically 0, even for not existing MAC addresses. The promise might reject with an error in case invalid arguments are passed.

Type: 
Promise.<number>

get(opt) → {null|string|Array.<string>}

Read the given UCI option value of this wireless network.

Parameters:
NameTypeDescription
optstring

The UCI option name to read.

Returns:

Returns the UCI option value or null if the requested option is not found.

Type: 
null | string | Array.<string>

getActiveBSSID() → {string}

Query the current BSSID from runtime information.

Returns:

Returns the current BSSID or Mesh ID as reported by ubus runtime information.

Type: 
string

getActiveEncryption() → {string}

Query the current encryption settings from runtime information.

Returns:

Returns a string describing the current encryption or - if the encryption state could not be found in ubus runtime information.

Type: 
string

getActiveMode() → {string}

Query the current operation mode from runtime information.

Returns:

Returns the human readable mode name as reported by iwinfo or uci mode. Possible returned values are:

  • Master
  • Ad-Hoc
  • Client
  • Monitor
  • Master (VLAN)
  • WDS
  • Mesh Point
  • P2P Client
  • P2P Go
  • Unknown
Type: 
string

getActiveModeI18n() → {string}

Query the current operation mode from runtime information as translated string.

Returns:

Returns the translated, human readable mode name as reported by ubus runtime state.

Type: 
string

getActiveSSID() → {string}

Query the current SSID from runtime information.

Returns:

Returns the current SSID or Mesh ID as reported by ubus runtime information.

Type: 
string

getAssocList() → {Promise.<Array.<LuCI.network.WifiPeerEntry>>}

Fetch the list of associated peers.

Returns:

Returns a promise resolving to an array of wireless peers associated with this network.

Type: 
Promise.<Array.<LuCI.network.WifiPeerEntry>>

getBSSID() → {null|string}

Get the configured BSSID of the wireless network.

Returns:

Returns the BSSID value or null if none has been specified.

Type: 
null | string

getBitRate() → {null|number}

Query the current average bit-rate of all peers associated with this wireless network.

Returns:

Returns the average bit rate among all peers associated with the network as reported by ubus runtime information or null if the information is not available.

Type: 
null | number

getChannel() → {null|number}

Query the current wireless channel.

Returns:

Returns the wireless channel as reported by ubus runtime information or null if it cannot be determined.

Type: 
null | number

getCountryCode() → {string}

Query the current country code.

Returns:

Returns the wireless country code as reported by ubus runtime information or 00 if it cannot be determined.

Type: 
string

getDevice() → {LuCI.network.Device}

Get the associated Linux network device.

Returns:

Returns a Network.Device instance representing the Linux network device associated with this wireless network.

Type: 
LuCI.network.Device

getFrequency() → {null|string}

Query the current operating frequency of the wireless network.

Returns:

Returns the current operating frequency of the network from ubus runtime information in GHz or null if the information is not available.

Type: 
null | string

getI18n() → {string}

Get a description string for this wireless network.

Returns:

Returns a string describing this network, consisting of the term Wireless Network, followed by the active operation mode, the SSID, BSSID or internal network ID and the Linux network device name, depending on which information is available.

Type: 
string

getID() → {string}

Get the internal network ID of this wireless network.

The network ID is a LuCI specific identifier in the form radio#.network# to identify wireless networks by their corresponding radio and network index numbers.

Returns:

Returns the LuCI specific network ID.

Type: 
string

getIfname() → {null|string}

Get the Linux network device name.

Returns:

Returns the current Linux network device name as resolved from ubus runtime information or null if this network has no associated network device, e.g. when not configured or up.

Type: 
null | string

getMeshID() → {null|string}

Get the configured Mesh ID of the wireless network.

Returns:

Returns the configured mesh ID value or null when this network is not in mesh mode.

Type: 
null | string

getMode() → {string}

Get the configured operation mode of the wireless network.

Returns:

Returns the configured operation mode. Possible values are:

  • ap - Master (Access Point) mode
  • sta - Station (client) mode
  • adhoc - Ad-Hoc (IBSS) mode
  • mesh - Mesh (IEEE 802.11s) mode
  • monitor - Monitor mode
Type: 
string

getName() → {string}

Get the configuration ID of this wireless network.

Returns:

Returns the corresponding UCI section ID of the network.

Type: 
string

getNetwork() → {null|LuCI.network.Protocol}

Get the primary logical interface this network is attached to.

Returns:

Returns a Network.Protocol instance representing the logical interface or null if this network is not attached to any logical interface.

Type: 
null | LuCI.network.Protocol

getNetworkNames() → {Array.<string>}

Get the names of the logical interfaces this wireless network is attached to.

Returns:

Returns an array of logical interface names.

Type: 
Array.<string>

getNetworks() → {Array.<LuCI.network.Protocol>}

Get the logical interfaces this network is attached to.

Returns:

Returns an array of Network.Protocol instances representing the logical interfaces this wireless network is attached to.

Type: 
Array.<LuCI.network.Protocol>

getNoise() → {number}

Query the current radio noise floor.

Returns:

Returns the radio noise floor in dBm as reported by ubus runtime information or 0 if it cannot be determined.

Type: 
number

getSSID() → {null|string}

Get the configured SSID of the wireless network.

Returns:

Returns the configured SSID value or null when this network is in mesh mode.

Type: 
null | string

getShortName() → {string}

Get a short description string for this wireless network.

Returns:

Returns a string describing this network, consisting of the active operation mode, followed by either the SSID, BSSID or internal network ID, depending on which information is available.

Type: 
string

getSignal() → {null|number}

Query the current wireless signal.

Returns:

Returns the wireless signal in dBm as reported by ubus runtime information or null if it cannot be determined.

Type: 
null | number

getSignalLevel(signal, noise) → {number}

Calculate the current signal.

Parameters:
NameTypeDescription
signalnumber
noisenumber
Deprecated
  • Yes
Returns:

Returns the calculated signal level, which is the difference between noise and signal (SNR), divided by 5.

Type: 
number

getSignalPercent() → {number}

Calculate the current signal quality percentage.

Returns:

Returns the calculated signal quality in percent. The value is calculated from the quality and quality_max indicators reported by ubus runtime state.

Type: 
number

getTXPower() → {null|number}

Query the current radio TX power.

Returns:

Returns the wireless network transmit power in dBm as reported by ubus runtime information or null if it cannot be determined.

Type: 
null | number

getTXPowerOffset() → {number}

Query the radio TX power offset.

Some wireless radios have a fixed power offset, e.g. due to the use of external amplifiers.

Returns:

Returns the wireless network transmit power offset in dBm as reported by ubus runtime information or 0 if there is no offset, or if it cannot be determined.

Type: 
number

getVlanIfnames() → {Array.<string>}

Get the Linux VLAN network device names.

Returns:

Returns the current Linux VLAN network device name as resolved from ubus runtime information or empty array if this network has no associated VLAN network devices.

Type: 
Array.<string>

getVlans() → {Array.<LuCI.network.WifiVlan>}

Fetch the vlans for this network.

Returns:

Returns an array of vlans for this network.

Type: 
Array.<LuCI.network.WifiVlan>

getWifiDevice() → {null|LuCI.network.WifiDevice}

Get the corresponding WiFi radio device.

Returns:

Returns a Network.WifiDevice instance representing the corresponding WiFi radio device or null if the related radio device could not be found.

Type: 
null | LuCI.network.WifiDevice

getWifiDeviceName() → {null|string}

Get the name of the corresponding WiFi radio device.

Returns:

Returns the name of the radio device this network is configured on or null if it cannot be determined.

Type: 
null | string

isClientDisconnectSupported() → {boolean}

Check whether this WiFi network supports de-authenticating clients.

Returns:

Returns true when this WiFi network instance supports forcibly de-authenticating clients, otherwise false.

Type: 
boolean

isDisabled() → {boolean}

Checks whether this wireless network is disabled.

Returns:

Returns true when the wireless radio is marked as disabled in ubus runtime state or when the disabled option is set in the corresponding UCI configuration.

Type: 
boolean

isUp() → {boolean}

Check whether the radio network is up.

This function actually queries the up state of the related radio device and assumes this network to be up as well when the parent radio is up. This is due to the fact that OpenWrt does not control virtual interfaces individually but within one common hostapd instance.

Returns:

Returns true when the network is up, else false.

Type: 
boolean

set(opt, value) → {null}

Set the given UCI option of this network to the given value.

Parameters:
NameTypeDescription
optstring

The name of the UCI option to set.

valuenull | string | Array.<string>

The value to set or null to remove the given option from the configuration.

Returns:
Type: 
null