diff --git a/api/@ohos.nfc.tag.d.ts b/api/@ohos.nfc.tag.d.ts index 761c31f24ece98f41bf69d020cdd0f8cee7e66e1..20ac89240b326b0e8ddc0e072d06fd10a65241e4 100644 --- a/api/@ohos.nfc.tag.d.ts +++ b/api/@ohos.nfc.tag.d.ts @@ -56,18 +56,18 @@ declare namespace tag { /** Indicates an NDEF tag. */ const NDEF = 6; - /** Indicates a MifareClassic tag. */ - const MIFARE_CLASSIC = 8; - - /** Indicates a MifareUltralight tag. */ - const MIFARE_ULTRALIGHT = 9; - /** - * Indicates an NdefFormatable tag. + * Indicates an NDEF Formatable tag. * * @since 9 */ - const NDEF_FORMATABLE = 10; + const NDEF_FORMATABLE = 7; + + /** Indicates a MIFARE Classic tag. */ + const MIFARE_CLASSIC = 8; + + /** Indicates a MIFARE Ultralight tag. */ + const MIFARE_ULTRALIGHT = 9; /** * TNF types definitions, see NFCForum-TS-NDEF_1.0. @@ -253,7 +253,7 @@ declare namespace tag { * @param { TagInfo } tagInfo - Indicates the diapatched tag information. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ @@ -268,7 +268,7 @@ declare namespace tag { * @param { TagInfo } tagInfo - Indicates the diapatched tag information. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ @@ -277,13 +277,13 @@ declare namespace tag { /** * Obtains an {@link MifareClassicTag} object based on the tag information. * - * During tag reading, if the tag supports the MifareClassic technology, + * During tag reading, if the tag supports the MIFARE Classic technology, * an {@link MifareClassicTag} object will be created based on the tag information. * * @param { TagInfo } tagInfo - Indicates the diapatched tag information. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ @@ -292,13 +292,13 @@ declare namespace tag { /** * Obtains an {@link MifareUltralightTag} object based on the tag information. * - * During tag reading, if the tag supports the MifareUltralight technology, + * During tag reading, if the tag supports the MIFARE Ultralight technology, * an {@link MifareUltralightTag} object will be created based on the tag information. * * @param { TagInfo } tagInfo - Indicates the diapatched tag information. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ @@ -307,13 +307,13 @@ declare namespace tag { /** * Obtains an {@link NdefFormatableTag} object based on the tag information. * - * During tag reading, if the tag supports the NdefFormatable technology, + * During tag reading, if the tag supports the NDEF Formatable technology, * an {@link NdefFormatableTag} object will be created based on the tag information. * * @param { TagInfo } tagInfo - Indicates the diapatched tag information. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @syscap SystemCapability.Communication.NFC.Core * @since 9 */ @@ -408,6 +408,88 @@ declare namespace tag { payload: number[]; } + namespace ndef { + /** + * Creates an NDEF record with uri data. + * + * @param { string } uri - Uri data for new NDEF record. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeUriRecord(uri: string): NdefRecord; + + /** + * Creates an NDEF record with text data. + * + * @param { string } text - Text data for new an NDEF record. + * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeTextRecord(text: string, locale: string): NdefRecord; + + /** + * Creates an NDEF record with mime data. + * + * @param { string } mimeType type of mime data for new an NDEF record. + * @param { string } mimeData mime data for new an NDEF record. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeMimeRecord(mimeType: string, mimeData: number[]): NdefRecord; + + /** + * Creates an NDEF record with external data. + * + * @param { string } domainName - Domain name of issuing organization for the external data. + * @param { string } type - Domain specific type of data for the external data. + * @param { number[] } externalData - Data payload of an NDEF record. + * @return { NdefRecord } The instance of NdefRecord. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function makeExternalRecord(domainName: string, type: string, externalData: number[]): NdefRecord; + /** + * Creates an NDEF message with raw bytes. + * + * @param { number[] } data - The raw bytes to parse NDEF message. + * @return { NdefMessage } The instance of NdefMessage. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function createNdefMessage(data: number[]): NdefMessage; + + /** + * Creates an NDEF message with record list. + * + * @param { NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. + * @return { NdefMessage } The instance of NdefMessage. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function createNdefMessage(ndefRecords: NdefRecord[]): NdefMessage; + + /** + * Parses an NDEF message into raw bytes. + * + * @param { NdefMessage } ndefMessage - An NDEF message to parse. + * @return { number[] } Returns the raw bytes of an NDEF message. + * @throws { BusinessError } 401 - The parameter check failed. + * @syscap SystemCapability.Communication.NFC.Core + * @since 9 + */ + function messageToBytes(ndefMessage: NdefMessage): number[]; + } + export type NfcATag = _NfcATag export type NfcBTag = _NfcBTag export type NfcFTag = _NfcFTag diff --git a/api/tag/nfctech.d.ts b/api/tag/nfctech.d.ts index b7632d3029654b7366bb5d7a3b6cfee3a0eae02c..7fa6ba118aed306fcd06620cb47b1a9398c9ce2d 100644 --- a/api/tag/nfctech.d.ts +++ b/api/tag/nfctech.d.ts @@ -172,7 +172,7 @@ export interface IsoDepTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ isExtendedApduSupported(): Promise; @@ -187,60 +187,6 @@ export interface NdefMessage { * @since 9 */ getNdefRecords(): tag.NdefRecord[]; - - /** - * Creates an NDEF record with uri data. - * - * @param { string } uri - Uri data for new NDEF record. - * @return { tag.NdefRecord } The instance of NdefRecord. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - makeUriRecord(uri: string): tag.NdefRecord; - - /** - * Creates an NDEF record with text data. - * - * @param { string } text - Text data for new an NDEF record. - * @param { string } locale - Language code for the NDEF record. if locale is null, use default locale. - * @return { tag.NdefRecord } The instance of NdefRecord. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - makeTextRecord(text: string, locale: string): tag.NdefRecord; - - /** - * Creates an NDEF record with mime data. - * - * @param { string } mimeType type of mime data for new an NDEF record. - * @param { string } mimeData mime data for new an NDEF record. - * @return { tag.NdefRecord } The instance of NdefRecord. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - makeMimeRecord(mimeType: string, mimeData: number[]): tag.NdefRecord; - - /** - * Creates an NDEF record with external data. - * - * @param { string } domainName - Domain name of issuing organization for the external data. - * @param { string } serviceName - Domain specific type of data for the external data. - * @param { number[] } externalData - Data payload of an NDEF record. - * @return { tag.NdefRecord } The instance of NdefRecord. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - makeExternalRecord(domainName: string, serviceName: string, externalData: number[]): tag.NdefRecord; - - /** - * Parses an NDEF message into raw bytes. - * - * @param { NdefMessage } ndefMessage - An NDEF message to parse. - * @return { number[] } Returns the raw bytes of an NDEF message. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - messageToBytes(ndefMessage: NdefMessage): number[]; } /** @@ -250,26 +196,6 @@ export interface NdefMessage { * @syscap SystemCapability.Communication.NFC.Core */ export interface NdefTag extends TagSession { - /** - * Creates an NDEF message with raw bytes. - * - * @param { number[] } data - The raw bytes to parse NDEF message. - * @return { NdefMessage } The instance of NdefMessage. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - createNdefMessage(data: number[]): NdefMessage; - - /** - * Creates an NDEF message with record list. - * - * @param { tag.NdefRecord[] } ndefRecords - The NDEF records to parse NDEF message. - * @return { NdefMessage } The instance of NdefMessage. - * @throws { BusinessError } 401 - The parameter check failed. - * @since 9 - */ - createNdefMessage(ndefRecords: tag.NdefRecord[]): NdefMessage; - /** * Gets the type of NDEF tag. * @@ -301,7 +227,7 @@ export interface NdefTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ readNdef(): Promise; @@ -314,7 +240,7 @@ export interface NdefTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ writeNdef(msg: NdefMessage): Promise; @@ -326,7 +252,7 @@ export interface NdefTag extends TagSession { * @return { boolean } Returns true if the tag can be set readonly, otherwise returns false. * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ canSetReadOnly(): boolean; @@ -337,7 +263,7 @@ export interface NdefTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ setReadOnly(): Promise; @@ -370,7 +296,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise; @@ -384,7 +310,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ readSingleBlock(blockIndex: number): Promise; @@ -398,7 +324,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ writeSingleBlock(blockIndex: number, data: number[]): Promise; @@ -412,7 +338,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ incrementBlock(blockIndex: number, value: number): Promise; @@ -426,7 +352,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ decrementBlock(blockIndex: number, value: number): Promise; @@ -439,7 +365,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ transferToBlock(blockIndex: number): Promise; @@ -452,7 +378,7 @@ export interface MifareClassicTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ restoreFromBlock(blockIndex: number): Promise; @@ -536,7 +462,7 @@ export interface MifareUltralightTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ readMultiplePages(pageIndex: number): Promise; @@ -550,7 +476,7 @@ export interface MifareUltralightTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ writeSinglePage(pageIndex: number, data: number[]): Promise; @@ -579,7 +505,7 @@ export interface NdefFormatableTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ format(message: NdefMessage): Promise; @@ -592,7 +518,7 @@ export interface NdefFormatableTag extends TagSession { * @permission ohos.permission.NFC_TAG * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 401 - The parameter check failed. - * @throws { BusinessError } 3100201 - Tag running state of service is abnormal. + * @throws { BusinessError } 3100201 - Tag running state is abnormal in service. * @since 9 */ formatReadOnly(message: NdefMessage): Promise;