uhf_app_i.h 2.5 KB

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