js-apis-wifiext.md 4.3 KB
Newer Older
A
annie_wangli 已提交
1
# WLAN
A
Annie_wang 已提交
2
This **wifiext** module provides WLAN extension interfaces for non-universal products.
A
annie_wangli 已提交
3

A
Annie_wang 已提交
4
> **NOTE**<br>
A
annie_wangli 已提交
5
> 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.
A
annie_wangli 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
The APIs described in this document are used only for non-universal products, such as routers.


## Modules to Import

```js
import wifiext from '@ohos.wifiext';
```

## wifiext.enableHotspot

enableHotspot(): boolean;

Enables the WLAN hotspot.

A
Annie_wang 已提交
21
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
A
annie_wangli 已提交
22

A
Annie_wang 已提交
23
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
24

A
Annie_wang 已提交
25
**Return value**
A
annie_wangli 已提交
26 27 28 29 30 31 32 33 34 35 36
  | **Type**| **Description**|
  | -------- | -------- |
  | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|


## wifiext.disableHotspot

disableHotspot(): boolean;

Disables the WLAN hotspot.

A
Annie_wang 已提交
37
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
A
annie_wangli 已提交
38

A
Annie_wang 已提交
39
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
40

A
Annie_wang 已提交
41
**Return value**
A
annie_wangli 已提交
42 43 44 45 46 47 48 49 50
  | **Type**| **Description**|
  | -------- | -------- |
  | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|


## wifiext.getSupportedPowerModel

getSupportedPowerModel(): Promise&lt;Array&lt;PowerModel&gt;&gt;

A
Annie_wang 已提交
51
Obtains the supported power models. This API uses a promise to return the result.
A
annie_wangli 已提交
52

A
Annie_wang 已提交
53
**Required permissions**: ohos.permission.GET_WIFI_INFO
A
annie_wangli 已提交
54

A
Annie_wang 已提交
55
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
56

A
Annie_wang 已提交
57
**Return value**
A
annie_wangli 已提交
58 59
  | Type| Description|
  | -------- | -------- |
A
Annie_wang 已提交
60
  | Promise&lt;Array&lt;[PowerModel](#powermodel)&gt;&gt; | Promise used to return the power models obtained.|
A
annie_wangli 已提交
61 62 63 64


## PowerModel

A
Annie_wang 已提交
65
Enumerates the power models.
A
annie_wangli 已提交
66

A
Annie_wang 已提交
67 68
**System capability**: SystemCapability.Communication.WiFi.AP.Extension

A
annie_wangli 已提交
69 70 71 72 73 74 75 76 77 78 79
| Name| Default Value| Description|
| -------- | -------- | -------- |
| SLEEPING | 0 | Sleeping|
| GENERAL | 1 | General|
| THROUGH_WALL | 2 | Through_wall|


## wifiext.getSupportedPowerModel

getSupportedPowerModel(callback: AsyncCallback&lt;Array&lt;PowerModel&gt;&gt;): void

A
Annie_wang 已提交
80
Obtains the supported power models. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
81

A
Annie_wang 已提交
82
**Required permissions**: ohos.permission.GET_WIFI_INFO
A
annie_wangli 已提交
83

A
Annie_wang 已提交
84
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
85

A
Annie_wang 已提交
86
**Parameters**
A
annie_wangli 已提交
87 88
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
A
Annie_wang 已提交
89
  | 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 models obtained. If **err** is not **0**, an error has occurred.|
A
annie_wangli 已提交
90 91 92 93 94 95


## wifiext.getPowerModel

getPowerModel(): Promise&lt;PowerModel&gt;

A
Annie_wang 已提交
96
Obtains the power model. This API uses a promise to return the result.
A
annie_wangli 已提交
97

A
Annie_wang 已提交
98
**Required permissions**: ohos.permission.GET_WIFI_INFO
A
annie_wangli 已提交
99

A
Annie_wang 已提交
100
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
101

A
Annie_wang 已提交
102
**Return value**
A
annie_wangli 已提交
103 104
  | Type| Description|
  | -------- | -------- |
A
Annie_wang 已提交
105
  | Promise&lt;[PowerModel](#powermodel)&gt; | Promise used to return the power model obtained.|
A
annie_wangli 已提交
106 107 108 109 110 111


## wifiext.getPowerModel

getPowerModel(callback: AsyncCallback&lt;PowerModel&gt;): void

A
Annie_wang 已提交
112
Obtains the power model. This API uses an asynchronous callback to return the result.
A
annie_wangli 已提交
113

A
Annie_wang 已提交
114
**Required permissions**: ohos.permission.GET_WIFI_INFO
A
annie_wangli 已提交
115

A
Annie_wang 已提交
116
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
117

A
Annie_wang 已提交
118
**Parameters**
A
annie_wangli 已提交
119 120
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
A
Annie_wang 已提交
121
  | 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.|
A
annie_wangli 已提交
122 123 124 125 126 127 128 129


## wifiext.setPowerModel

setPowerModel(model: PowerModel) : boolean;

 Sets the power model.

A
Annie_wang 已提交
130
**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
A
annie_wangli 已提交
131

A
Annie_wang 已提交
132
**System capability**: SystemCapability.Communication.WiFi.AP.Extension
A
annie_wangli 已提交
133

A
Annie_wang 已提交
134
**Parameters**
A
annie_wangli 已提交
135 136
  | Name| Type| Mandatory| Description|
  | -------- | -------- | -------- | -------- |
A
Annie_wang 已提交
137
  | model | AsyncCallback&lt;[PowerModel](#powermodel)&gt; | Yes| Power model to set.|
A
annie_wangli 已提交
138

A
Annie_wang 已提交
139
**Return value**
A
annie_wangli 已提交
140 141 142
  | **Type**| **Description**|
  | -------- | -------- |
  | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|