@Override public void onTagDiscovered(Tag tag) { IsoDep isoDep = IsoDep.get(tag); IsoDepTransceiver transceiver = new IsoDepTransceiver(isoDep, this); Thread thread = new Thread(transceiver); thread.start(); }
public static DesfireCard dumpTag(Tag tag) throws Exception { List<DesfireApplication> apps = new ArrayList<DesfireApplication>(); IsoDep tech = IsoDep.get(tag); tech.connect(); DesfireManufacturingData manufData; DesfireApplication[] appsArray; try { DesfireProtocol desfireTag = new DesfireProtocol(tech); manufData = desfireTag.getManufacturingData(); for (int appId : desfireTag.getAppList()) { desfireTag.selectApp(appId); List<DesfireFile> files = new ArrayList<DesfireFile>(); for (int fileId : desfireTag.getFileList()) { try { DesfireFileSettings settings = desfireTag.getFileSettings(fileId); byte[] data = null; if (settings instanceof DesfireFileSettings.StandardDesfireFileSettings) data = desfireTag.readFile(fileId); else data = desfireTag.readRecord(fileId); files.add(DesfireFile.create(fileId, settings, data)); } catch (TagLostException ex) { throw ex; } catch (Exception ex) { files.add(new DesfireFile.InvalidDesfireFile(fileId, ex.toString())); } } DesfireFile[] filesArray = new DesfireFile[files.size()]; files.toArray(filesArray); apps.add(new DesfireApplication(appId, filesArray)); } appsArray = new DesfireApplication[apps.size()]; apps.toArray(appsArray); } finally { if (tech.isConnected()) tech.close(); } return new DesfireCard(tag.getId(), new Date(), manufData, appsArray); }