2020-11-12 09:44:35 +00:00
|
|
|
#include "nfc_i.h"
|
2021-05-06 19:51:20 +00:00
|
|
|
#include "api-hal-nfc.h"
|
2020-10-18 22:09:48 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
osMessageQueueId_t message_queue = NULL;
|
|
|
|
|
|
|
|
uint32_t nfc_view_stop(void* context) {
|
|
|
|
furi_assert(message_queue);
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
NfcMessage message;
|
|
|
|
message.type = NfcMessageTypeStop;
|
2021-05-06 19:51:20 +00:00
|
|
|
furi_check(osMessageQueuePut(message_queue, &message, 0, osWaitForever) == osOK);
|
|
|
|
return NfcViewMenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t nfc_view_exit(void* context) {
|
|
|
|
furi_assert(message_queue);
|
|
|
|
NfcMessage message;
|
|
|
|
message.type = NfcMessageTypeExit;
|
|
|
|
furi_check(osMessageQueuePut(message_queue, &message, 0, osWaitForever) == osOK);
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
return VIEW_NONE;
|
2020-10-18 22:09:48 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
void nfc_menu_callback(void* context, uint32_t index) {
|
|
|
|
furi_assert(message_queue);
|
|
|
|
NfcMessage message;
|
|
|
|
if(index == 0) {
|
|
|
|
message.type = NfcMessageTypeDetect;
|
|
|
|
} else if(index == 1) {
|
2021-05-18 18:12:01 +00:00
|
|
|
message.type = NfcMessageTypeReadEMV;
|
2021-05-06 19:51:20 +00:00
|
|
|
} else if(index == 2) {
|
2021-05-25 23:54:44 +00:00
|
|
|
message.type = NfcMessageTypeEmulateEMV;
|
2021-05-18 18:12:01 +00:00
|
|
|
} else if(index == 3) {
|
2021-05-25 23:54:44 +00:00
|
|
|
message.type = NfcMessageTypeEmulate;
|
|
|
|
} else if(index == 4) {
|
2021-05-06 19:51:20 +00:00
|
|
|
message.type = NfcMessageTypeField;
|
|
|
|
}
|
|
|
|
furi_check(osMessageQueuePut(message_queue, &message, 0, osWaitForever) == osOK);
|
|
|
|
}
|
|
|
|
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
Nfc* nfc_alloc() {
|
|
|
|
Nfc* nfc = furi_alloc(sizeof(Nfc));
|
2020-10-18 22:09:48 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
message_queue = osMessageQueueNew(8, sizeof(NfcMessage), NULL);
|
2020-10-18 22:09:48 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
nfc->worker = nfc_worker_alloc(message_queue);
|
2020-11-16 15:26:34 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// Open GUI record
|
|
|
|
nfc->gui = furi_record_open("gui");
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// View Dispatcher
|
|
|
|
nfc->view_dispatcher = view_dispatcher_alloc();
|
|
|
|
view_dispatcher_attach_to_gui(nfc->view_dispatcher, nfc->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
|
|
|
|
// Menu
|
|
|
|
nfc->submenu = submenu_alloc();
|
|
|
|
submenu_add_item(nfc->submenu, "Detect", 0, nfc_menu_callback, nfc);
|
2021-05-18 18:12:01 +00:00
|
|
|
submenu_add_item(nfc->submenu, "Read EMV", 1, nfc_menu_callback, nfc);
|
2021-05-25 23:54:44 +00:00
|
|
|
submenu_add_item(nfc->submenu, "Emulate EMV", 2, nfc_menu_callback, nfc);
|
|
|
|
submenu_add_item(nfc->submenu, "Emulate", 3, nfc_menu_callback, nfc);
|
|
|
|
submenu_add_item(nfc->submenu, "Field", 4, nfc_menu_callback, nfc);
|
2021-05-06 19:51:20 +00:00
|
|
|
View* submenu_view = submenu_get_view(nfc->submenu);
|
|
|
|
view_set_previous_callback(submenu_view, nfc_view_exit);
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewMenu, submenu_view);
|
|
|
|
|
|
|
|
// Detect
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
nfc->view_detect = view_alloc();
|
|
|
|
view_set_context(nfc->view_detect, nfc);
|
|
|
|
view_set_draw_callback(nfc->view_detect, nfc_view_read_draw);
|
2021-05-06 19:51:20 +00:00
|
|
|
view_set_previous_callback(nfc->view_detect, nfc_view_stop);
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
view_allocate_model(nfc->view_detect, ViewModelTypeLocking, sizeof(NfcViewReadModel));
|
2021-05-06 19:51:20 +00:00
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewRead, nfc->view_detect);
|
|
|
|
|
2021-05-18 18:12:01 +00:00
|
|
|
// Read EMV
|
|
|
|
nfc->view_read_emv = view_alloc();
|
|
|
|
view_set_context(nfc->view_read_emv, nfc);
|
|
|
|
view_set_draw_callback(nfc->view_read_emv, nfc_view_read_emv_draw);
|
|
|
|
view_set_previous_callback(nfc->view_read_emv, nfc_view_stop);
|
|
|
|
view_allocate_model(nfc->view_read_emv, ViewModelTypeLocking, sizeof(NfcViewReadModel));
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewReadEmv, nfc->view_read_emv);
|
|
|
|
|
2021-05-25 23:54:44 +00:00
|
|
|
// Emulate EMV
|
|
|
|
nfc->view_emulate_emv = view_alloc();
|
|
|
|
view_set_context(nfc->view_emulate_emv, nfc);
|
|
|
|
view_set_draw_callback(nfc->view_emulate_emv, nfc_view_emulate_emv_draw);
|
|
|
|
view_set_previous_callback(nfc->view_emulate_emv, nfc_view_stop);
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewEmulateEMV, nfc->view_emulate_emv);
|
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// Emulate
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
nfc->view_emulate = view_alloc();
|
|
|
|
view_set_context(nfc->view_emulate, nfc);
|
|
|
|
view_set_draw_callback(nfc->view_emulate, nfc_view_emulate_draw);
|
2021-05-06 19:51:20 +00:00
|
|
|
view_set_previous_callback(nfc->view_emulate, nfc_view_stop);
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewEmulate, nfc->view_emulate);
|
|
|
|
|
|
|
|
// Field
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
nfc->view_field = view_alloc();
|
|
|
|
view_set_context(nfc->view_field, nfc);
|
|
|
|
view_set_draw_callback(nfc->view_field, nfc_view_field_draw);
|
2021-05-06 19:51:20 +00:00
|
|
|
view_set_previous_callback(nfc->view_field, nfc_view_stop);
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewField, nfc->view_field);
|
|
|
|
|
|
|
|
// Error
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
nfc->view_error = view_alloc();
|
|
|
|
view_set_context(nfc->view_error, nfc);
|
|
|
|
view_set_draw_callback(nfc->view_error, nfc_view_error_draw);
|
2021-05-06 19:51:20 +00:00
|
|
|
view_set_previous_callback(nfc->view_error, nfc_view_stop);
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
view_allocate_model(nfc->view_error, ViewModelTypeLockFree, sizeof(NfcViewErrorModel));
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewError, nfc->view_error);
|
2020-11-16 15:26:34 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// Switch to menu
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewMenu);
|
|
|
|
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
return nfc;
|
2020-11-12 09:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
void nfc_free(Nfc* nfc) {
|
|
|
|
// Free nfc worker
|
|
|
|
nfc_worker_free(nfc->worker);
|
|
|
|
// Free allocated queue
|
|
|
|
osMessageQueueDelete(message_queue);
|
|
|
|
message_queue = NULL;
|
2020-11-12 09:44:35 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// Free allocated views
|
|
|
|
// Menu
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewMenu);
|
|
|
|
submenu_free(nfc->submenu);
|
2020-10-18 22:09:48 +00:00
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// Detect
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewRead);
|
|
|
|
view_free(nfc->view_detect);
|
2020-10-18 22:09:48 +00:00
|
|
|
|
2021-05-25 23:54:44 +00:00
|
|
|
// Read EMV
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewReadEmv);
|
|
|
|
view_free(nfc->view_read_emv);
|
|
|
|
|
|
|
|
// Emulate EMV
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewEmulateEMV);
|
|
|
|
view_free(nfc->view_emulate_emv);
|
|
|
|
|
2021-05-06 19:51:20 +00:00
|
|
|
// Emulate
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewEmulate);
|
|
|
|
view_free(nfc->view_emulate);
|
|
|
|
|
|
|
|
// Field
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewField);
|
|
|
|
view_free(nfc->view_field);
|
|
|
|
|
|
|
|
// Error
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewError);
|
|
|
|
view_free(nfc->view_error);
|
|
|
|
|
|
|
|
// Free View Dispatcher
|
|
|
|
view_dispatcher_free(nfc->view_dispatcher);
|
|
|
|
|
|
|
|
// Close all opened records
|
|
|
|
furi_record_close("gui");
|
|
|
|
nfc->gui = NULL;
|
|
|
|
|
|
|
|
// Free nfc object
|
|
|
|
free(nfc);
|
2020-10-18 22:09:48 +00:00
|
|
|
}
|
|
|
|
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
void nfc_start(Nfc* nfc, NfcView view_id, NfcWorkerState worker_state) {
|
|
|
|
NfcWorkerState state = nfc_worker_get_state(nfc->worker);
|
|
|
|
if(state == NfcWorkerStateBroken) {
|
|
|
|
with_view_model(
|
2021-02-10 09:06:29 +00:00
|
|
|
nfc->view_error, (NfcViewErrorModel * model) {
|
|
|
|
model->error = nfc_worker_get_error(nfc->worker);
|
|
|
|
return true;
|
|
|
|
});
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewError);
|
|
|
|
} else if(state == NfcWorkerStateReady) {
|
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, view_id);
|
|
|
|
nfc_worker_start(nfc->worker, worker_state);
|
|
|
|
}
|
2020-10-18 22:09:48 +00:00
|
|
|
}
|
|
|
|
|
2021-02-12 17:24:34 +00:00
|
|
|
int32_t nfc_task(void* p) {
|
2020-10-18 22:55:41 +00:00
|
|
|
Nfc* nfc = nfc_alloc();
|
2020-10-18 22:09:48 +00:00
|
|
|
|
2020-10-18 22:55:41 +00:00
|
|
|
NfcMessage message;
|
2020-10-18 22:09:48 +00:00
|
|
|
while(1) {
|
2021-05-06 19:51:20 +00:00
|
|
|
furi_check(osMessageQueueGet(message_queue, &message, NULL, osWaitForever) == osOK);
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
if(message.type == NfcMessageTypeDetect) {
|
|
|
|
with_view_model(
|
2021-02-10 09:06:29 +00:00
|
|
|
nfc->view_detect, (NfcViewReadModel * model) {
|
|
|
|
model->found = false;
|
|
|
|
return true;
|
|
|
|
});
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
nfc_start(nfc, NfcViewRead, NfcWorkerStatePoll);
|
2021-05-18 18:12:01 +00:00
|
|
|
} else if(message.type == NfcMessageTypeReadEMV) {
|
|
|
|
with_view_model(
|
|
|
|
nfc->view_read_emv, (NfcViewReadModel * model) {
|
|
|
|
model->found = false;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
nfc_start(nfc, NfcViewReadEmv, NfcWorkerStateReadEMV);
|
2021-05-25 23:54:44 +00:00
|
|
|
} else if(message.type == NfcMessageTypeEmulateEMV) {
|
|
|
|
nfc_start(nfc, NfcViewEmulateEMV, NfcWorkerStateEmulateEMV);
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
} else if(message.type == NfcMessageTypeEmulate) {
|
|
|
|
nfc_start(nfc, NfcViewEmulate, NfcWorkerStateEmulate);
|
|
|
|
} else if(message.type == NfcMessageTypeField) {
|
|
|
|
nfc_start(nfc, NfcViewField, NfcWorkerStateField);
|
|
|
|
} else if(message.type == NfcMessageTypeStop) {
|
|
|
|
nfc_worker_stop(nfc->worker);
|
|
|
|
} else if(message.type == NfcMessageTypeDeviceFound) {
|
2021-05-06 19:51:20 +00:00
|
|
|
with_view_model(
|
|
|
|
nfc->view_detect, (NfcViewReadModel * model) {
|
|
|
|
model->found = true;
|
|
|
|
model->device = message.device;
|
|
|
|
return true;
|
|
|
|
});
|
FL-53: new NFC worker, A/B/F/V poll and display. (#283)
* GUI: view. Flooper-blooper fix compilation error.
* GUI: view and viewdispatcher bones
* GUI: view implementation, view models, view dispatcher
* GUI: view navigation, model refinement. Power: use view, view dispatcher.
* HAL Flash: proper page write. Dolphin: views. Power: views
* Dolphin: transition idle scree to Views
* Dolphin: input events on stats view. Format sources.
* HAL: flash erase. Dolphin: permanent state storage.
* Dolphin: first start welcome. HAL: flash operation status, errata 2.2.9 crutch.
* NFC: rewrite worker
* NFC: add support for B,F,V.
* NFC: replace rfal irq hanlder with realtime thread, more details about cards.
* Bootloader: LSE and RTS shenanigans, LED control, morse code for LSE failure error.
* F4: stop in Error_Handler
* BLE: handle working FUS, but empty radio stack.
* HAL: alive FUS is now sufficient for flash controller access
* Dolphin: update model after state load
* NFC: detect navigation
* RFAL: use osPriorityISR for isr thread
* NFC: emulation
* Bootloader: rollback incorrectly merged rename
* Dolphin: rollback incorrectly merged changes
* RFAL: remove volatile from thread attr
* RFAL: do not call platform ErrorHandler, error codes is enough
* NFC: improved error handling
* Format sources
* NFC: reset detect view model on start
* Format sources
* update codeowners
* NFC: hide last info if no card detected
2021-01-11 12:42:25 +00:00
|
|
|
} else if(message.type == NfcMessageTypeDeviceNotFound) {
|
2021-05-06 19:51:20 +00:00
|
|
|
with_view_model(
|
|
|
|
nfc->view_detect, (NfcViewReadModel * model) {
|
|
|
|
model->found = false;
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-18 18:12:01 +00:00
|
|
|
} else if(message.type == NfcMessageTypeEMVFound) {
|
|
|
|
with_view_model(
|
|
|
|
nfc->view_read_emv, (NfcViewReadModel * model) {
|
|
|
|
model->found = true;
|
|
|
|
model->device = message.device;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
} else if(message.type == NfcMessageTypeEMVNotFound) {
|
|
|
|
with_view_model(
|
|
|
|
nfc->view_read_emv, (NfcViewReadModel * model) {
|
|
|
|
model->found = false;
|
|
|
|
return true;
|
|
|
|
});
|
2021-05-06 19:51:20 +00:00
|
|
|
} else if(message.type == NfcMessageTypeExit) {
|
|
|
|
nfc_free(nfc);
|
|
|
|
break;
|
2020-10-18 22:09:48 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-12 17:24:34 +00:00
|
|
|
|
|
|
|
return 0;
|
2020-10-18 22:09:48 +00:00
|
|
|
}
|