提交 aa620b33 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 024b3de8
# Standard NFC Card Emulation
The cardEmulation module implements Near-Field Communication (NFC) card emulation.
The **cardEmulation** module implements Near-Field Communication (NFC) card emulation.
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
......@@ -19,7 +19,7 @@ isSupported(feature: number): boolean
Checks whether a certain type of card emulation is supported.
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -27,11 +27,11 @@ Checks whether a certain type of card emulation is supported.
| -------- | -------- |
| boolean | Returns **true** if the card emulation is supported; returns **false** otherwise.|
## HceService
## HceService<sup>8+</sup>
Implements Host-based Card Emulation (HCE). Before calling any API in **HceService**, you must use **new cardEmulation.HceService()** to create an **HceService** instance.
### startHCE
### startHCE<sup>8+</sup>
startHCE(aidList: string[]): boolean
......@@ -39,7 +39,7 @@ Starts HCE.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
......@@ -47,7 +47,7 @@ Starts HCE.
| ------- | -------- | ---- | ----------------------- |
| aidList | string[] | Yes | Application ID (AID) list to be registered for card emulation.|
### stopHCE
### stopHCE<sup>8+</sup>
stopHCE(): boolean
......@@ -55,9 +55,9 @@ Stops HCE.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
### on
### on<sup>8+</sup>
on(type: "hceCmd", callback: AsyncCallback<number[]>): void;
......@@ -65,7 +65,7 @@ Subscribes to messages from the peer device after **startHCE()**.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
......@@ -74,7 +74,7 @@ Subscribes to messages from the peer device after **startHCE()**.
| type | string | Yes | Event type to subscribe to. The value is **hceCmd**. |
| callback | AsyncCallback<number[]> | Yes | Callback invoked to return the subscribed event. The input parameter is a data array that complies with the Application Protocol Data Unit (APDU).|
### sendResponse
### sendResponse<sup>8+</sup>
sendResponse(responseApdu: number[]): void;
......@@ -82,7 +82,7 @@ Sends a response to the peer device.
**Required permissions**: ohos.permission.NFC_CARD_EMULATION
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Parameters**
......
# Active Tag
The **connectedTag** module provides methods for using active tags. You can use the APIs provided by this module to initialize the active tag chip and read and write active tags.
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
......@@ -22,9 +24,9 @@ Initializes the active tag chip.
**System capability**: SystemCapability.Communication.ConnectedTag
- Return value
| **Type** | **Description** |
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the initialization is successful; returns **false** otherwise. |
| boolean | Returns **true** if the initialization is successful; returns **false** otherwise.|
## connectedTag.uninit
......@@ -38,9 +40,9 @@ Uninitializes the active tag resources.
**System capability**: SystemCapability.Communication.ConnectedTag
- Return value
| **Type** | **Description** |
| **Type**| **Description**|
| -------- | -------- |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise. |
| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
## connectedTag.readNdefTag
......@@ -54,9 +56,9 @@ Reads the content of this active tag. This method uses a promise to return the r
**System capability**: SystemCapability.Communication.ConnectedTag
- Return value
| **Type** | **Description** |
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the content of the active tag. |
| Promise&lt;string&gt; | Promise used to return the content of the active tag.|
- Example
```
......@@ -78,9 +80,9 @@ Reads the content of this active tag. This method uses an asynchronous callback
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name** | **Type** | **Mandatory** | **Description** |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the active tag content obtained. |
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example
```
......@@ -102,14 +104,14 @@ Writes data to this active tag. This method uses a promise to return the result.
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name** | **Type** | **Mandatory** | **Description** |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | string | Yes | Data to write. The maximum length is 1024 bytes. |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
- Return value
| **Type** | **Description** |
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. This method returns no value. |
| Promise&lt;void&gt; | Promise used to return the result. This method returns no value.|
- Example
```
......@@ -127,7 +129,7 @@ Writes data to this active tag. This method uses a promise to return the result.
## connectedTag.writeNdefTag
writeNdefTag(data: string, callback: AsyncCallback&lt;string&gt;): void
writeNdefTag(data: string, callback: AsyncCallback&lt;void&gt;): void
Writes data to this active tag. This method uses an asynchronous callback to return the result.
......@@ -136,10 +138,10 @@ Writes data to this active tag. This method uses an asynchronous callback to ret
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name** | **Type** | **Mandatory** | **Description** |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| data | string | Yes | Data to write. The maximum length is 1024 bytes. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback invoked to return the operation result. |
| data | string | Yes| Data to write. The maximum length is 1024 bytes.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback invoked to return the active tag content obtained.|
- Example
```
......@@ -168,16 +170,16 @@ Registers the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name** | **Type** | **Mandatory** | **Description** |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes | Event type. The value is **notify**. |
| callback | Callback&lt;number&gt; | Yes | Callback invoked to return the field strength state. |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | Yes| Callback invoked to return the field strength state.|
- Enumerates the field strength states.
| **Value** | **Description** |
| **Value**| **Description**|
| -------- | -------- |
| 0 | Field off. |
| 1 | Field on. |
| 0 | Field off.|
| 1 | Field on.|
## connectedTag.off('notify')
......@@ -191,10 +193,10 @@ Unregisters the NFC field strength state events.
**System capability**: SystemCapability.Communication.ConnectedTag
- Parameters
| **Name** | **Type** | **Mandatory** | **Description** |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| type | string | Yes | Event type. The value is **notify**. |
| callback | Callback&lt;number&gt; | No | Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered. |
| type | string | Yes| Event type. The value is **notify**.|
| callback | Callback&lt;number&gt; | No| Callback used to return the field strength state. If this parameter is not specified, all callbacks associated with the specified event will be unregistered.|
- Example
```
......@@ -206,10 +208,10 @@ Unregisters the NFC field strength state events.
console.info("nfc rf receive state: " + result);
}
// Register event notification
// Register event notification.
connectedTag.on(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
// Unregister event notification
// Unregister event notification.
connectedTag.off(NFC_RF_NOTIFY, recvNfcRfNotifyFunc);
```
......@@ -217,7 +219,9 @@ Unregisters the NFC field strength state events.
Enumerates the NFC states.
| Name | Default Value | Description |
| -------- | -------- | -------- |
| NFC_RF_LEAVE | 0 | Field off. |
| NFC_RF_ENTER | 1 | Field on. |
**System capability**: SystemCapability.Communication.ConnectedTag
| Name| Default Value| Description|
| -------- | -------- | -------- |
| NFC_RF_LEAVE | 0 | Field on.|
| NFC_RF_ENTER | 1 | Field on.|
# Standard NFC
Implements Near-Field Communication (NFC).
The **nfcController** module implements Near-Field Communication (NFC).
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
......@@ -19,6 +19,8 @@ isNfcAvailable(): boolean
Checks whether NFC is available.
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description**|
......@@ -34,7 +36,7 @@ Opens NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -50,7 +52,7 @@ Closes NFC.
**Required permissions**: ohos.permission.MANAGE_SECURE_SETTINGS
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -64,7 +66,7 @@ isNfcOpen(): boolean
Checks whether NFC is open.
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -78,7 +80,7 @@ getNfcState(): NfcState
Obtains the NFC state.
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -92,7 +94,7 @@ on(type: "nfcStateChange", callback: Callback&lt;NfcState&gt;): void
Subscribes to NFC state changes.
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Parameter**
......@@ -109,7 +111,7 @@ off(type: "nfcStateChange", callback?: Callback&lt;NfcState&gt;): void
Unsubscribes from the NFC state changes.
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Parameter**
......@@ -140,6 +142,8 @@ Unsubscribes from the NFC state changes.
Enumerates the NFC states.
**System capability**: SystemCapability.Communication.NFC.Core
| Name| Default Value| Description|
| -------- | -------- | -------- |
| STATE_OFF | 1 | Off|
......
# Standard NFC Tag
Manages Near-Field Communication (NFC) tags.
The **nfcTag** module provides methods for managing Near-Field Communication (NFC) tags.
> **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## **Modules to Import**
```
```js
import tag from '@ohos.nfc.tag';
```
## tag.getNfcATag
getNfcATag(tagInfo: TagInfo): NfcATag
getNfcATag(tagInfo: [TagInfo](#taginfo9)): [NfcATag](js-apis-nfctech.md#nfcatag)
Obtains an **NfcATag** object, which allows access to the tags that use the NFC-A technology.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description**|
| -------- | -------- |
| NfcATag | **NfcATag** object obtained.|
| [NfcATag](js-apis-nfctech.md#nfcatag) | **NfcATag** object obtained.|
## tag.getNfcBTag
getNfcBTag(tagInfo: TagInfo): NfcBTag
getNfcBTag(tagInfo: [TagInfo](#taginfo9)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-B technology.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| NfcBTag | **NfcBTag** object obtained.|
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | **NfcBTag** object obtained.|
## tag.getNfcFTag
getNfcFTag(tagInfo: TagInfo): NfcFTag
getNfcFTag(tagInfo: [TagInfo](#taginfo9)): [NfcFTag](js-apis-nfctech.md#nfcftag)
Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-F technology.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| NfcFTag | **NfcFTag** object obtained.|
| [NfcFTag](js-apis-nfctech.md#nfcftag) | **NfcFTag** object obtained.|
## tag.getNfcVTag
getNfcVTag(tagInfo: TagInfo): NfcVTag
getNfcVTag(tagInfo: [TagInfo](#taginfo9)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-V technology.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| -------- | ---------------- |
| NfcVTag | **NfcVTag** object obtained.|
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | **NfcVTag** object obtained.|
## tag.getIsoDepTag<sup>9+</sup>
getIsoDepTag(tagInfo: [TagInfo](#taginfo9)): [IsoDepTag](js-apis-nfctech.md#isodeptag9 )
Obtains an **IsoDepTag** object, which allows access to the tags that use the ISO-DEP technology.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| ---------- | ------------------|
| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | **IsoDepTag** object obtained.|
## tag.getNdefTag<sup>9+</sup>
getNdefTag(tagInfo: [TagInfo](#taginfo9)): [NdefTag](js-apis-nfctech.md#ndeftag9)
Obtains an **NdefTag** object, which allows access to the tags in the NFC Data Exchange Format (NDEF).
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| ---------| -------------- |
| [NdefTag](js-apis-nfctech.md#ndeftag9) | **NdefTag** object obtained.|
## tag.getMifareClassicTag<sup>9+</sup>
getMifareClassicTag(tagInfo: [TagInfo](#taginfo9)): [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9)
Obtains a **MifareClassicTag** object, which allows access to the tags that use MIFARE Classic.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| ----------------- | ------------------------|
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | **MifareClassicTag** object obtained.|
## tag.getMifareUltralightTag<sup>9+</sup>
getMifareUltralightTag(tagInfo: [TagInfo](#taginfo9)): [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9)
Obtains a **MifareUltralightTag** object, which allows access to the tags that use MIFARE Ultralight.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| -------------------- | ---------------------------|
| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | **MifareUltralightTag** object obtained.|
## tag.getNdefFormatableTag<sup>9+</sup>
getNdefFormatableTag(tagInfo: [TagInfo](#taginfo9)): [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag9)
Obtains an **NdefFormatableTag** object, which allows access to the tags that are NDEF formattable.
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
| **Type**| **Description** |
| ------------------ | --------------------------|
| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | **NdefFormatableTag** object obtained.|
## TagInfo<sup>9+</sup>
Represents the NFC tag information.
| **Name**| **Type**| **Description**|
| -------- | -------- | -------- |
| uid | string | UID of the tag.|
| technology | number[] | Technology supported by the tag.|
| extrasData | PacMap[] | Additional information about the tag.|
| tagRfDiscId | number | RF discovery ID of the tag.|
| remoteTagService | rpc.RemoteObject | RPC remote object of the tag service.|
| supportedProfiles | number[] | Profiles supported by the tag.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册