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