Kaynağa Gözat

Blink the LED while emulating cards

Vladimir Kondenko 2 yıl önce
ebeveyn
işleme
7fd38a6be6
3 değiştirilmiş dosya ile 19 ekleme ve 0 silme
  1. 7 0
      mifare_fuzzer.c
  2. 2 0
      mifare_fuzzer_i.h
  3. 10 0
      scenes/mifare_fuzzer_scene_emulator.c

+ 7 - 0
mifare_fuzzer.c

@@ -49,6 +49,9 @@ MifareFuzzerApp* mifare_fuzzer_alloc() {
     app->gui = furi_record_open(RECORD_GUI);
     view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
 
+    // Open Notifications record
+    app->notifications = furi_record_open(RECORD_NOTIFICATION);
+
     // view: select card type
     app->submenu_card = submenu_alloc();
     view_dispatcher_add_view(
@@ -116,6 +119,10 @@ void mifare_fuzzer_free(MifareFuzzerApp* app) {
     furi_record_close(RECORD_GUI);
     app->gui = NULL;
 
+    // Notifications
+    furi_record_close(RECORD_NOTIFICATION);
+    app->notifications = NULL;
+
     // Worker
     //FURI_LOG_D(TAG, "mifare_fuzzer_free() :: Worker");
     mifare_fuzzer_worker_free(app->worker);

+ 2 - 0
mifare_fuzzer_i.h

@@ -10,6 +10,7 @@
 #include <gui/gui.h>
 #include <gui/view_dispatcher.h>
 #include <gui/scene_manager.h>
+#include <notification/notification_messages.h>
 
 #include <gui/modules/submenu.h>
 
@@ -54,6 +55,7 @@ typedef enum {
 
 struct MifareFuzzerApp {
     Gui* gui;
+    NotificationApp* notifications;
 
     ViewDispatcher* view_dispatcher;
 

+ 10 - 0
scenes/mifare_fuzzer_scene_emulator.c

@@ -1,4 +1,6 @@
 #include "../mifare_fuzzer_i.h"
+#include <notification/notification.h>
+#include <notification/notification_messages.h>
 
 uint8_t tick_counter = 0;
 uint8_t attack_step = 0;
@@ -77,10 +79,12 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
         if(event.event == MifareFuzzerEventStartAttack) {
             NfcDevice* nfc_device = NULL;
             const MfClassicData* mf_classic_data = NULL;
+            bool nfc_device_parsed = false;
             if(app->card_file_path) {
                 nfc_device = app->worker->nfc_device;
                 const char* path = furi_string_get_cstr(app->card_file_path);
                 if(nfc_device_load(nfc_device, path)) {
+                    nfc_device_parsed = true;
                     mf_classic_data = nfc_device_get_data(nfc_device, NfcProtocolMfClassic);
                     if(mf_classic_data->type == MfClassicType1k) {
                         app->card = MifareCardClassic1k;
@@ -203,10 +207,15 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
 
             // Start worker
             mifare_fuzzer_worker_start(app->worker);
+
+            if(nfc_device_parsed) {
+                notification_message(app->notifications, &sequence_blink_start_magenta);
+            }
         } else if(event.event == MifareFuzzerEventStopAttack) {
             //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStopAttack");
             // Stop worker
             mifare_fuzzer_worker_stop(app->worker);
+            notification_message(app->notifications, &sequence_blink_stop);
         } else if(event.event == MifareFuzzerEventIncrementTicks) {
             if(!emulator->is_attacking) {
                 if(emulator->ticks_between_cards < MIFARE_FUZZER_MAX_TICKS_BETWEEN_CARDS) {
@@ -257,6 +266,7 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
 void mifare_fuzzer_scene_emulator_on_exit(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_exit()");
     MifareFuzzerApp* app = context;
+    notification_message(app->notifications, &sequence_blink_stop);
     mifare_fuzzer_worker_stop(app->worker);
 
     if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {