@@ -13,10 +13,11 @@ int32_t nfc_playlist_emulation_task(void* context) {
13
13
14
14
Storage * storage = furi_record_open (RECORD_STORAGE );
15
15
Stream * stream = file_stream_alloc (storage );
16
+ bool skip_delay = false;
16
17
17
18
popup_reset (nfc_playlist -> popup );
18
19
popup_set_context (nfc_playlist -> popup , nfc_playlist );
19
-
20
+
20
21
view_dispatcher_switch_to_view (nfc_playlist -> view_dispatcher , NfcPlaylistView_Popup );
21
22
22
23
if (file_stream_open (stream , furi_string_get_cstr (nfc_playlist -> settings .file_path ), FSAM_READ , FSOM_OPEN_EXISTING )) {
@@ -31,19 +32,20 @@ int32_t nfc_playlist_emulation_task(void* context) {
31
32
32
33
char * file_path = (char * )furi_string_get_cstr (line );
33
34
34
- if (strlen (file_path ) <= 1 ) {continue ;}
35
+ if (strlen (file_path ) <= 1 ) {continue ;}
35
36
36
- if (nfc_playlist -> settings .emulate_delay > 0 && file_position != 0 ) {
37
+ if (nfc_playlist -> settings .emulate_delay > 0 && file_position != 0 && ! skip_delay ) {
37
38
popup_set_header (nfc_playlist -> popup , "Delaying" , 64 , 10 , AlignCenter , AlignTop );
38
39
start_blink (nfc_playlist , NfcPlaylistLedState_Error );
39
40
int time_counter_delay_ms = (options_emulate_delay [nfc_playlist -> settings .emulate_delay ]* 1000 );
40
- do {
41
+ while ( time_counter_delay_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
41
42
furi_string_printf (tmp_counter_str , "%ds" , (time_counter_delay_ms /1000 ));
42
43
popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
43
44
furi_delay_ms (50 );
44
45
time_counter_delay_ms -= 50 ;
45
- } while ( time_counter_delay_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) ;
46
+ };
46
47
} else if (nfc_playlist -> settings .emulate_delay > 0 ) {
48
+ skip_delay = false;
47
49
file_position ++ ;
48
50
}
49
51
@@ -53,38 +55,46 @@ int32_t nfc_playlist_emulation_task(void* context) {
53
55
char const * file_ext = & strrchr (file_path , '.' )[1 ];
54
56
int time_counter_ms = (options_emulate_timeout [nfc_playlist -> settings .emulate_timeout ]* 1000 );
55
57
56
- if (storage_file_exists (storage , file_path ) == false) {
57
- furi_string_printf (tmp_header_str , "ERROR not found:\n%s" , file_name );
58
+ if (!strcasestr (file_ext , "nfc" )) {
59
+ if (nfc_playlist -> settings .skip_error ) {
60
+ skip_delay = true;
61
+ continue ;
62
+ }
63
+ furi_string_printf (tmp_header_str , "ERROR invalid file:\n%s" , file_name );
58
64
popup_set_header (nfc_playlist -> popup , furi_string_get_cstr (tmp_header_str ), 64 , 10 , AlignCenter , AlignTop );
59
65
start_blink (nfc_playlist , NfcPlaylistLedState_Error );
60
- do {
66
+ while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
61
67
furi_string_printf (tmp_counter_str , "%ds" , (time_counter_ms /1000 ));
62
68
popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
63
69
furi_delay_ms (50 );
64
70
time_counter_ms -= 50 ;
65
- } while (time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating );
66
- } else if (strcasestr (file_ext , "nfc" ) == NULL ) {
67
- furi_string_printf (tmp_header_str , "ERROR invalid file:\n%s" , file_name );
71
+ };
72
+ } else if (!storage_file_exists (storage , file_path )) {
73
+ if (nfc_playlist -> settings .skip_error ) {
74
+ skip_delay = true;
75
+ continue ;
76
+ }
77
+ furi_string_printf (tmp_header_str , "ERROR not found:\n%s" , file_name );
68
78
popup_set_header (nfc_playlist -> popup , furi_string_get_cstr (tmp_header_str ), 64 , 10 , AlignCenter , AlignTop );
69
79
start_blink (nfc_playlist , NfcPlaylistLedState_Error );
70
- do {
80
+ while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
71
81
furi_string_printf (tmp_counter_str , "%ds" , (time_counter_ms /1000 ));
72
82
popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
73
83
furi_delay_ms (50 );
74
84
time_counter_ms -= 50 ;
75
- } while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) ;
85
+ };
76
86
} else {
77
87
furi_string_printf (tmp_header_str , "Emulating:\n%s" , file_name );
78
88
popup_set_header (nfc_playlist -> popup , furi_string_get_cstr (tmp_header_str ), 64 , 10 , AlignCenter , AlignTop );
79
89
nfc_playlist_worker_set_nfc_data (nfc_playlist -> nfc_playlist_worker , file_path );
80
90
nfc_playlist_worker_start (nfc_playlist -> nfc_playlist_worker );
81
91
start_blink (nfc_playlist , NfcPlaylistLedState_Normal );
82
- do {
92
+ while ( nfc_playlist_worker_is_emulating ( nfc_playlist -> nfc_playlist_worker ) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
83
93
furi_string_printf (tmp_counter_str , "%ds" , (time_counter_ms /1000 ));
84
94
popup_set_text (nfc_playlist -> popup , furi_string_get_cstr (tmp_counter_str ), 64 , 50 , AlignCenter , AlignTop );
85
95
furi_delay_ms (50 );
86
96
time_counter_ms -= 50 ;
87
- } while ( nfc_playlist_worker_is_emulating ( nfc_playlist -> nfc_playlist_worker ) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) ;
97
+ };
88
98
nfc_playlist_worker_stop (nfc_playlist -> nfc_playlist_worker );
89
99
nfc_playlist_worker_clear_nfc_data (nfc_playlist -> nfc_playlist_worker );
90
100
}
@@ -98,7 +108,6 @@ int32_t nfc_playlist_emulation_task(void* context) {
98
108
furi_string_free (line );
99
109
furi_string_free (tmp_header_str );
100
110
furi_string_free (tmp_counter_str );
101
-
102
111
} else {
103
112
popup_set_header (nfc_playlist -> popup , "Failed to open playlist" , 64 , 10 , AlignCenter , AlignTop );
104
113
popup_set_text (nfc_playlist -> popup , "Press back" , 64 , 50 , AlignCenter , AlignTop );
0 commit comments