Skip to content

Commit

Permalink
Merge pull request #11 from acegoal07/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
acegoal07 authored Feb 24, 2024
2 parents 5040683 + 45118d4 commit c626381
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FlipperZero_NFC_Playlist:
The idea behind this app is to allow for you to test multiple copies of NFC's at once as a bulk test

## How it works (As of the moment will change):
## How it works:
When starting the app you are greeted by a select file option where you choose the playlist you wanna run.

All the playlists should be placed in ext/apps_data/nfc_playlist and an example of how the data in the file should look can be found below.
Expand All @@ -14,12 +14,12 @@ An example file can be found in the repository
## How to build
This app was design, built and tested using the <a href="https://github.com/Flipper-XFW/Xtreme-Firmware">Xtreme firmware</a> so keep that in mind when building the FAP for yourself

## Settings
## Settings:
- Emulate time (How long the NFC card will be emulated for)
- Delay time (How long the gap between the cards will be)
- LED indicator (Whether or not the LED's will be on)
- Reset settings (Puts all the settings back to the defaults)

## Playlist editor
## Playlist editor:
- Delete playlist (Deletes the selected playlist)
- Rename playlist (Renames the selected playlist the new name provided)
4 changes: 4 additions & 0 deletions lib/worker/nfc_playlist_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ void nfc_playlist_worker_set_nfc_data(NfcPlaylistWorker* nfc_playlist_worker, ch
nfc_playlist_worker->nfc_protocol = nfc_device_get_protocol(nfc_playlist_worker->nfc_device);
}

void nfc_playlist_worker_clear_nfc_data(NfcPlaylistWorker* nfc_playlist_worker) {
nfc_device_clear(nfc_playlist_worker->nfc_device);
}

NfcDeviceData* nfc_playlist_worker_get_nfc_data(NfcPlaylistWorker* nfc_playlist_worker) {
return nfc_playlist_worker->nfc_data;
}
3 changes: 2 additions & 1 deletion lib/worker/nfc_playlist_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ int32_t nfc_playlist_worker_task(void* context);

bool nfc_playlist_worker_is_emulating(NfcPlaylistWorker* nfc_playlist_worker);
void nfc_playlist_worker_set_nfc_data(NfcPlaylistWorker* nfc_playlist_worker, char* file_path);
NfcDeviceData* nfc_playlist_worker_get_nfc_data(NfcPlaylistWorker* nfc_playlist_worker);
void nfc_playlist_worker_clear_nfc_data(NfcPlaylistWorker* nfc_playlist_worker);
NfcDeviceData* nfc_playlist_worker_get_nfc_data(NfcPlaylistWorker* nfc_playlist_worker);
2 changes: 1 addition & 1 deletion nfc_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static NfcPlaylist* nfc_playlist_alloc() {
nfc_playlist->file_browser = file_browser_alloc(nfc_playlist->settings.file_path);
nfc_playlist->text_input = text_input_alloc();
nfc_playlist->popup = popup_alloc();

view_dispatcher_set_event_callback_context(nfc_playlist->view_dispatcher, nfc_playlist);
view_dispatcher_set_custom_event_callback(nfc_playlist->view_dispatcher, nfc_playlist_custom_callback);
view_dispatcher_set_navigation_event_callback(nfc_playlist->view_dispatcher, nfc_playlist_back_event_callback);
Expand Down
33 changes: 16 additions & 17 deletions scences/emulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int32_t nfc_playlist_emulation_task(void* context) {

if (strlen(file_path) <= 1) {continue;}

if (nfc_playlist->settings.emulate_delay > 0 && file_position > 0) {
if (nfc_playlist->settings.emulate_delay > 0 && file_position != 0) {
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);
Expand All @@ -87,10 +87,7 @@ int32_t nfc_playlist_emulation_task(void* context) {

if (EmulationState != NfcPlaylistEmulationState_Emulating) {break;}

char const* full_file_name = strchr(file_path, '/') != NULL ? &strrchr(file_path, '/')[1] : file_path;
char file_name[sizeof(full_file_name)];
strcpy(file_name, full_file_name);
strtok(file_name, ".");
char* file_name = strchr(file_path, '/') != NULL ? &strrchr(file_path, '/')[1] : file_path;
char const* file_ext = &strrchr(file_path, '.')[1];
int time_counter_ms = (options_emulate_timeout[nfc_playlist->settings.emulate_timeout]*1000);

Expand All @@ -100,26 +97,26 @@ int32_t nfc_playlist_emulation_task(void* context) {
snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR not found:", file_name);
popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
start_blink(nfc_playlist, NfcPlaylistLedState_Error);
while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
char popup_text[9];
snprintf(popup_text, 9, "%ds", (time_counter_ms/1000));
do {
char popup_text[10];
snprintf(popup_text, 10, "%ds", (time_counter_ms/1000));
popup_set_text(nfc_playlist->popup, popup_text, 64, 50, AlignCenter, AlignTop);
furi_delay_ms(50);
time_counter_ms -= 50;
}
} while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating);
} else if (strcasestr(file_ext, "nfc") == NULL) {
int popup_header_text_size = strlen(file_name) + 21;
char popup_header_text[popup_header_text_size];
snprintf(popup_header_text, popup_header_text_size, "%s\n%s", "ERROR invalid file:", file_name);
popup_set_header(nfc_playlist->popup, popup_header_text, 64, 10, AlignCenter, AlignTop);
start_blink(nfc_playlist, NfcPlaylistLedState_Error);
while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
char popup_text[9];
snprintf(popup_text, 9, "%ds", (time_counter_ms/1000));
do {
char popup_text[10];
snprintf(popup_text, 10, "%ds", (time_counter_ms/1000));
popup_set_text(nfc_playlist->popup, popup_text, 64, 50, AlignCenter, AlignTop);
furi_delay_ms(50);
time_counter_ms -= 50;
}
} while(time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating);
} else {
int popup_header_text_size = strlen(file_name) + 12;
char popup_header_text[popup_header_text_size];
Expand All @@ -128,15 +125,17 @@ int32_t nfc_playlist_emulation_task(void* context) {
nfc_playlist_worker_set_nfc_data(nfc_playlist->nfc_playlist_worker, file_path);
nfc_playlist_worker_start(nfc_playlist->nfc_playlist_worker);
start_blink(nfc_playlist, NfcPlaylistLedState_Normal);
while(nfc_playlist_worker_is_emulating(nfc_playlist->nfc_playlist_worker) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating) {
char popup_text[9];
snprintf(popup_text, 9, "%ds", (time_counter_ms/1000));
do {
char popup_text[10];
snprintf(popup_text, 10, "%ds", (time_counter_ms/1000));
popup_set_text(nfc_playlist->popup, popup_text, 64, 50, AlignCenter, AlignTop);
furi_delay_ms(50);
time_counter_ms -= 50;
}
} while(nfc_playlist_worker_is_emulating(nfc_playlist->nfc_playlist_worker) && time_counter_ms > 0 && EmulationState == NfcPlaylistEmulationState_Emulating);
nfc_playlist_worker_stop(nfc_playlist->nfc_playlist_worker);
nfc_playlist_worker_clear_nfc_data(nfc_playlist->nfc_playlist_worker);
}
free(file_path);
}
popup_reset(nfc_playlist->popup);
popup_set_header(nfc_playlist->popup, EmulationState == NfcPlaylistEmulationState_Canceled ? "Emulation stopped" : "Emulation finished", 64, 10, AlignCenter, AlignTop);
Expand Down
4 changes: 2 additions & 2 deletions scences/main_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void nfc_playlist_main_menu_scene_on_enter(void* context) {
NfcPlaylistMenuSelection_FileSelect,
nfc_playlist_main_menu_menu_callback,
nfc_playlist);

submenu_add_item(
nfc_playlist->submenu,
"Edit playlist",
Expand Down Expand Up @@ -101,7 +101,7 @@ bool nfc_playlist_main_menu_scene_on_event(void* context, SceneManagerEvent even
default:
break;
}
}
}
return consumed;
}

Expand Down

0 comments on commit c626381

Please sign in to comment.