metroflip_i.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. #include "scenes/navigo_structs.h"
  42. typedef struct {
  43. Gui* gui;
  44. SceneManager* scene_manager;
  45. ViewDispatcher* view_dispatcher;
  46. NotificationApp* notifications;
  47. Submenu* submenu;
  48. TextInput* text_input;
  49. TextBox* text_box;
  50. ByteInput* byte_input;
  51. Popup* popup;
  52. uint8_t mac_buf[GAP_MAC_ADDR_SIZE];
  53. FuriString* text_box_store;
  54. Widget* widget;
  55. Nfc* nfc;
  56. NfcPoller* poller;
  57. NfcScanner* scanner;
  58. NfcDevice* nfc_device;
  59. // card details:
  60. uint32_t balance_lari;
  61. uint8_t balance_tetri;
  62. uint32_t card_number;
  63. size_t sec_num;
  64. float value;
  65. char currency[4];
  66. char card_type[32];
  67. // Navigo specific context
  68. NavigoContext* navigo_context;
  69. } Metroflip;
  70. enum MetroflipCustomEvent {
  71. // Reserve first 100 events for button types and indexes, starting from 0
  72. MetroflipCustomEventReserved = 100,
  73. MetroflipCustomEventViewExit,
  74. MetroflipCustomEventByteInputDone,
  75. MetroflipCustomEventTextInputDone,
  76. MetroflipCustomEventWorkerExit,
  77. MetroflipCustomEventPollerDetect,
  78. MetroflipCustomEventPollerSuccess,
  79. MetroflipCustomEventPollerFail,
  80. MetroflipCustomEventPollerSelectFailed,
  81. MetroflipCustomEventPollerFileNotFound,
  82. MetroflipCustomEventCardLost,
  83. MetroflipCustomEventCardDetected,
  84. MetroflipCustomEventWrongCard
  85. };
  86. typedef enum {
  87. MetroflipPollerEventTypeStart,
  88. MetroflipPollerEventTypeCardDetect,
  89. MetroflipPollerEventTypeSuccess,
  90. MetroflipPollerEventTypeFail,
  91. } MetroflipPollerEventType;
  92. typedef enum {
  93. MetroflipViewSubmenu,
  94. MetroflipViewTextInput,
  95. MetroflipViewByteInput,
  96. MetroflipViewPopup,
  97. MetroflipViewMenu,
  98. MetroflipViewLoading,
  99. MetroflipViewTextBox,
  100. MetroflipViewWidget,
  101. MetroflipViewUart,
  102. } MetroflipView;
  103. void metroflip_app_blink_start(Metroflip* metroflip);
  104. void metroflip_app_blink_stop(Metroflip* metroflip);
  105. #ifdef FW_ORIGIN_Official
  106. #define submenu_add_lockable_item( \
  107. submenu, label, index, callback, callback_context, locked, locked_message) \
  108. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  109. #endif
  110. void metroflip_exit_widget_callback(GuiButtonType result, InputType type, void* context);
  111. ///////////////////////////////// Calypso /////////////////////////////////
  112. #define Metroflip_POLLER_MAX_BUFFER_SIZE 1024
  113. #define epoch 852073200
  114. void locale_format_datetime_cat(FuriString* out, const DateTime* dt, bool time);
  115. extern uint8_t read_file[5];
  116. extern uint8_t apdu_success[2];
  117. extern uint8_t select_app[8];
  118. void byte_to_binary(uint8_t byte, char* bits);
  119. int binary_to_decimal(const char binary[]);
  120. int bit_slice_to_dec(const char* bit_representation, int start, int end);
  121. void dec_to_bits(char dec_representation, char* bit_representation);