metroflip_i.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/gui.h>
  4. #include <gui/view.h>
  5. #include <gui/modules/validators.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/scene_manager.h>
  8. #if __has_include(<assets_icons.h>)
  9. #include <assets_icons.h>
  10. #else
  11. extern const Icon I_RFIDDolphinReceive_97x61;
  12. #endif
  13. #include <gui/modules/submenu.h>
  14. #include <gui/modules/popup.h>
  15. #include <gui/modules/loading.h>
  16. #include <gui/modules/text_input.h>
  17. #include <gui/modules/text_box.h>
  18. #include <gui/modules/widget.h>
  19. #include <gui/modules/byte_input.h>
  20. #include <gui/modules/popup.h>
  21. #include "scenes/metroflip_scene.h"
  22. #include <lib/flipper_format/flipper_format.h>
  23. #include <toolbox/name_generator.h>
  24. #include <lib/nfc/protocols/mf_ultralight/mf_ultralight.h>
  25. #include <lib/nfc/helpers/nfc_data_generator.h>
  26. #include <furi_hal_bt.h>
  27. #include <notification/notification_messages.h>
  28. #include <lib/nfc/nfc.h>
  29. #include <nfc/nfc_poller.h>
  30. #include <nfc/nfc_scanner.h>
  31. #include <datetime.h>
  32. #include <dolphin/dolphin.h>
  33. #include <locale/locale.h>
  34. #include <flipper_application/flipper_application.h>
  35. #include <loader/firmware_api/firmware_api.h>
  36. #include "scenes/metroflip_scene.h"
  37. typedef struct {
  38. Gui* gui;
  39. SceneManager* scene_manager;
  40. ViewDispatcher* view_dispatcher;
  41. NotificationApp* notifications;
  42. Submenu* submenu;
  43. TextInput* text_input;
  44. TextBox* text_box;
  45. ByteInput* byte_input;
  46. Popup* popup;
  47. uint8_t mac_buf[GAP_MAC_ADDR_SIZE];
  48. FuriString* text_box_store;
  49. Widget* widget;
  50. Nfc* nfc;
  51. NfcPoller* poller;
  52. NfcScanner* scanner;
  53. NfcDevice* nfc_device;
  54. // card details:
  55. uint32_t balance_lari;
  56. uint8_t balance_tetri;
  57. uint32_t card_number;
  58. size_t sec_num;
  59. float value;
  60. char currency[4];
  61. char card_type[32];
  62. } Metroflip;
  63. enum MetroflipCustomEvent {
  64. // Reserve first 100 events for button types and indexes, starting from 0
  65. MetroflipCustomEventReserved = 100,
  66. MetroflipCustomEventViewExit,
  67. MetroflipCustomEventByteInputDone,
  68. MetroflipCustomEventTextInputDone,
  69. MetroflipCustomEventWorkerExit,
  70. MetroflipCustomEventPollerDetect,
  71. MetroflipCustomEventPollerSuccess,
  72. MetroflipCustomEventPollerFail,
  73. MetroflipCustomEventPollerSelectFailed,
  74. MetroflipCustomEventPollerFileNotFound,
  75. MetroflipCustomEventCardLost,
  76. MetroflipCustomEventCardDetected,
  77. MetroflipCustomEventWrongCard
  78. };
  79. typedef enum {
  80. MetroflipPollerEventTypeStart,
  81. MetroflipPollerEventTypeCardDetect,
  82. MetroflipPollerEventTypeSuccess,
  83. MetroflipPollerEventTypeFail,
  84. } MetroflipPollerEventType;
  85. typedef enum {
  86. MetroflipViewSubmenu,
  87. MetroflipViewTextInput,
  88. MetroflipViewByteInput,
  89. MetroflipViewPopup,
  90. MetroflipViewMenu,
  91. MetroflipViewLoading,
  92. MetroflipViewTextBox,
  93. MetroflipViewWidget,
  94. MetroflipViewUart,
  95. } MetroflipView;
  96. void metroflip_app_blink_start(Metroflip* metroflip);
  97. void metroflip_app_blink_stop(Metroflip* metroflip);
  98. #ifdef FW_ORIGIN_Official
  99. #define submenu_add_lockable_item( \
  100. submenu, label, index, callback, callback_context, locked, locked_message) \
  101. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  102. #endif
  103. // Calypso
  104. #define Metroflip_POLLER_MAX_BUFFER_SIZE 1024
  105. #define epoch 852073200
  106. void locale_format_datetime_cat(FuriString* out, const DateTime* dt, bool time);
  107. extern uint8_t read_file[5];
  108. extern uint8_t apdu_success[2];
  109. extern uint8_t select_app[8];
  110. void byte_to_binary(uint8_t byte, char* bits);
  111. int binary_to_decimal(const char binary[]);
  112. int bit_slice_to_dec(const char* bit_representation, int start, int end);