The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN.
> **NOTE**
...
...
@@ -30,6 +30,14 @@ Enables WLAN.
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.disableWifi<sup>9+</sup>
...
...
@@ -49,6 +57,13 @@ Disables WLAN.
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.isWifiActive<sup>9+</sup>
...
...
@@ -66,6 +81,13 @@ Checks whether WLAN is enabled.
| -------- | -------- |
| boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.scan<sup>9+</sup>
...
...
@@ -83,6 +105,13 @@ Starts a scan for WLAN.
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getScanResults<sup>9+</sup>
...
...
@@ -100,6 +129,13 @@ Obtains the scan result. This API uses a promise to return the result.
| -------- | -------- |
| Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the detected hotspots.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getScanResults<sup>9+</sup>
...
...
@@ -117,6 +153,14 @@ Obtains the scan result. This API uses an asynchronous callback to return the re
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the detected hotspots. Otherwise, **err** is a non-zero value and **data** is empty.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example**
```js
importwififrom'@ohos.wifi';
...
...
@@ -250,6 +294,13 @@ Obtains the scan result. This API returns the result synchronously.
| -------- | -------- |
| Array<[WifiScanInfo](#wifiscaninfo)> | Scan result obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addDeviceConfig<sup>9+</sup>
...
...
@@ -275,6 +326,14 @@ Adds network configuration. This API uses a promise to return the result.
| -------- | -------- |
| Promise<number> | Promise used to return the ID of the added network configuration. If **-1** is returned, the network configuration fails to be added.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## WifiDeviceConfig<sup>9+</sup>
Represents the WLAN configuration.
...
...
@@ -417,6 +476,13 @@ Adds network configuration. This API uses an asynchronous callback to return the
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addCandidateConfig<sup>9+</sup>
...
...
@@ -440,6 +506,13 @@ Adds the configuration of a candidate network. This API uses a promise to return
| -------- | -------- |
| Promise<number> | Promise used to return the network configuration ID.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addCandidateConfig<sup>9+</sup>
...
...
@@ -458,6 +531,13 @@ Adds the configuration of a candidate network. This API uses an asynchronous cal
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback<number> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the network configuration ID. If **data** is **-1**, the operation has failed. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.removeCandidateConfig<sup>9+</sup>
...
...
@@ -481,6 +561,13 @@ Removes the configuration of a candidate network. This API uses a promise to ret
| -------- | -------- |
| Promise<void> | Promise used to return the result.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.removeCandidateConfig<sup>9+</sup>
...
...
@@ -499,6 +586,13 @@ Removes the configuration of a candidate network. This API uses an asynchronous
| networkId | number | Yes| ID of the network configuration to remove.|
| callback | AsyncCallback<void> | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.disconnect<sup>9+</sup>
...
...
@@ -598,12 +711,13 @@ Disconnects the network.
**System capability**:
SystemCapability.Communication.WiFi.STA
**Return value**
**Error codes**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getSignalLevel<sup>9+</sup>
...
...
@@ -628,6 +742,13 @@ Obtains the WLAN signal level.
| -------- | -------- |
| number | Signal level obtained. The value range is [0, 4].|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getLinkedInfo<sup>9+</sup>
...
...
@@ -645,6 +766,14 @@ Obtains WLAN connection information. This API uses a promise to return the resul
| -------- | -------- |
| Promise<[WifiLinkedInfo](#wifilinkedinfo)> | Promise used to return the WLAN connection information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.getLinkedInfo<sup>9+</sup>
...
...
@@ -662,6 +791,15 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiLinkedInfo](#wifilinkedinfo)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the WLAN connection information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
**Example**
```js
importwififrom'@ohos.wifi';
...
...
@@ -766,6 +904,13 @@ Checks whether the WLAN is connected.
| -------- | -------- |
| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.getSupportedFeatures<sup>9+</sup>
...
...
@@ -794,12 +939,19 @@ Obtains the features supported by this device.
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## StationInfo<sup>9+</sup>
...
...
@@ -1233,7 +1465,13 @@ Obtains P2P link information. This API uses a promise to return the result.
| -------- | -------- |
| Promise<[WifiP2pLinkedInfo](#wifip2plinkedinfo9)> | Promise used to return the P2P link information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2pLinkedInfo<sup>9+</sup>
...
...
@@ -1293,6 +1531,13 @@ Obtains the current P2P group information. This API uses a promise to return the
| -------- | -------- |
| Promise<[WifiP2pGroupInfo](#wifip2pgroupinfo9)> | Promise used to return the P2P group information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getCurrentGroup<sup>9+</sup>
...
...
@@ -1310,6 +1555,13 @@ Obtains the current P2P group information. This API uses an asynchronous callbac
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pGroupInfo](#wifip2pgroupinfo9)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup>
...
...
@@ -1327,6 +1579,13 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r
| -------- | -------- |
| Promise<[WifiP2pDevice[]](#wifip2pdevice9)> | Promise used to return the peer device list.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup>
...
...
@@ -1344,6 +1603,13 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pDevice[]](#wifip2pdevice9)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the peer device list obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2pDevice<sup>9+</sup>
...
...
@@ -1391,6 +1657,13 @@ Obtains the local device information in the P2P connection. This API uses a prom
| -------- | -------- |
| Promise<[WifiP2pDevice](#wifip2pdevice9)> | Promise used to return the local device information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pLocalDevice<sup>9+</sup>
...
...
@@ -1425,12 +1698,13 @@ Creates a P2P group.
| -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig9) | Yes| Group configuration.|
**Return value**
**Error codes**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.deletePersistentGroup<sup>9+</sup>
...
...
@@ -1638,12 +1917,13 @@ Deletes a persistent group.
| -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the group to delete.|
**Return value**
**Error codes**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pGroups<sup>9+</sup>
...
...
@@ -1663,6 +1943,13 @@ Obtains information about all P2P groups. This API uses a promise to return the
| -------- | -------- |
| Promise< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo9)> > | Promise used to return the group information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## WifiP2pGroupInfo<sup>9+</sup>
...
...
@@ -1701,6 +1988,13 @@ Obtains information about all P2P groups. This API uses an asynchronous callback
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback< Array<[WifiP2pGroupInfo](#wifip2pgroupinfo9)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the group information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.setDeviceName<sup>9+</sup>
...
...
@@ -1720,12 +2014,13 @@ Sets the device name.
| -------- | -------- | -------- | -------- |
| devName | string | Yes| Device name to set.|
**Return value**
**Error codes**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('wifiStateChange')<sup>9+</sup>
...
...
@@ -1744,6 +2039,14 @@ Registers the WLAN state change events.
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback<number> | Yes| Callback invoked to return the WLAN state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
**WLAN states**
| **Value**| **Description**|
...
...
@@ -1769,7 +2072,15 @@ Unregisters the WLAN state change events.
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback<number> | No| Callback for the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the WLAN state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example**
```js
...
...
@@ -1811,6 +2122,13 @@ Registers the WLAN connection state change events.
| 0 | Disconnected.|
| 1 | Connected.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiConnectionChange')<sup>9+</sup>
...
...
@@ -1827,8 +2145,15 @@ Unregisters the WLAN connection state change events.
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback<number> | No| Callback for the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the WLAN connection state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.on('wifiScanStateChange')<sup>9+</sup>
...
...
@@ -1854,6 +2179,13 @@ Registers the WLAN scan state change events.
| 0 | Scan failed.|
| 1 | Scan successful.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiScanStateChange')<sup>9+</sup>
...
...
@@ -1870,8 +2202,15 @@ Unregisters the WLAN scan state change events.
| type | string | Yes| Event type. The value is **wifiScanStateChange**.|
| callback | Callback<number> | No| Callback for the WLAN scan state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the WLAN scan state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.on('wifiRssiChange')<sup>9+</sup>
...
...
@@ -1890,6 +2229,13 @@ Registers the RSSI change events.
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback<number> | Yes| Callback invoked to return the RSSI, in dBm.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiRssiChange')<sup>9+</sup>
...
...
@@ -1906,8 +2252,15 @@ Unregisters the RSSI change events.
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback<number> | No| Callback for the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the RSSI change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.on('hotspotStateChange')<sup>9+</sup>
...
...
@@ -1935,6 +2288,13 @@ Registers the hotspot state change events.
| 2 | Activating|
| 3 | Deactivating|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.off('hotspotStateChange')<sup>9+</sup>
...
...
@@ -1951,8 +2311,15 @@ Unregisters the hotspot state change events.
| type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback<number> | No| Callback for the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the hotspot state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.on('p2pStateChange')<sup>9+</sup>
...
...
@@ -1981,6 +2348,14 @@ Registers the P2P state change events.
| 4 | Closing|
| 5 | Closed|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback<number> | No| Callback for the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the P2P state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pConnectionChange')<sup>9+</sup>
...
...
@@ -2016,6 +2398,13 @@ Registers the P2P connection state change events.
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo9)> | Yes| Callback invoked to return the P2P connection state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pConnectionChange')<sup>9+</sup>
...
...
@@ -2032,8 +2421,15 @@ Unregisters the P2P connection state change events.
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo9)> | No| Callback for the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo9)> | No| Callback for the P2P connection state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pDeviceChange')<sup>9+</sup>
...
...
@@ -2052,6 +2448,13 @@ Registers the P2P device state change events.
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback<[WifiP2pDevice](#wifip2pdevice9)> | Yes| Callback invoked to return the P2P device state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pDeviceChange')<sup>9+</sup>
...
...
@@ -2068,8 +2471,15 @@ Unregisters the P2P device state change events.
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback<[WifiP2pDevice](#wifip2pdevice9)> | No| Callback for the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<[WifiP2pDevice](#wifip2pdevice9)> | No| Callback for the P2P device state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pPeerDeviceChange')<sup>9+</sup>
...
...
@@ -2088,6 +2498,13 @@ Registers the P2P peer device state change events.
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice9)> | Yes| Callback invoked to return the P2P peer device state.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pPeerDeviceChange')<sup>9+</sup>
...
...
@@ -2104,8 +2521,15 @@ Unregisters the P2P peer device state change events.
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice9)> | No| Callback for the peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice9)> | No| Callback for the P2P peer device state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback<void> | No| Callback for the P2P persistent group state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<void> | No| Callback for the P2P persistent group state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.on('p2pDiscoveryChange')<sup>9+</sup>
...
...
@@ -2167,6 +2605,13 @@ Registers the P2P device discovery state change events.
| 0 | Initial state.|
| 1 | Discovered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pDiscoveryChange')<sup>9+</sup>
...
...
@@ -2183,4 +2628,12 @@ Unregisters the P2P device discovery state change events.
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback<number> | No| Callback for the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback for the P2P device discovery state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE**
>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs described in this document are used only for non-universal products, such as routers.
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.getSupportedPowerModel
...
...
@@ -59,10 +60,17 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<Array<[PowerModel](#powermodel)>> | Promise used to return the power models obtained.|
| Type| Description|
| -------- | -------- |
| Promise<Array<[PowerModel](#powermodel)>> | Promise used to return the power models obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## PowerModel
...
...
@@ -89,10 +97,17 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array<[PowerModel](#powermodel)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<Array<[PowerModel](#powermodel)>> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.getPowerModel
...
...
@@ -106,10 +121,17 @@ Obtains the power model. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[PowerModel](#powermodel)> | Promise used to return the power model obtained.|
| Type| Description|
| -------- | -------- |
| Promise<[PowerModel](#powermodel)> | Promise used to return the power models obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **Type**| **Description**|
| -------- | -------- |
| 2701000 | Operation failed.|
## wifiext.getPowerModel
...
...
@@ -123,16 +145,23 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[PowerModel](#powermodel)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[PowerModel](#powermodel)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).