mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-23 11:13:09 +00:00
f11df49468
* Move DolphinDeedNfcRead * Move DolphinDeedNfcReadSuccess * Move DolphinDeedNfcSave * Move DolphinDeedNfcDetectReader * Move DolphinDeedNfcEmulate * Count DolphinDeedNfcEmulate when launched from file browser * Implement most of the score accounting for NFC * Fully update Nfc icounter handling * Move DolphinDeedSubGhzFrequencyAnalyzer * Update the rest of icounter in SubGHz * Adjust SubGHz icounter handling * Adjust LFRFID icounter handling * Adjust Infrared icounter handling * Don't count renaming RFID tags as saving * Don't count renaming SubGHz signals as saving * Don't count renaming NFC tags as saving * Adjust iButton icounter handling * Minor code refactoring * Correct formatting * Account for emulating iButton keys from file manager/rpc Co-authored-by: あく <alleteam@gmail.com>
74 lines
2.8 KiB
C
74 lines
2.8 KiB
C
#include "../ibutton_i.h"
|
|
#include <dolphin/dolphin.h>
|
|
|
|
static void ibutton_scene_read_callback(void* context) {
|
|
iButton* ibutton = context;
|
|
view_dispatcher_send_custom_event(ibutton->view_dispatcher, iButtonCustomEventWorkerRead);
|
|
}
|
|
|
|
void ibutton_scene_read_on_enter(void* context) {
|
|
iButton* ibutton = context;
|
|
Popup* popup = ibutton->popup;
|
|
iButtonKey* key = ibutton->key;
|
|
iButtonWorker* worker = ibutton->key_worker;
|
|
|
|
popup_set_header(popup, "iButton", 95, 26, AlignCenter, AlignBottom);
|
|
popup_set_text(popup, "Waiting\nfor key ...", 95, 30, AlignCenter, AlignTop);
|
|
popup_set_icon(popup, 0, 5, &I_DolphinWait_61x59);
|
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewPopup);
|
|
furi_string_set(ibutton->file_path, IBUTTON_APP_FOLDER);
|
|
|
|
ibutton_worker_read_set_callback(worker, ibutton_scene_read_callback, ibutton);
|
|
ibutton_worker_read_start(worker, key);
|
|
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageReadStart);
|
|
}
|
|
|
|
bool ibutton_scene_read_on_event(void* context, SceneManagerEvent event) {
|
|
iButton* ibutton = context;
|
|
SceneManager* scene_manager = ibutton->scene_manager;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeTick) {
|
|
consumed = true;
|
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
|
consumed = true;
|
|
if(event.event == iButtonCustomEventWorkerRead) {
|
|
bool success = false;
|
|
iButtonKey* key = ibutton->key;
|
|
|
|
if(ibutton_key_get_type(key) == iButtonKeyDS1990) {
|
|
if(!ibutton_key_dallas_crc_is_valid(key)) {
|
|
scene_manager_next_scene(scene_manager, iButtonSceneReadCRCError);
|
|
} else if(!ibutton_key_dallas_is_1990_key(key)) {
|
|
scene_manager_next_scene(scene_manager, iButtonSceneReadNotKeyError);
|
|
} else {
|
|
success = true;
|
|
}
|
|
} else {
|
|
success = true;
|
|
}
|
|
|
|
if(success) {
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageSuccess);
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageGreenOn);
|
|
scene_manager_next_scene(scene_manager, iButtonSceneReadSuccess);
|
|
DOLPHIN_DEED(DolphinDeedIbuttonReadSuccess);
|
|
}
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void ibutton_scene_read_on_exit(void* context) {
|
|
iButton* ibutton = context;
|
|
Popup* popup = ibutton->popup;
|
|
ibutton_worker_stop(ibutton->key_worker);
|
|
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
|
|
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
|
|
popup_set_icon(popup, 0, 0, NULL);
|
|
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageBlinkStop);
|
|
}
|