nfc_scene_set_sak.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <nfc/scenes/nfc_scene_set_sak.h>
  2. #include <furi.h>
  3. #include "../nfc_i.h"
  4. #include <gui/view_dispatcher.h>
  5. #define SCENE_SET_SAK_CUSTOM_EVENT (0UL)
  6. void nfc_scene_set_sak_byte_input_callback(void* context) {
  7. Nfc* nfc = (Nfc*)context;
  8. view_dispatcher_send_custom_event(nfc->nfc_common.view_dispatcher, SCENE_SET_SAK_CUSTOM_EVENT);
  9. }
  10. const void nfc_scene_set_sak_on_enter(void* context) {
  11. Nfc* nfc = (Nfc*)context;
  12. // Setup view
  13. ByteInput* byte_input = nfc->byte_input;
  14. byte_input_set_header_text(byte_input, "Enter SAK in hex");
  15. byte_input_set_result_callback(
  16. byte_input, nfc_scene_set_sak_byte_input_callback, NULL, nfc, &nfc->device.data.sak, 1);
  17. view_dispatcher_switch_to_view(nfc->nfc_common.view_dispatcher, NfcViewByteInput);
  18. }
  19. const bool nfc_scene_set_sak_on_event(void* context, uint32_t event) {
  20. Nfc* nfc = (Nfc*)context;
  21. if(event == SCENE_SET_SAK_CUSTOM_EVENT) {
  22. view_dispatcher_add_scene(nfc->nfc_common.view_dispatcher, nfc->scene_set_atqa);
  23. view_dispatcher_send_navigation_event(
  24. nfc->nfc_common.view_dispatcher, ViewNavigatorEventNext);
  25. return true;
  26. }
  27. return false;
  28. }
  29. const void nfc_scene_set_sak_on_exit(void* context) {
  30. Nfc* nfc = (Nfc*)context;
  31. // Clear view
  32. byte_input_set_result_callback(nfc->byte_input, NULL, NULL, NULL, NULL, 0);
  33. byte_input_set_header_text(nfc->byte_input, "");
  34. }
  35. AppScene* nfc_scene_set_sak_alloc() {
  36. AppScene* scene = furi_alloc(sizeof(AppScene));
  37. scene->id = NfcSceneSetSak;
  38. scene->on_enter = nfc_scene_set_sak_on_enter;
  39. scene->on_event = nfc_scene_set_sak_on_event;
  40. scene->on_exit = nfc_scene_set_sak_on_exit;
  41. return scene;
  42. }
  43. void nfc_scene_set_sak_free(AppScene* scene) {
  44. free(scene);
  45. }