• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# WLAN
2
3> **NOTE**<br>
4> 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.
5The APIs described in this document are used only for non-universal products, such as routers.
6The APIs of this module are not supported by OpenHarmony 3.1 Release.
7
8
9## Modules to Import
10
11```js
12import wifiext from '@ohos.wifiext';
13```
14
15## wifiext.enableHotspot
16
17enableHotspot(): boolean;
18
19Enables the WLAN hotspot.
20
21- **Required permissions**:
22  ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
23
24- **System capability**:
25  SystemCapability.Communication.WiFi.AP.Extension
26
27- **Return value**:
28  | **Type**| **Description**|
29  | -------- | -------- |
30  | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
31
32
33## wifiext.disableHotspot
34
35disableHotspot(): boolean;
36
37Disables the WLAN hotspot.
38
39- **Required permissions**:
40  ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
41
42- **System capability**:
43  SystemCapability.Communication.WiFi.AP.Extension
44
45- **Return value**:
46  | **Type**| **Description**|
47  | -------- | -------- |
48  | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
49
50
51## wifiext.getSupportedPowerModel
52
53getSupportedPowerModel(): Promise&lt;Array&lt;PowerModel&gt;&gt;
54
55Obtains the supported power models. The API uses a promise to return the result.
56
57- **Required permissions**:
58  ohos.permission.GET_WIFI_INFO
59
60- **System capability**:
61  SystemCapability.Communication.WiFi.AP.Extension
62
63- **Return value**:
64  | Type| Description|
65  | -------- | -------- |
66  | Promise&lt;Array&lt;[PowerModel](#PowerModel)&gt;&gt; | Promise used to return the power models obtained.|
67
68
69## PowerModel
70
71Enumerates the power models.
72
73| Name| Default Value| Description|
74| -------- | -------- | -------- |
75| SLEEPING | 0 | Sleeping|
76| GENERAL | 1 | General|
77| THROUGH_WALL | 2 | Through_wall|
78
79
80## wifiext.getSupportedPowerModel
81
82getSupportedPowerModel(callback: AsyncCallback&lt;Array&lt;PowerModel&gt;&gt;): void
83
84Obtains the supported power models. The API uses an asynchronous callback to return the result.
85
86- **Required permissions**:
87  ohos.permission.GET_WIFI_INFO
88
89- **System capability**:
90  SystemCapability.Communication.WiFi.AP.Extension
91
92- **Parameters**
93  | Name| Type| Mandatory| Description|
94  | -------- | -------- | -------- | -------- |
95  | callback | AsyncCallback&lt;[PowerModel](#PowerModel)&gt; | Yes| Callback invoked to return the power models obtained.|
96
97
98## wifiext.getPowerModel
99
100getPowerModel(): Promise&lt;PowerModel&gt;
101
102Obtains the power model. The API uses a promise to return the result.
103
104- **Required permissions**:
105  ohos.permission.GET_WIFI_INFO
106
107- **System capability**:
108  SystemCapability.Communication.WiFi.AP.Extension
109
110- **Return value**:
111  | Type| Description|
112  | -------- | -------- |
113  | Promise&lt;[PowerModel](#PowerModel)&gt; | Promise used to return the power model obtained.|
114
115
116## wifiext.getPowerModel
117
118getPowerModel(callback: AsyncCallback&lt;PowerModel&gt;): void
119
120Obtains the power model. The API uses an asynchronous callback to return the result.
121
122- **Required permissions**:
123  ohos.permission.GET_WIFI_INFO
124
125- **System capability**:
126  SystemCapability.Communication.WiFi.AP.Extension
127
128- **Parameters**
129  | Name| Type| Mandatory| Description|
130  | -------- | -------- | -------- | -------- |
131  | callback | AsyncCallback&lt;[PowerModel](#PowerModel)&gt; | Yes| Callback invoked to return the power mode obtained.|
132
133
134## wifiext.setPowerModel
135
136setPowerModel(model: PowerModel) : boolean;
137
138 Sets the power model.
139
140- **Required permissions**:
141  ohos.permission.MANAGE_WIFI_HOTSPOT_EXT
142
143- **System capability**:
144  SystemCapability.Communication.WiFi.AP.Extension
145
146- **Parameters**
147  | Name| Type| Mandatory| Description|
148  | -------- | -------- | -------- | -------- |
149  | model | AsyncCallback&lt;[PowerModel](#PowerModel)&gt; | Yes| Power model to set.|
150
151- **Return value**:
152  | **Type**| **Description**|
153  | -------- | -------- |
154  | boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
155