Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2f1e9470
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看板
未验证
提交
2f1e9470
编写于
9月 06, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 06, 2023
浏览文件
操作
浏览文件
下载
差异文件
!24115 fix:Modifying arkts alarms
Merge pull request !24115 from 马海/master
上级
89d964ec
87fb7cda
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
90 addition
and
86 deletion
+90
-86
zh-cn/application-dev/reference/apis/js-apis-usbManager.md
zh-cn/application-dev/reference/apis/js-apis-usbManager.md
+90
-86
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-usbManager.md
浏览文件 @
2f1e9470
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
## 导入模块
## 导入模块
```
j
s
```
t
s
import
usb
from
"
@ohos.usbManager
"
;
import
usb
from
"
@ohos.usbManager
"
;
```
```
...
@@ -28,8 +28,9 @@ getDevices(): Array<Readonly<USBDevice>>
...
@@ -28,8 +28,9 @@ getDevices(): Array<Readonly<USBDevice>>
**示例:**
**示例:**
```
js
```
ts
let
devicesList
=
usb
.
getDevices
();
/*
let devicesList: Array<USBDevice> = usb.getDevices();
console.log(`devicesList = ${devicesList}`);
console.log(`devicesList = ${devicesList}`);
//devicesList 返回的数据结构
//devicesList 返回的数据结构
//此处提供一个简单的示例,如下
//此处提供一个简单的示例,如下
...
@@ -81,6 +82,7 @@ console.log(`devicesList = ${devicesList}`);
...
@@ -81,6 +82,7 @@ console.log(`devicesList = ${devicesList}`);
],
],
},
},
]
]
*/
```
```
## usb.connectDevice
## usb.connectDevice
...
@@ -115,15 +117,15 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe>
...
@@ -115,15 +117,15 @@ connectDevice(device: USBDevice): Readonly<USBDevicePipe>
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
let
device
=
devicesList
[
0
];
let
device
:
USBDevice
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
device
);
console
.
log
(
`devicepipe =
${
devicepipe
}
`
);
console
.
log
(
`devicepipe =
${
devicepipe
}
`
);
```
```
...
@@ -151,10 +153,10 @@ hasRight(deviceName: string): boolean
...
@@ -151,10 +153,10 @@ hasRight(deviceName: string): boolean
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesName
=
"
1-1
"
;
let
devicesName
:
string
=
"
1-1
"
;
let
bool
=
usb
.
hasRight
(
devicesName
);
let
right
:
boolean
=
usb
.
hasRight
(
devicesName
);
console
.
log
(
`
${
bool
}
`
);
console
.
log
(
`
${
right
}
`
);
```
```
## usb.requestRight
## usb.requestRight
...
@@ -179,9 +181,9 @@ requestRight(deviceName: string): Promise<boolean>
...
@@ -179,9 +181,9 @@ requestRight(deviceName: string): Promise<boolean>
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesName
=
"
1-1
"
;
let
devicesName
:
string
=
"
1-1
"
;
usb
.
requestRight
(
devicesName
).
then
((
ret
)
=>
{
usb
.
requestRight
(
devicesName
:).
then
((
ret
:
number
)
=>
{
console
.
log
(
`requestRight =
${
ret
}
`
);
console
.
log
(
`requestRight =
${
ret
}
`
);
});
});
```
```
...
@@ -208,8 +210,8 @@ removeRight(deviceName: string): boolean
...
@@ -208,8 +210,8 @@ removeRight(deviceName: string): boolean
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesName
=
"
1-1
"
;
let
devicesName
:
string
=
"
1-1
"
;
if
(
usb
.
removeRight
(
devicesName
))
{
if
(
usb
.
removeRight
(
devicesName
))
{
console
.
log
(
`Succeed in removing right`
);
console
.
log
(
`Succeed in removing right`
);
}
}
...
@@ -242,9 +244,9 @@ addRight(bundleName: string, deviceName: string): boolean
...
@@ -242,9 +244,9 @@ addRight(bundleName: string, deviceName: string): boolean
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesName
=
"
1-1
"
;
let
devicesName
:
string
=
"
1-1
"
;
let
bundleName
=
"
com.example.hello
"
;
let
bundleName
:
string
=
"
com.example.hello
"
;
if
(
usb
.
addRight
(
bundleName
,
devicesName
))
{
if
(
usb
.
addRight
(
bundleName
,
devicesName
))
{
console
.
log
(
`Succeed in adding right`
);
console
.
log
(
`Succeed in adding right`
);
}
}
...
@@ -276,17 +278,17 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): numb
...
@@ -276,17 +278,17 @@ claimInterface(pipe: USBDevicePipe, iface: USBInterface, force ?: boolean): numb
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
let
device
=
devicesList
[
0
];
let
device
:
USBDevice
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
interfaces
:
USBInterface
=
device
.
configs
[
0
].
interfaces
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
let
ret
:
number
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
console
.
log
(
`claimInterface =
${
ret
}
`
);
console
.
log
(
`claimInterface =
${
ret
}
`
);
```
```
...
@@ -315,17 +317,17 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number
...
@@ -315,17 +317,17 @@ releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
let
device
=
devicesList
[
0
];
let
device
:
USBDevice
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
interfaces
:
USBInterface
=
device
.
configs
[
0
].
interfaces
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
let
ret
:
number
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
ret
=
usb
.
releaseInterface
(
devicepipe
,
interfaces
);
ret
=
usb
.
releaseInterface
(
devicepipe
,
interfaces
);
console
.
log
(
`releaseInterface =
${
ret
}
`
);
console
.
log
(
`releaseInterface =
${
ret
}
`
);
```
```
...
@@ -355,17 +357,17 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number
...
@@ -355,17 +357,17 @@ setConfiguration(pipe: USBDevicePipe, config: USBConfiguration): number
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
let
device
=
devicesList
[
0
];
let
device
:
USBDevice
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
device
);
let
config
=
device
.
configs
[
0
];
let
config
:
USBConfiguration
=
device
.
configs
[
0
];
let
ret
=
usb
.
setConfiguration
(
devicepipe
,
config
);
let
ret
:
number
=
usb
.
setConfiguration
(
devicepipe
,
config
);
console
.
log
(
`setConfiguration =
${
ret
}
`
);
console
.
log
(
`setConfiguration =
${
ret
}
`
);
```
```
...
@@ -394,17 +396,17 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number
...
@@ -394,17 +396,17 @@ setInterface(pipe: USBDevicePipe, iface: USBInterface): number
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
let
device
=
devicesList
[
0
];
let
device
:
USBDevice
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
interfaces
:
USBInterface
=
device
.
configs
[
0
].
interfaces
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
let
ret
:
number
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
ret
=
usb
.
setInterface
(
devicepipe
,
interfaces
);
ret
=
usb
.
setInterface
(
devicepipe
,
interfaces
);
console
.
log
(
`setInterface =
${
ret
}
`
);
console
.
log
(
`setInterface =
${
ret
}
`
);
```
```
...
@@ -433,15 +435,15 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array
...
@@ -433,15 +435,15 @@ getRawDescriptor(pipe: USBDevicePipe): Uint8Array
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
ret
=
usb
.
getRawDescriptor
(
devicepipe
);
let
ret
:
number
=
usb
.
getRawDescriptor
(
devicepipe
);
```
```
## usb.getFileDescriptor
## usb.getFileDescriptor
...
@@ -468,15 +470,15 @@ getFileDescriptor(pipe: USBDevicePipe): number
...
@@ -468,15 +470,15 @@ getFileDescriptor(pipe: USBDevicePipe): number
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
ret
=
usb
.
getFileDescriptor
(
devicepipe
);
let
ret
:
number
=
usb
.
getFileDescriptor
(
devicepipe
);
```
```
## usb.controlTransfer
## usb.controlTransfer
...
@@ -505,8 +507,8 @@ controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?:
...
@@ -505,8 +507,8 @@ controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout ?:
**示例:**
**示例:**
```
j
s
```
t
s
let
param
=
{
let
param
:
number
=
{
request
:
0
,
request
:
0
,
reqType
:
0
,
reqType
:
0
,
target
:
0
,
target
:
0
,
...
@@ -515,14 +517,14 @@ let param = {
...
@@ -515,14 +517,14 @@ let param = {
data
:
null
data
:
null
};
};
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
usb
.
controlTransfer
(
devicepipe
,
param
).
then
((
ret
)
=>
{
usb
.
controlTransfer
(
devicepipe
,
param
).
then
((
ret
:
number
)
=>
{
console
.
log
(
`controlTransfer =
${
ret
}
`
);
console
.
log
(
`controlTransfer =
${
ret
}
`
);
})
})
```
```
...
@@ -554,24 +556,24 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
...
@@ -554,24 +556,24 @@ bulkTransfer(pipe: USBDevicePipe, endpoint: USBEndpoint, buffer: Uint8Array, tim
**示例:**
**示例:**
```
j
s
```
t
s
//usb.getDevices 接口返回数据集合,取其中一个设备对象,并获取权限 。
//usb.getDevices 接口返回数据集合,取其中一个设备对象,并获取权限 。
//把获取到的设备对象作为参数传入usb.connectDevice;当usb.connectDevice接口成功返回之后;
//把获取到的设备对象作为参数传入usb.connectDevice;当usb.connectDevice接口成功返回之后;
//才可以调用第三个接口usb.claimInterface.当usb.claimInterface 调用成功以后,再调用该接口。
//才可以调用第三个接口usb.claimInterface.当usb.claimInterface 调用成功以后,再调用该接口。
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
let
device
=
devicesList
[
0
];
let
device
:
USBDevice
=
devicesList
[
0
];
usb
.
requestRight
(
device
.
name
);
usb
.
requestRight
(
device
.
name
);
let
devicepipe
=
usb
.
connectDevice
(
device
);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
device
);
let
interfaces
=
device
.
configs
[
0
].
interfaces
[
0
];
let
interfaces
:
USBInterface
=
device
.
configs
[
0
].
interfaces
[
0
];
let
endpoint
=
device
.
configs
[
0
].
interfaces
[
0
].
endpoints
[
0
];
let
endpoint
:
USBEndpoint
=
device
.
configs
[
0
].
interfaces
[
0
].
endpoints
[
0
];
let
ret
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
let
ret
:
number
=
usb
.
claimInterface
(
devicepipe
,
interfaces
);
let
buffer
=
new
Uint8Array
(
128
);
let
buffer
=
new
Uint8Array
(
128
);
usb
.
bulkTransfer
(
devicepipe
,
endpoint
,
buffer
).
then
((
ret
)
=>
{
usb
.
bulkTransfer
(
devicepipe
,
endpoint
,
buffer
).
then
((
ret
:
number
)
=>
{
console
.
log
(
`bulkTransfer =
${
ret
}
`
);
console
.
log
(
`bulkTransfer =
${
ret
}
`
);
});
});
```
```
...
@@ -600,15 +602,15 @@ closePipe(pipe: USBDevicePipe): number
...
@@ -600,15 +602,15 @@ closePipe(pipe: USBDevicePipe): number
**示例:**
**示例:**
```
j
s
```
t
s
let
devicesList
=
usb
.
getDevices
();
let
devicesList
:
Array
<
USBDevice
>
=
usb
.
getDevices
();
if
(
devicesList
.
length
==
0
)
{
if
(
devicesList
.
length
==
0
)
{
console
.
log
(
`device list is empty`
);
console
.
log
(
`device list is empty`
);
}
}
usb
.
requestRight
(
devicesList
[
0
].
name
);
usb
.
requestRight
(
devicesList
[
0
].
name
);
let
devicepipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
devicepipe
:
USBDevicePipe
=
usb
.
connectDevice
(
devicesList
[
0
]);
let
ret
=
usb
.
closePipe
(
devicepipe
);
let
ret
:
number
=
usb
.
closePipe
(
devicepipe
);
console
.
log
(
`closePipe =
${
ret
}
`
);
console
.
log
(
`closePipe =
${
ret
}
`
);
```
```
...
@@ -636,9 +638,9 @@ usbFunctionsFromString(funcs: string): number
...
@@ -636,9 +638,9 @@ usbFunctionsFromString(funcs: string): number
**示例:**
**示例:**
```
j
s
```
t
s
let
funcs
=
"
acm
"
;
let
funcs
:
string
=
"
acm
"
;
let
ret
=
usb
.
usbFunctionsFromString
(
funcs
);
let
ret
:
number
=
usb
.
usbFunctionsFromString
(
funcs
);
```
```
## usb.usbFunctionsToString
## usb.usbFunctionsToString
...
@@ -665,9 +667,9 @@ usbFunctionsToString(funcs: FunctionType): string
...
@@ -665,9 +667,9 @@ usbFunctionsToString(funcs: FunctionType): string
**示例:**
**示例:**
```
j
s
```
t
s
let
funcs
=
usb
.
FunctionType
.
ACM
|
usb
.
FunctionType
.
ECM
;
let
funcs
:
string
=
usb
.
FunctionType
.
ACM
|
usb
.
FunctionType
.
ECM
;
let
ret
=
usb
.
usbFunctionsToString
(
funcs
);
let
ret
:
number
=
usb
.
usbFunctionsToString
(
funcs
);
```
```
## usb.setCurrentFunctions
## usb.setCurrentFunctions
...
@@ -702,11 +704,12 @@ setCurrentFunctions(funcs: FunctionType): Promise\<void\>
...
@@ -702,11 +704,12 @@ setCurrentFunctions(funcs: FunctionType): Promise\<void\>
**示例:**
**示例:**
```
js
```
ts
let
funcs
=
usb
.
FunctionType
.
HDC
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
funcs
:
string
=
usb
.
FunctionType
.
HDC
;
usb
.
setCurrentFunctions
(
funcs
).
then
(()
=>
{
usb
.
setCurrentFunctions
(
funcs
).
then
(()
=>
{
console
.
info
(
'
usb setCurrentFunctions successfully.
'
);
console
.
info
(
'
usb setCurrentFunctions successfully.
'
);
}).
catch
(
err
=>
{
}).
catch
(
err
:
BusinessError
=>
{
console
.
error
(
'
usb setCurrentFunctions failed:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
console
.
error
(
'
usb setCurrentFunctions failed:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
});
});
```
```
...
@@ -729,8 +732,8 @@ getCurrentFunctions(): FunctionType
...
@@ -729,8 +732,8 @@ getCurrentFunctions(): FunctionType
**示例:**
**示例:**
```
j
s
```
t
s
let
ret
=
usb
.
getCurrentFunctions
();
let
ret
:
number
=
usb
.
getCurrentFunctions
();
```
```
## usb.getPorts
## usb.getPorts
...
@@ -751,8 +754,8 @@ getPorts(): Array\<USBPort\>
...
@@ -751,8 +754,8 @@ getPorts(): Array\<USBPort\>
**示例:**
**示例:**
```
j
s
```
t
s
let
ret
=
usb
.
getPorts
();
let
ret
:
number
=
usb
.
getPorts
();
```
```
## usb.getSupportedModes
## usb.getSupportedModes
...
@@ -779,8 +782,8 @@ getSupportedModes(portId: number): PortModeType
...
@@ -779,8 +782,8 @@ getSupportedModes(portId: number): PortModeType
**示例:**
**示例:**
```
j
s
```
t
s
let
ret
=
usb
.
getSupportedModes
(
0
);
let
ret
:
number
=
usb
.
getSupportedModes
(
0
);
```
```
## usb.setPortRoles
## usb.setPortRoles
...
@@ -809,11 +812,12 @@ setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType):
...
@@ -809,11 +812,12 @@ setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType):
**示例:**
**示例:**
```
js
```
ts
let
portId
=
1
;
import
{
BusinessError
}
from
'
@ohos.base
'
;
let
portId
:
number
=
1
;
usb
.
setPortRoles
(
portId
,
usb
.
PowerRoleType
.
SOURCE
,
usb
.
DataRoleType
.
HOST
).
then
(()
=>
{
usb
.
setPortRoles
(
portId
,
usb
.
PowerRoleType
.
SOURCE
,
usb
.
DataRoleType
.
HOST
).
then
(()
=>
{
console
.
info
(
'
usb setPortRoles successfully.
'
);
console
.
info
(
'
usb setPortRoles successfully.
'
);
}).
catch
(
er
r
=>
{
}).
catch
(
:
BusinessErro
r
=>
{
console
.
error
(
'
usb setPortRoles failed:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
console
.
error
(
'
usb setPortRoles failed:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
});
});
```
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录