提交 7425f5ae 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 cb2781b4
......@@ -17,16 +17,15 @@ import cardEmulation from '@ohos.nfc.cardEmulation';
Enumerates the NFC card emulation types.
> **NOTE**
>
> This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [hasHceCapability](#hashcecapability9).
**System capability**: SystemCapability.Communication.NFC.CardEmulation
| Name| Value| Description|
| -------- | -------- | -------- |
| HCE | 0 | HCE.|
| UICC | 1 | Subscriber identity module (SIM) card emulation.|
| ESE | 2 | embedded Secure Element (eSE) emulation.|
| Name | Value | Description |
| ---- | ---- | -------- |
| HCE | 0 | HCE.|
| UICC | 1 | Subscriber identity module (SIM) card emulation.|
| ESE | 2 | embedded Secure Element (eSE) emulation. |
## CardType<sup>9+</sup>
......@@ -34,10 +33,10 @@ Enumerates the types of services used by the card emulation application.
**System capability**: SystemCapability.Communication.NFC.CardEmulation
| Name| Value| Description|
| -------- | -------- | -------- |
| Name | Value | Description |
| ------- | --------- | ----------------- |
| PAYMENT | "payment" | Payment type.|
| OTHER | "other" | Other types.|
| OTHER | "other" | Other types.|
## isSupported
......@@ -46,21 +45,20 @@ isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported.
> **NOTE**
>
> This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [hasHceCapability](#hashcecapability9).
**System capability**: SystemCapability.Communication.NFC.CardEmulation
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| feature | number | Yes | Card emulation type. For details, see [FeatureType](#featuretype).|
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------------------------------------- |
| feature | number | Yes | Card emulation type. For details, see [FeatureType](#featuretype).|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| **Type** | **Description** |
| ------- | -------------------------------------- |
| boolean | Returns **true** if the card emulation type is supported; returns **false** otherwise.|
## hasHceCapability<sup>9+</sup>
......@@ -75,8 +73,8 @@ Checks whether HCE is supported.
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| **Type** | **Description** |
| ------- | -------------------------------- |
| boolean | Returns **true** if HCE is supported; returns **false** otherwise.|
## isDefaultService<sup>9+</sup>
......@@ -91,15 +89,15 @@ Checks whether an application is the default application of the specified servic
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | -------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes| Application description, which consists of the bundle name and component name.|
| type | [CardType](#cardtype9) | Yes| Card emulation service type.|
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | ----------------------- |
| elementName | [ElementName](js-apis-bundleManager-elementName.md#elementname) | Yes | Application description, which consists of the bundle name and component name.|
| type | [CardType](#cardtype9) | Yes | Card emulation service type. |
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| **Type** | **Description** |
| ------- | ------------------------------------ |
| boolean | Returns **true** if the application is the default payment application; returns **false** otherwise.|
**Example**
......@@ -110,13 +108,11 @@ import cardEmulation from '@ohos.nfc.cardEmulation';
var isHceSupported = cardEmulation.isSupported(cardEmulation.FeatureType.HCE);
if (!isHceSupported) {
console.log('this device is not supported for HCE, ignore it.');
return;
}
var hasHceCap = cardEmulation.hasHceCapability();
if (!hasHceCap) {
console.log('this device hasHceCapability false, ignore it.');
return;
}
var elementName = {
......
......@@ -28,6 +28,23 @@ Initializes the active tag chip.
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.initialize<sup>9+</sup>
initialize(): void
Initializes the active tag chip.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| -------- | -------- |
| 3200101 | Connected NFC tag running state is abnormal in service. |
## connectedTag.uninit
uninit(): boolean
......@@ -44,6 +61,23 @@ Uninitializes the active tag resources.
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.uninitialize<sup>9+</sup>
uninitialize(): void
Uninitializes the active tag resources.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| -------- | -------- |
| 3200101 | Connected NFC tag running state is abnormal in service. |
## connectedTag.readNdefTag
readNdefTag(): Promise&lt;string&gt;
......@@ -72,6 +106,41 @@ connectedTag.readNdefTag().then((data) => {
});
```
## connectedTag.read<sup>9+</sup>
read(): Promise&lt;number[]&gt;
Reads the content of this active tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;number[]&gt; | Promise used to return the content of the active tag.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| -------- | -------- |
| 3200101 | Connected NFC tag running state is abnormal in service. |
**Example**
```js
import connectedTag from '@ohos.connectedTag';
connectedTag.read().then((data) => {
console.log("connectedTag read Promise data = " + data);
}).catch((err)=> {
console.log("connectedTag read Promise err: " + err);
});
```
## connectedTag.readNdefTag
readNdefTag(callback: AsyncCallback&lt;string&gt;): void
......@@ -102,6 +171,43 @@ connectedTag.readNdefTag((err, data)=> {
});
```
## connectedTag.read<sup>9+</sup>
read(callback: AsyncCallback&lt;number[]&gt;): void
Reads the content of this active tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;number[]&gt; | Yes| Callback invoked to return the active tag content obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| -------- | -------- |
| 3200101 | Connected NFC tag running state is abnormal in service. |
**Example**
```js
import connectedTag from '@ohos.connectedTag';
connectedTag.read((err, data)=> {
if (err) {
console.log("connectedTag read AsyncCallback err: " + err);
} else {
console.log("connectedTag read AsyncCallback data: " + data);
}
});
```
## connectedTag.writeNdefTag
writeNdefTag(data: string): Promise&lt;void&gt;
......@@ -137,6 +243,48 @@ connectedTag.writeNdefTag(rawData).then(() => {
});
```
## connectedTag.write<sup>9+</sup>
write(data: number[]): Promise&lt;void&gt;
Writes data to this active tag. This API uses a promise to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | number[] | Yes| Data to be written to the active tag. The value is a hexadecimal number ranging from 0x00 to 0xFF.|
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;void&gt; | Promise that returns no value.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| -------- | -------- |
| 3200101 | Connected NFC tag running state is abnormal in service. |
**Example**
```js
import connectedTag from '@ohos.connectedTag';
var rawData = [0x01, 0x02, 0x03]; // change it tobe correct.
connectedTag.write(rawData).then(() => {
console.log("connectedTag write NdefTag Promise success.");
}).catch((err)=> {
console.log("connectedTag write NdefTag Promise err: " + err);
});
```
## connectedTag.writeNdefTag
writeNdefTag(data: string, callback: AsyncCallback&lt;void&gt;): void
......@@ -169,6 +317,45 @@ connectedTag.writeNdefTag(rawData, (err)=> {
});
```
## connectedTag.write<sup>9+</sup>
write(data: number[], callback: AsyncCallback&lt;void&gt;): void
Writes data to this active tag. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.ConnectedTag
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | number[] | Yes| Data to be written to the active tag. The value is a hexadecimal number ranging from 0x00 to 0xFF.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback invoked to return the active tag content obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| -------- | -------- |
| 3200101 | Connected NFC tag running state is abnormal in service. |
**Example**
```js
import connectedTag from '@ohos.connectedTag';
var rawData = [0x01, 0x02, 0x03]; // change it tobe correct.
connectedTag.write(rawData, (err)=> {
if (err) {
console.log("connectedTag write NdefTag AsyncCallback err: " + err);
} else {
console.log("connectedTag write NdefTag AsyncCallback success.");
}
});
```
## connectedTag.on('notify')
on(type: "notify", callback: Callback&lt;number&gt;): void
......
......@@ -176,7 +176,7 @@ Unsubscribes from the NFC state changes. The subscriber will not receive NFC sta
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes| Event type to unsubscribe from. The value is **nfcStateChange**.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank.|
| callback | Callback&lt;[NfcState](#nfcstate)&gt; | No| Callback for the NFC state changes. This parameter can be left blank. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
**Example**
......
......@@ -53,6 +53,7 @@ Before developing applications related to tag read and write, you must declare N
> - The **name** field under **metadata** is mandatory. It must be **tag-tech** and cannot be changed.
> - The **value** field under **metadata** is mandatory. It can be **NfcA**, **NfcB**, **NfcF**, **NfcV**, **IsoDep**, **Ndef**, **MifareClassic**, **MifareUL**, **NdefFormatable** or any of their combinations. Incorrect settings of this field will cause a parsing failure.
> - The **name** field under **requestPermissions** is mandatory. It must be **ohos.permission.NFC_TAG** and cannot be changed.
## **Modules to Import**
```js
......@@ -98,7 +99,7 @@ onCreate(want, launchParam) {
if (isNfcATag) {
var nfcA;
try {
nfcA = tag.getNfcATag(taginfo);
nfcA = tag.getNfcATag(tagInfo);
} catch (error) {
console.log("tag.getNfcATag caught error: " + error);
}
......@@ -109,7 +110,7 @@ onCreate(want, launchParam) {
if (isIsoDepTag) {
var isoDep;
try {
isoDep = tag.getIsoDep(taginfo);
isoDep = tag.getIsoDep(tagInfo);
} catch (error) {
console.log("tag.getIsoDep caught error: " + error);
}
......@@ -139,8 +140,8 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.|
## tag.getNfcA<sup>9+</sup>
......@@ -159,16 +160,16 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNfcBTag
......@@ -190,9 +191,9 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
## tag.getNfcB<sup>9+</sup>
......@@ -210,16 +211,16 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNfcFTag
......@@ -241,9 +242,9 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
## tag.getNfcF<sup>9+</sup>
......@@ -261,16 +262,16 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNfcVTag
......@@ -292,9 +293,9 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
## tag.getNfcV<sup>9+</sup>
......@@ -312,16 +313,16 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
| **Type** | **Description** |
| ------------------------------------- | ------------- |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getIsoDep<sup>9+</sup>
......@@ -334,22 +335,22 @@ Obtains an **IsoDepTag** object, which allows access to the tags that use the IS
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes| Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
| Name | Type | Mandatory | Description |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
**Return value**
| **Type**| **Description** |
| ---------- | ------------------|
| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** object obtained.|
| **Type** | **Description** |
| ---------------------------------------- | ----------------------------------- |
| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNdef<sup>9+</sup>
......@@ -362,27 +363,27 @@ Obtains an **NdefTag** object, which allows access to the tags in the NFC Data E
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
| Name | Type | Mandatory | Description |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
**Return value**
| **Type**| **Description** |
| ---------| -------------- |
| [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** object obtained.|
| **Type** | **Description** |
| -------------------------------------- | ------------------------------- |
| [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getMifareClassic<sup>9+</sup>
getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9)
getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag9)
Obtains a **MifareClassicTag** object, which allows access to the tags that use MIFARE Classic.
......@@ -390,22 +391,22 @@ Obtains a **MifareClassicTag** object, which allows access to the tags that use
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
| Name | Type | Mandatory | Description |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
**Return value**
| **Type**| **Description** |
| ----------------- | ------------------------|
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.|
| **Type** | **Description** |
| ---------------------------------------- | ---------------------------------------- |
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getMifareUltralight<sup>9+</sup>
......@@ -417,22 +418,22 @@ Obtains a **MifareUltralightTag** object, which allows access to the tags that u
**System capability**: SystemCapability.Communication.NFC.Tag
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**. |
| Name | Type | Mandatory | Description |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | Yes | Tag information including the technology type and related parameters, which are obtained from **tag.getTagInfo(want: Want)**.|
**Return value**
| **Type**| **Description** |
| -------------------- | ---------------------------|
| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** object obtained.|
| **Type** | **Description** |
| ---------------------------------------- | ---------------------------------------- |
| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNdefFormatable<sup>9+</sup>
......@@ -445,16 +446,16 @@ Obtains an **NdefFormatableTag** object, which allows access to the tags that ar
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** object obtained.|
| **Type** | **Description** |
| ---------------------------------------- | ---------------------------------------- |
| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** object obtained.|
**Error codes**
For details about the error codes, see [NFC Error Codes](../errorcodes/errorcode-nfc.md).
| ID| Error Message|
| ------- | -------|
| ID | Error Message |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getTagInfo<sup>9+</sup>
......@@ -467,14 +468,14 @@ Obtains **TagInfo** from **Want**, which is initialized by the NFC service and c
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| want | [Want](js-apis-app-ability-want.md#Want) | Yes | Data obtained from the parameters of the **onCreate** entry function when an ability is dispatched. |
| Name | Type | Mandatory | Description |
| ---- | ---------------------------------------- | ---- | --------------------------------- |
| want | [Want](js-apis-app-ability-want.md#Want) | Yes | Data obtained from the parameters of the **onCreate** entry function when an ability is dispatched.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| ------------------- | --------------------------- |
| [TagInfo](#taginfo) | **TagInfo** object obtained.|
......@@ -488,14 +489,14 @@ Creates an NDEF record based on the specified URI.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| uri | string | Yes| Data to write to the NDEF record.|
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | ---------------------- |
| uri | string | Yes | Data to write to the NDEF record.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| -------------------------- | ---------------------------------------- |
| [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.|
**Example**
......@@ -527,15 +528,15 @@ Creates an NDEF record based on the specified text data and encoding type.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| text | string | Yes | Text to write to the NDEF record.|
| locale | string | Yes | Encoding mode of the text.|
| Name | Type | Mandatory | Description |
| ------ | ------ | ---- | ------------------------ |
| text | string | Yes | Text to write to the NDEF record.|
| locale | string | Yes | Encoding mode of the text. |
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| -------------------------- | ---------------------------------------- |
| [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.|
**Example**
......@@ -569,15 +570,15 @@ Creates an NDEF record based on the specified MIME data and type.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| mimeType | string | Yes | MIME type that complies with RFC rules, for example, **text/plain** or **image/jpeg**.|
| mimeData | number[] | Yes | MIME data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| Name | Type | Mandatory | Description |
| -------- | -------- | ---- | ---------------------------------------- |
| mimeType | string | Yes | MIME type that complies with RFC rules, for example, **text/plain** or **image/jpeg**.|
| mimeData | number[] | Yes | MIME data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. |
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| -------------------------- | ---------------------------------------- |
| [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.|
**Example**
......@@ -609,16 +610,16 @@ Creates an NDEF record based on application-specific data.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| domainName | string | Yes | Bundle name of the application or domain name of the organization that releases the applications.|
| type | string | Yes | Type of the application data.|
| externalData | number[] | Yes | Application data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| Name | Type | Mandatory | Description |
| ------------ | -------- | ---- | ----------------------------------- |
| domainName | string | Yes | Bundle name of the application or domain name of the organization that releases the applications. |
| type | string | Yes | Type of the application data. |
| externalData | number[] | Yes | Application data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| -------------------------- | ---------------------------------------- |
| [NdefRecord](#ndefrecord9) | NDEF record created. For details, see *NFCForum-TS-NDEF_1.0*.|
**Example**
......@@ -652,14 +653,14 @@ Converts an NDEF message to bytes.
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | Yes | NDEF message to convert.|
| Name | Type | Mandatory | Description |
| ----------- | ---------------------------------------- | ---- | ----------- |
| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | Yes | NDEF message to convert.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| -------- | ---------------------------------------- |
| number[] | NDEF message in bytes, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
**Example**
......@@ -693,14 +694,14 @@ Creates an NDEF message from raw byte data. The data must comply with the NDEF r
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | number[] | Yes| Raw byte data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. The data must comply with the NDEF record format.|
| **Name**| **Type** | **Mandatory**| **Description** |
| ------- | -------- | ------ | ---------------------------------------- |
| data | number[] | Yes | Raw byte data, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. The data must comply with the NDEF record format.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| ---------------------------------------- | ---------------------------------------- |
| [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF message created. For details, see *NFCForum-TS-NDEF_1.0*.|
**Example**
......@@ -727,14 +728,14 @@ Creates an NDEF message from the NDEF records list.
**Parameters**
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | Yes| NDEF record list used to create the NDEF message. For details, see *NFCForum-TS-NDEF_1.0*.|
| **Name** | **Type** | **Mandatory**| **Description** |
| ----------- | ---------------------------------------- | ------ | ---------------------------------------- |
| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | Yes | NDEF record list used to create the NDEF message. For details, see *NFCForum-TS-NDEF_1.0*.|
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| **Type** | **Description** |
| ---------------------------------------- | ---------------------------------------- |
| [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF message created. For details, see *NFCForum-TS-NDEF_1.0*.|
**Example**
......@@ -762,67 +763,66 @@ Defines the **TagInfo** object, which provides information about the tag technol
**Required permissions**: ohos.permission.NFC_TAG
| **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- |
| uid<sup>9+</sup> | number[] | Yes| No| Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| technology<sup>9+</sup> | number[] | Yes| No| Supported technologies. Each number is a constant indicating the supported technology.|
| supportedProfiles | number[] | Yes| No| Supported profiles. This parameter is not supported since API version 9. Use [technology](#taginfo).|
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes| No| Extended attribute value of the tag technology.<br>**System API**: This is a system API.|
| tagRfDiscId<sup>9+</sup> | number | Yes| No| ID allocated when the tag is discovered.<br>**System API**: This is a system API.|
| remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes| No| Remote object of the NFC service process used for interface communication between the client and the service.<br>**System API**: This is a system API.|
| **Name** | **Type** | **Readable**| **Writable**| **Description** |
| ----------------------------- | ---------------------------------------- | ------ | ------ | ---------------------------------------- |
| uid<sup>9+</sup> | number[] | Yes | No | Tag unique identifier (UID), which consists of hexadecimal numbers ranging from **0x00** to **0xFF**. |
| technology<sup>9+</sup> | number[] | Yes | No | Supported technologies. Each number is a constant indicating the supported technology. |
| supportedProfiles | number[] | Yes | No | Supported profiles. This parameter is not supported since API version 9. Use [tag.TagInfo#technology](#tagtaginfo) instead.|
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | Yes | No | Extended attribute value of the tag technology.<br>**System API**: This is a system API. |
| tagRfDiscId<sup>9+</sup> | number | Yes | No | ID allocated when the tag is discovered.<br>**System API**: This is a system API. |
| remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | Yes | No | Remote object of the NFC service process used for interface communication between the client and the service.<br>**System API**: This is a system API.|
## NdefRecord<sup>9+</sup>
Defines an NDEF record. For details, see *NFCForum-TS-NDEF_1.0*.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Type**| **Readable**| **Writable**| **Description**|
| -------- | -------- | -------- | -------- | -------- |
| tnf | number | Yes| No| Type name field (TNF) of the NDEF record.|
| rtdType| number[] | Yes| No| Record type definition (RTD) of the NDEF record. It consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| id | number[] | Yes| No| NDEF record ID, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| payload | number[] | Yes| No| NDEF payload, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| **Name** | **Type** | **Readable**| **Writable**| **Description** |
| ------- | -------- | ------ | ------ | ---------------------------------------- |
| tnf | number | Yes | No | Type name field (TNF) of the NDEF record. |
| rtdType | number[] | Yes | No | Record type definition (RTD) of the NDEF record. It consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| id | number[] | Yes | No | NDEF record ID, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
| payload | number[] | Yes | No | NDEF payload, which consists of hexadecimal numbers ranging from **0x00** to **0xFF**.|
## Technology Type Definition
Enumerates the tag technology types.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| NFC_A | 1 | NFC-A (ISO 14443-3A).|
| **Name** | **Value**| **Description** |
| ---------------------------- | ----- | ------------------------ |
| NFC_A | 1 | NFC-A (ISO 14443-3A). |
| NFC_B | 2 | NFC-B (ISO 14443-3B).|
| ISO_DEP | 3 | ISO-DEP (ISO 14443-4).|
| NFC_F | 4 | NFC-F (JIS 6319-4).|
| NFC_V | 5 | NFC-V (ISO 15693).|
| NDEF | 6 | NDEF.|
| NDEF_FORMATABLE<sup>9+</sup> | 7 | NDEF formattable.|
| MIFARE_CLASSIC | 8 | MIFARE Classic.|
| MIFARE_ULTRALIGHT | 9 | MIFARE Ultralight.|
| ISO_DEP | 3 | ISO-DEP (ISO 14443-4).|
| NFC_F | 4 | NFC-F (JIS 6319-4). |
| NFC_V | 5 | NFC-V (ISO 15693). |
| NDEF | 6 | NDEF. |
| NDEF_FORMATABLE<sup>9+</sup> | 7 | NDEF formattable. |
| MIFARE_CLASSIC | 8 | MIFARE Classic. |
| MIFARE_ULTRALIGHT | 9 | MIFARE Ultralight. |
## TnfType<sup>9+</sup>
Enumerates the TNF types. For details, see *NFCForum-TS-NDEF_1.0*.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| TNF_EMPTY | 0x0 | Empty.|
| TNF_WELL_KNOWN | 0x1 | NFC Forum Well Known Type [NFC RTD].|
| TNF_MEDIA | 0x2 | Media-type as defined in RFC 2046 [RFC 2046].|
| TNF_ABSOLUTE_URI | 0x3 | Absolute URI as defined in RFC 3986 [RFC 3986].|
| TNF_EXT_APP | 0x4 | NFC Forum external type [NFC RTD].|
| TNF_UNKNOWN | 0x5 | Unknown.|
| TNF_UNCHANGED | 0x6 | Unchanged (see section 2.3.3 in *NFCForum-TS-NDEF_1.0*).|
| **Name** | **Value**| **Description** |
| ---------------- | ----- | ---------------------------------------- |
| TNF_EMPTY | 0x0 | Empty. |
| TNF_WELL_KNOWN | 0x1 | NFC Forum Well Known Type [NFC RTD]. |
| TNF_MEDIA | 0x2 | Media-type as defined in RFC 2046 [RFC 2046].|
| TNF_ABSOLUTE_URI | 0x3 | Absolute URI as defined in RFC 3986 [RFC 3986].|
| TNF_EXT_APP | 0x4 | NFC Forum external type [NFC RTD]. |
| TNF_UNKNOWN | 0x5 | Unknown. |
| TNF_UNCHANGED | 0x6 | Unchanged (see section 2.3.3 in *NFCForum-TS-NDEF_1.0*). |
## NDEF Record RTD
Enumerates the NDEF record types. For details about the RTD, see *NFCForum-TS-NDEF_1.0*.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| RTD_TEXT<sup>9+</sup> | [0x54] | NDEF record of the text type.|
| **Name** | **Value** | **Description** |
| --------------------- | ------ | ------------------ |
| RTD_TEXT<sup>9+</sup> | [0x54] | NDEF record of the text type. |
| RTD_URI<sup>9+</sup> | [0x55] | NDEF record of the URI type.|
## NfcForumType<sup>9+</sup>
......@@ -830,46 +830,47 @@ Enumerates the NFC Forum tag types.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| NFC_FORUM_TYPE_1 | 1 | NFC Forum tag type 1.|
| NFC_FORUM_TYPE_2 | 2 | NFC Forum tag type 2.|
| NFC_FORUM_TYPE_3 | 3 | NFC Forum tag type 3.|
| NFC_FORUM_TYPE_4 | 4 | NFC Forum tag type 4.|
| MIFARE_CLASSIC | 101 | MIFARE Classic.|
| **Name** | **Value**| **Description** |
| ---------------- | ----- | ----------------- |
| NFC_FORUM_TYPE_1 | 1 | NFC Forum tag type 1. |
| NFC_FORUM_TYPE_2 | 2 | NFC Forum tag type 2. |
| NFC_FORUM_TYPE_3 | 3 | NFC Forum tag type 3. |
| NFC_FORUM_TYPE_4 | 4 | NFC Forum tag type 4. |
| MIFARE_CLASSIC | 101 | MIFARE Classic.|
## MifareClassicType<sup>9+</sup>
Enumerates the MIFARE Classic tag types.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| TYPE_UNKNOWN | 0 | Unknown type.|
| TYPE_CLASSIC | 1 | MIFARE Classic.|
| TYPE_PLUS | 2 | MIFARE Plus.|
| TYPE_PRO | 3 | MIFARE Pro.|
| **Name** | **Value**| **Description** |
| ------------ | ----- | ----------------- |
| TYPE_UNKNOWN | 0 | Unknown type. |
| TYPE_CLASSIC | 1 | MIFARE Classic.|
| TYPE_PLUS | 2 | MIFARE Plus. |
| TYPE_PRO | 3 | MIFARE Pro. |
## MifareClassicSize<sup>9+</sup>
Enumerates the sizes of a MIFARE Classic tag.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks.|
| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.|
| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.|
| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.|
| **Name** | **Value**| **Description** |
| ------------ | ----- | ------------------ |
| MC_SIZE_MINI | 320 | Each tag has 5 sectors, and each sector has 4 blocks. |
| MC_SIZE_1K | 1024 | Each tag has 16 sectors, and each sector has 4 blocks.|
| MC_SIZE_2K | 2048 | Each tag has 32 sectors, and each sector has 4 blocks.|
| MC_SIZE_4K | 4096 | Each tag has 40 sectors, and each sector has 4 blocks.|
## MifareUltralightType<sup>9+</sup>
Enumerates the MIFARE Ultralight tag types.
**System capability**: SystemCapability.Communication.NFC.Tag
| **Name**| **Value**| **Description**|
| -------- | -------- | -------- |
| TYPE_UNKNOWN | 0 | Unknown type.|
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight.|
| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.|
| **Name** | **Value**| **Description** |
| ----------------- | ----- | ---------------------- |
| TYPE_UNKNOWN | 0 | Unknown type. |
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight. |
| TYPE_ULTRALIGHT_C | 2 | MIFARE Ultralight C.|
<!--no_check-->
\ No newline at end of file
......@@ -47,3 +47,21 @@ An error occurs when the NFC service executes the tag service logic.
3. Connect to the tag and then perform the read and write operations.
4. Touch and read the card again.
5. Exit the app and read the card again.
## 3200101
**Error Message**
Connected NFC tag running state is abnormal in service.
**Description**
An error occurs when the service logic of the active NFC tag is executed.
**Possible Causes**
1. The parameter values of the active NFC tag does not match the API called.
2. The active NFC tag chip does not respond within the specified time or returns an error state.
**Solution**
1. Check that the active NFC tag parameters match the API called.
2. Touch and read the card again.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册