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

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 dd816222
...@@ -27,9 +27,9 @@ Enables WLAN. ...@@ -27,9 +27,9 @@ Enables WLAN.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -57,9 +57,9 @@ Disables WLAN. ...@@ -57,9 +57,9 @@ Disables WLAN.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -86,9 +86,9 @@ Checks whether WLAN is enabled. ...@@ -86,9 +86,9 @@ Checks whether WLAN is enabled.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.| | boolean | Returns **true** if WLAN is enabled; returns **false** otherwise.|
**Example** **Example**
...@@ -96,8 +96,8 @@ Checks whether WLAN is enabled. ...@@ -96,8 +96,8 @@ Checks whether WLAN is enabled.
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
try { try {
let isActivate = wifi.isActivate(); let isWifiActive = wifi.isWifiActive();
console.info("isActivate:" + isActivate); console.info("isWifiActive:" + isWifiActive);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
...@@ -115,9 +115,9 @@ Starts a scan for WLAN. ...@@ -115,9 +115,9 @@ Starts a scan for WLAN.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -143,9 +143,9 @@ Obtains the scan result. This API uses a promise to return the result. ...@@ -143,9 +143,9 @@ Obtains the scan result. This API uses a promise to return the result.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the detected hotspots.| | Promise&lt;&nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt;&nbsp;&gt; | Promise used to return the detected hotspots.|
## wifi.getScanInfos ## wifi.getScanInfos
...@@ -160,9 +160,9 @@ Obtains the scan result. This API uses an asynchronous callback to return the re ...@@ -160,9 +160,9 @@ Obtains the scan result. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **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.| | 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** **Example**
...@@ -258,15 +258,15 @@ Adds network configuration. This API uses a promise to return the result. ...@@ -258,15 +258,15 @@ Adds network configuration. This API uses a promise to return the result.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
**Return value** **Return value**
| **Type**| **Description**| | **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.| | Promise&lt;number&gt; | Promise used to return the WLAN configuration ID. If **-1** is returned, the network configuration fails to be added.|
**Example** **Example**
...@@ -356,10 +356,10 @@ Adds network configuration. This API uses an asynchronous callback to return the ...@@ -356,10 +356,10 @@ Adds network configuration. This API uses an asynchronous callback to return the
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| | 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.| | 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** **Example**
...@@ -391,15 +391,15 @@ Adds the configuration of an untrusted network. This API uses a promise to retur ...@@ -391,15 +391,15 @@ Adds the configuration of an untrusted network. This API uses a promise to retur
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.| | Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
**Example** **Example**
```js ```js
...@@ -431,10 +431,10 @@ Adds the configuration of an untrusted network. This API uses an asynchronous ca ...@@ -431,10 +431,10 @@ Adds the configuration of an untrusted network. This API uses an asynchronous ca
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to add.| | 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.| | 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** **Example**
```js ```js
...@@ -466,15 +466,15 @@ Removes the configuration of an untrusted network. This API uses a promise to re ...@@ -466,15 +466,15 @@ Removes the configuration of an untrusted network. This API uses a promise to re
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.| | Promise&lt;boolean&gt; | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
**Example** **Example**
...@@ -504,10 +504,10 @@ Removes the configuration of an untrusted network. This API uses an asynchronous ...@@ -504,10 +504,10 @@ Removes the configuration of an untrusted network. This API uses an asynchronous
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration to remove.| | 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** **Example**
```js ```js
...@@ -537,15 +537,15 @@ Connects to the specified network. ...@@ -537,15 +537,15 @@ Connects to the specified network.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| Network configuration ID.| | networkId | number | Yes| Network configuration ID.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -569,21 +569,21 @@ Connects to the specified network. ...@@ -569,21 +569,21 @@ Connects to the specified network.
**System API**: This is a system API. **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) **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**: **System capability**:
SystemCapability.Communication.WiFi.STA SystemCapability.Communication.WiFi.STA
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| WLAN configuration.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -617,9 +617,9 @@ Disconnects the network. ...@@ -617,9 +617,9 @@ Disconnects the network.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -644,16 +644,16 @@ Obtains the WLAN signal level. ...@@ -644,16 +644,16 @@ Obtains the WLAN signal level.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| rssi | number | Yes| RSSI of the hotspot, in dBm.| | rssi | number | Yes| RSSI of the hotspot, in dBm.|
| band | number | Yes| Frequency band of the WLAN AP.| | band | number | Yes| Frequency band of the WLAN AP.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| number | Signal level obtained. The value range is [0, 4].| | number | Signal level obtained. The value range is [0, 4].|
**Example** **Example**
```js ```js
...@@ -682,9 +682,9 @@ Obtains WLAN connection information. This API uses a promise to return the resul ...@@ -682,9 +682,9 @@ Obtains WLAN connection information. This API uses a promise to return the resul
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Promise used to return the WLAN connection information.| | Promise&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Promise used to return the WLAN connection information.|
## wifi.getLinkedInfo ## wifi.getLinkedInfo
...@@ -699,9 +699,9 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r ...@@ -699,9 +699,9 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
```js ```js
...@@ -802,9 +802,9 @@ Checks whether the WLAN is connected. ...@@ -802,9 +802,9 @@ Checks whether the WLAN is connected.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.| | boolean | Returns **true** if the WLAN is connected; returns **false** otherwise.|
## wifi.getSupportedFeatures<sup>7+</sup> ## wifi.getSupportedFeatures<sup>7+</sup>
...@@ -821,9 +821,9 @@ Obtains the features supported by this device. ...@@ -821,9 +821,9 @@ Obtains the features supported by this device.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| number | Feature value. | | number | Feature value. |
**Feature IDs** **Feature IDs**
...@@ -854,15 +854,15 @@ Checks whether the device supports the specified WLAN feature. ...@@ -854,15 +854,15 @@ Checks whether the device supports the specified WLAN feature.
**Parameters** **Parameters**
| **Name**| **Type**| Mandatory| **Description**| | **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| featureId | number | Yes| Feature ID.| | featureId | number | Yes| Feature ID.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| | boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -892,9 +892,9 @@ Obtains the device MAC address. ...@@ -892,9 +892,9 @@ Obtains the device MAC address.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| string[] | MAC address obtained.| | string[] | MAC address obtained.|
**Example** **Example**
```js ```js
...@@ -921,9 +921,9 @@ Obtains IP information. ...@@ -921,9 +921,9 @@ Obtains IP information.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| [IpInfo](#ipinfo7) | IP information obtained.| | [IpInfo](#ipinfo7) | IP information obtained.|
**Example** **Example**
```js ```js
...@@ -966,9 +966,9 @@ Obtains the country code. ...@@ -966,9 +966,9 @@ Obtains the country code.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| string | Country code obtained.| | string | Country code obtained.|
**Example** **Example**
```js ```js
...@@ -996,9 +996,9 @@ Re-associates with the network. ...@@ -996,9 +996,9 @@ Re-associates with the network.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1025,9 +1025,9 @@ Reconnects to the network. ...@@ -1025,9 +1025,9 @@ Reconnects to the network.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1054,9 +1054,9 @@ Obtains network configuration. ...@@ -1054,9 +1054,9 @@ Obtains network configuration.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Array of network configuration obtained.| | &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Array of network configuration obtained.|
**Example** **Example**
```js ```js
...@@ -1084,15 +1084,15 @@ Updates network configuration. ...@@ -1084,15 +1084,15 @@ Updates network configuration.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiDeviceConfig](#wifideviceconfig) | Yes| New WLAN configuration.| | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| New WLAN configuration.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.| | number | ID of the updated network configuration. The value **-1** indicates that the operation has failed.|
**Example** **Example**
```js ```js
...@@ -1125,15 +1125,15 @@ Disables network configuration. ...@@ -1125,15 +1125,15 @@ Disables network configuration.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the network configuration to disable.| | netId | number | Yes| ID of the network configuration to disable.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1161,9 +1161,9 @@ Removes the configuration of all networks. ...@@ -1161,9 +1161,9 @@ Removes the configuration of all networks.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1190,15 +1190,15 @@ Removes the specified network configuration. ...@@ -1190,15 +1190,15 @@ Removes the specified network configuration.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| id | number | Yes| ID of the network configuration to remove.| | id | number | Yes| ID of the network configuration to remove.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1226,9 +1226,9 @@ Enables this hotspot. ...@@ -1226,9 +1226,9 @@ Enables this hotspot.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1255,9 +1255,9 @@ Disables this hotspot. ...@@ -1255,9 +1255,9 @@ Disables this hotspot.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1284,9 +1284,9 @@ Checks whether the hotspot supports dual band. ...@@ -1284,9 +1284,9 @@ Checks whether the hotspot supports dual band.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.| | boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1314,9 +1314,9 @@ Checks whether this hotspot is active. ...@@ -1314,9 +1314,9 @@ Checks whether this hotspot is active.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the hotspot is active; returns **false** otherwise.| | boolean | Returns **true** if the hotspot is active; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1344,15 +1344,15 @@ Sets hotspot configuration. ...@@ -1344,15 +1344,15 @@ Sets hotspot configuration.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [HotspotConfig](#hotspotconfig7) | Yes| Hotspot configuration to set.| | config | [HotspotConfig](#hotspotconfig7) | Yes| Hotspot configuration to set.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1405,9 +1405,9 @@ obtains hotspot configuration. ...@@ -1405,9 +1405,9 @@ obtains hotspot configuration.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| [HotspotConfig](#hotspotconfig7) | Hotspot configuration obtained.| | [HotspotConfig](#hotspotconfig7) | Hotspot configuration obtained.|
**Example** **Example**
```js ```js
...@@ -1435,9 +1435,9 @@ Obtains information about the connected stations. ...@@ -1435,9 +1435,9 @@ Obtains information about the connected stations.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt; | Connected stations obtained.| | &nbsp;Array&lt;[StationInfo](#stationinfo7)&gt; | Connected stations obtained.|
**Example** **Example**
```js ```js
...@@ -1478,9 +1478,9 @@ Obtains P2P link information. This API uses a promise to return the result. ...@@ -1478,9 +1478,9 @@ Obtains P2P link information. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | Promise used to return the P2P link information obtained.| | 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 ...@@ -1521,9 +1521,9 @@ Obtains P2P link information. This API uses an asynchronous callback to return t
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
```js ```js
...@@ -1554,9 +1554,9 @@ Obtains the current P2P group information. This API uses a promise to return the ...@@ -1554,9 +1554,9 @@ Obtains the current P2P group information. This API uses a promise to return the
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo8)&gt; | Promise used to return the P2P group information obtained.| | Promise&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo8)&gt; | Promise used to return the P2P group information obtained.|
## wifi.getCurrentGroup<sup>8+</sup> ## wifi.getCurrentGroup<sup>8+</sup>
...@@ -1571,9 +1571,9 @@ Obtains the current P2P group information. This API uses an asynchronous callbac ...@@ -1571,9 +1571,9 @@ Obtains the current P2P group information. This API uses an asynchronous callbac
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
```js ```js
...@@ -1604,9 +1604,9 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r ...@@ -1604,9 +1604,9 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | Promise used to return the peer device list.| | Promise&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | Promise used to return the peer device list.|
## wifi.getP2pPeerDevices<sup>8+</sup> ## wifi.getP2pPeerDevices<sup>8+</sup>
...@@ -1621,9 +1621,9 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou ...@@ -1621,9 +1621,9 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | 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.| | 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** **Example**
```js ```js
...@@ -1684,15 +1684,15 @@ Creates a P2P group. ...@@ -1684,15 +1684,15 @@ Creates a P2P group.
**Parameters** **Parameters**
| **Name**| **Type**| Mandatory| **Description**| | **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| Group configuration.| | config | [WifiP2PConfig](#wifip2pconfig8) | Yes| Group configuration.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1753,9 +1753,9 @@ Removes this P2P group. ...@@ -1753,9 +1753,9 @@ Removes this P2P group.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1781,15 +1781,15 @@ Sets up a P2P connection. ...@@ -1781,15 +1781,15 @@ Sets up a P2P connection.
**Parameters** **Parameters**
| **Name**| **Type**| Mandatory| **Description**| | **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig8) | Yes| P2P group configuration.| | config | [WifiP2PConfig](#wifip2pconfig8) | Yes| P2P group configuration.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
...@@ -1871,9 +1871,9 @@ Cancels this P2P connection. ...@@ -1871,9 +1871,9 @@ Cancels this P2P connection.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1898,9 +1898,9 @@ Starts to discover devices. ...@@ -1898,9 +1898,9 @@ Starts to discover devices.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1925,9 +1925,9 @@ Stops discovering devices. ...@@ -1925,9 +1925,9 @@ Stops discovering devices.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -1955,15 +1955,15 @@ Deletes a persistent group. ...@@ -1955,15 +1955,15 @@ Deletes a persistent group.
**Parameters** **Parameters**
| **Name**| **Type**| Mandatory| **Description**| | **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| netId | number | Yes| ID of the group to delete.| | netId | number | Yes| ID of the group to delete.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -2010,15 +2010,15 @@ Sets the device name. ...@@ -2010,15 +2010,15 @@ Sets the device name.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| devName | string | Yes| Device name to set.| | devName | string | Yes| Device name to set.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.| | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Example** **Example**
```js ```js
...@@ -2044,10 +2044,10 @@ Registers the WLAN state change events. ...@@ -2044,10 +2044,10 @@ Registers the WLAN state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiStateChange**.| | type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN state.|
**WLAN states** **WLAN states**
...@@ -2071,10 +2071,10 @@ Unregisters the WLAN state change events. ...@@ -2071,10 +2071,10 @@ Unregisters the WLAN state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiStateChange**.| | 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.| | 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** **Example**
```js ```js
...@@ -2104,10 +2104,10 @@ Registers the WLAN connection state change events. ...@@ -2104,10 +2104,10 @@ Registers the WLAN connection state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiConnectionChange**.| | type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN connection state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN connection state.|
**WLAN connection states** **WLAN connection states**
...@@ -2129,10 +2129,10 @@ Unregisters the WLAN connection state change events. ...@@ -2129,10 +2129,10 @@ Unregisters the WLAN connection state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiConnectionChange**.| | 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.| | 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** **Example**
```js ```js
...@@ -2161,10 +2161,10 @@ Registers the WLAN scan state change events. ...@@ -2161,10 +2161,10 @@ Registers the WLAN scan state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiScanStateChange**.| | type | string | Yes| Event type. The value is **wifiScanStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN scan state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the WLAN scan state.|
**WLAN scan states** **WLAN scan states**
...@@ -2218,10 +2218,10 @@ Registers the RSSI change events. ...@@ -2218,10 +2218,10 @@ Registers the RSSI change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiRssiChange**.| | type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the RSSI, in dBm.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the RSSI, in dBm.|
## wifi.off('wifiRssiChange')<sup>7+</sup> ## wifi.off('wifiRssiChange')<sup>7+</sup>
...@@ -2236,9 +2236,9 @@ Unregisters the RSSI change events. ...@@ -2236,9 +2236,9 @@ Unregisters the RSSI change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **wifiRssiChange**.| | 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.| | 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** **Example**
...@@ -2254,7 +2254,58 @@ wifi.on("wifiRssiChange", recvWifiRssiChangeFunc); ...@@ -2254,7 +2254,58 @@ wifi.on("wifiRssiChange", recvWifiRssiChangeFunc);
// Unregister an event. // Unregister an event.
wifi.off("wifiRssiChange", recvWifiRssiChangeFunc); 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> ## wifi.on('hotspotStateChange')<sup>7+</sup>
on(type: "hotspotStateChange", callback: Callback&lt;number&gt;): void on(type: "hotspotStateChange", callback: Callback&lt;number&gt;): void
...@@ -2267,10 +2318,10 @@ Registers the hotspot state change events. ...@@ -2267,10 +2318,10 @@ Registers the hotspot state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStateChange**.| | type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the hotspot state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the hotspot state.|
**Hotspot states** **Hotspot states**
...@@ -2308,11 +2359,110 @@ Unregisters the hotspot state change events. ...@@ -2308,11 +2359,110 @@ Unregisters the hotspot state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **hotspotStateChange**.| | 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.| | 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> ## wifi.on('p2pStateChange')<sup>8+</sup>
...@@ -2326,10 +2476,10 @@ Registers the P2P state change events. ...@@ -2326,10 +2476,10 @@ Registers the P2P state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pStateChange**.| | type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P state.|
**P2P states** **P2P states**
...@@ -2353,9 +2503,9 @@ Unregisters the P2P state change events. ...@@ -2353,9 +2503,9 @@ Unregisters the P2P state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pStateChange**.| | 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.| | 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** **Example**
...@@ -2373,7 +2523,7 @@ wifi.on("p2pStateChange", recvP2pStateChangeFunc); ...@@ -2373,7 +2523,7 @@ wifi.on("p2pStateChange", recvP2pStateChangeFunc);
wifi.off("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 on(type: "p2pConnectionChange", callback: Callback&lt;WifiP2pLinkedInfo&gt;): void
...@@ -2385,10 +2535,10 @@ Registers the P2P connection state change events. ...@@ -2385,10 +2535,10 @@ Registers the P2P connection state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pConnectionChange**.| | type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | Yes| Callback invoked to return the P2P connection state.| | callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | Yes| Callback invoked to return the P2P connection state.|
## wifi.off('p2pConnectionChange')<sup>8+</sup> ## wifi.off('p2pConnectionChange')<sup>8+</sup>
...@@ -2403,9 +2553,9 @@ Unregisters the P2P connection state change events. ...@@ -2403,9 +2553,9 @@ Unregisters the P2P connection state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pConnectionChange**.| | 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.| | 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** **Example**
...@@ -2435,10 +2585,10 @@ Registers the P2P device state change events. ...@@ -2435,10 +2585,10 @@ Registers the P2P device state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDeviceChange**.| | type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | Yes| Callback invoked to return the P2P device state.| | callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | Yes| Callback invoked to return the P2P device state.|
## wifi.off('p2pDeviceChange')<sup>8+</sup> ## wifi.off('p2pDeviceChange')<sup>8+</sup>
...@@ -2453,9 +2603,9 @@ Unregisters the P2P device state change events. ...@@ -2453,9 +2603,9 @@ Unregisters the P2P device state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDeviceChange**.| | 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.| | 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** **Example**
...@@ -2463,7 +2613,7 @@ Unregisters the P2P device state change events. ...@@ -2463,7 +2613,7 @@ Unregisters the P2P device state change events.
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
var recvP2pDeviceChangeFunc = result => { var recvP2pDeviceChangeFunc = result => {
console.info("Receive recv p2p device change event: " + result); console.info("Receive p2p device change event: " + result);
} }
// Register an event. // Register an event.
...@@ -2485,9 +2635,9 @@ Registers the P2P peer device state change events. ...@@ -2485,9 +2635,9 @@ Registers the P2P peer device state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| | 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.| | 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. ...@@ -2503,9 +2653,9 @@ Unregisters the P2P peer device state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.| | 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.| | 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** **Example**
...@@ -2513,7 +2663,7 @@ Unregisters the P2P peer device state change events. ...@@ -2513,7 +2663,7 @@ Unregisters the P2P peer device state change events.
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
var recvP2pPeerDeviceChangeFunc = result => { 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. // Register an event.
...@@ -2535,10 +2685,10 @@ Registers the P2P persistent group state change events. ...@@ -2535,10 +2685,10 @@ Registers the P2P persistent group state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| | type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.|
| callback | Callback&lt;void&gt; | Yes| Callback invoked to return the P2P persistent group state.| | callback | Callback&lt;void&gt; | Yes| Callback invoked to return the P2P persistent group state.|
## wifi.off('p2pPersistentGroupChange')<sup>8+</sup> ## wifi.off('p2pPersistentGroupChange')<sup>8+</sup>
...@@ -2553,9 +2703,9 @@ Unregisters the P2P persistent group state change events. ...@@ -2553,9 +2703,9 @@ Unregisters the P2P persistent group state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pPersistentGroupChange**.| | 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.| | 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** **Example**
...@@ -2563,7 +2713,7 @@ Unregisters the P2P persistent group state change events. ...@@ -2563,7 +2713,7 @@ Unregisters the P2P persistent group state change events.
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
var recvP2pPersistentGroupChangeFunc = result => { 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. // Register an event.
...@@ -2586,10 +2736,10 @@ Registers the P2P device discovery state change events. ...@@ -2586,10 +2736,10 @@ Registers the P2P device discovery state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| | type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P device discovery state.| | callback | Callback&lt;number&gt; | Yes| Callback invoked to return the P2P device discovery state.|
**P2P discovered device states** **P2P discovered device states**
...@@ -2611,9 +2761,9 @@ Unregisters the P2P device discovery state change events. ...@@ -2611,9 +2761,9 @@ Unregisters the P2P device discovery state change events.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.| | 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.| | 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** **Example**
...@@ -2621,7 +2771,7 @@ Unregisters the P2P device discovery state change events. ...@@ -2621,7 +2771,7 @@ Unregisters the P2P device discovery state change events.
import wifi from '@ohos.wifi'; import wifi from '@ohos.wifi';
var recvP2pDiscoveryChangeFunc = result => { var recvP2pDiscoveryChangeFunc = result => {
console.info("Receive recv p2p discovery change event: " + result); console.info("Receive p2p discovery change event: " + result);
} }
// Register an event. // Register an event.
......
...@@ -11,7 +11,7 @@ The **WLAN** module provides basic wireless local area network (WLAN) functions, ...@@ -11,7 +11,7 @@ The **WLAN** module provides basic wireless local area network (WLAN) functions,
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
``` ```
## wifi.enableWifi<sup>9+</sup> ## wifiManager.enableWifi<sup>9+</sup>
enableWifi(): void enableWifi(): void
...@@ -23,12 +23,6 @@ Enables WLAN. ...@@ -23,12 +23,6 @@ Enables WLAN.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes** **Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). 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 ...@@ -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 disableWifi(): void
...@@ -61,12 +55,6 @@ Disables WLAN. ...@@ -61,12 +55,6 @@ Disables WLAN.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
**Error codes** **Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). 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 ...@@ -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 isWifiActive(): boolean
...@@ -117,14 +105,14 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -117,14 +105,14 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let isActivate = wifiManager.isActivate(); let isWifiActive = wifiManager.isWifiActive();
console.info("isActivate:" + isActivate); console.info("isWifiActive:" + isWifiActive);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## wifi.scan<sup>9+</sup> ## wifiManager.scan<sup>9+</sup>
scan(): void scan(): void
...@@ -134,11 +122,37 @@ Starts a scan for WLAN. ...@@ -134,11 +122,37 @@ Starts a scan for WLAN.
**System capability**: SystemCapability.Communication.WiFi.STA **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** **Error codes**
...@@ -154,22 +168,164 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -154,22 +168,164 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.scan(); wifiManager.startScan();
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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)) **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 **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** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
...@@ -224,6 +380,7 @@ Represents WLAN hotspot information. ...@@ -224,6 +380,7 @@ Represents WLAN hotspot information.
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| ssid | string | Yes| No| Service set identifier (SSID) of the hotspot, in UTF-8 format.| | 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.| | 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.| | capabilities | string | Yes| No| Hotspot capabilities.|
| securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| WLAN security type.| | securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| WLAN security type.|
| rssi | number | Yes| No| Received signal strength indicator (RSSI) of the hotspot, in dBm.| | rssi | number | Yes| No| Received signal strength indicator (RSSI) of the hotspot, in dBm.|
...@@ -235,6 +392,16 @@ Represents WLAN hotspot information. ...@@ -235,6 +392,16 @@ Represents WLAN hotspot information.
| infoElems | Array&lt;[WifiInfoElem](#wifiinfoelem9)&gt; | Yes| No| Information elements.| | infoElems | Array&lt;[WifiInfoElem](#wifiinfoelem9)&gt; | Yes| No| Information elements.|
| timestamp | number | Yes| No| Timestamp.| | 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> ## WifiSecurityType<sup>9+</sup>
...@@ -317,7 +484,84 @@ Enumerates the WLAN channel widths. ...@@ -317,7 +484,84 @@ Enumerates the WLAN channel widths.
| WIDTH_80MHZ_PLUS | 4 | 80 MHz<sup>+</sup>| | WIDTH_80MHZ_PLUS | 4 | 80 MHz<sup>+</sup>|
| WIDTH_INVALID | 5 | Invalid value| | 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; addDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
...@@ -379,6 +623,7 @@ Represents the WLAN configuration. ...@@ -379,6 +623,7 @@ Represents the WLAN configuration.
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| ssid | string | Yes| No| SSID of the hotspot, in UTF-8 format.| | ssid | string | Yes| No| SSID of the hotspot, in UTF-8 format.|
| bssid | string | Yes| No| BSSID of the hotspot.| | 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.| | preSharedKey | string | Yes| No| PSK of the hotspot.|
| isHiddenSsid | boolean | Yes| No| Whether the network is hidden.| | isHiddenSsid | boolean | Yes| No| Whether the network is hidden.|
| securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| Security type.| | securityType | [WifiSecurityType](#wifisecuritytype) | Yes| No| Security type.|
...@@ -389,8 +634,8 @@ Represents the WLAN configuration. ...@@ -389,8 +634,8 @@ Represents the WLAN configuration.
| randomMacAddr | string | Yes| No| Random MAC address.<br>**System API**: This is a system API.| | 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.| | 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.| | 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> ## IpType<sup>9+</sup>
...@@ -425,18 +670,16 @@ Represents IP configuration information. ...@@ -425,18 +670,16 @@ Represents IP configuration information.
| domains | Array&lt;string&gt; | Yes| No| Domain information.| | domains | Array&lt;string&gt; | Yes| No| Domain information.|
## WifiEapConfig<sup>9+</sup> ## WifiEapConfig<sup>10+</sup>
Represents EAP configuration information. Represents EAP configuration information.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
| **Name**| **Type**| **Readable**| **Writable**| **Description**| | **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| eapMethod | [EapMethod](#eapmethod9) | Yes| No| EAP authentication method.| | eapMethod | [EapMethod](#eapmethod10) | Yes| No| EAP authentication method.|
| phase2Method | [Phase2Method](#phase2method9) | Yes| No| Phase 2 authentication method.| | phase2Method | [Phase2Method](#phase2method10) | Yes| No| Phase 2 authentication method.|
| identity | string | Yes| No| Identity Information.| | identity | string | Yes| No| Identity Information.|
| anonymousIdentity | string | Yes| No| Anonymous identity.| | anonymousIdentity | string | Yes| No| Anonymous identity.|
| password | string | Yes| No| Password.| | password | string | Yes| No| Password.|
...@@ -452,12 +695,10 @@ Represents EAP configuration information. ...@@ -452,12 +695,10 @@ Represents EAP configuration information.
| eapSubId | number | Yes| No| Sub-ID of the SIM card.| | eapSubId | number | Yes| No| Sub-ID of the SIM card.|
## EapMethod<sup>9+</sup> ## EapMethod<sup>10+</sup>
Enumerates the EAP authentication methods. Enumerates the EAP authentication methods.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description| | Name| Value| Description|
...@@ -473,12 +714,10 @@ Enumerates the EAP authentication methods. ...@@ -473,12 +714,10 @@ Enumerates the EAP authentication methods.
| EAP_UNAUTH_TLS | 8 | UNAUTH TLS.| | EAP_UNAUTH_TLS | 8 | UNAUTH TLS.|
## Phase2Method<sup>9+</sup> ## Phase2Method<sup>10+</sup>
Enumerates the Phase 2 authentication methods. Enumerates the Phase 2 authentication methods.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description| | Name| Value| Description|
...@@ -493,7 +732,37 @@ Enumerates the Phase 2 authentication methods. ...@@ -493,7 +732,37 @@ Enumerates the Phase 2 authentication methods.
| PHASE2_AKA_PRIME | 7 | AKA Prime.| | 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 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 ...@@ -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; addCandidateConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
...@@ -587,7 +856,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 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 ...@@ -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; removeCandidateConfig(networkId: number): Promise&lt;void&gt;
...@@ -675,7 +944,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 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 ...@@ -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; getCandidateConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
...@@ -760,7 +1029,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 connectToCandidateConfig(networkId: number): void
...@@ -799,7 +1068,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 connectToNetwork(networkId: number): void
...@@ -839,7 +1108,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 connectToDevice(config: WifiDeviceConfig): void
...@@ -884,7 +1153,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 disconnect(): void
...@@ -916,7 +1185,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 getSignalLevel(rssi: number, band: number): number
...@@ -962,7 +1231,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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; getLinkedInfo(): Promise&lt;WifiLinkedInfo&gt;
...@@ -987,7 +1256,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -987,7 +1256,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
## wifi.getLinkedInfo<sup>9+</sup> ## wifiManager.getLinkedInfo<sup>9+</sup>
getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void getLinkedInfo(callback: AsyncCallback&lt;WifiLinkedInfo&gt;): void
...@@ -1103,7 +1372,7 @@ Enumerates the supplicant states. ...@@ -1103,7 +1372,7 @@ Enumerates the supplicant states.
| UNINITIALIZED | 10 | The supplicant failed to set up the connection.| | UNINITIALIZED | 10 | The supplicant failed to set up the connection.|
| INVALID | 11 | Invalid value.| | INVALID | 11 | Invalid value.|
## wifi.isConnected<sup>9+</sup> ## wifiManager.isConnected<sup>9+</sup>
isConnected(): boolean isConnected(): boolean
...@@ -1140,7 +1409,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 getSupportedFeatures(): number
...@@ -1194,7 +1463,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 isFeatureSupported(featureId: number): boolean
...@@ -1239,7 +1508,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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[] getDeviceMacAddress(): string[]
...@@ -1278,7 +1547,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 getIpInfo(): IpInfo
...@@ -1331,7 +1600,59 @@ Represents IP information. ...@@ -1331,7 +1600,59 @@ Represents IP information.
| leaseDuration | number | Yes| No| Lease duration of the IP address.| | 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 getCountryCode(): string
...@@ -1367,7 +1688,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 reassociate(): void
...@@ -1399,7 +1720,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 reconnect(): void
...@@ -1431,7 +1752,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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; getDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt;
...@@ -1469,9 +1790,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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. Updates network configuration.
...@@ -1511,16 +1832,16 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -1511,16 +1832,16 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
preSharedKey : "****", preSharedKey : "****",
securityType : 3 securityType : 3
} }
let ret = wifiManager.updateDeviceConfig(config); let ret = wifiManager.updateNetwork(config);
console.error("ret:" + ret); console.error("ret:" + ret);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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. Disables network configuration.
...@@ -1550,15 +1871,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -1550,15 +1871,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try { try {
let netId = 0; let netId = 0;
wifiManager.disableDeviceConfig(netId); wifiManager.disableNetwork(netId);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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. Removes the configuration of all networks.
...@@ -1581,15 +1902,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -1581,15 +1902,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.removeAllDeviceConfigs(); wifiManager.removeAllNetwork();
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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. Removes the specified network configuration.
...@@ -1619,13 +1940,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -1619,13 +1940,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try { try {
let id = 0; let id = 0;
wifiManager.removeDeviceConfig(id); wifiManager.removeDevice(id);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## wifi.isBandTypeSupported<sup>10+</sup> ## wifiManager.isBandTypeSupported<sup>10+</sup>
isBandTypeSupported(bandType: WifiBandType): boolean isBandTypeSupported(bandType: WifiBandType): boolean
...@@ -1641,6 +1962,12 @@ Checks whether the current frequency band is supported. ...@@ -1641,6 +1962,12 @@ Checks whether the current frequency band is supported.
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bandType | WifiBandType | Yes| Wi-Fi band type.| | bandType | WifiBandType | Yes| Wi-Fi band type.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the feature is supported; returns **false** otherwise.|
**Error codes** **Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). 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 ...@@ -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; get5GChannelList(): Array&lt;number&gt;
...@@ -1674,6 +2001,12 @@ Obtains the list of 5 GHz channels supported by this device. ...@@ -1674,6 +2001,12 @@ Obtains the list of 5 GHz channels supported by this device.
**System capability**: SystemCapability.Communication.WiFi.STA **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** **Error codes**
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md). 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 ...@@ -1693,7 +2026,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## wifi.getDisconnectedReason<sup>10+</sup> ## wifiManager.getDisconnectedReason<sup>10+</sup>
getDisconnectedReason(): DisconnectedReason getDisconnectedReason(): DisconnectedReason
...@@ -1745,7 +2078,7 @@ Enumerates the Wi-Fi disconnection reasons. ...@@ -1745,7 +2078,7 @@ Enumerates the Wi-Fi disconnection reasons.
| DISC_REASON_WRONG_PWD | 1 | Incorrect password.| | DISC_REASON_WRONG_PWD | 1 | Incorrect password.|
| DISC_REASON_CONNECTION_FULL | 2 | The number of connections to the router has reached the limit.| | 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 enableHotspot(): void
...@@ -1776,7 +2109,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 disableHotspot(): void
...@@ -1807,7 +2140,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 isHotspotDualBandSupported(): boolean
...@@ -1845,7 +2178,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 isHotspotActive(): boolean
...@@ -1883,7 +2216,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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 setHotspotConfig(config: HotspotConfig): void
...@@ -1946,7 +2279,7 @@ Represents the hotspot configuration. ...@@ -1946,7 +2279,7 @@ Represents the hotspot configuration.
| preSharedKey | string | Yes| Yes| PSK of the hotspot.| | preSharedKey | string | Yes| Yes| PSK of the hotspot.|
| maxConn | number | Yes| Yes| Maximum number of connections allowed.| | maxConn | number | Yes| Yes| Maximum number of connections allowed.|
## wifi.getHotspotConfig<sup>9+</sup> ## wifiManager.getHotspotConfig<sup>9+</sup>
getHotspotConfig(): HotspotConfig getHotspotConfig(): HotspotConfig
...@@ -1984,9 +2317,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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. Obtains information about the connected stations.
...@@ -2015,7 +2348,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2015,7 +2348,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let stations = wifiManager.getHotspotStations(); let stations = wifiManager.getStations();
console.info("result:" + JSON.stringify(stations)); console.info("result:" + JSON.stringify(stations));
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
...@@ -2034,10 +2367,11 @@ Represents the station information. ...@@ -2034,10 +2367,11 @@ Represents the station information.
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| name | string | Yes| No| Device name.| | name | string | Yes| No| Device name.|
| macAddress | string | Yes| No| MAC address.| | macAddress | string | Yes| No| MAC address.|
| macAddressType<sup>10+</sup> | DeviceAddressType | Yes| No| MAC address type.|
| ipAddress | string | Yes| No| IP address.| | ipAddress | string | Yes| No| IP address.|
## wifi.getP2pLinkedInfo<sup>9+</sup> ## wifiManager.getP2pLinkedInfo<sup>9+</sup>
getP2pLinkedInfo(): Promise&lt;WifiP2pLinkedInfo&gt; getP2pLinkedInfo(): Promise&lt;WifiP2pLinkedInfo&gt;
...@@ -2104,7 +2438,7 @@ Enumerates the P2P connection states. ...@@ -2104,7 +2438,7 @@ Enumerates the P2P connection states.
| CONNECTED | 1 | Connected.| | CONNECTED | 1 | Connected.|
## wifi.getP2pLinkedInfo<sup>9+</sup> ## wifiManager.getP2pLinkedInfo<sup>9+</sup>
getP2pLinkedInfo(callback: AsyncCallback&lt;WifiP2pLinkedInfo&gt;): void getP2pLinkedInfo(callback: AsyncCallback&lt;WifiP2pLinkedInfo&gt;): void
...@@ -2121,7 +2455,7 @@ Obtains P2P link information. This API uses an asynchronous callback to return t ...@@ -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.| | 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; getCurrentP2pGroup(): Promise&lt;WifiP2pGroupInfo&gt;
...@@ -2145,7 +2479,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2145,7 +2479,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.getCurrentP2pGroup<sup>9+</sup> ## wifiManager.getCurrentP2pGroup<sup>9+</sup>
getCurrentP2pGroup(callback: AsyncCallback&lt;WifiP2pGroupInfo&gt;): void getCurrentP2pGroup(callback: AsyncCallback&lt;WifiP2pGroupInfo&gt;): void
...@@ -2186,7 +2520,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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; getP2pPeerDevices(): Promise&lt;WifiP2pDevice[]&gt;
...@@ -2210,7 +2544,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2210,7 +2544,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup> ## wifiManager.getP2pPeerDevices<sup>9+</sup>
getP2pPeerDevices(callback: AsyncCallback&lt;WifiP2pDevice[]&gt;): void getP2pPeerDevices(callback: AsyncCallback&lt;WifiP2pDevice[]&gt;): void
...@@ -2261,6 +2595,7 @@ Represents the P2P device information. ...@@ -2261,6 +2595,7 @@ Represents the P2P device information.
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| No| Device name.| | deviceName | string | Yes| No| Device name.|
| deviceAddress | string | Yes| No| MAC address of the device.| | 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.| | primaryDeviceType | string | Yes| No| Type of the primary device.|
| deviceStatus | [P2pDeviceStatus](#p2pdevicestatus9) | Yes| No| Device status.| | deviceStatus | [P2pDeviceStatus](#p2pdevicestatus9) | Yes| No| Device status.|
| groupCapabilities | number | Yes| No| Group capabilities.| | groupCapabilities | number | Yes| No| Group capabilities.|
...@@ -2281,7 +2616,7 @@ Enumerates the P2P device states. ...@@ -2281,7 +2616,7 @@ Enumerates the P2P device states.
| UNAVAILABLE | 4 | Unavailable.| | UNAVAILABLE | 4 | Unavailable.|
## wifi.getP2pLocalDevice<sup>9+</sup> ## wifiManager.getP2pLocalDevice<sup>9+</sup>
getP2pLocalDevice(): Promise&lt;WifiP2pDevice&gt; getP2pLocalDevice(): Promise&lt;WifiP2pDevice&gt;
...@@ -2305,7 +2640,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2305,7 +2640,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.getP2pLocalDevice<sup>9+</sup> ## wifiManager.getP2pLocalDevice<sup>9+</sup>
getP2pLocalDevice(callback: AsyncCallback&lt;WifiP2pDevice&gt;): void 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 ...@@ -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. Creates a P2P group.
...@@ -2380,7 +2715,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2380,7 +2715,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
groupName: "****", groupName: "****",
goBand: 0 goBand: 0
} }
wifiManager.createP2pGroup(config); wifiManager.createGroup(config);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
...@@ -2396,6 +2731,7 @@ Represents P2P group configuration. ...@@ -2396,6 +2731,7 @@ Represents P2P group configuration.
| Name| Type| Readable| Writable| Description| | Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| deviceAddress | string | Yes| No| Device address.| | 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.| | 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.| | passphrase | string | Yes| No| Passphrase of the group.|
| groupName | string | Yes| No| Name of the group.| | groupName | string | Yes| No| Name of the group.|
...@@ -2415,9 +2751,9 @@ Enumerates the P2P group frequency bands. ...@@ -2415,9 +2751,9 @@ Enumerates the P2P group frequency bands.
| GO_BAND_5GHZ | 2 | 5 GHz.| | GO_BAND_5GHZ | 2 | 5 GHz.|
## wifi.removeP2pGroup<sup>9+</sup> ## wifiManager.removeGroup<sup>9+</sup>
removeP2pGroup(): void removeGroup(): void
Removes this P2P group. Removes this P2P group.
...@@ -2438,13 +2774,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2438,13 +2774,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.removeP2pGroup(); wifiManager.removeGroup();
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## wifi.p2pConnect<sup>9+</sup> ## wifiManager.p2pConnect<sup>9+</sup>
p2pConnect(config: WifiP2PConfig): void p2pConnect(config: WifiP2PConfig): void
...@@ -2535,7 +2871,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2535,7 +2871,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("start discover devices -> " + wifiManager.startDiscoverP2pDevices()); console.info("start discover devices -> " + wifiManager.startDiscoverP2pDevices());
``` ```
## wifi.p2pCancelConnect<sup>9+</sup> ## wifiManager.p2pCancelConnect<sup>9+</sup>
p2pCancelConnect(): void p2pCancelConnect(): void
...@@ -2564,9 +2900,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -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. Starts to discover devices.
...@@ -2587,15 +2923,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2587,15 +2923,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.startDiscoverP2pDevices(); wifiManager.startDiscoverDevices();
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## wifi.stopDiscoverP2pDevices<sup>9+</sup> ## wifiManager.stopDiscoverDevices<sup>10+</sup>
stopDiscoverP2pDevices(): void stopDiscoverDevices(): void
Stops discovering devices. Stops discovering devices.
...@@ -2616,15 +2952,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2616,15 +2952,15 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.stopDiscoverP2pDevices(); wifiManager.stopDiscoverDevices();
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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. Deletes a persistent group.
...@@ -2655,13 +2991,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2655,13 +2991,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try { try {
let netId = 0; let netId = 0;
wifiManager.deletePersistentP2pGroup(netId); wifiManager.deletePersistentGroup(netId);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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; getP2pGroups(): Promise&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;
...@@ -2724,7 +3060,7 @@ Represents the P2P group information. ...@@ -2724,7 +3060,7 @@ Represents the P2P group information.
| goIpAddress | string | Yes| No| IP address of the group.| | 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 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 ...@@ -2750,9 +3086,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 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. Sets the device name.
...@@ -2782,13 +3118,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2782,13 +3118,13 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
try { try {
let name = "****"; let name = "****";
wifiManager.setP2pDeviceName(name); wifiManager.setDeviceName(name);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(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 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 ...@@ -2823,7 +3159,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| 3 | Deactivating| | 3 | Deactivating|
## wifi.off('wifiStateChange')<sup>9+</sup> ## wifiManager.off('wifiStateChange')<sup>9+</sup>
off(type: "wifiStateChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -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 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 ...@@ -2896,7 +3232,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
## wifi.off('wifiConnectionChange')<sup>9+</sup> ## wifiManager.off('wifiConnectionChange')<sup>9+</sup>
off(type: "wifiConnectionChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -2936,7 +3272,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("wifiConnectionChange", recvWifiConnectionChangeFunc); 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 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 ...@@ -2968,7 +3304,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
## wifi.off('wifiScanStateChange')<sup>9+</sup> ## wifiManager.off('wifiScanStateChange')<sup>9+</sup>
off(type: "wifiScanStateChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -3008,7 +3344,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("wifiScanStateChange", recvWifiScanStateChangeFunc); 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 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 ...@@ -3033,7 +3369,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
## wifi.off('wifiRssiChange')<sup>9+</sup> ## wifiManager.off('wifiRssiChange')<sup>9+</sup>
off(type: "wifiRssiChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -3073,7 +3409,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("wifiRssiChange", recvWifiRssiChangeFunc); 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 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 ...@@ -3107,7 +3443,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
## wifi.off('hotspotStateChange')<sup>9+</sup> ## wifiManager.off('hotspotStateChange')<sup>9+</sup>
off(type: "hotspotStateChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -3147,7 +3483,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("hotspotStateChange", recvHotspotStateChangeFunc); 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 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 ...@@ -3182,7 +3518,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pStateChange')<sup>9+</sup> ## wifiManager.off('p2pStateChange')<sup>9+</sup>
off(type: "p2pStateChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -3222,7 +3558,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pStateChange", recvP2pStateChangeFunc); 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 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 ...@@ -3247,7 +3583,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pConnectionChange')<sup>9+</sup> ## wifiManager.off('p2pConnectionChange')<sup>9+</sup>
off(type: "p2pConnectionChange", callback?: Callback&lt;WifiP2pLinkedInfo&gt;): void 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 ...@@ -3287,7 +3623,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pConnectionChange", recvP2pConnectionChangeFunc); 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 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 ...@@ -3312,7 +3648,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pDeviceChange')<sup>9+</sup> ## wifiManager.off('p2pDeviceChange')<sup>9+</sup>
off(type: "p2pDeviceChange", callback?: Callback&lt;WifiP2pDevice&gt;): void 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 ...@@ -3342,7 +3678,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvP2pDeviceChangeFunc = result => { var recvP2pDeviceChangeFunc = result => {
console.info("Receive recv p2p device change event: " + result); console.info("Receive p2p device change event: " + result);
} }
// Register an event. // Register an event.
...@@ -3352,7 +3688,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3352,7 +3688,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pDeviceChange", recvP2pDeviceChangeFunc); 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 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 ...@@ -3377,7 +3713,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pPeerDeviceChange')<sup>9+</sup> ## wifiManager.off('p2pPeerDeviceChange')<sup>9+</sup>
off(type: "p2pPeerDeviceChange", callback?: Callback&lt;WifiP2pDevice[]&gt;): void 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 ...@@ -3407,7 +3743,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvP2pPeerDeviceChangeFunc = result => { 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. // Register an event.
...@@ -3417,7 +3753,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3417,7 +3753,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc); 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 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 ...@@ -3442,7 +3778,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pPersistentGroupChange')<sup>9+</sup> ## wifiManager.off('p2pPersistentGroupChange')<sup>9</sup>
off(type: "p2pPersistentGroupChange", callback?: Callback&lt;void&gt;): void 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 ...@@ -3472,7 +3808,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvP2pPersistentGroupChangeFunc = result => { 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. // Register an event.
...@@ -3482,7 +3818,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3482,7 +3818,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
wifiManager.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc); 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 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 ...@@ -3514,7 +3850,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pDiscoveryChange')<sup>9+</sup> ## wifiManager.off('p2pDiscoveryChange')<sup>9+</sup>
off(type: "p2pDiscoveryChange", callback?: Callback&lt;number&gt;): void 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 ...@@ -3544,7 +3880,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
import wifiManager from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvP2pDiscoveryChangeFunc = result => { var recvP2pDiscoveryChangeFunc = result => {
console.info("Receive recv p2p discovery change event: " + result); console.info("Receive p2p discovery change event: " + result);
} }
// Register an event. // Register an event.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册