Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7bffdce7
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7bffdce7
编写于
1月 30, 2023
作者:
@
@shi-xiaoxiao-iris
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[分布式硬件DM]示例代码问题修改
Signed-off-by:
N
@shi-xiaoxiao-iris
<
shixiaoxiao2@huawei.com
>
上级
b7515aec
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
13 deletion
+27
-13
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
.../application-dev/reference/apis/js-apis-device-manager.md
+27
-13
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-device-manager.md
浏览文件 @
7bffdce7
...
...
@@ -588,8 +588,9 @@ stopDeviceDiscovery(subscribeId: number): void
**示例:**
```
js
// 入参需要和startDeviceDiscovery接口传入的subscribeId配对使用
try
{
// 入参需要和startDeviceDiscovery接口传入的subscribeId配对使用
var
subscribeId
=
123456
;
dmInstance
.
stopDeviceDiscovery
(
subscribeId
);
}
catch
(
err
)
{
console
.
error
(
"
stopDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
...
@@ -630,7 +631,7 @@ publishDeviceDiscovery(publishInfo: PublishInfo): void
"
publishId
"
:
publishId
,
"
mode
"
:
0xAA
,
// 主动模式
"
freq
"
:
2
,
// 高频率
"
ranging
"
:
1
// 支持发现时测距
"
ranging
"
:
true
// 支持发现时测距
};
try
{
dmInstance
.
publishDeviceDiscovery
(
publishInfo
);
// 当有发布结果时,通过回调通知给应用程序
...
...
@@ -666,8 +667,9 @@ unPublishDeviceDiscovery(publishId: number): void
**示例:**
```
js
// 入参需要和publishDeviceDiscovery接口传入的publishId配对使用
try
{
// 入参需要和publishDeviceDiscovery接口传入的publishId配对使用
var
publishId
=
123456
;
dmInstance
.
unPublishDeviceDiscovery
(
publishId
);
}
catch
(
err
)
{
console
.
error
(
"
unPublishDeviceDiscovery errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
...
@@ -708,11 +710,19 @@ authenticateDevice(deviceInfo: DeviceInfo, authParam: AuthParam, callback: Async
var
deviceInfo
=
{
"
deviceId
"
:
"
XXXXXXXX
"
,
"
deviceName
"
:
""
,
deviceType
:
0x0E
"
deviceType
"
:
0x0E
,
"
networkId
"
:
"
xxxxxxx
"
,
"
range
"
:
0
};
let
extraInfo
=
{
'
targetPkgName
'
:
'
ohos.samples.xxx
'
,
'
appName
'
:
'
xxx
'
,
'
appDescription
'
:
'
xxx
'
,
'
business
'
:
'
0
'
}
let
authParam
=
{
"
authType
"
:
1
,
// 认证类型: 1 - 无帐号PIN码认证
"
extraInfo
"
:
{}
'
authType
'
:
1
,
// 认证类型: 1 - 无帐号PIN码认证
'
extraInfo
'
:
extraInfo
}
try
{
dmInstance
.
authenticateDevice
(
deviceInfo
,
authParam
,
(
err
,
data
)
=>
{
...
...
@@ -756,6 +766,13 @@ unAuthenticateDevice(deviceInfo: DeviceInfo): void
```
js
try
{
var
deviceInfo
=
{
"
deviceId
"
:
"
XXXXXXXX
"
,
"
deviceName
"
:
""
,
"
deviceType
"
:
0x0E
,
"
networkId
"
:
"
xxxxxxx
"
,
"
range
"
:
0
};
dmInstance
.
unAuthenticateDevice
(
deviceInfo
);
}
catch
(
err
)
{
console
.
error
(
"
unAuthenticateDevice errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
...
...
@@ -792,7 +809,7 @@ verifyAuthInfo(authInfo: AuthInfo, callback: AsyncCallback<{deviceId: string,
```
js
let
authInfo
=
{
"
authType
"
:
1
,
"
token
"
:
xxxxxx
,
"
token
"
:
123456
,
"
extraInfo
"
:
{}
}
try
{
...
...
@@ -838,7 +855,7 @@ setUserOperation(operateAction: number, params: string): void;
operateAction = 5 - pin码输入框确定操作
*/
let
operation
=
0
;
this
.
dmInstance
.
setUserOperation
(
operation
,
"
extra
"
)
dmInstance
.
setUserOperation
(
operation
,
"
extra
"
)
}
catch
(
err
)
{
console
.
error
(
"
setUserOperation errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
}
...
...
@@ -868,11 +885,8 @@ ui状态变更回调。
dmInstance
.
on
(
'
uiStateChange
'
,
(
data
)
=>
{
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
JSON
.
stringify
(
data
))
var
tmpStr
=
JSON
.
parse
(
data
.
param
)
this
.
isShow
=
tmpStr
.
verifyFailed
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
this
.
isShow
)
if
(
!
this
.
isShow
)
{
this
.
destruction
()
}
var
isShow
=
tmpStr
.
verifyFailed
console
.
log
(
"
uiStateChange executed, dialog closed
"
+
isShow
)
});
}
catch
(
err
)
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录