MX 2 лет назад
Родитель
Сommit
43792d8a7d
4 измененных файлов с 22 добавлено и 13 удалено
  1. 10 1
      README.md
  2. 1 0
      mag_i.h
  3. 10 10
      scenes/mag_scene_read.c
  4. 1 2
      scenes/mag_scene_read.h

+ 10 - 1
README.md

@@ -1,8 +1,17 @@
-# magspoof_flipper
+# magspoof_flipper by Zachary Weiss
 WIP of MagSpoof for the Flipper Zero. Basic TX of saved files confirmed working against an MSR90 with an external H-bridge module mirroring Samy Kamkar's design. RFID coil output weaker; able to be picked up/detected by more compact mag readers such as Square, but yet to have success with it being decoded/parsed properly. Additional investigation into alternate internal TX options (CC1101, ST25R3916, piezo) underway; tentatively, RFID coil + speaker (`LF + P` config setting) results in the strongest internal TX tested to date but still weaker than a dedicated external module or an actual card swipe (and sounds like a dial-up modem from hell). Sample files with test data are included in `assets` for anyone wishing to experiment.
 
 Disclaimer: use responsibly, and at your own risk. While in my testing, I've seen no reason to believe this could damage the RFID (or other) hardware, this is inherently driving the coil in ways it was not designed or intended for; I take no responsibility for fried/bricked Flippers. Similarly, please only use this with magstripe cards and mag readers you own — this is solely meant as a proof of concept for educational purposes. I neither condone nor am sympathetic to malicious uses of my code.
 
+## Hummus's Fork
+I made this fork initially to add reading capability using UART magnetic card readers.
+
+Things that changed in this fork:
+- Added a basic card reading ability
+- Added a function to parse a new MagDevice from a Card String (%Track1?;Track2;Track3?;)
+- Swapped the pins between A6 to A7 on the card that I'm using, might add this to configuration scene later on
+- Adapted some of the APIs to the most recent firmware changes.
+
 ## Optional GPIO TX Module
 For those desiring better TX than the internal RFID coil can offer, one can build the module below, consisting of an H-bridge, a capacitor, and a coil.
 

+ 1 - 0
mag_i.h

@@ -84,6 +84,7 @@ typedef struct {
     FuriStreamBuffer* uart_rx_stream;
     uint8_t uart_rx_buf[UART_RX_BUF_SIZE + 1];
     void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
+    FuriHalSerialHandle* serial_handle;
     
     char uart_text_input_store[UART_TERMINAL_TEXT_INPUT_STORE_SIZE + 1];
     FuriString* uart_text_box_store;

+ 10 - 10
scenes/mag_scene_read.c

@@ -7,9 +7,10 @@
 
 #define TAG "MagSceneRead"
 
-void uart_callback(UartIrqEvent event, uint8_t data, void* context) {
+void uart_callback(FuriHalSerialHandle* handle, FuriHalSerialRxEvent event, void* context) {
     Mag* mag = context;
-    if(event == UartIrqEventRXNE) {
+    if(event == FuriHalSerialRxEventData) {
+        uint8_t data = furi_hal_serial_async_rx(handle);
         furi_stream_buffer_send(mag->uart_rx_stream, &data, 1, 0);
         furi_thread_flags_set(furi_thread_get_id(mag->uart_rx_thread), WorkerEvtRxDone);
     }
@@ -93,10 +94,10 @@ void mag_scene_read_on_enter(void* context) {
     update_widgets(mag);
 
     // Initialize UART
-    // furi_hal_console_disable();
-    furi_hal_uart_deinit(FuriHalUartIdUSART1);
-    furi_hal_uart_init(FuriHalUartIdUSART1, 9600);
-    furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, uart_callback, mag);
+    mag->serial_handle = furi_hal_serial_control_acquire(FuriHalSerialIdUsart);
+    furi_check(mag->serial_handle);
+    furi_hal_serial_init(mag->serial_handle, 9600);
+    furi_hal_serial_async_rx_start(mag->serial_handle, uart_callback, mag, false);
     FURI_LOG_D(TAG, "UART initialized");
 
     mag->uart_rx_thread = furi_thread_alloc();
@@ -177,9 +178,8 @@ void mag_scene_read_on_exit(void* context) {
 
     furi_string_free(mag->uart_text_box_store);
 
-    furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, NULL, NULL);
-    furi_hal_uart_deinit(FuriHalUartIdUSART1);
-    // furi_hal_console_enable();
+    furi_hal_serial_deinit(mag->serial_handle);
+    furi_hal_serial_control_release(mag->serial_handle);
 
     notification_message(mag->notifications, &sequence_blink_stop);
-}
+}

+ 1 - 2
scenes/mag_scene_read.h

@@ -5,7 +5,7 @@
 #define UART_RX_BUF_SIZE (320)
 #define UART_TERMINAL_TEXT_BOX_STORE_SIZE (4096)
 #define UART_TERMINAL_TEXT_INPUT_STORE_SIZE (512)
-#define UART_CH (FuriHalUartIdUSART1)
+#define UART_CH (FuriHalSerialIdUsart)
 #define UART_BAUDRATE (9600)
 
 typedef enum {
@@ -17,5 +17,4 @@ typedef enum {
     UARTEventRxData = 100,
 } UARTEvents;
 
-
 #define WORKER_ALL_RX_EVENTS (WorkerEvtStop | WorkerEvtRxDone)