2022-12-20 12:40:25 +00:00
|
|
|
#include "../lfrfid_i.h"
|
2023-05-29 19:15:07 +00:00
|
|
|
#define TAG "Clear T5577"
|
2022-12-20 12:40:25 +00:00
|
|
|
|
2022-12-21 04:34:54 +00:00
|
|
|
static void lfrfid_clear_t5577_password_and_config_to_EM(LfRfid* app) {
|
2022-12-20 12:40:25 +00:00
|
|
|
Popup* popup = app->popup;
|
|
|
|
char curr_buf[32] = {};
|
2024-01-12 16:36:07 +00:00
|
|
|
|
|
|
|
uint8_t default_passwords_len;
|
|
|
|
const uint32_t* default_passwords = t5577_get_default_passwords(&default_passwords_len);
|
2022-12-20 12:40:25 +00:00
|
|
|
|
|
|
|
popup_set_header(popup, "Removing\npassword", 90, 36, AlignCenter, AlignCenter);
|
|
|
|
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
2022-12-21 10:00:27 +00:00
|
|
|
popup_set_text(popup, curr_buf, 90, 56, AlignCenter, AlignCenter);
|
2022-12-21 05:11:58 +00:00
|
|
|
notification_message(app->notifications, &sequence_blink_start_magenta);
|
2022-12-21 10:00:27 +00:00
|
|
|
|
2023-05-29 19:15:07 +00:00
|
|
|
LFRFIDT5577 data = {
|
|
|
|
.block[0] = 0b00000000000101001000000001000000,
|
|
|
|
.blocks_to_write = 1,
|
|
|
|
};
|
|
|
|
|
2022-12-21 04:34:54 +00:00
|
|
|
for(uint8_t i = 0; i < default_passwords_len; i++) {
|
2022-12-20 12:40:25 +00:00
|
|
|
snprintf(curr_buf, sizeof(curr_buf), "Pass %d of %d", i, default_passwords_len);
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
2023-05-29 19:15:07 +00:00
|
|
|
|
|
|
|
t5577_write_with_pass(&data, default_passwords[i]);
|
2022-12-21 00:07:07 +00:00
|
|
|
furi_delay_ms(8);
|
2022-12-20 12:40:25 +00:00
|
|
|
}
|
2023-05-29 19:15:07 +00:00
|
|
|
|
2022-12-21 04:34:54 +00:00
|
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
2022-12-20 12:40:25 +00:00
|
|
|
popup_reset(app->popup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void lfrfid_scene_clear_t5577_on_enter(void* context) {
|
|
|
|
LfRfid* app = context;
|
2022-12-21 04:34:54 +00:00
|
|
|
Popup* popup = app->popup;
|
2022-12-21 10:00:27 +00:00
|
|
|
|
2022-12-21 04:34:54 +00:00
|
|
|
lfrfid_clear_t5577_password_and_config_to_EM(app);
|
2022-12-20 12:40:25 +00:00
|
|
|
|
2022-12-21 04:34:54 +00:00
|
|
|
notification_message(app->notifications, &sequence_success);
|
2024-01-02 11:10:19 +00:00
|
|
|
popup_set_header(popup, "Success!", 75, 10, AlignLeft, AlignTop);
|
|
|
|
popup_set_icon(popup, 0, 9, &I_DolphinSuccess_91x55);
|
2022-12-21 04:34:54 +00:00
|
|
|
popup_set_context(popup, app);
|
|
|
|
popup_set_callback(popup, lfrfid_popup_timeout_callback);
|
|
|
|
popup_set_timeout(popup, 1500);
|
|
|
|
popup_enable_timeout(popup);
|
2022-12-20 12:40:25 +00:00
|
|
|
|
2022-12-21 04:34:54 +00:00
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
|
|
|
notification_message_block(app->notifications, &sequence_set_green_255);
|
2022-12-20 12:40:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool lfrfid_scene_clear_t5577_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
LfRfid* app = context;
|
|
|
|
bool consumed = false;
|
2022-12-21 10:00:27 +00:00
|
|
|
|
2023-04-26 23:40:33 +00:00
|
|
|
if(event.type == SceneManagerEventTypeBack) {
|
|
|
|
consumed = true; // Ignore Back button presses
|
|
|
|
} else if(event.type == SceneManagerEventTypeCustom && event.event == LfRfidEventPopupClosed) {
|
|
|
|
scene_manager_search_and_switch_to_previous_scene(
|
|
|
|
app->scene_manager, LfRfidSceneExtraActions);
|
2022-12-20 12:40:25 +00:00
|
|
|
consumed = true;
|
2022-12-21 04:34:54 +00:00
|
|
|
}
|
2022-12-20 12:40:25 +00:00
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lfrfid_scene_clear_t5577_on_exit(void* context) {
|
|
|
|
LfRfid* app = context;
|
|
|
|
popup_reset(app->popup);
|
2022-12-21 04:34:54 +00:00
|
|
|
notification_message_block(app->notifications, &sequence_reset_green);
|
2022-12-20 12:40:25 +00:00
|
|
|
}
|