>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.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<td class="cellrowborder" valign="top" width="73.74000000000001%" headers="mcps1.1.3.1.2 "><p id="p02548143416"><a name="p02548143416"></a><a name="p02548143416"></a>Promise used to return the scan result, which is a list of hotspot information.</p>
</td>
</tr>
</tbody>
</table>
- Return value
| **Type**| **Description**|
| -------- | -------- |
| Promise< Array<[WifiScanInfo](#wifiscaninfo)> > | Promise used to return the scan result, which is a list of hotspots detected.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.5.1.4 "><p id="p142551714104114"><a name="p142551714104114"></a><a name="p142551714104114"></a>Callback invoked to return the scan result, which is a list of hotspot information.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
import wifi from '@ohos.wifi';
wifi.getScanInfos(result => {
var len = Object.keys(result).length;
console.log("wifi received scan info call back: " + len);
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p825591416410"><aname="p825591416410"></a><aname="p825591416410"></a>Hotspot service set identifier (SSID), in UTF-8 format.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p12256121419419"><aname="p12256121419419"></a><aname="p12256121419419"></a>Basic service set identifier (BSSID) of the hotspot.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p1425621424114"><aname="p1425621424114"></a><aname="p1425621424114"></a>Received Signal Strength Indicator (RSSI) of the hotspot, in dBm.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p12257111454112"><aname="p12257111454112"></a><aname="p12257111454112"></a>Frequency band of the WLAN access point (AP).</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p52571514134116"><aname="p52571514134116"></a><aname="p52571514134116"></a>Frequency of the WLAN AP.</p>
| callback | AsyncCallback< Array<[WifiScanInfo](#wifiscaninfo)>> | Yes| Callback invoked to return the result, which is a list of hotspots detected.|
<td class="cellrowborder" valign="top" width="48.980000000000004%" headers="mcps1.1.5.1.4 "><p id="p13241114144112"><a name="p13241114144112"></a><a name="p13241114144112"></a>RSSI of the hotspot, in dBm.</p>
<td class="cellrowborder" valign="top" width="48.980000000000004%" headers="mcps1.1.5.1.4 "><p id="p92411214204119"><a name="p92411214204119"></a><a name="p92411214204119"></a>Frequency band of the WLAN AP.</p>
<td class="cellrowborder" valign="top" width="73.74000000000001%" headers="mcps1.1.3.1.2 "><p id="p142423146417"><a name="p142423146417"></a><a name="p142423146417"></a>Signal strength obtained. The value range is 0 to 4.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p182591314174119"><aname="p182591314174119"></a><aname="p182591314174119"></a>IP address of the preferred DNS server.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p8260214194119"><aname="p8260214194119"></a><aname="p8260214194119"></a>IP address of the alternate DNS server.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p3260101411417"><aname="p3260101411417"></a><aname="p3260101411417"></a>IP address of the DHCP server.</p>
<tdclass="cellrowborder"valign="top"width="48.980000000000004%"headers="mcps1.1.5.1.4 "><pid="p6260514124114"><aname="p6260514124114"></a><aname="p6260514124114"></a>Lease duration of the IP address.</p>
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to add.|
- Return value
| **Type**| **Description**|
| -------- | -------- |
| Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.|
| 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.|
| config | [WifiDeviceConfig](#WifiDeviceConfig) | Yes| WLAN configuration to remove.|
- Return value
| **Type**| **Description**|
| -------- | -------- |
| Promise<boolean> | Promise used to return the operation result. The value **true** indicates that the operation is successful; **false** indicates the opposite.|
| 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.|
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p1597826195510"><aname="p1597826195510"></a><aname="p1597826195510"></a>BSSID of the hotspot.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p197914615552"><aname="p197914615552"></a><aname="p197914615552"></a>RSSI of the hotspot, in dBm.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p19979165557"><aname="p19979165557"></a><aname="p19979165557"></a>Frequency band of the WLAN AP.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p199794615552"><aname="p199794615552"></a><aname="p199794615552"></a>Speed of the WLAN AP.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p149791617552"><aname="p149791617552"></a><aname="p149791617552"></a>Frequency of the WLAN AP.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p15979863558"><aname="p15979863558"></a><aname="p15979863558"></a>Whether the WLAN AP is hidden.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p698011635515"><aname="p698011635515"></a><aname="p698011635515"></a>Whether data volume is restricted at the WLAN AP.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p5980116145514"><aname="p5980116145514"></a><aname="p5980116145514"></a>MAC address of the device that sets up the WLAN connection.</p>
<tdclass="cellrowborder"valign="top"width="48.54514548545145%"headers="mcps1.1.5.1.4 "><pid="p89801611556"><aname="p89801611556"></a><aname="p89801611556"></a>IP address of the device that sets up the WLAN connection.</p>
<tdclass="cellrowborder"valign="top"width="60.199999999999996%"headers="mcps1.1.4.1.3 "><pid="p149831768559"><aname="p149831768559"></a><aname="p149831768559"></a>The device is scanning for available APs.</p>
<tdclass="cellrowborder"valign="top"width="60.199999999999996%"headers="mcps1.1.4.1.3 "><pid="p1298317611557"><aname="p1298317611557"></a><aname="p1298317611557"></a>A WLAN connection is being established.</p>
<tdclass="cellrowborder"valign="top"width="60.199999999999996%"headers="mcps1.1.4.1.3 "><pid="p109844610557"><aname="p109844610557"></a><aname="p109844610557"></a>An authentication is being performed for a WLAN connection.</p>
<tdclass="cellrowborder"valign="top"width="60.199999999999996%"headers="mcps1.1.4.1.3 "><pid="p169844619556"><aname="p169844619556"></a><aname="p169844619556"></a>The IP address of the WLAN connection is being acquired.</p>
<tdclass="cellrowborder"valign="top"width="60.199999999999996%"headers="mcps1.1.4.1.3 "><pid="p20984264555"><aname="p20984264555"></a><aname="p20984264555"></a>The WLAN connection is being disconnected.</p>
<tdclass="cellrowborder"valign="top"width="60.199999999999996%"headers="mcps1.1.4.1.3 "><pid="p59841465550"><aname="p59841465550"></a><aname="p59841465550"></a>Failed to set up a WLAN connection.</p>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.5.1.4 "><p id="p7271131416411"><a name="p7271131416411"></a><a name="p7271131416411"></a>Callback used to report the WLAN state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
import wifi from '@ohos.wifi';
import { EventListener } from '@ohos.wifi';
var WIFI_POWER_STATE = "wifiStateChange";
var listener = new EventListener();
var recvPowerNotifyFunc = result => {
console.info("power state receive event: " + result);
| 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.|
- Example
```js
importwififrom'@ohos.wifi';
varWIFI_POWER_STATE="wifiStateChange";
varrecvPowerNotifyFunc=result=>{
console.info("Receive power state change event: "+result);
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.5.1.4 "><p id="p20273171416419"><a name="p20273171416419"></a><a name="p20273171416419"></a>Callback used to report the WLAN connection state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.</p>
| 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.|
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.1.5.1.4 "><pid="p1927417146415"><aname="p1927417146415"></a><aname="p1927417146415"></a>Event type. The value is <strongid="b2048976800"><aname="b2048976800"></a><aname="b2048976800"></a>wifiScanStateChange</strong>.</p>
<tdclass="cellrowborder"valign="top"width="50%"headers="mcps1.1.5.1.4 "><pid="p202741014174114"><aname="p202741014174114"></a><aname="p202741014174114"></a>Callback used to report the WLAN scan state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.</p>
| type | string | Yes| Event type. The value is **wifiScanStateChange**.|
| callback | Callback<number> | No| Callback used to return the WLAN scan state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.5.1.4 "><p id="p1892151845312"><a name="p1892151845312"></a><a name="p1892151845312"></a>Callback used to report the RSSI. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.</p>
| 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.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.5.1.4 "><p id="p5279161411417"><a name="p5279161411417"></a><a name="p5279161411417"></a>Callback used to report the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.</p>
| type | string | Yes| Event type. The value is **hotspotStateChange**.|
| callback | Callback<number> | No| Callback used to return the hotspot state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| type | string | Yes| Event type. The value is **p2pStateChange**.|
| callback | Callback<number> | No| Callback used to return the P2P state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
| type | string | Yes| Event type. The value is **p2pConnectionChange**.|
| callback | Callback<[WifiP2pLinkedInfo](#WifiP2pLinkedInfo)> | No| Callback used to return the P2P 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 **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.|
| type | string | Yes| Event type. The value is **p2pPeerDeviceChange**.|
| callback | Callback<[WifiP2pDevice[]](#WifiP2pDevice)> | No| Callback used to return the 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 **p2pPersistentGroupChange**.|
| callback | Callback<void> | No| Callback used to return the P2P persistent group 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**.|
| 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.|
> 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.
## Modules to Import
```js
importwifiextfrom'@ohos.wifiext';
```
## wifiext.enableHotspot
enableHotspot(): boolean;
Enables the WLAN hotspot.
- Required permissions:
ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
- System capability:
SystemCapability.Communication.WiFi.HotspotExt
- Return value
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## wifiext.disableHotspot
disableHotspot(): boolean;
Disables the WLAN hotspot.
- Required permissions:
ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
- System capability:
SystemCapability.Communication.WiFi.HotspotExt
- Return value
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|