提交 cccc41b7 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
无相关合并请求
# 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** |
| -------- | -------- |
| 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&lt;string&gt; | Promise used to return the content of the active tag. |
| **Type**| **Description**|
| -------- | -------- |
| Promise&lt;string&gt; | 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&lt;string&gt; | Yes | Callback invoked to return the active tag content obtained. |
| **Name**| **Type**| **Mandatory**| **Description**|
| -------- | -------- | -------- | -------- |
| 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** |
| -------- | -------- | -------- | -------- |
| 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&lt;void&gt; | Promise used to return the result. This method returns no value. |
| **Type**| **Description**|
| -------- | -------- |
| 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** |
| -------- | -------- | -------- | -------- |
| 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. |
| **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 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&lt;number&gt; | Yes | Callback invoked to return the field strength state. |
| **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.|
- 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&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. |
| **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.|
- 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**
......@@ -12,7 +11,6 @@ Manages Near-Field Communication (NFC) tags.
import tag from '@ohos.nfc.tag';
```
## tag.getNfcATag
getNfcATag(tagInfo: TagInfo): NfcATag
......@@ -21,7 +19,7 @@ Obtains an **NfcATag** object, which allows access to the tags that use the NFC-
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -37,7 +35,7 @@ Obtains an **NfcBTag** object, which allows access to the tags that use the NFC-
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -53,7 +51,7 @@ Obtains an **NfcFTag** object, which allows access to the tags that use the NFC-
**Required permissions**: ohos.permission.NFC_TAG
**System capability**: SystemCapability.Communication.NFC
**System capability**: SystemCapability.Communication.NFC.Core
**Return value**
......@@ -69,10 +67,11 @@ Obtains an **NfcVTag** object, which allows access to the tags that use the NFC-
**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.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部