Skip to content

Commit

Permalink
fix: keep error msgs until we have proper error codes to diff them on…
Browse files Browse the repository at this point in the history
… the client side
  • Loading branch information
douniwan5788 committed Sep 15, 2024
1 parent e15356a commit ec82788
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions armsrc/hitagS.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,21 +450,21 @@ static void hts_handle_reader_command(uint8_t *rx, const size_t rxlen,
tag.pstate = HT_READY;
tag.tstate = HT_NO_OP;

if ((rx[0] & 0xf0) == HITAGS_UID_REQ_STD) {
if (rx[0] == HITAGS_UID_REQ_STD) {
DBG Dbprintf("HT_STANDARD");
tag.mode = HT_STANDARD;
sof_bits = 1;
m = AC2K;
}

if ((rx[0] & 0xf0) == HITAGS_UID_REQ_ADV) {
if (rx[0] == HITAGS_UID_REQ_ADV) {
DBG Dbprintf("HT_ADVANCED");
tag.mode = HT_ADVANCED;
sof_bits = 3;
m = AC2K;
}

if ((rx[0] & 0xf0) == HITAGS_UID_REQ_FADV) {
if (rx[0] == HITAGS_UID_REQ_FADV) {
DBG Dbprintf("HT_FAST_ADVANCED");
tag.mode = HT_FAST_ADVANCED;
sof_bits = 3;
Expand Down Expand Up @@ -730,7 +730,6 @@ void hts_simulate(bool tag_mem_supplied, const uint8_t *data, bool ledcontrol) {
clear_trace();

DbpString("Starting Hitag S simulation");
if (ledcontrol) LED_D_ON();

tag.pstate = HT_READY;
tag.tstate = HT_NO_OP;
Expand Down Expand Up @@ -874,6 +873,8 @@ void hts_simulate(bool tag_mem_supplied, const uint8_t *data, bool ledcontrol) {
// synchronized startup procedure
while (AT91C_BASE_TC0->TC_CV != 0); // wait until TC0 returned to zero

if (ledcontrol) LED_D_ON();

while ((BUTTON_PRESS() == false) && (data_available() == false)) {

WDT_HIT();
Expand Down Expand Up @@ -1210,7 +1211,7 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
hts_send_receive(tx, txlen, rx, sizeofrx, &rxlen, t_wait, ledcontrol, true);

if (rxlen != 32) {
DBG DbpString("UID Request failed!");
DbpString("UID Request failed!");
return -1;
}

Expand All @@ -1229,7 +1230,7 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
hts_send_receive(tx, txlen, rx, sizeofrx, &rxlen, HITAG_T_WAIT_SC, ledcontrol, false);

if (rxlen != 40) {
DBG Dbprintf("Select UID failed! %i", rxlen);
Dbprintf("Select UID failed! %i", rxlen);
return -1;
}

Expand Down Expand Up @@ -1334,7 +1335,7 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
hts_send_receive(tx, txlen, rx, sizeofrx, &rxlen, HITAG_T_WAIT_SC, ledcontrol, false);

if ((rxlen != 2) || (rx[0] >> (8 - 2) != 0x01)) {
DBG Dbprintf("no write access on page " _YELLOW_("64") ". not 82xx?");
Dbprintf("no write access on page " _YELLOW_("64") ". not 82xx?");
return -1;
}

Expand All @@ -1346,23 +1347,23 @@ static int hts_select_tag(const lf_hitag_data_t *packet, uint8_t *tx, size_t siz
hts_send_receive(tx, txlen, rx, sizeofrx, &rxlen, HITAG_T_WAIT_SC, ledcontrol, false);

if ((rxlen != 2) || (rx[0] >> (8 - 2) != 0x01)) {
DBG Dbprintf("write to page " _YELLOW_("64") " failed! wrong password?");
Dbprintf("write to page " _YELLOW_("64") " failed! wrong password?");
return -1;
}

return 0;
} else if (packet->cmd == RHTSF_PLAIN || packet->cmd == WHTSF_PLAIN) {
DBG Dbprintf("Error, " _YELLOW_("AUT=1") " This tag is configured in Authentication Mode");
Dbprintf("Error, " _YELLOW_("AUT=1") " This tag is configured in Authentication Mode");
return -1;
} else {
DBG Dbprintf("Error, unknown function: " _RED_("%d"), packet->cmd);
Dbprintf("Error, unknown function: " _RED_("%d"), packet->cmd);
return -1;
}

hts_send_receive(tx, txlen, rx, sizeofrx, &rxlen, HITAG_T_WAIT_SC, ledcontrol, false);

if (rxlen != 40) {
DBG Dbprintf("Authenticate failed! " _RED_("%i"), rxlen);
Dbprintf("Authenticate failed! " _RED_("%i"), rxlen);
return -1;
}

Expand Down

0 comments on commit ec82788

Please sign in to comment.