nfc_maker.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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/mf_classic/mf_classic.h>
  35. #include <lib/nfc/protocols/slix/slix.h>
  36. #include <lib/nfc/helpers/nfc_data_generator.h>
  37. #define MAC_INPUT_LEN (GAP_MAC_ADDR_SIZE)
  38. #define MAIL_INPUT_LEN (128)
  39. #define PHONE_INPUT_LEN (17)
  40. #define BIG_INPUT_LEN (248)
  41. #define SMALL_INPUT_LEN (90)
  42. #define NTAG_DATA_AREA_UNIT_SIZE (2 * MF_ULTRALIGHT_PAGE_SIZE)
  43. typedef enum {
  44. // MfUltralight
  45. CardNtag203,
  46. CardNtag213,
  47. CardNtag215,
  48. CardNtag216,
  49. CardNtagI2C1K,
  50. CardNtagI2C2K,
  51. // MfClassic
  52. CardMfClassicMini,
  53. CardMfClassic1K4b,
  54. CardMfClassic1K7b,
  55. CardMfClassic4K4b,
  56. CardMfClassic4K7b,
  57. // Slix
  58. CardSlix,
  59. CardSlixS,
  60. CardSlixL,
  61. CardSlix2,
  62. CardMAX,
  63. } Card;
  64. typedef struct {
  65. const char* name;
  66. size_t size;
  67. NfcProtocol protocol;
  68. NfcDataGeneratorType generator;
  69. } CardDef;
  70. extern const CardDef cards[CardMAX];
  71. typedef enum {
  72. WifiAuthenticationOpen = 0x01,
  73. WifiAuthenticationWpa2Personal = 0x20,
  74. WifiAuthenticationWpa2Enterprise = 0x10,
  75. WifiAuthenticationWpaPersonal = 0x02,
  76. WifiAuthenticationWpaEnterprise = 0x08,
  77. WifiAuthenticationShared = 0x04,
  78. } WifiAuthentication;
  79. typedef enum {
  80. WifiEncryptionAes = 0x08,
  81. WifiEncryptionWep = 0x02,
  82. WifiEncryptionTkip = 0x04,
  83. WifiEncryptionNone = 0x01,
  84. } WifiEncryption;
  85. typedef struct {
  86. Gui* gui;
  87. SceneManager* scene_manager;
  88. ViewDispatcher* view_dispatcher;
  89. Submenu* submenu;
  90. TextInput* text_input;
  91. ByteInput* byte_input;
  92. Popup* popup;
  93. NfcDevice* nfc_device;
  94. uint8_t* ndef_buffer;
  95. size_t ndef_size;
  96. uint8_t mac_buf[MAC_INPUT_LEN];
  97. char mail_buf[MAIL_INPUT_LEN];
  98. char phone_buf[PHONE_INPUT_LEN];
  99. char big_buf[BIG_INPUT_LEN];
  100. char small_buf1[SMALL_INPUT_LEN];
  101. char small_buf2[SMALL_INPUT_LEN];
  102. char save_buf[BIG_INPUT_LEN];
  103. uint8_t uid_buf[10];
  104. } NfcMaker;
  105. typedef enum {
  106. NfcMakerViewSubmenu,
  107. NfcMakerViewTextInput,
  108. NfcMakerViewByteInput,
  109. NfcMakerViewPopup,
  110. } NfcMakerView;
  111. #ifdef FW_ORIGIN_Official
  112. #define submenu_add_lockable_item( \
  113. submenu, label, index, callback, callback_context, locked, locked_message) \
  114. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  115. #endif