2012-07-08 3 views
4

Mifare 1K 태그의 섹터 0의 첫 번째 블록에 간단한 "Hello World"문자열을 쓰려고합니다. 이 태그는 기본 구성의 새로운 태그입니다. 섹터 트레일러 (블록 3)는 읽을 때 00 00 00 00 00 00 00 00 ff 07 80 69 ff ff ff ff ff ff ff ff입니다. 따라서 액세스 조건은 ff 07 80 69이며 키 A로 각 블록을 읽고 쓸 수 있습니다.Android NFC로 Mifare 태그에 쓰기?

여전히 태그에는 아무 것도 쓸 수 없습니다. 나는 다음과 같은 예외를 받고 있어요

try { 
    mfc.connect(); 
    boolean auth = false; 

    auth = mfc.authenticateSectorWithKeyA(0,MifareClassic.KEY_DEFAULT); 

    if (auth) { 

     String text = "Hello, World!"; 
     byte[] value = text.getBytes(); 
     byte[] toWrite = new byte[MifareClassic.BLOCK_SIZE];   

     for (int i=0; i<MifareClassic.BLOCK_SIZE; i++) { 
       if (i < value.length) toWrite[i] = value[i]; 
       else toWrite[i] = 0; 
     }   

     mfc.writeBlock(0, toWrite); 
    }  

: Transceived failed 여기 내 코드입니다.

내가 뭘 잘못하고 있니?

07-09 00:19:44.836: W/System.err(13167): at android.nfc.TransceiveResult.getResponseOrThrow(TransceiveResult.java:52) 
07-09 00:19:44.843: W/System.err(13167): at android.nfc.tech.BasicTagTechnology.transceive(BasicTagTechnology.java:151) 
07-09 00:19:44.843: W/System.err(13167): at android.nfc.tech.MifareClassic.writeBlock(MifareClassic.java:453) 
07-09 00:19:44.843: W/System.err(13167): at com.example.andorid.apis.mifare.MainActivity.resolveIntent(MainActivity.java:128) 
07-09 00:19:44.843: W/System.err(13167): at com.example.andorid.apis.mifare.MainActivity.onNewIntent(MainActivity.java:275) 
07-09 00:19:44.843: W/System.err(13167): at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1123) 
07-09 00:19:44.843: W/System.err(13167): at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2041) 
07-09 00:19:44.843: W/System.err(13167): at android.app.ActivityThread.performNewIntents(ActivityThread.java:2054) 
07-09 00:19:44.843: W/System.err(13167): at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2063) 
07-09 00:19:44.843: W/System.err(13167): at android.app.ActivityThread.access$1400(ActivityThread.java:122) 
07-09 00:19:44.843: W/System.err(13167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1193) 
07-09 00:19:44.851: W/System.err(13167): at android.os.Handler.dispatchMessage(Handler.java:99) 
07-09 00:19:44.851: W/System.err(13167): at android.os.Looper.loop(Looper.java:137) 
07-09 00:19:44.851: W/System.err(13167): at android.app.ActivityThread.main(ActivityThread.java:4340) 
07-09 00:19:44.851: W/System.err(13167): at java.lang.reflect.Method.invokeNative(Native Method) 
07-09 00:19:44.851: W/System.err(13167): at java.lang.reflect.Method.invoke(Method.java:511) 
07-09 00:19:44.851: W/System.err(13167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
07-09 00:19:44.851: W/System.err(13167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
07-09 00:19:44.851: W/System.err(13167): at dalvik.system.NativeStart.main(Native Method) 
+0

전체 스택 추적을 표시 할 수 있습니까? – Brad

+0

예, 제 편집 참조! –

+0

Transceive failed 같은 오류가 발생했습니다. 나는 그것이 안드로이드 ICS4.0.3과 ICS 4.0.4 버그라고 생각한다. S3 i9300 및 Galaxy Note E160K에서 테스트를 모두 마쳤습니다. My MiFare 1k 카드는 다른 응용 프로그램에서 NDEF를 통해 읽고 쓸 수 있습니다. – fordiy

답변

7

블록 0에 쓰려고합니다. 불가능합니다. 블록 0은 항상 읽기 전용이며 액세스 조건에서도 쓰기 가능이라고합니다. 블록 0은 UID 및 다른 제조업체 데이터와 일치합니다. 대신 블록 1 또는 2에 글을 쓰면서 동일한 문제가 있는지 확인하십시오.

1

더 이상 리더 (reader)에 연결되지 않은 태그에서 읽으려고 할 때 나는 그 예외를 본 적이 :

여기 스택 추적입니다.

일부 카드/리더 조합의 경우 괜찮은 연결을 유지하기가 어렵다는 것을 알고 있습니다.

예를 들어 내 Nexus S는 일부 태그와의 연결을 유지하는 데 문제가 있습니다. Nexus S에는 가장 강력한 필드가 없습니다. 나는 갤럭시 노트가 그 점에서 비슷하다고 생각한다.

다른 독자는 물론 다른 브랜드의 태그를 사용해보십시오.

또한, 귀하의 읽기를 실행하여 연결을 유지하는지 확인하는 것이 좋습니다.

+0

아니 ... 나는 이것이 문제라고 생각하지 않는다. NXP 태그 작성기로 데이터를 쉽게 쓸 수 있습니다. 나는 은하계 넥서스 i9250을 가지고있다. –

관련 문제