- isOK = sendCmdGetResponseWithRetries(write, sizeof(write), resp, sizeof(resp), 10, 10, 0, ICLASS_READER_TIMEOUT_UPDATE, &eof_time);
- if (isOK && blockNo != 3 && blockNo != 4 && memcmp(write+2, resp, 8)) { // check response
- isOK = false;
+ isOK = sendCmdGetResponseWithRetries(write, sizeof(write), resp, sizeof(resp), 10, 3, 0, ICLASS_READER_TIMEOUT_UPDATE, &eof_time);
+ if (!isOK) {
+ return false;
+ }
+
+ uint8_t all_ff[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ if (blockNo == 2) {
+ if (memcmp(data+4, resp, 4) || memcmp(data, resp+4, 4)) { // check response. e-purse update swaps first and second half
+ return false;
+ }
+ } else if (blockNo == 3 || blockNo == 4) {
+ if (memcmp(all_ff, resp, 8)) { // check response. Key updates always return 0xffffffffffffffff
+ return false;
+ }
+ } else {
+ if (memcmp(data, resp, 8)) { // check response. All other updates return unchanged data
+ return false;
+ }