> 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.
...
@@ -16,13 +16,13 @@ isWifiActive(): boolean
...
@@ -16,13 +16,13 @@ isWifiActive(): boolean
Checks whether the WLAN is activated.
Checks whether the WLAN is activated.
-Required permissions:
-**Required permissions**:
ohos.permission.GET_WIFI_INFO
ohos.permission.GET_WIFI_INFO
-System capability:
-**System capability**:
SystemCapability.Communication.WiFi.STA
SystemCapability.Communication.WiFi.STA
-Return value
-**Return value**
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| boolean | Returns **true** if the WLAN is activated; returns **false** otherwise.|
| boolean | Returns **true** if the WLAN is activated; returns **false** otherwise.|
...
@@ -34,31 +34,31 @@ scan(): boolean
...
@@ -34,31 +34,31 @@ scan(): boolean
Starts a scan for WLAN.
Starts a scan for WLAN.
-Required permissions:
-**Required permissions**:
ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION
ohos.permission.SET_WIFI_INFO and ohos.permission.LOCATION
-System capability:
-**System capability**:
SystemCapability.Communication.WiFi.STA
SystemCapability.Communication.WiFi.STA
-Return value
-**Return value**
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| boolean | Returns **true** if the scan is successful; returns **false** otherwise.|
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
Obtains the scan result. This method uses a promise to return the result.
Obtains the scan result. This API uses a promise to return the result.
-Required permissions:
-**Required permissions**:
ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, or ohos.permission.LOCATION
ohos.permission.GET_WIFI_INFO, ohos.permission.GET_WIFI_PEERS_MAC, or ohos.permission.LOCATION
-System capability:
-**System capability**:
SystemCapability.Communication.WiFi.STA
SystemCapability.Communication.WiFi.STA
-Return value
-**Return value**
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the scan result, which is a list of hotspots detected.|
| Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the scan result, which is a list of hotspots detected.|
...
@@ -68,20 +68,20 @@ Obtains the scan result. This method uses a promise to return the result.
...
@@ -68,20 +68,20 @@ Obtains the scan result. This method uses a promise to return the result.
| callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result, which is a list of hotspots detected.|
| callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result, which is a list of hotspots detected.|
| 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<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.|
| Promise<boolean> | Promise used to return the operation result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
## WifiDeviceConfig
## WifiDeviceConfig
...
@@ -182,111 +183,113 @@ Represents the WLAN configuration.
...
@@ -182,111 +183,113 @@ Represents the WLAN configuration.
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.|
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.|
| callback | AsyncCallback<boolean> | Yes| Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.|
| callback | AsyncCallback<boolean> | Yes| Callback invoked to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.|
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.|
-Return value
-**Return value**
| **Type**| **Description**|
| **Type**| **Description**|
| -------- | -------- |
| -------- | -------- |
| Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.|
| Promise<boolean> | Promise used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.|
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.|
| callback | AsyncCallback<boolean> | Yes| Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.|
| callback | AsyncCallback<boolean> | Yes| Callback invoked used to return the result. If the operation is successful, **true** is returned; otherwise, **false** is returned.|
## wifi.getSignalLevel
## wifi.getSignalLevel
getSignalLevel(rssi: number, band: number): number
getSignalLevel(rssi: number, band: number): number
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| type | string | Yes| Event type. The value is **wifiStateChange**.|
| callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback used to return the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
-Example
-**Example**
```js
```js
importwififrom'@ohos.wifi';
importwififrom'@ohos.wifi';
...
@@ -901,10 +904,10 @@ Unregisters the WLAN state change events.
...
@@ -901,10 +904,10 @@ Unregisters the WLAN state change events.
console.info("Receive power state change event: "+result);
console.info("Receive power state change event: "+result);
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| type | string | Yes| Event type. The value is **wifiConnectionChange**.|
| callback | Callback<number> | No| Callback used to report the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback used to return the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| type | string | Yes| Event type. The value is **wifiRssiChange**.|
| callback | Callback<number> | No| Callback used to return the RSSI, in dBm. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback used to return the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| type | string | Yes| Event type. The value is **p2pDeviceChange**.|
| callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | No| Callback used to return the P2P device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<[WifiP2pDevice](#WifiP2pDevice)> | No| Callback used to return the P2P peer device state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| type | string | Yes| Event type. The value is **p2pDiscoveryChange**.|
| callback | Callback<number> | No| Callback used to return the state of the P2P discovered device. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| callback | Callback<number> | No| Callback used to return the P2P device discovery state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs described in this document are used only for non-universal products, such as routers.
The APIs described in this document are used only for non-universal products, such as routers.
The APIs of this module are not supported by OpenHarmony 3.1 Release.
## Modules to Import
## Modules to Import
...
@@ -17,13 +18,13 @@ enableHotspot(): boolean;
...
@@ -17,13 +18,13 @@ enableHotspot(): boolean;
Enables the WLAN hotspot.
Enables the WLAN hotspot.
-Required permissions:
-**Required permissions**:
ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
-System capability:
-**System capability**:
SystemCapability.Communication.WiFi.AP.Extension
SystemCapability.Communication.WiFi.AP.Extension
-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.|
...
@@ -35,13 +36,13 @@ disableHotspot(): boolean;
...
@@ -35,13 +36,13 @@ disableHotspot(): boolean;
Disables the WLAN hotspot.
Disables the WLAN hotspot.
-Required permissions:
-**Required permissions**:
ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
-System capability:
-**System capability**:
SystemCapability.Communication.WiFi.AP.Extension
SystemCapability.Communication.WiFi.AP.Extension
-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.|