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