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 tag from '../@ohos.nfc.tag'; 17import { TagSession } from './tagSession'; 18import { AsyncCallback, Callback } from '../@ohos.base'; 19 20/** 21 * Provides interfaces to control the read and write of tags that support the NFC-A technology. 22 * <p>This class is inherited from the {@link TagSession} abstract class, and provides methods to create 23 * {@code NfcATag} objects and obtain the ATQA and SAK. 24 * 25 * @typedef NfcATag 26 * @syscap SystemCapability.Communication.NFC.Tag 27 * @since 7 28 */ 29export interface NfcATag extends TagSession { 30 /** 31 * Obtains the SAK of an NFC-A tag. 32 * 33 * @returns { number } Returns the SAK of the NFC-A tag. 34 * @syscap SystemCapability.Communication.NFC.Tag 35 * @since 7 36 */ 37 getSak(): number; 38 39 /** 40 * Obtains the ATQA of an NFC-A tag. 41 * 42 * @returns { number[] } Returns the ATQA of the NFC-A tag. 43 * @syscap SystemCapability.Communication.NFC.Tag 44 * @since 7 45 */ 46 getAtqa(): number[]; 47} 48 49/** 50 * Provides interfaces to create an {@code NfcBTag} and perform I/O operations on the tag. 51 * <p>This class inherits from the {@link TagSession} abstract class and provides interfaces to create an 52 * {@code NfcBTag} and obtain the tag information. 53 * 54 * @typedef NfcBTag 55 * @syscap SystemCapability.Communication.NFC.Tag 56 * @since 7 57 */ 58export interface NfcBTag extends TagSession { 59 /** 60 * Obtains the application data of a tag. 61 * 62 * @returns { number[] } Returns the application data of the tag. 63 * @syscap SystemCapability.Communication.NFC.Tag 64 * @since 7 65 */ 66 getRespAppData(): number[]; 67 68 /** 69 * Obtains the protocol information of a tag. 70 * 71 * @returns { number[] } Returns the protocol information of the tag. 72 * @syscap SystemCapability.Communication.NFC.Tag 73 * @since 7 74 */ 75 getRespProtocol(): number[]; 76} 77 78/** 79 * Provides methods for creating an NFC-F tag, obtaining tag information, and controlling tag read and write. 80 * <p>This class inherits from the {@link TagSession} abstract class and provides interfaces to create an 81 * {@code NfcFTag} and obtain the tag information. 82 * 83 * @typedef NfcFTag 84 * @syscap SystemCapability.Communication.NFC.Tag 85 * @since 7 86 */ 87export interface NfcFTag extends TagSession { 88 /** 89 * Obtains the system code from this {@code NfcFTag} instance. 90 * 91 * @returns { number[] } Returns the system code. 92 * @syscap SystemCapability.Communication.NFC.Tag 93 * @since 7 94 */ 95 getSystemCode(): number[]; 96 97 /** 98 * Obtains the PMm (consisting of the IC code and manufacturer parameters) from this {@code NfcFTag} instance. 99 * 100 * @returns { number[] } Returns the PMm. 101 * @syscap SystemCapability.Communication.NFC.Tag 102 * @since 7 103 */ 104 getPmm(): number[]; 105} 106 107/** 108 * Provides methods for creating an NFC-V tag, obtaining tag information, and controlling tag read and write. 109 * <p>This class inherits from the {@link TagSession} abstract class and provides interfaces to create an 110 * {@code NfcVTag} and obtain the tag information. 111 * 112 * @typedef NfcVTag 113 * @syscap SystemCapability.Communication.NFC.Tag 114 * @since 7 115 */ 116export interface NfcVTag extends TagSession { 117 /** 118 * Obtains the response flags from this {@code NfcVTag} instance. 119 * 120 * @returns { number } Returns the response flags. 121 * @syscap SystemCapability.Communication.NFC.Tag 122 * @since 7 123 */ 124 getResponseFlags(): number; 125 126 /** 127 * Obtains the data storage format identifier (DSFID) from this {@code NfcVTag} instance. 128 * 129 * @returns { number } Returns the DSFID. 130 * @syscap SystemCapability.Communication.NFC.Tag 131 * @since 7 132 */ 133 getDsfId(): number; 134} 135 136/** 137 * Provides methods for accessing IsoDep tag. 138 * 139 * @typedef IsoDepTag 140 * @syscap SystemCapability.Communication.NFC.Tag 141 * @since 9 142 */ 143export interface IsoDepTag extends TagSession { 144 /** 145 * Gets IsoDep Historical bytes of the tag, which is based on NfcA RF technology. 146 * It could be null if not based on NfcA. 147 * 148 * @returns { number[] } Returns the Historical bytes, the length could be 0. 149 * @syscap SystemCapability.Communication.NFC.Tag 150 * @since 9 151 */ 152 getHistoricalBytes(): number[]; 153 154 /** 155 * Gets IsoDep HiLayer Response bytes of the tag, which is based on NfcB RF technology. 156 * It could be null if not based on NfcB. 157 * 158 * @returns { number[] } Returns HiLayer Response bytes, the length could be 0. 159 * @syscap SystemCapability.Communication.NFC.Tag 160 * @since 9 161 */ 162 getHiLayerResponse(): number[]; 163 164 /** 165 * Checks if extended apdu length supported or not. 166 * 167 * @permission ohos.permission.NFC_TAG 168 * @returns { Promise<boolean> } Returns true if extended apdu length supported, otherwise false. 169 * @throws { BusinessError } 201 - Permission denied. 170 * @throws { BusinessError } 401 - The parameter check failed. 171 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 172 * @syscap SystemCapability.Communication.NFC.Tag 173 * @since 9 174 */ 175 isExtendedApduSupported(): Promise<boolean>; 176 177 /** 178 * Checks if extended apdu length supported or not. 179 * 180 * @permission ohos.permission.NFC_TAG 181 * @param { AsyncCallback<boolean> } callback The callback. 182 * @throws { BusinessError } 201 - Permission denied. 183 * @throws { BusinessError } 401 - The parameter check failed. 184 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 185 * @syscap SystemCapability.Communication.NFC.Tag 186 * @since 9 187 */ 188 isExtendedApduSupported(callback: AsyncCallback<boolean>): void; 189} 190 191export interface NdefMessage { 192 /** 193 * Obtains all records of an NDEF message. 194 * 195 * @returns { tag.NdefRecord[] } Records the list of NDEF records. 196 * @syscap SystemCapability.Communication.NFC.Tag 197 * @since 9 198 */ 199 getNdefRecords(): tag.NdefRecord[]; 200} 201 202/** 203 * Provides methods for accessing NDEF tag. 204 * 205 * @typedef NdefTag 206 * @syscap SystemCapability.Communication.NFC.Tag 207 * @since 9 208 */ 209export interface NdefTag extends TagSession { 210 /** 211 * Gets the type of NDEF tag. 212 * 213 * @returns { tag.NfcForumType } The type of NDEF tag. 214 * @syscap SystemCapability.Communication.NFC.Tag 215 * @since 9 216 */ 217 getNdefTagType(): tag.NfcForumType; 218 219 /** 220 * Gets the NDEF message that was read from NDEF tag when tag discovery. 221 * 222 * @returns { NdefMessage } The instance of NdefMessage. 223 * @syscap SystemCapability.Communication.NFC.Tag 224 * @since 9 225 */ 226 getNdefMessage(): NdefMessage; 227 228 /** 229 * Checks if NDEF tag is writable. 230 * 231 * @returns { boolean } Returns true if the tag is writable, otherwise returns false. 232 * @syscap SystemCapability.Communication.NFC.Tag 233 * @since 9 234 */ 235 isNdefWritable(): boolean; 236 237 /** 238 * Reads NDEF message on this tag. 239 * 240 * @permission ohos.permission.NFC_TAG 241 * @returns { Promise<NdefMessage> } The NDEF message in tag. 242 * @throws { BusinessError } 201 - Permission denied. 243 * @throws { BusinessError } 401 - The parameter check failed. 244 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 245 * @syscap SystemCapability.Communication.NFC.Tag 246 * @since 9 247 */ 248 readNdef(): Promise<NdefMessage>; 249 250 /** 251 * Reads NDEF message on this tag. 252 * 253 * @permission ohos.permission.NFC_TAG 254 * @param { AsyncCallback<NdefMessage> } callback The callback. 255 * @throws { BusinessError } 201 - Permission denied. 256 * @throws { BusinessError } 401 - The parameter check failed. 257 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 258 * @syscap SystemCapability.Communication.NFC.Tag 259 * @since 9 260 */ 261 readNdef(callback: AsyncCallback<NdefMessage>): void; 262 263 /** 264 * Writes NDEF message into this tag. 265 * 266 * @permission ohos.permission.NFC_TAG 267 * @param { NdefMessage } msg - The NDEF message to be written. 268 * @returns { Promise<void> } The void 269 * @throws { BusinessError } 201 - Permission denied. 270 * @throws { BusinessError } 401 - The parameter check failed. 271 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 272 * @syscap SystemCapability.Communication.NFC.Tag 273 * @since 9 274 */ 275 writeNdef(msg: NdefMessage): Promise<void>; 276 277 /** 278 * Writes NDEF message into this tag. 279 * 280 * @permission ohos.permission.NFC_TAG 281 * @param { NdefMessage } msg - The NDEF message to be written. 282 * @param { AsyncCallback<void> } callback The callback. 283 * @throws { BusinessError } 201 - Permission denied. 284 * @throws { BusinessError } 401 - The parameter check failed. 285 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 286 * @syscap SystemCapability.Communication.NFC.Tag 287 * @since 9 288 */ 289 writeNdef(msg: NdefMessage, callback: AsyncCallback<void>): void; 290 291 /** 292 * Checks NDEF tag can be set read-only. 293 * 294 * @permission ohos.permission.NFC_TAG 295 * @returns { boolean } Returns true if the tag can be set readonly, otherwise returns false. 296 * @throws { BusinessError } 201 - Permission denied. 297 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 298 * @syscap SystemCapability.Communication.NFC.Tag 299 * @since 9 300 */ 301 canSetReadOnly(): boolean; 302 303 /** 304 * Sets the NDEF tag read-only. 305 * 306 * @permission ohos.permission.NFC_TAG 307 * @returns { Promise<void> } The void 308 * @throws { BusinessError } 201 - Permission denied. 309 * @throws { BusinessError } 401 - The parameter check failed. 310 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 311 * @syscap SystemCapability.Communication.NFC.Tag 312 * @since 9 313 */ 314 setReadOnly(): Promise<void>; 315 316 /** 317 * Sets the NDEF tag read-only. 318 * 319 * @permission ohos.permission.NFC_TAG 320 * @param { AsyncCallback<void> } callback The callback. 321 * @throws { BusinessError } 201 - Permission denied. 322 * @throws { BusinessError } 401 - The parameter check failed. 323 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 324 * @syscap SystemCapability.Communication.NFC.Tag 325 * @since 9 326 */ 327 setReadOnly(callback: AsyncCallback<void>): void; 328 329 /** 330 * Converts the NFC forum type into string defined in NFC forum. 331 * 332 * @param { tag.NfcForumType } type - NFC forum type of NDEF tag. 333 * @returns { string } The NFC forum string type. 334 * @throws { BusinessError } 401 - The parameter check failed. 335 * @syscap SystemCapability.Communication.NFC.Tag 336 * @since 9 337 */ 338 getNdefTagTypeString(type: tag.NfcForumType): string; 339} 340 341/** 342 * Provides methods for accessing MifareClassic tag. 343 * 344 * @typedef MifareClassicTag 345 * @syscap SystemCapability.Communication.NFC.Tag 346 * @since 9 347 */ 348export interface MifareClassicTag extends TagSession { 349 /** 350 * Authenticates a sector with the key.Only successful authentication sector can be operated. 351 * 352 * @permission ohos.permission.NFC_TAG 353 * @param { number } sectorIndex - Index of sector to authenticate. 354 * @param { number[] } key - The key(6-bytes) to authenticate. 355 * @param { boolean } isKeyA - KeyA flag. true means KeyA, otherwise KeyB. 356 * @returns { Promise<void> } The void 357 * @throws { BusinessError } 201 - Permission denied. 358 * @throws { BusinessError } 401 - The parameter check failed. 359 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 360 * @syscap SystemCapability.Communication.NFC.Tag 361 * @since 9 362 */ 363 authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise<void>; 364 365 /** 366 * Authenticates a sector with the key.Only successful authentication sector can be operated. 367 * 368 * @permission ohos.permission.NFC_TAG 369 * @param { number } sectorIndex - Index of sector to authenticate. 370 * @param { number[] } key - The key(6-bytes) to authenticate. 371 * @param { boolean } isKeyA - KeyA flag. true means KeyA, otherwise KeyB. 372 * @param { AsyncCallback<void> } callback The callback. 373 * @throws { BusinessError } 201 - Permission denied. 374 * @throws { BusinessError } 401 - The parameter check failed. 375 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 376 * @syscap SystemCapability.Communication.NFC.Tag 377 * @since 9 378 */ 379 authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback<void>): void; 380 381 /** 382 * Reads a block, one block size is 16 bytes. 383 * 384 * @permission ohos.permission.NFC_TAG 385 * @param { number } blockIndex - The index of block to read. 386 * @returns { Promise<number[]> } Returns the block data. 387 * @throws { BusinessError } 201 - Permission denied. 388 * @throws { BusinessError } 401 - The parameter check failed. 389 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 390 * @syscap SystemCapability.Communication.NFC.Tag 391 * @since 9 392 */ 393 readSingleBlock(blockIndex: number): Promise<number[]>; 394 395 /** 396 * Reads a block, one block size is 16 bytes. 397 * 398 * @permission ohos.permission.NFC_TAG 399 * @param { number } blockIndex - The index of block to read. 400 * @param { AsyncCallback<number[]> } callback The callback. 401 * @throws { BusinessError } 201 - Permission denied. 402 * @throws { BusinessError } 401 - The parameter check failed. 403 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 404 * @syscap SystemCapability.Communication.NFC.Tag 405 * @since 9 406 */ 407 readSingleBlock(blockIndex: number, callback: AsyncCallback<number[]>): void; 408 409 /** 410 * Writes a block, one block size is 16 bytes. 411 * 412 * @permission ohos.permission.NFC_TAG 413 * @param { number } blockIndex - The index of block to write. 414 * @param { number[] } data - The block data to write. 415 * @returns { Promise<void> } The void 416 * @throws { BusinessError } 201 - Permission denied. 417 * @throws { BusinessError } 401 - The parameter check failed. 418 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 419 * @syscap SystemCapability.Communication.NFC.Tag 420 * @since 9 421 */ 422 writeSingleBlock(blockIndex: number, data: number[]): Promise<void>; 423 424 /** 425 * Writes a block, one block size is 16 bytes. 426 * 427 * @permission ohos.permission.NFC_TAG 428 * @param { number } blockIndex - The index of block to write. 429 * @param { number[] } data - The block data to write. 430 * @param { AsyncCallback<void> } callback The callback. 431 * @throws { BusinessError } 201 - Permission denied. 432 * @throws { BusinessError } 401 - The parameter check failed. 433 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 434 * @syscap SystemCapability.Communication.NFC.Tag 435 * @since 9 436 */ 437 writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback<void>): void; 438 439 /** 440 * Increments the contents of a block, and stores the result in the internal transfer buffer. 441 * 442 * @permission ohos.permission.NFC_TAG 443 * @param { number } blockIndex - The index of block to increment. 444 * @param { number } value - The value to increment, none-negative. 445 * @returns { Promise<void> } The void 446 * @throws { BusinessError } 201 - Permission denied. 447 * @throws { BusinessError } 401 - The parameter check failed. 448 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 449 * @syscap SystemCapability.Communication.NFC.Tag 450 * @since 9 451 */ 452 incrementBlock(blockIndex: number, value: number): Promise<void>; 453 454 /** 455 * Increments the contents of a block, and stores the result in the internal transfer buffer. 456 * 457 * @permission ohos.permission.NFC_TAG 458 * @param { number } blockIndex - The index of block to increment. 459 * @param { number } value - The value to increment, none-negative. 460 * @param { AsyncCallback<void> } callback The callback. 461 * @throws { BusinessError } 201 - Permission denied. 462 * @throws { BusinessError } 401 - The parameter check failed. 463 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 464 * @syscap SystemCapability.Communication.NFC.Tag 465 * @since 9 466 */ 467 incrementBlock(blockIndex: number, value: number, callback: AsyncCallback<void>): void; 468 469 /** 470 * Decreases the contents of a block, and stores the result in the internal transfer buffer. 471 * 472 * @permission ohos.permission.NFC_TAG 473 * @param { number } blockIndex - The index of block to decrease. 474 * @param { number } value - The value to decrease, none-negative. 475 * @returns { Promise<void> } The void 476 * @throws { BusinessError } 201 - Permission denied. 477 * @throws { BusinessError } 401 - The parameter check failed. 478 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 479 * @syscap SystemCapability.Communication.NFC.Tag 480 * @since 9 481 */ 482 decrementBlock(blockIndex: number, value: number): Promise<void>; 483 484 /** 485 * Decreases the contents of a block, and stores the result in the internal transfer buffer. 486 * 487 * @permission ohos.permission.NFC_TAG 488 * @param { number } blockIndex - The index of block to decrease. 489 * @param { number } value - The value to decrease, none-negative. 490 * @param { AsyncCallback<void> } callback The callback. 491 * @throws { BusinessError } 201 - Permission denied. 492 * @throws { BusinessError } 401 - The parameter check failed. 493 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 494 * @syscap SystemCapability.Communication.NFC.Tag 495 * @since 9 496 */ 497 decrementBlock(blockIndex: number, value: number, callback: AsyncCallback<void>): void; 498 499 /** 500 * Writes the contents of the internal transfer buffer to a value block. 501 * 502 * @permission ohos.permission.NFC_TAG 503 * @param { number } blockIndex - The index of value block to be written. 504 * @returns { Promise<void> } The void 505 * @throws { BusinessError } 201 - Permission denied. 506 * @throws { BusinessError } 401 - The parameter check failed. 507 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 508 * @syscap SystemCapability.Communication.NFC.Tag 509 * @since 9 510 */ 511 transferToBlock(blockIndex: number): Promise<void>; 512 513 /** 514 * Writes the contents of the internal transfer buffer to a value block. 515 * 516 * @permission ohos.permission.NFC_TAG 517 * @param { number } blockIndex - The index of value block to be written. 518 * @param { AsyncCallback<void> } callback The callback. 519 * @throws { BusinessError } 201 - Permission denied. 520 * @throws { BusinessError } 401 - The parameter check failed. 521 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 522 * @syscap SystemCapability.Communication.NFC.Tag 523 * @since 9 524 */ 525 transferToBlock(blockIndex: number, callback: AsyncCallback<void>): void; 526 527 /** 528 * Moves the contents of a block into the internal transfer buffer. 529 * 530 * @permission ohos.permission.NFC_TAG 531 * @param { number } blockIndex - The index of value block to be moved from. 532 * @returns { Promise<void> } The void 533 * @throws { BusinessError } 201 - Permission denied. 534 * @throws { BusinessError } 401 - The parameter check failed. 535 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 536 * @syscap SystemCapability.Communication.NFC.Tag 537 * @since 9 538 */ 539 restoreFromBlock(blockIndex: number): Promise<void>; 540 541 /** 542 * Moves the contents of a block into the internal transfer buffer. 543 * 544 * @permission ohos.permission.NFC_TAG 545 * @param { number } blockIndex - The index of value block to be moved from. 546 * @param { AsyncCallback<void> } callback The callback. 547 * @throws { BusinessError } 201 - Permission denied. 548 * @throws { BusinessError } 401 - The parameter check failed. 549 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 550 * @syscap SystemCapability.Communication.NFC.Tag 551 * @since 9 552 */ 553 restoreFromBlock(blockIndex: number, callback: AsyncCallback<void>): void; 554 555 /** 556 * Gets the number of sectors in MifareClassic tag. 557 * 558 * @returns { number } Returns the number of sectors. 559 * @syscap SystemCapability.Communication.NFC.Tag 560 * @since 9 561 */ 562 getSectorCount(): number; 563 564 /** 565 * Gets the number of blocks in the sector. 566 * 567 * @param { number } sectorIndex - The index of sector. 568 * @returns { number } Returns the number of blocks. 569 * @throws { BusinessError } 401 - The parameter check failed. 570 * @syscap SystemCapability.Communication.NFC.Tag 571 * @since 9 572 */ 573 getBlockCountInSector(sectorIndex: number): number; 574 575 /** 576 * Gets the type of the MifareClassic tag. 577 * 578 * @returns { tag.MifareClassicType } Returns type of MifareClassic tag. 579 * @syscap SystemCapability.Communication.NFC.Tag 580 * @since 9 581 */ 582 getType(): tag.MifareClassicType; 583 584 /** 585 * Gets size of the tag in bytes. 586 * 587 * @returns { number } Returns the size of the tag. 588 * @syscap SystemCapability.Communication.NFC.Tag 589 * @since 9 590 */ 591 getTagSize(): number; 592 593 /** 594 * Checks if the tag is emulated or not. 595 * 596 * @returns { boolean } Returns true if tag is emulated, otherwise false. 597 * @syscap SystemCapability.Communication.NFC.Tag 598 * @since 9 599 */ 600 isEmulatedTag(): boolean; 601 602 /** 603 * Gets the first block of the specific sector. 604 * 605 * @param { number } sectorIndex - The index of sector. 606 * @returns { number } Returns index of first block in the sector. 607 * @throws { BusinessError } 401 - The parameter check failed. 608 * @syscap SystemCapability.Communication.NFC.Tag 609 * @since 9 610 */ 611 getBlockIndex(sectorIndex: number): number; 612 613 /** 614 * Gets the sector index, that the sector contains the specific block. 615 * 616 * @param { number } blockIndex - The index of block. 617 * @returns { number } Returns the sector index. 618 * @throws { BusinessError } 401 - The parameter check failed. 619 * @syscap SystemCapability.Communication.NFC.Tag 620 * @since 9 621 */ 622 getSectorIndex(blockIndex: number): number; 623} 624 625/** 626 * Provides methods for accessing MifareUltralight tag. 627 * 628 * @typedef MifareUltralightTag 629 * @syscap SystemCapability.Communication.NFC.Tag 630 * @since 9 631 */ 632export interface MifareUltralightTag extends TagSession { 633 /** 634 * Reads 4 pages, total is 16 bytes. Page size is 4 bytes. 635 * 636 * @permission ohos.permission.NFC_TAG 637 * @param { number } pageIndex - The index of page to read. 638 * @returns { Promise<number[]> } Returns 4 pages data. 639 * @throws { BusinessError } 201 - Permission denied. 640 * @throws { BusinessError } 401 - The parameter check failed. 641 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 642 * @syscap SystemCapability.Communication.NFC.Tag 643 * @since 9 644 */ 645 readMultiplePages(pageIndex: number): Promise<number[]>; 646 647 /** 648 * Reads 4 pages, total is 16 bytes. Page size is 4 bytes. 649 * 650 * @permission ohos.permission.NFC_TAG 651 * @param { number } pageIndex - The index of page to read. 652 * @param { AsyncCallback<number[]> } callback The callback. 653 * @throws { BusinessError } 201 - Permission denied. 654 * @throws { BusinessError } 401 - The parameter check failed. 655 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 656 * @syscap SystemCapability.Communication.NFC.Tag 657 * @since 9 658 */ 659 readMultiplePages(pageIndex: number, callback: AsyncCallback<number[]>): void; 660 661 /** 662 * Writes a page, total 4 bytes. 663 * 664 * @permission ohos.permission.NFC_TAG 665 * @param { number } pageIndex - The index of page to write. 666 * @param { number[] } data - The page data to write. 667 * @returns { Promise<void> } The void 668 * @throws { BusinessError } 201 - Permission denied. 669 * @throws { BusinessError } 401 - The parameter check failed. 670 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 671 * @syscap SystemCapability.Communication.NFC.Tag 672 * @since 9 673 */ 674 writeSinglePage(pageIndex: number, data: number[]): Promise<void>; 675 676 /** 677 * Writes a page, total 4 bytes. 678 * 679 * @permission ohos.permission.NFC_TAG 680 * @param { number } pageIndex - The index of page to write. 681 * @param { number[] } data - The page data to write. 682 * @param { AsyncCallback<void> } callback The callback. 683 * @throws { BusinessError } 201 - Permission denied. 684 * @throws { BusinessError } 401 - The parameter check failed. 685 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 686 * @syscap SystemCapability.Communication.NFC.Tag 687 * @since 9 688 */ 689 writeSinglePage(pageIndex: number, data: number[], callback: AsyncCallback<void>): void; 690 691 /** 692 * Gets the type of the MifareUltralight tag. 693 * 694 * @returns { tag.MifareUltralightType } Returns the type of MifareUltralight tag. 695 * @syscap SystemCapability.Communication.NFC.Tag 696 * @since 9 697 */ 698 getType(): tag.MifareUltralightType; 699} 700 701/** 702 * Provides methods for accessing NdefFormatable tag. 703 * 704 * @typedef NdefFormatableTag 705 * @syscap SystemCapability.Communication.NFC.Tag 706 * @since 9 707 */ 708export interface NdefFormatableTag extends TagSession { 709 /** 710 * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag. 711 * 712 * @permission ohos.permission.NFC_TAG 713 * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag. 714 * @returns { Promise<void> } The void 715 * @throws { BusinessError } 201 - Permission denied. 716 * @throws { BusinessError } 401 - The parameter check failed. 717 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 718 * @syscap SystemCapability.Communication.NFC.Tag 719 * @since 9 720 */ 721 format(message: NdefMessage): Promise<void>; 722 723 /** 724 * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag. 725 * 726 * @permission ohos.permission.NFC_TAG 727 * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag. 728 * @param { AsyncCallback<void> } callback The callback. 729 * @throws { BusinessError } 201 - Permission denied. 730 * @throws { BusinessError } 401 - The parameter check failed. 731 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 732 * @syscap SystemCapability.Communication.NFC.Tag 733 * @since 9 734 */ 735 format(message: NdefMessage, callback: AsyncCallback<void>): void; 736 737 /** 738 * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag, then sets the tag readonly. 739 * 740 * @permission ohos.permission.NFC_TAG 741 * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag. 742 * @returns { Promise<void> } The void 743 * @throws { BusinessError } 201 - Permission denied. 744 * @throws { BusinessError } 401 - The parameter check failed. 745 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 746 * @syscap SystemCapability.Communication.NFC.Tag 747 * @since 9 748 */ 749 formatReadOnly(message: NdefMessage): Promise<void>; 750 751 /** 752 * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag, then sets the tag readonly. 753 * 754 * @permission ohos.permission.NFC_TAG 755 * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag. 756 * @param { AsyncCallback<void> } callback The callback. 757 * @throws { BusinessError } 201 - Permission denied. 758 * @throws { BusinessError } 401 - The parameter check failed. 759 * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. 760 * @syscap SystemCapability.Communication.NFC.Tag 761 * @since 9 762 */ 763 formatReadOnly(message: NdefMessage, callback: AsyncCallback<void>): void; 764}