From f41609de2360d92d73ade9f1dfae90ee4a0ba460 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:59:39 +0000 Subject: [PATCH] No auto stop emulate after 5 mins --nobuild --- .../main/lfrfid/scenes/lfrfid_scene_emulate.c | 24 +++++++++---------- .../main/nfc/scenes/nfc_scene_emulate.c | 24 +++++++++---------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c index 1a39cb8bb..c87ebc1c9 100644 --- a/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c +++ b/applications/main/lfrfid/scenes/lfrfid_scene_emulate.c @@ -2,9 +2,7 @@ #include -#define LFRFID_EMULATION_TIME_MAX_MS (5 * 60 * 1000) - -FuriTimer* timer_auto_exit; +FuriTimer* timer_auto_exit = NULL; void lfrfid_scene_emulate_popup_callback(void* context) { LfRfid* app = context; @@ -33,15 +31,12 @@ 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); - - if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) || app->fav_timeout) + if(app->fav_timeout) { + timer_auto_exit = + furi_timer_alloc(lfrfid_scene_emulate_popup_callback, FuriTimerTypeOnce, app); furi_timer_start( - timer_auto_exit, - app->fav_timeout ? - xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency() : - LFRFID_EMULATION_TIME_MAX_MS); + timer_auto_exit, xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency()); + } view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup); } @@ -68,8 +63,11 @@ bool lfrfid_scene_emulate_on_event(void* context, SceneManagerEvent event) { void lfrfid_scene_emulate_on_exit(void* context) { LfRfid* app = context; - furi_timer_stop(timer_auto_exit); - furi_timer_free(timer_auto_exit); + if(timer_auto_exit) { + furi_timer_stop(timer_auto_exit); + furi_timer_free(timer_auto_exit); + timer_auto_exit = NULL; + } notification_message(app->notifications, &sequence_blink_stop); popup_reset(app->popup); diff --git a/applications/main/nfc/scenes/nfc_scene_emulate.c b/applications/main/nfc/scenes/nfc_scene_emulate.c index e530cfb9f..009bf674e 100644 --- a/applications/main/nfc/scenes/nfc_scene_emulate.c +++ b/applications/main/nfc/scenes/nfc_scene_emulate.c @@ -4,9 +4,7 @@ #include -#define NFC_EMULATION_TIME_MAX_MS (5 * 60 * 1000) - -FuriTimer* timer_auto_exit; +FuriTimer* timer_auto_exit = NULL; void nfc_scene_emulate_timer_callback(void* context) { NfcApp* instance = context; @@ -20,15 +18,12 @@ void nfc_scene_emulate_on_enter(void* context) { nfc_protocol_support_on_enter(NfcProtocolSupportSceneEmulate, context); - timer_auto_exit = - furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance); - - if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) || instance->fav_timeout) + if(instance->fav_timeout) { + timer_auto_exit = + furi_timer_alloc(nfc_scene_emulate_timer_callback, FuriTimerTypeOnce, instance); furi_timer_start( - timer_auto_exit, - instance->fav_timeout ? - xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency() : - NFC_EMULATION_TIME_MAX_MS); + timer_auto_exit, xtreme_settings.favorite_timeout * furi_kernel_get_tick_frequency()); + } } bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { @@ -49,7 +44,10 @@ bool nfc_scene_emulate_on_event(void* context, SceneManagerEvent event) { } void nfc_scene_emulate_on_exit(void* context) { - furi_timer_stop(timer_auto_exit); - furi_timer_free(timer_auto_exit); + if(timer_auto_exit) { + furi_timer_stop(timer_auto_exit); + furi_timer_free(timer_auto_exit); + timer_auto_exit = NULL; + } nfc_protocol_support_on_exit(NfcProtocolSupportSceneEmulate, context); }