提交 c3ec956c 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 8542a39c
...@@ -244,23 +244,6 @@ Enumerates the WLAN security types. ...@@ -244,23 +244,6 @@ Enumerates the WLAN security types.
| WIFI_SEC_TYPE_SAE | 4 | Simultaneous Authentication of Equals (SAE).| | WIFI_SEC_TYPE_SAE | 4 | Simultaneous Authentication of Equals (SAE).|
## wifi.getScanInfosSync<sup>9+</sup>
getScanInfosSync(): &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)
**System capability**: SystemCapability.Communication.WiFi.STA
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| &nbsp;Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Scan result obtained.|
## wifi.addDeviceConfig ## wifi.addDeviceConfig
addDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt; addDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
...@@ -585,8 +568,8 @@ Connects to the specified network. ...@@ -585,8 +568,8 @@ 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.permissio.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
...@@ -680,7 +663,7 @@ try { ...@@ -680,7 +663,7 @@ try {
let rssi = 0; let rssi = 0;
let band = 0; let band = 0;
let level = wifi.getSignalLevel(rssi,band); let level = wifi.getSignalLevel(rssi,band);
console.info("lelvel:" + JSON.stringify(lelvel)); console.info("level:" + JSON.stringify(level));
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
...@@ -1278,10 +1261,10 @@ Disables this hotspot. ...@@ -1278,10 +1261,10 @@ Disables this hotspot.
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifi from '@ohos.wifi';
try { try {
wifiManager.disableHotspot(); wifi.disableHotspot();
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
...@@ -1644,7 +1627,7 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou ...@@ -1644,7 +1627,7 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifi from '@ohos.wifi';
wifi.getP2pPeerDevices((err, data) => { wifi.getP2pPeerDevices((err, data) => {
if (err) { if (err) {
...@@ -2043,7 +2026,7 @@ import wifi from '@ohos.wifi'; ...@@ -2043,7 +2026,7 @@ import wifi from '@ohos.wifi';
try { try {
let name = "****"; let name = "****";
wifi.setDeviceName(netId); wifi.setDeviceName(name);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN. The **WLAN** module provides basic wireless local area network (WLAN) functions, peer-to-peer (P2P) functions, and WLAN message notification services. It allows applications to communicate with other devices over WLAN.
> **NOTE** > **NOTE**
>
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
...@@ -26,22 +25,22 @@ Enables WLAN. ...@@ -26,22 +25,22 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.enableWifi(); wifiManager.enableWifi();
...@@ -64,22 +63,22 @@ Disables WLAN. ...@@ -64,22 +63,22 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.disableWifi(); wifiManager.disableWifi();
...@@ -100,22 +99,22 @@ Checks whether WLAN is enabled. ...@@ -100,22 +99,22 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let isActivate = wifiManager.isActivate(); let isActivate = wifiManager.isActivate();
...@@ -137,22 +136,22 @@ Starts a scan for WLAN. ...@@ -137,22 +136,22 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.scan(); wifiManager.scan();
...@@ -173,27 +172,27 @@ Obtains the scan result. ...@@ -173,27 +172,27 @@ Obtains the scan result.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Returns the hotspots detected.| | Array&lt;[WifiScanInfo](#wifiscaninfo)&gt; | Returns the hotspots detected.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let scanInfoList = wifiManager.getScanInfoList(); let scanInfoList = wifiManager.getScanInfoList();
console.info("scanInfoList:" + JSON.stringify(scanInfoList)); console.info("scanInfoList:" + JSON.stringify(scanInfoList));
let len = Object.keys(result).length; let len = Object.keys(scanInfoList).length;
console.log("wifi received scan info: " + len); console.log("wifi received scan info: " + len);
if(len > 0){ if(len > 0){
for (var i = 0; i < len; ++i) { for (var i = 0; i < len; ++i) {
...@@ -332,14 +331,14 @@ Adds network configuration. This API uses a promise to return the result. ...@@ -332,14 +331,14 @@ 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 ID of the added network configuration. If **-1** is returned, the network configuration fails to be added.| | Promise&lt;number&gt; | Promise used to return the ID of the added network configuration. If **-1** is returned, the network configuration fails to be added.|
**Error codes** **Error codes**
...@@ -347,13 +346,13 @@ Adds network configuration. This API uses a promise to return the result. ...@@ -347,13 +346,13 @@ Adds network configuration. This API uses a promise to return the result.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -508,23 +507,23 @@ Adds network configuration. This API uses an asynchronous callback to return the ...@@ -508,23 +507,23 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -552,27 +551,27 @@ Adds the configuration of a candidate network. This API uses a promise to return ...@@ -552,27 +551,27 @@ Adds the configuration of a candidate network. This API uses a promise to return
**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 network configuration ID.| | Promise&lt;number&gt; | Promise used to return the network configuration ID.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
````` `````js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -600,22 +599,22 @@ Adds the configuration of a candidate network. This API uses an asynchronous cal ...@@ -600,22 +599,22 @@ Adds the configuration of a candidate network. This API uses an asynchronous cal
**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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
````` `````js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -643,28 +642,28 @@ Removes the configuration of a candidate network. This API uses a promise to ret ...@@ -643,28 +642,28 @@ Removes the configuration of a candidate network. This API uses a promise to ret
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| ID of the network configuration to remove.| | networkId | number | Yes| ID of the network configuration to remove.|
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result.| | Promise&lt;void&gt; | Promise used to return the result.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let networkId = 0; let networkId = 0;
...@@ -688,9 +687,9 @@ Removes the configuration of a candidate network. This API uses an asynchronous ...@@ -688,9 +687,9 @@ Removes the configuration of a candidate network. This API uses an asynchronous
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| ID of the network configuration to remove.| | networkId | number | Yes| ID of the network configuration to remove.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the result. If the operation is successful, the value of **err** is **0**. If **err** is not **0**, an error has occurred.|
**Error codes** **Error codes**
...@@ -698,12 +697,12 @@ Removes the configuration of a candidate network. This API uses an asynchronous ...@@ -698,12 +697,12 @@ Removes the configuration of a candidate network. This API uses an asynchronous
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let networkId = 0; let networkId = 0;
...@@ -727,22 +726,22 @@ Obtains candidate network configuration. ...@@ -727,22 +726,22 @@ Obtains candidate network configuration.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Candidate network configuration obtained.| | &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig)&gt; | Candidate network configuration obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
````` `````js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let configs = wifiManager.getCandidateConfigs(); let configs = wifiManager.getCandidateConfigs();
...@@ -773,22 +772,22 @@ Connects to a candidate network added by the application. If the device is alrea ...@@ -773,22 +772,22 @@ Connects to a candidate network added by the application. If the device is alrea
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| ID of the candidate network configuration.| | networkId | number | Yes| ID of the candidate network configuration.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let networkId = 0; let networkId = 0;
...@@ -814,23 +813,23 @@ Connects to the specified network. If the device is already connected to a hotsp ...@@ -814,23 +813,23 @@ Connects to the specified network. If the device is already connected to a hotsp
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| Network configuration ID.| | networkId | number | Yes| Network configuration ID.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let networkId = 0; let networkId = 0;
...@@ -848,15 +847,15 @@ Connects to the specified network. If the device is already connected to a hotsp ...@@ -848,15 +847,15 @@ Connects to the specified network. If the device is already connected to a hotsp
**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.permissio.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| Configuration of the WLAN to connect. | | config | [WifiDeviceConfig](#wifideviceconfig) | Yes| Configuration of the WLAN to connect. |
**Error codes** **Error codes**
...@@ -864,13 +863,13 @@ Connects to the specified network. If the device is already connected to a hotsp ...@@ -864,13 +863,13 @@ Connects to the specified network. If the device is already connected to a hotsp
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -903,12 +902,12 @@ Disconnects the network. ...@@ -903,12 +902,12 @@ Disconnects the network.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.disconnect(); wifiManager.disconnect();
...@@ -929,34 +928,34 @@ Obtains the WLAN signal level. ...@@ -929,34 +928,34 @@ 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].|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let rssi = 0; let rssi = 0;
let band = 0; let band = 0;
let level = wifiManager.getSignalLevel(rssi,band); let level = wifiManager.getSignalLevel(rssi,band);
console.info("lelvel:" + JSON.stringify(lelvel)); console.info("level:" + JSON.stringify(level));
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
...@@ -975,8 +974,8 @@ Obtains WLAN connection information. This API uses a promise to return the resul ...@@ -975,8 +974,8 @@ 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 obtained.| | Promise&lt;[WifiLinkedInfo](#wifilinkedinfo)&gt; | Promise used to return the WLAN connection information obtained.|
**Error codes** **Error codes**
...@@ -984,7 +983,7 @@ Obtains WLAN connection information. This API uses a promise to return the resul ...@@ -984,7 +983,7 @@ Obtains WLAN connection information. This API uses a promise to return the resul
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
...@@ -1000,24 +999,24 @@ Obtains WLAN connection information. This API uses an asynchronous callback to r ...@@ -1000,24 +999,24 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
wifi.getLinkedInfo((err, data) => { wifiManager.getLinkedInfo((err, data) => {
if (err) { if (err) {
console.error("get linked info error"); console.error("get linked info error");
return; return;
...@@ -1025,12 +1024,12 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -1025,12 +1024,12 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get wifi linked info: " + JSON.stringify(data)); console.info("get wifi linked info: " + JSON.stringify(data));
}); });
wifi.getLinkedInfo().then(data => { wifiManager.getLinkedInfo().then(data => {
console.info("get wifi linked info: " + JSON.stringify(data)); console.info("get wifi linked info: " + JSON.stringify(data));
}).catch(error => { }).catch(error => {
console.info("get linked info error"); console.info("get linked info error");
}); });
``` ```
## WifiLinkedInfo<sup>9+</sup> ## WifiLinkedInfo<sup>9+</sup>
...@@ -1104,24 +1103,6 @@ Enumerates the supplicant states. ...@@ -1104,24 +1103,6 @@ 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.|
## SuppState<sup>10+</sup>
Enumerates the Wi-Fi standards.
**System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description|
| -------- | -------- | -------- |
| WIFI_STANDARD_UNDEFINED | 0 | Undefined|
| WIFI_STANDARD_11A | 1 | 802.11a|
| WIFI_STANDARD_11B | 2 | 802.11b|
| WIFI_STANDARD_11G | 3 | 802.11g|
| WIFI_STANDARD_11N | 4 | 802.11n|
| WIFI_STANDARD_11AC | 5 | 802.11ac|
| WIFI_STANDARD_11AX | 6 | 802.11ax|
| WIFI_STANDARD_11AD | 7 | 802.11ad|
## wifi.isConnected<sup>9+</sup> ## wifi.isConnected<sup>9+</sup>
isConnected(): boolean isConnected(): boolean
...@@ -1134,21 +1115,21 @@ Checks whether the WLAN is connected. ...@@ -1134,21 +1115,21 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let ret = wifiManager.isConnected(); let ret = wifiManager.isConnected();
...@@ -1173,9 +1154,9 @@ Obtains the features supported by this device. ...@@ -1173,9 +1154,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**
...@@ -1197,12 +1178,12 @@ Obtains the features supported by this device. ...@@ -1197,12 +1178,12 @@ Obtains the features supported by this device.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2401000 | Operation failed.| | 2401000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let ret = wifiManager.getSupportedFeatures(); let ret = wifiManager.getSupportedFeatures();
...@@ -1226,27 +1207,27 @@ Checks whether the device supports the specified WLAN feature. ...@@ -1226,27 +1207,27 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2401000 | Operation failed.| | 2401000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let featureId = 0; let featureId = 0;
...@@ -1272,21 +1253,21 @@ Obtains the device MAC address. ...@@ -1272,21 +1253,21 @@ Obtains the device MAC address.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| string[] | MAC address obtained.| | string[] | MAC address obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let ret = wifiManager.getDeviceMacAddress(); let ret = wifiManager.getDeviceMacAddress();
...@@ -1309,21 +1290,21 @@ Obtains IP information. ...@@ -1309,21 +1290,21 @@ Obtains IP information.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| [IpInfo](#ipinfo9) | IP information obtained.| | [IpInfo](#ipinfo9) | IP information obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let info = wifiManager.getIpInfo(); let info = wifiManager.getIpInfo();
...@@ -1362,21 +1343,21 @@ Obtains the country code. ...@@ -1362,21 +1343,21 @@ Obtains the country code.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| string | Country code obtained.| | string | Country code obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2401000 | Operation failed.| | 2401000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let code = wifiManager.getCountryCode(); let code = wifiManager.getCountryCode();
...@@ -1403,13 +1384,13 @@ Re-associates with the network. ...@@ -1403,13 +1384,13 @@ Re-associates with the network.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.reassociate(); wifiManager.reassociate();
...@@ -1435,13 +1416,13 @@ Reconnects to the network. ...@@ -1435,13 +1416,13 @@ Reconnects to the network.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
| 2501001 | Wifi is closed.| | 2501001 | Wifi is closed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.reconnect(); wifiManager.reconnect();
...@@ -1464,21 +1445,21 @@ Obtains network configuration. ...@@ -1464,21 +1445,21 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let configs = wifiManager.getDeviceConfigs(); let configs = wifiManager.getDeviceConfigs();
...@@ -1502,27 +1483,27 @@ Updates network configuration. ...@@ -1502,27 +1483,27 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -1551,8 +1532,8 @@ Disables network configuration. ...@@ -1551,8 +1532,8 @@ 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.|
**Error codes** **Error codes**
...@@ -1560,12 +1541,12 @@ Disables network configuration. ...@@ -1560,12 +1541,12 @@ Disables network configuration.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let netId = 0; let netId = 0;
...@@ -1592,12 +1573,12 @@ Removes the configuration of all networks. ...@@ -1592,12 +1573,12 @@ Removes the configuration of all networks.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.removeAllDeviceConfigs(); wifiManager.removeAllDeviceConfigs();
...@@ -1620,21 +1601,21 @@ Removes the specified network configuration. ...@@ -1620,21 +1601,21 @@ Removes the specified network configuration.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| networkId | number | Yes| ID of the network configuration to remove.| | networkId | number | Yes| ID of the network configuration to remove.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let id = 0; let id = 0;
...@@ -1656,51 +1637,67 @@ Checks whether the current frequency band is supported. ...@@ -1656,51 +1637,67 @@ Checks whether the current frequency band is supported.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| bandType | WifiBandType | Yes| Wi-Fi band type.| | bandType | WifiBandType | Yes| Wi-Fi band type.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let type = 0; let type = 0;
boolean isBandTypeSupported = wifiManager.isBandTypeSupported(type); let isBandTypeSupported = wifiManager.isBandTypeSupported(type);
console.info("isBandTypeSupported:" + isBandTypeSupported); console.info("isBandTypeSupported:" + isBandTypeSupported);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## WifiBandType <sup>10+</sup> ## wifi.get5GChannelList<sup>10+</sup>
Enumerates the Wi-Fi band types. get5GChannelList(): Array&lt;number&gt;
Obtains the list of 5 GHz channels supported by this device.
**System API**: This is a system API.
**Required permissions**: ohos.permission.GET_WIFI_INFO and ohos.permission.GET_WIFI_CONFIG
**System capability**: SystemCapability.Communication.WiFi.STA **System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description| **Error codes**
| -------- | -------- | -------- |
| WIFI_BAND_NONE | 0 | Undefined|
| WIFI_BAND_2G | 1 | 2 GHz|
| WIFI_BAND_5G | 2 | 5 GHz|
| WIFI_BAND_6G | 3 | 6 GHz|
| WIFI_BAND_60G | 4 | 60 GHz|
For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorcode-wifi.md).
## wifi.get5GChannelList<sup>10+</sup> | **ID**| **Error Message**|
| -------- | -------- |
| 2501000 | Operation failed.|
get5GChannelList(): Array&lt;number&gt; **Example**
```js
import wifiManager from '@ohos.wifiManager';
Obtains the list of 5 GHz channels supported by this device. try {
let channelList = wifiManager.get5GChannelList();
console.info("channelList:" + JSON.stringify(channelList));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getDisconnectedReason<sup>10+</sup>
getDisconnectedReason(): DisconnectedReason
Obtains the reason of the latest disconnection.
**System API**: This is a system API. **System API**: This is a system API.
...@@ -1713,21 +1710,41 @@ Obtains the list of 5 GHz channels supported by this device. ...@@ -1713,21 +1710,41 @@ Obtains the list of 5 GHz channels supported by this device.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- |
| 2601000 | Operation failed.|
**Return value**
| **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | DisconnectedReason | Returns the reason of the latest disconnection obtained.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let channelList = wifiManager.get5GChannelList(); let disconnectedReason = wifiManager.getDisconnectedReason();
console.info("channelList:" + JSON.stringify(channelList)); console.info("disconnectedReason:" + disconnectedReason);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
``` ```
## DisconnectedReason <sup>10+</sup>
Enumerates the Wi-Fi disconnection reasons.
**System API**: This is a system API.
**System capability**: SystemCapability.Communication.WiFi.STA
| Name| Value| Description|
| -------- | -------- | -------- |
| DISC_REASON_DEFAULT | 0 | Default reason.|
| DISC_REASON_WRONG_PWD | 1 | Incorrect password.|
| DISC_REASON_CONNECTION_FULL | 2 | The number of connections to the router has reached the limit.|
## wifi.enableHotspot<sup>9+</sup> ## wifi.enableHotspot<sup>9+</sup>
enableHotspot(): void enableHotspot(): void
...@@ -1745,12 +1762,12 @@ Enables this hotspot. ...@@ -1745,12 +1762,12 @@ Enables this hotspot.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.enableHotspot(); wifiManager.enableHotspot();
...@@ -1776,12 +1793,12 @@ Disables this hotspot. ...@@ -1776,12 +1793,12 @@ Disables this hotspot.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.disableHotspot(); wifiManager.disableHotspot();
...@@ -1804,21 +1821,21 @@ Checks whether the hotspot supports dual band. ...@@ -1804,21 +1821,21 @@ Checks whether the hotspot supports dual band.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the hotspot supports dual band; returns **false** otherwise.| | boolean | Returns **true** if the hotspot supports dual band; 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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let ret = wifiManager.isHotspotDualBandSupported(); let ret = wifiManager.isHotspotDualBandSupported();
...@@ -1842,21 +1859,21 @@ Checks whether this hotspot is active. ...@@ -1842,21 +1859,21 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let ret = wifiManager.isHotspotActive(); let ret = wifiManager.isHotspotActive();
...@@ -1880,21 +1897,21 @@ Sets hotspot configuration. ...@@ -1880,21 +1897,21 @@ Sets hotspot configuration.
**Parameters** **Parameters**
| **Name**| **Type**| **Mandatory**| **Description**| | **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [HotspotConfig](#hotspotconfig9) | Yes| Hotspot configuration to set.| | config | [HotspotConfig](#hotspotconfig9) | Yes| Hotspot configuration to set.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -1943,21 +1960,21 @@ Obtains hotspot configuration. ...@@ -1943,21 +1960,21 @@ Obtains hotspot configuration.
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| [HotspotConfig](#hotspotconfig9) | Hotspot configuration obtained.| | [HotspotConfig](#hotspotconfig9) | Hotspot configuration obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = wifiManager.getHotspotConfig(); let config = wifiManager.getHotspotConfig();
...@@ -1975,27 +1992,27 @@ Obtains information about the connected stations. ...@@ -1975,27 +1992,27 @@ Obtains information about the connected stations.
**System API**: This is a system API. **System API**: This is a system API.
**Required permissions**: ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, ohos.permission.APPROXIMATELY_LOCATION, and ohos.permission.MANAGE_WIFI_HOTSPOT (available only to system applications) **Required permissions**: ohos.permission.GET_WIFI_INFO, ohos.permission.LOCATION, ohos.permission.APPROXIMATELY_LOCATION, and ohos.permission.MANAGE_WIFI_HOTSPOT (available only to system applications)
**System capability**: SystemCapability.Communication.WiFi.AP.Core **System capability**: SystemCapability.Communication.WiFi.AP.Core
**Return value** **Return value**
| **Type**| **Description**| | **Type**| **Description**|
| -------- | -------- | | -------- | -------- |
| &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt; | Connected stations obtained.| | &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt; | Connected stations obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let stations = wifiManager.getHotspotStations(); let stations = wifiManager.getHotspotStations();
...@@ -2032,8 +2049,8 @@ Obtains P2P link information. This API uses a promise to return the result. ...@@ -2032,8 +2049,8 @@ Obtains P2P link information. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Promise used to return the P2P link information obtained.| | Promise&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Promise used to return the P2P link information obtained.|
**Error codes** **Error codes**
...@@ -2041,14 +2058,14 @@ Obtains P2P link information. This API uses a promise to return the result. ...@@ -2041,14 +2058,14 @@ Obtains P2P link information. This API uses a promise to return the result.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
wifi.getP2pLinkedInfo((err, data) => { wifiManager.getP2pLinkedInfo((err, data) => {
if (err) { if (err) {
console.error("get p2p linked info error"); console.error("get p2p linked info error");
return; return;
...@@ -2056,7 +2073,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2056,7 +2073,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get wifi p2p linked info: " + JSON.stringify(data)); console.info("get wifi p2p linked info: " + JSON.stringify(data));
}); });
wifi.getP2pLinkedInfo().then(data => { wifiManager.getP2pLinkedInfo().then(data => {
console.info("get wifi p2p linked info: " + JSON.stringify(data)); console.info("get wifi p2p linked info: " + JSON.stringify(data));
}); });
``` ```
...@@ -2099,9 +2116,9 @@ Obtains P2P link information. This API uses an asynchronous callback to return t ...@@ -2099,9 +2116,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](#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> ## wifi.getCurrentP2pGroup<sup>9+</sup>
...@@ -2116,8 +2133,8 @@ Obtains the current P2P group information. This API uses a promise to return the ...@@ -2116,8 +2133,8 @@ 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](#wifip2pgroupinfo9)&gt; | Promise used to return the P2P group information obtained.| | Promise&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt; | Promise used to return the P2P group information obtained.|
**Error codes** **Error codes**
...@@ -2125,7 +2142,7 @@ Obtains the current P2P group information. This API uses a promise to return the ...@@ -2125,7 +2142,7 @@ Obtains the current P2P group information. This API uses a promise to return the
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.getCurrentP2pGroup<sup>9+</sup> ## wifi.getCurrentP2pGroup<sup>9+</sup>
...@@ -2140,23 +2157,23 @@ Obtains the current P2P group information. This API uses an asynchronous callbac ...@@ -2140,23 +2157,23 @@ 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](#wifip2pgroupinfo9)&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](#wifip2pgroupinfo9)&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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
wifi.getCurrentP2pGroup((err, data) => { wifiManager.getCurrentP2pGroup((err, data) => {
if (err) { if (err) {
console.error("get current P2P group error"); console.error("get current P2P group error");
return; return;
...@@ -2164,7 +2181,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2164,7 +2181,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get current P2P group: " + JSON.stringify(data)); console.info("get current P2P group: " + JSON.stringify(data));
}); });
wifi.getCurrentP2pGroup().then(data => { wifiManager.getCurrentP2pGroup().then(data => {
console.info("get current P2P group: " + JSON.stringify(data)); console.info("get current P2P group: " + JSON.stringify(data));
}); });
``` ```
...@@ -2181,16 +2198,16 @@ Obtains the peer device list in the P2P connection. This API uses a promise to r ...@@ -2181,16 +2198,16 @@ 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[]](#wifip2pdevice9)&gt; | Promise used to return the peer device list.| | Promise&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Promise used to return the peer device list.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.getP2pPeerDevices<sup>9+</sup> ## wifi.getP2pPeerDevices<sup>9+</sup>
...@@ -2205,23 +2222,23 @@ Obtains the peer device list in the P2P connection. This API uses an asynchronou ...@@ -2205,23 +2222,23 @@ 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[]](#wifip2pdevice9)&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[]](#wifip2pdevice9)&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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
wifi.getP2pPeerDevices((err, data) => { wifiManager.getP2pPeerDevices((err, data) => {
if (err) { if (err) {
console.error("get P2P peer devices error"); console.error("get P2P peer devices error");
return; return;
...@@ -2229,7 +2246,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2229,7 +2246,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get P2P peer devices: " + JSON.stringify(data)); console.info("get P2P peer devices: " + JSON.stringify(data));
}); });
wifi.getP2pPeerDevices().then(data => { wifiManager.getP2pPeerDevices().then(data => {
console.info("get P2P peer devices: " + JSON.stringify(data)); console.info("get P2P peer devices: " + JSON.stringify(data));
}); });
``` ```
...@@ -2276,16 +2293,16 @@ Obtains the local device information in the P2P connection. This API uses a prom ...@@ -2276,16 +2293,16 @@ Obtains the local device information in the P2P connection. This API uses a prom
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Promise used to return the local device information obtained.| | Promise&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Promise used to return the local device information obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.getP2pLocalDevice<sup>9+</sup> ## wifi.getP2pLocalDevice<sup>9+</sup>
...@@ -2300,17 +2317,19 @@ Obtains the local device information in the P2P connection. This API uses an asy ...@@ -2300,17 +2317,19 @@ Obtains the local device information in the P2P connection. This API uses an asy
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the local device information obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the local device information obtained. If **err** is not **0**, an error has occurred.|
**Error codes**
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
wifiManager.getP2pLocalDevice((err, data) => { wifiManager.getP2pLocalDevice((err, data) => {
if (err) { if (err) {
...@@ -2320,7 +2339,7 @@ Obtains the local device information in the P2P connection. This API uses an asy ...@@ -2320,7 +2339,7 @@ Obtains the local device information in the P2P connection. This API uses an asy
console.info("get P2P local device: " + JSON.stringify(data)); console.info("get P2P local device: " + JSON.stringify(data));
}); });
wifi.getP2pLocalDevice().then(data => { wifiManager.getP2pLocalDevice().then(data => {
console.info("get P2P local device: " + JSON.stringify(data)); console.info("get P2P local device: " + JSON.stringify(data));
}); });
``` ```
...@@ -2337,21 +2356,21 @@ Creates a P2P group. ...@@ -2337,21 +2356,21 @@ Creates a P2P group.
**Parameters** **Parameters**
| **Name**| **Type**| Mandatory| **Description**| | **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig9) | Yes| Group configuration.| | config | [WifiP2PConfig](#wifip2pconfig9) | Yes| Group configuration.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let config = { let config = {
...@@ -2411,12 +2430,12 @@ Removes this P2P group. ...@@ -2411,12 +2430,12 @@ Removes this P2P group.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.removeP2pGroup(); wifiManager.removeP2pGroup();
...@@ -2437,25 +2456,25 @@ Sets up a P2P connection. ...@@ -2437,25 +2456,25 @@ Sets up a P2P connection.
**Parameters** **Parameters**
| **Name**| **Type**| Mandatory| **Description**| | **Name**| **Type**| Mandatory| **Description**|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| config | [WifiP2PConfig](#wifip2pconfig9) | Yes| P2P group configuration.| | config | [WifiP2PConfig](#wifip2pconfig9) | Yes| P2P group configuration.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifiManager from '@ohos.wifiManager';
var recvP2pConnectionChangeFunc = result => { var recvP2pConnectionChangeFunc = result => {
console.info("p2p connection change receive event: " + JSON.stringify(result)); console.info("p2p connection change receive event: " + JSON.stringify(result));
wifi.getP2pLinkedInfo((err, data) => { wifiManager.getP2pLinkedInfo((err, data) => {
if (err) { if (err) {
console.error('failed to get getP2pLinkedInfo: ' + JSON.stringify(err)); console.error('failed to get getP2pLinkedInfo: ' + JSON.stringify(err));
return; return;
...@@ -2463,16 +2482,16 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2463,16 +2482,16 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get getP2pLinkedInfo: " + JSON.stringify(data)); console.info("get getP2pLinkedInfo: " + JSON.stringify(data));
}); });
} }
wifi.on("p2pConnectionChange", recvP2pConnectionChangeFunc); wifiManager.on("p2pConnectionChange", recvP2pConnectionChangeFunc);
var recvP2pDeviceChangeFunc = result => { var recvP2pDeviceChangeFunc = result => {
console.info("p2p device change receive event: " + JSON.stringify(result)); console.info("p2p device change receive event: " + JSON.stringify(result));
} }
wifi.on("p2pDeviceChange", recvP2pDeviceChangeFunc); wifiManager.on("p2pDeviceChange", recvP2pDeviceChangeFunc);
var recvP2pPeerDeviceChangeFunc = result => { var recvP2pPeerDeviceChangeFunc = result => {
console.info("p2p peer device change receive event: " + JSON.stringify(result)); console.info("p2p peer device change receive event: " + JSON.stringify(result));
wifi.getP2pPeerDevices((err, data) => { wifiManager.getP2pPeerDevices((err, data) => {
if (err) { if (err) {
console.error('failed to get peer devices: ' + JSON.stringify(err)); console.error('failed to get peer devices: ' + JSON.stringify(err));
return; return;
...@@ -2489,17 +2508,17 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2489,17 +2508,17 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
"groupName":"", "groupName":"",
"goBand":0, "goBand":0,
} }
wifi.p2pConnect(config); wifiManager.p2pConnect(config);
} }
} }
}); });
} }
wifi.on("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc); wifiManager.on("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);
var recvP2pPersistentGroupChangeFunc = () => { var recvP2pPersistentGroupChangeFunc = () => {
console.info("p2p persistent group change receive event"); console.info("p2p persistent group change receive event");
wifi.getCurrentGroup((err, data) => { wifiManager.getCurrentP2pGroup((err, data) => {
if (err) { if (err) {
console.error('failed to get current group: ' + JSON.stringify(err)); console.error('failed to get current group: ' + JSON.stringify(err));
return; return;
...@@ -2507,14 +2526,14 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2507,14 +2526,14 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get current group: " + JSON.stringify(data)); console.info("get current group: " + JSON.stringify(data));
}); });
} }
wifi.on("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc); wifiManager.on("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);
setTimeout(function() {wifi.off("p2pConnectionChange", recvP2pConnectionChangeFunc);}, 125 * 1000); setTimeout(function() {wifiManager.off("p2pConnectionChange", recvP2pConnectionChangeFunc);}, 125 * 1000);
setTimeout(function() {wifi.off("p2pDeviceChange", recvP2pDeviceChangeFunc);}, 125 * 1000); setTimeout(function() {wifiManager.off("p2pDeviceChange", recvP2pDeviceChangeFunc);}, 125 * 1000);
setTimeout(function() {wifi.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);}, 125 * 1000); setTimeout(function() {wifiManager.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);}, 125 * 1000);
setTimeout(function() {wifi.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);}, 125 * 1000); setTimeout(function() {wifiManager.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);}, 125 * 1000);
console.info("start discover devices -> " + wifi.startP2pDiscoverDevices()); console.info("start discover devices -> " + wifiManager.startDiscoverP2pDevices());
``` ```
## wifi.p2pCancelConnect<sup>9+</sup> ## wifi.p2pCancelConnect<sup>9+</sup>
...@@ -2531,12 +2550,12 @@ Cancels this P2P connection. ...@@ -2531,12 +2550,12 @@ Cancels this P2P connection.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.p2pCancelConnect(); wifiManager.p2pCancelConnect();
...@@ -2560,12 +2579,12 @@ Starts to discover devices. ...@@ -2560,12 +2579,12 @@ Starts to discover devices.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.startDiscoverP2pDevices(); wifiManager.startDiscoverP2pDevices();
...@@ -2589,12 +2608,12 @@ Stops discovering devices. ...@@ -2589,12 +2608,12 @@ Stops discovering devices.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
wifiManager.stopDiscoverP2pDevices(); wifiManager.stopDiscoverP2pDevices();
...@@ -2618,21 +2637,21 @@ Deletes a persistent group. ...@@ -2618,21 +2637,21 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let netId = 0; let netId = 0;
...@@ -2656,21 +2675,21 @@ Obtains information about all P2P groups. This API uses a promise to return the ...@@ -2656,21 +2675,21 @@ Obtains information about all P2P groups. This API uses a promise to return the
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&nbsp;&gt; | Promise used to return the group information obtained.| | Promise&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&nbsp;&gt; | Promise used to return the group information obtained.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
wifiManager.getP2pGroups((err, data) => { wifiManager.getP2pGroups((err, data) => {
if (err) { if (err) {
...@@ -2680,7 +2699,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -2680,7 +2699,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
console.info("get P2P groups: " + JSON.stringify(data)); console.info("get P2P groups: " + JSON.stringify(data));
}); });
wifi.getP2pGroups().then(data => { wifiManager.getP2pGroups().then(data => {
console.info("get P2P groups: " + JSON.stringify(data)); console.info("get P2P groups: " + JSON.stringify(data));
}); });
...@@ -2719,16 +2738,16 @@ Obtains information about all P2P groups. This API uses an asynchronous callback ...@@ -2719,16 +2738,16 @@ Obtains information about all P2P groups. This API uses an asynchronous callback
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&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;&nbsp;Array&lt;[WifiP2pGroupInfo](#wifip2pgroupinfo9)&gt;&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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.setP2pDeviceName<sup>9+</sup> ## wifi.setP2pDeviceName<sup>9+</sup>
...@@ -2745,25 +2764,25 @@ Sets the device name. ...@@ -2745,25 +2764,25 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
``` ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
try { try {
let name = "****"; let name = "****";
wifiManager.setP2pDeviceName(netId); wifiManager.setP2pDeviceName(name);
}catch(error){ }catch(error){
console.error("failed:" + JSON.stringify(error)); console.error("failed:" + JSON.stringify(error));
} }
...@@ -2781,17 +2800,17 @@ Registers the WLAN state change events. ...@@ -2781,17 +2800,17 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**WLAN states** **WLAN states**
...@@ -2816,9 +2835,9 @@ Unregisters the WLAN state change events. ...@@ -2816,9 +2835,9 @@ 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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -2826,23 +2845,23 @@ Unregisters the WLAN state change events. ...@@ -2826,23 +2845,23 @@ Unregisters the WLAN state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifiManager from '@ohos.wifiManager';
var recvPowerNotifyFunc = result => { var recvPowerNotifyFunc = result => {
console.info("Receive power state change event: " + result); console.info("Receive power state change event: " + result);
} }
// Register an event. // Register an event.
wifi.on("wifiStateChange", recvPowerNotifyFunc); wifiManager.on("wifiStateChange", recvPowerNotifyFunc);
// Unregister an event. // Unregister an event.
wifi.off("wifiStateChange", recvPowerNotifyFunc); wifiManager.off("wifiStateChange", recvPowerNotifyFunc);
``` ```
## wifi.on('wifiConnectionChange')<sup>9+</sup> ## wifi.on('wifiConnectionChange')<sup>9+</sup>
...@@ -2857,10 +2876,10 @@ Registers the WLAN connection state change events. ...@@ -2857,10 +2876,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**
...@@ -2874,7 +2893,7 @@ Registers the WLAN connection state change events. ...@@ -2874,7 +2893,7 @@ Registers the WLAN connection state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
## wifi.off('wifiConnectionChange')<sup>9+</sup> ## wifi.off('wifiConnectionChange')<sup>9+</sup>
...@@ -2889,9 +2908,9 @@ Unregisters the WLAN connection state change events. ...@@ -2889,9 +2908,9 @@ 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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -2899,23 +2918,23 @@ Unregisters the WLAN connection state change events. ...@@ -2899,23 +2918,23 @@ Unregisters the WLAN connection state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifiManager from '@ohos.wifiManager';
var recvWifiConnectionChangeFunc = result => { var recvWifiConnectionChangeFunc = result => {
console.info("Receive wifi connection change event: " + result); console.info("Receive wifi connection change event: " + result);
} }
// Register an event. // Register an event.
wifi.on("wifiConnectionChange", recvWifiConnectionChangeFunc); wifiManager.on("wifiConnectionChange", recvWifiConnectionChangeFunc);
// Unregister an event. // Unregister an event.
wifi.off("wifiConnectionChange", recvWifiConnectionChangeFunc); wifiManager.off("wifiConnectionChange", recvWifiConnectionChangeFunc);
``` ```
## wifi.on('wifiScanStateChange')<sup>9+</sup> ## wifi.on('wifiScanStateChange')<sup>9+</sup>
...@@ -2929,10 +2948,10 @@ Registers the WLAN scan state change events. ...@@ -2929,10 +2948,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**
...@@ -2946,7 +2965,7 @@ Registers the WLAN scan state change events. ...@@ -2946,7 +2965,7 @@ Registers the WLAN scan state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
## wifi.off('wifiScanStateChange')<sup>9+</sup> ## wifi.off('wifiScanStateChange')<sup>9+</sup>
...@@ -2971,23 +2990,23 @@ Unregisters the WLAN scan state change events. ...@@ -2971,23 +2990,23 @@ Unregisters the WLAN scan state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifi'; import wifiManager from '@ohos.wifiManager';
var recvWifiScanStateChangeFunc = result => { var recvWifiScanStateChangeFunc = result => {
console.info("Receive Wifi scan state change event: " + result); console.info("Receive Wifi scan state change event: " + result);
} }
// Register an event. // Register an event.
wifi.on("wifiScanStateChange", recvWifiScanStateChangeFunc); wifiManager.on("wifiScanStateChange", recvWifiScanStateChangeFunc);
// Unregister an event. // Unregister an event.
wifi.off("wifiScanStateChange", recvWifiScanStateChangeFunc); wifiManager.off("wifiScanStateChange", recvWifiScanStateChangeFunc);
``` ```
## wifi.on('wifiRssiChange')<sup>9+</sup> ## wifi.on('wifiRssiChange')<sup>9+</sup>
...@@ -3001,17 +3020,17 @@ Registers the RSSI change events. ...@@ -3001,17 +3020,17 @@ 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.|
**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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
## wifi.off('wifiRssiChange')<sup>9+</sup> ## wifi.off('wifiRssiChange')<sup>9+</sup>
...@@ -3026,9 +3045,9 @@ Unregisters the RSSI change events. ...@@ -3026,9 +3045,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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3036,12 +3055,12 @@ Unregisters the RSSI change events. ...@@ -3036,12 +3055,12 @@ Unregisters the RSSI change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2501000 | Operation failed.| | 2501000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvWifiRssiChangeFunc = result => { var recvWifiRssiChangeFunc = result => {
console.info("Receive wifi rssi change event: " + result); console.info("Receive wifi rssi change event: " + result);
...@@ -3052,7 +3071,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3052,7 +3071,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("wifiRssiChange", recvWifiRssiChangeFunc); wifiManager.off("wifiRssiChange", recvWifiRssiChangeFunc);
``` ```
## wifi.on('hotspotStateChange')<sup>9+</sup> ## wifi.on('hotspotStateChange')<sup>9+</sup>
...@@ -3066,10 +3085,10 @@ Registers the hotspot state change events. ...@@ -3066,10 +3085,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**
...@@ -3085,7 +3104,7 @@ Registers the hotspot state change events. ...@@ -3085,7 +3104,7 @@ Registers the hotspot state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
## wifi.off('hotspotStateChange')<sup>9+</sup> ## wifi.off('hotspotStateChange')<sup>9+</sup>
...@@ -3100,9 +3119,9 @@ Unregisters the hotspot state change events. ...@@ -3100,9 +3119,9 @@ 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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3110,12 +3129,12 @@ Unregisters the hotspot state change events. ...@@ -3110,12 +3129,12 @@ Unregisters the hotspot state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2601000 | Operation failed.| | 2601000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvHotspotStateChangeFunc = result => { var recvHotspotStateChangeFunc = result => {
console.info("Receive hotspot state change event: " + result); console.info("Receive hotspot state change event: " + result);
...@@ -3126,7 +3145,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3126,7 +3145,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("hotspotStateChange", recvHotspotStateChangeFunc); wifiManager.off("hotspotStateChange", recvHotspotStateChangeFunc);
``` ```
## wifi.on('p2pStateChange')<sup>9+</sup> ## wifi.on('p2pStateChange')<sup>9+</sup>
...@@ -3140,10 +3159,10 @@ Registers the P2P state change events. ...@@ -3140,10 +3159,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**
...@@ -3160,7 +3179,7 @@ Registers the P2P state change events. ...@@ -3160,7 +3179,7 @@ Registers the P2P state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pStateChange')<sup>9+</sup> ## wifi.off('p2pStateChange')<sup>9+</sup>
...@@ -3175,9 +3194,9 @@ Unregisters the P2P state change events. ...@@ -3175,9 +3194,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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3185,12 +3204,12 @@ Unregisters the P2P state change events. ...@@ -3185,12 +3204,12 @@ Unregisters the P2P state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvP2pStateChangeFunc = result => { var recvP2pStateChangeFunc = result => {
console.info("Receive p2p state change event: " + result); console.info("Receive p2p state change event: " + result);
...@@ -3201,9 +3220,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3201,9 +3220,9 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("p2pStateChange", recvP2pStateChangeFunc); wifiManager.off("p2pStateChange", recvP2pStateChangeFunc);
``` ```
## wifi.on('p2pConnectionChange')<sup>9+</sup> ## wifi.on('p2pConnectionChange')<sup>9+</sup>
on(type: "p2pConnectionChange", callback: Callback&lt;WifiP2pLinkedInfo&gt;): void on(type: "p2pConnectionChange", callback: Callback&lt;WifiP2pLinkedInfo&gt;): void
...@@ -3215,9 +3234,9 @@ Registers the P2P connection state change events. ...@@ -3215,9 +3234,9 @@ 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](#wifip2plinkedinfo9)&gt; | Yes| Callback invoked to return the P2P connection state.| | callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | Yes| Callback invoked to return the P2P connection state.|
**Error codes** **Error codes**
...@@ -3225,7 +3244,7 @@ Registers the P2P connection state change events. ...@@ -3225,7 +3244,7 @@ Registers the P2P connection state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pConnectionChange')<sup>9+</sup> ## wifi.off('p2pConnectionChange')<sup>9+</sup>
...@@ -3240,9 +3259,9 @@ Unregisters the P2P connection state change events. ...@@ -3240,9 +3259,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](#wifip2plinkedinfo9)&gt; | No| Callback for the P2P connection state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo9)&gt; | No| Callback for the P2P connection state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3250,12 +3269,12 @@ Unregisters the P2P connection state change events. ...@@ -3250,12 +3269,12 @@ Unregisters the P2P connection state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi from '@ohos.wifiManager'; import wifiManager from '@ohos.wifiManager';
var recvP2pConnectionChangeFunc = result => { var recvP2pConnectionChangeFunc = result => {
console.info("Receive p2p connection change event: " + result); console.info("Receive p2p connection change event: " + result);
...@@ -3266,7 +3285,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3266,7 +3285,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("p2pConnectionChange", recvP2pConnectionChangeFunc); wifiManager.off("p2pConnectionChange", recvP2pConnectionChangeFunc);
``` ```
## wifi.on('p2pDeviceChange')<sup>9+</sup> ## wifi.on('p2pDeviceChange')<sup>9+</sup>
...@@ -3280,9 +3299,9 @@ Registers the P2P device state change events. ...@@ -3280,9 +3299,9 @@ 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](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P device state.| | callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P device state.|
**Error codes** **Error codes**
...@@ -3290,7 +3309,7 @@ Registers the P2P device state change events. ...@@ -3290,7 +3309,7 @@ Registers the P2P device state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pDeviceChange')<sup>9+</sup> ## wifi.off('p2pDeviceChange')<sup>9+</sup>
...@@ -3305,9 +3324,9 @@ Unregisters the P2P device state change events. ...@@ -3305,9 +3324,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](#wifip2pdevice9)&gt; | No| Callback for the P2P device state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice9)&gt; | No| Callback for the P2P device state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3315,12 +3334,12 @@ Unregisters the P2P device state change events. ...@@ -3315,12 +3334,12 @@ Unregisters the P2P device state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi 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 recv p2p device change event: " + result);
...@@ -3331,7 +3350,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3331,7 +3350,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("p2pDeviceChange", recvP2pDeviceChangeFunc); wifiManager.off("p2pDeviceChange", recvP2pDeviceChangeFunc);
``` ```
## wifi.on('p2pPeerDeviceChange')<sup>9+</sup> ## wifi.on('p2pPeerDeviceChange')<sup>9+</sup>
...@@ -3345,9 +3364,9 @@ Registers the P2P peer device state change events. ...@@ -3345,9 +3364,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[]](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P peer device state.| | callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | Yes| Callback invoked to return the P2P peer device state.|
**Error codes** **Error codes**
...@@ -3355,7 +3374,7 @@ Registers the P2P peer device state change events. ...@@ -3355,7 +3374,7 @@ Registers the P2P peer device state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pPeerDeviceChange')<sup>9+</sup> ## wifi.off('p2pPeerDeviceChange')<sup>9+</sup>
...@@ -3370,9 +3389,9 @@ Unregisters the P2P peer device state change events. ...@@ -3370,9 +3389,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[]](#wifip2pdevice9)&gt; | No| Callback for the P2P peer device state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.| | callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice9)&gt; | No| Callback for the P2P peer device state change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3380,12 +3399,12 @@ Unregisters the P2P peer device state change events. ...@@ -3380,12 +3399,12 @@ Unregisters the P2P peer device state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi 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 recv p2p peer device change event: " + result);
...@@ -3396,7 +3415,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3396,7 +3415,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc); wifiManager.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);
``` ```
## wifi.on('p2pPersistentGroupChange')<sup>9+</sup> ## wifi.on('p2pPersistentGroupChange')<sup>9+</sup>
...@@ -3410,9 +3429,9 @@ Registers the P2P persistent group state change events. ...@@ -3410,9 +3429,9 @@ 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.|
**Error codes** **Error codes**
...@@ -3420,7 +3439,7 @@ Registers the P2P persistent group state change events. ...@@ -3420,7 +3439,7 @@ Registers the P2P persistent group state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pPersistentGroupChange')<sup>9+</sup> ## wifi.off('p2pPersistentGroupChange')<sup>9+</sup>
...@@ -3435,9 +3454,9 @@ Unregisters the P2P persistent group state change events. ...@@ -3435,9 +3454,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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3445,12 +3464,12 @@ Unregisters the P2P persistent group state change events. ...@@ -3445,12 +3464,12 @@ Unregisters the P2P persistent group state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi 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 recv p2p persistent group change event: " + result);
...@@ -3461,7 +3480,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3461,7 +3480,7 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc); wifiManager.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);
``` ```
## wifi.on('p2pDiscoveryChange')<sup>9+</sup> ## wifi.on('p2pDiscoveryChange')<sup>9+</sup>
...@@ -3475,10 +3494,10 @@ Registers the P2P device discovery state change events. ...@@ -3475,10 +3494,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**
...@@ -3492,7 +3511,7 @@ Registers the P2P device discovery state change events. ...@@ -3492,7 +3511,7 @@ Registers the P2P device discovery state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
## wifi.off('p2pDiscoveryChange')<sup>9+</sup> ## wifi.off('p2pDiscoveryChange')<sup>9+</sup>
...@@ -3507,9 +3526,9 @@ Unregisters the P2P device discovery state change events. ...@@ -3507,9 +3526,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 change. 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 change. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Error codes** **Error codes**
...@@ -3517,12 +3536,12 @@ Unregisters the P2P device discovery state change events. ...@@ -3517,12 +3536,12 @@ Unregisters the P2P device discovery state change events.
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).
| **ID**| **Error Message**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2801000 | Operation failed.| | 2801000 | Operation failed.|
**Example** **Example**
```js ```js
import wifi 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 recv p2p discovery change event: " + result);
...@@ -3533,4 +3552,4 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco ...@@ -3533,4 +3552,4 @@ For details about the error codes, see [Wi-Fi Error Codes](../errorcodes/errorco
// Unregister an event. // Unregister an event.
wifiManager.off("p2pDiscoveryChange", recvP2pDiscoveryChangeFunc); wifiManager.off("p2pDiscoveryChange", recvP2pDiscoveryChangeFunc);
``` ```
# @ohos.wifiManagerExt (WLAN Extension Interface) # @ohos.wifiManagerExt (WLAN Extension)
This **wifiext** module provides WLAN extension interfaces for non-universal products. This **wifiext** module provides WLAN extension interfaces for non-universal products.
> **NOTE** > **NOTE**
...@@ -27,8 +27,8 @@ Enables the WLAN hotspot. ...@@ -27,8 +27,8 @@ Enables the WLAN hotspot.
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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
## wifiext.disableHotspot<sup>9+</sup> ## wifiext.disableHotspot<sup>9+</sup>
...@@ -45,8 +45,8 @@ Disables the WLAN hotspot. ...@@ -45,8 +45,8 @@ Disables the WLAN hotspot.
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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
## wifiext.getSupportedPowerMode<sup>9+</sup> ## wifiext.getSupportedPowerMode<sup>9+</sup>
...@@ -61,19 +61,19 @@ Obtains the supported power modes. This API uses a promise to return the result. ...@@ -61,19 +61,19 @@ Obtains the supported power modes. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[PowerMode](#powermode)&gt;&gt; | Promise used to return the power modes obtained.| | Promise&lt;Array&lt;[PowerMode](#powermode)&gt;&gt; | Promise used to return the power modes obtained.|
**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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
## PowerMode ## PowerMode<sup>9+</sup>
Enumerates the power modes. Enumerates the power modes.
...@@ -98,16 +98,16 @@ Obtains the supported power modes. This API uses an asynchronous callback to ret ...@@ -98,16 +98,16 @@ Obtains the supported power modes. This API uses an asynchronous callback to ret
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerMode](#powermode)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power modes obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;Array&lt;[PowerMode](#powermode)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power modes obtained. If **err** is not **0**, an error has occurred.|
**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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
## wifiext.getPowerMode<sup>9+</sup> ## wifiext.getPowerMode<sup>9+</sup>
...@@ -122,16 +122,16 @@ Obtains the power mode. This API uses a promise to return the result. ...@@ -122,16 +122,16 @@ Obtains the power mode. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PowerMode](#powermode)&gt; | Promise used to return the power modes obtained.| | Promise&lt;[PowerMode](#powermode)&gt; | Promise used to return the power modes obtained.|
**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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
## wifiext.getPowerMode<sup>9+</sup> ## wifiext.getPowerMode<sup>9+</sup>
...@@ -146,21 +146,21 @@ Obtains the power mode. This API uses an asynchronous callback to return the res ...@@ -146,21 +146,21 @@ Obtains the power mode. This API uses an asynchronous callback to return the res
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerMode](#powermode)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power mode obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[PowerMode](#powermode)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power mode obtained. If **err** is not **0**, an error has occurred.|
**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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
## wifiext.setPowerMode<sup>9+</sup> ## wifiext.setPowerMode<sup>9+</sup>
setPowerMode(model: PowerMode) : boolean; setPowerMode(mode: PowerMode) : void;
Sets the power mode. Sets the power mode.
...@@ -170,14 +170,14 @@ setPowerMode(model: PowerMode) : boolean; ...@@ -170,14 +170,14 @@ setPowerMode(model: PowerMode) : boolean;
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| model | [PowerMode](#powermode) | Yes| Power mode to set.| | model | [PowerMode](#powermode) | Yes| Power mode to set.|
**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).
| **Type**| **Description**| | **ID**| **Error Message**|
| -------- | -------- | | -------- | -------- |
| 2701000 | Operation failed.| | 2701000 | Operation failed.|
...@@ -26,9 +26,9 @@ Enables the WLAN hotspot. ...@@ -26,9 +26,9 @@ Enables the WLAN 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.|
## wifiext.disableHotspot ## wifiext.disableHotspot
...@@ -43,9 +43,9 @@ Disables the WLAN hotspot. ...@@ -43,9 +43,9 @@ Disables the WLAN 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.|
## wifiext.getSupportedPowerModel ## wifiext.getSupportedPowerModel
...@@ -60,9 +60,9 @@ Obtains the supported power models. This API uses a promise to return the result ...@@ -60,9 +60,9 @@ Obtains the supported power models. This API uses a promise to return the result
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.| | Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
## PowerModel ## PowerModel
...@@ -90,9 +90,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re ...@@ -90,9 +90,9 @@ Obtains the supported power models. This API uses an asynchronous callback to re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is 0 and **data** is the power models obtained. If **err** is not **0**, an error has occurred.|
## wifiext.getPowerModel ## wifiext.getPowerModel
...@@ -107,9 +107,9 @@ Obtains the power model. This API uses a promise to return the result. ...@@ -107,9 +107,9 @@ Obtains the power model. This API uses a promise to return the result.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.| | Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
## wifiext.getPowerModel ## wifiext.getPowerModel
...@@ -124,16 +124,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re ...@@ -124,16 +124,16 @@ Obtains the power model. This API uses an asynchronous callback to return the re
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.| | callback | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Callback invoked to return the result. If the operation is successful, **err** is **0** and **data** is the power model obtained. If **err** is not **0**, an error has occurred.|
## wifiext.setPowerModel ## wifiext.setPowerModel
setPowerModel(model: PowerModel) : boolean; setPowerModel(model: PowerModel) : boolean;
Sets the power model. Sets the power model.
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT **Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
...@@ -141,12 +141,12 @@ Sets the power model. ...@@ -141,12 +141,12 @@ Sets the power model.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| model | [PowerModel](#powermodel) | Yes| Power model to set.| | model | [PowerModel](#powermodel) | Yes| Power model 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.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册