nfc_scene_set_atqa.c 1.8 KB

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