diff --git a/zh-cn/application-dev/reference/apis/js-apis-usb.md b/zh-cn/application-dev/reference/apis/js-apis-usb.md index d0331a03cdd608b1dd7bd467af0ff552e9e51ab5..827b7fb62a07a5ac57bda59fb2b8ef51e4936693 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-usb.md +++ b/zh-cn/application-dev/reference/apis/js-apis-usb.md @@ -585,7 +585,7 @@ let ret = usb.usbFunctionsToString(funcs); ## usb.setCurrentFunctions -setCurrentFunctions(funcs: FunctionType): Promise\ +setCurrentFunctions(funcs: FunctionType): Promise\ 在设备模式下,设置当前的USB功能列表。 @@ -601,15 +601,19 @@ setCurrentFunctions(funcs: FunctionType): Promise\ **返回值:** -| 类型 | 说明 | -| ------------------ | ------------------------------------------------------------ | -| Promise\ | Promise对象,返回设置成功与否的结果。true表示设置成功,false表示设置失败。 | +| 类型 | 说明 | +| --------------- | ------------- | +| Promise\ | Promise对象。 | **示例:** ```js let funcs = HDC; -let ret = usb.setCurrentFunctions(funcs); +usb.setCurrentFunctions(funcs).then(() => { + console.info('usb setCurrentFunctions successfully.'); +}).catch(err => { + console.error('usb setCurrentFunctions failed: ' + err.code + ' message: ' + err.message); +}); ``` ## usb.getCurrentFunctions @@ -686,7 +690,7 @@ let ret = usb.getSupportedModes(0); ## usb.setPortRoles -setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\ +setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise\ 设置指定的端口支持的角色模式,包含充电角色、数据传输角色。 @@ -704,14 +708,19 @@ setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): **返回值:** -| 类型 | 说明 | -| ------------------ | ------------------------------------------------------------ | -| Promise\ | Promise对象,返回设置成功与否的结果。true表示设置成功,false表示设置失败。 | +| 类型 | 说明 | +| --------------- | ------------- | +| Promise\ | Promise对象。 | **示例:** ```js -let ret = usb.getSupportedModes(0); +let portId = 1; +usb.usb.setPortRoles(portId, usb.PowerRoleType.SOURCE, usb.DataRoleType.HOST).then(() => { + console.info('usb setPortRoles successfully.'); +}).catch(err => { + console.error('usb setPortRoles failed: ' + err.code + ' message: ' + err.message); +}); ``` ## USBEndpoint