mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 20:43:07 +00:00
NFC: Add manually MF Classic UID desync bug fixed
This commit is contained in:
parent
66756853a6
commit
d1df26cc83
1 changed files with 26 additions and 0 deletions
|
@ -2,6 +2,29 @@
|
|||
|
||||
#include "../helpers/protocol_support/nfc_protocol_support_gui_common.h"
|
||||
|
||||
// Sync UID from #UID to block 0 data
|
||||
void mfclassic_sync_uid(NfcDevice* instance) {
|
||||
size_t uid_len;
|
||||
const uint8_t* uid = nfc_device_get_uid(instance, &uid_len);
|
||||
|
||||
MfClassicData* mfc_data = (MfClassicData*)nfc_device_get_data(instance, NfcProtocolMfClassic);
|
||||
uint8_t* block = mfc_data->block[0].data;
|
||||
|
||||
// Sync UID
|
||||
for(uint8_t i = 0; i < (uint8_t)uid_len; i++) {
|
||||
block[i] = uid[i];
|
||||
}
|
||||
|
||||
if(uid_len == 4) {
|
||||
// Calculate BCC
|
||||
block[uid_len] = 0;
|
||||
|
||||
for(uint8_t i = 0; i < (uint8_t)uid_len; i++) {
|
||||
block[uid_len] ^= block[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void nfc_scene_set_uid_byte_input_changed_callback(void* context) {
|
||||
NfcApp* instance = context;
|
||||
// Retrieve previously saved UID length
|
||||
|
@ -45,6 +68,9 @@ bool nfc_scene_set_uid_on_event(void* context, SceneManagerEvent event) {
|
|||
consumed = true;
|
||||
}
|
||||
} else {
|
||||
if(nfc_device_get_protocol(instance->nfc_device) == NfcProtocolMfClassic)
|
||||
mfclassic_sync_uid(instance->nfc_device);
|
||||
|
||||
scene_manager_next_scene(instance->scene_manager, NfcSceneSaveName);
|
||||
consumed = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue