-
Notifications
You must be signed in to change notification settings - Fork 8
/
uhf_worker.h
51 lines (44 loc) · 1.2 KB
/
uhf_worker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#include <furi.h>
#include <furi_hal.h>
#include "uhf_module.h"
#define UHF_WORKER_STACK_SIZE 1 * 1024
typedef enum {
// Init states
UHFWorkerStateNone,
UHFWorkerStateBroken,
UHFWorkerStateReady,
UHFWorkerStateVerify,
// Main worker states
UHFWorkerStateDetectSingle,
UHFWorkerStateWriteSingle,
UHFWorkerStateWriteKey,
// Transition
UHFWorkerStateStop,
} UHFWorkerState;
typedef enum {
UHFWorkerEventSuccess,
UHFWorkerEventFail,
UHFWorkerEventNoTagDetected,
UHFWorkerEventAborted,
UHFWorkerEventCardDetected,
} UHFWorkerEvent;
typedef void (*UHFWorkerCallback)(UHFWorkerEvent event, void* ctx);
typedef struct UHFWorker {
FuriThread* thread;
M100Module* module;
UHFWorkerCallback callback;
UHFWorkerState state;
UHFTagWrapper* uhf_tag_wrapper;
void* ctx;
} UHFWorker;
int32_t uhf_worker_task(void* ctx);
UHFWorker* uhf_worker_alloc();
void uhf_worker_change_state(UHFWorker* worker, UHFWorkerState state);
void uhf_worker_start(
UHFWorker* uhf_worker,
UHFWorkerState state,
UHFWorkerCallback callback,
void* ctx);
void uhf_worker_stop(UHFWorker* uhf_worker);
void uhf_worker_free(UHFWorker* uhf_worker);