diff --git a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md index 52750e0743704b2cfd897e3b4fa4d8560ae30080..af859fbd34391edbca7779d79aafa23b9029cc7c 100644 --- a/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md +++ b/en/application-dev/reference/apis/js-apis-abilityAccessCtrl.md @@ -461,7 +461,7 @@ For details about the error codes, see [Application Access Control Error Codes]( **Example** ```js -import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; +import {Permissions} from '@ohos.abilityAccessCtrl'; import bundleManager from '@ohos.bundle.bundleManager'; let atManager = abilityAccessCtrl.createAtManager(); @@ -512,7 +512,7 @@ For details about the error codes, see [Application Access Control Error Codes]( **Example** ```js -import abilityAccessCtrl, {Permissions} from '@ohos.abilityAccessCtrl'; +import {Permissions} from '@ohos.abilityAccessCtrl'; import bundleManager from '@ohos.bundle.bundleManager'; let atManager = abilityAccessCtrl.createAtManager(); diff --git a/en/application-dev/reference/apis/js-apis-bluetoothManager.md b/en/application-dev/reference/apis/js-apis-bluetoothManager.md index 761cc2d9949952e3797d71271e97190ec4f71854..ac6105538d4ec026924963c5ba54ca2fd430e5e4 100644 --- a/en/application-dev/reference/apis/js-apis-bluetoothManager.md +++ b/en/application-dev/reference/apis/js-apis-bluetoothManager.md @@ -893,7 +893,7 @@ try { on(type: "stateChange", callback: Callback<BluetoothState>): void -Subscribes to the Bluetooth connection state change events. +Subscribes to Bluetooth state events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -932,7 +932,7 @@ try { off(type: "stateChange", callback?: Callback<BluetoothState>): void -Unsubscribes from the Bluetooth connection state change events. +Unsubscribes from Bluetooth state events. **Required permissions**: ohos.permission.USE_BLUETOOTH @@ -1994,7 +1994,7 @@ Subscribes to the HFP connection state change events. | Name | Type | Mandatory | Description | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event. | +| type | string | Yes | Event type. The value **connectionStateChange** indicates an HFP connection state change event.| | callback | Callback<[StateChangeParam](#StateChangeParam)> | Yes | Callback invoked to return the HFP connection state change event. | **Example** @@ -2075,7 +2075,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; + let hidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHostProfile.connect('XX:XX:XX:XX:XX:XX'); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2116,7 +2116,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let hidHostProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; + let hidHostProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHostProfile.disconnect('XX:XX:XX:XX:XX:XX'); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2145,7 +2145,7 @@ Subscribes to the HidHost connection state change events. function onReceiveEvent(data) { console.info('hidHost state = '+ JSON.stringify(data)); } -let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; +let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHost.on('connectionStateChange', onReceiveEvent); ``` @@ -2171,7 +2171,7 @@ Unsubscribes from the HidHost connection state change events. function onReceiveEvent(data) { console.info('hidHost state = '+ JSON.stringify(data)); } -let hidHost = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; +let hidHost = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_HID_HOST) as bluetoothManager.HidHostProfile; hidHost.on('connectionStateChange', onReceiveEvent); hidHost.off('connectionStateChange', onReceiveEvent); ``` @@ -2215,7 +2215,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; + let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.disconnect('XX:XX:XX:XX:XX:XX'); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2244,7 +2244,7 @@ Subscribes to the PAN connection state change events. function onReceiveEvent(data) { console.info('pan state = '+ JSON.stringify(data)); } -let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; +let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.on('connectionStateChange', onReceiveEvent); ``` @@ -2270,7 +2270,7 @@ Unsubscribes from the PAN connection state change events. function onReceiveEvent(data) { console.info('pan state = '+ JSON.stringify(data)); } -let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; +let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.on('connectionStateChange', onReceiveEvent); panProfile.off('connectionStateChange', onReceiveEvent); ``` @@ -2309,7 +2309,7 @@ For details about the error codes, see [Bluetooth Error Codes](../errorcodes/err ```js try { - let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; + let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; panProfile.setTethering(true); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); @@ -2337,7 +2337,7 @@ Obtains the network sharing status. ```js try { - let panProfile = bluetoothManager.getProfileInst(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; + let panProfile = bluetoothManager.getProfileInstance(bluetoothManager.ProfileId.PROFILE_PAN_NETWORK) as bluetoothManager.PanProfile; let ret = panProfile.isTetheringOn(); } catch (err) { console.error("errCode:" + err.code + ",errMessage:" + err.message); diff --git a/en/application-dev/reference/apis/js-apis-connectedTag.md b/en/application-dev/reference/apis/js-apis-connectedTag.md index 1bfb1231c3c4584fe4d608891bdf2be54458e425..9f8ea1bd9dcf8b2586865648732db2dd367bf20a 100644 --- a/en/application-dev/reference/apis/js-apis-connectedTag.md +++ b/en/application-dev/reference/apis/js-apis-connectedTag.md @@ -1,4 +1,4 @@ -# @ohos.connectedTag +# @ohos.connectedTag (Active Tags) The **connectedTag** module provides APIs for using active tags. You can use the APIs to initialize the active tag chip and read and write active tags. @@ -28,6 +28,23 @@ Initializes the active tag chip. | -------- | -------- | | boolean | Returns **true** if the operation is successful; returns **false** otherwise.| +## connectedTag.initialize9+ + +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.uninitialize9+ + +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<string> @@ -72,6 +106,41 @@ connectedTag.readNdefTag().then((data) => { }); ``` +## connectedTag.read9+ + +read(): Promise<number[]> + +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<number[]> | 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<string>): void @@ -102,6 +171,43 @@ connectedTag.readNdefTag((err, data)=> { }); ``` +## connectedTag.read9+ + +read(callback: AsyncCallback<number[]>): 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<number[]> | 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<void> @@ -129,7 +235,7 @@ Writes data to this active tag. This API uses a promise to return the result. ```js import connectedTag from '@ohos.connectedTag'; -var rawData = "010203"; // change it tobe correct. +var rawData = "010203"; // Set it as required. connectedTag.writeNdefTag(rawData).then(() => { console.log("connectedTag writeNdefTag Promise success."); }).catch((err)=> { @@ -137,6 +243,48 @@ connectedTag.writeNdefTag(rawData).then(() => { }); ``` +## connectedTag.write9+ + +write(data: number[]): Promise<void> + +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<void> | 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<void>): void @@ -159,7 +307,7 @@ Writes data to this active tag. This API uses an asynchronous callback to return ```js import connectedTag from '@ohos.connectedTag'; -var rawData = "010203"; // change it tobe correct. +var rawData = "010203"; // Set it as required. connectedTag.writeNdefTag(rawData, (err)=> { if (err) { console.log("connectedTag writeNdefTag AsyncCallback err: " + err); @@ -169,6 +317,45 @@ connectedTag.writeNdefTag(rawData, (err)=> { }); ``` +## connectedTag.write9+ + +write(data: number[], callback: AsyncCallback<void>): 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<void> | 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<number>): void @@ -220,7 +407,7 @@ connectedTag.on("notify", (err, rfState)=> { var initStatus = connectedTag.init(); console.log("connectedTag init status: " + initStatus); -// Add nfc connecected tag business oprations here... +// Add NFC connected tag business operations here. // connectedTag.writeNdefTag(rawData) // connectedTag.readNdefTag() diff --git a/en/application-dev/reference/apis/js-apis-nfcController.md b/en/application-dev/reference/apis/js-apis-nfcController.md index 4c55691b61cd60cb59543ae0881a719d5bb8fc1b..c9c909b93e7b345a99fd934078b76af6873d639a 100644 --- a/en/application-dev/reference/apis/js-apis-nfcController.md +++ b/en/application-dev/reference/apis/js-apis-nfcController.md @@ -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<[NfcState](#nfcstate)> | No| Callback for the NFC state changes. This parameter can be left blank.| +| callback | Callback<[NfcState](#nfcstate)> | 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** diff --git a/en/application-dev/reference/errorcodes/errorcode-nfc.md b/en/application-dev/reference/errorcodes/errorcode-nfc.md index 07e1648fe3256d63c9a74a0a580041ebd4b869d9..a8af05666cd02995cda09fd28d9823944fd1699c 100644 --- a/en/application-dev/reference/errorcodes/errorcode-nfc.md +++ b/en/application-dev/reference/errorcodes/errorcode-nfc.md @@ -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.