1/* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit BasicServicesKit 19 */ 20 21/** 22 * @namespace usb 23 * @syscap SystemCapability.USB.USBManager 24 * @since 8 25 * @deprecated since 9 26 * @useinstead ohos.usbManager 27 */ 28declare namespace usb { 29 /** 30 * Obtains the USB device list. 31 * 32 * @returns { Array<Readonly<USBDevice>> } USB device list. 33 * @syscap SystemCapability.USB.USBManager 34 * @since 8 35 * @deprecated since 9 36 */ 37 function getDevices(): Array<Readonly<USBDevice>>; 38 39 /** 40 * Connects to the USB device based on the device information returned by getDevices(). 41 * 42 * @param { USBDevice } device - USB device on the device list returned by getDevices(). 43 * @returns { Readonly<USBDevicePipe> } object for data transfer. 44 * @syscap SystemCapability.USB.USBManager 45 * @since 8 46 * @deprecated since 9 47 */ 48 function connectDevice(device: USBDevice): Readonly<USBDevicePipe>; 49 50 /** 51 * Checks whether the application has the permission to access the device. 52 * 53 * @param { string } deviceName - device name defined by USBDevice.name. 54 * @returns { boolean } indicates if the user has the permission to access the device. 55 * @syscap SystemCapability.USB.USBManager 56 * @since 8 57 * @deprecated since 9 58 */ 59 function hasRight(deviceName: string): boolean; 60 61 /** 62 * Requests the temporary permission for a given application to access the USB device. 63 * 64 * @param { string } deviceName - device name defined by USBDevice.name. 65 * @returns { Promise<boolean> } indicates if the device access permissions are granted. 66 * @syscap SystemCapability.USB.USBManager 67 * @since 8 68 * @deprecated since 9 69 */ 70 function requestRight(deviceName: string): Promise<boolean>; 71 72 /** 73 * Converts the string descriptor of a given USB function list to a numeric mask combination. 74 * 75 * @param { string } funcs - descriptor of the supported function list. 76 * @returns { number } the numeric mask combination of the function list. 77 * @syscap SystemCapability.USB.USBManager 78 * @systemapi 79 * @since 9 80 * @deprecated since 9 81 */ 82 function usbFunctionsFromString(funcs: string): number; 83 84 /** 85 * Converts the numeric mask combination of a given USB function list to a string descriptor. 86 * 87 * @param { FunctionType } funcs - numeric mask combination of the function list. 88 * @returns { string } - descriptor of the supported function list. 89 * @syscap SystemCapability.USB.USBManager 90 * @systemapi 91 * @since 9 92 * @deprecated since 9 93 */ 94 function usbFunctionsToString(funcs: FunctionType): string; 95 96 /** 97 * Sets the current USB function list in Device mode. 98 * 99 * @param { FunctionType } funcs - numeric mask combination of the supported function list. 100 * @returns { Promise<boolean> } returns **true** if the setting is successful; returns **false** otherwise. 101 * @syscap SystemCapability.USB.USBManager 102 * @systemapi 103 * @since 9 104 * @deprecated since 9 105 */ 106 function setCurrentFunctions(funcs: FunctionType): Promise<boolean>; 107 108 /** 109 * Obtains the numeric mask combination for the current USB function list in Device mode. 110 * 111 * @returns { FunctionType } the numeric mask combination for the current USB function list in FunctionType. 112 * @syscap SystemCapability.USB.USBManager 113 * @systemapi 114 * @since 9 115 * @deprecated since 9 116 */ 117 function getCurrentFunctions(): FunctionType; 118 119 /** 120 * Obtains the USBPort list. 121 * 122 * @returns { Array<USBPort> } the USBPort list. 123 * @syscap SystemCapability.USB.USBManager 124 * @systemapi 125 * @since 9 126 * @deprecated since 9 127 */ 128 function getPorts(): Array<USBPort>; 129 130 /** 131 * Gets the mask combination for the supported mode list of the specified USBPort. 132 * 133 * @param { number } portId 134 * @returns { PortModeType } the mask combination for the supported mode list in PortModeType. 135 * @syscap SystemCapability.USB.USBManager 136 * @systemapi 137 * @since 9 138 * @deprecated since 9 139 */ 140 function getSupportedModes(portId: number): PortModeType; 141 142 /** 143 * Sets the role types supported by the specified USBPort, which can be powerRole (for charging) and dataRole (for data transfer). 144 * 145 * @param { number } portId - unique ID of the port. 146 * @param { PowerRoleType } powerRole - charging role. 147 * @param { DataRoleType } dataRole - data role. 148 * @returns { Promise<boolean> } returns **true** if the setting is successful; returns **false** otherwise. 149 * @syscap SystemCapability.USB.USBManager 150 * @systemapi 151 * @since 9 152 * @deprecated since 9 153 */ 154 function setPortRoles(portId: number, powerRole: PowerRoleType, dataRole: DataRoleType): Promise<boolean>; 155 156 /* usb pipe functions begin */ 157 /** 158 * Claims a USB interface. 159 * 160 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the bus number and device address. 161 * @param { USBInterface } iface - USB interface , which is used to determine the interface to claim. 162 * @param { boolean } [force] - optional parameter that determines whether to forcibly claim the USB interface. 163 * @returns { number } returns **0** if the USB interface is successfully claimed; returns an error code otherwise. 164 * @syscap SystemCapability.USB.USBManager 165 * @since 8 166 * @deprecated since 9 167 */ 168 function claimInterface(pipe: USBDevicePipe, iface: USBInterface, force?: boolean): number; 169 170 /** 171 * Releases a USB interface. 172 * 173 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the bus number and device address. 174 * @param { USBInterface } iface - USB interface , which is used to determine the interface to release. 175 * @returns { number } returns **0** if the USB interface is successfully released; returns an error code otherwise. 176 * @syscap SystemCapability.USB.USBManager 177 * @since 8 178 * @deprecated since 9 179 */ 180 function releaseInterface(pipe: USBDevicePipe, iface: USBInterface): number; 181 182 /** 183 * Sets the device configuration. 184 * 185 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the bus number and device address. 186 * @param { USBConfig } config - device configuration. 187 * @returns { number } returns **0** if the device configuration is successfully set; returns an error code otherwise. 188 * @syscap SystemCapability.USB.USBManager 189 * @since 8 190 * @deprecated since 9 191 */ 192 function setConfiguration(pipe: USBDevicePipe, config: USBConfig): number; 193 194 /** 195 * Sets a USB interface. 196 * 197 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the bus number and device address. 198 * @param { USBInterface } iface - USB interface , which is used to determine the interface to set. 199 * @returns { number } returns **0** if the USB interface is successfully set; return an error code otherwise. 200 * @syscap SystemCapability.USB.USBManager 201 * @since 8 202 * @deprecated since 9 203 */ 204 function setInterface(pipe: USBDevicePipe, iface: USBInterface): number; 205 206 /** 207 * Obtains the raw USB descriptor. 208 * 209 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the bus number and device address. 210 * @returns { Uint8Array } returns the raw descriptor data. 211 * @syscap SystemCapability.USB.USBManager 212 * @since 8 213 * @deprecated since 9 214 */ 215 function getRawDescriptor(pipe: USBDevicePipe): Uint8Array; 216 217 /** 218 * Obtains the file descriptor. 219 * 220 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the USB device. 221 * @returns { number } returns the file descriptor of the USB device. 222 * @syscap SystemCapability.USB.USBManager 223 * @since 8 224 * @deprecated since 9 225 */ 226 function getFileDescriptor(pipe: USBDevicePipe): number; 227 228 /** 229 * Performs control transfer. 230 * 231 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the USB device. 232 * @param { USBControlParams } controlparam - control transfer parameters. 233 * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. 234 * @returns { Promise<number> } returns the size of the transmitted or received data block if the control transfer is successful; 235 * return -1 if an exception occurs. 236 * @syscap SystemCapability.USB.USBManager 237 * @since 8 238 * @deprecated since 9 239 */ 240 function controlTransfer(pipe: USBDevicePipe, controlparam: USBControlParams, timeout?: number): Promise<number>; 241 242 /** 243 * Performs bulk transfer. 244 * 245 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the USB device. 246 * @param { USBEndpoint } endpoint - USB endpoint, which is used to determine the USB port for data transfer. 247 * @param { Uint8Array } buffer - buffer for writing or reading data. 248 * @param { number } [timeout] - timeout duration. This parameter is optional. The default value is **0**, indicating no timeout. 249 * @returns { Promise<number> } the size of the transmitted or received data block if the control transfer is successful; 250 * return -1 if an exception occurs. 251 * @syscap SystemCapability.USB.USBManager 252 * @since 8 253 * @deprecated since 9 254 */ 255 function bulkTransfer( 256 pipe: USBDevicePipe, 257 endpoint: USBEndpoint, 258 buffer: Uint8Array, 259 timeout?: number 260 ): Promise<number>; 261 262 /** 263 * Closes a USB device pipe. 264 * 265 * @param { USBDevicePipe } pipe - device pipe , which is used to determine the USB device. 266 * @returns { number } returns **0** if the USB device pipe is closed successfully; return an error code otherwise. 267 * @syscap SystemCapability.USB.USBManager 268 * @since 8 269 * @deprecated since 9 270 */ 271 function closePipe(pipe: USBDevicePipe): number; 272 273 /** 274 * Represents the USB endpoint from which data is sent or received. You can obtain the USB endpoint through USBInterface. 275 * 276 * @typedef USBEndpoint 277 * @syscap SystemCapability.USB.USBManager 278 * @since 8 279 * @deprecated since 9 280 */ 281 interface USBEndpoint { 282 /** 283 * Endpoint address 284 * 285 * @type { number } 286 * @syscap SystemCapability.USB.USBManager 287 * @since 8 288 * @deprecated since 9 289 */ 290 address: number; 291 292 /** 293 * Endpoint attributes 294 * 295 * @type { number } 296 * @syscap SystemCapability.USB.USBManager 297 * @since 8 298 * @deprecated since 9 299 */ 300 attributes: number; 301 302 /** 303 * Endpoint interval 304 * 305 * @type { number } 306 * @syscap SystemCapability.USB.USBManager 307 * @since 8 308 * @deprecated since 9 309 */ 310 interval: number; 311 312 /** 313 * Maximum size of data packets on the endpoint 314 * 315 * @type { number } 316 * @syscap SystemCapability.USB.USBManager 317 * @since 8 318 * @deprecated since 9 319 */ 320 maxPacketSize: number; 321 322 /** 323 * Endpoint direction 324 * 325 * @type { USBRequestDirection } 326 * @syscap SystemCapability.USB.USBManager 327 * @since 8 328 * @deprecated since 9 329 */ 330 direction: USBRequestDirection; 331 332 /** 333 * Endpoint number 334 * 335 * @type { number } 336 * @syscap SystemCapability.USB.USBManager 337 * @since 8 338 * @deprecated since 9 339 */ 340 number: number; 341 342 /** 343 * Endpoint type 344 * 345 * @type { number } 346 * @syscap SystemCapability.USB.USBManager 347 * @since 8 348 * @deprecated since 9 349 */ 350 type: number; 351 352 /** 353 * Unique ID defined by {@link USBInterface.id}, which indicates the interface to which the endpoint belongs 354 * 355 * @type { number } 356 * @syscap SystemCapability.USB.USBManager 357 * @since 8 358 * @deprecated since 9 359 */ 360 interfaceId: number; 361 } 362 363 /** 364 * Represents a USB interface. One config can contain multiple **USBInterface** instances, each providing a specific function. 365 * 366 * @typedef USBInterface 367 * @syscap SystemCapability.USB.USBManager 368 * @since 8 369 * @deprecated since 9 370 */ 371 interface USBInterface { 372 /** 373 * Unique ID of the USB interface 374 * 375 * @type { number } 376 * @syscap SystemCapability.USB.USBManager 377 * @since 8 378 * @deprecated since 9 379 */ 380 id: number; 381 382 /** 383 * Interface protocol 384 * 385 * @type { number } 386 * @syscap SystemCapability.USB.USBManager 387 * @since 8 388 * @deprecated since 9 389 */ 390 protocol: number; 391 392 /** 393 * Device type 394 * 395 * @type { number } 396 * @syscap SystemCapability.USB.USBManager 397 * @since 8 398 * @deprecated since 9 399 */ 400 clazz: number; 401 402 /** 403 * Device subclass 404 * 405 * @type { number } 406 * @syscap SystemCapability.USB.USBManager 407 * @since 8 408 * @deprecated since 9 409 */ 410 subClass: number; 411 412 /** 413 * Alternation between descriptors of the same USB interface 414 * 415 * @type { number } 416 * @syscap SystemCapability.USB.USBManager 417 * @since 8 418 * @deprecated since 9 419 */ 420 alternateSetting: number; 421 422 /** 423 * Interface name 424 * 425 * @type { string } 426 * @syscap SystemCapability.USB.USBManager 427 * @since 8 428 * @deprecated since 9 429 */ 430 name: string; 431 432 /** 433 * USBEndpoint that belongs to the USB interface 434 * 435 * @type { Array<USBEndpoint> } 436 * @syscap SystemCapability.USB.USBManager 437 * @since 8 438 * @deprecated since 9 439 */ 440 endpoints: Array<USBEndpoint>; 441 } 442 443 /** 444 * USB configuration. One USBDevice can contain multiple USBConfig instances. 445 * 446 * @typedef USBConfig 447 * @syscap SystemCapability.USB.USBManager 448 * @since 8 449 * @deprecated since 9 450 */ 451 interface USBConfig { 452 /** 453 * Unique ID of the USB configuration 454 * 455 * @type { number } 456 * @syscap SystemCapability.USB.USBManager 457 * @since 8 458 * @deprecated since 9 459 */ 460 id: number; 461 462 /** 463 * Configuration attributes 464 * 465 * @type { number } 466 * @syscap SystemCapability.USB.USBManager 467 * @since 8 468 * @deprecated since 9 469 */ 470 attributes: number; 471 472 /** 473 * Maximum power consumption, in mA 474 * 475 * @type { number } 476 * @syscap SystemCapability.USB.USBManager 477 * @since 8 478 * @deprecated since 9 479 */ 480 maxPower: number; 481 482 /** 483 * Configuration name, which can be left empty 484 * 485 * @type { string } 486 * @syscap SystemCapability.USB.USBManager 487 * @since 8 488 * @deprecated since 9 489 */ 490 name: string; 491 492 /** 493 * Support for remote wakeup 494 * 495 * @type { boolean } 496 * @syscap SystemCapability.USB.USBManager 497 * @since 8 498 * @deprecated since 9 499 */ 500 isRemoteWakeup: boolean; 501 502 /** 503 * Support for independent power supplies 504 * 505 * @type { boolean } 506 * @syscap SystemCapability.USB.USBManager 507 * @since 8 508 * @deprecated since 9 509 */ 510 isSelfPowered: boolean; 511 512 /** 513 * Supported interface 514 * 515 * @type { Array<USBInterface> } 516 * @syscap SystemCapability.USB.USBManager 517 * @since 8 518 * @deprecated since 9 519 */ 520 interfaces: Array<USBInterface>; 521 } 522 523 /** 524 * Represents a USB device. 525 * 526 * @typedef USBDevice 527 * @syscap SystemCapability.USB.USBManager 528 * @since 8 529 * @deprecated since 9 530 */ 531 interface USBDevice { 532 /** 533 * Bus address 534 * 535 * @type { number } 536 * @syscap SystemCapability.USB.USBManager 537 * @since 8 538 * @deprecated since 9 539 */ 540 busNum: number; 541 542 /** 543 * Device address 544 * 545 * @type { number } 546 * @syscap SystemCapability.USB.USBManager 547 * @since 8 548 * @deprecated since 9 549 */ 550 devAddress: number; 551 552 /** 553 * Device SN 554 * 555 * @type { string } 556 * @syscap SystemCapability.USB.USBManager 557 * @since 8 558 * @deprecated since 9 559 */ 560 serial: string; 561 562 /** 563 * Device name 564 * 565 * @type { string } 566 * @syscap SystemCapability.USB.USBManager 567 * @since 8 568 * @deprecated since 9 569 */ 570 name: string; 571 572 /** 573 * Device manufacturer 574 * 575 * @type { string } 576 * @syscap SystemCapability.USB.USBManager 577 * @since 8 578 * @deprecated since 9 579 */ 580 manufacturerName: string; 581 582 /** 583 * Product information 584 * 585 * @type { string } 586 * @syscap SystemCapability.USB.USBManager 587 * @since 8 588 * @deprecated since 9 589 */ 590 productName: string; 591 592 /** 593 * Product version 594 * 595 * @type { string } 596 * @syscap SystemCapability.USB.USBManager 597 * @since 8 598 * @deprecated since 9 599 */ 600 version: string; 601 602 /** 603 * Vendor ID 604 * 605 * @type { number } 606 * @syscap SystemCapability.USB.USBManager 607 * @since 8 608 * @deprecated since 9 609 */ 610 vendorId: number; 611 612 /** 613 * Product ID 614 * 615 * @type { number } 616 * @syscap SystemCapability.USB.USBManager 617 * @since 8 618 * @deprecated since 9 619 */ 620 productId: number; 621 622 /** 623 * Device class 624 * 625 * @type { number } 626 * @syscap SystemCapability.USB.USBManager 627 * @since 8 628 * @deprecated since 9 629 */ 630 clazz: number; 631 632 /** 633 * Device subclass 634 * 635 * @type { number } 636 * @syscap SystemCapability.USB.USBManager 637 * @since 8 638 * @deprecated since 9 639 */ 640 subClass: number; 641 642 /** 643 * Device protocol code 644 * 645 * @type { number } 646 * @syscap SystemCapability.USB.USBManager 647 * @since 8 648 * @deprecated since 9 649 */ 650 protocol: number; 651 652 /** 653 * Device configuration descriptor information 654 * 655 * @type { Array<USBConfig> } 656 * @syscap SystemCapability.USB.USBManager 657 * @since 8 658 * @deprecated since 9 659 */ 660 configs: Array<USBConfig>; 661 } 662 663 /** 664 * Represents a USB device pipe, which is used to determine the USB device. 665 * 666 * @typedef USBDevicePipe 667 * @syscap SystemCapability.USB.USBManager 668 * @since 8 669 * @deprecated since 9 670 */ 671 interface USBDevicePipe { 672 /** 673 * Bus address. 674 * 675 * @type { number } 676 * @syscap SystemCapability.USB.USBManager 677 * @since 8 678 * @deprecated since 9 679 */ 680 busNum: number; 681 682 /** 683 * Device address 684 * 685 * @type { number } 686 * @syscap SystemCapability.USB.USBManager 687 * @since 8 688 * @deprecated since 9 689 */ 690 devAddress: number; 691 } 692 693 /** 694 * Enumerates power role types. 695 * 696 * @enum { number } 697 * @syscap SystemCapability.USB.USBManager 698 * @systemapi 699 * @since 9 700 * @deprecated since 9 701 */ 702 export enum PowerRoleType { 703 /** 704 * None 705 * 706 * @syscap SystemCapability.USB.USBManager 707 * @systemapi 708 * @since 9 709 * @deprecated since 9 710 */ 711 NONE = 0, 712 713 /** 714 * External power supply 715 * 716 * @syscap SystemCapability.USB.USBManager 717 * @systemapi 718 * @since 9 719 * @deprecated since 9 720 */ 721 SOURCE = 1, 722 723 /** 724 * Internal power supply 725 * 726 * @syscap SystemCapability.USB.USBManager 727 * @systemapi 728 * @since 9 729 * @deprecated since 9 730 */ 731 SINK = 2 732 } 733 734 /** 735 * Enumerates data role types. 736 * 737 * @enum { number } 738 * @syscap SystemCapability.USB.USBManager 739 * @systemapi 740 * @since 9 741 * @deprecated since 9 742 */ 743 export enum DataRoleType { 744 /** 745 * None 746 * 747 * @syscap SystemCapability.USB.USBManager 748 * @systemapi 749 * @since 9 750 * @deprecated since 9 751 */ 752 NONE = 0, 753 754 /** 755 * Host mode 756 * 757 * @syscap SystemCapability.USB.USBManager 758 * @systemapi 759 * @since 9 760 * @deprecated since 9 761 */ 762 HOST = 1, 763 764 /** 765 * Device mode 766 * 767 * @syscap SystemCapability.USB.USBManager 768 * @systemapi 769 * @since 9 770 * @deprecated since 9 771 */ 772 DEVICE = 2 773 } 774 775 /** 776 * Enumerates port mode types 777 * 778 * @enum { number } 779 * @syscap SystemCapability.USB.USBManager 780 * @systemapi 781 * @since 9 782 * @deprecated since 9 783 */ 784 export enum PortModeType { 785 /** 786 * None 787 * 788 * @syscap SystemCapability.USB.USBManager 789 * @systemapi 790 * @since 9 791 * @deprecated since 9 792 */ 793 NONE = 0, 794 795 /** 796 * Upstream facing port, which functions as the sink of power supply 797 * 798 * @syscap SystemCapability.USB.USBManager 799 * @systemapi 800 * @since 9 801 * @deprecated since 9 802 */ 803 UFP = 1, 804 805 /** 806 * Downstream facing port, which functions as the source of power supply 807 * 808 * @syscap SystemCapability.USB.USBManager 809 * @systemapi 810 * @since 9 811 * @deprecated since 9 812 */ 813 DFP = 2, 814 815 /** 816 * Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently. 817 * 818 * @syscap SystemCapability.USB.USBManager 819 * @systemapi 820 * @since 9 821 * @deprecated since 9 822 */ 823 DRP = 3, 824 825 /** 826 * Not supported currently 827 * 828 * @syscap SystemCapability.USB.USBManager 829 * @systemapi 830 * @since 9 831 * @deprecated since 9 832 */ 833 NUM_MODES = 4 834 } 835 836 /** 837 * Enumerates USB device port roles. 838 * 839 * @typedef USBPortStatus 840 * @syscap SystemCapability.USB.USBManager 841 * @systemapi 842 * @since 9 843 * @deprecated since 9 844 */ 845 interface USBPortStatus { 846 /** 847 * USB mode 848 * 849 * @type { number } 850 * @syscap SystemCapability.USB.USBManager 851 * @systemapi 852 * @since 9 853 * @deprecated since 9 854 */ 855 currentMode: number; 856 857 /** 858 * Power role 859 * 860 * @type { number } 861 * @syscap SystemCapability.USB.USBManager 862 * @systemapi 863 * @since 9 864 * @deprecated since 9 865 */ 866 currentPowerRole: number; 867 868 /** 869 * Data role 870 * 871 * @type { number } 872 * @syscap SystemCapability.USB.USBManager 873 * @systemapi 874 * @since 9 875 * @deprecated since 9 876 */ 877 currentDataRole: number; 878 } 879 880 /** 881 * Represents a USB device port. 882 * 883 * @typedef USBPort 884 * @syscap SystemCapability.USB.USBManager 885 * @systemapi 886 * @since 9 887 * @deprecated since 9 888 */ 889 interface USBPort { 890 /** 891 * Unique ID of the USB port 892 * 893 * @type { number } 894 * @syscap SystemCapability.USB.USBManager 895 * @systemapi 896 * @since 9 897 * @deprecated since 9 898 */ 899 id: number; 900 901 /** 902 * Mask combination for the supported mode list of the USB port 903 * 904 * @type { PortModeType } 905 * @syscap SystemCapability.USB.USBManager 906 * @systemapi 907 * @since 9 908 * @deprecated since 9 909 */ 910 supportedModes: PortModeType; 911 912 /** 913 * USB port role 914 * 915 * @type { USBPortStatus } 916 * @syscap SystemCapability.USB.USBManager 917 * @systemapi 918 * @since 9 919 * @deprecated since 9 920 */ 921 status: USBPortStatus; 922 } 923 924 /** 925 * Represents control transfer parameters. 926 * 927 * @typedef USBControlParams 928 * @syscap SystemCapability.USB.USBManager 929 * @since 8 930 * @deprecated since 9 931 */ 932 interface USBControlParams { 933 /** 934 * Request type 935 * 936 * @type { number } 937 * @syscap SystemCapability.USB.USBManager 938 * @since 8 939 * @deprecated since 9 940 */ 941 request: number; 942 943 /** 944 * Request target type 945 * 946 * @type { USBRequestTargetType } 947 * @syscap SystemCapability.USB.USBManager 948 * @since 8 949 * @deprecated since 9 950 */ 951 target: USBRequestTargetType; 952 953 /** 954 * Control request type 955 * 956 * @type { USBControlRequestType } 957 * @syscap SystemCapability.USB.USBManager 958 * @since 8 959 * @deprecated since 9 960 */ 961 reqType: USBControlRequestType; 962 963 /** 964 * Request parameter value 965 * 966 * @type { number } 967 * @syscap SystemCapability.USB.USBManager 968 * @since 8 969 * @deprecated since 9 970 */ 971 value: number; 972 973 /** 974 * Index of the parameter value 975 * 976 * @type { number } 977 * @syscap SystemCapability.USB.USBManager 978 * @since 8 979 * @deprecated since 9 980 */ 981 index: number; 982 983 /** 984 * Data written to or read from the buffer 985 * 986 * @type { Uint8Array } 987 * @syscap SystemCapability.USB.USBManager 988 * @since 8 989 * @deprecated since 9 990 */ 991 data: Uint8Array; 992 } 993 994 /** 995 * Enumerates USB request target types. 996 * 997 * @enum { number } 998 * @syscap SystemCapability.USB.USBManager 999 * @since 8 1000 * @deprecated since 9 1001 */ 1002 export enum USBRequestTargetType { 1003 /** 1004 * USB device 1005 * 1006 * @syscap SystemCapability.USB.USBManager 1007 * @since 8 1008 * @deprecated since 9 1009 */ 1010 USB_REQUEST_TARGET_DEVICE = 0, 1011 1012 /** 1013 * USB interface 1014 * 1015 * @syscap SystemCapability.USB.USBManager 1016 * @since 8 1017 * @deprecated since 9 1018 */ 1019 USB_REQUEST_TARGET_INTERFACE = 1, 1020 1021 /** 1022 * Endpoint 1023 * 1024 * @syscap SystemCapability.USB.USBManager 1025 * @since 8 1026 * @deprecated since 9 1027 */ 1028 USB_REQUEST_TARGET_ENDPOINT = 2, 1029 1030 /** 1031 * Others 1032 * 1033 * @syscap SystemCapability.USB.USBManager 1034 * @since 8 1035 * @deprecated since 9 1036 */ 1037 USB_REQUEST_TARGET_OTHER = 3 1038 } 1039 1040 /** 1041 * Enumerates control request types. 1042 * 1043 * @enum { number } 1044 * @syscap SystemCapability.USB.USBManager 1045 * @since 8 1046 * @deprecated since 9 1047 */ 1048 export enum USBControlRequestType { 1049 /** 1050 * Standard 1051 * 1052 * @syscap SystemCapability.USB.USBManager 1053 * @since 8 1054 * @deprecated since 9 1055 */ 1056 USB_REQUEST_TYPE_STANDARD = 0, 1057 1058 /** 1059 * Class 1060 * 1061 * @syscap SystemCapability.USB.USBManager 1062 * @since 8 1063 * @deprecated since 9 1064 */ 1065 USB_REQUEST_TYPE_CLASS = 1, 1066 1067 /** 1068 * Vendor 1069 * 1070 * @syscap SystemCapability.USB.USBManager 1071 * @since 8 1072 * @deprecated since 9 1073 */ 1074 USB_REQUEST_TYPE_VENDOR = 2 1075 } 1076 1077 /** 1078 * Enumerates request directions. 1079 * 1080 * @enum { number } 1081 * @syscap SystemCapability.USB.USBManager 1082 * @since 8 1083 * @deprecated since 9 1084 */ 1085 export enum USBRequestDirection { 1086 /** 1087 * Request for writing data from the host to the device 1088 * 1089 * @syscap SystemCapability.USB.USBManager 1090 * @since 8 1091 * @deprecated since 9 1092 */ 1093 USB_REQUEST_DIR_TO_DEVICE = 0, 1094 1095 /** 1096 * Request for reading data from the device to the host 1097 * 1098 * @syscap SystemCapability.USB.USBManager 1099 * @since 8 1100 * @deprecated since 9 1101 */ 1102 USB_REQUEST_DIR_FROM_DEVICE = 0x80 1103 } 1104 1105 /** 1106 * Enumerates function modes. 1107 * 1108 * @enum { number } 1109 * @syscap SystemCapability.USB.USBManager 1110 * @systemapi 1111 * @since 9 1112 * @deprecated since 9 1113 */ 1114 export enum FunctionType { 1115 /** 1116 * None 1117 * 1118 * @syscap SystemCapability.USB.USBManager 1119 * @systemapi 1120 * @since 9 1121 * @deprecated since 9 1122 */ 1123 NONE = 0, 1124 1125 /** 1126 * Serial port device 1127 * 1128 * @syscap SystemCapability.USB.USBManager 1129 * @systemapi 1130 * @since 9 1131 * @deprecated since 9 1132 */ 1133 ACM = 1, 1134 1135 /** 1136 * Ethernet port device 1137 * 1138 * @syscap SystemCapability.USB.USBManager 1139 * @systemapi 1140 * @since 9 1141 * @deprecated since 9 1142 */ 1143 ECM = 2, 1144 1145 /** 1146 * HDC device 1147 * 1148 * @syscap SystemCapability.USB.USBManager 1149 * @systemapi 1150 * @since 9 1151 * @deprecated since 9 1152 */ 1153 HDC = 4, 1154 1155 /** 1156 * MTP device 1157 * 1158 * @syscap SystemCapability.USB.USBManager 1159 * @systemapi 1160 * @since 9 1161 * @deprecated since 9 1162 */ 1163 MTP = 8, 1164 1165 /** 1166 * PTP device 1167 * 1168 * @syscap SystemCapability.USB.USBManager 1169 * @systemapi 1170 * @since 9 1171 * @deprecated since 9 1172 */ 1173 PTP = 16, 1174 1175 /** 1176 * RNDIS device 1177 * 1178 * @syscap SystemCapability.USB.USBManager 1179 * @systemapi 1180 * @since 9 1181 * @deprecated since 9 1182 */ 1183 RNDIS = 32, 1184 1185 /** 1186 * MIDI device 1187 * 1188 * @syscap SystemCapability.USB.USBManager 1189 * @systemapi 1190 * @since 9 1191 * @deprecated since 9 1192 */ 1193 MIDI = 64, 1194 1195 /** 1196 * Audio source device 1197 * 1198 * @syscap SystemCapability.USB.USBManager 1199 * @systemapi 1200 * @since 9 1201 * @deprecated since 9 1202 */ 1203 AUDIO_SOURCE = 128, 1204 1205 /** 1206 * NCM device 1207 * 1208 * @syscap SystemCapability.USB.USBManager 1209 * @systemapi 1210 * @since 9 1211 * @deprecated since 9 1212 */ 1213 NCM = 256 1214 } 1215} 1216 1217export default usb; 1218