Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
ca7a91ad
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看板
未验证
提交
ca7a91ad
编写于
2月 25, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
!15221 翻译完成:14047 【分布式硬件DM】示例代码问题修改
Merge pull request !15221 from wusongqing/TR14047
上级
d7daa46a
38c22222
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
13 deletion
+40
-13
en/application-dev/reference/apis/js-apis-device-manager.md
en/application-dev/reference/apis/js-apis-device-manager.md
+40
-13
未找到文件。
en/application-dev/reference/apis/js-apis-device-manager.md
浏览文件 @
ca7a91ad
...
@@ -78,6 +78,7 @@ Defines device information.
...
@@ -78,6 +78,7 @@ Defines device information.
| deviceType |
[
DeviceType
](
#devicetype
)
| Yes | Device type. |
| deviceType |
[
DeviceType
](
#devicetype
)
| Yes | Device type. |
| networkId
<sup>
8+
</sup>
| string | Yes | Network ID of the device. |
| networkId
<sup>
8+
</sup>
| string | Yes | Network ID of the device. |
| range
<sup>
9+
</sup>
| number | Yes | Distance between the device (discovered device) and the device that initiates device discovery. |
| range
<sup>
9+
</sup>
| number | Yes | Distance between the device (discovered device) and the device that initiates device discovery. |
| authForm
<sup>
10+
</sup>
|
[
AuthForm
](
#authform
)
| Yes | Authentication type of the device. |
## DeviceType
## DeviceType
...
@@ -95,6 +96,18 @@ Enumerates the device types.
...
@@ -95,6 +96,18 @@ Enumerates the device types.
| CAR | 0x83 | Car. |
| CAR | 0x83 | Car. |
| UNKNOWN_TYPE | 0 | Unknown device type.|
| UNKNOWN_TYPE | 0 | Unknown device type.|
## AuthForm
Enumerates the device authentication types.
**System capability**
: SystemCapability.DistributedHardware.DeviceManager
| Name | Value | Description |
| ------------------- | ---- | --------------- |
| INVALID_TYPE | -1 | No authentication.|
| PEER_TO_PEER | 0 | Point-to-point authentication for devices without accounts. |
| IDENTICAL_ACCOUNT | 1 | Authentication for devices using the same account. |
| ACROSS_ACCOUNT | 2 | Authentication for devices using different accounts.|
## DeviceStateChangeAction
## DeviceStateChangeAction
...
@@ -588,8 +601,9 @@ For details about the error codes, see [Device Management Error Codes](../errorc
...
@@ -588,8 +601,9 @@ For details about the error codes, see [Device Management Error Codes](../errorc
**Example**
**Example**
```
js
```
js
// The subscribeId input must be the same as that automatically generated in startDeviceDiscovery.
try
{
try
{
// stopDeviceDiscovery and startDeviceDiscovery must be used in pairs, and the input parameter **subscribeId** passed in them must be the same.
var
subscribeId
=
12345
;
dmInstance
.
stopDeviceDiscovery
(
subscribeId
);
dmInstance
.
stopDeviceDiscovery
(
subscribeId
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
stopDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
stopDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
@@ -630,7 +644,7 @@ For details about the error codes, see [Device Management Error Codes](../errorc
...
@@ -630,7 +644,7 @@ For details about the error codes, see [Device Management Error Codes](../errorc
"
publishId
"
:
publishId
,
"
publishId
"
:
publishId
,
"
mode
"
:
0xAA
,
// Active discovery
"
mode
"
:
0xAA
,
// Active discovery
"
freq
"
:
2
,
// High frequency
"
freq
"
:
2
,
// High frequency
"
ranging
"
:
1
// The device supports reporting the distance to the discovery initiator.
"
ranging
"
:
true
// The device supports reporting the distance to the discovery initiator.
};
};
try
{
try
{
dmInstance
.
publishDeviceDiscovery
(
publishInfo
);
// A callback is invoked to notify the application when the device information is published.
dmInstance
.
publishDeviceDiscovery
(
publishInfo
);
// A callback is invoked to notify the application when the device information is published.
...
@@ -666,8 +680,9 @@ For details about the error codes, see [Device Management Error Codes](../errorc
...
@@ -666,8 +680,9 @@ For details about the error codes, see [Device Management Error Codes](../errorc
**Example**
**Example**
```
js
```
js
// The publishId input must be the same as that automatically generated in publishDeviceDiscovery.
try
{
try
{
// unPublishDeviceDiscovery and publishDeviceDiscovery must be used in pairs, and the input parameter **publishId** passed in them must be the same.
var
publishId
=
12345
;
dmInstance
.
unPublishDeviceDiscovery
(
publishId
);
dmInstance
.
unPublishDeviceDiscovery
(
publishId
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
unPublishDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
unPublishDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
@@ -708,11 +723,19 @@ For details about the error codes, see [Device Management Error Codes](../errorc
...
@@ -708,11 +723,19 @@ For details about the error codes, see [Device Management Error Codes](../errorc
var
deviceInfo
=
{
var
deviceInfo
=
{
"
deviceId
"
:
"
XXXXXXXX
"
,
"
deviceId
"
:
"
XXXXXXXX
"
,
"
deviceName
"
:
""
,
"
deviceName
"
:
""
,
deviceType
:
0x0E
"
deviceType
"
:
0x0E
,
"
networkId
"
:
"
xxxxxxx
"
,
"
range
"
:
0
};
};
let
extraInfo
=
{
'
targetPkgName
'
:
'
ohos.samples.xxx
'
,
'
appName
'
:
'
xxx
'
,
'
appDescription
'
:
'
xxx
'
,
'
business
'
:
'
0
'
}
let
authParam
=
{
let
authParam
=
{
"
authType
"
:
1
,
// Authentication type. The value 1 means no account PIN authentication.
'
authType
'
:
1
,
// Authentication type. The value 1 means no account PIN authentication.
"
extraInfo
"
:
{}
'
extraInfo
'
:
extraInfo
}
}
try
{
try
{
dmInstance
.
authenticateDevice
(
deviceInfo
,
authParam
,
(
err
,
data
)
=>
{
dmInstance
.
authenticateDevice
(
deviceInfo
,
authParam
,
(
err
,
data
)
=>
{
...
@@ -756,6 +779,13 @@ For details about the error codes, see [Device Management Error Codes](../errorc
...
@@ -756,6 +779,13 @@ For details about the error codes, see [Device Management Error Codes](../errorc
```
js
```
js
try
{
try
{
var
deviceInfo
=
{
"
deviceId
"
:
"
XXXXXXXX
"
,
"
deviceName
"
:
""
,
"
deviceType
"
:
0x0E
,
"
networkId
"
:
"
xxxxxxx
"
,
"
range
"
:
0
};
dmInstance
.
unAuthenticateDevice
(
deviceInfo
);
dmInstance
.
unAuthenticateDevice
(
deviceInfo
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
unAuthenticateDevice errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
unAuthenticateDevice errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
@@ -792,7 +822,7 @@ For details about the error codes, see [Device Management Error Codes](../errorc
...
@@ -792,7 +822,7 @@ For details about the error codes, see [Device Management Error Codes](../errorc
```
js
```
js
let
authInfo
=
{
let
authInfo
=
{
"
authType
"
:
1
,
"
authType
"
:
1
,
"
token
"
:
xxxxxx
,
"
token
"
:
123456
,
"
extraInfo
"
:
{}
"
extraInfo
"
:
{}
}
}
try
{
try
{
...
@@ -838,7 +868,7 @@ Sets a user operation.
...
@@ -838,7 +868,7 @@ Sets a user operation.
operateAction = 5 - Confirm the input in the PIN input box.
operateAction = 5 - Confirm the input in the PIN input box.
*/
*/
let
operation
=
0
;
let
operation
=
0
;
this
.
dmInstance
.
setUserOperation
(
operation
,
"
extra
"
)
dmInstance
.
setUserOperation
(
operation
,
"
extra
"
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
setUserOperation errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
setUserOperation errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
}
...
@@ -868,11 +898,8 @@ Subscribes to UI status changes.
...
@@ -868,11 +898,8 @@ Subscribes to UI status changes.
dmInstance
.
on
(
'
uiStateChange
'
,
(
data
)
=>
{
dmInstance
.
on
(
'
uiStateChange
'
,
(
data
)
=>
{
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
JSON
.
stringify
(
data
))
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
JSON
.
stringify
(
data
))
var
tmpStr
=
JSON
.
parse
(
data
.
param
)
var
tmpStr
=
JSON
.
parse
(
data
.
param
)
this
.
isShow
=
tmpStr
.
verifyFailed
var
isShow
=
tmpStr
.
verifyFailed
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
this
.
isShow
)
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
isShow
)
if
(
!
this
.
isShow
)
{
this
.
destruction
()
}
});
});
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"
uiStateChange errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
uiStateChange errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录