정수 값을 저장하고 API 함수로 증가 또는 감소시키고 싶습니다.android nfc - mifare classic 1k 증가 작업이 실패 함
나는 유틸리티를 사용하여 카드를 읽혀질 수 있고,이 블록 (5)의 내용이다 : 값 블록이없는 것 같다
.
이 내 코드입니다 : 내가 잘못 뭐하는 거지 내가 이해가 안 this.mClassic.increment(firstBlock, 1);
에서 tranceive failed
을 돌아왔다
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();
... 나를 도울 수 있습니까? 고마워요.
코드를 다소 정리하고 수행하려는 작업을 알려주십시오. – ThomasRS
정수 값을 저장하고 API 함수로 증가 또는 감소시키고 싶습니다. – michele