@@ -87,7 +87,6 @@ int32_t nfc_playlist_emulation_task(void* context) {
8787
8888 if (EmulationState != NfcPlaylistEmulationState_Emulating ) {break ;}
8989
90-
9190 char * file_name = strchr (file_path , '/' ) != NULL ? & strrchr (file_path , '/' )[1 ] : file_path ;
9291 char const * file_ext = & strrchr (file_path , '.' )[1 ];
9392 int time_counter_ms = (options_emulate_timeout [nfc_playlist -> settings .emulate_timeout ]* 1000 );
@@ -98,26 +97,26 @@ int32_t nfc_playlist_emulation_task(void* context) {
9897 snprintf (popup_header_text , popup_header_text_size , "%s\n%s" , "ERROR not found:" , file_name );
9998 popup_set_header (nfc_playlist -> popup , popup_header_text , 64 , 10 , AlignCenter , AlignTop );
10099 start_blink (nfc_playlist , NfcPlaylistLedState_Error );
101- while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
102- char popup_text [9 ];
103- snprintf (popup_text , 9 , "%ds" , (time_counter_ms /1000 ));
100+ do {
101+ char popup_text [10 ];
102+ snprintf (popup_text , 10 , "%ds" , (time_counter_ms /1000 ));
104103 popup_set_text (nfc_playlist -> popup , popup_text , 64 , 50 , AlignCenter , AlignTop );
105104 furi_delay_ms (50 );
106105 time_counter_ms -= 50 ;
107- }
106+ } while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating );
108107 } else if (strcasestr (file_ext , "nfc" ) == NULL ) {
109108 int popup_header_text_size = strlen (file_name ) + 21 ;
110109 char popup_header_text [popup_header_text_size ];
111110 snprintf (popup_header_text , popup_header_text_size , "%s\n%s" , "ERROR invalid file:" , file_name );
112111 popup_set_header (nfc_playlist -> popup , popup_header_text , 64 , 10 , AlignCenter , AlignTop );
113112 start_blink (nfc_playlist , NfcPlaylistLedState_Error );
114- while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
115- char popup_text [9 ];
116- snprintf (popup_text , 9 , "%ds" , (time_counter_ms /1000 ));
113+ do {
114+ char popup_text [10 ];
115+ snprintf (popup_text , 10 , "%ds" , (time_counter_ms /1000 ));
117116 popup_set_text (nfc_playlist -> popup , popup_text , 64 , 50 , AlignCenter , AlignTop );
118117 furi_delay_ms (50 );
119118 time_counter_ms -= 50 ;
120- }
119+ } while ( time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating );
121120 } else {
122121 int popup_header_text_size = strlen (file_name ) + 12 ;
123122 char popup_header_text [popup_header_text_size ];
@@ -126,13 +125,13 @@ int32_t nfc_playlist_emulation_task(void* context) {
126125 nfc_playlist_worker_set_nfc_data (nfc_playlist -> nfc_playlist_worker , file_path );
127126 nfc_playlist_worker_start (nfc_playlist -> nfc_playlist_worker );
128127 start_blink (nfc_playlist , NfcPlaylistLedState_Normal );
129- while ( nfc_playlist_worker_is_emulating ( nfc_playlist -> nfc_playlist_worker ) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating ) {
130- char popup_text [9 ];
131- snprintf (popup_text , 9 , "%ds" , (time_counter_ms /1000 ));
128+ do {
129+ char popup_text [10 ];
130+ snprintf (popup_text , 10 , "%ds" , (time_counter_ms /1000 ));
132131 popup_set_text (nfc_playlist -> popup , popup_text , 64 , 50 , AlignCenter , AlignTop );
133132 furi_delay_ms (50 );
134133 time_counter_ms -= 50 ;
135- }
134+ } while ( nfc_playlist_worker_is_emulating ( nfc_playlist -> nfc_playlist_worker ) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating );
136135 nfc_playlist_worker_stop (nfc_playlist -> nfc_playlist_worker );
137136 nfc_playlist_worker_clear_nfc_data (nfc_playlist -> nfc_playlist_worker );
138137 }
0 commit comments