Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

Specify the right interface for my code

JavaCard Applet Development Related Questions and Answers.
Classicni
Posts: 15
Joined: Tue Sep 06, 2016 3:00 am
Points :188
Contact:

Specify the right interface for my code

Post by Classicni » Thu Mar 09, 2017 4:08 am

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.

Crawford
Posts: 39
Joined: Thu Sep 17, 2015 11:50 pm
Points :246
Contact:

Re: Specify the right interface for my code

Post by Crawford » Fri Mar 10, 2017 1:19 am

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);
        }
    }
}

Classicni
Posts: 15
Joined: Tue Sep 06, 2016 3:00 am
Points :188
Contact:

Re: Specify the right interface for my code

Post by Classicni » Sun Mar 12, 2017 10:35 pm

Thanks for your help. It indeed helps.

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 49 guests

JavaCard OS : Disclaimer