uhf_app_i.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/gui.h>
  4. #include <gui/view_dispatcher.h>
  5. #include <gui/scene_manager.h>
  6. #include <gui/canvas_i.h>
  7. #include <notification/notification_messages.h>
  8. #include <gui/modules/submenu.h>
  9. #include <gui/modules/popup.h>
  10. #include <gui/modules/loading.h>
  11. #include <gui/modules/text_input.h>
  12. #include <gui/modules/widget.h>
  13. #include <input/input.h>
  14. #include "scenes/uhf_scene.h"
  15. #include <storage/storage.h>
  16. // #include <lib/toolbox/path.h>
  17. #include <toolbox/path.h>
  18. #include <flipper_format/flipper_format.h>
  19. #include "uhf_app.h"
  20. #include "uhf_worker.h"
  21. #include <uhf_rfid_icons.h>
  22. #define UHF_FILE_HEADER \
  23. "Filetype: Flipper uhf data\n" \
  24. "Version: 1"
  25. #define UHF_TEXT_STORE_SIZE 128
  26. #define UHF_APPS_DATA_FOLDER EXT_PATH("apps_data")
  27. #define UHF_APPS_STORAGE_FOLDER \
  28. UHF_APPS_DATA_FOLDER "/" \
  29. "uhf_rfid"
  30. #define UHF_FILE_EXTENSION ".uhf"
  31. enum UHFCustomEvent {
  32. // Reserve first 100 events for button types and indexes, starting from 0
  33. UHFCustomEventReserved = 100,
  34. UHFCustomEventVerifyDone,
  35. UHFCustomEventViewExit,
  36. UHFCustomEventWorkerExit,
  37. UHFCustomEventByteInputDone,
  38. UHFCustomEventTextInputDone,
  39. };
  40. typedef enum {
  41. EventTypeTick,
  42. EventTypeKey,
  43. } EventType;
  44. struct UHFApp {
  45. UHFWorker* worker;
  46. ViewDispatcher* view_dispatcher;
  47. Gui* gui;
  48. NotificationApp* notifications;
  49. SceneManager* scene_manager;
  50. Storage* storage;
  51. char text_store[UHF_TEXT_STORE_SIZE + 1];
  52. FuriString* text_box_store;
  53. // Common Views
  54. Submenu* submenu;
  55. Popup* popup;
  56. Loading* loading;
  57. TextInput* text_input;
  58. Widget* widget;
  59. };
  60. typedef enum {
  61. UHFViewMenu,
  62. UHFViewPopup,
  63. UHFViewLoading,
  64. UHFViewTextInput,
  65. UHFViewWidget,
  66. } UHFView;
  67. UHFApp* uhf_app_alloc();
  68. void uhf_text_store_set(UHFApp* uhf, const char* text, ...);
  69. void uhf_text_store_clear(UHFApp* uhf);
  70. void uhf_blink_start(UHFApp* uhf);
  71. void uhf_blink_stop(UHFApp* uhf);
  72. void uhf_show_loading_popup(void* context, bool show);
  73. /** Check if memory is set to pattern
  74. *
  75. * @warning zero size will return false
  76. *
  77. * @param[in] data Pointer to the byte array
  78. * @param[in] pattern The pattern
  79. * @param[in] size The byte array size
  80. *
  81. * @return True if memory is set to pattern, false otherwise
  82. */
  83. bool uhf_is_memset(const uint8_t* data, const uint8_t pattern, size_t size);
  84. char* convertToHexString(const uint8_t* array, size_t length);
  85. bool uhf_save_read_data(UHFResponseData* uhf_response_data, Storage* storage, const char* filename);