0

整数値を格納し、API 関数でインクリメントまたはデクリメントしたい。

ユーティリティを使用してカードを読み取りました。これがブロック 5 の内容です。 ここに画像の説明を入力

値ブロックがないようです。

これは私のコードです:

    int sector = 5;
    this.mClassic.connect();
    boolean success = this.mClassic.authenticateSectorWithKeyA(sector, MifareClassic.KEY_DEFAULT );

        if(success){
            int firstBlock = mClassic.sectorToBlock(sector);
            Log.i("MIFARE CLASSIC", "first block of the given sector:" + firstBlock);


            //set the value = 0
            byte[] zeroValue = {0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,};
            //save this value 
                            mClassic.writeBlock(firstBlock, zeroValue);

            //increment the value and store it
            this.mClassic.increment(firstBlock, 1);
            this.mClassic.transfer(firstBlock);

            // read the incremented value by converting it in integer from bytearray
            b = readSector(firstBlock);
            data = b.toByteArray();
            value = 0;
            for (int i = 0; i < data.length; i++)
            {
               value = (value << 8) + (data[i] & 0xff);
            }
            Log.i("MIFARE CLASSIC", "After increment " + value);
        }
        mClassic.close();

I don't understand what I'm doing wrong... に戻ってきtranceive failedまし た。誰が私を助けてくれますか? this.mClassic.increment(firstBlock, 1);どうもありがとう。

4

1 に答える 1