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