本模塊主要用于采用不同Nfc技術(shù)的Tag的讀寫操作。
本模塊首批接口從API version 7開始支持。后續(xù)版本的新增接口,采用上角標(biāo)單獨(dú)標(biāo)記接口的起始版本。
NfcATag 提供 NFC-A(ISO 14443-3A)技術(shù)的屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是NfcATag的獨(dú)有接口。
getSak(): number
獲取NFC-A標(biāo)簽的SAK值。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number | NfcA 標(biāo)簽的SAK值,十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcA' correctly.
- let sak = nfcA.getSak();
- console.log("nfcA sak: " + sak);
getAtqa(): number[]
獲取NFC-A標(biāo)簽的Atqa值。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | NfcA 標(biāo)簽的Atqa值,每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcA' correctly.
- let atqa = nfcA.getAtqa();
- console.log("nfcA atqa: " + atqa);
NfcBTag 提供對(duì)NFC-B(ISO 14443-3B)技術(shù)的屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類,提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是NfcBTag的獨(dú)有接口。
getRespAppData(): number[]
獲取標(biāo)簽的應(yīng)用程序數(shù)據(jù)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | NfcB 標(biāo)簽的應(yīng)用程序數(shù)據(jù),每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcB' correctly.
- let respAppData = nfcB.getRespAppData();
- console.log("nfcB respAppData: " + respAppData);
getRespProtocol(): number[]
獲取標(biāo)簽的協(xié)議信息。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | NfcB 標(biāo)簽的協(xié)議信息,每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcB' correctly.
- let respProtocol = nfcB.getRespProtocol();
- console.log("nfcB respProtocol: " + respProtocol);
NfcFTag 提供對(duì)NFC-F(JIS 6319-4)技術(shù)的屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是NfcFTag的獨(dú)有接口。
getSystemCode(): number[]
從標(biāo)簽實(shí)例獲取系統(tǒng)代碼。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | NfcF 標(biāo)簽的系統(tǒng)代碼,每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcF' correctly.
- let systemCode = nfcF.getSystemCode();
- console.log("nfcF systemCode: " + systemCode);
getPmm(): number[]
從標(biāo)簽實(shí)例獲取PMm(由IC代碼和制造商參數(shù)組成)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | NfcF 標(biāo)簽的PMm信息,每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcF' correctly.
- let pmm = nfcF.getPmm();
- console.log("nfcF pmm: " + pmm);
NfcVTag 提供對(duì)NFC-V(ISO 15693)技術(shù)的屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是NfcVTag的獨(dú)有接口。
getResponseFlags(): number
從標(biāo)簽實(shí)例實(shí)例獲取響應(yīng)標(biāo)志。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number | NfcV 標(biāo)簽的響應(yīng)標(biāo)志,十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcV' correctly.
- let responseFlags = nfcV.getResponseFlags();
- console.log("nfcV responseFlags: " + responseFlags);
getDsfId(): number
從標(biāo)簽實(shí)例實(shí)例獲取數(shù)據(jù)存儲(chǔ)格式標(biāo)識(shí)符(DSFID)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number | NfcV 標(biāo)簽的數(shù)據(jù)存儲(chǔ)格式標(biāo)識(shí)符,十六進(jìn)制表示,范圍是0x00~0xFF。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'nfcV' correctly.
- let dsfId = nfcV.getDsfId();
- console.log("nfcV dsfId: " + dsfId);
IsoDepTag 提供對(duì)ISO-DEP(ISO 14443-4)技術(shù)的屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是IsoDepTag的獨(dú)有接口。
getHistoricalBytes(): number[]
獲取標(biāo)簽的歷史字節(jié),針對(duì)基于NfcA通信技術(shù)的IsoDep卡片。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | IsoDepTag 標(biāo)簽的歷史字節(jié),每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。如果該IsoDep類型Tag是基于NfcB技術(shù)的,則該返回值為空。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'isoDep' correctly.
- let historicalBytes = isoDep.getHistoricalBytes();
- console.log("isoDep historicalBytes: " + historicalBytes);
getHiLayerResponse(): number[]
獲取標(biāo)簽的更高層響應(yīng)字節(jié),針對(duì)基于NfcB通信技術(shù)的IsoDep卡片。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number[] | IsoDepTag 標(biāo)簽的更高層響應(yīng)字節(jié),每個(gè)number十六進(jìn)制表示,范圍是0x00~0xFF。如果該IsoDep類型Tag是基于NfcA技術(shù)的,則該返回值為空。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'isoDep' correctly.
- let hiLayerResponse = isoDep.getHiLayerResponse();
- console.log("isoDep hiLayerResponse: " + hiLayerResponse);
isExtendedApduSupported(): Promise<boolean>
檢查是否支持?jǐn)U展的APDU,使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
Promise<boolean> | 檢查結(jié)果,true: 支持, false: 不支持。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'isoDep' correctly.
- // connect the tag at first if not connected.
- if (!isoDep.isTagConnected()) {
- if (!isoDep.connectTag()) {
- console.log("isoDep connectTag failed.");
- return;
- }
- }
- try {
- isoDep.isExtendedApduSupported().then((response) => {
- console.log("isoDep isExtendedApduSupported Promise response: " + response);
- }).catch((err)=> {
- console.log("isoDep isExtendedApduSupported Promise err: " + err);
- });
- } catch (busiError) {
- console.log("isoDep isExtendedApduSupported Promise busiError: " + busiError);
- }
isExtendedApduSupported(callback: AsyncCallback<boolean>): void
檢查是否支持?jǐn)U展的APDU,使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
callback | AsyncCallback<boolean> | 是 | 回調(diào)函數(shù),true: 支持, false: 不支持。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'isoDep' correctly.
- // connect the tag at first if not connected.
- if (!isoDep.isTagConnected()) {
- if (!isoDep.connectTag()) {
- console.log("isoDep connectTag failed.");
- return;
- }
- }
- try {
- isoDep.isExtendedApduSupported((err, response)=> {
- if (err) {
- console.log("isoDep isExtendedApduSupported AsyncCallback err: " + err);
- } else {
- console.log("isoDep isExtendedApduSupported AsyncCallback response: " + response);
- }
- });
- } catch (busiError) {
- console.log("isoDep isExtendedApduSupported AsyncCallback busiError: " + busiError);
- }
getNdefRecords(): tag.NdefRecord[]
獲取NDEF消息中的所有記錄。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
tag.NdefRecord[] | NDEF標(biāo)簽的Record列表,詳見NDEF技術(shù)規(guī)范《NFCForum-TS-NDEF_1.0》。 |
示例:
- import tag from '@ohos.nfc.tag';
- // Obtains ndefMessage from tag.ndef.createNdefMessage or ndefTag.getNdefMessage.
- // var ndefMessage = tag.ndef.createNdefMessage(...);
- // var ndefMessage = ndefTag.getNdefMessage();
- let ndefRecords = ndefMessage.getNdefRecords();
- console.log("ndef ndefRecords number: " + ndefRecords.length);
提供對(duì)已格式化為NDEF的NFC標(biāo)簽的數(shù)據(jù)和操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是NdefTag的獨(dú)有接口。
getNdefTagType(): tag.NfcForumType
獲取NDEF標(biāo)簽的類型。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
tag.NfcForumType | NDEF標(biāo)簽類型,包括NFC FORUM TYPE 1/2/3/4等。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- let ndefTagType = ndefTag.getNdefTagType();
- console.log("ndef ndefTagType: " + ndefTagType);
getNdefMessage(): NdefMessage
獲取發(fā)現(xiàn)NDEF標(biāo)簽時(shí),從標(biāo)簽讀取的Message。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
NdefMessage | NDEF標(biāo)簽的Message,詳見NDEF技術(shù)規(guī)范《NFCForum-TS-NDEF_1.0》。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- let ndefMessage = ndefTag.getNdefMessage();
- console.log("ndef ndefMessage: " + ndefMessage);
isNdefWritable(): boolean;
檢查NDEF標(biāo)簽是否可寫。在調(diào)用寫數(shù)據(jù)接口前,需要先判斷是否支持寫操作。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
boolean | 檢查結(jié)果,true: 可寫, false: 不可寫。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- var isWritable = ndefTag.isNdefWritable();
- console.log("ndef isNdefWritable: " + isWritable);
readNdef(): Promise<NdefMessage>
讀取標(biāo)簽上的NDEF消息,使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
Promise<NdefMessage> | 以Promise形式返回從NDEF標(biāo)簽中讀取到的Message數(shù)據(jù)對(duì)象。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- // connect the tag at first if not connected.
- if (!ndefTag.isTagConnected()) {
- if (!ndefTag.connectTag()) {
- console.log("ndefTag connectTag failed.");
- return;
- }
- }
- try {
- ndefTag.readNdef().then((ndefmessage) => {
- console.log("ndef readNdef Promise ndefmessage: " + ndefmessage);
- }).catch((err)=> {
- console.log("ndef readNdef Promise err: " + err);
- });
- } catch (busiError) {
- console.log("ndef readNdef Promise catched busiError: " + busiError);
- }
readNdef(callback: AsyncCallback<NdefMessage>): void
讀取標(biāo)簽上的NDEF消息,使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
callback | AsyncCallback<NdefMessage> | 是 | 回調(diào)函數(shù),返回從NDEF標(biāo)簽中讀取到的Message信息。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- // connect the tag at first if not connected.
- if (!ndefTag.isTagConnected()) {
- if (!ndefTag.connectTag()) {
- console.log("ndefTag connectTag failed.");
- return;
- }
- }
- try {
- ndefTag.readNdef((err, ndefmessage)=> {
- if (err) {
- console.log("ndef readNdef AsyncCallback err: " + err);
- } else {
- console.log("ndef readNdef AsyncCallback ndefmessage: " + ndefmessage);
- }
- });
- } catch (busiError) {
- console.log("ndef readNdef AsyncCallback catched busiError: " + busiError);
- }
writeNdef(msg: NdefMessage): Promise<void>;
將NDEF Messsage數(shù)據(jù)對(duì)象寫入標(biāo)簽,使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
msg | NdefMessage | 是 | NDEF Message數(shù)據(jù)對(duì)象。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- // ndefMessage created from raw data, such as:
- let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record.
- // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[])
- // connect the tag at first if not connected.
- if (!ndefTag.isTagConnected()) {
- if (!ndefTag.connectTag()) {
- console.log("ndefTag connectTag failed.");
- return;
- }
- }
- try {
- ndefTag.writeNdef(ndefMessage).then(() => {
- console.log("ndef writeNdef Promise success.");
- }).catch((err)=> {
- console.log("ndef writeNdef err: " + err);
- });
- } catch (busiError) {
- console.log("ndef writeNdef Promise catch busiError: " + busiError);
- }
writeNdef(msg: NdefMessage, callback: AsyncCallback<void>): void
將NDEF Message數(shù)據(jù)對(duì)象寫入此標(biāo)簽,使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
msg | NdefMessage | 是 | NDEF Message數(shù)據(jù)對(duì)象。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- // ndefMessage created from raw data, such as:
- let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record.
- // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[])
- // connect the tag at first if not connected.
- if (!ndefTag.isTagConnected()) {
- if (!ndefTag.connectTag()) {
- console.log("ndefTag connectTag failed.");
- return;
- }
- }
- try {
- ndefTag.writeNdef(ndefMessage, (err)=> {
- if (err) {
- console.log("ndef writeNdef AsyncCallback err: " + err);
- } else {
- console.log("ndef writeNdef AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("ndef writeNdef AsyncCallback catch busiError: " + busiError);
- }
canSetReadOnly(): boolean
檢查NDEF標(biāo)簽是否可以設(shè)置為只讀。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
boolean | true: NDEF標(biāo)簽可設(shè)置為只讀, false: NDEF標(biāo)簽不可設(shè)置為只讀。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- var canSetReadOnly = ndefTag.canSetReadOnly();
- console.log("ndef canSetReadOnly: " + canSetReadOnly);
setReadOnly(): Promise<void>
將NDEF標(biāo)簽設(shè)置為只讀,使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- // connect the tag at first if not connected.
- if (!ndefTag.isTagConnected()) {
- if (!ndefTag.connectTag()) {
- console.log("ndefTag connectTag failed.");
- return;
- }
- }
- try {
- ndefTag.setReadOnly().then(() => {
- console.log("ndef setReadOnly Promise success.");
- }).catch((err)=> {
- console.log("ndef setReadOnly Promise err: " + err);
- });
- } catch (busiError) {
- console.log("ndef setReadOnly Promise catch busiError: " + busiError);
- }
setReadOnly(callback: AsyncCallback<void>): void
將NDEF標(biāo)簽設(shè)置為只讀,使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- // connect the tag at first if not connected.
- if (!ndefTag.isTagConnected()) {
- if (!ndefTag.connectTag()) {
- console.log("ndefTag connectTag failed.");
- return;
- }
- }
- try {
- ndefTag.setReadOnly((err)=> {
- if (err) {
- console.log("ndef setReadOnly AsyncCallback err: " + err);
- } else {
- console.log("ndef setReadOnly AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("ndef setReadOnly AsyncCallback catch busiError: " + busiError);
- }
getNdefTagTypeString(type: tag.NfcForumType): string
將NFC論壇類型,轉(zhuǎn)換為NFC論壇中定義的字符串描述。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
type | tag.NfcForumType | 是 | NDEF標(biāo)簽類型,包括NFC FORUM TYPE 1/2/3/4等。 |
返回值:
類型 | 說明 |
---|---|
string | NFC論壇類型的字符串描述。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefTag' correctly.
- try {
- let ndefTypeString = ndefTag.getNdefTagTypeString(tag.NFC_FORUM_TYPE_1);
- console.log("ndef ndefTypeString: " + ndefTypeString);
- } catch (busiError) {
- console.log("ndef getNdefTagTypeString catch busiError: " + busiError);
- }
MifareClassicTag提供對(duì)MIFARE Classic屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是MifareClassicTag的獨(dú)有接口。
authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean): Promise<void>
使用密鑰對(duì)扇區(qū)進(jìn)行身份驗(yàn)證,只有身份驗(yàn)證成功的扇區(qū)可以進(jìn)行操作。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
sectorIndex | number | 是 | 待驗(yàn)證的扇區(qū)索引,從0開始。 |
key | number[] | 是 | 用于扇區(qū)驗(yàn)證的密鑰(6字節(jié))。 |
isKeyA | boolean | 是 | isKeyA標(biāo)志。true 表示KeyA,false 表示KeyB。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let sectorIndex = 1; // change it to be correct index.
- let key = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06] // MUST be 6 bytes, change it to be correct key.
- mifareClassic.authenticateSector(sectorIndex, key, true).then(() => {
- console.log("mifareClassic authenticateSector Promise success.");
- }).catch((err)=> {
- console.log("mifareClassic authenticateSector Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic authenticateSector Promise catch busiError: " + busiError);
- }
authenticateSector(sectorIndex: number, key: number[], isKeyA: boolean, callback: AsyncCallback<void>): void
使用密鑰對(duì)扇區(qū)進(jìn)行身份驗(yàn)證,只有身份驗(yàn)證成功的扇區(qū)可以進(jìn)行操作。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
sectorIndex | number | 是 | 待驗(yàn)證的扇區(qū)索引,從0開始。 |
key | number[] | 是 | 用于扇區(qū)驗(yàn)證的密鑰(6字節(jié))。 |
isKeyA | boolean | 是 | isKeyA標(biāo)志。true 表示KeyA,false 表示KeyB。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let sectorIndex = 1; // change it to be correct index.
- let key = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06] // MUST be 6 bytes, change it to be correct key.
- mifareClassic.authenticateSector(sectorIndex, key, true, (err)=> {
- if (err) {
- console.log("mifareClassic authenticateSector AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic authenticateSector AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareClassic authenticateSector AsyncCallback catch busiError: " + busiError);
- }
readSingleBlock(blockIndex: number): Promise<number[]>
讀取標(biāo)簽中一個(gè)塊存儲(chǔ)的內(nèi)容,一個(gè)塊大小為16字節(jié)。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要讀取的塊索引,從0開始。 |
返回值:
類型 | 說明 |
---|---|
Promise<number[]> | 讀取的塊數(shù)據(jù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- mifareClassic.readSingleBlock(blockIndex).then((data) => {
- console.log("mifareClassic readSingleBlock Promise data: " + data);
- }).catch((err)=> {
- console.log("mifareClassic readSingleBlock Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic readSingleBlock Promise catch busiError: " + busiError);
- }
readSingleBlock(blockIndex: number, callback: AsyncCallback<number[]>): void
讀取標(biāo)簽中一個(gè)塊存儲(chǔ)的內(nèi)容,一個(gè)塊大小為16字節(jié)。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要讀取的塊索引,從0開始。 |
callback | AsyncCallback<number[]> | 是 | 回調(diào)函數(shù),返回讀取到的數(shù)據(jù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- mifareClassic.readSingleBlock(blockIndex, (err, data)=> {
- if (err) {
- console.log("mifareClassic readSingleBlock AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic readSingleBlock AsyncCallback data: " + data);
- }
- });
- } catch (busiError) {
- console.log("mifareClassic readSingleBlock AsyncCallback catch busiError: " + busiError);
- }
writeSingleBlock(blockIndex: number, data: number[]): Promise<void>
向標(biāo)簽中一個(gè)塊存儲(chǔ)寫入內(nèi)容,一個(gè)塊大小為16字節(jié)。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要寫入的塊索引,從0開始。 |
data | number[] | 是 | 要寫入的數(shù)據(jù),大小必須是16個(gè)字節(jié)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- let rawData = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
- 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]; // MUST be 16 bytes, change it to be correct data.
- mifareClassic.writeSingleBlock(blockIndex, rawData).then(() => {
- console.log("mifareClassic writeSingleBlock Promise success.");
- }).catch((err)=> {
- console.log("mifareClassic writeSingleBlock Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic writeSingleBlock Promise catch busiError: " + busiError);
- }
writeSingleBlock(blockIndex: number, data: number[], callback: AsyncCallback<void>): void
向標(biāo)簽中一個(gè)塊存儲(chǔ)寫入內(nèi)容,一個(gè)塊大小為16字節(jié)。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要寫入的塊索引,從0開始。 |
data | number[] | 是 | 要寫入的數(shù)據(jù),大小必須是16個(gè)字節(jié)。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- let rawData = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
- 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10]; // MUST be 16 bytes, change it to be correct data.
- mifareClassic.writeSingleBlock(blockIndex, rawData, (err)=> {
- if (err) {
- console.log("mifareClassic writeSingleBlock AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic writeSingleBlock AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareClassic writeSingleBlock AsyncCallback catch busiError: " + busiError);
- }
incrementBlock(blockIndex: number, value: number): Promise<void>
對(duì)指定塊的內(nèi)容,增加指定的數(shù)值。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要指定增加的塊索引,從0開始。 |
value | number | 是 | 要指定增加的數(shù)據(jù),非負(fù)數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- let value = 0x20; // change it to be correct data.
- mifareClassic.incrementBlock(blockIndex, value).then(() => {
- console.log("mifareClassic incrementBlock Promise success.");
- }).catch((err)=> {
- console.log("mifareClassic incrementBlock Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic incrementBlock Promise catch busiError: " + busiError);
- }
incrementBlock(blockIndex: number, value: number, callback: AsyncCallback<void>): void
對(duì)指定塊的內(nèi)容,增加指定的數(shù)值。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要被運(yùn)算的塊索引,從0開始。 |
value | number | 是 | 要增加的數(shù)值,非負(fù)數(shù)。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- let value = 0x20; // change it to be correct data.
- mifareClassic.incrementBlock(blockIndex, value, (err)=> {
- if (err) {
- console.log("mifareClassic incrementBlock AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic incrementBlock AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareClassic incrementBlock AsyncCallback catch busiError: " + busiError);
- }
decrementBlock(blockIndex: number, value: number): Promise<void>
對(duì)指定塊的內(nèi)容,減少指定的數(shù)值。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要被運(yùn)算的塊索引,從0開始。 |
value | number | 是 | 要減少的數(shù)值,非負(fù)數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- let value = 0x20; // change it to be correct data.
- mifareClassic.decrementBlock(blockIndex, value).then(() => {
- console.log("mifareClassic decrementBlock Promise success.");
- }).catch((err)=> {
- console.log("mifareClassic decrementBlock Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic decrementBlock Promise catch busiError: " + busiError);
- }
decrementBlock(blockIndex: number, value: number, callback: AsyncCallback<void>): void
對(duì)指定塊的內(nèi)容,減少指定的數(shù)值。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 要被運(yùn)算的塊索引,從0開始。 |
value | number | 是 | 要減少的數(shù)值,非負(fù)數(shù)。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- let value = 0x20; // change it to be correct data.
- mifareClassic.decrementBlock(blockIndex, value, (err)=> {
- if (err) {
- console.log("mifareClassic decrementBlock AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic decrementBlock AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareClassic decrementBlock AsyncCallback catch busiError: " + busiError);
- }
transferToBlock(blockIndex: number): Promise<void>
將臨時(shí)寄存器的值轉(zhuǎn)移到指定的塊。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 被操作的塊的索引,從0開始。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- mifareClassic.transferToBlock(blockIndex).then(() => {
- console.log("mifareClassic transferToBlock Promise success.");
- }).catch((err)=> {
- console.log("mifareClassic transferToBlock Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic transferToBlock Promise catch busiError: " + busiError);
- }
transferToBlock(blockIndex: number, callback: AsyncCallback<void>): void
將臨時(shí)寄存器的值轉(zhuǎn)移到指定的塊。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 被操作的塊的索引,從0開始。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- mifareClassic.transferToBlock(blockIndex, (err)=> {
- if (err) {
- console.log("mifareClassic transferToBlock AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic transferToBlock AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareClassic transferToBlock AsyncCallback catch busiError: " + busiError);
- }
restoreFromBlock(blockIndex: number): Promise<void>
將指定塊的值復(fù)制到臨時(shí)寄存器。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 被操作的塊的索引,從0開始。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- mifareClassic.restoreFromBlock(blockIndex).then(() => {
- console.log("mifareClassic restoreFromBlock Promise success.");
- }).catch((err)=> {
- console.log("mifareClassic restoreFromBlock Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareClassic restoreFromBlock Promise catch busiError: " + busiError);
- }
restoreFromBlock(blockIndex: number, callback: AsyncCallback<void>): void
將指定塊的值復(fù)制到臨時(shí)寄存器。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 被操作的塊的索引,從0開始。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- // connect the tag at first if not connected.
- if (!mifareClassic.isTagConnected()) {
- if (!mifareClassic.connectTag()) {
- console.log("mifareClassic connectTag failed.");
- return;
- }
- }
- try {
- let blockIndex = 1; // change it to be correct index.
- mifareClassic.restoreFromBlock(blockIndex, (err)=> {
- if (err) {
- console.log("mifareClassic restoreFromBlock AsyncCallback err: " + err);
- } else {
- console.log("mifareClassic restoreFromBlock AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareClassic restoreFromBlock AsyncCallback catch busiError: " + busiError);
- }
getSectorCount(): number
獲取MIFARE Classic標(biāo)簽中的扇區(qū)數(shù)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number | 標(biāo)簽中的扇區(qū)數(shù)量。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- let sectorCount = mifareClassic.getSectorCount();
- console.log("mifareClassic sectorCount: " + sectorCount);
getBlockCountInSector(sectorIndex: number): number
獲取指定扇區(qū)中的塊數(shù)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
sectorIndex | number | 是 | 扇區(qū)序號(hào),從0開始。 |
返回值:
類型 | 說明 |
---|---|
number | 該扇區(qū)內(nèi)的塊數(shù)量。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- try {
- let sectorIndex = 1; // change it to be correct index.
- let blockCnt = mifareClassic.getBlockCountInSector(sectorIndex);
- console.log("mifareClassic blockCnt: " + blockCnt);
- } catch (busiError) {
- console.log("mifareClassic getBlockCountInSector catch busiError: " + busiError);
- }
getType(): tag.MifareClassicType
獲取MIFARE Classic標(biāo)簽的類型。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
tag.MifareClassicType | MifareClassic標(biāo)簽的類型。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- let getType = mifareClassic.getType();
- console.log("mifareClassic getType: " + getType);
getTagSize(): number
獲取標(biāo)簽的存儲(chǔ)空間大小,具體請(qǐng)參見MifareClassicSize。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
number | 標(biāo)簽的大小,單位為字節(jié),請(qǐng)參見MifareClassicSize。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- let tagSize = mifareClassic.getTagSize();
- console.log("mifareClassic tagSize: " + tagSize);
isEmulatedTag(): boolean
檢查標(biāo)簽是不是被模擬的。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
boolean | 檢查結(jié)果,true: 是;false:否。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- let isEmulatedTag = mifareClassic.isEmulatedTag();
- console.log("mifareClassic isEmulatedTag: " + isEmulatedTag);
getBlockIndex(sectorIndex: number): number
獲取特定扇區(qū)的第一個(gè)塊的序號(hào)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
sectorIndex | number | 是 | 扇區(qū)序號(hào),從0開始。 |
返回值:
類型 | 說明 |
---|---|
number | 該扇區(qū)內(nèi)的第一個(gè)塊的序號(hào),從0開始。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- try {
- let sectorIndex = 1; // change it to be correct index.
- let blockIndex = mifareClassic.getBlockIndex(sectorIndex);
- console.log("mifareClassic blockIndex: " + blockIndex);
- } catch (busiError) {
- console.log("mifareClassic getBlockIndex catch busiError: " + busiError);
- }
getSectorIndex(blockIndex: number): number
獲取包含指定塊號(hào)的扇區(qū)序號(hào)。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
blockIndex | number | 是 | 塊序號(hào),從0開始。 |
返回值:
類型 | 說明 |
---|---|
number | 扇區(qū)序號(hào),從0開始。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareClassic' correctly.
- try {
- let blockIndex = 1; // change it to be correct index.
- let sectorIndex = mifareClassic.getSectorIndex(blockIndex);
- console.log("mifareClassic sectorIndex: " + sectorIndex);
- } catch (busiError) {
- console.log("mifareClassic getSectorIndex catch busiError: " + busiError);
- }
MifareUltralightTag 提供對(duì)MIFARE Ultralight屬性和I/O操作的訪問,繼承自TagSession。
TagSession是所有NFC Tag技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是MifareUltralightTag的獨(dú)有接口。
readMultiplePages(pageIndex: number): Promise<number[]>
讀取標(biāo)簽的4頁(yè)數(shù)據(jù),共16字節(jié)的數(shù)據(jù)。每個(gè)頁(yè)面數(shù)據(jù)大小為4字節(jié)。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
pageIndex | number | 是 | 要讀取頁(yè)面的索引,從0開始。 |
返回值:
類型 | 說明 |
---|---|
Promise<number[]> | 讀取的4頁(yè)的數(shù)據(jù),共16字節(jié)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareUltralight' correctly.
- // connect the tag at first if not connected.
- if (!mifareUltralight.isTagConnected()) {
- if (!mifareUltralight.connectTag()) {
- console.log("mifareUltralight connectTag failed.");
- return;
- }
- }
- try {
- let pageIndex = 1; // change it to be correct index.
- mifareUltralight.readMultiplePages(pageIndex).then((data) => {
- console.log("mifareUltralight readMultiplePages Promise data = " + data);
- }).catch((err)=> {
- console.log("mifareUltralight readMultiplePages Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareUltralight readMultiplePages Promise catch busiError: " + busiError);
- }
readMultiplePages(pageIndex: number, callback: AsyncCallback<number[]>): void
讀取標(biāo)簽的4頁(yè)數(shù)據(jù),共16字節(jié)的數(shù)據(jù)。每個(gè)頁(yè)面數(shù)據(jù)大小為4字節(jié)。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
pageIndex | number | 是 | 要讀取頁(yè)面的索引,從0開始。 |
callback | AsyncCallback<number[]> | 是 | 回調(diào)函數(shù),返回讀取到的數(shù)據(jù),共16字節(jié)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareUltralight' correctly.
- // connect the tag at first if not connected.
- if (!mifareUltralight.isTagConnected()) {
- if (!mifareUltralight.connectTag()) {
- console.log("mifareUltralight connectTag failed.");
- return;
- }
- }
- try {
- let pageIndex = 1; // change it to be correct index.
- mifareUltralight.readMultiplePages(pageIndex, (err, data)=> {
- if (err) {
- console.log("mifareUltralight readMultiplePages AsyncCallback err: " + err);
- } else {
- console.log("mifareUltralight readMultiplePages AsyncCallback data: " + data);
- }
- });
- } catch (busiError) {
- console.log("mifareUltralight readMultiplePages AsyncCallback catch busiError: " + busiError);
- }
writeSinglePage(pageIndex: number, data: number[]): Promise<void>
寫入一頁(yè)數(shù)據(jù),數(shù)據(jù)大小為4字節(jié)。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
pageIndex | number | 是 | 要寫入頁(yè)面的索引,從0開始。 |
data | number[] | 是 | 要寫入頁(yè)面的數(shù)據(jù)內(nèi)容,必須是4個(gè)字節(jié)大小。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareUltralight' correctly.
- // connect the tag at first if not connected.
- if (!mifareUltralight.isTagConnected()) {
- if (!mifareUltralight.connectTag()) {
- console.log("mifareUltralight connectTag failed.");
- return;
- }
- }
- try {
- let pageIndex = 1; // change it to be correct index.
- let rawData = [0x01, 0x02, 0x03, 0x04]; // MUST be 4 bytes, change it to be correct raw data.
- mifareUltralight.writeSinglePage(pageIndex, rawData).then(() => {
- console.log("mifareUltralight writeSinglePage Promise success.");
- }).catch((err)=> {
- console.log("mifareUltralight writeSinglePage Promise err: " + err);
- });
- } catch (busiError) {
- console.log("mifareUltralight writeSinglePage Promise catch busiError: " + busiError);
- }
writeSinglePage(pageIndex: number, data: number[], callback: AsyncCallback<void>): void
寫入一頁(yè)數(shù)據(jù),數(shù)據(jù)大小為4字節(jié)。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
pageIndex | number | 是 | 要寫入頁(yè)面的索引,從0開始。 |
data | number[] | 是 | 要寫入頁(yè)面的數(shù)據(jù)內(nèi)容,必須是4個(gè)字節(jié)大小。 |
callback | AsyncCallback<void> | 是 | 回調(diào)函數(shù)。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareUltralight' correctly.
- // connect the tag at first if not connected.
- if (!mifareUltralight.isTagConnected()) {
- if (!mifareUltralight.connectTag()) {
- console.log("mifareUltralight connectTag failed.");
- return;
- }
- }
- try {
- let pageIndex = 1; // change it to be correct index.
- let rawData = [0x01, 0x02, 0x03, 0x04]; // MUST be 4 bytes, change it to be correct raw data.
- mifareUltralight.writeSinglePage(pageIndex, rawData, (err)=> {
- if (err) {
- console.log("mifareUltralight writeSinglePage AsyncCallback err: " + err);
- } else {
- console.log("mifareUltralight writeSinglePage AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("mifareUltralight writeSinglePage AsyncCallback catch busiError: " + busiError);
- }
getType(): tag.MifareUltralightType
獲取MIFARE Ultralight標(biāo)簽的類型。
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
返回值:
類型 | 說明 |
---|---|
tag.MifareUltralightType | MIFARE Ultralight標(biāo)簽的類型。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'mifareUltralight' correctly.
- let getType = mifareClassic.getType();
- console.log("mifareUltralight getType: " + getType);
NdefFormatableTag為NDEF Formattable的標(biāo)簽提供格式化操作,繼承自TagSession。
TagSession是所有NFC Tag 技術(shù)類型的基類, 提供建立連接和發(fā)送數(shù)據(jù)等共同接口。具體請(qǐng)參見TagSession。
以下是NdefFormatableTag的獨(dú)有接口。
format(message: NdefMessage): Promise<void>
將標(biāo)簽格式化為NDEF標(biāo)簽,將NDEF消息寫入NDEF標(biāo)簽。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
message | NdefMessage | 是 | 格式化成功時(shí)要寫入的NDEF消息。可以為null,為null時(shí)僅格式化標(biāo)簽,不寫入內(nèi)容。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefFormatable' correctly.
- // connect the tag at first if not connected.
- if (!ndefFormatable.isTagConnected()) {
- if (!ndefFormatable.connectTag()) {
- console.log("ndefFormatable connectTag failed.");
- return;
- }
- }
- try {
- // ndefMessage created from raw data, such as:
- let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record.
- // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[])
- ndefFormatable.format(ndefMessage).then(() => {
- console.log("ndefFormatable format Promise success.");
- }).catch((err)=> {
- console.log("ndefFormatable format Promise err: " + err);
- });
- } catch (busiError) {
- console.log("ndefFormatable format Promise catch busiError: " + busiError);
- }
format(message: NdefMessage, callback: AsyncCallback<void>): void
將標(biāo)簽格式化為NDEF標(biāo)簽,然后將NDEF消息寫入NDEF標(biāo)簽。使用AsyncCallback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
message | NdefMessage | 是 | 格式化成功時(shí)要寫入的Ndef消息??梢詾閚ull,為null時(shí)僅格式化標(biāo)簽,不寫入內(nèi)容。 |
返回值:
類型 | 說明 |
---|---|
callback: AsyncCallback<void> | 回調(diào)函數(shù)。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefFormatable' correctly.
- // connect the tag at first if not connected.
- if (!ndefFormatable.isTagConnected()) {
- if (!ndefFormatable.connectTag()) {
- console.log("ndefFormatable connectTag failed.");
- return;
- }
- }
- try {
- // ndefMessage created from raw data, such as:
- let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record.
- // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[])
- ndefFormatable.format(ndefMessage, (err)=> {
- if (err) {
- console.log("ndefFormatable format AsyncCallback err: " + err);
- } else {
- console.log("ndefFormatable format AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("ndefFormatable format AsyncCallback catch busiError: " + busiError);
- }
formatReadOnly(message: NdefMessage): Promise<void>
將標(biāo)簽格式化為NDEF標(biāo)簽,將NDEF消息寫入NDEF標(biāo)簽,之后將標(biāo)簽設(shè)置為只讀。使用Promise方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
message | NdefMessage | 是 | 格式化成功時(shí)要寫入的NDEF消息??梢詾閚ull,為null時(shí)僅格式化標(biāo)簽,不寫入內(nèi)容。 |
錯(cuò)誤碼:
以下錯(cuò)誤碼的詳細(xì)介紹請(qǐng)參見NFC錯(cuò)誤碼。
錯(cuò)誤碼ID | 錯(cuò)誤信息 |
---|---|
3100201 | Tag running state is abnormal in service. |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefFormatable' correctly.
- // connect the tag at first if not connected.
- if (!ndefFormatable.isTagConnected()) {
- if (!ndefFormatable.connectTag()) {
- console.log("ndefFormatable connectTag failed.");
- return;
- }
- }
- try {
- // ndefMessage created from raw data, such as:
- let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record.
- // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[])
- ndefFormatable.formatReadOnly(ndefMessage).then(() => {
- console.log("ndefFormatable formatReadOnly Promise success.");
- }).catch((err)=> {
- console.log("ndefFormatable formatReadOnly Promise err: " + err);
- });
- } catch (busiError) {
- console.log("ndefFormatable formatReadOnly Promise catch busiError: " + busiError);
- }
formatReadOnly(message: NdefMessage, callback: AsyncCallback<void>): void
將標(biāo)簽格式化為NDEF標(biāo)簽,然后將NDEF消息寫入NDEF標(biāo)簽,之后將標(biāo)簽設(shè)置為只讀。使用callback方式作為異步方法。
需要權(quán)限: ohos.permission.NFC_TAG
系統(tǒng)能力: SystemCapability.Communication.NFC.Tag
參數(shù):
參數(shù)名 | 類型 | 必填 | 說明 |
---|---|---|---|
message | NdefMessage | 是 | 格式化成功時(shí)要寫入的NDEF消息??梢詾閚ull,為null時(shí)僅格式化標(biāo)簽,不寫入內(nèi)容。 |
返回值:
類型 | 說明 |
---|---|
callback: AsyncCallback<void> | 回調(diào)函數(shù)。 |
示例:
- import tag from '@ohos.nfc.tag';
- // see 'tag.TagInfo' at 'js-apis-nfcTag.md', obtains the 'ndefFormatable' correctly.
- // connect the tag at first if not connected.
- if (!ndefFormatable.isTagConnected()) {
- if (!ndefFormatable.connectTag()) {
- console.log("ndefFormatable connectTag failed.");
- return;
- }
- }
- try {
- // ndefMessage created from raw data, such as:
- let ndefMessage = tag.ndef.createNdefMessage([0xD1, 0x01, 0x03, 0x54, 0x4E, 0x46, 0x43]); // MUST can be parsed as NDEF Record.
- // or ndefMessage created from tag.ndef.createNdefMessage(ndefRecords: NdefRecord[])
- ndefFormatable.formatReadOnly(ndefMessage, (err)=> {
- if (err) {
- console.log("ndefFormatable formatReadOnly AsyncCallback err: " + err);
- } else {
- console.log("ndefFormatable formatReadOnly AsyncCallback success.");
- }
- });
- } catch (busiError) {
- console.log("ndefFormatable formatReadOnly AsyncCallback catch busiError: " + busiError);
- }
更多建議: