Selaa lähdekoodia

Notes, improved info scene

Initial NFC testing results and leftover kruft
Improved info scene for saved cards
Beginnings of manual-input code
Zachary Weiss 3 vuotta sitten
vanhempi
commit
5d6168e14f

+ 1 - 1
README.md

@@ -21,5 +21,5 @@ Other misc things to investigate / build:
 
 
 
 
 HF coil notes:
 HF coil notes:
-NFC reader field can be turned on / off with `furi_hal_nfc_field_on();` and `furi_hal_nfc_field_off();` respectively, as seen in nfc_scene_field.c (used for debug purposes). Initial tests with `furi_hal_nfc_field_on();` are promising signal-wise, but the delay introduced by the wake/sleep initialization renders it impossible to toggle rapidly. At a lower level, that consists of `furi_hal_nfc_exit_sleep();` and `st25r3916TxRxOn();` to turn on, and `st25r3916TxRxOff();` and `furi_hal_nfc_start_sleep();` to turn off. May be worth trying directly (wake from sleep at setup, toggle on and off corresponding with bit direction, send to sleep on exit). Initial tests have been difficult to get work as some of the st25r3916 symbols are unresolved; need to figure out how to import/call it properly, or how to get another layer lower of control. 
+~~NFC reader field can be turned on / off with `furi_hal_nfc_field_on();` and `furi_hal_nfc_field_off();` respectively, as seen in nfc_scene_field.c (used for debug purposes). Initial tests with `furi_hal_nfc_field_on();` are promising signal-wise, but the delay introduced by the wake/sleep initialization renders it impossible to toggle rapidly. At a lower level, that consists of `furi_hal_nfc_exit_sleep();` and `st25r3916TxRxOn();` to turn on, and `st25r3916TxRxOff();` and `furi_hal_nfc_start_sleep();` to turn off. May be worth trying directly (wake from sleep at setup, toggle on and off corresponding with bit direction, send to sleep on exit). Initial tests have been difficult to get work as some of the st25r3916 symbols are unresolved; need to figure out how to import/call it properly, or how to get another layer lower of control.~~ Testing with furi_hal_nfc_ll_rxtx_on(); and furi_hal_nfc_ll_rxtx_off(); does indeed create a nice strong signal on my 'scope (thanks @dlz#7721 for finding the wrapped functions), but no response from a mag reader; makes sense, was a long shot -- next step NFC testing would be lower-level control that lets us pull the coil high/low, rather than just producing the standard 13.56MHz signal and OOK modulating it.
 
 

+ 0 - 1
mag_device.c

@@ -95,7 +95,6 @@ static bool mag_device_save_file(
     furi_string_free(temp_str);
     furi_string_free(temp_str);
     flipper_format_free(file);
     flipper_format_free(file);
 
 
-    // TODO. Extrapolating from the picopass app
     return saved;
     return saved;
 }
 }
 
 

+ 2 - 2
scenes/mag_scene_config.h

@@ -3,8 +3,8 @@ ADD_SCENE(mag, emulate_test, EmulateTest)
 ADD_SCENE(mag, file_select, FileSelect)
 ADD_SCENE(mag, file_select, FileSelect)
 ADD_SCENE(mag, saved_menu, SavedMenu)
 ADD_SCENE(mag, saved_menu, SavedMenu)
 ADD_SCENE(mag, saved_info, SavedInfo)
 ADD_SCENE(mag, saved_info, SavedInfo)
-ADD_SCENE(mag, save_data, SaveData)
-ADD_SCENE(mag, save_name, SaveName)
+ADD_SCENE(mag, input_name, InputName)
+ADD_SCENE(mag, input_value, InputValue)
 ADD_SCENE(mag, save_success, SaveSuccess)
 ADD_SCENE(mag, save_success, SaveSuccess)
 ADD_SCENE(mag, delete_success, DeleteSuccess)
 ADD_SCENE(mag, delete_success, DeleteSuccess)
 ADD_SCENE(mag, delete_confirm, DeleteConfirm)
 ADD_SCENE(mag, delete_confirm, DeleteConfirm)

+ 3 - 2
scenes/mag_scene_delete_confirm.c

@@ -1,6 +1,5 @@
 #include "../mag_i.h"
 #include "../mag_i.h"
 #include "../mag_device.h"
 #include "../mag_device.h"
-#include <toolbox/path.h>
 
 
 void mag_scene_delete_confirm_on_enter(void* context) {
 void mag_scene_delete_confirm_on_enter(void* context) {
     Mag* mag = context;
     Mag* mag = context;
@@ -12,6 +11,8 @@ void mag_scene_delete_confirm_on_enter(void* context) {
 
 
     furi_string_printf(tmp_str, "\e#Delete %s?\e#", mag_dev->dev_name);
     furi_string_printf(tmp_str, "\e#Delete %s?\e#", mag_dev->dev_name);
 
 
+    //TODO: print concise summary of data on card? Would need to vary by card/track type
+
     widget_add_text_box_element(
     widget_add_text_box_element(
         widget, 0, 0, 128, 27, AlignCenter, AlignCenter, furi_string_get_cstr(tmp_str), true);
         widget, 0, 0, 128, 27, AlignCenter, AlignCenter, furi_string_get_cstr(tmp_str), true);
     widget_add_button_element(widget, GuiButtonTypeLeft, "Cancel", mag_widget_callback, mag);
     widget_add_button_element(widget, GuiButtonTypeLeft, "Cancel", mag_widget_callback, mag);
@@ -45,4 +46,4 @@ bool mag_scene_delete_confirm_on_event(void* context, SceneManagerEvent event) {
 void mag_scene_delete_confirm_on_exit(void* context) {
 void mag_scene_delete_confirm_on_exit(void* context) {
     Mag* mag = context;
     Mag* mag = context;
     widget_reset(mag->widget);
     widget_reset(mag->widget);
-}
+}

+ 6 - 9
scenes/mag_scene_emulate_test.c

@@ -3,7 +3,7 @@
 #define PIN_A 0
 #define PIN_A 0
 #define PIN_B 1 // currently unused
 #define PIN_B 1 // currently unused
 #define CLOCK_US 240 // typically set between 200-500us
 #define CLOCK_US 240 // typically set between 200-500us
-#define TEST_STR "%%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?;1234567812?"
+#define TEST_STR "%%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?"
 #define TEST_TRACK 0
 #define TEST_TRACK 0
 // TODO: better way of setting temp test str,
 // TODO: better way of setting temp test str,
 //       text wrapping on screen? (Will be relevant for any loaded data too)
 //       text wrapping on screen? (Will be relevant for any loaded data too)
@@ -28,17 +28,15 @@ static void play_bit(uint8_t send_bit) {
     gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
     gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
     furi_delay_us(CLOCK_US);
     furi_delay_us(CLOCK_US);
 
 
-    // NFC tests
-    //(magspoof_bit_dir) ? st25r3916TxRxOn() : st25r3916TxRxOff();
-    //(magspoof_bit_dir) ? furi_hal_nfc_field_on() : furi_hal_nfc_field_off();
+    // NFC TEST
+    //(magspoof_bit_dir) ? furi_hal_nfc_ll_txrx_on() : furi_hal_nfc_ll_txrx_off();
 
 
     if(send_bit) {
     if(send_bit) {
         magspoof_bit_dir ^= 1;
         magspoof_bit_dir ^= 1;
         gpio_item_set_rfid_pin(PIN_A, magspoof_bit_dir);
         gpio_item_set_rfid_pin(PIN_A, magspoof_bit_dir);
         gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
         gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
 
 
-        //(magspoof_bit_dir) ? st25r3916TxRxOn() : st25r3916TxRxOff();
-        //(magspoof_bit_dir) ? furi_hal_nfc_field_on() : furi_hal_nfc_field_off();
+        //(magspoof_bit_dir) ? furi_hal_nfc_ll_txrx_on() : furi_hal_nfc_ll_txrx_off();
     }
     }
     furi_delay_us(CLOCK_US);
     furi_delay_us(CLOCK_US);
 }
 }
@@ -140,8 +138,7 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
     gpio_item_set_rfid_pin(PIN_A, 0);
     gpio_item_set_rfid_pin(PIN_A, 0);
     gpio_item_set_rfid_pin(PIN_B, 0);
     gpio_item_set_rfid_pin(PIN_B, 0);
     // NFC TEST
     // NFC TEST
-    //st25r3916TxRxOff();
-    //furi_hal_nfc_field_off();
+    //furi_hal_nfc_ll_txrx_off();
 
 
     // end critical timing section
     // end critical timing section
     FURI_CRITICAL_EXIT();
     FURI_CRITICAL_EXIT();
@@ -204,4 +201,4 @@ bool mag_scene_emulate_test_on_event(void* context, SceneManagerEvent event) {
 void mag_scene_emulate_test_on_exit(void* context) {
 void mag_scene_emulate_test_on_exit(void* context) {
     Mag* mag = context;
     Mag* mag = context;
     widget_reset(mag->widget);
     widget_reset(mag->widget);
-}
+}

+ 1 - 1
scenes/mag_scene_exit_confirm.c

@@ -17,4 +17,4 @@ bool mag_scene_exit_confirm_on_event(void* context, SceneManagerEvent event) {
 void mag_scene_exit_confirm_on_exit(void* context) {
 void mag_scene_exit_confirm_on_exit(void* context) {
     Mag* mag = context;
     Mag* mag = context;
     UNUSED(mag);
     UNUSED(mag);
-}
+}

+ 10 - 7
scenes/mag_scene_save_name.c → scenes/mag_scene_input_name.c

@@ -1,20 +1,23 @@
 #include <lib/toolbox/random_name.h>
 #include <lib/toolbox/random_name.h>
 #include "../mag_i.h"
 #include "../mag_i.h"
 
 
-void mag_scene_save_name_on_enter(void* context) {
+void mag_scene_input_name_on_enter(void* context) {
     Mag* mag = context;
     Mag* mag = context;
     TextInput* text_input = mag->text_input;
     TextInput* text_input = mag->text_input;
     FuriString* folder_path;
     FuriString* folder_path;
     folder_path = furi_string_alloc();
     folder_path = furi_string_alloc();
 
 
-    bool key_name_is_empty = furi_string_empty(mag->file_name);
+    //TODO: compatible types / etc
+    //bool name_is_empty = furi_string_empty(mag->mag_dev->dev_name);
+    bool name_is_empty = false;
 
 
-    if(key_name_is_empty) {
+    if(name_is_empty) {
         furi_string_set(mag->file_path, MAG_APP_FOLDER);
         furi_string_set(mag->file_path, MAG_APP_FOLDER);
         set_random_name(mag->text_store, MAG_TEXT_STORE_SIZE);
         set_random_name(mag->text_store, MAG_TEXT_STORE_SIZE);
         furi_string_set(folder_path, MAG_APP_FOLDER);
         furi_string_set(folder_path, MAG_APP_FOLDER);
     } else {
     } else {
-        mag_text_store_set(mag, "%s", furi_string_get_cstr(mag->file_name));
+        // TODO: compatible types etc
+        //mag_text_store_set(mag, "%s", furi_string_get_cstr(mag->mag_dev->dev_name));
         path_extract_dirname(furi_string_get_cstr(mag->file_path), folder_path);
         path_extract_dirname(furi_string_get_cstr(mag->file_path), folder_path);
     }
     }
 
 
@@ -25,7 +28,7 @@ void mag_scene_save_name_on_enter(void* context) {
         mag,
         mag,
         mag->text_store,
         mag->text_store,
         MAG_DEV_NAME_MAX_LEN,
         MAG_DEV_NAME_MAX_LEN,
-        key_name_is_empty);
+        name_is_empty);
 
 
     FURI_LOG_I("", "%s %s", furi_string_get_cstr(folder_path), mag->text_store);
     FURI_LOG_I("", "%s %s", furi_string_get_cstr(folder_path), mag->text_store);
 
 
@@ -40,7 +43,7 @@ void mag_scene_save_name_on_enter(void* context) {
     view_dispatcher_switch_to_view(mag->view_dispatcher, MagViewTextInput);
     view_dispatcher_switch_to_view(mag->view_dispatcher, MagViewTextInput);
 }
 }
 
 
-bool mag_scene_save_name_on_event(void* context, SceneManagerEvent event) {
+bool mag_scene_input_name_on_event(void* context, SceneManagerEvent event) {
     Mag* mag = context;
     Mag* mag = context;
     SceneManager* scene_manager = mag->scene_manager;
     SceneManager* scene_manager = mag->scene_manager;
     bool consumed = false;
     bool consumed = false;
@@ -76,7 +79,7 @@ bool mag_scene_save_name_on_event(void* context, SceneManagerEvent event) {
     return consumed;
     return consumed;
 }
 }
 
 
-void mag_scene_save_name_on_exit(void* context) {
+void mag_scene_input_name_on_exit(void* context) {
     Mag* mag = context;
     Mag* mag = context;
     TextInput* text_input = mag->text_input;
     TextInput* text_input = mag->text_input;
 
 

+ 28 - 0
scenes/mag_scene_input_value.c

@@ -0,0 +1,28 @@
+#include "../mag_i.h"
+
+void mag_scene_input_value_on_enter(void* context) {
+    Mag* mag = context;
+    TextInput* text_input = mag->text_input;
+
+    FuriString* tmp_str;
+    tmp_str = furi_string_alloc();
+    UNUSED(tmp_str);
+
+    text_input_set_header_text(text_input, "Enter track data (WIP)");
+    //text_input_set_result_callback(
+    //    text_input, mag_text_input_callback, mag, mag->mag_dev->dev_data, )
+}
+
+bool mag_scene_input_value_on_event(void* context, SceneManagerEvent event) {
+    Mag* mag = context;
+    UNUSED(mag);
+    UNUSED(event);
+    bool consumed = false;
+
+    return consumed;
+}
+
+void mag_scene_input_value_on_exit(void* context) {
+    Mag* mag = context;
+    UNUSED(mag);
+}

+ 0 - 20
scenes/mag_scene_save_data.c

@@ -1,20 +0,0 @@
-#include "../mag_i.h"
-
-void mag_scene_save_data_on_enter(void* context) {
-    Mag* mag = context;
-    UNUSED(mag);
-}
-
-bool mag_scene_save_data_on_event(void* context, SceneManagerEvent event) {
-    Mag* mag = context;
-    UNUSED(mag);
-    UNUSED(event);
-    bool consumed = false;
-
-    return consumed;
-}
-
-void mag_scene_save_data_on_exit(void* context) {
-    Mag* mag = context;
-    UNUSED(mag);
-}

+ 10 - 3
scenes/mag_scene_saved_info.c

@@ -1,4 +1,5 @@
 #include "../mag_i.h"
 #include "../mag_i.h"
+#include "mag_icons.h"
 
 
 void mag_scene_saved_info_on_enter(void* context) {
 void mag_scene_saved_info_on_enter(void* context) {
     Mag* mag = context;
     Mag* mag = context;
@@ -7,11 +8,17 @@ void mag_scene_saved_info_on_enter(void* context) {
     FuriString* tmp_str;
     FuriString* tmp_str;
     tmp_str = furi_string_alloc();
     tmp_str = furi_string_alloc();
 
 
+    // Use strlcpy instead perhaps, to truncate to screen width, then add ellipses if needed?
     furi_string_printf(tmp_str, "%s\r\n", mag->mag_dev->dev_name);
     furi_string_printf(tmp_str, "%s\r\n", mag->mag_dev->dev_name);
-    furi_string_cat_printf(tmp_str, furi_string_get_cstr(mag->mag_dev->dev_data));
 
 
+    widget_add_icon_element(widget, 1, 1, &I_mag_10px);
+    widget_add_string_element(
+        widget, 13, 2, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(tmp_str));
+    furi_string_reset(tmp_str);
+
+    furi_string_printf(tmp_str, furi_string_get_cstr(mag->mag_dev->dev_data));
     widget_add_string_multiline_element(
     widget_add_string_multiline_element(
-        widget, 0, 1, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_str));
+        widget, 0, 15, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_str));
 
 
     widget_add_button_element(widget, GuiButtonTypeLeft, "Back", mag_widget_callback, mag);
     widget_add_button_element(widget, GuiButtonTypeLeft, "Back", mag_widget_callback, mag);
 
 
@@ -38,4 +45,4 @@ bool mag_scene_saved_info_on_event(void* context, SceneManagerEvent event) {
 void mag_scene_saved_info_on_exit(void* context) {
 void mag_scene_saved_info_on_exit(void* context) {
     Mag* mag = context;
     Mag* mag = context;
     widget_reset(mag->widget);
     widget_reset(mag->widget);
-}
+}

+ 1 - 1
scenes/mag_scene_saved_menu.c

@@ -62,4 +62,4 @@ void mag_scene_saved_menu_on_exit(void* context) {
     Mag* mag = context;
     Mag* mag = context;
 
 
     submenu_reset(mag->submenu);
     submenu_reset(mag->submenu);
-}
+}