# Class: WifiDevice

## LuCI .network. WifiDevice

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.

#### new LuCI.network.WifiDevice()

network.js, line 3080

### Methods

#### addWifiNetwork(options){Promise.<(null|LuCI.network.WifiNetwork)>}

network.js, line 3346

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

  Name | Type | Description
  --- | --- | ---
  `options` | Object.<string, (string|Array.<string>)> | optional The options to set for the newly added wireless network.

  ##### Returns:

  Type | Description
  --- | ---
  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){Promise.<boolean>}

network.js, line 3371

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

  Name | Type | Description
  --- | --- | ---
  `network` | string | The name of the wireless network to lookup. 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:

  Type | Description
  --- | ---
  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.

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

network.js, line 3120

  Read the given UCI option value of this wireless device.

  Name | Type | Description
  --- | --- | ---
  `opt` | string | The UCI option name to read.

  ##### Returns:

  Type | Description
  --- | ---
  null | string | Array.<string> | Returns the UCI option value or `null` if the requested option is not found.

#### getHTModes(){Array.<string>}

network.js, line 3198

  Gets a list of supported htmodes.

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

  ##### Returns:

  Type | Description
  --- | ---

  Array.<string>

  Returns an array of valid htmode values for this radio. Currently known mode values are:
  - `HT20` - applicable to IEEE 802.11n, 20 MHz wide channels
  - `HT40` - applicable to IEEE 802.11n, 40 MHz wide channels
  - `VHT20` - applicable to IEEE 802.11ac, 20 MHz wide channels
  - `VHT40` - applicable to IEEE 802.11ac, 40 MHz wide channels
  - `VHT80` - applicable to IEEE 802.11ac, 80 MHz wide channels
  - `VHT160` - applicable to IEEE 802.11ac, 160 MHz wide channels

#### getHWModes(){Array.<string>}

network.js, line 3177

  Gets a list of supported hwmodes.

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

  ##### Returns:

  Type | Description
  --- | ---

  Array.<string>

  Returns an array of valid hwmode values for this radio. Currently known mode values are:
  - `a` - Legacy 802.11a mode, 5 GHz, up to 54 Mbit/s
  - `b` - Legacy 802.11b mode, 2.4 GHz, up to 11 Mbit/s
  - `g` - Legacy 802.11g mode, 2.4 GHz, up to 54 Mbit/s
  - `n` - IEEE 802.11n mode, 2.4 or 5 GHz, up to 600 Mbit/s
  - `ac` - IEEE 802.11ac mode, 5 GHz, up to 6770 Mbit/s

#### getI18n(){string}

network.js, line 3209

  Get a string describing the wireless radio hardware.

  ##### Returns:

  Type | Description
  --- | ---
  string | Returns the description string.

#### getName(){string}

network.js, line 3158

  Get the configuration name of this wireless radio.

  ##### Returns:

  Type | Description
  --- | ---
  string | Returns the UCI section name (e.g. `radio0`) of the corresponding radio configuration which also serves as unique logical identifier for the wireless phy.

#### getScanList(){Promise.<Array.<LuCI.network.WifiScanResult>>}

network.js, line 3270

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

  ##### Returns:

  Type | Description
  --- | ---
  Promise.<Array.<LuCI.network.WifiScanResult>> | Returns a promise resolving to an array of scan result objects describing the networks found in the vincinity.

#### getWifiNetwork(network){Promise.<LuCI.network.WifiNetwork>}

network.js, line 3303

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

  Name | Type | Description
  --- | --- | ---
  `network` | string | The name of the wireless network to lookup. 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:

  Type | Description
  --- | ---
  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>>}

network.js, line 3322

  Get all wireless networks associated with this wireless radio device.

  ##### Returns:

  Type | Description
  --- | ---
  Promise.<Array.<LuCI.network.WifiNetwork>> | Returns a promise resolving to an array of `Network.WifiNetwork` instances respresenting the wireless networks associated with this radio device.

#### isDisabled(){boolean}

network.js, line 3146

  Checks whether this wireless radio is disabled.

  ##### Returns:

  Type | Description
  --- | ---
  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.

#### isUp(){boolean}

network.js, line 3281

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

  ##### Returns:

  Type | Description
  --- | ---
  boolean | Returns `true` when the radio device is up, else `false`.

#### set(opt, val)

network.js, line 3134

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

  Name | Type | Description
  --- | --- | ---
  `opt` | string | The name of the UCI option to set.
  `val` | null | string | Array.<string> | The value to set or `null` to remove the given option from the configuration.