|
@@ -20,13 +20,20 @@ int32_t nfc_playlist_emulation_task(void* context) {
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_Popup);
|
|
view_dispatcher_switch_to_view(nfc_playlist->view_dispatcher, NfcPlaylistView_Popup);
|
|
|
|
|
|
|
|
- if(file_stream_open(
|
|
|
|
|
- stream,
|
|
|
|
|
- furi_string_get_cstr(nfc_playlist->settings.playlist_path),
|
|
|
|
|
- FSAM_READ,
|
|
|
|
|
- FSOM_OPEN_EXISTING)) {
|
|
|
|
|
|
|
+ if(nfc_playlist->settings.playlist_length == 0) {
|
|
|
|
|
+ popup_set_header(
|
|
|
|
|
+ nfc_playlist->popup,
|
|
|
|
|
+ "The playlist you have\nselected is empty",
|
|
|
|
|
+ 64,
|
|
|
|
|
+ 10,
|
|
|
|
|
+ AlignCenter,
|
|
|
|
|
+ AlignTop);
|
|
|
|
|
+ } else if(file_stream_open(
|
|
|
|
|
+ stream,
|
|
|
|
|
+ furi_string_get_cstr(nfc_playlist->settings.playlist_path),
|
|
|
|
|
+ FSAM_READ,
|
|
|
|
|
+ FSOM_OPEN_EXISTING)) {
|
|
|
EmulationState = NfcPlaylistEmulationState_Emulating;
|
|
EmulationState = NfcPlaylistEmulationState_Emulating;
|
|
|
- int file_position = 0;
|
|
|
|
|
|
|
|
|
|
FuriString* line = furi_string_alloc();
|
|
FuriString* line = furi_string_alloc();
|
|
|
FuriString* tmp_header_str = furi_string_alloc();
|
|
FuriString* tmp_header_str = furi_string_alloc();
|
|
@@ -34,6 +41,9 @@ int32_t nfc_playlist_emulation_task(void* context) {
|
|
|
FuriString* tmp_file_name = furi_string_alloc();
|
|
FuriString* tmp_file_name = furi_string_alloc();
|
|
|
FuriString* tmp_file_ext = furi_string_alloc();
|
|
FuriString* tmp_file_ext = furi_string_alloc();
|
|
|
|
|
|
|
|
|
|
+ bool delay_setting_on = nfc_playlist->settings.emulate_delay > 0;
|
|
|
|
|
+ bool delay_active = false;
|
|
|
|
|
+
|
|
|
while(stream_read_line(stream, line) &&
|
|
while(stream_read_line(stream, line) &&
|
|
|
EmulationState == NfcPlaylistEmulationState_Emulating) {
|
|
EmulationState == NfcPlaylistEmulationState_Emulating) {
|
|
|
char* file_path = (char*)furi_string_get_cstr(line);
|
|
char* file_path = (char*)furi_string_get_cstr(line);
|
|
@@ -42,28 +52,31 @@ int32_t nfc_playlist_emulation_task(void* context) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(nfc_playlist->settings.emulate_delay > 0 && file_position != 0 && !skip_delay) {
|
|
|
|
|
- popup_set_header(nfc_playlist->popup, "Delaying", 64, 10, AlignCenter, AlignTop);
|
|
|
|
|
- start_blink(nfc_playlist, NfcPlaylistLedState_Error);
|
|
|
|
|
- int time_counter_delay_ms =
|
|
|
|
|
- (options_emulate_delay[nfc_playlist->settings.emulate_delay] * 1000);
|
|
|
|
|
- while(time_counter_delay_ms > 0 &&
|
|
|
|
|
- EmulationState == NfcPlaylistEmulationState_Emulating) {
|
|
|
|
|
- furi_string_printf(tmp_counter_str, "%ds", (time_counter_delay_ms / 1000));
|
|
|
|
|
- popup_set_text(
|
|
|
|
|
- nfc_playlist->popup,
|
|
|
|
|
- furi_string_get_cstr(tmp_counter_str),
|
|
|
|
|
- 64,
|
|
|
|
|
- 50,
|
|
|
|
|
- AlignCenter,
|
|
|
|
|
- AlignTop);
|
|
|
|
|
- furi_delay_ms(50);
|
|
|
|
|
- time_counter_delay_ms -= 50;
|
|
|
|
|
- furi_string_reset(tmp_counter_str);
|
|
|
|
|
- };
|
|
|
|
|
- } else if(nfc_playlist->settings.emulate_delay > 0) {
|
|
|
|
|
- skip_delay = false;
|
|
|
|
|
- file_position++;
|
|
|
|
|
|
|
+ if(delay_setting_on) {
|
|
|
|
|
+ if(delay_active && !skip_delay) {
|
|
|
|
|
+ popup_set_header(
|
|
|
|
|
+ nfc_playlist->popup, "Delaying", 64, 10, AlignCenter, AlignTop);
|
|
|
|
|
+ start_blink(nfc_playlist, NfcPlaylistLedState_Error);
|
|
|
|
|
+ int time_counter_delay_ms =
|
|
|
|
|
+ (options_emulate_delay[nfc_playlist->settings.emulate_delay] * 1000);
|
|
|
|
|
+ while(time_counter_delay_ms > 0 &&
|
|
|
|
|
+ EmulationState == NfcPlaylistEmulationState_Emulating) {
|
|
|
|
|
+ furi_string_printf(tmp_counter_str, "%ds", (time_counter_delay_ms / 1000));
|
|
|
|
|
+ popup_set_text(
|
|
|
|
|
+ nfc_playlist->popup,
|
|
|
|
|
+ furi_string_get_cstr(tmp_counter_str),
|
|
|
|
|
+ 64,
|
|
|
|
|
+ 50,
|
|
|
|
|
+ AlignCenter,
|
|
|
|
|
+ AlignTop);
|
|
|
|
|
+ furi_delay_ms(50);
|
|
|
|
|
+ time_counter_delay_ms -= 50;
|
|
|
|
|
+ };
|
|
|
|
|
+ } else if(!delay_active) {
|
|
|
|
|
+ delay_active = true;
|
|
|
|
|
+ } else if(skip_delay) {
|
|
|
|
|
+ skip_delay = false;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if(EmulationState != NfcPlaylistEmulationState_Emulating) {
|
|
if(EmulationState != NfcPlaylistEmulationState_Emulating) {
|
|
@@ -76,7 +89,7 @@ int32_t nfc_playlist_emulation_task(void* context) {
|
|
|
int time_counter_ms =
|
|
int time_counter_ms =
|
|
|
(options_emulate_timeout[nfc_playlist->settings.emulate_timeout] * 1000);
|
|
(options_emulate_timeout[nfc_playlist->settings.emulate_timeout] * 1000);
|
|
|
|
|
|
|
|
- if(!furi_string_cmpi_str(tmp_file_ext, "nfc")) {
|
|
|
|
|
|
|
+ if(!strcasestr(furi_string_get_cstr(tmp_file_ext), ".nfc")) {
|
|
|
if(nfc_playlist->settings.skip_error) {
|
|
if(nfc_playlist->settings.skip_error) {
|
|
|
skip_delay = true;
|
|
skip_delay = true;
|
|
|
continue;
|
|
continue;
|
|
@@ -168,38 +181,35 @@ int32_t nfc_playlist_emulation_task(void* context) {
|
|
|
nfc_playlist->nfc_playlist_emulation_worker);
|
|
nfc_playlist->nfc_playlist_emulation_worker);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- popup_reset(nfc_playlist->popup);
|
|
|
|
|
- if(nfc_playlist->settings.playlist_length == 0) {
|
|
|
|
|
- popup_set_header(nfc_playlist->popup, "Empty playlist", 64, 10, AlignCenter, AlignTop);
|
|
|
|
|
- } else {
|
|
|
|
|
- popup_set_header(
|
|
|
|
|
- nfc_playlist->popup,
|
|
|
|
|
- EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" :
|
|
|
|
|
- "Emulation finished",
|
|
|
|
|
- 64,
|
|
|
|
|
- 10,
|
|
|
|
|
- AlignCenter,
|
|
|
|
|
- AlignTop);
|
|
|
|
|
- }
|
|
|
|
|
- popup_set_text(nfc_playlist->popup, "Press back", 64, 50, AlignCenter, AlignTop);
|
|
|
|
|
stop_blink(nfc_playlist);
|
|
stop_blink(nfc_playlist);
|
|
|
|
|
|
|
|
- EmulationState = NfcPlaylistEmulationState_Stopped;
|
|
|
|
|
furi_string_free(line);
|
|
furi_string_free(line);
|
|
|
furi_string_free(tmp_header_str);
|
|
furi_string_free(tmp_header_str);
|
|
|
furi_string_free(tmp_counter_str);
|
|
furi_string_free(tmp_counter_str);
|
|
|
furi_string_free(tmp_file_name);
|
|
furi_string_free(tmp_file_name);
|
|
|
furi_string_free(tmp_file_ext);
|
|
furi_string_free(tmp_file_ext);
|
|
|
|
|
+ file_stream_close(stream);
|
|
|
|
|
+
|
|
|
|
|
+ popup_reset(nfc_playlist->popup);
|
|
|
|
|
+ popup_set_header(
|
|
|
|
|
+ nfc_playlist->popup,
|
|
|
|
|
+ EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" :
|
|
|
|
|
+ "Emulation finished",
|
|
|
|
|
+ 64,
|
|
|
|
|
+ 10,
|
|
|
|
|
+ AlignCenter,
|
|
|
|
|
+ AlignTop);
|
|
|
} else {
|
|
} else {
|
|
|
popup_set_header(
|
|
popup_set_header(
|
|
|
nfc_playlist->popup, "Failed to open playlist", 64, 10, AlignCenter, AlignTop);
|
|
nfc_playlist->popup, "Failed to open playlist", 64, 10, AlignCenter, AlignTop);
|
|
|
- popup_set_text(nfc_playlist->popup, "Press back", 64, 50, AlignCenter, AlignTop);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ popup_set_text(nfc_playlist->popup, "Press back", 64, 50, AlignCenter, AlignTop);
|
|
|
|
|
|
|
|
- file_stream_close(stream);
|
|
|
|
|
furi_record_close(RECORD_STORAGE);
|
|
furi_record_close(RECORD_STORAGE);
|
|
|
stream_free(stream);
|
|
stream_free(stream);
|
|
|
|
|
|
|
|
|
|
+ EmulationState = NfcPlaylistEmulationState_Stopped;
|
|
|
|
|
+
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|