public void run() {
try {
while (true) {
log.info("Waiting for connection");
NFCIPConnection nfcipConnection = nfcipManager.connectAsInitiator();
log.info("Connected, sending data...");
long time = System.currentTimeMillis();
int totalSend = 0;
byte[] data = new byte[200];
for (int k = 0; k < data.length; k++)
data[k] = (byte)(255 - k);
for (int runs = 0; runs < RUNS; runs++) {
log.trace("Start of Run: " + runs);
nfcipConnection.send(data);
totalSend += data.length;
log.info("Send: " + data.length + " Runs: " + runs);
byte[] receive = nfcipConnection.receive();
log.info("Response: " + receive.length);
log.trace("End of Run: " + runs);
}
nfcipConnection.send(new byte[0]);
nfcipConnection.receive();
double timeNeeded = (double)(System.currentTimeMillis() - time) / 1000.0;
log.info("DONE in " + timeNeeded + "sec, " + df.format(((double)totalSend / 1024) / timeNeeded)
+ " kb/s");
log.info("Closing connection");
nfcipConnection.close();
}
}
catch (Exception e) {
e.printStackTrace();
}