WifiDevice

Source: network.js:3396

A Network.WifiDevice class instance represents a wireless radio device present on the system and provides wireless capability information as well as methods for enumerating related wireless networks.


Instance Methods

get(opt: string): null | string | Array.<string>

Read the given UCI option value of this wireless device.

Parameters

  • opt (string) — The UCI option name to read.

Returns

  • null | string | Array.<string> — Returns the UCI option value or null if the requested option is not found.

set(opt: string, value: null | string | Array.<string>): null

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

Parameters

  • opt (string) — The name of the UCI option to set.
  • value (null | string | Array.<string>) — The value to set or null to remove the given option from the configuration.

Returns

  • null

isDisabled(): boolean

Checks whether this wireless radio is disabled.

Returns

  • boolean — 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.

getName(): string

Get the configuration name of this wireless radio.

Returns

  • string — Returns the UCI section name (e.g. radio0) of the corresponding radio configuration, which also serves as a unique logical identifier for the wireless phy.

getHWModes(): Array.<string>

Gets a list of supported hwmodes.

The hwmode values describe the frequency band and wireless standard versions supported by the wireless phy.

Returns

  • Array.<string> — Returns an array of valid hwmode values for this radio. Currently known mode values are:

getHTModes(): Array.<string>

Gets a list of supported htmodes.

The htmode values describe the wide-frequency options supported by the wireless phy.

Returns

  • Array.<string> — Returns an array of valid htmode values for this radio. Currently known mode values are:

getI18n(): string

Get a string describing the wireless radio hardware.

Returns

  • string — Returns the description string.

getScanList(): Promise.<Array.<LuCI.network.WifiScanResult>>

Trigger a wireless scan on this radio device and obtain a list of nearby networks.

Returns

  • Promise.<Array.<LuCI.network.WifiScanResult>> — Returns a promise resolving to an array of scan result objects describing the networks found in the vicinity.

isUp(): boolean

Check whether the wireless radio is marked as up in the ubus runtime state.

Returns

  • boolean — Returns true when the radio device is up, else false.

getWifiNetwork( network: string, ): Promise.<LuCI.network.WifiNetwork>

Get the wifi network of the given name belonging to this radio device

Parameters

  • network (string) — The name of the wireless network to look up. This may be either an uci configuration section ID, a network ID in the form radio#.network# or a Linux network device name like wlan0 which is resolved to the corresponding configuration section through ubus runtime information.

Returns

  • Promise.<LuCI.network.WifiNetwork> — Returns a promise resolving to a Network.WifiNetwork instance representing the wireless network and rejecting with null if the given network could not be found or is not associated with this radio device.

getWifiNetworks(): Promise.<Array.<LuCI.network.WifiNetwork>>

Get all wireless networks associated with this wireless radio device.

Returns

  • Promise.<Array.<LuCI.network.WifiNetwork>> — Returns a promise resolving to an array of Network.WifiNetwork instances representing the wireless networks associated with this radio device.

addWifiNetwork( options?: Object.<string, (string|Array.<string>)>, ): Promise.<(null|LuCI.network.WifiNetwork)>

Adds a new wireless network associated with this radio device to the configuration and sets its options to the provided values.

Parameters

  • options (Object.<string, (string|Array.<string>)>, optional) — The options to set for the newly added wireless network.

Returns

  • Promise.<(null|LuCI.network.WifiNetwork)> — Returns a promise resolving to a WifiNetwork instance describing the newly added wireless network or null if the given options were invalid.

deleteWifiNetwork(network: string): Promise.<boolean>

Deletes the wireless network with the given name associated with this radio device.

Parameters

  • network (string) — The name of the wireless network to look up. This may be either an uci configuration section ID, a network ID in the form radio#.network# or a Linux network device name like wlan0 which is resolved to the corresponding configuration section through ubus runtime information.

Returns

  • Promise.<boolean> — Returns a promise resolving to true when the wireless network was successfully deleted from the configuration or false when the given network could not be found or if the found network was not associated with this wireless radio device.