1# @ohos.wifiManagerExt (WLAN Extension) 2This **wifiext** module provides WLAN extension interfaces for non-universal products. 3 4> **NOTE** 5> 6> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 7> - The APIs described in this document are used only for non-universal products, such as routers. 8 9 10## Modules to Import 11 12```js 13import { wifiManagerExt } from '@kit.ConnectivityKit'; 14``` 15 16## wifiManagerExt.enableHotspot<sup>9+</sup> 17 18enableHotspot(): void; 19 20Enables the WLAN hotspot. 21 22> **NOTE**<br> 23> This API is supported since API version 9 and deprecated since API version 10. 24 25**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT 26 27**System capability**: SystemCapability.Communication.WiFi.AP.Extension 28 29**Error codes** 30 31For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 32 33| **ID**| **Error Message**| 34| -------- | -------- | 35| 201 | Permission denied. | 36| 801 | Capability not supported. | 37| 2701000 | Operation failed. | 38 39**Example** 40 41```ts 42 import { wifiManagerExt } from '@kit.ConnectivityKit'; 43 44 try { 45 wifiManagerExt.enableHotspot(); 46 }catch(error){ 47 console.error("failed:" + JSON.stringify(error)); 48 } 49``` 50 51## wifiManagerExt.disableHotspot<sup>9+</sup> 52 53disableHotspot(): void; 54 55Disables the WLAN hotspot. 56 57> **NOTE**<br> 58> This API is supported since API version 9 and deprecated since API version 10. 59 60**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT 61 62**System capability**: SystemCapability.Communication.WiFi.AP.Extension 63 64**Error codes** 65 66For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 67 68| **ID**| **Error Message**| 69| -------- | -------- | 70| 201 | Permission denied. | 71| 801 | Capability not supported. | 72| 2701000 | Operation failed. | 73 74**Example** 75 76```ts 77 import { wifiManagerExt } from '@kit.ConnectivityKit'; 78 79 try { 80 wifiManagerExt.disableHotspot(); 81 }catch(error){ 82 console.error("failed:" + JSON.stringify(error)); 83 } 84``` 85 86## wifiManagerExt.getSupportedPowerMode<sup>9+</sup> 87 88getSupportedPowerMode(): Promise<Array<PowerMode>> 89 90Obtains the supported power modes. This API uses a promise to return the result. 91 92**Required permissions**: ohos.permission.GET_WIFI_INFO 93 94**System capability**: SystemCapability.Communication.WiFi.AP.Extension 95 96**Return value** 97 98| Type| Description| 99| -------- | -------- | 100| Promise<Array<[PowerMode](#powermode9)>> | Promise used to return the power modes obtained.| 101 102**Error codes** 103 104For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 105 106| **ID**| **Error Message**| 107| -------- | -------- | 108| 201 | Permission denied. | 109| 801 | Capability not supported. | 110| 2701000 | Operation failed. | 111## PowerMode<sup>9+</sup> 112 113Enumerates the power modes. 114 115**System capability**: SystemCapability.Ability.AbilityRuntime.Core 116 117| Name| Value| Description| 118| -------- | -------- | -------- | 119| SLEEPING | 0 | Sleeping| 120| GENERAL | 1 | General| 121| THROUGH_WALL | 2 | Through_wall| 122 123 124## wifiManagerExt.getSupportedPowerMode<sup>9+</sup> 125 126getSupportedPowerMode(callback: AsyncCallback<Array<PowerMode>>): void 127 128Obtains the supported power modes. This API uses an asynchronous callback to return the result. 129 130**Required permissions**: ohos.permission.GET_WIFI_INFO 131 132**System capability**: SystemCapability.Communication.WiFi.AP.Extension 133 134**Parameters** 135 136| Name| Type| Mandatory| Description| 137| -------- | -------- | -------- | -------- | 138| callback | AsyncCallback<Array<[PowerMode](#powermode9)>> | Yes| Callback used to return the result. If the operation is successful, **err** is **0** and **data** is the power modes obtained. If the operation fails, **err** is not **0**.| 139 140**Error codes** 141 142For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 143 144| **ID**| **Error Message**| 145| -------- | -------- | 146| 201 | Permission denied. | 147| 801 | Capability not supported. | 148| 2701000 | Operation failed. | 149 150**Example** 151 152```ts 153 import { wifiManagerExt } from '@kit.ConnectivityKit'; 154 155 wifiManagerExt.getSupportedPowerMode((err, data:wifiManagerExt.PowerMode) => { 156 if (err) { 157 console.error("get supported power mode info error"); 158 return; 159 } 160 console.info("get supported power mode info: " + JSON.stringify(data)); 161 }); 162 163 wifiManagerExt.getSupportedPowerMode().then(data => { 164 console.info("get supported power mode info: " + JSON.stringify(data)); 165 }).catch((error:number) => { 166 console.info("get supported power mode error"); 167 }); 168``` 169 170## wifiManagerExt.getPowerMode<sup>9+</sup> 171 172getPowerMode(): Promise<PowerMode> 173 174Obtains the power mode. This API uses a promise to return the result. 175 176> **NOTE**<br> 177> This API is supported since API version 9 and deprecated since API version 10. 178 179**Required permissions**: ohos.permission.GET_WIFI_INFO 180 181**System capability**: SystemCapability.Communication.WiFi.AP.Extension 182 183**Return value** 184 185| Type| Description| 186| -------- | -------- | 187| Promise<[PowerMode](#powermode9)> | Promise used to return the power modes obtained.| 188 189**Error codes** 190 191For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 192 193| **ID**| **Error Message**| 194| -------- | -------- | 195| 201 | Permission denied. | 196| 801 | Capability not supported. | 197| 2701000 | Operation failed. | 198 199**Example** 200 201```ts 202 import { wifiManagerExt } from '@kit.ConnectivityKit'; 203 204 try { 205 let model = wifiManagerExt.getPowerMode(); 206 console.info("model info:" + model); 207 }catch(error){ 208 console.error("failed:" + JSON.stringify(error)); 209 } 210``` 211 212## wifiManagerExt.getPowerMode<sup>9+</sup> 213 214getPowerMode(callback: AsyncCallback<PowerMode>): void 215 216Obtains the power mode. This API uses an asynchronous callback to return the result. 217 218**Required permissions**: ohos.permission.GET_WIFI_INFO 219 220**System capability**: SystemCapability.Communication.WiFi.AP.Extension 221 222**Parameters** 223 224| Name| Type| Mandatory| Description| 225| -------- | -------- | -------- | -------- | 226| callback | AsyncCallback<[PowerMode](#powermode9)> | Yes| Callback used to return the result. If the operation is successful, **err** is **0** and **data** is the power mode obtained. If the operation fails, **err** is not **0**.| 227 228**Error codes** 229 230For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 231 232| **ID**| **Error Message**| 233| -------- | -------- | 234| 201 | Permission denied. | 235| 801 | Capability not supported. | 236| 2701000 | Operation failed. | 237 238**Example** 239 240```ts 241 import { wifiManagerExt } from '@kit.ConnectivityKit'; 242 243 wifiManagerExt.getPowerMode((err, data:wifiManagerExt.PowerMode) => { 244 if (err) { 245 console.error("get linked info error"); 246 return; 247 } 248 console.info("get power mode info: " + JSON.stringify(data)); 249 }); 250 251 wifiManagerExt.getPowerMode().then(data => { 252 console.info("get power mode info: " + JSON.stringify(data)); 253 }).catch((error:number) => { 254 console.info("get power mode error"); 255 }); 256``` 257 258## wifiManagerExt.setPowerMode<sup>9+</sup> 259 260setPowerMode(mode: PowerMode) : void; 261 262 Sets the power mode. 263 264> **NOTE**<br> 265> This API is supported since API version 9 and deprecated since API version 10. 266 267**Required permissions**: ohos.permission.MANAGE_WIFI_HOTSPOT_EXT 268 269**System capability**: SystemCapability.Communication.WiFi.AP.Extension 270 271**Parameters** 272 273| Name| Type| Mandatory| Description| 274| -------- | -------- | -------- | -------- | 275| mode | [PowerMode](#powermode9) | Yes| Power mode to set.| 276 277**Error codes** 278 279For details about the error codes, see [Wi-Fi Error Codes](errorcode-wifi.md). 280 281| **ID**| **Error Message**| 282| -------- | -------- | 283| 201 | Permission denied. | 284| 801 | Capability not supported. | 285| 2701000 | Operation failed. | 286 287**Example** 288 289```ts 290 import { wifiManagerExt } from '@kit.ConnectivityKit'; 291 292 try { 293 let model = 0; 294 wifiManagerExt.setPowerMode(model); 295 }catch(error){ 296 console.error("failed:" + JSON.stringify(error)); 297 } 298``` 299