From aa620b331ec78f01c7e1e4c3e81922c83616838f Mon Sep 17 00:00:00 2001 From: Annie_wang Date: Fri, 19 Aug 2022 09:32:22 +0800 Subject: [PATCH] update docs Signed-off-by: Annie_wang --- .../reference/apis/js-apis-cardEmulation.md | 24 ++-- .../reference/apis/js-apis-connectedTag.md | 90 +++++++------ .../reference/apis/js-apis-nfcController.md | 20 +-- .../reference/apis/js-apis-nfcTag.md | 127 +++++++++++++++--- 4 files changed, 181 insertions(+), 80 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-cardEmulation.md b/en/application-dev/reference/apis/js-apis-cardEmulation.md index 7c65ecbd61..9168a42e97 100644 --- a/en/application-dev/reference/apis/js-apis-cardEmulation.md +++ b/en/application-dev/reference/apis/js-apis-cardEmulation.md @@ -1,9 +1,9 @@ # 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**
-> 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 +## HceService8+ Implements Host-based Card Emulation (HCE). Before calling any API in **HceService**, you must use **new cardEmulation.HceService()** to create an **HceService** instance. -### startHCE +### startHCE8+ 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 +### stopHCE8+ 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 +### on8+ on(type: "hceCmd", callback: AsyncCallback): 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 | 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 +### sendResponse8+ 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** diff --git a/en/application-dev/reference/apis/js-apis-connectedTag.md b/en/application-dev/reference/apis/js-apis-connectedTag.md index f351fb3148..57cf8eadb5 100644 --- a/en/application-dev/reference/apis/js-apis-connectedTag.md +++ b/en/application-dev/reference/apis/js-apis-connectedTag.md @@ -1,5 +1,7 @@ # 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**
> 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** | - | -------- | -------- | - | boolean | Returns **true** if the initialization is successful; returns **false** otherwise. | + | **Type**| **Description**| + | -------- | -------- | + | 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** | - | -------- | -------- | - | boolean | Returns **true** if the operation is successful; returns **false** otherwise. | + | **Type**| **Description**| + | -------- | -------- | + | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| ## connectedTag.readNdefTag @@ -54,14 +56,14 @@ 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** | - | -------- | -------- | - | Promise<string> | Promise used to return the content of the active tag. | + | **Type**| **Description**| + | -------- | -------- | + | Promise<string> | Promise used to return the content of the active tag.| - Example ``` import connectedTag from '@ohos.connectedTag'; - + connectedTag.readNdefTag().then(result => { console.log("promise recv ndef response: " + result); }); @@ -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** | - | -------- | -------- | -------- | -------- | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the active tag content obtained. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | callback | AsyncCallback<string> | 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** | - | -------- | -------- | -------- | -------- | - | data | string | Yes | Data to write. The maximum length is 1024 bytes. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | data | string | Yes| Data to write. The maximum length is 1024 bytes.| - Return value - | **Type** | **Description** | - | -------- | -------- | - | Promise<void> | Promise used to return the result. This method returns no value. | + | **Type**| **Description**| + | -------- | -------- | + | Promise<void> | 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<string>): void +writeNdefTag(data: string, callback: AsyncCallback<void>): 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** | - | -------- | -------- | -------- | -------- | - | data | string | Yes | Data to write. The maximum length is 1024 bytes. | - | callback | AsyncCallback<string> | Yes | Callback invoked to return the operation result. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | data | string | Yes| Data to write. The maximum length is 1024 bytes.| + | callback | AsyncCallback<string> | Yes| Callback invoked to return the active tag content obtained.| - Example ``` @@ -151,7 +153,7 @@ Writes data to this active tag. This method uses an asynchronous callback to ret console.error(`failed to write event because ${err.code}`); return; } - + // Data is written to the tag. console.log(`success to write event: ${value}`); }); @@ -168,16 +170,16 @@ Registers the NFC field strength state events. **System capability**: SystemCapability.Communication.ConnectedTag - Parameters - | **Name** | **Type** | **Mandatory** | **Description** | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Event type. The value is **notify**. | - | callback | Callback<number> | Yes | Callback invoked to return the field strength state. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is **notify**.| + | callback | Callback<number> | Yes| Callback invoked to return the field strength state.| - Enumerates the field strength states. - | **Value** | **Description** | - | -------- | -------- | - | 0 | Field off. | - | 1 | Field on. | + | **Value**| **Description**| + | -------- | -------- | + | 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** | - | -------- | -------- | -------- | -------- | - | type | string | Yes | Event type. The value is **notify**. | - | callback | Callback<number> | 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. | + | **Name**| **Type**| **Mandatory**| **Description**| + | -------- | -------- | -------- | -------- | + | type | string | Yes| Event type. The value is **notify**.| + | callback | Callback<number> | 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.| diff --git a/en/application-dev/reference/apis/js-apis-nfcController.md b/en/application-dev/reference/apis/js-apis-nfcController.md index d4c9945248..c8a9d7cf69 100644 --- a/en/application-dev/reference/apis/js-apis-nfcController.md +++ b/en/application-dev/reference/apis/js-apis-nfcController.md @@ -1,9 +1,9 @@ # Standard NFC -Implements Near-Field Communication (NFC). +The **nfcController** module implements Near-Field Communication (NFC). > **NOTE**
-> 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<NfcState>): 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<NfcState>): 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| diff --git a/en/application-dev/reference/apis/js-apis-nfcTag.md b/en/application-dev/reference/apis/js-apis-nfcTag.md index 51731e95e1..01315a62d6 100644 --- a/en/application-dev/reference/apis/js-apis-nfcTag.md +++ b/en/application-dev/reference/apis/js-apis-nfcTag.md @@ -1,78 +1,171 @@ # Standard NFC Tag -Manages Near-Field Communication (NFC) tags. +The **nfcTag** module provides methods for managing Near-Field Communication (NFC) tags. > **NOTE**
-> 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.getIsoDepTag9+ + +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.getNdefTag9+ + +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.getMifareClassicTag9+ + +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.getMifareUltralightTag9+ + +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.getNdefFormatableTag9+ + +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.| + +## TagInfo9+ + +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.| -- GitLab