Skip to content

Commit 6a34f2b

Browse files
committed
Name changes
1 parent eea3cb3 commit 6a34f2b

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
App(
22
appid="nfc_playlist",
3-
name="nfc playlist",
3+
name="NFC Playlist",
44
apptype=FlipperAppType.EXTERNAL,
55
entry_point="nfc_playlist_main",
66
requires=["gui", "nfx"],

nfc_playlist.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,29 @@ int32_t nfc_playlist_main(void* p) {
2727
Storage* storage = furi_record_open(RECORD_STORAGE);
2828
Stream* stream = file_stream_alloc(storage);
2929
FuriString* line = furi_string_alloc();
30-
NfcDevice* nfcDevice = nfc_device_alloc();
31-
Nfc* nfc = nfc_alloc();
3230

3331
// Read file
3432
if(file_stream_open(stream, APP_DATA_PATH("playlistTest.txt"), FSAM_READ, FSOM_OPEN_EXISTING)) {
33+
34+
// Get resources
35+
NfcDevice* nfc_device = nfc_device_alloc();
36+
Nfc* nfc = nfc_alloc();
37+
3538
while(stream_read_line(stream, line)) {
3639
// Store file location
37-
const char* fileLocation = strcat("/ext/nfc/",furi_string_get_cstr(line));
40+
const char* fileLocation = strcat("/ext/nfc/", furi_string_get_cstr(line));
3841

3942
// Load file
40-
if (nfc_device_load(nfcDevice, fileLocation)) {
43+
if (nfc_device_load(nfc_device, fileLocation)) {
4144

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

4447
// Get protocol
45-
const NfcProtocol protocol = nfc_device_get_protocol(nfcDevice);
48+
const NfcProtocol nfc_protocol = nfc_device_get_protocol(nfc_device);
4649
// Get listern
47-
NfcListener* mfu_listener = nfc_listener_alloc(nfc, protocol, nfc_device_get_data(nfcDevice, protocol));
50+
NfcListener* listener = nfc_listener_alloc(nfc, nfc_protocol, nfc_device_get_data(nfc_device, nfc_protocol));
4851
// Start listener
49-
nfc_listener_start(mfu_listener, NULL, NULL);
52+
nfc_listener_start(listener, NULL, NULL);
5053

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

6164
// Stop listener && free
62-
nfc_listener_stop(mfu_listener);
63-
nfc_listener_free(mfu_listener);
65+
nfc_listener_stop(listener);
66+
nfc_listener_free(listener);
6467

6568
} else {
6669
if (DEBUG) {FURI_LOG_E(TAG, "Failed to load file");}
6770
}
6871
// output file location
6972
if (DEBUG) {FURI_LOG_I(TAG, "%s", fileLocation);}
7073
// clear instance
71-
nfc_device_clear(nfcDevice);
74+
nfc_device_clear(nfc_device);
7275
}
76+
77+
// Free/close resources
78+
nfc_device_free(nfc_device);
79+
nfc_free(nfc);
80+
7381
} else {
7482
if (DEBUG) {FURI_LOG_E(TAG, "Failed to open file");}
7583
}
@@ -78,8 +86,6 @@ int32_t nfc_playlist_main(void* p) {
7886
furi_string_free(line);
7987
file_stream_close(stream);
8088
stream_free(stream);
81-
nfc_device_free(nfcDevice);
82-
nfc_free(nfc);
8389

8490
// Close storage
8591
furi_record_close(RECORD_STORAGE);

0 commit comments

Comments
 (0)