2022-05-06 16:48:39 +00:00
|
|
|
#include "../ibutton_i.h"
|
|
|
|
#include <one_wire/maxim_crc.h>
|
|
|
|
|
|
|
|
static void ibutton_scene_read_crc_error_dialog_ex_callback(DialogExResult result, void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
view_dispatcher_send_custom_event(ibutton->view_dispatcher, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_read_crc_error_on_enter(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
DialogEx* dialog_ex = ibutton->dialog_ex;
|
|
|
|
iButtonKey* key = ibutton->key;
|
|
|
|
const uint8_t* key_data = ibutton_key_get_data_p(key);
|
|
|
|
|
|
|
|
ibutton_text_store_set(
|
|
|
|
ibutton,
|
|
|
|
"%02X %02X %02X %02X %02X %02X %02X %02X\nExpected CRC: %X",
|
|
|
|
key_data[0],
|
|
|
|
key_data[1],
|
|
|
|
key_data[2],
|
|
|
|
key_data[3],
|
|
|
|
key_data[4],
|
|
|
|
key_data[5],
|
|
|
|
key_data[6],
|
|
|
|
key_data[7],
|
|
|
|
maxim_crc8(key_data, 7, MAXIM_CRC8_INIT));
|
|
|
|
|
|
|
|
dialog_ex_set_header(dialog_ex, "CRC ERROR", 64, 10, AlignCenter, AlignCenter);
|
|
|
|
dialog_ex_set_text(dialog_ex, ibutton->text_store, 64, 19, AlignCenter, AlignTop);
|
|
|
|
dialog_ex_set_left_button_text(dialog_ex, "Retry");
|
|
|
|
dialog_ex_set_right_button_text(dialog_ex, "More");
|
|
|
|
dialog_ex_set_result_callback(dialog_ex, ibutton_scene_read_crc_error_dialog_ex_callback);
|
|
|
|
dialog_ex_set_context(dialog_ex, ibutton);
|
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewDialogEx);
|
|
|
|
|
|
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageError);
|
|
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageRedOn);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ibutton_scene_read_crc_error_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
SceneManager* scene_manager = ibutton->scene_manager;
|
|
|
|
bool consumed = false;
|
|
|
|
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
if(event.type == SceneManagerEventTypeBack) {
|
|
|
|
consumed = true;
|
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
|
|
|
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
2022-05-06 16:48:39 +00:00
|
|
|
consumed = true;
|
|
|
|
if(event.event == DialogExResultRight) {
|
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneReadKeyMenu);
|
|
|
|
} else if(event.event == DialogExResultLeft) {
|
|
|
|
scene_manager_previous_scene(scene_manager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_read_crc_error_on_exit(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
DialogEx* dialog_ex = ibutton->dialog_ex;
|
|
|
|
|
|
|
|
ibutton_text_store_clear(ibutton);
|
|
|
|
|
2022-05-19 16:07:45 +00:00
|
|
|
dialog_ex_reset(dialog_ex);
|
2022-05-06 16:48:39 +00:00
|
|
|
|
|
|
|
ibutton_notification_message(ibutton, iButtonNotificationMessageRedOff);
|
|
|
|
}
|