簡體   English   中英

Android:重置NFC NTAG213上的動態鎖定時出錯(28h)

[英]Android: Error when resetting Dynamic locks on NFC NTAG213 (28h)

我正在使用NFCA.transceive寫入NTAG213,並且可以成功地寫入保存動態鎖的位置28h,而在標記為空時不會出現任何問題。 但是,當我嘗試將其寫回到默認狀態時,會收到TAG_LOST異常。 其他所有字段都可以重設,例如密碼,AUTH0等。

在規范中,NTAG213表示對特定內存內容具有“撕裂”受保護的寫操作功能,並提到28h。 這和它有關嗎? 我不理解“撕裂”一詞。

我應該提到的是,在我更新之前,我使用了身份驗證,這必須可以正常進行,因為此頁面/位置之外的所有內容都將更改。 我一直在按順序進行寫操作,但沒有任何效果。

相關代碼:

public String resetBDtag(Tag tag) {
    NfcA nfca = NfcA.get(tag);

    String resultString = "";

    byte[] result;
    try {

        nfca.connect();
        try {
        result = nfca.transceive(new byte[]{
                (byte)0x1B,  // Command: password Auth
                (byte)0x93, (byte)0xD0, (byte)0x55, (byte)0xB7
        });} catch (IOException e) {
            Log.e(TAG, "IOException while authenticating :" + resultString, e );
            resultString = "Error authenticating"+ e.toString();
        }



        try {
            result = nfca.transceive(new byte[]{
                    (byte) 0xA2,  // Command: WRITE
                    (byte) 0x29,  // Address: page 0x29 (2)

                    (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0xFF  // CF

            });
        } catch (IOException e) {
            Log.e(TAG, "IOException while resting Auth0 requirement :" + resultString, e );
            resultString = "Error removing Authentication requirement"+ e.toString();;
        }

        try {
            result = nfca.transceive(new byte[]{
                    (byte) 0xA2,  // Command: WRITE
                    (byte) 0x2B,  // Address: page 0x2B (2)

                    (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF  // Password
            });

        } catch (IOException e) {
            Log.e(TAG, "IOException while clearing password :" + resultString, e );
            resultString = "Error clearing password"+ e.toString();;
        }
        try {
            result = nfca.transceive(new byte[]{
                    (byte) 0xA2,  // Command: WRITE
                    (byte) 0x10,  // Address: page 0x10 (2)

                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00  // Status / Count
            });
        } catch (IOException e) {
            Log.e(TAG, "IOException while clearing the status data :" + resultString, e );
            resultString = "Error clearing status data"+ e.toString();;
        }
        try {
            // This does not work!
            result = nfca.transceive(new byte[]{
                    (byte) 0xA2,  // Command: WRITE
                    (byte) 0x28,  // CFG1

                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xBD  // reset CFG1

            });
        } catch (IOException e) {
            Log.e(TAG, "IOException while removing locked pages 18-19 :" + resultString, e );
            resultString = "Error removing locks"+ e.toString();;
        }


    } catch (IOException e) {
        Log.e(TAG, "IOException while writing MifareUltralight :" + resultString, e );
        resultString = "Can not speak to the tag!";
    } finally {
        if (nfca != null) {
            try {
                nfca.close();
                Log.d("finally","isoDep closed");
            }
            catch (IOException e) {
                Log.e(TAG, "Error closing tag...", e);
                resultString = "Can not close the connection to the  tag!";
            }
        }
    }
    return resultString;
}

關於動態鎖定位的寫入命令

您嘗試寫入字節3(即,寫入命令中字節3的值不是0x00 )。 你不應該那樣做。 數據表明確指出,您應該將所有RFUI位都設置為0(這適用於字節3,以及字節1和2中的某些位)。

寫命令如何用於一次性可編程存儲區(如動態鎖定位)

寫命令將在頁面的當前值和寫命令參數中發送的新值之間進行邏輯或。 例如,如果頁面當前設置為FF 0F 00 BD而您嘗試寫入00 00 3F 00 ,則頁面的新值將為FF 0F 3F BD 因此,您只能在動態鎖定位中設置位(=設置為1),而永遠不能將它們重置為零。

為什么您的寫命令失敗

您可以設置RFUI字節(字節3) 0xBD在寫命令。 這是不允許的。

什么是“撕裂”保護?

撕裂是指您在寫入操作期間從讀取器中刪除(意外或有意)標簽的情況。 寫入期間的這種刪除操作可能導致頁面的部分寫入,這將使內存處於未定義狀態。 撕毀保護意味着標簽將完全完成寫入或完全不執行寫入。 因此,內存不會進入任何意外狀態。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM