未验证 提交 bfcc1975 编写于 作者: O openharmony_ci 提交者: Gitee

!21387 Fix example code for deviceManager

Merge pull request !21387 from dongbinbin/bran0629
......@@ -82,7 +82,8 @@ bindDevice(deviceId: number, onDisconnect: AsyncCallback<number>,
```js
try {
deviceManager.bindDevice(device.deviceId, (error, data) => {
// 12345678为示例deviceId,应用开发时可通过queryDevices查询到相应设备的deviceId作为入参
deviceManager.bindDevice(12345678, (error, data) => {
console.error('Device is disconnected');
}, (error, data) => {
if (error) {
......@@ -131,7 +132,8 @@ bindDevice(deviceId: number, onDisconnect: AsyncCallback<number>): Promise
```js
try {
deviceManager.bindDevice(matchDevice.deviceId, (error, data) => {
// 12345678为示例deviceId,应用开发时可通过queryDevices查询到相应设备的deviceId作为入参
deviceManager.bindDevice(12345678, (error, data) => {
console.error('Device is disconnected');
}).then(data => {
console.info('bindDevice success');
......@@ -169,7 +171,8 @@ unbindDevice(deviceId: number, callback: AsyncCallback<number>): void
```js
try {
deviceManager.unbindDevice(matchDevice.deviceId, (error, data) => {
// 12345678为示例deviceId,应用开发时可通过queryDevices查询到相应设备的deviceId作为入参
deviceManager.unbindDevice(12345678, (error, data) => {
if (error) {
console.error('unbindDevice async fail. Code is ${error.code}, message is ${error.message}');
return;
......@@ -211,7 +214,8 @@ unbindDevice(deviceId: number): Promise<number>
```js
try {
deviceManager.unbindDevice(matchDevice.deviceId).then(data => {
// 12345678为示例deviceId,应用开发时可通过queryDevices查询到相应设备的deviceId作为入参
deviceManager.unbindDevice(12345678).then(data => {
console.info('unbindDevice success');
}, error => {
console.error('unbindDevice async fail. Code is ${error.code}, message is ${error.message}');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册