2012-08-31 6 views

답변

2

올바른 형식의 데이터를 태그에 써야합니다. 예를 들어 MIFARE Classic datasheet의 8.6.2 절을 참조하십시오. 블록에 대한 액세스 제어 비트는 키 증분 조작을 할 수 있도록 정확하게 설정되어야한다는

// connect to the tag using a Tag object from an NFC intent 
MifareClassic mifare = MifareClassic.get(tag); 
mifare.connect(); 

// need to authenticate first to get access 
int sector = blockToSector(blockIndex); 
mifare.authenticateSectorWithKeyA(sector, keyA); // you need to know key A 
// mifare.authenticateSectorWithKeyB(sector, keyB); // in case you know key B 

// construct value block of value zero; "address" byte is set to 0 in this example 
byte[] zeroValue = {0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 0, 255 }; 
mifare.writeBlock(blockIndex, zeroValue); 

// increase the value block by some amount 
mifare.increment(blockIndex, value); 
// result is stored in scratch register inside tag; now write result to block 
mifare.transfer(blockIndex); 

주의 사항 :

예 안드로이드 코드 블록 blockIndex 가치 블록으로 정수 value을 저장하도록 당신은 인증하는 데 사용합니다.

+0

대단히 감사합니다! 정말 효과가 있습니다! 죄송합니다. – James

+0

필자는 writeBlock 만 작성하고 쓰기는하지 않습니다 ... 정상입니까? – michele

+0

@michele 수정 됨, 감사합니다. –

관련 문제