From fe05c678c4aa8b174633bf22a5ea772689014871 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:37:23 +0300 Subject: [PATCH 01/13] fix nfc saved success scene --- applications/main/nfc/scenes/nfc_scene_save_success.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/applications/main/nfc/scenes/nfc_scene_save_success.c b/applications/main/nfc/scenes/nfc_scene_save_success.c index 230e9a1a6..40165d95a 100644 --- a/applications/main/nfc/scenes/nfc_scene_save_success.c +++ b/applications/main/nfc/scenes/nfc_scene_save_success.c @@ -31,12 +31,22 @@ bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) { } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSaveConfirm)) { scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicDetectReader); consumed = true; + } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetType)) { + consumed = scene_manager_search_and_switch_to_another_scene( + nfc->scene_manager, NfcSceneFileSelect); + } else if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneReadSuccess)) { + consumed = scene_manager_search_and_switch_to_another_scene( + nfc->scene_manager, NfcSceneFileSelect); } else { consumed = scene_manager_search_and_switch_to_previous_scene( nfc->scene_manager, NfcSceneFileSelect); if(!consumed) { consumed = scene_manager_search_and_switch_to_previous_scene( nfc->scene_manager, NfcSceneSavedMenu); + if(!consumed) { + consumed = scene_manager_search_and_switch_to_another_scene( + nfc->scene_manager, NfcSceneFileSelect); + } } } } From 4573046df8b6045dfa669c5d2d6bcd911029ef03 Mon Sep 17 00:00:00 2001 From: Methodius Date: Wed, 31 Jan 2024 20:14:05 +0900 Subject: [PATCH 02/13] nfc/lfrfid emulation abort after 5min disable if debug on --- applications/main/lfrfid/scenes/lfrfid_scene_emulate.c | 4 +++- applications/main/nfc/scenes/nfc_scene_emulate.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c index b729f4de0..54d72f9b0 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c @@ -33,7 +33,9 @@ void lfrfid_scene_emulate_on_enter(void* context) { timer_auto_exit = furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app); - furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS); + + if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) + furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS); view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); } diff --git a/applications/main/nfc/scenes/nfc_scene_emulate.c b/applications/main/nfc/scenes/nfc_scene_emulate.c index 0f178f463..7fd94390b 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate.c @@ -20,7 +20,9 @@ void nfc_scene_emulate_on_enter(void* context) { timer_auto_exit = furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance); - furi_timer_start(timer_auto_exit, NFC_EMULATION_TIME_MAX_MS); + + if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) + furi_timer_start(timer_auto_exit, NFC_EMULATION_TIME_MAX_MS); } bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { From 6bfa591e9253277ec42dfa95301f9575ca3981b6 Mon Sep 17 00:00:00 2001 From: Radek Pilar Date: Wed, 31 Jan 2024 02:32:19 +0100 Subject: [PATCH 03/13] lfrfid/em4100: added support for different bit rates --- lib/lfrfid/protocols/lfrfid_protocols.c | 2 + lib/lfrfid/protocols/lfrfid_protocols.h | 2 + lib/lfrfid/protocols/protocol_em4100.c | 135 +++++++++++++++++++++--- lib/lfrfid/protocols/protocol_em4100.h | 6 +- 4 files changed, 128 insertions(+), 17 deletions(-) diff --git a/lib/lfrfid/protocols/lfrfid_protocols.c b/lib/lfrfid/protocols/lfrfid_protocols.c index f07218d7f..a8d0ff280 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.c +++ b/lib/lfrfid/protocols/lfrfid_protocols.c @@ -20,6 +20,8 @@ const ProtocolBase* lfrfid_protocols[] = { [LFRFIDProtocolEM4100] = &protocol_em4100, + [LFRFIDProtocolEM410032] = &protocol_em4100_32, + [LFRFIDProtocolEM410016] = &protocol_em4100_16, [LFRFIDProtocolH10301] = &protocol_h10301, [LFRFIDProtocolIdteck] = &protocol_idteck, [LFRFIDProtocolIndala26] = &protocol_indala26, diff --git a/lib/lfrfid/protocols/lfrfid_protocols.h b/lib/lfrfid/protocols/lfrfid_protocols.h index 0cb7cbc84..64a9fcba2 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.h +++ b/lib/lfrfid/protocols/lfrfid_protocols.h @@ -9,6 +9,8 @@ typedef enum { typedef enum { LFRFIDProtocolEM4100, + LFRFIDProtocolEM410032, + LFRFIDProtocolEM410016, LFRFIDProtocolH10301, LFRFIDProtocolIdteck, LFRFIDProtocolIndala26, diff --git a/lib/lfrfid/protocols/protocol_em4100.c b/lib/lfrfid/protocols/protocol_em4100.c index 4b720dffd..8dd3b2ce0 100644 --- a/lib/lfrfid/protocols/protocol_em4100.c +++ b/lib/lfrfid/protocols/protocol_em4100.c @@ -24,16 +24,9 @@ typedef uint64_t EM4100DecodedData; #define EM4100_DECODED_DATA_SIZE (5) #define EM4100_ENCODED_DATA_SIZE (sizeof(EM4100DecodedData)) -#define EM4100_CLOCK_PER_BIT (64) - -#define EM_READ_SHORT_TIME (256) -#define EM_READ_LONG_TIME (512) -#define EM_READ_JITTER_TIME (100) - -#define EM_READ_SHORT_TIME_LOW (EM_READ_SHORT_TIME - EM_READ_JITTER_TIME) -#define EM_READ_SHORT_TIME_HIGH (EM_READ_SHORT_TIME + EM_READ_JITTER_TIME) -#define EM_READ_LONG_TIME_LOW (EM_READ_LONG_TIME - EM_READ_JITTER_TIME) -#define EM_READ_LONG_TIME_HIGH (EM_READ_LONG_TIME + EM_READ_JITTER_TIME) +#define EM_READ_SHORT_TIME_BASE (256) +#define EM_READ_LONG_TIME_BASE (512) +#define EM_READ_JITTER_TIME_BASE (100) typedef struct { uint8_t data[EM4100_DECODED_DATA_SIZE]; @@ -43,13 +36,74 @@ typedef struct { bool encoded_polarity; ManchesterState decoder_manchester_state; + uint8_t clock_per_bit; } ProtocolEM4100; +uint16_t protocol_em4100_get_time_divisor(ProtocolEM4100 *proto) { + switch (proto->clock_per_bit) { + case 64: + return 1; + case 32: + return 2; + case 16: + return 4; + default: + return 1; + } +} + +uint32_t protocol_em4100_get_t5577_bitrate(ProtocolEM4100 *proto) { + switch (proto->clock_per_bit) { + case 64: + return LFRFID_T5577_BITRATE_RF_64; + case 32: + return LFRFID_T5577_BITRATE_RF_32; + case 16: + return LFRFID_T5577_BITRATE_RF_16; + default: + return LFRFID_T5577_BITRATE_RF_64; + } +} + +uint16_t protocol_em4100_get_short_time_low(ProtocolEM4100 *proto) { + return EM_READ_SHORT_TIME_BASE / protocol_em4100_get_time_divisor(proto) - EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); +} + +uint16_t protocol_em4100_get_short_time_high(ProtocolEM4100 *proto) { + return EM_READ_SHORT_TIME_BASE / protocol_em4100_get_time_divisor(proto) + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); +} + +uint16_t protocol_em4100_get_long_time_low(ProtocolEM4100 *proto) { + return EM_READ_LONG_TIME_BASE / protocol_em4100_get_time_divisor(proto) - EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); + +} + +uint16_t protocol_em4100_get_long_time_high(ProtocolEM4100 *proto) { + return EM_READ_LONG_TIME_BASE / protocol_em4100_get_time_divisor(proto) + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); +} + + + ProtocolEM4100* protocol_em4100_alloc(void) { ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); + proto->clock_per_bit = 64; return (void*)proto; }; +ProtocolEM4100* protocol_em4100_16_alloc(void) { + ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); + proto->clock_per_bit = 16; + return (void*)proto; +}; + +ProtocolEM4100* protocol_em4100_32_alloc(void) { + ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); + proto->clock_per_bit = 32; + return (void*)proto; +}; + + + void protocol_em4100_free(ProtocolEM4100* proto) { free(proto); }; @@ -145,13 +199,13 @@ bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t du ManchesterEvent event = ManchesterEventReset; - if(duration > EM_READ_SHORT_TIME_LOW && duration < EM_READ_SHORT_TIME_HIGH) { + if(duration > protocol_em4100_get_short_time_low(proto) && duration < protocol_em4100_get_short_time_high(proto)) { if(!level) { event = ManchesterEventShortHigh; } else { event = ManchesterEventShortLow; } - } else if(duration > EM_READ_LONG_TIME_LOW && duration < EM_READ_LONG_TIME_HIGH) { + } else if(duration > protocol_em4100_get_long_time_low(proto) && duration < protocol_em4100_get_long_time_high(proto)) { if(!level) { event = ManchesterEventLongHigh; } else { @@ -227,7 +281,7 @@ bool protocol_em4100_encoder_start(ProtocolEM4100* proto) { LevelDuration protocol_em4100_encoder_yield(ProtocolEM4100* proto) { bool level = (proto->encoded_data >> (63 - proto->encoded_data_index)) & 1; - uint32_t duration = EM4100_CLOCK_PER_BIT / 2; + uint32_t duration = proto->clock_per_bit / 2; if(proto->encoded_polarity) { proto->encoded_polarity = false; @@ -260,7 +314,7 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) { if(request->write_type == LFRFIDWriteTypeT5577) { request->t5577.block[0] = - (LFRFID_T5577_MODULATION_MANCHESTER | LFRFID_T5577_BITRATE_RF_64 | + (LFRFID_T5577_MODULATION_MANCHESTER | protocol_em4100_get_t5577_bitrate(protocol) | (2 << LFRFID_T5577_MAXBLOCK_SHIFT)); request->t5577.block[1] = protocol->encoded_data; request->t5577.block[2] = protocol->encoded_data >> 32; @@ -273,7 +327,7 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) { void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) { uint8_t* data = protocol->data; furi_string_printf( - result, "FC: %03u, Card: %05u", data[2], (uint16_t)((data[3] << 8) | (data[4]))); + result, "FC: %03u, Card: %05u (RF/%u)", data[2], (uint16_t)((data[3] << 8) | (data[4])), protocol->clock_per_bit); }; const ProtocolBase protocol_em4100 = { @@ -298,4 +352,53 @@ const ProtocolBase protocol_em4100 = { .render_data = (ProtocolRenderData)protocol_em4100_render_data, .render_brief_data = (ProtocolRenderData)protocol_em4100_render_data, .write_data = (ProtocolWriteData)protocol_em4100_write_data, -}; \ No newline at end of file +}; + + +const ProtocolBase protocol_em4100_32 = { + .name = "EM4100/32", + .manufacturer = "EM-Micro", + .data_size = EM4100_DECODED_DATA_SIZE, + .features = LFRFIDFeatureASK | LFRFIDFeaturePSK, + .validate_count = 3, + .alloc = (ProtocolAlloc)protocol_em4100_32_alloc, + .free = (ProtocolFree)protocol_em4100_free, + .get_data = (ProtocolGetData)protocol_em4100_get_data, + .decoder = + { + .start = (ProtocolDecoderStart)protocol_em4100_decoder_start, + .feed = (ProtocolDecoderFeed)protocol_em4100_decoder_feed, + }, + .encoder = + { + .start = (ProtocolEncoderStart)protocol_em4100_encoder_start, + .yield = (ProtocolEncoderYield)protocol_em4100_encoder_yield, + }, + .render_data = (ProtocolRenderData)protocol_em4100_render_data, + .render_brief_data = (ProtocolRenderData)protocol_em4100_render_data, + .write_data = (ProtocolWriteData)protocol_em4100_write_data, +}; + +const ProtocolBase protocol_em4100_16 = { + .name = "EM4100/16", + .manufacturer = "EM-Micro", + .data_size = EM4100_DECODED_DATA_SIZE, + .features = LFRFIDFeatureASK | LFRFIDFeaturePSK, + .validate_count = 3, + .alloc = (ProtocolAlloc)protocol_em4100_16_alloc, + .free = (ProtocolFree)protocol_em4100_free, + .get_data = (ProtocolGetData)protocol_em4100_get_data, + .decoder = + { + .start = (ProtocolDecoderStart)protocol_em4100_decoder_start, + .feed = (ProtocolDecoderFeed)protocol_em4100_decoder_feed, + }, + .encoder = + { + .start = (ProtocolEncoderStart)protocol_em4100_encoder_start, + .yield = (ProtocolEncoderYield)protocol_em4100_encoder_yield, + }, + .render_data = (ProtocolRenderData)protocol_em4100_render_data, + .render_brief_data = (ProtocolRenderData)protocol_em4100_render_data, + .write_data = (ProtocolWriteData)protocol_em4100_write_data, +}; diff --git a/lib/lfrfid/protocols/protocol_em4100.h b/lib/lfrfid/protocols/protocol_em4100.h index 6e1e25b93..23af66e27 100644 --- a/lib/lfrfid/protocols/protocol_em4100.h +++ b/lib/lfrfid/protocols/protocol_em4100.h @@ -1,4 +1,8 @@ #pragma once #include -extern const ProtocolBase protocol_em4100; \ No newline at end of file +extern const ProtocolBase protocol_em4100; + +extern const ProtocolBase protocol_em4100_32; + +extern const ProtocolBase protocol_em4100_16; From 22be06174a5593fa89885566d6b474fcf6b52c24 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:38:03 +0300 Subject: [PATCH 04/13] better naming --- applications/main/lfrfid/scenes/lfrfid_scene_saved_key_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_saved_key_menu.c b/applications/main/lfrfid/scenes/lfrfid_scene_saved_key_menu.c index b4d6a6f43..482783fa4 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_saved_key_menu.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_saved_key_menu.c @@ -26,7 +26,7 @@ void lfrfid_scene_saved_key_menu_on_enter(void* context) { submenu, "Write", SubmenuIndexWrite, lfrfid_scene_saved_key_menu_submenu_callback, app); submenu_add_item( submenu, - "Write and set pass", + "Write and set password", SubmenuIndexWriteAndSetPass, lfrfid_scene_saved_key_menu_submenu_callback, app); From 3446b38a06689987d1f627ee4539bfc8f7b6170a Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:41:41 +0300 Subject: [PATCH 05/13] OFW PR 3412 - Fixed MyKey LockID by zProAle https://github.com/flipperdevices/flipperzero-firmware/pull/3412/files --- applications/main/nfc/plugins/supported_cards/mykey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/main/nfc/plugins/supported_cards/mykey.c b/applications/main/nfc/plugins/supported_cards/mykey.c index 340557241..61619ddf3 100644 --- a/applications/main/nfc/plugins/supported_cards/mykey.c +++ b/applications/main/nfc/plugins/supported_cards/mykey.c @@ -13,7 +13,7 @@ static bool mykey_is_blank(const St25tbData* data) { } static bool mykey_has_lockid(const St25tbData* data) { - return (data->blocks[5] & 0xFF) == 0x7F; + return (data->blocks[5] >> 24) == 0x7F; } static bool check_invalid_low_nibble(uint8_t value) { From 7caf2bd2ffa3f197b32bc5f85ee9bb01458c2ec8 Mon Sep 17 00:00:00 2001 From: Methodius Date: Wed, 31 Jan 2024 23:32:37 +0900 Subject: [PATCH 06/13] enter t5577 password scene fix --- applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c b/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c index 486be136c..87593c94f 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c @@ -17,7 +17,7 @@ void lfrfid_scene_enter_password_on_enter(void* context) { const uint32_t* password_list = lfrfid_get_t5577_default_passwords(&password_list_size); uint32_t pass = password_list[furi_get_tick() % password_list_size]; - for(uint8_t i = 0; i < 4; i++) app->password[i] = (pass >> (8 * i)) & 0xFF; + for(uint8_t i = 0; i < 4; i++) app->password[4 - (i + 1)] = (pass >> (8 * i)) & 0xFF; } byte_input_set_header_text(byte_input, "Enter the password in hex"); From 90b49926ea5bc05e3967090a60a06547379c6160 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:32:13 +0300 Subject: [PATCH 07/13] fix render with no date/amount --- .../main/nfc/helpers/protocol_support/emv/emv_render.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/applications/main/nfc/helpers/protocol_support/emv/emv_render.c b/applications/main/nfc/helpers/protocol_support/emv/emv_render.c index b897db787..a01a0ba68 100644 --- a/applications/main/nfc/helpers/protocol_support/emv/emv_render.c +++ b/applications/main/nfc/helpers/protocol_support/emv/emv_render.c @@ -117,7 +117,8 @@ void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { furi_string_cat_printf(str, "Transactions:\n"); for(int i = 0; i < len; i++) { - //if(!apl->trans[i].amount) continue; - NO Skip here pls + // If no date and amount - skip + if((!apl->trans[i].date) && (!apl->trans[i].amount)) continue; // transaction counter furi_string_cat_printf(str, "\e#%d: ", apl->trans[i].atc); @@ -167,10 +168,13 @@ void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { if(apl->trans[i].time) furi_string_cat_printf( str, - "%02lx:%02lx:%02lx\n", + "%02lx:%02lx:%02lx", apl->trans[i].time & 0xff, (apl->trans[i].time >> 8) & 0xff, apl->trans[i].time >> 16); + + // Line break + furi_string_cat_printf(str, "\n"); } furi_string_free(tmp); From 398a468fd709d34df4081f61db5a914f84228fa7 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:32:48 +0300 Subject: [PATCH 08/13] disable em4100 16clk due to non working read 32 is working well --- lib/lfrfid/protocols/lfrfid_protocols.c | 3 +- lib/lfrfid/protocols/lfrfid_protocols.h | 3 +- lib/lfrfid/protocols/protocol_em4100.c | 109 +++++++++--------------- lib/lfrfid/protocols/protocol_em4100.h | 2 - 4 files changed, 42 insertions(+), 75 deletions(-) diff --git a/lib/lfrfid/protocols/lfrfid_protocols.c b/lib/lfrfid/protocols/lfrfid_protocols.c index a8d0ff280..a15b25ed4 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.c +++ b/lib/lfrfid/protocols/lfrfid_protocols.c @@ -20,8 +20,7 @@ const ProtocolBase* lfrfid_protocols[] = { [LFRFIDProtocolEM4100] = &protocol_em4100, - [LFRFIDProtocolEM410032] = &protocol_em4100_32, - [LFRFIDProtocolEM410016] = &protocol_em4100_16, + [LFRFIDProtocolEM4100_32] = &protocol_em4100_32, [LFRFIDProtocolH10301] = &protocol_h10301, [LFRFIDProtocolIdteck] = &protocol_idteck, [LFRFIDProtocolIndala26] = &protocol_indala26, diff --git a/lib/lfrfid/protocols/lfrfid_protocols.h b/lib/lfrfid/protocols/lfrfid_protocols.h index 64a9fcba2..ce14ca1c9 100644 --- a/lib/lfrfid/protocols/lfrfid_protocols.h +++ b/lib/lfrfid/protocols/lfrfid_protocols.h @@ -9,8 +9,7 @@ typedef enum { typedef enum { LFRFIDProtocolEM4100, - LFRFIDProtocolEM410032, - LFRFIDProtocolEM410016, + LFRFIDProtocolEM4100_32, LFRFIDProtocolH10301, LFRFIDProtocolIdteck, LFRFIDProtocolIndala26, diff --git a/lib/lfrfid/protocols/protocol_em4100.c b/lib/lfrfid/protocols/protocol_em4100.c index 8dd3b2ce0..5a49eeb87 100644 --- a/lib/lfrfid/protocols/protocol_em4100.c +++ b/lib/lfrfid/protocols/protocol_em4100.c @@ -39,71 +39,60 @@ typedef struct { uint8_t clock_per_bit; } ProtocolEM4100; -uint16_t protocol_em4100_get_time_divisor(ProtocolEM4100 *proto) { - switch (proto->clock_per_bit) { - case 64: - return 1; - case 32: - return 2; - case 16: - return 4; - default: - return 1; - } +uint16_t protocol_em4100_get_time_divisor(ProtocolEM4100* proto) { + switch(proto->clock_per_bit) { + case 64: + return 1; + case 32: + return 2; + default: + return 1; + } } -uint32_t protocol_em4100_get_t5577_bitrate(ProtocolEM4100 *proto) { - switch (proto->clock_per_bit) { - case 64: - return LFRFID_T5577_BITRATE_RF_64; - case 32: - return LFRFID_T5577_BITRATE_RF_32; - case 16: - return LFRFID_T5577_BITRATE_RF_16; - default: - return LFRFID_T5577_BITRATE_RF_64; - } +uint32_t protocol_em4100_get_t5577_bitrate(ProtocolEM4100* proto) { + switch(proto->clock_per_bit) { + case 64: + return LFRFID_T5577_BITRATE_RF_64; + case 32: + return LFRFID_T5577_BITRATE_RF_32; + default: + return LFRFID_T5577_BITRATE_RF_64; + } } -uint16_t protocol_em4100_get_short_time_low(ProtocolEM4100 *proto) { - return EM_READ_SHORT_TIME_BASE / protocol_em4100_get_time_divisor(proto) - EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); +uint16_t protocol_em4100_get_short_time_low(ProtocolEM4100* proto) { + return EM_READ_SHORT_TIME_BASE / protocol_em4100_get_time_divisor(proto) - + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); } -uint16_t protocol_em4100_get_short_time_high(ProtocolEM4100 *proto) { - return EM_READ_SHORT_TIME_BASE / protocol_em4100_get_time_divisor(proto) + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); +uint16_t protocol_em4100_get_short_time_high(ProtocolEM4100* proto) { + return EM_READ_SHORT_TIME_BASE / protocol_em4100_get_time_divisor(proto) + + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); } -uint16_t protocol_em4100_get_long_time_low(ProtocolEM4100 *proto) { - return EM_READ_LONG_TIME_BASE / protocol_em4100_get_time_divisor(proto) - EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); - +uint16_t protocol_em4100_get_long_time_low(ProtocolEM4100* proto) { + return EM_READ_LONG_TIME_BASE / protocol_em4100_get_time_divisor(proto) - + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); } -uint16_t protocol_em4100_get_long_time_high(ProtocolEM4100 *proto) { - return EM_READ_LONG_TIME_BASE / protocol_em4100_get_time_divisor(proto) + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); +uint16_t protocol_em4100_get_long_time_high(ProtocolEM4100* proto) { + return EM_READ_LONG_TIME_BASE / protocol_em4100_get_time_divisor(proto) + + EM_READ_JITTER_TIME_BASE / protocol_em4100_get_time_divisor(proto); } - - ProtocolEM4100* protocol_em4100_alloc(void) { ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); proto->clock_per_bit = 64; return (void*)proto; }; -ProtocolEM4100* protocol_em4100_16_alloc(void) { - ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); - proto->clock_per_bit = 16; - return (void*)proto; -}; - ProtocolEM4100* protocol_em4100_32_alloc(void) { ProtocolEM4100* proto = malloc(sizeof(ProtocolEM4100)); proto->clock_per_bit = 32; return (void*)proto; }; - - void protocol_em4100_free(ProtocolEM4100* proto) { free(proto); }; @@ -199,13 +188,16 @@ bool protocol_em4100_decoder_feed(ProtocolEM4100* proto, bool level, uint32_t du ManchesterEvent event = ManchesterEventReset; - if(duration > protocol_em4100_get_short_time_low(proto) && duration < protocol_em4100_get_short_time_high(proto)) { + if(duration > protocol_em4100_get_short_time_low(proto) && + duration < protocol_em4100_get_short_time_high(proto)) { if(!level) { event = ManchesterEventShortHigh; } else { event = ManchesterEventShortLow; } - } else if(duration > protocol_em4100_get_long_time_low(proto) && duration < protocol_em4100_get_long_time_high(proto)) { + } else if( + duration > protocol_em4100_get_long_time_low(proto) && + duration < protocol_em4100_get_long_time_high(proto)) { if(!level) { event = ManchesterEventLongHigh; } else { @@ -327,7 +319,11 @@ bool protocol_em4100_write_data(ProtocolEM4100* protocol, void* data) { void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) { uint8_t* data = protocol->data; furi_string_printf( - result, "FC: %03u, Card: %05u (RF/%u)", data[2], (uint16_t)((data[3] << 8) | (data[4])), protocol->clock_per_bit); + result, + "FC: %03u, Card: %05u (RF/%u)", + data[2], + (uint16_t)((data[3] << 8) | (data[4])), + protocol->clock_per_bit); }; const ProtocolBase protocol_em4100 = { @@ -354,7 +350,6 @@ const ProtocolBase protocol_em4100 = { .write_data = (ProtocolWriteData)protocol_em4100_write_data, }; - const ProtocolBase protocol_em4100_32 = { .name = "EM4100/32", .manufacturer = "EM-Micro", @@ -378,27 +373,3 @@ const ProtocolBase protocol_em4100_32 = { .render_brief_data = (ProtocolRenderData)protocol_em4100_render_data, .write_data = (ProtocolWriteData)protocol_em4100_write_data, }; - -const ProtocolBase protocol_em4100_16 = { - .name = "EM4100/16", - .manufacturer = "EM-Micro", - .data_size = EM4100_DECODED_DATA_SIZE, - .features = LFRFIDFeatureASK | LFRFIDFeaturePSK, - .validate_count = 3, - .alloc = (ProtocolAlloc)protocol_em4100_16_alloc, - .free = (ProtocolFree)protocol_em4100_free, - .get_data = (ProtocolGetData)protocol_em4100_get_data, - .decoder = - { - .start = (ProtocolDecoderStart)protocol_em4100_decoder_start, - .feed = (ProtocolDecoderFeed)protocol_em4100_decoder_feed, - }, - .encoder = - { - .start = (ProtocolEncoderStart)protocol_em4100_encoder_start, - .yield = (ProtocolEncoderYield)protocol_em4100_encoder_yield, - }, - .render_data = (ProtocolRenderData)protocol_em4100_render_data, - .render_brief_data = (ProtocolRenderData)protocol_em4100_render_data, - .write_data = (ProtocolWriteData)protocol_em4100_write_data, -}; diff --git a/lib/lfrfid/protocols/protocol_em4100.h b/lib/lfrfid/protocols/protocol_em4100.h index 23af66e27..b19a29705 100644 --- a/lib/lfrfid/protocols/protocol_em4100.h +++ b/lib/lfrfid/protocols/protocol_em4100.h @@ -4,5 +4,3 @@ extern const ProtocolBase protocol_em4100; extern const ProtocolBase protocol_em4100_32; - -extern const ProtocolBase protocol_em4100_16; From 1bd42af688632ffc47ea854760de27cf0a51ae1b Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:34:22 +0300 Subject: [PATCH 09/13] upd changelog --- CHANGELOG.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3990a20..8ad35e5d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ ## New changes +* NFC: **Fixed stuck Saved success screen** +* NFC: Fixed EMV txs render +* NFC/LFRFID: Don't Stop emulation after 5 mins to avoid antenna damage if debug is ON (by @Leptopt1los) +* LFRFID: Fixed T5577 custom password input (by @Leptopt1los) +* OFW PR 3410: lfrfid/em4100: added support for different bit rates - by @Mrkvak (RF/32 full support, RF/16 support without reading) +* OFW PR 3412: Fixed MyKey LockID - by @zProAle +-- +Changes from 070 release: * NFC: **EMV parser** added (by @Leptopt1los and @wosk | PR #700) * NFC: Metromoney parser balance fix (by @Leptopt1los | PR #699) * NFC/LFRFID: Stop emulation after 5 mins to avoid antenna damage (by @Leptopt1los) @@ -16,11 +24,11 @@ * System: More contrast values for replacement displays (up to +8 or -8) * USB/BLE HID: Add macOS Music app volume control * Apps: **Check out Apps updates by following** [this link](https://github.com/xMasterX/all-the-plugins/commits/dev) -* OFW PR 3384: NFC: Display unread Mifare Classic bytes as question marks - by TollyH -* OFW PR 3396: NFC: **fix application opening from browser** - by RebornedBrain (+ fix for leftover issues) -* OFW PR 3382: NFC UI refactor - by RebornedBrain -* OFW PR 3391: Rework more info scene for Ultralight cards - by RebornedBrain -* OFW PR 3401: it-IT-mac layout - by nminaylov +* OFW PR 3384: NFC: Display unread Mifare Classic bytes as question marks - by @TollyH +* OFW PR 3396: NFC: **fix application opening from browser** - by @RebornedBrain (+ fix for leftover issues) +* OFW PR 3382: NFC UI refactor - by @RebornedBrain +* OFW PR 3391: Rework more info scene for Ultralight cards - by @RebornedBrain +* OFW PR 3401: it-IT-mac layout - by @nminaylov * OFW: Fix expansion protocol crash when fed lots of garbage * OFW: 0.98.0-rc various fixes * OFW: RFID CLI: better usage From 6aa7f2e2610492dd0d6a488fa5f269ee3c42efc5 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:35:07 +0300 Subject: [PATCH 10/13] upd changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ad35e5d1..fe3405d5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ * NFC: Fixed EMV txs render * NFC/LFRFID: Don't Stop emulation after 5 mins to avoid antenna damage if debug is ON (by @Leptopt1los) * LFRFID: Fixed T5577 custom password input (by @Leptopt1los) -* OFW PR 3410: lfrfid/em4100: added support for different bit rates - by @Mrkvak (RF/32 full support, RF/16 support without reading) +* OFW PR 3410: lfrfid/em4100: added support for different bit rates - by @Mrkvak (RF/32 full support, RF/16 support without reading (16clk removed for now)) * OFW PR 3412: Fixed MyKey LockID - by @zProAle -- Changes from 070 release: From 603421bd8cec70d5357e64a75d36ab6def88f776 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 31 Jan 2024 20:19:39 +0300 Subject: [PATCH 11/13] fix display --- lib/lfrfid/protocols/protocol_em4100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lfrfid/protocols/protocol_em4100.c b/lib/lfrfid/protocols/protocol_em4100.c index 5a49eeb87..38d6bcb82 100644 --- a/lib/lfrfid/protocols/protocol_em4100.c +++ b/lib/lfrfid/protocols/protocol_em4100.c @@ -320,7 +320,7 @@ void protocol_em4100_render_data(ProtocolEM4100* protocol, FuriString* result) { uint8_t* data = protocol->data; furi_string_printf( result, - "FC: %03u, Card: %05u (RF/%u)", + "FC: %03u, Card: %05u\n(RF/%u)", data[2], (uint16_t)((data[3] << 8) | (data[4])), protocol->clock_per_bit); From ebcc3178165d119c5a4cd47cd5964e846663d34a Mon Sep 17 00:00:00 2001 From: Methodius Date: Thu, 1 Feb 2024 02:59:21 +0900 Subject: [PATCH 12/13] lfrfid enter password scene events handler fix --- applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c b/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c index 87593c94f..4809ef669 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_enter_password.c @@ -7,7 +7,6 @@ void lfrfid_scene_enter_password_on_enter(void* context) { LfRfid* app = context; ByteInput* byte_input = app->byte_input; - // true - use password for write, false - use password for clear pass next_scene = scene_manager_get_scene_state(app->scene_manager, LfRfidSceneEnterPassword); bool password_set = app->password[0] | app->password[1] | app->password[2] | app->password[3]; @@ -38,11 +37,9 @@ bool lfrfid_scene_enter_password_on_event(void* context, SceneManagerEvent event consumed = true; scene_manager_next_scene(scene_manager, next_scene); - scene_manager_set_scene_state(scene_manager, LfRfidSceneEnterPassword, 1); } } else if(event.type == SceneManagerEventTypeBack) { uint32_t prev_scenes[] = {LfRfidSceneExtraActions, LfRfidSceneSavedKeyMenu}; - scene_manager_set_scene_state(scene_manager, LfRfidSceneEnterPassword, 0); scene_manager_search_and_switch_to_previous_scene_one_of( scene_manager, prev_scenes, sizeof(prev_scenes[0])); } From c63089a9295316350025aa1a3826adeecbd4376f Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Thu, 1 Feb 2024 05:34:48 +0300 Subject: [PATCH 13/13] finally --- applications/main/nfc/scenes/nfc_scene_start.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/applications/main/nfc/scenes/nfc_scene_start.c b/applications/main/nfc/scenes/nfc_scene_start.c index c923226fc..63ed8373e 100644 --- a/applications/main/nfc/scenes/nfc_scene_start.c +++ b/applications/main/nfc/scenes/nfc_scene_start.c @@ -24,6 +24,9 @@ void nfc_scene_start_on_enter(void* context) { furi_string_reset(nfc->file_name); nfc_device_clear(nfc->nfc_device); iso14443_3a_reset(nfc->iso14443_3a_edit_data); + // Clear detected protocols list + memset(nfc->protocols_detected, NfcProtocolIso14443_3a, NfcProtocolNum); + nfc_app_reset_detected_protocols(nfc); submenu_add_item(submenu, "Read", SubmenuIndexRead, nfc_scene_start_submenu_callback, nfc); submenu_add_item(