flip_wifi.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef FLIP_WIFI_E_H
  2. #define FLIP_WIFI_E_H
  3. #include <flipper_http/flipper_http.h>
  4. #include <easy_flipper/easy_flipper.h>
  5. #include <storage/storage.h>
  6. #define TAG "FlipWiFi"
  7. #define VERSION "1.5.1"
  8. #define VERSION_TAG TAG " " VERSION
  9. #define MAX_SCAN_NETWORKS 100
  10. #define MAX_SAVED_NETWORKS 25
  11. #define MAX_SSID_LENGTH 64
  12. // Define the submenu items for our FlipWiFi application
  13. typedef enum
  14. {
  15. FlipWiFiSubmenuIndexAbout,
  16. //
  17. FlipWiFiSubmenuIndexWiFiScan,
  18. FlipWiFiSubmenuIndexWiFiAP,
  19. FlipWiFiSubmenuIndexWiFiSaved,
  20. FlipWiFiSubmenuIndexCommands,
  21. //
  22. FlipWiFiSubmenuIndexWiFiAPStart,
  23. FlipWiFiSubmenuIndexWiFiAPSetSSID,
  24. FlipWiFiSubmenuIndexWiFiAPSetHTML,
  25. //
  26. FlipWiFiSubmenuIndexWiFiSavedAddSSID,
  27. //
  28. FlipWiFiSubmenuIndexFastCommandStart = 50,
  29. FlipWiFiSubmenuIndexWiFiScanStart = 100,
  30. FlipWiFiSubmenuIndexWiFiSavedStart = 200
  31. } FlipWiFiSubmenuIndex;
  32. // Define a single view for our FlipWiFi application
  33. typedef enum
  34. {
  35. FlipWiFiViewWiFiScan, // The view for the wifi scan screen
  36. FlipWiFiViewWiFiAP, // The view for the wifi AP screen
  37. FlipWiFiViewWiFiSaved, // The view for the wifi scan screen
  38. //
  39. FlipWiFiViewSubmenuMain, // The submenu for the main screen
  40. FlipWiFiViewSubmenuScan, // The submenu for the wifi scan screen
  41. FlipWiFiViewSubmenuAP, // The submenu for the wifi AP screen
  42. FlipWiFiViewSubmenuSaved, // The submenu for the wifi saved screen
  43. FlipWiFiViewSubmenuCommands, // The submenu for the fast commands screen
  44. FlipWiFiViewAbout, // The about screen
  45. FlipWiFiViewTextInputScan, // The text input screen for the wifi scan screen
  46. FlipWiFiViewTextInputSaved, // The text input screen for the wifi saved screen
  47. //
  48. FlipWiFiViewTextInputSavedAddSSID, // The text input screen for the wifi saved screen
  49. FlipWiFiViewTextInputSavedAddPassword, // The text input screen for the wifi saved screen
  50. //
  51. FlipWiFiViewGeneric, // generic view
  52. FlipWiFiViewSubmenu, // generic submenu
  53. FlipWiFiViewTextInput, // generic text input
  54. //
  55. FlipWiFiViewWidgetResult, // The text box that displays the random fact
  56. FlipWiFiViewLoader, // The loader screen retrieves data from the internet
  57. } FlipWiFiView;
  58. typedef enum
  59. {
  60. FlipWiFiCustomEventAP,
  61. FlipWiFiCustomEventProcess
  62. } FlipWiFiCustomEvent;
  63. // Define the WiFiPlaylist structure
  64. typedef struct
  65. {
  66. char ssids[MAX_SAVED_NETWORKS][MAX_SSID_LENGTH];
  67. char passwords[MAX_SAVED_NETWORKS][MAX_SSID_LENGTH];
  68. size_t count;
  69. } WiFiPlaylist;
  70. // Each screen will have its own view
  71. typedef struct
  72. {
  73. View *view_loader;
  74. Widget *widget_result;
  75. View *view_message;
  76. //
  77. ViewDispatcher *view_dispatcher; // Switches between our views
  78. Widget *widget_info; // The widget for the about screen
  79. View *view_wifi; // generic view for the wifi scan,ap and saved screens
  80. Submenu *submenu_main; // The submenu for the main screen
  81. Submenu *submenu_wifi; // generic submenu for the wifi scan and saved screens
  82. VariableItemList *variable_item_list_wifi; // The variable item list (settngs)
  83. VariableItem *variable_item_ssid; // The variable item
  84. UART_TextInput *uart_text_input; // The text input screen
  85. char *uart_text_input_buffer; // Buffer for the text input
  86. char *uart_text_input_temp_buffer; // Temporary buffer for the text input
  87. uint32_t uart_text_input_buffer_size; // Size of the text input buffer
  88. TextBox *textbox; // The text box
  89. FlipperHTTP *fhttp; // FlipperHTTP (UART, simplified loading, etc.)
  90. FuriTimer *timer; // timer to redraw the UART data as it comes in
  91. } FlipWiFiApp;
  92. // Function to free the resources used by FlipWiFiApp
  93. void flip_wifi_app_free(FlipWiFiApp *app);
  94. extern WiFiPlaylist *wifi_playlist; // The playlist of wifi networks
  95. extern char *ssid_list[64];
  96. extern uint32_t ssid_index;
  97. extern char current_ssid[64];
  98. extern char current_password[64];
  99. extern bool back_from_ap;
  100. #endif // FLIP_WIFI_E_H