Categories: Code Examples | Java | NFC | WIMA2008
This page was last modified 16:47, 1 May 2008.
NFC Secure Element Example Java Card for Emulator
From Forum Nokia Wiki
This is the code for the JAR file in order to emulate a smartcard (JavaCard) in the Nokia 6131 Emulator (no other emulator is supporting this example!). Click in the emulator on Internal Secure Card => Edit => and then chose the JAR compiled out of this code. Download appropriate NetBeans Project.
package at.nfcresearch.wima.examples; import com.nokia.phone.sdk.concept.srv.modules.nfc.cards.SecureCard; public class TicketSmartCard extends SecureCard { // Command (APDU INS) for increading the value in the wallet private final static byte INS_INC = 0x01; // Command (APDU INS) for decreading the value in the wallet private final static byte INS_DEC = 0x02; // command (APDU INS) for reading the value in the wallet private final static byte INS_READ = 0x03; // variable holding the amount stored in the wallet. private byte value = (byte) 0x20; private static byte APDU_OK[] = {(byte) 0x90, 0x00}; private static byte APDU_NOT_OK[] = {0x69, 0x00}; public TicketSmartCard() { super(); } public byte[] exchangeData(byte[] buf) { byte cmd = buf[1]; switch (cmd) { case INS_INC: if (value < 0xff) { value++; } return APDU_OK; case INS_DEC: if (value > 0x00) { value--; } return APDU_OK; case INS_READ: byte[] outBuffer = {value, APDU_OK[0], APDU_OK[1]}; return outBuffer; } return APDU_NOT_OK; } // Implemeation of Interface SecureCard public void createCardUID() { setCardUID("abcd"); } // Implemeation of Interface SecureCard public void initSecureCard() { System.out.println("InnerCard initialized"); } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mifare Key when phone isn't unlocked | i12vamor | Near Field Communication | 4 | 2008-05-07 12:50 |
| Nokia Cover Emulator 2.0 and JCOP Tools | matt__13 | Mobile Java Tools & SDKs | 2 | 2007-01-23 11:52 |
| JSR257 contactless.jar doesn’t work on 6131 NFC phone | matelco | Near Field Communication | 4 | 2008-02-04 02:51 |
| What are the operating modes of NFC devices? | Natalia Aramayo | Near Field Communication | 1 | 2008-04-30 09:38 |
| Exception with ISO14443Connection Connector.open and message "null" | smischi | Near Field Communication | 2 | 2008-01-21 16:31 |
