JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html
https://ftsafe.en.alibaba.com/index.html
Specify the right interface for my code
Specify the right interface for my code
I have finished an applet but there is a special point. Part of my code should run only under contact interface, and some of them should run only under contactless interface. So now my question is how to specify the right interface for my code. Is there any method to specify the interface firstly before running the code. I appreciate any help.
Re: Specify the right interface for my code
Maybe this code helps:
Code: Select all
byte protocolMedia = (byte) (apdu.getProtocol() & APDU.PROTOCOL_MEDIA_MASK);
if ((protocolMedia == APDU.PROTOCOL_MEDIA_CONTACTLESS_TYPE_A) || (protocolMedia == APDU.PROTOCOL_MEDIA_CONTACTLESS_TYPE_B)) {
// Contactless interface;
switch (buf[ISO7816.OFFSET_INS]) {
case INS_READ_RECORD:
contactless_readRecord(apdu, buf);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
} else {
// Contact interface;
switch (buf[ISO7816.OFFSET_INS]) {
case INS_READ_RECORD:
contact_readRecord(apdu, buf);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}
}
Re: Specify the right interface for my code
Thanks for your help. It indeed helps.
Who is online
Users browsing this forum: No registered users and 65 guests