nfc_maker.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #pragma once
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <gui/gui.h>
  5. #include <gui/view.h>
  6. #include <gui/modules/validators.h>
  7. #include <gui/view_dispatcher.h>
  8. #include <gui/scene_manager.h>
  9. #ifdef FW_ORIGIN_Momentum
  10. #include <assets_icons.h>
  11. #else
  12. extern const Icon I_DolphinDone_80x58;
  13. extern const Icon I_WarningDolphinFlip_45x42;
  14. #endif
  15. #include <gui/modules/submenu.h>
  16. #ifdef FW_ORIGIN_Momentum
  17. #include <gui/modules/text_input.h>
  18. #else
  19. #include "dropin/text_input.h"
  20. #endif
  21. #include <gui/modules/byte_input.h>
  22. #include <gui/modules/popup.h>
  23. #include "scenes/nfc_maker_scene.h"
  24. #include <lib/flipper_format/flipper_format.h>
  25. #include <toolbox/name_generator.h>
  26. #include <bit_lib/bit_lib.h>
  27. #if defined(FW_ORIGIN_Momentum) && __has_include(<applications/main/nfc/nfc_app_i.h>)
  28. #include <applications/main/nfc/nfc_app_i.h>
  29. #else
  30. #define NFC_APP_FOLDER EXT_PATH("nfc")
  31. #define NFC_APP_EXTENSION ".nfc"
  32. #endif
  33. #include <lib/nfc/protocols/mf_ultralight/mf_ultralight.h>
  34. #include <lib/nfc/protocols/type_4_tag/type_4_tag.h>
  35. #include <lib/nfc/protocols/mf_classic/mf_classic.h>
  36. #include <lib/nfc/protocols/slix/slix.h>
  37. #include <lib/nfc/helpers/nfc_data_generator.h>
  38. #define MAC_INPUT_LEN (GAP_MAC_ADDR_SIZE)
  39. #define MAIL_INPUT_LEN (128)
  40. #define PHONE_INPUT_LEN (17)
  41. #define BIG_INPUT_LEN (248)
  42. #define SMALL_INPUT_LEN (90)
  43. #define NTAG_DATA_AREA_UNIT_SIZE (2 * MF_ULTRALIGHT_PAGE_SIZE)
  44. typedef enum {
  45. // MfUltralight
  46. CardNtag203,
  47. CardNtag213,
  48. CardNtag215,
  49. CardNtag216,
  50. CardNtagI2C1K,
  51. CardNtagI2C2K,
  52. // Type4Tag
  53. CardNtag413DNA,
  54. CardNtag424DNA,
  55. CardMfDesfire,
  56. CardType4Generic,
  57. // MfClassic
  58. CardMfClassicMini,
  59. CardMfClassic1K4b,
  60. CardMfClassic1K7b,
  61. CardMfClassic4K4b,
  62. CardMfClassic4K7b,
  63. // Slix
  64. CardSlix,
  65. CardSlixS,
  66. CardSlixL,
  67. CardSlix2,
  68. CardMAX,
  69. } Card;
  70. typedef struct {
  71. const char* name;
  72. size_t size;
  73. NfcProtocol protocol;
  74. NfcDataGeneratorType generator;
  75. } CardDef;
  76. extern const CardDef cards[CardMAX];
  77. typedef enum {
  78. WifiAuthenticationOpen = 0x01,
  79. WifiAuthenticationWpa2Personal = 0x20,
  80. WifiAuthenticationWpa2Enterprise = 0x10,
  81. WifiAuthenticationWpaPersonal = 0x02,
  82. WifiAuthenticationWpaEnterprise = 0x08,
  83. WifiAuthenticationShared = 0x04,
  84. } WifiAuthentication;
  85. typedef enum {
  86. WifiEncryptionAes = 0x08,
  87. WifiEncryptionWep = 0x02,
  88. WifiEncryptionTkip = 0x04,
  89. WifiEncryptionNone = 0x01,
  90. } WifiEncryption;
  91. typedef struct {
  92. Gui* gui;
  93. SceneManager* scene_manager;
  94. ViewDispatcher* view_dispatcher;
  95. Submenu* submenu;
  96. TextInput* text_input;
  97. ByteInput* byte_input;
  98. Popup* popup;
  99. NfcDevice* nfc_device;
  100. uint8_t* ndef_buffer;
  101. size_t ndef_size;
  102. uint8_t mac_buf[MAC_INPUT_LEN];
  103. char mail_buf[MAIL_INPUT_LEN];
  104. char phone_buf[PHONE_INPUT_LEN];
  105. char big_buf[BIG_INPUT_LEN];
  106. char small_buf1[SMALL_INPUT_LEN];
  107. char small_buf2[SMALL_INPUT_LEN];
  108. char save_buf[BIG_INPUT_LEN];
  109. uint8_t uid_buf[10];
  110. } NfcMaker;
  111. typedef enum {
  112. NfcMakerViewSubmenu,
  113. NfcMakerViewTextInput,
  114. NfcMakerViewByteInput,
  115. NfcMakerViewPopup,
  116. } NfcMakerView;
  117. #ifdef FW_ORIGIN_Official
  118. #define submenu_add_lockable_item( \
  119. submenu, label, index, callback, callback_context, locked, locked_message) \
  120. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  121. #endif