chg: 'hf 14a sim' - send 4bit ACK/NACK responses
This commit is contained in:
@@ -1138,8 +1138,7 @@ void SimulateIso14443aTag(int tagType, int flags, uint8_t *data) {
|
|||||||
uint8_t index = receivedCmd[1];
|
uint8_t index = receivedCmd[1];
|
||||||
if (index > 2) {
|
if (index > 2) {
|
||||||
// send NACK 0x0 == invalid argument
|
// send NACK 0x0 == invalid argument
|
||||||
uint8_t nack[] = {0x00};
|
EmSend4bit(0x00);
|
||||||
EmSendCmd(nack, sizeof(nack));
|
|
||||||
} else {
|
} else {
|
||||||
uint8_t cmd[] = {0x00, 0x00, 0x00, 0x14, 0xa5};
|
uint8_t cmd[] = {0x00, 0x00, 0x00, 0x14, 0xa5};
|
||||||
num_to_bytes(counters[index], 3, cmd);
|
num_to_bytes(counters[index], 3, cmd);
|
||||||
@@ -1151,8 +1150,7 @@ void SimulateIso14443aTag(int tagType, int flags, uint8_t *data) {
|
|||||||
uint8_t index = receivedCmd[1];
|
uint8_t index = receivedCmd[1];
|
||||||
if (index > 2) {
|
if (index > 2) {
|
||||||
// send NACK 0x0 == invalid argument
|
// send NACK 0x0 == invalid argument
|
||||||
uint8_t nack[] = {0x00};
|
EmSend4bit(0x00);
|
||||||
EmSendCmd(nack, sizeof(nack));
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
uint32_t val = bytes_to_num(receivedCmd + 2, 4);
|
uint32_t val = bytes_to_num(receivedCmd + 2, 4);
|
||||||
@@ -1160,13 +1158,12 @@ void SimulateIso14443aTag(int tagType, int flags, uint8_t *data) {
|
|||||||
// if new value + old value is bigger 24bits, fail
|
// if new value + old value is bigger 24bits, fail
|
||||||
if (val + counters[index] > 0xFFFFFF) {
|
if (val + counters[index] > 0xFFFFFF) {
|
||||||
// send NACK 0x4 == counter overflow
|
// send NACK 0x4 == counter overflow
|
||||||
uint8_t nack[] = {0x04};
|
EmSend4bit(CARD_NACK_NA);
|
||||||
EmSendCmd(nack, sizeof(nack));
|
|
||||||
} else {
|
} else {
|
||||||
counters[index] = val;
|
counters[index] = val;
|
||||||
// send ACK
|
// send ACK
|
||||||
uint8_t ack[] = {0x0a};
|
EmSend4bit(CARD_ACK);
|
||||||
EmSendCmd(ack, sizeof(ack));
|
CARD_ACK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p_response = NULL;
|
p_response = NULL;
|
||||||
@@ -1176,8 +1173,7 @@ void SimulateIso14443aTag(int tagType, int flags, uint8_t *data) {
|
|||||||
uint8_t index = receivedCmd[1];
|
uint8_t index = receivedCmd[1];
|
||||||
if (index > 2) {
|
if (index > 2) {
|
||||||
// send NACK 0x0 == invalid argument
|
// send NACK 0x0 == invalid argument
|
||||||
uint8_t nack[] = {0x00};
|
EmSend4bit(0x00);
|
||||||
EmSendCmd(nack, sizeof(nack));
|
|
||||||
} else {
|
} else {
|
||||||
emlGetMemBt(emdata, 10 + index, 1);
|
emlGetMemBt(emdata, 10 + index, 1);
|
||||||
AddCrc14A(emdata, sizeof(emdata) - 2);
|
AddCrc14A(emdata, sizeof(emdata) - 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user