mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 13:03:13 +00:00
d511d76a1b
* Added new image DolphinSaved_113x58.png for all "saved" pages * New image DolphinDone_80x58.png added * Replaced dolphins on all scenes accroding to new UI specs * New success dolphin image added * Success scene image replaced * Changed image and text for update initial scene * Image and text adjusted for "Original restored" scene * Removed old DolphinNice_96x59.png image * New image for LFRFID scene * Removed unused image * New UI image added to assets * Replaced warning dolphin on mf_classic write initial fail scene * Removed old image * Changed image on scenes to a new one * New dolphin mafia image * Replaced dolphin mafia image to a new one * Removed DolphinMafia_115x62.png * New check symbol on completed state for detect_reader * Adjusted layout elements position * Removed second switching to popup view in order to achieve control in support callbacks In general now we show generic scene and after that in on_enter callback we can redefine it for particular protocol * CardDetected event now also triggers on_event callback * Now on AuthRequest we throw CardDetected custom event * Added callback for read_on_event * Now we show different screen while reading and unlocking * Fixed missing asstes for some scenes * Update DolphinMafia_119x62.png * Adjusted all the scenes with DolphinMafia image * Scenes with save image adjusted * Removed unnecessary assets DolphinMafia_119x62.png and DolphinSaved_113x58.png * All common dolphins moved to Dolphin folder * Moved DolphinReadingSuccess_59x63.png to Dolphin folder * Set proper led color for detect and read scenes * Added new notification sequence for semi_success results * Use new sequence for semi_success nfc reads * Different events are now throwed depending on read result * Added handling of incomplete event for ultralight cards * Replaced image for iButton scene * Updated API for f18 * Fixed issue with unlock retry sequence * Fix after review * Success notification replaced to semi success in case of incomplete mf classic reading * New text for read scene * New read result sound notification logic for mf classic cards Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: gornekich <n.gorbadey@gmail.com>
94 lines
3.6 KiB
C
94 lines
3.6 KiB
C
#include "../lfrfid_i.h"
|
|
|
|
static void lfrfid_write_callback(LFRFIDWorkerWriteResult result, void* context) {
|
|
LfRfid* app = context;
|
|
uint32_t event = 0;
|
|
|
|
if(result == LFRFIDWorkerWriteOK) {
|
|
event = LfRfidEventWriteOK;
|
|
} else if(result == LFRFIDWorkerWriteProtocolCannotBeWritten) {
|
|
event = LfRfidEventWriteProtocolCannotBeWritten;
|
|
} else if(result == LFRFIDWorkerWriteFobCannotBeWritten) {
|
|
event = LfRfidEventWriteFobCannotBeWritten;
|
|
} else if(result == LFRFIDWorkerWriteTooLongToWrite) {
|
|
event = LfRfidEventWriteTooLongToWrite;
|
|
}
|
|
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, event);
|
|
}
|
|
|
|
void lfrfid_scene_write_on_enter(void* context) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
|
|
popup_set_header(popup, "Writing", 89, 30, AlignCenter, AlignTop);
|
|
if(!furi_string_empty(app->file_name)) {
|
|
popup_set_text(popup, furi_string_get_cstr(app->file_name), 89, 43, AlignCenter, AlignTop);
|
|
} else {
|
|
popup_set_text(
|
|
popup,
|
|
protocol_dict_get_name(app->dict, app->protocol_id),
|
|
89,
|
|
43,
|
|
AlignCenter,
|
|
AlignTop);
|
|
}
|
|
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
|
|
|
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
|
protocol_dict_get_data(app->dict, app->protocol_id, app->old_key_data, size);
|
|
|
|
lfrfid_worker_start_thread(app->lfworker);
|
|
lfrfid_worker_write_start(
|
|
app->lfworker, (LFRFIDProtocol)app->protocol_id, lfrfid_write_callback, app);
|
|
notification_message(app->notifications, &sequence_blink_start_magenta);
|
|
}
|
|
|
|
bool lfrfid_scene_write_on_event(void* context, SceneManagerEvent event) {
|
|
LfRfid* app = context;
|
|
Popup* popup = app->popup;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == LfRfidEventWriteOK) {
|
|
notification_message(app->notifications, &sequence_success);
|
|
scene_manager_next_scene(app->scene_manager, LfRfidSceneWriteSuccess);
|
|
consumed = true;
|
|
} else if(event.event == LfRfidEventWriteProtocolCannotBeWritten) {
|
|
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
|
|
popup_set_header(popup, "Error", 64, 3, AlignCenter, AlignTop);
|
|
popup_set_text(popup, "This protocol\ncannot be written", 3, 17, AlignLeft, AlignTop);
|
|
notification_message(app->notifications, &sequence_blink_start_red);
|
|
consumed = true;
|
|
} else if(
|
|
(event.event == LfRfidEventWriteFobCannotBeWritten) ||
|
|
(event.event == LfRfidEventWriteTooLongToWrite)) {
|
|
popup_set_icon(popup, 83, 22, &I_WarningDolphinFlip_45x42);
|
|
popup_set_header(popup, "Still trying to write...", 64, 3, AlignCenter, AlignTop);
|
|
popup_set_text(
|
|
popup,
|
|
"Make sure this\ncard is writable\nand not\nprotected.",
|
|
3,
|
|
17,
|
|
AlignLeft,
|
|
AlignTop);
|
|
notification_message(app->notifications, &sequence_blink_start_yellow);
|
|
consumed = true;
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void lfrfid_scene_write_on_exit(void* context) {
|
|
LfRfid* app = context;
|
|
notification_message(app->notifications, &sequence_blink_stop);
|
|
popup_reset(app->popup);
|
|
lfrfid_worker_stop(app->lfworker);
|
|
lfrfid_worker_stop_thread(app->lfworker);
|
|
|
|
size_t size = protocol_dict_get_data_size(app->dict, app->protocol_id);
|
|
protocol_dict_set_data(app->dict, app->protocol_id, app->old_key_data, size);
|
|
}
|