| 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.|
| 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.|
**Example**
...
...
@@ -258,15 +258,15 @@ Adds network configuration. This API uses a promise to return the result.
| 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.|
| 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.|
**Example**
...
...
@@ -391,15 +391,15 @@ Adds the configuration of an untrusted network. This API uses a promise to retur
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.|
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.|
**Example**
```js
...
...
@@ -466,15 +466,15 @@ Removes the configuration of an untrusted network. This API uses a promise to re
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.|
| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.|
| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is **true**. If the operation fails, **data** is **false**. If **err** is not **0**, an error has occurred.|
**Example**
```js
...
...
@@ -537,15 +537,15 @@ Connects to the specified network.
| networkId | number | Yes| Network configuration ID.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
...
...
@@ -569,21 +569,21 @@ Connects to the specified network.
**System API**: This is a system API.
**Required permissions**: ohos.permission.SET_WIFI_INFO, ohos.permission.SET_WIFI_CONFIG, and ohos.permission.MANAGE_WIFI_CONNECTION (available only to system applications)
| rssi | number | Yes| RSSI of the hotspot, in dBm.|
| band | number | Yes| Frequency band of the WLAN AP.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| number | Signal level obtained. The value range is [0, 4].|
| **Type**| **Description**|
| -------- | -------- |
| number | Signal level obtained. The value range is [0, 4].|
**Example**
```js
...
...
@@ -682,9 +682,9 @@ Obtains WLAN connection information. This API uses a promise to return the resul
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[WifiLinkedInfo](#wifilinkedinfo)> | Promise used to return the WLAN connection information.|
| Type| Description|
| -------- | -------- |
| Promise<[WifiLinkedInfo](#wifilinkedinfo)> | Promise used to return the WLAN connection information.|
## wifi.getLinkedInfo
...
...
@@ -699,9 +699,9 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| 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.|
**Example**
```js
...
...
@@ -802,9 +802,9 @@ Checks whether the WLAN is connected.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.|
## wifi.getSupportedFeatures<sup>7+</sup>
...
...
@@ -821,9 +821,9 @@ Obtains the features supported by this device.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| number | Feature value. |
| **Type**| **Description**|
| -------- | -------- |
| number | Feature value. |
**Feature IDs**
...
...
@@ -854,15 +854,15 @@ Checks whether the device supports the specified WLAN feature.
**Parameters**
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| featureId | number | Yes| Feature ID.|
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| featureId | number | Yes| Feature ID.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Example**
```js
...
...
@@ -892,9 +892,9 @@ Obtains the device MAC address.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| string[] | MAC address obtained.|
| **Type**| **Description**|
| -------- | -------- |
| string[] | MAC address obtained.|
**Example**
```js
...
...
@@ -921,9 +921,9 @@ Obtains IP information.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| [IpInfo](#ipinfo7) | IP information obtained.|
| **Type**| **Description**|
| -------- | -------- |
| [IpInfo](#ipinfo7) | IP information obtained.|
**Example**
```js
...
...
@@ -966,9 +966,9 @@ Obtains the country code.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| string | Country code obtained.|
| **Type**| **Description**|
| -------- | -------- |
| string | Country code obtained.|
**Example**
```js
...
...
@@ -996,9 +996,9 @@ Re-associates with the network.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
...
...
@@ -1025,9 +1025,9 @@ Reconnects to the network.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
@@ -1478,9 +1478,9 @@ Obtains P2P link information. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Promise used to return the P2P link information obtained.|
| Type| Description|
| -------- | -------- |
| Promise<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Promise used to return the P2P link information obtained.|
...
...
@@ -1521,9 +1521,9 @@ Obtains P2P link information. This API uses an asynchronous callback to return t
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the P2P link information. If **err** is not **0**, an error has occurred.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the P2P link information. If **err** is not **0**, an error has occurred.|
**Example**
```js
...
...
@@ -1554,9 +1554,9 @@ Obtains the current P2P group information. This API uses a promise to return the
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Promise used to return the P2P group information obtained.|
| Type| Description|
| -------- | -------- |
| Promise<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | Promise used to return the P2P group information obtained.|
## wifi.getCurrentGroup<sup>8+</sup>
...
...
@@ -1571,9 +1571,9 @@ Obtains the current P2P group information. This API uses an asynchronous callbac
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pGroupInfo](#wifip2pgroupinfo8)> | 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.|
**Example**
```js
...
...
@@ -1604,9 +1604,9 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r
**Return value**
| Type| Description|
| -------- | -------- |
| Promise<[WifiP2pDevice[]](#wifip2pdevice8)> | Promise used to return the peer device list.|
| Type| Description|
| -------- | -------- |
| Promise<[WifiP2pDevice[]](#wifip2pdevice8)> | Promise used to return the peer device list.|
## wifi.getP2pPeerDevices<sup>8+</sup>
...
...
@@ -1621,9 +1621,9 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pDevice[]](#wifip2pdevice8)> | 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.|
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback<[WifiP2pDevice[]](#wifip2pdevice8)> | 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.|
**Example**
```js
...
...
@@ -1684,15 +1684,15 @@ Creates a P2P group.
**Parameters**
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| Group configuration.|
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| Group configuration.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
...
...
@@ -1753,9 +1753,9 @@ Removes this P2P group.
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
...
...
@@ -1781,15 +1781,15 @@ Sets up a P2P connection.
**Parameters**
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| P2P group configuration.|
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| P2P group configuration.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
...
...
@@ -1871,9 +1871,9 @@ Cancels this P2P connection.
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
...
...
@@ -1898,9 +1898,9 @@ Starts to discover devices.
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
...
...
@@ -1925,9 +1925,9 @@ Stops discovering devices.
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example**
```js
...
...
@@ -1955,15 +1955,15 @@ Deletes a persistent group.
**Parameters**
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the group to delete.|
| **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the group to delete.|
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| 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.|
| 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.|
**Example**
```js
...
...
@@ -2104,10 +2104,10 @@ Registers 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.|
| 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.|
**Example**
```js
...
...
@@ -2161,10 +2161,10 @@ Registers the WLAN scan state 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.|
| type | string | Yes| Event type. The value is **streamChange**. |
| callback | Callback<number> | Yes| Callback invoked to return the Wi-Fi stream change, which can be any of the following values:<br>- **0**: No change.<br>- **1**: Downward.<br>- **2**: Upward.<br>- **3**: Bidirectional. |
| type | string | Yes| Event type. The value is **streamChange**. |
| callback | Callback<number> | Yes| Callback invoked to return the Wi-Fi stream change, which can be any of the following values:<br>- **0**: No change.<br>- **1**: Downward.<br>- **2**: Upward.<br>- **3**: Bidirectional. |
| 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.|
| 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.|
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | No| Callback for the P2P connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
...
...
@@ -2435,10 +2585,10 @@ Registers the P2P device state change events.
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | No| Callback for the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
...
...
@@ -2463,7 +2613,7 @@ Unregisters the P2P device state change events.
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | No| Callback for the peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
...
...
@@ -2513,7 +2663,7 @@ Unregisters the P2P peer device state change events.
| 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.|
**Example**
...
...
@@ -2563,7 +2713,7 @@ Unregisters the P2P persistent group state change events.
importwififrom'@ohos.wifi';
varrecvP2pPersistentGroupChangeFunc=result=>{
console.info("Receive recv p2p persistent group change event: "+result);
console.info("Receive p2p persistent group change event: "+result);
}
// Register an event.
...
...
@@ -2586,10 +2736,10 @@ Registers 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.|
**Example**
...
...
@@ -2621,7 +2771,7 @@ Unregisters the P2P device discovery state change events.
Obtains the scan result. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or (ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION))
Obtains the scan result. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or (ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION))
| 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.|
| Array<[WifiScanInfo](#wifiscaninfo)> | Returns the hotspots detected.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
Obtains the scan result. This API returns the result synchronously.
**Required permissions**: ohos.permission.GET_WIFI_INFO and (ohos.permission.GET_WIFI_PEERS_MAC or (ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION))
@@ -2121,7 +2455,7 @@ Obtains P2P link information. This API uses an asynchronous callback to return t
| callback | AsyncCallback<[WifiP2pLinkedInfo](#wifip2plinkedinfo9)> | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the P2P link information. If **err** is not **0**, an error has occurred.|