Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
No auto stop emulate after 5 mins --nobuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Feb 22, 2024
1 parent e2ab71e commit f41609d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
24 changes: 11 additions & 13 deletions applications/main/lfrfid/scenes/lfrfid_scene_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

#include <xtreme/xtreme.h>

#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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
24 changes: 11 additions & 13 deletions applications/main/nfc/scenes/nfc_scene_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

#include <xtreme/xtreme.h>

#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;
Expand All @@ -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) {
Expand All @@ -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);
}

0 comments on commit f41609d

Please sign in to comment.