未验证 提交 0ef98eb4 编写于 作者: O openharmony_ci 提交者: Gitee

!20273 docs :seCureElement入参说明标准修改

Merge pull request !20273 from wujie/master
......@@ -34,7 +34,7 @@
{
"name": "tag-tech",
"value": "IsoDep"
},
}
// add other technology if neccessary,
// such as: NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable
]
......@@ -66,59 +66,61 @@ import tag from '@ohos.nfc.tag';
在对相关Tag类型卡片进行读写之前,必须先获取TagInfo相关属性值,以确认设备读取到的Tag卡片支持哪些技术类型。这样Tag应用程序才能调用正确的接口和所读取到的Tag卡片进行通信。
```js
import tag from '@ohos.nfc.tag';
import UIAbility from '@ohos.app.ability.UIAbility';
onCreate(want, launchParam) {
// add other code here...
// want is initialized by nfc service, contains tag info for this found tag
var tagInfo;
try {
tagInfo = tag.getTagInfo(want);
} catch (error) {
console.log("tag.getTagInfo catched error: " + error);
}
if (tagInfo == null || tagInfo == undefined) {
console.log("no TagInfo to be created, ignore it.");
return;
}
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
// add other code here...
// get the supported technologies for this found tag.
var isNfcATag = false;
var isIsoDepTag = false;
for (var i = 0; i < tagInfo.technology.length; i++) {
if (tagInfo.technology[i] == tag.NFC_A) {
isNfcATag = true;
// want is initialized by nfc service, contains tag info for this found tag
var tagInfo;
try {
tagInfo = tag.getTagInfo(want);
} catch (error) {
console.log("tag.getTagInfo catched error: " + error);
}
if (tagInfo == null || tagInfo == undefined) {
console.log("no TagInfo to be created, ignore it.");
return;
}
if (tagInfo.technology[i] == tag.ISO_DEP) {
isIsoDepTag = true;
// get the supported technologies for this found tag.
var isNfcATag = false;
var isIsoDepTag = false;
for (var i = 0; i < tagInfo.technology.length; i++) {
if (tagInfo.technology[i] == tag.NFC_A) {
isNfcATag = true;
}
if (tagInfo.technology[i] == tag.ISO_DEP) {
isIsoDepTag = true;
}
// also check for technology: tag.NFC_B/NFC_F/NFC_V/NDEF/MIFARE_CLASSIC/MIFARE_ULTRALIGHT/NDEF_FORMATABLE
}
// also check for technology: tag.NFC_B/NFC_F/NFC_V/NDEF/MIFARE_CLASSIC/MIFARE_ULTRALIGHT/NDEF_FORMATABLE
}
// use NfcA APIs to access the found tag.
if (isNfcATag) {
var nfcA;
try {
nfcA = tag.getNfcATag(tagInfo);
} catch (error) {
console.log("tag.getNfcATag catched error: " + error);
// use NfcA APIs to access the found tag.
if (isNfcATag) {
var nfcA;
try {
nfcA = tag.getNfcATag(tagInfo);
} catch (error) {
console.log("tag.getNfcATag catched error: " + error);
}
// other code to read or write this found tag.
}
// other code to read or write this found tag.
}
// use getIsoDep APIs to access the found tag.
if (isIsoDepTag) {
var isoDep;
try {
isoDep = tag.getIsoDep(tagInfo);
} catch (error) {
console.log("tag.getIsoDep catched error: " + error);
// use getIsoDep APIs to access the found tag.
if (isIsoDepTag) {
var isoDep;
try {
isoDep = tag.getIsoDep(tagInfo);
} catch (error) {
console.log("tag.getIsoDep catched error: " + error);
}
// other code to read or write this found tag.
}
// other code to read or write this found tag.
// use the same code to handle for "NfcA/NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable".
}
// use the same code to handle for "NfcA/NfcB/NfcF/NfcV/Ndef/MifareClassic/MifareUL/NdefFormatable".
}
```
......@@ -135,14 +137,14 @@ getNfcATag(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcATag](js-apis-nfctech.md#nfcatag) | NFC A类型Tag对象。 |
## tag.getNfcA<sup>9+</sup>
......@@ -155,23 +157,23 @@ getNfcA(tagInfo: [TagInfo](#taginfo)): [NfcATag](js-apis-nfctech.md#nfcatag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcATag](js-apis-nfctech.md#nfcatag) | NFC A类型Tag对象。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNfcBTag
......@@ -186,14 +188,14 @@ getNfcBTag(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | NFC B类型Tag对象。 |
## tag.getNfcB<sup>9+</sup>
......@@ -206,23 +208,23 @@ getNfcB(tagInfo: [TagInfo](#taginfo)): [NfcBTag](js-apis-nfctech.md#nfcbtag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcBTag](js-apis-nfctech.md#nfcbtag) | NFC B类型Tag对象。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNfcFTag
......@@ -237,14 +239,14 @@ getNfcFTag(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | NFC F类型Tag对象。 |
## tag.getNfcF<sup>9+</sup>
......@@ -257,23 +259,23 @@ getNfcF(tagInfo: [TagInfo](#taginfo)): [NfcFTag](js-apis-nfctech.md#nfcftag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcFTag](js-apis-nfctech.md#nfcftag) | NFC F类型Tag对象。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNfcVTag
......@@ -288,14 +290,14 @@ getNfcVTag(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 |
## tag.getNfcV<sup>9+</sup>
......@@ -308,23 +310,23 @@ getNfcV(tagInfo: [TagInfo](#taginfo)): [NfcVTag](js-apis-nfctech.md#nfcvtag)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------------------------- | ------------- |
| **类型** | **说明** |
| ------------------------------------- | ------------------ |
| [NfcVTag](js-apis-nfctech.md#nfcvtag) | NFC V类型Tag对象。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getIsoDep<sup>9+</sup>
......@@ -336,23 +338,23 @@ getIsoDep(tagInfo: [TagInfo](#taginfo)): [IsoDepTag](js-apis-nfctech.md#isoDepTa
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ---------------------------------------- | ----------------------------------- |
| **类型** | **说明** |
| ------------------------------------------ | ------------------------------------------------------- |
| [IsoDepTag](js-apis-nfctech.md#isodeptag9) | IsoDep类型Tag对象,通过该对象访问IsoDep类型的相关接口。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNdef<sup>9+</sup>
......@@ -364,23 +366,23 @@ getNdef(tagInfo: [TagInfo](#taginfo)): [NdefTag](js-apis-nfctech.md#ndeftag9)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| -------------------------------------- | ------------------------------- |
| **类型** | **说明** |
| -------------------------------------- | --------------------------------------------------- |
| [NdefTag](js-apis-nfctech.md#ndeftag9) | NDEF类型Tag对象,通过该对象访问NDEF类型的相关接口。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getMifareClassic<sup>9+</sup>
......@@ -392,23 +394,23 @@ getMifareClassic(tagInfo: [TagInfo](#taginfo)): [MifareClassicTag](js-apis-nfcte
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ---------------------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| --------------------------------------------------------- | ----------------------------------------------------------------------- |
| [MifareClassicTag](js-apis-nfctech.md#mifareclassictag-9) | MIFARE Classic类型Tag对象,通过该对象访问MIFARE Classic类型的相关接口。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getMifareUltralight<sup>9+</sup>
......@@ -419,23 +421,23 @@ getMifareUltralight(tagInfo: [TagInfo](#taginfo)): [MifareUltralightTag](js-apis
**系统能力:** SystemCapability.Communication.NFC.Tag
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ---------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------- | ---- | ------------------------------------------------------------- |
| taginfo | [TagInfo](#taginfo) | 是 | 包含Tag技术类型和相关参数,从tag.getTagInfo(want: Want)获取。 |
**返回值:**
| **类型** | **说明** |
| ---------------------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| -------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [MifareUltralightTag](js-apis-nfctech.md#mifareultralighttag9) | MIFARE Ultralight类型Tag对象,通过该对象访问MIFARE Ultralight类型的相关接口。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getNdefFormatable<sup>9+</sup>
......@@ -447,17 +449,17 @@ getNdefFormatable(tagInfo: [TagInfo](#taginfo)): [NdefFormatableTag](js-apis-nfc
**返回值:**
| **类型** | **说明** |
| ---------------------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| --------------------------------------------------------- | ------------------------------------------------------------------------- |
| [NdefFormatableTag](js-apis-nfctech.md#ndefformatabletag) | NDEF Formatable类型Tag对象,通过该对象访问NDEF Formatable类型的相关接口。 |
**错误码:**
以下错误码的详细介绍请参见[NFC错误码](../errorcodes/errorcode-nfc.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
| 错误码ID | 错误信息 |
| -------- | ----------------------------------------- |
| 3100201 | Tag running state is abnormal in service. |
## tag.getTagInfo<sup>9+</sup>
......@@ -469,14 +471,14 @@ getTagInfo(want: [Want](js-apis-app-ability-want.md#Want)): [TagInfo](#taginfo)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ---------------------------------------- | ---- | --------------------------------- |
| want | [Want](js-apis-app-ability-want.md#Want) | 是 | 分发Ability时,在系统onCreate入口函数的参数中获取。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------- | ---- | --------------------------------------------------- |
| want | [Want](js-apis-app-ability-want.md#Want) | 是 | 分发Ability时,在系统onCreate入口函数的参数中获取。 |
**返回值:**
| **类型** | **说明** |
| ------------------- | --------------------------- |
| **类型** | **说明** |
| ------------------- | -------------------------------------------- |
| [TagInfo](#taginfo) | TagInfo对象,用于获取不同技术类型的Tag对象。 |
......@@ -490,14 +492,14 @@ makeUriRecord(uri: string): [NdefRecord](#ndefrecord9);
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------- |
| uri | string | 是 | 写入到NDEF Record里面的数据内容。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------------- |
| uri | string | 是 | 写入到NDEF Record里面的数据内容。 |
**返回值:**
| **类型** | **说明** |
| -------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| -------------------------- | ------------------------------------------------------------ |
| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**示例:**
......@@ -529,15 +531,15 @@ makeTextRecord(text: string, locale: string): [NdefRecord](#ndefrecord9);
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------ |
| text | string | 是 | 写入到NDEF Record里面的文本数据内容。 |
| locale | string | 是 | 文本数据内容的编码方式。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------------------- |
| text | string | 是 | 写入到NDEF Record里面的文本数据内容。 |
| locale | string | 是 | 文本数据内容的编码方式。 |
**返回值:**
| **类型** | **说明** |
| -------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| -------------------------- | ------------------------------------------------------------ |
| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**示例:**
......@@ -571,15 +573,15 @@ makeMimeRecord(mimeType: string, mimeData: number[]): [NdefRecord](#ndefrecord9)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ---------------------------------------- |
| mimeType | string | 是 | 符合RFC规则的MIME类型,比如"text/plain"或"image/jpeg"。 |
| mimeData | number[] | 是 | MIME数据内容,每个number十六进制表示,范围是0x00~0xFF。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | ---- | ------------------------------------------------------- |
| mimeType | string | 是 | 符合RFC规则的MIME类型,比如"text/plain"或"image/jpeg"。 |
| mimeData | number[] | 是 | MIME数据内容,每个number十六进制表示,范围是0x00~0xFF。 |
**返回值:**
| **类型** | **说明** |
| -------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| -------------------------- | ------------------------------------------------------------ |
| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**示例:**
......@@ -611,16 +613,16 @@ makeExternalRecord(domainName: string, type: string, externalData: number[]): [N
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | -------- | ---- | ----------------------------------- |
| domainName | string | 是 | 外部数据发布组织的域名,一般是应用程序的包名。 |
| type | string | 是 | 外部数据的指定类型。 |
| externalData | number[] | 是 | 外部数据内容,每个number十六进制表示,范围是0x00~0xFF。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | -------- | ---- | ------------------------------------------------------- |
| domainName | string | 是 | 外部数据发布组织的域名,一般是应用程序的包名。 |
| type | string | 是 | 外部数据的指定类型。 |
| externalData | number[] | 是 | 外部数据内容,每个number十六进制表示,范围是0x00~0xFF。 |
**返回值:**
| **类型** | **说明** |
| -------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| -------------------------- | ------------------------------------------------------------ |
| [NdefRecord](#ndefrecord9) | NDEF标签的Record,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**示例:**
......@@ -654,14 +656,14 @@ messageToBytes(ndefMessage: [NdefMessage](js-apis-nfctech.md#ndefmessage9)): num
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ---------------------------------------- | ---- | ----------- |
| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | 是 | NDEF消息数据对象。 |
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ---------------------------------------------- | ---- | ------------------ |
| ndefMessage | [NdefMessage](js-apis-nfctech.md#ndefmessage9) | 是 | NDEF消息数据对象。 |
**返回值:**
| **类型** | **说明** |
| -------- | ---------------------------------------- |
| **类型** | **说明** |
| -------- | ------------------------------------------------------------------------------------- |
| number[] | NDEF消息数据对象,所转换成的字节格式的数据。每个number十六进制表示,范围是0x00~0xFF。 |
**示例:**
......@@ -695,14 +697,14 @@ createNdefMessage(data: number[]): [NdefMessage](js-apis-nfctech.md#ndefmessage9
**参数:**
| **参数名** | **类型** | **必填** | **说明** |
| ------- | -------- | ------ | ---------------------------------------- |
| data | number[] | 是 | 原始字节,每个number十六进制表示,范围是0x00~0xFF。要求必须满足NDEF Record的格式。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | -------- | -------- | ---------------------------------------------------------------------------------- |
| data | number[] | 是 | 原始字节,每个number十六进制表示,范围是0x00~0xFF。要求必须满足NDEF Record的格式。 |
**返回值:**
| **类型** | **说明** |
| ---------------------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| ---------------------------------------------- | ------------------------------------------------------------- |
| [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**示例:**
......@@ -729,14 +731,14 @@ createNdefMessage(ndefRecords: NdefRecord[]): [NdefMessage](js-apis-nfctech.md#n
**参数:**
| **参数名** | **类型** | **必填** | **说明** |
| ----------- | ---------------------------------------- | ------ | ---------------------------------------- |
| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | 是 | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
| **参数名** | **类型** | **必填** | **说明** |
| ----------- | --------------------------------------------- | -------- | ---------------------------------------------------------------- |
| ndefRecords | [NdefRecord](js-apis-nfcTag.md#ndefrecord9)[] | 是 | NDEF标签的Record列表,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**返回值:**
| **类型** | **说明** |
| ---------------------------------------- | ---------------------------------------- |
| **类型** | **说明** |
| ---------------------------------------------- | ------------------------------------------------------------- |
| [NdefMessage](js-apis-nfctech.md#ndefmessage9) | NDEF标签的Message,详见NDEF技术规范《NFCForum-TS-NDEF_1.0》。 |
**示例:**
......@@ -764,113 +766,113 @@ NFC服务在读取到标签时给出的对象,通过改对象属性,应用
**需要权限:** ohos.permission.NFC_TAG
| **名称** | **类型** | **可读** | **可写** | **说明** |
| ----------------------------- | ---------------------------------------- | ------ | ------ | ---------------------------------------- |
| uid<sup>9+</sup> | number[] | 是 | 否 | 标签的uid,每个number值是十六进制表示,范围是0x00~0xFF。 |
| technology<sup>9+</sup> | number[] | 是 | 否 | 支持的技术类型,每个number值表示所支持技术类型的常量值。 |
| supportedProfiles | number[] | 是 | 否 | 支持的技术类型,从API9开始不支持,使用[tag.TagInfo#technology](#tagtaginfo)替代。 |
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | 是 | 否 | 标签所支持技术的扩展属性值。<br>**系统接口:** 此接口为系统接口。 |
| tagRfDiscId<sup>9+</sup> | number | 是 | 否 | 标签发现时分配的ID值。<br>**系统接口:** 此接口为系统接口。 |
| remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 否 | NFC服务进程的远端对象,用于客户端和服务之间的接口通信。<br>**系统接口:** 此接口为系统接口。 |
| **名称** | **类型** | **可读** | **可写** | **说明** |
| ----------------------------- | ------------------------------------------------------------- | -------- | -------- | -------------------------------------------------------------------------------------------- |
| uid<sup>9+</sup> | number[] | 是 | 否 | 标签的uid,每个number值是十六进制表示,范围是0x00~0xFF。 |
| technology<sup>9+</sup> | number[] | 是 | 否 | 支持的技术类型,每个number值表示所支持技术类型的常量值。 |
| supportedProfiles | number[] | 是 | 否 | 支持的技术类型,从API9开始不支持,使用[tag.TagInfo#technology](#tagtaginfo)替代。 |
| extrasData<sup>9+</sup> | [PacMap](js-apis-inner-ability-dataAbilityHelper.md#pacmap)[] | 是 | 否 | 标签所支持技术的扩展属性值。<br>**系统接口:** 此接口为系统接口。 |
| tagRfDiscId<sup>9+</sup> | number | 是 | 否 | 标签发现时分配的ID值。<br>**系统接口:** 此接口为系统接口。 |
| remoteTagService<sup>9+</sup> | [rpc.RemoteObject](js-apis-rpc.md#remoteobject) | 是 | 否 | NFC服务进程的远端对象,用于客户端和服务之间的接口通信。<br>**系统接口:** 此接口为系统接口。 |
## NdefRecord<sup>9+</sup>
NDEF标签Record属性的定义,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **类型** | **可读** | **可写** | **说明** |
| ------- | -------- | ------ | ------ | ---------------------------------------- |
| tnf | number | 是 | 否 | NDEF Record的TNF(Type Name Field)。 |
| rtdType | number[] | 是 | 否 | NDEF Record的RTD(Record Type Definition)类型值,每个number十六进制表示,范围是0x00~0xFF。 |
| id | number[] | 是 | 否 | NDEF Record的ID,每个number十六进制表示,范围是0x00~0xFF。 |
| payload | number[] | 是 | 否 | NDEF Record的PAYLOAD,每个number十六进制表示,范围是0x00~0xFF。 |
| **名称** | **类型** | **可读** | **可写** | **说明** |
| -------- | -------- | -------- | -------- | ----------------------------------------------------------------------------------------- |
| tnf | number | 是 | 否 | NDEF Record的TNF(Type Name Field)。 |
| rtdType | number[] | 是 | 否 | NDEF Record的RTD(Record Type Definition)类型值,每个number十六进制表示,范围是0x00~0xFF。 |
| id | number[] | 是 | 否 | NDEF Record的ID,每个number十六进制表示,范围是0x00~0xFF。 |
| payload | number[] | 是 | 否 | NDEF Record的PAYLOAD,每个number十六进制表示,范围是0x00~0xFF。 |
## 技术类型定义
NFC Tag有多种不同的技术类型,定义常量描述不同的技术类型。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| ---------------------------- | ----- | ------------------------ |
| NFC_A | 1 | NFC-A (ISO 14443-3A)技术。 |
| NFC_B | 2 | NFC-A (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技术。 |
| MIFARE_CLASSIC | 8 | MIFARE Classic技术。 |
| MIFARE_ULTRALIGHT | 9 | MIFARE Utralight技术。 |
| **名称** | **值** | **说明** |
| ---------------------------- | ------ | --------------------------- |
| NFC_A | 1 | NFC-A (ISO 14443-3A)技术。 |
| NFC_B | 2 | NFC-A (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技术。 |
| MIFARE_CLASSIC | 8 | MIFARE Classic技术。 |
| MIFARE_ULTRALIGHT | 9 | MIFARE Utralight技术。 |
## TnfType<sup>9+</sup>
NDEF Record的TNF(Type Name Field)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| ---------------- | ----- | ---------------------------------------- |
| 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)。 |
| **名称** | **值** | **说明** |
| ---------------- | ------ | ------------------------------------------------ |
| 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)。 |
## NDEF Record RTD类型定义
NDEF Record的RTD(Record Type Definition)类型值,参考NDEF标签技术规范《NFCForum-TS-NDEF_1.0》的定义细节。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| --------------------- | ------ | ------------------ |
| RTD_TEXT<sup>9+</sup> | [0x54] | 文本类型的NDEF Record。 |
| RTD_URI<sup>9+</sup> | [0x55] | URI类型的NDEF Record。 |
| **名称** | **值** | **说明** |
| --------------------- | ------ | ----------------------- |
| RTD_TEXT<sup>9+</sup> | [0x54] | 文本类型的NDEF Record。 |
| RTD_URI<sup>9+</sup> | [0x55] | URI类型的NDEF Record。 |
## NfcForumType<sup>9+</sup>
NFC Forum标准里面Tag类型的定义。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| ---------------- | ----- | ----------------- |
| NFC_FORUM_TYPE_1 | 1 | NFC论坛类型1。 |
| NFC_FORUM_TYPE_2 | 2 | NFC论坛类型2。 |
| NFC_FORUM_TYPE_3 | 3 | NFC论坛类型3。 |
| NFC_FORUM_TYPE_4 | 4 | NFC论坛类型4。 |
| MIFARE_CLASSIC | 101 | MIFARE Classic类型。 |
| **名称** | **值** | **说明** |
| ---------------- | ------ | -------------------- |
| NFC_FORUM_TYPE_1 | 1 | NFC论坛类型1。 |
| NFC_FORUM_TYPE_2 | 2 | NFC论坛类型2。 |
| NFC_FORUM_TYPE_3 | 3 | NFC论坛类型3。 |
| NFC_FORUM_TYPE_4 | 4 | NFC论坛类型4。 |
| MIFARE_CLASSIC | 101 | MIFARE Classic类型。 |
## MifareClassicType<sup>9+</sup>
MIFARE Classic标签类型的定义。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| ------------ | ----- | ----------------- |
| TYPE_UNKNOWN | 0 | 未知的MIFARE类型。 |
| TYPE_CLASSIC | 1 | MIFARE Classic类型。 |
| TYPE_PLUS | 2 | MIFARE Plus类型。 |
| TYPE_PRO | 3 | MIFARE Pro类型。 |
| **名称** | **值** | **说明** |
| ------------ | ------ | -------------------- |
| TYPE_UNKNOWN | 0 | 未知的MIFARE类型。 |
| TYPE_CLASSIC | 1 | MIFARE Classic类型。 |
| TYPE_PLUS | 2 | MIFARE Plus类型。 |
| TYPE_PRO | 3 | MIFARE Pro类型。 |
## MifareClassicSize<sup>9+</sup>
MIFARE Classic标签存储大小的定义。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| ------------ | ----- | ------------------ |
| MC_SIZE_MINI | 320 | 每个标签5个扇区,每个扇区4个块。 |
| MC_SIZE_1K | 1024 | 每个标签16个扇区,每个扇区4个块。 |
| MC_SIZE_2K | 2048 | 每个标签32个扇区,每个扇区4个块。 |
| MC_SIZE_4K | 4096 | 每个标签40个扇区,每个扇区4个块。 |
| **名称** | **值** | **说明** |
| ------------ | ------ | --------------------------------- |
| MC_SIZE_MINI | 320 | 每个标签5个扇区,每个扇区4个块。 |
| MC_SIZE_1K | 1024 | 每个标签16个扇区,每个扇区4个块。 |
| MC_SIZE_2K | 2048 | 每个标签32个扇区,每个扇区4个块。 |
| MC_SIZE_4K | 4096 | 每个标签40个扇区,每个扇区4个块。 |
## MifareUltralightType<sup>9+</sup>
MIFARE Ultralight标签类型的定义。
**系统能力:** SystemCapability.Communication.NFC.Tag
| **名称** | **值** | **说明** |
| ----------------- | ----- | ---------------------- |
| TYPE_UNKNOWN | 0 | 未知的 MIFARE 类型。 |
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight类型。 |
| TYPE_ULTRALIGHT_C | 2 | MIFARE UltralightC 类型。 |
| **名称** | **值** | **说明** |
| ----------------- | ------ | ------------------------- |
| TYPE_UNKNOWN | 0 | 未知的 MIFARE 类型。 |
| TYPE_ULTRALIGHT | 1 | MIFARE Ultralight类型。 |
| TYPE_ULTRALIGHT_C | 2 | MIFARE UltralightC 类型。 |
<!--no_check-->
\ No newline at end of file
......@@ -43,10 +43,10 @@ newSEService(type: 'serviceState', callback: Callback<[ServiceState](#secureelem
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | ---------------------------------------------------- | -------------------- |
| type | string | 'serviceState' |
| callback | Callback<[ServiceState](#secureelementservicestate)> | 返回SE服务状态的回调 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | ---------------------------------------------------- | ------ | -------------------- |
| type | string | 是 | 'serviceState' |
| callback | Callback<[ServiceState](#secureelementservicestate)> | 是 | 返回SE服务状态的回调 |
**返回值:**
......@@ -59,20 +59,18 @@ newSEService(type: 'serviceState', callback: Callback<[ServiceState](#secureelem
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcSEService: secureElement.SEService = null;
let nfcSEService = null;
this.result = "Service state is Unkown";
try {
this.nfcSEService = secureElement.newSEService("serviceState", (state) => {
nfcSEService = secureElement.newSEService("serviceState", (state) => {
if (state == secureElement.ServiceState.DISCONNECTED) {
this.result = "Service state is Disconnected";
console.log("Service state is Disconnected");
} else {
this.result = "Service state is Connected";
console.log.("Service state is Connected");
}
});
} catch (e) {
this.result = "newSEService occurs exception:" + e.message;
console.log("newSEService occurs exception:" + e.message);
}
```
......@@ -95,35 +93,34 @@ getReaders(): Reader[]
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcSEService: secureElement.SEService = null;
@State nfcServiceState: secureElement.ServiceState = null;
@State nfcOmaReader: secureElement.Reader = null;
@State nfcOmaReaderList: secureElement.Reader[] = null;
let nfcSEService = null;
let nfcServiceState = null;
let nfcOmaReader = null;
let nfcOmaReaderList = null;
// get SEService
try {
this.nfcSEService = secureElement.newSEService("serviceState", (state) => {
nfcSEService = secureElement.newSEService("serviceState", (state) => {
if (state == secureElement.ServiceState.DISCONNECTED) {
this.result = "Service state is Disconnected";
console.log("Service state is Disconnected");
} else {
this.result = "Service state is Connected";
console.log("Service state is Connected");
}
});
} catch (e) {
this.result = "newSEService excpetion:" + e.message;
console.log("newSEService excpetion:" + e.message);
}
try {
this.nfcOmaReaderList = this.nfcSEService.getReaders();
if (this.nfcOmaReaderList != null && this.nfcOmaReaderList.length > 0) {
this.nfcOmaReader = this.nfcOmaReaderList[0];
this.result = "get reader successfully";
nfcOmaReaderList = nfcSEService.getReaders();
if (nfcOmaReaderList != null && nfcOmaReaderList.length > 0) {
nfcOmaReader = this.nfcOmaReaderList[0];
console.log("get reader successfully");
} else {
this.result = "get reader failed";
console.log("get reader failed");
}
} catch (e) {
this.result = "getReaders exception:" + e.message;
console.log("getReaders exception:" + e.message);
}
```
......@@ -146,20 +143,19 @@ isConnected(): boolean
```JS
import secureElement from '@ohos.secureElement';
@State result: string = ''
@State nfcSEService: secureElement.SEService = null;
let nfcSEService = null;
try {
let ret: boolean;
// refer to newSEService for this.nfcSEService
ret = this.nfcSEService.isConnected();
ret = nfcSEService.isConnected();
if (ret) {
this.result = 'get state: connected';
console.log("get state: connected");
} else {
this.result = 'get state: not connected';
console.log("get state: not connected");
}
} catch (e) {
this.result = "isConnected exception: " + e.message;
console.log("isConnected exception: " + e.message);
}
```
......@@ -176,15 +172,15 @@ shutdown(): void
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcSEService: secureElement.SEService = null;
let nfcSEService = null;
try {
// refer to newSEService for this.nfcSEService
this.nfcSEService.shutdown();
this.result = "shutdown successfully";
nfcSEService.shutdown();
console.log("shutdown successfully");
} catch (e) {
this.result = "shutdown exception:" + e.message;
console.log("shutdown exception:" + e.message);
}
```
......@@ -207,15 +203,14 @@ getVersion(): string
```JS
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcSEService: secureElement.SEService = null;
let nfcSEService = null;
this.result = "version: "
try {
// refer to newSEService for this.nfcSEService
this.result += this.nfcSEService.getVersion();
console.log("version: " + nfcSEService.getVersion());
} catch (e) {
this.result = "getVersion exception:" + e.message;
console.log("getVersion exception:" + e.message);
}
```
......@@ -238,14 +233,13 @@ getName(): string
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaReader: secureElement.Reader = null;
let nfcOmaReader = null;
try {
// refer to SEService.getReaders for this.nfcOmaReader
this.result = this.nfcOmaReader.getName();
console.log(nfcOmaReader.getName());
} catch (e) {
this.result = "getName exception:" + e.message;
console.log("getName exception:" + e.message);
}
```
......@@ -276,18 +270,17 @@ isSecureElementPresent(): boolean
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaReader: secureElement.Reader = null;
let nfcOmaReader = null;
try {
// refer to SEService.getReaders for this.nfcOmaReader
if (this.nfcOmaReader.isSecureElementPresent()) {
this.result = "isSecureElementPresent TRUE";
if (nfcOmaReader.isSecureElementPresent()) {
console.log("isSecureElementPresent TRUE");
} else {
this.result = "isSecureElementPresent FALSE";
console.log("isSecureElementPresent FALSE");
}
} catch (e) {
this.result = "isSecureElementPresent exception:" + e.message;
console.log("isSecureElementPresent exception:" + e.message);
}
```
......@@ -319,20 +312,19 @@ try {
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaReader: secureElement.Reader = null;
@State nfcOmaSession: secureElement.Session = null;
let nfcOmaReader = null;
let nfcOmaSession = null;
try {
// refer to SEService.getReaders for this.nfcOmaReader
this.nfcOmaSession = this.nfcOmaReader.openSession();
if (this.nfcOmaSession) {
this.result = "get session successfully";
nfcOmaSession = nfcOmaReader.openSession();
if (nfcOmaSession) {
console.log("get session successfully");
} else {
this.result = "get session failed";
console.log("get session failed");
}
} catch (e) {
this.result = "OpenSession exception: " + e.message;
console.log("OpenSession exception: " + e.message);
}
```
......@@ -357,15 +349,14 @@ try {
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaReader: secureElement.Reader = null;
nfcOmaReader = null;
try {
// refer to SEService.getReaders for this.nfcOmaReader
this.nfcOmaReader.closeSessions();
this.result = "close Sessions successfully";
nfcOmaReader.closeSessions();
console.log("close Sessions successfully");
} catch (e) {
this.result = "closeSessions exception:" + e.message;
console.log("closeSessions exception:" + e.message);
}
```
......@@ -388,20 +379,19 @@ getReader(): Reader
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaReader: secureElement.Reader = null;
@State nfcOmaSession: secureElement.Session = null;
let nfcOmaReader = null;
let nfcOmaSession = null;
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaReader = this.nfcOmaSession.getReader();
if (this.nfcOmaReader) {
this.result = "get reader successfully";
nfcOmaReader = nfcOmaSession.getReader();
if (nfcOmaReader) {
console.log("get reader successfully");
} else {
this.result = "get reader failed";
console.log("get reader failed");
}
} catch (e) {
this.result = "getReader exception:" + e.message;
console.log("getReader exception:" + e.message);
}
```
......@@ -432,24 +422,25 @@ getATR(): number[]
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
let nfcOmaSession = null;
let str = "";
try {
// refer to Reader.openSession for this.nfcOmaSession
let ret = this.nfcOmaSession.getATR();
let ret = nfcOmaSession.getATR();
if (ret) {
this.result = "getATR result:[";
str = 'getATR result:[';
for (let i = 0; i < ret.length; ++i) {
this.result += ret[i];
this.result += ' ';
str += ret[i];
str += ' ';
}
this.result += ']';
str += ']';
console.log(str);
} else {
this.result = "getATR result is null";
console.log("getATR result is null");
}
} catch (e) {
this.result = "getATR exception:" + e.message;
console.log("getATR exception:" + e.message);
}
```
......@@ -474,15 +465,14 @@ close(): void
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
let nfcOmaSession = null;
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaSession.close();
this.result = "session close successfully";
nfcOmaSession.close();
console.log("session close successfully");
} catch (e) {
this.result = "session close exception:" + e.message;
console.log("session close exception:" + e.message);
}
```
......@@ -509,19 +499,18 @@ isClosed(): boolean
```Js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
let nfcOmaSession = null;
try {
// refer to Reader.openSession for this.nfcOmaSession
let ret = this.nfcOmaSession.isClosed();
let ret = nfcOmaSession.isClosed();
if (ret) {
this.result = "session state is closed";
console.log("session state is closed");
} else {
this.result = "session state is not closed";
console.log("session state is not closed");
}
} catch (e) {
this.result = "isClosed exception:" + e.message;
console.log("isClosed exception:" + e.message);
}
```
......@@ -546,15 +535,14 @@ closeChannels(): void
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
let nfcOmaSession = null;
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaSession.closeChannels();
this.result = "close Channels successfully";
nfcOmaSession.closeChannels();
console.log("close Channels successfully");
} catch (e) {
this.result = "closeChannels exception:" + e.message;
console.log("closeChannels exception:" + e.message);
}
```
......@@ -568,9 +556,9 @@ openBasicChannel(aid: number[]): Promise<Channel>
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | -------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或如果没有applet被选择时空的数组null。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | -------- | ------ | ------------------------------------------------------------ |
| aid | number[] | 是 |在此channel上选择的applet的AID数组或如果没有applet被选择时空的数组null。 |
**返回值:**
......@@ -594,21 +582,20 @@ openBasicChannel(aid: number[]): Promise<Channel>
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
let nfcOmaSession = null;
let nfcOmaChannel = null;
try {
// refer to Reader.openSession for this.nfcOmaSession
let getPromise = this.nfcOmaSession.openBasicChannel(this.aidArray);
let getPromise = nfcOmaSession.openBasicChannel(this.aidArray);
getPromise.then((channel) => {
this.nfcOmaChannel = channel;
this.result = "openBasicChannel1 get channel successfully";
nfcOmaChannel = channel;
console.log("openBasicChannel1 get channel successfully");
}).catch ((err) => {
this.result = "openBasicChannel1 exception:" + err.message;
console.log("openBasicChannel1 exception:" + err.message);
});
} catch (e) {
this.result = "OpenBasicChannel1 exception:" + e.message;
console.log("OpenBasicChannel1 exception:" + e.message);
}
```
......@@ -622,10 +609,10 @@ try {
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| callback | AsyncCallback<Channel> | callback返回可用Channel对象实例。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
| aid | number[] | 是 | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| callback | AsyncCallback<Channel> | 是 | callback返回可用Channel对象实例。 |
**错误码:**
......@@ -643,23 +630,22 @@ try {
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaSession.openBasicChannel(this.aidArray, (error, data) => {
nfcOmaSession.openBasicChannel(aidArray, (error, data) => {
if (error) {
this.result = "openBasicChannel2 failed:" + JSON.stringify(error);
console.log("openBasicChannel2 failed:" + JSON.stringify(error));
return;
}
this.nfcOmaChannel = data;
this.result = "openBasicChannel2 get channel successfully";
nfcOmaChannel = data;
console.log("openBasicChannel2 get channel successfully");
});
} catch (e) {
this.result = "openBasicChannel2 exception:" + e.message;
console.log("openBasicChannel2 exception:" + e.message);
}
```
......@@ -673,10 +659,10 @@ openBasicChannel(aid: number[], p2: number): Promise<Channel>
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | -------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| p2 | number | 在该channel上执行的SELECT APDU的P2参数。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | -------- | ------ | ------------------------------------------------------------ |
| aid | number[] | 是 | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| p2 | number | 是 |在该channel上执行的SELECT APDU的P2参数。 |
**返回值:**
......@@ -700,23 +686,22 @@ openBasicChannel(aid: number[], p2: number): Promise<Channel>
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
p2: number = 0x00;
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
let p2 = 0x00;
try {
// refer to Reader.openSession for this.nfcOmaSession
let getPromise = this.nfcOmaSession.openBasicChannel(this.aidArray, this.p2);
let getPromise = nfcOmaSession.openBasicChannel(aidArray, p2);
getPromise.then((channel) => {
this.nfcOmaChannel = channel;
this.result = "openBasicChannel3 get channel successfully";
nfcOmaChannel = channel;
console.log("openBasicChannel3 get channel successfully");
}).catch ((err) => {
this.result = "openBasicChannel3 exception";
console.log("openBasicChannel3 exception");
});
} catch (e) {
this.result = "openBasicChannel3 exception:" + e.message;
console.log("openBasicChannel3 exception:" + e.message);
}
```
......@@ -730,11 +715,11 @@ openBasicChannel(aid: number[], p2:number, callback: AsyncCallback<Channel>): vo
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number[] | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| callback | AsyncCallback<Channel> | callback返回可用Channel对象实例。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
| aid | number[] | 是 | 在此channel上选择的applet的AID数组或null 如果没有applet被选择。 |
| p2 | number | 是 | 此channel上执行SELECT APDU命令的P2参数。 |
| callback | AsyncCallback<Channel> | 是 | callback返回可用Channel对象实例。 |
**错误码:**
......@@ -752,24 +737,24 @@ openBasicChannel(aid: number[], p2:number, callback: AsyncCallback<Channel>): vo
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
p2: number = 0x00;
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
let p2 = 0x00;
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaSession.openBasicChannel(this.aidArray, this.p2, (error, data) => {
nfcOmaSession.openBasicChannel(aidArray, p2, (error, data) => {
if (error) {
this.result = "openBasicChannel4 failed:" + JSON.stringify(error);
console.log("openBasicChannel4 failed:" + JSON.stringify(error));
return;
}
this.nfcOmaChannel = data;
this.result = "openBasicChannel4 get channel successfully";
nfcOmaChannel = data;
console.log("openBasicChannel4 get channel successfully");
});
} catch (e) {
this.result = "openBasicChannel4 exception:" + e.message;
console.log("openBasicChannel4 exception:" + e.message);
}
```
......@@ -783,9 +768,9 @@ openLogicalChannel(aid: number[]): Promise<Channel>
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | -------- | --------------------------------------- |
| aid | number[] | 在该Channel对象上选择的applet AID数组。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | -------- | ------ | --------------------------------------- |
| aid | number[] | 是 | 在该Channel对象上选择的applet AID数组。 |
**返回值:**
......@@ -809,22 +794,21 @@ openLogicalChannel(aid: number[]): Promise<Channel>
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
try {
// refer to Reader.openSession for this.nfcOmaSession
let getPromise = this.nfcOmaSession.openLogicalChannel(this.aidArray)
let getPromise = nfcOmaSession.openLogicalChannel(aidArray)
getPromise.then((channel) => {
this.nfcOmaChannel = channel;
this.result = "openLogicChannel1 get channel successfully";
nfcOmaChannel = channel;
console.log("openLogicChannel1 get channel successfully");
}).catch ((err) => {
this.result = "openLogicChannel1 exception:" + err.message;
console.log("openLogicChannel1 exception:" + err.message);
});
} catch (e) {
this.result = "openLogicChannel1 exception:" + e.message;
console.log("openLogicChannel1 exception:" + e.message);
}
```
......@@ -838,10 +822,10 @@ try {
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number[] | 在该Channel对象上被选择的applet AID数组。 |
| callback | AsyncCallback<Channel> | callback返回可用Channel对象实例,SE不能提供新的channel或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
| aid | number[] | 是 | 在该Channel对象上被选择的applet AID数组。 |
| callback | AsyncCallback<Channel> | 是 | callback返回可用Channel对象实例,SE不能提供新的channel或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。 |
**错误码:**
......@@ -859,23 +843,22 @@ try {
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaSession.openLogicalChannel(this.aidArray, (error, data) => {
nfcOmaSession.openLogicalChannel(aidArray, (error, data) => {
if (error) {
this.result = "openLogicChannel2 failed:" + JSON.stringify(error);
console.log("openLogicChannel2 failed:" + JSON.stringify(error));
return;
}
this.nfcOmaChannel = data;
this.result = "openLogicChannel2 get channel successfully";
nfcOmaChannel = data;
console.log("openLogicChannel2 get channel successfully");
});
} catch (e) {
this.result = "openLogicChannel2 exception:" + e.message;
console.log("openLogicChannel2 exception:" + e.message);
}
```
......@@ -895,10 +878,10 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | -------- | ----------------------------------------- |
| aid | number[] | 在该Channel对象上被选择的applet AID数组。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | -------- | ------ | ----------------------------------------- |
| aid | number[] | 是 | 在该Channel对象上被选择的applet AID数组。 |
| p2 | number | 是 | 此channel上执行SELECT APDU命令的P2参数。 |
**错误码:**
......@@ -916,24 +899,24 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
p2: number = 0x00;
if (this.nfcOmaSession) {
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
let p2 = 0x00;
if (nfcOmaSession) {
try {
// refer to Reader.openSession for this.nfcOmaSession
let getPromise = this.nfcOmaSession.openLogicalChannel(this.aidArray, this.p2);
let getPromise = nfcOmaSession.openLogicalChannel(aidArray, p2);
getPromise.then((channel) => {
this.nfcOmaChannel = channel;
this.result = "openLogicChannel3 get channel successfully";
nfcOmaChannel = channel;
console.log("openLogicChannel3 get channel successfully");
}).catch ((err) => {
this.result = "openLogicChannel3 exception";
console.log("openLogicChannel3 exception");
})
} catch (e) {
this.result = "openLogicChannel3 exception:" + e.message;
console.log("openLogicChannel3 exception:" + e.message);
}
```
......@@ -953,11 +936,11 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | ---------------------- | ------------------------------------------------------------ |
| aid | number[] | 在该Channel对象上被选择的applet AID数组。 |
| p2 | number | 此channel上执行SELECT APDU命令的P2参数。 |
| callback | AsyncCallback<Channel> | callback返回可用Channel对象实例,SE不能提供新的Channel对象或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | ---------------------- | ------ | ------------------------------------------------------------ |
| aid | number[] | 是 | 在该Channel对象上被选择的applet AID数组。 |
| p2 | number | 是 | 此channel上执行SELECT APDU命令的P2参数。 |
| callback | AsyncCallback<Channel> | 是 | callback返回可用Channel对象实例,SE不能提供新的Channel对象或因缺乏可用逻辑Channel对象无法获取访问控制规则返回null。 |
**错误码:**
......@@ -975,24 +958,23 @@ P2通常为0x00。设备应允许P2的任何值,并且应允许以下值: 0x
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
aidArray: number[] = [720, 1080];
p2: number = 0x00;
let nfcOmaSession = null;
let nfcOmaChannel = null;
let aidArray = [720, 1080];
let p2 = 0x00;
try {
// refer to Reader.openSession for this.nfcOmaSession
this.nfcOmaSession.openLogicalChannel(this.aidArray, this.p2, (error, data) => {
nfcOmaSession.openLogicalChannel(aidArray, p2, (error, data) => {
if (error) {
this.result = "openLogicChannel4 failed:" + JSON.stringify(error);
console.log("openLogicChannel4 failed:" + JSON.stringify(error));
return;
}
this.nfcOmaChannel = data;
this.result = "openLogicChannel4 get channel successfully";
nfcOmaChannel = data;
console.log("openLogicChannel4 get channel successfully");
})
} catch (e) {
this.result = "openLogicChannel4 exception:" + e.message;
console.log("openLogicChannel4 exception:" + e.message);
}
```
......@@ -1015,20 +997,19 @@ try {
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
let nfcOmaSession = null;
let nfcOmaChannel = null;
try {
// refer to Session.openBasicChannel for this.nfcOmaChannel
let ret = this.nfcOmaChannel.getSession();
let ret = nfcOmaChannel.getSession();
if (ret) {
this.result = "get session successfully";
console.log("get session successfully");
} else {
this.result = "get session failed";
console.log("get session failed");
}
} catch (e) {
this.result = "getSession exception:" + e.message;
console.log("getSession exception:" + e.message);
}
```
......@@ -1045,16 +1026,15 @@ close(): void
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaSession: secureElement.Session = null;
@State nfcOmaChannel: secureElement.Channel = null;
let nfcOmaSession = null;
let nfcOmaChannel = null;
try {
// refer to Session.openBasicChannel for this.nfcOmaChannel
this.nfcOmaChannel.close();
this.result = "channel close successfully";
nfcOmaChannel.close();
console.log("channel close successfully");
} catch (e) {
this.result = "channel close exception:" + e.message;
console.log("channel close exception:" + e.message);
}
```
......@@ -1077,19 +1057,18 @@ isBasicChannel(): boolean
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaChannel: secureElement.Channel = null;
let nfcOmaChannel = null;
try {
// refer to Session.openBasicChannel for this.nfcOmaChannel
let ret = this.nfcOmaChannel.isBasicChannel();
let ret = nfcOmaChannel.isBasicChannel();
if (ret) {
this.result = "isBasicChannel TRUE";
console.log("isBasicChannel TRUE");
} else {
this.result = "isBasicChannel FALSE";
console.log("isBasicChannel FALSE");
}
} catch (e) {
this.result = "isBasicChannel异常:" + e.message;
console.log("isBasicChannel异常:" + e.message);
}
```
......@@ -1112,19 +1091,18 @@ isClosed(): boolean
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaChannel: secureElement.Channel = null;
let nfcOmaChannel = null;
try {
// refer to Session.openBasicChannel for this.nfcOmaChannel
let ret = this.nfcOmaChannel.isClosed();
let ret = nfcOmaChannel.isClosed();
if (ret) {
this.result = "channel isClosed TRUE";
console.log("channel isClosed TRUE");
} else {
this.result = "channel isClosed False";
console.log("channel isClosed False");
}
} catch (e) {
this.result = "Channel isClosed exception:" + e.message;
console.log("Channel isClosed exception:" + e.message);
}
```
......@@ -1151,24 +1129,25 @@ getSelectResponse():number[]
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaChannel: secureElement.Channel = null;
let str = '';
let nfcOmaChannel = null;
try {
// refer to Session.openBasicChannel for this.nfcOmaChannel
let ret = this.nfcOmaChannel.getSelectResponse();
let ret = nfcOmaChannel.getSelectResponse();
if (ret) {
this.result = "getSelectResponse result:[";
str = "getSelectResponse result:[";
for (let i = 0; i < ret.length; ++i) {
this.result += ret[i];
this.result += ' ';
str += ret[i];
str += ' ';
}
this.result += ']';
str += ']';
console.log(str);
} else {
this.result = "getSelectResponse result is null";
console.log("getSelectResponse result is null");
}
} catch (e) {
this.result = "getSelectResponse exception:" + e.message;
console.log("getSelectResponse exception:" + e.message);
}
```
......@@ -1182,9 +1161,9 @@ transmit(command: number[]): Promise<number[]>
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | -------- | ------------------------------------- |
| command | number[] | 在该channel上被选择的applet AID数组。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | -------- | ------ | ------------------------------------- |
| command | number[] | 是 | 在该channel上被选择的applet AID数组。 |
**返回值:**
......@@ -1207,25 +1186,25 @@ transmit(command: number[]): Promise<number[]>
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaChannel: secureElement.Channel = null;
let nfcOmaChannel = null;
let str = "";
try {
let command: number[] = [100, 200];
// refer to Session.openBasicChannel for this.nfcOmaChannel
let getPromise = this.nfcOmaChannel.transmit(command);
let getPromise = nfcOmaChannel.transmit(command);
getPromise.then((data) => {
this.result = "transmit1 result:[";
str = "transmit1 result:[";
for (let i = 0; i < data.length; ++i) {
this.result += data[i];
this.result += " ";
str += data[i];
str += " ";
}
this.result += "]";
str += "]";
console.log(str);
}).catch ((err) => {
this.result = "transmit1 exception:" + err.code;
console.log("transmit1 exception:" + err.code);
})
} catch (e) {
this.result = "transit1 exception:" + e.message;
console.log("transit1 exception:" + e.message);
}
```
......@@ -1239,10 +1218,10 @@ transmit(command: number[], callback: AsyncCallback<number[]>): void
**参数:**
| **参数名** | **类型** | **说明** |
| ---------- | ----------------------- | ------------------------------------- |
| command | number[] | 在该Channel上被选择的applet AID数组。 |
| callback | AsyncCallback<number[]> | 返回接收到的响应的回调,number数组。 |
| **参数名** | **类型** | **必填** | **说明** |
| ---------- | ----------------------- | ------ | ------------------------------------- |
| command | number[] | 是 | 在该Channel上被选择的applet AID数组。 |
| callback | AsyncCallback<number[]> | 是 | 返回接收到的响应的回调,number数组。 |
**错误码:**
......@@ -1259,25 +1238,26 @@ transmit(command: number[], callback: AsyncCallback<number[]>): void
```js
import secureElement from '@ohos.secureElement';
@State result: string = '';
@State nfcOmaChannel: secureElement.Channel = null;
let str = "";
let nfcOmaChannel = null;
try {
let command: number[] = [100, 200];
// refer to Session.openBasicChannel for this.nfcOmaChannel
this.nfcOmaChannel.transmit(command, (error, data) => {
nfcOmaChannel.transmit(command, (error, data) => {
if (error) {
this.result = "transmit2 exception:" + JSON.stringify(error);
console.log("transmit2 exception:" + JSON.stringify(error));
return;
}
this.result = "transmit2 result:[";
str = "transmit2 result:[";
for (let i = 0; i < data.length; ++i) {
this.result += data[i];
this.result += " ";
str += data[i];
str += " ";
}
this.result += "]";
str += "]";
console.log(str)
});
} catch (e) {
this.result = "transit2 exception:" + e.message;
console.log("transit2 exception:" + e.message);
}
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册