1e41f4b71Sopenharmony_ci# @ohos.wifiext (WLAN扩展接口) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci该模块主要提供WLAN扩展接口,供非通用类型产品使用。 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **说明:** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 8e41f4b71Sopenharmony_ci该文档中的接口只供非通用类型产品使用,如路由器等,对于常规类型产品,不应该使用这些接口。 9e41f4b71Sopenharmony_ci> 从API Version 9 开始,该接口不再维护,推荐使用[`@ohos.wifiManagerExt (WLAN扩展接口)`](js-apis-wifiManagerExt.md)等相关接口。 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## 导入模块 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci```js 14e41f4b71Sopenharmony_ciimport wifiext from '@ohos.wifiext'; 15e41f4b71Sopenharmony_ci``` 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## wifiext.enableHotspot 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_cienableHotspot(): boolean; 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci使能WLAN热点。 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT_EXT 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**返回值:** 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci | **类型** | **说明** | 30e41f4b71Sopenharmony_ci | -------- | -------- | 31e41f4b71Sopenharmony_ci | boolean | 操作结果, true: 成功, false: 失败。 | 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci## wifiext.disableHotspot 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_cidisableHotspot(): boolean; 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci去使能WLAN热点。 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT_EXT 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci**返回值:** 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci | **类型** | **说明** | 47e41f4b71Sopenharmony_ci | -------- | -------- | 48e41f4b71Sopenharmony_ci | boolean | 操作结果, true: 成功, false: 失败。 | 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci## wifiext.getSupportedPowerModel 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_cigetSupportedPowerModel(): Promise<Array<PowerModel>> 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci获取支持的功率模式,使用Promise异步回调。 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci**返回值:** 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci | 类型 | 说明 | 64e41f4b71Sopenharmony_ci | -------- | -------- | 65e41f4b71Sopenharmony_ci | Promise<Array<[PowerModel](#powermodel)>> | Promise对象。表示功率模式。 | 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci## PowerModel 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci表示功率模式的枚举。 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 | 75e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 76e41f4b71Sopenharmony_ci| SLEEPING | 0 | 睡眠模式。 | 77e41f4b71Sopenharmony_ci| GENERAL | 1 | 常规模式。 | 78e41f4b71Sopenharmony_ci| THROUGH_WALL | 2 | 穿墙模式。 | 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci## wifiext.getSupportedPowerModel 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_cigetSupportedPowerModel(callback: AsyncCallback<Array<PowerModel>>): void 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci获取支持的功率模式,使用callback异步回调。 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci**参数:** 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci | 参数名 | 类型 | 必填 | 说明 | 94e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 95e41f4b71Sopenharmony_ci | callback | AsyncCallback<Array<[PowerModel](#powermodel)>> | 是 | 回调函数。当操作成功时,err为0,data表示支持的功率模式。如果err为非0,表示处理出现错误。 | 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci## wifiext.getPowerModel 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_cigetPowerModel(): Promise<PowerModel> 101e41f4b71Sopenharmony_ci 102e41f4b71Sopenharmony_ci获取功率模式,使用Promise异步回调。 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci**返回值:** 109e41f4b71Sopenharmony_ci 110e41f4b71Sopenharmony_ci | 类型 | 说明 | 111e41f4b71Sopenharmony_ci | -------- | -------- | 112e41f4b71Sopenharmony_ci | Promise<[PowerModel](#powermodel)> | Promise对象。表示功率模式。 | 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ci## wifiext.getPowerModel 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_cigetPowerModel(callback: AsyncCallback<PowerModel>): void 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci获取功率模式,使用callback异步回调。 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci**参数:** 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci | 参数名 | 类型 | 必填 | 说明 | 128e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 129e41f4b71Sopenharmony_ci | callback | AsyncCallback<[PowerModel](#powermodel)> | 是 | 回调函数。当操作成功时,err为0,data表示功率模式。如果err为非0,表示处理出现错误。 | 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci## wifiext.setPowerModel 133e41f4b71Sopenharmony_ci 134e41f4b71Sopenharmony_cisetPowerModel(model: PowerModel) : boolean; 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci 设置功率模式。 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT_EXT 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Extension 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci**参数:** 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci | 参数名 | 类型 | 必填 | 说明 | 145e41f4b71Sopenharmony_ci | -------- | -------- | -------- | -------- | 146e41f4b71Sopenharmony_ci | model | [PowerModel](#powermodel) | 是 | 功率模式。 | 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci**返回值:** 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci | **类型** | **说明** | 151e41f4b71Sopenharmony_ci | -------- | -------- | 152e41f4b71Sopenharmony_ci | boolean | 操作结果, true: 成功, false: 失败。 | 153