Skip to content

Commit bbf4ed1

Browse files
committed
upd picopass
1 parent 7c40674 commit bbf4ed1

6 files changed

+79
-3
lines changed

base_pack/picopass/picopass.c

+11
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ Picopass* picopass_alloc() {
7676
PicopassViewByteInput,
7777
byte_input_get_view(picopass->byte_input));
7878

79+
// TextBox
80+
picopass->text_box = text_box_alloc();
81+
view_dispatcher_add_view(
82+
picopass->view_dispatcher, PicopassViewTextBox, text_box_get_view(picopass->text_box));
83+
picopass->text_box_store = furi_string_alloc();
84+
7985
// Custom Widget
8086
picopass->widget = widget_alloc();
8187
view_dispatcher_add_view(
@@ -123,6 +129,11 @@ void picopass_free(Picopass* picopass) {
123129
view_dispatcher_remove_view(picopass->view_dispatcher, PicopassViewByteInput);
124130
byte_input_free(picopass->byte_input);
125131

132+
// TextBox
133+
view_dispatcher_remove_view(picopass->view_dispatcher, PicopassViewTextBox);
134+
text_box_free(picopass->text_box);
135+
furi_string_free(picopass->text_box_store);
136+
126137
// Custom Widget
127138
view_dispatcher_remove_view(picopass->view_dispatcher, PicopassViewWidget);
128139
widget_free(picopass->widget);

base_pack/picopass/picopass_i.h

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <gui/modules/loading.h>
1717
#include <gui/modules/text_input.h>
1818
#include <gui/modules/byte_input.h>
19+
#include <gui/modules/text_box.h>
1920
#include <gui/modules/widget.h>
2021

2122
#include <input/input.h>
@@ -100,6 +101,7 @@ struct Picopass {
100101
Loading* loading;
101102
TextInput* text_input;
102103
ByteInput* byte_input;
104+
TextBox* text_box;
103105
Widget* widget;
104106
DictAttack* dict_attack;
105107
Loclass* loclass;
@@ -115,6 +117,7 @@ typedef enum {
115117
PicopassViewLoading,
116118
PicopassViewTextInput,
117119
PicopassViewByteInput,
120+
PicopassViewTextBox,
118121
PicopassViewWidget,
119122
PicopassViewDictAttack,
120123
PicopassViewLoclass,

base_pack/picopass/scenes/picopass_scene_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ ADD_SCENE(picopass, emulate, Emulate)
2020
ADD_SCENE(picopass, loclass, Loclass)
2121
ADD_SCENE(picopass, key_input, KeyInput)
2222
ADD_SCENE(picopass, nr_mac_saved, NrMacSaved)
23+
ADD_SCENE(picopass, more_info, MoreInfo)

base_pack/picopass/scenes/picopass_scene_device_info.c

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ void picopass_scene_device_info_on_enter(void* context) {
7777
"Back",
7878
picopass_scene_device_info_widget_callback,
7979
picopass);
80+
widget_add_button_element(
81+
picopass->widget,
82+
GuiButtonTypeRight,
83+
"More",
84+
picopass_scene_device_info_widget_callback,
85+
picopass);
8086

8187
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget);
8288
}
@@ -88,6 +94,9 @@ bool picopass_scene_device_info_on_event(void* context, SceneManagerEvent event)
8894
if(event.type == SceneManagerEventTypeCustom) {
8995
if(event.event == GuiButtonTypeLeft) {
9096
consumed = scene_manager_previous_scene(picopass->scene_manager);
97+
} else if(event.event == GuiButtonTypeRight) {
98+
scene_manager_next_scene(picopass->scene_manager, PicopassSceneMoreInfo);
99+
consumed = true;
91100
} else if(event.event == PicopassCustomEventViewExit) {
92101
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget);
93102
consumed = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include "../picopass_i.h"
2+
#include <dolphin/dolphin.h>
3+
4+
void picopass_scene_more_info_widget_callback(GuiButtonType result, InputType type, void* context) {
5+
Picopass* picopass = context;
6+
if(type == InputTypeShort) {
7+
view_dispatcher_send_custom_event(picopass->view_dispatcher, result);
8+
}
9+
}
10+
11+
void picopass_scene_more_info_on_enter(void* context) {
12+
Picopass* picopass = context;
13+
PicopassBlock* AA1 = picopass->dev->dev_data.AA1;
14+
15+
furi_string_reset(picopass->text_box_store);
16+
17+
size_t app_limit = MIN(AA1[PICOPASS_CONFIG_BLOCK_INDEX].data[0], PICOPASS_MAX_APP_LIMIT);
18+
FuriString* str = picopass->text_box_store;
19+
20+
for(size_t i = 0; i < app_limit; i++) {
21+
for(size_t j = 0; j < PICOPASS_BLOCK_LEN; j += 2) {
22+
furi_string_cat_printf(str, "%02X%02X ", AA1[i].data[j], AA1[i].data[j + 1]);
23+
}
24+
}
25+
26+
text_box_set_font(picopass->text_box, TextBoxFontHex);
27+
text_box_set_text(picopass->text_box, furi_string_get_cstr(picopass->text_box_store));
28+
view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewTextBox);
29+
}
30+
31+
bool picopass_scene_more_info_on_event(void* context, SceneManagerEvent event) {
32+
Picopass* picopass = context;
33+
bool consumed = false;
34+
35+
if(event.type == SceneManagerEventTypeCustom) {
36+
if(event.event == GuiButtonTypeLeft) {
37+
consumed = scene_manager_previous_scene(picopass->scene_manager);
38+
}
39+
} else if(event.type == SceneManagerEventTypeBack) {
40+
consumed = scene_manager_previous_scene(picopass->scene_manager);
41+
}
42+
return consumed;
43+
}
44+
45+
void picopass_scene_more_info_on_exit(void* context) {
46+
Picopass* picopass = context;
47+
48+
// Clear views
49+
widget_reset(picopass->widget);
50+
}

base_pack/picopass/scenes/picopass_scene_read_card_success.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ void picopass_scene_read_card_success_on_enter(void* context) {
4343
AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data, 0x00, PICOPASS_BLOCK_LEN);
4444
bool empty = picopass_is_memset(
4545
AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data, 0xFF, PICOPASS_BLOCK_LEN);
46-
bool sio = 0x30 == AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[0];
46+
bool SE = 0x30 == AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[0];
47+
bool configCard = (AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[7] >> 2 & 3) == 2;
4748

4849
if(no_key) {
4950
furi_string_cat_printf(wiegand_str, "Read Failed");
@@ -68,7 +69,8 @@ void picopass_scene_read_card_success_on_enter(void* context) {
6869
"More",
6970
picopass_scene_read_card_success_widget_callback,
7071
picopass);
71-
72+
} else if(configCard) {
73+
furi_string_cat_printf(wiegand_str, "Config Card");
7274
} else if(empty) {
7375
furi_string_cat_printf(wiegand_str, "Empty");
7476
widget_add_button_element(
@@ -79,7 +81,7 @@ void picopass_scene_read_card_success_on_enter(void* context) {
7981
picopass);
8082
} else if(pacs->bitLength == 0 || pacs->bitLength == 255) {
8183
// Neither of these are valid. Indicates the block was all 0x00 or all 0xff
82-
if(sio) {
84+
if(SE) {
8385
furi_string_cat_printf(wiegand_str, "SIO");
8486
} else {
8587
furi_string_cat_printf(wiegand_str, "Invalid PACS");

0 commit comments

Comments
 (0)