diff --git a/applications/main/lfrfid/lfrfid_i.h b/applications/main/lfrfid/lfrfid_i.h index 1f07db1fa..97e6e9db4 100644 --- a/applications/main/lfrfid/lfrfid_i.h +++ b/applications/main/lfrfid/lfrfid_i.h @@ -65,6 +65,7 @@ enum LfRfidCustomEvent { LfRfidEventWriteTooLongToWrite, LfRfidEventRpcLoadFile, LfRfidEventRpcSessionClose, + LfRfidEventEmulationTimeExpired, }; typedef enum { diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c index dc3918994..b729f4de0 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c @@ -1,5 +1,14 @@ #include "../lfrfid_i.h" +#define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000) + +FuriTimer* timer_auto_exit; + +void lfrfid_scene_emulate_popup_callback(void* context) { + LfRfid* app = context; + view_dispatcher_send_custom_event(app->view_dispatcher, LfRfidEventEmulationTimeExpired); +} + void lfrfid_scene_emulate_on_enter(void* context) { LfRfid* app = context; Popup* popup = app->popup; @@ -22,18 +31,38 @@ void lfrfid_scene_emulate_on_enter(void* context) { lfrfid_worker_emulate_start(app->lfworker, (LFRFIDProtocol)app->protocol_id); notification_message(app->notifications, &sequence_blink_start_magenta); + timer_auto_exit = + furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app); + furi_timer_start(timer_auto_exit, LFRFID_EMULATION_TIME_MAX_MS); + view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); } bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) { - UNUSED(context); - UNUSED(event); + LfRfid* app = context; bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == LfRfidEventEmulationTimeExpired) { + if(!scene_manager_previous_scene(app->scene_manager)) { + scene_manager_stop(app->scene_manager); + view_dispatcher_stop(app->view_dispatcher); + } else { + scene_manager_previous_scene(app->scene_manager); + } + consumed = true; + } + } + return consumed; } void lfrfid_scene_emulate_on_exit(void* context) { LfRfid* app = context; + + furi_timer_stop(timer_auto_exit); + furi_timer_free(timer_auto_exit); + notification_message(app->notifications, &sequence_blink_stop); popup_reset(app->popup); lfrfid_worker_stop(app->lfworker); diff --git a/applications/main/nfc/helpers/nfc_custom_event.h b/applications/main/nfc/helpers/nfc_custom_event.h index 16fbc4749..86fcdd3d3 100644 --- a/applications/main/nfc/helpers/nfc_custom_event.h +++ b/applications/main/nfc/helpers/nfc_custom_event.h @@ -30,4 +30,6 @@ typedef enum { NfcCustomEventPollerFailure, NfcCustomEventListenerUpdate, + + NfcCustomEventEmulationTimeExpired, } NfcCustomEvent; 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 c1320a077..b897db787 100644 --- a/applications/main/nfc/helpers/protocol_support/emv/emv_render.c +++ b/applications/main/nfc/helpers/protocol_support/emv/emv_render.c @@ -97,12 +97,12 @@ void nfc_render_emv_application(const EmvApplication* apl, FuriString* str) { static void nfc_render_emv_pin_try_counter(uint8_t counter, FuriString* str) { if(counter == 0xff) return; - furi_string_cat_printf(str, "PIN try left: %d\n", counter); + furi_string_cat_printf(str, "PIN attempts left: %d\n", counter); } void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { if(apl->transaction_counter) - furi_string_cat_printf(str, "Transactions: %d\n", apl->transaction_counter); + furi_string_cat_printf(str, "Transactions count: %d\n", apl->transaction_counter); if(apl->last_online_atc) furi_string_cat_printf(str, "Last Online ATC: %d\n", apl->last_online_atc); @@ -115,27 +115,31 @@ void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { Storage* storage = furi_record_open(RECORD_STORAGE); FuriString* tmp = furi_string_alloc(); - //furi_string_cat_printf(str, "Transactions:\n"); + furi_string_cat_printf(str, "Transactions:\n"); for(int i = 0; i < len; i++) { - if(!apl->trans[i].amount) continue; + //if(!apl->trans[i].amount) continue; - NO Skip here pls // transaction counter furi_string_cat_printf(str, "\e#%d: ", apl->trans[i].atc); // Print transaction amount - uint8_t* a = (uint8_t*)&apl->trans[i].amount; - bool top = true; - for(int x = 0; x < 6; x++) { - // cents - if(x == 5) { - furi_string_cat_printf(str, ".%02X", a[x]); - break; - } - if(a[x]) { - if(top) { - furi_string_cat_printf(str, "%X", a[x]); - top = false; - } else { - furi_string_cat_printf(str, "%02X", a[x]); + if(!apl->trans[i].amount) { + furi_string_cat_printf(str, "???"); + } else { + uint8_t* a = (uint8_t*)&apl->trans[i].amount; + bool top = true; + for(int x = 0; x < 6; x++) { + // cents + if(x == 5) { + furi_string_cat_printf(str, ".%02X", a[x]); + break; + } + if(a[x]) { + if(top) { + furi_string_cat_printf(str, "%X", a[x]); + top = false; + } else { + furi_string_cat_printf(str, "%02X", a[x]); + } } } } @@ -155,7 +159,7 @@ void nfc_render_emv_transactions(const EmvApplication* apl, FuriString* str) { if(apl->trans[i].date) furi_string_cat_printf( str, - "%02lx/%02lx/%02lx ", + "%02lx.%02lx.%02lx ", apl->trans[i].date >> 16, (apl->trans[i].date >> 8) & 0xff, apl->trans[i].date & 0xff); diff --git a/applications/main/nfc/plugins/supported_cards/emv.c b/applications/main/nfc/plugins/supported_cards/emv.c index ebcc392c8..a8253edff 100644 --- a/applications/main/nfc/plugins/supported_cards/emv.c +++ b/applications/main/nfc/plugins/supported_cards/emv.c @@ -105,7 +105,7 @@ static bool emv_parse(const NfcDevice* device, FuriString* parsed_data) { furi_string_cat_printf(parsed_data, "Currency: %s\n", furi_string_get_cstr(str)); if(app.pin_try_counter != 0xFF) - furi_string_cat_printf(parsed_data, "PIN try left: %d\n", app.pin_try_counter); + furi_string_cat_printf(parsed_data, "PIN attempts left: %d\n", app.pin_try_counter); parsed = true; } while(false); diff --git a/applications/main/nfc/scenes/nfc_scene_delete.c b/applications/main/nfc/scenes/nfc_scene_delete.c index c1a676168..924ed78fa 100644 --- a/applications/main/nfc/scenes/nfc_scene_delete.c +++ b/applications/main/nfc/scenes/nfc_scene_delete.c @@ -51,8 +51,11 @@ bool nfc_scene_delete_on_event(void* context, SceneManagerEvent event) { if(nfc_delete(nfc)) { scene_manager_next_scene(nfc->scene_manager, NfcSceneDeleteSuccess); } else { - scene_manager_search_and_switch_to_previous_scene( - nfc->scene_manager, NfcSceneStart); + if(!scene_manager_search_and_switch_to_previous_scene( + nfc->scene_manager, NfcSceneStart)) { + scene_manager_stop(nfc->scene_manager); + view_dispatcher_stop(nfc->view_dispatcher); + } } consumed = true; } diff --git a/applications/main/nfc/scenes/nfc_scene_delete_success.c b/applications/main/nfc/scenes/nfc_scene_delete_success.c index 73856c292..d41e52549 100644 --- a/applications/main/nfc/scenes/nfc_scene_delete_success.c +++ b/applications/main/nfc/scenes/nfc_scene_delete_success.c @@ -31,6 +31,11 @@ bool nfc_scene_delete_success_on_event(void* context, SceneManagerEvent event) { } else { consumed = scene_manager_search_and_switch_to_previous_scene( nfc->scene_manager, NfcSceneFileSelect); + + if(!consumed) { + scene_manager_stop(nfc->scene_manager); + view_dispatcher_stop(nfc->view_dispatcher); + } } } } diff --git a/applications/main/nfc/scenes/nfc_scene_emulate.c b/applications/main/nfc/scenes/nfc_scene_emulate.c index 6f217f315..0f178f463 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate.c @@ -1,13 +1,47 @@ #include "../helpers/protocol_support/nfc_protocol_support.h" +#include "nfc_app_i.h" + +#define NFC_EMULATION_TIME_MAX_MS (5 * 60 * 1000) + +FuriTimer* timer_auto_exit; + +void nfc_scene_emulate_timer_callback(void* context) { + NfcApp* instance = context; + + view_dispatcher_send_custom_event( + instance->view_dispatcher, NfcCustomEventEmulationTimeExpired); +} + void nfc_scene_emulate_on_enter(void* context) { + NfcApp* instance = context; + nfc_protocol_support_on_enter(NfcProtocolSupportSceneEmulate, 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); } bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { + NfcApp* instance = context; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == NfcCustomEventEmulationTimeExpired) { + if(!scene_manager_previous_scene(instance->scene_manager)) { + scene_manager_stop(instance->scene_manager); + view_dispatcher_stop(instance->view_dispatcher); + } else { + scene_manager_previous_scene(instance->scene_manager); + } + return true; + } + } return nfc_protocol_support_on_event(NfcProtocolSupportSceneEmulate, context, event); } void nfc_scene_emulate_on_exit(void* context) { + furi_timer_stop(timer_auto_exit); + furi_timer_free(timer_auto_exit); nfc_protocol_support_on_exit(NfcProtocolSupportSceneEmulate, context); } diff --git a/applications/main/nfc/scenes/nfc_scene_save_success.c b/applications/main/nfc/scenes/nfc_scene_save_success.c index ef7863c13..230e9a1a6 100644 --- a/applications/main/nfc/scenes/nfc_scene_save_success.c +++ b/applications/main/nfc/scenes/nfc_scene_save_success.c @@ -32,8 +32,12 @@ bool nfc_scene_save_success_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(nfc->scene_manager, NfcSceneMfClassicDetectReader); consumed = true; } else { - consumed = scene_manager_search_and_switch_to_another_scene( + 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); + } } } } diff --git a/applications/main/subghz/scenes/subghz_scene_need_saving.c b/applications/main/subghz/scenes/subghz_scene_need_saving.c index 76801f885..64ab2cbf2 100644 --- a/applications/main/subghz/scenes/subghz_scene_need_saving.c +++ b/applications/main/subghz/scenes/subghz_scene_need_saving.c @@ -55,6 +55,7 @@ bool subghz_scene_need_saving_on_event(void* context, SceneManagerEvent event) { subghz_delete_file(subghz); } } + subghz_txrx_set_preset( subghz->txrx, "AM650", subghz->last_settings->frequency, 0, 0, NULL, 0); scene_manager_search_and_switch_to_previous_scene( diff --git a/applications/services/expansion/expansion_i.h b/applications/services/expansion/expansion_i.h index 65bc0fe82..13a496252 100644 --- a/applications/services/expansion/expansion_i.h +++ b/applications/services/expansion/expansion_i.h @@ -3,4 +3,4 @@ #include "expansion_settings.h" #include "expansion.h" -ExpansionSettings* expansion_get_settings(Expansion* instance); \ No newline at end of file +ExpansionSettings* expansion_get_settings(Expansion* instance); diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 26641280d..21427b3a4 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -255,7 +255,7 @@ static bool subghz_protocol_keeloq_gen_data( // Centurion -> no serial in hop, uses fixed value 0x1CE - normal learning } else if(strcmp(instance->manufacture_name, "Dea_Mio") == 0) { uint8_t first_disc_num = (instance->generic.serial >> 8) & 0xF; - uint8_t result_disc = (0xC + ((first_disc_num % 4) ? 2 : 0)); + uint8_t result_disc = (0xC + (first_disc_num % 4)); uint32_t dea_serial = (instance->generic.serial & 0xFF) | (((uint32_t)result_disc) << 8); decrypt = btn << 28 | (dea_serial & 0xFFF) << 16 | instance->generic.cnt;