nfc_maker.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #if __has_include(<assets_icons.h>)
  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 __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. #define MAX_NDEF_LEN ntag_sizes[NtagI2C2K]
  53. typedef enum {
  54. WifiAuthenticationOpen = 0x01,
  55. WifiAuthenticationWpa2Personal = 0x20,
  56. WifiAuthenticationWpa2Enterprise = 0x10,
  57. WifiAuthenticationWpaPersonal = 0x02,
  58. WifiAuthenticationWpaEnterprise = 0x08,
  59. WifiAuthenticationShared = 0x04,
  60. } WifiAuthentication;
  61. typedef enum {
  62. WifiEncryptionAes = 0x08,
  63. WifiEncryptionWep = 0x02,
  64. WifiEncryptionTkip = 0x04,
  65. WifiEncryptionNone = 0x01,
  66. } WifiEncryption;
  67. typedef struct {
  68. Gui* gui;
  69. SceneManager* scene_manager;
  70. ViewDispatcher* view_dispatcher;
  71. Submenu* submenu;
  72. TextInput* text_input;
  73. ByteInput* byte_input;
  74. Popup* popup;
  75. NfcDevice* nfc_device;
  76. uint8_t* ndef_buffer;
  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. } NfcMaker;
  85. typedef enum {
  86. NfcMakerViewSubmenu,
  87. NfcMakerViewTextInput,
  88. NfcMakerViewByteInput,
  89. NfcMakerViewPopup,
  90. } NfcMakerView;
  91. #ifdef FW_ORIGIN_Official
  92. #define submenu_add_lockable_item( \
  93. submenu, label, index, callback, callback_context, locked, locked_message) \
  94. if(!(locked)) submenu_add_item(submenu, label, index, callback, callback_context)
  95. #endif