Skip to content

Commit 5d6168e

Browse files
committed
Notes, improved info scene
Initial NFC testing results and leftover kruft Improved info scene for saved cards Beginnings of manual-input code
1 parent 3e646d9 commit 5d6168e

11 files changed

+62
-47
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ Other misc things to investigate / build:
2121

2222

2323
HF coil notes:
24-
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.
24+
~~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.
2525

mag_device.c

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ static bool mag_device_save_file(
9595
furi_string_free(temp_str);
9696
flipper_format_free(file);
9797

98-
// TODO. Extrapolating from the picopass app
9998
return saved;
10099
}
101100

scenes/mag_scene_config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ ADD_SCENE(mag, emulate_test, EmulateTest)
33
ADD_SCENE(mag, file_select, FileSelect)
44
ADD_SCENE(mag, saved_menu, SavedMenu)
55
ADD_SCENE(mag, saved_info, SavedInfo)
6-
ADD_SCENE(mag, save_data, SaveData)
7-
ADD_SCENE(mag, save_name, SaveName)
6+
ADD_SCENE(mag, input_name, InputName)
7+
ADD_SCENE(mag, input_value, InputValue)
88
ADD_SCENE(mag, save_success, SaveSuccess)
99
ADD_SCENE(mag, delete_success, DeleteSuccess)
1010
ADD_SCENE(mag, delete_confirm, DeleteConfirm)

scenes/mag_scene_delete_confirm.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "../mag_i.h"
22
#include "../mag_device.h"
3-
#include <toolbox/path.h>
43

