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