1

I'm getting a tag lost exception when sending SELECT PPSE command using the tag's transceive method.

The intent is passed to readTag and the method is getting the tag from the intent but calling the transceive method for the SELECT PPSE command APDU results in a tag lost exception instead of getting the Response APDU message:

public void readTag(Intent intent) {
    String action = intent.getAction();
    if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) {
        System.out.println("Got the tag");
        Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        NfcA mfc = NfcA.get(tagFromIntent);
        System.out.println(mfc);
        try {
            mfc.connect();
            System.out.println(mfc.getTag());
            System.out.println(mfc.getClass());
            byte[] ATQA = mfc.getAtqa();
            System.out.println(getHexString(ATQA));
            System.out.println(mfc.getMaxTransceiveLength());
            mfc.setTimeout(500000);

            String value = "00A404000e325041592e5359532e444446303100"; //PPSE APDU value
            String hex = value.toString();
            byte[] data = HexToByte(hex);
            byte[] response = mfc.transceive(data); //sending request
            System.out.println(getHexString(response));
            mfc.close();
        } catch(Exception e) {
            Toast.makeText(getBaseContext(), e.getMessage(),
                           Toast.LENGTH_SHORT).show();
        }
    }
}
Michael Roland
  • 39,663
  • 10
  • 99
  • 206
Saravana Cd
  • 61
  • 2
  • 7

1 Answers1

1

The tag technology NfcA (and also NfcB) is for communicating using ISO 14443-3 proprietary command sets. APDUs are typically sent on top of ISO-DEP / T=CL (ISO 14443-4 transmission protocol), so you would want to use IsoDep tag technology instead of NfcA.

Also you might want to use a slightly lower timeout value. Typically a value in the order of 1 to 10 seconds should be enough (by far) -- unless you trigger some complex operations on the smartcard.

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
  • Thanks Micheal, It worked ,I'm getting the response.Can you guide me in how to form the Select AID from the PPSE response . – Saravana Cd Feb 11 '14 at 01:43