Skip to content

Commit

Permalink
Name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
acegoal07 committed Dec 12, 2023
1 parent eea3cb3 commit 6a34f2b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
App(
appid="nfc_playlist",
name="nfc playlist",
name="NFC Playlist",
apptype=FlipperAppType.EXTERNAL,
entry_point="nfc_playlist_main",
requires=["gui", "nfx"],
Expand Down
30 changes: 18 additions & 12 deletions nfc_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,29 @@ int32_t nfc_playlist_main(void* p) {
Storage* storage = furi_record_open(RECORD_STORAGE);
Stream* stream = file_stream_alloc(storage);
FuriString* line = furi_string_alloc();
NfcDevice* nfcDevice = nfc_device_alloc();
Nfc* nfc = nfc_alloc();

// Read file
if(file_stream_open(stream, APP_DATA_PATH("playlistTest.txt"), FSAM_READ, FSOM_OPEN_EXISTING)) {

// Get resources
NfcDevice* nfc_device = nfc_device_alloc();
Nfc* nfc = nfc_alloc();

while(stream_read_line(stream, line)) {
// Store file location
const char* fileLocation = strcat("/ext/nfc/",furi_string_get_cstr(line));
const char* fileLocation = strcat("/ext/nfc/", furi_string_get_cstr(line));

// Load file
if (nfc_device_load(nfcDevice, fileLocation)) {
if (nfc_device_load(nfc_device, fileLocation)) {

if (DEBUG) {FURI_LOG_I(TAG, "Loaded file");}

// Get protocol
const NfcProtocol protocol = nfc_device_get_protocol(nfcDevice);
const NfcProtocol nfc_protocol = nfc_device_get_protocol(nfc_device);
// Get listern
NfcListener* mfu_listener = nfc_listener_alloc(nfc, protocol, nfc_device_get_data(nfcDevice, protocol));
NfcListener* listener = nfc_listener_alloc(nfc, nfc_protocol, nfc_device_get_data(nfc_device, nfc_protocol));
// Start listener
nfc_listener_start(mfu_listener, NULL, NULL);
nfc_listener_start(listener, NULL, NULL);

// Worst timer ever
int counter = 0;
Expand All @@ -59,17 +62,22 @@ int32_t nfc_playlist_main(void* p) {
}

// Stop listener && free
nfc_listener_stop(mfu_listener);
nfc_listener_free(mfu_listener);
nfc_listener_stop(listener);
nfc_listener_free(listener);

} else {
if (DEBUG) {FURI_LOG_E(TAG, "Failed to load file");}
}
// output file location
if (DEBUG) {FURI_LOG_I(TAG, "%s", fileLocation);}
// clear instance
nfc_device_clear(nfcDevice);
nfc_device_clear(nfc_device);
}

// Free/close resources
nfc_device_free(nfc_device);
nfc_free(nfc);

} else {
if (DEBUG) {FURI_LOG_E(TAG, "Failed to open file");}
}
Expand All @@ -78,8 +86,6 @@ int32_t nfc_playlist_main(void* p) {
furi_string_free(line);
file_stream_close(stream);
stream_free(stream);
nfc_device_free(nfcDevice);
nfc_free(nfc);

// Close storage
furi_record_close(RECORD_STORAGE);
Expand Down

0 comments on commit 6a34f2b

Please sign in to comment.