nfc_maker.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #if defined(FW_ORIGIN_Momentum) && __has_include(<applications/main/nfc/nfc_app_i.h>)
  27. #include <applications/main/nfc/nfc_app_i.h>
  28. #else
  29. #define NFC_APP_FOLDER EXT_PATH("nfc")
  30. #define NFC_APP_EXTENSION ".nfc"
  31. #endif
  32. #include <lib/nfc/protocols/mf_ultralight/mf_ultralight.h>
  33. #include <lib/nfc/helpers/nfc_data_generator.h>
  34. #define MAC_INPUT_LEN (GAP_MAC_ADDR_SIZE)
  35. #define MAIL_INPUT_LEN (128)
  36. #define PHONE_INPUT_LEN (17)
  37. #define BIG_INPUT_LEN (248)
  38. #define SMALL_INPUT_LEN (90)
  39. #define NTAG_DATA_AREA_UNIT_SIZE (2 * MF_ULTRALIGHT_PAGE_SIZE)
  40. typedef enum {
  41. // MfUltralight
  42. CardNtag203,
  43. CardNtag213,
  44. CardNtag215,
  45. CardNtag216,
  46. CardNtagI2C1K,
  47. CardNtagI2C2K,
  48. CardMAX,
  49. } Card;
  50. typedef struct {
  51. const char* name;
  52. size_t size;
  53. NfcProtocol protocol;
  54. NfcDataGeneratorType generator;
  55. } CardDef;
  56. extern const CardDef cards[CardMAX];
  57. typedef enum {
  58. WifiAuthenticationOpen = 0x01,
  59. WifiAuthenticationWpa2Personal = 0x20,
  60. WifiAuthenticationWpa2Enterprise = 0x10,
  61. WifiAuthenticationWpaPersonal = 0x02,
  62. WifiAuthenticationWpaEnterprise = 0x08,
  63. WifiAuthenticationShared = 0x04,
  64. } WifiAuthentication;
  65. typedef enum {
  66. WifiEncryptionAes = 0x08,
  67. WifiEncryptionWep = 0x02,
  68. WifiEncryptionTkip = 0x04,
  69. WifiEncryptionNone = 0x01,
  70. } WifiEncryption;
  71. typedef struct {
  72. Gui* gui;
  73. SceneManager* scene_manager;
  74. ViewDispatcher* view_dispatcher;
  75. Submenu* submenu;
  76. TextInput* text_input;
  77. ByteInput* byte_input;
  78. Popup* popup;
  79. NfcDevice* nfc_device;
  80. uint8_t* ndef_buffer;
  81. size_t ndef_size;
  82. uint8_t mac_buf[MAC_INPUT_LEN];
  83. char mail_buf[MAIL_INPUT_LEN];
  84. char phone_buf[PHONE_INPUT_LEN];
  85. char big_buf[BIG_INPUT_LEN];
  86. char small_buf1[SMALL_INPUT_LEN];
  87. char small_buf2[SMALL_INPUT_LEN];
  88. char save_buf[BIG_INPUT_LEN];
  89. uint8_t uid_buf[10];
  90. } NfcMaker;
  91. typedef enum {
  92. NfcMakerViewSubmenu,
  93. NfcMakerViewTextInput,
  94. NfcMakerViewByteInput,
  95. NfcMakerViewPopup,
  96. } NfcMakerView;
  97. #ifdef FW_ORIGIN_Official
  98. #define submenu_add_lockable_item( \
  99. submenu, label, index, callback, callback_context, locked, locked_message) \
  100. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  101. #endif