Created
June 2, 2016 09:54
-
-
Save Komarev/04a3219ffaf87137698a2219c69e2c82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Observable<String> resetClock(NfcA nfca, long timestamp) { | |
return Observable.fromCallable(() -> { | |
prepareToIO(nfca); | |
writeOperationCommand(nfca, | |
NfcOperationFactory.getCommandForTimeSetup(timestamp)); | |
//checkForOperationSuccess(nfca); ////////////////// | |
try { | |
selectSector(nfca, SECTOR_3); | |
} catch (Exception e) { | |
throw new NfcOperationException("select sector 3" + e.getMessage()); | |
} | |
byte[] record = new byte[4]; | |
byte[] command = new byte[] {COMMAND_READ_RECORD, (byte) (249)}; | |
DateTime startTime = DateTime.now().plusSeconds(1); | |
while (true) { | |
try { | |
record = nfca.transceive(command); | |
} catch (Exception e) { | |
} | |
if (startTime.isBeforeNow()) { | |
throw new NfcOperationException("timed out"); | |
} | |
if ((record[2] & 8) == 8) { | |
break; | |
} | |
} | |
//////////////////////////////////////////// | |
return readOperationAnswer(nfca); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment