Search code examples
javacredit-cardjavacardapdu

How to identify java card protocol (T=0 or T=1) using java card technology?


I used following in the code to connect card and get channel

card = terminal.connect("T=1");
channel = card.getBasicChannel();

Here T=1 i.e. protocol is hardcoded. Is there any way from which we can find protocol of the card inserted in card reader ?

javacard.framework.APDU has method getProtocol() but I want protocol at the time of connecting with card.


Solution

  • From the javadoc of CardTerminal.connect(String protocol)

    protocol - the protocol to use ("T=0", "T=1", or "T=CL"), or "*" to connect using any available protocol.

    So it looks like you could use the wildcard.