3
3
#define PIN_A 0
4
4
#define PIN_B 1 // currently unused
5
5
#define CLOCK_US 250 // typically set between 200-500us
6
+ #define TEST_STR "%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?;1234567812?"
6
7
7
8
uint8_t magspoof_bit_dir = 0 ;
9
+ const char * test_str = TEST_STR ;
8
10
9
11
void mag_scene_emulate_test_dialog_callback (DialogExResult result , void * context ) {
10
12
Mag * mag = context ;
@@ -66,6 +68,8 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
66
68
furi_hal_ibutton_start_drive ();
67
69
furi_hal_ibutton_pin_low ();
68
70
71
+ // Initializing at GpioSpeedLow seems sufficient for our needs; no improvements seen by increasing speed setting
72
+
69
73
// this doesn't seem to make a difference, leaving it in
70
74
furi_hal_gpio_init (& gpio_rfid_data_in , GpioModeOutputPushPull , GpioPullNo , GpioSpeedLow );
71
75
furi_hal_gpio_write (& gpio_rfid_data_in , false);
@@ -81,8 +85,11 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
81
85
// A7 GPIO pin for debugging purposes
82
86
//furi_hal_gpio_init(&gpio_ext_pa7, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
83
87
88
+ // TODO: initialize pins on scene enter, perhaps, so as to avoid this delay each time the button is pressed?
89
+ // Also, why is such a long delay needed?
84
90
furi_delay_ms (300 );
85
91
92
+ // prevents interrupts &c. from impacting critical timings
86
93
FURI_CRITICAL_ENTER ();
87
94
88
95
const uint8_t bitlen [] = {7 , 5 , 5 };
@@ -126,6 +133,7 @@ static void mag_spoof(FuriString* track_str, uint8_t track) {
126
133
gpio_item_set_rfid_pin (PIN_A , 0 );
127
134
gpio_item_set_rfid_pin (PIN_B , 0 );
128
135
136
+ // end critical timing section
129
137
FURI_CRITICAL_EXIT ();
130
138
131
139
furi_hal_rfid_pins_reset ();
@@ -140,11 +148,11 @@ void mag_scene_emulate_test_on_enter(void* context) {
140
148
tmp_string = furi_string_alloc ();
141
149
142
150
widget_add_button_element (widget , GuiButtonTypeLeft , "Back" , mag_widget_callback , mag );
143
- widget_add_button_element (widget , GuiButtonTypeCenter , "Emulate" , mag_widget_callback , mag );
151
+ widget_add_button_element (widget , GuiButtonTypeRight , "Emulate" , mag_widget_callback , mag );
144
152
145
- furi_string_printf (tmp_string , "Emulate?" );
153
+ furi_string_printf (tmp_string , test_str );
146
154
widget_add_string_element (
147
- widget , 64 , 0 , AlignCenter , AlignTop , FontPrimary , furi_string_get_cstr (tmp_string ));
155
+ widget , 64 , 0 , AlignLeft , AlignTop , FontSecondary , furi_string_get_cstr (tmp_string ));
148
156
furi_string_reset (tmp_string );
149
157
150
158
view_dispatcher_switch_to_view (mag -> view_dispatcher , MagViewWidget );
@@ -157,15 +165,15 @@ bool mag_scene_emulate_test_on_event(void* context, SceneManagerEvent event) {
157
165
bool consumed = false;
158
166
159
167
if (event .type == SceneManagerEventTypeCustom ) {
160
- if (event .event == DialogExResultCenter ) {
168
+ if (event .event == GuiButtonTypeRight ) {
161
169
consumed = true;
162
170
163
171
// Hardcoding a test string for the time being, while we debug/improve LF RFID TX
164
172
FuriString * v = furi_string_alloc ();
165
- furi_string_set_str (
166
- v ,
167
- "%B123456781234567^LASTNAME/FIRST^YYMMSSSDDDDDDDDDDDDDDDDDDDDDDDDD?;1234567812?" );
173
+ furi_string_set_str (v , test_str );
174
+ notification_message (mag -> notifications , & sequence_blink_start_magenta );
168
175
mag_spoof (v , 0 );
176
+ notification_message (mag -> notifications , & sequence_blink_stop );
169
177
furi_string_free (v );
170
178
} else if (event .event == GuiButtonTypeLeft ) {
171
179
consumed = true;
0 commit comments