提交 e50be7f7 编写于 作者: L liujiaojiao

修改md文档与d.ts不一致的问题

Signed-off-by: Nliujiaojiao <liujiaojiao9@huawei.com>
上级 4331c3c0
......@@ -1706,6 +1706,24 @@ createGroup(config: WifiP2PConfig): boolean
| -------- | -------- |
| boolean | true:创建群组操作执行成功,&nbsp;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>
......@@ -1751,6 +1769,16 @@ removeGroup(): boolean
| -------- | -------- |
| boolean | true:操作执行成功,&nbsp;false:操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.removeGroup();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.p2pConnect<sup>8+</sup>
......@@ -1859,6 +1887,16 @@ p2pCancelConnect(): boolean
| -------- | -------- |
| boolean | true:操作执行成功,&nbsp;false:操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.p2pCancelConnect();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.startDiscoverDevices<sup>8+</sup>
......@@ -1876,6 +1914,16 @@ startDiscoverDevices(): boolean
| -------- | -------- |
| boolean | true:操作执行成功,&nbsp;false:操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.startDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.stopDiscoverDevices<sup>8+</sup>
......@@ -1893,6 +1941,16 @@ stopDiscoverDevices(): boolean
| -------- | -------- |
| boolean | true:操作执行成功,操作执行失败。 |
**示例:**
```
import wifi from '@ohos.wifi';
try {
wifi.stopDiscoverDevices();
}catch(error){
console.error("failed:" + JSON.stringify(error));
}
```
## wifi.deletePersistentGroup<sup>8+</sup>
......@@ -1919,6 +1977,17 @@ deletePersistentGroup(netId: number): boolean
| -------- | -------- |
| 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>
......@@ -1963,6 +2032,17 @@ setDeviceName(devName: string): boolean
| -------- | -------- |
| boolean | true:操作成功,&nbsp;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>
......@@ -2006,7 +2086,7 @@ off(type: "wifiStateChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiStateChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
**示例:**
```js
......@@ -2064,8 +2144,22 @@ off(type: "wifiConnectionChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiConnectionChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 连接状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 连接状态改变回调函数。如果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>
......@@ -2107,8 +2201,22 @@ off(type: "wifiScanStateChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiScanStateChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2143,8 +2251,22 @@ off(type: "wifiRssiChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"wifiRssiChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2172,6 +2294,21 @@ on(type: "hotspotStateChange", callback: Callback&lt;number&gt;): void
| 2 | 激活中。 |
| 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>
......@@ -2188,7 +2325,7 @@ off(type: "hotspotStateChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"hotspotStateChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将取消注册该事件关联的所有回调函数。 |
## wifi.on('p2pStateChange')<sup>8+</sup>
......@@ -2233,8 +2370,22 @@ off(type: "p2pStateChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pStateChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2269,8 +2420,22 @@ off(type: "p2pConnectionChange", callback?: Callback&lt;WifiP2pLinkedInfo&gt;):
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pConnectionChange"字符串。 |
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;[WifiP2pLinkedInfo](#wifip2plinkedinfo8)&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2305,8 +2470,22 @@ off(type: "p2pDeviceChange", callback?: Callback&lt;WifiP2pDevice&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pDeviceChange"字符串。 |
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;[WifiP2pDevice](#wifip2pdevice8)&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2341,8 +2520,22 @@ off(type: "p2pPeerDeviceChange", callback?: Callback&lt;WifiP2pDevice[]&gt;): vo
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pPeerDeviceChange"字符串。 |
| callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;[WifiP2pDevice[]](#wifip2pdevice8)&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2377,8 +2570,23 @@ off(type: "p2pPersistentGroupChange", callback?: Callback&lt;void&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pPersistentGroupChange"字符串。 |
| callback | Callback&lt;void&gt; | 否 | 状态改变回调函数。如果callback不填,将注册该事件关联的所有回调函数。 |
| callback | Callback&lt;void&gt; | 否 | 状态改变回调函数。如果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>
......@@ -2420,5 +2628,19 @@ off(type: "p2pDiscoveryChange", callback?: Callback&lt;number&gt;): void
| **参数名** | **类型** | **必填** | **说明** |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 固定填"p2pDiscoveryChange"字符串。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果callback不填,将去注册该事件关联的所有回调函数。 |
| callback | Callback&lt;number&gt; | 否 | 状态改变回调函数。如果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
......@@ -2901,6 +2901,21 @@ off(type: "wifiConnectionChange", callback?: Callback&lt;number&gt;): void
| -------- | -------- |
| 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>
on(type: "wifiScanStateChange", callback: Callback&lt;number&gt;): void
......@@ -2958,6 +2973,21 @@ off(type: "wifiScanStateChange", callback?: Callback&lt;number&gt;): void
| -------- | -------- |
| 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>
on(type: "wifiRssiChange", callback: Callback&lt;number&gt;): void
......@@ -3008,6 +3038,21 @@ off(type: "wifiRssiChange", callback?: Callback&lt;number&gt;): void
| -------- | -------- |
| 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>
on(type: "hotspotStateChange", callback: Callback&lt;number&gt;): void
......@@ -3067,6 +3112,21 @@ off(type: "hotspotStateChange", callback?: Callback&lt;number&gt;): void
| -------- | -------- |
| 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>
on(type: "p2pStateChange", callback: Callback&lt;number&gt;): void
......@@ -3127,6 +3187,21 @@ off(type: "p2pStateChange", callback?: Callback&lt;number&gt;): void
| -------- | -------- |
| 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>
on(type: "p2pConnectionChange", callback: Callback&lt;WifiP2pLinkedInfo&gt;): void
......@@ -3177,6 +3252,21 @@ off(type: "p2pConnectionChange", callback?: Callback&lt;WifiP2pLinkedInfo&gt;):
| -------- | -------- |
| 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>
on(type: "p2pDeviceChange", callback: Callback&lt;WifiP2pDevice&gt;): void
......@@ -3227,6 +3317,21 @@ off(type: "p2pDeviceChange", callback?: Callback&lt;WifiP2pDevice&gt;): void
| -------- | -------- |
| 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>
on(type: "p2pPeerDeviceChange", callback: Callback&lt;WifiP2pDevice[]&gt;): void
......@@ -3277,6 +3382,21 @@ off(type: "p2pPeerDeviceChange", callback?: Callback&lt;WifiP2pDevice[]&gt;): vo
| -------- | -------- |
| 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>
on(type: "p2pPersistentGroupChange", callback: Callback&lt;void&gt;): void
......@@ -3327,6 +3447,21 @@ off(type: "p2pPersistentGroupChange", callback?: Callback&lt;void&gt;): void
| -------- | -------- |
| 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>
on(type: "p2pDiscoveryChange", callback: Callback&lt;number&gt;): void
......@@ -3383,3 +3518,18 @@ off(type: "p2pDiscoveryChange", callback?: Callback&lt;number&gt;): void
| **错误码ID** | **错误信息** |
| -------- | -------- |
| 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.
先完成此消息的编辑!
想要评论请 注册