1
0
mirror of https://github.com/whowechina/aic_pico.git synced 2025-01-19 11:18:39 +01:00

Fix ghost PN5180 mifare cards

This commit is contained in:
whowechina 2024-05-24 22:10:37 +08:00
parent 0bd8258a9d
commit f326db8329
2 changed files with 16 additions and 2 deletions

Binary file not shown.

View File

@ -251,6 +251,7 @@ static void anti_collision(uint8_t code, uint8_t uid[5], uint8_t *sak)
} }
static struct { static struct {
uint8_t atqa[2];
uint8_t buf[5]; uint8_t buf[5];
uint8_t sak; uint8_t sak;
uint8_t uid[7]; uint8_t uid[7];
@ -269,12 +270,24 @@ static void poll_mifare_1()
pn5180_or_reg(PN5180_REG_SYSTEM_CONFIG, 0x03); pn5180_or_reg(PN5180_REG_SYSTEM_CONFIG, 0x03);
uint8_t cmd[1] = {0x26}; uint8_t cmd[1] = {0x26};
pn5180_send_data(cmd, 1, 7); pn5180_send_data(cmd, 1, 7);
pn5180_read_data(mi_poll.buf, 2); pn5180_read_data(mi_poll.atqa, 2);
} }
static void poll_mifare_2() static void poll_mifare_2()
{ {
if ((memcmp(mi_poll.atqa, "\x44\x00", 2) != 0) &&
(memcmp(mi_poll.atqa, "\x04\x00", 2) != 0)) {
mi_poll.len = 0;
return;
}
anti_collision(0x93, mi_poll.buf, &mi_poll.sak); anti_collision(0x93, mi_poll.buf, &mi_poll.sak);
if (mi_poll.sak == 0x00) {
mi_poll.len = 0;
return;
}
mi_poll.len = 0; mi_poll.len = 0;
if ((mi_poll.sak & 0x04) == 0) { if ((mi_poll.sak & 0x04) == 0) {
memmove(mi_poll.uid, mi_poll.buf, 4); memmove(mi_poll.uid, mi_poll.buf, 4);
@ -292,6 +305,7 @@ static void poll_mifare_2()
bool pn5180_poll_mifare(uint8_t uid[7], int *len) bool pn5180_poll_mifare(uint8_t uid[7], int *len)
{ {
DEBUG("pn5180_poll_mifare\n"); DEBUG("pn5180_poll_mifare\n");
poll_mifare_1(); poll_mifare_1();
poll_mifare_2(); poll_mifare_2();