Hi Cameron,
To detect the card you have to set the target listener as follows:
Code:
private DiscoveryManager dm = null;
dm = DiscoveryManager.getInstance();
try {
dm.addTargetListener(this, TargetType.ISO14443_CARD);
}
Once you have placed an ISO14443 Card (DESFire, SmartMX,...) on the reader, the program will jump into the TargetDetected() method where you can set up the connection to the card:
Code:
import com.nokia.nfc.nxp.desfire.DESFireConnection;
public void targetDetected(TargetProperties[] properties){
log.append(">> Target detected!\n");
TargetProperties target = properties[0];
Class[] classes = target.getConnectionNames();
for (int i=0; i<classes.length; i++) {
try {
if (classes[i].equals(Class.forName("com.nokia.nfc.nxp.desfire.DESFireConnection"))) {
String url = target.getUrl(classes[i]);
// Open connection to DesFire Card
log.append(">> Opening connection\n");
private DESFireConnection conn = null;
conn = (DESFireConnection)Connector.open(url);
//Now you can communicate with the card!!
//example for exchanging data with card
//byte[] response = conn.exchangeData(msg);
}
}
}
//catch() {}
}
Hope that helps!!