1e41f4b71Sopenharmony_ci# @ohos.wifiManager (WLAN)(系统接口)
2e41f4b71Sopenharmony_ci该模块主要提供WLAN基础功能、P2P(peer-to-peer)功能和WLAN消息通知的相应服务,让应用可以通过WLAN和其他设备互联互通。
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci> **说明:**
5e41f4b71Sopenharmony_ci> 本模块首批接口从API version 6开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
6e41f4b71Sopenharmony_ci> 当前页面仅包含本模块的系统接口,其他公开接口参见[@ohos.wifiManager (WLAN)](js-apis-wifiManager.md)
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci## 导入模块
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci```ts
11e41f4b71Sopenharmony_ciimport { wifiManager } from '@kit.ConnectivityKit';
12e41f4b71Sopenharmony_ci```
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## wifiManager.enableWifi<sup>9+</sup>
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_cienableWifi(): void
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci使能WLAN,异步接口,需要通过注册"wifiStateChange"事件的回调来监听是否打开成功。
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
21e41f4b71Sopenharmony_ci
22e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION  仅系统应用可用。
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**错误码:**
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
31e41f4b71Sopenharmony_ci| -------- | -------- |
32e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
33e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
34e41f4b71Sopenharmony_ci| 801 | Capability not supported.          | 
35e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
36e41f4b71Sopenharmony_ci| 2501003  | Operation failed because the service is being closed. |
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci**示例:**
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci```ts
41e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci	try {
44e41f4b71Sopenharmony_ci		wifiManager.enableWifi();
45e41f4b71Sopenharmony_ci	}catch(error){
46e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
47e41f4b71Sopenharmony_ci	}
48e41f4b71Sopenharmony_ci```
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci## wifiManager.disableWifi<sup>9+</sup>
51e41f4b71Sopenharmony_ci
52e41f4b71Sopenharmony_cidisableWifi(): void
53e41f4b71Sopenharmony_ci
54e41f4b71Sopenharmony_ci去使能WLAN,异步接口,需要通过注册"wifiStateChange"事件的回调来监听是否关闭成功。
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci**错误码:**
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
65e41f4b71Sopenharmony_ci
66e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
67e41f4b71Sopenharmony_ci| -------- | -------- |
68e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
69e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
70e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
71e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
72e41f4b71Sopenharmony_ci| 2501004  | Operation failed because the service is being opened. |
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci**示例:**
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci```ts
77e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci	try {
80e41f4b71Sopenharmony_ci		wifiManager.disableWifi();
81e41f4b71Sopenharmony_ci	}catch(error){
82e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
83e41f4b71Sopenharmony_ci	}
84e41f4b71Sopenharmony_ci```
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci## wifiManager.enableSemiWifi<sup>12+</sup>
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_cienableSemiWifi(): void
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci使能WLAN半关闭(STA关闭、其他P2p、Hml可用),异步接口,需要通过注册"wifiStateChange"事件的回调来监听是否使能成功。
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION  仅系统应用可用。
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci**错误码:**
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
103e41f4b71Sopenharmony_ci| -------- | -------- |
104e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
105e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
106e41f4b71Sopenharmony_ci| 801 | Capability not supported.          | 
107e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
108e41f4b71Sopenharmony_ci| 2501004  | Operation failed because the service is being opened. |
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**示例:**
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci```ts
113e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci	try {
116e41f4b71Sopenharmony_ci		wifiManager.enableSemiWifi();
117e41f4b71Sopenharmony_ci	} catch(error) {
118e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
119e41f4b71Sopenharmony_ci	}
120e41f4b71Sopenharmony_ci```
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci## wifiManager.startScan<sup>10+</sup>
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_cistartScan(): void
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci启动WLAN扫描。
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**错误码:**
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
139e41f4b71Sopenharmony_ci| -------- | -------- |
140e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
141e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
142e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
143e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**示例:**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci```ts
148e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci	try {
151e41f4b71Sopenharmony_ci		wifiManager.startScan();
152e41f4b71Sopenharmony_ci	}catch(error){
153e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
154e41f4b71Sopenharmony_ci	}
155e41f4b71Sopenharmony_ci```
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci## wifiManager.setScanAlwaysAllowed<sup>10+</sup>
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_cisetScanAlwaysAllowed(isScanAlwaysAllowed: boolean): void
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci设置是否始终允许扫描。
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.SET_WIFI_CONFIG
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**参数:**
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
172e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
173e41f4b71Sopenharmony_ci| isScanAlwaysAllowed | boolean | 是 | 是否始终允许扫描。 |
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci**错误码:**
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
180e41f4b71Sopenharmony_ci  | -------- | -------- |
181e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
182e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
183e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
184e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
185e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci```ts
188e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci	try {
191e41f4b71Sopenharmony_ci		let isScanAlwaysAllowed = true;
192e41f4b71Sopenharmony_ci		wifiManager.setScanAlwaysAllowed(isScanAlwaysAllowed);
193e41f4b71Sopenharmony_ci	}catch(error){
194e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
195e41f4b71Sopenharmony_ci	}
196e41f4b71Sopenharmony_ci```
197e41f4b71Sopenharmony_ci
198e41f4b71Sopenharmony_ci## wifiManager.getScanAlwaysAllowed<sup>10+</sup>
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_cigetScanAlwaysAllowed(): boolean
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci获取是否始终允许扫描。
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.GET_WIFI_CONFIG
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci**返回值:**
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci| **类型** | **说明** |
213e41f4b71Sopenharmony_ci| -------- | -------- |
214e41f4b71Sopenharmony_ci| boolean| 是否始终允许扫描。 true 表示允许触发扫描,false表示在禁用wifi时不允许触发扫描|
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci**错误码:**
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
221e41f4b71Sopenharmony_ci| -------- | -------- |
222e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
223e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
224e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
225e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci**示例:**
228e41f4b71Sopenharmony_ci
229e41f4b71Sopenharmony_ci```ts
230e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci	try {
233e41f4b71Sopenharmony_ci		let isScanAlwaysAllowed = wifiManager.getScanAlwaysAllowed();
234e41f4b71Sopenharmony_ci		console.info("isScanAlwaysAllowed:" + isScanAlwaysAllowed);
235e41f4b71Sopenharmony_ci	}catch(error){
236e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
237e41f4b71Sopenharmony_ci	}
238e41f4b71Sopenharmony_ci```
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci## wifiManager.addDeviceConfig<sup>9+</sup>
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ciaddDeviceConfig(config: WifiDeviceConfig): Promise&lt;number&gt;
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci添加网络配置,使用Promise异步回调。
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.SET_WIFI_CONFIG
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**参数:**
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
255e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
256e41f4b71Sopenharmony_ci| config | [WifiDeviceConfig](#wifideviceconfig9) | 是 | WLAN配置信息。如果bssidType未指定值,则bssidType默认为随机设备地址类型。 |
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci**返回值:**
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci  | **类型** | **说明** |
261e41f4b71Sopenharmony_ci  | -------- | -------- |
262e41f4b71Sopenharmony_ci  | Promise&lt;number&gt; | Promise对象。返回添加的网络配置ID,如果值为-1表示添加失败。 |
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci**错误码:**
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
267e41f4b71Sopenharmony_ci
268e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
269e41f4b71Sopenharmony_ci| -------- | -------- |
270e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
271e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
272e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
273e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
274e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
275e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci**示例:**
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ci```ts
280e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci	try {
283e41f4b71Sopenharmony_ci		let config:wifiManager.WifiDeviceConfig = {
284e41f4b71Sopenharmony_ci			ssid : "****",
285e41f4b71Sopenharmony_ci			preSharedKey : "****",
286e41f4b71Sopenharmony_ci			securityType : 0
287e41f4b71Sopenharmony_ci		}
288e41f4b71Sopenharmony_ci		wifiManager.addDeviceConfig(config).then(result => {
289e41f4b71Sopenharmony_ci			console.info("result:" + JSON.stringify(result));
290e41f4b71Sopenharmony_ci		}).catch((err:number) => {
291e41f4b71Sopenharmony_ci			console.error("failed:" + JSON.stringify(err));
292e41f4b71Sopenharmony_ci		});
293e41f4b71Sopenharmony_ci	}catch(error){
294e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
295e41f4b71Sopenharmony_ci	}
296e41f4b71Sopenharmony_ci```
297e41f4b71Sopenharmony_ci
298e41f4b71Sopenharmony_ci## WifiDeviceConfig<sup>9+</sup>
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ciWLAN配置信息。
301e41f4b71Sopenharmony_ci
302e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci| **名称** | **类型** | **可读** | **可写** | **说明** |
306e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
307e41f4b71Sopenharmony_ci| creatorUid | number | 是 | 否 | 创建用户的ID。 <br /> **系统接口:** 此接口为系统接口。 |
308e41f4b71Sopenharmony_ci| disableReason | number | 是 | 否 | 禁用原因。 <br /> **系统接口:** 此接口为系统接口。 |
309e41f4b71Sopenharmony_ci| netId | number | 是 | 否 | 分配的网络ID。 <br /> **系统接口:** 此接口为系统接口。 |
310e41f4b71Sopenharmony_ci| randomMacType | number | 是 | 否 | MAC地址类型。0 - 随机MAC地址,1 - 设备MAC地址 <br /> **系统接口:** 此接口为系统接口。 |
311e41f4b71Sopenharmony_ci| randomMacAddr | string | 是 | 否 | MAC地址。<br /> **系统接口:** 此接口为系统接口。 |
312e41f4b71Sopenharmony_ci| ipType | [IpType](#iptype9) | 是 | 否 | IP地址类型。 <br /> **系统接口:** 此接口为系统接口。 |
313e41f4b71Sopenharmony_ci| staticIp | [IpConfig](#ipconfig9) | 是 | 否 | 静态IP配置信息。 <br /> **系统接口:** 此接口为系统接口。 |
314e41f4b71Sopenharmony_ci| proxyConfig<sup>10+</sup> | [WifiProxyConfig](#wifiproxyconfig10) | 是 | 否 | 代理配置。  <br /> **系统接口:** 此接口为系统接口。|
315e41f4b71Sopenharmony_ci| configStatus<sup>12+</sup> | number | 是 | 否 | 返回当前网络是否允许参与选网。  <br /> **系统接口:** 此接口为系统接口。|
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci## IpType<sup>9+</sup>
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci表示IP类型的枚举。
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
327e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
328e41f4b71Sopenharmony_ci| STATIC | 0 | 静态IP。 |
329e41f4b71Sopenharmony_ci| DHCP | 1 | 通过DHCP获取。 |
330e41f4b71Sopenharmony_ci| UNKNOWN | 2 | 未指定。 |
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ci## IpConfig<sup>9+</sup>
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ciIP配置信息。
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci| **名称** | **类型** | **可读** | **可写** | **说明** |
342e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
343e41f4b71Sopenharmony_ci| ipAddress | number | 是 | 否 | IP地址。 |
344e41f4b71Sopenharmony_ci| gateway | number | 是 | 否 | 网关。 |
345e41f4b71Sopenharmony_ci| prefixLength | number | 是 | 否 | 掩码。 |
346e41f4b71Sopenharmony_ci| dnsServers | number[] | 是 | 否 | DNS服务器。 |
347e41f4b71Sopenharmony_ci| domains | Array&lt;string&gt; | 是 | 否 | 域信息。 |
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci
350e41f4b71Sopenharmony_ci## WifiProxyConfig<sup>10+</sup>
351e41f4b71Sopenharmony_ci
352e41f4b71Sopenharmony_ciWifi 代理配置。
353e41f4b71Sopenharmony_ci
354e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
357e41f4b71Sopenharmony_ci
358e41f4b71Sopenharmony_ci| **名称** | **类型** | **可读** | **可写** | **说明** |
359e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
360e41f4b71Sopenharmony_ci| proxyMethod | ProxyMethod | 是 | 否 | 代理方法 |
361e41f4b71Sopenharmony_ci| pacWebAddress | string | 是 | 否 | 自动配置代理的PAC web 地址。 |
362e41f4b71Sopenharmony_ci| serverHostName | string | 是 | 否 | 手动配置代理的服务器主机名。 |
363e41f4b71Sopenharmony_ci| serverPort | number | 是 | 否 | 手动配置代理的服务器端口。 |
364e41f4b71Sopenharmony_ci| exclusionObjects | string | 是 | 否 | 手动配置代理的排除对象,对象用“,”分隔。|
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci## ProxyMethod<sup>10+</sup>
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci表示WiFi代理方法的枚举。
369e41f4b71Sopenharmony_ci
370e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
375e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
376e41f4b71Sopenharmony_ci| METHOD_NONE  | 0 | 不使用代理。 |
377e41f4b71Sopenharmony_ci| METHOD_AUTO  | 1 | 使用自动配置的代理。 |
378e41f4b71Sopenharmony_ci| METHOD_MANUAL  | 2 | 使用手动配置的代理。 |
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci## wifiManager.addDeviceConfig<sup>9+</sup>
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ciaddDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback&lt;number&gt;): void
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci添加网络配置,使用callback异步回调。
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.SET_WIFI_CONFIG
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci**参数:**
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
395e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
396e41f4b71Sopenharmony_ci| config | [WifiDeviceConfig](#wifideviceconfig9) | 是 | WLAN配置信息。如果bssidType未指定值,则bssidType默认为随机设备地址类型。 |
397e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt; | 是 | 回调函数。当操作成功时,err为0,data为添加的网络配置ID,如果data值为-1,表示添加失败。当error为非0,表示处理出现错误。 |
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**错误码:**
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
404e41f4b71Sopenharmony_ci| -------- | -------- |
405e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
406e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
407e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
408e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
409e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
410e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
411e41f4b71Sopenharmony_ci
412e41f4b71Sopenharmony_ci**示例:**
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_ci```ts
415e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci	try {
418e41f4b71Sopenharmony_ci		let config:wifiManager.WifiDeviceConfig = {
419e41f4b71Sopenharmony_ci			ssid : "****",
420e41f4b71Sopenharmony_ci			preSharedKey : "****",
421e41f4b71Sopenharmony_ci			securityType : 0
422e41f4b71Sopenharmony_ci		}
423e41f4b71Sopenharmony_ci		wifiManager.addDeviceConfig(config,(error,result) => {
424e41f4b71Sopenharmony_ci			console.info("result:" + JSON.stringify(result));
425e41f4b71Sopenharmony_ci		});	
426e41f4b71Sopenharmony_ci	}catch(error){
427e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
428e41f4b71Sopenharmony_ci	}
429e41f4b71Sopenharmony_ci```
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci## wifiManager.connectToNetwork<sup>9+</sup>
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ciconnectToNetwork(networkId: number): void
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci连接到指定网络(如果当前已经连接到热点,请先使用disconnect()接口断开连接)。
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
439e41f4b71Sopenharmony_ci
440e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ci**参数:**
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
447e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
448e41f4b71Sopenharmony_ci  | networkId | number | 是 | 待连接的网络配置ID。 |
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci**错误码:**
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
455e41f4b71Sopenharmony_ci| -------- | -------- |
456e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
457e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
458e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
459e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
460e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
461e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled.|
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci**示例:**
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_ci```ts
466e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci	try {
469e41f4b71Sopenharmony_ci		let networkId = 0;
470e41f4b71Sopenharmony_ci		wifiManager.connectToNetwork(networkId);
471e41f4b71Sopenharmony_ci	}catch(error){
472e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
473e41f4b71Sopenharmony_ci	}	
474e41f4b71Sopenharmony_ci```
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci## wifiManager.connectToDevice<sup>9+</sup>
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ciconnectToDevice(config: WifiDeviceConfig): void
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ci连接到指定网络(如果当前已经连接到热点,请先使用disconnect()接口断开连接)。
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.SET_WIFI_CONFIGohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci**系统能力:**
487e41f4b71Sopenharmony_ci  SystemCapability.Communication.WiFi.STA
488e41f4b71Sopenharmony_ci
489e41f4b71Sopenharmony_ci**参数:**
490e41f4b71Sopenharmony_ci
491e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
492e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
493e41f4b71Sopenharmony_ci| config | [WifiDeviceConfig](#wifideviceconfig9) | 是 | WLAN配置信息。如果bssidType未指定值,则bssidType默认为随机设备地址类型。 |
494e41f4b71Sopenharmony_ci
495e41f4b71Sopenharmony_ci**错误码:**
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
498e41f4b71Sopenharmony_ci
499e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
500e41f4b71Sopenharmony_ci| -------- | -------- |
501e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
502e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
503e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
504e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
505e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
506e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled.|
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci**示例:**
509e41f4b71Sopenharmony_ci```ts
510e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci	try {
513e41f4b71Sopenharmony_ci		let config:wifiManager.WifiDeviceConfig = {
514e41f4b71Sopenharmony_ci			ssid : "****",
515e41f4b71Sopenharmony_ci			preSharedKey : "****",
516e41f4b71Sopenharmony_ci			securityType : 3
517e41f4b71Sopenharmony_ci		}
518e41f4b71Sopenharmony_ci		wifiManager.connectToDevice(config);
519e41f4b71Sopenharmony_ci				
520e41f4b71Sopenharmony_ci	}catch(error){
521e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
522e41f4b71Sopenharmony_ci	}
523e41f4b71Sopenharmony_ci```
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci## wifiManager.disconnect<sup>9+</sup>
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_cidisconnect(): void
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci断开连接的网络。
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci**系统能力:**
536e41f4b71Sopenharmony_ci  SystemCapability.Communication.WiFi.STA
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci**错误码:**
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
543e41f4b71Sopenharmony_ci| -------- | -------- |
544e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
545e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
546e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
547e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
548e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci**示例:**
551e41f4b71Sopenharmony_ci```ts
552e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci	try {
555e41f4b71Sopenharmony_ci		wifiManager.disconnect();
556e41f4b71Sopenharmony_ci	}catch(error){
557e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
558e41f4b71Sopenharmony_ci	}
559e41f4b71Sopenharmony_ci```
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci## WifiLinkedInfo<sup>9+</sup>
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci提供WLAN连接的相关信息。
565e41f4b71Sopenharmony_ci
566e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
567e41f4b71Sopenharmony_ci
568e41f4b71Sopenharmony_ci| 名称 | 类型 | 可读 | 可写 | 说明 |
569e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
570e41f4b71Sopenharmony_ci| networkId | number | 是 | 否 | 网络配置ID。 <br /> **系统接口:** 此接口为系统接口。 |
571e41f4b71Sopenharmony_ci| chload | number | 是 | 否 | 连接负载,值越大表示负载约高。 <br /> **系统接口:** 此接口为系统接口。 |
572e41f4b71Sopenharmony_ci| snr | number | 是 | 否 | 信噪比。 <br /> **系统接口:** 此接口为系统接口。 |
573e41f4b71Sopenharmony_ci| suppState | [SuppState](#suppstate9) | 是 | 否 | 请求状态。 <br /> **系统接口:** 此接口为系统接口。 |
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci## SuppState<sup>9+</sup>
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci表示请求状态的枚举。
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
586e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
587e41f4b71Sopenharmony_ci| DISCONNECTED | 0 | 已断开。 |
588e41f4b71Sopenharmony_ci| INTERFACE_DISABLED | 1 | 接口禁用。 |
589e41f4b71Sopenharmony_ci| INACTIVE | 2 | 未激活。 |
590e41f4b71Sopenharmony_ci| SCANNING | 3 | 扫描中。 |
591e41f4b71Sopenharmony_ci| AUTHENTICATING | 4 | 认证中。 |
592e41f4b71Sopenharmony_ci| ASSOCIATING | 5 | 关联中。 |
593e41f4b71Sopenharmony_ci| ASSOCIATED | 6 | 已关联。 |
594e41f4b71Sopenharmony_ci| FOUR_WAY_HANDSHAKE | 7 | 四次握手。 |
595e41f4b71Sopenharmony_ci| GROUP_HANDSHAKE | 8 | 组握手。 |
596e41f4b71Sopenharmony_ci| COMPLETED | 9 | 所有认证已完成。 |
597e41f4b71Sopenharmony_ci| UNINITIALIZED | 10 | 连接建立失败。 |
598e41f4b71Sopenharmony_ci| INVALID | 11 | 无效值。 |
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci## wifiManager.getSupportedFeatures<sup>9+</sup>
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_cigetSupportedFeatures(): number
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci查询设备支持的特性。
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
608e41f4b71Sopenharmony_ci
609e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO
610e41f4b71Sopenharmony_ci
611e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.Core
612e41f4b71Sopenharmony_ci
613e41f4b71Sopenharmony_ci**返回值:**
614e41f4b71Sopenharmony_ci
615e41f4b71Sopenharmony_ci  | **类型** | **说明** |
616e41f4b71Sopenharmony_ci  | -------- | -------- |
617e41f4b71Sopenharmony_ci  | number | 支持的特性值。 |
618e41f4b71Sopenharmony_ci
619e41f4b71Sopenharmony_ci**特性ID值枚举:**
620e41f4b71Sopenharmony_ci
621e41f4b71Sopenharmony_ci| 枚举值 | 说明 |
622e41f4b71Sopenharmony_ci| -------- | -------- |
623e41f4b71Sopenharmony_ci| 0x0001 | 基础结构模式特性。 |
624e41f4b71Sopenharmony_ci| 0x0002 | 5&nbsp;GHz带宽特性。 |
625e41f4b71Sopenharmony_ci| 0x0004 | GAS/ANQP特性。 |
626e41f4b71Sopenharmony_ci| 0x0008 | Wifi-Direct特性。 |
627e41f4b71Sopenharmony_ci| 0x0010 | Soft&nbsp;AP特性。 |
628e41f4b71Sopenharmony_ci| 0x0040 | Wi-Fi&nbsp;AWare组网特性。 |
629e41f4b71Sopenharmony_ci| 0x8000 | AP&nbsp;STA共存特性。 |
630e41f4b71Sopenharmony_ci| 0x8000000 | WPA3-Personal&nbsp;SAE特性。 |
631e41f4b71Sopenharmony_ci| 0x10000000 | WPA3-Enterprise&nbsp;Suite-B |
632e41f4b71Sopenharmony_ci| 0x20000000 | 增强开放特性。 |
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci**错误码:**
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
639e41f4b71Sopenharmony_ci| -------- | -------- |
640e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
641e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
642e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
643e41f4b71Sopenharmony_ci| 2401000  | Operation failed.|
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci**示例:**
646e41f4b71Sopenharmony_ci```ts
647e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
648e41f4b71Sopenharmony_ci
649e41f4b71Sopenharmony_ci	try {
650e41f4b71Sopenharmony_ci		let ret = wifiManager.getSupportedFeatures();
651e41f4b71Sopenharmony_ci		console.info("supportedFeatures:" + ret);
652e41f4b71Sopenharmony_ci	}catch(error){
653e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
654e41f4b71Sopenharmony_ci	}
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci```
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_ci## wifiManager.getDeviceMacAddress<sup>9+</sup>
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_cigetDeviceMacAddress(): string[]
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci获取设备的MAC地址。
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_LOCAL_MACohos.permission.GET_WIFI_INFO,仅系统应用可用。
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
670e41f4b71Sopenharmony_ci
671e41f4b71Sopenharmony_ci**返回值:**
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci  | **类型** | **说明** |
674e41f4b71Sopenharmony_ci  | -------- | -------- |
675e41f4b71Sopenharmony_ci  | string[] | MAC地址。 |
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci**错误码:**
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
682e41f4b71Sopenharmony_ci| -------- | -------- |
683e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
684e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
685e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
686e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
687e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled.|
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**示例:**
690e41f4b71Sopenharmony_ci```ts
691e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci	try {
694e41f4b71Sopenharmony_ci		let ret = wifiManager.getDeviceMacAddress();
695e41f4b71Sopenharmony_ci		console.info("deviceMacAddress:" + JSON.stringify(ret));
696e41f4b71Sopenharmony_ci	}catch(error){
697e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
698e41f4b71Sopenharmony_ci	}
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci```
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_ci## wifiManager.getWifiDetailState<sup>12+</sup>
703e41f4b71Sopenharmony_ci
704e41f4b71Sopenharmony_cigetWifiDetailState(): WifiDetailState
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ci获取Wifi开关详细状态。
707e41f4b71Sopenharmony_ci
708e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
709e41f4b71Sopenharmony_ci
710e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
711e41f4b71Sopenharmony_ci
712e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
713e41f4b71Sopenharmony_ci
714e41f4b71Sopenharmony_ci**返回值:**
715e41f4b71Sopenharmony_ci
716e41f4b71Sopenharmony_ci  | **类型** | **说明** |
717e41f4b71Sopenharmony_ci  | -------- | -------- |
718e41f4b71Sopenharmony_ci  | WifiDetailState | Wifi枚举状态。 |
719e41f4b71Sopenharmony_ci
720e41f4b71Sopenharmony_ci**错误码:**
721e41f4b71Sopenharmony_ci
722e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
723e41f4b71Sopenharmony_ci
724e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
725e41f4b71Sopenharmony_ci| -------- | -------- |
726e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
727e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
728e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
729e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**示例:**
732e41f4b71Sopenharmony_ci```ts
733e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci	try {
736e41f4b71Sopenharmony_ci		let ret = wifiManager.getWifiDetailState();
737e41f4b71Sopenharmony_ci		console.info("wifiDetailState:" + ret);
738e41f4b71Sopenharmony_ci	} catch(error) {
739e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
740e41f4b71Sopenharmony_ci	}
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci```
743e41f4b71Sopenharmony_ci
744e41f4b71Sopenharmony_ci## WifiDetailState<sup>12+</sup>
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_ci表示Wifi开关状态的枚举。
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
753e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
754e41f4b71Sopenharmony_ci| UNKNOWN | -1 | 未指定。 |
755e41f4b71Sopenharmony_ci| INACTIVE | 0 | 已关闭。 |
756e41f4b71Sopenharmony_ci| ACTIVATED | 1 | 已激活。 |
757e41f4b71Sopenharmony_ci| ACTIVATING | 2 | 激活中。 |
758e41f4b71Sopenharmony_ci| DEACTIVATING | 3 | 关闭中。 |
759e41f4b71Sopenharmony_ci| SEMI_ACTIVATING | 4 | 半关闭中。 |
760e41f4b71Sopenharmony_ci| SEMI_ACTIVE | 5 | 已半关闭。 |
761e41f4b71Sopenharmony_ci
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci## wifiManager.reassociate<sup>9+</sup>
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_cireassociate(): void
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ci重新关联网络。
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci**错误码:**
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
780e41f4b71Sopenharmony_ci| -------- | -------- |
781e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
782e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
783e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
784e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
785e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled.|
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci**示例:**
788e41f4b71Sopenharmony_ci```ts
789e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci	try {
792e41f4b71Sopenharmony_ci		wifiManager.reassociate();
793e41f4b71Sopenharmony_ci	}catch(error){
794e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
795e41f4b71Sopenharmony_ci	}
796e41f4b71Sopenharmony_ci```
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ci## wifiManager.reconnect<sup>9+</sup>
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_cireconnect(): void
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci重新连接网络。
803e41f4b71Sopenharmony_ci
804e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ci**错误码:**
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
815e41f4b71Sopenharmony_ci| -------- | -------- |
816e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
817e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
818e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
819e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
820e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled.|
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci**示例:**
823e41f4b71Sopenharmony_ci```ts
824e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci	try {
827e41f4b71Sopenharmony_ci		wifiManager.reconnect();
828e41f4b71Sopenharmony_ci	}catch(error){
829e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
830e41f4b71Sopenharmony_ci	}
831e41f4b71Sopenharmony_ci```
832e41f4b71Sopenharmony_ci
833e41f4b71Sopenharmony_ci## wifiManager.getDeviceConfigs<sup>9+</sup>
834e41f4b71Sopenharmony_ci
835e41f4b71Sopenharmony_cigetDeviceConfigs(): &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig9)&gt;
836e41f4b71Sopenharmony_ci
837e41f4b71Sopenharmony_ci获取网络配置。
838e41f4b71Sopenharmony_ci
839e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ci**需要权限:**
842e41f4b71Sopenharmony_ci
843e41f4b71Sopenharmony_ciAPI 9:ohos.permission.GET_WIFI_INFOohos.permission.LOCATIONohos.permission.APPROXIMATELY_LOCATIONohos.permission.GET_WIFI_CONFIG
844e41f4b71Sopenharmony_ci
845e41f4b71Sopenharmony_ciAPI 10起:ohos.permission.GET_WIFI_INFOohos.permission.GET_WIFI_CONFIG
846e41f4b71Sopenharmony_ci
847e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
848e41f4b71Sopenharmony_ci
849e41f4b71Sopenharmony_ci**返回值:**
850e41f4b71Sopenharmony_ci
851e41f4b71Sopenharmony_ci  | **类型** | **说明** |
852e41f4b71Sopenharmony_ci  | -------- | -------- |
853e41f4b71Sopenharmony_ci  | &nbsp;Array&lt;[WifiDeviceConfig](#wifideviceconfig9)&gt; | 网络配置信息的数组。 |
854e41f4b71Sopenharmony_ci
855e41f4b71Sopenharmony_ci**错误码:**
856e41f4b71Sopenharmony_ci
857e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
858e41f4b71Sopenharmony_ci
859e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
860e41f4b71Sopenharmony_ci| -------- | -------- |
861e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
862e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
863e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
864e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
865e41f4b71Sopenharmony_ci
866e41f4b71Sopenharmony_ci**示例:**
867e41f4b71Sopenharmony_ci```ts
868e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci	try {
871e41f4b71Sopenharmony_ci		let configs = wifiManager.getDeviceConfigs();
872e41f4b71Sopenharmony_ci		console.info("configs:" + JSON.stringify(configs));
873e41f4b71Sopenharmony_ci	}catch(error){
874e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
875e41f4b71Sopenharmony_ci	}
876e41f4b71Sopenharmony_ci```
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci## wifiManager.updateNetwork<sup>9+</sup>
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ciupdateNetwork(config: WifiDeviceConfig): number
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci更新网络配置。
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.SET_WIFI_CONFIG
887e41f4b71Sopenharmony_ci
888e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ci**参数:**
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
893e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
894e41f4b71Sopenharmony_ci  | config | [WifiDeviceConfig](#wifideviceconfig9) | 是 | WLAN配置信息。 |
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci**返回值:**
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci  | **类型** | **说明** |
899e41f4b71Sopenharmony_ci  | -------- | -------- |
900e41f4b71Sopenharmony_ci  | number | 返回更新的网络配置ID,如果值为-1表示更新失败。 |
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ci**错误码:**
903e41f4b71Sopenharmony_ci
904e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
905e41f4b71Sopenharmony_ci
906e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
907e41f4b71Sopenharmony_ci| -------- | -------- |
908e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
909e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
910e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
911e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
912e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
913e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci**示例:**
916e41f4b71Sopenharmony_ci```ts
917e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
918e41f4b71Sopenharmony_ci
919e41f4b71Sopenharmony_ci	try {
920e41f4b71Sopenharmony_ci		let config:wifiManager.WifiDeviceConfig = {
921e41f4b71Sopenharmony_ci			ssid : "****",
922e41f4b71Sopenharmony_ci			preSharedKey : "****",
923e41f4b71Sopenharmony_ci			securityType : 3
924e41f4b71Sopenharmony_ci		}
925e41f4b71Sopenharmony_ci		let ret = wifiManager.updateNetwork(config);
926e41f4b71Sopenharmony_ci		console.info("ret:" + ret);
927e41f4b71Sopenharmony_ci	}catch(error){
928e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
929e41f4b71Sopenharmony_ci	}
930e41f4b71Sopenharmony_ci```
931e41f4b71Sopenharmony_ci
932e41f4b71Sopenharmony_ci## wifiManager.disableNetwork<sup>9+</sup>
933e41f4b71Sopenharmony_ci
934e41f4b71Sopenharmony_cidisableNetwork(netId: number): void
935e41f4b71Sopenharmony_ci
936e41f4b71Sopenharmony_ci去使能网络配置。
937e41f4b71Sopenharmony_ci
938e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
939e41f4b71Sopenharmony_ci
940e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
941e41f4b71Sopenharmony_ci
942e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
943e41f4b71Sopenharmony_ci
944e41f4b71Sopenharmony_ci**参数:**
945e41f4b71Sopenharmony_ci
946e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
947e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
948e41f4b71Sopenharmony_ci  | netId | number | 是 | 网络配置ID。 |
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci**错误码:**
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
955e41f4b71Sopenharmony_ci| -------- | -------- |
956e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
957e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
958e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
959e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
960e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
961e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
962e41f4b71Sopenharmony_ci
963e41f4b71Sopenharmony_ci**示例:**
964e41f4b71Sopenharmony_ci```ts
965e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
966e41f4b71Sopenharmony_ci
967e41f4b71Sopenharmony_ci	try {
968e41f4b71Sopenharmony_ci		let netId = 0;
969e41f4b71Sopenharmony_ci		wifiManager.disableNetwork(netId);		
970e41f4b71Sopenharmony_ci	}catch(error){
971e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
972e41f4b71Sopenharmony_ci	}
973e41f4b71Sopenharmony_ci```
974e41f4b71Sopenharmony_ci
975e41f4b71Sopenharmony_ci## wifiManager.removeAllNetwork<sup>9+</sup>
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ciremoveAllNetwork(): void
978e41f4b71Sopenharmony_ci
979e41f4b71Sopenharmony_ci移除所有网络配置。
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ci**错误码:**
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
992e41f4b71Sopenharmony_ci| -------- | -------- |
993e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
994e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
995e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
996e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
997e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci**示例:**
1000e41f4b71Sopenharmony_ci```ts
1001e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ci	try {
1004e41f4b71Sopenharmony_ci		wifiManager.removeAllNetwork();		
1005e41f4b71Sopenharmony_ci	}catch(error){
1006e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1007e41f4b71Sopenharmony_ci	}
1008e41f4b71Sopenharmony_ci```
1009e41f4b71Sopenharmony_ci
1010e41f4b71Sopenharmony_ci## wifiManager.removeDevice<sup>9+</sup>
1011e41f4b71Sopenharmony_ci
1012e41f4b71Sopenharmony_ciremoveDevice(id: number): void
1013e41f4b71Sopenharmony_ci
1014e41f4b71Sopenharmony_ci移除指定的网络配置。
1015e41f4b71Sopenharmony_ci
1016e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1021e41f4b71Sopenharmony_ci
1022e41f4b71Sopenharmony_ci**参数:**
1023e41f4b71Sopenharmony_ci
1024e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
1025e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1026e41f4b71Sopenharmony_ci  | id | number | 是 | 网络配置ID。 |
1027e41f4b71Sopenharmony_ci
1028e41f4b71Sopenharmony_ci**错误码:**
1029e41f4b71Sopenharmony_ci
1030e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1031e41f4b71Sopenharmony_ci
1032e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1033e41f4b71Sopenharmony_ci| -------- | -------- |
1034e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1035e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1036e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
1037e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1038e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1039e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci**示例:**
1042e41f4b71Sopenharmony_ci```ts
1043e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1044e41f4b71Sopenharmony_ci
1045e41f4b71Sopenharmony_ci	try {
1046e41f4b71Sopenharmony_ci		let id = 0;
1047e41f4b71Sopenharmony_ci		wifiManager.removeDevice(id);		
1048e41f4b71Sopenharmony_ci	}catch(error){
1049e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1050e41f4b71Sopenharmony_ci	}
1051e41f4b71Sopenharmony_ci```
1052e41f4b71Sopenharmony_ci
1053e41f4b71Sopenharmony_ci## wifiManager.get5GChannelList<sup>10+</sup>
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ciget5GChannelList(): Array&lt;number&gt;
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ci获取当前设备支持的5G信道列表。
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1060e41f4b71Sopenharmony_ci
1061e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.GET_WIFI_CONFIG
1062e41f4b71Sopenharmony_ci
1063e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1064e41f4b71Sopenharmony_ci
1065e41f4b71Sopenharmony_ci**返回值:**
1066e41f4b71Sopenharmony_ci
1067e41f4b71Sopenharmony_ci  | **类型** | **说明** |
1068e41f4b71Sopenharmony_ci  | -------- | -------- |
1069e41f4b71Sopenharmony_ci  | &nbsp;Array&lt;number&gt; | 设备支持的5G信道列表。 |
1070e41f4b71Sopenharmony_ci
1071e41f4b71Sopenharmony_ci**错误码:**
1072e41f4b71Sopenharmony_ci
1073e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1074e41f4b71Sopenharmony_ci
1075e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1076e41f4b71Sopenharmony_ci| -------- | -------- |
1077e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1078e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1079e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1080e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ci**示例:**
1083e41f4b71Sopenharmony_ci```ts
1084e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci	try {
1087e41f4b71Sopenharmony_ci		let channelList = wifiManager.get5GChannelList();
1088e41f4b71Sopenharmony_ci		console.info("channelList:" + JSON.stringify(channelList));		
1089e41f4b71Sopenharmony_ci	}catch(error){
1090e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1091e41f4b71Sopenharmony_ci	}
1092e41f4b71Sopenharmony_ci```
1093e41f4b71Sopenharmony_ci## wifiManager.getDisconnectedReason<sup>10+</sup>
1094e41f4b71Sopenharmony_ci
1095e41f4b71Sopenharmony_cigetDisconnectedReason(): DisconnectedReason
1096e41f4b71Sopenharmony_ci
1097e41f4b71Sopenharmony_ci获取最近一次断连原因。
1098e41f4b71Sopenharmony_ci
1099e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1100e41f4b71Sopenharmony_ci
1101e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.GET_WIFI_CONFIG
1102e41f4b71Sopenharmony_ci
1103e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1104e41f4b71Sopenharmony_ci
1105e41f4b71Sopenharmony_ci**错误码:**
1106e41f4b71Sopenharmony_ci
1107e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1108e41f4b71Sopenharmony_ci
1109e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1110e41f4b71Sopenharmony_ci| -------- | -------- |
1111e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1112e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1113e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1114e41f4b71Sopenharmony_ci
1115e41f4b71Sopenharmony_ci**返回值:**
1116e41f4b71Sopenharmony_ci
1117e41f4b71Sopenharmony_ci| **类型** | **说明** |
1118e41f4b71Sopenharmony_ci| -------- | -------- |
1119e41f4b71Sopenharmony_ci| [DisconnectedReason](#disconnectedreason-10) | 最近断开的原因 |
1120e41f4b71Sopenharmony_ci
1121e41f4b71Sopenharmony_ci**示例:**
1122e41f4b71Sopenharmony_ci```ts
1123e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1124e41f4b71Sopenharmony_ci
1125e41f4b71Sopenharmony_ci	try {
1126e41f4b71Sopenharmony_ci		let disconnectedReason = wifiManager.getDisconnectedReason();	
1127e41f4b71Sopenharmony_ci        console.info("disconnectedReason:" + disconnectedReason);
1128e41f4b71Sopenharmony_ci	}catch(error){
1129e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1130e41f4b71Sopenharmony_ci	}
1131e41f4b71Sopenharmony_ci```
1132e41f4b71Sopenharmony_ci
1133e41f4b71Sopenharmony_ci## DisconnectedReason <sup>10+</sup>
1134e41f4b71Sopenharmony_ci
1135e41f4b71Sopenharmony_ci表示wifi断开原因的枚举。
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1138e41f4b71Sopenharmony_ci
1139e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1140e41f4b71Sopenharmony_ci
1141e41f4b71Sopenharmony_ci| 名称 | 值 | 说明 |
1142e41f4b71Sopenharmony_ci| -------- | -------- | -------- |
1143e41f4b71Sopenharmony_ci| DISC_REASON_DEFAULT  | 0 | 默认原因。 |
1144e41f4b71Sopenharmony_ci| DISC_REASON_WRONG_PWD  | 1 | 密码错误。 |
1145e41f4b71Sopenharmony_ci| DISC_REASON_CONNECTION_FULL  | 2 | 路由器的连接数已达到最大数量限制。 |
1146e41f4b71Sopenharmony_ci
1147e41f4b71Sopenharmony_ci## wifiManager.startPortalCertification<sup>11+</sup>
1148e41f4b71Sopenharmony_ci
1149e41f4b71Sopenharmony_cistartPortalCertification(): void
1150e41f4b71Sopenharmony_ci
1151e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1152e41f4b71Sopenharmony_ci
1153e41f4b71Sopenharmony_ci启动portal认证。
1154e41f4b71Sopenharmony_ci
1155e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION
1156e41f4b71Sopenharmony_ci
1157e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1158e41f4b71Sopenharmony_ci
1159e41f4b71Sopenharmony_ci**错误码:**
1160e41f4b71Sopenharmony_ci
1161e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1162e41f4b71Sopenharmony_ci
1163e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1164e41f4b71Sopenharmony_ci| -------- | -------- |
1165e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1166e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1167e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1168e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1169e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
1170e41f4b71Sopenharmony_ci
1171e41f4b71Sopenharmony_ci**示例:**
1172e41f4b71Sopenharmony_ci
1173e41f4b71Sopenharmony_ci```ts
1174e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1175e41f4b71Sopenharmony_ci
1176e41f4b71Sopenharmony_ci	try {
1177e41f4b71Sopenharmony_ci		wifiManager.startPortalCertification();
1178e41f4b71Sopenharmony_ci	}catch(error){
1179e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1180e41f4b71Sopenharmony_ci	}
1181e41f4b71Sopenharmony_ci```
1182e41f4b71Sopenharmony_ci
1183e41f4b71Sopenharmony_ci## wifiManager.enableHiLinkHandshake<sup>12+</sup>
1184e41f4b71Sopenharmony_ci
1185e41f4b71Sopenharmony_cienableHiLinkHandshake(isHiLinkEnable: boolean, bssid: string, config: WifiDeviceConfig): void
1186e41f4b71Sopenharmony_ci
1187e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1188e41f4b71Sopenharmony_ci
1189e41f4b71Sopenharmony_ci设置是否使能hiLink。
1190e41f4b71Sopenharmony_ci
1191e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION
1192e41f4b71Sopenharmony_ci
1193e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1194e41f4b71Sopenharmony_ci
1195e41f4b71Sopenharmony_ci**参数:**
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
1198e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1199e41f4b71Sopenharmony_ci| isHiLinkEnable | boolean | 是 | 是否使能hiLink。true:使能,&nbsp;false:去使能。 |
1200e41f4b71Sopenharmony_ci| bssid | string | 是 | 热点的mac地址,例如:00:11:22:33:44:55。 |
1201e41f4b71Sopenharmony_ci| config | [WifiDeviceConfig](#wifideviceconfig9) | 是 | WLAN的配置信息。config.bssid必须和第二个参数bssid保持一致。如果bssidType未指定值,则bssidType默认为随机设备地址类型。 |
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ci**错误码:**
1204e41f4b71Sopenharmony_ci
1205e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1206e41f4b71Sopenharmony_ci
1207e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1208e41f4b71Sopenharmony_ci| -------- | -------- |
1209e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1210e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1211e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
1212e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1213e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1214e41f4b71Sopenharmony_ci| 2501001  | Wi-Fi STA disabled. |
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_ci**示例:**
1217e41f4b71Sopenharmony_ci
1218e41f4b71Sopenharmony_ci```ts
1219e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1220e41f4b71Sopenharmony_ci	// config数据可以通过getScanInfoList接口获取,只有WifiScanInfo.isHiLinkNetwork为true的热点,才能正常使用该接口
1221e41f4b71Sopenharmony_ci	let config:wifiManager.WifiDeviceConfig = {
1222e41f4b71Sopenharmony_ci		ssid : "****",
1223e41f4b71Sopenharmony_ci		preSharedKey : "****",
1224e41f4b71Sopenharmony_ci		securityType : 0,
1225e41f4b71Sopenharmony_ci		bssid : "38:37:8b:80:bf:cc",
1226e41f4b71Sopenharmony_ci		bssidType : 1,
1227e41f4b71Sopenharmony_ci		isHiddenSsid : false
1228e41f4b71Sopenharmony_ci	}	
1229e41f4b71Sopenharmony_ci	try {
1230e41f4b71Sopenharmony_ci		wifiManager.enableHiLinkHandshake(true, config.bssid, config);
1231e41f4b71Sopenharmony_ci	}catch(error){
1232e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1233e41f4b71Sopenharmony_ci	}
1234e41f4b71Sopenharmony_ci```
1235e41f4b71Sopenharmony_ci
1236e41f4b71Sopenharmony_ci## wifiManager.factoryReset<sup>11+</sup>
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_cifactoryReset(): void
1239e41f4b71Sopenharmony_ci
1240e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1241e41f4b71Sopenharmony_ci
1242e41f4b71Sopenharmony_ci重置wifi相关配置。
1243e41f4b71Sopenharmony_ci
1244e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.SET_WIFI_CONFIG
1245e41f4b71Sopenharmony_ci
1246e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ci**错误码:**
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1253e41f4b71Sopenharmony_ci| -------- | -------- |
1254e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1255e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1256e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1257e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1258e41f4b71Sopenharmony_ci
1259e41f4b71Sopenharmony_ci**示例:**
1260e41f4b71Sopenharmony_ci
1261e41f4b71Sopenharmony_ci```ts
1262e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1263e41f4b71Sopenharmony_ci
1264e41f4b71Sopenharmony_ci	try {
1265e41f4b71Sopenharmony_ci		wifiManager.factoryReset();
1266e41f4b71Sopenharmony_ci	}catch(error){
1267e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1268e41f4b71Sopenharmony_ci	}
1269e41f4b71Sopenharmony_ci```
1270e41f4b71Sopenharmony_ci## wifiManager.enableHotspot<sup>9+</sup>
1271e41f4b71Sopenharmony_ci
1272e41f4b71Sopenharmony_cienableHotspot(): void
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_ci使能热点,异步接口,是否打开成功需要注册并监听hotspotStateChange的回调。
1275e41f4b71Sopenharmony_ci
1276e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1277e41f4b71Sopenharmony_ci
1278e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1279e41f4b71Sopenharmony_ci
1280e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1281e41f4b71Sopenharmony_ci
1282e41f4b71Sopenharmony_ci**错误码:**
1283e41f4b71Sopenharmony_ci
1284e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1285e41f4b71Sopenharmony_ci
1286e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1287e41f4b71Sopenharmony_ci| -------- | -------- |
1288e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1289e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1290e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1291e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1292e41f4b71Sopenharmony_ci
1293e41f4b71Sopenharmony_ci**示例:**
1294e41f4b71Sopenharmony_ci```ts
1295e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1296e41f4b71Sopenharmony_ci
1297e41f4b71Sopenharmony_ci	try {
1298e41f4b71Sopenharmony_ci		wifiManager.enableHotspot();	
1299e41f4b71Sopenharmony_ci	}catch(error){
1300e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1301e41f4b71Sopenharmony_ci	}
1302e41f4b71Sopenharmony_ci```
1303e41f4b71Sopenharmony_ci
1304e41f4b71Sopenharmony_ci## wifiManager.disableHotspot<sup>9+</sup>
1305e41f4b71Sopenharmony_ci
1306e41f4b71Sopenharmony_cidisableHotspot(): void
1307e41f4b71Sopenharmony_ci
1308e41f4b71Sopenharmony_ci去使能热点 ,异步接口,是否关闭成功需要注册并监听hotspotStateChange的回调。
1309e41f4b71Sopenharmony_ci
1310e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1311e41f4b71Sopenharmony_ci
1312e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1313e41f4b71Sopenharmony_ci
1314e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci**错误码:**
1317e41f4b71Sopenharmony_ci
1318e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1321e41f4b71Sopenharmony_ci| -------- | -------- |
1322e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1323e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1324e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1325e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1326e41f4b71Sopenharmony_ci
1327e41f4b71Sopenharmony_ci**示例:**
1328e41f4b71Sopenharmony_ci```ts
1329e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1330e41f4b71Sopenharmony_ci
1331e41f4b71Sopenharmony_ci	try {
1332e41f4b71Sopenharmony_ci		wifiManager.disableHotspot();	
1333e41f4b71Sopenharmony_ci	}catch(error){
1334e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1335e41f4b71Sopenharmony_ci	}
1336e41f4b71Sopenharmony_ci```
1337e41f4b71Sopenharmony_ci
1338e41f4b71Sopenharmony_ci## wifiManager.isHotspotDualBandSupported<sup>9+</sup>
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ciisHotspotDualBandSupported(): boolean
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci热点是否支持双频。
1343e41f4b71Sopenharmony_ci
1344e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1345e41f4b71Sopenharmony_ci
1346e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1347e41f4b71Sopenharmony_ci
1348e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1349e41f4b71Sopenharmony_ci
1350e41f4b71Sopenharmony_ci**返回值:**
1351e41f4b71Sopenharmony_ci
1352e41f4b71Sopenharmony_ci  | **类型** | **说明** |
1353e41f4b71Sopenharmony_ci  | -------- | -------- |
1354e41f4b71Sopenharmony_ci  | boolean | true:支持,&nbsp;false:不支持.|
1355e41f4b71Sopenharmony_ci
1356e41f4b71Sopenharmony_ci**错误码:**
1357e41f4b71Sopenharmony_ci
1358e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1359e41f4b71Sopenharmony_ci
1360e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1361e41f4b71Sopenharmony_ci| -------- | -------- |
1362e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1363e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1364e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1365e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1366e41f4b71Sopenharmony_ci
1367e41f4b71Sopenharmony_ci**示例:**
1368e41f4b71Sopenharmony_ci```ts
1369e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1370e41f4b71Sopenharmony_ci
1371e41f4b71Sopenharmony_ci	try {
1372e41f4b71Sopenharmony_ci		let ret = wifiManager.isHotspotDualBandSupported();
1373e41f4b71Sopenharmony_ci		console.info("result:" + ret);		
1374e41f4b71Sopenharmony_ci	}catch(error){
1375e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1376e41f4b71Sopenharmony_ci	}
1377e41f4b71Sopenharmony_ci```
1378e41f4b71Sopenharmony_ci
1379e41f4b71Sopenharmony_ci## wifiManager.isHotspotActive<sup>9+</sup>
1380e41f4b71Sopenharmony_ci
1381e41f4b71Sopenharmony_ciisHotspotActive(): boolean
1382e41f4b71Sopenharmony_ci
1383e41f4b71Sopenharmony_ci热点是否已使能。
1384e41f4b71Sopenharmony_ci
1385e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1386e41f4b71Sopenharmony_ci
1387e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO
1388e41f4b71Sopenharmony_ci
1389e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1390e41f4b71Sopenharmony_ci
1391e41f4b71Sopenharmony_ci**返回值:**
1392e41f4b71Sopenharmony_ci
1393e41f4b71Sopenharmony_ci  | **类型** | **说明** |
1394e41f4b71Sopenharmony_ci  | -------- | -------- |
1395e41f4b71Sopenharmony_ci  | boolean | true:已使能,&nbsp;false:未使能.|
1396e41f4b71Sopenharmony_ci
1397e41f4b71Sopenharmony_ci**错误码:**
1398e41f4b71Sopenharmony_ci
1399e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1400e41f4b71Sopenharmony_ci
1401e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1402e41f4b71Sopenharmony_ci| -------- | -------- |
1403e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1404e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1405e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1406e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1407e41f4b71Sopenharmony_ci
1408e41f4b71Sopenharmony_ci**示例:**
1409e41f4b71Sopenharmony_ci```ts
1410e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1411e41f4b71Sopenharmony_ci
1412e41f4b71Sopenharmony_ci	try {
1413e41f4b71Sopenharmony_ci		let ret = wifiManager.isHotspotActive();
1414e41f4b71Sopenharmony_ci		console.info("result:" + ret);		
1415e41f4b71Sopenharmony_ci	}catch(error){
1416e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1417e41f4b71Sopenharmony_ci	}
1418e41f4b71Sopenharmony_ci```
1419e41f4b71Sopenharmony_ci
1420e41f4b71Sopenharmony_ci## wifiManager.setHotspotConfig<sup>9+</sup>
1421e41f4b71Sopenharmony_ci
1422e41f4b71Sopenharmony_cisetHotspotConfig(config: HotspotConfig): void
1423e41f4b71Sopenharmony_ci
1424e41f4b71Sopenharmony_ci设置热点配置信息。
1425e41f4b71Sopenharmony_ci
1426e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1427e41f4b71Sopenharmony_ci
1428e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.GET_WIFI_CONFIG
1429e41f4b71Sopenharmony_ci
1430e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1431e41f4b71Sopenharmony_ci
1432e41f4b71Sopenharmony_ci**参数:**
1433e41f4b71Sopenharmony_ci
1434e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
1435e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1436e41f4b71Sopenharmony_ci  | config | [HotspotConfig](#hotspotconfig9) | 是 | 热点配置信息。 |
1437e41f4b71Sopenharmony_ci
1438e41f4b71Sopenharmony_ci**错误码:**
1439e41f4b71Sopenharmony_ci
1440e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1441e41f4b71Sopenharmony_ci
1442e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1443e41f4b71Sopenharmony_ci| -------- | -------- |
1444e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1445e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1446e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Incorrect parameter types.<br>2. Parameter verification failed. |
1447e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1448e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1449e41f4b71Sopenharmony_ci
1450e41f4b71Sopenharmony_ci**示例:**
1451e41f4b71Sopenharmony_ci```ts
1452e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1453e41f4b71Sopenharmony_ci
1454e41f4b71Sopenharmony_ci	try {
1455e41f4b71Sopenharmony_ci		let config:wifiManager.HotspotConfig = {
1456e41f4b71Sopenharmony_ci			ssid: "****",
1457e41f4b71Sopenharmony_ci			securityType: 3,
1458e41f4b71Sopenharmony_ci			band: 0,
1459e41f4b71Sopenharmony_ci			channel: 0,
1460e41f4b71Sopenharmony_ci			preSharedKey: "****",
1461e41f4b71Sopenharmony_ci			maxConn: 0
1462e41f4b71Sopenharmony_ci		}
1463e41f4b71Sopenharmony_ci		let ret = wifiManager.setHotspotConfig(config);
1464e41f4b71Sopenharmony_ci		console.info("result:" + ret);		
1465e41f4b71Sopenharmony_ci	}catch(error){
1466e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1467e41f4b71Sopenharmony_ci	}
1468e41f4b71Sopenharmony_ci```
1469e41f4b71Sopenharmony_ci
1470e41f4b71Sopenharmony_ci## HotspotConfig<sup>9+</sup>
1471e41f4b71Sopenharmony_ci
1472e41f4b71Sopenharmony_ci热点配置信息。
1473e41f4b71Sopenharmony_ci
1474e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1475e41f4b71Sopenharmony_ci
1476e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1477e41f4b71Sopenharmony_ci
1478e41f4b71Sopenharmony_ci| **名称** | **类型** | **可读** | **可写** | **说明** |
1479e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
1480e41f4b71Sopenharmony_ci| ssid | string | 是 | 是 | 热点的SSID,编码格式为UTF-8。 |
1481e41f4b71Sopenharmony_ci| securityType | [WifiSecurityType](js-apis-wifiManager.md#wifisecuritytype9)| 是 | 是 | 加密类型。 |
1482e41f4b71Sopenharmony_ci| band | number | 是 | 是 | 热点的带宽。1: 2.4G, 2: 5G, 3: 双模频段 |
1483e41f4b71Sopenharmony_ci| channel<sup>10+</sup> | number | 是 | 是 | 热点的信道(2.4G:1~14,5G:7~196)。 |
1484e41f4b71Sopenharmony_ci| preSharedKey | string | 是 | 是 | 热点的密钥。 |
1485e41f4b71Sopenharmony_ci| maxConn | number | 是 | 是 | 最大设备连接数。 |
1486e41f4b71Sopenharmony_ci
1487e41f4b71Sopenharmony_ci## wifiManager.getHotspotConfig<sup>9+</sup>
1488e41f4b71Sopenharmony_ci
1489e41f4b71Sopenharmony_cigetHotspotConfig(): HotspotConfig
1490e41f4b71Sopenharmony_ci
1491e41f4b71Sopenharmony_ci获取热点配置信息。
1492e41f4b71Sopenharmony_ci
1493e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1494e41f4b71Sopenharmony_ci
1495e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.GET_WIFI_CONFIG
1496e41f4b71Sopenharmony_ci
1497e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1498e41f4b71Sopenharmony_ci
1499e41f4b71Sopenharmony_ci**返回值:**
1500e41f4b71Sopenharmony_ci
1501e41f4b71Sopenharmony_ci  | **类型** | **说明** |
1502e41f4b71Sopenharmony_ci  | -------- | -------- |
1503e41f4b71Sopenharmony_ci  | [HotspotConfig](#hotspotconfig9) | 热点的配置信息。 |
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_ci**错误码:**
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1508e41f4b71Sopenharmony_ci
1509e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1510e41f4b71Sopenharmony_ci| -------- | -------- |
1511e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1512e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1513e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1514e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1515e41f4b71Sopenharmony_ci
1516e41f4b71Sopenharmony_ci**示例:**
1517e41f4b71Sopenharmony_ci```ts
1518e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1519e41f4b71Sopenharmony_ci
1520e41f4b71Sopenharmony_ci	try {
1521e41f4b71Sopenharmony_ci		let config = wifiManager.getHotspotConfig();
1522e41f4b71Sopenharmony_ci		console.info("result:" + JSON.stringify(config));		
1523e41f4b71Sopenharmony_ci	}catch(error){
1524e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1525e41f4b71Sopenharmony_ci	}
1526e41f4b71Sopenharmony_ci```
1527e41f4b71Sopenharmony_ci
1528e41f4b71Sopenharmony_ci## wifiManager.getStations<sup>9+</sup>
1529e41f4b71Sopenharmony_ci
1530e41f4b71Sopenharmony_cigetStations(): &nbsp;Array&lt;StationInfo&gt;
1531e41f4b71Sopenharmony_ci
1532e41f4b71Sopenharmony_ci获取连接的设备。
1533e41f4b71Sopenharmony_ci
1534e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1535e41f4b71Sopenharmony_ci
1536e41f4b71Sopenharmony_ci**需要权限:**
1537e41f4b71Sopenharmony_ci
1538e41f4b71Sopenharmony_ciAPI 9:ohos.permission.GET_WIFI_INFOohos.permission.LOCATIONohos.permission.APPROXIMATELY_LOCATIONohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_ciAPI 10起:ohos.permission.GET_WIFI_INFOohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1543e41f4b71Sopenharmony_ci
1544e41f4b71Sopenharmony_ci**返回值:**
1545e41f4b71Sopenharmony_ci
1546e41f4b71Sopenharmony_ci| **类型** | **说明** |
1547e41f4b71Sopenharmony_ci| -------- | -------- |
1548e41f4b71Sopenharmony_ci| &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt; | 连接的设备数组。如果应用申请了ohos.permission.GET_WIFI_PEERS_MAC权限,则返回结果中的macAddress为真实设备地址,否则为随机设备地址。 |
1549e41f4b71Sopenharmony_ci
1550e41f4b71Sopenharmony_ci**错误码:**
1551e41f4b71Sopenharmony_ci
1552e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1553e41f4b71Sopenharmony_ci
1554e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1555e41f4b71Sopenharmony_ci| -------- | -------- |
1556e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1557e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1558e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1559e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1560e41f4b71Sopenharmony_ci
1561e41f4b71Sopenharmony_ci**示例:**
1562e41f4b71Sopenharmony_ci```ts
1563e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1564e41f4b71Sopenharmony_ci
1565e41f4b71Sopenharmony_ci	try {
1566e41f4b71Sopenharmony_ci		let stations = wifiManager.getStations();
1567e41f4b71Sopenharmony_ci		console.info("result:" + JSON.stringify(stations));		
1568e41f4b71Sopenharmony_ci	}catch(error){
1569e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1570e41f4b71Sopenharmony_ci	}
1571e41f4b71Sopenharmony_ci```
1572e41f4b71Sopenharmony_ci
1573e41f4b71Sopenharmony_ci## StationInfo<sup>9+</sup>
1574e41f4b71Sopenharmony_ci
1575e41f4b71Sopenharmony_ci接入的设备信息。
1576e41f4b71Sopenharmony_ci
1577e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1580e41f4b71Sopenharmony_ci
1581e41f4b71Sopenharmony_ci| **名称** | **类型** | **可读** | **可写** | **说明** |
1582e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | -------- |
1583e41f4b71Sopenharmony_ci| name | string | 是 | 否 | 设备名称。 |
1584e41f4b71Sopenharmony_ci| macAddress | string | 是 | 否 | MAC地址。 |
1585e41f4b71Sopenharmony_ci| macAddressType<sup>10+</sup> | [DeviceAddressType](js-apis-wifiManager.md#deviceaddresstype10) | 是 | 否 | MAC地址类型。 |
1586e41f4b71Sopenharmony_ci| ipAddress | string | 是 | 否 | IP地址。 |
1587e41f4b71Sopenharmony_ci
1588e41f4b71Sopenharmony_ci## wifiManager.addHotspotBlockList<sup>11+</sup>
1589e41f4b71Sopenharmony_ci
1590e41f4b71Sopenharmony_ciaddHotspotBlockList(stationInfo: StationInfo)
1591e41f4b71Sopenharmony_ci
1592e41f4b71Sopenharmony_ci将设备添加到热点的阻止连接设备列表中,列表中的设备将不能访问热点。
1593e41f4b71Sopenharmony_ci
1594e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1595e41f4b71Sopenharmony_ci
1596e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1597e41f4b71Sopenharmony_ci
1598e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1599e41f4b71Sopenharmony_ci
1600e41f4b71Sopenharmony_ci**参数:**
1601e41f4b71Sopenharmony_ci
1602e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
1603e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1604e41f4b71Sopenharmony_ci| stationInfo | [StationInfo](#stationinfo9) | 是 | 将添加到热点的阻止列表中的设备。 |
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ci**错误码:**
1607e41f4b71Sopenharmony_ci
1608e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1609e41f4b71Sopenharmony_ci
1610e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1611e41f4b71Sopenharmony_ci| -------- | -------- |
1612e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1613e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1614e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Incorrect parameter types.<br>2. Parameter verification failed. |
1615e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1616e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1617e41f4b71Sopenharmony_ci
1618e41f4b71Sopenharmony_ci**示例:**
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ci```ts
1621e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1622e41f4b71Sopenharmony_ci
1623e41f4b71Sopenharmony_ci	try {
1624e41f4b71Sopenharmony_ci		let config:wifiManager.StationInfo = {
1625e41f4b71Sopenharmony_ci			name : "testSsid",
1626e41f4b71Sopenharmony_ci			macAddress : "11:22:33:44:55:66",
1627e41f4b71Sopenharmony_ci			ipAddress : "192.168.1.111"
1628e41f4b71Sopenharmony_ci		}
1629e41f4b71Sopenharmony_ci		// 热点开启后,才能正常将设备添加到连接阻止列表中
1630e41f4b71Sopenharmony_ci		wifiManager.addHotspotBlockList(config);
1631e41f4b71Sopenharmony_ci	}catch(error){
1632e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1633e41f4b71Sopenharmony_ci	}
1634e41f4b71Sopenharmony_ci```
1635e41f4b71Sopenharmony_ci
1636e41f4b71Sopenharmony_ci## wifiManager.delHotspotBlockList<sup>11+</sup>
1637e41f4b71Sopenharmony_ci
1638e41f4b71Sopenharmony_cidelHotspotBlockList(stationInfo: StationInfo)
1639e41f4b71Sopenharmony_ci
1640e41f4b71Sopenharmony_ci将设备从热点的阻止列表中删除。
1641e41f4b71Sopenharmony_ci
1642e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1643e41f4b71Sopenharmony_ci
1644e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1645e41f4b71Sopenharmony_ci
1646e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1647e41f4b71Sopenharmony_ci
1648e41f4b71Sopenharmony_ci**参数:**
1649e41f4b71Sopenharmony_ci
1650e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
1651e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1652e41f4b71Sopenharmony_ci| stationInfo | [StationInfo](#stationinfo9) | 是 | 将从热点的阻止列表中删除的设备。 |
1653e41f4b71Sopenharmony_ci
1654e41f4b71Sopenharmony_ci**错误码:**
1655e41f4b71Sopenharmony_ci
1656e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1657e41f4b71Sopenharmony_ci
1658e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1659e41f4b71Sopenharmony_ci| -------- | -------- |
1660e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1661e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1662e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Incorrect parameter types.<br>2. Parameter verification failed. |
1663e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1664e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1665e41f4b71Sopenharmony_ci
1666e41f4b71Sopenharmony_ci**示例:**
1667e41f4b71Sopenharmony_ci
1668e41f4b71Sopenharmony_ci```ts
1669e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1670e41f4b71Sopenharmony_ci
1671e41f4b71Sopenharmony_ci	try {
1672e41f4b71Sopenharmony_ci		let config:wifiManager.StationInfo = {
1673e41f4b71Sopenharmony_ci			name : "testSsid",
1674e41f4b71Sopenharmony_ci			macAddress : "11:22:33:44:55:66",
1675e41f4b71Sopenharmony_ci			ipAddress : "192.168.1.111"
1676e41f4b71Sopenharmony_ci		}
1677e41f4b71Sopenharmony_ci		wifiManager.delHotspotBlockList(config);
1678e41f4b71Sopenharmony_ci	}catch(error){
1679e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1680e41f4b71Sopenharmony_ci	}
1681e41f4b71Sopenharmony_ci```
1682e41f4b71Sopenharmony_ci
1683e41f4b71Sopenharmony_ci## wifiManager.getHotspotBlockList<sup>11+</sup>
1684e41f4b71Sopenharmony_ci
1685e41f4b71Sopenharmony_cigetHotspotBlockList(): Array&lt;StationInfo&gt;
1686e41f4b71Sopenharmony_ci
1687e41f4b71Sopenharmony_ci获取热点的阻止列表。
1688e41f4b71Sopenharmony_ci
1689e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1690e41f4b71Sopenharmony_ci
1691e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFOohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
1692e41f4b71Sopenharmony_ci
1693e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
1694e41f4b71Sopenharmony_ci
1695e41f4b71Sopenharmony_ci**返回值:**
1696e41f4b71Sopenharmony_ci
1697e41f4b71Sopenharmony_ci| **类型** | **说明** |
1698e41f4b71Sopenharmony_ci| -------- | -------- |
1699e41f4b71Sopenharmony_ci| &nbsp;Array&lt;[StationInfo](#stationinfo9)&gt; | 热点的阻止列表。 |
1700e41f4b71Sopenharmony_ci
1701e41f4b71Sopenharmony_ci**错误码:**
1702e41f4b71Sopenharmony_ci
1703e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1704e41f4b71Sopenharmony_ci
1705e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1706e41f4b71Sopenharmony_ci  | -------- | -------- |
1707e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1708e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1709e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. |
1710e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1711e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
1712e41f4b71Sopenharmony_ci
1713e41f4b71Sopenharmony_ci**示例:**
1714e41f4b71Sopenharmony_ci
1715e41f4b71Sopenharmony_ci```ts
1716e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1717e41f4b71Sopenharmony_ci
1718e41f4b71Sopenharmony_ci	try {
1719e41f4b71Sopenharmony_ci		let data = wifiManager.getHotspotBlockList();
1720e41f4b71Sopenharmony_ci		console.info("result:" + JSON.stringify(data));
1721e41f4b71Sopenharmony_ci	}catch(error){
1722e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1723e41f4b71Sopenharmony_ci	}
1724e41f4b71Sopenharmony_ci```
1725e41f4b71Sopenharmony_ci
1726e41f4b71Sopenharmony_ci## wifiManager.deletePersistentGroup<sup>9+</sup>
1727e41f4b71Sopenharmony_ci
1728e41f4b71Sopenharmony_cideletePersistentGroup(netId: number): void
1729e41f4b71Sopenharmony_ci
1730e41f4b71Sopenharmony_ci删除永久组。
1731e41f4b71Sopenharmony_ci
1732e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1733e41f4b71Sopenharmony_ci
1734e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION
1735e41f4b71Sopenharmony_ci
1736e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.P2P
1737e41f4b71Sopenharmony_ci
1738e41f4b71Sopenharmony_ci**参数:**
1739e41f4b71Sopenharmony_ci
1740e41f4b71Sopenharmony_ci
1741e41f4b71Sopenharmony_ci  | **参数名** | **类型** | 必填 | **说明** |
1742e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1743e41f4b71Sopenharmony_ci  | netId | number | 是 | 组的ID。 |
1744e41f4b71Sopenharmony_ci
1745e41f4b71Sopenharmony_ci**错误码:**
1746e41f4b71Sopenharmony_ci
1747e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1748e41f4b71Sopenharmony_ci
1749e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1750e41f4b71Sopenharmony_ci| -------- | -------- |
1751e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1752e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1753e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1.Incorrect parameter types. |
1754e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1755e41f4b71Sopenharmony_ci| 2801000  | Operation failed. |
1756e41f4b71Sopenharmony_ci| 2801001  | Wi-Fi STA disabled. |
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci**示例:**
1759e41f4b71Sopenharmony_ci```ts
1760e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_ci	try {
1763e41f4b71Sopenharmony_ci		let netId = 0;
1764e41f4b71Sopenharmony_ci		wifiManager.deletePersistentGroup(netId);	
1765e41f4b71Sopenharmony_ci	}catch(error){
1766e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1767e41f4b71Sopenharmony_ci	}
1768e41f4b71Sopenharmony_ci```
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci## wifiManager.getP2pGroups<sup>9+</sup>
1771e41f4b71Sopenharmony_ci
1772e41f4b71Sopenharmony_cigetP2pGroups(): Promise&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;
1773e41f4b71Sopenharmony_ci
1774e41f4b71Sopenharmony_ci获取创建的所有P2P群组信息,使用Promise异步回调。
1775e41f4b71Sopenharmony_ci
1776e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1777e41f4b71Sopenharmony_ci
1778e41f4b71Sopenharmony_ci**需要权限:**
1779e41f4b71Sopenharmony_ci
1780e41f4b71Sopenharmony_ciAPI 9:ohos.permission.GET_WIFI_INFOohos.permission.LOCATIONohos.permission.APPROXIMATELY_LOCATION
1781e41f4b71Sopenharmony_ci
1782e41f4b71Sopenharmony_ciAPI 10起:ohos.permission.GET_WIFI_INFO
1783e41f4b71Sopenharmony_ci
1784e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.P2P
1785e41f4b71Sopenharmony_ci
1786e41f4b71Sopenharmony_ci**返回值:**
1787e41f4b71Sopenharmony_ci
1788e41f4b71Sopenharmony_ci| 类型 | 说明 |
1789e41f4b71Sopenharmony_ci| -------- | -------- |
1790e41f4b71Sopenharmony_ci| Promise&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](js-apis-wifiManager.md#wifip2pgroupinfo9)&gt;&nbsp;&gt; | Promise对象。表示所有群组信息。如果应用申请了ohos.permission.GET_WIFI_PEERS_MAC权限,则返回结果中的deviceAddress为真实设备地址,否则为随机设备地址。 |
1791e41f4b71Sopenharmony_ci
1792e41f4b71Sopenharmony_ci**错误码:**
1793e41f4b71Sopenharmony_ci
1794e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1795e41f4b71Sopenharmony_ci
1796e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1797e41f4b71Sopenharmony_ci| -------- | -------- |
1798e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1799e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1800e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1801e41f4b71Sopenharmony_ci| 2801000  | Operation failed. |
1802e41f4b71Sopenharmony_ci
1803e41f4b71Sopenharmony_ci**示例:**
1804e41f4b71Sopenharmony_ci```ts
1805e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci	wifiManager.getP2pGroups((err, data:wifiManager.WifiP2pGroupInfo) => {
1808e41f4b71Sopenharmony_ci    if (err) {
1809e41f4b71Sopenharmony_ci        console.error("get P2P groups error");
1810e41f4b71Sopenharmony_ci        return;
1811e41f4b71Sopenharmony_ci    }
1812e41f4b71Sopenharmony_ci		console.info("get P2P groups: " + JSON.stringify(data));
1813e41f4b71Sopenharmony_ci	});
1814e41f4b71Sopenharmony_ci
1815e41f4b71Sopenharmony_ci	wifiManager.getP2pGroups().then(data => {
1816e41f4b71Sopenharmony_ci		console.info("get P2P groups: " + JSON.stringify(data));
1817e41f4b71Sopenharmony_ci	});
1818e41f4b71Sopenharmony_ci	
1819e41f4b71Sopenharmony_ci```
1820e41f4b71Sopenharmony_ci
1821e41f4b71Sopenharmony_ci
1822e41f4b71Sopenharmony_ci## wifiManager.getP2pGroups<sup>9+</sup>
1823e41f4b71Sopenharmony_ci
1824e41f4b71Sopenharmony_cigetP2pGroups(callback: AsyncCallback&lt;Array&lt;WifiP2pGroupInfo&gt;&gt;): void
1825e41f4b71Sopenharmony_ci
1826e41f4b71Sopenharmony_ci获取创建的所有P2P群组信息,使用callback方式作为异步方法。
1827e41f4b71Sopenharmony_ci
1828e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1829e41f4b71Sopenharmony_ci
1830e41f4b71Sopenharmony_ci**需要权限:**
1831e41f4b71Sopenharmony_ci
1832e41f4b71Sopenharmony_ciAPI 9:ohos.permission.GET_WIFI_INFOohos.permission.LOCATIONohos.permission.APPROXIMATELY_LOCATION
1833e41f4b71Sopenharmony_ci
1834e41f4b71Sopenharmony_ciAPI 10起:ohos.permission.GET_WIFI_INFO
1835e41f4b71Sopenharmony_ci
1836e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.P2P
1837e41f4b71Sopenharmony_ci
1838e41f4b71Sopenharmony_ci**参数:**
1839e41f4b71Sopenharmony_ci
1840e41f4b71Sopenharmony_ci| 参数名 | 类型 | 必填 | 说明 |
1841e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1842e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;&nbsp;Array&lt;[WifiP2pGroupInfo](js-apis-wifiManager.md#wifip2pgroupinfo9)&gt;&gt; | 是 | 回调函数。当操作成功时,err为0,data表示所有群组信息。如果error为非0,表示处理出现错误。如果应用申请了ohos.permission.GET_WIFI_PEERS_MAC权限,则返回结果中的deviceAddress为真实设备地址,否则为随机设备地址。 |
1843e41f4b71Sopenharmony_ci
1844e41f4b71Sopenharmony_ci**错误码:**
1845e41f4b71Sopenharmony_ci
1846e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1847e41f4b71Sopenharmony_ci
1848e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1849e41f4b71Sopenharmony_ci| -------- | -------- |
1850e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1851e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1852e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1853e41f4b71Sopenharmony_ci| 2801000  | Operation failed. |
1854e41f4b71Sopenharmony_ci| 2801001  | Wi-Fi STA disabled. |
1855e41f4b71Sopenharmony_ci
1856e41f4b71Sopenharmony_ci## wifiManager.setDeviceName<sup>9+</sup>
1857e41f4b71Sopenharmony_ci
1858e41f4b71Sopenharmony_cisetDeviceName(devName: string): void
1859e41f4b71Sopenharmony_ci
1860e41f4b71Sopenharmony_ci设置设备名称。
1861e41f4b71Sopenharmony_ci
1862e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1863e41f4b71Sopenharmony_ci
1864e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.SET_WIFI_INFOohos.permission.MANAGE_WIFI_CONNECTION,仅系统应用可用。
1865e41f4b71Sopenharmony_ci
1866e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.P2P
1867e41f4b71Sopenharmony_ci
1868e41f4b71Sopenharmony_ci**参数:**
1869e41f4b71Sopenharmony_ci
1870e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
1871e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
1872e41f4b71Sopenharmony_ci  | devName | string | 是 | 设备名称。 |
1873e41f4b71Sopenharmony_ci
1874e41f4b71Sopenharmony_ci**错误码:**
1875e41f4b71Sopenharmony_ci
1876e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1877e41f4b71Sopenharmony_ci
1878e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1879e41f4b71Sopenharmony_ci| -------- | -------- |
1880e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1881e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1882e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified.<br>2. Incorrect parameter types. 3. Parameter verification failed. |
1883e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1884e41f4b71Sopenharmony_ci| 2801000  | Operation failed. |
1885e41f4b71Sopenharmony_ci| 2801001  | Wi-Fi STA disabled. |
1886e41f4b71Sopenharmony_ci
1887e41f4b71Sopenharmony_ci**示例:**
1888e41f4b71Sopenharmony_ci```ts
1889e41f4b71Sopenharmony_ci	import { wifiManager } from '@kit.ConnectivityKit';
1890e41f4b71Sopenharmony_ci
1891e41f4b71Sopenharmony_ci	try {
1892e41f4b71Sopenharmony_ci		let name = "****";
1893e41f4b71Sopenharmony_ci		wifiManager.setDeviceName(name);	
1894e41f4b71Sopenharmony_ci	}catch(error){
1895e41f4b71Sopenharmony_ci		console.error("failed:" + JSON.stringify(error));
1896e41f4b71Sopenharmony_ci	}
1897e41f4b71Sopenharmony_ci```
1898e41f4b71Sopenharmony_ci
1899e41f4b71Sopenharmony_ci
1900e41f4b71Sopenharmony_ci## wifiManager.on('streamChange')<sup>9+</sup>
1901e41f4b71Sopenharmony_ci
1902e41f4b71Sopenharmony_cion(type: 'streamChange', callback: Callback&lt;number&gt;): void
1903e41f4b71Sopenharmony_ci
1904e41f4b71Sopenharmony_ci注册WIFI流变更事件。
1905e41f4b71Sopenharmony_ci
1906e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1907e41f4b71Sopenharmony_ci
1908e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_CONNECTION
1909e41f4b71Sopenharmony_ci
1910e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1911e41f4b71Sopenharmony_ci
1912e41f4b71Sopenharmony_ci**参数:**
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
1915e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1916e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"streamChange"字符串。 |
1917e41f4b71Sopenharmony_ci| callback | Callback&lt;number&gt; | 是 | 状态改变回调函数,返回0:无,1:向下,2:向上,3:双向。 |
1918e41f4b71Sopenharmony_ci
1919e41f4b71Sopenharmony_ci**错误码:**
1920e41f4b71Sopenharmony_ci
1921e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1922e41f4b71Sopenharmony_ci
1923e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1924e41f4b71Sopenharmony_ci| -------- | -------- |
1925e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1926e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1927e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1928e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1929e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1930e41f4b71Sopenharmony_ci
1931e41f4b71Sopenharmony_ci## wifiManager.off('streamChange')<sup>9+</sup>
1932e41f4b71Sopenharmony_ci
1933e41f4b71Sopenharmony_cioff(type: 'streamChange', callback?: Callback&lt;number&gt;): void
1934e41f4b71Sopenharmony_ci
1935e41f4b71Sopenharmony_ci取消注册WIFI流变更事件。
1936e41f4b71Sopenharmony_ci
1937e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1938e41f4b71Sopenharmony_ci
1939e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_CONNECTION
1940e41f4b71Sopenharmony_ci
1941e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1942e41f4b71Sopenharmony_ci
1943e41f4b71Sopenharmony_ci**参数:**
1944e41f4b71Sopenharmony_ci
1945e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
1946e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1947e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"streamChange"字符串。 |
1948e41f4b71Sopenharmony_ci| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数,返回0:无,1:向下,2:向上,3:双向。 |
1949e41f4b71Sopenharmony_ci
1950e41f4b71Sopenharmony_ci**错误码:**
1951e41f4b71Sopenharmony_ci
1952e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1953e41f4b71Sopenharmony_ci
1954e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
1955e41f4b71Sopenharmony_ci| -------- | -------- |
1956e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
1957e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
1958e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1959e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
1960e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
1961e41f4b71Sopenharmony_ci
1962e41f4b71Sopenharmony_ci**示例:**
1963e41f4b71Sopenharmony_ci```ts
1964e41f4b71Sopenharmony_ciimport { wifi } from '@kit.ConnectivityKit';
1965e41f4b71Sopenharmony_ci
1966e41f4b71Sopenharmony_cilet recvStreamChangeFunc = (result:number) => {
1967e41f4b71Sopenharmony_ci    console.info("Receive stream change event: " + result);
1968e41f4b71Sopenharmony_ci}
1969e41f4b71Sopenharmony_ci
1970e41f4b71Sopenharmony_ci// Register event
1971e41f4b71Sopenharmony_ciwifi.on("streamChange", recvStreamChangeFunc);
1972e41f4b71Sopenharmony_ci
1973e41f4b71Sopenharmony_ci// Unregister event
1974e41f4b71Sopenharmony_ciwifi.off("streamChange", recvStreamChangeFunc);
1975e41f4b71Sopenharmony_ci
1976e41f4b71Sopenharmony_ci```
1977e41f4b71Sopenharmony_ci## wifiManager.on('deviceConfigChange')<sup>9+</sup>
1978e41f4b71Sopenharmony_ci
1979e41f4b71Sopenharmony_cion(type: 'deviceConfigChange', callback: Callback&lt;number&gt;): void
1980e41f4b71Sopenharmony_ci
1981e41f4b71Sopenharmony_ci注册WIFI设备配置更改事件。
1982e41f4b71Sopenharmony_ci
1983e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
1984e41f4b71Sopenharmony_ci
1985e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO
1986e41f4b71Sopenharmony_ci
1987e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
1988e41f4b71Sopenharmony_ci
1989e41f4b71Sopenharmony_ci**参数:**
1990e41f4b71Sopenharmony_ci
1991e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
1992e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
1993e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"deviceConfigChange"字符串。 |
1994e41f4b71Sopenharmony_ci| callback | Callback&lt;number&gt; | 是 | 状态改变回调函数,返回0: 添加配置, 1: 更改配置, 2: 删除配置. |
1995e41f4b71Sopenharmony_ci
1996e41f4b71Sopenharmony_ci**错误码:**
1997e41f4b71Sopenharmony_ci
1998e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
1999e41f4b71Sopenharmony_ci
2000e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
2001e41f4b71Sopenharmony_ci| -------- | -------- |
2002e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
2003e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
2004e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2005e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
2006e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
2007e41f4b71Sopenharmony_ci
2008e41f4b71Sopenharmony_ci## wifiManager.off('deviceConfigChange')<sup>9+</sup>
2009e41f4b71Sopenharmony_ci
2010e41f4b71Sopenharmony_cioff(type: 'deviceConfigChange', callback?: Callback&lt;number&gt;): void
2011e41f4b71Sopenharmony_ci
2012e41f4b71Sopenharmony_ci取消注册WIFI设备配置更改事件。
2013e41f4b71Sopenharmony_ci
2014e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2015e41f4b71Sopenharmony_ci
2016e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.GET_WIFI_INFO
2017e41f4b71Sopenharmony_ci
2018e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.STA
2019e41f4b71Sopenharmony_ci
2020e41f4b71Sopenharmony_ci**参数:**
2021e41f4b71Sopenharmony_ci
2022e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
2023e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
2024e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"deviceConfigChange"字符串。 |
2025e41f4b71Sopenharmony_ci| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数,返回0: 添加配置, 1: 更改配置, 2: 删除配置.|
2026e41f4b71Sopenharmony_ci
2027e41f4b71Sopenharmony_ci**错误码:**
2028e41f4b71Sopenharmony_ci
2029e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
2030e41f4b71Sopenharmony_ci
2031e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
2032e41f4b71Sopenharmony_ci| -------- | -------- |
2033e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
2034e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
2035e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2036e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
2037e41f4b71Sopenharmony_ci| 2501000  | Operation failed.|
2038e41f4b71Sopenharmony_ci
2039e41f4b71Sopenharmony_ci**示例:**
2040e41f4b71Sopenharmony_ci```ts
2041e41f4b71Sopenharmony_ciimport { wifiManager } from '@kit.ConnectivityKit';
2042e41f4b71Sopenharmony_ci
2043e41f4b71Sopenharmony_cilet recvDeviceConfigChangeFunc = (result:number) => {
2044e41f4b71Sopenharmony_ci    console.info("Receive device config change event: " + result);
2045e41f4b71Sopenharmony_ci}
2046e41f4b71Sopenharmony_ci
2047e41f4b71Sopenharmony_ci// Register event
2048e41f4b71Sopenharmony_ciwifi.on("deviceConfigChange", recvDeviceConfigChangeFunc);
2049e41f4b71Sopenharmony_ci
2050e41f4b71Sopenharmony_ci// Unregister event
2051e41f4b71Sopenharmony_ciwifi.off("deviceConfigChange", recvDeviceConfigChangeFunc);
2052e41f4b71Sopenharmony_ci
2053e41f4b71Sopenharmony_ci```
2054e41f4b71Sopenharmony_ci
2055e41f4b71Sopenharmony_ci## wifiManager.on('hotspotStaJoin')<sup>9+</sup>
2056e41f4b71Sopenharmony_ci
2057e41f4b71Sopenharmony_cion(type: 'hotspotStaJoin', callback: Callback&lt;StationInfo&gt;): void
2058e41f4b71Sopenharmony_ci
2059e41f4b71Sopenharmony_ci注册wifi热点sta加入事件。
2060e41f4b71Sopenharmony_ci
2061e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2062e41f4b71Sopenharmony_ci
2063e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT
2064e41f4b71Sopenharmony_ci
2065e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
2066e41f4b71Sopenharmony_ci
2067e41f4b71Sopenharmony_ci**参数:**
2068e41f4b71Sopenharmony_ci
2069e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
2070e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
2071e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"hotspotStaJoin"字符串。 |
2072e41f4b71Sopenharmony_ci| callback | Callback&lt;StationInfo&gt; | 是 | 状态改变回调函数。 |
2073e41f4b71Sopenharmony_ci
2074e41f4b71Sopenharmony_ci**错误码:**
2075e41f4b71Sopenharmony_ci
2076e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
2077e41f4b71Sopenharmony_ci
2078e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
2079e41f4b71Sopenharmony_ci| -------- | -------- |
2080e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
2081e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
2082e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2083e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
2084e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
2085e41f4b71Sopenharmony_ci
2086e41f4b71Sopenharmony_ci## wifiManager.off('hotspotStaJoin')<sup>9+</sup>
2087e41f4b71Sopenharmony_ci
2088e41f4b71Sopenharmony_cioff(type: 'hotspotStaJoin', callback?: Callback&lt;StationInfo&gt;): void
2089e41f4b71Sopenharmony_ci
2090e41f4b71Sopenharmony_ci取消注册wifi热点sta加入事件。
2091e41f4b71Sopenharmony_ci
2092e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2093e41f4b71Sopenharmony_ci
2094e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT
2095e41f4b71Sopenharmony_ci
2096e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
2097e41f4b71Sopenharmony_ci
2098e41f4b71Sopenharmony_ci**参数:**
2099e41f4b71Sopenharmony_ci
2100e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
2101e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
2102e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"hotspotStaJoin"字符串。 |
2103e41f4b71Sopenharmony_ci| callback | Callback&lt;StationInfo&gt; | 否 | 状态改变回调函数。 |
2104e41f4b71Sopenharmony_ci
2105e41f4b71Sopenharmony_ci**错误码:**
2106e41f4b71Sopenharmony_ci
2107e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
2108e41f4b71Sopenharmony_ci
2109e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
2110e41f4b71Sopenharmony_ci| -------- | -------- |
2111e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
2112e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
2113e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2114e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
2115e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
2116e41f4b71Sopenharmony_ci
2117e41f4b71Sopenharmony_ci**示例:**
2118e41f4b71Sopenharmony_ci```ts
2119e41f4b71Sopenharmony_ciimport { wifiManager } from '@kit.ConnectivityKit';
2120e41f4b71Sopenharmony_ci
2121e41f4b71Sopenharmony_cilet recvHotspotStaJoinFunc = (result:wifiManager.StationInfo) => {
2122e41f4b71Sopenharmony_ci    console.info("Receive hotspot sta join event: " + result);
2123e41f4b71Sopenharmony_ci}
2124e41f4b71Sopenharmony_ci
2125e41f4b71Sopenharmony_ci// Register event
2126e41f4b71Sopenharmony_ciwifiManager.on("hotspotStaJoin", recvHotspotStaJoinFunc);
2127e41f4b71Sopenharmony_ci
2128e41f4b71Sopenharmony_ci// Unregister event
2129e41f4b71Sopenharmony_ciwifiManager.off("hotspotStaJoin", recvHotspotStaJoinFunc);
2130e41f4b71Sopenharmony_ci
2131e41f4b71Sopenharmony_ci```
2132e41f4b71Sopenharmony_ci
2133e41f4b71Sopenharmony_ci## wifiManager.on('hotspotStaLeave')<sup>9+</sup>
2134e41f4b71Sopenharmony_ci
2135e41f4b71Sopenharmony_cion(type: 'hotspotStaLeave', callback: Callback&lt;StationInfo&gt;): void
2136e41f4b71Sopenharmony_ci
2137e41f4b71Sopenharmony_ci注册wifi热点sta离开事件。
2138e41f4b71Sopenharmony_ci
2139e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2140e41f4b71Sopenharmony_ci
2141e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT
2142e41f4b71Sopenharmony_ci
2143e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
2144e41f4b71Sopenharmony_ci
2145e41f4b71Sopenharmony_ci**参数:**
2146e41f4b71Sopenharmony_ci
2147e41f4b71Sopenharmony_ci  | **参数名** | **类型** | **必填** | **说明** |
2148e41f4b71Sopenharmony_ci  | -------- | -------- | -------- | -------- |
2149e41f4b71Sopenharmony_ci  | type | string | 是 | 固定填"hotspotStaLeave"字符串。 |
2150e41f4b71Sopenharmony_ci  | callback | Callback&lt;StationInf]&gt; | 是 | 状态改变回调函数。 |
2151e41f4b71Sopenharmony_ci
2152e41f4b71Sopenharmony_ci**错误码:**
2153e41f4b71Sopenharmony_ci
2154e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
2155e41f4b71Sopenharmony_ci
2156e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
2157e41f4b71Sopenharmony_ci| -------- | -------- |
2158e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
2159e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
2160e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2161e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
2162e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
2163e41f4b71Sopenharmony_ci
2164e41f4b71Sopenharmony_ci## wifiManager.off('hotspotStaLeave')<sup>9+</sup>
2165e41f4b71Sopenharmony_ci
2166e41f4b71Sopenharmony_cioff(type: 'hotspotStaLeave', callback?: Callback&lt;StationInfo&gt;): void
2167e41f4b71Sopenharmony_ci
2168e41f4b71Sopenharmony_ci取消注册wifi热点sta离开事件。
2169e41f4b71Sopenharmony_ci
2170e41f4b71Sopenharmony_ci**系统接口:** 此接口为系统接口。
2171e41f4b71Sopenharmony_ci
2172e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.MANAGE_WIFI_HOTSPOT
2173e41f4b71Sopenharmony_ci
2174e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Communication.WiFi.AP.Core
2175e41f4b71Sopenharmony_ci
2176e41f4b71Sopenharmony_ci**参数:**
2177e41f4b71Sopenharmony_ci
2178e41f4b71Sopenharmony_ci| **参数名** | **类型** | **必填** | **说明** |
2179e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
2180e41f4b71Sopenharmony_ci| type | string | 是 | 固定填"hotspotStaLeave"字符串。 |
2181e41f4b71Sopenharmony_ci| callback | Callback&lt;StationInf]&gt; | 否 | 状态改变回调函数。 |
2182e41f4b71Sopenharmony_ci
2183e41f4b71Sopenharmony_ci**错误码:**
2184e41f4b71Sopenharmony_ci
2185e41f4b71Sopenharmony_ci以下错误码的详细介绍请参见[WIFI错误码](errorcode-wifi.md)。
2186e41f4b71Sopenharmony_ci
2187e41f4b71Sopenharmony_ci| **错误码ID** | **错误信息** |
2188e41f4b71Sopenharmony_ci| -------- | -------- |
2189e41f4b71Sopenharmony_ci| 201 | Permission denied.                 |
2190e41f4b71Sopenharmony_ci| 202 | System API is not allowed called by Non-system application. |
2191e41f4b71Sopenharmony_ci| 401 | Invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2192e41f4b71Sopenharmony_ci| 801 | Capability not supported.          |
2193e41f4b71Sopenharmony_ci| 2601000  | Operation failed. |
2194e41f4b71Sopenharmony_ci
2195e41f4b71Sopenharmony_ci**示例:**
2196e41f4b71Sopenharmony_ci```ts
2197e41f4b71Sopenharmony_ciimport { wifiManager } from '@kit.ConnectivityKit';
2198e41f4b71Sopenharmony_ci
2199e41f4b71Sopenharmony_cilet recvHotspotStaLeaveFunc = (result:wifiManager.StationInfo) => {
2200e41f4b71Sopenharmony_ci    console.info("Receive hotspot sta leave event: " + result);
2201e41f4b71Sopenharmony_ci}
2202e41f4b71Sopenharmony_ci
2203e41f4b71Sopenharmony_ci// Register event
2204e41f4b71Sopenharmony_ciwifiManager.on("hotspotStaLeave", recvHotspotStaLeaveFunc);
2205e41f4b71Sopenharmony_ci
2206e41f4b71Sopenharmony_ci// Unregister event
2207e41f4b71Sopenharmony_ciwifiManager.off("hotspotStaLeave", recvHotspotStaLeaveFunc);
2208e41f4b71Sopenharmony_ci
2209e41f4b71Sopenharmony_ci```
2210e41f4b71Sopenharmony_ci
2211