nfc_maker.h 3.1 KB

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