提交 18a19c1d 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 dd816222
......@@ -27,9 +27,9 @@ Enables WLAN.
**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**
......@@ -57,9 +57,9 @@ Disables WLAN.
**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**
......@@ -86,9 +86,9 @@ Checks whether WLAN is enabled.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.|
**Example**
......@@ -96,8 +96,8 @@ Checks whether WLAN is enabled.
import wifi from '@ohos.wifi';
try {
let isActivate = wifi.isActivate();
console.info("isActivate:" + isActivate);
let isWifiActive = wifi.isWifiActive();
console.info("isWifiActive:" + isWifiActive);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
......@@ -115,9 +115,9 @@ Starts a scan for WLAN.
**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**
......@@ -143,9 +143,9 @@ Obtains the scan result. This API uses a promise to return the result.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the detected hotspots.|
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the detected hotspots.|
## wifi.getScanInfos
......@@ -160,9 +160,9 @@ Obtains the scan result. This API uses an asynchronous callback to return the re
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&gt; | 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.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&gt; | 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.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the WLAN configuration ID. If **-1** is returned, the network configuration fails to be added.|
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the WLAN configuration ID. If **-1** is returned, the network configuration fails to be added.|
**Example**
......@@ -356,10 +356,10 @@ Adds network configuration. This API uses an asynchronous callback to return the
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback&lt;number&gt; | 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.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback&lt;number&gt; | 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
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
**Example**
```js
......@@ -431,10 +431,10 @@ Adds the configuration of an untrusted network. This API uses an asynchronous ca
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback&lt;boolean&gt; | 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.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback&lt;boolean&gt; | 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
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
**Example**
......@@ -504,10 +504,10 @@ Removes the configuration of an untrusted network. This API uses an asynchronous
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.|
| callback | AsyncCallback&lt;boolean&gt; | 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&lt;boolean&gt; | 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.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| networkId | number | Yes| Network configuration ID.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| 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)
**System capability**:
SystemCapability.Communication.WiFi.STA
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN 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
......@@ -617,9 +617,9 @@ Disconnects 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
......@@ -644,16 +644,16 @@ Obtains the WLAN signal level.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| rssi | number | Yes| RSSI of the hotspot, in dBm.|
| band | number | Yes| Frequency band of the WLAN AP.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| 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&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Promise used to return the WLAN connection information.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | 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&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | 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&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | 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.|
**Example**
```js
......@@ -1054,9 +1054,9 @@ Obtains network configuration.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Array of network configuration obtained.|
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Array of network configuration obtained.|
**Example**
```js
......@@ -1084,15 +1084,15 @@ Updates network configuration.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| New WLAN configuration.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.|
| **Type**| **Description**|
| -------- | -------- |
| number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.|
**Example**
```js
......@@ -1125,15 +1125,15 @@ Disables network configuration.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the network configuration to disable.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the network configuration to disable.|
**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
......@@ -1161,9 +1161,9 @@ Removes the configuration of all networks.
**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
......@@ -1190,15 +1190,15 @@ Removes the specified network configuration.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| id | number | Yes| ID of the network configuration to remove.|
**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
......@@ -1226,9 +1226,9 @@ Enables this hotspot.
**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
......@@ -1255,9 +1255,9 @@ Disables this hotspot.
**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
......@@ -1284,9 +1284,9 @@ Checks whether the hotspot supports dual band.
**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
......@@ -1314,9 +1314,9 @@ Checks whether this hotspot is active.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the hotspot is active; returns **false** otherwise.|
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the hotspot is active; returns **false** otherwise.|
**Example**
```js
......@@ -1344,15 +1344,15 @@ Sets hotspot configuration.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [HotspotConfig](#hotspotconfig7) | Yes| Hotspot configuration to set.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| config | [HotspotConfig](#hotspotconfig7) | Yes| Hotspot configuration to set.|
**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
......@@ -1405,9 +1405,9 @@ obtains hotspot configuration.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| [HotspotConfig](#hotspotconfig7) | Hotspot configuration obtained.|
| **Type**| **Description**|
| -------- | -------- |
| [HotspotConfig](#hotspotconfig7) | Hotspot configuration obtained.|
**Example**
```js
......@@ -1435,9 +1435,9 @@ Obtains information about the connected stations.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt; | Connected stations obtained.|
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt; | Connected stations obtained.|
**Example**
```js
......@@ -1478,9 +1478,9 @@ Obtains P2P link information. This API uses a promise to return the result.
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | Promise used to return the P2P link information obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | 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&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | 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&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | 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&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo8)&gt; | Promise used to return the P2P group information obtained.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo8)&gt; | 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&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo8)&gt; | 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&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo8)&gt; | 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&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | Promise used to return the peer device list.|
| Type| Description|
| -------- | -------- |
| Promise&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | 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&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | 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&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | 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.|
**Example**
```js
......@@ -2010,15 +2010,15 @@ Sets the device name.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| devName | string | Yes| Device name to set.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| devName | string | Yes| Device name to set.|
**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
......@@ -2044,10 +2044,10 @@ Registers the WLAN state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN state.|
**WLAN states**
......@@ -2071,10 +2071,10 @@ Unregisters the WLAN state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | 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.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN connection state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN connection state.|
**WLAN connection states**
......@@ -2129,10 +2129,10 @@ Unregisters the WLAN connection state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback&lt;number&gt; | 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.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiScanStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN scan state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiScanStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN scan state.|
**WLAN scan states**
......@@ -2218,10 +2218,10 @@ Registers the RSSI change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the RSSI, in dBm.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the RSSI, in dBm.|
## wifi.off('wifiRssiChange')<sup>7+</sup>
......@@ -2236,9 +2236,9 @@ Unregisters the RSSI change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
......@@ -2254,7 +2254,58 @@ wifi.on("wifiRssiChange", recvWifiRssiChangeFunc);
// Unregister an event.
wifi.off("wifiRssiChange", recvWifiRssiChangeFunc);
```
## wifi.on('streamChange')<sup>7+</sup>
on(type: "streamChange", callback: Callback&lt;number&gt;): void
Registers Wi-Fi stream changes.
**Required permissions**: ohos.permission.MANAGE_WIFI_CONNECTION
**System capability**: SystemCapability.Communication.WiFi.STA
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **streamChange**. |
| callback | Callback&lt;number&gt; | 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. |
## wifi.off('streamChange')<sup>7+</sup>
off(type: "streamChange", callback: Callback&lt;number&gt;): void
Unregisters Wi-Fi stream changes.
**Required permissions**: ohos.permission.MANAGE_WIFI_CONNECTION
**System capability**: SystemCapability.Communication.WiFi.STA
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **streamChange**. |
| callback | Callback&lt;number&gt; | 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. |
**Example**
```js
import wifi from '@ohos.wifi';
var recvStreamChangeFunc = result => {
console.info("Receive stream change event: " + result);
}
// Register an event.
wifi.on("streamChange", recvStreamChangeFunc);
// Unregister an event.
wifi.off("streamChange", recvStreamChangeFunc);
```
## wifi.on('hotspotStateChange')<sup>7+</sup>
on(type: "hotspotStateChange", callback: Callback&lt;number&gt;): void
......@@ -2267,10 +2318,10 @@ Registers the hotspot state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the hotspot state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the hotspot state.|
**Hotspot states**
......@@ -2308,11 +2359,110 @@ Unregisters the hotspot state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStateChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
## wifi.on('hotspotStaJoin')<sup>7+</sup>
on(type: "hotspotStaJoin", callback: Callback&lt;StationInfo&gt;): void
Registers the connection of an STA to a Wi-Fi hotspot.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT
**System capability**: SystemCapability.Communication.WiFi.AP.Core
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStaJoin**. |
| callback | Callback&lt;StationInfo&gt; | Yes| Callback invoked when an STA is connected to a Wi-Fi hotspot. |
## wifi.off('hotspotStaJoin')<sup>7+</sup>
off(type: "hotspotStaJoin", callback: Callback&lt;StationInfo&gt;): void
Unregisters the connection of an STA to a Wi-Fi hotspot.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT
**System capability**: SystemCapability.Communication.WiFi.AP.Core
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStaJoin**. |
| callback | Callback&lt;StationInfo&gt; | Yes| Callback for the connection of an STA to a Wi-Fi hotspot. |
**Example**
```js
import wifi from '@ohos.wifi';
var recvHotspotStaJoinFunc = result => {
console.info("Receive hotspot sta join event: " + result);
}
// Register an event.
wifi.on("hotspotStaJoin", recvHotspotStaJoinFunc);
// Unregister an event.
wifi.off("hotspotStaJoin", recvHotspotStaJoinFunc);
```
## wifi.on('hotspotStaLeave')<sup>7+</sup>
on(type: "hotspotStaLeave", callback: Callback&lt;StationInfo&gt;): void
Registers the disconnection of an STA from a Wi-Fi hotspot.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT
**System capability**: SystemCapability.Communication.WiFi.AP.Core
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStaLeave**. |
| callback | Callback&lt;StationInf]&gt; | Yes| Callback invoked when an STA is disconnected from a Wi-Fi hotspot. |
## wifi.off('hotspotStaLeave')<sup>7+</sup>
off(type: "hotspotStaLeave", callback: Callback&lt;StationInfo&gt;): void
Unregisters the disconnection of an STA from a Wi-Fi hotspot.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT
**System capability**: SystemCapability.Communication.WiFi.AP.Core
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStaLeave**. |
| callback | Callback&lt;StationInf]&gt; | Yes| Callback for the disconnection of an STA from a Wi-Fi hotspot. |
**Example**
```js
import wifi from '@ohos.wifi';
var recvHotspotStaLeaveFunc = result => {
console.info("Receive hotspot sta leave event: " + result);
}
// Register an event.
wifi.on("hotspotStaLeave", recvHotspotStaLeaveFunc);
// Unregister an event.
wifi.off("hotspotStaLeave", recvHotspotStaLeaveFunc);
```
## wifi.on('p2pStateChange')<sup>8+</sup>
......@@ -2326,10 +2476,10 @@ Registers the P2P state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P state.|
**P2P states**
......@@ -2353,9 +2503,9 @@ Unregisters the P2P state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pStateChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback&lt;number&gt; | No| Callback for the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
......@@ -2373,7 +2523,7 @@ wifi.on("p2pStateChange", recvP2pStateChangeFunc);
wifi.off("p2pStateChange", recvP2pStateChangeFunc);
```
## wifi.on('p2pConnectionChange')<sup>8+</sup>
## wifi.on('p2pConnectionChange')<sup>8+</sup>
on(type: "p2pConnectionChange", callback: Callback&lt;WifiP2pLinkedInfo&gt;): void
......@@ -2385,10 +2535,10 @@ Registers the P2P connection state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | Yes| Callback invoked to return the P2P connection state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | Yes| Callback invoked to return the P2P connection state.|
## wifi.off('p2pConnectionChange')<sup>8+</sup>
......@@ -2403,9 +2553,9 @@ Unregisters the P2P connection state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | 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.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | Yes| Callback invoked to return the P2P device state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | Yes| Callback invoked to return the P2P device state.|
## wifi.off('p2pDeviceChange')<sup>8+</sup>
......@@ -2453,9 +2603,9 @@ Unregisters the P2P device state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | 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.
import wifi from '@ohos.wifi';
var recvP2pDeviceChangeFunc = result => {
console.info("Receive recv p2p device change event: " + result);
console.info("Receive p2p device change event: " + result);
}
// Register an event.
......@@ -2485,9 +2635,9 @@ Registers the P2P peer device state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | Yes| Callback invoked to return the P2P peer device state.|
......@@ -2503,9 +2653,9 @@ Unregisters the P2P peer device state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | 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.
import wifi from '@ohos.wifi';
var recvP2pPeerDeviceChangeFunc = result => {
console.info("Receive recv p2p peer device change event: " + result);
console.info("Receive p2p peer device change event: " + result);
}
// Register an event.
......@@ -2535,10 +2685,10 @@ Registers the P2P persistent group state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback&lt;void&gt; | Yes| Callback invoked to return the P2P persistent group state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback&lt;void&gt; | Yes| Callback invoked to return the P2P persistent group state.|
## wifi.off('p2pPersistentGroupChange')<sup>8+</sup>
......@@ -2553,9 +2703,9 @@ Unregisters the P2P persistent group state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback&lt;void&gt; | 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.
import wifi from '@ohos.wifi';
var recvP2pPersistentGroupChangeFunc = 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.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P device discovery state.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P device discovery state.|
**P2P discovered device states**
......@@ -2611,9 +2761,9 @@ Unregisters the P2P device discovery state change events.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback&lt;number&gt; | 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.
import wifi from '@ohos.wifi';
var recvP2pDiscoveryChangeFunc = result => {
console.info("Receive recv p2p discovery change event: " + result);
console.info("Receive p2p discovery change event: " + result);
}
// Register an event.
......
......@@ -11,7 +11,7 @@ The **WLAN** module provides basic wireless local area network (WLAN) functions,
import wifiManager from '@ohos.wifiManager';
```
## wifi.enableWifi<sup>9+</sup>
## wifiManager.enableWifi<sup>9+</sup>
enableWifi(): void
......@@ -23,12 +23,6 @@ Enables WLAN.
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| 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).
......@@ -49,7 +43,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.disableWifi<sup>9+</sup>
## wifiManager.disableWifi<sup>9+</sup>
disableWifi(): void
......@@ -61,12 +55,6 @@ Disables WLAN.
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| 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).
......@@ -87,7 +75,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.isWifiActive<sup>9+</sup>
## wifiManager.isWifiActive<sup>9+</sup>
isWifiActive(): boolean
......@@ -117,14 +105,14 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
let isActivate = wifiManager.isActivate();
console.info("isActivate:" + isActivate);
let isWifiActive = wifiManager.isWifiActive();
console.info("isWifiActive:" + isWifiActive);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.scan<sup>9+</sup>
## wifiManager.scan<sup>9+</sup>
scan(): void
......@@ -134,11 +122,37 @@ Starts a scan for WLAN.
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
**Error codes**
| **Type**| **Description**|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
| 2501000 | Operation failed.|
**Example**
```js
import wifiManager from '@ohos.wifiManager';
try {
wifiManager.scan();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifiManager.startScan<sup>10+</sup>
startScan(): void
**System API**: This is a system API.
Starts a scan for WLAN.
**Required permissions**: ohos.permission.SET_WIFI_INFO and ohos.permission.MANAGE_WIFI_CONNECTION
**System capability**: SystemCapability.Communication.WiFi.STA
**Error codes**
......@@ -154,22 +168,164 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
wifiManager.scan();
wifiManager.startScan();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifiManager.getScanResults<sup>10+</sup>
## wifi.getScanInfoList<sup>9+</sup>
getScanResults(): Promise&lt;Array&lt;WifiScanInfo&gt;&gt;
getScanInfoList(): Array&lt;WifiScanInfo&gt;;
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))
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the Returns the hotspots detected.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifiManager.getScanResults<sup>10+</sup>
getScanResults(callback: AsyncCallback&lt;Array&lt;WifiScanInfo&gt;&gt;): void
Obtains the scan result.
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))
**System capability**: SystemCapability.Communication.WiFi.STA
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&gt; | 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&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Returns the hotspots detected.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example**
```js
import wifiManager from '@ohos.wifiManager';
wifiManager.getScanResults((err, result) => {
if (err) {
console.error("get scan info error");
return;
}
var len = Object.keys(result).length;
console.log("wifi received scan info: " + len);
for (var i = 0; i < len; ++i) {
console.info("ssid: " + result[i].ssid);
console.info("bssid: " + result[i].bssid);
console.info("capabilities: " + result[i].capabilities);
console.info("securityType: " + result[i].securityType);
console.info("rssi: " + result[i].rssi);
console.info("band: " + result[i].band);
console.info("frequency: " + result[i].frequency);
console.info("channelWidth: " + result[i].channelWidth);
console.info("timestamp: " + result[i].timestamp);
}
});
wifiManager.getScanResults().then(result => {
var len = Object.keys(result).length;
console.log("wifi received scan info: " + len);
for (var i = 0; i < len; ++i) {
console.info("ssid: " + result[i].ssid);
console.info("bssid: " + result[i].bssid);
console.info("capabilities: " + result[i].capabilities);
console.info("securityType: " + result[i].securityType);
console.info("rssi: " + result[i].rssi);
console.info("band: " + result[i].band);
console.info("frequency: " + result[i].frequency);
console.info("channelWidth: " + result[i].channelWidth);
console.info("timestamp: " + result[i].timestamp);
}
});
```
## wifiManager.getScanResultsSync<sup>10+</sup>
getScanResultsSync(): &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;
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))
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Scan result obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example**
```js
import wifiManager from '@ohos.wifiManager';
try {
let scanInfoList = wifiManager.getScanResultsSync();
console.info("scanInfoList:" + JSON.stringify(scanInfoList));
let len = Object.keys(scanInfoList).length;
console.log("wifi received scan info: " + len);
if(len > 0){
for (var i = 0; i < len; ++i) {
console.info("ssid: " + scanInfoList[i].ssid);
console.info("bssid: " + scanInfoList[i].bssid);
console.info("capabilities: " + scanInfoList[i].capabilities);
console.info("securityType: " + scanInfoList[i].securityType);
console.info("rssi: " + scanInfoList[i].rssi);
console.info("band: " + scanInfoList[i].band);
console.info("frequency: " + scanInfoList[i].frequency);
console.info("channelWidth: " + scanInfoList[i].channelWidth);
console.info("timestamp: " + scanInfoList[i].timestamp);
}
}
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifiManager.getScanInfoList<sup>10+</sup>
getScanInfoList(): Array&lt;WifiScanInfo&gt;;
Obtains the scanning result.
**Required permissions**: ohos.permission.GET_WIFI_INFO
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
......@@ -224,6 +380,7 @@ Represents WLAN hotspot information.
| -------- | -------- | -------- | -------- | -------- |
| ssid | string | Yes| No| Service set identifier (SSID) of the hotspot, in UTF-8 format.|
| bssid | string | Yes| No| Basic service set identifier (BSSID) of the hotspot.|
| bssidType<sup>10+</sup>| DeviceAddressType | Yes| No| BSSID type of the hotspot.|
| capabilities | string | Yes| No| Hotspot capabilities.|
| securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| WLAN security type.|
| rssi | number | Yes| No| Received signal strength indicator (RSSI) of the hotspot, in dBm.|
......@@ -235,6 +392,16 @@ Represents WLAN hotspot information.
| infoElems | Array&lt;[WifiInfoElem](#wifiinfoelem9)&gt; | Yes| No| Information elements.|
| timestamp | number | Yes| No| Timestamp.|
## DeviceAddressType <sup>10+</sup>
Enumerates the Wi-Fi device address (MAC/BISSID) types.
**System capability**: SystemCapability.Communication.WiFi.Core
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| RANDOM_DEVICE_ADDRESS | 0 | Random device address.|
| REAL_DEVICE_ADDRESS | 1 | Read device address.|
## WifiSecurityType<sup>9+</sup>
......@@ -317,7 +484,84 @@ Enumerates the WLAN channel widths.
| WIDTH_80MHZ_PLUS | 4 | 80 MHz<sup>+</sup>|
| WIDTH_INVALID | 5 | Invalid value|
## wifi.addDeviceConfig<sup>9+</sup>
## wifiManager.setScanAlwaysAllowed<sup>10+</sup>
setScanAlwaysAllowed(isScanAlwaysAllowed: boolean): void
Sets whether scan is always allowed.
**System API**: This is a system API.
**Required permissions**: ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG
**System capability**: SystemCapability.Communication.WiFi.STA
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| isScanAlwaysAllowed | boolean | Yes| Whether scan is always allowed.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
```js
import wifiManager from '@ohos.wifiManager';
try {
let isScanAlwaysAllowed = true;
wifiManager.setScanAlwaysAllowed(isScanAlwaysAllowed);
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifiManager.getScanAlwaysAllowed<sup>10+</sup>
getScanAlwaysAllowed(): boolean
Obtains whether scan is always allowed.
**System API**: This is a system API.
**Required permissions**: ohos.permission.SET_WIFI_INFO and ohos.permission.SET_WIFI_CONFIG
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean| Whether scan is always allowed. The value **true** means scan is allowed; the value **false** means the opposite.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example**
```js
import wifiManager from '@ohos.wifiManager';
try {
let isScanAlwaysAllowed = wifiManager.getScanAlwaysAllowed();
console.info("isScanAlwaysAllowed:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifiManager.addDeviceConfig<sup>9+</sup>
addDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
......@@ -379,6 +623,7 @@ Represents the WLAN configuration.
| -------- | -------- | -------- | -------- | -------- |
| ssid | string | Yes| No| SSID of the hotspot, in UTF-8 format.|
| bssid | string | Yes| No| BSSID of the hotspot.|
| bssidType<sup>10+</sup> | DeviceAddressType | Yes| No| BSSID type of the hotspot.|
| preSharedKey | string | Yes| No| PSK of the hotspot.|
| isHiddenSsid | boolean | Yes| No| Whether the network is hidden.|
| securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| Security type.|
......@@ -389,8 +634,8 @@ Represents the WLAN configuration.
| randomMacAddr | string | Yes| No| Random MAC address.<br>**System API**: This is a system API.|
| ipType | [IpType](#iptype9) | Yes| No| IP address type.<br>**System API**: This is a system API.|
| staticIp | [IpConfig](#ipconfig9) | Yes| No| Static IP address configuration.<br>**System API**: This is a system API.|
| eapConfig<sup>9+</sup> | [WifiEapConfig](#wifieapconfig9) | Yes| No| EAP configuration.<br>**System API**: This is a system API.|
| eapConfig<sup>10+</sup> | [WifiEapConfig](#wifieapconfig10) | Yes| No| EAP configuration.|
| proxyConfig<sup>10+</sup> | WifiProxyConfig | Yes| No| Proxy configuration.<br>**System API**: This is a system API.|
## IpType<sup>9+</sup>
......@@ -425,18 +670,16 @@ Represents IP configuration information.
| domains | Array&lt;string&gt; | Yes| No| Domain information.|
## WifiEapConfig<sup>9+</sup>
## WifiEapConfig<sup>10+</sup>
Represents EAP configuration information.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA
| **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- |
| eapMethod | [EapMethod](#eapmethod9) | Yes| No| EAP authentication method.|
| phase2Method | [Phase2Method](#phase2method9) | Yes| No| Phase 2 authentication method.|
| eapMethod | [EapMethod](#eapmethod10) | Yes| No| EAP authentication method.|
| phase2Method | [Phase2Method](#phase2method10) | Yes| No| Phase 2 authentication method.|
| identity | string | Yes| No| Identity Information.|
| anonymousIdentity | string | Yes| No| Anonymous identity.|
| password | string | Yes| No| Password.|
......@@ -452,12 +695,10 @@ Represents EAP configuration information.
| eapSubId | number | Yes| No| Sub-ID of the SIM card.|
## EapMethod<sup>9+</sup>
## EapMethod<sup>10+</sup>
Enumerates the EAP authentication methods.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description|
......@@ -473,12 +714,10 @@ Enumerates the EAP authentication methods.
| EAP_UNAUTH_TLS | 8 | UNAUTH TLS.|
## Phase2Method<sup>9+</sup>
## Phase2Method<sup>10+</sup>
Enumerates the Phase 2 authentication methods.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description|
......@@ -493,7 +732,37 @@ Enumerates the Phase 2 authentication methods.
| PHASE2_AKA_PRIME | 7 | AKA Prime.|
## wifi.addDeviceConfig<sup>9+</sup>
## WifiProxyConfig <sup>10+</sup>
Represents the Wi-Fi proxy configuration.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA
| **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- |
| proxyMethod | ProxyMethod | Yes| No| Proxy method.|
| pacWebAddress | string | Yes| No| PAC web address of the proxy automatically configured.|
| serverHostName | string | Yes| No| Server host name of the proxy manually configured.|
| serverPort | string | Yes| No| Server port of the proxy manually configured.|
| exclusionObjects | string | Yes| No| Excluded objects of the manually configured proxy. Multiple objects are separated by commas (,).|
## ProxyMethod<sup>10+</sup>
Enumerates the Wi-Fi proxy methods.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description|
| -------- | -------- | -------- |
| METHOD_NONE | 0 | No proxy.|
| METHOD_AUTO | 1 | Use an automatically configured proxy.|
| METHOD_MANUAL | 2 | Use a manually configured proxy.|
## wifiManager.addDeviceConfig<sup>9+</sup>
addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;number&gt;): void
......@@ -539,7 +808,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.addCandidateConfig<sup>9+</sup>
## wifiManager.addCandidateConfig<sup>9+</sup>
addCandidateConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
......@@ -587,7 +856,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
`````
## wifi.addCandidateConfig<sup>9+</sup>
## wifiManager.addCandidateConfig<sup>9+</sup>
addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;number&gt;): void
......@@ -630,7 +899,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
`````
## wifi.removeCandidateConfig<sup>9+</sup>
## wifiManager.removeCandidateConfig<sup>9+</sup>
removeCandidateConfig(networkId: number): Promise&lt;void&gt;
......@@ -675,7 +944,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.removeCandidateConfig<sup>9+</sup>
## wifiManager.removeCandidateConfig<sup>9+</sup>
removeCandidateConfig(networkId: number, callback: AsyncCallback&lt;void&gt;): void
......@@ -714,7 +983,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.getCandidateConfigs<sup>9+</sup>
## wifiManager.getCandidateConfigs<sup>9+</sup>
getCandidateConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
......@@ -760,7 +1029,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
`````
## wifi.connectToCandidateConfig<sup>9+</sup>
## wifiManager.connectToCandidateConfig<sup>9+</sup>
connectToCandidateConfig(networkId: number): void
......@@ -799,7 +1068,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.connectToNetwork<sup>9+</sup>
## wifiManager.connectToNetwork<sup>9+</sup>
connectToNetwork(networkId: number): void
......@@ -839,7 +1108,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.connectToDevice<sup>9+</sup>
## wifiManager.connectToDevice<sup>9+</sup>
connectToDevice(config: WifiDeviceConfig): void
......@@ -884,7 +1153,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.disconnect<sup>9+</sup>
## wifiManager.disconnect<sup>9+</sup>
disconnect(): void
......@@ -916,7 +1185,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.getSignalLevel<sup>9+</sup>
## wifiManager.getSignalLevel<sup>9+</sup>
getSignalLevel(rssi: number, band: number): number
......@@ -962,7 +1231,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.getLinkedInfo<sup>9+</sup>
## wifiManager.getLinkedInfo<sup>9+</sup>
getLinkedInfo(): Promise&lt;WifiLinkedInfo&gt;
......@@ -987,7 +1256,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
## wifi.getLinkedInfo<sup>9+</sup>
## wifiManager.getLinkedInfo<sup>9+</sup>
getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void
......@@ -1103,7 +1372,7 @@ Enumerates the supplicant states.
| UNINITIALIZED | 10 | The supplicant failed to set up the connection.|
| INVALID | 11 | Invalid value.|
## wifi.isConnected<sup>9+</sup>
## wifiManager.isConnected<sup>9+</sup>
isConnected(): boolean
......@@ -1140,7 +1409,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.getSupportedFeatures<sup>9+</sup>
## wifiManager.getSupportedFeatures<sup>9+</sup>
getSupportedFeatures(): number
......@@ -1194,7 +1463,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.isFeatureSupported<sup>9+</sup>
## wifiManager.isFeatureSupported<sup>9+</sup>
isFeatureSupported(featureId: number): boolean
......@@ -1239,7 +1508,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.getDeviceMacAddress<sup>9+</sup>
## wifiManager.getDeviceMacAddress<sup>9+</sup>
getDeviceMacAddress(): string[]
......@@ -1278,7 +1547,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.getIpInfo<sup>9+</sup>
## wifiManager.getIpInfo<sup>9+</sup>
getIpInfo(): IpInfo
......@@ -1331,7 +1600,59 @@ Represents IP information.
| leaseDuration | number | Yes| No| Lease duration of the IP address.|
## wifi.getCountryCode<sup>9+</sup>
## wifiManager.getIpv6Info<sup>10+</sup>
getIpv6Info(): Ipv6Info
Obtains IP information.
**Required permissions**: ohos.permission.GET_WIFI_INFO
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Ipv6Info | IPv6 information obtained.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
| **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
**Example**
```js
import wifiManager from '@ohos.wifiManager';
try {
let info = wifiManager.getIpv6Info();
console.info("info:" + JSON.stringify(info));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## Ipv6Info <sup>10+</sup>
Represents the IPv6 information.
**System capability**: SystemCapability.Communication.WiFi.STA
| **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- |
| linkIpv6Address | string | Yes| No| IPv6 address of the link.|
| globalIpv6Address | string | Yes| No| Global IPv6 address.|
| randomGlobalIpv6Address | number | Yes| No| Random global IPv6 address.|
| gateway | string | Yes| No| Gateway IP address.|
| netmask | string | Yes| No| Subnet mask.|
| primaryDNS | string | Yes| No| IPv6 address of the preferred DNS server.|
| secondDNS | string | Yes| No| IPv6 address of the alternate DNS server.|
## wifiManager.getCountryCode<sup>9+</sup>
getCountryCode(): string
......@@ -1367,7 +1688,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.reassociate<sup>9+</sup>
## wifiManager.reassociate<sup>9+</sup>
reassociate(): void
......@@ -1399,7 +1720,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.reconnect<sup>9+</sup>
## wifiManager.reconnect<sup>9+</sup>
reconnect(): void
......@@ -1431,7 +1752,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.getDeviceConfigs<sup>9+</sup>
## wifiManager.getDeviceConfigs<sup>9+</sup>
getDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
......@@ -1469,9 +1790,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.updateDeviceConfig<sup>9+</sup>
## wifiManager.updateNetwork<sup>9+</sup>
updateDeviceConfig(config: WifiDeviceConfig): number
updateNetwork(config: WifiDeviceConfig): number
Updates network configuration.
......@@ -1511,16 +1832,16 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
preSharedKey : "****",
securityType : 3
}
let ret = wifiManager.updateDeviceConfig(config);
let ret = wifiManager.updateNetwork(config);
console.error("ret:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.disableDeviceConfig<sup>9+</sup>
## wifiManager.disableNetwork<sup>9+</sup>
disableDeviceConfig(networkId: number): void
disableNetwork(networkId: number): void
Disables network configuration.
......@@ -1550,15 +1871,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try {
let netId = 0;
wifiManager.disableDeviceConfig(netId);
wifiManager.disableNetwork(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.removeAllDeviceConfigs<sup>9+</sup>
## wifiManager.removeAllNetwork<sup>9+</sup>
removeAllDeviceConfigs(): void
removeAllNetwork(): void
Removes the configuration of all networks.
......@@ -1581,15 +1902,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
wifiManager.removeAllDeviceConfigs();
wifiManager.removeAllNetwork();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.removeDeviceConfig<sup>9+</sup>
## wifiManager.removeDevice<sup>9+</sup>
removeDeviceConfig(networkId: number): void
removeDevice(networkId: number): void
Removes the specified network configuration.
......@@ -1619,13 +1940,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try {
let id = 0;
wifiManager.removeDeviceConfig(id);
wifiManager.removeDevice(id);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.isBandTypeSupported<sup>10+</sup>
## wifiManager.isBandTypeSupported<sup>10+</sup>
isBandTypeSupported(bandType: WifiBandType): boolean
......@@ -1641,6 +1962,12 @@ Checks whether the current frequency band is supported.
| -------- | -------- | -------- | -------- |
| bandType | WifiBandType | Yes| Wi-Fi band type.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
......@@ -1662,7 +1989,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.get5GChannelList<sup>10+</sup>
## wifiManager.get5GChannelList<sup>10+</sup>
get5GChannelList(): Array&lt;number&gt;
......@@ -1674,6 +2001,12 @@ Obtains the list of 5 GHz channels supported by this device.
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;number&gt; | List of 5 GHz channels supported by the device.|
**Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
......@@ -1693,7 +2026,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getDisconnectedReason<sup>10+</sup>
## wifiManager.getDisconnectedReason<sup>10+</sup>
getDisconnectedReason(): DisconnectedReason
......@@ -1745,7 +2078,7 @@ Enumerates the Wi-Fi disconnection reasons.
| DISC_REASON_WRONG_PWD | 1 | Incorrect password.|
| DISC_REASON_CONNECTION_FULL | 2 | The number of connections to the router has reached the limit.|
## wifi.enableHotspot<sup>9+</sup>
## wifiManager.enableHotspot<sup>9+</sup>
enableHotspot(): void
......@@ -1776,7 +2109,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.disableHotspot<sup>9+</sup>
## wifiManager.disableHotspot<sup>9+</sup>
disableHotspot(): void
......@@ -1807,7 +2140,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.isHotspotDualBandSupported<sup>9+</sup>
## wifiManager.isHotspotDualBandSupported<sup>9+</sup>
isHotspotDualBandSupported(): boolean
......@@ -1845,7 +2178,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.isHotspotActive<sup>9+</sup>
## wifiManager.isHotspotActive<sup>9+</sup>
isHotspotActive(): boolean
......@@ -1883,7 +2216,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.setHotspotConfig<sup>9+</sup>
## wifiManager.setHotspotConfig<sup>9+</sup>
setHotspotConfig(config: HotspotConfig): void
......@@ -1946,7 +2279,7 @@ Represents the hotspot configuration.
| preSharedKey | string | Yes| Yes| PSK of the hotspot.|
| maxConn | number | Yes| Yes| Maximum number of connections allowed.|
## wifi.getHotspotConfig<sup>9+</sup>
## wifiManager.getHotspotConfig<sup>9+</sup>
getHotspotConfig(): HotspotConfig
......@@ -1984,9 +2317,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.getHotspotStations<sup>9+</sup>
## wifiManager.getStations<sup>9+</sup>
getHotspotStations(): &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt;
getStations(): &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt;
Obtains information about the connected stations.
......@@ -2015,7 +2348,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
let stations = wifiManager.getHotspotStations();
let stations = wifiManager.getStations();
console.info("result:" + JSON.stringify(stations));
}catch(error){
console.error("failed:" + JSON.stringify(error));
......@@ -2034,10 +2367,11 @@ Represents the station information.
| -------- | -------- | -------- | -------- | -------- |
| name | string | Yes| No| Device name.|
| macAddress | string | Yes| No| MAC address.|
| macAddressType<sup>10+</sup> | DeviceAddressType | Yes| No| MAC address type.|
| ipAddress | string | Yes| No| IP address.|
## wifi.getP2pLinkedInfo<sup>9+</sup>
## wifiManager.getP2pLinkedInfo<sup>9+</sup>
getP2pLinkedInfo(): Promise&lt;WifiP2pLinkedInfo&gt;
......@@ -2104,7 +2438,7 @@ Enumerates the P2P connection states.
| CONNECTED | 1 | Connected.|
## wifi.getP2pLinkedInfo<sup>9+</sup>
## wifiManager.getP2pLinkedInfo<sup>9+</sup>
getP2pLinkedInfo(callback: AsyncCallback&lt;WifiP2pLinkedInfo&gt;): void
......@@ -2121,7 +2455,7 @@ Obtains P2P link information. This API uses an asynchronous callback to return t
| callback | AsyncCallback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | 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.|
## wifi.getCurrentP2pGroup<sup>9+</sup>
## wifiManager.getCurrentP2pGroup<sup>9+</sup>
getCurrentP2pGroup(): Promise&lt;WifiP2pGroupInfo&gt;
......@@ -2145,7 +2479,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getCurrentP2pGroup<sup>9+</sup>
## wifiManager.getCurrentP2pGroup<sup>9+</sup>
getCurrentP2pGroup(callback: AsyncCallback&lt;WifiP2pGroupInfo&gt;): void
......@@ -2186,7 +2520,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
});
```
## wifi.getP2pPeerDevices<sup>9+</sup>
## wifiManager.getP2pPeerDevices<sup>9+</sup>
getP2pPeerDevices(): Promise&lt;WifiP2pDevice[]&gt;
......@@ -2210,7 +2544,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup>
## wifiManager.getP2pPeerDevices<sup>9+</sup>
getP2pPeerDevices(callback: AsyncCallback&lt;WifiP2pDevice[]&gt;): void
......@@ -2261,6 +2595,7 @@ Represents the P2P device information.
| -------- | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| No| Device name.|
| deviceAddress | string | Yes| No| MAC address of the device.|
| deviceAddressType<sup>10+</sup> | DeviceAddressType | Yes| No| MAC address type of the device.|
| primaryDeviceType | string | Yes| No| Type of the primary device.|
| deviceStatus | [P2pDeviceStatus](#p2pdevicestatus9) | Yes| No| Device status.|
| groupCapabilities | number | Yes| No| Group capabilities.|
......@@ -2281,7 +2616,7 @@ Enumerates the P2P device states.
| UNAVAILABLE | 4 | Unavailable.|
## wifi.getP2pLocalDevice<sup>9+</sup>
## wifiManager.getP2pLocalDevice<sup>9+</sup>
getP2pLocalDevice(): Promise&lt;WifiP2pDevice&gt;
......@@ -2305,7 +2640,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.getP2pLocalDevice<sup>9+</sup>
## wifiManager.getP2pLocalDevice<sup>9+</sup>
getP2pLocalDevice(callback: AsyncCallback&lt;WifiP2pDevice&gt;): void
......@@ -2344,9 +2679,9 @@ Obtains the local device information in the P2P connection. This API uses an asy
});
```
## wifi.createP2pGroup<sup>9+</sup>
## wifiManager.createGroup<sup>9+</sup>
createP2pGroup(config: WifiP2PConfig): void
createGroup(config: WifiP2PConfig): void
Creates a P2P group.
......@@ -2380,7 +2715,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
groupName: "****",
goBand: 0
}
wifiManager.createP2pGroup(config);
wifiManager.createGroup(config);
}catch(error){
console.error("failed:" + JSON.stringify(error));
......@@ -2396,6 +2731,7 @@ Represents P2P group configuration.
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| deviceAddress | string | Yes| No| Device address.|
| deviceAddressType<sup>10+</sup>| DeviceAddressType | Yes| No| Device address type.|
| netId | number | Yes| No| Network ID. The value **-1** indicates a temporary group, and **-2** indicates a persistent group.|
| passphrase | string | Yes| No| Passphrase of the group.|
| groupName | string | Yes| No| Name of the group.|
......@@ -2415,9 +2751,9 @@ Enumerates the P2P group frequency bands.
| GO_BAND_5GHZ | 2 | 5 GHz.|
## wifi.removeP2pGroup<sup>9+</sup>
## wifiManager.removeGroup<sup>9+</sup>
removeP2pGroup(): void
removeGroup(): void
Removes this P2P group.
......@@ -2438,13 +2774,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
wifiManager.removeP2pGroup();
wifiManager.removeGroup();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.p2pConnect<sup>9+</sup>
## wifiManager.p2pConnect<sup>9+</sup>
p2pConnect(config: WifiP2PConfig): void
......@@ -2535,7 +2871,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("start discover devices -> " + wifiManager.startDiscoverP2pDevices());
```
## wifi.p2pCancelConnect<sup>9+</sup>
## wifiManager.p2pCancelConnect<sup>9+</sup>
p2pCancelConnect(): void
......@@ -2564,9 +2900,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
}
```
## wifi.startDiscoverP2pDevices<sup>9+</sup>
## wifiManager.startDiscoverDevices<sup>10+</sup>
startDiscoverP2pDevices(): void
startDiscoverDevices(): void
Starts to discover devices.
......@@ -2587,15 +2923,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
wifiManager.startDiscoverP2pDevices();
wifiManager.startDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.stopDiscoverP2pDevices<sup>9+</sup>
## wifiManager.stopDiscoverDevices<sup>10+</sup>
stopDiscoverP2pDevices(): void
stopDiscoverDevices(): void
Stops discovering devices.
......@@ -2616,15 +2952,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
try {
wifiManager.stopDiscoverP2pDevices();
wifiManager.stopDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.deletePersistentP2pGroup<sup>9+</sup>
## wifiManager.deletePersistentGroup<sup>9+</sup>
deletePersistentP2pGroup(netId: number): void
deletePersistentGroup(netId: number): void
Deletes a persistent group.
......@@ -2655,13 +2991,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try {
let netId = 0;
wifiManager.deletePersistentP2pGroup(netId);
wifiManager.deletePersistentGroup(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getP2pGroups<sup>9+</sup>
## wifiManager.getP2pGroups<sup>9+</sup>
getP2pGroups(): Promise&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;
......@@ -2724,7 +3060,7 @@ Represents the P2P group information.
| goIpAddress | string | Yes| No| IP address of the group.|
## wifi.getP2pGroups<sup>9+</sup>
## wifiManager.getP2pGroups<sup>9+</sup>
getP2pGroups(callback: AsyncCallback&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;): void
......@@ -2750,9 +3086,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.setP2pDeviceName<sup>9+</sup>
## wifiManager.setDeviceName<sup>9+</sup>
setP2pDeviceName(devName: string): void
setDeviceName(devName: string): void
Sets the device name.
......@@ -2782,13 +3118,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try {
let name = "****";
wifiManager.setP2pDeviceName(name);
wifiManager.setDeviceName(name);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.on('wifiStateChange')<sup>9+</sup>
## wifiManager.on('wifiStateChange')<sup>9+</sup>
on(type: "wifiStateChange", callback: Callback&lt;number&gt;): void
......@@ -2823,7 +3159,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| 3 | Deactivating|
## wifi.off('wifiStateChange')<sup>9+</sup>
## wifiManager.off('wifiStateChange')<sup>9+</sup>
off(type: "wifiStateChange", callback?: Callback&lt;number&gt;): void
......@@ -2864,7 +3200,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
```
## wifi.on('wifiConnectionChange')<sup>9+</sup>
## wifiManager.on('wifiConnectionChange')<sup>9+</sup>
on(type: "wifiConnectionChange", callback: Callback&lt;number&gt;): void
......@@ -2896,7 +3232,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiConnectionChange')<sup>9+</sup>
## wifiManager.off('wifiConnectionChange')<sup>9+</sup>
off(type: "wifiConnectionChange", callback?: Callback&lt;number&gt;): void
......@@ -2936,7 +3272,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("wifiConnectionChange", recvWifiConnectionChangeFunc);
```
## wifi.on('wifiScanStateChange')<sup>9+</sup>
## wifiManager.on('wifiScanStateChange')<sup>9+</sup>
on(type: "wifiScanStateChange", callback: Callback&lt;number&gt;): void
......@@ -2968,7 +3304,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiScanStateChange')<sup>9+</sup>
## wifiManager.off('wifiScanStateChange')<sup>9+</sup>
off(type: "wifiScanStateChange", callback?: Callback&lt;number&gt;): void
......@@ -3008,7 +3344,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("wifiScanStateChange", recvWifiScanStateChangeFunc);
```
## wifi.on('wifiRssiChange')<sup>9+</sup>
## wifiManager.on('wifiRssiChange')<sup>9+</sup>
on(type: "wifiRssiChange", callback: Callback&lt;number&gt;): void
......@@ -3033,7 +3369,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.off('wifiRssiChange')<sup>9+</sup>
## wifiManager.off('wifiRssiChange')<sup>9+</sup>
off(type: "wifiRssiChange", callback?: Callback&lt;number&gt;): void
......@@ -3073,7 +3409,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("wifiRssiChange", recvWifiRssiChangeFunc);
```
## wifi.on('hotspotStateChange')<sup>9+</sup>
## wifiManager.on('hotspotStateChange')<sup>9+</sup>
on(type: "hotspotStateChange", callback: Callback&lt;number&gt;): void
......@@ -3107,7 +3443,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2601000 | Operation failed.|
## wifi.off('hotspotStateChange')<sup>9+</sup>
## wifiManager.off('hotspotStateChange')<sup>9+</sup>
off(type: "hotspotStateChange", callback?: Callback&lt;number&gt;): void
......@@ -3147,7 +3483,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("hotspotStateChange", recvHotspotStateChangeFunc);
```
## wifi.on('p2pStateChange')<sup>9+</sup>
## wifiManager.on('p2pStateChange')<sup>9+</sup>
on(type: "p2pStateChange", callback: Callback&lt;number&gt;): void
......@@ -3182,7 +3518,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pStateChange')<sup>9+</sup>
## wifiManager.off('p2pStateChange')<sup>9+</sup>
off(type: "p2pStateChange", callback?: Callback&lt;number&gt;): void
......@@ -3222,7 +3558,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pStateChange", recvP2pStateChangeFunc);
```
## wifi.on('p2pConnectionChange')<sup>9+</sup>
## wifiManager.on('p2pConnectionChange')<sup>9+</sup>
on(type: "p2pConnectionChange", callback: Callback&lt;WifiP2pLinkedInfo&gt;): void
......@@ -3247,7 +3583,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pConnectionChange')<sup>9+</sup>
## wifiManager.off('p2pConnectionChange')<sup>9+</sup>
off(type: "p2pConnectionChange", callback?: Callback&lt;WifiP2pLinkedInfo&gt;): void
......@@ -3287,7 +3623,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pConnectionChange", recvP2pConnectionChangeFunc);
```
## wifi.on('p2pDeviceChange')<sup>9+</sup>
## wifiManager.on('p2pDeviceChange')<sup>9+</sup>
on(type: "p2pDeviceChange", callback: Callback&lt;WifiP2pDevice&gt;): void
......@@ -3312,7 +3648,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pDeviceChange')<sup>9+</sup>
## wifiManager.off('p2pDeviceChange')<sup>9+</sup>
off(type: "p2pDeviceChange", callback?: Callback&lt;WifiP2pDevice&gt;): void
......@@ -3342,7 +3678,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
var recvP2pDeviceChangeFunc = result => {
console.info("Receive recv p2p device change event: " + result);
console.info("Receive p2p device change event: " + result);
}
// Register an event.
......@@ -3352,7 +3688,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pDeviceChange", recvP2pDeviceChangeFunc);
```
## wifi.on('p2pPeerDeviceChange')<sup>9+</sup>
## wifiManager.on('p2pPeerDeviceChange')<sup>9+</sup>
on(type: "p2pPeerDeviceChange", callback: Callback&lt;WifiP2pDevice[]&gt;): void
......@@ -3377,7 +3713,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pPeerDeviceChange')<sup>9+</sup>
## wifiManager.off('p2pPeerDeviceChange')<sup>9+</sup>
off(type: "p2pPeerDeviceChange", callback?: Callback&lt;WifiP2pDevice[]&gt;): void
......@@ -3407,7 +3743,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
var recvP2pPeerDeviceChangeFunc = result => {
console.info("Receive recv p2p peer device change event: " + result);
console.info("Receive p2p peer device change event: " + result);
}
// Register an event.
......@@ -3417,7 +3753,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);
```
## wifi.on('p2pPersistentGroupChange')<sup>9+</sup>
## wifiManager.on('p2pPersistentGroupChange')<sup>9</sup>
on(type: "p2pPersistentGroupChange", callback: Callback&lt;void&gt;): void
......@@ -3442,7 +3778,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pPersistentGroupChange')<sup>9+</sup>
## wifiManager.off('p2pPersistentGroupChange')<sup>9</sup>
off(type: "p2pPersistentGroupChange", callback?: Callback&lt;void&gt;): void
......@@ -3472,7 +3808,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
var recvP2pPersistentGroupChangeFunc = result => {
console.info("Receive recv p2p persistent group change event: " + result);
console.info("Receive p2p persistent group change event: " + result);
}
// Register an event.
......@@ -3482,7 +3818,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);
```
## wifi.on('p2pDiscoveryChange')<sup>9+</sup>
## wifiManager.on('p2pDiscoveryChange')<sup>9+</sup>
on(type: "p2pDiscoveryChange", callback: Callback&lt;number&gt;): void
......@@ -3514,7 +3850,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.off('p2pDiscoveryChange')<sup>9+</sup>
## wifiManager.off('p2pDiscoveryChange')<sup>9+</sup>
off(type: "p2pDiscoveryChange", callback?: Callback&lt;number&gt;): void
......@@ -3544,7 +3880,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager';
var recvP2pDiscoveryChangeFunc = result => {
console.info("Receive recv p2p discovery change event: " + result);
console.info("Receive p2p discovery change event: " + result);
}
// Register an event.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部