Skip to content

Commit

Permalink
Worker update
Browse files Browse the repository at this point in the history
  • Loading branch information
acegoal07 committed Mar 1, 2024
1 parent aaa7858 commit bf9314c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
19 changes: 5 additions & 14 deletions lib/worker/nfc_playlist_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@

NfcPlaylistWorker* nfc_playlist_worker_alloc() {
NfcPlaylistWorker* nfc_playlist_worker = malloc(sizeof(NfcPlaylistWorker));

nfc_playlist_worker->thread = furi_thread_alloc_ex("NfcPlaylistWorker", 8192, nfc_playlist_worker_task, nfc_playlist_worker);
nfc_playlist_worker->state = NfcPlaylistWorkerState_Stopped;

nfc_playlist_worker->nfc = nfc_alloc();
nfc_playlist_worker->nfc_device = nfc_device_alloc();

return nfc_playlist_worker;
}

void nfc_playlist_worker_free(NfcPlaylistWorker* nfc_playlist_worker) {
furi_assert(nfc_playlist_worker);
furi_thread_free(nfc_playlist_worker->thread);

nfc_free(nfc_playlist_worker->nfc);
nfc_device_free(nfc_playlist_worker->nfc_device);

nfc_listener_free(nfc_playlist_worker->nfc_listener);
free(nfc_playlist_worker);
}

Expand Down Expand Up @@ -62,22 +58,17 @@ int32_t nfc_playlist_worker_task(void* context) {
}

bool nfc_playlist_worker_is_emulating(NfcPlaylistWorker* nfc_playlist_worker) {
if (nfc_playlist_worker->state == NfcPlaylistWorkerState_Emulating) {
return true;
}
return false;
furi_assert(nfc_playlist_worker);
return nfc_playlist_worker->state == NfcPlaylistWorkerState_Emulating;
}

void nfc_playlist_worker_set_nfc_data(NfcPlaylistWorker* nfc_playlist_worker, char* file_path) {
nfc_device_clear(nfc_playlist_worker->nfc_device);
furi_assert(nfc_playlist_worker);
nfc_device_load(nfc_playlist_worker->nfc_device, file_path);
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) {
furi_assert(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;
}
4 changes: 1 addition & 3 deletions lib/worker/nfc_playlist_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ typedef struct NfcPlaylistWorker {
NfcListener* nfc_listener;
NfcDevice* nfc_device;
NfcProtocol nfc_protocol;
NfcDeviceData* nfc_data;
Nfc* nfc;
} NfcPlaylistWorker;

Expand All @@ -29,5 +28,4 @@ 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);
void nfc_playlist_worker_clear_nfc_data(NfcPlaylistWorker* nfc_playlist_worker);
NfcDeviceData* nfc_playlist_worker_get_nfc_data(NfcPlaylistWorker* nfc_playlist_worker);
void nfc_playlist_worker_clear_nfc_data(NfcPlaylistWorker* nfc_playlist_worker);

0 comments on commit bf9314c

Please sign in to comment.