2020-11-12 12:44:35 +03:00
|
|
|
#include "nfc_i.h"
|
2021-05-06 22:51:20 +03:00
|
|
|
#include "api-hal-nfc.h"
|
2020-10-19 01:09:48 +03:00
|
|
|
|
2021-05-06 22:51:20 +03: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 15:42:25 +03:00
|
|
|
NfcMessage message;
|
|
|
|
message.type = NfcMessageTypeStop;
|
2021-05-06 22:51:20 +03: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 15:42:25 +03:00
|
|
|
return VIEW_NONE;
|
2020-10-19 01:09:48 +03:00
|
|
|
}
|
|
|
|
|
2021-05-06 22:51:20 +03: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) {
|
|
|
|
message.type = NfcMessageTypeEmulate;
|
|
|
|
} else if(index == 2) {
|
|
|
|
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 15:42:25 +03:00
|
|
|
Nfc* nfc_alloc() {
|
|
|
|
Nfc* nfc = furi_alloc(sizeof(Nfc));
|
2020-10-19 01:09:48 +03:00
|
|
|
|
2021-05-06 22:51:20 +03:00
|
|
|
message_queue = osMessageQueueNew(8, sizeof(NfcMessage), NULL);
|
2020-10-19 01:09:48 +03:00
|
|
|
|
2021-05-06 22:51:20 +03:00
|
|
|
nfc->worker = nfc_worker_alloc(message_queue);
|
2020-11-16 18:26:34 +03:00
|
|
|
|
2021-05-06 22:51:20 +03: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 15:42:25 +03:00
|
|
|
|
2021-05-06 22:51:20 +03: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);
|
|
|
|
submenu_add_item(nfc->submenu, "Emulate", 1, nfc_menu_callback, nfc);
|
|
|
|
submenu_add_item(nfc->submenu, "Field", 2, nfc_menu_callback, nfc);
|
|
|
|
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 15:42:25 +03: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 22:51:20 +03: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 15:42:25 +03:00
|
|
|
view_allocate_model(nfc->view_detect, ViewModelTypeLocking, sizeof(NfcViewReadModel));
|
2021-05-06 22:51:20 +03:00
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewRead, nfc->view_detect);
|
|
|
|
|
|
|
|
// 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 15:42:25 +03: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 22:51:20 +03: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 15:42:25 +03: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 22:51:20 +03: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 15:42:25 +03: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 22:51:20 +03: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 15:42:25 +03:00
|
|
|
view_allocate_model(nfc->view_error, ViewModelTypeLockFree, sizeof(NfcViewErrorModel));
|
|
|
|
view_dispatcher_add_view(nfc->view_dispatcher, NfcViewError, nfc->view_error);
|
2020-11-16 18:26:34 +03:00
|
|
|
|
2021-05-06 22:51:20 +03: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 15:42:25 +03:00
|
|
|
return nfc;
|
2020-11-12 12:44:35 +03:00
|
|
|
}
|
|
|
|
|
2021-05-06 22:51:20 +03: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 12:44:35 +03:00
|
|
|
|
2021-05-06 22:51:20 +03:00
|
|
|
// Free allocated views
|
|
|
|
// Menu
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewMenu);
|
|
|
|
submenu_free(nfc->submenu);
|
2020-10-19 01:09:48 +03:00
|
|
|
|
2021-05-06 22:51:20 +03:00
|
|
|
// Detect
|
|
|
|
view_dispatcher_remove_view(nfc->view_dispatcher, NfcViewRead);
|
|
|
|
view_free(nfc->view_detect);
|
2020-10-19 01:09:48 +03:00
|
|
|
|
2021-05-06 22:51:20 +03: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-19 01:09:48 +03:00
|
|
|
}
|
|
|
|
|
2021-05-18 16:57:39 +03:00
|
|
|
void nfc_cli_detect(Cli* cli, string_t args, void* context) {
|
2021-05-06 22:51:20 +03:00
|
|
|
// Check if nfc worker is not busy
|
|
|
|
if(api_hal_nfc_is_busy()) {
|
2021-03-12 16:18:01 +03:00
|
|
|
printf("Nfc is busy");
|
|
|
|
return;
|
|
|
|
}
|
2021-05-06 22:51:20 +03:00
|
|
|
rfalNfcDevice* dev_list;
|
|
|
|
uint8_t dev_cnt = 0;
|
|
|
|
bool cmd_exit = false;
|
|
|
|
api_hal_nfc_init();
|
|
|
|
printf("Detecting nfc...\r\nPress Ctrl+C to abort\r\n");
|
|
|
|
while(!cmd_exit) {
|
|
|
|
cmd_exit |= cli_cmd_interrupt_received(cli);
|
|
|
|
cmd_exit |= api_hal_nfc_detect(&dev_list, &dev_cnt, 100);
|
|
|
|
if(dev_cnt > 0) {
|
|
|
|
printf("Found %d devices\r\n", dev_cnt);
|
|
|
|
for(uint8_t i = 0; i < dev_cnt; i++) {
|
|
|
|
printf("%d found: %s ", i, nfc_get_dev_type(dev_list[i].type));
|
|
|
|
if(dev_list[i].type == RFAL_NFC_LISTEN_TYPE_NFCA) {
|
|
|
|
printf("type: %s, ", nfc_get_nfca_type(dev_list[i].dev.nfca.type));
|
|
|
|
}
|
|
|
|
printf("UID length: %d, UID:", dev_list[i].nfcidLen);
|
|
|
|
for(uint8_t j = 0; j < dev_list[i].nfcidLen; j++) {
|
|
|
|
printf("%02X", dev_list[i].nfcid[j]);
|
|
|
|
}
|
|
|
|
printf("\r\n");
|
2021-03-12 16:18:01 +03:00
|
|
|
}
|
|
|
|
}
|
2021-05-06 22:51:20 +03:00
|
|
|
osDelay(50);
|
2021-03-12 16:18:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-06 22:51:20 +03:00
|
|
|
void nfc_cli_init() {
|
|
|
|
Cli* cli = furi_record_open("cli");
|
2021-05-18 16:57:39 +03:00
|
|
|
cli_add_command(cli, "nfc_detect", nfc_cli_detect, NULL);
|
2021-05-06 22:51:20 +03:00
|
|
|
furi_record_close("cli");
|
|
|
|
}
|
|
|
|
|
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 15:42:25 +03: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 12:06:29 +03: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 15:42:25 +03: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-19 01:09:48 +03:00
|
|
|
}
|
|
|
|
|
2021-02-12 20:24:34 +03:00
|
|
|
int32_t nfc_task(void* p) {
|
2020-10-19 01:55:41 +03:00
|
|
|
Nfc* nfc = nfc_alloc();
|
2020-10-19 01:09:48 +03:00
|
|
|
|
2020-10-19 01:55:41 +03:00
|
|
|
NfcMessage message;
|
2020-10-19 01:09:48 +03:00
|
|
|
while(1) {
|
2021-05-06 22:51:20 +03: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 15:42:25 +03:00
|
|
|
if(message.type == NfcMessageTypeDetect) {
|
|
|
|
with_view_model(
|
2021-02-10 12:06:29 +03: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 15:42:25 +03:00
|
|
|
nfc_start(nfc, NfcViewRead, NfcWorkerStatePoll);
|
|
|
|
} 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 22:51:20 +03: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 15:42:25 +03:00
|
|
|
} else if(message.type == NfcMessageTypeDeviceNotFound) {
|
2021-05-06 22:51:20 +03:00
|
|
|
with_view_model(
|
|
|
|
nfc->view_detect, (NfcViewReadModel * model) {
|
|
|
|
model->found = false;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
} else if(message.type == NfcMessageTypeExit) {
|
|
|
|
nfc_free(nfc);
|
|
|
|
break;
|
2020-10-19 01:09:48 +03:00
|
|
|
}
|
|
|
|
}
|
2021-02-12 20:24:34 +03:00
|
|
|
|
|
|
|
return 0;
|
2020-10-19 01:09:48 +03:00
|
|
|
}
|