• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
191/**
192 * Provides methods for Message of NDEF.
193 *
194 * @typedef NdefMessage
195 * @syscap SystemCapability.Communication.NFC.Tag
196 * @since 9
197 */
198export interface NdefMessage {
199  /**
200   * Obtains all records of an NDEF message.
201   *
202   * @returns { tag.NdefRecord[] } Records the list of NDEF records.
203   * @syscap SystemCapability.Communication.NFC.Tag
204   * @since 9
205   */
206  getNdefRecords(): tag.NdefRecord[];
207}
208
209/**
210 * Provides methods for accessing NDEF tag.
211 *
212 * @typedef NdefTag
213 * @syscap SystemCapability.Communication.NFC.Tag
214 * @since 9
215 */
216export interface NdefTag extends TagSession {
217  /**
218   * Gets the type of NDEF tag.
219   *
220   * @returns { tag.NfcForumType } The type of NDEF tag.
221   * @syscap SystemCapability.Communication.NFC.Tag
222   * @since 9
223   */
224  getNdefTagType(): tag.NfcForumType;
225
226  /**
227   * Gets the NDEF message that was read from NDEF tag when tag discovery.
228   *
229   * @returns { NdefMessage } The instance of NdefMessage.
230   * @syscap SystemCapability.Communication.NFC.Tag
231   * @since 9
232   */
233  getNdefMessage(): NdefMessage;
234
235  /**
236   * Checks if NDEF tag is writable.
237   *
238   * @returns { boolean } Returns true if the tag is writable, otherwise returns false.
239   * @syscap SystemCapability.Communication.NFC.Tag
240   * @since 9
241   */
242  isNdefWritable(): boolean;
243
244  /**
245   * Reads NDEF message on this tag.
246   *
247   * @permission ohos.permission.NFC_TAG
248   * @returns { Promise<NdefMessage> } The NDEF message in tag.
249   * @throws { BusinessError } 201 - Permission denied.
250   * @throws { BusinessError } 401 - The parameter check failed.
251   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
252   * @syscap SystemCapability.Communication.NFC.Tag
253   * @since 9
254   */
255  readNdef(): Promise<NdefMessage>;
256
257  /**
258   * Reads NDEF message on this tag.
259   *
260   * @permission ohos.permission.NFC_TAG
261   * @param { AsyncCallback<NdefMessage> } callback The callback.
262   * @throws { BusinessError } 201 - Permission denied.
263   * @throws { BusinessError } 401 - The parameter check failed.
264   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
265   * @syscap SystemCapability.Communication.NFC.Tag
266   * @since 9
267   */
268  readNdef(callback: AsyncCallback<NdefMessage>): void;
269
270  /**
271   * Writes NDEF message into this tag.
272   *
273   * @permission ohos.permission.NFC_TAG
274   * @param { NdefMessage } msg - The NDEF message to be written.
275   * @returns { Promise<void> } The void
276   * @throws { BusinessError } 201 - Permission denied.
277   * @throws { BusinessError } 401 - The parameter check failed.
278   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
279   * @syscap SystemCapability.Communication.NFC.Tag
280   * @since 9
281   */
282  writeNdef(msg: NdefMessage): Promise<void>;
283
284  /**
285   * Writes NDEF message into this tag.
286   *
287   * @permission ohos.permission.NFC_TAG
288   * @param { NdefMessage } msg - The NDEF message to be written.
289   * @param { AsyncCallback<void> } callback The callback.
290   * @throws { BusinessError } 201 - Permission denied.
291   * @throws { BusinessError } 401 - The parameter check failed.
292   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
293   * @syscap SystemCapability.Communication.NFC.Tag
294   * @since 9
295   */
296  writeNdef(msg: NdefMessage, callback: AsyncCallback<void>): void;
297
298  /**
299   * Checks NDEF tag can be set read-only.
300   *
301   * @permission ohos.permission.NFC_TAG
302   * @returns { boolean } Returns true if the tag can be set readonly, otherwise returns false.
303   * @throws { BusinessError } 201 - Permission denied.
304   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
305   * @syscap SystemCapability.Communication.NFC.Tag
306   * @since 9
307   */
308  canSetReadOnly(): boolean;
309
310  /**
311   * Sets the NDEF tag read-only.
312   *
313   * @permission ohos.permission.NFC_TAG
314   * @returns { Promise<void> } The void
315   * @throws { BusinessError } 201 - Permission denied.
316   * @throws { BusinessError } 401 - The parameter check failed.
317   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
318   * @syscap SystemCapability.Communication.NFC.Tag
319   * @since 9
320   */
321  setReadOnly(): Promise<void>;
322
323  /**
324   * Sets the NDEF tag read-only.
325   *
326   * @permission ohos.permission.NFC_TAG
327   * @param { AsyncCallback<void> } callback The callback.
328   * @throws { BusinessError } 201 - Permission denied.
329   * @throws { BusinessError } 401 - The parameter check failed.
330   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
331   * @syscap SystemCapability.Communication.NFC.Tag
332   * @since 9
333   */
334  setReadOnly(callback: AsyncCallback<void>): void;
335
336  /**
337   * Converts the NFC forum type into string defined in NFC forum.
338   *
339   * @param { tag.NfcForumType } type - NFC forum type of NDEF tag.
340   * @returns { string } The NFC forum string type.
341   * @throws { BusinessError } 401 - The parameter check failed.
342   * @syscap SystemCapability.Communication.NFC.Tag
343   * @since 9
344   */
345  getNdefTagTypeString(type: tag.NfcForumType): string;
346}
347
348/**
349 * Provides methods for accessing MifareClassic tag.
350 *
351 * @typedef MifareClassicTag
352 * @syscap SystemCapability.Communication.NFC.Tag
353 * @since 9
354 */
355export interface MifareClassicTag extends TagSession {
356  /**
357   * Authenticates a sector with the key.Only successful authentication sector can be operated.
358   *
359   * @permission ohos.permission.NFC_TAG
360   * @param { number } sectorIndex - Index of sector to authenticate.
361   * @param { number[] } key - The key(6-bytes) to authenticate.
362   * @param { boolean } isKeyA - KeyA flag. true means KeyA, otherwise KeyB.
363   * @returns { Promise<void> } The void
364   * @throws { BusinessError } 201 - Permission denied.
365   * @throws { BusinessError } 401 - The parameter check failed.
366   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
367   * @syscap SystemCapability.Communication.NFC.Tag
368   * @since 9
369   */
370  authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise<void>;
371
372  /**
373   * Authenticates a sector with the key.Only successful authentication sector can be operated.
374   *
375   * @permission ohos.permission.NFC_TAG
376   * @param { number } sectorIndex - Index of sector to authenticate.
377   * @param { number[] } key - The key(6-bytes) to authenticate.
378   * @param { boolean } isKeyA - KeyA flag. true means KeyA, otherwise KeyB.
379   * @param { AsyncCallback<void> } callback The callback.
380   * @throws { BusinessError } 201 - Permission denied.
381   * @throws { BusinessError } 401 - The parameter check failed.
382   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
383   * @syscap SystemCapability.Communication.NFC.Tag
384   * @since 9
385   */
386  authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback<void>): void;
387
388  /**
389   * Reads a block, one block size is 16 bytes.
390   *
391   * @permission ohos.permission.NFC_TAG
392   * @param { number } blockIndex - The index of block to read.
393   * @returns { Promise<number[]> } Returns the block data.
394   * @throws { BusinessError } 201 - Permission denied.
395   * @throws { BusinessError } 401 - The parameter check failed.
396   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
397   * @syscap SystemCapability.Communication.NFC.Tag
398   * @since 9
399   */
400  readSingleBlock(blockIndex: number): Promise<number[]>;
401
402  /**
403   * Reads a block, one block size is 16 bytes.
404   *
405   * @permission ohos.permission.NFC_TAG
406   * @param { number } blockIndex - The index of block to read.
407   * @param { AsyncCallback<number[]> } callback The callback.
408   * @throws { BusinessError } 201 - Permission denied.
409   * @throws { BusinessError } 401 - The parameter check failed.
410   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
411   * @syscap SystemCapability.Communication.NFC.Tag
412   * @since 9
413   */
414  readSingleBlock(blockIndex: number, callback: AsyncCallback<number[]>): void;
415
416  /**
417   * Writes a block, one block size is 16 bytes.
418   *
419   * @permission ohos.permission.NFC_TAG
420   * @param { number } blockIndex - The index of block to write.
421   * @param { number[] } data - The block data to write.
422   * @returns { Promise<void> } The void
423   * @throws { BusinessError } 201 - Permission denied.
424   * @throws { BusinessError } 401 - The parameter check failed.
425   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
426   * @syscap SystemCapability.Communication.NFC.Tag
427   * @since 9
428   */
429  writeSingleBlock(blockIndex: number, data: number[]): Promise<void>;
430
431  /**
432   * Writes a block, one block size is 16 bytes.
433   *
434   * @permission ohos.permission.NFC_TAG
435   * @param { number } blockIndex - The index of block to write.
436   * @param { number[] } data - The block data to write.
437   * @param { AsyncCallback<void> } callback The callback.
438   * @throws { BusinessError } 201 - Permission denied.
439   * @throws { BusinessError } 401 - The parameter check failed.
440   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
441   * @syscap SystemCapability.Communication.NFC.Tag
442   * @since 9
443   */
444  writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback<void>): void;
445
446  /**
447   * Increments the contents of a block, and stores the result in the internal transfer buffer.
448   *
449   * @permission ohos.permission.NFC_TAG
450   * @param { number } blockIndex - The index of block to increment.
451   * @param { number } value - The value to increment, none-negative.
452   * @returns { Promise<void> } The void
453   * @throws { BusinessError } 201 - Permission denied.
454   * @throws { BusinessError } 401 - The parameter check failed.
455   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
456   * @syscap SystemCapability.Communication.NFC.Tag
457   * @since 9
458   */
459  incrementBlock(blockIndex: number, value: number): Promise<void>;
460
461  /**
462   * Increments the contents of a block, and stores the result in the internal transfer buffer.
463   *
464   * @permission ohos.permission.NFC_TAG
465   * @param { number } blockIndex - The index of block to increment.
466   * @param { number } value - The value to increment, none-negative.
467   * @param { AsyncCallback<void> } callback The callback.
468   * @throws { BusinessError } 201 - Permission denied.
469   * @throws { BusinessError } 401 - The parameter check failed.
470   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
471   * @syscap SystemCapability.Communication.NFC.Tag
472   * @since 9
473   */
474  incrementBlock(blockIndex: number, value: number, callback: AsyncCallback<void>): void;
475
476  /**
477   * Decreases the contents of a block, and stores the result in the internal transfer buffer.
478   *
479   * @permission ohos.permission.NFC_TAG
480   * @param { number } blockIndex - The index of block to decrease.
481   * @param { number } value - The value to decrease, none-negative.
482   * @returns { Promise<void> } The void
483   * @throws { BusinessError } 201 - Permission denied.
484   * @throws { BusinessError } 401 - The parameter check failed.
485   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
486   * @syscap SystemCapability.Communication.NFC.Tag
487   * @since 9
488   */
489  decrementBlock(blockIndex: number, value: number): Promise<void>;
490
491  /**
492   * Decreases the contents of a block, and stores the result in the internal transfer buffer.
493   *
494   * @permission ohos.permission.NFC_TAG
495   * @param { number } blockIndex - The index of block to decrease.
496   * @param { number } value - The value to decrease, none-negative.
497   * @param { AsyncCallback<void> } callback The callback.
498   * @throws { BusinessError } 201 - Permission denied.
499   * @throws { BusinessError } 401 - The parameter check failed.
500   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
501   * @syscap SystemCapability.Communication.NFC.Tag
502   * @since 9
503   */
504  decrementBlock(blockIndex: number, value: number, callback: AsyncCallback<void>): void;
505
506  /**
507   * Writes the contents of the internal transfer buffer to a value block.
508   *
509   * @permission ohos.permission.NFC_TAG
510   * @param { number } blockIndex - The index of value block to be written.
511   * @returns { Promise<void> } The void
512   * @throws { BusinessError } 201 - Permission denied.
513   * @throws { BusinessError } 401 - The parameter check failed.
514   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
515   * @syscap SystemCapability.Communication.NFC.Tag
516   * @since 9
517   */
518  transferToBlock(blockIndex: number): Promise<void>;
519
520  /**
521   * Writes the contents of the internal transfer buffer to a value block.
522   *
523   * @permission ohos.permission.NFC_TAG
524   * @param { number } blockIndex - The index of value block to be written.
525   * @param { AsyncCallback<void> } callback The callback.
526   * @throws { BusinessError } 201 - Permission denied.
527   * @throws { BusinessError } 401 - The parameter check failed.
528   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
529   * @syscap SystemCapability.Communication.NFC.Tag
530   * @since 9
531   */
532  transferToBlock(blockIndex: number, callback: AsyncCallback<void>): void;
533
534  /**
535   * Moves the contents of a block into the internal transfer buffer.
536   *
537   * @permission ohos.permission.NFC_TAG
538   * @param { number } blockIndex - The index of value block to be moved from.
539   * @returns { Promise<void> } The void
540   * @throws { BusinessError } 201 - Permission denied.
541   * @throws { BusinessError } 401 - The parameter check failed.
542   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
543   * @syscap SystemCapability.Communication.NFC.Tag
544   * @since 9
545   */
546  restoreFromBlock(blockIndex: number): Promise<void>;
547
548  /**
549   * Moves the contents of a block into the internal transfer buffer.
550   *
551   * @permission ohos.permission.NFC_TAG
552   * @param { number } blockIndex - The index of value block to be moved from.
553   * @param { AsyncCallback<void> } callback The callback.
554   * @throws { BusinessError } 201 - Permission denied.
555   * @throws { BusinessError } 401 - The parameter check failed.
556   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
557   * @syscap SystemCapability.Communication.NFC.Tag
558   * @since 9
559   */
560  restoreFromBlock(blockIndex: number, callback: AsyncCallback<void>): void;
561
562  /**
563   * Gets the number of sectors in MifareClassic tag.
564   *
565   * @returns { number } Returns the number of sectors.
566   * @syscap SystemCapability.Communication.NFC.Tag
567   * @since 9
568   */
569  getSectorCount(): number;
570
571  /**
572   * Gets the number of blocks in the sector.
573   *
574   * @param { number } sectorIndex - The index of sector.
575   * @returns { number } Returns the number of blocks.
576   * @throws { BusinessError } 401 - The parameter check failed.
577   * @syscap SystemCapability.Communication.NFC.Tag
578   * @since 9
579   */
580  getBlockCountInSector(sectorIndex: number): number;
581
582  /**
583   * Gets the type of the MifareClassic tag.
584   *
585   * @returns { tag.MifareClassicType } Returns type of MifareClassic tag.
586   * @syscap SystemCapability.Communication.NFC.Tag
587   * @since 9
588   */
589  getType(): tag.MifareClassicType;
590
591  /**
592   * Gets size of the tag in bytes.
593   *
594   * @returns { number } Returns the size of the tag.
595   * @syscap SystemCapability.Communication.NFC.Tag
596   * @since 9
597   */
598  getTagSize(): number;
599
600  /**
601   * Checks if the tag is emulated or not.
602   *
603   * @returns { boolean } Returns true if tag is emulated, otherwise false.
604   * @syscap SystemCapability.Communication.NFC.Tag
605   * @since 9
606   */
607  isEmulatedTag(): boolean;
608
609  /**
610   * Gets the first block of the specific sector.
611   *
612   * @param { number } sectorIndex - The index of sector.
613   * @returns { number } Returns index of first block in the sector.
614   * @throws { BusinessError } 401 - The parameter check failed.
615   * @syscap SystemCapability.Communication.NFC.Tag
616   * @since 9
617   */
618  getBlockIndex(sectorIndex: number): number;
619
620  /**
621   * Gets the sector index, that the sector contains the specific block.
622   *
623   * @param { number } blockIndex - The index of block.
624   * @returns { number } Returns the sector index.
625   * @throws { BusinessError } 401 - The parameter check failed.
626   * @syscap SystemCapability.Communication.NFC.Tag
627   * @since 9
628   */
629  getSectorIndex(blockIndex: number): number;
630}
631
632/**
633 * Provides methods for accessing MifareUltralight tag.
634 *
635 * @typedef MifareUltralightTag
636 * @syscap SystemCapability.Communication.NFC.Tag
637 * @since 9
638 */
639export interface MifareUltralightTag extends TagSession {
640  /**
641   * Reads 4 pages, total is 16 bytes. Page size is 4 bytes.
642   *
643   * @permission ohos.permission.NFC_TAG
644   * @param { number } pageIndex - The index of page to read.
645   * @returns { Promise<number[]> } Returns 4 pages data.
646   * @throws { BusinessError } 201 - Permission denied.
647   * @throws { BusinessError } 401 - The parameter check failed.
648   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
649   * @syscap SystemCapability.Communication.NFC.Tag
650   * @since 9
651   */
652  readMultiplePages(pageIndex: number): Promise<number[]>;
653
654  /**
655   * Reads 4 pages, total is 16 bytes. Page size is 4 bytes.
656   *
657   * @permission ohos.permission.NFC_TAG
658   * @param { number } pageIndex - The index of page to read.
659   * @param { AsyncCallback<number[]> } callback The callback.
660   * @throws { BusinessError } 201 - Permission denied.
661   * @throws { BusinessError } 401 - The parameter check failed.
662   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
663   * @syscap SystemCapability.Communication.NFC.Tag
664   * @since 9
665   */
666  readMultiplePages(pageIndex: number, callback: AsyncCallback<number[]>): void;
667
668  /**
669   * Writes a page, total 4 bytes.
670   *
671   * @permission ohos.permission.NFC_TAG
672   * @param { number } pageIndex - The index of page to write.
673   * @param { number[] } data - The page data to write.
674   * @returns { Promise<void> } The void
675   * @throws { BusinessError } 201 - Permission denied.
676   * @throws { BusinessError } 401 - The parameter check failed.
677   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
678   * @syscap SystemCapability.Communication.NFC.Tag
679   * @since 9
680   */
681  writeSinglePage(pageIndex: number, data: number[]): Promise<void>;
682
683  /**
684   * Writes a page, total 4 bytes.
685   *
686   * @permission ohos.permission.NFC_TAG
687   * @param { number } pageIndex - The index of page to write.
688   * @param { number[] } data - The page data to write.
689   * @param { AsyncCallback<void> } callback The callback.
690   * @throws { BusinessError } 201 - Permission denied.
691   * @throws { BusinessError } 401 - The parameter check failed.
692   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
693   * @syscap SystemCapability.Communication.NFC.Tag
694   * @since 9
695   */
696  writeSinglePage(pageIndex: number, data: number[], callback: AsyncCallback<void>): void;
697
698  /**
699   * Gets the type of the MifareUltralight tag.
700   *
701   * @returns { tag.MifareUltralightType } Returns the type of MifareUltralight tag.
702   * @syscap SystemCapability.Communication.NFC.Tag
703   * @since 9
704   */
705  getType(): tag.MifareUltralightType;
706}
707
708/**
709 * Provides methods for accessing NdefFormatable tag.
710 *
711 * @typedef NdefFormatableTag
712 * @syscap SystemCapability.Communication.NFC.Tag
713 * @since 9
714 */
715export interface NdefFormatableTag extends TagSession {
716  /**
717   * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag.
718   *
719   * @permission ohos.permission.NFC_TAG
720   * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag.
721   * @returns { Promise<void> } The void
722   * @throws { BusinessError } 201 - Permission denied.
723   * @throws { BusinessError } 401 - The parameter check failed.
724   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
725   * @syscap SystemCapability.Communication.NFC.Tag
726   * @since 9
727   */
728  format(message: NdefMessage): Promise<void>;
729
730  /**
731   * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag.
732   *
733   * @permission ohos.permission.NFC_TAG
734   * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag.
735   * @param { AsyncCallback<void> } callback The callback.
736   * @throws { BusinessError } 201 - Permission denied.
737   * @throws { BusinessError } 401 - The parameter check failed.
738   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
739   * @syscap SystemCapability.Communication.NFC.Tag
740   * @since 9
741   */
742  format(message: NdefMessage, callback: AsyncCallback<void>): void;
743
744  /**
745   * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag, then sets the tag readonly.
746   *
747   * @permission ohos.permission.NFC_TAG
748   * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag.
749   * @returns { Promise<void> } The void
750   * @throws { BusinessError } 201 - Permission denied.
751   * @throws { BusinessError } 401 - The parameter check failed.
752   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
753   * @syscap SystemCapability.Communication.NFC.Tag
754   * @since 9
755   */
756  formatReadOnly(message: NdefMessage): Promise<void>;
757
758  /**
759   * Formats a tag as NDEF tag, writes NDEF message into the NDEF Tag, then sets the tag readonly.
760   *
761   * @permission ohos.permission.NFC_TAG
762   * @param { NdefMessage } message - NDEF message to write while format. It can be null, then only format the tag.
763   * @param { AsyncCallback<void> } callback The callback.
764   * @throws { BusinessError } 201 - Permission denied.
765   * @throws { BusinessError } 401 - The parameter check failed.
766   * @throws { BusinessError } 3100201 - Tag running state is abnormal in service.
767   * @syscap SystemCapability.Communication.NFC.Tag
768   * @since 9
769   */
770  formatReadOnly(message: NdefMessage, callback: AsyncCallback<void>): void;
771}