Hi all,
I'm starting developing a small application that must read data from a MiFare SIM card. I've been following the examples in the T80 Programmer's Guide, as well as the tips that appear in this forum. However, calling pconn.transceive(input), where pconn is an InternalPlainTagConnection, does not return.
The code is very similar to that present in pages 7 to 9 in T80 Programmer's Guide. It includes some authentication code and reading code:
byte[][] authent_buffer = new byte[16][7];
// buffer containing the password for each block
for (int j = 0; j < 16; j++) {
// index of the
// block 0, 4, 8,12,...,60
authent_buffer[j][0] = (byte) (4 * j);
for (int u = 1; u < 7; u++) {
// default passwords
// are 0xFFFFFFFFFFFF
authent_buffer[j][u] = (byte) 0xFF;
}
}
int sector = 1;
try {
// authenticate the bloc
Vector input = new Vector();
input.addElement(new Integer(0/*MIFARE_AUTHENT_A_CMD*/));
input.addElement(authent_buffer[sector]);
log("."); // This is the last message I can see
Vector output = pconn.transceive(input);
log(".");
int block = 0;
input = new Vector();
input.addElement(new Integer(2)/*READ_COMMAND*/);
input.addElement(new byte[]{(byte) (4 * sector + block)});
logNewLine("Try to read Block " + (4 * sector + block));
// now do the reading
Vector out = pconn.transceive(input);
logNewLine("Read");
// print the ouptut of the reading
byte[] x = (byte[]) out.elementAt(0);
// Management of the element just read:
....
} catch (ContactlessException ce) {
// Handle exception
logNewLine("Exception while reading data: " + ce.getMessage());
} catch (IOException ioe) {
logNewLine("I/O Exception: " + ioe.getMessage());
}
As you can see, I'm trying to read sector 1, block 0.
There are some points I'd like to clarify:
- If I want to read from SIM card, must I open connector like this: pconn = (InternalPlainTagConnection) Connector.open("nfc:InternalPlainTag")?
- Are values 0 and 2 correct for commands authenticate and read?
- Is 0xFF the password for reading? I've seen in another post something about D3F7D3F7D3F7.
Thanks in advance.