mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-19 03:11:52 +03:00
mf classic listener: reset state before sleep and after nack
This commit is contained in:
parent
55b4f87cd7
commit
73145e0beb
@ -40,10 +40,11 @@ static void mf_classic_listener_reset_state(MfClassicListener* instance) {
|
|||||||
|
|
||||||
static MfClassicListenerCommand
|
static MfClassicListenerCommand
|
||||||
mf_classic_listener_halt_handler(MfClassicListener* instance, BitBuffer* buff) {
|
mf_classic_listener_halt_handler(MfClassicListener* instance, BitBuffer* buff) {
|
||||||
|
UNUSED(instance);
|
||||||
|
|
||||||
MfClassicListenerCommand command = MfClassicListenerCommandNack;
|
MfClassicListenerCommand command = MfClassicListenerCommandNack;
|
||||||
|
|
||||||
if(bit_buffer_get_byte(buff, 1) == MF_CLASSIC_CMD_HALT_LSB) {
|
if(bit_buffer_get_byte(buff, 1) == MF_CLASSIC_CMD_HALT_LSB) {
|
||||||
mf_classic_listener_reset_state(instance);
|
|
||||||
command = MfClassicListenerCommandSleep;
|
command = MfClassicListenerCommandSleep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +60,7 @@ static MfClassicListenerCommand mf_classic_listener_auth_first_part_handler(
|
|||||||
do {
|
do {
|
||||||
instance->state = MfClassicListenerStateIdle;
|
instance->state = MfClassicListenerStateIdle;
|
||||||
|
|
||||||
if(block_num >= instance->total_block_num) {
|
if(block_num >= instance->total_block_num) break;
|
||||||
mf_classic_listener_reset_state(instance);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t sector_num = mf_classic_get_sector_by_block(block_num);
|
uint8_t sector_num = mf_classic_get_sector_by_block(block_num);
|
||||||
|
|
||||||
@ -135,7 +133,7 @@ static MfClassicListenerCommand
|
|||||||
instance->cmd_in_progress = false;
|
instance->cmd_in_progress = false;
|
||||||
|
|
||||||
if(bit_buffer_get_size_bytes(buff) != (sizeof(MfClassicNr) + sizeof(MfClassicAr))) {
|
if(bit_buffer_get_size_bytes(buff) != (sizeof(MfClassicNr) + sizeof(MfClassicAr))) {
|
||||||
mf_classic_listener_reset_state(instance);
|
command = MfClassicListenerCommandSleep;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bit_buffer_write_bytes_mid(buff, instance->auth_context.nr.data, 0, sizeof(MfClassicNr));
|
bit_buffer_write_bytes_mid(buff, instance->auth_context.nr.data, 0, sizeof(MfClassicNr));
|
||||||
@ -157,7 +155,7 @@ static MfClassicListenerCommand
|
|||||||
if(secret_poller != prng_successor(nt_num, 64)) {
|
if(secret_poller != prng_successor(nt_num, 64)) {
|
||||||
FURI_LOG_T(
|
FURI_LOG_T(
|
||||||
TAG, "Wrong reader key: %08lX != %08lX", secret_poller, prng_successor(nt_num, 64));
|
TAG, "Wrong reader key: %08lX != %08lX", secret_poller, prng_successor(nt_num, 64));
|
||||||
mf_classic_listener_reset_state(instance);
|
command = MfClassicListenerCommandSleep;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,9 +608,11 @@ NfcCommand mf_classic_listener_run(NfcGenericEvent event, void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mf_classic_listener_send_short_frame(instance, nack);
|
mf_classic_listener_send_short_frame(instance, nack);
|
||||||
|
mf_classic_listener_reset_state(instance);
|
||||||
} else if(mfc_command == MfClassicListenerCommandSilent) {
|
} else if(mfc_command == MfClassicListenerCommandSilent) {
|
||||||
command = NfcCommandReset;
|
command = NfcCommandReset;
|
||||||
} else if(mfc_command == MfClassicListenerCommandSleep) {
|
} else if(mfc_command == MfClassicListenerCommandSleep) {
|
||||||
|
mf_classic_listener_reset_state(instance);
|
||||||
command = NfcCommandSleep;
|
command = NfcCommandSleep;
|
||||||
}
|
}
|
||||||
} else if(iso3_event->type == Iso14443_3aListenerEventTypeHalted) {
|
} else if(iso3_event->type == Iso14443_3aListenerEventTypeHalted) {
|
||||||
|
Loading…
Reference in New Issue
Block a user