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 16import type { NfcATag as _NfcATag, NfcBTag as _NfcBTag, NfcFTag as _NfcFTag, NfcVTag as _NfcVTag } from './tag/nfctech'; 17import { 18 IsoDepTag as _IsoDepTag, 19 NdefTag as _NdefTag, 20 MifareClassicTag as _MifareClassicTag, 21 MifareUltralightTag as _MifareUltralightTag, 22 NdefFormatableTag as _NdefFormatableTag 23} from './tag/nfctech'; 24import { NdefMessage as _NdefMessage } from './tag/nfctech'; 25import { TagSession as _TagSession } from './tag/tagSession'; 26import type { PacMap } from './ability/dataAbilityHelper'; 27import type rpc from './@ohos.rpc'; 28import type { AsyncCallback } from './@ohos.base'; 29import Want from './@ohos.app.ability.Want'; 30import type { ElementName } from './bundleManager/ElementName'; 31 32/** 33 * Provides methods to operate or manage NFC tag. 34 * 35 * @namespace tag 36 * @syscap SystemCapability.Communication.NFC.Tag 37 * @since 7 38 */ 39declare namespace tag { 40 /** 41 * Indicates an NFC-A tag. 42 * 43 * @constant 44 * @syscap SystemCapability.Communication.NFC.Tag 45 * @since 7 46 */ 47 const NFC_A = 1; 48 49 /** 50 * Indicates an NFC-B tag. 51 * 52 * @constant 53 * @syscap SystemCapability.Communication.NFC.Tag 54 * @since 7 55 */ 56 const NFC_B = 2; 57 58 /** 59 * Indicates an ISO_DEP tag. 60 * 61 * @constant 62 * @syscap SystemCapability.Communication.NFC.Tag 63 * @since 7 64 */ 65 const ISO_DEP = 3; 66 67 /** 68 * Indicates an NFC-F tag. 69 * 70 * @constant 71 * @syscap SystemCapability.Communication.NFC.Tag 72 * @since 7 73 */ 74 const NFC_F = 4; 75 76 /** 77 * Indicates an NFC-V tag. 78 * 79 * @constant 80 * @syscap SystemCapability.Communication.NFC.Tag 81 * @since 7 82 */ 83 const NFC_V = 5; 84 85 /** 86 * Indicates an NDEF tag. 87 * 88 * @constant 89 * @syscap SystemCapability.Communication.NFC.Tag 90 * @since 7 91 */ 92 const NDEF = 6; 93 94 /** 95 * Indicates an NDEF Formatable tag. 96 * 97 * @constant 98 * @syscap SystemCapability.Communication.NFC.Tag 99 * @since 9 100 */ 101 const NDEF_FORMATABLE = 7; 102 103 /** 104 * Indicates an MIFARE CLASSIC tag. 105 * 106 * @constant 107 * @syscap SystemCapability.Communication.NFC.Tag 108 * @since 7 109 */ 110 const MIFARE_CLASSIC = 8; 111 112 /** 113 * Indicates an MIFARE ULTRALIGHT tag. 114 * 115 * @constant 116 * @syscap SystemCapability.Communication.NFC.Tag 117 * @since 7 118 */ 119 const MIFARE_ULTRALIGHT = 9; 120 121 /** 122 * TNF types definitions, see NFCForum-TS-NDEF_1.0. 123 * 124 * @enum { number } 125 * @syscap SystemCapability.Communication.NFC.Tag 126 * @since 9 127 */ 128 enum TnfType { 129 /** 130 * Empty 131 * 132 * @syscap SystemCapability.Communication.NFC.Tag 133 * @since 9 134 */ 135 TNF_EMPTY = 0x0, 136 137 /** 138 * NFC Forum well-known type [NFC RTD] 139 * 140 * @syscap SystemCapability.Communication.NFC.Tag 141 * @since 9 142 */ 143 TNF_WELL_KNOWN = 0x1, 144 145 /** 146 * Media-type as defined in RFC 2046 [RFC 2046] 147 * 148 * @syscap SystemCapability.Communication.NFC.Tag 149 * @since 9 150 */ 151 TNF_MEDIA = 0x2, 152 153 /** 154 * Absolute URI as defined in RFC 3986 [RFC 3986] 155 * 156 * @syscap SystemCapability.Communication.NFC.Tag 157 * @since 9 158 */ 159 TNF_ABSOLUTE_URI = 0x3, 160 161 /** 162 * NFC Forum external type [NFC RTD] 163 * 164 * @syscap SystemCapability.Communication.NFC.Tag 165 * @since 9 166 */ 167 TNF_EXT_APP = 0x4, 168 169 /** 170 * Unknown 171 * 172 * @syscap SystemCapability.Communication.NFC.Tag 173 * @since 9 174 */ 175 TNF_UNKNOWN = 0x5, 176 177 /** 178 * Unchanged (see section 2.3.3) 179 * 180 * @syscap SystemCapability.Communication.NFC.Tag 181 * @since 9 182 */ 183 TNF_UNCHANGED = 0x6 184 } 185 186 /** 187 * NfcForum Type definition. The NDEF tag may use one of them. 188 * 189 * @enum { number } 190 * @syscap SystemCapability.Communication.NFC.Tag 191 * @since 9 192 */ 193 enum NfcForumType { 194 /** 195 * NFC FORUM TYPE 1 196 * 197 * @syscap SystemCapability.Communication.NFC.Tag 198 * @since 9 199 */ 200 NFC_FORUM_TYPE_1 = 1, 201 202 /** 203 * NFC FORUM TYPE 2 204 * 205 * @syscap SystemCapability.Communication.NFC.Tag 206 * @since 9 207 */ 208 NFC_FORUM_TYPE_2 = 2, 209 210 /** 211 * NFC FORUM TYPE 3 212 * 213 * @syscap SystemCapability.Communication.NFC.Tag 214 * @since 9 215 */ 216 NFC_FORUM_TYPE_3 = 3, 217 218 /** 219 * NFC FORUM TYPE 4 220 * 221 * @syscap SystemCapability.Communication.NFC.Tag 222 * @since 9 223 */ 224 NFC_FORUM_TYPE_4 = 4, 225 226 /** 227 * Mifare Classic 228 * 229 * @syscap SystemCapability.Communication.NFC.Tag 230 * @since 9 231 */ 232 MIFARE_CLASSIC = 101 233 } 234 235 /** 236 * RTD type TEXT, see NFC Record Type Definition (RTD) Specification. 237 * 238 * @constant 239 * @syscap SystemCapability.Communication.NFC.Tag 240 * @since 9 241 */ 242 const RTD_TEXT: number[]; 243 244 /** 245 * RTD type URI, see NFC Record Type Definition (RTD) Specification. 246 * 247 * @constant 248 * @syscap SystemCapability.Communication.NFC.Tag 249 * @since 9 250 */ 251 const RTD_URI: number[]; 252 253 /** 254 * MifareClassic Type definition 255 * 256 * @enum { number } 257 * @syscap SystemCapability.Communication.NFC.Tag 258 * @since 9 259 */ 260 enum MifareClassicType { 261 /** 262 * Mifare Type unknown 263 * 264 * @syscap SystemCapability.Communication.NFC.Tag 265 * @since 9 266 */ 267 TYPE_UNKNOWN = 0, 268 269 /** 270 * Mifare Classic 271 * 272 * @syscap SystemCapability.Communication.NFC.Tag 273 * @since 9 274 */ 275 TYPE_CLASSIC = 1, 276 277 /** 278 * Mifare Plus 279 * 280 * @syscap SystemCapability.Communication.NFC.Tag 281 * @since 9 282 */ 283 TYPE_PLUS = 2, 284 285 /** 286 * Mifare Pro 287 * 288 * @syscap SystemCapability.Communication.NFC.Tag 289 * @since 9 290 */ 291 TYPE_PRO = 3 292 } 293 294 /** 295 * MifareClassic Tag size. 296 * 297 * @enum { number } 298 * @syscap SystemCapability.Communication.NFC.Tag 299 * @since 9 300 */ 301 enum MifareClassicSize { 302 /** 303 * 5 sectors per tag, 4 blocks per sector 304 * 305 * @syscap SystemCapability.Communication.NFC.Tag 306 * @since 9 307 */ 308 MC_SIZE_MINI = 320, 309 310 /** 311 * 16 sectors per tag, 4 blocks per sector 312 * 313 * @syscap SystemCapability.Communication.NFC.Tag 314 * @since 9 315 */ 316 MC_SIZE_1K = 1024, 317 318 /** 319 * 32 sectors per tag, 4 blocks per sector 320 * 321 * @syscap SystemCapability.Communication.NFC.Tag 322 * @since 9 323 */ 324 MC_SIZE_2K = 2048, 325 326 /** 327 * 40 sectors per tag, 4 blocks per sector 328 * 329 * @syscap SystemCapability.Communication.NFC.Tag 330 * @since 9 331 */ 332 MC_SIZE_4K = 4096 333 } 334 335 /** 336 * MifareUltralight Type definition 337 * 338 * @enum { number } 339 * @syscap SystemCapability.Communication.NFC.Tag 340 * @since 9 341 */ 342 enum MifareUltralightType { 343 /** 344 * Mifare Type unknown 345 * 346 * @syscap SystemCapability.Communication.NFC.Tag 347 * @since 9 348 */ 349 TYPE_UNKNOWN = 0, 350 351 /** 352 * Mifare Ultralight 353 * 354 * @syscap SystemCapability.Communication.NFC.Tag 355 * @since 9 356 */ 357 TYPE_ULTRALIGHT = 1, 358 359 /** 360 * Mifare UltralightC 361 * 362 * @syscap SystemCapability.Communication.NFC.Tag 363 * @since 9 364 */ 365 TYPE_ULTRALIGHT_C = 2 366 } 367 368 /** 369 * Obtains an {@link NfcATag} object based on the tag information. 370 * <p>During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object 371 * will be created based on the tag information. 372 * 373 * @param { TagInfo } tagInfo Indicates the tag information. 374 * @returns { NfcATag } The {@link NfcATag} object. 375 * @syscap SystemCapability.Communication.NFC.Tag 376 * @since 7 377 * @deprecated since 9 378 * @useinstead ohos.nfc.tag/tag#getNfcA 379 */ 380 function getNfcATag(tagInfo: TagInfo): NfcATag; 381 382 /** 383 * Obtains an {@link NfcATag} object based on the tag information. 384 * During tag reading, if the tag supports the NFC-A technology, an {@link NfcATag} object 385 * will be created based on the tag information. 386 * 387 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 388 * @returns { NfcATag } {@link NfcATag} object. 389 * @throws { BusinessError } 401 - The parameter check failed. 390 * @throws { BusinessError } 801 - Capability not supported. 391 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 392 * @syscap SystemCapability.Communication.NFC.Tag 393 * @since 9 394 */ 395 function getNfcA(tagInfo: TagInfo): NfcATag; 396 397 /** 398 * Obtains an {@link NfcBTag} object based on the tag information. 399 * <p>During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object 400 * will be created based on the tag information. 401 * 402 * @param { TagInfo } tagInfo Indicates the tag information. 403 * @returns { NfcBTag } The {@link NfcBTag} object. 404 * @syscap SystemCapability.Communication.NFC.Tag 405 * @since 7 406 * @deprecated since 9 407 * @useinstead ohos.nfc.tag/tag#getNfcB 408 */ 409 function getNfcBTag(tagInfo: TagInfo): NfcBTag; 410 411 /** 412 * Obtains an {@link NfcBTag} object based on the tag information. 413 * During tag reading, if the tag supports the NFC-B technology, an {@link NfcBTag} object 414 * will be created based on the tag information. 415 * 416 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 417 * @returns { NfcBTag } The {@link NfcBTag} object. 418 * @throws { BusinessError } 401 - The parameter check failed. 419 * @throws { BusinessError } 801 - Capability not supported. 420 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 421 * @syscap SystemCapability.Communication.NFC.Tag 422 * @since 9 423 */ 424 function getNfcB(tagInfo: TagInfo): NfcBTag; 425 426 /** 427 * Obtains an {@link NfcFTag} object based on the tag information. 428 * <p>During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object 429 * will be created based on the tag information. 430 * 431 * @param { TagInfo } tagInfo Indicates the tag information. 432 * @returns { NfcFTag } The {@link NfcFTag} object. 433 * @syscap SystemCapability.Communication.NFC.Tag 434 * @since 7 435 * @deprecated since 9 436 * @useinstead ohos.nfc.tag/tag#getNfcF 437 */ 438 function getNfcFTag(tagInfo: TagInfo): NfcFTag; 439 440 /** 441 * Obtains an {@link NfcFTag} object based on the tag information. 442 * During tag reading, if the tag supports the NFC-F technology, an {@link NfcFTag} object 443 * will be created based on the tag information. 444 * 445 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 446 * @returns { NfcFTag } The {@link NfcFTag} object. 447 * @throws { BusinessError } 401 - The parameter check failed. 448 * @throws { BusinessError } 801 - Capability not supported. 449 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 450 * @syscap SystemCapability.Communication.NFC.Tag 451 * @since 9 452 */ 453 function getNfcF(tagInfo: TagInfo): NfcFTag; 454 455 /** 456 * Obtains an {@link NfcVTag} object based on the tag information. 457 * <p>During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object 458 * will be created based on the tag information. 459 * 460 * @param { TagInfo } tagInfo Indicates the tag information. 461 * @returns { NfcVTag } The {@link NfcVTag} object. 462 * @syscap SystemCapability.Communication.NFC.Tag 463 * @since 7 464 * @deprecated since 9 465 * @useinstead ohos.nfc.tag/tag#getNfcV 466 */ 467 function getNfcVTag(tagInfo: TagInfo): NfcVTag; 468 469 /** 470 * Obtains an {@link NfcVTag} object based on the tag information. 471 * During tag reading, if the tag supports the NFC-V technology, an {@link NfcVTag} object 472 * will be created based on the tag information. 473 * 474 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 475 * @returns { NfcVTag } The {@link NfcVTag} object. 476 * @throws { BusinessError } 401 - The parameter check failed. 477 * @throws { BusinessError } 801 - Capability not supported. 478 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 479 * @syscap SystemCapability.Communication.NFC.Tag 480 * @since 9 481 */ 482 function getNfcV(tagInfo: TagInfo): NfcVTag; 483 484 /** 485 * Obtains an {@link IsoDepTag} object based on the tag information. 486 * During tag reading, if the tag supports the IsoDep technology, an {@link IsoDepTag} object 487 * will be created based on the tag information. 488 * 489 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 490 * @returns { IsoDepTag } The {@link IsoDepTag} object. 491 * @throws { BusinessError } 401 - The parameter check failed. 492 * @throws { BusinessError } 801 - Capability not supported. 493 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 494 * @syscap SystemCapability.Communication.NFC.Tag 495 * @since 9 496 */ 497 function getIsoDep(tagInfo: TagInfo): IsoDepTag; 498 499 /** 500 * Obtains an {@link NdefTag} object based on the tag information. 501 * During tag reading, if the tag supports the NDEF technology, an {@link NdefTag} object 502 * will be created based on the tag information. 503 * 504 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 505 * @returns { NdefTag } The {@link NdefTag} object. 506 * @throws { BusinessError } 401 - The parameter check failed. 507 * @throws { BusinessError } 801 - Capability not supported. 508 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 509 * @syscap SystemCapability.Communication.NFC.Tag 510 * @since 9 511 */ 512 function getNdef(tagInfo: TagInfo): NdefTag; 513 514 /** 515 * Obtains an {@link MifareClassicTag} object based on the tag information. 516 * During tag reading, if the tag supports the MIFARE Classic technology, 517 * an {@link MifareClassicTag} object will be created based on the tag information. 518 * 519 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 520 * @returns { MifareClassicTag } The {@link MifareClassicTag} object. 521 * @throws { BusinessError } 401 - The parameter check failed. 522 * @throws { BusinessError } 801 - Capability not supported. 523 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 524 * @syscap SystemCapability.Communication.NFC.Tag 525 * @since 9 526 */ 527 function getMifareClassic(tagInfo: TagInfo): MifareClassicTag; 528 529 /** 530 * Obtains an {@link MifareUltralightTag} object based on the tag information. 531 * During tag reading, if the tag supports the MIFARE Ultralight technology, 532 * an {@link MifareUltralightTag} object will be created based on the tag information. 533 * 534 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 535 * @returns { MifareUltralightTag } The {@link MifareUltralightTag} object. 536 * @throws { BusinessError } 401 - The parameter check failed. 537 * @throws { BusinessError } 801 - Capability not supported. 538 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 539 * @syscap SystemCapability.Communication.NFC.Tag 540 * @since 9 541 */ 542 function getMifareUltralight(tagInfo: TagInfo): MifareUltralightTag; 543 544 /** 545 * Obtains an {@link NdefFormatableTag} object based on the tag information. 546 * During tag reading, if the tag supports the NDEF Formatable technology, 547 * an {@link NdefFormatableTag} object will be created based on the tag information. 548 * 549 * @param { TagInfo } tagInfo - Indicates the dispatched tag information. 550 * @returns { NdefFormatableTag } The {@link NdefFormatableTag} object. 551 * @throws { BusinessError } 401 - The parameter check failed. 552 * @throws { BusinessError } 801 - Capability not supported. 553 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 554 * @syscap SystemCapability.Communication.NFC.Tag 555 * @since 9 556 */ 557 function getNdefFormatable(tagInfo: TagInfo): NdefFormatableTag; 558 559 /** 560 * Parse a {@link TagInfo} object from Want. 561 * 562 * @param { Want } want - The want object that contains the values of TagInfo. 563 * @returns { TagInfo } The {@link TagInfo} object. 564 * @throws { BusinessError } 401 - The parameter check failed. 565 * @throws { BusinessError } 801 - Capability not supported. 566 * @syscap SystemCapability.Communication.NFC.Tag 567 * @since 9 568 */ 569 function getTagInfo(want: Want): TagInfo; 570 571 /** 572 * Register tag foreground dispatch. Dispatches to this application only if a tag discovered. 573 * 574 * @permission ohos.permission.NFC_TAG 575 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 576 * @param { number[] } discTech - The technologies list to set for discovering. From {@link NFC_A} to {@link MIFARE_ULTRALIGHT}. 577 * @param { AsyncCallback<TagInfo> } callback - The callback to dispatched the TagInfo object for application. 578 * @throws { BusinessError } 201 - Permission denied. 579 * @throws { BusinessError } 401 - The parameter check failed. 580 * @throws { BusinessError } 801 - Capability not supported. 581 * @syscap SystemCapability.Communication.NFC.Tag 582 * @since 10 583 */ 584 function registerForegroundDispatch( 585 elementName: ElementName, 586 discTech: number[], 587 callback: AsyncCallback<TagInfo> 588 ): void; 589 590 /** 591 * Unregister tag foreground dispatch. 592 * 593 * @permission ohos.permission.NFC_TAG 594 * @param { ElementName } elementName - The element name of application, must include the bundleName and abilityName. 595 * @throws { BusinessError } 201 - Permission denied. 596 * @throws { BusinessError } 401 - The parameter check failed. 597 * @throws { BusinessError } 801 - Capability not supported. 598 * @syscap SystemCapability.Communication.NFC.Tag 599 * @since 10 600 */ 601 function unregisterForegroundDispatch(elementName: ElementName): void; 602 603 /** 604 * Provides tag information. 605 * <p>This class provides the technology a tag supports, for example, NFC-A. Applications can create 606 * different tags based on the supported technology. 607 * 608 * @typedef TagInfo 609 * @permission ohos.permission.NFC_TAG 610 * @syscap SystemCapability.Communication.NFC.Tag 611 * @since 7 612 */ 613 export interface TagInfo { 614 /** 615 * The uid of this tag, it. 616 * 617 * @permission ohos.permission.NFC_TAG 618 * @syscap SystemCapability.Communication.NFC.Tag 619 * @since 9 620 */ 621 uid: number[]; 622 623 /** 624 * The supported technology list of this tag. 625 * 626 * @permission ohos.permission.NFC_TAG 627 * @syscap SystemCapability.Communication.NFC.Tag 628 * @since 9 629 */ 630 technology: number[]; 631 632 /** 633 * The extra data for each technology of this tag. 634 * 635 * @permission ohos.permission.NFC_TAG 636 * @syscap SystemCapability.Communication.NFC.Tag 637 * @systemapi hide for inner use. 638 * @since 9 639 */ 640 extrasData: PacMap[]; 641 642 /** 643 * The the RF discovery id of this tag. 644 * 645 * @permission ohos.permission.NFC_TAG 646 * @syscap SystemCapability.Communication.NFC.Tag 647 * @systemapi hide for inner use. 648 * @since 9 649 */ 650 tagRfDiscId: number; 651 652 /** 653 * The extra data for the technology of this tag. 654 * 655 * @permission ohos.permission.NFC_TAG 656 * @syscap SystemCapability.Communication.NFC.Tag 657 * @systemapi hide for inner use. 658 * @since 9 659 */ 660 remoteTagService: rpc.RemoteObject; 661 662 /** 663 * The supported technology list of this tag. 664 * 665 * @permission ohos.permission.NFC_TAG 666 * @syscap SystemCapability.Communication.NFC.Tag 667 * @since 7 668 * @deprecated since 9 669 * @useinstead ohos.nfc.tag/tag.TagInfo#technology 670 */ 671 supportedProfiles: number[]; 672 } 673 674 /** 675 * NDEF records definition, see NFCForum-TS-NDEF_1.0. 676 * 677 * @typedef NdefRecord 678 * @syscap SystemCapability.Communication.NFC.Tag 679 * @since 9 680 */ 681 export interface NdefRecord { 682 /** 683 * tnf of NdefRecord 684 * 685 * @syscap SystemCapability.Communication.NFC.Tag 686 * @since 9 687 */ 688 tnf: number; 689 690 /** 691 * RTD type of NdefRecord 692 * 693 * @syscap SystemCapability.Communication.NFC.Tag 694 * @since 9 695 */ 696 rtdType: number[]; 697 698 /** 699 * id of NdefRecord 700 * 701 * @syscap SystemCapability.Communication.NFC.Tag 702 * @since 9 703 */ 704 id: number[]; 705 706 /** 707 * payload of NdefRecord 708 * 709 * @syscap SystemCapability.Communication.NFC.Tag 710 * @since 9 711 */ 712 payload: number[]; 713 } 714 715 namespace ndef { 716 /** 717 * Creates an NDEF record with uri data. 718 * 719 * @param { string } uri - Uri data for new NDEF record. 720 * @returns { NdefRecord } The instance of NdefRecord. 721 * @throws { BusinessError } 401 - The parameter check failed. 722 * @syscap SystemCapability.Communication.NFC.Tag 723 * @since 9 724 */ 725 function makeUriRecord(uri: string): NdefRecord; 726 727 /** 728 * Creates an NDEF record with text data. 729 * 730 * @param { string } text - Text data for new an NDEF record. 731 * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. 732 * @returns { NdefRecord } The instance of NdefRecord. 733 * @throws { BusinessError } 401 - The parameter check failed. 734 * @syscap SystemCapability.Communication.NFC.Tag 735 * @since 9 736 */ 737 function makeTextRecord(text: string, locale: string): NdefRecord; 738 739 /** 740 * Creates an NDEF record with mime data. 741 * 742 * @param { string } mimeType type of mime data for new an NDEF record. 743 * @param { number[] } mimeData mime data for new an NDEF record. 744 * @returns { NdefRecord } The instance of NdefRecord. 745 * @throws { BusinessError } 401 - The parameter check failed. 746 * @syscap SystemCapability.Communication.NFC.Tag 747 * @since 9 748 */ 749 function makeMimeRecord(mimeType: string, mimeData: number[]): NdefRecord; 750 751 /** 752 * Creates an NDEF record with external data. 753 * 754 * @param { string } domainName - Domain name of issuing organization for the external data. 755 * @param { string } type - Domain specific type of data for the external data. 756 * @param { number[] } externalData - Data payload of an NDEF record. 757 * @returns { NdefRecord } The instance of NdefRecord. 758 * @throws { BusinessError } 401 - The parameter check failed. 759 * @syscap SystemCapability.Communication.NFC.Tag 760 * @since 9 761 */ 762 function makeExternalRecord(domainName: string, type: string, externalData: number[]): NdefRecord; 763 /** 764 * Creates an NDEF message with raw bytes. 765 * 766 * @param { number[] } data - The raw bytes to parse NDEF message. 767 * @returns { NdefMessage } The instance of NdefMessage. 768 * @throws { BusinessError } 401 - The parameter check failed. 769 * @syscap SystemCapability.Communication.NFC.Tag 770 * @since 9 771 */ 772 function createNdefMessage(data: number[]): NdefMessage; 773 774 /** 775 * Creates an NDEF message with record list. 776 * 777 * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. 778 * @returns { NdefMessage } The instance of NdefMessage. 779 * @throws { BusinessError } 401 - The parameter check failed. 780 * @syscap SystemCapability.Communication.NFC.Tag 781 * @since 9 782 */ 783 function createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; 784 785 /** 786 * Parses an NDEF message into raw bytes. 787 * 788 * @param { NdefMessage } ndefMessage - An NDEF message to parse. 789 * @returns { number[] } Returns the raw bytes of an NDEF message. 790 * @throws { BusinessError } 401 - The parameter check failed. 791 * @syscap SystemCapability.Communication.NFC.Tag 792 * @since 9 793 */ 794 function messageToBytes(ndefMessage: NdefMessage): number[]; 795 } 796 797 export type NfcATag = _NfcATag; 798 export type NfcBTag = _NfcBTag; 799 export type NfcFTag = _NfcFTag; 800 export type NfcVTag = _NfcVTag; 801 export type IsoDepTag = _IsoDepTag; 802 export type NdefTag = _NdefTag; 803 export type MifareClassicTag = _MifareClassicTag; 804 export type MifareUltralightTag = _MifareUltralightTag; 805 export type NdefFormatableTag = _NdefFormatableTag; 806 export type NdefMessage = _NdefMessage; 807 export type TagSession = _TagSession; 808} 809export default tag;