54
void mag_scene_delete_confirm_on_enter(void* context) {
65
Mag* mag = context;
@@ -12,6 +11,8 @@ void mag_scene_delete_confirm_on_enter(void* context) {
1211

1312
furi_string_printf(tmp_str, "\e#Delete %s?\e#", mag_dev->dev_name);
1413

14+
//TODO: print concise summary of data on card? Would need to vary by card/track type
15+
1516
widget_add_text_box_element(
1617
widget, 0, 0, 128, 27, AlignCenter, AlignCenter, furi_string_get_cstr(tmp_str), true);
1718
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) {
4546
void mag_scene_delete_confirm_on_exit(void* context) {
4647
Mag* mag = context;
4748
widget_reset(mag->widget);
48-
}
49+
}

scenes/mag_scene_emulate_test.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define PIN_A 0
44
#define PIN_B 1 // currently unused
55
#define CLOCK_US 240 // typically set between 200-500us
6-
#define TEST_STR "%%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?;1234567812?"
6+
#define TEST_STR "%%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?"
77
#define TEST_TRACK 0
88
// TODO: better way of setting temp test str,
99
// text wrapping on screen? (Will be relevant for any loaded data too)
@@ -28,17 +28,15 @@ static void play_bit(uint8_t send_bit) {
2828
gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
2929
furi_delay_us(CLOCK_US);
3030

31-
// NFC tests
32-
//(magspoof_bit_dir) ? st25r3916TxRxOn() : st25r3916TxRxOff();
33-
//(magspoof_bit_dir) ? furi_hal_nfc_field_on() : furi_hal_nfc_field_off();
31+
// NFC TEST
32+
//(magspoof_bit_dir) ? furi_hal_nfc_ll_txrx_on() : furi_hal_nfc_ll_txrx_off();
3433

3534
if(send_bit) {
3635
magspoof_bit_dir ^= 1;
3736
gpio_item_set_rfid_pin(PIN_A, magspoof_bit_dir);
3837
gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
3938

40-
//(magspoof_bit_dir) ? st25r3916TxRxOn() : st25r3916TxRxOff();
41-
//(magspoof_bit_dir) ? furi_hal_nfc_field_on() : furi_hal_nfc_field_off();
39+
//(magspoof_bit_dir) ? furi_hal_nfc_ll_txrx_on() : furi_hal_nfc_ll_txrx_off();
4240
}
4341
furi_delay_us(CLOCK_US);
4442
}
@@ -140,8 +138,7 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
140138
gpio_item_set_rfid_pin(PIN_A, 0);
141139
gpio_item_set_rfid_pin(PIN_B, 0);
142140
// NFC TEST
143-
//st25r3916TxRxOff();
144-
//furi_hal_nfc_field_off();
141+
//furi_hal_nfc_ll_txrx_off();
145142

146143
// end critical timing section
147144
FURI_CRITICAL_EXIT();
@@ -204,4 +201,4 @@ bool mag_scene_emulate_test_on_event(void* context, SceneManagerEvent event) {
204201
void mag_scene_emulate_test_on_exit(void* context) {
205202
Mag* mag = context;
206203
widget_reset(mag->widget);
207-
}
204+
}

scenes/mag_scene_exit_confirm.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ bool mag_scene_exit_confirm_on_event(void* context, SceneManagerEvent event) {
1717
void mag_scene_exit_confirm_on_exit(void* context) {
1818
Mag* mag = context;
1919
UNUSED(mag);
20-
}
20+
}

scenes/mag_scene_save_name.c scenes/mag_scene_input_name.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
#include <lib/toolbox/random_name.h>
22
#include "../mag_i.h"
33

4-
void mag_scene_save_name_on_enter(void* context) {
4+
void mag_scene_input_name_on_enter(void* context) {
55
Mag* mag = context;
66
TextInput* text_input = mag->text_input;
77
FuriString* folder_path;
88
folder_path = furi_string_alloc();
99

10-
bool key_name_is_empty = furi_string_empty(mag->file_name);
10+
//TODO: compatible types / etc
11+
//bool name_is_empty = furi_string_empty(mag->mag_dev->dev_name);
12+
bool name_is_empty = false;
1113

12-
if(key_name_is_empty) {
14+
if(name_is_empty) {
1315
furi_string_set(mag->file_path, MAG_APP_FOLDER);
1416
set_random_name(mag->text_store, MAG_TEXT_STORE_SIZE);
1517
furi_string_set(folder_path, MAG_APP_FOLDER);
1618
} else {
17-
mag_text_store_set(mag, "%s", furi_string_get_cstr(mag->file_name));
19+
// TODO: compatible types etc
20+
//mag_text_store_set(mag, "%s", furi_string_get_cstr(mag->mag_dev->dev_name));
1821
path_extract_dirname(furi_string_get_cstr(mag->file_path), folder_path);
1922
}
2023

@@ -25,7 +28,7 @@ void mag_scene_save_name_on_enter(void* context) {
2528
mag,
2629
mag->text_store,
2730
MAG_DEV_NAME_MAX_LEN,
28-
key_name_is_empty);
31+
name_is_empty);
2932

3033
FURI_LOG_I("", "%s %s", furi_string_get_cstr(folder_path), mag->text_store);
3134

@@ -40,7 +43,7 @@ void mag_scene_save_name_on_enter(void* context) {
4043
view_dispatcher_switch_to_view(mag->view_dispatcher, MagViewTextInput);
4144
}
4245

43-
bool mag_scene_save_name_on_event(void* context, SceneManagerEvent event) {
46+
bool mag_scene_input_name_on_event(void* context, SceneManagerEvent event) {
4447
Mag* mag = context;
4548
SceneManager* scene_manager = mag->scene_manager;
4649
bool consumed = false;
@@ -76,7 +79,7 @@ bool mag_scene_save_name_on_event(void* context, SceneManagerEvent event) {
7679
return consumed;
7780
}
7881

79-
void mag_scene_save_name_on_exit(void* context) {
82+
void mag_scene_input_name_on_exit(void* context) {
8083
Mag* mag = context;
8184
TextInput* text_input = mag->text_input;
8285

scenes/mag_scene_input_value.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "../mag_i.h"
2+
3+
void mag_scene_input_value_on_enter(void* context) {
4+
Mag* mag = context;
5+
TextInput* text_input = mag->text_input;
6+
7+
FuriString* tmp_str;
8+
tmp_str = furi_string_alloc();
9+
UNUSED(tmp_str);
10+
11+
text_input_set_header_text(text_input, "Enter track data (WIP)");
12+
//text_input_set_result_callback(
13+
// text_input, mag_text_input_callback, mag, mag->mag_dev->dev_data, )
14+
}
15+
16+
bool mag_scene_input_value_on_event(void* context, SceneManagerEvent event) {
17+
Mag* mag = context;
18+
UNUSED(mag);
19+
UNUSED(event);
20+
bool consumed = false;
21+
22+
return consumed;
23+
}
24+
25+
void mag_scene_input_value_on_exit(void* context) {
26+
Mag* mag = context;
27+
UNUSED(mag);
28+
}

scenes/mag_scene_save_data.c

-20
This file was deleted.

scenes/mag_scene_saved_info.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../mag_i.h"
2+
#include "mag_icons.h"
23

34
void mag_scene_saved_info_on_enter(void* context) {
45
Mag* mag = context;
@@ -7,11 +8,17 @@ void mag_scene_saved_info_on_enter(void* context) {
78
FuriString* tmp_str;
89
tmp_str = furi_string_alloc();
910

11+
// Use strlcpy instead perhaps, to truncate to screen width, then add ellipses if needed?
1012
furi_string_printf(tmp_str, "%s\r\n", mag->mag_dev->dev_name);
11-
furi_string_cat_printf(tmp_str, furi_string_get_cstr(mag->mag_dev->dev_data));
1213

14+
widget_add_icon_element(widget, 1, 1, &I_mag_10px);
15+
widget_add_string_element(
16+
widget, 13, 2, AlignLeft, AlignTop, FontPrimary, furi_string_get_cstr(tmp_str));
17+
furi_string_reset(tmp_str);
18+
19+
furi_string_printf(tmp_str, furi_string_get_cstr(mag->mag_dev->dev_data));
1320
widget_add_string_multiline_element(
14-
widget, 0, 1, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_str));
21+
widget, 0, 15, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(tmp_str));
1522

1623
widget_add_button_element(widget, GuiButtonTypeLeft, "Back", mag_widget_callback, mag);
1724

@@ -38,4 +45,4 @@ bool mag_scene_saved_info_on_event(void* context, SceneManagerEvent event) {
3845
void mag_scene_saved_info_on_exit(void* context) {
3946
Mag* mag = context;
4047
widget_reset(mag->widget);
41-
}
48+
}

scenes/mag_scene_saved_menu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ void mag_scene_saved_menu_on_exit(void* context) {
6262
Mag* mag = context;
6363

6464
submenu_reset(mag->submenu);
65-
}
65+
}

0 commit comments

Comments
 (0)