passy_scene_read_success.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "../passy_i.h"
  2. #include <dolphin/dolphin.h>
  3. #define TAG "PassySceneReadCardSuccess"
  4. void passy_scene_read_success_on_enter(void* context) {
  5. Passy* passy = context;
  6. dolphin_deed(DolphinDeedNfcReadSuccess);
  7. notification_message(passy->notifications, &sequence_success);
  8. furi_string_reset(passy->text_box_store);
  9. FuriString* str = passy->text_box_store;
  10. if(passy->read_type == PassyReadDG1) {
  11. // +5 is derived epirically, but really should be from parsing the ASN.1
  12. furi_string_cat_printf(str, "%s\n", bit_buffer_get_data(passy->DG1) + 5);
  13. } else if(passy->read_type == PassyReadDG2) {
  14. furi_string_cat_printf(str, "Saved to disk");
  15. }
  16. text_box_set_font(passy->text_box, TextBoxFontText);
  17. text_box_set_text(passy->text_box, furi_string_get_cstr(passy->text_box_store));
  18. view_dispatcher_switch_to_view(passy->view_dispatcher, PassyViewTextBox);
  19. }
  20. bool passy_scene_read_success_on_event(void* context, SceneManagerEvent event) {
  21. Passy* passy = context;
  22. bool consumed = false;
  23. if(event.type == SceneManagerEventTypeCustom) {
  24. } else if(event.type == SceneManagerEventTypeBack) {
  25. scene_manager_search_and_switch_to_previous_scene(
  26. passy->scene_manager, PassySceneMainMenu);
  27. consumed = true;
  28. }
  29. return consumed;
  30. }
  31. void passy_scene_read_success_on_exit(void* context) {
  32. Passy* passy = context;
  33. // Clear view
  34. text_box_reset(passy->text_box);
  35. }