Hey guys, I have been struggling with this for a few days, and I am sure that you can all help.
I have a card withone target and two connections for that target. One of the connections is a MFStandard connection to a MiFare 1k. I am simply trying to read the value of the first block of this card. I have been told the key of the card, so I am pretty sure that it is correct.
Please look at my code and tell me what I am doing wrong.
/*****/
MFBlock tempMFB;
MFValue tempMFV;
byte key[] = {(byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff};
MFKey.KeyA KA = new MFKey.KeyA(key);
try
{
System.err.println("a");
this.MFSConn = (MFStandardConnection)Connector.open("nfc:rf;type=mf1k;uid=31;timeout=5000", Connector.READ_WRITE, true);
System.err.println(MFSConn.toString());
System.err.println("b");
tempMFB = MFSConn.getBlock(0); //Get the first block, which should hold the UID
System.err.println("c");
tempMFV = tempMFB.readValue(KA);
System.err.println("d");
UID = tempMFV.getValue();
System.err.println("e");
append(" " + UID + "\n");
}
catch (Exception e)
{
System.err.println("Caught an exception during connection.");
System.err.println(e.toString());
}
/*****/
The output I get is:
a
1k:0:1024
b
c
Caught an exception during connection.
java.lang.NullPointerException
and so this means that it is failing during the call to readValue. Am I using the key correctly?
Thanks in advance,
Cam

Reply With Quote

