nfc_maker.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #pragma once
  2. #include <furi.h>
  3. #include <gui/gui.h>
  4. #include <gui/view.h>
  5. #include <gui/modules/validators.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/scene_manager.h>
  8. #ifdef FW_ORIGIN_Momentum
  9. #include <assets_icons.h>
  10. #else
  11. extern const Icon I_DolphinDone_80x58;
  12. extern const Icon I_WarningDolphinFlip_45x42;
  13. #endif
  14. #include <gui/modules/submenu.h>
  15. #ifdef FW_ORIGIN_Momentum
  16. #include <gui/modules/text_input.h>
  17. #else
  18. #include "dropin/text_input.h"
  19. #endif
  20. #include <gui/modules/byte_input.h>
  21. #include <gui/modules/popup.h>
  22. #include "scenes/nfc_maker_scene.h"
  23. #include <lib/flipper_format/flipper_format.h>
  24. #include <toolbox/name_generator.h>
  25. #if defined(FW_ORIGIN_Momentum) && __has_include(<applications/main/nfc/nfc_app_i.h>)
  26. #include <applications/main/nfc/nfc_app_i.h>
  27. #else
  28. #define NFC_APP_FOLDER EXT_PATH("nfc")
  29. #define NFC_APP_EXTENSION ".nfc"
  30. #endif
  31. #include <lib/nfc/protocols/mf_ultralight/mf_ultralight.h>
  32. #include <lib/nfc/helpers/nfc_data_generator.h>
  33. #include <furi_hal_bt.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. Ntag203,
  42. Ntag213,
  43. Ntag215,
  44. Ntag216,
  45. NtagI2C1K,
  46. NtagI2C2K,
  47. NtagMAX,
  48. } Ntag;
  49. extern const NfcDataGeneratorType ntag_generators[NtagMAX];
  50. extern const char* ntag_names[NtagMAX];
  51. extern const size_t ntag_sizes[NtagMAX];
  52. typedef enum {
  53. WifiAuthenticationOpen = 0x01,
  54. WifiAuthenticationWpa2Personal = 0x20,
  55. WifiAuthenticationWpa2Enterprise = 0x10,
  56. WifiAuthenticationWpaPersonal = 0x02,
  57. WifiAuthenticationWpaEnterprise = 0x08,
  58. WifiAuthenticationShared = 0x04,
  59. } WifiAuthentication;
  60. typedef enum {
  61. WifiEncryptionAes = 0x08,
  62. WifiEncryptionWep = 0x02,
  63. WifiEncryptionTkip = 0x04,
  64. WifiEncryptionNone = 0x01,
  65. } WifiEncryption;
  66. typedef struct {
  67. Gui* gui;
  68. SceneManager* scene_manager;
  69. ViewDispatcher* view_dispatcher;
  70. Submenu* submenu;
  71. TextInput* text_input;
  72. ByteInput* byte_input;
  73. Popup* popup;
  74. NfcDevice* nfc_device;
  75. uint8_t* ndef_buffer;
  76. size_t ndef_size;
  77. uint8_t mac_buf[MAC_INPUT_LEN];
  78. char mail_buf[MAIL_INPUT_LEN];
  79. char phone_buf[PHONE_INPUT_LEN];
  80. char big_buf[BIG_INPUT_LEN];
  81. char small_buf1[SMALL_INPUT_LEN];
  82. char small_buf2[SMALL_INPUT_LEN];
  83. char save_buf[BIG_INPUT_LEN];
  84. uint8_t uid_buf[10];
  85. } NfcMaker;
  86. typedef enum {
  87. NfcMakerViewSubmenu,
  88. NfcMakerViewTextInput,
  89. NfcMakerViewByteInput,
  90. NfcMakerViewPopup,
  91. } NfcMakerView;
  92. #ifdef FW_ORIGIN_Official
  93. #define submenu_add_lockable_item( \
  94. submenu, label, index, callback, callback_context, locked, locked_message) \
  95. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  96. #endif