1/* 2 * Copyright (c) 2021-2022 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 ConnectivityKit 19 */ 20 21import type { NfcATag as _NfcATag, NfcBTag as _NfcBTag, NfcFTag as _NfcFTag, NfcVTag as _NfcVTag } from './tag/nfctech'; 22import { 23 IsoDepTag as _IsoDepTag, 24 NdefTag as _NdefTag, 25 MifareClassicTag as _MifareClassicTag, 26 MifareUltralightTag as _MifareUltralightTag, 27 NdefFormatableTag as _NdefFormatableTag 28} from './tag/nfctech'; 29import { NdefMessage as _NdefMessage } from './tag/nfctech'; 30import { TagSession as _TagSession } from './tag/tagSession'; 31import type { PacMap } from './ability/dataAbilityHelper'; 32import type rpc from './@ohos.rpc'; 33import type { AsyncCallback } from './@ohos.base'; 34import Want from './@ohos.app.ability.Want'; 35import type { ElementName } from './bundleManager/ElementName'; 36 37/** 38 * Provides methods to operate or manage NFC tag. 39 * 40 * @namespace tag 41 * @syscap SystemCapability.Communication.NFC.Tag 42 * @since 7 43 */ 44/** 45 * Provides methods to operate or manage NFC tag. 46 * 47 * @namespace tag 48 * @syscap SystemCapability.Communication.NFC.Tag 49 * @atomicservice 50 * @since 12 51 */ 52declare namespace tag { 53 /** 54 * Indicates an NFC-A tag. 55 * 56 * @constant 57 * @syscap SystemCapability.Communication.NFC.Tag 58 * @since 7 59 */ 60 /** 61 * Indicates an NFC-A tag. 62 * 63 * @constant 64 * @syscap SystemCapability.Communication.NFC.Tag 65 * @atomicservice 66 * @since 12 67 */ 68 const NFC_A = 1; 69 70 /** 71 * Indicates an NFC-B tag. 72 * 73 * @constant 74 * @syscap SystemCapability.Communication.NFC.Tag 75 * @since 7 76 */ 77 /** 78 * Indicates an NFC-B tag. 79 * 80 * @constant 81 * @syscap SystemCapability.Communication.NFC.Tag 82 * @atomicservice 83 * @since 12 84 */ 85 const NFC_B = 2; 86 87 /** 88 * Indicates an ISO_DEP tag. 89 * 90 * @constant 91 * @syscap SystemCapability.Communication.NFC.Tag 92 * @since 7 93 */ 94 /** 95 * Indicates an ISO_DEP tag. 96 * 97 * @constant 98 * @syscap SystemCapability.Communication.NFC.Tag 99 * @atomicservice 100 * @since 12 101 */ 102 const ISO_DEP = 3; 103 104 /** 105 * Indicates an NFC-F tag. 106 * 107 * @constant 108 * @syscap SystemCapability.Communication.NFC.Tag 109 * @since 7 110 */ 111 /** 112 * Indicates an NFC-F tag. 113 * 114 * @constant 115 * @syscap SystemCapability.Communication.NFC.Tag 116 * @atomicservice 117 * @since 12 118 */ 119 const NFC_F = 4; 120 121 /** 122 * Indicates an NFC-V tag. 123 * 124 * @constant 125 * @syscap SystemCapability.Communication.NFC.Tag 126 * @since 7 127 */ 128 /** 129 * Indicates an NFC-V tag. 130 * 131 * @constant 132 * @syscap SystemCapability.Communication.NFC.Tag 133 * @atomicservice 134 * @since 12 135 */ 136 const NFC_V = 5; 137 138 /** 139 * Indicates an NDEF tag. 140 * 141 * @constant 142 * @syscap SystemCapability.Communication.NFC.Tag 143 * @since 7 144 */ 145 /** 146 * Indicates an NDEF tag. 147 * 148 * @constant 149 * @syscap SystemCapability.Communication.NFC.Tag 150 * @atomicservice 151 * @since 12 152 */ 153 const NDEF = 6; 154 155 /** 156 * Indicates an NDEF Formatable tag. 157 * 158 * @constant 159 * @syscap SystemCapability.Communication.NFC.Tag 160 * @since 9 161 */ 162 /** 163 * Indicates an NDEF Formatable tag. 164 * 165 * @constant 166 * @syscap SystemCapability.Communication.NFC.Tag 167 * @atomicservice 168 * @since 12 169 */ 170 const NDEF_FORMATABLE = 7; 171 172 /** 173 * Indicates an MIFARE CLASSIC tag. 174 * 175 * @constant 176 * @syscap SystemCapability.Communication.NFC.Tag 177 * @since 7 178 */ 179 /** 180 * Indicates an MIFARE CLASSIC tag. 181 * 182 * @constant 183 * @syscap SystemCapability.Communication.NFC.Tag 184 * @atomicservice 185 * @since 12 186 */ 187 const MIFARE_CLASSIC = 8; 188 189 /** 190 * Indicates an MIFARE ULTRALIGHT tag. 191 * 192 * @constant 193 * @syscap SystemCapability.Communication.NFC.Tag 194 * @since 7 195 */ 196 /** 197 * Indicates an MIFARE ULTRALIGHT tag. 198 * 199 * @constant 200 * @syscap SystemCapability.Communication.NFC.Tag 201 * @atomicservice 202 * @since 12 203 */ 204 const MIFARE_ULTRALIGHT = 9; 205 206 /** 207 * TNF types definitions, see NFCForum-TS-NDEF_1.0. 208 * 209 * @enum { number } 210 * @syscap SystemCapability.Communication.NFC.Tag 211 * @since 9 212 */ 213 /** 214 * TNF types definitions, see NFCForum-TS-NDEF_1.0. 215 * 216 * @enum { number } 217 * @syscap SystemCapability.Communication.NFC.Tag 218 * @atomicservice 219 * @since 12 220 */ 221 enum TnfType { 222 /** 223 * Empty 224 * 225 * @syscap SystemCapability.Communication.NFC.Tag 226 * @since 9 227 */ 228 /** 229 * Empty 230 * 231 * @syscap SystemCapability.Communication.NFC.Tag 232 * @atomicservice 233 * @since 12 234 */ 235 TNF_EMPTY = 0x0, 236 237 /** 238 * NFC Forum well-known type [NFC RTD] 239 * 240 * @syscap SystemCapability.Communication.NFC.Tag 241 * @since 9 242 */ 243 /** 244 * NFC Forum well-known type [NFC RTD] 245 * 246 * @syscap SystemCapability.Communication.NFC.Tag 247 * @atomicservice 248 * @since 12 249 */ 250 TNF_WELL_KNOWN = 0x1, 251 252 /** 253 * Media-type as defined in RFC 2046 [RFC 2046] 254 * 255 * @syscap SystemCapability.Communication.NFC.Tag 256 * @since 9 257 */ 258 /** 259 * Media-type as defined in RFC 2046 [RFC 2046] 260 * 261 * @syscap SystemCapability.Communication.NFC.Tag 262 * @atomicservice 263 * @since 12 264 */ 265 TNF_MEDIA = 0x2, 266 267 /** 268 * Absolute URI as defined in RFC 3986 [RFC 3986] 269 * 270 * @syscap SystemCapability.Communication.NFC.Tag 271 * @since 9 272 */ 273 /** 274 * Absolute URI as defined in RFC 3986 [RFC 3986] 275 * 276 * @syscap SystemCapability.Communication.NFC.Tag 277 * @atomicservice 278 * @since 12 279 */ 280 TNF_ABSOLUTE_URI = 0x3, 281 282 /** 283 * NFC Forum external type [NFC RTD] 284 * 285 * @syscap SystemCapability.Communication.NFC.Tag 286 * @since 9 287 */ 288 /** 289 * NFC Forum external type [NFC RTD] 290 * 291 * @syscap SystemCapability.Communication.NFC.Tag 292 * @atomicservice 293 * @since 12 294 */ 295 TNF_EXT_APP = 0x4, 296 297 /** 298 * Unknown 299 * 300 * @syscap SystemCapability.Communication.NFC.Tag 301 * @since 9 302 */ 303 /** 304 * Unknown 305 * 306 * @syscap SystemCapability.Communication.NFC.Tag 307 * @atomicservice 308 * @since 12 309 */ 310 TNF_UNKNOWN = 0x5, 311 312 /** 313 * Unchanged (see section 2.3.3) 314 * 315 * @syscap SystemCapability.Communication.NFC.Tag 316 * @since 9 317 */ 318 /** 319 * Unchanged (see section 2.3.3) 320 * 321 * @syscap SystemCapability.Communication.NFC.Tag 322 * @atomicservice 323 * @since 12 324 */ 325 TNF_UNCHANGED = 0x6 326 } 327 328 /** 329 * NfcForum Type definition. The NDEF tag may use one of them. 330 * 331 * @enum { number } 332 * @syscap SystemCapability.Communication.NFC.Tag 333 * @since 9 334 */ 335 /** 336 * NfcForum Type definition. The NDEF tag may use one of them. 337 * 338 * @enum { number } 339 * @syscap SystemCapability.Communication.NFC.Tag 340 * @atomicservice 341 * @since 12 342 */ 343 enum NfcForumType { 344 /** 345 * NFC FORUM TYPE 1 346 * 347 * @syscap SystemCapability.Communication.NFC.Tag 348 * @since 9 349 */ 350 /** 351 * NFC FORUM TYPE 1 352 * 353 * @syscap SystemCapability.Communication.NFC.Tag 354 * @atomicservice 355 * @since 12 356 */ 357 NFC_FORUM_TYPE_1 = 1, 358 359 /** 360 * NFC FORUM TYPE 2 361 * 362 * @syscap SystemCapability.Communication.NFC.Tag 363 * @since 9 364 */ 365 /** 366 * NFC FORUM TYPE 2 367 * 368 * @syscap SystemCapability.Communication.NFC.Tag 369 * @atomicservice 370 * @since 12 371 */ 372 NFC_FORUM_TYPE_2 = 2, 373 374 /** 375 * NFC FORUM TYPE 3 376 * 377 * @syscap SystemCapability.Communication.NFC.Tag 378 * @since 9 379 */ 380 /** 381 * NFC FORUM TYPE 3 382 * 383 * @syscap SystemCapability.Communication.NFC.Tag 384 * @atomicservice 385 * @since 12 386 */ 387 NFC_FORUM_TYPE_3 = 3, 388 389 /** 390 * NFC FORUM TYPE 4 391 * 392 * @syscap SystemCapability.Communication.NFC.Tag 393 * @since 9 394 */ 395 /** 396 * NFC FORUM TYPE 4 397 * 398 * @syscap SystemCapability.Communication.NFC.Tag 399 * @atomicservice 400 * @since 12 401 */ 402 NFC_FORUM_TYPE_4 = 4, 403 404 /** 405 * Mifare Classic 406 * 407 * @syscap SystemCapability.Communication.NFC.Tag 408 * @since 9 409 */ 410 /** 411 * Mifare Classic 412 * 413 * @syscap SystemCapability.Communication.NFC.Tag 414 * @atomicservice 415 * @since 12 416 */ 417 MIFARE_CLASSIC = 101 418 } 419 420 /** 421 * RTD type TEXT, see NFC Record Type Definition (RTD) Specification. 422 * 423 * @constant 424 * @syscap SystemCapability.Communication.NFC.Tag 425 * @since 9 426 */ 427 /** 428 * RTD type TEXT, see NFC Record Type Definition (RTD) Specification. 429 * 430 * @constant 431 * @syscap SystemCapability.Communication.NFC.Tag 432 * @atomicservice 433 * @since 12 434 */ 435 const RTD_TEXT: number[]; 436 437 /** 438 * RTD type URI, see NFC Record Type Definition (RTD) Specification. 439 * 440 * @constant 441 * @syscap SystemCapability.Communication.NFC.Tag 442 * @since 9 443 */ 444 /** 445 * RTD type URI, see NFC Record Type Definition (RTD) Specification. 446 * 447 * @constant 448 * @syscap SystemCapability.Communication.NFC.Tag 449 * @atomicservice 450 * @since 12 451 */ 452 const RTD_URI: number[]; 453 454 /** 455 * MifareClassic Type definition 456 * 457 * @enum { number } 458 * @syscap SystemCapability.Communication.NFC.Tag 459 * @since 9 460 */ 461 /** 462 * MifareClassic Type definition 463 * 464 * @enum { number } 465 * @syscap SystemCapability.Communication.NFC.Tag 466 * @atomicservice 467 * @since 12 468 */ 469 enum MifareClassicType { 470 /** 471 * Mifare Type unknown 472 * 473 * @syscap SystemCapability.Communication.NFC.Tag 474 * @since 9 475 */ 476 /** 477 * Mifare Type unknown 478 * 479 * @syscap SystemCapability.Communication.NFC.Tag 480 * @atomicservice 481 * @since 12 482 */ 483 TYPE_UNKNOWN = 0, 484 485 /** 486 * Mifare Classic 487 * 488 * @syscap SystemCapability.Communication.NFC.Tag 489 * @since 9 490 */ 491 /** 492 * Mifare Classic 493 * 494 * @syscap SystemCapability.Communication.NFC.Tag 495 * @atomicservice 496 * @since 12 497 */ 498 TYPE_CLASSIC = 1, 499 500 /** 501 * Mifare Plus 502 * 503 * @syscap SystemCapability.Communication.NFC.Tag 504 * @since 9 505 */ 506 /** 507 * Mifare Plus 508 * 509 * @syscap SystemCapability.Communication.NFC.Tag 510 * @atomicservice 511 * @since 12 512 */ 513 TYPE_PLUS = 2, 514 515 /** 516 * Mifare Pro 517 * 518 * @syscap SystemCapability.Communication.NFC.Tag 519 * @since 9 520 */ 521 /** 522 * Mifare Pro 523 * 524 * @syscap SystemCapability.Communication.NFC.Tag 525 * @atomicservice 526 * @since 12 527 */ 528 TYPE_PRO = 3 529 } 530 531 /** 532 * MifareClassic Tag size. 533 * 534 * @enum { number } 535 * @syscap SystemCapability.Communication.NFC.Tag 536 * @since 9 537 */ 538 /** 539 * MifareClassic Tag size. 540 * 541 * @enum { number } 542 * @syscap SystemCapability.Communication.NFC.Tag 543 * @atomicservice 544 * @since 12 545 */ 546 enum MifareClassicSize { 547 /** 548 * 5 sectors per tag, 4 blocks per sector 549 * 550 * @syscap SystemCapability.Communication.NFC.Tag 551 * @since 9 552 */ 553 /** 554 * 5 sectors per tag, 4 blocks per sector 555 * 556 * @syscap SystemCapability.Communication.NFC.Tag 557 * @atomicservice 558 * @since 12 559 */ 560 MC_SIZE_MINI = 320, 561 562 /** 563 * 16 sectors per tag, 4 blocks per sector 564 * 565 * @syscap SystemCapability.Communication.NFC.Tag 566 * @since 9 567 */ 568 /** 569 * 16 sectors per tag, 4 blocks per sector 570 * 571 * @syscap SystemCapability.Communication.NFC.Tag 572 * @atomicservice 573 * @since 12 574 */ 575 MC_SIZE_1K = 1024, 576 577 /** 578 * 32 sectors per tag, 4 blocks per sector 579 * 580 * @syscap SystemCapability.Communication.NFC.Tag 581 * @since 9 582 */ 583 /** 584 * 32 sectors per tag, 4 blocks per sector 585 * 586 * @syscap SystemCapability.Communication.NFC.Tag 587 * @atomicservice 588 * @since 12 589 */ 590 MC_SIZE_2K = 2048, 591 592 /** 593 * 40 sectors per tag, 4 blocks per sector 594 * 595 * @syscap SystemCapability.Communication.NFC.Tag 596 * @since 9 597 */ 598 /** 599 * 40 sectors per tag, 4 blocks per sector 600 * 601 * @syscap SystemCapability.Communication.NFC.Tag 602 * @atomicservice 603 * @since 12 604 */ 605 MC_SIZE_4K = 4096 606 } 607 608 /** 609 * MifareUltralight Type definition 610 * 611 * @enum { number } 612 * @syscap SystemCapability.Communication.NFC.Tag 613 * @since 9 614 */ 615 /** 616 * MifareUltralight Type definition 617 * 618 * @enum { number } 619 * @syscap SystemCapability.Communication.NFC.Tag 620 * @atomicservice 621 * @since 12 622 */ 623 enum MifareUltralightType { 624 /** 625 * Mifare Type unknown 626 * 627 * @syscap SystemCapability.Communication.NFC.Tag 628 * @since 9 629 */ 630 /** 631 * Mifare Type unknown 632 * 633 * @syscap SystemCapability.Communication.NFC.Tag 634 * @atomicservice 635 * @since 12 636 */ 637 TYPE_UNKNOWN = 0, 638 639 /** 640 * Mifare Ultralight 641 * 642 * @syscap SystemCapability.Communication.NFC.Tag 643 * @since 9 644 */ 645 /** 646 * Mifare Ultralight 647 * 648 * @syscap SystemCapability.Communication.NFC.Tag 649 * @atomicservice 650 * @since 12 651 */ 652 TYPE_ULTRALIGHT = 1, 653 654 /** 655 * Mifare UltralightC 656 * 657 * @syscap SystemCapability.Communication.NFC.Tag 658 * @since 9 659 */ 660 /** 661 * Mifare UltralightC 662 * 663 * @syscap SystemCapability.Communication.NFC.Tag 664 * @atomicservice 665 * @since 12 666 */ 667 TYPE_ULTRALIGHT_C = 2 668 } 669 670 /** 671 * Obtains an {@link NfcATag} object based on the tag information. 672 * <p>During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object 673 * will be created based on the tag information. 674 * 675 * @param { TagInfo } tagInfo Indicates the tag information. 676 * @returns { NfcATag } The {@link NfcATag} object. 677 * @syscap SystemCapability.Communication.NFC.Tag 678 * @since 7 679 * @deprecated since 9 680 * @useinstead ohos.nfc.tag/tag#getNfcA 681 */ 682 function getNfcATag(tagInfo: TagInfo): NfcATag; 683 684 /** 685 * Obtains an {@link NfcATag} object based on the tag information. 686 * During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object 687 * will be created based on the tag information. 688 * 689 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 690 * @returns { NfcATag } {@link NfcATag} object. 691 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 692 * <br> 1. Mandatory parameters are left unspecified. 693 * <br> 2. Incorrect parameters types. 694 * <br> 3. Parameter verification failed. 695 * @throws { BusinessError } 801 - Capability not supported. 696 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 697 * @syscap SystemCapability.Communication.NFC.Tag 698 * @since 9 699 */ 700 /** 701 * Obtains an {@link NfcATag} object based on the tag information. 702 * During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object 703 * will be created based on the tag information. 704 * 705 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 706 * @returns { NfcATag } {@link NfcATag} object. 707 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 708 * <br> 1. Mandatory parameters are left unspecified. 709 * <br> 2. Incorrect parameters types. 710 * <br> 3. Parameter verification failed. 711 * @throws { BusinessError } 801 - Capability not supported. 712 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 713 * @syscap SystemCapability.Communication.NFC.Tag 714 * @atomicservice 715 * @since 12 716 */ 717 function getNfcA(tagInfo: TagInfo): NfcATag; 718 719 /** 720 * Obtains an {@link NfcBTag} object based on the tag information. 721 * <p>During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object 722 * will be created based on the tag information. 723 * 724 * @param { TagInfo } tagInfo Indicates the tag information. 725 * @returns { NfcBTag } The {@link NfcBTag} object. 726 * @syscap SystemCapability.Communication.NFC.Tag 727 * @since 7 728 * @deprecated since 9 729 * @useinstead ohos.nfc.tag/tag#getNfcB 730 */ 731 function getNfcBTag(tagInfo: TagInfo): NfcBTag; 732 733 /** 734 * Obtains an {@link NfcBTag} object based on the tag information. 735 * During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object 736 * will be created based on the tag information. 737 * 738 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 739 * @returns { NfcBTag } The {@link NfcBTag} object. 740 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 741 * <br> 1. Mandatory parameters are left unspecified. 742 * <br> 2. Incorrect parameters types. 743 * <br> 3. Parameter verification failed. 744 * @throws { BusinessError } 801 - Capability not supported. 745 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 746 * @syscap SystemCapability.Communication.NFC.Tag 747 * @since 9 748 */ 749 /** 750 * Obtains an {@link NfcBTag} object based on the tag information. 751 * During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object 752 * will be created based on the tag information. 753 * 754 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 755 * @returns { NfcBTag } The {@link NfcBTag} object. 756 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 757 * <br> 1. Mandatory parameters are left unspecified. 758 * <br> 2. Incorrect parameters types. 759 * <br> 3. Parameter verification failed. 760 * @throws { BusinessError } 801 - Capability not supported. 761 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 762 * @syscap SystemCapability.Communication.NFC.Tag 763 * @atomicservice 764 * @since 12 765 */ 766 function getNfcB(tagInfo: TagInfo): NfcBTag; 767 768 /** 769 * Obtains an {@link NfcFTag} object based on the tag information. 770 * <p>During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object 771 * will be created based on the tag information. 772 * 773 * @param { TagInfo } tagInfo Indicates the tag information. 774 * @returns { NfcFTag } The {@link NfcFTag} object. 775 * @syscap SystemCapability.Communication.NFC.Tag 776 * @since 7 777 * @deprecated since 9 778 * @useinstead ohos.nfc.tag/tag#getNfcF 779 */ 780 function getNfcFTag(tagInfo: TagInfo): NfcFTag; 781 782 /** 783 * Obtains an {@link NfcFTag} object based on the tag information. 784 * During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object 785 * will be created based on the tag information. 786 * 787 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 788 * @returns { NfcFTag } The {@link NfcFTag} object. 789 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 790 * <br> 1. Mandatory parameters are left unspecified. 791 * <br> 2. Incorrect parameters types. 792 * <br> 3. Parameter verification failed. 793 * @throws { BusinessError } 801 - Capability not supported. 794 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 795 * @syscap SystemCapability.Communication.NFC.Tag 796 * @since 9 797 */ 798 /** 799 * Obtains an {@link NfcFTag} object based on the tag information. 800 * During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object 801 * will be created based on the tag information. 802 * 803 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 804 * @returns { NfcFTag } The {@link NfcFTag} object. 805 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 806 * <br> 1. Mandatory parameters are left unspecified. 807 * <br> 2. Incorrect parameters types. 808 * <br> 3. Parameter verification failed. 809 * @throws { BusinessError } 801 - Capability not supported. 810 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 811 * @syscap SystemCapability.Communication.NFC.Tag 812 * @atomicservice 813 * @since 12 814 */ 815 function getNfcF(tagInfo: TagInfo): NfcFTag; 816 817 /** 818 * Obtains an {@link NfcVTag} object based on the tag information. 819 * <p>During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object 820 * will be created based on the tag information. 821 * 822 * @param { TagInfo } tagInfo Indicates the tag information. 823 * @returns { NfcVTag } The {@link NfcVTag} object. 824 * @syscap SystemCapability.Communication.NFC.Tag 825 * @since 7 826 * @deprecated since 9 827 * @useinstead ohos.nfc.tag/tag#getNfcV 828 */ 829 function getNfcVTag(tagInfo: TagInfo): NfcVTag; 830 831 /** 832 * Obtains an {@link NfcVTag} object based on the tag information. 833 * During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object 834 * will be created based on the tag information. 835 * 836 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 837 * @returns { NfcVTag } The {@link NfcVTag} object. 838 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 839 * <br> 1. Mandatory parameters are left unspecified. 840 * <br> 2. Incorrect parameters types. 841 * <br> 3. Parameter verification failed. 842 * @throws { BusinessError } 801 - Capability not supported. 843 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 844 * @syscap SystemCapability.Communication.NFC.Tag 845 * @since 9 846 */ 847 /** 848 * Obtains an {@link NfcVTag} object based on the tag information. 849 * During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object 850 * will be created based on the tag information. 851 * 852 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 853 * @returns { NfcVTag } The {@link NfcVTag} object. 854 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 855 * <br> 1. Mandatory parameters are left unspecified. 856 * <br> 2. Incorrect parameters types. 857 * <br> 3. Parameter verification failed. 858 * @throws { BusinessError } 801 - Capability not supported. 859 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 860 * @syscap SystemCapability.Communication.NFC.Tag 861 * @atomicservice 862 * @since 12 863 */ 864 function getNfcV(tagInfo: TagInfo): NfcVTag; 865 866 /** 867 * Obtains an {@link IsoDepTag} object based on the tag information. 868 * During tag reading, if the tag supports the IsoDep technology, an {@link IsoDepTag} object 869 * will be created based on the tag information. 870 * 871 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 872 * @returns { IsoDepTag } The {@link IsoDepTag} object. 873 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 874 * <br> 1. Mandatory parameters are left unspecified. 875 * <br> 2. Incorrect parameters types. 876 * <br> 3. Parameter verification failed. 877 * @throws { BusinessError } 801 - Capability not supported. 878 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 879 * @syscap SystemCapability.Communication.NFC.Tag 880 * @since 9 881 */ 882 /** 883 * Obtains an {@link IsoDepTag} object based on the tag information. 884 * During tag reading, if the tag supports the IsoDep technology, an {@link IsoDepTag} object 885 * will be created based on the tag information. 886 * 887 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 888 * @returns { IsoDepTag } The {@link IsoDepTag} object. 889 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 890 * <br> 1. Mandatory parameters are left unspecified. 891 * <br> 2. Incorrect parameters types. 892 * <br> 3. Parameter verification failed. 893 * @throws { BusinessError } 801 - Capability not supported. 894 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 895 * @syscap SystemCapability.Communication.NFC.Tag 896 * @atomicservice 897 * @since 12 898 */ 899 function getIsoDep(tagInfo: TagInfo): IsoDepTag; 900 901 /** 902 * Obtains an {@link NdefTag} object based on the tag information. 903 * During tag reading, if the tag supports the NDEF technology, an {@link NdefTag} object 904 * will be created based on the tag information. 905 * 906 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 907 * @returns { NdefTag } The {@link NdefTag} object. 908 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 909 * <br> 1. Mandatory parameters are left unspecified. 910 * <br> 2. Incorrect parameters types. 911 * <br> 3. Parameter verification failed. 912 * @throws { BusinessError } 801 - Capability not supported. 913 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 914 * @syscap SystemCapability.Communication.NFC.Tag 915 * @since 9 916 */ 917 /** 918 * Obtains an {@link NdefTag} object based on the tag information. 919 * During tag reading, if the tag supports the NDEF technology, an {@link NdefTag} object 920 * will be created based on the tag information. 921 * 922 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 923 * @returns { NdefTag } The {@link NdefTag} object. 924 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 925 * <br> 1. Mandatory parameters are left unspecified. 926 * <br> 2. Incorrect parameters types. 927 * <br> 3. Parameter verification failed. 928 * @throws { BusinessError } 801 - Capability not supported. 929 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 930 * @syscap SystemCapability.Communication.NFC.Tag 931 * @atomicservice 932 * @since 12 933 */ 934 function getNdef(tagInfo: TagInfo): NdefTag; 935 936 /** 937 * Obtains an {@link MifareClassicTag} object based on the tag information. 938 * During tag reading, if the tag supports the MIFARE Classic technology, 939 * an {@link MifareClassicTag} object will be created based on the tag information. 940 * 941 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 942 * @returns { MifareClassicTag } The {@link MifareClassicTag} object. 943 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 944 * <br> 1. Mandatory parameters are left unspecified. 945 * <br> 2. Incorrect parameters types. 946 * <br> 3. Parameter verification failed. 947 * @throws { BusinessError } 801 - Capability not supported. 948 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 949 * @syscap SystemCapability.Communication.NFC.Tag 950 * @since 9 951 */ 952 /** 953 * Obtains an {@link MifareClassicTag} object based on the tag information. 954 * During tag reading, if the tag supports the MIFARE Classic technology, 955 * an {@link MifareClassicTag} object will be created based on the tag information. 956 * 957 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 958 * @returns { MifareClassicTag } The {@link MifareClassicTag} object. 959 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 960 * <br> 1. Mandatory parameters are left unspecified. 961 * <br> 2. Incorrect parameters types. 962 * <br> 3. Parameter verification failed. 963 * @throws { BusinessError } 801 - Capability not supported. 964 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 965 * @syscap SystemCapability.Communication.NFC.Tag 966 * @atomicservice 967 * @since 12 968 */ 969 function getMifareClassic(tagInfo: TagInfo): MifareClassicTag; 970 971 /** 972 * Obtains an {@link MifareUltralightTag} object based on the tag information. 973 * During tag reading, if the tag supports the MIFARE Ultralight technology, 974 * an {@link MifareUltralightTag} object will be created based on the tag information. 975 * 976 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 977 * @returns { MifareUltralightTag } The {@link MifareUltralightTag} object. 978 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 979 * <br> 1. Mandatory parameters are left unspecified. 980 * <br> 2. Incorrect parameters types. 981 * <br> 3. Parameter verification failed. 982 * @throws { BusinessError } 801 - Capability not supported. 983 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 984 * @syscap SystemCapability.Communication.NFC.Tag 985 * @since 9 986 */ 987 /** 988 * Obtains an {@link MifareUltralightTag} object based on the tag information. 989 * During tag reading, if the tag supports the MIFARE Ultralight technology, 990 * an {@link MifareUltralightTag} object will be created based on the tag information. 991 * 992 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 993 * @returns { MifareUltralightTag } The {@link MifareUltralightTag} object. 994 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 995 * <br> 1. Mandatory parameters are left unspecified. 996 * <br> 2. Incorrect parameters types. 997 * <br> 3. Parameter verification failed. 998 * @throws { BusinessError } 801 - Capability not supported. 999 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 1000 * @syscap SystemCapability.Communication.NFC.Tag 1001 * @atomicservice 1002 * @since 12 1003 */ 1004 function getMifareUltralight(tagInfo: TagInfo): MifareUltralightTag; 1005 1006 /** 1007 * Obtains an {@link NdefFormatableTag} object based on the tag information. 1008 * During tag reading, if the tag supports the NDEF Formatable technology, 1009 * an {@link NdefFormatableTag} object will be created based on the tag information. 1010 * 1011 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 1012 * @returns { NdefFormatableTag } The {@link NdefFormatableTag} object. 1013 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1014 * <br> 1. Mandatory parameters are left unspecified. 1015 * <br> 2. Incorrect parameters types. 1016 * <br> 3. Parameter verification failed. 1017 * @throws { BusinessError } 801 - Capability not supported. 1018 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 1019 * @syscap SystemCapability.Communication.NFC.Tag 1020 * @since 9 1021 */ 1022 /** 1023 * Obtains an {@link NdefFormatableTag} object based on the tag information. 1024 * During tag reading, if the tag supports the NDEF Formatable technology, 1025 * an {@link NdefFormatableTag} object will be created based on the tag information. 1026 * 1027 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 1028 * @returns { NdefFormatableTag } The {@link NdefFormatableTag} object. 1029 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1030 * <br> 1. Mandatory parameters are left unspecified. 1031 * <br> 2. Incorrect parameters types. 1032 * <br> 3. Parameter verification failed. 1033 * @throws { BusinessError } 801 - Capability not supported. 1034 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 1035 * @syscap SystemCapability.Communication.NFC.Tag 1036 * @atomicservice 1037 * @since 12 1038 */ 1039 function getNdefFormatable(tagInfo: TagInfo): NdefFormatableTag; 1040 1041 /** 1042 * Parse a {@link TagInfo} object from Want. 1043 * 1044 * @param { Want } want - The want object that contains the values of TagInfo. 1045 * @returns { TagInfo } The {@link TagInfo} object. 1046 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1047 * <br> 1. Mandatory parameters are left unspecified. 1048 * <br> 2. Incorrect parameters types. 1049 * <br> 3. Parameter verification failed. 1050 * @throws { BusinessError } 801 - Capability not supported. 1051 * @syscap SystemCapability.Communication.NFC.Tag 1052 * @since 9 1053 */ 1054 /** 1055 * Parse a {@link TagInfo} object from Want. 1056 * 1057 * @param { Want } want - The want object that contains the values of TagInfo. 1058 * @returns { TagInfo } The {@link TagInfo} object. 1059 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1060 * <br> 1. Mandatory parameters are left unspecified. 1061 * <br> 2. Incorrect parameters types. 1062 * <br> 3. Parameter verification failed. 1063 * @throws { BusinessError } 801 - Capability not supported. 1064 * @syscap SystemCapability.Communication.NFC.Tag 1065 * @atomicservice 1066 * @since 12 1067 */ 1068 function getTagInfo(want: Want): TagInfo; 1069 1070 /** 1071 * Register tag foreground dispatch. Dispatches to this application only if a tag discovered. 1072 * 1073 * @permission ohos.permission.NFC_TAG 1074 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1075 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 1076 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 1077 * @throws { BusinessError } 201 - Permission denied. 1078 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1079 * <br> 1. Mandatory parameters are left unspecified. 1080 * <br> 2. Incorrect parameters types. 1081 * <br> 3. Parameter verification failed. 1082 * @throws { BusinessError } 801 - Capability not supported. 1083 * @syscap SystemCapability.Communication.NFC.Tag 1084 * @since 10 1085 */ 1086 /** 1087 * Register tag foreground dispatch. Dispatches to this application only if a tag discovered. 1088 * 1089 * @permission ohos.permission.NFC_TAG 1090 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1091 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 1092 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 1093 * @throws { BusinessError } 201 - Permission denied. 1094 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1095 * <br> 1. Mandatory parameters are left unspecified. 1096 * <br> 2. Incorrect parameters types. 1097 * <br> 3. Parameter verification failed. 1098 * @throws { BusinessError } 801 - Capability not supported. 1099 * @throws { BusinessError } 3100202 - The element state is invalid. 1100 * @syscap SystemCapability.Communication.NFC.Tag 1101 * @atomicservice 1102 * @since 12 1103 */ 1104 function registerForegroundDispatch( 1105 elementName: ElementName, 1106 discTech: number[], 1107 callback: AsyncCallback<TagInfo> 1108 ): void; 1109 1110 /** 1111 * Unregister tag foreground dispatch. 1112 * 1113 * @permission ohos.permission.NFC_TAG 1114 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1115 * @throws { BusinessError } 201 - Permission denied. 1116 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1117 * <br> 1. Mandatory parameters are left unspecified. 1118 * <br> 2. Incorrect parameters types. 1119 * <br> 3. Parameter verification failed. 1120 * @throws { BusinessError } 801 - Capability not supported. 1121 * @syscap SystemCapability.Communication.NFC.Tag 1122 * @since 10 1123 */ 1124 /** 1125 * Unregister tag foreground dispatch. 1126 * 1127 * @permission ohos.permission.NFC_TAG 1128 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1129 * @throws { BusinessError } 201 - Permission denied. 1130 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1131 * <br> 1. Mandatory parameters are left unspecified. 1132 * <br> 2. Incorrect parameters types. 1133 * <br> 3. Parameter verification failed. 1134 * @throws { BusinessError } 801 - Capability not supported. 1135 * @syscap SystemCapability.Communication.NFC.Tag 1136 * @atomicservice 1137 * @since 12 1138 */ 1139 function unregisterForegroundDispatch(elementName: ElementName): void; 1140 1141 /** 1142 * Set reader mode enabled when the specific application is foreground. Dispatches to this application only if a tag discovered. 1143 * 1144 * @permission ohos.permission.NFC_TAG 1145 * @param { 'readerMode' } type - The callback type to be registered. 1146 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1147 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 1148 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 1149 * @throws { BusinessError } 201 - Permission denied. 1150 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1151 * <br> 1. Mandatory parameters are left unspecified. 1152 * <br> 2. Incorrect parameters types. 1153 * <br> 3. Parameter verification failed. 1154 * @throws { BusinessError } 801 - Capability not supported. 1155 * @throws { BusinessError } 3100202 - The element state is invalid. 1156 * @syscap SystemCapability.Communication.NFC.Tag 1157 * @since 11 1158 */ 1159 /** 1160 * Set reader mode enabled when the specific application is foreground. Dispatches to this application only if a tag discovered. 1161 * 1162 * @permission ohos.permission.NFC_TAG 1163 * @param { 'readerMode' } type - The callback type to be registered. 1164 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1165 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 1166 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 1167 * @throws { BusinessError } 201 - Permission denied. 1168 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1169 * <br> 1. Mandatory parameters are left unspecified. 1170 * <br> 2. Incorrect parameters types. 1171 * <br> 3. Parameter verification failed. 1172 * @throws { BusinessError } 801 - Capability not supported. 1173 * @throws { BusinessError } 3100202 - The element state is invalid. 1174 * @syscap SystemCapability.Communication.NFC.Tag 1175 * @atomicservice 1176 * @since 12 1177 */ 1178 function on(type: 'readerMode', elementName: ElementName, discTech: number[], callback: AsyncCallback<TagInfo>): void; 1179 1180 /** 1181 * Disable foreground reader mode settings explicitly. 1182 * 1183 * @permission ohos.permission.NFC_TAG 1184 * @param { 'readerMode' } type - The callback type to be unregistered. 1185 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1186 * @param { AsyncCallback<TagInfo> } [callback] - The callback to dispatched the TagInfo object for application. 1187 * @throws { BusinessError } 201 - Permission denied. 1188 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1189 * <br> 1. Mandatory parameters are left unspecified. 1190 * <br> 2. Incorrect parameters types. 1191 * <br> 3. Parameter verification failed. 1192 * @throws { BusinessError } 801 - Capability not supported. 1193 * @throws { BusinessError } 3100203 - The off() can be called only when the on() has been called. 1194 * @syscap SystemCapability.Communication.NFC.Tag 1195 * @since 11 1196 */ 1197 /** 1198 * Disable foreground reader mode settings explicitly. 1199 * 1200 * @permission ohos.permission.NFC_TAG 1201 * @param { 'readerMode' } type - The callback type to be unregistered. 1202 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1203 * @param { AsyncCallback<TagInfo> } [callback] - The callback to dispatched the TagInfo object for application. 1204 * @throws { BusinessError } 201 - Permission denied. 1205 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1206 * <br> 1. Mandatory parameters are left unspecified. 1207 * <br> 2. Incorrect parameters types. 1208 * <br> 3. Parameter verification failed. 1209 * @throws { BusinessError } 801 - Capability not supported. 1210 * @throws { BusinessError } 3100203 - The off() can be called only when the on() has been called. 1211 * @syscap SystemCapability.Communication.NFC.Tag 1212 * @atomicservice 1213 * @since 12 1214 */ 1215 function off(type: 'readerMode', elementName: ElementName, callback?: AsyncCallback<TagInfo>): void; 1216 1217 /** 1218 * Provides tag information. 1219 * <p>This class provides the technology a tag supports, for example, NFC-A. Applications can create 1220 * different tags based on the supported technology. 1221 * 1222 * @typedef TagInfo 1223 * @permission ohos.permission.NFC_TAG 1224 * @syscap SystemCapability.Communication.NFC.Tag 1225 * @since 7 1226 */ 1227 /** 1228 * Provides tag information. 1229 * <p>This class provides the technology a tag supports, for example, NFC-A. Applications can create 1230 * different tags based on the supported technology. 1231 * 1232 * @typedef TagInfo 1233 * @permission ohos.permission.NFC_TAG 1234 * @syscap SystemCapability.Communication.NFC.Tag 1235 * @atomicservice 1236 * @since 12 1237 */ 1238 export interface TagInfo { 1239 /** 1240 * The uid of this tag, it. 1241 * 1242 * @permission ohos.permission.NFC_TAG 1243 * @syscap SystemCapability.Communication.NFC.Tag 1244 * @since 9 1245 */ 1246 /** 1247 * The uid of this tag, it. 1248 * 1249 * @permission ohos.permission.NFC_TAG 1250 * @type { number[] } 1251 * @syscap SystemCapability.Communication.NFC.Tag 1252 * @atomicservice 1253 * @since 12 1254 */ 1255 uid: number[]; 1256 1257 /** 1258 * The supported technology list of this tag. 1259 * 1260 * @permission ohos.permission.NFC_TAG 1261 * @syscap SystemCapability.Communication.NFC.Tag 1262 * @since 9 1263 */ 1264 /** 1265 * The supported technology list of this tag. 1266 * 1267 * @permission ohos.permission.NFC_TAG 1268 * @type { number[] } 1269 * @syscap SystemCapability.Communication.NFC.Tag 1270 * @atomicservice 1271 * @since 12 1272 */ 1273 technology: number[]; 1274 1275 /** 1276 * The extra data for each technology of this tag. 1277 * 1278 * @permission ohos.permission.NFC_TAG 1279 * @type { PacMap[] } 1280 * @syscap SystemCapability.Communication.NFC.Tag 1281 * @systemapi hide for inner use. 1282 * @since 9 1283 */ 1284 extrasData: PacMap[]; 1285 1286 /** 1287 * The the RF discovery id of this tag. 1288 * 1289 * @permission ohos.permission.NFC_TAG 1290 * @type { number } 1291 * @syscap SystemCapability.Communication.NFC.Tag 1292 * @systemapi hide for inner use. 1293 * @since 9 1294 */ 1295 tagRfDiscId: number; 1296 1297 /** 1298 * The extra data for the technology of this tag. 1299 * 1300 * @permission ohos.permission.NFC_TAG 1301 * @type { rpc.RemoteObject } 1302 * @syscap SystemCapability.Communication.NFC.Tag 1303 * @systemapi hide for inner use. 1304 * @since 9 1305 */ 1306 remoteTagService: rpc.RemoteObject; 1307 1308 /** 1309 * The supported technology list of this tag. 1310 * 1311 * @permission ohos.permission.NFC_TAG 1312 * @syscap SystemCapability.Communication.NFC.Tag 1313 * @since 7 1314 * @deprecated since 9 1315 * @useinstead ohos.nfc.tag/tag.TagInfo#technology 1316 */ 1317 supportedProfiles: number[]; 1318 } 1319 1320 /** 1321 * NDEF records definition, see NFCForum-TS-NDEF_1.0. 1322 * 1323 * @typedef NdefRecord 1324 * @syscap SystemCapability.Communication.NFC.Tag 1325 * @since 9 1326 */ 1327 /** 1328 * NDEF records definition, see NFCForum-TS-NDEF_1.0. 1329 * 1330 * @typedef NdefRecord 1331 * @syscap SystemCapability.Communication.NFC.Tag 1332 * @atomicservice 1333 * @since 12 1334 */ 1335 export interface NdefRecord { 1336 /** 1337 * tnf of NdefRecord 1338 * 1339 * @syscap SystemCapability.Communication.NFC.Tag 1340 * @since 9 1341 */ 1342 /** 1343 * tnf of NdefRecord 1344 * 1345 * @type { number } 1346 * @syscap SystemCapability.Communication.NFC.Tag 1347 * @atomicservice 1348 * @since 12 1349 */ 1350 tnf: number; 1351 1352 /** 1353 * RTD type of NdefRecord 1354 * 1355 * @type { number[] } 1356 * @syscap SystemCapability.Communication.NFC.Tag 1357 * @since 9 1358 */ 1359 /** 1360 * RTD type of NdefRecord 1361 * 1362 * @type { number[] } 1363 * @syscap SystemCapability.Communication.NFC.Tag 1364 * @atomicservice 1365 * @since 12 1366 */ 1367 rtdType: number[]; 1368 1369 /** 1370 * id of NdefRecord 1371 * 1372 * @syscap SystemCapability.Communication.NFC.Tag 1373 * @since 9 1374 */ 1375 /** 1376 * id of NdefRecord 1377 * 1378 * @type { number[] } 1379 * @syscap SystemCapability.Communication.NFC.Tag 1380 * @atomicservice 1381 * @since 12 1382 */ 1383 id: number[]; 1384 1385 /** 1386 * payload of NdefRecord 1387 * 1388 * @syscap SystemCapability.Communication.NFC.Tag 1389 * @since 9 1390 */ 1391 /** 1392 * payload of NdefRecord 1393 * 1394 * @type { number[] } 1395 * @syscap SystemCapability.Communication.NFC.Tag 1396 * @atomicservice 1397 * @since 12 1398 */ 1399 payload: number[]; 1400 } 1401 1402 /** 1403 * Provides methods for accessing NDEF tag. 1404 * 1405 * @namespace ndef 1406 * @syscap SystemCapability.Communication.NFC.Tag 1407 * @since 9 1408 */ 1409 /** 1410 * Provides methods for accessing NDEF tag. 1411 * 1412 * @namespace ndef 1413 * @syscap SystemCapability.Communication.NFC.Tag 1414 * @atomicservice 1415 * @since 12 1416 */ 1417 namespace ndef { 1418 /** 1419 * Creates an NDEF record with uri data. 1420 * 1421 * @param { string } uri - Uri data for new NDEF record. 1422 * @returns { NdefRecord } The instance of NdefRecord. 1423 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1424 * <br> 1. Mandatory parameters are left unspecified. 1425 * <br> 2. Incorrect parameters types. 1426 * <br> 3. Parameter verification failed. 1427 * @syscap SystemCapability.Communication.NFC.Tag 1428 * @since 9 1429 */ 1430 /** 1431 * Creates an NDEF record with uri data. 1432 * 1433 * @param { string } uri - Uri data for new NDEF record. 1434 * @returns { NdefRecord } The instance of NdefRecord. 1435 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1436 * <br> 1. Mandatory parameters are left unspecified. 1437 * <br> 2. Incorrect parameters types. 1438 * <br> 3. Parameter verification failed. 1439 * @syscap SystemCapability.Communication.NFC.Tag 1440 * @atomicservice 1441 * @since 12 1442 */ 1443 function makeUriRecord(uri: string): NdefRecord; 1444 1445 /** 1446 * Creates an NDEF record with text data. 1447 * 1448 * @param { string } text - Text data for new an NDEF record. 1449 * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. 1450 * @returns { NdefRecord } The instance of NdefRecord. 1451 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1452 * <br> 1. Mandatory parameters are left unspecified. 1453 * <br> 2. Incorrect parameters types. 1454 * <br> 3. Parameter verification failed. 1455 * @syscap SystemCapability.Communication.NFC.Tag 1456 * @since 9 1457 */ 1458 /** 1459 * Creates an NDEF record with text data. 1460 * 1461 * @param { string } text - Text data for new an NDEF record. 1462 * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. 1463 * @returns { NdefRecord } The instance of NdefRecord. 1464 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1465 * <br> 1. Mandatory parameters are left unspecified. 1466 * <br> 2. Incorrect parameters types. 1467 * <br> 3. Parameter verification failed. 1468 * @syscap SystemCapability.Communication.NFC.Tag 1469 * @atomicservice 1470 * @since 12 1471 */ 1472 function makeTextRecord(text: string, locale: string): NdefRecord; 1473 1474 /** 1475 * Creates an NDEF record with mime data. 1476 * 1477 * @param { string } mimeType type of mime data for new an NDEF record. 1478 * @param { number[] } mimeData mime data for new an NDEF record. 1479 * @returns { NdefRecord } The instance of NdefRecord. 1480 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1481 * <br> 1. Mandatory parameters are left unspecified. 1482 * <br> 2. Incorrect parameters types. 1483 * <br> 3. Parameter verification failed. 1484 * @syscap SystemCapability.Communication.NFC.Tag 1485 * @since 9 1486 */ 1487 /** 1488 * Creates an NDEF record with mime data. 1489 * 1490 * @param { string } mimeType type of mime data for new an NDEF record. 1491 * @param { number[] } mimeData mime data for new an NDEF record. 1492 * @returns { NdefRecord } The instance of NdefRecord. 1493 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1494 * <br> 1. Mandatory parameters are left unspecified. 1495 * <br> 2. Incorrect parameters types. 1496 * <br> 3. Parameter verification failed. 1497 * @syscap SystemCapability.Communication.NFC.Tag 1498 * @atomicservice 1499 * @since 12 1500 */ 1501 function makeMimeRecord(mimeType: string, mimeData: number[]): NdefRecord; 1502 1503 /** 1504 * Creates an NDEF record with external data. 1505 * 1506 * @param { string } domainName - Domain name of issuing organization for the external data. 1507 * @param { string } type - Domain specific type of data for the external data. 1508 * @param { number[] } externalData - Data payload of an NDEF record. 1509 * @returns { NdefRecord } The instance of NdefRecord. 1510 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1511 * <br> 1. Mandatory parameters are left unspecified. 1512 * <br> 2. Incorrect parameters types. 1513 * <br> 3. Parameter verification failed. 1514 * @syscap SystemCapability.Communication.NFC.Tag 1515 * @since 9 1516 */ 1517 /** 1518 * Creates an NDEF record with external data. 1519 * 1520 * @param { string } domainName - Domain name of issuing organization for the external data. 1521 * @param { string } type - Domain specific type of data for the external data. 1522 * @param { number[] } externalData - Data payload of an NDEF record. 1523 * @returns { NdefRecord } The instance of NdefRecord. 1524 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1525 * <br> 1. Mandatory parameters are left unspecified. 1526 * <br> 2. Incorrect parameters types. 1527 * <br> 3. Parameter verification failed. 1528 * @syscap SystemCapability.Communication.NFC.Tag 1529 * @atomicservice 1530 * @since 12 1531 */ 1532 function makeExternalRecord(domainName: string, type: string, externalData: number[]): NdefRecord; 1533 /** 1534 * Creates an NDEF message with raw bytes. 1535 * 1536 * @param { number[] } data - The raw bytes to parse NDEF message. 1537 * @returns { NdefMessage } The instance of NdefMessage. 1538 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1539 * <br> 1. Mandatory parameters are left unspecified. 1540 * <br> 2. Incorrect parameters types. 1541 * <br> 3. Parameter verification failed. 1542 * @syscap SystemCapability.Communication.NFC.Tag 1543 * @since 9 1544 */ 1545 /** 1546 * Creates an NDEF message with raw bytes. 1547 * 1548 * @param { number[] } data - The raw bytes to parse NDEF message. 1549 * @returns { NdefMessage } The instance of NdefMessage. 1550 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1551 * <br> 1. Mandatory parameters are left unspecified. 1552 * <br> 2. Incorrect parameters types. 1553 * <br> 3. Parameter verification failed. 1554 * @syscap SystemCapability.Communication.NFC.Tag 1555 * @atomicservice 1556 * @since 12 1557 */ 1558 function createNdefMessage(data: number[]): NdefMessage; 1559 1560 /** 1561 * Creates an NDEF message with record list. 1562 * 1563 * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. 1564 * @returns { NdefMessage } The instance of NdefMessage. 1565 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1566 * <br> 1. Mandatory parameters are left unspecified. 1567 * <br> 2. Incorrect parameters types. 1568 * <br> 3. Parameter verification failed. 1569 * @syscap SystemCapability.Communication.NFC.Tag 1570 * @since 9 1571 */ 1572 /** 1573 * Creates an NDEF message with record list. 1574 * 1575 * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. 1576 * @returns { NdefMessage } The instance of NdefMessage. 1577 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1578 * <br> 1. Mandatory parameters are left unspecified. 1579 * <br> 2. Incorrect parameters types. 1580 * <br> 3. Parameter verification failed. 1581 * @syscap SystemCapability.Communication.NFC.Tag 1582 * @atomicservice 1583 * @since 12 1584 */ 1585 function createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; 1586 1587 /** 1588 * Parses an NDEF message into raw bytes. 1589 * 1590 * @param { NdefMessage } ndefMessage - An NDEF message to parse. 1591 * @returns { number[] } Returns the raw bytes of an NDEF message. 1592 * @throws { BusinessError } 401 - The parameter check failed. 1593 * @syscap SystemCapability.Communication.NFC.Tag 1594 * @since 9 1595 */ 1596 /** 1597 * Parses an NDEF message into raw bytes. 1598 * 1599 * @param { NdefMessage } ndefMessage - An NDEF message to parse. 1600 * @returns { number[] } Returns the raw bytes of an NDEF message. 1601 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1602 * <br> 1. Mandatory parameters are left unspecified. 1603 * <br> 2. Incorrect parameters types. 1604 * <br> 3. Parameter verification failed. 1605 * @syscap SystemCapability.Communication.NFC.Tag 1606 * @atomicservice 1607 * @since 12 1608 */ 1609 function messageToBytes(ndefMessage: NdefMessage): number[]; 1610 } 1611 1612 /** 1613 * Exports type NfcATag. 1614 * 1615 * @syscap SystemCapability.Communication.NFC.Tag 1616 * @since 7 1617 */ 1618 /** 1619 * Exports type NfcATag. 1620 * 1621 * @typedef { _NfcATag } 1622 * @syscap SystemCapability.Communication.NFC.Tag 1623 * @atomicservice 1624 * @since 12 1625 */ 1626 export type NfcATag = _NfcATag; 1627 1628 /** 1629 * Exports type NfcBTag. 1630 * 1631 * @syscap SystemCapability.Communication.NFC.Tag 1632 * @since 7 1633 */ 1634 /** 1635 * Exports type NfcBTag. 1636 * 1637 * @typedef { _NfcBTag } 1638 * @syscap SystemCapability.Communication.NFC.Tag 1639 * @atomicservice 1640 * @since 12 1641 */ 1642 export type NfcBTag = _NfcBTag; 1643 1644 /** 1645 * Exports type NfcFTag. 1646 * 1647 * @syscap SystemCapability.Communication.NFC.Tag 1648 * @since 7 1649 */ 1650 /** 1651 * Exports type NfcFTag. 1652 * 1653 * @typedef { _NfcFTag } 1654 * @syscap SystemCapability.Communication.NFC.Tag 1655 * @atomicservice 1656 * @since 12 1657 */ 1658 export type NfcFTag = _NfcFTag; 1659 1660 /** 1661 * Exports type NfcVTag. 1662 * 1663 * @syscap SystemCapability.Communication.NFC.Tag 1664 * @since 7 1665 */ 1666 /** 1667 * Exports type NfcVTag. 1668 * 1669 * @typedef { _NfcVTag } 1670 * @syscap SystemCapability.Communication.NFC.Tag 1671 * @atomicservice 1672 * @since 12 1673 */ 1674 export type NfcVTag = _NfcVTag; 1675 1676 /** 1677 * Exports type IsoDepTag. 1678 * 1679 * @syscap SystemCapability.Communication.NFC.Tag 1680 * @since 9 1681 */ 1682 /** 1683 * Exports type IsoDepTag. 1684 * 1685 * @typedef { _IsoDepTag } 1686 * @syscap SystemCapability.Communication.NFC.Tag 1687 * @atomicservice 1688 * @since 12 1689 */ 1690 export type IsoDepTag = _IsoDepTag; 1691 1692 /** 1693 * Exports type NdefTag. 1694 * 1695 * @syscap SystemCapability.Communication.NFC.Tag 1696 * @since 9 1697 */ 1698 /** 1699 * Exports type NdefTag. 1700 * 1701 * @typedef { _NdefTag } 1702 * @syscap SystemCapability.Communication.NFC.Tag 1703 * @atomicservice 1704 * @since 12 1705 */ 1706 export type NdefTag = _NdefTag; 1707 1708 /** 1709 * Exports type MifareClassicTag. 1710 * 1711 * @syscap SystemCapability.Communication.NFC.Tag 1712 * @since 9 1713 */ 1714 /** 1715 * Exports type MifareClassicTag. 1716 * 1717 * @typedef { _MifareClassicTag } 1718 * @syscap SystemCapability.Communication.NFC.Tag 1719 * @atomicservice 1720 * @since 12 1721 */ 1722 export type MifareClassicTag = _MifareClassicTag; 1723 1724 /** 1725 * Exports type MifareUltralightTag. 1726 * 1727 * @syscap SystemCapability.Communication.NFC.Tag 1728 * @since 9 1729 */ 1730 /** 1731 * Exports type MifareUltralightTag. 1732 * 1733 * @typedef { _MifareUltralightTag } 1734 * @syscap SystemCapability.Communication.NFC.Tag 1735 * @atomicservice 1736 * @since 12 1737 */ 1738 export type MifareUltralightTag = _MifareUltralightTag; 1739 1740 /** 1741 * Exports type NdefFormatableTag. 1742 * 1743 * @syscap SystemCapability.Communication.NFC.Tag 1744 * @since 9 1745 */ 1746 /** 1747 * Exports type NdefFormatableTag. 1748 * 1749 * @typedef { _NdefFormatableTag } 1750 * @syscap SystemCapability.Communication.NFC.Tag 1751 * @atomicservice 1752 * @since 12 1753 */ 1754 export type NdefFormatableTag = _NdefFormatableTag; 1755 1756 /** 1757 * Exports type NdefMessage. 1758 * 1759 * @syscap SystemCapability.Communication.NFC.Tag 1760 * @since 9 1761 */ 1762 /** 1763 * Exports type NdefMessage. 1764 * 1765 * @typedef { _NdefMessage } 1766 * @syscap SystemCapability.Communication.NFC.Tag 1767 * @atomicservice 1768 * @since 12 1769 */ 1770 export type NdefMessage = _NdefMessage; 1771 1772 /** 1773 * Exports type TagSession. 1774 * 1775 * @syscap SystemCapability.Communication.NFC.Tag 1776 * @since 7 1777 */ 1778 /** 1779 * Exports type TagSession. 1780 * 1781 * @typedef { _TagSession } 1782 * @syscap SystemCapability.Communication.NFC.Tag 1783 * @atomicservice 1784 * @since 12 1785 */ 1786 export type TagSession = _TagSession; 1787} 1788export default tag;