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 } 3100201 - The tag running state is abnormal in the service. 1100 * @throws { BusinessError } 3100202 - The element state is invalid. 1101 * @syscap SystemCapability.Communication.NFC.Tag 1102 * @atomicservice 1103 * @since 12 1104 */ 1105 function registerForegroundDispatch( 1106 elementName: ElementName, 1107 discTech: number[], 1108 callback: AsyncCallback<TagInfo> 1109 ): void; 1110 1111 /** 1112 * Unregister tag foreground dispatch. 1113 * 1114 * @permission ohos.permission.NFC_TAG 1115 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1116 * @throws { BusinessError } 201 - Permission denied. 1117 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1118 * <br> 1. Mandatory parameters are left unspecified. 1119 * <br> 2. Incorrect parameters types. 1120 * <br> 3. Parameter verification failed. 1121 * @throws { BusinessError } 801 - Capability not supported. 1122 * @syscap SystemCapability.Communication.NFC.Tag 1123 * @since 10 1124 */ 1125 /** 1126 * Unregister tag foreground dispatch. 1127 * 1128 * @permission ohos.permission.NFC_TAG 1129 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1130 * @throws { BusinessError } 201 - Permission denied. 1131 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1132 * <br> 1. Mandatory parameters are left unspecified. 1133 * <br> 2. Incorrect parameters types. 1134 * <br> 3. Parameter verification failed. 1135 * @throws { BusinessError } 801 - Capability not supported. 1136 * @throws { BusinessError } 3100201 - The tag running state is abnormal in the service. 1137 * @syscap SystemCapability.Communication.NFC.Tag 1138 * @atomicservice 1139 * @since 12 1140 */ 1141 function unregisterForegroundDispatch(elementName: ElementName): void; 1142 1143 /** 1144 * Set reader mode enabled when the specific application is foreground. Dispatches to this application only if a tag discovered. 1145 * 1146 * @permission ohos.permission.NFC_TAG 1147 * @param { 'readerMode' } type - The callback type to be registered. 1148 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1149 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 1150 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 1151 * @throws { BusinessError } 201 - Permission denied. 1152 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1153 * <br> 1. Mandatory parameters are left unspecified. 1154 * <br> 2. Incorrect parameters types. 1155 * <br> 3. Parameter verification failed. 1156 * @throws { BusinessError } 801 - Capability not supported. 1157 * @throws { BusinessError } 3100202 - The element state is invalid. 1158 * @syscap SystemCapability.Communication.NFC.Tag 1159 * @since 11 1160 */ 1161 /** 1162 * Set reader mode enabled when the specific application is foreground. Dispatches to this application only if a tag discovered. 1163 * 1164 * @permission ohos.permission.NFC_TAG 1165 * @param { 'readerMode' } type - The callback type to be registered. 1166 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1167 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 1168 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 1169 * @throws { BusinessError } 201 - Permission denied. 1170 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1171 * <br> 1. Mandatory parameters are left unspecified. 1172 * <br> 2. Incorrect parameters types. 1173 * <br> 3. Parameter verification failed. 1174 * @throws { BusinessError } 801 - Capability not supported. 1175 * @throws { BusinessError } 3100201 - The tag running state is abnormal in the service. 1176 * @throws { BusinessError } 3100202 - The element state is invalid. 1177 * @syscap SystemCapability.Communication.NFC.Tag 1178 * @atomicservice 1179 * @since 12 1180 */ 1181 function on(type: 'readerMode', elementName: ElementName, discTech: number[], callback: AsyncCallback<TagInfo>): void; 1182 1183 /** 1184 * Disable foreground reader mode settings explicitly. 1185 * 1186 * @permission ohos.permission.NFC_TAG 1187 * @param { 'readerMode' } type - The callback type to be unregistered. 1188 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1189 * @param { AsyncCallback<TagInfo> } [callback] - The callback to dispatched the TagInfo object for application. 1190 * @throws { BusinessError } 201 - Permission denied. 1191 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1192 * <br> 1. Mandatory parameters are left unspecified. 1193 * <br> 2. Incorrect parameters types. 1194 * <br> 3. Parameter verification failed. 1195 * @throws { BusinessError } 801 - Capability not supported. 1196 * @throws { BusinessError } 3100203 - The off() can be called only when the on() has been called. 1197 * @syscap SystemCapability.Communication.NFC.Tag 1198 * @since 11 1199 */ 1200 /** 1201 * Disable foreground reader mode settings explicitly. 1202 * 1203 * @permission ohos.permission.NFC_TAG 1204 * @param { 'readerMode' } type - The callback type to be unregistered. 1205 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 1206 * @param { AsyncCallback<TagInfo> } [callback] - The callback to dispatched the TagInfo object for application. 1207 * @throws { BusinessError } 201 - Permission denied. 1208 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1209 * <br> 1. Mandatory parameters are left unspecified. 1210 * <br> 2. Incorrect parameters types. 1211 * <br> 3. Parameter verification failed. 1212 * @throws { BusinessError } 801 - Capability not supported. 1213 * @throws { BusinessError } 3100201 - The tag running state is abnormal in the service. 1214 * @throws { BusinessError } 3100203 - The off() can be called only when the on() has been called. 1215 * @syscap SystemCapability.Communication.NFC.Tag 1216 * @atomicservice 1217 * @since 12 1218 */ 1219 function off(type: 'readerMode', elementName: ElementName, callback?: AsyncCallback<TagInfo>): void; 1220 1221 /** 1222 * Provides tag information. 1223 * <p>This class provides the technology a tag supports, for example, NFC-A. Applications can create 1224 * different tags based on the supported technology. 1225 * 1226 * @typedef TagInfo 1227 * @syscap SystemCapability.Communication.NFC.Tag 1228 * @since 7 1229 */ 1230 /** 1231 * Provides tag information. 1232 * <p>This class provides the technology a tag supports, for example, NFC-A. Applications can create 1233 * different tags based on the supported technology. 1234 * 1235 * @typedef TagInfo 1236 * @syscap SystemCapability.Communication.NFC.Tag 1237 * @atomicservice 1238 * @since 12 1239 */ 1240 export interface TagInfo { 1241 /** 1242 * The uid of this tag, it. 1243 * 1244 * @permission ohos.permission.NFC_TAG 1245 * @syscap SystemCapability.Communication.NFC.Tag 1246 * @since 9 1247 */ 1248 /** 1249 * The uid of this tag, it. 1250 * 1251 * @permission ohos.permission.NFC_TAG 1252 * @type { number[] } 1253 * @syscap SystemCapability.Communication.NFC.Tag 1254 * @atomicservice 1255 * @since 12 1256 */ 1257 uid: number[]; 1258 1259 /** 1260 * The supported technology list of this tag. 1261 * 1262 * @permission ohos.permission.NFC_TAG 1263 * @syscap SystemCapability.Communication.NFC.Tag 1264 * @since 9 1265 */ 1266 /** 1267 * The supported technology list of this tag. 1268 * 1269 * @permission ohos.permission.NFC_TAG 1270 * @type { number[] } 1271 * @syscap SystemCapability.Communication.NFC.Tag 1272 * @atomicservice 1273 * @since 12 1274 */ 1275 technology: number[]; 1276 1277 /** 1278 * The extra data for each technology of this tag. 1279 * 1280 * @permission ohos.permission.NFC_TAG 1281 * @type { PacMap[] } 1282 * @syscap SystemCapability.Communication.NFC.Tag 1283 * @systemapi hide for inner use. 1284 * @since 9 1285 */ 1286 extrasData: PacMap[]; 1287 1288 /** 1289 * The the RF discovery id of this tag. 1290 * 1291 * @permission ohos.permission.NFC_TAG 1292 * @type { number } 1293 * @syscap SystemCapability.Communication.NFC.Tag 1294 * @systemapi hide for inner use. 1295 * @since 9 1296 */ 1297 tagRfDiscId: number; 1298 1299 /** 1300 * The extra data for the technology of this tag. 1301 * 1302 * @permission ohos.permission.NFC_TAG 1303 * @type { rpc.RemoteObject } 1304 * @syscap SystemCapability.Communication.NFC.Tag 1305 * @systemapi hide for inner use. 1306 * @since 9 1307 */ 1308 remoteTagService: rpc.RemoteObject; 1309 1310 /** 1311 * The supported technology list of this tag. 1312 * 1313 * @permission ohos.permission.NFC_TAG 1314 * @syscap SystemCapability.Communication.NFC.Tag 1315 * @since 7 1316 * @deprecated since 9 1317 * @useinstead ohos.nfc.tag/tag.TagInfo#technology 1318 */ 1319 supportedProfiles: number[]; 1320 } 1321 1322 /** 1323 * NDEF records definition, see NFCForum-TS-NDEF_1.0. 1324 * 1325 * @typedef NdefRecord 1326 * @syscap SystemCapability.Communication.NFC.Tag 1327 * @since 9 1328 */ 1329 /** 1330 * NDEF records definition, see NFCForum-TS-NDEF_1.0. 1331 * 1332 * @typedef NdefRecord 1333 * @syscap SystemCapability.Communication.NFC.Tag 1334 * @atomicservice 1335 * @since 12 1336 */ 1337 export interface NdefRecord { 1338 /** 1339 * tnf of NdefRecord 1340 * 1341 * @syscap SystemCapability.Communication.NFC.Tag 1342 * @since 9 1343 */ 1344 /** 1345 * tnf of NdefRecord 1346 * 1347 * @type { number } 1348 * @syscap SystemCapability.Communication.NFC.Tag 1349 * @atomicservice 1350 * @since 12 1351 */ 1352 tnf: number; 1353 1354 /** 1355 * RTD type of NdefRecord 1356 * 1357 * @type { number[] } 1358 * @syscap SystemCapability.Communication.NFC.Tag 1359 * @since 9 1360 */ 1361 /** 1362 * RTD type of NdefRecord 1363 * 1364 * @type { number[] } 1365 * @syscap SystemCapability.Communication.NFC.Tag 1366 * @atomicservice 1367 * @since 12 1368 */ 1369 rtdType: number[]; 1370 1371 /** 1372 * id of NdefRecord 1373 * 1374 * @syscap SystemCapability.Communication.NFC.Tag 1375 * @since 9 1376 */ 1377 /** 1378 * id of NdefRecord 1379 * 1380 * @type { number[] } 1381 * @syscap SystemCapability.Communication.NFC.Tag 1382 * @atomicservice 1383 * @since 12 1384 */ 1385 id: number[]; 1386 1387 /** 1388 * payload of NdefRecord 1389 * 1390 * @syscap SystemCapability.Communication.NFC.Tag 1391 * @since 9 1392 */ 1393 /** 1394 * payload of NdefRecord 1395 * 1396 * @type { number[] } 1397 * @syscap SystemCapability.Communication.NFC.Tag 1398 * @atomicservice 1399 * @since 12 1400 */ 1401 payload: number[]; 1402 } 1403 1404 /** 1405 * Provides methods for accessing NDEF tag. 1406 * 1407 * @namespace ndef 1408 * @syscap SystemCapability.Communication.NFC.Tag 1409 * @since 9 1410 */ 1411 /** 1412 * Provides methods for accessing NDEF tag. 1413 * 1414 * @namespace ndef 1415 * @syscap SystemCapability.Communication.NFC.Tag 1416 * @atomicservice 1417 * @since 12 1418 */ 1419 namespace ndef { 1420 /** 1421 * Creates an NDEF record with uri data. 1422 * 1423 * @param { string } uri - Uri data for new NDEF record. 1424 * @returns { NdefRecord } The instance of NdefRecord. 1425 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1426 * <br> 1. Mandatory parameters are left unspecified. 1427 * <br> 2. Incorrect parameters types. 1428 * <br> 3. Parameter verification failed. 1429 * @syscap SystemCapability.Communication.NFC.Tag 1430 * @since 9 1431 */ 1432 /** 1433 * Creates an NDEF record with uri data. 1434 * 1435 * @param { string } uri - Uri data for new NDEF record. 1436 * @returns { NdefRecord } The instance of NdefRecord. 1437 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1438 * <br> 1. Mandatory parameters are left unspecified. 1439 * <br> 2. Incorrect parameters types. 1440 * <br> 3. Parameter verification failed. 1441 * @syscap SystemCapability.Communication.NFC.Tag 1442 * @atomicservice 1443 * @since 12 1444 */ 1445 function makeUriRecord(uri: string): NdefRecord; 1446 1447 /** 1448 * Creates an NDEF record with text data. 1449 * 1450 * @param { string } text - Text data for new an NDEF record. 1451 * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. 1452 * @returns { NdefRecord } The instance of NdefRecord. 1453 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1454 * <br> 1. Mandatory parameters are left unspecified. 1455 * <br> 2. Incorrect parameters types. 1456 * <br> 3. Parameter verification failed. 1457 * @syscap SystemCapability.Communication.NFC.Tag 1458 * @since 9 1459 */ 1460 /** 1461 * Creates an NDEF record with text data. 1462 * 1463 * @param { string } text - Text data for new an NDEF record. 1464 * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. 1465 * @returns { NdefRecord } The instance of NdefRecord. 1466 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1467 * <br> 1. Mandatory parameters are left unspecified. 1468 * <br> 2. Incorrect parameters types. 1469 * <br> 3. Parameter verification failed. 1470 * @syscap SystemCapability.Communication.NFC.Tag 1471 * @atomicservice 1472 * @since 12 1473 */ 1474 function makeTextRecord(text: string, locale: string): NdefRecord; 1475 1476 /** 1477 * Creates an NDEF record with mime data. 1478 * 1479 * @param { string } mimeType type of mime data for new an NDEF record. 1480 * @param { number[] } mimeData mime data for new an NDEF record. 1481 * @returns { NdefRecord } The instance of NdefRecord. 1482 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1483 * <br> 1. Mandatory parameters are left unspecified. 1484 * <br> 2. Incorrect parameters types. 1485 * <br> 3. Parameter verification failed. 1486 * @syscap SystemCapability.Communication.NFC.Tag 1487 * @since 9 1488 */ 1489 /** 1490 * Creates an NDEF record with mime data. 1491 * 1492 * @param { string } mimeType type of mime data for new an NDEF record. 1493 * @param { number[] } mimeData mime data for new an NDEF record. 1494 * @returns { NdefRecord } The instance of NdefRecord. 1495 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1496 * <br> 1. Mandatory parameters are left unspecified. 1497 * <br> 2. Incorrect parameters types. 1498 * <br> 3. Parameter verification failed. 1499 * @syscap SystemCapability.Communication.NFC.Tag 1500 * @atomicservice 1501 * @since 12 1502 */ 1503 function makeMimeRecord(mimeType: string, mimeData: number[]): NdefRecord; 1504 1505 /** 1506 * Creates an NDEF record with external data. 1507 * 1508 * @param { string } domainName - Domain name of issuing organization for the external data. 1509 * @param { string } type - Domain specific type of data for the external data. 1510 * @param { number[] } externalData - Data payload of an NDEF record. 1511 * @returns { NdefRecord } The instance of NdefRecord. 1512 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1513 * <br> 1. Mandatory parameters are left unspecified. 1514 * <br> 2. Incorrect parameters types. 1515 * <br> 3. Parameter verification failed. 1516 * @syscap SystemCapability.Communication.NFC.Tag 1517 * @since 9 1518 */ 1519 /** 1520 * Creates an NDEF record with external data. 1521 * 1522 * @param { string } domainName - Domain name of issuing organization for the external data. 1523 * @param { string } type - Domain specific type of data for the external data. 1524 * @param { number[] } externalData - Data payload of an NDEF record. 1525 * @returns { NdefRecord } The instance of NdefRecord. 1526 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1527 * <br> 1. Mandatory parameters are left unspecified. 1528 * <br> 2. Incorrect parameters types. 1529 * <br> 3. Parameter verification failed. 1530 * @syscap SystemCapability.Communication.NFC.Tag 1531 * @atomicservice 1532 * @since 12 1533 */ 1534 function makeExternalRecord(domainName: string, type: string, externalData: number[]): NdefRecord; 1535 /** 1536 * Creates an NDEF message with raw bytes. 1537 * 1538 * @param { number[] } data - The raw bytes to parse NDEF message. 1539 * @returns { NdefMessage } The instance of NdefMessage. 1540 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1541 * <br> 1. Mandatory parameters are left unspecified. 1542 * <br> 2. Incorrect parameters types. 1543 * <br> 3. Parameter verification failed. 1544 * @syscap SystemCapability.Communication.NFC.Tag 1545 * @since 9 1546 */ 1547 /** 1548 * Creates an NDEF message with raw bytes. 1549 * 1550 * @param { number[] } data - The raw bytes to parse NDEF message. 1551 * @returns { NdefMessage } The instance of NdefMessage. 1552 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1553 * <br> 1. Mandatory parameters are left unspecified. 1554 * <br> 2. Incorrect parameters types. 1555 * <br> 3. Parameter verification failed. 1556 * @syscap SystemCapability.Communication.NFC.Tag 1557 * @atomicservice 1558 * @since 12 1559 */ 1560 function createNdefMessage(data: number[]): NdefMessage; 1561 1562 /** 1563 * Creates an NDEF message with record list. 1564 * 1565 * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. 1566 * @returns { NdefMessage } The instance of NdefMessage. 1567 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1568 * <br> 1. Mandatory parameters are left unspecified. 1569 * <br> 2. Incorrect parameters types. 1570 * <br> 3. Parameter verification failed. 1571 * @syscap SystemCapability.Communication.NFC.Tag 1572 * @since 9 1573 */ 1574 /** 1575 * Creates an NDEF message with record list. 1576 * 1577 * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. 1578 * @returns { NdefMessage } The instance of NdefMessage. 1579 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1580 * <br> 1. Mandatory parameters are left unspecified. 1581 * <br> 2. Incorrect parameters types. 1582 * <br> 3. Parameter verification failed. 1583 * @syscap SystemCapability.Communication.NFC.Tag 1584 * @atomicservice 1585 * @since 12 1586 */ 1587 function createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; 1588 1589 /** 1590 * Parses an NDEF message into raw bytes. 1591 * 1592 * @param { NdefMessage } ndefMessage - An NDEF message to parse. 1593 * @returns { number[] } Returns the raw bytes of an NDEF message. 1594 * @throws { BusinessError } 401 - The parameter check failed. 1595 * @syscap SystemCapability.Communication.NFC.Tag 1596 * @since 9 1597 */ 1598 /** 1599 * Parses an NDEF message into raw bytes. 1600 * 1601 * @param { NdefMessage } ndefMessage - An NDEF message to parse. 1602 * @returns { number[] } Returns the raw bytes of an NDEF message. 1603 * @throws { BusinessError } 401 - The parameter check failed. Possible causes: 1604 * <br> 1. Mandatory parameters are left unspecified. 1605 * <br> 2. Incorrect parameters types. 1606 * <br> 3. Parameter verification failed. 1607 * @syscap SystemCapability.Communication.NFC.Tag 1608 * @atomicservice 1609 * @since 12 1610 */ 1611 function messageToBytes(ndefMessage: NdefMessage): number[]; 1612 } 1613 1614 /** 1615 * Exports type NfcATag. 1616 * 1617 * @syscap SystemCapability.Communication.NFC.Tag 1618 * @since 7 1619 */ 1620 /** 1621 * Exports type NfcATag. 1622 * 1623 * @typedef { _NfcATag } 1624 * @syscap SystemCapability.Communication.NFC.Tag 1625 * @atomicservice 1626 * @since 12 1627 */ 1628 export type NfcATag = _NfcATag; 1629 1630 /** 1631 * Exports type NfcBTag. 1632 * 1633 * @syscap SystemCapability.Communication.NFC.Tag 1634 * @since 7 1635 */ 1636 /** 1637 * Exports type NfcBTag. 1638 * 1639 * @typedef { _NfcBTag } 1640 * @syscap SystemCapability.Communication.NFC.Tag 1641 * @atomicservice 1642 * @since 12 1643 */ 1644 export type NfcBTag = _NfcBTag; 1645 1646 /** 1647 * Exports type NfcFTag. 1648 * 1649 * @syscap SystemCapability.Communication.NFC.Tag 1650 * @since 7 1651 */ 1652 /** 1653 * Exports type NfcFTag. 1654 * 1655 * @typedef { _NfcFTag } 1656 * @syscap SystemCapability.Communication.NFC.Tag 1657 * @atomicservice 1658 * @since 12 1659 */ 1660 export type NfcFTag = _NfcFTag; 1661 1662 /** 1663 * Exports type NfcVTag. 1664 * 1665 * @syscap SystemCapability.Communication.NFC.Tag 1666 * @since 7 1667 */ 1668 /** 1669 * Exports type NfcVTag. 1670 * 1671 * @typedef { _NfcVTag } 1672 * @syscap SystemCapability.Communication.NFC.Tag 1673 * @atomicservice 1674 * @since 12 1675 */ 1676 export type NfcVTag = _NfcVTag; 1677 1678 /** 1679 * Exports type IsoDepTag. 1680 * 1681 * @syscap SystemCapability.Communication.NFC.Tag 1682 * @since 9 1683 */ 1684 /** 1685 * Exports type IsoDepTag. 1686 * 1687 * @typedef { _IsoDepTag } 1688 * @syscap SystemCapability.Communication.NFC.Tag 1689 * @atomicservice 1690 * @since 12 1691 */ 1692 export type IsoDepTag = _IsoDepTag; 1693 1694 /** 1695 * Exports type NdefTag. 1696 * 1697 * @syscap SystemCapability.Communication.NFC.Tag 1698 * @since 9 1699 */ 1700 /** 1701 * Exports type NdefTag. 1702 * 1703 * @typedef { _NdefTag } 1704 * @syscap SystemCapability.Communication.NFC.Tag 1705 * @atomicservice 1706 * @since 12 1707 */ 1708 export type NdefTag = _NdefTag; 1709 1710 /** 1711 * Exports type MifareClassicTag. 1712 * 1713 * @syscap SystemCapability.Communication.NFC.Tag 1714 * @since 9 1715 */ 1716 /** 1717 * Exports type MifareClassicTag. 1718 * 1719 * @typedef { _MifareClassicTag } 1720 * @syscap SystemCapability.Communication.NFC.Tag 1721 * @atomicservice 1722 * @since 12 1723 */ 1724 export type MifareClassicTag = _MifareClassicTag; 1725 1726 /** 1727 * Exports type MifareUltralightTag. 1728 * 1729 * @syscap SystemCapability.Communication.NFC.Tag 1730 * @since 9 1731 */ 1732 /** 1733 * Exports type MifareUltralightTag. 1734 * 1735 * @typedef { _MifareUltralightTag } 1736 * @syscap SystemCapability.Communication.NFC.Tag 1737 * @atomicservice 1738 * @since 12 1739 */ 1740 export type MifareUltralightTag = _MifareUltralightTag; 1741 1742 /** 1743 * Exports type NdefFormatableTag. 1744 * 1745 * @syscap SystemCapability.Communication.NFC.Tag 1746 * @since 9 1747 */ 1748 /** 1749 * Exports type NdefFormatableTag. 1750 * 1751 * @typedef { _NdefFormatableTag } 1752 * @syscap SystemCapability.Communication.NFC.Tag 1753 * @atomicservice 1754 * @since 12 1755 */ 1756 export type NdefFormatableTag = _NdefFormatableTag; 1757 1758 /** 1759 * Exports type NdefMessage. 1760 * 1761 * @syscap SystemCapability.Communication.NFC.Tag 1762 * @since 9 1763 */ 1764 /** 1765 * Exports type NdefMessage. 1766 * 1767 * @typedef { _NdefMessage } 1768 * @syscap SystemCapability.Communication.NFC.Tag 1769 * @atomicservice 1770 * @since 12 1771 */ 1772 export type NdefMessage = _NdefMessage; 1773 1774 /** 1775 * Exports type TagSession. 1776 * 1777 * @syscap SystemCapability.Communication.NFC.Tag 1778 * @since 7 1779 */ 1780 /** 1781 * Exports type TagSession. 1782 * 1783 * @typedef { _TagSession } 1784 * @syscap SystemCapability.Communication.NFC.Tag 1785 * @atomicservice 1786 * @since 12 1787 */ 1788 export type TagSession = _TagSession; 1789} 1790export default tag;