• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.bluetooth.opp (蓝牙opp模块)(系统接口)
2
3OPP模块提供了使用蓝牙传输文件的功能,包括发送文件、接收文件和获取文件传输进度等。
4
5> **说明:**
6>
7> 本模块首批接口从API version 16开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8>
9> 当前页面仅包含本模块的系统接口。
10
11## 导入模块
12
13```js
14import { opp } from '@kit.ConnectivityKit';
15```
16
17## createOppServerProfile
18
19createOppServerProfile(): OppServerProfile
20
21创建oppServer profile实例。
22
23**系统接口**:此接口为系统接口。
24
25**系统能力**:SystemCapability.Communication.Bluetooth.Core
26
27**返回值:**
28
29| 类型                            | 说明         |
30| ----------------------------- | ---------- |
31| OppServerProfile | 返回profile实例。 |
32
33**错误码**:
34
35以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)。
36
37| 错误码ID | 错误信息 |
38| -------- | ---------------------------- |
39|202 | Non-system applications are not allowed to use system APIs.          |
40|801 | Capability not supported.          |
41
42**示例:**
43
44```js
45import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
46try {
47    let oppProfile = opp.createOppServerProfile();
48    console.info('oppServer success');
49} catch (err) {
50    console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
51}
52```
53
54## OppServerProfile
55
56Profile类,使用opp方法之前需要创建该类的实例进行操作,通过[createOppServerProfile()](#createoppserverprofile)方法构造此实例。
57
58### sendFile
59
60sendFile(deviceId: string, fileHolds: Array<FileHolder<): Promise<void>
61
62使用蓝牙发送文件。
63
64**系统接口**:此接口为系统接口。
65
66**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
67
68**系统能力**:SystemCapability.Communication.Bluetooth.Core
69
70**参数:**
71
72| 参数名     | 类型                          | 必填   | 说明                       |
73| ------- | --------------------------- | ---- | ------------------------ |
74| deviceId | string | 是    | 接收端的蓝牙MAC地址。 |
75| fileHolds | Array<[FileHolder](#fileholder)>| 是    | 发送的文件数据,依据插入Array的次序进行发送。 |
76
77**错误码**:
78
79以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
80
81| 错误码ID | 错误信息 |
82| -------- | ---------------------------- |
83|201 | Permission denied.                 |
84|202 | Permission denied. Non-system applications are not allowed to use system APIs.                 |
85|203 | This function is prohibited by enterprise management policies.                 |
86|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
87|801 | Capability not supported.          |
88|2900001 | Service stopped.                         |
89|2900003 | Bluetooth disabled.                 |
90|2900004 | Profile is not supported.                 |
91|2900099 | Failed to send file.                        |
92|2903001 | The file type is not supported.                 |
93|2903002 | Current Transfer Information is busy.                 |
94|2903003 | The file is not accessible.                        |
95
96**示例:**
97
98```js
99import { BusinessError } from '@kit.BasicServicesKit';
100import { fileIo } from '@kit.CoreFileKit';
101import { opp } from '@kit.ConnectivityKit';
102// 创建fileHolders
103try {
104    let oppProfile = opp.createOppServerProfile();
105    let fileHolders : Array<opp.FileHolder> = [];
106    // 有效的URIS
107    let uris: Array<string> = ['test1.jpg', 'test2.jpg'];
108    for (let i = 0; i < uris.length; i++) {
109        let filePath = uris[i];
110        console.info('opp deal filePath is :' + filePath);
111        let file = fs.openSync(filePath, fs.OpenMode.READ_ONLY);
112        let stat: fs.Stat = fs.statSync(file.fd);
113        let fileHolder: opp.FileHolder = {
114        filePath:filePath,
115        fileSize:stat.size,
116        fileFd:file.fd
117        };
118        fileHolders.push(fileHolder);
119    }
120    oppProfile.sendFile("11:22:33:44:55:66", fileHolders);
121    // 等待文件传输完后,记得关闭文件描述符  fs.colse(file.fd);
122} catch (err) {
123      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
124}
125```
126
127### setIncomingFileConfirmation
128
129setIncomingFileConfirmation(accept: boolean, fileFd: number): Promise&lt;void&gt;
130
131蓝牙接收文件。
132
133**系统接口**:此接口为系统接口。
134
135**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
136
137**系统能力**:SystemCapability.Communication.Bluetooth.Core
138
139**参数:**
140
141| 参数名     | 类型                          | 必填   | 说明                       |
142| ------- | --------------------------- | ---- | ------------------------ |
143| accept | boolean | 是    | 表示是否接受接收文件。true表示接受,false表示不接受。 |
144| fileFd | number| 是    | 接收的文件描述符,接收过程中需要保持开启。 |
145
146**错误码**:
147
148以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
149
150| 错误码ID | 错误信息 |
151| -------- | ---------------------------- |
152|201 | Permission denied.                 |
153|202 | Permission denied. Non-system applications are not allowed to use system APIs.                 |
154|203 | This function is prohibited by enterprise management policies.                 |
155|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
156|801 | Capability not supported.          |
157|2900001 | Service stopped.                         |
158|2900003 | Bluetooth disabled.                 |
159|2900004 | Profile is not supported.                 |
160|2900099 | Failed to confirm the received file information.                        |
161|2903002 | Current Transfer Information is busy.                 |
162|2903003 | The file is not accessible.                        |
163
164**示例:**
165
166```js
167import { BusinessError } from '@kit.BasicServicesKit';
168import { fileIo } from '@kit.CoreFileKit';
169import { opp } from '@kit.ConnectivityKit';
170// 创建fileHolders
171try {
172    let oppProfile = opp.createOppServerProfile();
173    let pathDir = this.context.filesDir + "/test.jpg";
174    let file = fs.openSync(pathDir, fs.OpenMode.CREATE | fs.OpenMode.READ_WRITE);
175    oppProfile.setIncomingFileConfirmation(true, file.fd);
176    // 接收完成后关闭
177    fs.close(file.fd);
178} catch (err) {
179      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
180}
181```
182
183### on('transferStateChange')
184
185on(type: 'transferStateChange', callback: Callback&lt;OppTransferInformation&gt;): void
186
187订阅蓝牙文件传输的进度和状态变化。
188
189**系统接口**:此接口为系统接口。
190
191**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
192
193**系统能力**:SystemCapability.Communication.Bluetooth.Core
194
195**参数:**
196
197| 参数名      | 类型                                       | 必填   | 说明                                       |
198| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
199| type     | string                                   | 是    | 事件回调类型,支持的事件为'transferStateChange',当on('transferStateChange')调用完成后,可以收到文件传输进度和状态变化事件。 |
200| callback | Callback&lt;[OppTransferInformation](#opptransferinformation)&gt; | 是    | 表示文件传输进度和状态变化事件的回调函数。                  |
201
202**错误码**:
203
204以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
205
206| 错误码ID | 错误信息 |
207| -------- | ---------------------------- |
208|201 | Permission denied.                 |
209|202 | Permission denied. Non-system applications are not allowed to use system APIs.                 |
210|203 | This function is prohibited by enterprise management policies.                 |
211|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
212|801 | Capability not supported.          |
213|2900001 | Service stopped.                         |
214|2900003 | Bluetooth disabled.                 |
215|2900004 | Profile is not supported.                 |
216|2903001 | The file type is not supported.                 |
217|2903002 | Current Transfer Information is busy.                 |
218|2903003 | The file is not accessible.                        |
219
220**示例:**
221
222```js
223import { BusinessError } from '@kit.BasicServicesKit';
224import { fileIo } from '@kit.CoreFileKit';
225import { opp } from '@kit.ConnectivityKit';
226// 创建fileHolders
227try {
228    let oppProfile = opp.createOppServerProfile();
229    oppProfile.on("transferStateChange", (data: opp.OppTransferInformation) => {
230        if (data.status == opp.TransferStatus.PENDING) {
231          console.info("[opp_js] waiting to transfer : " + data.remoteDeviceName);
232        } else if (data.status == opp.TransferStatus.RUNNING){
233          console.info("[opp_js] running data.currentBytes " + data.currentBytes + " data.totalBytes" + data.totalBytes);
234        } else if (data.status == opp.TransferStatus.FINISH){
235          console.info("[opp_js] transfer finished, result is " + data.result);
236        }
237      });
238} catch (err) {
239      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
240}
241```
242
243### off('transferStateChange')
244
245off(type: 'transferStateChange', callback?: Callback&lt;OppTransferInformation&gt;): void
246
247取消订阅蓝牙文件传输的进度和状态变化事件。
248
249**系统接口**:此接口为系统接口。
250
251**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
252
253**系统能力**:SystemCapability.Communication.Bluetooth.Core
254
255**参数:**
256
257| 参数名      | 类型                                       | 必填   | 说明                                       |
258| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
259| type     | string                                   | 是    | 事件回调类型,支持的事件为'transferStateChange',调用off('transferStateChange')后,停止接收文件传输进度和状态变化事件。 |
260
261**错误码**:
262
263以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
264
265| 错误码ID | 错误信息 |
266| -------- | ---------------------------- |
267|201 | Permission denied.                 |
268|202 | Permission denied. Non-system applications are not allowed to use system APIs.          |
269|203 | This function is prohibited by enterprise management policies.          |
270|801 | Capability not supported.          |
271|2900001 | Service stopped.                         |
272|2900003 | Bluetooth disabled.                 |
273|2900004 | Profile is not supported.                 |
274|2903001 | The file type is not supported.                 |
275|2903002 | Current Transfer Information is busy.                 |
276|2903003 | The file is not accessible.                        |
277
278**示例:**
279
280```js
281import { BusinessError } from '@kit.BasicServicesKit';
282import { fileIo } from '@kit.CoreFileKit';
283import { opp } from '@kit.ConnectivityKit';
284// 创建fileHolders
285try {
286    let oppProfile = opp.createOppServerProfile();
287    oppProfile.off("transferStateChange");
288} catch (err) {
289      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
290}
291```
292
293### on('receiveIncomingFile')
294
295on(type: 'receiveIncomingFile', callback: Callback&lt;OppTransferInformation&gt;): void
296
297订阅蓝牙文件传输事件以接收文件。
298
299**系统接口**:此接口为系统接口。
300
301**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
302
303**系统能力**:SystemCapability.Communication.Bluetooth.Core
304
305**参数:**
306
307| 参数名      | 类型                                       | 必填   | 说明                                       |
308| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
309| type     | string                                   | 是    | 事件回调类型,支持的事件为'receiveIncomingFile',当on('receiveIncomingFile')调用完成后,表示可以收到是否有文件传输通知的事件。 |
310| callback | Callback&lt;[OppTransferInformation](#opptransferinformation)&gt; | 是    | 表示文件传输进度和状态变化事件的回调函数。                  |
311
312**错误码**:
313
314以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
315
316| 错误码ID | 错误信息 |
317| -------- | ---------------------------- |
318|201 | Permission denied.                 |
319|202 | Permission denied. Non-system applications are not allowed to use system APIs.          |
320|203 | This function is prohibited by enterprise management policies.          |
321|801 | Capability not supported.          |
322|2900001 | Service stopped.                         |
323|2900003 | Bluetooth disabled.                 |
324|2900004 | Profile is not supported.                 |
325|2903001 | The file type is not supported.                 |
326|2903002 | Current Transfer Information is busy.                 |
327|2903003 | The file is not accessible.                        |
328
329**示例:**
330
331```js
332import { BusinessError } from '@kit.BasicServicesKit';
333import { fileIo } from '@kit.CoreFileKit';
334import { opp } from '@kit.ConnectivityKit';
335// 创建fileHolders
336try {
337    let oppProfile = opp.createOppServerProfile();
338    oppProfile.on("receiveIncomingFile", (data: opp.OppTransferInformation) => {
339        if (data.status == opp.TransferStatus.PENDING) {
340          console.info("[opp_js] received file waiting to confirm : " + data.remoteDeviceName);
341        } else if (data.status == opp.TransferStatus.RUNNING){
342          console.info("[opp_js] running data.currentBytes " + data.currentBytes + " data.totalBytes" + data.totalBytes);
343        } else if (data.status == opp.TransferStatus.FINISH){
344          console.info("[opp_js] transfer finished, result is " + data.result);
345        }
346      });
347} catch (err) {
348      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
349}
350```
351
352### off('receiveIncomingFile')
353
354off(type: 'receiveIncomingFile', callback?: Callback&lt;OppTransferInformation&gt;): void
355
356取消订阅蓝牙文件传输完成的事件。
357
358**系统接口**:此接口为系统接口。
359
360**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
361
362**系统能力**:SystemCapability.Communication.Bluetooth.Core
363
364**参数:**
365
366| 参数名      | 类型                                       | 必填   | 说明                                       |
367| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
368| type     | string                                   | 是    | 事件回调类型,支持的事件为'receiveIncomingFile',调用off('receiveIncomingFile')后,停止接收文件传输通知的事件。 |
369
370**错误码**:
371
372以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
373
374| 错误码ID | 错误信息 |
375| -------- | ---------------------------- |
376|201 | Permission denied.                 |
377|202 | Permission denied. Non-system applications are not allowed to use system APIs.          |
378|203 | This function is prohibited by enterprise management policies.          |
379|801 | Capability not supported.          |
380|2900001 | Service stopped.                         |
381|2900003 | Bluetooth disabled.                 |
382|2900004 | Profile is not supported.                 |
383|2903001 | The file type is not supported.                 |
384|2903002 | Current Transfer Information is busy.                 |
385|2903003 | The file is not accessible.                        |
386
387**示例:**
388
389```js
390import { BusinessError } from '@kit.BasicServicesKit';
391import { fileIo } from '@kit.CoreFileKit';
392import { opp } from '@kit.ConnectivityKit';
393// 创建fileHolders
394try {
395    let oppProfile = opp.createOppServerProfile();
396    oppProfile.off("receiveIncomingFile");
397} catch (err) {
398      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
399}
400```
401
402### cancelTransfer
403
404cancelTransfer(): Promise&lt;void&gt;
405
406取消文件传输。
407
408**系统接口**:此接口为系统接口。
409
410**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
411
412**系统能力**:SystemCapability.Communication.Bluetooth.Core
413
414**错误码**:
415
416以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
417
418| 错误码ID | 错误信息 |
419| -------- | ---------------------------- |
420|201 | Permission denied.                 |
421|202 | Permission denied. Non-system applications are not allowed to use system APIs.          |
422|203 | This function is prohibited by enterprise management policies.          |
423|801 | Capability not supported.          |
424|2900001 | Service stopped.                         |
425|2900003 | Bluetooth disabled.                 |
426|2900004 | Profile is not supported.                 |
427|2900099 | Failed to cancel the current transfer.                        |
428|2903002 | Current Transfer Information is busy.                 |
429
430**示例:**
431
432```js
433import { BusinessError } from '@kit.BasicServicesKit';
434import { fileIo } from '@kit.CoreFileKit';
435import { opp } from '@kit.ConnectivityKit';
436// 创建fileHolders
437try {
438    let oppProfile = opp.createOppServerProfile();
439    oppProfile.cancelTransfer();
440} catch (err) {
441      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
442}
443```
444
445### getCurrentTransferInformation
446
447getCurrentTransferInformation(): Promise&lt;[OppTransferInformation](#opptransferinformation)&gt;
448
449获取当前传输的文件信息。
450
451**系统接口**:此接口为系统接口。
452
453**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
454
455**系统能力**:SystemCapability.Communication.Bluetooth.Core
456
457**错误码**:
458
459以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
460
461| 错误码ID | 错误信息 |
462| -------- | ---------------------------- |
463|201 | Permission denied.                 |
464|202 | Permission denied. Non-system applications are not allowed to use system APIs.          |
465|203 | This function is prohibited by enterprise management policies.          |
466|801 | Capability not supported.          |
467|2900001 | Service stopped.                         |
468|2900003 | Bluetooth disabled.                 |
469|2900004 | Profile is not supported.                 |
470|2900099 | Failed to obtain the current transmission information.                        |
471|2903004 | Current Transfer Information is empty.                 |
472
473**示例:**
474
475```js
476import { BusinessError } from '@kit.BasicServicesKit';
477import { fileIo } from '@kit.CoreFileKit';
478import { opp } from '@kit.ConnectivityKit';
479// 创建fileHolders
480try {
481    let oppProfile = opp.createOppServerProfile();
482    let data = oppProfile.getCurrentTransferInformation();
483    console.info('[opp_js] data ', data.status);
484} catch (err) {
485      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
486}
487```
488
489### setLastReceivedFileUri
490
491setLastReceivedFileUri(uri: string): Promise&lt;void&gt;
492
493设置最后一个接收文件的URI。
494
495**系统接口**:此接口为系统接口。
496
497**需要权限**:ohos.permission.ACCESS_BLUETOOTHohos.permission.MANAGE_BLUETOOTH
498
499**系统能力**:SystemCapability.Communication.Bluetooth.Core
500
501**参数:**
502
503| 参数名     | 类型                          | 必填   | 说明                       |
504| ------- | --------------------------- | ---- | ------------------------ |
505| uri | string | 是    | 最后一个接收文件的URI。 |
506
507**错误码**:
508
509以下错误码的详细介绍请参见[通用错误码说明文档](../errorcode-universal.md)和[蓝牙服务子系统错误码](errorcode-bluetoothManager.md)。
510
511| 错误码ID | 错误信息 |
512| -------- | ---------------------------- |
513|201 | Permission denied.                 |
514|202 | Permission denied. Non-system applications are not allowed to use system APIs.          |
515|203 | This function is prohibited by enterprise management policies.          |
516|401 | Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. 3. Parameter verification failed.                 |
517|801 | Capability not supported.          |
518|2900001 | Service stopped.                         |
519|2900003 | Bluetooth disabled.                 |
520|2900004 | Profile is not supported.                 |
521|2900099 | Failed to set the URI of the last file.                        |
522
523**示例:**
524
525```js
526import { BusinessError } from '@kit.BasicServicesKit';
527import { fileIo } from '@kit.CoreFileKit';
528import { opp } from '@kit.ConnectivityKit';
529// 创建fileHolders
530try {
531    let oppProfile = opp.createOppServerProfile();
532    oppProfile.setLastReceivedFileUri("file://media/Photo/1/IMG_1739266559_000/screenshot_20250211_173419.jpg ");
533} catch (err) {
534      console.error('errCode: ' + (err as BusinessError).code + ', errMessage: ' + (err as BusinessError).message);
535}
536```
537
538## FileHolder
539
540描述发送的文件信息。
541
542**系统接口**:此接口为系统接口。
543
544**系统能力**:SystemCapability.Communication.Bluetooth.Core
545
546| 名称              | 类型                                     | 可读   | 可写   | 说明                                       |
547| --------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
548| filePath     | string                                   | 是    | 是    | 待传输文件的URI,例如:file://media/Photo/1/IMG_1739266559_000/test.jpg 。 |
549| fileSize       | number                                  | 是    | 是    | 待传输文件的大小,以字节为单位。          |
550| fileFd | number | 是    | 是    | 待传输文件的已打开的文件描述符(传输过程中需要保持打开直到传输完成)。                                    |
551
552## OppTransferInformation
553
554描述文件的传输信息。
555
556**系统接口**:此接口为系统接口。
557
558**系统能力**:SystemCapability.Communication.Bluetooth.Core
559
560| 名称              | 类型                                     | 可读   | 可写   | 说明                                       |
561| --------------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
562| filePath     | string                                   | 是    | 是    | 待传输文件的URI,例如:file://media/Photo/1/IMG_1739266559_000/test.jpg 。 |
563| remoteDeviceName       | string                                  | 是    | 是    | 传输对端设备名。                |
564| remoteDeviceId | number | 是    | 是    | 传输对端MAC地址。                |
565| direction | [DirectionType](#directiontype) | 是    | 是    | 传输方向。                |
566| status | [TransferStatus](#transferstatus) | 是    | 是    | 传输状态。                |
567| result | [TransferResult](#transferresult) | 是    | 是    | 传输结果。                |
568| currentBytes | number | 是    | 是    | 当前传输的字节数。                |
569| totalBytes | number | 是    | 是    | 需要传输的总字节数。                |
570| currentCount | number | 是    | 是    | 本次传输当前文件序列。                |
571| totalCount | number | 是    | 是    | 本次传输总传输的文件个数。                |
572
573## DirectionType
574
575枚举,文件传输方向。
576
577**系统接口**:此接口为系统接口。
578
579**系统能力**:SystemCapability.Communication.Bluetooth.Core
580
581| 名称                    | 值  | 说明           |
582| --------------------- | ---- | ------------ |
583| OUTBOUND   | 0    | 表示本文件是发送方向。 |
584| INBOUND    | 1    | 表示本文件是接收方向。      |
585
586## TransferStatus
587
588枚举,文件传输状态。
589
590**系统接口**:此接口为系统接口。
591
592**系统能力**:SystemCapability.Communication.Bluetooth.Core
593
594| 名称                    | 值  | 说明           |
595| --------------------- | ---- | ------------ |
596| PENDING   | 0    | 表示等待传输。 |
597| RUNNING    | 1    | 表示正在传输。      |
598| FINISH | 2    | 表示传输完成。     |
599
600## TransferResult
601
602枚举,文件传输结果。
603
604**系统接口**:此接口为系统接口。
605
606**系统能力**:SystemCapability.Communication.Bluetooth.Core
607
608| 名称                    | 值  | 说明           |
609| --------------------- | ---- | ------------ |
610| SUCCESS   | 0    | 表示传输成功。 |
611| ERROR_UNSUPPORTED_TYPE    | 1    | 表示传输文件类型不支持。      |
612| ERROR_BAD_REQUEST | 2    | 表示对端设备不能处理该请求。     |
613| ERROR_NOT_ACCEPTABLE   | 3    | 表示对端设备拒绝接收该文件。 |
614| ERROR_CANCELED    | 4    | 表示对端设备取消正在传输的该文件。      |
615| ERROR_CONNECTION_FAILED | 5    | 表示对端设备失去连接。     |
616| ERROR_TRANSFER   | 6    | 表示传输过程中发生错误。 |
617| ERROR_UNKNOWN    | 7    | 表示发生未知错误。      |
618