Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


Question:NFC with NFC-Tools, Creating NDEF Application


I am attempting to do what I would have guessed would be pretty simple, but as it turns out is not. I have an ACR122 NFC reader and a bunch of Mifare Classic and Mifare Ultralight tags, and all I want to do is read and write a mime-type and a short text string to each card from a Java application. Here's what I've got working so far:

    I can connect to my reader and listen for tags
    I can detect which type of tag is on the reader
    On the Mifare Classic tags I can loop through all of the data on the tag (after programming the tag from my phone) and build an ascii string, but most of the data is "junk" data
    I can determine whether or not there is an Application directory on the tag.

Here's my code for doing that:

Main:

public static void main(String[] args){
        TerminalFactory factory = TerminalFactory.getDefault();
        List terminals;
        try{
            TerminalHandler handler = new TerminalHandler();
            terminals = factory.terminals().list();
            CardTerminal cardTerminal = terminals.get(0);
            AcsTerminal terminal = new AcsTerminal();
            terminal.setCardTerminal(cardTerminal);
            handler.addTerminal(terminal);
            NfcAdapter adapter = new NfcAdapter(handler.getAvailableTerminal(), TerminalMode.INITIATOR);
            adapter.registerTagListener(new CustomNDEFListener());
            adapter.startListening();
            System.in.read();
            adapter.stopListening();
        }
        catch(IOException e){
        }
        catch(CardException e){
            System.out.println("CardException: " + e.getMessage());
        }

}

asked Sep 13, 2013 in Core java by rajesh
edited Sep 12, 2013
0 votes
181 views



Related Hot Questions



Government Jobs Opening


...