metroflip_i.h 3.9 KB

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