Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e50be7f7
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
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看板
提交
e50be7f7
编写于
5月 22, 2023
作者:
L
liujiaojiao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改md文档与d.ts不一致的问题
Signed-off-by:
N
liujiaojiao
<
liujiaojiao9@huawei.com
>
上级
4331c3c0
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
390 addition
and
18 deletion
+390
-18
zh-cn/application-dev/reference/apis/js-apis-wifi.md
zh-cn/application-dev/reference/apis/js-apis-wifi.md
+240
-18
zh-cn/application-dev/reference/apis/js-apis-wifiManager.md
zh-cn/application-dev/reference/apis/js-apis-wifiManager.md
+150
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-wifi.md
浏览文件 @
e50be7f7
...
@@ -1706,6 +1706,24 @@ createGroup(config: WifiP2PConfig): boolean
...
@@ -1706,6 +1706,24 @@ createGroup(config: WifiP2PConfig): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:创建群组操作执行成功, false:创建群组操作执行失败。 |
| boolean | true:创建群组操作执行成功, false:创建群组操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
let config = {
deviceAddress: "****",
netId: 0,
passphrase: "*****",
groupName: "****",
goBand: 0
}
wifi.createGroup(config);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## WifiP2PConfig<sup>8+</sup>
## WifiP2PConfig<sup>8+</sup>
...
@@ -1751,6 +1769,16 @@ removeGroup(): boolean
...
@@ -1751,6 +1769,16 @@ removeGroup(): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:操作执行成功, false:操作执行失败。 |
| boolean | true:操作执行成功, false:操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.removeGroup();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.p2pConnect<sup>8+</sup>
## wifi.p2pConnect<sup>8+</sup>
...
@@ -1859,6 +1887,16 @@ p2pCancelConnect(): boolean
...
@@ -1859,6 +1887,16 @@ p2pCancelConnect(): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:操作执行成功, false:操作执行失败。 |
| boolean | true:操作执行成功, false:操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.p2pCancelConnect();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.startDiscoverDevices<sup>8+</sup>
## wifi.startDiscoverDevices<sup>8+</sup>
...
@@ -1876,6 +1914,16 @@ startDiscoverDevices(): boolean
...
@@ -1876,6 +1914,16 @@ startDiscoverDevices(): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:操作执行成功, false:操作执行失败。 |
| boolean | true:操作执行成功, false:操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.startDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.stopDiscoverDevices<sup>8+</sup>
## wifi.stopDiscoverDevices<sup>8+</sup>
...
@@ -1893,6 +1941,16 @@ stopDiscoverDevices(): boolean
...
@@ -1893,6 +1941,16 @@ stopDiscoverDevices(): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:操作执行成功,操作执行失败。 |
| boolean | true:操作执行成功,操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.stopDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.deletePersistentGroup<sup>8+</sup>
## wifi.deletePersistentGroup<sup>8+</sup>
...
@@ -1919,6 +1977,17 @@ deletePersistentGroup(netId: number): boolean
...
@@ -1919,6 +1977,17 @@ deletePersistentGroup(netId: number): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:操作执行成功,操作执行失败。 |
| boolean | true:操作执行成功,操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
let netId = 0;
wifi.deletePersistentGroup(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## WifiP2pGroupInfo<sup>8+</sup>
## WifiP2pGroupInfo<sup>8+</sup>
...
@@ -1963,6 +2032,17 @@ setDeviceName(devName: string): boolean
...
@@ -1963,6 +2032,17 @@ setDeviceName(devName: string): boolean
| -------- | -------- |
| -------- | -------- |
| boolean | true:操作成功, false:操作失败。 |
| boolean | true:操作成功, false:操作失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
let name = "****";
wifi.setDeviceName(netId);
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.on('wifiStateChange')<sup>7+</sup>
## wifi.on('wifiStateChange')<sup>7+</sup>
...
@@ -2006,7 +2086,7 @@ off(type: "wifiStateChange", callback?: Callback<number>): void
...
@@ -2006,7 +2086,7 @@ off(type: "wifiStateChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiStateChange"字符串。 |
| type | string | 是 | 固定填"wifiStateChange"字符串。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将
去
注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将
取消
注册该事件关联的所有回调函数。 |
**示例:**
**示例:**
```
js
```
js
...
@@ -2064,8 +2144,22 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void
...
@@ -2064,8 +2144,22 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiConnectionChange"字符串。 |
| type | string | 是 | 固定填"wifiConnectionChange"字符串。 |
| callback | Callback<number> | 否 | 连接状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 连接状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvWifiConnectionChangeFunc = result => {
console.info("Receive wifi connection change event: " + result);
}
// Register event
wifi.on("wifiConnectionChange", recvWifiConnectionChangeFunc);
// Unregister event
wifi.off("wifiConnectionChange", recvWifiConnectionChangeFunc);
```
## wifi.on('wifiScanStateChange')<sup>7+</sup>
## wifi.on('wifiScanStateChange')<sup>7+</sup>
...
@@ -2107,8 +2201,22 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void
...
@@ -2107,8 +2201,22 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiScanStateChange"字符串。 |
| type | string | 是 | 固定填"wifiScanStateChange"字符串。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将
去
注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将
取消
注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvWifiScanStateChangeFunc = result => {
console.info("Receive Wifi scan state change event: " + result);
}
// Register event
wifi.on("wifiScanStateChange", recvWifiScanStateChangeFunc);
// Unregister event
wifi.off("wifiScanStateChange", recvWifiScanStateChangeFunc);
```
## wifi.on('wifiRssiChange')<sup>7+</sup>
## wifi.on('wifiRssiChange')<sup>7+</sup>
...
@@ -2143,8 +2251,22 @@ off(type: "wifiRssiChange", callback?: Callback<number>): void
...
@@ -2143,8 +2251,22 @@ off(type: "wifiRssiChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiRssiChange"字符串。 |
| type | string | 是 | 固定填"wifiRssiChange"字符串。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvWifiRssiChangeFunc = result => {
console.info("Receive wifi rssi change event: " + result);
}
// Register event
wifi.on("wifiRssiChange", recvWifiRssiChangeFunc);
// Unregister event
wifi.off("wifiRssiChange", recvWifiRssiChangeFunc);
```
## wifi.on('hotspotStateChange')<sup>7+</sup>
## wifi.on('hotspotStateChange')<sup>7+</sup>
...
@@ -2172,6 +2294,21 @@ on(type: "hotspotStateChange", callback: Callback<number>): void
...
@@ -2172,6 +2294,21 @@ on(type: "hotspotStateChange", callback: Callback<number>): void
| 2 | 激活中。 |
| 2 | 激活中。 |
| 3 | 去激活中。 |
| 3 | 去激活中。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvHotspotStateChangeFunc = result => {
console.info("Receive hotspot state change event: " + result);
}
// Register event
wifi.on("hotspotStateChange", recvHotspotStateChangeFunc);
// Unregister event
wifi.off("hotspotStateChange", recvHotspotStateChangeFunc);
```
## wifi.off('hotspotStateChange')<sup>7+</sup>
## wifi.off('hotspotStateChange')<sup>7+</sup>
...
@@ -2188,7 +2325,7 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void
...
@@ -2188,7 +2325,7 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"hotspotStateChange"字符串。 |
| type | string | 是 | 固定填"hotspotStateChange"字符串。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将
去
注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将
取消
注册该事件关联的所有回调函数。 |
## wifi.on('p2pStateChange')<sup>8+</sup>
## wifi.on('p2pStateChange')<sup>8+</sup>
...
@@ -2233,8 +2370,22 @@ off(type: "p2pStateChange", callback?: Callback<number>): void
...
@@ -2233,8 +2370,22 @@ off(type: "p2pStateChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pStateChange"字符串。 |
| type | string | 是 | 固定填"p2pStateChange"字符串。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvP2pStateChangeFunc = result => {
console.info("Receive p2p state change event: " + result);
}
// Register event
wifi.on("p2pStateChange", recvP2pStateChangeFunc);
// Unregister event
wifi.off("p2pStateChange", recvP2pStateChangeFunc);
```
## wifi.on('p2pConnectionChange')<sup>8+</sup>
## wifi.on('p2pConnectionChange')<sup>8+</sup>
...
@@ -2269,8 +2420,22 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>):
...
@@ -2269,8 +2420,22 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>):
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pConnectionChange"字符串。 |
| type | string | 是 | 固定填"p2pConnectionChange"字符串。 |
| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<[WifiP2pLinkedInfo](#wifip2plinkedinfo8)> | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvP2pConnectionChangeFunc = result => {
console.info("Receive p2p connection change event: " + result);
}
// Register event
wifi.on("p2pConnectionChange", recvP2pConnectionChangeFunc);
// Unregister event
wifi.off("p2pConnectionChange", recvP2pConnectionChangeFunc);
```
## wifi.on('p2pDeviceChange')<sup>8+</sup>
## wifi.on('p2pDeviceChange')<sup>8+</sup>
...
@@ -2305,8 +2470,22 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
...
@@ -2305,8 +2470,22 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pDeviceChange"字符串。 |
| type | string | 是 | 固定填"p2pDeviceChange"字符串。 |
| callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<[WifiP2pDevice](#wifip2pdevice8)> | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvP2pDeviceChangeFunc = result => {
console.info("Receive recv p2p device change event: " + result);
}
// Register event
wifi.on("p2pDeviceChange", recvP2pDeviceChangeFunc);
// Unregister event
wifi.off("p2pDeviceChange", recvP2pDeviceChangeFunc);
```
## wifi.on('p2pPeerDeviceChange')<sup>8+</sup>
## wifi.on('p2pPeerDeviceChange')<sup>8+</sup>
...
@@ -2341,8 +2520,22 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
...
@@ -2341,8 +2520,22 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pPeerDeviceChange"字符串。 |
| type | string | 是 | 固定填"p2pPeerDeviceChange"字符串。 |
| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<[WifiP2pDevice[]](#wifip2pdevice8)> | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvP2pPeerDeviceChangeFunc = result => {
console.info("Receive recv p2p peer device change event: " + result);
}
// Register event
wifi.on("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);
// Unregister event
wifi.off("p2pPeerDeviceChange", recvP2pPeerDeviceChangeFunc);
```
## wifi.on('p2pPersistentGroupChange')<sup>8+</sup>
## wifi.on('p2pPersistentGroupChange')<sup>8+</sup>
...
@@ -2377,8 +2570,23 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void
...
@@ -2377,8 +2570,23 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pPersistentGroupChange"字符串。 |
| type | string | 是 | 固定填"p2pPersistentGroupChange"字符串。 |
| callback | Callback<void> | 否 | 状态改变回调函数。如果callback不填,将
去
注册该事件关联的所有回调函数。 |
| callback | Callback<void> | 否 | 状态改变回调函数。如果callback不填,将
取消
注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvP2pPersistentGroupChangeFunc = result => {
console.info("Receive recv p2p persistent group change event: " + result);
}
// Register event
wifi.on("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);
// Unregister event
wifi.off("p2pPersistentGroupChange", recvP2pPersistentGroupChangeFunc);
```
## wifi.on('p2pDiscoveryChange')<sup>8+</sup>
## wifi.on('p2pDiscoveryChange')<sup>8+</sup>
...
@@ -2420,5 +2628,19 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void
...
@@ -2420,5 +2628,19 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void
| **参数名** | **类型** | **必填** | **说明** |
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pDiscoveryChange"字符串。 |
| type | string | 是 | 固定填"p2pDiscoveryChange"字符串。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback<number> | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```
js
import wifi from '@ohos.wifi';
var recvP2pDiscoveryChangeFunc = result => {
console.info("Receive recv p2p discovery change event: " + result);
}
// Register event
wifi.on("p2pDiscoveryChange", recvP2pDiscoveryChangeFunc);
// Unregister event
wifi.off("p2pDiscoveryChange", recvP2pDiscoveryChangeFunc);
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-wifiManager.md
浏览文件 @
e50be7f7
...
@@ -2901,6 +2901,21 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void
...
@@ -2901,6 +2901,21 @@ off(type: "wifiConnectionChange", callback?: Callback<number>): void
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifi
'
;
var
recvWifiConnectionChangeFunc
=
result
=>
{
console
.
info
(
"
Receive wifi connection change event:
"
+
result
);
}
// Register event
wifi
.
on
(
"
wifiConnectionChange
"
,
recvWifiConnectionChangeFunc
);
// Unregister event
wifi
.
off
(
"
wifiConnectionChange
"
,
recvWifiConnectionChangeFunc
);
```
## wifi.on('wifiScanStateChange')<sup>9+</sup>
## wifi.on('wifiScanStateChange')<sup>9+</sup>
on(type: "wifiScanStateChange", callback: Callback
<
number
>
): void
on(type: "wifiScanStateChange", callback: Callback
<
number
>
): void
...
@@ -2958,6 +2973,21 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void
...
@@ -2958,6 +2973,21 @@ off(type: "wifiScanStateChange", callback?: Callback<number>): void
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifi
'
;
var
recvWifiScanStateChangeFunc
=
result
=>
{
console
.
info
(
"
Receive Wifi scan state change event:
"
+
result
);
}
// Register event
wifi
.
on
(
"
wifiScanStateChange
"
,
recvWifiScanStateChangeFunc
);
// Unregister event
wifi
.
off
(
"
wifiScanStateChange
"
,
recvWifiScanStateChangeFunc
);
```
## wifi.on('wifiRssiChange')<sup>9+</sup>
## wifi.on('wifiRssiChange')<sup>9+</sup>
on(type: "wifiRssiChange", callback: Callback
<
number
>
): void
on(type: "wifiRssiChange", callback: Callback
<
number
>
): void
...
@@ -3008,6 +3038,21 @@ off(type: "wifiRssiChange", callback?: Callback<number>): void
...
@@ -3008,6 +3038,21 @@ off(type: "wifiRssiChange", callback?: Callback<number>): void
| -------- | -------- |
| -------- | -------- |
| 2501000 | Operation failed.|
| 2501000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvWifiRssiChangeFunc
=
result
=>
{
console
.
info
(
"
Receive wifi rssi change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
wifiRssiChange
"
,
recvWifiRssiChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
wifiRssiChange
"
,
recvWifiRssiChangeFunc
);
```
## wifi.on('hotspotStateChange')<sup>9+</sup>
## wifi.on('hotspotStateChange')<sup>9+</sup>
on(type: "hotspotStateChange", callback: Callback
<
number
>
): void
on(type: "hotspotStateChange", callback: Callback
<
number
>
): void
...
@@ -3067,6 +3112,21 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void
...
@@ -3067,6 +3112,21 @@ off(type: "hotspotStateChange", callback?: Callback<number>): void
| -------- | -------- |
| -------- | -------- |
| 2601000 | Operation failed.|
| 2601000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvHotspotStateChangeFunc
=
result
=>
{
console
.
info
(
"
Receive hotspot state change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
hotspotStateChange
"
,
recvHotspotStateChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
hotspotStateChange
"
,
recvHotspotStateChangeFunc
);
```
## wifi.on('p2pStateChange')<sup>9+</sup>
## wifi.on('p2pStateChange')<sup>9+</sup>
on(type: "p2pStateChange", callback: Callback
<
number
>
): void
on(type: "p2pStateChange", callback: Callback
<
number
>
): void
...
@@ -3127,6 +3187,21 @@ off(type: "p2pStateChange", callback?: Callback<number>): void
...
@@ -3127,6 +3187,21 @@ off(type: "p2pStateChange", callback?: Callback<number>): void
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvP2pStateChangeFunc
=
result
=>
{
console
.
info
(
"
Receive p2p state change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
p2pStateChange
"
,
recvP2pStateChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
p2pStateChange
"
,
recvP2pStateChangeFunc
);
```
## wifi.on('p2pConnectionChange')
<sup>
9+
</sup>
## wifi.on('p2pConnectionChange')
<sup>
9+
</sup>
on(type: "p2pConnectionChange", callback: Callback
<
WifiP2pLinkedInfo
>
): void
on(type: "p2pConnectionChange", callback: Callback
<
WifiP2pLinkedInfo
>
): void
...
@@ -3177,6 +3252,21 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>):
...
@@ -3177,6 +3252,21 @@ off(type: "p2pConnectionChange", callback?: Callback<WifiP2pLinkedInfo>):
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvP2pConnectionChangeFunc
=
result
=>
{
console
.
info
(
"
Receive p2p connection change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
p2pConnectionChange
"
,
recvP2pConnectionChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
p2pConnectionChange
"
,
recvP2pConnectionChangeFunc
);
```
## wifi.on('p2pDeviceChange')<sup>9+</sup>
## wifi.on('p2pDeviceChange')<sup>9+</sup>
on(type: "p2pDeviceChange", callback: Callback
<
WifiP2pDevice
>
): void
on(type: "p2pDeviceChange", callback: Callback
<
WifiP2pDevice
>
): void
...
@@ -3227,6 +3317,21 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
...
@@ -3227,6 +3317,21 @@ off(type: "p2pDeviceChange", callback?: Callback<WifiP2pDevice>): void
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvP2pDeviceChangeFunc
=
result
=>
{
console
.
info
(
"
Receive recv p2p device change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
p2pDeviceChange
"
,
recvP2pDeviceChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
p2pDeviceChange
"
,
recvP2pDeviceChangeFunc
);
```
## wifi.on('p2pPeerDeviceChange')<sup>9+</sup>
## wifi.on('p2pPeerDeviceChange')<sup>9+</sup>
on(type: "p2pPeerDeviceChange", callback: Callback
<
WifiP2pDevice[]
>
): void
on(type: "p2pPeerDeviceChange", callback: Callback
<
WifiP2pDevice[]
>
): void
...
@@ -3277,6 +3382,21 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
...
@@ -3277,6 +3382,21 @@ off(type: "p2pPeerDeviceChange", callback?: Callback<WifiP2pDevice[]>): vo
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvP2pPeerDeviceChangeFunc
=
result
=>
{
console
.
info
(
"
Receive recv p2p peer device change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
p2pPeerDeviceChange
"
,
recvP2pPeerDeviceChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
p2pPeerDeviceChange
"
,
recvP2pPeerDeviceChangeFunc
);
```
## wifi.on('p2pPersistentGroupChange')<sup>9+</sup>
## wifi.on('p2pPersistentGroupChange')<sup>9+</sup>
on(type: "p2pPersistentGroupChange", callback: Callback
<
void
>
): void
on(type: "p2pPersistentGroupChange", callback: Callback
<
void
>
): void
...
@@ -3327,6 +3447,21 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void
...
@@ -3327,6 +3447,21 @@ off(type: "p2pPersistentGroupChange", callback?: Callback<void>): void
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvP2pPersistentGroupChangeFunc
=
result
=>
{
console
.
info
(
"
Receive recv p2p persistent group change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
p2pPersistentGroupChange
"
,
recvP2pPersistentGroupChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
p2pPersistentGroupChange
"
,
recvP2pPersistentGroupChangeFunc
);
```
## wifi.on('p2pDiscoveryChange')<sup>9+</sup>
## wifi.on('p2pDiscoveryChange')<sup>9+</sup>
on(type: "p2pDiscoveryChange", callback: Callback
<
number
>
): void
on(type: "p2pDiscoveryChange", callback: Callback
<
number
>
): void
...
@@ -3383,3 +3518,18 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void
...
@@ -3383,3 +3518,18 @@ off(type: "p2pDiscoveryChange", callback?: Callback<number>): void
|
**错误码ID**
|
**错误信息**
|
|
**错误码ID**
|
**错误信息**
|
| -------- | -------- |
| -------- | -------- |
| 2801000 | Operation failed.|
| 2801000 | Operation failed.|
**示例:**
```
js
import
wifi
from
'
@ohos.wifiManager
'
;
var
recvP2pDiscoveryChangeFunc
=
result
=>
{
console
.
info
(
"
Receive recv p2p discovery change event:
"
+
result
);
}
// Register event
wifiManager
.
on
(
"
p2pDiscoveryChange
"
,
recvP2pDiscoveryChangeFunc
);
// Unregister event
wifiManager
.
off
(
"
p2pDiscoveryChange
"
,
recvP2pDiscoveryChangeFunc
);
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录