Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
da46c6b6
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
da46c6b6
编写于
5月 19, 2023
作者:
L
liujiaojiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改md文档与的d.ts不一致的问题
Signed-off-by:
N
liujiaojiao
<
liujiaojiao9@huawei.com
>
上级
e561d51f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
909 addition
and
268 deletion
+909
-268
zh-cn/application-dev/reference/apis/js-apis-wifiManager.md
zh-cn/application-dev/reference/apis/js-apis-wifiManager.md
+909
-268
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-wifiManager.md
浏览文件 @
da46c6b6
...
@@ -19,7 +19,7 @@ enableWifi(): void
...
@@ -19,7 +19,7 @@ enableWifi(): void
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION
,
仅系统应用可用。
**需要权限:**
ohos.permission.SET_WIFI_INFO 和 ohos.permission.MANAGE_WIFI_CONNECTION
仅系统应用可用。
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
...
@@ -33,10 +33,21 @@ enableWifi(): void
...
@@ -33,10 +33,21 @@ enableWifi(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.enableWifi();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.disableWifi<sup>9+</sup>
## wifi.disableWifi<sup>9+</sup>
...
@@ -60,10 +71,22 @@ disableWifi(): void
...
@@ -60,10 +71,22 @@ disableWifi(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.disableWifi();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.isWifiActive<sup>9+</sup>
## wifi.isWifiActive<sup>9+</sup>
isWifiActive(): boolean
isWifiActive(): boolean
...
@@ -84,17 +107,30 @@ isWifiActive(): boolean
...
@@ -84,17 +107,30 @@ isWifiActive(): boolean
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let isActivate = wifiManager.isActivate();
console.info("isActivate:" + isActivate);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.scan<sup>9+</sup>
## wifi.scan<sup>9+</sup>
scan(): void
scan(): void
启动WLAN扫描。
启动WLAN扫描。
**需要权限:**
ohos.permission.SET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.SET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
...
@@ -108,100 +144,74 @@ scan(): void
...
@@ -108,100 +144,74 @@ scan(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
## wifi.getScanResults<sup>9+</sup>
**示例:**
getScanResults(): Promise
<
Array
<
WifiScanInfo
>>
获取扫描结果,使用Promise异步回调。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 (ohos.permission.GET_WIFI_PEERS_MAC 或 ohos.permission.LOCATION)
**系统能力:**
SystemCapability.Communication.WiFi.STA
**返回值:**
|
**类型**
|
**说明**
|
| -------- | -------- |
| Promise
<
Array
<
[WifiScanInfo](#wifiscaninfo)
> >
| Promise对象。返回扫描到的热点列表。 |
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
```
import wifi from '@ohos.wifiManager';
|
**类型**
|
**说明**
|
try {
| -------- | -------- |
wifiManager.scan();
| 2501000 | Operation failed.|
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getScan
Results
<sup>9+</sup>
## wifi.getScan
InfoList
<sup>9+</sup>
getScan
Results(callback: AsyncCallback
<
Array
<
WifiScanInfo
>>
): void
getScan
InfoList(): Array
<
WifiScanInfo
>
;
获取扫描结果
,使用callback异步回调
。
获取扫描结果。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 (ohos.permission.GET_WIFI_PEERS_MAC 或
ohos.permission.LOCATION
)
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 (ohos.permission.GET_WIFI_PEERS_MAC 或
(ohos.permission.LOCATION 和 ohos.permission.APPROXIMATELY_LOCATION)
)
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
**
参数
:**
**
返回值
:**
|
**
参数名**
|
**类型**
|
**必填
**
|
**说明**
|
|
**
类型
**
|
**说明**
|
| -------- | -------- |
-------- | -------- |
| -------- | -------- |
|
callback | AsyncCallback
<
Array
<
[WifiScanInfo](#wifiscaninfo)
>>
| 是 | 回调函数。当成功时,err为0,data为扫描到的热点;否则err为非0值,data为空
。 |
|
Array
<
[WifiScanInfo](#wifiscaninfo)
>
| 返回扫描到的热点列表
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
wifi
.
getScanResults
((
err
,
result
)
=>
{
```
if
(
err
)
{
import wifi from '@ohos.wifiManager';
console
.
error
(
"
get scan info error
"
);
return
;
}
var
len
=
Object
.
keys
(
result
).
length
;
try {
let scanInfoList = wifiManager.getScanInfoList();
console.info("scanInfoList:" + JSON.stringify(scanInfoList));
let len = Object.keys(result).length;
console.log("wifi received scan info: " + len);
console.log("wifi received scan info: " + len);
if(len > 0){
for (var i = 0; i < len; ++i) {
for (var i = 0; i < len; ++i) {
console
.
info
(
"
ssid:
"
+
resul
t
[
i
].
ssid
);
console.info("ssid: " + scanInfoLis
t[i].ssid);
console
.
info
(
"
bssid:
"
+
resul
t
[
i
].
bssid
);
console.info("bssid: " + scanInfoLis
t[i].bssid);
console
.
info
(
"
capabilities:
"
+
resul
t
[
i
].
capabilities
);
console.info("capabilities: " + scanInfoLis
t[i].capabilities);
console
.
info
(
"
securityType:
"
+
resul
t
[
i
].
securityType
);
console.info("securityType: " + scanInfoLis
t[i].securityType);
console
.
info
(
"
rssi:
"
+
resul
t
[
i
].
rssi
);
console.info("rssi: " + scanInfoLis
t[i].rssi);
console
.
info
(
"
band:
"
+
resul
t
[
i
].
band
);
console.info("band: " + scanInfoLis
t[i].band);
console
.
info
(
"
frequency:
"
+
resul
t
[
i
].
frequency
);
console.info("frequency: " + scanInfoLis
t[i].frequency);
console
.
info
(
"
channelWidth:
"
+
resul
t
[
i
].
channelWidth
);
console.info("channelWidth: " + scanInfoLis
t[i].channelWidth);
console
.
info
(
"
timestamp:
"
+
resul
t
[
i
].
timestamp
);
console.info("timestamp: " + scanInfoLis
t[i].timestamp);
}
}
});
wifi
.
getScanResults
().
then
(
result
=>
{
var
len
=
Object
.
keys
(
result
).
length
;
console
.
log
(
"
wifi received scan info:
"
+
len
);
for
(
var
i
=
0
;
i
<
len
;
++
i
)
{
console
.
info
(
"
ssid:
"
+
result
[
i
].
ssid
);
console
.
info
(
"
bssid:
"
+
result
[
i
].
bssid
);
console
.
info
(
"
capabilities:
"
+
result
[
i
].
capabilities
);
console
.
info
(
"
securityType:
"
+
result
[
i
].
securityType
);
console
.
info
(
"
rssi:
"
+
result
[
i
].
rssi
);
console
.
info
(
"
band:
"
+
result
[
i
].
band
);
console
.
info
(
"
frequency:
"
+
result
[
i
].
frequency
);
console
.
info
(
"
channelWidth:
"
+
result
[
i
].
channelWidth
);
console
.
info
(
"
timestamp:
"
+
result
[
i
].
timestamp
);
}
}
});
}catch(error){
```
console.error("failed:" + JSON.stringify(error));
}
```
## WifiScanInfo<sup>9+</sup>
## WifiScanInfo<sup>9+</sup>
...
@@ -247,37 +257,6 @@ WLAN热点信息。
...
@@ -247,37 +257,6 @@ WLAN热点信息。
| WIFI_SEC_TYPE_WAPI_PSK
<sup>
9+
</sup>
| 9 | WAPI-PSK加密类型。 |
| WIFI_SEC_TYPE_WAPI_PSK
<sup>
9+
</sup>
| 9 | WAPI-PSK加密类型。 |
## WifiBandType<sup>10+</sup>
表示WIFI频段类型的枚举。
**系统能力:**
SystemCapability.Communication.WiFi.STA
|
**名称**
|
**值**
|
**说明**
|
| -------- | -------- | -------- |
| WIFI_BAND_NONE | 0 | 无效频段类型。 |
| WIFI_BAND_2G | 1 | 2.4G频段类型。 |
| WIFI_BAND_5G | 2 | 5G频段类型。 |
| WIFI_BAND_6G | 3 | 6G频段类型。 |
| WIFI_BAND_60G | 4 | 60G频段类型。 |
## WifiStandard<sup>10+</sup>
表示WIFI标准的枚举。
**系统能力:**
SystemCapability.Communication.WiFi.STA
|
**名称**
|
**值**
|
**说明**
|
| -------- | -------- | -------- |
| WIFI_STANDARD_UNDEFINED | 0 | 无效WIFI标准类型。 |
| WIFI_STANDARD_11A | 1 | 802.11a WiFi标准类型。 |
| WIFI_STANDARD_11B | 2 | 802.11b WiFi标准类型。 |
| WIFI_STANDARD_11G | 3 | 802.11g WiFi标准类型。 |
| WIFI_STANDARD_11N | 4 | 802.11n WiFi标准类型。 |
| WIFI_STANDARD_11AC | 5 | 802.11ac WiFi标准类型。 |
| WIFI_STANDARD_11AX | 6 | 802.11ax WiFi标准类型。 |
| WIFI_STANDARD_11AD | 7 | 802.11ad WiFi标准类型。 |
## WifiInfoElem<sup>9+</sup>
## WifiInfoElem<sup>9+</sup>
WLAN热点信息。
WLAN热点信息。
...
@@ -307,31 +286,6 @@ WLAN热点信息。
...
@@ -307,31 +286,6 @@ WLAN热点信息。
| WIDTH_80MHZ_PLUS | 4 | 80MHZ
<sup>
+
</sup>
。 |
| WIDTH_80MHZ_PLUS | 4 | 80MHZ
<sup>
+
</sup>
。 |
| WIDTH_INVALID | 5 | 无效值 |
| WIDTH_INVALID | 5 | 无效值 |
## wifi.getScanResultsSync<sup>9+</sup>
getScanResultsSync():
Array
<
[WifiScanInfo](#wifiscaninfo)
>
获取扫描结果,使用同步方式返回结果。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 (ohos.permission.GET_WIFI_PEERS_MAC 或 ohos.permission.LOCATION)
**系统能力:**
SystemCapability.Communication.WiFi.STA
**返回值:**
|
**类型**
|
**说明**
|
| -------- | -------- |
|
Array
<
[WifiScanInfo](#wifiscaninfo)
>
| 扫描结果数组。 |
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**类型**
|
**说明**
|
| -------- | -------- |
| 2501000 | Operation failed.|
## wifi.addDeviceConfig<sup>9+</sup>
## wifi.addDeviceConfig<sup>9+</sup>
addDeviceConfig(config: WifiDeviceConfig): Promise
<
number
>
addDeviceConfig(config: WifiDeviceConfig): Promise
<
number
>
...
@@ -360,10 +314,29 @@ addDeviceConfig(config: WifiDeviceConfig): Promise<number>
...
@@ -360,10 +314,29 @@ addDeviceConfig(config: WifiDeviceConfig): Promise<number>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid : "****",
preSharedKey : "****",
securityType : 0
}
wifiManager.addDeviceConfig(config).then(result => {
console.info("result:" + JSON.stringify(result));
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## WifiDeviceConfig<sup>9+</sup>
## WifiDeviceConfig<sup>9+</sup>
WLAN配置信息。
WLAN配置信息。
...
@@ -512,10 +485,29 @@ addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback<number>)
...
@@ -512,10 +485,29 @@ addDeviceConfig(config: WifiDeviceConfig, callback: AsyncCallback<number>)
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid : "****",
preSharedKey : "****",
securityType : 0
}
wifiManager.addDeviceConfig(config,(error,result) => {
console.info("result:" + JSON.stringify(result));
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.addCandidateConfig<sup>9+</sup>
## wifi.addCandidateConfig<sup>9+</sup>
addCandidateConfig(config: WifiDeviceConfig): Promise
<
number
>
addCandidateConfig(config: WifiDeviceConfig): Promise
<
number
>
...
@@ -542,10 +534,28 @@ addCandidateConfig(config: WifiDeviceConfig): Promise<number>
...
@@ -542,10 +534,28 @@ addCandidateConfig(config: WifiDeviceConfig): Promise<number>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
`````
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid : "****",
preSharedKey : "****",
securityType : 0
}
wifiManager.addCandidateConfig(config).then(result => {
console.info("result:" + JSON.stringify(result));
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
`````
## wifi.addCandidateConfig<sup>9+</sup>
## wifi.addCandidateConfig<sup>9+</sup>
addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback
<
number
>
): void
addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback
<
number
>
): void
...
@@ -567,10 +577,28 @@ addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback<number&g
...
@@ -567,10 +577,28 @@ addCandidateConfig(config: WifiDeviceConfig, callback: AsyncCallback<number&g
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
`````
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid : "****",
preSharedKey : "****",
securityType : 0
}
wifiManager.addCandidateConfig(config,(error,result) => {
console.info("result:" + JSON.stringify(result));
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
`````
## wifi.removeCandidateConfig<sup>9+</sup>
## wifi.removeCandidateConfig<sup>9+</sup>
removeCandidateConfig(networkId: number): Promise
<
void
>
removeCandidateConfig(networkId: number): Promise
<
void
>
...
@@ -597,10 +625,25 @@ removeCandidateConfig(networkId: number): Promise<void>
...
@@ -597,10 +625,25 @@ removeCandidateConfig(networkId: number): Promise<void>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let networkId = 0;
wifiManager.addCandidateConfig(networkId).then(result => {
console.info("result:" + JSON.stringify(result));
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.removeCandidateConfig<sup>9+</sup>
## wifi.removeCandidateConfig<sup>9+</sup>
removeCandidateConfig(networkId: number, callback: AsyncCallback
<
void
>
): void
removeCandidateConfig(networkId: number, callback: AsyncCallback
<
void
>
): void
...
@@ -622,17 +665,31 @@ removeCandidateConfig(networkId: number, callback: AsyncCallback<void>): v
...
@@ -622,17 +665,31 @@ removeCandidateConfig(networkId: number, callback: AsyncCallback<void>): v
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let networkId = 0;
wifiManager.addCandidateConfig(networkId,(error,result) => {
console.info("result:" + JSON.stringify(result));
});
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getCandidateConfigs<sup>9+</sup>
## wifi.getCandidateConfigs<sup>9+</sup>
getCandidateConfigs():
Array
<
[WifiDeviceConfig](#wifideviceconfig)
>
getCandidateConfigs():
Array
<
[WifiDeviceConfig](#wifideviceconfig)
>
获取候选网络配置。
获取候选网络配置。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
...
@@ -646,10 +703,32 @@ getCandidateConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)>
...
@@ -646,10 +703,32 @@ getCandidateConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
`````
import wifi from '@ohos.wifiManager';
try {
let configs = wifiManager.getCandidateConfigs();
console.info("configs:" + JSON.stringify(configs));
let len = Object.keys(configs).length;
console.log("result len: " + len);
if(len > 0){
for (var i = 0; i < len; ++i) {
console.info("ssid: " + configs[i].ssid);
console.info("bssid: " + configs[i].bssid);
}
}
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
`````
## wifi.connectToCandidateConfig<sup>9+</sup>
## wifi.connectToCandidateConfig<sup>9+</sup>
connectToCandidateConfig(networkId: number): void
connectToCandidateConfig(networkId: number): void
...
@@ -670,11 +749,25 @@ connectToCandidateConfig(networkId: number): void
...
@@ -670,11 +749,25 @@ connectToCandidateConfig(networkId: number): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let networkId = 0;
let ret = wifiManager.connectToCandidateConfig(networkId);
console.info("result:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.connectToNetwork<sup>9+</sup>
## wifi.connectToNetwork<sup>9+</sup>
connectToNetwork(networkId: number): void
connectToNetwork(networkId: number): void
...
@@ -697,11 +790,24 @@ connectToNetwork(networkId: number): void
...
@@ -697,11 +790,24 @@ connectToNetwork(networkId: number): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let networkId = 0;
wifiManager.connectToNetwork(networkId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.connectToDevice<sup>9+</sup>
## wifi.connectToDevice<sup>9+</sup>
connectToDevice(config: WifiDeviceConfig): void
connectToDevice(config: WifiDeviceConfig): void
...
@@ -725,11 +831,28 @@ connectToDevice(config: WifiDeviceConfig): void
...
@@ -725,11 +831,28 @@ connectToDevice(config: WifiDeviceConfig): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid : "****",
preSharedKey : "****",
securityType : 3
}
wifiManager.connectToDevice(config);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.disconnect<sup>9+</sup>
## wifi.disconnect<sup>9+</sup>
disconnect(): void
disconnect(): void
...
@@ -747,10 +870,21 @@ disconnect(): void
...
@@ -747,10 +870,21 @@ disconnect(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.disconnect();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getSignalLevel<sup>9+</sup>
## wifi.getSignalLevel<sup>9+</sup>
getSignalLevel(rssi: number, band: number): number
getSignalLevel(rssi: number, band: number): number
...
@@ -778,10 +912,25 @@ getSignalLevel(rssi: number, band: number): number
...
@@ -778,10 +912,25 @@ getSignalLevel(rssi: number, band: number): number
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let rssi = 0;
let band = 0;
let level = wifiManager.getSignalLevel(rssi,band);
console.info("lelvel:" + JSON.stringify(lelvel));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getLinkedInfo<sup>9+</sup>
## wifi.getLinkedInfo<sup>9+</sup>
getLinkedInfo(): Promise
<
WifiLinkedInfo
>
getLinkedInfo(): Promise
<
WifiLinkedInfo
>
...
@@ -802,7 +951,7 @@ getLinkedInfo(): Promise<WifiLinkedInfo>
...
@@ -802,7 +951,7 @@ getLinkedInfo(): Promise<WifiLinkedInfo>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
...
@@ -827,7 +976,7 @@ getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void
...
@@ -827,7 +976,7 @@ getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
...
@@ -923,6 +1072,23 @@ getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void
...
@@ -923,6 +1072,23 @@ getLinkedInfo(callback: AsyncCallback<WifiLinkedInfo>): void
| UNINITIALIZED | 10 | 连接建立失败。 |
| UNINITIALIZED | 10 | 连接建立失败。 |
| INVALID | 11 | 无效值。 |
| INVALID | 11 | 无效值。 |
## SuppState<sup>10+</sup>
表示Wi-Fi标准的枚举。
**系统能力:**
SystemCapability.Communication.WiFi.STA
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| WIFI_STANDARD_UNDEFINED | 0 | 未定义。 |
| WIFI_STANDARD_11A | 1 | 11A。 |
| WIFI_STANDARD_11B | 2 | 11B。 |
| WIFI_STANDARD_11G | 3 | 11G。 |
| WIFI_STANDARD_11N | 4 | 11N。 |
| WIFI_STANDARD_11AC | 5 | 11AC。 |
| WIFI_STANDARD_11AX | 6 | 11AX。 |
| WIFI_STANDARD_11AD | 7 | 11AD。 |
## wifi.isConnected<sup>9+</sup>
## wifi.isConnected<sup>9+</sup>
...
@@ -944,10 +1110,23 @@ isConnected(): boolean
...
@@ -944,10 +1110,23 @@ isConnected(): boolean
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let ret = wifiManager.isConnected();
console.info("isConnected:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getSupportedFeatures<sup>9+</sup>
## wifi.getSupportedFeatures<sup>9+</sup>
getSupportedFeatures(): number
getSupportedFeatures(): number
...
@@ -985,10 +1164,23 @@ getSupportedFeatures(): number
...
@@ -985,10 +1164,23 @@ getSupportedFeatures(): number
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2401000 | Operation failed.|
| 2401000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let ret = wifiManager.getSupportedFeatures();
console.info("supportedFeatures:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.isFeatureSupported<sup>9+</sup>
## wifi.isFeatureSupported<sup>9+</sup>
isFeatureSupported(featureId: number): boolean
isFeatureSupported(featureId: number): boolean
...
@@ -1016,10 +1208,24 @@ isFeatureSupported(featureId: number): boolean
...
@@ -1016,10 +1208,24 @@ isFeatureSupported(featureId: number): boolean
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2401000 | Operation failed.|
| 2401000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let featureId = 0;
let ret = wifiManager.isFeatureSupported(featureId);
console.info("isFeatureSupported:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getDeviceMacAddress<sup>9+</sup>
## wifi.getDeviceMacAddress<sup>9+</sup>
getDeviceMacAddress(): string[]
getDeviceMacAddress(): string[]
...
@@ -1042,10 +1248,23 @@ getDeviceMacAddress(): string[]
...
@@ -1042,10 +1248,23 @@ getDeviceMacAddress(): string[]
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let ret = wifiManager.getDeviceMacAddress();
console.info("deviceMacAddress:" + JSON.stringify(ret));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getIpInfo<sup>9+</sup>
## wifi.getIpInfo<sup>9+</sup>
getIpInfo(): IpInfo
getIpInfo(): IpInfo
...
@@ -1066,10 +1285,22 @@ getIpInfo(): IpInfo
...
@@ -1066,10 +1285,22 @@ getIpInfo(): IpInfo
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let info = wifiManager.getIpInfo();
console.info("info:" + JSON.stringify(info));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## IpInfo<sup>9+</sup>
## IpInfo<sup>9+</sup>
IP信息。
IP信息。
...
@@ -1107,10 +1338,22 @@ getCountryCode(): string
...
@@ -1107,10 +1338,22 @@ getCountryCode(): string
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2401000 | Operation failed.|
| 2401000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let code = wifiManager.getCountryCode();
console.info("code:" + code);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.reassociate<sup>9+</sup>
## wifi.reassociate<sup>9+</sup>
reassociate(): void
reassociate(): void
...
@@ -1127,11 +1370,22 @@ reassociate(): void
...
@@ -1127,11 +1370,22 @@ reassociate(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.reassociate();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.reconnect<sup>9+</sup>
## wifi.reconnect<sup>9+</sup>
reconnect(): void
reconnect(): void
...
@@ -1148,11 +1402,22 @@ reconnect(): void
...
@@ -1148,11 +1402,22 @@ reconnect(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
| 2501001 | Wifi is closed.|
| 2501001 | Wifi is closed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.reconnect();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getDeviceConfigs<sup>9+</sup>
## wifi.getDeviceConfigs<sup>9+</sup>
getDeviceConfigs():
Array
<
[WifiDeviceConfig](#wifideviceconfig)
>
getDeviceConfigs():
Array
<
[WifiDeviceConfig](#wifideviceconfig)
>
...
@@ -1161,7 +1426,7 @@ getDeviceConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)>
...
@@ -1161,7 +1426,7 @@ getDeviceConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)>
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.GET_WIFI_CONFIG
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.
APPROXIMATELY_LOCATION 和 ohos.permission.
GET_WIFI_CONFIG
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
...
@@ -1175,13 +1440,25 @@ getDeviceConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)>
...
@@ -1175,13 +1440,25 @@ getDeviceConfigs(): Array<[WifiDeviceConfig](#wifideviceconfig)>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
## wifi.updateNetwork<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let configs = wifiManager.getDeviceConfigs();
console.info("configs:" + JSON.stringify(configs));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.updateDeviceConfig<sup>9+</sup>
update
Network
(config: WifiDeviceConfig): number
update
DeviceConfig
(config: WifiDeviceConfig): number
更新网络配置。
更新网络配置。
...
@@ -1207,13 +1484,30 @@ updateNetwork(config: WifiDeviceConfig): number
...
@@ -1207,13 +1484,30 @@ updateNetwork(config: WifiDeviceConfig): number
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
## wifi.disableNetwork<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid : "****",
preSharedKey : "****",
securityType : 3
}
let ret = wifiManager.updateDeviceConfig(config);
console.error("ret:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.disableDeviceConfig<sup>9+</sup>
disable
Network(net
Id: number): void
disable
DeviceConfig(network
Id: number): void
去使能网络配置。
去使能网络配置。
...
@@ -1227,19 +1521,31 @@ disableNetwork(netId: number): void
...
@@ -1227,19 +1521,31 @@ disableNetwork(netId: number): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| netId | number | 是 | 网络配置ID。 |
| net
work
Id | number | 是 | 网络配置ID。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
## wifi.removeAllNetwork<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let netId = 0;
wifiManager.disableDeviceConfig(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.removeAllDeviceConfigs<sup>9+</sup>
removeAll
Network
(): void
removeAll
DeviceConfigs
(): void
移除所有网络配置。
移除所有网络配置。
...
@@ -1253,13 +1559,24 @@ removeAllNetwork(): void
...
@@ -1253,13 +1559,24 @@ removeAllNetwork(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
## wifi.removeDevice<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.removeAllNetwork();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.removeDeviceConfig<sup>9+</sup>
removeDevice
(i
d: number): void
removeDevice
Config(networkI
d: number): void
移除指定的网络配置。
移除指定的网络配置。
...
@@ -1273,16 +1590,28 @@ removeDevice(id: number): void
...
@@ -1273,16 +1590,28 @@ removeDevice(id: number): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
|
i
d | number | 是 | 网络配置ID。 |
|
networkI
d | number | 是 | 网络配置ID。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let id = 0;
wifiManager.removeDeviceConfig(id);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.isBandTypeSupported<sup>10+</sup>
## wifi.isBandTypeSupported<sup>10+</sup>
isBandTypeSupported(bandType: WifiBandType): boolean
isBandTypeSupported(bandType: WifiBandType): boolean
...
@@ -1293,23 +1622,57 @@ isBandTypeSupported(bandType: WifiBandType): boolean
...
@@ -1293,23 +1622,57 @@ isBandTypeSupported(bandType: WifiBandType): boolean
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
**参数:**
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| bandType | WifiBandType | 是 | Wifi 频段类型。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let type = 0;
boolean isBandTypeSupported = wifiManager.isBandTypeSupported(type);
console.info("isBandTypeSupported:" + isBandTypeSupported);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## WifiBandType <sup>10+</sup>
表示wifi频段类型的枚举。
**系统能力:**
SystemCapability.Communication.WiFi.STA
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| WIFI_BAND_NONE | 0 | 未定义。 |
| WIFI_BAND_2G | 1 | 2G频段。 |
| WIFI_BAND_5G | 2 | 5G频段。 |
| WIFI_BAND_6G | 3 | 6G频段。 |
| WIFI_BAND_60G | 4 | 60G频段。|
## wifi.get5GChannelList<sup>10+</sup>
## wifi.get5GChannelList<sup>10+</sup>
get5GChannelList(): Array
<number>
get5GChannelList(): Array
<
number
>
获取当前设备支持的5G信道列表。
获取当前设备支持的5G信道列表。
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG
。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.GET_WIFI_CONFIG
**系统能力:**
SystemCapability.Communication.WiFi.STA
**系统能力:**
SystemCapability.Communication.WiFi.STA
...
@@ -1317,10 +1680,22 @@ get5GChannelList(): Array<number>
...
@@ -1317,10 +1680,22 @@ get5GChannelList(): Array<number>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let channelList = wifiManager.get5GChannelList();
console.info("channelList:" + JSON.stringify(channelList));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.enableHotspot<sup>9+</sup>
## wifi.enableHotspot<sup>9+</sup>
enableHotspot(): void
enableHotspot(): void
...
@@ -1337,10 +1712,21 @@ enableHotspot(): void
...
@@ -1337,10 +1712,21 @@ enableHotspot(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.enableHotspot();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.disableHotspot<sup>9+</sup>
## wifi.disableHotspot<sup>9+</sup>
disableHotspot(): void
disableHotspot(): void
...
@@ -1357,10 +1743,21 @@ disableHotspot(): void
...
@@ -1357,10 +1743,21 @@ disableHotspot(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.disableHotspot();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.isHotspotDualBandSupported<sup>9+</sup>
## wifi.isHotspotDualBandSupported<sup>9+</sup>
isHotspotDualBandSupported(): boolean
isHotspotDualBandSupported(): boolean
...
@@ -1383,10 +1780,22 @@ isHotspotDualBandSupported(): boolean
...
@@ -1383,10 +1780,22 @@ isHotspotDualBandSupported(): boolean
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let ret = wifiManager.isHotspotDualBandSupported();
console.info("result:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.isHotspotActive<sup>9+</sup>
## wifi.isHotspotActive<sup>9+</sup>
isHotspotActive(): boolean
isHotspotActive(): boolean
...
@@ -1409,10 +1818,22 @@ isHotspotActive(): boolean
...
@@ -1409,10 +1818,22 @@ isHotspotActive(): boolean
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let ret = wifiManager.isHotspotActive();
console.info("result:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.setHotspotConfig<sup>9+</sup>
## wifi.setHotspotConfig<sup>9+</sup>
setHotspotConfig(config: HotspotConfig): void
setHotspotConfig(config: HotspotConfig): void
...
@@ -1435,10 +1856,30 @@ setHotspotConfig(config: HotspotConfig): void
...
@@ -1435,10 +1856,30 @@ setHotspotConfig(config: HotspotConfig): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = {
ssid: "****",
securityType: 3,
band: 0,
channel: 0,
preSharedKey: "****",
maxConn: 0
}
let ret = wifiManager.isHotspotActive();
console.info("result:" + ret);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## HotspotConfig<sup>9+</sup>
## HotspotConfig<sup>9+</sup>
热点配置信息。
热点配置信息。
...
@@ -1478,19 +1919,31 @@ getHotspotConfig(): HotspotConfig
...
@@ -1478,19 +1919,31 @@ getHotspotConfig(): HotspotConfig
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
## wifi.getStations<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = wifiManager.getHotspotConfig();
console.info("result:" + JSON.stringify(config));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
getStations():
Array
<
[StationInfo](#stationinfo9)
>
## wifi.getHotspotStations<sup>9+</sup>
getHotspotStations():
Array
<
[StationInfo](#stationinfo9)
>
获取连接的设备。
获取连接的设备。
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.MANAGE_WIFI_HOTSPOT,仅系统应用可用。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION 和 ohos.permission.
APPROXIMATELY_LOCATION 和 ohos.permission.
MANAGE_WIFI_HOTSPOT,仅系统应用可用。
**系统能力:**
SystemCapability.Communication.WiFi.AP.Core
**系统能力:**
SystemCapability.Communication.WiFi.AP.Core
...
@@ -1504,10 +1957,22 @@ getStations(): Array<[StationInfo](#stationinfo9)>
...
@@ -1504,10 +1957,22 @@ getStations(): Array<[StationInfo](#stationinfo9)>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let stations = wifiManager.getStations();
console.info("result:" + JSON.stringify(stations));
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## StationInfo<sup>9+</sup>
## StationInfo<sup>9+</sup>
接入的设备信息。
接入的设备信息。
...
@@ -1543,10 +2008,28 @@ getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo>
...
@@ -1543,10 +2008,28 @@ getP2pLinkedInfo(): Promise<WifiP2pLinkedInfo>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
wifi.getP2pLinkedInfo((err, data) => {
if (err) {
console.error("get p2p linked info error");
return;
}
console.info("get wifi p2p linked info: " + JSON.stringify(data));
});
wifi.getP2pLinkedInfo().then(data => {
console.info("get wifi p2p linked info: " + JSON.stringify(data));
});
```
## WifiP2pLinkedInfo<sup>9+</sup>
## WifiP2pLinkedInfo<sup>9+</sup>
提供WLAN连接的相关信息。
提供WLAN连接的相关信息。
...
@@ -1589,13 +2072,13 @@ getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void
...
@@ -1589,13 +2072,13 @@ getP2pLinkedInfo(callback: AsyncCallback<WifiP2pLinkedInfo>): void
| callback | AsyncCallback
<
[WifiP2pLinkedInfo](#wifip2plinkedinfo9)
>
| 是 | 回调函数。当操作成功时,err为0,data表示P2P连接信息。如果error为非0,表示处理出现错误。 |
| callback | AsyncCallback
<
[WifiP2pLinkedInfo](#wifip2plinkedinfo9)
>
| 是 | 回调函数。当操作成功时,err为0,data表示P2P连接信息。如果error为非0,表示处理出现错误。 |
## wifi.getCurrentGroup<sup>9+</sup>
## wifi.getCurrent
P2p
Group<sup>9+</sup>
getCurrentGroup(): Promise
<
WifiP2pGroupInfo
>
getCurrent
P2p
Group(): Promise
<
WifiP2pGroupInfo
>
获取P2P当前组信息,使用Promise异步回调。
获取P2P当前组信息,使用Promise异步回调。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -1609,17 +2092,17 @@ getCurrentGroup(): Promise<WifiP2pGroupInfo>
...
@@ -1609,17 +2092,17 @@ getCurrentGroup(): Promise<WifiP2pGroupInfo>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
## wifi.getCurrentGroup<sup>9+</sup>
## wifi.getCurrent
P2p
Group<sup>9+</sup>
getCurrentGroup(callback: AsyncCallback
<
WifiP2pGroupInfo
>
): void
getCurrent
P2p
Group(callback: AsyncCallback
<
WifiP2pGroupInfo
>
): void
获取P2P当前组信息,使用callback异步回调。
获取P2P当前组信息,使用callback异步回调。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -1633,17 +2116,34 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void
...
@@ -1633,17 +2116,34 @@ getCurrentGroup(callback: AsyncCallback<WifiP2pGroupInfo>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
wifi.getCurrentP2pGroup((err, data) => {
if (err) {
console.error("get current P2P group error");
return;
}
console.info("get current P2P group: " + JSON.stringify(data));
});
wifi.getP2pLinkedInfo().then(data => {
console.info("get current P2P group: " + JSON.stringify(data));
});
```
## wifi.getP2pPeerDevices<sup>9+</sup>
## wifi.getP2pPeerDevices<sup>9+</sup>
getP2pPeerDevices(): Promise
<
WifiP2pDevice[]
>
getP2pPeerDevices(): Promise
<
WifiP2pDevice[]
>
获取P2P对端设备列表信息,使用Promise异步回调。
获取P2P对端设备列表信息,使用Promise异步回调。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -1657,7 +2157,7 @@ getP2pPeerDevices(): Promise<WifiP2pDevice[]>
...
@@ -1657,7 +2157,7 @@ getP2pPeerDevices(): Promise<WifiP2pDevice[]>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -1667,7 +2167,7 @@ getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void
...
@@ -1667,7 +2167,7 @@ getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void
获取P2P对端设备列表信息,使用callback异步回调。
获取P2P对端设备列表信息,使用callback异步回调。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -1681,10 +2181,27 @@ getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void
...
@@ -1681,10 +2181,27 @@ getP2pPeerDevices(callback: AsyncCallback<WifiP2pDevice[]>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
wifi.getP2pPeerDevices((err, data) => {
if (err) {
console.error("get P2P peer devices error");
return;
}
console.info("get P2P peer devices: " + JSON.stringify(data));
});
wifi.getP2pLinkedInfo().then(data => {
console.info("get P2P peer devices: " + JSON.stringify(data));
});
```
## WifiP2pDevice<sup>9+</sup>
## WifiP2pDevice<sup>9+</sup>
表示P2P设备信息。
表示P2P设备信息。
...
@@ -1735,7 +2252,7 @@ getP2pLocalDevice(): Promise<WifiP2pDevice>
...
@@ -1735,7 +2252,7 @@ getP2pLocalDevice(): Promise<WifiP2pDevice>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -1755,10 +2272,30 @@ getP2pLocalDevice(callback: AsyncCallback<WifiP2pDevice>): void
...
@@ -1755,10 +2272,30 @@ getP2pLocalDevice(callback: AsyncCallback<WifiP2pDevice>): void
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
[WifiP2pDevice](#wifip2pdevice9)
>
| 是 | 回调函数。当操作成功时,err为0,data表示本端设备信息。如果error为非0,表示处理出现错误。 |
| callback | AsyncCallback
<
[WifiP2pDevice](#wifip2pdevice9)
>
| 是 | 回调函数。当操作成功时,err为0,data表示本端设备信息。如果error为非0,表示处理出现错误。 |
|
**错误码ID**
|
**错误信息**
|
| -------- | -------- |
| 2801000 | Operation failed.|
## wifi.createGroup<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
wifiManager.getP2pLocalDevice((err, data) => {
if (err) {
console.error("get P2P local device error");
return;
}
console.info("get P2P local device: " + JSON.stringify(data));
});
createGroup(config: WifiP2PConfig): void
wifi.getP2pLinkedInfo().then(data => {
console.info("get P2P local device: " + JSON.stringify(data));
});
```
## wifi.createP2pGroup<sup>9+</sup>
createP2pGroup(config: WifiP2PConfig): void
创建群组。
创建群组。
...
@@ -1776,10 +2313,29 @@ createGroup(config: WifiP2PConfig): void
...
@@ -1776,10 +2313,29 @@ createGroup(config: WifiP2PConfig): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let config = {
deviceAddress: "****",
netId: 0,
passphrase: "*****",
groupName: "****",
goBand: 0
}
wifiManager.createP2pGroup(config);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## WifiP2PConfig<sup>9+</sup>
## WifiP2PConfig<sup>9+</sup>
表示P2P配置信息。
表示P2P配置信息。
...
@@ -1808,9 +2364,9 @@ createGroup(config: WifiP2PConfig): void
...
@@ -1808,9 +2364,9 @@ createGroup(config: WifiP2PConfig): void
| GO_BAND_5GHZ | 2 | 5GHZ。 |
| GO_BAND_5GHZ | 2 | 5GHZ。 |
## wifi.removeGroup<sup>9+</sup>
## wifi.remove
P2p
Group<sup>9+</sup>
removeGroup(): void
remove
P2p
Group(): void
移除群组。
移除群组。
...
@@ -1822,23 +2378,33 @@ removeGroup(): void
...
@@ -1822,23 +2378,33 @@ removeGroup(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.removeP2pGroup();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.p2pConnect<sup>9+</sup>
## wifi.p2pConnect<sup>9+</sup>
p2pConnect(config: WifiP2PConfig): void
p2pConnect(config: WifiP2PConfig): void
执行P2P连接。
执行P2P连接。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**参数:**
**参数:**
|
**参数名**
|
**类型**
| 必填 |
**说明**
|
|
**参数名**
|
**类型**
| 必填 |
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| config |
[
WifiP2PConfig
](
#wifip2pconfig9
)
| 是 | 连接配置信息。 |
| config |
[
WifiP2PConfig
](
#wifip2pconfig9
)
| 是 | 连接配置信息。 |
...
@@ -1847,13 +2413,13 @@ p2pConnect(config: WifiP2PConfig): void
...
@@ -1847,13 +2413,13 @@ p2pConnect(config: WifiP2PConfig): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
**示例:**
```
js
```
js
import
wifi
from
'
@ohos.wifi
Manager
'
;
import
wifi
from
'
@ohos.wifi
'
;
var
recvP2pConnectionChangeFunc
=
result
=>
{
var
recvP2pConnectionChangeFunc
=
result
=>
{
console
.
info
(
"
p2p connection change receive event:
"
+
JSON
.
stringify
(
result
));
console
.
info
(
"
p2p connection change receive event:
"
+
JSON
.
stringify
(
result
));
...
@@ -1915,7 +2481,7 @@ p2pConnect(config: WifiP2PConfig): void
...
@@ -1915,7 +2481,7 @@ p2pConnect(config: WifiP2PConfig): void
setTimeout
(
function
()
{
wifi
.
off
(
"
p2pDeviceChange
"
,
recvP2pDeviceChangeFunc
);},
125
*
1000
);
setTimeout
(
function
()
{
wifi
.
off
(
"
p2pDeviceChange
"
,
recvP2pDeviceChangeFunc
);},
125
*
1000
);
setTimeout
(
function
()
{
wifi
.
off
(
"
p2pPeerDeviceChange
"
,
recvP2pPeerDeviceChangeFunc
);},
125
*
1000
);
setTimeout
(
function
()
{
wifi
.
off
(
"
p2pPeerDeviceChange
"
,
recvP2pPeerDeviceChangeFunc
);},
125
*
1000
);
setTimeout
(
function
()
{
wifi
.
off
(
"
p2pPersistentGroupChange
"
,
recvP2pPersistentGroupChangeFunc
);},
125
*
1000
);
setTimeout
(
function
()
{
wifi
.
off
(
"
p2pPersistentGroupChange
"
,
recvP2pPersistentGroupChangeFunc
);},
125
*
1000
);
console
.
info
(
"
start discover devices ->
"
+
wifi
.
startDiscoverDevices
());
console
.
info
(
"
start discover devices ->
"
+
wifi
.
start
P2p
DiscoverDevices
());
```
```
## wifi.p2pCancelConnect<sup>9+</sup>
## wifi.p2pCancelConnect<sup>9+</sup>
...
@@ -1932,17 +2498,28 @@ p2pCancelConnect(): void
...
@@ -1932,17 +2498,28 @@ p2pCancelConnect(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
## wifi.startDiscoverDevices<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
startDiscoverDevices(): void
try {
wifiManager.p2pCancelConnect();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.startDiscoverP2pDevices<sup>9+</sup>
startDiscoverP2pDevices(): void
开始发现设备。
开始发现设备。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -1950,13 +2527,24 @@ startDiscoverDevices(): void
...
@@ -1950,13 +2527,24 @@ startDiscoverDevices(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
## wifi.stopDiscoverDevices<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
stopDiscoverDevices(): void
try {
wifiManager.startDiscoverP2pDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.stopDiscoverP2pDevices<sup>9+</sup>
stopDiscoverP2pDevices(): void
停止发现设备。
停止发现设备。
...
@@ -1968,13 +2556,24 @@ stopDiscoverDevices(): void
...
@@ -1968,13 +2556,24 @@ stopDiscoverDevices(): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
## wifi.deletePersistentGroup<sup>9+</sup>
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
wifiManager.stopDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
deletePersistentGroup(netId: number): void
## wifi.deletePersistentP2pGroup<sup>9+</sup>
deletePersistentP2pGroup(netId: number): void
删除永久组。
删除永久组。
...
@@ -1995,10 +2594,22 @@ deletePersistentGroup(netId: number): void
...
@@ -1995,10 +2594,22 @@ deletePersistentGroup(netId: number): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let netId = 0;
wifiManager.deletePersistentP2pGroup(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.getP2pGroups<sup>9+</sup>
## wifi.getP2pGroups<sup>9+</sup>
getP2pGroups(): Promise
<
Array
<
WifiP2pGroupInfo
>>
getP2pGroups(): Promise
<
Array
<
WifiP2pGroupInfo
>>
...
@@ -2007,7 +2618,7 @@ getP2pGroups(): Promise<Array<WifiP2pGroupInfo>>
...
@@ -2007,7 +2618,7 @@ getP2pGroups(): Promise<Array<WifiP2pGroupInfo>>
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -2021,10 +2632,28 @@ getP2pGroups(): Promise<Array<WifiP2pGroupInfo>>
...
@@ -2021,10 +2632,28 @@ getP2pGroups(): Promise<Array<WifiP2pGroupInfo>>
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
wifiManager.getP2pGroups((err, data) => {
if (err) {
console.error("get P2P groups error");
return;
}
console.info("get P2P groups: " + JSON.stringify(data));
});
wifi.getP2pGroups().then(data => {
console.info("get P2P groups: " + JSON.stringify(data));
});
```
## WifiP2pGroupInfo<sup>9+</sup>
## WifiP2pGroupInfo<sup>9+</sup>
表示P2P群组相关信息。
表示P2P群组相关信息。
...
@@ -2052,7 +2681,7 @@ getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void
...
@@ -2052,7 +2681,7 @@ getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void
**系统接口:**
此接口为系统接口。
**系统接口:**
此接口为系统接口。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -2066,13 +2695,13 @@ getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void
...
@@ -2066,13 +2695,13 @@ getP2pGroups(callback: AsyncCallback<Array<WifiP2pGroupInfo>>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
## wifi.setDeviceName<sup>9+</sup>
## wifi.set
P2p
DeviceName<sup>9+</sup>
setDeviceName(devName: string): void
set
P2p
DeviceName(devName: string): void
设置设备名称。
设置设备名称。
...
@@ -2092,10 +2721,22 @@ setDeviceName(devName: string): void
...
@@ -2092,10 +2721,22 @@ setDeviceName(devName: string): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
import wifi from '@ohos.wifiManager';
try {
let name = "****";
wifiManager.setDeviceName(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.on('wifiStateChange')<sup>9+</sup>
## wifi.on('wifiStateChange')<sup>9+</sup>
on(type: "wifiStateChange", callback: Callback
<
number
>
): void
on(type: "wifiStateChange", callback: Callback
<
number
>
): void
...
@@ -2117,7 +2758,7 @@ on(type: "wifiStateChange", callback: Callback<number>): void
...
@@ -2117,7 +2758,7 @@ on(type: "wifiStateChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2146,19 +2787,19 @@ off(type: "wifiStateChange", callback?: Callback<number>): void
...
@@ -2146,19 +2787,19 @@ off(type: "wifiStateChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiStateChange"字符串。 |
| type | string | 是 | 固定填"wifiStateChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
**示例:**
```
js
```
js
import
wifi
from
'
@ohos.wifi
Manager
'
;
import
wifi
from
'
@ohos.wifi
'
;
var
recvPowerNotifyFunc
=
result
=>
{
var
recvPowerNotifyFunc
=
result
=>
{
console
.
info
(
"
Receive power state change event:
"
+
result
);
console
.
info
(
"
Receive power state change event:
"
+
result
);
...
@@ -2200,7 +2841,7 @@ on(type: "wifiConnectionChange", callback: Callback<number>): void
...
@@ -2200,7 +2841,7 @@ on(type: "wifiConnectionChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2219,13 +2860,13 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void
...
@@ -2219,13 +2860,13 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiConnectionChange"字符串。 |
| type | string | 是 | 固定填"wifiConnectionChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
连接状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2257,7 +2898,7 @@ on(type: "wifiScanStateChange", callback: Callback<number>): void
...
@@ -2257,7 +2898,7 @@ on(type: "wifiScanStateChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2276,13 +2917,13 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void
...
@@ -2276,13 +2917,13 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiScanStateChange"字符串。 |
| type | string | 是 | 固定填"wifiScanStateChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2307,7 +2948,7 @@ on(type: "wifiRssiChange", callback: Callback<number>): void
...
@@ -2307,7 +2948,7 @@ on(type: "wifiRssiChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2326,13 +2967,13 @@ off(type: "wifiRssiChange", callback?: Callback<number>): void
...
@@ -2326,13 +2967,13 @@ off(type: "wifiRssiChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiRssiChange"字符串。 |
| type | string | 是 | 固定填"wifiRssiChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
...
@@ -2366,7 +3007,7 @@ on(type: "hotspotStateChange", callback: Callback<number>): void
...
@@ -2366,7 +3007,7 @@ on(type: "hotspotStateChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
...
@@ -2385,13 +3026,13 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void
...
@@ -2385,13 +3026,13 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"hotspotStateChange"字符串。 |
| type | string | 是 | 固定填"hotspotStateChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
...
@@ -2426,7 +3067,7 @@ on(type: "p2pStateChange", callback: Callback<number>): void
...
@@ -2426,7 +3067,7 @@ on(type: "p2pStateChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2445,13 +3086,13 @@ off(type: "p2pStateChange", callback?: Callback<number>): void
...
@@ -2445,13 +3086,13 @@ off(type: "p2pStateChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pStateChange"字符串。 |
| type | string | 是 | 固定填"p2pStateChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2476,7 +3117,7 @@ on(type: "p2pConnectionChange", callback: Callback<WifiP2pLinkedInfo>): vo
...
@@ -2476,7 +3117,7 @@ on(type: "p2pConnectionChange", callback: Callback<WifiP2pLinkedInfo>): vo
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2495,13 +3136,13 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>):
...
@@ -2495,13 +3136,13 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>):
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pConnectionChange"字符串。 |
| type | string | 是 | 固定填"p2pConnectionChange"字符串。 |
| callback | Callback
<
[WifiP2pLinkedInfo](#wifip2plinkedinfo9)
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
[WifiP2pLinkedInfo](#wifip2plinkedinfo9)
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2511,7 +3152,7 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void
...
@@ -2511,7 +3152,7 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void
注册P2P设备状态改变事件。
注册P2P设备状态改变事件。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -2526,7 +3167,7 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void
...
@@ -2526,7 +3167,7 @@ on(type: "p2pDeviceChange", callback: Callback<WifiP2pDevice>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2536,7 +3177,7 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
...
@@ -2536,7 +3177,7 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
取消注册P2P设备状态改变事件。
取消注册P2P设备状态改变事件。
**需要权限:**
ohos.permission.LOCATION
**需要权限:**
ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -2545,13 +3186,13 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
...
@@ -2545,13 +3186,13 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pDeviceChange"字符串。 |
| type | string | 是 | 固定填"p2pDeviceChange"字符串。 |
| callback | Callback
<
[WifiP2pDevice](#wifip2pdevice9)
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
[WifiP2pDevice](#wifip2pdevice9)
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2561,7 +3202,7 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void
...
@@ -2561,7 +3202,7 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void
注册P2P对端设备状态改变事件。
注册P2P对端设备状态改变事件。
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
**需要权限:**
ohos.permission.GET_WIFI_INFO 和 ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -2576,7 +3217,7 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void
...
@@ -2576,7 +3217,7 @@ on(type: "p2pPeerDeviceChange", callback: Callback<WifiP2pDevice[]>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2586,7 +3227,7 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
...
@@ -2586,7 +3227,7 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
取消注册P2P对端设备状态改变事件。
取消注册P2P对端设备状态改变事件。
**需要权限:**
ohos.permission.LOCATION
**需要权限:**
ohos.permission.LOCATION
和 ohos.permission.APPROXIMATELY_LOCATION
**系统能力:**
SystemCapability.Communication.WiFi.P2P
**系统能力:**
SystemCapability.Communication.WiFi.P2P
...
@@ -2595,13 +3236,13 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
...
@@ -2595,13 +3236,13 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pPeerDeviceChange"字符串。 |
| type | string | 是 | 固定填"p2pPeerDeviceChange"字符串。 |
| callback | Callback
<
[WifiP2pDevice[]](#wifip2pdevice9)
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
[WifiP2pDevice[]](#wifip2pdevice9)
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2626,7 +3267,7 @@ on(type: "p2pPersistentGroupChange", callback: Callback<void>): void
...
@@ -2626,7 +3267,7 @@ on(type: "p2pPersistentGroupChange", callback: Callback<void>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2645,13 +3286,13 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void
...
@@ -2645,13 +3286,13 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pPersistentGroupChange"字符串。 |
| type | string | 是 | 固定填"p2pPersistentGroupChange"字符串。 |
| callback | Callback
<
void
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
void
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2683,7 +3324,7 @@ on(type: "p2pDiscoveryChange", callback: Callback<number>): void
...
@@ -2683,7 +3324,7 @@ on(type: "p2pDiscoveryChange", callback: Callback<number>): void
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
...
@@ -2702,12 +3343,12 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void
...
@@ -2702,12 +3343,12 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
|
**参数名**
|
**类型**
|
**必填**
|
**说明**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pDiscoveryChange"字符串。 |
| type | string | 是 | 固定填"p2pDiscoveryChange"字符串。 |
| callback | Callback
<
number
>
| 否 |
状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数
。 |
| callback | Callback
<
number
>
| 否 |
需要取消订阅的回调函数。若无此函数,则取消当前类型的所有订阅
。 |
**错误码:**
**错误码:**
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
以下错误码的详细介绍请参见
[
WIFI错误码
](
../errorcodes/errorcode-wifi.md
)
。
|
**
类型**
|
**说明
**
|
|
**
错误码ID**
|
**错误信息
**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录