Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NDEF Message with HCE Android

I wanna emulate a host card with the HCE feature from Android. For that I extend the service class HostApduService and overwrite following method:

 public byte[] processCommandApdu(byte[] commandApdu, Bundle extras) {
    if (Arrays.equals(SELECT_APDU, commandApdu)) {
        NdefMessage message = new NdefMessage(new NdefRecord  [] {NdefRecord.createTextRecord("en", "test"});
       return message.toByteArray();
    } else {
        return UNKNOWN_CMD_SW;
    }
}

With a second device its possible to receive data from the HCE Service. The problem is that I always receive "Type A" Tag, but I need a NDEF Message.

Can anybody help me?

like image 304
user3431818 Avatar asked Dec 06 '22 22:12

user3431818


1 Answers

For anyone who stuck on this issue, I have read NFCForum-TS-Type-4-Tag which proposed by @Michael Roland. The whole idea is correct. All you need is to simulate the process SEND and RECEIVED commands to convert the byte array to a NDEF message. I created two repositories, one conclude the whole package about converting string to a NDEF message and the other one is a iOS Reader NDEF TAG to verify whether Android HCE is correct or not.

So Good luck!

like image 94
underwood Avatar answered Dec 08 '22 12:12

underwood