-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from bettse/mfc
MFC SE
- Loading branch information
Showing
9 changed files
with
312 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "../seader_i.h" | ||
#include <dolphin/dolphin.h> | ||
|
||
#define TAG "SceneReadNfc" | ||
|
||
void seader_scene_read_mfc_on_enter(void* context) { | ||
Seader* seader = context; | ||
dolphin_deed(DolphinDeedNfcRead); | ||
|
||
// Setup view | ||
Popup* popup = seader->popup; | ||
popup_set_header(popup, "Detecting\nMFC\ncard", 68, 30, AlignLeft, AlignTop); | ||
popup_set_icon(popup, 0, 3, &I_RFIDDolphinReceive_97x61); | ||
|
||
// Start worker | ||
view_dispatcher_switch_to_view(seader->view_dispatcher, SeaderViewPopup); | ||
|
||
seader->poller = nfc_poller_alloc(seader->nfc, NfcProtocolMfClassic); | ||
|
||
seader->worker->stage = SeaderPollerEventTypeCardDetect; | ||
seader_credential_clear(seader->credential); | ||
seader->credential->type = SeaderCredentialTypeMifareClassic; | ||
|
||
FURI_LOG_W(TAG, "Start poller"); | ||
nfc_poller_start(seader->poller, seader_worker_poller_callback_mfc, seader); | ||
|
||
seader_blink_start(seader); | ||
} | ||
|
||
bool seader_scene_read_mfc_on_event(void* context, SceneManagerEvent event) { | ||
Seader* seader = context; | ||
bool consumed = false; | ||
|
||
if(event.type == SceneManagerEventTypeCustom) { | ||
if(event.event == SeaderCustomEventWorkerExit) { | ||
seader->credential->type = SeaderCredentialTypeMifareClassic; | ||
scene_manager_next_scene(seader->scene_manager, SeaderSceneReadCardSuccess); | ||
consumed = true; | ||
} else if(event.event == SeaderCustomEventPollerSuccess) { | ||
seader->credential->type = SeaderCredentialTypeMifareClassic; | ||
scene_manager_next_scene(seader->scene_manager, SeaderSceneReadCardSuccess); | ||
consumed = true; | ||
} | ||
} else if(event.type == SceneManagerEventTypeBack) { | ||
scene_manager_search_and_switch_to_previous_scene( | ||
seader->scene_manager, SeaderSceneSamPresent); | ||
consumed = true; | ||
} | ||
|
||
return consumed; | ||
} | ||
|
||
void seader_scene_read_mfc_on_exit(void* context) { | ||
Seader* seader = context; | ||
|
||
if(seader->poller) { | ||
nfc_poller_stop(seader->poller); | ||
nfc_poller_free(seader->poller); | ||
} | ||
|
||
// Clear view | ||
popup_reset(seader->popup); | ||
|
||
seader_blink_stop(seader); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.